CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

Public Types

typedef std::vector< double > DVec
 

Public Member Functions

unsigned int indexOfMax () 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

unsigned int indexOfMax_
 
const double qNSecPerBin_
 
DVec shape_
 
double timeOfMax_
 

Detailed Description

Definition at line 9 of file MTDShapeBase.h.

Member Typedef Documentation

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

Definition at line 11 of file MTDShapeBase.h.

Constructor & Destructor Documentation

MTDShapeBase::MTDShapeBase ( )

Definition at line 6 of file MTDShapeBase.cc.

const double qNSecPerBin_
Definition: MTDShapeBase.h:40
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:26
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:27
double timeOfMax_
Definition: MTDShapeBase.h:42
unsigned int indexOfMax_
Definition: MTDShapeBase.h:41
std::vector< double > DVec
Definition: MTDShapeBase.h:11
MTDShapeBase::~MTDShapeBase ( )
override

Definition at line 4 of file MTDShapeBase.cc.

4 {}

Member Function Documentation

void MTDShapeBase::buildMe ( )
protected

Definition at line 73 of file MTDShapeBase.cc.

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

Referenced by BTLPulseShape::BTLPulseShape().

73  {
74  // --- Fill the vector with the pulse shape
76 
77  // --- Find the index of maximum
78  for (unsigned int i = 0; i < shape_.size(); ++i) {
79  if (shape_[indexOfMax_] < shape_[i])
80  indexOfMax_ = i;
81  }
82 
83  if (indexOfMax_ != 0)
85 }
virtual void fillShape(DVec &aVec) const =0
const double qNSecPerBin_
Definition: MTDShapeBase.h:40
double timeOfMax_
Definition: MTDShapeBase.h:42
unsigned int indexOfMax_
Definition: MTDShapeBase.h:41
virtual void MTDShapeBase::fillShape ( DVec aVec) const
protectedpure virtual

Implemented in BTLPulseShape.

Referenced by buildMe().

unsigned int MTDShapeBase::indexOfMax ( ) const

Definition at line 69 of file MTDShapeBase.cc.

References indexOfMax_.

69 { return indexOfMax_; }
unsigned int indexOfMax_
Definition: MTDShapeBase.h:41
double MTDShapeBase::linear_interpolation ( const double &  y,
const double &  x1,
const double &  x2,
const double &  y1,
const double &  y2 
) const
private

Definition at line 104 of file MTDShapeBase.cc.

References a, b, and Exception.

Referenced by timeAtThr().

105  {
106  if (x1 == x2)
107  throw cms::Exception("BadValue") << " MTDShapeBase: Trying to interpolate two points with the same x coordinate!";
108 
109  double a = (y2 - y1) / (x2 - x1);
110  double b = y1 - a * x1;
111 
112  return (y - b) / a;
113 }
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
double MTDShapeBase::operator() ( double  aTime) const
overridevirtual

Implements CaloVShape.

Definition at line 98 of file MTDShapeBase.cc.

References k1NSecBinsTotal, shape_, and timeIndex().

98  {
99  // return pulse amplitude for request time in ns
100  const unsigned int index(timeIndex(aTime));
101  return (k1NSecBinsTotal == index ? 0 : shape_[index]);
102 }
unsigned int timeIndex(double aTime) const
Definition: MTDShapeBase.cc:87
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:27
std::array< float, 3 > MTDShapeBase::timeAtThr ( const float  scale,
const float  threshold1,
const float  threshold2 
) const

Definition at line 9 of file MTDShapeBase.cc.

References mps_fire::i, indexOfMax_, linear_interpolation(), qNSecPerBin_, pileupReCalc_HLTpaths::scale, and shape_.

Referenced by BTLElectronicsSim::run().

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

Definition at line 87 of file MTDShapeBase.cc.

References k1NSecBinsTotal, kNBinsPerNSec, and LogDebug.

Referenced by operator()().

87  {
88  const unsigned int index = aTime * kNBinsPerNSec;
89 
90  const bool bad = (k1NSecBinsTotal <= index);
91 
92  if (bad)
93  LogDebug("MTDShapeBase") << " MTD pulse shape requested for out of range time " << aTime;
94 
95  return (bad ? k1NSecBinsTotal : index);
96 }
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:26
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:27
#define LogDebug(id)
double MTDShapeBase::timeOfMax ( ) const

Definition at line 71 of file MTDShapeBase.cc.

References timeOfMax_.

71 { return timeOfMax_; }
double timeOfMax_
Definition: MTDShapeBase.h:42
double MTDShapeBase::timeToRise ( ) const
inlineoverridevirtual

Implements CaloVShape.

Definition at line 21 of file MTDShapeBase.h.

21 { return 0.; }

Member Data Documentation

unsigned int MTDShapeBase::indexOfMax_
private

Definition at line 41 of file MTDShapeBase.h.

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

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

Definition at line 27 of file MTDShapeBase.h.

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

constexpr unsigned int MTDShapeBase::kNBinsPerNSec = 100
static

Definition at line 26 of file MTDShapeBase.h.

Referenced by timeIndex().

constexpr unsigned int MTDShapeBase::kReadoutTimeInterval = 28
static

Definition at line 25 of file MTDShapeBase.h.

const double MTDShapeBase::qNSecPerBin_
private

Definition at line 40 of file MTDShapeBase.h.

Referenced by buildMe(), and timeAtThr().

DVec MTDShapeBase::shape_
private

Definition at line 43 of file MTDShapeBase.h.

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

double MTDShapeBase::timeOfMax_
private

Definition at line 42 of file MTDShapeBase.h.

Referenced by buildMe(), and timeOfMax().