20 : suppressor_(params, consumesCollector()), firstCallEB_(
true), firstCallEE_(
true), iEvent_(1) {
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>();
130 suppressorSettingsSet_ =
true;
142 selectedEBDigis.get(),
143 selectedEEDigis.get(),
155 srfFile <<
"# Event " <<
iEvent_ <<
"\n";
159 ofstream afFile(
"AF.txt", (iEvent_ == 1 ?
ios::trunc : ios::app));
160 printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent_, iEvent_ == 1 ?
true :
false);
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"
256 << tccFlagMarker[0 + 1]
257 <<
": 000 (low interest)\n"
259 << tccFlagMarker[1 + 1]
260 <<
": 001 (mid interest)\n"
262 << tccFlagMarker[2 + 1]
263 <<
": 010 (not valid)\n"
265 << tccFlagMarker[3 + 1]
266 <<
": 011 (high interest)\n"
268 << tccFlagMarker[4 + 1]
269 <<
": 1xx forced readout (Hw error)\n"
273 vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
276 if (trigPrim.
size() > 0) {
277 int iEta = trigPrim.
id().
ieta();
278 int iEta0 = iEta < 0 ? iEta + nEta / 2 : iEta + nEta / 2 - 1;
279 int iPhi0 = trigPrim.
id().
iphi() - 1;
280 ttf[iEta0][iPhi0] = trigPrim.
ttFlag();
283 for (
int iEta = 0; iEta <
nEta; ++iEta) {
284 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
285 os << tccFlagMarker[ttf[iEta][iPhi] + 1];
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.";
307 if (!weights.empty()) {
309 double maxWeight = weights[iMaxWeight];
311 for (
unsigned i = 0;
i < weights.size(); ++
i) {
312 if (weights[
i] > maxWeight) {
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 {
345 string bofm(
"binOfMaximum");
346 if (
find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) != ebDigiParamList.end()) {
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;
430 assert(iZ0 >= 0 && iZ0 < nEndcaps);
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) {
444 int iEta = flag.
id().
ieta();
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];
465 assert(srFlag >= -1 && srFlag < (
int)(
sizeof(srpFlagMarker) /
sizeof(srpFlagMarker[0])));
466 os << (srFlag == -1 ?
' ' : srpFlagMarker[srFlag]);
472 for (
int iEta0 = 0; iEta0 < nEbTtEta; ++iEta0) {
473 for (
int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0) {
474 int srFlag = ebSrf[iEta0][iPhi0];
475 assert(srFlag >= -1 && srFlag < (
int)(
sizeof(srpFlagMarker) /
sizeof(srpFlagMarker[0])));
476 os << (srFlag == -1 ?
'?' : srpFlagMarker[srFlag]);
482 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
483 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
484 int srFlag = eeSrf[1][iX0][iY0];
485 assert(srFlag >= -1 && srFlag < (
int)(
sizeof(srpFlagMarker) /
sizeof(srpFlagMarker[0])));
486 os << (srFlag == -1 ?
' ' : srpFlagMarker[srFlag]);
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
T getUntrackedParameter(std::string const &, T const &) const
std::string trigPrimProducer_
std::string eedigiCollection_
void setSettings(const EcalSRSettings *settings)
edm::ESGetToken< EcalSRSettings, EcalSRSettingsRcd > hSr_token_
std::string ebSRPdigiCollection_
const EBDigiCollection * getEBDigis(edm::Event &event)
void checkTriggerMap(const edm::EventSetup &eventSetup)
EcalSelectiveReadout * getEcalSelectiveReadout()
void printTTFlags(std::ostream &os, int iEvent=-1, bool withHeader=true) const
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmap_token_
void checkGeometry(const edm::EventSetup &eventSetup)
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[]
bool getBinOfMax(const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
void printHeader(std::ostream &os) const
print out header for the map: see print(std::ostream&)
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)
const EcalTrigTowerDetId & id() const override
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geom_token_
int ieta() const
get the tower ieta
bool suppressorSettingsSet_
edm::EDGetTokenT< EBDigiCollection > EB_token
const EcalScDetId & id() const override
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)
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
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
int iphi() const
get the tower iphi
ProcessHistory const & processHistory() const override
static const int nEndcaps
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
const EcalTrigTowerDetId & id() const
std::unique_ptr< EcalSRSettings > settingsFromFile_
T const * product() const
void print(std::ostream &os) const
print out the map
T const * product() const
T getParameter(std::string const &) const
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
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() override
void setElecMap(const EcalElectronicsMapping *map)
EcalSelectiveReadoutProducer(const edm::ParameterSet ¶ms)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
StableProvenance const & getStableProvenance(BranchID const &theID) const
static void checkValidity(const EcalSRSettings &settings)
int ttFlag() const
get the Trigger tower Flag of interesting sample
EcalSelectiveReadoutSuppressor suppressor_
std::string eeSRPdigiCollection_
const_iterator begin() const
const char srpFlagMarker[]
std::string ebdigiCollection_