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

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 10 of file MTDShapeBase.h.

Member Typedef Documentation

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

Definition at line 14 of file MTDShapeBase.h.

Constructor & Destructor Documentation

MTDShapeBase::MTDShapeBase ( )

Definition at line 8 of file MTDShapeBase.cc.

8  :
10  indexOfMax_ ( 0 ),
11  timeOfMax_ ( 0. ),
12  shape_ ( DVec(k1NSecBinsTotal, 0.0) ) { }
const double qNSecPerBin_
Definition: MTDShapeBase.h:50
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:31
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:32
double timeOfMax_
Definition: MTDShapeBase.h:52
unsigned int indexOfMax_
Definition: MTDShapeBase.h:51
std::vector< double > DVec
Definition: MTDShapeBase.h:14
MTDShapeBase::~MTDShapeBase ( )
override

Definition at line 5 of file MTDShapeBase.cc.

5 { }

Member Function Documentation

void MTDShapeBase::buildMe ( )
protected

Definition at line 101 of file MTDShapeBase.cc.

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

Referenced by BTLPulseShape::BTLPulseShape().

102 {
103 
104  // --- Fill the vector with the pulse shape
105  fillShape( shape_ );
106 
107  // --- Find the index of maximum
108  for( unsigned int i=0; i<shape_.size(); ++i ) {
109 
110  if( shape_[indexOfMax_] < shape_[i] )
111  indexOfMax_ = i;
112 
113  }
114 
115  if ( indexOfMax_ != 0 )
117 
118 }
const double qNSecPerBin_
Definition: MTDShapeBase.h:50
double timeOfMax_
Definition: MTDShapeBase.h:52
unsigned int indexOfMax_
Definition: MTDShapeBase.h:51
virtual void fillShape(DVec &aVec) const =0
virtual void MTDShapeBase::fillShape ( DVec aVec) const
protectedpure virtual

Implemented in BTLPulseShape.

Referenced by buildMe().

unsigned int MTDShapeBase::indexOfMax ( ) const

Definition at line 89 of file MTDShapeBase.cc.

References indexOfMax_.

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

Definition at line 145 of file MTDShapeBase.cc.

References a, b, Exception, and globals_cff::x1.

Referenced by timeAtThr().

148 {
149 
150  if ( x1 == x2 )
151  throw cms::Exception("BadValue") << " MTDShapeBase: Trying to interpolate two points with the same x coordinate!";
152 
153  double a = (y2-y1)/(x2-x1);
154  double b = y1 - a*x1;
155 
156  return (y-b)/a;
157 
158 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
double MTDShapeBase::operator() ( double  aTime) const
overridevirtual

Implements CaloVShape.

Definition at line 135 of file MTDShapeBase.cc.

References k1NSecBinsTotal, shape_, and timeIndex().

136 {
137 
138  // return pulse amplitude for request time in ns
139  const unsigned int index ( timeIndex( aTime ) ) ;
140  return ( k1NSecBinsTotal == index ? 0 : shape_[ index ] ) ;
141 
142 }
unsigned int timeIndex(double aTime) const
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:32
std::array< float, 3 > MTDShapeBase::timeAtThr ( const float  scale,
const float  threshold1,
const float  threshold2 
) const

Definition at line 15 of file MTDShapeBase.cc.

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

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

18 {
19 
20  std::array<float,3> times_tmp = { {0., 0., 0.} };
21 
22 
23  // --- Check if the pulse amplitude is greater than threshold 2
24  if ( shape_[indexOfMax_]*scale < threshold2 )
25  return times_tmp;
26 
27 
28  // --- Find the times corresponding to thresholds 1 and 2 on the pulse leading edge
29  // NB: To speed up the search we loop only on the rising edge
30  unsigned int index_LT1 = 0;
31  unsigned int index_LT2 = 0;
32 
33  for( unsigned int i=0; i<indexOfMax_; ++i ){
34 
35  float amplitude = shape_[i]*scale;
36 
37  if( amplitude > threshold1 && index_LT1 == 0 )
38  index_LT1 = i;
39 
40  if( amplitude > threshold2 && index_LT2 == 0 ){
41  index_LT2 = i;
42  break;
43  }
44 
45  }
46 
47 
48  // --- Find the time corresponding to thresholds 1 on the pulse falling edge
49  unsigned int index_FT1 = 0;
50 
51  for( unsigned int i=shape_.size()-1; i>indexOfMax_; i-- ){
52 
53  float amplitude = shape_[i]*scale;
54 
55  if( amplitude>threshold1 && index_FT1==0){
56  index_FT1 = i+1;
57  break;
58  }
59 
60  }
61 
62 
63  if ( index_LT1 != 0 )
64  times_tmp[0] = linear_interpolation( threshold1,
65  (index_LT1-1)*qNSecPerBin_,
66  index_LT1*qNSecPerBin_,
67  shape_[index_LT1-1]*scale,
68  shape_[index_LT1]*scale );
69 
70  if ( index_LT2 != 0 )
71  times_tmp[1] = linear_interpolation( threshold2,
72  (index_LT2-1)*qNSecPerBin_,
73  index_LT2*qNSecPerBin_,
74  shape_[index_LT2-1]*scale,
75  shape_[index_LT2]*scale );
76 
77  if ( index_FT1 != 0 )
78  times_tmp[2] = linear_interpolation( threshold1,
79  (index_FT1-1)*qNSecPerBin_,
80  index_FT1*qNSecPerBin_,
81  shape_[index_FT1-1]*scale,
82  shape_[index_FT1]*scale );
83 
84  return times_tmp;
85 
86 }
const double qNSecPerBin_
Definition: MTDShapeBase.h:50
unsigned int indexOfMax_
Definition: MTDShapeBase.h:51
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 121 of file MTDShapeBase.cc.

References k1NSecBinsTotal, kNBinsPerNSec, and LogDebug.

Referenced by operator()().

122 {
123  const unsigned int index = aTime*kNBinsPerNSec;
124 
125  const bool bad = ( k1NSecBinsTotal <= index );
126 
127  if( bad )
128  LogDebug("MTDShapeBase") << " MTD pulse shape requested for out of range time " << aTime;
129 
130  return ( bad ? k1NSecBinsTotal : index ) ;
131 
132 }
#define LogDebug(id)
static constexpr unsigned int kNBinsPerNSec
Definition: MTDShapeBase.h:31
static constexpr unsigned int k1NSecBinsTotal
Definition: MTDShapeBase.h:32
double MTDShapeBase::timeOfMax ( ) const

Definition at line 95 of file MTDShapeBase.cc.

References timeOfMax_.

96 {
97  return timeOfMax_;
98 }
double timeOfMax_
Definition: MTDShapeBase.h:52
double MTDShapeBase::timeToRise ( ) const
inlineoverridevirtual

Implements CaloVShape.

Definition at line 24 of file MTDShapeBase.h.

References Scenarios_cff::scale, and timeAtThr().

24 { return 0.; }

Member Data Documentation

unsigned int MTDShapeBase::indexOfMax_
private

Definition at line 51 of file MTDShapeBase.h.

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

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

Definition at line 32 of file MTDShapeBase.h.

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

constexpr unsigned int MTDShapeBase::kNBinsPerNSec = 100
static

Definition at line 31 of file MTDShapeBase.h.

Referenced by timeIndex().

constexpr unsigned int MTDShapeBase::kReadoutTimeInterval = 28
static

Definition at line 30 of file MTDShapeBase.h.

const double MTDShapeBase::qNSecPerBin_
private

Definition at line 50 of file MTDShapeBase.h.

Referenced by buildMe(), and timeAtThr().

DVec MTDShapeBase::shape_
private

Definition at line 53 of file MTDShapeBase.h.

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

double MTDShapeBase::timeOfMax_
private

Definition at line 52 of file MTDShapeBase.h.

Referenced by buildMe(), and timeOfMax().