20 : suppressor_(
params, consumesCollector()), firstCallEB_(
true), firstCallEE_(
true), iEvent_(1) {
40 if (
params.getParameter<
bool>(
"configFromCondDB")) {
45 edm::LogWarning(
"EcalSelectiveReadout") <<
"Parameter configFromCondDB of EcalSelectiveReadout module not found. " 46 "Selective readout configuration will be read from python file.";
79 hSr_token_ = esConsumes<EcalSRSettings, EcalSRSettingsRcd>();
81 geom_token_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
82 eTTmap_token_ = esConsumes<EcalTrigTowerConstituentsMap, IdealGeometryRecord>();
110 unique_ptr<EBDigiCollection> selectedEBDigis;
111 unique_ptr<EEDigiCollection> selectedEEDigis;
112 unique_ptr<EBSrFlagCollection> ebSrFlags;
113 unique_ptr<EESrFlagCollection> eeSrFlags;
116 selectedEBDigis = std::make_unique<EBDigiCollection>();
117 selectedEEDigis = std::make_unique<EEDigiCollection>();
121 ebSrFlags = std::make_unique<EBSrFlagCollection>();
122 eeSrFlags = std::make_unique<EESrFlagCollection>();
142 selectedEBDigis.get(),
143 selectedEEDigis.get(),
155 srfFile <<
"# Event " <<
iEvent_ <<
"\n";
180 event.getByToken(
EB_token, hEBDigis);
193 event.getByToken(
EE_token, hEEDigis);
247 const char tccFlagMarker[] = {
'x',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
254 os <<
"# TCC flag map\n#\n" 257 <<
": 000 (low interest)\n" 260 <<
": 001 (mid interest)\n" 263 <<
": 010 (not valid)\n" 266 <<
": 011 (high interest)\n" 269 <<
": 1xx forced readout (Hw error)\n" 273 vector<vector<int> > ttf(
nEta, vector<int>(
nPhi, -1));
276 if (trigPrim.
size() > 0) {
279 int iPhi0 = trigPrim.
id().
iphi() - 1;
280 ttf[iEta0][iPhi0] = trigPrim.
ttFlag();
284 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
295 static std::atomic<bool> warnWeightCnt{
true};
296 bool expected =
true;
297 if ((
int)
weights.size() > nFIRTaps &&
298 warnWeightCnt.compare_exchange_strong(expected,
false, std::memory_order_acq_rel)) {
299 edm::LogWarning(
"Configuration") <<
"The list of DCC zero suppression FIR " 300 "weights given in parameter dccNormalizedWeights is longer " 301 "than the expected depth of the FIR filter :(" 304 "The last weights will be discarded.";
309 double maxWeight =
weights[iMaxWeight];
311 for (
unsigned i = 0;
i <
weights.size(); ++
i) {
314 maxWeight =
weights[iMaxWeight];
326 if (rc && maxWeightBin != binOfMax) {
327 edm::LogWarning(
"Configuration") <<
"The maximum weight of DCC zero suppression FIR filter is not " 328 "applied to the expected maximum sample(" 330 << (binOfMax == 1 ?
"st" 331 : (binOfMax == 2 ?
"nd" : (binOfMax == 3 ?
"rd" :
"th")))
332 <<
" time sample). This may indicate faulty 'dccNormalizedWeights' " 333 "or 'ecalDccZs1sSample' parameters.";
340 int& binOfMax)
const {
344 vector<string> ebDigiParamList =
result.getParameterNames();
345 string bofm(
"binOfMaximum");
346 if (
find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) != ebDigiParamList.end()) {
347 binOfMax =
result.getParameter<
int>(
"binOfMaximum");
360 const char srpFlagMarker[] = {
'.',
'z',
'Z',
'F',
'4',
'5',
'6',
'7'};
364 const char* date = ctime(&
t);
365 os <<
"#SRP flag map\n#\n" 380 <<
": full readout\n" 415 os <<
"# Event " <<
iEvent <<
"\n";
423 for (
size_t i = 0;
i <
sizeof(eeSrf) /
sizeof(
int); ((
int*)eeSrf)[
i++] = -1) {
427 int iZ0 =
flag.id().zside() > 0 ? 1 : 0;
428 int iX0 =
flag.id().ix() - 1;
429 int iY0 =
flag.id().iy() - 1;
431 assert(iX0 >= 0 && iX0 < nScX);
432 assert(iY0 >= 0 && iY0 < nScY);
433 eeSrf[iZ0][iX0][iY0] =
flag.value();
435 const int nEbTtEta = 34;
436 const int nEeTtEta = 11;
437 const int nTtEta = nEeTtEta * 2 + nEbTtEta;
438 const int nTtPhi = 72;
439 int ebSrf[nEbTtEta][nTtPhi];
440 for (
size_t i = 0;
i <
sizeof(ebSrf) /
sizeof(
int); ((
int*)ebSrf)[
i++] = -1) {
445 int iEta0 =
iEta + nTtEta / 2 - (
iEta >= 0 ? 1 : 0);
446 int iEbEta0 = iEta0 - nEeTtEta;
447 int iPhi0 =
flag.id().iphi() - 1;
448 assert(iEbEta0 >= 0 && iEbEta0 < nEbTtEta);
449 assert(iPhi0 >= 0 && iPhi0 < nTtPhi);
456 ebSrf[iEbEta0][iPhi0] =
flag.value();
462 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
463 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
464 int srFlag = eeSrf[0][iX0][iY0];
472 for (
int iEta0 = 0; iEta0 < nEbTtEta; ++iEta0) {
473 for (
int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0) {
474 int srFlag = ebSrf[iEta0][iPhi0];
482 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
483 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
484 int srFlag = eeSrf[1][iX0][iY0];
498 <<
"Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. " 499 "while the configuration contains " 515 <<
"Inconsistency between number of weigth sets (" << settings.
dccNormalizedWeights_.size() <<
") and "
void setGeometry(const CaloGeometry *caloGeometry)
const CaloGeometry * theGeometry
std::string trigPrimProducer_
std::string eedigiCollection_
void setSettings(const EcalSRSettings *settings)
edm::ESGetToken< EcalSRSettings, EcalSRSettingsRcd > hSr_token_
void printHeader(std::ostream &os) const
print out header for the map: see print(std::ostream&)
std::string ebSRPdigiCollection_
int ieta() const
get the tower ieta
const EBDigiCollection * getEBDigis(edm::Event &event)
void checkTriggerMap(const edm::EventSetup &eventSetup)
EcalSelectiveReadout * getEcalSelectiveReadout()
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmap_token_
void checkGeometry(const edm::EventSetup &eventSetup)
const EcalTrigTowerDetId & id() const
T const * product() const
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
std::vector< T >::const_iterator const_iterator
std::string eeSrFlagCollection_
std::vector< std::vector< float > > dccNormalizedWeights_
const char tccFlagMarker[]
const EcalSRSettings * settings_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
bool suppressorSettingsSet_
edm::EDGetTokenT< EBDigiCollection > EB_token
void setTriggerMap(const EcalTrigTowerConstituentsMap *map)
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > eElecmap_token_
void checkElecMap(const edm::EventSetup &eventSetup)
void run(const edm::EventSetup &eventSetup, const EcalTrigPrimDigiCollection &trigPrims, EBDigiCollection &barrelDigis, EEDigiCollection &endcapDigis)
T const * product() const
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
std::vector< int > ecalDccZs1stSample_
const EEDigiCollection * getEEDigis(edm::Event &event)
std::string trigPrimCollection_
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
const EcalElectronicsMapping * theElecMap
const_iterator begin() const
bool getBinOfMax(const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
static int getFIRTapCount()
const_iterator end() const
static const int nEndcaps
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
std::unique_ptr< EcalSRSettings > settingsFromFile_
void printTTFlags(const EcalTrigPrimDigiCollection &tp, std::ostream &os) const
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
void print(std::ostream &os) const
print out the map
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
std::string digiProducer_
edm::EDGetTokenT< EEDigiCollection > EE_token
int ttFlag() const
get the Trigger tower Flag of interesting sample
std::string ebSrFlagCollection_
static void printSrFlags(std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)
~EcalSelectiveReadoutProducer() override
void setElecMap(const EcalElectronicsMapping *map)
EcalSelectiveReadoutProducer(const edm::ParameterSet ¶ms)
Log< level::Warning, false > LogWarning
int iphi() const
get the tower iphi
void printTTFlags(std::ostream &os, int iEvent=-1, bool withHeader=true) const
static void checkValidity(const EcalSRSettings &settings)
EcalSelectiveReadoutSuppressor suppressor_
ProcessHistory const & processHistory() const override
std::string eeSRPdigiCollection_
StableProvenance const & getStableProvenance(BranchID const &theID) const
const char srpFlagMarker[]
std::string ebdigiCollection_