67 static void printSrFlags(std::ostream& os,
71 bool withHeader =
true);
75 static std::unique_ptr<esrp::Cache> initializeGlobalCache(
const edm::ParameterSet&);
134 bool suppressorSettingsSet_ =
false;
192 return std::make_unique<esrp::Cache>();
196 : suppressor_(
params, consumesCollector()), firstCallEB_(
true), firstCallEE_(
true) {
245 hSr_token_ = esConsumes<EcalSRSettings, EcalSRSettingsRcd>();
247 geom_token_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
248 eTTmap_token_ = esConsumes<EcalTrigTowerConstituentsMap, IdealGeometryRecord>();
249 eElecmap_token_ = esConsumes<EcalElectronicsMapping, EcalMappingRcd>();
256 ps.
add<
string>(
"digiProducer");
263 ps.
add<
string>(
"trigPrimProducer");
264 ps.
add<
string>(
"trigPrimCollection");
265 ps.
add<
bool>(
"trigPrimBypass");
266 ps.
add<
int>(
"trigPrimBypassMode");
270 ps.
add<
bool>(
"configFromCondDB",
false);
271 ps.
add<
bool>(
"UseFullReadout");
274 ps.
add<
int>(
"defaultTtf");
275 ps.
add<
bool>(
"trigPrimBypassWithPeakFinder");
276 ps.
add<
double>(
"trigPrimBypassLTH");
277 ps.
add<
double>(
"trigPrimBypassHTH");
285 ps.
addOptional<std::vector<double>>(
"dccNormalizedWeights");
287 ps.
addOptional<
double>(
"srpBarrelLowInterestChannelZS");
288 ps.
addOptional<
double>(
"srpEndcapLowInterestChannelZS");
289 ps.
addOptional<
double>(
"srpBarrelHighInterestChannelZS");
290 ps.
addOptional<
double>(
"srpEndcapHighInterestChannelZS");
318 unique_ptr<EBDigiCollection> selectedEBDigis;
319 unique_ptr<EEDigiCollection> selectedEEDigis;
320 unique_ptr<EBSrFlagCollection> ebSrFlags;
321 unique_ptr<EESrFlagCollection> eeSrFlags;
324 selectedEBDigis = std::make_unique<EBDigiCollection>();
325 selectedEEDigis = std::make_unique<EEDigiCollection>();
329 ebSrFlags = std::make_unique<EBSrFlagCollection>();
330 eeSrFlags = std::make_unique<EESrFlagCollection>();
350 selectedEBDigis.get(),
351 selectedEEDigis.get(),
356 auto*
cache = globalCache();
357 std::lock_guard<std::mutex> guard(
cache->mutex_);
358 auto iEvent_ =
cache->iEvent_;
360 ofstream ttfFile(
"TTF.txt", (iEvent_ == 1 ?
ios::trunc : ios::app));
363 ofstream srfFile(
"SRF.txt", (iEvent_ == 1 ?
ios::trunc : ios::app));
367 srfFile <<
"# Event " << iEvent_ <<
"\n";
371 ofstream afFile(
"AF.txt", (iEvent_ == 1 ?
ios::trunc : ios::app));
372 printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent_, iEvent_ == 1 ?
true :
false);
395 event.getByToken(
EB_token, hEBDigis);
408 event.getByToken(
EE_token, hEEDigis);
462 const char tccFlagMarker[] = {
'x',
'.',
'S',
'?',
'C',
'E',
'E',
'E',
'E'};
469 os <<
"# TCC flag map\n#\n" 472 <<
": 000 (low interest)\n" 475 <<
": 001 (mid interest)\n" 478 <<
": 010 (not valid)\n" 481 <<
": 011 (high interest)\n" 484 <<
": 1xx forced readout (Hw error)\n" 488 vector<vector<int>> ttf(
nEta, vector<int>(
nPhi, -1));
491 if (trigPrim.
size() > 0) {
494 int iPhi0 = trigPrim.
id().
iphi() - 1;
495 ttf[iEta0][iPhi0] = trigPrim.
ttFlag();
499 for (
int iPhi = 0; iPhi <
nPhi; ++iPhi) {
510 static std::atomic<bool> warnWeightCnt{
true};
511 bool expected =
true;
512 if ((
int)
weights.size() > nFIRTaps &&
513 warnWeightCnt.compare_exchange_strong(expected,
false, std::memory_order_acq_rel)) {
514 edm::LogWarning(
"Configuration") <<
"The list of DCC zero suppression FIR " 515 "weights given in parameter dccNormalizedWeights is longer " 516 "than the expected depth of the FIR filter :(" 519 "The last weights will be discarded.";
524 double maxWeight =
weights[iMaxWeight];
526 for (
unsigned i = 0;
i <
weights.size(); ++
i) {
529 maxWeight =
weights[iMaxWeight];
541 if (rc && maxWeightBin != binOfMax) {
542 edm::LogWarning(
"Configuration") <<
"The maximum weight of DCC zero suppression FIR filter is not " 543 "applied to the expected maximum sample(" 545 << (binOfMax == 1 ?
"st" 546 : (binOfMax == 2 ?
"nd" : (binOfMax == 3 ?
"rd" :
"th")))
547 <<
" time sample). This may indicate faulty 'dccNormalizedWeights' " 548 "or 'ecalDccZs1sSample' parameters.";
555 int& binOfMax)
const {
559 vector<string> ebDigiParamList =
result.getParameterNames();
560 string bofm(
"binOfMaximum");
561 if (
find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) != ebDigiParamList.end()) {
562 binOfMax =
result.getParameter<
int>(
"binOfMaximum");
575 const char srpFlagMarker[] = {
'.',
'z',
'Z',
'F',
'4',
'5',
'6',
'7'};
579 const char* date = ctime(&
t);
580 os <<
"#SRP flag map\n#\n" 595 <<
": full readout\n" 630 os <<
"# Event " <<
iEvent <<
"\n";
638 for (
size_t i = 0;
i <
sizeof(eeSrf) /
sizeof(
int); ((
int*)eeSrf)[
i++] = -1) {
642 int iZ0 =
flag.id().zside() > 0 ? 1 : 0;
643 int iX0 =
flag.id().ix() - 1;
644 int iY0 =
flag.id().iy() - 1;
646 assert(iX0 >= 0 && iX0 < nScX);
647 assert(iY0 >= 0 && iY0 < nScY);
648 eeSrf[iZ0][iX0][iY0] =
flag.value();
650 const int nEbTtEta = 34;
651 const int nEeTtEta = 11;
652 const int nTtEta = nEeTtEta * 2 + nEbTtEta;
653 const int nTtPhi = 72;
654 int ebSrf[nEbTtEta][nTtPhi];
655 for (
size_t i = 0;
i <
sizeof(ebSrf) /
sizeof(
int); ((
int*)ebSrf)[
i++] = -1) {
660 int iEta0 =
iEta + nTtEta / 2 - (
iEta >= 0 ? 1 : 0);
661 int iEbEta0 = iEta0 - nEeTtEta;
662 int iPhi0 =
flag.id().iphi() - 1;
663 assert(iEbEta0 >= 0 && iEbEta0 < nEbTtEta);
664 assert(iPhi0 >= 0 && iPhi0 < nTtPhi);
671 ebSrf[iEbEta0][iPhi0] =
flag.value();
677 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
678 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
679 int srFlag = eeSrf[0][iX0][iY0];
687 for (
int iEta0 = 0; iEta0 < nEbTtEta; ++iEta0) {
688 for (
int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0) {
689 int srFlag = ebSrf[iEta0][iPhi0];
697 for (
int iX0 = 0; iX0 < nScX; ++iX0) {
698 for (
int iY0 = 0; iY0 < nScY; ++iY0) {
699 int srFlag = eeSrf[1][iX0][iY0];
713 <<
"Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. " 714 "while the configuration contains " 730 <<
"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)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
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_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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_
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
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
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &iDesc)
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
static void globalEndJob(esrp::Cache *)
std::vector< int > ecalDccZs1stSample_
const EEDigiCollection * getEEDigis(edm::Event &event)
std::string trigPrimCollection_
#define CMS_THREAD_GUARD(_var_)
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
const EcalElectronicsMapping * theElecMap
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
bool getBinOfMax(const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static std::unique_ptr< esrp::Cache > initializeGlobalCache(const edm::ParameterSet &)
typename CacheTypes::GlobalCache GlobalCache
static int getFIRTapCount()
const_iterator end() const
static const int nEndcaps
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
EcalSelectiveReadoutProducer(const edm::ParameterSet ¶ms, esrp::Cache const *)
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)
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_