CMS 3D CMS Logo

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

#include <CaloTDigitizer.h>

Public Types

typedef Traits::Digi Digi
 
typedef Traits::DigiCollection DigiCollection
 
typedef Traits::ElectronicsSim ElectronicsSim
 

Public Member Functions

void add (const std::vector< PCaloHit > &hits, int bunchCrossing)
 
void addNoiseHits ()
 
void addNoiseSignals ()
 
 CaloTDigitizer (CaloHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)
 
const std::vector< DetId > & detIds () const
 tell the digitizer which cells exist More...
 
void initializeHits ()
 
void run (MixCollection< PCaloHit > &, DigiCollection &)
 turns hits into digis More...
 
void run (DigiCollection &output)
 Collects the digis. More...
 
void setDetIds (const std::vector< DetId > &detIds)
 
void setNoiseHitGenerator (CaloVNoiseHitGenerator *generator)
 
void setNoiseSignalGenerator (CaloVNoiseSignalGenerator *generator)
 
void setRandomEngine (CLHEP::HepRandomEngine &engine)
 
 ~CaloTDigitizer ()
 doesn't delete the pointers passed in More...
 

Private Attributes

bool addNoise_
 
const std::vector< DetId > * theDetIds
 
ElectronicsSimtheElectronicsSim
 
CaloHitResponsetheHitResponse
 
CaloVNoiseHitGeneratortheNoiseHitGenerator
 
CaloVNoiseSignalGeneratortheNoiseSignalGenerator
 

Detailed Description

template<class Traits>
class CaloTDigitizer< Traits >

Turns hits into digis. Assumes that there's an ElectroncsSim class with the interface analogToDigital(const CaloSamples &, Digi &);

Definition at line 18 of file CaloTDigitizer.h.

Member Typedef Documentation

template<class Traits >
typedef Traits::Digi CaloTDigitizer< Traits >::Digi

Definition at line 25 of file CaloTDigitizer.h.

template<class Traits >
typedef Traits::DigiCollection CaloTDigitizer< Traits >::DigiCollection

Definition at line 26 of file CaloTDigitizer.h.

template<class Traits >
typedef Traits::ElectronicsSim CaloTDigitizer< Traits >::ElectronicsSim

these are the types that need to be defined in the Traits class. The ElectronicsSim needs to have an interface that you'll see in the run() method

Definition at line 24 of file CaloTDigitizer.h.

Constructor & Destructor Documentation

template<class Traits >
CaloTDigitizer< Traits >::CaloTDigitizer ( CaloHitResponse hitResponse,
ElectronicsSim electronicsSim,
bool  addNoise 
)
inline

Definition at line 28 of file CaloTDigitizer.h.

29  : theHitResponse(hitResponse),
32  theElectronicsSim(electronicsSim),
33  theDetIds(0),
34  addNoise_(addNoise)
35  {
36  }
CaloVNoiseHitGenerator * theNoiseHitGenerator
CaloVNoiseSignalGenerator * theNoiseSignalGenerator
CaloHitResponse * theHitResponse
ElectronicsSim * theElectronicsSim
const std::vector< DetId > * theDetIds
template<class Traits >
CaloTDigitizer< Traits >::~CaloTDigitizer ( )
inline

doesn't delete the pointers passed in

Definition at line 40 of file CaloTDigitizer.h.

40 {}

Member Function Documentation

template<class Traits >
void CaloTDigitizer< Traits >::add ( const std::vector< PCaloHit > &  hits,
int  bunchCrossing 
)
inline

Definition at line 62 of file CaloTDigitizer.h.

References CaloHitResponse::add(), CaloTDigitizer< Traits >::theHitResponse, and CaloHitResponse::withinBunchRange().

Referenced by CastorDigiProducer::accumulateCaloHits(), HcalTBDigiProducer::accumulateCaloHits(), HcalDigitizer::accumulateCaloHits(), and EcalDigiProducer::accumulateCaloHits().

62  {
63  if(theHitResponse->withinBunchRange(bunchCrossing)) {
64  for(std::vector<PCaloHit>::const_iterator it = hits.begin(), itEnd = hits.end(); it != itEnd; ++it) {
65  theHitResponse->add(*it);
66  }
67  }
68  }
bool withinBunchRange(int bunchCrossing) const
check if crossing is within bunch range:
virtual void add(const PCaloHit &hit)
process a single SimHit
CaloHitResponse * theHitResponse
template<class Traits >
void CaloTDigitizer< Traits >::addNoiseHits ( )
inline

Definition at line 120 of file CaloTDigitizer.h.

References CaloHitResponse::add(), CaloVNoiseHitGenerator::getNoiseHits(), CaloTDigitizer< Traits >::theHitResponse, and CaloTDigitizer< Traits >::theNoiseHitGenerator.

Referenced by CaloTDigitizer< Traits >::run().

121  {
122  std::vector<PCaloHit> noiseHits;
124  for(std::vector<PCaloHit>::const_iterator hitItr = noiseHits.begin(),
125  hitEnd = noiseHits.end(); hitItr != hitEnd; ++hitItr)
126  {
127  theHitResponse->add(*hitItr);
128  }
129  }
virtual void getNoiseHits(std::vector< PCaloHit > &noiseHits)=0
virtual void add(const PCaloHit &hit)
process a single SimHit
CaloVNoiseHitGenerator * theNoiseHitGenerator
CaloHitResponse * theHitResponse
template<class Traits >
void CaloTDigitizer< Traits >::addNoiseSignals ( )
inline

Definition at line 131 of file CaloTDigitizer.h.

References CaloHitResponse::add(), CaloVNoiseSignalGenerator::fillEvent(), CaloVNoiseSignalGenerator::getNoiseSignals(), CaloTDigitizer< Traits >::theHitResponse, and CaloTDigitizer< Traits >::theNoiseSignalGenerator.

Referenced by CaloTDigitizer< Traits >::run().

132  {
133  std::vector<CaloSamples> noiseSignals;
134  // noise signals need to be in units of photoelectrons. Fractional is OK
137  for(std::vector<CaloSamples>::const_iterator signalItr = noiseSignals.begin(),
138  signalEnd = noiseSignals.end(); signalItr != signalEnd; ++signalItr)
139  {
140  theHitResponse->add(*signalItr);
141  }
142  }
virtual void add(const PCaloHit &hit)
process a single SimHit
CaloVNoiseSignalGenerator * theNoiseSignalGenerator
CaloHitResponse * theHitResponse
void fillEvent()
fill theNoiseSignals with one event&#39;s worth of noise, in units of pe
void getNoiseSignals(std::vector< CaloSamples > &noiseSignals)
template<class Traits >
const std::vector<DetId>& CaloTDigitizer< Traits >::detIds ( void  ) const
inline

tell the digitizer which cells exist

Definition at line 43 of file CaloTDigitizer.h.

References CaloTDigitizer< Traits >::theDetIds.

Referenced by CaloTDigitizer< Traits >::setDetIds().

43 {assert( 0 != theDetIds ) ; return *theDetIds;}
const std::vector< DetId > * theDetIds
template<class Traits >
void CaloTDigitizer< Traits >::initializeHits ( )
inline
template<class Traits >
void CaloTDigitizer< Traits >::run ( MixCollection< PCaloHit > &  ,
DigiCollection  
)
inline

turns hits into digis

Definition at line 75 of file CaloTDigitizer.h.

Referenced by CastorDigiProducer::finalizeEvent(), HcalTBDigiProducer::finalizeEvent(), HcalDigitizer::finalizeEvent(), and EcalDigiProducer::finalizeEvent().

75  {
76  assert(0);
77  }
template<class Traits >
void CaloTDigitizer< Traits >::run ( DigiCollection output)
inline

Collects the digis.

Definition at line 80 of file CaloTDigitizer.h.

References CaloTDigitizer< Traits >::addNoise_, CaloTDigitizer< Traits >::addNoiseHits(), CaloTDigitizer< Traits >::addNoiseSignals(), CaloHitResponse::clear(), CaloHitResponse::finalizeHits(), CaloHitResponse::findSignal(), CaloHitResponse::makeBlankSignal(), CaloHitResponse::nSignals(), CaloTDigitizer< Traits >::theDetIds, CaloTDigitizer< Traits >::theElectronicsSim, CaloTDigitizer< Traits >::theHitResponse, CaloTDigitizer< Traits >::theNoiseHitGenerator, and CaloTDigitizer< Traits >::theNoiseSignalGenerator.

80  {
82 
83  assert(theDetIds->size() != 0);
84 
87 
88  theElectronicsSim->newEvent();
89 
90  // reserve space for how many digis we expect
91  int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals();
92  output.reserve(nDigisExpected);
93 
94  // make a raw digi for evey cell
95  for(std::vector<DetId>::const_iterator idItr = theDetIds->begin();
96  idItr != theDetIds->end(); ++idItr)
97  {
98  Digi digi(*idItr);
99  CaloSamples * analogSignal = theHitResponse->findSignal(*idItr);
100  bool needToDeleteSignal = false;
101  // don't bother digitizing if no signal and no noise
102  if(analogSignal == 0 && addNoise_) {
103  // I guess we need to make a blank signal for this cell.
104  // Don't bother storing it anywhere.
105  analogSignal = new CaloSamples(theHitResponse->makeBlankSignal(*idItr));
106  needToDeleteSignal = true;
107  }
108  if(analogSignal != 0) {
109  theElectronicsSim->analogToDigital(*analogSignal , digi);
110  output.push_back(std::move(digi));
111  if(needToDeleteSignal) delete analogSignal;
112  }
113  }
114 
115  // free up some memory
117  }
CaloSamples makeBlankSignal(const DetId &detId) const
creates an empty signal for this DetId
Traits::Digi Digi
CaloVNoiseHitGenerator * theNoiseHitGenerator
CaloVNoiseSignalGenerator * theNoiseSignalGenerator
CaloHitResponse * theHitResponse
void addNoiseSignals()
virtual void finalizeHits()
Finalize hits.
ElectronicsSim * theElectronicsSim
CaloSamples * findSignal(const DetId &detId)
users can look for the signal for a given cell
void clear()
frees up memory
const std::vector< DetId > * theDetIds
int nSignals() const
number of signals in the current cache
template<class Traits >
void CaloTDigitizer< Traits >::setDetIds ( const std::vector< DetId > &  detIds)
inline
template<class Traits >
void CaloTDigitizer< Traits >::setNoiseHitGenerator ( CaloVNoiseHitGenerator generator)
inline

Definition at line 46 of file CaloTDigitizer.h.

References python.IdGenerator::generator, and CaloTDigitizer< Traits >::theNoiseHitGenerator.

Referenced by HcalDigitizer::HcalDigitizer().

47  {
49  }
CaloVNoiseHitGenerator * theNoiseHitGenerator
template<class Traits >
void CaloTDigitizer< Traits >::setNoiseSignalGenerator ( CaloVNoiseSignalGenerator generator)
inline
template<class Traits >
void CaloTDigitizer< Traits >::setRandomEngine ( CLHEP::HepRandomEngine &  engine)
inline

Definition at line 56 of file CaloTDigitizer.h.

References CaloHitResponse::setRandomEngine(), CaloTDigitizer< Traits >::theElectronicsSim, and CaloTDigitizer< Traits >::theHitResponse.

Referenced by HcalDigitizer::HcalDigitizer().

57  {
59  theElectronicsSim->setRandomEngine(engine);
60  }
CaloHitResponse * theHitResponse
ElectronicsSim * theElectronicsSim
virtual void setRandomEngine(CLHEP::HepRandomEngine &engine)

Member Data Documentation

template<class Traits >
bool CaloTDigitizer< Traits >::addNoise_
private

Definition at line 150 of file CaloTDigitizer.h.

Referenced by CaloTDigitizer< Traits >::run().

template<class Traits >
const std::vector<DetId>* CaloTDigitizer< Traits >::theDetIds
private
template<class Traits >
ElectronicsSim* CaloTDigitizer< Traits >::theElectronicsSim
private
template<class Traits >
CaloHitResponse* CaloTDigitizer< Traits >::theHitResponse
private
template<class Traits >
CaloVNoiseHitGenerator* CaloTDigitizer< Traits >::theNoiseHitGenerator
private
template<class Traits >
CaloVNoiseSignalGenerator* CaloTDigitizer< Traits >::theNoiseSignalGenerator
private