CMS 3D CMS Logo

HcalSignalGenerator.h
Go to the documentation of this file.
1 #ifndef HcalSimAlgos_HcalSignalGenerator_h
2 #define HcalSimAlgos_HcalSignalGenerator_h
3 
19 
24 #include <iostream>
25 
26 namespace edm {
27  class ModuleCallingContext;
28 }
29 
30 template <class Traits>
32 public:
33  typedef typename Traits::Digi DIGI;
35 
37 
40 
41  ~HcalSignalGenerator() override {}
42 
43  void initializeEvent(const edm::Event* event, const edm::EventSetup* eventSetup) {
44  theEvent = event;
45  eventSetup->get<HcalDbRecord>().get(theConditions);
47  }
48 
50  void initializeEvent(const edm::EventPrincipal* eventPrincipal, const edm::EventSetup* eventSetup) {
51  theEventPrincipal = eventPrincipal;
52  eventSetup->get<HcalDbRecord>().get(theConditions);
54  }
55 
56  virtual void fill(edm::ModuleCallingContext const* mcc) {
57  theNoiseSignals.clear();
59  const COLLECTION* digis = nullptr;
60  // try accessing by whatever is set, Event or EventPrincipal
61  if (theEvent) {
62  if (theEvent->getByToken(tok_, pDigis)) {
63  digis = pDigis.product(); // get a ptr to the product
64  LogTrace("HcalSignalGenerator") << "total # digis for " << theInputTag << " " << digis->size();
65  } else {
66  throw cms::Exception("HcalSignalGenerator") << "Cannot find input data " << theInputTag;
67  }
68  } else if (theEventPrincipal) {
69  std::shared_ptr<edm::Wrapper<COLLECTION> const> digisPTR =
70  edm::getProductByTag<COLLECTION>(*theEventPrincipal, theInputTag, mcc);
71  if (digisPTR) {
72  digis = digisPTR->product();
73  }
74  } else {
75  throw cms::Exception("HcalSignalGenerator") << "No Event or EventPrincipal was set";
76  }
77 
78  if (digis)
79  fillDigis(digis);
80  }
81 
82 private:
83  virtual void fillDigis(const COLLECTION* digis) {
84  // loop over digis, adding these to the existing maps
85  for (typename COLLECTION::const_iterator it = digis->begin(); it != digis->end(); ++it) {
86  // for the first signal, set the starting cap id
87  if ((it == digis->begin()) && theElectronicsSim) {
88  int startingCapId = (*it)[0].capid();
89  theElectronicsSim->setStartingCapId(startingCapId);
90  // theParameterMap->setFrameSize(it->id(), it->size()); //don't need this
91  }
92  if (validDigi(*it)) {
93  theNoiseSignals.push_back(samplesInPE(*it));
94  }
95  }
96  }
97 
98  void fillNoiseSignals(CLHEP::HepRandomEngine*) override {}
99  void fillNoiseSignals() override {}
100 
101  bool validDigi(const DIGI& digi) {
102  int DigiSum = 0;
103  for (int id = 0; id < digi.size(); id++) {
104  if (digi[id].adc() > 0)
105  ++DigiSum;
106  }
107  return (DigiSum > 0);
108  }
109 
110  CaloSamples samplesInPE(const DIGI& digi) {
111  // For PreMixing, (Note that modifications will need to be made for DataMixing) the
112  // energy for each channel is kept as fC*10, but stored as an integer in ADC. If this
113  // results in an overflow, the "standard" ADC conversion is used and that channel is marked
114  // with an error that allows the "standard" decoding to convert ADC back to fC. So, most
115  // channels get to fC by just dividing ADC/10; some require special treatment.
116 
117  // calibration, for future reference: (same block for all Hcal types)
118  HcalDetId cell = digi.id();
119  CaloSamples result = CaloSamples(cell, digi.size());
120 
121  // first, check if there was an overflow in this fake digi:
122  bool overflow = false;
123  // find and list them
124 
125  for (int isample = 0; isample < digi.size(); ++isample) {
126  if (digi[isample].er())
127  overflow = true;
128  }
129 
130  if (overflow) { // do full conversion, go back and overwrite fake entries
131 
132  const HcalQIECoder* channelCoder = theConditions->getHcalCoder(cell);
133  const HcalQIEShape* channelShape = theConditions->getHcalShape(cell);
134  HcalCoderDb coder(*channelCoder, *channelShape);
135  coder.adc2fC(digi, result);
136 
137  // overwrite with coded information
138  for (int isample = 0; isample < digi.size(); ++isample) {
139  if (!digi[isample].er())
140  result[isample] = float(digi[isample].adc()) / Traits::PreMixFactor;
141  }
142  } else { // saves creating the coder, etc., every time
143  // use coded information
144  for (int isample = 0; isample < digi.size(); ++isample) {
145  result[isample] = float(digi[isample].adc()) / Traits::PreMixFactor;
146  }
147  result.setPresamples(digi.presamples());
148  }
149 
150  // translation done in fC, convert to pe:
151  fC2pe(result);
152 
153  return result;
154  }
155 
163 };
164 
165 //forward declarations of specializations
166 template <>
169 template <>
172 template <>
175 template <>
178 template <>
181 template <>
184 
191 
192 #endif
HcalBaseSignalGenerator::fC2pe
void fC2pe(CaloSamples &samples) const
Definition: HcalBaseSignalGenerator.h:20
HcalSignalGenerator::COLLECTION
Traits::DigiCollection COLLECTION
Definition: HcalSignalGenerator.h:34
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
Handle.h
HcalCalibrations.h
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
edm::EDGetTokenT< COLLECTION >
edm
HLT enums.
Definition: AlignableModifier.h:19
TrendClient_cfi.Digi
Digi
Definition: TrendClient_cfi.py:7
HcalSignalGenerator::samplesInPE
CaloSamples samplesInPE(const DIGI &digi)
Definition: HcalSignalGenerator.h:110
HcalCoderDb::adc2fC
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
Definition: HcalCoderDb.cc:73
HcalSignalGenerator::initializeEvent
void initializeEvent(const edm::Event *event, const edm::EventSetup *eventSetup)
Definition: HcalSignalGenerator.h:43
QIE10SignalGenerator
HcalSignalGenerator< HcalQIE10DigitizerTraits > QIE10SignalGenerator
Definition: HcalSignalGenerator.h:189
HcalElectronicsSim::setStartingCapId
void setStartingCapId(int startingCapId)
Definition: HcalElectronicsSim.cc:163
HcalSignalGenerator::tok_
edm::EDGetTokenT< COLLECTION > tok_
Definition: HcalSignalGenerator.h:162
QIE11SignalGenerator
HcalSignalGenerator< HcalQIE11DigitizerTraits > QIE11SignalGenerator
Definition: HcalSignalGenerator.h:190
edm::Handle
Definition: AssociativeIterator.h:50
HcalSimParameterMap::setDbService
void setDbService(const HcalDbService *service)
Definition: HcalSimParameterMap.cc:57
HcalDbService::getHcalShape
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:326
HcalCoderDb.h
HcalDigitizerTraits.h
HFSignalGenerator
HcalSignalGenerator< HFDigitizerTraits > HFSignalGenerator
Definition: HcalSignalGenerator.h:187
HcalDbService::getHcalCoder
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:319
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EventPrincipal.h
HcalSignalGenerator::HcalSignalGenerator
HcalSignalGenerator(const edm::InputTag &inputTag, const edm::EDGetTokenT< COLLECTION > &t)
Definition: HcalSignalGenerator.h:38
HcalBaseSignalGenerator::theParameterMap
HcalSimParameterMap * theParameterMap
Definition: HcalBaseSignalGenerator.h:26
CaloVNoiseSignalGenerator::theNoiseSignals
std::vector< CaloSamples > theNoiseSignals
Definition: CaloVNoiseSignalGenerator.h:34
HcalBaseSignalGenerator.h
edm::ESHandle< HcalDbService >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
HcalSignalGenerator::theInputTag
edm::InputTag theInputTag
these come from the ParameterSet
Definition: HcalSignalGenerator.h:161
HcalDbRecord.h
OrderedSet.t
t
Definition: OrderedSet.py:90
HcalSignalGenerator::DIGI
Traits::Digi DIGI
Definition: HcalSignalGenerator.h:33
HcalBaseSignalGenerator::theElectronicsSim
HcalElectronicsSim * theElectronicsSim
Definition: HcalBaseSignalGenerator.h:27
HcalSignalGenerator::validDigi
bool validDigi(const DIGI &digi)
Definition: HcalSignalGenerator.h:101
HcalSignalGenerator
Definition: HcalSignalGenerator.h:31
Event.h
HOSignalGenerator
HcalSignalGenerator< HODigitizerTraits > HOSignalGenerator
Definition: HcalSignalGenerator.h:186
HcalDetId
Definition: HcalDetId.h:12
edm::EventSetup
Definition: EventSetup.h:57
CaloSamples
Definition: CaloSamples.h:14
HcalSubdetector.h
get
#define get
HBHESignalGenerator
HcalSignalGenerator< HBHEDigitizerTraits > HBHESignalGenerator
Definition: HcalSignalGenerator.h:185
HcalQIECoder
Definition: HcalQIECoder.h:20
HcalQIE1011Traits.h
siStripShotFilter_cfi.DigiCollection
DigiCollection
Definition: siStripShotFilter_cfi.py:6
HcalSignalGenerator::theEvent
const edm::Event * theEvent
these fields are set in initializeEvent()
Definition: HcalSignalGenerator.h:157
HcalSignalGenerator::theConditions
edm::ESHandle< HcalDbService > theConditions
Definition: HcalSignalGenerator.h:159
HcalSignalGenerator::fillDigis
virtual void fillDigis(const COLLECTION *digis)
Definition: HcalSignalGenerator.h:83
Exception
Definition: hltDiff.cc:246
HcalElectronicsSim.h
HcalSignalGenerator::theEventPrincipal
const edm::EventPrincipal * theEventPrincipal
Definition: HcalSignalGenerator.h:158
EventSetup.h
HcalQIEShape
Definition: HcalQIEShape.h:17
HcalCoderDb
Definition: HcalCoderDb.h:15
HcalDbService.h
ZDCSignalGenerator
HcalSignalGenerator< ZDCDigitizerTraits > ZDCSignalGenerator
Definition: HcalSignalGenerator.h:188
HcalSignalGenerator::~HcalSignalGenerator
~HcalSignalGenerator() override
Definition: HcalSignalGenerator.h:41
mps_fire.result
result
Definition: mps_fire.py:303
HcalSignalGenerator::fill
virtual void fill(edm::ModuleCallingContext const *mcc)
Definition: HcalSignalGenerator.h:56
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
HcalDbRecord
Definition: HcalDbRecord.h:30
HcalBaseSignalGenerator
Definition: HcalBaseSignalGenerator.h:8
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
HcalSignalGenerator::initializeEvent
void initializeEvent(const edm::EventPrincipal *eventPrincipal, const edm::EventSetup *eventSetup)
some users use EventPrincipals, not Events. We support both
Definition: HcalSignalGenerator.h:50
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
HcalSignalGenerator::fillNoiseSignals
void fillNoiseSignals() override
Definition: HcalSignalGenerator.h:99
event
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of "!*" before the partial wildcard feature was incorporated). The per-event "cost" of each negative criterion with multiple relevant triggers is about the same as ! *was in the past
edm::InputTag
Definition: InputTag.h:15
HcalSignalGenerator::fillNoiseSignals
void fillNoiseSignals(CLHEP::HepRandomEngine *) override
Definition: HcalSignalGenerator.h:98
HcalSignalGenerator::HcalSignalGenerator
HcalSignalGenerator()
Definition: HcalSignalGenerator.h:36
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29