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 template<class HCALDIGITIZERTRAITS>
25 {
26 public:
27  typedef typename HCALDIGITIZERTRAITS::Digi DIGI;
28  typedef typename HCALDIGITIZERTRAITS::DigiCollection COLLECTION;
29 
32 
33  virtual ~HcalSignalGenerator() {}
34 
35  void initializeEvent(const edm::Event * event, const edm::EventSetup * eventSetup)
36  {
37  theEvent = event;
38  eventSetup->get<HcalDbRecord>().get(theConditions);
39  theShape = theConditions->getHcalShape (); // this one is generic
41  }
42 
44  void initializeEvent(const edm::EventPrincipal * eventPrincipal, const edm::EventSetup * eventSetup)
45  {
46  theEventPrincipal = eventPrincipal;
47  eventSetup->get<HcalDbRecord>().get(theConditions);
48  theShape = theConditions->getHcalShape (); // this one is generic
50  }
51 
52  virtual void fill()
53  {
54  theNoiseSignals.clear();
56  const COLLECTION * digis = 0;
57  // try accessing by whatever is set, Event or EventPrincipal
58  if(theEvent)
59  {
60  if( theEvent->getByLabel(theInputTag, pDigis) ) {
61  digis = pDigis.product(); // get a ptr to the product
62  LogTrace("HcalSignalGenerator") << "total # digis for " << theInputTag << " " << digis->size();
63  }
64  else
65  {
66  throw cms::Exception("HcalSignalGenerator") << "Cannot find input data " << theInputTag;
67  }
68  }
69  else if(theEventPrincipal)
70  {
71  boost::shared_ptr<edm::Wrapper<COLLECTION> const> digisPTR =
72  edm::getProductByTag<COLLECTION>(*theEventPrincipal, theInputTag );
73  if(digisPTR) {
74  digis = digisPTR->product();
75  }
76  }
77  else
78  {
79  throw cms::Exception("HcalSignalGenerator") << "No Event or EventPrincipal was set";
80  }
81 
82  if (digis)
83  {
84  // loop over digis, adding these to the existing maps
85  for(typename COLLECTION::const_iterator it = digis->begin();
86  it != digis->end(); ++it)
87  {
88  // for the first signal, set the starting cap id
89  if((it == digis->begin()) && theElectronicsSim)
90  {
91  int startingCapId = (*it)[0].capid();
92  theElectronicsSim->setStartingCapId(startingCapId);
93  theParameterMap->setFrameSize(it->id(), it->size());
94  }
95 
96  theNoiseSignals.push_back(samplesInPE(*it));
97  }
98  }
99  }
100 
101 private:
102 
104  {
105  // calibration, for future reference: (same block for all Hcal types)
106  HcalDetId cell = digi.id();
107  // const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
108  const HcalQIECoder* channelCoder = theConditions->getHcalCoder (cell);
109  HcalCoderDb coder (*channelCoder, *theShape);
111  coder.adc2fC(digi, result);
112  fC2pe(result);
113  return result;
114  }
115 
116 
124 };
125 
130 
131 #endif
132 
edm::InputTag theInputTag
these come from the ParameterSet
void setStartingCapId(int startingCapId)
void fC2pe(CaloSamples &samples) const
HCALDIGITIZERTRAITS::Digi DIGI
std::vector< T >::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
const HcalQIEShape * theShape
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const
Definition: HcalCoderDb.cc:37
const edm::EventPrincipal * theEventPrincipal
HcalSignalGenerator< HFDigitizerTraits > HFSignalGenerator
tuple result
Definition: query.py:137
void setFrameSize(const DetId &detId, int frameSize)
HcalSimParameterMap * theParameterMap
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#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:74
HcalSignalGenerator< HODigitizerTraits > HOSignalGenerator
size_type size() const
HcalSignalGenerator< ZDCDigitizerTraits > ZDCSignalGenerator
HcalSignalGenerator< HBHEDigitizerTraits > HBHESignalGenerator
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
HcalSignalGenerator(const edm::InputTag &inputTag)
void initializeEvent(const edm::Event *event, const edm::EventSetup *eventSetup)
void setDbService(const HcalDbService *service)
const_iterator begin() const