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 ComponentShape 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) const
 
double operator() (double aTime) const override
 
void setEventSetup (const edm::EventSetup &evtSetup, bool normalize=true)
 
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 (const edm::EventSetup *=nullptr, bool normalize=true)
 
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
 
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

◆ DVec

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

Definition at line 26 of file EcalShapeBase.h.

Constructor & Destructor Documentation

◆ EcalShapeBase()

EcalShapeBase::EcalShapeBase ( bool  useDBShape)

Definition at line 11 of file EcalShapeBase.cc.

12  : m_useDBShape(useDBShape),
15  m_indexOfMax(0),
16  m_timeOfMax(0.0),
17  m_thresh(0.0) {}
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:58
unsigned int m_indexOfMax
Definition: EcalShapeBase.h:59
double m_timeOfMax
Definition: EcalShapeBase.h:60
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:57

◆ ~EcalShapeBase()

EcalShapeBase::~EcalShapeBase ( )
override

Definition at line 9 of file EcalShapeBase.cc.

9 {}

Member Function Documentation

◆ buildMe()

void EcalShapeBase::buildMe ( const edm::EventSetup evtSetup = nullptr,
bool  normalize = true 
)
protected

Definition at line 29 of file EcalShapeBase.cc.

References a, b, HltBtagPostValidation_cff::c, dumpMFGeometry_cfg::delta, MillePedeFileConverter_cfg::e, DeadROC_duringRun::f1, DeadROC_duringRun::f2, fillShape(), mps_fire::i, createfilelist::int, m_arraySize, m_denseArraySize, m_deriv, m_firstIndexOverThreshold, m_firstTimeOverThreshold, m_indexOfMax, m_kNBinsPerNSec, m_qNSecPerBin, m_shape, m_thresh, m_timeOfMax, reco::mlpf::normalize(), DMR_cfg::thresh, threshold(), relativeConstraints::value, and x.

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

29  {
30  DVec shapeArray;
31 
32  float time_interval = 0;
33  fillShape(time_interval,
34  m_thresh,
35  shapeArray,
36  evtSetup); // pure virtual function, implementation may vary for EB/EE/APD ...
37  m_arraySize = shapeArray.size(); // original data
38 
39  m_denseArraySize = 10 * m_arraySize; // dense array with interpolation between data
41  (unsigned int)(10 /
42  time_interval); // used to be an unsigned int = 10 in < CMSSW10X, should work for time intervals ~0.1, 0.2, 0.5, 1
43  m_qNSecPerBin = time_interval / 10.;
44 
45  m_deriv.resize(m_denseArraySize);
46  m_shape.resize(m_denseArraySize);
47 
48  const double maxel(*max_element(shapeArray.begin(), shapeArray.end()));
49 
50  const double maxelt(1.e-5 < maxel ? maxel : 1);
51 
52  if (normalize) {
53  for (unsigned int i(0); i != shapeArray.size(); ++i) {
54  shapeArray[i] = shapeArray[i] / maxelt;
55  }
56  }
57 
58  const double thresh(threshold() / maxelt);
59 
60  const double delta(m_qNSecPerBin / 2.);
61 
62  for (unsigned int denseIndex(0); denseIndex != m_denseArraySize; ++denseIndex) {
63  const double xb((denseIndex + 0.5) * m_qNSecPerBin);
64 
65  const unsigned int ibin(denseIndex / 10);
66 
67  double value = 0.0;
68  double deriv = 0.0;
69 
70  if (0 == ibin || shapeArray.size() == 1 + ibin) // cannot do quadratic interpolation at ends
71  {
72  value = shapeArray[ibin];
73  deriv = 0.0;
74  } else {
75  const double x(xb - (ibin + 0.5) * time_interval);
76  const double f1(shapeArray[ibin - 1]);
77  const double f2(shapeArray[ibin]);
78  const double f3(shapeArray[ibin + 1]);
79  const double a(f2);
80  const double b((f3 - f1) / (2. * time_interval));
81  const double c(((f1 + f3) / 2. - f2) / (time_interval * time_interval));
82  value = a + b * x + c * x * x;
83  deriv = (b + 2 * c * x) / delta;
84  }
85 
86  m_shape[denseIndex] = value;
87  m_deriv[denseIndex] = deriv;
88 
89  if (0 < denseIndex && thresh < value && 0 == m_firstIndexOverThreshold) {
90  m_firstIndexOverThreshold = denseIndex - 1;
92  }
93 
94  if (m_shape[m_indexOfMax] < value) {
95  m_indexOfMax = denseIndex;
96  }
97  }
99 }
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:67
std::vector< double > DVec
Definition: EcalShapeBase.h:26
Definition: value.py:1
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:58
double m_qNSecPerBin
Definition: EcalShapeBase.h:68
unsigned int m_arraySize
Definition: EcalShapeBase.h:66
double b
Definition: hdecay.h:120
unsigned int m_indexOfMax
Definition: EcalShapeBase.h:59
double m_timeOfMax
Definition: EcalShapeBase.h:60
float normalize(float in)
Definition: MLPFModel.cc:207
double a
Definition: hdecay.h:121
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:57
unsigned int m_kNBinsPerNSec
Definition: EcalShapeBase.h:62

◆ derivative()

double EcalShapeBase::derivative ( double  time) const

Definition at line 119 of file EcalShapeBase.cc.

References m_denseArraySize, m_deriv, and timeIndex().

119  {
120  const unsigned int index(timeIndex(aTime));
121  return (m_denseArraySize == index ? 0 : m_deriv[index]);
122 }
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:67
unsigned int timeIndex(double aTime) const

◆ fillShape()

virtual void EcalShapeBase::fillShape ( float &  time_interval,
double &  m_thresh,
EcalShapeBase::DVec aVec,
const edm::EventSetup es 
) const
protectedpure virtual

Implemented in ComponentShape, APDShape, EBShape, and EEShape.

Referenced by buildMe().

◆ m_shape_print()

void EcalShapeBase::m_shape_print ( const char *  fileName) const

Definition at line 124 of file EcalShapeBase.cc.

References MillePedeFileConverter_cfg::fileName, compareTotals::fs, mps_fire::i, and m_shape.

124  {
125  std::ofstream fs;
126  fs.open(fileName);
127  fs << "{\n";
128  for (auto i : m_shape)
129  fs << "vec.push_back(" << i << ");\n";
130  fs << "}\n";
131  fs.close();
132 }

◆ operator()()

double EcalShapeBase::operator() ( double  aTime) const
overridevirtual

Implements CaloVShape.

Definition at line 112 of file EcalShapeBase.cc.

References m_denseArraySize, m_shape, and timeIndex().

112  {
113  // return pulse amplitude for request time in ns
114 
115  const unsigned int index(timeIndex(aTime));
116  return (m_denseArraySize == index ? 0 : m_shape[index]);
117 }
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:67
unsigned int timeIndex(double aTime) const

◆ setEventSetup()

void EcalShapeBase::setEventSetup ( const edm::EventSetup evtSetup,
bool  normalize = true 
)

Definition at line 19 of file EcalShapeBase.cc.

References buildMe(), and reco::mlpf::normalize().

Referenced by EcalDigiProducer_Ph2::accumulate(), EcalDigiProducer::accumulate(), EcalTPGParamBuilder::analyze(), EcalUncalibRecHitWorkerWeights::set(), and EcalUncalibRecHitWorkerGlobal::set().

19 { buildMe(&evtSetup, normalize); }
float normalize(float in)
Definition: MLPFModel.cc:207
void buildMe(const edm::EventSetup *=nullptr, bool normalize=true)

◆ threshold()

double EcalShapeBase::threshold ( ) const

Definition at line 27 of file EcalShapeBase.cc.

References m_thresh.

Referenced by buildMe().

27 { return m_thresh; }

◆ timeIndex()

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

Definition at line 101 of file EcalShapeBase.cc.

References LogDebug, m_denseArraySize, m_firstIndexOverThreshold, and m_kNBinsPerNSec.

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

101  {
102  const int index(m_firstIndexOverThreshold + (unsigned int)(aTime * m_kNBinsPerNSec + 0.5));
103 
104  const bool bad((int)m_firstIndexOverThreshold > index || (int)m_denseArraySize <= index);
105 
106  if ((int)m_denseArraySize <= index) {
107  LogDebug("EcalShapeBase") << " ECAL MGPA shape requested for out of range time " << aTime;
108  }
109  return (bad ? m_denseArraySize : (unsigned int)index);
110 }
unsigned int m_denseArraySize
Definition: EcalShapeBase.h:67
unsigned int m_firstIndexOverThreshold
Definition: EcalShapeBase.h:57
unsigned int m_kNBinsPerNSec
Definition: EcalShapeBase.h:62
#define LogDebug(id)

◆ timeOfMax()

double EcalShapeBase::timeOfMax ( ) const

Definition at line 23 of file EcalShapeBase.cc.

References m_timeOfMax.

Referenced by timeToRise().

23 { return m_timeOfMax; }
double m_timeOfMax
Definition: EcalShapeBase.h:60

◆ timeOfThr()

double EcalShapeBase::timeOfThr ( ) const

Definition at line 21 of file EcalShapeBase.cc.

References m_firstTimeOverThreshold.

Referenced by timeToRise().

21 { return m_firstTimeOverThreshold; }
double m_firstTimeOverThreshold
Definition: EcalShapeBase.h:58

◆ timeToRise()

double EcalShapeBase::timeToRise ( ) const
overridevirtual

Implements CaloVShape.

Definition at line 25 of file EcalShapeBase.cc.

References timeOfMax(), and timeOfThr().

Referenced by EcalUncalibRecHitRecChi2Algo< C >::EcalUncalibRecHitRecChi2Algo().

25 { return timeOfMax() - timeOfThr(); }
double timeOfThr() const
double timeOfMax() const

Member Data Documentation

◆ m_arraySize

unsigned int EcalShapeBase::m_arraySize
private

Definition at line 66 of file EcalShapeBase.h.

Referenced by buildMe().

◆ m_denseArraySize

unsigned int EcalShapeBase::m_denseArraySize
private

Definition at line 67 of file EcalShapeBase.h.

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

◆ m_deriv

DVec EcalShapeBase::m_deriv
private

Definition at line 64 of file EcalShapeBase.h.

Referenced by buildMe(), and derivative().

◆ m_firstIndexOverThreshold

unsigned int EcalShapeBase::m_firstIndexOverThreshold
private

Definition at line 57 of file EcalShapeBase.h.

Referenced by buildMe(), and timeIndex().

◆ m_firstTimeOverThreshold

double EcalShapeBase::m_firstTimeOverThreshold
private

Definition at line 58 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfThr().

◆ m_indexOfMax

unsigned int EcalShapeBase::m_indexOfMax
private

Definition at line 59 of file EcalShapeBase.h.

Referenced by buildMe().

◆ m_kNBinsPerNSec

unsigned int EcalShapeBase::m_kNBinsPerNSec
private

Definition at line 62 of file EcalShapeBase.h.

Referenced by buildMe(), and timeIndex().

◆ m_qNSecPerBin

double EcalShapeBase::m_qNSecPerBin
private

Definition at line 68 of file EcalShapeBase.h.

Referenced by buildMe().

◆ m_shape

DVec EcalShapeBase::m_shape
private

Definition at line 63 of file EcalShapeBase.h.

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

◆ m_thresh

double EcalShapeBase::m_thresh
private

◆ m_timeOfMax

double EcalShapeBase::m_timeOfMax
private

Definition at line 60 of file EcalShapeBase.h.

Referenced by buildMe(), and timeOfMax().

◆ m_useDBShape

bool EcalShapeBase::m_useDBShape
protected