CMS 3D CMS Logo

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

EBHitResponse Class Reference

#include <EBHitResponse.h>

Inheritance diagram for EBHitResponse:
EcalHitResponse

List of all members.

Public Types

enum  { kNOffsets = 2000 }
typedef CaloTSamples< float, 10 > EBSamples
typedef std::vector< double > VecD

Public Member Functions

 EBHitResponse (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape, bool apdOnly, const APDSimParameters *apdPars, const CaloVShape *apdShape)
virtual bool keepBlank () const
const VecDoffsets () const
virtual EcalSamplesoperator[] (unsigned int i)
virtual const EcalSamplesoperator[] (unsigned int i) const
virtual void run (MixCollection< PCaloHit > &hits)
virtual unsigned int samplesSize () const
void setIntercal (const EcalIntercalibConstantsMC *ical)
virtual ~EBHitResponse ()

Protected Member Functions

void putAPDSignal (const DetId &detId, double npe, double time)
virtual unsigned int samplesSizeAll () const
virtual EcalSamplesvSam (unsigned int i)
virtual const EcalSamplesvSamAll (unsigned int i) const
virtual EcalSamplesvSamAll (unsigned int i)

Private Member Functions

const APDSimParametersapdParameters () const
const CaloVShapeapdShape () const
double apdSignalAmplitude (const PCaloHit &hit) const
void findIntercalibConstant (const DetId &detId, double &icalconst) const
const double nonlFunc (double enr) const
const double nonlFunc1 (double energy) const

Private Attributes

std::vector< double > m_apdNpeVec
const bool m_apdOnly
const APDSimParametersm_apdPars
const CaloVShapem_apdShape
std::vector< double > m_apdTimeVec
const EcalIntercalibConstantsMCm_intercal
std::vector< double > m_timeOffVec
std::vector< EBSamplesm_vSam
const double pasy
const double pcon
const double pcub
const double pehi
const double pelo
const double pext
const double pfac
const double plin
const double poff
const double pqua

Detailed Description

Definition at line 10 of file EBHitResponse.h.


Member Typedef Documentation

Definition at line 14 of file EBHitResponse.h.

typedef std::vector<double> EBHitResponse::VecD

Definition at line 16 of file EBHitResponse.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
kNOffsets 

Definition at line 18 of file EBHitResponse.h.

{ kNOffsets = 2000 } ;

Constructor & Destructor Documentation

EBHitResponse::EBHitResponse ( const CaloVSimParameterMap parameterMap,
const CaloVShape shape,
bool  apdOnly,
const APDSimParameters apdPars = 0,
const CaloVShape apdShape = 0 
)

Definition at line 13 of file EBHitResponse.cc.

References apdParameters(), DetId::det(), EBDetId::detIdFromDenseIndex(), i, kNOffsets, EBDetId::kSizeForDenseIndexing, m_timeOffVec, m_vSam, Parameters::parameters, EcalHitResponse::ranGauss(), CaloVSimParameterMap::simParameters(), findQualityFiles::size, and DetId::subdetId().

                                                                           :

   EcalHitResponse( parameterMap, shape ) ,

   m_apdOnly  ( apdOnly  ) ,
   m_apdPars  ( apdPars  ) ,
   m_apdShape ( apdShape ) ,
   m_timeOffVec ( kNOffsets, apdParameters()->timeOffset() ) ,
   pcub ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[0] ) ,
   pqua ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[1] ) ,
   plin ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[2] ) ,
   pcon ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[3] ) ,
   pelo ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[4] ) ,
   pehi ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[5] ) ,
   pasy ( 0 == apdPars ? 0 : apdParameters()->nonlParms()[6] ) ,
   pext ( 0 == apdPars ? 0 : nonlFunc1( pelo ) ) ,
   poff ( 0 == apdPars ? 0 : nonlFunc1( pehi ) ) ,
   pfac ( 0 == apdPars ? 0 : ( pasy - poff )*2./M_PI ) 
{
   for( unsigned int i ( 0 ) ; i != kNOffsets ; ++i )
   {
      m_timeOffVec[ i ] +=
         ranGauss()->fire( 0 , apdParameters()->timeOffWidth() ) ;
   }

   const EBDetId detId ( EBDetId::detIdFromDenseIndex( 0 ) ) ;
   const CaloSimParameters& parameters ( parameterMap->simParameters( detId ) ) ;

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

   const unsigned int size ( EBDetId::kSizeForDenseIndexing ) ;

   m_vSam.reserve( size ) ;

   for( unsigned int i ( 0 ) ; i != size ; ++i )
   {
      m_vSam.push_back(
         EBSamples( CaloGenericDetId( detId.det(), detId.subdetId(), i ) ,
                    rSize, nPre ) ) ;
   }
}
EBHitResponse::~EBHitResponse ( ) [virtual]

Definition at line 60 of file EBHitResponse.cc.

{
}

Member Function Documentation

const APDSimParameters * EBHitResponse::apdParameters ( ) const [private]

Definition at line 65 of file EBHitResponse.cc.

References m_apdPars.

Referenced by apdSignalAmplitude(), EBHitResponse(), and run().

{
   assert ( 0 != m_apdPars ) ;
   return m_apdPars ;
}
const CaloVShape * EBHitResponse::apdShape ( ) const [private]

Definition at line 72 of file EBHitResponse.cc.

References m_apdShape.

Referenced by putAPDSignal().

{
   assert( 0 != m_apdShape ) ;
   return m_apdShape ;
}
double EBHitResponse::apdSignalAmplitude ( const PCaloHit hit) const [private]

Definition at line 113 of file EBHitResponse.cc.

References apdParameters(), PCaloHit::depth(), PCaloHit::energy(), findIntercalibConstant(), PCaloHit::id(), m_apdOnly, m_intercal, EcalHitResponse::ranPois(), APDSimParameters::simToPEHigh(), and APDSimParameters::simToPELow().

Referenced by run().

{
   assert( 1 == hit.depth() ||
           2 == hit.depth()    ) ;

   double npe ( hit.energy()*( 2 == hit.depth() ?
                               apdParameters()->simToPELow() :
                               apdParameters()->simToPEHigh() ) ) ;

   // do we need to do Poisson statistics for the photoelectrons?
   if( apdParameters()->doPEStats() &&
       !m_apdOnly                      ) npe = ranPois()->fire( npe ) ;

   assert( 0 != m_intercal ) ;
   double fac ( 1 ) ;
   findIntercalibConstant( hit.id(), fac ) ;

   npe *= fac ;

//   edm::LogError( "EBHitResponse" ) << "--- # photoelectrons for "
/*   std::cout << "--- # photoelectrons for "
             << EBDetId( hit.id() ) 
             <<" is " << npe //;
             <<std::endl ;*/

   return npe ;
}
void EBHitResponse::findIntercalibConstant ( const DetId detId,
double &  icalconst 
) const [private]

Definition at line 148 of file EBHitResponse.cc.

References EcalCondObjectContainer< T >::getMap(), m_intercal, and DetId::rawId().

Referenced by apdSignalAmplitude().

{
   EcalIntercalibConstantMC thisconst ( 1. ) ;

   if( 0 == m_intercal )
   {
      edm::LogError( "EBHitResponse" ) << 
         "No intercal constant defined for EBHitResponse" ;
   }
   else
   {
      const EcalIntercalibConstantMCMap&          icalMap ( m_intercal->getMap()  ) ;
      EcalIntercalibConstantMCMap::const_iterator icalit  ( icalMap.find( detId ) ) ;
      if( icalit != icalMap.end() )
      {
         thisconst = *icalit ;
         if ( thisconst == 0. ) thisconst = 1. ; 
      } 
      else
      {
         edm::LogError("EBHitResponse") << "No intercalib const found for xtal " 
                                        << detId.rawId() 
                                        << "! something wrong with EcalIntercalibConstants in your DB? ";
      }
   }
   icalconst = thisconst ;
}
virtual bool EBHitResponse::keepBlank ( ) const [inline, virtual]

Definition at line 28 of file EBHitResponse.h.

References funct::false.

{ return false ; }
const double EBHitResponse::nonlFunc ( double  enr) const [inline, private]

Definition at line 56 of file EBHitResponse.h.

References nonlFunc1(), pehi, pelo, pext, pfac, and poff.

Referenced by putAPDSignal().

                                                {
         return ( pelo > enr ? pext :
                  ( pehi > enr ? nonlFunc1( enr ) : 
                    pfac*atan( log10( enr - pehi + 0.00001 ) ) + poff ) ) ; }
const double EBHitResponse::nonlFunc1 ( double  energy) const [inline, private]

Definition at line 61 of file EBHitResponse.h.

References pcon, pcub, plin, and pqua.

Referenced by nonlFunc().

                                                    {
         const double enr ( log10(energy) ) ;
         const double enr2 ( enr*enr ) ;
         const double enr3 ( enr2*enr ) ;
         return ( pcub*enr3 + pqua*enr2 + plin*enr + pcon ) ; }
const VecD& EBHitResponse::offsets ( ) const [inline]

Definition at line 32 of file EBHitResponse.h.

References m_timeOffVec.

Referenced by putAPDSignal().

{ return m_timeOffVec ; }
EcalHitResponse::EcalSamples * EBHitResponse::operator[] ( unsigned int  i) [virtual]

Implements EcalHitResponse.

Definition at line 257 of file EBHitResponse.cc.

References i, and m_vSam.

{
   return &m_vSam[ i ] ;
}
const EcalHitResponse::EcalSamples * EBHitResponse::operator[] ( unsigned int  i) const [virtual]

Implements EcalHitResponse.

Definition at line 251 of file EBHitResponse.cc.

References i, and m_vSam.

{
   return &m_vSam[ i ] ;
}
void EBHitResponse::putAPDSignal ( const DetId detId,
double  npe,
double  time 
) [protected]

Definition at line 79 of file EBHitResponse.cc.

References apdShape(), newFWLiteAna::bin, CaloSimParameters::binOfMaximum(), EcalHitResponse::BUNCHSPACE, EcalHitResponse::findSignal(), kNOffsets, nonlFunc(), offsets(), Parameters::parameters, EcalHitResponse::params(), EcalHitResponse::phaseShift(), query::result, CaloSimParameters::simHitToPhotoelectrons(), CaloTSamplesBase< Ttype >::size(), EcalHitResponse::timeOfFlight(), and tzero.

Referenced by run().

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

   const double energyFac ( 1./parameters.simHitToPhotoelectrons( detId ) ) ;

//   std::cout<<"******** Input APD Npe="<<npe<<", Efactor="<<energyFac
//          <<", Energy="<<npe*energyFac
//          <<", nonlFunc="<<nonlFunc( npe*energyFac )<<std::endl ;

   const double signal ( npe*nonlFunc( npe*energyFac ) ) ;

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

   const double tzero ( apdShape()->timeToRise()
                        - jitter
                        - offsets()[ EBDetId( detId ).denseIndex()%kNOffsets ]
                        - BUNCHSPACE*( parameters.binOfMaximum()
                                       - phaseShift()            ) ) ;

   double binTime ( tzero ) ;

   EcalSamples& result ( *findSignal( detId ) );

   for( unsigned int bin ( 0 ) ; bin != result.size(); ++bin )
   {
      result[bin] += (*apdShape())(binTime)*signal ;
      binTime += BUNCHSPACE ;
   }
}
void EBHitResponse::run ( MixCollection< PCaloHit > &  hits) [virtual]

Reimplemented from EcalHitResponse.

Definition at line 179 of file EBHitResponse.cc.

References CaloVHitFilter::accepts(), apdParameters(), apdSignalAmplitude(), MixCollection< T >::begin(), EcalHitResponse::blankOutUsedSamples(), PCaloHit::depth(), EBDetId::detIdFromDenseIndex(), MixCollection< T >::end(), EcalHitResponse::hitFilter(), i, PCaloHit::id(), EcalHitResponse::index(), edm::detail::isnan(), EBDetId::kSizeForDenseIndexing, m_apdNpeVec, m_apdOnly, m_apdTimeVec, EcalHitResponse::maxBunch(), EcalHitResponse::minBunch(), EcalHitResponse::putAnalogSignal(), putAPDSignal(), findQualityFiles::size, and PCaloHit::time().

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

   const unsigned int bSize ( EBDetId::kSizeForDenseIndexing ) ;

   if( 0 == m_apdNpeVec.size() ) 
   {
      m_apdNpeVec  = std::vector<double>( bSize, (double)0.0 ) ;
      m_apdTimeVec = std::vector<double>( bSize, (double)0.0 ) ;
   }

   for( MixCollection<PCaloHit>::MixItr hitItr ( hits.begin() ) ;
        hitItr != hits.end() ; ++hitItr )
   {
      const PCaloHit& hit ( *hitItr ) ;
      const int bunch ( hitItr.bunch() ) ;
      if( minBunch() <= bunch  &&
          maxBunch() >= bunch  &&
          !isnan( hit.time() ) &&
          ( 0 == hitFilter() ||
            hitFilter()->accepts( hit ) ) )
      { 
         if( 0 == hit.depth() ) // for now take only nonAPD hits
         {
            if( !m_apdOnly ) putAnalogSignal( hit ) ;
         }
         else // APD hits here
         {
            if( apdParameters()->addToBarrel() ||
                m_apdOnly                         )
            {
               const unsigned int icell ( EBDetId( hit.id() ).denseIndex() ) ;
               m_apdNpeVec[ icell ] += apdSignalAmplitude( hit ) ;
               if( 0 == m_apdTimeVec[ icell ] ) m_apdTimeVec[ icell ] = hit.time() ;
            }
         }
      }
   }

   if( apdParameters()->addToBarrel() ||
       m_apdOnly                         )
   {
      for( unsigned int i ( 0 ) ; i != bSize ; ++i )
      {
         if( 0 < m_apdNpeVec[i] )
         {
            putAPDSignal( EBDetId::detIdFromDenseIndex( i ),
                          m_apdNpeVec[i] ,
                          m_apdTimeVec[i]                    ) ;

            // now zero out for next time
            m_apdNpeVec[i] = 0. ;
            m_apdTimeVec[i] = 0. ;
         }
      }
   }
}
unsigned int EBHitResponse::samplesSize ( ) const [virtual]

Implements EcalHitResponse.

Definition at line 239 of file EBHitResponse.cc.

References m_vSam.

{
   return m_vSam.size() ;
}
unsigned int EBHitResponse::samplesSizeAll ( ) const [protected, virtual]

Implements EcalHitResponse.

Definition at line 245 of file EBHitResponse.cc.

References m_vSam.

{
   return m_vSam.size() ;
}
void EBHitResponse::setIntercal ( const EcalIntercalibConstantsMC ical)

Definition at line 142 of file EBHitResponse.cc.

References m_intercal.

Referenced by EcalDigiProducer::checkCalibrations().

{
   m_intercal = ical ;
}
EcalHitResponse::EcalSamples * EBHitResponse::vSam ( unsigned int  i) [protected, virtual]

Implements EcalHitResponse.

Definition at line 263 of file EBHitResponse.cc.

References i, and m_vSam.

{
   return &m_vSam[ i ] ;
}
EcalHitResponse::EcalSamples * EBHitResponse::vSamAll ( unsigned int  i) [protected, virtual]

Implements EcalHitResponse.

Definition at line 269 of file EBHitResponse.cc.

References i, and m_vSam.

{
   return &m_vSam[ i ] ;
}
const EcalHitResponse::EcalSamples * EBHitResponse::vSamAll ( unsigned int  i) const [protected, virtual]

Implements EcalHitResponse.

Definition at line 275 of file EBHitResponse.cc.

References i, and m_vSam.

{
   return &m_vSam[ i ] ;
}

Member Data Documentation

std::vector<double> EBHitResponse::m_apdNpeVec [private]

Definition at line 82 of file EBHitResponse.h.

Referenced by run().

const bool EBHitResponse::m_apdOnly [private]

Definition at line 75 of file EBHitResponse.h.

Referenced by apdSignalAmplitude(), and run().

Definition at line 76 of file EBHitResponse.h.

Referenced by apdParameters().

Definition at line 77 of file EBHitResponse.h.

Referenced by apdShape().

std::vector<double> EBHitResponse::m_apdTimeVec [private]

Definition at line 83 of file EBHitResponse.h.

Referenced by run().

Definition at line 78 of file EBHitResponse.h.

Referenced by apdSignalAmplitude(), findIntercalibConstant(), and setIntercal().

std::vector<double> EBHitResponse::m_timeOffVec [private]

Definition at line 80 of file EBHitResponse.h.

Referenced by EBHitResponse(), and offsets().

std::vector<EBSamples> EBHitResponse::m_vSam [private]

Definition at line 87 of file EBHitResponse.h.

Referenced by EBHitResponse(), operator[](), samplesSize(), samplesSizeAll(), vSam(), and vSamAll().

const double EBHitResponse::pasy [private]

Definition at line 85 of file EBHitResponse.h.

const double EBHitResponse::pcon [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc1().

const double EBHitResponse::pcub [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc1().

const double EBHitResponse::pehi [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc().

const double EBHitResponse::pelo [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc().

const double EBHitResponse::pext [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc().

const double EBHitResponse::pfac [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc().

const double EBHitResponse::plin [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc1().

const double EBHitResponse::poff [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc().

const double EBHitResponse::pqua [private]

Definition at line 85 of file EBHitResponse.h.

Referenced by nonlFunc1().