CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
EcalSelectiveReadoutProducer Class Reference

#include <EcalSelectiveReadoutProducer.h>

Inheritance diagram for EcalSelectiveReadoutProducer:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalSelectiveReadoutProducer (const edm::ParameterSet &params)
 
void produce (edm::Event &event, const edm::EventSetup &eventSetup) override
 
 ~EcalSelectiveReadoutProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void printSrFlags (std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void checkWeights (const edm::Event &evt, const edm::ProductID &noZSDigiId) const
 
bool getBinOfMax (const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
 
const EBDigiCollectiongetEBDigis (edm::Event &event)
 
const EEDigiCollectiongetEEDigis (edm::Event &event)
 
const EcalTrigPrimDigiCollectiongetTrigPrims (edm::Event &event) const
 
void printTTFlags (const EcalTrigPrimDigiCollection &tp, std::ostream &os) const
 
void checkGeometry (const edm::EventSetup &eventSetup)
 
void checkTriggerMap (const edm::EventSetup &eventSetup)
 
void checkElecMap (const edm::EventSetup &eventSetup)
 

Static Private Member Functions

static void checkValidity (const EcalSRSettings &settings)
 

Private Attributes

std::string digiProducer_
 
int dumpFlags_
 
edm::EDGetTokenT< EBDigiCollectionEB_token
 
std::string ebdigiCollection_
 
std::string ebSrFlagCollection_
 
std::string ebSRPdigiCollection_
 
edm::EDGetTokenT< EcalTrigPrimDigiCollectionEcTP_token
 
edm::EDGetTokenT< EEDigiCollectionEE_token
 
std::string eedigiCollection_
 
std::string eeSrFlagCollection_
 
std::string eeSRPdigiCollection_
 
bool firstCallEB_
 
bool firstCallEE_
 
int iEvent_
 
edm::ParameterSet params_
 
bool produceDigis_
 
const EcalSRSettingssettings_
 
std::unique_ptr< EcalSRSettingssettingsFromFile_
 
std::unique_ptr< EcalSelectiveReadoutSuppressorsuppressor_
 
const EcalElectronicsMappingtheElecMap
 
const CaloGeometrytheGeometry
 
const EcalTrigTowerConstituentsMaptheTriggerTowerMap
 
bool trigPrimBypass_
 
int trigPrimBypassMode_
 
std::string trigPrimCollection_
 
std::string trigPrimProducer_
 
bool useCondDb_
 
bool useFullReadout_
 
bool writeSrFlags_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 14 of file EcalSelectiveReadoutProducer.h.

Constructor & Destructor Documentation

EcalSelectiveReadoutProducer::EcalSelectiveReadoutProducer ( const edm::ParameterSet params)
explicit

Constructor

Parameters
paramsseletive readout parameters

Definition at line 20 of file EcalSelectiveReadoutProducer.cc.

References digiProducer_, dumpFlags_, EB_token, ebdigiCollection_, ebSrFlagCollection_, ebSRPdigiCollection_, EcTP_token, EE_token, eedigiCollection_, eeSrFlagCollection_, eeSRPdigiCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), EcalSRCondTools::importParameterSet(), HLT_2018_cff::InputTag, produceDigis_, settings_, settingsFromFile_, AlCaHLTBitMon_QueryRunRegistry::string, theElecMap, theGeometry, theTriggerTowerMap, trigPrimBypass_, trigPrimBypassMode_, trigPrimCollection_, trigPrimProducer_, useCondDb_, useFullReadout_, and writeSrFlags_.

21  : params_(params), firstCallEB_(true), firstCallEE_(true), iEvent_(1) {
22  //settings:
23  // settings which are only in python config files:
24  digiProducer_ = params.getParameter<string>("digiProducer");
25  ebdigiCollection_ = params.getParameter<std::string>("EBdigiCollection");
26  eedigiCollection_ = params.getParameter<std::string>("EEdigiCollection");
27  ebSRPdigiCollection_ = params.getParameter<std::string>("EBSRPdigiCollection");
28  eeSRPdigiCollection_ = params.getParameter<std::string>("EESRPdigiCollection");
29  ebSrFlagCollection_ = params.getParameter<std::string>("EBSrFlagCollection");
30  eeSrFlagCollection_ = params.getParameter<std::string>("EESrFlagCollection");
31  trigPrimProducer_ = params.getParameter<string>("trigPrimProducer");
32  trigPrimCollection_ = params.getParameter<string>("trigPrimCollection");
33  trigPrimBypass_ = params.getParameter<bool>("trigPrimBypass");
34  trigPrimBypassMode_ = params.getParameter<int>("trigPrimBypassMode");
35  dumpFlags_ = params.getUntrackedParameter<int>("dumpFlags", 0);
36  writeSrFlags_ = params.getUntrackedParameter<bool>("writeSrFlags", false);
37  produceDigis_ = params.getUntrackedParameter<bool>("produceDigis", true);
38  // settings which can come from either condition database or python configuration file:
39  useCondDb_ = false;
40  try {
41  if (params.getParameter<bool>("configFromCondDB")) {
42  useCondDb_ = true;
43  }
44  } catch (cms::Exception const&) {
45  /* pameter not found */
46  edm::LogWarning("EcalSelectiveReadout") << "Parameter configFromCondDB of EcalSelectiveReadout module not found. "
47  "Selective readout configuration will be read from python file.";
48  }
49  if (!useCondDb_) {
50  settingsFromFile_ = unique_ptr<EcalSRSettings>(new EcalSRSettings());
53  }
54 
55  //declares the products made by this producer:
56  if (produceDigis_) {
57  produces<EBDigiCollection>(ebSRPdigiCollection_);
58  produces<EEDigiCollection>(eeSRPdigiCollection_);
59  }
60 
61  if (writeSrFlags_) {
62  produces<EBSrFlagCollection>(ebSrFlagCollection_);
63  produces<EESrFlagCollection>(eeSrFlagCollection_);
64  }
65 
66  useFullReadout_ = false;
67  useFullReadout_ = params.getParameter<bool>("UseFullReadout");
68 
69  theGeometry = nullptr;
70  theTriggerTowerMap = nullptr;
71  theElecMap = nullptr;
72 
73  EB_token = consumes<EBDigiCollection>(edm::InputTag(digiProducer_, ebdigiCollection_));
74  EE_token = consumes<EEDigiCollection>(edm::InputTag(digiProducer_, eedigiCollection_));
75  ;
76  EcTP_token = consumes<EcalTrigPrimDigiCollection>(edm::InputTag(trigPrimProducer_, trigPrimCollection_));
77  ;
78 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static void importParameterSet(EcalSRSettings &sr, const edm::ParameterSet &ps)
edm::EDGetTokenT< EBDigiCollection > EB_token
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
const EcalElectronicsMapping * theElecMap
std::unique_ptr< EcalSRSettings > settingsFromFile_
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
edm::EDGetTokenT< EEDigiCollection > EE_token
EcalSelectiveReadoutProducer::~EcalSelectiveReadoutProducer ( )
override

Destructor

Definition at line 80 of file EcalSelectiveReadoutProducer.cc.

80 {}

Member Function Documentation

void EcalSelectiveReadoutProducer::checkElecMap ( const edm::EventSetup eventSetup)
private

Definition at line 234 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theElecMap.

Referenced by produce().

234  {
236  eventSetup.get<EcalMappingRcd>().get(eElecmap);
237 
238  const EcalElectronicsMapping* pMap = &*eElecmap;
239 
240  // see if we need to update
241  if (pMap != theElecMap) {
242  theElecMap = pMap;
243  suppressor_->setElecMap(theElecMap);
244  }
245 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const EcalElectronicsMapping * theElecMap
T get() const
Definition: EventSetup.h:73
void EcalSelectiveReadoutProducer::checkGeometry ( const edm::EventSetup eventSetup)
private

call these once an event, to make sure everything is up-to-date

Definition at line 208 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theGeometry.

Referenced by produce().

208  {
209  edm::ESHandle<CaloGeometry> hGeometry;
210  eventSetup.get<CaloGeometryRecord>().get(hGeometry);
211 
212  const CaloGeometry* pGeometry = &*hGeometry;
213 
214  // see if we need to update
215  if (pGeometry != theGeometry) {
216  theGeometry = pGeometry;
217  suppressor_->setGeometry(theGeometry);
218  }
219 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
T get() const
Definition: EventSetup.h:73
void EcalSelectiveReadoutProducer::checkTriggerMap ( const edm::EventSetup eventSetup)
private

Definition at line 221 of file EcalSelectiveReadoutProducer.cc.

References edm::EventSetup::get(), suppressor_, and theTriggerTowerMap.

Referenced by produce().

221  {
223  eventSetup.get<IdealGeometryRecord>().get(eTTmap);
224 
225  const EcalTrigTowerConstituentsMap* pMap = &*eTTmap;
226 
227  // see if we need to update
228  if (pMap != theTriggerTowerMap) {
229  theTriggerTowerMap = pMap;
230  suppressor_->setTriggerMap(theTriggerTowerMap);
231  }
232 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
T get() const
Definition: EventSetup.h:73
void EcalSelectiveReadoutProducer::checkValidity ( const EcalSRSettings settings)
staticprivate

Checks validity of selective setting object is valid to be used for MC, especially checks the number of elements in the vectors

Parameters
forEmulatorif true check the restriction that applies for EcalSelectiveReadoutProducer
Exceptions
cms::Exceptionif the setting is not valid.

Definition at line 496 of file EcalSelectiveReadoutProducer.cc.

References EcalSRSettings::dccNormalizedWeights_, EcalSRSettings::ecalDccZs1stSample_, and Exception.

Referenced by produce().

496  {
497  if (settings.dccNormalizedWeights_.size() != 1) {
498  throw cms::Exception("Configuration")
499  << "Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. "
500  "while the configuration contains "
501  << settings.dccNormalizedWeights_.size() << " set(s)\n";
502  }
503 
504  // if(settings.dccNormalizedWeights_.size() != 1
505  // && settings.dccNormalizedWeights_.size() != 2
506  // && settings.dccNormalizedWeights_.size() != 54
507  // && settings.dccNormalizedWeights_.size() != 75848){
508  // throw cms::Exception("Configuration") << "Invalid number of DCC weight set (" << settings.dccNormalizedWeights_.size()
509  // << ") in condition object EcalSRSetting::dccNormalizedWeights_. "
510  // << "Valid counts are: 1 (single set), 2 (EB and EE), 54 (one per DCC) and 75848 "
511  // "(one per crystal)\n";
512  // }
513 
514  if (settings.dccNormalizedWeights_.size() != settings.ecalDccZs1stSample_.size()) {
515  throw cms::Exception("Configuration")
516  << "Inconsistency between number of weigth sets (" << settings.dccNormalizedWeights_.size() << ") and "
517  << "number of ecalDccZs1Sample values (" << settings.ecalDccZs1stSample_.size() << ").";
518  }
519 }
std::vector< std::vector< float > > dccNormalizedWeights_
std::vector< int > ecalDccZs1stSample_
void EcalSelectiveReadoutProducer::checkWeights ( const edm::Event evt,
const edm::ProductID noZSDigiId 
) const
private

Sanity check on the DCC FIR filter weights. Log warning or error message if an unexpected weight set is found. In principle it is checked that the maximum weight is applied to the expected maximum sample.

Definition at line 292 of file EcalSelectiveReadoutProducer.cc.

References EcalSRSettings::dccNormalizedWeights_, EcalSRSettings::ecalDccZs1stSample_, getBinOfMax(), EcalSelectiveReadoutSuppressor::getFIRTapCount(), mps_fire::i, settings_, and HGCalRecHit_cfi::weights.

Referenced by getEBDigis(), and getEEDigis().

292  {
293  const vector<float>& weights =
294  settings_->dccNormalizedWeights_[0]; //params_.getParameter<vector<double> >("dccNormalizedWeights");
296  static std::atomic<bool> warnWeightCnt{true};
297  bool expected = true;
298  if ((int)weights.size() > nFIRTaps &&
299  warnWeightCnt.compare_exchange_strong(expected, false, std::memory_order_acq_rel)) {
300  edm::LogWarning("Configuration") << "The list of DCC zero suppression FIR "
301  "weights given in parameter dccNormalizedWeights is longer "
302  "than the expected depth of the FIR filter :("
303  << nFIRTaps
304  << "). "
305  "The last weights will be discarded.";
306  }
307 
308  if (!weights.empty()) {
309  int iMaxWeight = 0;
310  double maxWeight = weights[iMaxWeight];
311  //looks for index of maximum weight
312  for (unsigned i = 0; i < weights.size(); ++i) {
313  if (weights[i] > maxWeight) {
314  iMaxWeight = i;
315  maxWeight = weights[iMaxWeight];
316  }
317  }
318 
319  //position of time sample whose maximum weight is applied:
320  int maxWeightBin = settings_->ecalDccZs1stSample_[0] //params_.getParameter<int>("ecalDccZs1stSample")
321  + iMaxWeight;
322 
323  //gets the bin of maximum (in case of raw data it will not exist)
324  int binOfMax = 0;
325  bool rc = getBinOfMax(evt, noZsDigiId, binOfMax);
326 
327  if (rc && maxWeightBin != binOfMax) {
328  edm::LogWarning("Configuration") << "The maximum weight of DCC zero suppression FIR filter is not "
329  "applied to the expected maximum sample("
330  << binOfMax
331  << (binOfMax == 1 ? "st"
332  : (binOfMax == 2 ? "nd" : (binOfMax == 3 ? "rd" : "th")))
333  << " time sample). This may indicate faulty 'dccNormalizedWeights' "
334  "or 'ecalDccZs1sSample' parameters.";
335  }
336  }
337 }
std::vector< std::vector< float > > dccNormalizedWeights_
bool getBinOfMax(const edm::Event &evt, const edm::ProductID &noZsDigiId, int &binOfMax) const
std::vector< int > ecalDccZs1stSample_
bool EcalSelectiveReadoutProducer::getBinOfMax ( const edm::Event evt,
const edm::ProductID noZsDigiId,
int &  binOfMax 
) const
private

Gets the value of the digitizer binOfMaximum parameter.

Parameters
noZsDigiIdproduct ID of the non-suppressed digis
binOfMax[out] set the parameter value if found
Returns
true on success, false otherwise

Definition at line 339 of file EcalSelectiveReadoutProducer.cc.

References spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::Event::getProvenance(), AlCaHLTBitMon_ParallelJobs::p, edm::parameterSet(), and mps_fire::result.

Referenced by checkWeights().

341  {
342  bool rc;
343  const edm::Provenance p = evt.getProvenance(noZsDigiId);
345  vector<string> ebDigiParamList = result.getParameterNames();
346  string bofm("binOfMaximum");
347  if (find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm) != ebDigiParamList.end()) { //bofm found
348  binOfMax = result.getParameter<int>("binOfMaximum");
349  rc = true;
350  } else {
351  rc = false;
352  }
353  return rc;
354 }
T getParameter(std::string const &) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< std::string > getParameterNames() const
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:114
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis ( edm::Event event)
private

Definition at line 176 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), EB_token, firstCallEB_, edm::HandleBase::id(), edm::Handle< T >::product(), and mps_fire::result.

Referenced by produce().

176  {
178  event.getByToken(EB_token, hEBDigis);
179  //product() method is called before id() in order to get an exception
180  //if the handle is not available (check not done by id() method).
181  const EBDigiCollection* result = hEBDigis.product();
182  if (firstCallEB_) {
183  checkWeights(event, hEBDigis.id());
184  firstCallEB_ = false;
185  }
186  return result;
187 }
ProductID id() const
Definition: HandleBase.cc:13
edm::EDGetTokenT< EBDigiCollection > EB_token
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
T const * product() const
Definition: Handle.h:69
const EEDigiCollection * EcalSelectiveReadoutProducer::getEEDigis ( edm::Event event)
private

Definition at line 189 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), EE_token, firstCallEE_, edm::HandleBase::id(), edm::Handle< T >::product(), and mps_fire::result.

Referenced by produce().

189  {
191  event.getByToken(EE_token, hEEDigis);
192  //product() method is called before id() in order to get an exception
193  //if the handle is not available (check not done by id() method).
194  const EEDigiCollection* result = hEEDigis.product();
195  if (firstCallEE_) {
196  checkWeights(event, hEEDigis.id());
197  firstCallEE_ = false;
198  }
199  return result;
200 }
ProductID id() const
Definition: HandleBase.cc:13
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
T const * product() const
Definition: Handle.h:69
edm::EDGetTokenT< EEDigiCollection > EE_token
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims ( edm::Event event) const
private

Definition at line 202 of file EcalSelectiveReadoutProducer.cc.

References EcTP_token, and edm::Handle< T >::product().

Referenced by produce().

202  {
204  event.getByToken(EcTP_token, hTPDigis);
205  return hTPDigis.product();
206 }
T const * product() const
Definition: Handle.h:69
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
void EcalSelectiveReadoutProducer::printSrFlags ( std::ostream &  os,
const EBSrFlagCollection ebSrFlags,
const EESrFlagCollection eeSrFlags,
int  iEvent = -1,
bool  withHeader = true 
)
static

Help function to print SR flags.

Parameters
ebSrFlagsthe action flags of EB
eeSrFlagthe action flags of EE
iEventevent number. Ignored if <0.
withHeader,iftrue an output description is written out as header.

Definition at line 356 of file EcalSelectiveReadoutProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), indexGen::date, edm::SortedCollection< T, SORT >::end(), RemoveAddSevLevel::flag, mps_fire::i, EBSrFlag::id(), EESrFlag::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), EcalScDetId::ix(), EcalScDetId::iy(), nEndcaps, srpFlagMarker, OrderedSet::t, ntuplemaker::time, EcalSrFlag::value(), and EcalScDetId::zside().

Referenced by produce().

360  {
361  const char srpFlagMarker[] = {'.', 'z', 'Z', 'F', '4', '5', '6', '7'};
362  if (withHeader) {
363  time_t t;
364  time(&t);
365  const char* date = ctime(&t);
366  os << "#SRP flag map\n#\n"
367  "# Generatied on: "
368  << date
369  << "\n#\n"
370  "# +-->Phi/Y "
371  << srpFlagMarker[0]
372  << ": suppressed\n"
373  "# | "
374  << srpFlagMarker[1]
375  << ": ZS 1\n"
376  "# | "
377  << srpFlagMarker[2]
378  << ": ZS 2\n"
379  "# V Eta/X "
380  << srpFlagMarker[3]
381  << ": full readout\n"
382  "#\n";
383  }
384 
385  //EE-,EB,EE+ map wil be written onto file in following format:
386  //
387  // 72
388  // <-------------->
389  // 20
390  // <--->
391  // EEE A +-----> Y
392  // EEEEE | |
393  // EE EE | 20 EE- |
394  // EEEEE | |
395  // EEE V V X
396  // BBBBBBBBBBBBBBBBB A
397  // BBBBBBBBBBBBBBBBB | +-----> Phi
398  // BBBBBBBBBBBBBBBBB | |
399  // BBBBBBBBBBBBBBBBB | 34 EB |
400  // BBBBBBBBBBBBBBBBB | |
401  // BBBBBBBBBBBBBBBBB | V Eta
402  // BBBBBBBBBBBBBBBBB |
403  // BBBBBBBBBBBBBBBBB |
404  // BBBBBBBBBBBBBBBBB V
405  // EEE A +-----> Y
406  // EEEEE | |
407  // EE EE | 20 EE+ |
408  // EEEEE | |
409  // EEE V V X
410  //
411  //
412  //
413  //
414  //event header:
415  if (iEvent >= 0) {
416  os << "# Event " << iEvent << "\n";
417  }
418 
419  //retrieve flags:
420  const int nEndcaps = 2;
421  const int nScX = 20;
422  const int nScY = 20;
423  int eeSrf[nEndcaps][nScX][nScY];
424  for (size_t i = 0; i < sizeof(eeSrf) / sizeof(int); ((int*)eeSrf)[i++] = -1) {
425  };
426  for (EESrFlagCollection::const_iterator it = eeSrFlags.begin(); it != eeSrFlags.end(); ++it) {
427  const EESrFlag& flag = *it;
428  int iZ0 = flag.id().zside() > 0 ? 1 : 0;
429  int iX0 = flag.id().ix() - 1;
430  int iY0 = flag.id().iy() - 1;
431  assert(iZ0 >= 0 && iZ0 < nEndcaps);
432  assert(iX0 >= 0 && iX0 < nScX);
433  assert(iY0 >= 0 && iY0 < nScY);
434  eeSrf[iZ0][iX0][iY0] = flag.value();
435  }
436  const int nEbTtEta = 34;
437  const int nEeTtEta = 11;
438  const int nTtEta = nEeTtEta * 2 + nEbTtEta;
439  const int nTtPhi = 72;
440  int ebSrf[nEbTtEta][nTtPhi];
441  for (size_t i = 0; i < sizeof(ebSrf) / sizeof(int); ((int*)ebSrf)[i++] = -1) {
442  };
443  for (EBSrFlagCollection::const_iterator it = ebSrFlags.begin(); it != ebSrFlags.end(); ++it) {
444  const EBSrFlag& flag = *it;
445  int iEta = flag.id().ieta();
446  int iEta0 = iEta + nTtEta / 2 - (iEta >= 0 ? 1 : 0); //0->55 from eta=-3 to eta=3
447  int iEbEta0 = iEta0 - nEeTtEta; //0->33 from eta=-1.48 to eta=1.48
448  int iPhi0 = flag.id().iphi() - 1;
449  assert(iEbEta0 >= 0 && iEbEta0 < nEbTtEta);
450  assert(iPhi0 >= 0 && iPhi0 < nTtPhi);
451 
452  // cout << __FILE__ << ":" << __LINE__ << ": "
453  // << iEta << "\t" << flag.id().iphi() << " -> "
454  // << iEbEta0 << "\t" << iPhi0
455  // << "... Flag: " << flag.value() << "\n";
456 
457  ebSrf[iEbEta0][iPhi0] = flag.value();
458  }
459 
460  //print flags:
461 
462  //EE-
463  for (int iX0 = 0; iX0 < nScX; ++iX0) {
464  for (int iY0 = 0; iY0 < nScY; ++iY0) {
465  int srFlag = eeSrf[0][iX0][iY0];
466  assert(srFlag >= -1 && srFlag < (int)(sizeof(srpFlagMarker) / sizeof(srpFlagMarker[0])));
467  os << (srFlag == -1 ? ' ' : srpFlagMarker[srFlag]);
468  }
469  os << "\n"; //one Y supercystal column per line
470  } //next supercrystal X-index
471 
472  //EB
473  for (int iEta0 = 0; iEta0 < nEbTtEta; ++iEta0) {
474  for (int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0) {
475  int srFlag = ebSrf[iEta0][iPhi0];
476  assert(srFlag >= -1 && srFlag < (int)(sizeof(srpFlagMarker) / sizeof(srpFlagMarker[0])));
477  os << (srFlag == -1 ? '?' : srpFlagMarker[srFlag]);
478  }
479  os << "\n"; //one phi per line
480  }
481 
482  //EE+
483  for (int iX0 = 0; iX0 < nScX; ++iX0) {
484  for (int iY0 = 0; iY0 < nScY; ++iY0) {
485  int srFlag = eeSrf[1][iX0][iY0];
486  assert(srFlag >= -1 && srFlag < (int)(sizeof(srpFlagMarker) / sizeof(srpFlagMarker[0])));
487  os << (srFlag == -1 ? ' ' : srpFlagMarker[srFlag]);
488  }
489  os << "\n"; //one Y supercystal column per line
490  } //next supercrystal X-index
491 
492  //event trailer:
493  os << "\n";
494 }
int value() const
Definition: EcalSrFlag.h:44
std::vector< T >::const_iterator const_iterator
int ieta() const
get the tower ieta
int iEvent
Definition: GenABIO.cc:224
int ix() const
Definition: EcalScDetId.h:70
int iy() const
Definition: EcalScDetId.h:76
const_iterator end() const
const EcalTrigTowerDetId & id() const override
Definition: EBSrFlag.h:36
int iphi() const
get the tower iphi
static const int nEndcaps
Definition: GenABIO.cc:115
int zside() const
Definition: EcalScDetId.h:64
const EcalScDetId & id() const override
Definition: EESrFlag.h:37
const_iterator begin() const
const char srpFlagMarker[]
Definition: GenABIO.cc:163
void EcalSelectiveReadoutProducer::printTTFlags ( const EcalTrigPrimDigiCollection tp,
std::ostream &  os 
) const
private

Definition at line 247 of file EcalSelectiveReadoutProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), HLT_2018_cff::nEta, HLT_2018_cff::nPhi, EcalSelectiveReadout::nTriggerTowersInEta, EcalSelectiveReadout::nTriggerTowersInPhi, EcalTriggerPrimitiveDigi::size(), tccFlagMarker, and EcalTriggerPrimitiveDigi::ttFlag().

247  {
248  const char tccFlagMarker[] = {'x', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
251 
252  //static bool firstCall=true;
253  // if(firstCall){
254  // firstCall=false;
255  os << "# TCC flag map\n#\n"
256  "# +-->Phi "
257  << tccFlagMarker[0 + 1]
258  << ": 000 (low interest)\n"
259  "# | "
260  << tccFlagMarker[1 + 1]
261  << ": 001 (mid interest)\n"
262  "# | "
263  << tccFlagMarker[2 + 1]
264  << ": 010 (not valid)\n"
265  "# V Eta "
266  << tccFlagMarker[3 + 1]
267  << ": 011 (high interest)\n"
268  "# "
269  << tccFlagMarker[4 + 1]
270  << ": 1xx forced readout (Hw error)\n"
271  "#\n";
272  //}
273 
274  vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
275  for (EcalTrigPrimDigiCollection::const_iterator it = tp.begin(); it != tp.end(); ++it) {
276  const EcalTriggerPrimitiveDigi& trigPrim = *it;
277  if (trigPrim.size() > 0) {
278  int iEta = trigPrim.id().ieta();
279  int iEta0 = iEta < 0 ? iEta + nEta / 2 : iEta + nEta / 2 - 1;
280  int iPhi0 = trigPrim.id().iphi() - 1;
281  ttf[iEta0][iPhi0] = trigPrim.ttFlag();
282  }
283  }
284  for (int iEta = 0; iEta < nEta; ++iEta) {
285  for (int iPhi = 0; iPhi < nPhi; ++iPhi) {
286  os << tccFlagMarker[ttf[iEta][iPhi] + 1];
287  }
288  os << "\n";
289  }
290 }
std::vector< T >::const_iterator const_iterator
const char tccFlagMarker[]
Definition: GenABIO.cc:164
int ieta() const
get the tower ieta
const_iterator end() const
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
static const size_t nTriggerTowersInEta
static const size_t nTriggerTowersInPhi
int ttFlag() const
get the Trigger tower Flag of interesting sample
const_iterator begin() const
void EcalSelectiveReadoutProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

Produces the EDM products

Parameters
CMSevent
eventSetupevent conditions

Definition at line 82 of file EcalSelectiveReadoutProducer.cc.

References checkElecMap(), checkGeometry(), checkTriggerMap(), checkValidity(), dumpFlags_, ebSrFlagCollection_, ebSRPdigiCollection_, SimL1EmulatorDM_cff::eeDigis, eeSrFlagCollection_, eeSRPdigiCollection_, edm::EventSetup::get(), getEBDigis(), getEEDigis(), getTrigPrims(), iEvent_, eostools::move(), params_, printSrFlags(), produceDigis_, edm::ESHandle< T >::product(), settings_, suppressor_, trigPrimBypass_, trigPrimBypassMode_, pileupReCalc_HLTpaths::trunc, useCondDb_, useFullReadout_, and writeSrFlags_.

82  {
83  if (useCondDb_) {
84  //getting selective readout configuration:
86 
87  if (useFullReadout_) {
88  eventSetup.get<EcalSRSettingsRcd>().get("fullReadout", hSr);
89  } else {
90  eventSetup.get<EcalSRSettingsRcd>().get(hSr);
91  }
92  settings_ = hSr.product();
93  }
94 
95  //gets the trigger primitives:
96  EcalTrigPrimDigiCollection emptyTPColl;
97  const EcalTrigPrimDigiCollection* trigPrims =
98  (trigPrimBypass_ && trigPrimBypassMode_ == 0) ? &emptyTPColl : getTrigPrims(event);
99 
100  //gets the digis from the events:
101  EBDigiCollection dummyEbDigiColl;
102  EEDigiCollection dummyEeDigiColl;
103 
104  const EBDigiCollection* ebDigis = produceDigis_ ? getEBDigis(event) : &dummyEbDigiColl;
105  const EEDigiCollection* eeDigis = produceDigis_ ? getEEDigis(event) : &dummyEeDigiColl;
106 
107  //runs the selective readout algorithm:
108  unique_ptr<EBDigiCollection> selectedEBDigis;
109  unique_ptr<EEDigiCollection> selectedEEDigis;
110  unique_ptr<EBSrFlagCollection> ebSrFlags;
111  unique_ptr<EESrFlagCollection> eeSrFlags;
112 
113  if (produceDigis_) {
114  selectedEBDigis = unique_ptr<EBDigiCollection>(new EBDigiCollection);
115  selectedEEDigis = unique_ptr<EEDigiCollection>(new EEDigiCollection);
116  }
117 
118  if (writeSrFlags_) {
119  ebSrFlags = unique_ptr<EBSrFlagCollection>(new EBSrFlagCollection);
120  eeSrFlags = unique_ptr<EESrFlagCollection>(new EESrFlagCollection);
121  }
122 
123  if (suppressor_.get() == nullptr) {
124  //Check the validity of EcalSRSettings
126 
127  //instantiates the selective readout algorithm:
128  suppressor_ = unique_ptr<EcalSelectiveReadoutSuppressor>(new EcalSelectiveReadoutSuppressor(params_, settings_));
129 
130  // check that everything is up-to-date
131  checkGeometry(eventSetup);
132  checkTriggerMap(eventSetup);
133  checkElecMap(eventSetup);
134  }
135 
136  suppressor_->run(eventSetup,
137  *trigPrims,
138  *ebDigis,
139  *eeDigis,
140  selectedEBDigis.get(),
141  selectedEEDigis.get(),
142  ebSrFlags.get(),
143  eeSrFlags.get());
144 
145  if (dumpFlags_ >= iEvent_) {
146  ofstream ttfFile("TTF.txt", (iEvent_ == 1 ? ios::trunc : ios::app));
147  suppressor_->printTTFlags(ttfFile, iEvent_, iEvent_ == 1 ? true : false);
148 
149  ofstream srfFile("SRF.txt", (iEvent_ == 1 ? ios::trunc : ios::app));
150  if (iEvent_ == 1) {
151  suppressor_->getEcalSelectiveReadout()->printHeader(srfFile);
152  }
153  srfFile << "# Event " << iEvent_ << "\n";
154  suppressor_->getEcalSelectiveReadout()->print(srfFile);
155  srfFile << "\n";
156 
157  ofstream afFile("AF.txt", (iEvent_ == 1 ? ios::trunc : ios::app));
158  printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent_, iEvent_ == 1 ? true : false);
159  }
160 
161  ++iEvent_; //event counter
162 
163  if (produceDigis_) {
164  //puts the selected digis into the event:
165  event.put(std::move(selectedEBDigis), ebSRPdigiCollection_);
166  event.put(std::move(selectedEEDigis), eeSRPdigiCollection_);
167  }
168 
169  //puts the SR flags into the event:
170  if (writeSrFlags_) {
171  event.put(std::move(ebSrFlags), ebSrFlagCollection_);
172  event.put(std::move(eeSrFlags), eeSrFlagCollection_);
173  }
174 }
const EBDigiCollection * getEBDigis(edm::Event &event)
void checkTriggerMap(const edm::EventSetup &eventSetup)
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
void checkGeometry(const edm::EventSetup &eventSetup)
void checkElecMap(const edm::EventSetup &eventSetup)
edm::SortedCollection< EBSrFlag > EBSrFlagCollection
edm::SortedCollection< EESrFlag > EESrFlagCollection
const EEDigiCollection * getEEDigis(edm::Event &event)
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
T get() const
Definition: EventSetup.h:73
static void printSrFlags(std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)
static void checkValidity(const EcalSRSettings &settings)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::string EcalSelectiveReadoutProducer::digiProducer_
private

Definition at line 85 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

int EcalSelectiveReadoutProducer::dumpFlags_
private

Number of event whose TT and SR flags must be dumped into a file.

Definition at line 107 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

edm::EDGetTokenT<EBDigiCollection> EcalSelectiveReadoutProducer::EB_token
private

Definition at line 145 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().

std::string EcalSelectiveReadoutProducer::ebdigiCollection_
private

Definition at line 86 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::ebSrFlagCollection_
private

Definition at line 90 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::ebSRPdigiCollection_
private

Definition at line 88 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

edm::EDGetTokenT<EcalTrigPrimDigiCollection> EcalSelectiveReadoutProducer::EcTP_token
private

Definition at line 147 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

edm::EDGetTokenT<EEDigiCollection> EcalSelectiveReadoutProducer::EE_token
private

Definition at line 146 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().

std::string EcalSelectiveReadoutProducer::eedigiCollection_
private

Definition at line 87 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::eeSrFlagCollection_
private

Definition at line 91 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::eeSRPdigiCollection_
private

Definition at line 89 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

bool EcalSelectiveReadoutProducer::firstCallEB_
private

keys

Definition at line 134 of file EcalSelectiveReadoutProducer.h.

Referenced by getEBDigis().

bool EcalSelectiveReadoutProducer::firstCallEE_
private

Definition at line 135 of file EcalSelectiveReadoutProducer.h.

Referenced by getEEDigis().

int EcalSelectiveReadoutProducer::iEvent_
private

Definition at line 136 of file EcalSelectiveReadoutProducer.h.

Referenced by produce().

edm::ParameterSet EcalSelectiveReadoutProducer::params_
private

Definition at line 99 of file EcalSelectiveReadoutProducer.h.

Referenced by produce().

bool EcalSelectiveReadoutProducer::produceDigis_
private

Switch for suppressed digi production If false SR flags are produced but selective readout is not applied on the crystal channel digis.

Definition at line 116 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

const EcalSRSettings* EcalSelectiveReadoutProducer::settings_
private

SR settings

Definition at line 120 of file EcalSelectiveReadoutProducer.h.

Referenced by checkWeights(), EcalSelectiveReadoutProducer(), and produce().

std::unique_ptr<EcalSRSettings> EcalSelectiveReadoutProducer::settingsFromFile_
private

Used when settings_ is imported from configuration file. Just used for memory management. Used settings_ to access to the object

Definition at line 141 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::unique_ptr<EcalSelectiveReadoutSuppressor> EcalSelectiveReadoutProducer::suppressor_
private
const EcalElectronicsMapping* EcalSelectiveReadoutProducer::theElecMap
private

Definition at line 98 of file EcalSelectiveReadoutProducer.h.

Referenced by checkElecMap(), and EcalSelectiveReadoutProducer().

const CaloGeometry* EcalSelectiveReadoutProducer::theGeometry
private

Definition at line 96 of file EcalSelectiveReadoutProducer.h.

Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().

const EcalTrigTowerConstituentsMap* EcalSelectiveReadoutProducer::theTriggerTowerMap
private

Definition at line 97 of file EcalSelectiveReadoutProducer.h.

Referenced by checkTriggerMap(), and EcalSelectiveReadoutProducer().

bool EcalSelectiveReadoutProducer::trigPrimBypass_
private

Definition at line 101 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

int EcalSelectiveReadoutProducer::trigPrimBypassMode_
private

Definition at line 103 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::trigPrimCollection_
private

Definition at line 93 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::trigPrimProducer_
private

Definition at line 92 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

bool EcalSelectiveReadoutProducer::useCondDb_
private

Switch for retrieving SR settings from condition database instead of CMSSW python configuration file.

Definition at line 125 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

bool EcalSelectiveReadoutProducer::useFullReadout_
private

Special switch to turn off SR entirely using special DB entries

Definition at line 130 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

bool EcalSelectiveReadoutProducer::writeSrFlags_
private

switch to write out the SrFlags collections in the event

Definition at line 111 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().