22 : params_(params),firstCallEB_(
true),firstCallEE_(
true),iEvent_(1)
48 edm::LogWarning(
"EcalSelectiveReadout") <<
"Parameter configFromCondDB of EcalSelectiveReadout module not found. " 49 "Selective readout configuration will be read from python file.";
69 useFullReadout_ = params.
getParameter<
bool>(
"UseFullReadout");
119 unique_ptr<EBDigiCollection> selectedEBDigis;
120 unique_ptr<EEDigiCollection> selectedEEDigis;
121 unique_ptr<EBSrFlagCollection> ebSrFlags;
122 unique_ptr<EESrFlagCollection> eeSrFlags;
147 suppressor_->run(eventSetup, *trigPrims, *ebDigis, *eeDigis,
148 selectedEBDigis.get(), selectedEEDigis.get(),
149 ebSrFlags.get(), eeSrFlags.get());
158 suppressor_->getEcalSelectiveReadout()->printHeader(srfFile);
160 srfFile <<
"# Event " <<
iEvent_ <<
"\n";
161 suppressor_->getEcalSelectiveReadout()->print(srfFile);
164 ofstream afFile(
"AF.txt", (iEvent_==1?
ios::trunc:ios::app));
166 iEvent_==1?
true:
false);
188 event.getByToken(
EB_token, hEBDigis);
203 event.getByToken(
EE_token, hEEDigis);
271 const char tccFlagMarker[] = {
'x',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
278 os <<
"# TCC flag map\n#\n" 279 "# +-->Phi " << tccFlagMarker[0+1] <<
": 000 (low interest)\n" 280 "# | " << tccFlagMarker[1+1] <<
": 001 (mid interest)\n" 281 "# | " << tccFlagMarker[2+1] <<
": 010 (not valid)\n" 282 "# V Eta " << tccFlagMarker[3+1] <<
": 011 (high interest)\n" 283 "# " << tccFlagMarker[4+1] <<
": 1xx forced readout (Hw error)\n" 287 vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
289 it != tp.
end(); ++it){
291 if(trigPrim.
size()>0){
292 int iEta = trigPrim.
id().
ieta();
293 int iEta0 = iEta<0?iEta+nEta/2:iEta+nEta/2-1;
294 int iPhi0 = trigPrim.
id().
iphi() - 1;
295 ttf[iEta0][iPhi0] = trigPrim.
ttFlag();
298 for(
int iEta=0; iEta<
nEta; ++iEta){
299 for(
int iPhi=0; iPhi<
nPhi; ++iPhi){
300 os << tccFlagMarker[ttf[iEta][iPhi]+1];
310 static std::atomic<bool> warnWeightCnt{
true};
311 bool expected =
true;
312 if((
int)weights.size() > nFIRTaps && warnWeightCnt.compare_exchange_strong(expected,
false,std::memory_order_acq_rel)){
313 edm::LogWarning(
"Configuration") <<
"The list of DCC zero suppression FIR " 314 "weights given in parameter dccNormalizedWeights is longer " 315 "than the expected depth of the FIR filter :(" << nFIRTaps <<
"). " 316 "The last weights will be discarded.";
319 if(weights.size()>0){
321 double maxWeight = weights[iMaxWeight];
323 for(
unsigned i=0;
i<weights.size(); ++
i){
324 if(weights[
i]>maxWeight){
326 maxWeight = weights[iMaxWeight];
338 if(rc && maxWeightBin!=binOfMax){
340 <<
"The maximum weight of DCC zero suppression FIR filter is not " 341 "applied to the expected maximum sample(" << binOfMax
342 << (binOfMax==1?
"st":(binOfMax==2?
"nd":(binOfMax==3?
"rd":
"th")))
343 <<
" time sample). This may indicate faulty 'dccNormalizedWeights' " 344 "or 'ecalDccZs1sSample' parameters.";
352 int& binOfMax)
const{
357 string bofm(
"binOfMaximum");
358 if(
find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm)
359 != ebDigiParamList.end()){
374 const char srpFlagMarker[] = {
'.',
'z',
'Z',
'F',
'4',
'5',
'6',
'7'};
378 const char*
date = ctime(&t);
379 os <<
"#SRP flag map\n#\n" 380 "# Generatied on: " << date <<
"\n#\n" 381 "# +-->Phi/Y " << srpFlagMarker[0] <<
": suppressed\n" 382 "# | " << srpFlagMarker[1] <<
": ZS 1\n" 383 "# | " << srpFlagMarker[2] <<
": ZS 2\n" 384 "# V Eta/X " << srpFlagMarker[3] <<
": full readout\n" 419 os <<
"# Event " << iEvent <<
"\n";
427 for(
size_t i=0;
i <
sizeof(eeSrf)/
sizeof(
int); ((
int*)eeSrf)[
i++] = -1){};
429 it != eeSrFlags.
end(); ++it){
431 int iZ0 = flag.
id().
zside()>0?1:0;
432 int iX0 = flag.
id().
ix()-1;
433 int iY0 = flag.
id().
iy()-1;
434 assert(iZ0>=0 && iZ0<nEndcaps);
435 assert(iX0>=0 && iX0<nScX);
436 assert(iY0>=0 && iY0<nScY);
437 eeSrf[iZ0][iX0][iY0] = flag.
value();
439 const int nEbTtEta = 34;
440 const int nEeTtEta = 11;
441 const int nTtEta = nEeTtEta*2+nEbTtEta;
442 const int nTtPhi = 72;
443 int ebSrf[nEbTtEta][nTtPhi];
444 for(
size_t i=0;
i<
sizeof(ebSrf)/
sizeof(
int); ((
int*)ebSrf)[
i++] = -1){};
446 it != ebSrFlags.
end(); ++it){
449 int iEta = flag.
id().
ieta();
450 int iEta0 = iEta + nTtEta/2 - (iEta>=0?1:0);
451 int iEbEta0 = iEta0 - nEeTtEta;
452 int iPhi0 = flag.
id().
iphi() - 1;
453 assert(iEbEta0>=0 && iEbEta0<nEbTtEta);
454 assert(iPhi0>=0 && iPhi0<nTtPhi);
462 ebSrf[iEbEta0][iPhi0] = flag.
value();
469 for(
int iX0=0; iX0<nScX; ++iX0){
470 for(
int iY0=0; iY0<nScY; ++iY0){
471 int srFlag = eeSrf[0][iX0][iY0];
473 && srFlag<(
int)(
sizeof(srpFlagMarker)/
sizeof(srpFlagMarker[0])));
474 os << (srFlag==-1?
' ':srpFlagMarker[srFlag]);
483 for(
int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0){
484 int srFlag = ebSrf[iEta0][iPhi0];
486 && srFlag<(
int)(
sizeof(srpFlagMarker)/
sizeof(srpFlagMarker[0])));
487 os << (srFlag==-1?
'?':srpFlagMarker[srFlag]);
493 for(
int iX0=0; iX0<nScX; ++iX0){
494 for(
int iY0=0; iY0<nScY; ++iY0){
495 int srFlag = eeSrf[1][iX0][iY0];
497 && srFlag<(
int)(
sizeof(srpFlagMarker)/
sizeof(srpFlagMarker[0])));
498 os << (srFlag==-1?
' ':srpFlagMarker[srFlag]);
509 throw cms::Exception(
"Configuration") <<
"Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. " 524 throw cms::Exception(
"Configuration") <<
"Inconsistency between number of weigth sets (" 526 <<
"number of ecalDccZs1Sample values ("
T getParameter(std::string const &) const
const CaloGeometry * theGeometry
T getUntrackedParameter(std::string const &, T const &) const
std::string trigPrimProducer_
std::string eedigiCollection_
std::string ebSRPdigiCollection_
const EBDigiCollection * getEBDigis(edm::Event &event)
void checkTriggerMap(const edm::EventSetup &eventSetup)
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
void checkGeometry(const edm::EventSetup &eventSetup)
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
std::string eeSrFlagCollection_
std::vector< std::vector< float > > dccNormalizedWeights_
const char tccFlagMarker[]
bool getBinOfMax(const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
const EcalSRSettings * settings_
void printTTFlags(const EcalTrigPrimDigiCollection &tp, std::ostream &os) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
int ieta() const
get the tower ieta
edm::EDGetTokenT< EBDigiCollection > EB_token
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup)
edm::ParameterSet params_
void checkElecMap(const edm::EventSetup &eventSetup)
edm::SortedCollection< EBSrFlag > EBSrFlagCollection
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
edm::SortedCollection< EESrFlag > EESrFlagCollection
std::vector< int > ecalDccZs1stSample_
const EEDigiCollection * getEEDigis(edm::Event &event)
std::string trigPrimCollection_
const EcalElectronicsMapping * theElecMap
std::vector< std::string > getParameterNames() const
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
static int getFIRTapCount()
const_iterator end() const
virtual ~EcalSelectiveReadoutProducer()
int iphi() const
get the tower iphi
static const int nEndcaps
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
const EcalTrigTowerDetId & id() const
std::unique_ptr< EcalSRSettings > settingsFromFile_
T const * product() const
const EcalScDetId & id() const
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
const EcalTrigTowerDetId & id() const
std::string digiProducer_
edm::EDGetTokenT< EEDigiCollection > EE_token
std::string ebSrFlagCollection_
static void printSrFlags(std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)
EcalSelectiveReadoutProducer(const edm::ParameterSet ¶ms)
Provenance getProvenance(BranchID const &theID) const
static void checkValidity(const EcalSRSettings &settings)
int ttFlag() const
get the Trigger tower Flag of interesting sample
T const * product() const
ParameterSet const & parameterSet(Provenance const &provenance)
std::string eeSRPdigiCollection_
const_iterator begin() const
const char srpFlagMarker[]
std::string ebdigiCollection_