-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pixel simulated bad channel info packed into FED raw data #25748
Changes from all commits
4e1eb4f
fe18d5e
36089c2
06db132
3f89ec1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
#include "EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h" | ||
#include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h" | ||
|
||
#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h" | ||
|
||
#include <atomic> | ||
#include <memory> | ||
|
||
|
@@ -63,10 +65,11 @@ class SiPixelDigiToRaw final : public edm::global::EDProducer<edm::LuminosityBlo | |
|
||
private: | ||
|
||
mutable std::atomic_flag lock_{ ATOMIC_FLAG_INIT }; | ||
mutable std::atomic_flag lock_ = ATOMIC_FLAG_INIT; | ||
CMS_THREAD_GUARD(lock_) mutable edm::ESWatcher<SiPixelFedCablingMapRcd> recordWatcher; | ||
CMS_THREAD_GUARD(lock_) mutable std::shared_ptr<pr::Cache> previousCache_; | ||
const edm::EDGetTokenT<edm::DetSetVector<PixelDigi>> tPixelDigi; | ||
const edm::EDGetTokenT<PixelFEDChannelCollection> theBadPixelFEDChannelsToken; | ||
const edm::EDPutTokenT<FEDRawDataCollection> putToken_; | ||
const bool usePilotBlade = false; // I am not yet sure we need it here? | ||
const bool usePhase1; | ||
|
@@ -76,6 +79,7 @@ using namespace std; | |
|
||
SiPixelDigiToRaw::SiPixelDigiToRaw( const edm::ParameterSet& pset ) : | ||
tPixelDigi{ consumes<edm::DetSetVector<PixelDigi> >(pset.getParameter<edm::InputTag>("InputLabel")) }, | ||
theBadPixelFEDChannelsToken{ consumes<PixelFEDChannelCollection>(pset.getParameter<edm::InputTag>("InputLabel")) }, | ||
putToken_{produces<FEDRawDataCollection>()}, | ||
usePhase1{ pset.getParameter<bool> ("UsePhase1") } | ||
{ | ||
|
@@ -130,6 +134,25 @@ void SiPixelDigiToRaw::produce( edm::StreamID, edm::Event& ev, | |
|
||
LogDebug("SiPixelDigiToRaw") << cache->cablingTree_->version(); | ||
|
||
PixelDataFormatter::BadChannels badChannels; | ||
edm::Handle<PixelFEDChannelCollection> pixelFEDChannelCollectionHandle; | ||
if (ev.getByToken(theBadPixelFEDChannelsToken, pixelFEDChannelCollectionHandle)){ | ||
for (auto const& fedChannels: *pixelFEDChannelCollectionHandle) { | ||
PixelDataFormatter::DetBadChannels detBadChannels; | ||
for(const auto& fedChannel: fedChannels) { | ||
sipixelobjects::CablingPathToDetUnit path={fedChannel.fed, fedChannel.link, 1}; | ||
if (cache->cablingTree_->findItem(path)!=nullptr) { | ||
detBadChannels.push_back(fedChannel); | ||
} else { | ||
edm::LogError("SiPixelDigiToRaw") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which is the expected frequency of this Error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically should never happen if the payload based on which the digitizer kills modules lists only existing channels. This is just a safety net here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about throwing an exception then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In regular production, we would definitely want to notice if this happens (frequent warning would probably trigger attention), but not sure if we would want to enforce only one possible usage of the code by preventing any exotic used cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't know. My experience is just that log messages are usually ignored until their amount becomes excessive. One option would be to have a boolean flag to control whether to throw or not (default being to throw). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @makortel IMHO, throwing here would be a bit of an overkill, the check that Viktor does here, if failed, doesn't lead to corrupt data or to random failures. It just checks that whatever we have put in the payload for the simulation does correspond to an actual FED channel, i.e. logs an error if we are trying to kill anything which is not physically a FED channel (e.g. single-ROCs, etc.), so it's more a question of book-keeping of inefficiency source. Also there are other failsafes in the payload producers that are meant to avoid fall in this case and indeed it should never happen. |
||
<<" FED "<<fedChannel.fed<<" Link "<<fedChannel.link<<" for module "<<fedChannels.detId() | ||
<<" marked bad, but this channel does not exist in the cabling map" <<endl; | ||
} | ||
} // channels reading a module | ||
if (!detBadChannels.empty()) badChannels.insert({fedChannels.detId(), std::move(detBadChannels)}); | ||
} // loop on detId-s | ||
} | ||
|
||
//PixelDataFormatter formatter(cablingTree_.get()); | ||
PixelDataFormatter formatter(cache->cablingTree_.get(), usePhase1); | ||
|
||
|
@@ -139,7 +162,7 @@ void SiPixelDigiToRaw::produce( edm::StreamID, edm::Event& ev, | |
FEDRawDataCollection buffers; | ||
|
||
// convert data to raw | ||
formatter.formatRawData( ev.id().event(), rawdata, digis ); | ||
formatter.formatRawData( ev.id().event(), rawdata, digis, badChannels); | ||
|
||
// pack raw data into collection | ||
for (auto const* fed: cache->cablingTree_->fedList()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,7 +281,7 @@ void PixelDataFormatter::interpretRawData(bool& errorsInEvent, int fedId, const | |
// } | ||
|
||
|
||
void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis) | ||
void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis, const BadChannels & badChannels) | ||
{ | ||
std::map<int, vector<Word32> > words; | ||
|
||
|
@@ -294,27 +294,51 @@ void PixelDataFormatter::formatRawData(unsigned int lvl1_ID, RawData & fedRawDat | |
if(barrel) layer = PixelROC::bpixLayerPhase1(rawId); | ||
//if(DANEK) cout<<" layer "<<layer<<" "<<phase1<<endl; | ||
|
||
BadChannels::const_iterator detBadChannels=badChannels.find(rawId); | ||
|
||
hasDetDigis++; | ||
const DetDigis & detDigis = im->second; | ||
for (DetDigis::const_iterator it = detDigis.begin(); it != detDigis.end(); it++) { | ||
theDigiCounter++; | ||
const PixelDigi & digi = (*it); | ||
int status=0; | ||
int fedId=0; | ||
|
||
if(layer==1 && phase1) status = digi2wordPhase1Layer1( rawId, digi, words); | ||
else status = digi2word( rawId, digi, words); | ||
if(layer==1 && phase1) fedId = digi2wordPhase1Layer1( rawId, digi, words); | ||
else fedId = digi2word( rawId, digi, words); | ||
|
||
if (status) { | ||
if (fedId<0) { | ||
LogError("FormatDataException") | ||
<<" digi2word returns error #"<<status | ||
<<" digi2word returns error #"<<fedId | ||
<<" Ndigis: "<<theDigiCounter << endl | ||
<<" detector: "<<rawId<< endl | ||
<< print(digi) <<endl; | ||
} // if (status) | ||
} else if (detBadChannels!=badChannels.end()) { | ||
auto badChannel=std::find_if(detBadChannels->second.begin(), | ||
detBadChannels->second.end(), | ||
[&] (const PixelFEDChannel& ch) { | ||
return (int(ch.fed)==fedId && ch.link==linkId(words[fedId].back())); | ||
}); | ||
if (badChannel!=detBadChannels->second.end()) { | ||
LogError("FormatDataException") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which is the expected frequency of this Error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, just a safety net, should never be needed. It just checks that the digitizer consistently killed pixels in channels that it marked bad, or that the digitizer uses the same cabling map as the DigiToRaw module that called the formatRawData. |
||
<<" while marked bad, found digi for FED "<<fedId<<" Link "<<linkId(words[fedId].back()) | ||
<<" on module "<<rawId<< endl | ||
<< print(digi) <<endl; | ||
} | ||
} // if (fedId) | ||
} // for (DetDigis | ||
} // for (Digis | ||
LogTrace(" allDetDigis/hasDetDigis : ") << allDetDigis<<"/"<<hasDetDigis; | ||
|
||
// fill FED error 25 words | ||
for(const auto& detBadChannels: badChannels) { | ||
for(const auto& badChannel: detBadChannels.second) { | ||
unsigned int FEDError25=25; | ||
Word32 word = (badChannel.link << LINK_shift) | (FEDError25 << ROC_shift); | ||
words[badChannel.fed].push_back(word); | ||
theWordCounter++; | ||
} | ||
} | ||
|
||
typedef std::map<int, vector<Word32> >::const_iterator RI; | ||
for (RI feddata = words.begin(); feddata != words.end(); feddata++) { | ||
int fedId = feddata->first; | ||
|
@@ -382,7 +406,7 @@ int PixelDataFormatter::digi2word( cms_uint32_t detId, const PixelDigi& digi, | |
words[fedId].push_back(word); | ||
theWordCounter++; | ||
|
||
return 0; | ||
return fedId; | ||
} | ||
int PixelDataFormatter::digi2wordPhase1Layer1( cms_uint32_t detId, const PixelDigi& digi, | ||
std::map<int, vector<Word32> > & words) const | ||
|
@@ -412,7 +436,7 @@ int PixelDataFormatter::digi2wordPhase1Layer1( cms_uint32_t detId, const PixelDi | |
words[fedId].push_back(word); | ||
theWordCounter++; | ||
|
||
return 0; | ||
return fedId; | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this "if" is not satisfied? Shouldn't it throw, or give some error at least?
if so,
badChannels
would remain uninitialized: wouldn't it give troubles toformatter.formatRawData
below, as such?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the bad component simulation is turned OFF in the digitizer, currently the default setting, the digitizer does not produce any FEDChannelCollection output. Then the if is not satisfied, and badChannels remains an empty map. In this case, no FED25 error will be generated in the RAW output.