CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
EcalShapeBase Class Referenceabstract

#include <EcalShapeBase.h>

Inheritance diagram for EcalShapeBase:
CaloVShape APDShape EBShape EEShape

Public Types

typedef std::vector< double > DVec
 

Public Member Functions

double derivative (double time) const
 
 EcalShapeBase (bool)
 
void m_shape_print (const char *fileName)
 
double operator() (double aTime) const override
 
void setEventSetup (const edm::EventSetup &evtSetup)
 
double threshold () const
 
double timeOfMax () const
 
double timeOfThr () const
 
double timeToRise () const override
 
 ~EcalShapeBase () override
 
- Public Member Functions inherited from CaloVShape
 CaloVShape ()
 
virtual ~CaloVShape ()
 

Protected Member Functions

void buildMe ()
 
virtual void fillShape (float &time_interval, double &m_thresh, EcalShapeBase::DVec &aVec, const edm::EventSetup *es) const =0
 
unsigned int timeIndex (double aTime) const
 

Protected Attributes

bool m_useDBShape
 

Private Attributes

unsigned int m_arraySize
 
unsigned int m_denseArraySize
 
DVec m_deriv
 
const edm::EventSetupm_es
 
unsigned int m_firstIndexOverThreshold
 
double m_firstTimeOverThreshold
 
unsigned int m_indexOfMax
 
unsigned int m_kNBinsPerNSec
 
double m_qNSecPerBin
 
DVec m_shape
 
double m_thresh
 
double m_timeOfMax
 

Detailed Description

Definition at line 24 of file EcalShapeBase.h.

Member Typedef Documentation

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

Definition at line 28 of file EcalShapeBase.h.

Constructor & Destructor Documentation

EcalShapeBase::EcalShapeBase ( bool  useDBShape)

Definition at line 13 of file EcalShapeBase.cc.

13  :
14  m_useDBShape (useDBShape),
16  m_firstTimeOverThreshold ( 0.0 ) ,
17  m_indexOfMax ( 0 ) ,
18  m_timeOfMax ( 0.0 ) ,
19  m_thresh ( 0.0 ) ,
20  m_es ( nullptr )
21 {
22 }
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:59
unsigned int m_indexOfMax
Definition: EcalShapeBase.h:60
double m_timeOfMax
Definition: EcalShapeBase.h:61
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:58
const edm::EventSetup * m_es
Definition: EcalShapeBase.h:70
EcalShapeBase::~EcalShapeBase ( )
override

Definition at line 9 of file EcalShapeBase.cc.

10 {
11 }

Member Function Documentation

void EcalShapeBase::buildMe ( )
protected

Definition at line 54 of file EcalShapeBase.cc.

References a, b, EnergyCorrector::c, delta, MillePedeFileConverter_cfg::e, connectstrParser::f1, connectstrParser::f2, connectstrParser::f3, fillShape(), mps_fire::i, createfilelist::int, m_arraySize, m_denseArraySize, m_deriv, m_es, m_firstIndexOverThreshold, m_firstTimeOverThreshold, m_indexOfMax, m_kNBinsPerNSec, m_qNSecPerBin, m_shape, m_thresh, m_timeOfMax, scrapingFilter_cfi::thresh, threshold(), relativeConstraints::value, and x.

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

55 {
56  DVec shapeArray;
57 
58  float time_interval = 0;
59  fillShape(time_interval, m_thresh, shapeArray, m_es) ; // pure virtual function, implementation may vary for EB/EE/APD ...
60  m_arraySize = shapeArray.size(); // original data
61 
62  m_denseArraySize = 10*m_arraySize; // dense array with interpolation between data
63  m_kNBinsPerNSec = (unsigned int) (10/time_interval); // used to be an unsigned int = 10 in < CMSSW10X, should work for time intervals ~0.1, 0.2, 0.5, 1
64  m_qNSecPerBin = time_interval/10.;
65 
66  for(unsigned int i = 0; i < m_denseArraySize; ++i) { m_deriv.push_back(0.0); m_shape.push_back(0.0); }
67 
68  const double maxel ( *max_element( shapeArray.begin(), shapeArray.end() ) ) ;
69 
70  const double maxelt ( 1.e-5 < maxel ? maxel : 1 ) ;
71 
72  for( unsigned int i ( 0 ) ; i != shapeArray.size(); ++i )
73  {
74  shapeArray[i] = shapeArray[i]/maxelt ;
75  }
76 
77  const double thresh ( threshold()/maxelt ) ;
78 
79 
80 
81  const double delta ( m_qNSecPerBin/2. ) ;
82 
83  for( unsigned int denseIndex ( 0 ) ; denseIndex != m_denseArraySize ; ++denseIndex )
84  {
85  const double xb ( ( denseIndex + 0.5 )*m_qNSecPerBin ) ;
86 
87  const unsigned int ibin ( denseIndex/10 ) ;
88 
89  double value = 0.0 ;
90  double deriv = 0.0 ;
91 
92  if( 0 == ibin ||
93  shapeArray.size() == 1 + ibin ) // cannot do quadratic interpolation at ends
94  {
95  value = shapeArray[ibin];
96  deriv = 0.0 ;
97  }
98  else
99  {
100  const double x ( xb - ( ibin + 0.5 )*time_interval ) ;
101  const double f1 ( shapeArray[ ibin - 1 ] ) ;
102  const double f2 ( shapeArray[ ibin ] ) ;
103  const double f3 ( shapeArray[ ibin + 1 ] ) ;
104  const double a ( f2 ) ;
105  const double b ( ( f3 - f1 )/(2.*time_interval) ) ;
106  const double c ( (( f1 + f3 )/2. - f2 )/(time_interval*time_interval) );
107  value = a + b*x + c*x*x;
108  deriv = ( b + 2*c*x )/delta ;
109  }
110 
111  m_shape[ denseIndex ] = value;
112  m_deriv[ denseIndex ] = deriv;
113 
114  if( 0 < denseIndex &&
115  thresh < value &&
117  {
118  m_firstIndexOverThreshold = denseIndex - 1 ;
120  }
121 
122  if( m_shape[ m_indexOfMax ] < value )
123  {
124  m_indexOfMax = denseIndex ;
125  }
126 
127  }
129 
130 }
dbl * delta
Definition: mlp_gen.cc:36
virtual void fillShape(float &time_interval, double &m_thresh, EcalShapeBase::DVec &aVec, const edm::EventSetup *es) const =0
double threshold() const
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:68
std::vector< double > DVec
Definition: EcalShapeBase.h:28
Definition: value.py:1
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:59
double m_qNSecPerBin
Definition: EcalShapeBase.h:69
unsigned int m_arraySize
Definition: EcalShapeBase.h:67
double b
Definition: hdecay.h:120
unsigned int m_indexOfMax
Definition: EcalShapeBase.h:60
double m_timeOfMax
Definition: EcalShapeBase.h:61
double a
Definition: hdecay.h:121
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:58
const edm::EventSetup * m_es
Definition: EcalShapeBase.h:70
unsigned int m_kNBinsPerNSec
Definition: EcalShapeBase.h:63
double EcalShapeBase::derivative ( double  time) const

Definition at line 158 of file EcalShapeBase.cc.

References m_denseArraySize, m_deriv, and timeIndex().

159 {
160  const unsigned int index ( timeIndex( aTime ) ) ;
161  return ( m_denseArraySize == index ? 0 : m_deriv[ index ] ) ;
162 }
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:68
unsigned int timeIndex(double aTime) const
virtual void EcalShapeBase::fillShape ( float &  time_interval,
double &  m_thresh,
EcalShapeBase::DVec aVec,
const edm::EventSetup es 
) const
protectedpure virtual

Implemented in APDShape, EBShape, and EEShape.

Referenced by buildMe().

void EcalShapeBase::m_shape_print ( const char *  fileName)

Definition at line 165 of file EcalShapeBase.cc.

References mps_fire::i, and m_shape.

165 {std::ofstream fs; fs.open(fileName); for (auto i:m_shape) fs << "vec.push_back(" << i << ");\n"; fs.close();}
double EcalShapeBase::operator() ( double  aTime) const
overridevirtual

Implements CaloVShape.

Definition at line 149 of file EcalShapeBase.cc.

References m_denseArraySize, m_shape, and timeIndex().

150 {
151  // return pulse amplitude for request time in ns
152 
153  const unsigned int index ( timeIndex( aTime ) ) ;
154  return ( m_denseArraySize == index ? 0 : m_shape[ index ] ) ;
155 }
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:68
unsigned int timeIndex(double aTime) const
void EcalShapeBase::setEventSetup ( const edm::EventSetup evtSetup)
double EcalShapeBase::threshold ( ) const

Definition at line 47 of file EcalShapeBase.cc.

References m_thresh.

Referenced by buildMe().

48 {
49  return m_thresh;
50 }
unsigned int EcalShapeBase::timeIndex ( double  aTime) const
protected

Definition at line 133 of file EcalShapeBase.cc.

References LogDebug, m_denseArraySize, m_firstIndexOverThreshold, and m_kNBinsPerNSec.

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

134 {
135  const int index ( m_firstIndexOverThreshold +
136  (unsigned int) ( aTime*m_kNBinsPerNSec + 0.5 ) ) ;
137 
138  const bool bad ( (int) m_firstIndexOverThreshold > index ||
139  (int) m_denseArraySize <= index ) ;
140 
141  if( (int) m_denseArraySize <= index )
142  {
143  LogDebug("EcalShapeBase") << " ECAL MGPA shape requested for out of range time " << aTime ;
144  }
145  return ( bad ? m_denseArraySize : (unsigned int) index ) ;
146 }
#define LogDebug(id)
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:68
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:58
unsigned int m_kNBinsPerNSec
Definition: EcalShapeBase.h:63
double EcalShapeBase::timeOfMax ( ) const

Definition at line 34 of file EcalShapeBase.cc.

References m_timeOfMax.

Referenced by EcalTPGParamBuilder::computeWeights(), and timeToRise().

35 {
36  return m_timeOfMax ;
37 }
double m_timeOfMax
Definition: EcalShapeBase.h:61
double EcalShapeBase::timeOfThr ( ) const

Definition at line 28 of file EcalShapeBase.cc.

References m_firstTimeOverThreshold.

Referenced by EcalTPGParamBuilder::computeWeights(), and timeToRise().

29 {
31  }
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:59
double EcalShapeBase::timeToRise ( ) const
overridevirtual

Implements CaloVShape.

Definition at line 40 of file EcalShapeBase.cc.

References timeOfMax(), and timeOfThr().

Referenced by EcalDccWeightBuilder::computeWeights(), and EcalUncalibRecHitRecChi2Algo< C >::EcalUncalibRecHitRecChi2Algo().

41 {
42  return timeOfMax() - timeOfThr() ;
43 }
double timeOfThr() const
double timeOfMax() const

Member Data Documentation

unsigned int EcalShapeBase::m_arraySize
private

Definition at line 67 of file EcalShapeBase.h.

Referenced by buildMe().

unsigned int EcalShapeBase::m_denseArraySize
private

Definition at line 68 of file EcalShapeBase.h.

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

DVec EcalShapeBase::m_deriv
private

Definition at line 65 of file EcalShapeBase.h.

Referenced by buildMe(), and derivative().

const edm::EventSetup* EcalShapeBase::m_es
private

Definition at line 70 of file EcalShapeBase.h.

Referenced by buildMe(), and setEventSetup().

unsigned int EcalShapeBase::m_firstIndexOverThreshold
private

Definition at line 58 of file EcalShapeBase.h.

Referenced by buildMe(), and timeIndex().

double EcalShapeBase::m_firstTimeOverThreshold
private

Definition at line 59 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfThr().

unsigned int EcalShapeBase::m_indexOfMax
private

Definition at line 60 of file EcalShapeBase.h.

Referenced by buildMe().

unsigned int EcalShapeBase::m_kNBinsPerNSec
private

Definition at line 63 of file EcalShapeBase.h.

Referenced by buildMe(), and timeIndex().

double EcalShapeBase::m_qNSecPerBin
private

Definition at line 69 of file EcalShapeBase.h.

Referenced by buildMe().

DVec EcalShapeBase::m_shape
private

Definition at line 64 of file EcalShapeBase.h.

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

double EcalShapeBase::m_thresh
private
double EcalShapeBase::m_timeOfMax
private

Definition at line 61 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfMax().

bool EcalShapeBase::m_useDBShape
protected

Definition at line 54 of file EcalShapeBase.h.

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