CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
EcalUncalibRecHitTimeWeightsAlgo< C > Class Template Reference

#include <EcalUncalibRecHitTimeWeightsAlgo.h>

Public Member Functions

 EcalUncalibRecHitTimeWeightsAlgo ()
 
double time (const C &dataFrame, const std::vector< double > &amplitudes, const EcalPedestals::Item *aped, const EcalMGPAGainRatio *aGain, const FullSampleVector &fullpulse, const EcalWeightSet::EcalWeightMatrix **weights)
 Compute time. More...
 
virtual ~EcalUncalibRecHitTimeWeightsAlgo ()
 

Detailed Description

template<class C>
class EcalUncalibRecHitTimeWeightsAlgo< C >

Template used to compute amplitude, pedestal, time jitter, chi2 of a pulse using a weights method

Author
J. Bendavid, E. Di Marco

The chi2 computation with matrix is replaced by the chi2express which is moved outside the weight algo (need to clean up the interface in next iteration so that we do not pass-by useless arrays)

Definition at line 26 of file EcalUncalibRecHitTimeWeightsAlgo.h.

Constructor & Destructor Documentation

Definition at line 30 of file EcalUncalibRecHitTimeWeightsAlgo.h.

30 { };
template<class C>
virtual EcalUncalibRecHitTimeWeightsAlgo< C >::~EcalUncalibRecHitTimeWeightsAlgo ( )
inlinevirtual

Definition at line 31 of file EcalUncalibRecHitTimeWeightsAlgo.h.

31 { };

Member Function Documentation

template<class C>
double EcalUncalibRecHitTimeWeightsAlgo< C >::time ( const C &  dataFrame,
const std::vector< double > &  amplitudes,
const EcalPedestals::Item aped,
const EcalMGPAGainRatio aGain,
const FullSampleVector fullpulse,
const EcalWeightSet::EcalWeightMatrix **  weights 
)
inline

Compute time.

Definition at line 34 of file EcalUncalibRecHitTimeWeightsAlgo.h.

Referenced by EcalUncalibRecHitWorkerMultiFit::run().

34  {
35 
36  const unsigned int nsample = EcalDataFrame::MAXSAMPLES;
37 
38  double maxamplitude = -std::numeric_limits<double>::max();
39 
40  double pulsenorm = 0.;
41  int iGainSwitch = 0;
42 
43  ROOT::Math::SVector<double,nsample> pedSubSamples;
44  for(unsigned int iSample = 0; iSample < nsample; iSample++) {
45 
46  const EcalMGPASample &sample = dataFrame.sample(iSample);
47 
48  double amplitude = 0.;
49  int gainId = sample.gainId();
50 
51  double pedestal = 0.;
52  double gainratio = 1.;
53 
54  if (gainId==0 || gainId==3) {
55  pedestal = aped->mean_x1;
56  gainratio = aGain->gain6Over1()*aGain->gain12Over6();
57  iGainSwitch = 1;
58  }
59  else if (gainId==1) {
60  pedestal = aped->mean_x12;
61  gainratio = 1.;
62  iGainSwitch = 0;
63  }
64  else if (gainId==2) {
65  pedestal = aped->mean_x6;
66  gainratio = aGain->gain12Over6();
67  iGainSwitch = 1;
68  }
69 
70  amplitude = ((double)(sample.adc()) - pedestal) * gainratio;
71 
72  if (gainId == 0) {
73  //saturation
74  amplitude = (4095. - pedestal) * gainratio;
75  }
76 
77  pedSubSamples(iSample) = amplitude;
78 
79  if (amplitude>maxamplitude) {
80  maxamplitude = amplitude;
81  }
82  pulsenorm += fullpulse(iSample);
83  }
84 
85  std::vector<double>::const_iterator amplit;
86  for(amplit=amplitudes.begin(); amplit<amplitudes.end(); ++amplit) {
87  int ipulse = std::distance(amplitudes.begin(),amplit);
88  int bx = ipulse - 5;
89  int firstsamplet = std::max(0,bx + 3);
90  int offset = 7-3-bx;
91 
92  TVectorD pulse;
93  pulse.ResizeTo(nsample);
94  for (unsigned int isample = firstsamplet; isample<nsample; ++isample) {
95  pulse(isample) = fullpulse(isample+offset);
96  pedSubSamples(isample) = std::max(0., pedSubSamples(isample) - amplitudes[ipulse]*pulse(isample)/pulsenorm);
97  }
98  }
99 
100  // Compute parameters
101  double amplitude_(-1.), jitter_(-1.);
102  ROOT::Math::SVector <double,3> param = (*(weights[iGainSwitch])) * pedSubSamples;
103  amplitude_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iAmplitude);
104  if (amplitude_) jitter_ = -param(EcalUncalibRecHitRecAbsAlgo<C>::iTime) / amplitude_;
105  else jitter_ = 0.;
106 
107  return jitter_;
108  }
int gainId(sample_type sample)
get the gainId (2 bits)
int gainId() const
get the gainId (2 bits)
const T & max(const T &a, const T &b)
float gain6Over1() const
unsigned int offset(bool)
float gain12Over6() const
static const int MAXSAMPLES
Definition: EcalDataFrame.h:48
int adc() const
get the ADC sample (12 bits)