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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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)
 
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::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 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 21 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(), produceDigis_, settings_, settingsFromFile_, AlCaHLTBitMon_QueryRunRegistry::string, theElecMap, theGeometry, theTriggerTowerMap, trigPrimBypass_, trigPrimBypassMode_, trigPrimCollection_, trigPrimProducer_, useCondDb_, useFullReadout_, and writeSrFlags_.

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

84 { }

Member Function Documentation

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

Definition at line 254 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

255 {
256 
258  eventSetup.get<EcalMappingRcd>().get(eElecmap);
259 
260  const EcalElectronicsMapping * pMap = &*eElecmap;
261 
262  // see if we need to update
263  if(pMap!= theElecMap) {
264  theElecMap = pMap;
265  suppressor_->setElecMap(theElecMap);
266  }
267 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const EcalElectronicsMapping * theElecMap
const T & get() const
Definition: EventSetup.h:58
void EcalSelectiveReadoutProducer::checkGeometry ( const edm::EventSetup eventSetup)
private

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

Definition at line 223 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

224 {
225  edm::ESHandle<CaloGeometry> hGeometry;
226  eventSetup.get<CaloGeometryRecord>().get(hGeometry);
227 
228  const CaloGeometry * pGeometry = &*hGeometry;
229 
230  // see if we need to update
231  if(pGeometry != theGeometry) {
232  theGeometry = pGeometry;
233  suppressor_->setGeometry(theGeometry);
234  }
235 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const T & get() const
Definition: EventSetup.h:58
void EcalSelectiveReadoutProducer::checkTriggerMap ( const edm::EventSetup eventSetup)
private

Definition at line 238 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

239 {
240 
242  eventSetup.get<IdealGeometryRecord>().get(eTTmap);
243 
244  const EcalTrigTowerConstituentsMap * pMap = &*eTTmap;
245 
246  // see if we need to update
247  if(pMap!= theTriggerTowerMap) {
248  theTriggerTowerMap = pMap;
249  suppressor_->setTriggerMap(theTriggerTowerMap);
250  }
251 }
std::unique_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
const T & get() const
Definition: EventSetup.h:58
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 507 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

507  {
508  if(settings.dccNormalizedWeights_.size() != 1){
509  throw cms::Exception("Configuration") << "Selective readout emulator, EcalSelectiveReadout, supports only single set of ZS weights. "
510  "while the configuration contains " << settings.dccNormalizedWeights_.size() << " set(s)\n";
511  }
512 
513 // if(settings.dccNormalizedWeights_.size() != 1
514 // && settings.dccNormalizedWeights_.size() != 2
515 // && settings.dccNormalizedWeights_.size() != 54
516 // && settings.dccNormalizedWeights_.size() != 75848){
517 // throw cms::Exception("Configuration") << "Invalid number of DCC weight set (" << settings.dccNormalizedWeights_.size()
518 // << ") in condition object EcalSRSetting::dccNormalizedWeights_. "
519 // << "Valid counts are: 1 (single set), 2 (EB and EE), 54 (one per DCC) and 75848 "
520 // "(one per crystal)\n";
521 // }
522 
523  if(settings.dccNormalizedWeights_.size() != settings.ecalDccZs1stSample_.size()){
524  throw cms::Exception("Configuration") << "Inconsistency between number of weigth sets ("
525  << settings.dccNormalizedWeights_.size() << ") and "
526  << "number of ecalDccZs1Sample values ("
527  << settings.ecalDccZs1stSample_.size() << ").";
528  }
529 }
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 306 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by getEBDigis(), and getEEDigis().

307  {
308  const vector<float> & weights = settings_->dccNormalizedWeights_[0]; //params_.getParameter<vector<double> >("dccNormalizedWeights");
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.";
317  }
318 
319  if(!weights.empty()){
320  int iMaxWeight = 0;
321  double maxWeight = weights[iMaxWeight];
322  //looks for index of maximum weight
323  for(unsigned i=0; i<weights.size(); ++i){
324  if(weights[i]>maxWeight){
325  iMaxWeight = i;
326  maxWeight = weights[iMaxWeight];
327  }
328  }
329 
330  //position of time sample whose maximum weight is applied:
331  int maxWeightBin = settings_->ecalDccZs1stSample_[0] //params_.getParameter<int>("ecalDccZs1stSample")
332  + iMaxWeight;
333 
334  //gets the bin of maximum (in case of raw data it will not exist)
335  int binOfMax = 0;
336  bool rc = getBinOfMax(evt, noZsDigiId, binOfMax);
337 
338  if(rc && maxWeightBin!=binOfMax){
339  edm::LogWarning("Configuration")
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.";
345  }
346  }
347 }
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 350 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().

352  {
353  bool rc;
354  const edm::Provenance p=evt.getProvenance(noZsDigiId);
356  vector<string> ebDigiParamList = result.getParameterNames();
357  string bofm("binOfMaximum");
358  if(find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm)
359  != ebDigiParamList.end()){//bofm found
360  binOfMax=result.getParameter<int>("binOfMaximum");
361  rc = true;
362  } else{
363  rc = false;
364  }
365  return rc;
366 }
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:20
std::vector< std::string > getParameterNames() const
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:129
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis ( edm::Event event)
private

Definition at line 185 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

186 {
188  event.getByToken(EB_token, hEBDigis);
189  //product() method is called before id() in order to get an exception
190  //if the handle is not available (check not done by id() method).
191  const EBDigiCollection* result = hEBDigis.product();
192  if(firstCallEB_){
193  checkWeights(event, hEBDigis.id());
194  firstCallEB_ = false;
195  }
196  return result;
197 }
ProductID id() const
Definition: HandleBase.cc:15
edm::EDGetTokenT< EBDigiCollection > EB_token
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
T const * product() const
Definition: Handle.h:81
const EEDigiCollection * EcalSelectiveReadoutProducer::getEEDigis ( edm::Event event)
private

Definition at line 200 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

201 {
203  event.getByToken(EE_token, hEEDigis);
204  //product() method is called before id() in order to get an exception
205  //if the handle is not available (check not done by id() method).
206  const EEDigiCollection* result = hEEDigis.product();
207  if(firstCallEE_){
208  checkWeights(event, hEEDigis.id());
209  firstCallEE_ = false;
210  }
211  return result;
212 }
ProductID id() const
Definition: HandleBase.cc:15
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< EEDigiCollection > EE_token
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims ( edm::Event event) const
private

Definition at line 215 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

216 {
218  event.getByToken(EcTP_token, hTPDigis);
219  return hTPDigis.product();
220 }
T const * product() const
Definition: Handle.h:81
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 369 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, lumiQTWidget::t, ntuplemaker::time, EcalSrFlag::value(), and EcalScDetId::zside().

Referenced by produce().

373  {
374  const char srpFlagMarker[] = {'.', 'z', 'Z', 'F', '4','5','6','7'};
375  if(withHeader){
376  time_t t;
377  time(&t);
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"
385  "#\n";
386  }
387 
388  //EE-,EB,EE+ map wil be written onto file in following format:
389  //
390  // 72
391  // <-------------->
392  // 20
393  // <--->
394  // EEE A +-----> Y
395  // EEEEE | |
396  // EE EE | 20 EE- |
397  // EEEEE | |
398  // EEE V V X
399  // BBBBBBBBBBBBBBBBB A
400  // BBBBBBBBBBBBBBBBB | +-----> Phi
401  // BBBBBBBBBBBBBBBBB | |
402  // BBBBBBBBBBBBBBBBB | 34 EB |
403  // BBBBBBBBBBBBBBBBB | |
404  // BBBBBBBBBBBBBBBBB | V Eta
405  // BBBBBBBBBBBBBBBBB |
406  // BBBBBBBBBBBBBBBBB |
407  // BBBBBBBBBBBBBBBBB V
408  // EEE A +-----> Y
409  // EEEEE | |
410  // EE EE | 20 EE+ |
411  // EEEEE | |
412  // EEE V V X
413  //
414  //
415  //
416  //
417  //event header:
418  if(iEvent>=0){
419  os << "# Event " << iEvent << "\n";
420  }
421 
422  //retrieve flags:
423  const int nEndcaps = 2;
424  const int nScX = 20;
425  const int nScY = 20;
426  int eeSrf[nEndcaps][nScX][nScY];
427  for(size_t i=0; i < sizeof(eeSrf)/sizeof(int); ((int*)eeSrf)[i++] = -1){};
428  for(EESrFlagCollection::const_iterator it = eeSrFlags.begin();
429  it != eeSrFlags.end(); ++it){
430  const EESrFlag& flag = *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();
438  }
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){};
445  for(EBSrFlagCollection::const_iterator it = ebSrFlags.begin();
446  it != ebSrFlags.end(); ++it){
447 
448  const EBSrFlag& flag = *it;
449  int iEta = flag.id().ieta();
450  int iEta0 = iEta + nTtEta/2 - (iEta>=0?1:0); //0->55 from eta=-3 to eta=3
451  int iEbEta0 = iEta0 - nEeTtEta;//0->33 from eta=-1.48 to eta=1.48
452  int iPhi0 = flag.id().iphi() - 1;
453  assert(iEbEta0>=0 && iEbEta0<nEbTtEta);
454  assert(iPhi0>=0 && iPhi0<nTtPhi);
455 
456 // cout << __FILE__ << ":" << __LINE__ << ": "
457 // << iEta << "\t" << flag.id().iphi() << " -> "
458 // << iEbEta0 << "\t" << iPhi0
459 // << "... Flag: " << flag.value() << "\n";
460 
461 
462  ebSrf[iEbEta0][iPhi0] = flag.value();
463  }
464 
465 
466  //print flags:
467 
468  //EE-
469  for(int iX0=0; iX0<nScX; ++iX0){
470  for(int iY0=0; iY0<nScY; ++iY0){
471  int srFlag = eeSrf[0][iX0][iY0];
472  assert(srFlag>=-1
473  && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
474  os << (srFlag==-1?' ':srpFlagMarker[srFlag]);
475  }
476  os << "\n"; //one Y supercystal column per line
477  } //next supercrystal X-index
478 
479  //EB
480  for(int iEta0 = 0;
481  iEta0 < nEbTtEta;
482  ++iEta0){
483  for(int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0){
484  int srFlag = ebSrf[iEta0][iPhi0];
485  assert(srFlag>=-1
486  && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
487  os << (srFlag==-1?'?':srpFlagMarker[srFlag]);
488  }
489  os << "\n"; //one phi per line
490  }
491 
492  //EE+
493  for(int iX0=0; iX0<nScX; ++iX0){
494  for(int iY0=0; iY0<nScY; ++iY0){
495  int srFlag = eeSrf[1][iX0][iY0];
496  assert(srFlag>=-1
497  && srFlag<(int)(sizeof(srpFlagMarker)/sizeof(srpFlagMarker[0])));
498  os << (srFlag==-1?' ':srpFlagMarker[srFlag]);
499  }
500  os << "\n"; //one Y supercystal column per line
501  } //next supercrystal X-index
502 
503  //event trailer:
504  os << "\n";
505 }
int value() const
Definition: EcalSrFlag.h:44
std::vector< EESrFlag >::const_iterator const_iterator
int ieta() const
get the tower ieta
int iEvent
Definition: GenABIO.cc:230
int ix() const
Definition: EcalScDetId.h:71
int iy() const
Definition: EcalScDetId.h:77
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:126
int zside() const
Definition: EcalScDetId.h:65
const EcalScDetId & id() const override
Definition: EESrFlag.h:37
const_iterator begin() const
const char srpFlagMarker[]
Definition: GenABIO.cc:175
void EcalSelectiveReadoutProducer::printTTFlags ( const EcalTrigPrimDigiCollection tp,
std::ostream &  os 
) const
private

Definition at line 270 of file EcalSelectiveReadoutProducer.cc.

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

270  {
271  const char tccFlagMarker[] = { 'x', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
274 
275  //static bool firstCall=true;
276  // if(firstCall){
277  // firstCall=false;
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"
284  "#\n";
285  //}
286 
287  vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
289  it != tp.end(); ++it){
290  const EcalTriggerPrimitiveDigi& trigPrim = *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();
296  }
297  }
298  for(int iEta=0; iEta<nEta; ++iEta){
299  for(int iPhi=0; iPhi<nPhi; ++iPhi){
300  os << tccFlagMarker[ttf[iEta][iPhi]+1];
301  }
302  os << "\n";
303  }
304 }
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
const char tccFlagMarker[]
Definition: GenABIO.cc:176
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 88 of file EcalSelectiveReadoutProducer.cc.

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

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

Member Data Documentation

std::string EcalSelectiveReadoutProducer::digiProducer_
private

Definition at line 102 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 124 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

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

Definition at line 162 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().

std::string EcalSelectiveReadoutProducer::ebdigiCollection_
private

Definition at line 103 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::ebSrFlagCollection_
private

Definition at line 107 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::ebSRPdigiCollection_
private

Definition at line 105 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

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

Definition at line 164 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

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

Definition at line 163 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().

std::string EcalSelectiveReadoutProducer::eedigiCollection_
private

Definition at line 104 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::eeSrFlagCollection_
private

Definition at line 108 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::eeSRPdigiCollection_
private

Definition at line 106 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

bool EcalSelectiveReadoutProducer::firstCallEB_
private

keys

Definition at line 151 of file EcalSelectiveReadoutProducer.h.

Referenced by getEBDigis().

bool EcalSelectiveReadoutProducer::firstCallEE_
private

Definition at line 152 of file EcalSelectiveReadoutProducer.h.

Referenced by getEEDigis().

int EcalSelectiveReadoutProducer::iEvent_
private

Definition at line 153 of file EcalSelectiveReadoutProducer.h.

Referenced by produce().

edm::ParameterSet EcalSelectiveReadoutProducer::params_
private

Definition at line 116 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 133 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

const EcalSRSettings* EcalSelectiveReadoutProducer::settings_
private

SR settings

Definition at line 137 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 158 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

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

Definition at line 115 of file EcalSelectiveReadoutProducer.h.

Referenced by checkElecMap(), and EcalSelectiveReadoutProducer().

const CaloGeometry* EcalSelectiveReadoutProducer::theGeometry
private

Definition at line 113 of file EcalSelectiveReadoutProducer.h.

Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().

const EcalTrigTowerConstituentsMap* EcalSelectiveReadoutProducer::theTriggerTowerMap
private
bool EcalSelectiveReadoutProducer::trigPrimBypass_
private

Definition at line 118 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

int EcalSelectiveReadoutProducer::trigPrimBypassMode_
private

Definition at line 120 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::trigPrimCollection_
private

Definition at line 110 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::trigPrimProducer_
private

Definition at line 109 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 142 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 147 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 128 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().