CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalSelectiveReadoutProducer (const edm::ParameterSet &params)
 
virtual void produce (edm::Event &event, const edm::EventSetup &eventSetup)
 
virtual ~EcalSelectiveReadoutProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::EDProducer
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
 
const EEDigiCollectiongetEEDigis (edm::Event &event) const
 
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
< EBDigiCollection
EB_token
 
std::string ebdigiCollection_
 
std::string ebSrFlagCollection_
 
std::string ebSRPdigiCollection_
 
edm::EDGetTokenT
< EcalTrigPrimDigiCollection
EcTP_token
 
edm::EDGetTokenT
< EEDigiCollection
EE_token
 
std::string eedigiCollection_
 
std::string eeSrFlagCollection_
 
std::string eeSRPdigiCollection_
 
edm::ParameterSet params_
 
bool produceDigis_
 
const EcalSRSettingssettings_
 
std::auto_ptr< EcalSRSettingssettingsFromFile_
 
std::auto_ptr
< EcalSelectiveReadoutSuppressor
suppressor_
 
const EcalElectronicsMappingtheElecMap
 
const CaloGeometrytheGeometry
 
const
EcalTrigTowerConstituentsMap
theTriggerTowerMap
 
bool trigPrimBypass_
 
int trigPrimBypassMode_
 
std::string trigPrimCollection_
 
std::string trigPrimProducer_
 
bool useCondDb_
 
bool useFullReadout_
 
bool writeSrFlags_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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 18 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(), HLT_25ns10e33_v2_cff::InputTag, produceDigis_, settings_, settingsFromFile_, AlCaHLTBitMon_QueryRunRegistry::string, theElecMap, theGeometry, theTriggerTowerMap, trigPrimBypass_, trigPrimBypassMode_, trigPrimCollection_, trigPrimProducer_, useCondDb_, useFullReadout_, and writeSrFlags_.

22  : params_(params)
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_ = auto_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 = 0;
73  theElecMap = 0;
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
edm::EDGetTokenT< EcalTrigPrimDigiCollection > EcTP_token
edm::EDGetTokenT< EEDigiCollection > EE_token
std::auto_ptr< EcalSRSettings > settingsFromFile_
EcalSelectiveReadoutProducer::~EcalSelectiveReadoutProducer ( )
virtual

Destructor

Definition at line 83 of file EcalSelectiveReadoutProducer.cc.

84 { }

Member Function Documentation

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

Definition at line 257 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

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

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

Definition at line 226 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

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

Definition at line 241 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

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

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

Referenced by produce().

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

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

Referenced by getEBDigis(), and getEEDigis().

310  {
311  const vector<float> & weights = settings_->dccNormalizedWeights_[0]; //params_.getParameter<vector<double> >("dccNormalizedWeights");
313  static std::atomic<bool> warnWeightCnt{true};
314  bool expected = true;
315  if((int)weights.size() > nFIRTaps && warnWeightCnt.compare_exchange_strong(expected,false,std::memory_order_acq_rel)){
316  edm::LogWarning("Configuration") << "The list of DCC zero suppression FIR "
317  "weights given in parameter dccNormalizedWeights is longer "
318  "than the expected depth of the FIR filter :(" << nFIRTaps << "). "
319  "The last weights will be discarded.";
320  }
321 
322  if(weights.size()>0){
323  int iMaxWeight = 0;
324  double maxWeight = weights[iMaxWeight];
325  //looks for index of maximum weight
326  for(unsigned i=0; i<weights.size(); ++i){
327  if(weights[i]>maxWeight){
328  iMaxWeight = i;
329  maxWeight = weights[iMaxWeight];
330  }
331  }
332 
333  //position of time sample whose maximum weight is applied:
334  int maxWeightBin = settings_->ecalDccZs1stSample_[0] //params_.getParameter<int>("ecalDccZs1stSample")
335  + iMaxWeight;
336 
337  //gets the bin of maximum (in case of raw data it will not exist)
338  int binOfMax = 0;
339  bool rc = getBinOfMax(evt, noZsDigiId, binOfMax);
340 
341  if(rc && maxWeightBin!=binOfMax){
342  edm::LogWarning("Configuration")
343  << "The maximum weight of DCC zero suppression FIR filter is not "
344  "applied to the expected maximum sample(" << binOfMax
345  << (binOfMax==1?"st":(binOfMax==2?"nd":(binOfMax==3?"rd":"th")))
346  << " time sample). This may indicate faulty 'dccNormalizedWeights' "
347  "or 'ecalDccZs1sSample' parameters.";
348  }
349  }
350 }
int i
Definition: DBlmapReader.cc:9
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 353 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().

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

Definition at line 186 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

187 {
189  event.getByToken(EB_token, hEBDigis);
190  //product() method is called before id() in order to get an exception
191  //if the handle is not available (check not done by id() method).
192  const EBDigiCollection* result = hEBDigis.product();
193  static bool firstCall= true;
194  if(firstCall){
195  checkWeights(event, hEBDigis.id());
196  firstCall = false;
197  }
198  return result;
199 }
ProductID id() const
Definition: HandleBase.cc:15
edm::EDGetTokenT< EBDigiCollection > EB_token
tuple result
Definition: mps_fire.py:84
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) const
private

Definition at line 202 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

203 {
205  event.getByToken(EE_token, hEEDigis);
206  //product() method is called before id() in order to get an exception
207  //if the handle is not available (check not done by id() method).
208  const EEDigiCollection* result = hEEDigis.product();
209  static bool firstCall = true;
210  if(firstCall){
211  checkWeights(event, hEEDigis.id());
212  firstCall = false;
213  }
214  return result;
215 }
ProductID id() const
Definition: HandleBase.cc:15
tuple result
Definition: mps_fire.py:84
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 218 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

219 {
221  event.getByToken(EcTP_token, hTPDigis);
222  return hTPDigis.product();
223 }
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 372 of file EcalSelectiveReadoutProducer.cc.

References assert(), edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), i, EBSrFlag::id(), EESrFlag::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::iphi(), EcalScDetId::ix(), EcalScDetId::iy(), nEndcaps, srpFlagMarker, lumiQTWidget::t, EcalSrFlag::value(), and EcalScDetId::zside().

Referenced by produce().

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

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

273  {
274  const char tccFlagMarker[] = { 'x', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
277 
278  //static bool firstCall=true;
279  // if(firstCall){
280  // firstCall=false;
281  os << "# TCC flag map\n#\n"
282  "# +-->Phi " << tccFlagMarker[0+1] << ": 000 (low interest)\n"
283  "# | " << tccFlagMarker[1+1] << ": 001 (mid interest)\n"
284  "# | " << tccFlagMarker[2+1] << ": 010 (not valid)\n"
285  "# V Eta " << tccFlagMarker[3+1] << ": 011 (high interest)\n"
286  "# " << tccFlagMarker[4+1] << ": 1xx forced readout (Hw error)\n"
287  "#\n";
288  //}
289 
290  vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
292  it != tp.end(); ++it){
293  const EcalTriggerPrimitiveDigi& trigPrim = *it;
294  if(trigPrim.size()>0){
295  int iEta = trigPrim.id().ieta();
296  int iEta0 = iEta<0?iEta+nEta/2:iEta+nEta/2-1;
297  int iPhi0 = trigPrim.id().iphi() - 1;
298  ttf[iEta0][iPhi0] = trigPrim.ttFlag();
299  }
300  }
301  for(int iEta=0; iEta<nEta; ++iEta){
302  for(int iPhi=0; iPhi<nPhi; ++iPhi){
303  os << tccFlagMarker[ttf[iEta][iPhi]+1];
304  }
305  os << "\n";
306  }
307 }
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 
)
virtual

Produces the EDM products

Parameters
CMSevent
eventSetupevent conditions

Implements edm::EDProducer.

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, params_, printSrFlags(), produceDigis_, edm::ESHandle< class >::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  auto_ptr<EBDigiCollection> selectedEBDigis;
120  auto_ptr<EEDigiCollection> selectedEEDigis;
121  auto_ptr<EBSrFlagCollection> ebSrFlags;
122  auto_ptr<EESrFlagCollection> eeSrFlags;
123 
124  if(produceDigis_){
125  selectedEBDigis = auto_ptr<EBDigiCollection>(new EBDigiCollection);
126  selectedEEDigis = auto_ptr<EEDigiCollection>(new EEDigiCollection);
127  }
128 
129  if(writeSrFlags_){
130  ebSrFlags = auto_ptr<EBSrFlagCollection>(new EBSrFlagCollection);
131  eeSrFlags = auto_ptr<EESrFlagCollection>(new EESrFlagCollection);
132  }
133 
134  if(suppressor_.get() == 0){
135  //Check the validity of EcalSRSettings
137 
138  //instantiates the selective readout algorithm:
139  suppressor_ = auto_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  static int iEvent = 1;
152  if(dumpFlags_>=iEvent){
153  ofstream ttfFile("TTF.txt", (iEvent==1?ios::trunc:ios::app));
154  suppressor_->printTTFlags(ttfFile, iEvent,
155  iEvent==1?true:false);
156 
157  ofstream srfFile("SRF.txt", (iEvent==1?ios::trunc:ios::app));
158  if(iEvent==1){
159  suppressor_->getEcalSelectiveReadout()->printHeader(srfFile);
160  }
161  srfFile << "# Event " << iEvent << "\n";
162  suppressor_->getEcalSelectiveReadout()->print(srfFile);
163  srfFile << "\n";
164 
165  ofstream afFile("AF.txt", (iEvent==1?ios::trunc:ios::app));
166  printSrFlags(afFile, *ebSrFlags, *eeSrFlags, iEvent,
167  iEvent==1?true:false);
168  }
169 
170  ++iEvent; //event counter
171 
172  if(produceDigis_){
173  //puts the selected digis into the event:
174  event.put(selectedEBDigis, ebSRPdigiCollection_);
175  event.put(selectedEEDigis, eeSRPdigiCollection_);
176  }
177 
178  //puts the SR flags into the event:
179  if(writeSrFlags_) {
180  event.put(ebSrFlags, ebSrFlagCollection_);
181  event.put(eeSrFlags, eeSrFlagCollection_);
182  }
183 }
const EEDigiCollection * getEEDigis(edm::Event &event) const
void checkTriggerMap(const edm::EventSetup &eventSetup)
void checkGeometry(const edm::EventSetup &eventSetup)
void checkElecMap(const edm::EventSetup &eventSetup)
int iEvent
Definition: GenABIO.cc:230
edm::SortedCollection< EBSrFlag > EBSrFlagCollection
edm::SortedCollection< EESrFlag > EESrFlagCollection
std::auto_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const EBDigiCollection * getEBDigis(edm::Event &event) const
const EcalTrigPrimDigiCollection * getTrigPrims(edm::Event &event) const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
static void printSrFlags(std::ostream &os, const EBSrFlagCollection &ebSrFlags, const EESrFlagCollection &eeSrFlags, int iEvent=-1, bool withHeader=true)
static void checkValidity(const EcalSRSettings &settings)

Member Data Documentation

std::string EcalSelectiveReadoutProducer::digiProducer_
private

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

Referenced by EcalSelectiveReadoutProducer(), and produce().

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

Definition at line 161 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().

std::string EcalSelectiveReadoutProducer::ebdigiCollection_
private

Definition at line 107 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::ebSrFlagCollection_
private

Definition at line 111 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::ebSRPdigiCollection_
private

Definition at line 109 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

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

Definition at line 163 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

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

Definition at line 162 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().

std::string EcalSelectiveReadoutProducer::eedigiCollection_
private

Definition at line 108 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::eeSrFlagCollection_
private

Definition at line 112 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::eeSRPdigiCollection_
private

Definition at line 110 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

edm::ParameterSet EcalSelectiveReadoutProducer::params_
private

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

Referenced by EcalSelectiveReadoutProducer(), and produce().

const EcalSRSettings* EcalSelectiveReadoutProducer::settings_
private

SR settings

Definition at line 141 of file EcalSelectiveReadoutProducer.h.

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

std::auto_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 157 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

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

Definition at line 119 of file EcalSelectiveReadoutProducer.h.

Referenced by checkElecMap(), and EcalSelectiveReadoutProducer().

const CaloGeometry* EcalSelectiveReadoutProducer::theGeometry
private

Definition at line 117 of file EcalSelectiveReadoutProducer.h.

Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().

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

Definition at line 122 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

int EcalSelectiveReadoutProducer::trigPrimBypassMode_
private

Definition at line 124 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::trigPrimCollection_
private

Definition at line 114 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer().

std::string EcalSelectiveReadoutProducer::trigPrimProducer_
private

Definition at line 113 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 146 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 152 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 132 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().