CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSignalGenerator.h
Go to the documentation of this file.
1 #ifndef HcalSimAlgos_HcalSignalGenerator_h
2 #define HcalSimAlgos_HcalSignalGenerator_h
3 
16 
21 #include <iostream>
22 
23 namespace edm {
24  class ModuleCallingContext;
25 }
26 
27 template<class HCALDIGITIZERTRAITS>
29 {
30 public:
31  typedef typename HCALDIGITIZERTRAITS::Digi DIGI;
32  typedef typename HCALDIGITIZERTRAITS::DigiCollection COLLECTION;
33 
35 
38  { }
39 
40  virtual ~HcalSignalGenerator() {}
41 
42 
43  void initializeEvent(const edm::Event * event, const edm::EventSetup * eventSetup)
44  {
45  theEvent = event;
46  eventSetup->get<HcalDbRecord>().get(theConditions);
48  }
49 
51  void initializeEvent(const edm::EventPrincipal * eventPrincipal, const edm::EventSetup * eventSetup)
52  {
53  theEventPrincipal = eventPrincipal;
54  eventSetup->get<HcalDbRecord>().get(theConditions);
56  }
57 
58  virtual void fill(edm::ModuleCallingContext const* mcc)
59  {
60  theNoiseSignals.clear();
62  const COLLECTION * digis = 0;
63  // try accessing by whatever is set, Event or EventPrincipal
64  if(theEvent)
65  {
66  if( theEvent->getByToken(tok_, pDigis) ) {
67  digis = pDigis.product(); // get a ptr to the product
68  LogTrace("HcalSignalGenerator") << "total # digis for " << theInputTag << " " << digis->size();
69  }
70  else
71  {
72  throw cms::Exception("HcalSignalGenerator") << "Cannot find input data " << theInputTag;
73  }
74  }
75  else if(theEventPrincipal)
76  {
77  boost::shared_ptr<edm::Wrapper<COLLECTION> const> digisPTR =
78  edm::getProductByTag<COLLECTION>(*theEventPrincipal, theInputTag, mcc );
79  if(digisPTR) {
80  digis = digisPTR->product();
81  }
82  }
83  else
84  {
85  throw cms::Exception("HcalSignalGenerator") << "No Event or EventPrincipal was set";
86  }
87 
88  if (digis)
89  {
90  // loop over digis, adding these to the existing maps
91  for(typename COLLECTION::const_iterator it = digis->begin();
92  it != digis->end(); ++it)
93  {
94  // for the first signal, set the starting cap id
95  if((it == digis->begin()) && theElectronicsSim)
96  {
97  int startingCapId = (*it)[0].capid();
98  theElectronicsSim->setStartingCapId(startingCapId);
99  theParameterMap->setFrameSize(it->id(), it->size());
100  }
101 
102  theNoiseSignals.push_back(samplesInPE(*it));
103  }
104  }
105  }
106 
107 private:
108 
110  {
111  // calibration, for future reference: (same block for all Hcal types)
112  HcalDetId cell = digi.id();
113  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
114  const HcalQIECoder* channelCoder = theConditions->getHcalCoder (cell);
115  const HcalQIEShape* channelShape = theConditions->getHcalShape (cell);
116  HcalCoderDb coder (*channelCoder, *channelShape);
118  coder.adc2fC(digi, result);
119  fC2pe(result);
120  return result;
121  }
122 
123 
131 };
132 
137 
138 #endif
139 
edm::InputTag theInputTag
these come from the ParameterSet
void setStartingCapId(int startingCapId)
HcalSignalGenerator(const edm::InputTag &inputTag, const edm::EDGetTokenT< COLLECTION > &t)
void fC2pe(CaloSamples &samples) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
HCALDIGITIZERTRAITS::Digi DIGI
std::vector< HBHEDataFrame >::const_iterator const_iterator
HCALDIGITIZERTRAITS::DigiCollection COLLECTION
const edm::Event * theEvent
these fields are set in initializeEvent()
CaloSamples samplesInPE(const DIGI &digi)
void initializeEvent(const edm::EventPrincipal *eventPrincipal, const edm::EventSetup *eventSetup)
some users use EventPrincipals, not Events. We support both
edm::ESHandle< HcalDbService > theConditions
std::vector< CaloSamples > theNoiseSignals
virtual void fill(edm::ModuleCallingContext const *mcc)
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
Definition: HcalCoderDb.cc:44
const edm::EventPrincipal * theEventPrincipal
HcalSignalGenerator< HFDigitizerTraits > HFSignalGenerator
tuple result
Definition: query.py:137
void setFrameSize(const DetId &detId, int frameSize)
HcalSimParameterMap * theParameterMap
edm::EDGetTokenT< COLLECTION > tok_
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
#define LogTrace(id)
HcalElectronicsSim * theElectronicsSim
const_iterator end() const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
HcalSignalGenerator< HODigitizerTraits > HOSignalGenerator
size_type size() const
HcalSignalGenerator< ZDCDigitizerTraits > ZDCSignalGenerator
HcalSignalGenerator< HBHEDigitizerTraits > HBHESignalGenerator
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
void initializeEvent(const edm::Event *event, const edm::EventSetup *eventSetup)
void setDbService(const HcalDbService *service)
const_iterator begin() const