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
 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
 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
 
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_
 
std::string ebdigiCollection_
 
std::string ebSrFlagCollection_
 
std::string ebSRPdigiCollection_
 
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 writeSrFlags_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 17 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_, ebdigiCollection_, ebSrFlagCollection_, ebSRPdigiCollection_, 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_, 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  theGeometry = 0;
70  theElecMap = 0;
71 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static void importParameterSet(EcalSRSettings &sr, const edm::ParameterSet &ps)
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
const EcalElectronicsMapping * theElecMap
std::auto_ptr< EcalSRSettings > settingsFromFile_
EcalSelectiveReadoutProducer::~EcalSelectiveReadoutProducer ( )
virtual

Destructor

Definition at line 75 of file EcalSelectiveReadoutProducer.cc.

76 { }

Member Function Documentation

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

Definition at line 243 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

244 {
245 
247  eventSetup.get<EcalMappingRcd>().get(eElecmap);
248 
249  const EcalElectronicsMapping * pMap = &*eElecmap;
250 
251  // see if we need to update
252  if(pMap!= theElecMap) {
253  theElecMap = pMap;
254  suppressor_->setElecMap(theElecMap);
255  }
256 }
const EcalElectronicsMapping * theElecMap
std::auto_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const T & get() const
Definition: EventSetup.h:55
void EcalSelectiveReadoutProducer::checkGeometry ( const edm::EventSetup eventSetup)
private

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

Definition at line 212 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

213 {
214  edm::ESHandle<CaloGeometry> hGeometry;
215  eventSetup.get<CaloGeometryRecord>().get(hGeometry);
216 
217  const CaloGeometry * pGeometry = &*hGeometry;
218 
219  // see if we need to update
220  if(pGeometry != theGeometry) {
221  theGeometry = pGeometry;
222  suppressor_->setGeometry(theGeometry);
223  }
224 }
std::auto_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const T & get() const
Definition: EventSetup.h:55
void EcalSelectiveReadoutProducer::checkTriggerMap ( const edm::EventSetup eventSetup)
private

Definition at line 227 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

228 {
229 
231  eventSetup.get<IdealGeometryRecord>().get(eTTmap);
232 
233  const EcalTrigTowerConstituentsMap * pMap = &*eTTmap;
234 
235  // see if we need to update
236  if(pMap!= theTriggerTowerMap) {
237  theTriggerTowerMap = pMap;
238  suppressor_->setTriggerMap(theTriggerTowerMap);
239  }
240 }
const EcalTrigTowerConstituentsMap * theTriggerTowerMap
std::auto_ptr< EcalSelectiveReadoutSuppressor > suppressor_
const T & get() const
Definition: EventSetup.h:55
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 edm::hlt::Exception.

Referenced by produce().

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

296  {
297  const vector<float> & weights = settings_->dccNormalizedWeights_[0]; //params_.getParameter<vector<double> >("dccNormalizedWeights");
299  static std::atomic<bool> warnWeightCnt{true};
300  bool expected = true;
301  if((int)weights.size() > nFIRTaps && warnWeightCnt.compare_exchange_strong(expected,false,std::memory_order_acq_rel)){
302  edm::LogWarning("Configuration") << "The list of DCC zero suppression FIR "
303  "weights given in parameter dccNormalizedWeights is longer "
304  "than the expected depth of the FIR filter :(" << nFIRTaps << "). "
305  "The last weights will be discarded.";
306  }
307 
308  if(weights.size()>0){
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")
329  << "The maximum weight of DCC zero suppression FIR filter is not "
330  "applied to the expected maximum sample(" << binOfMax
331  << (binOfMax==1?"st":(binOfMax==2?"nd":(binOfMax==3?"rd":"th")))
332  << " time sample). This may indicate faulty 'dccNormalizedWeights' "
333  "or 'ecalDccZs1sSample' parameters.";
334  }
335  }
336 }
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 339 of file EcalSelectiveReadoutProducer.cc.

References spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::Event::getProvenance(), AlCaHLTBitMon_ParallelJobs::p, edm::parameterSet(), and query::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)
348  != ebDigiParamList.end()){//bofm found
349  binOfMax=result.getParameter<int>("binOfMaximum");
350  rc = true;
351  } else{
352  rc = false;
353  }
354  return rc;
355 }
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: query.py:137
std::vector< std::string > getParameterNames() const
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:76
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis ( edm::Event event) const
private

Definition at line 172 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), digiProducer_, ebdigiCollection_, edm::HandleBase::id(), edm::Handle< T >::product(), and query::result.

Referenced by produce().

173 {
175  event.getByLabel(digiProducer_, ebdigiCollection_, hEBDigis);
176  //product() method is called before id() in order to get an exception
177  //if the handle is not available (check not done by id() method).
178  const EBDigiCollection* result = hEBDigis.product();
179  static bool firstCall= true;
180  if(firstCall){
181  checkWeights(event, hEBDigis.id());
182  firstCall = false;
183  }
184  return result;
185 }
ProductID id() const
Definition: HandleBase.cc:15
tuple result
Definition: query.py:137
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 188 of file EcalSelectiveReadoutProducer.cc.

References checkWeights(), digiProducer_, eedigiCollection_, edm::HandleBase::id(), edm::Handle< T >::product(), and query::result.

Referenced by produce().

189 {
191  event.getByLabel(digiProducer_, eedigiCollection_, 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  static bool firstCall = true;
196  if(firstCall){
197  checkWeights(event, hEEDigis.id());
198  firstCall = false;
199  }
200  return result;
201 }
ProductID id() const
Definition: HandleBase.cc:15
tuple result
Definition: query.py:137
void checkWeights(const edm::Event &evt, const edm::ProductID &noZSDigiId) const
T const * product() const
Definition: Handle.h:81
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims ( edm::Event event) const
private

Definition at line 204 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

205 {
207  event.getByLabel(trigPrimProducer_, trigPrimCollection_, hTPDigis);
208  return hTPDigis.product();
209 }
T const * product() const
Definition: Handle.h:81
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 358 of file EcalSelectiveReadoutProducer.cc.

References 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, cond::rpcobgas::time, EcalSrFlag::value(), and EcalScDetId::zside().

Referenced by produce().

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

Definition at line 259 of file EcalSelectiveReadoutProducer.cc.

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

259  {
260  const char tccFlagMarker[] = { 'x', '.', 'S', '?', 'C', 'E', 'E', 'E', 'E'};
263 
264  //static bool firstCall=true;
265  // if(firstCall){
266  // firstCall=false;
267  os << "# TCC flag map\n#\n"
268  "# +-->Phi " << tccFlagMarker[0+1] << ": 000 (low interest)\n"
269  "# | " << tccFlagMarker[1+1] << ": 001 (mid interest)\n"
270  "# | " << tccFlagMarker[2+1] << ": 010 (not valid)\n"
271  "# V Eta " << tccFlagMarker[3+1] << ": 011 (high interest)\n"
272  "# " << tccFlagMarker[4+1] << ": 1xx forced readout (Hw error)\n"
273  "#\n";
274  //}
275 
276  vector<vector<int> > ttf(nEta, vector<int>(nPhi, -1));
278  it != tp.end(); ++it){
279  const EcalTriggerPrimitiveDigi& trigPrim = *it;
280  if(trigPrim.size()>0){
281  int iEta = trigPrim.id().ieta();
282  int iEta0 = iEta<0?iEta+nEta/2:iEta+nEta/2-1;
283  int iPhi0 = trigPrim.id().iphi() - 1;
284  ttf[iEta0][iPhi0] = trigPrim.ttFlag();
285  }
286  }
287  for(int iEta=0; iEta<nEta; ++iEta){
288  for(int iPhi=0; iPhi<nPhi; ++iPhi){
289  os << tccFlagMarker[ttf[iEta][iPhi]+1];
290  }
291  os << "\n";
292  }
293 }
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
const char tccFlagMarker[]
Definition: GenABIO.cc:189
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 80 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_, and writeSrFlags_.

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

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

Definition at line 127 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::ebdigiCollection_
private

Definition at line 106 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEBDigis().

std::string EcalSelectiveReadoutProducer::ebSrFlagCollection_
private

Definition at line 110 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::ebSRPdigiCollection_
private

Definition at line 108 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::eedigiCollection_
private

Definition at line 107 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getEEDigis().

std::string EcalSelectiveReadoutProducer::eeSrFlagCollection_
private

Definition at line 111 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::eeSRPdigiCollection_
private

Definition at line 109 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

edm::ParameterSet EcalSelectiveReadoutProducer::params_
private

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

Referenced by EcalSelectiveReadoutProducer(), and produce().

const EcalSRSettings* EcalSelectiveReadoutProducer::settings_
private

SR settings

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

Referenced by EcalSelectiveReadoutProducer().

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

Definition at line 118 of file EcalSelectiveReadoutProducer.h.

Referenced by checkElecMap(), and EcalSelectiveReadoutProducer().

const CaloGeometry* EcalSelectiveReadoutProducer::theGeometry
private

Definition at line 116 of file EcalSelectiveReadoutProducer.h.

Referenced by checkGeometry(), and EcalSelectiveReadoutProducer().

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

Definition at line 121 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

int EcalSelectiveReadoutProducer::trigPrimBypassMode_
private

Definition at line 123 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and produce().

std::string EcalSelectiveReadoutProducer::trigPrimCollection_
private

Definition at line 113 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

std::string EcalSelectiveReadoutProducer::trigPrimProducer_
private

Definition at line 112 of file EcalSelectiveReadoutProducer.h.

Referenced by EcalSelectiveReadoutProducer(), and getTrigPrims().

bool EcalSelectiveReadoutProducer::useCondDb_
private

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

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

Referenced by EcalSelectiveReadoutProducer(), and produce().