CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

CaloTDigitizer< Traits > Class Template Reference

#include <CaloTDigitizer.h>

List of all members.

Public Types

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

Public Member Functions

void addNoiseHits ()
void addNoiseSignals ()
 CaloTDigitizer (CaloHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)
const std::vector< DetId > & detIds () const
 tell the digitizer which cells exist
void run (MixCollection< PCaloHit > &input, DigiCollection &output)
 turns hits into digis
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

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


Member Typedef Documentation

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

Definition at line 24 of file CaloTDigitizer.h.

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

Definition at line 25 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 23 of file CaloTDigitizer.h.


Constructor & Destructor Documentation

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

Definition at line 27 of file CaloTDigitizer.h.

  :  theHitResponse(hitResponse),
     theNoiseHitGenerator(0),
     theNoiseSignalGenerator(0),
     theElectronicsSim(electronicsSim),
     theDetIds(0),
     addNoise_(addNoise)
  {
  }
template<class Traits >
CaloTDigitizer< Traits >::~CaloTDigitizer ( ) [inline]

doesn't delete the pointers passed in

Definition at line 39 of file CaloTDigitizer.h.

{}

Member Function Documentation

template<class Traits >
void CaloTDigitizer< Traits >::addNoiseHits ( ) [inline]

Definition at line 101 of file CaloTDigitizer.h.

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

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

  {
    std::vector<PCaloHit> noiseHits;
    theNoiseHitGenerator->getNoiseHits(noiseHits);
    for(std::vector<PCaloHit>::const_iterator hitItr = noiseHits.begin(),
        hitEnd = noiseHits.end(); hitItr != hitEnd; ++hitItr)
    {
      theHitResponse->add(*hitItr);
    }
  }
template<class Traits >
void CaloTDigitizer< Traits >::addNoiseSignals ( ) [inline]

Definition at line 112 of file CaloTDigitizer.h.

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

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

  {
    std::vector<CaloSamples> noiseSignals;
    // noise signals need to be in units of photoelectrons.  Fractional is OK
    theNoiseSignalGenerator->fillEvent();
    theNoiseSignalGenerator->getNoiseSignals(noiseSignals);
    for(std::vector<CaloSamples>::const_iterator signalItr = noiseSignals.begin(),
        signalEnd = noiseSignals.end(); signalItr != signalEnd; ++signalItr)
    {
      theHitResponse->add(*signalItr);
    }
  }
template<class Traits >
const std::vector<DetId>& CaloTDigitizer< Traits >::detIds ( ) const [inline]

tell the digitizer which cells exist

Definition at line 42 of file CaloTDigitizer.h.

References CaloTDigitizer< Traits >::theDetIds.

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

{assert( 0 != theDetIds ) ; return *theDetIds;}
template<class Traits >
void CaloTDigitizer< Traits >::run ( MixCollection< PCaloHit > &  input,
DigiCollection output 
) [inline]

turns hits into digis

Definition at line 62 of file CaloTDigitizer.h.

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

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

                                                                     {
    assert(theDetIds->size() != 0);

    if(theNoiseHitGenerator != 0) addNoiseHits();
    if(theNoiseSignalGenerator != 0) addNoiseSignals();

    theHitResponse->run(input);
    theElectronicsSim->newEvent();

    // reserve space for how many digis we expect
    int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals();
    output.reserve(nDigisExpected);

    // make a raw digi for evey cell
    for(std::vector<DetId>::const_iterator idItr = theDetIds->begin();
        idItr != theDetIds->end(); ++idItr)
    {
       Digi digi(*idItr);
       CaloSamples * analogSignal = theHitResponse->findSignal(*idItr);
       bool needToDeleteSignal = false;
       // don't bother digitizing if no signal and no noise
       if(analogSignal == 0 && addNoise_) {
         // I guess we need to make a blank signal for this cell.
         // Don't bother storing it anywhere.
         analogSignal = new CaloSamples(theHitResponse->makeBlankSignal(*idItr));
         needToDeleteSignal = true;
       }
       if(analogSignal != 0) { 
         theElectronicsSim->analogToDigital(*analogSignal , digi);
         output.push_back(digi);
         if(needToDeleteSignal) delete analogSignal;
      }
    }

    // free up some memory
    theHitResponse->clear();
  }
template<class Traits >
void CaloTDigitizer< Traits >::setDetIds ( const std::vector< DetId > &  detIds) [inline]
template<class Traits >
void CaloTDigitizer< Traits >::setNoiseHitGenerator ( CaloVNoiseHitGenerator generator) [inline]
template<class Traits >
void CaloTDigitizer< Traits >::setNoiseSignalGenerator ( CaloVNoiseSignalGenerator generator) [inline]
template<class Traits >
void CaloTDigitizer< Traits >::setRandomEngine ( CLHEP::HepRandomEngine &  engine) [inline]

Member Data Documentation

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

Definition at line 131 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]