CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Attributes

CaloHitRespoNew Class Reference

Creates electronics signals from hits. More...

#include <CaloHitRespoNew.h>

List of all members.

Public Types

enum  { BUNCHSPACE = 25 }
typedef std::vector< unsigned int > VecInd
typedef std::vector< CaloSamplesVecSam

Public Member Functions

virtual void add (const PCaloHit &hit)
 CaloHitRespoNew (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape, const DetId detId)
virtual void finalizeHits ()
virtual void initializeHits ()
const CaloSamplesoperator[] (unsigned int i) const
virtual void run (MixCollection< PCaloHit > &hits)
unsigned int samplesSize () const
void setBunchRange (int minBunch, int maxBunch)
void setGeometry (const CaloSubdetectorGeometry *geometry)
void setHitCorrection (const CaloVHitCorrection *hitCorrection)
void setHitFilter (const CaloVHitFilter *filter)
void setPECorrection (const CaloVPECorrection *peCorrection)
void setPhaseShift (double phaseShift)
virtual void setRandomEngine (CLHEP::HepRandomEngine &engine) const
bool withinBunchRange (int bunchCrossing) const
virtual ~CaloHitRespoNew ()

Protected Member Functions

double analogSignalAmplitude (const DetId &id, float energy) const
void blankOutUsedSamples ()
CaloSamplesfindSignal (const DetId &detId)
const CaloSubdetectorGeometrygeometry () const
const CaloVHitFilterhitFilter () const
VecIndindex ()
int maxBunch () const
int minBunch () const
const CaloSimParametersparams (const DetId &detId) const
double phaseShift () const
virtual void putAnalogSignal (const PCaloHit &inputHit)
CLHEP::RandGaussQ * ranGauss () const
CLHEP::RandPoissonQ * ranPois () const
void setupSamples (const DetId &detId)
const CaloVShapeshape () const
double timeOfFlight (const DetId &detId) const

Private Attributes

const CaloSubdetectorGeometrym_geometry
const CaloVHitCorrectionm_hitCorrection
const CaloVHitFilterm_hitFilter
VecInd m_index
int m_maxBunch
int m_minBunch
const CaloVSimParameterMapm_parameterMap
const CaloVPECorrectionm_PECorrection
double m_phaseShift
CLHEP::RandGaussQ * m_RandGauss
CLHEP::RandPoissonQ * m_RandPoisson
const CaloVShapem_shape
VecSam m_vSamp

Detailed Description

Creates electronics signals from hits.

Definition at line 34 of file CaloHitRespoNew.h.


Member Typedef Documentation

typedef std::vector< unsigned int > CaloHitRespoNew::VecInd

Definition at line 39 of file CaloHitRespoNew.h.

typedef std::vector< CaloSamples > CaloHitRespoNew::VecSam

Definition at line 38 of file CaloHitRespoNew.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
BUNCHSPACE 

Definition at line 41 of file CaloHitRespoNew.h.

{BUNCHSPACE=25};

Constructor & Destructor Documentation

CaloHitRespoNew::CaloHitRespoNew ( const CaloVSimParameterMap parameterMap,
const CaloVShape shape,
const DetId  detId 
)

Definition at line 24 of file CaloHitRespoNew.cc.

References setupSamples().

                                                                              :
   m_parameterMap  ( parameterMap ) ,
   m_shape         ( shape        ) ,
   m_hitCorrection ( 0            ) ,
   m_PECorrection  ( 0            ) ,
   m_hitFilter     ( 0            ) ,
   m_geometry      ( 0            ) ,
   m_RandPoisson   ( 0            ) ,
   m_RandGauss     ( 0            ) ,
   m_minBunch      ( -10          ) ,
   m_maxBunch      (  10          ) ,
   m_phaseShift    ( 1            ) 
{
   setupSamples( detId ) ;
}
CaloHitRespoNew::~CaloHitRespoNew ( ) [virtual]

Definition at line 42 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

{
   delete m_RandPoisson ;
   delete m_RandGauss   ;
}

Member Function Documentation

void CaloHitRespoNew::add ( const PCaloHit hit) [virtual]

Definition at line 218 of file CaloHitRespoNew.cc.

References CaloVHitFilter::accepts(), edm::isNotFinite(), m_hitFilter, putAnalogSignal(), and PCaloHit::time().

Referenced by run().

{
      if( !edm::isNotFinite( hit.time() ) &&
          ( 0 == m_hitFilter ||
            m_hitFilter->accepts( hit ) ) ) putAnalogSignal( hit ) ;
}
double CaloHitRespoNew::analogSignalAmplitude ( const DetId id,
float  energy 
) const [protected]

Definition at line 269 of file CaloHitRespoNew.cc.

References CaloVPECorrection::correctPE(), CaloSimParameters::doPhotostatistics(), m_PECorrection, Parameters::parameters, params(), ranPois(), and CaloSimParameters::simHitToPhotoelectrons().

Referenced by putAnalogSignal().

{
   const CaloSimParameters& parameters ( *params( detId ) ) ;

   // OK, the "energy" in the hit could be a real energy, deposited energy,
   // or pe count.  This factor converts to photoelectrons

   double npe ( energy*parameters.simHitToPhotoelectrons( detId ) ) ;

   // do we need to doPoisson statistics for the photoelectrons?
   if( parameters.doPhotostatistics() ) npe = ranPois()->fire( npe ) ;

   if( 0 != m_PECorrection ) npe = m_PECorrection->correctPE( detId, npe ) ;

   return npe ;
}
void CaloHitRespoNew::blankOutUsedSamples ( ) [protected]

Definition at line 190 of file CaloHitRespoNew.cc.

References i, m_index, m_vSamp, and findQualityFiles::size.

Referenced by run().

{
   const unsigned int size ( m_index.size() ) ;

   for( unsigned int i ( 0 ) ; i != size ; ++i )
   {
      m_vSamp[ m_index[i] ].setBlank() ;
   }
   m_index.erase( m_index.begin() ,    // done and make ready to start over
                  m_index.end()    ) ;
}
virtual void CaloHitRespoNew::finalizeHits ( ) [inline, virtual]

Definition at line 74 of file CaloHitRespoNew.h.

{}
CaloSamples * CaloHitRespoNew::findSignal ( const DetId detId) [protected]

Definition at line 261 of file CaloHitRespoNew.cc.

References CaloSamples::isBlank(), m_index, m_vSamp, and query::result.

Referenced by putAnalogSignal().

{
   CaloSamples& result ( m_vSamp[ CaloGenericDetId( detId ).denseIndex() ] ) ;
   if( result.isBlank() ) m_index.push_back( &result - &m_vSamp.front() ) ;
   return &result ;
}
const CaloSubdetectorGeometry * CaloHitRespoNew::geometry ( ) const [protected]

Definition at line 99 of file CaloHitRespoNew.cc.

References m_geometry.

Referenced by setGeometry(), and timeOfFlight().

{
   assert( 0 != m_geometry ) ;
   return m_geometry ;
}
const CaloVHitFilter* CaloHitRespoNew::hitFilter ( ) const [inline, protected]

Definition at line 113 of file CaloHitRespoNew.h.

References m_hitFilter.

{ return m_hitFilter ; }
VecInd& CaloHitRespoNew::index ( ) [inline, protected]

Definition at line 111 of file CaloHitRespoNew.h.

References m_index.

{ return m_index ; }
virtual void CaloHitRespoNew::initializeHits ( ) [inline, virtual]

Definition at line 72 of file CaloHitRespoNew.h.

{}
int CaloHitRespoNew::maxBunch ( ) const [inline, protected]

Definition at line 109 of file CaloHitRespoNew.h.

References m_maxBunch.

Referenced by setBunchRange().

{ return m_maxBunch ; }
int CaloHitRespoNew::minBunch ( ) const [inline, protected]

Definition at line 107 of file CaloHitRespoNew.h.

References m_minBunch.

Referenced by setBunchRange().

{ return m_minBunch ; }
const CaloSamples & CaloHitRespoNew::operator[] ( unsigned int  i) const

Definition at line 157 of file CaloHitRespoNew.cc.

References i, and m_vSamp.

{
   assert( i < m_vSamp.size() ) ;
   return m_vSamp[ i ] ;
}
const CaloSimParameters * CaloHitRespoNew::params ( const DetId detId) const [protected]

Definition at line 85 of file CaloHitRespoNew.cc.

References m_parameterMap, and CaloVSimParameterMap::simParameters().

Referenced by analogSignalAmplitude(), putAnalogSignal(), and setupSamples().

{
   assert( 0 != m_parameterMap ) ;
   return &m_parameterMap->simParameters( detId ) ;
}
double CaloHitRespoNew::phaseShift ( ) const [protected]

Definition at line 126 of file CaloHitRespoNew.cc.

References m_phaseShift.

Referenced by setPhaseShift().

{
   return m_phaseShift ;
}
void CaloHitRespoNew::putAnalogSignal ( const PCaloHit inputHit) [protected, virtual]

Definition at line 226 of file CaloHitRespoNew.cc.

References analogSignalAmplitude(), newFWLiteAna::bin, BUNCHSPACE, CaloVHitCorrection::delay(), PCaloHit::energy(), findSignal(), PCaloHit::id(), m_hitCorrection, m_phaseShift, Parameters::parameters, params(), query::result, shape(), CaloSamples::size(), cond::rpcobgas::time, PCaloHit::time(), timeOfFlight(), CaloVShape::timeToRise(), and tzero.

Referenced by add().

{
   const DetId detId ( hit.id() ) ;

   const CaloSimParameters* parameters ( params( detId ) ) ;

   const double signal ( analogSignalAmplitude( detId, hit.energy() ) ) ;

   double time = hit.time();

   if( m_hitCorrection ) {
     time += m_hitCorrection->delay( hit ) ;
   }

   const double jitter ( time - timeOfFlight( detId ) ) ;

   const double tzero = ( shape()->timeToRise()
                          + parameters->timePhase() 
                          - jitter 
                          - BUNCHSPACE*( parameters->binOfMaximum()
                                         - m_phaseShift             ) ) ;
   double binTime ( tzero ) ;

   CaloSamples& result ( *findSignal( detId ) ) ;

   const unsigned int rsize ( result.size() ) ;

   for( unsigned int bin ( 0 ) ; bin != rsize ; ++bin )
   {
      result[ bin ] += (*shape())( binTime )*signal ;
      binTime += BUNCHSPACE;
   }
}
CLHEP::RandGaussQ * CaloHitRespoNew::ranGauss ( ) const [protected]

Definition at line 67 of file CaloHitRespoNew.cc.

References Exception, edm::Service< T >::isAvailable(), and m_RandGauss.

{
   if( 0 == m_RandGauss )
   {
      edm::Service<edm::RandomNumberGenerator> rng ;
      if ( !rng.isAvailable() ) 
      {
         throw cms::Exception("Configuration")
            << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
            "which is not present in the configuration file.  You must add the service\n"
            "in the configuration file or remove the modules that require it.";
      }
      m_RandGauss = new CLHEP::RandGaussQ( rng->getEngine() );
   }
   return m_RandGauss ;
}
CLHEP::RandPoissonQ * CaloHitRespoNew::ranPois ( ) const [protected]

Definition at line 49 of file CaloHitRespoNew.cc.

References Exception, edm::Service< T >::isAvailable(), and m_RandPoisson.

Referenced by analogSignalAmplitude().

{
   if( 0 == m_RandPoisson )
   {
      edm::Service<edm::RandomNumberGenerator> rng ;
      if ( !rng.isAvailable() ) 
      {
         throw cms::Exception("Configuration")
            << "CaloHitRespoNew requires the RandomNumberGeneratorService\n"
            "which is not present in the configuration file.  You must add the service\n"
            "in the configuration file or remove the modules that require it.";
      }
      m_RandPoisson = new CLHEP::RandPoissonQ( rng->getEngine() );
   }
   return m_RandPoisson ;
}
void CaloHitRespoNew::run ( MixCollection< PCaloHit > &  hits) [virtual]

Definition at line 203 of file CaloHitRespoNew.cc.

References add(), MixCollection< T >::begin(), blankOutUsedSamples(), MixCollection< T >::end(), m_index, and withinBunchRange().

{
   if( 0 != m_index.size() ) blankOutUsedSamples() ;

   for( MixCollection<PCaloHit>::MixItr hitItr ( hits.begin() ) ;
        hitItr != hits.end() ; ++hitItr )
   {
      if(withinBunchRange(hitItr.bunch())) {
        add(*hitItr);
      }

   }
}
unsigned int CaloHitRespoNew::samplesSize ( ) const

Definition at line 164 of file CaloHitRespoNew.cc.

References m_vSamp.

{
   return m_vSamp.size() ;
}
void CaloHitRespoNew::setBunchRange ( int  minBunch,
int  maxBunch 
)

Definition at line 106 of file CaloHitRespoNew.cc.

References m_maxBunch, m_minBunch, maxBunch(), and minBunch().

void CaloHitRespoNew::setGeometry ( const CaloSubdetectorGeometry geometry)

Definition at line 114 of file CaloHitRespoNew.cc.

References geometry(), and m_geometry.

void CaloHitRespoNew::setHitCorrection ( const CaloVHitCorrection hitCorrection)

Definition at line 138 of file CaloHitRespoNew.cc.

References m_hitCorrection.

{
   m_hitCorrection = hitCorrection ;
}
void CaloHitRespoNew::setHitFilter ( const CaloVHitFilter filter)

Definition at line 132 of file CaloHitRespoNew.cc.

References alcazmumu_cfi::filter, and m_hitFilter.

void CaloHitRespoNew::setPECorrection ( const CaloVPECorrection peCorrection)

Definition at line 144 of file CaloHitRespoNew.cc.

References m_PECorrection.

{
   m_PECorrection = peCorrection ;
}
void CaloHitRespoNew::setPhaseShift ( double  phaseShift)

Definition at line 120 of file CaloHitRespoNew.cc.

References m_phaseShift, and phaseShift().

void CaloHitRespoNew::setRandomEngine ( CLHEP::HepRandomEngine &  engine) const [virtual]

Definition at line 150 of file CaloHitRespoNew.cc.

References m_RandGauss, and m_RandPoisson.

{
   m_RandPoisson = new CLHEP::RandPoissonQ( engine ) ;
   m_RandGauss   = new CLHEP::RandGaussQ(   engine ) ;
}
void CaloHitRespoNew::setupSamples ( const DetId detId) [protected]

Definition at line 170 of file CaloHitRespoNew.cc.

References CaloSimParameters::binOfMaximum(), DetId::det(), i, m_vSamp, Parameters::parameters, params(), CaloSimParameters::readoutFrameSize(), findQualityFiles::size, and DetId::subdetId().

Referenced by CaloHitRespoNew().

{
   const CaloSimParameters& parameters ( *params( detId ) ) ;

   const unsigned int rSize ( parameters.readoutFrameSize() ) ;
   const unsigned int nPre  ( parameters.binOfMaximum() - 1 ) ;

   m_vSamp = VecSam( CaloGenericDetId( detId ).sizeForDenseIndexing() ) ;

   const unsigned int size ( m_vSamp.size() ) ;

   for( unsigned int i ( 0 ) ; i != size ; ++i )
   {
      m_vSamp[ i ].setDetId( CaloGenericDetId( detId.det(), detId.subdetId(), i ) ) ;
      m_vSamp[ i ].setSize( rSize ) ;
      m_vSamp[ i ].setPresamples( nPre ) ;
   }
}
const CaloVShape * CaloHitRespoNew::shape ( void  ) const [protected]

Definition at line 92 of file CaloHitRespoNew.cc.

References m_shape.

Referenced by putAnalogSignal().

{
   assert( 0 != m_shape ) ;
   return m_shape ;
}
double CaloHitRespoNew::timeOfFlight ( const DetId detId) const [protected]

Definition at line 287 of file CaloHitRespoNew.cc.

References geometry(), CaloCellGeometry::getPosition(), and PV3DBase< T, PVType, FrameType >::mag().

Referenced by putAnalogSignal().

{
   const CaloCellGeometry* cellGeometry ( geometry()->getGeometry( detId ) ) ;
   assert( 0 != cellGeometry ) ;
   return cellGeometry->getPosition().mag()*cm/c_light ; // Units of c_light: mm/ns
}
bool CaloHitRespoNew::withinBunchRange ( int  bunchCrossing) const [inline]

Definition at line 76 of file CaloHitRespoNew.h.

References m_maxBunch, and m_minBunch.

Referenced by run().

                                                     {
        return(bunchCrossing >= m_minBunch && bunchCrossing <= m_maxBunch);
      }

Member Data Documentation

Definition at line 122 of file CaloHitRespoNew.h.

Referenced by geometry(), and setGeometry().

Definition at line 119 of file CaloHitRespoNew.h.

Referenced by putAnalogSignal(), and setHitCorrection().

Definition at line 121 of file CaloHitRespoNew.h.

Referenced by add(), hitFilter(), and setHitFilter().

Definition at line 133 of file CaloHitRespoNew.h.

Referenced by blankOutUsedSamples(), findSignal(), index(), and run().

Definition at line 129 of file CaloHitRespoNew.h.

Referenced by maxBunch(), setBunchRange(), and withinBunchRange().

Definition at line 128 of file CaloHitRespoNew.h.

Referenced by minBunch(), setBunchRange(), and withinBunchRange().

Definition at line 117 of file CaloHitRespoNew.h.

Referenced by params().

Definition at line 120 of file CaloHitRespoNew.h.

Referenced by analogSignalAmplitude(), and setPECorrection().

Definition at line 130 of file CaloHitRespoNew.h.

Referenced by phaseShift(), putAnalogSignal(), and setPhaseShift().

CLHEP::RandGaussQ* CaloHitRespoNew::m_RandGauss [mutable, private]

Definition at line 126 of file CaloHitRespoNew.h.

Referenced by ranGauss(), setRandomEngine(), and ~CaloHitRespoNew().

CLHEP::RandPoissonQ* CaloHitRespoNew::m_RandPoisson [mutable, private]

Definition at line 124 of file CaloHitRespoNew.h.

Referenced by ranPois(), setRandomEngine(), and ~CaloHitRespoNew().

Definition at line 118 of file CaloHitRespoNew.h.

Referenced by shape().