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::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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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 19 of file EcalSelectiveReadoutProducer.cc.

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

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

74 { }

Member Function Documentation

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

Definition at line 241 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

242 {
243 
245  eventSetup.get<EcalMappingRcd>().get(eElecmap);
246 
247  const EcalElectronicsMapping * pMap = &*eElecmap;
248 
249  // see if we need to update
250  if(pMap!= theElecMap) {
251  theElecMap = pMap;
252  suppressor_->setElecMap(theElecMap);
253  }
254 }
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 210 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

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

Definition at line 225 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

226 {
227 
229  eventSetup.get<IdealGeometryRecord>().get(eTTmap);
230 
231  const EcalTrigTowerConstituentsMap * pMap = &*eTTmap;
232 
233  // see if we need to update
234  if(pMap!= theTriggerTowerMap) {
235  theTriggerTowerMap = pMap;
236  suppressor_->setTriggerMap(theTriggerTowerMap);
237  }
238 }
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 494 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

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

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

References spr::find(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::getParameterSet(), edm::Event::getProvenance(), AlCaHLTBitMon_ParallelJobs::p, edm::Provenance::psetID(), and query::result.

Referenced by checkWeights().

339  {
340  bool rc;
341  const edm::Provenance p=evt.getProvenance(noZsDigiId);
343  vector<string> ebDigiParamList = result.getParameterNames();
344  string bofm("binOfMaximum");
345  if(find(ebDigiParamList.begin(), ebDigiParamList.end(), bofm)
346  != ebDigiParamList.end()){//bofm found
347  binOfMax=result.getParameter<int>("binOfMaximum");
348  rc = true;
349  } else{
350  rc = false;
351  }
352  return rc;
353 }
T getParameter(std::string const &) const
ParameterSet const & getParameterSet(ParameterSetID const &id)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
ParameterSetID psetID() const
Definition: Provenance.cc:76
tuple result
Definition: query.py:137
std::vector< std::string > getParameterNames() const
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:60
const EBDigiCollection * EcalSelectiveReadoutProducer::getEBDigis ( edm::Event event) const
private

Definition at line 170 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

171 {
173  event.getByLabel(digiProducer_, ebdigiCollection_, hEBDigis);
174  //product() method is called before id() in order to get an exception
175  //if the handle is not available (check not done by id() method).
176  const EBDigiCollection* result = hEBDigis.product();
177  static bool firstCall= true;
178  if(firstCall){
179  checkWeights(event, hEBDigis.id());
180  firstCall = false;
181  }
182  return result;
183 }
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:74
const EEDigiCollection * EcalSelectiveReadoutProducer::getEEDigis ( edm::Event event) const
private

Definition at line 186 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

187 {
189  event.getByLabel(digiProducer_, eedigiCollection_, hEEDigis);
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 EEDigiCollection* result = hEEDigis.product();
193  static bool firstCall = true;
194  if(firstCall){
195  checkWeights(event, hEEDigis.id());
196  firstCall = false;
197  }
198  return result;
199 }
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:74
const EcalTrigPrimDigiCollection * EcalSelectiveReadoutProducer::getTrigPrims ( edm::Event event) const
private

Definition at line 202 of file EcalSelectiveReadoutProducer.cc.

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

Referenced by produce().

203 {
205  event.getByLabel(trigPrimProducer_, trigPrimCollection_, hTPDigis);
206  return hTPDigis.product();
207 }
T const * product() const
Definition: Handle.h:74
void EcalSelectiveReadoutProducer::printSrFlags ( std::ostream &  os,
const EBSrFlagCollection ebSrFlags,
const EESrFlagCollection eeSrFlags,
int  iEvent = -1,
bool  withHeader = true 
)
static

Help function to print SR flags.

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

Definition at line 356 of file EcalSelectiveReadoutProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), 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().

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

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

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