CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HcalSignalGenerator< Traits > Class Template Reference

#include <HcalSignalGenerator.h>

Inheritance diagram for HcalSignalGenerator< Traits >:
HcalBaseSignalGenerator CaloVNoiseSignalGenerator

Public Types

typedef Traits::DigiCollection COLLECTION
 
typedef Traits::Digi DIGI
 

Public Member Functions

virtual void fill (edm::ModuleCallingContext const *mcc)
 
 HcalSignalGenerator ()
 
 HcalSignalGenerator (const edm::InputTag &inputTag, const edm::EDGetTokenT< COLLECTION > &t)
 
void initializeEvent (const edm::Event *event, const edm::EventSetup *eventSetup, const edm::ESGetToken< HcalDbService, HcalDbRecord > &tok)
 
void initializeEvent (const edm::EventPrincipal *eventPrincipal, const edm::EventSetup *eventSetup, const edm::ESGetToken< HcalDbService, HcalDbRecord > &tok)
 some users use EventPrincipals, not Events. We support both More...
 
 ~HcalSignalGenerator () override
 
- Public Member Functions inherited from HcalBaseSignalGenerator
 HcalBaseSignalGenerator ()
 
void setElectronicsSim (HcalElectronicsSim *electronicsSim)
 
void setParameterMap (HcalSimParameterMap *map)
 
 ~HcalBaseSignalGenerator () override
 
- Public Member Functions inherited from CaloVNoiseSignalGenerator
 CaloVNoiseSignalGenerator ()
 
bool contains (const DetId &detId) const
 
void fillEvent (CLHEP::HepRandomEngine *)
 fill theNoiseSignals with one event's worth of noise, in units of pe More...
 
void fillEvent ()
 
void getNoiseSignals (std::vector< CaloSamples > &noiseSignals)
 
void setNoiseSignals (const std::vector< CaloSamples > &noiseSignals)
 
virtual ~CaloVNoiseSignalGenerator ()
 

Private Member Functions

virtual void fillDigis (const COLLECTION *digis)
 
void fillNoiseSignals (CLHEP::HepRandomEngine *) override
 
void fillNoiseSignals () override
 
CaloSamples samplesInPE (const DIGI &digi)
 
bool validDigi (const DIGI &digi)
 

Private Attributes

const HcalDbServicetheConditions
 
const edm::EventtheEvent
 these fields are set in initializeEvent() More...
 
const edm::EventPrincipaltheEventPrincipal
 
edm::InputTag theInputTag
 these come from the ParameterSet More...
 
edm::EDGetTokenT< COLLECTIONtok_
 

Additional Inherited Members

- Protected Member Functions inherited from HcalBaseSignalGenerator
void fC2pe (CaloSamples &samples) const
 
- Protected Attributes inherited from HcalBaseSignalGenerator
HcalElectronicsSimtheElectronicsSim
 
HcalSimParameterMaptheParameterMap
 
- Protected Attributes inherited from CaloVNoiseSignalGenerator
std::vector< CaloSamplestheNoiseSignals
 

Detailed Description

template<class Traits>
class HcalSignalGenerator< Traits >

Definition at line 30 of file HcalSignalGenerator.h.

Member Typedef Documentation

template<class Traits>
typedef Traits::DigiCollection HcalSignalGenerator< Traits >::COLLECTION

Definition at line 33 of file HcalSignalGenerator.h.

template<class Traits>
typedef Traits::Digi HcalSignalGenerator< Traits >::DIGI

Definition at line 32 of file HcalSignalGenerator.h.

Constructor & Destructor Documentation

template<class Traits>
HcalSignalGenerator< Traits >::HcalSignalGenerator ( )
inline
template<class Traits>
HcalSignalGenerator< Traits >::HcalSignalGenerator ( const edm::InputTag inputTag,
const edm::EDGetTokenT< COLLECTION > &  t 
)
inline

Definition at line 37 of file HcalSignalGenerator.h.

38  : HcalBaseSignalGenerator(), theEvent(nullptr), theEventPrincipal(nullptr), theInputTag(inputTag), tok_(t) {}
const edm::EventPrincipal * theEventPrincipal
const edm::Event * theEvent
these fields are set in initializeEvent()
edm::InputTag theInputTag
these come from the ParameterSet
edm::EDGetTokenT< COLLECTION > tok_
template<class Traits>
HcalSignalGenerator< Traits >::~HcalSignalGenerator ( )
inlineoverride

Definition at line 40 of file HcalSignalGenerator.h.

40 {}

Member Function Documentation

template<class Traits>
virtual void HcalSignalGenerator< Traits >::fill ( edm::ModuleCallingContext const *  mcc)
inlinevirtual

Definition at line 59 of file HcalSignalGenerator.h.

Referenced by edm::DataMixingHcalDigiWorkerProd::addHcalPileups(), and PreMixingHcalWorker::addPileups().

59  {
60  theNoiseSignals.clear();
62  const COLLECTION* digis = nullptr;
63  // try accessing by whatever is set, Event or EventPrincipal
64  if (theEvent) {
65  if (theEvent->getByToken(tok_, pDigis)) {
66  digis = pDigis.product(); // get a ptr to the product
67  LogTrace("HcalSignalGenerator") << "total # digis for " << theInputTag << " " << digis->size();
68  } else {
69  throw cms::Exception("HcalSignalGenerator") << "Cannot find input data " << theInputTag;
70  }
71  } else if (theEventPrincipal) {
72  std::shared_ptr<edm::Wrapper<COLLECTION> const> digisPTR =
73  edm::getProductByTag<COLLECTION>(*theEventPrincipal, theInputTag, mcc);
74  if (digisPTR) {
75  digis = digisPTR->product();
76  }
77  } else {
78  throw cms::Exception("HcalSignalGenerator") << "No Event or EventPrincipal was set";
79  }
80 
81  if (digis)
82  fillDigis(digis);
83  }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const edm::EventPrincipal * theEventPrincipal
#define LogTrace(id)
std::vector< CaloSamples > theNoiseSignals
const edm::Event * theEvent
these fields are set in initializeEvent()
T const * product() const
Definition: Handle.h:70
Traits::DigiCollection COLLECTION
edm::InputTag theInputTag
these come from the ParameterSet
virtual void fillDigis(const COLLECTION *digis)
edm::EDGetTokenT< COLLECTION > tok_
template<class Traits>
virtual void HcalSignalGenerator< Traits >::fillDigis ( const COLLECTION digis)
inlineprivatevirtual

Definition at line 86 of file HcalSignalGenerator.h.

Referenced by HcalSignalGenerator< HBHEDigitizerTraits >::fill().

86  {
87  // loop over digis, adding these to the existing maps
88  for (typename COLLECTION::const_iterator it = digis->begin(); it != digis->end(); ++it) {
89  // for the first signal, set the starting cap id
90  if ((it == digis->begin()) && theElectronicsSim) {
91  int startingCapId = (*it)[0].capid();
92  theElectronicsSim->setStartingCapId(startingCapId);
93  // theParameterMap->setFrameSize(it->id(), it->size()); //don't need this
94  }
95  if (validDigi(*it)) {
96  theNoiseSignals.push_back(samplesInPE(*it));
97  }
98  }
99  }
CaloSamples samplesInPE(const DIGI &digi)
void setStartingCapId(int startingCapId)
bool validDigi(const DIGI &digi)
std::vector< CaloSamples > theNoiseSignals
HcalElectronicsSim * theElectronicsSim
template<class Traits>
void HcalSignalGenerator< Traits >::fillNoiseSignals ( CLHEP::HepRandomEngine *  )
inlineoverrideprivatevirtual

if you want to fill signals on demand, override this subclass is responsible for clearing theNoiseSignals before adding

Implements CaloVNoiseSignalGenerator.

Definition at line 101 of file HcalSignalGenerator.h.

101 {}
template<class Traits>
void HcalSignalGenerator< Traits >::fillNoiseSignals ( )
inlineoverrideprivatevirtual

Implements CaloVNoiseSignalGenerator.

Definition at line 102 of file HcalSignalGenerator.h.

102 {}
template<class Traits>
void HcalSignalGenerator< Traits >::initializeEvent ( const edm::Event event,
const edm::EventSetup eventSetup,
const edm::ESGetToken< HcalDbService, HcalDbRecord > &  tok 
)
inline

Definition at line 42 of file HcalSignalGenerator.h.

Referenced by edm::DataMixingHcalDigiWorkerProd::addHcalPileups(), and PreMixingHcalWorker::addPileups().

44  {
45  theEvent = event;
46  theConditions = &(eventSetup->getData(tok));
48  }
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::Event * theEvent
these fields are set in initializeEvent()
HcalSimParameterMap * theParameterMap
void setDbService(const HcalDbService *service)
const HcalDbService * theConditions
template<class Traits>
void HcalSignalGenerator< Traits >::initializeEvent ( const edm::EventPrincipal eventPrincipal,
const edm::EventSetup eventSetup,
const edm::ESGetToken< HcalDbService, HcalDbRecord > &  tok 
)
inline

some users use EventPrincipals, not Events. We support both

Definition at line 51 of file HcalSignalGenerator.h.

53  {
54  theEventPrincipal = eventPrincipal;
55  theConditions = &(eventSetup->getData(tok));
57  }
const edm::EventPrincipal * theEventPrincipal
bool getData(T &iHolder) const
Definition: EventSetup.h:128
HcalSimParameterMap * theParameterMap
void setDbService(const HcalDbService *service)
const HcalDbService * theConditions
template<class Traits>
CaloSamples HcalSignalGenerator< Traits >::samplesInPE ( const DIGI digi)
inlineprivate

Definition at line 113 of file HcalSignalGenerator.h.

Referenced by HcalSignalGenerator< HBHEDigitizerTraits >::fillDigis().

113  {
114  // For PreMixing, (Note that modifications will need to be made for DataMixing) the
115  // energy for each channel is kept as fC*10, but stored as an integer in ADC. If this
116  // results in an overflow, the "standard" ADC conversion is used and that channel is marked
117  // with an error that allows the "standard" decoding to convert ADC back to fC. So, most
118  // channels get to fC by just dividing ADC/10; some require special treatment.
119 
120  // calibration, for future reference: (same block for all Hcal types)
121  HcalDetId cell = digi.id();
122  CaloSamples result = CaloSamples(cell, digi.size());
123 
124  // first, check if there was an overflow in this fake digi:
125  bool overflow = false;
126  // find and list them
127 
128  for (int isample = 0; isample < digi.size(); ++isample) {
129  if (digi[isample].er())
130  overflow = true;
131  }
132 
133  if (overflow) { // do full conversion, go back and overwrite fake entries
134 
135  const HcalQIECoder* channelCoder = theConditions->getHcalCoder(cell);
136  const HcalQIEShape* channelShape = theConditions->getHcalShape(cell);
137  HcalCoderDb coder(*channelCoder, *channelShape);
138  coder.adc2fC(digi, result);
139 
140  // overwrite with coded information
141  for (int isample = 0; isample < digi.size(); ++isample) {
142  if (!digi[isample].er())
143  result[isample] = float(digi[isample].adc()) / Traits::PreMixFactor;
144  }
145  } else { // saves creating the coder, etc., every time
146  // use coded information
147  for (int isample = 0; isample < digi.size(); ++isample) {
148  result[isample] = float(digi[isample].adc()) / Traits::PreMixFactor;
149  }
150  result.setPresamples(digi.presamples());
151  }
152 
153  // translation done in fC, convert to pe:
154  fC2pe(result);
155 
156  return result;
157  }
void fC2pe(CaloSamples &samples) const
tuple result
Definition: mps_fire.py:311
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:33
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc
const HcalDbService * theConditions
template<class Traits>
bool HcalSignalGenerator< Traits >::validDigi ( const DIGI digi)
inlineprivate

Definition at line 104 of file HcalSignalGenerator.h.

Referenced by HcalSignalGenerator< HBHEDigitizerTraits >::fillDigis().

104  {
105  int DigiSum = 0;
106  for (int id = 0; id < digi.size(); id++) {
107  if (digi[id].adc() > 0)
108  ++DigiSum;
109  }
110  return (DigiSum > 0);
111  }
uint16_t *__restrict__ uint16_t const *__restrict__ adc

Member Data Documentation

template<class Traits>
const HcalDbService* HcalSignalGenerator< Traits >::theConditions
private
template<class Traits>
const edm::Event* HcalSignalGenerator< Traits >::theEvent
private
template<class Traits>
const edm::EventPrincipal* HcalSignalGenerator< Traits >::theEventPrincipal
private
template<class Traits>
edm::InputTag HcalSignalGenerator< Traits >::theInputTag
private

these come from the ParameterSet

Definition at line 164 of file HcalSignalGenerator.h.

Referenced by HcalSignalGenerator< HBHEDigitizerTraits >::fill().

template<class Traits>
edm::EDGetTokenT<COLLECTION> HcalSignalGenerator< Traits >::tok_
private