CMS 3D CMS Logo

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

#include <MTDShapeBase.h>

Inheritance diagram for MTDShapeBase:
CaloVShape BTLPulseShape ETLPulseShape

Public Types

typedef std::vector< double > DVec
 

Public Member Functions

float fallTime () const
 
unsigned int indexOfMax () const
 
float maximum () const
 
 MTDShapeBase ()
 
double operator() (double aTime) const override
 
std::array< float, 3 > timeAtThr (const float scale, const float threshold1, const float threshold2) const
 
double timeOfMax () const
 
double timeToRise () const override
 
 ~MTDShapeBase () override
 
- Public Member Functions inherited from CaloVShape
 CaloVShape ()
 
virtual ~CaloVShape ()
 

Static Public Attributes

static constexpr unsigned int k1NSecBinsTotal = kReadoutTimeInterval * kNBinsPerNSec
 
static constexpr unsigned int kNBinsPerNSec = 100
 
static constexpr unsigned int kReadoutTimeInterval = 28
 

Protected Member Functions

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

Private Member Functions

double linear_interpolation (const double &y, const double &x1, const double &x2, const double &y1, const double &y2) const
 

Private Attributes

float fallTime_
 
unsigned int indexOfMax_
 
const double qNSecPerBin_
 
DVec shape_
 
double timeOfMax_
 

Detailed Description

Definition at line 9 of file MTDShapeBase.h.

Member Typedef Documentation

◆ DVec

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

Definition at line 11 of file MTDShapeBase.h.

Constructor & Destructor Documentation

◆ MTDShapeBase()

MTDShapeBase::MTDShapeBase ( )

Definition at line 6 of file MTDShapeBase.cc.

8  indexOfMax_(0),
9  timeOfMax_(0.),
10  fallTime_(0.),
11  shape_(DVec(k1NSecBinsTotal, 0.0)) {}
const double qNSecPerBin_
Definition: MTDShapeBase.h:42
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:28
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:29
double timeOfMax_
Definition: MTDShapeBase.h:44
unsigned int indexOfMax_
Definition: MTDShapeBase.h:43
std::vector< double > DVec
Definition: MTDShapeBase.h:11
float fallTime_
Definition: MTDShapeBase.h:45

◆ ~MTDShapeBase()

MTDShapeBase::~MTDShapeBase ( )
override

Definition at line 4 of file MTDShapeBase.cc.

4 {}

Member Function Documentation

◆ buildMe()

void MTDShapeBase::buildMe ( )
protected

Definition at line 81 of file MTDShapeBase.cc.

References fallTime_, fillShape(), mps_fire::i, indexOfMax_, qNSecPerBin_, shape_, and timeOfMax_.

Referenced by BTLPulseShape::BTLPulseShape(), and ETLPulseShape::ETLPulseShape().

81  {
82  // --- Fill the vector with the pulse shape
84 
85  // --- Find the index of maximum
86  for (unsigned int i = 0; i < shape_.size(); ++i) {
87  if (shape_[indexOfMax_] < shape_[i])
88  indexOfMax_ = i;
89  }
90 
91  for (unsigned int i = indexOfMax_; i < shape_.size(); ++i) {
92  if (shape_[indexOfMax_] * 0.01 > shape_[i]) {
94  break;
95  }
96  }
97 
98  if (indexOfMax_ != 0)
100 }
virtual void fillShape(DVec &aVec) const =0
const double qNSecPerBin_
Definition: MTDShapeBase.h:42
double timeOfMax_
Definition: MTDShapeBase.h:44
unsigned int indexOfMax_
Definition: MTDShapeBase.h:43
float fallTime_
Definition: MTDShapeBase.h:45

◆ fallTime()

float MTDShapeBase::fallTime ( ) const

Definition at line 79 of file MTDShapeBase.cc.

References fallTime_.

Referenced by ETLElectronicsSim::run().

79 { return fallTime_; }
float fallTime_
Definition: MTDShapeBase.h:45

◆ fillShape()

virtual void MTDShapeBase::fillShape ( DVec aVec) const
protectedpure virtual

Implemented in BTLPulseShape, and ETLPulseShape.

Referenced by buildMe().

◆ indexOfMax()

unsigned int MTDShapeBase::indexOfMax ( ) const

Definition at line 73 of file MTDShapeBase.cc.

References indexOfMax_.

73 { return indexOfMax_; }
unsigned int indexOfMax_
Definition: MTDShapeBase.h:43

◆ linear_interpolation()

double MTDShapeBase::linear_interpolation ( const double &  y,
const double &  x1,
const double &  x2,
const double &  y1,
const double &  y2 
) const
private

Definition at line 119 of file MTDShapeBase.cc.

References a, b, Exception, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, y, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

Referenced by timeAtThr().

120  {
121  if (x1 == x2)
122  throw cms::Exception("BadValue") << " MTDShapeBase: Trying to interpolate two points with the same x coordinate!";
123 
124  double a = (y2 - y1) / (x2 - x1);
125  double b = y1 - a * x1;
126 
127  return (y - b) / a;
128 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ maximum()

float MTDShapeBase::maximum ( ) const

Definition at line 77 of file MTDShapeBase.cc.

References indexOfMax_, and shape_.

Referenced by ETLElectronicsSim::run().

77 { return shape_[indexOfMax_]; }
unsigned int indexOfMax_
Definition: MTDShapeBase.h:43

◆ operator()()

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

Implements CaloVShape.

Definition at line 113 of file MTDShapeBase.cc.

References k1NSecBinsTotal, shape_, and timeIndex().

113  {
114  // return pulse amplitude for request time in ns
115  const unsigned int index(timeIndex(aTime));
116  return (k1NSecBinsTotal == index ? 0 : shape_[index]);
117 }
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:29
unsigned int timeIndex(double aTime) const

◆ timeAtThr()

std::array< float, 3 > MTDShapeBase::timeAtThr ( const float  scale,
const float  threshold1,
const float  threshold2 
) const

Definition at line 13 of file MTDShapeBase.cc.

References CustomPhysics_cfi::amplitude, mps_fire::i, indexOfMax_, linear_interpolation(), qNSecPerBin_, isotrackNtupler::scale, and shape_.

Referenced by BTLElectronicsSim::run(), and ETLElectronicsSim::run().

13  {
14  std::array<float, 3> times_tmp = {{0., 0., 0.}};
15 
16  // --- Check if the pulse amplitude is greater than threshold 2
17  if (shape_[indexOfMax_] * scale < threshold2)
18  return times_tmp;
19 
20  // --- Find the times corresponding to thresholds 1 and 2 on the pulse leading edge
21  // NB: To speed up the search we loop only on the rising edge
22  unsigned int index_LT1 = 0;
23  unsigned int index_LT2 = 0;
24 
25  for (unsigned int i = 0; i < indexOfMax_; ++i) {
26  float amplitude = shape_[i] * scale;
27 
28  if (amplitude > threshold1 && index_LT1 == 0)
29  index_LT1 = i;
30 
31  if (amplitude > threshold2 && index_LT2 == 0) {
32  index_LT2 = i;
33  break;
34  }
35  }
36 
37  // --- Find the time corresponding to thresholds 1 on the pulse falling edge
38  unsigned int index_FT1 = 0;
39 
40  for (unsigned int i = shape_.size() - 1; i > indexOfMax_; i--) {
41  float amplitude = shape_[i] * scale;
42 
43  if (amplitude > threshold1 && index_FT1 == 0) {
44  index_FT1 = i + 1;
45  break;
46  }
47  }
48 
49  if (index_LT1 != 0)
50  times_tmp[0] = linear_interpolation(threshold1,
51  (index_LT1 - 1) * qNSecPerBin_,
52  index_LT1 * qNSecPerBin_,
53  shape_[index_LT1 - 1] * scale,
54  shape_[index_LT1] * scale);
55 
56  if (index_LT2 != 0)
57  times_tmp[1] = linear_interpolation(threshold2,
58  (index_LT2 - 1) * qNSecPerBin_,
59  index_LT2 * qNSecPerBin_,
60  shape_[index_LT2 - 1] * scale,
61  shape_[index_LT2] * scale);
62 
63  if (index_FT1 != 0)
64  times_tmp[2] = linear_interpolation(threshold1,
65  (index_FT1 - 1) * qNSecPerBin_,
66  index_FT1 * qNSecPerBin_,
67  shape_[index_FT1 - 1] * scale,
68  shape_[index_FT1] * scale);
69 
70  return times_tmp;
71 }
const double qNSecPerBin_
Definition: MTDShapeBase.h:42
double linear_interpolation(const double &y, const double &x1, const double &x2, const double &y1, const double &y2) const
unsigned int indexOfMax_
Definition: MTDShapeBase.h:43

◆ timeIndex()

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

Definition at line 102 of file MTDShapeBase.cc.

References k1NSecBinsTotal, kNBinsPerNSec, and LogDebug.

Referenced by operator()().

102  {
103  const unsigned int index = aTime * kNBinsPerNSec;
104 
105  const bool bad = (k1NSecBinsTotal <= index);
106 
107  if (bad)
108  LogDebug("MTDShapeBase") << " MTD pulse shape requested for out of range time " << aTime;
109 
110  return (bad ? k1NSecBinsTotal : index);
111 }
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:28
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:29
#define LogDebug(id)

◆ timeOfMax()

double MTDShapeBase::timeOfMax ( ) const

Definition at line 75 of file MTDShapeBase.cc.

References timeOfMax_.

Referenced by ETLElectronicsSim::run().

75 { return timeOfMax_; }
double timeOfMax_
Definition: MTDShapeBase.h:44

◆ timeToRise()

double MTDShapeBase::timeToRise ( ) const
inlineoverridevirtual

Implements CaloVShape.

Definition at line 21 of file MTDShapeBase.h.

21 { return 0.; }

Member Data Documentation

◆ fallTime_

float MTDShapeBase::fallTime_
private

Definition at line 45 of file MTDShapeBase.h.

Referenced by buildMe(), and fallTime().

◆ indexOfMax_

unsigned int MTDShapeBase::indexOfMax_
private

Definition at line 43 of file MTDShapeBase.h.

Referenced by buildMe(), indexOfMax(), maximum(), and timeAtThr().

◆ k1NSecBinsTotal

constexpr unsigned int MTDShapeBase::k1NSecBinsTotal = kReadoutTimeInterval * kNBinsPerNSec
static

Definition at line 29 of file MTDShapeBase.h.

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

◆ kNBinsPerNSec

constexpr unsigned int MTDShapeBase::kNBinsPerNSec = 100
static

Definition at line 28 of file MTDShapeBase.h.

Referenced by timeIndex().

◆ kReadoutTimeInterval

constexpr unsigned int MTDShapeBase::kReadoutTimeInterval = 28
static

Definition at line 27 of file MTDShapeBase.h.

◆ qNSecPerBin_

const double MTDShapeBase::qNSecPerBin_
private

Definition at line 42 of file MTDShapeBase.h.

Referenced by buildMe(), and timeAtThr().

◆ shape_

DVec MTDShapeBase::shape_
private

Definition at line 46 of file MTDShapeBase.h.

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

◆ timeOfMax_

double MTDShapeBase::timeOfMax_
private

Definition at line 44 of file MTDShapeBase.h.

Referenced by buildMe(), and timeOfMax().