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 131 of file CaloTDigitizer.h.

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

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

132  {
133  std::vector<PCaloHit> noiseHits;
135  for(std::vector<PCaloHit>::const_iterator hitItr = noiseHits.begin(),
136  hitEnd = noiseHits.end(); hitItr != hitEnd; ++hitItr)
137  {
138  theHitResponse->add(*hitItr);
139  }
140  }
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 142 of file CaloTDigitizer.h.

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

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

143  {
144  std::vector<CaloSamples> noiseSignals;
145  // noise signals need to be in units of photoelectrons. Fractional is OK
148  for(std::vector<CaloSamples>::const_iterator signalItr = noiseSignals.begin(),
149  signalEnd = noiseSignals.end(); signalItr != signalEnd; ++signalItr)
150  {
151  theHitResponse->add(*signalItr);
152  }
153  }
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  {
81 
82  //std::cout << " In CaloTDigitizer " << std::endl;
83 
85 
86  //std::cout << " In CaloTDigitizer, after finalize hits " << std::endl;
87 
88  assert(theDetIds->size() != 0);
89 
92 
93  //std::cout << " In CaloTDigitizer, after addNoiseSignals " << std::endl;
94 
95  theElectronicsSim->newEvent();
96 
97  // reserve space for how many digis we expect
98  int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals();
99  output.reserve(nDigisExpected);
100 
101  //std::cout << " In CaloTDigitizer, nDigisExpected " << nDigisExpected << std::endl;
102 
103  // make a raw digi for evey cell
104  for(std::vector<DetId>::const_iterator idItr = theDetIds->begin();
105  idItr != theDetIds->end(); ++idItr)
106  {
107  Digi digi(*idItr);
108  CaloSamples * analogSignal = theHitResponse->findSignal(*idItr);
109  bool needToDeleteSignal = false;
110  // don't bother digitizing if no signal and no noise
111  if(analogSignal == 0 && addNoise_) {
112  // I guess we need to make a blank signal for this cell.
113  // Don't bother storing it anywhere.
114  analogSignal = new CaloSamples(theHitResponse->makeBlankSignal(*idItr));
115  needToDeleteSignal = true;
116  }
117  if(analogSignal != 0) {
118  theElectronicsSim->analogToDigital(*analogSignal , digi);
119 
120  // std::cout << " New Digi: " << digi << std::endl;
121  output.push_back(std::move(digi));
122  if(needToDeleteSignal) delete analogSignal;
123  }
124  }
125 
126  // free up some memory
128  }
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 161 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