CMS 3D CMS Logo

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

EcalShapeBase Class Reference

#include <EcalShapeBase.h>

Inheritance diagram for EcalShapeBase:
CaloVShape APDShape EBShape EEShape

List of all members.

Public Types

enum  {
  kReadoutTimeInterval = 25, kNBinsPerNSec = 10, k1NSecBins = kReadoutTimeInterval*kNBinsPerNSec, k1NSecBinsTotal = 2*k1NSecBins,
  kNBinsStored = k1NSecBinsTotal*kNBinsPerNSec
}
typedef std::vector< double > DVec

Public Member Functions

double derivative (double time) const
 EcalShapeBase (bool aSaveDerivative)
double operator() (double aTime) const
virtual double threshold () const =0
double timeOfMax () const
double timeOfThr () const
virtual double timeToRise () const
virtual ~EcalShapeBase ()

Static Public Attributes

static const double qNSecPerBin = 1./(1.*kNBinsPerNSec)

Protected Member Functions

void buildMe ()
virtual void fillShape (DVec &aVec) const =0
unsigned int timeIndex (double aTime) const

Private Attributes

DVecm_derivPtr
unsigned int m_firstIndexOverThreshold
double m_firstTimeOverThreshold
unsigned int m_indexOfMax
DVec m_shape
double m_timeOfMax

Detailed Description

Definition at line 12 of file EcalShapeBase.h.


Member Typedef Documentation

typedef std::vector<double> EcalShapeBase::DVec

Definition at line 16 of file EcalShapeBase.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
kReadoutTimeInterval 
kNBinsPerNSec 
k1NSecBins 
k1NSecBinsTotal 
kNBinsStored 

Definition at line 32 of file EcalShapeBase.h.

           { kReadoutTimeInterval = 25 , // in nsec
             kNBinsPerNSec        = 10 , // granularity of internal array
             k1NSecBins           = kReadoutTimeInterval*kNBinsPerNSec ,
             k1NSecBinsTotal      = 2*k1NSecBins ,
             kNBinsStored         = k1NSecBinsTotal*kNBinsPerNSec
      } ;

Constructor & Destructor Documentation

EcalShapeBase::EcalShapeBase ( bool  aSaveDerivative)

Definition at line 16 of file EcalShapeBase.cc.

                                                     :
   m_firstIndexOverThreshold ( 0   ) ,
   m_firstTimeOverThreshold  ( 0.0 ) ,
   m_indexOfMax              ( 0   ) ,
   m_timeOfMax               ( 0.0 ) ,
   m_shape                   ( DVec( kNBinsStored, 0.0 ) ) ,
   m_derivPtr                ( aSaveDerivative ? new DVec( kNBinsStored, 0.0 ) : 0 )
{
}
EcalShapeBase::~EcalShapeBase ( ) [virtual]

Definition at line 11 of file EcalShapeBase.cc.

References m_derivPtr.

{
   delete m_derivPtr ;
}

Member Function Documentation

void EcalShapeBase::buildMe ( ) [protected]

Definition at line 46 of file EcalShapeBase.cc.

References a, b, trackerHits::c, delta, connectstrParser::f1, connectstrParser::f2, connectstrParser::f3, fillShape(), i, j, k1NSecBinsTotal, kNBinsPerNSec, kNBinsStored, m_derivPtr, m_firstIndexOverThreshold, m_firstTimeOverThreshold, m_indexOfMax, m_shape, m_timeOfMax, qNSecPerBin, GOODCOLL_filter_cfg::thresh, threshold(), relativeConstraints::value, and x.

Referenced by APDShape::APDShape(), EBShape::EBShape(), and EEShape::EEShape().

{
   DVec shapeArray( k1NSecBinsTotal , 0.0 ) ;

   fillShape( shapeArray ) ;

   const double maxel ( *max_element( shapeArray.begin(), shapeArray.end() ) ) ;

   const double maxelt ( 1.e-5 < maxel ? maxel : 1 ) ;

   for( unsigned int i ( 0 ) ; i != shapeArray.size(); ++i )
   {
      shapeArray[i] = shapeArray[i]/maxelt ;
   } 

   const double thresh ( threshold()/maxelt ) ;

/*
   for( unsigned int i ( 0 ) ; i != k1NSecBinsTotal ; ++i ) 
   {
      LogDebug("EcalShapeBase") << " time (ns) = " << (double)i << " tabulated ECAL pulse shape = " << shapeArray[i];
   }
*/

   const double delta ( qNSecPerBin/2. ) ;

   for( unsigned int j ( 0 ) ; j != kNBinsStored ; ++j )
   {
      const double xb ( ( j + 0.5 )*qNSecPerBin ) ; 

      const unsigned int ibin ( j/kNBinsPerNSec ) ;

      double value = 0.0 ;
      double deriv = 0.0 ;

      if( 0                 ==     ibin ||
          shapeArray.size() == 1 + ibin    ) // cannot do quadratic interpolation at ends
      {
         value = shapeArray[ibin]; 
         deriv = 0.0 ;
      }
      else 
      {
         const double x  ( xb - ( ibin + 0.5 ) ) ;
         const double f1 ( shapeArray[ ibin - 1 ] ) ;
         const double f2 ( shapeArray[ ibin     ] ) ;
         const double f3 ( shapeArray[ ibin + 1 ] ) ;
         const double a  ( f2 ) ;
         const double b  ( ( f3 - f1 )/2. ) ;
         const double c  ( ( f1 + f3 )/2. - f2 ) ;
         value = a + b*x + c*x*x;
         deriv = ( b + 2*c*x )/delta ;
      }

      m_shape[ j ] = value;
      if( 0 != m_derivPtr ) (*m_derivPtr)[ j ] = deriv;

      if( 0      <  j                         &&
          thresh <  value                     &&
          0      == m_firstIndexOverThreshold     )
      {
         m_firstIndexOverThreshold = j - 1 ;
         m_firstTimeOverThreshold  = m_firstIndexOverThreshold*qNSecPerBin ;
      }

      if( m_shape[ m_indexOfMax ] < value )
      {
         m_indexOfMax = j ;
      }

//      LogDebug("EcalShapeBase") << " time (ns) = " << ( j + 1.0 )*qNSecPerBin - delta 
//                              << " interpolated ECAL pulse shape = " << m_shape[ j ] 
//                              << " derivative = " << ( 0 != m_derivPtr ? (*m_derivPtr)[ j ] : 0 ) ;
   }
   m_timeOfMax = m_indexOfMax*qNSecPerBin ;
}
double EcalShapeBase::derivative ( double  time) const

Definition at line 149 of file EcalShapeBase.cc.

References getHLTprescales::index, kNBinsStored, m_derivPtr, and timeIndex().

{
   const unsigned int index ( timeIndex( aTime ) ) ;
   return ( 0            == m_derivPtr ||
            kNBinsStored == index         ? 0 : (*m_derivPtr)[ index ] ) ;
}
virtual void EcalShapeBase::fillShape ( DVec aVec) const [protected, pure virtual]

Implemented in APDShape, EBShape, and EEShape.

Referenced by buildMe().

double EcalShapeBase::operator() ( double  aTime) const [virtual]

Implements CaloVShape.

Definition at line 140 of file EcalShapeBase.cc.

References getHLTprescales::index, kNBinsStored, m_shape, and timeIndex().

{
   // return pulse amplitude for request time in ns

   const unsigned int index ( timeIndex( aTime ) ) ;
   return ( kNBinsStored == index ? 0 : m_shape[ index ] ) ;
}
virtual double EcalShapeBase::threshold ( ) const [pure virtual]

Implemented in APDShape, EBShape, and EEShape.

Referenced by buildMe().

unsigned int EcalShapeBase::timeIndex ( double  aTime) const [protected]

Definition at line 124 of file EcalShapeBase.cc.

References cond::ecalcond::bad(), getHLTprescales::index, kNBinsPerNSec, kNBinsStored, LogDebug, and m_firstIndexOverThreshold.

Referenced by derivative(), and operator()().

{
   const int index ( m_firstIndexOverThreshold +
                     (unsigned int) ( aTime*kNBinsPerNSec + 0.5 ) ) ;

   const bool bad ( (int) m_firstIndexOverThreshold >  index || 
                    (int) kNBinsStored              <= index    ) ;

   if(              (int) kNBinsStored              <= index    )
   {
      LogDebug("EcalShapeBase") << " ECAL MGPA shape requested for out of range time " << aTime ;
   }
   return ( bad ? kNBinsStored : (unsigned int) index ) ;
}
double EcalShapeBase::timeOfMax ( ) const

Definition at line 33 of file EcalShapeBase.cc.

References m_timeOfMax.

Referenced by timeToRise().

{
   return m_timeOfMax              ; 
}
double EcalShapeBase::timeOfThr ( ) const

Definition at line 27 of file EcalShapeBase.cc.

References m_firstTimeOverThreshold.

Referenced by timeToRise().

double EcalShapeBase::timeToRise ( ) const [virtual]

Member Data Documentation

Definition at line 56 of file EcalShapeBase.h.

Referenced by buildMe(), derivative(), and ~EcalShapeBase().

Definition at line 51 of file EcalShapeBase.h.

Referenced by buildMe(), and timeIndex().

Definition at line 52 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfThr().

unsigned int EcalShapeBase::m_indexOfMax [private]

Definition at line 53 of file EcalShapeBase.h.

Referenced by buildMe().

Definition at line 55 of file EcalShapeBase.h.

Referenced by buildMe(), and operator()().

double EcalShapeBase::m_timeOfMax [private]

Definition at line 54 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfMax().

const double EcalShapeBase::qNSecPerBin = 1./(1.*kNBinsPerNSec) [static]

Definition at line 39 of file EcalShapeBase.h.

Referenced by buildMe().