FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndSdsTotChargeConversion Class Reference

#include <PndSdsTotChargeConversion.h>

Inheritance diagram for PndSdsTotChargeConversion:
PndSdsChargeConversion

Public Member Functions

 PndSdsTotChargeConversion (Int_t VerboseLevel=0)
 Default constructor. More...
 
 PndSdsTotChargeConversion (Double_t tr, Double_t a, Double_t threshold, Double_t clockfrequency=0, Int_t VerboseLevel=0)
 Main constructor. More...
 
 ~PndSdsTotChargeConversion ()
 Destructor. More...
 
void StartExecute ()
 
virtual Double_t ChargeToDigiValue (Double_t charge)
 Converts a given charge in electrons into the electronics answer e.g. ToT [ns]. More...
 
virtual Double_t DigiValueToCharge (Double_t digivalue)
 Converts a given digitized charge into charge in electrons. More...
 
virtual Double_t GetPileUpTime (Double_t charge)
 returns the time the capacitor is loaded and therefore the time this MVD pixel/strip is blind for other events More...
 
virtual Double_t GetRelativeError (Double_t Charge)
 
virtual Double_t GetTimeStamp (Double_t tof, Double_t charge, Double_t MCEventTime)
 absolute time stamp of a hit in ns (clock is taken into account) More...
 
virtual Double_t GetTimeWalk (Double_t Charge)
 
virtual Double_t GetTimeStampErrorAfterCorrection ()
 
virtual Double_t GetTimeStep ()
 
virtual void EndExecute ()
 
virtual Double_t DigiValueToCharge (PndSdsDigi &digi)
 
Double_t GetParameter (TString param)
 
void SetParameter (TString param, Double_t value)
 

Private Member Functions

Double_t GetTotWC ()
 
Double_t DigitizeTime (Double_t time)
 returns the time in [ns] but binned to clock units More...
 
 ClassDef (PndSdsTotChargeConversion, 1)
 

Private Attributes

Double_t fthreshold
 
Double_t Qt
 
Double_t t1e
 
Double_t t2e
 
Double_t ftimestep
 
Double_t fstarttime
 
Double_t fstoptime
 
Double_t ftimeoffset
 
Double_t ftimewalk
 
Int_t fVerboseLevel
 
TRandom2 fRand
 

Detailed Description

Class to calculate the deposited charge in one digi <-> time over threshold and vice versa

Author
D.-L.Pohl d.poh.nosp@m.l@fz.nosp@m.-juel.nosp@m.ich..nosp@m.de

This class calculates the time over threshold by using the charge of a pixel/strip. To calculate the TOT a simple capacitor model (integrator) is used. The charge time tr [ns] is assumed to be constant. This leads to a rising straight line. A constant current unloads the capacitor with a ratio of: a [e/ns]. The distance between the points of intersection between the resulting triangle and the threshold line is the TOT.

q | | /\ a | / \ |—/-------—------------— threshold | / \ ----------------------------— q = 0 (charge) | tr| t[ns] <- TOT ->

Definition at line 32 of file PndSdsTotChargeConversion.h.

Constructor & Destructor Documentation

PndSdsTotChargeConversion::PndSdsTotChargeConversion ( Int_t  VerboseLevel = 0)

Default constructor.

Definition at line 5 of file PndSdsTotChargeConversion.cxx.

References ftimestep, fVerboseLevel, PndSdsChargeConversion::GetParameter(), PndSdsChargeConversion::SetParameter(), and StartExecute().

6 fthreshold(0.),
7 Qt(0.),
8 t1e(0.),
9 t2e(0.),
10 ftimestep(0.),
11 fstarttime(0.),
12 fstoptime(0.),
13 ftimeoffset(0.),
14 ftimewalk(0.),
15 fVerboseLevel(0),
16 fRand()
17 {
18  SetParameter("ftr", 100.); //todo take data from Database
19  SetParameter("fa", 60.);
20  SetParameter("fth", 3000.);
21  SetParameter("fclk", 156.);
22  ftimestep = 1. / GetParameter("fclk") * 1000.;
23  fVerboseLevel = VerboseLevel;
24  StartExecute();
25  Warning("constructor","default constructor used");
26  if (fVerboseLevel>0){
27  std::cout<<"Tot parameter "<<std::endl;
28  std::cout<<" charge time: "<<GetParameter("ftr")<<" ns"<<std::endl;
29  std::cout<<" const. current: "<<GetParameter("fa")<<" e/ns"<<std::endl;
30  std::cout<<" threshold: "<<GetParameter("fth")<<" e"<<std::endl;
31  std::cout<<" clock frequency: "<<GetParameter("fclk")<<" MHz"<<std::endl;
32  }
33 };
PndSdsChargeConversion(ConvType type)
Double_t GetParameter(TString param)
void SetParameter(TString param, Double_t value)
PndSdsTotChargeConversion::PndSdsTotChargeConversion ( Double_t  tr,
Double_t  a,
Double_t  threshold,
Double_t  clockfrequency = 0,
Int_t  VerboseLevel = 0 
)

Main constructor.

Definition at line 36 of file PndSdsTotChargeConversion.cxx.

References ftimestep, fVerboseLevel, PndSdsChargeConversion::GetParameter(), PndSdsChargeConversion::SetParameter(), and StartExecute().

37 fthreshold(0.),
38 Qt(0.),
39 t1e(0.),
40 t2e(0.),
41 ftimestep(0.),
42 fstarttime(0.),
43 fstoptime(0.),
44 ftimeoffset(0.),
45 ftimewalk(0.),
46 fVerboseLevel(0),
47 fRand()
48 {
49  SetParameter("ftr", tr); //charge time [ns]
50  SetParameter("fa", a); //const. curren [e/ns]
51  SetParameter("fth", threshold);
52  SetParameter("fclk", clockfrequency); //the frequency the readout chip works with
53  ftimestep = 1. / clockfrequency * 1000.;
54  fVerboseLevel = VerboseLevel;
55  if (fVerboseLevel>0){
56  std::cout<<"Tot parameter "<<std::endl;
57  std::cout<<" charge time: "<<GetParameter("ftr")<<" ns"<<std::endl;
58  std::cout<<" const. current: "<<GetParameter("fa")<<" e/ns"<<std::endl;
59  std::cout<<" threshold: "<<GetParameter("fth")<<" e"<<std::endl;
60  std::cout<<" clock frequency: "<<GetParameter("fclk")<<" MHz"<<std::endl;
61  }
62  StartExecute();
63 };
Int_t a
Definition: anaLmdDigi.C:126
PndSdsChargeConversion(ConvType type)
Double_t GetParameter(TString param)
double threshold
void SetParameter(TString param, Double_t value)
PndSdsTotChargeConversion::~PndSdsTotChargeConversion ( )
inline

Destructor.

Definition at line 42 of file PndSdsTotChargeConversion.h.

42 {};

Member Function Documentation

Double_t PndSdsTotChargeConversion::ChargeToDigiValue ( Double_t  Charge)
virtual

Converts a given charge in electrons into the electronics answer e.g. ToT [ns].

Implements PndSdsChargeConversion.

Definition at line 65 of file PndSdsTotChargeConversion.cxx.

References Double_t, ftimeoffset, fVerboseLevel, PndSdsChargeConversion::GetParameter(), GetTotWC(), Qt, PndSdsChargeConversion::SetParameter(), t1e, and t2e.

65  { //returns the TOT in ns
66  if (GetParameter("fa") <= 0){
67  if (fVerboseLevel>0)
68  Error("ConvertChargeToDigiValue(Double_t charge)","const. current is less or equal zero -> now set to 60 e/ns");
69  SetParameter("fa",60.);
70  }
71 
72  Double_t Q = charge;
73  Qt = GetParameter("fth");
74  //Error handling: if there is a parameter leading to a division by zero Q=Qt=1 is set to prevent this
75 
76  if (Qt < 0){
77  if (fVerboseLevel>0)
78  Error("ConvertChargeToDigiValue(Double_t charge)","threshold is less than zero -> now set to 0 eV");
79  Qt = 0.;
80  }
81 
82  if ((Q <= Qt) or (Q <= 0)){
83  if (fVerboseLevel>0)
84  Warning("ConvertChargeToDigiValue(Double_t charge)","charge (%g) is equal or less than threshold (%g) -> zero TOT",Q,Qt);
85  Q = 1.;
86  Qt = 1.;
87  }
88 
89  t1e = (GetParameter("ftr")*Qt/Q+ftimeoffset); //exact time when signal is over threshold
90  t2e = (Q-Qt)/GetParameter("fa")+ftimeoffset+GetParameter("ftr"); //exact time when signal is again below threshold
91 
92  //return (t2e-t1e); //turn off clock
93  return GetTotWC();
94 }
Double_t
Double_t GetParameter(TString param)
void SetParameter(TString param, Double_t value)
PndSdsTotChargeConversion::ClassDef ( PndSdsTotChargeConversion  ,
 
)
private
Double_t PndSdsTotChargeConversion::DigitizeTime ( Double_t  time)
private

returns the time in [ns] but binned to clock units

Definition at line 154 of file PndSdsTotChargeConversion.cxx.

References ftimestep, and fVerboseLevel.

Referenced by GetTimeStamp().

155 {
156  Int_t temp = (Int_t)((time) / ftimestep);
157  time = temp *ftimestep + ftimestep;
158 
159  if (fVerboseLevel>2) std::cout << "temp " << temp << " time " << time << std::endl;
160 
161  return time;
162 }
Double_t PndSdsChargeConversion::DigiValueToCharge ( PndSdsDigi digi)
virtualinherited

Definition at line 3 of file PndSdsChargeConversion.cxx.

References PndSdsChargeConversion::DigiValueToCharge(), and PndSdsDigi::GetCharge().

3  {
4  return DigiValueToCharge(digi.GetCharge());
5 }
Double_t GetCharge() const
Definition: PndSdsDigi.h:60
virtual Double_t DigiValueToCharge(Double_t digi)=0
Converts a given digitized charge into charge in electrons.
Double_t PndSdsTotChargeConversion::DigiValueToCharge ( Double_t  digi)
virtual

Converts a given digitized charge into charge in electrons.

Implements PndSdsChargeConversion.

Definition at line 218 of file PndSdsTotChargeConversion.cxx.

References fVerboseLevel, PndSdsChargeConversion::GetParameter(), and sqrt().

218  { //returns the charge for the given tot value
219  if (digivalue<0){
220  if (fVerboseLevel>0)
221  Error("ConvertDigiValueToELoss(Double_t digi)","charge digitization value not calculated properly");
222  return -1;
223  }
224  return (-GetParameter("fa")*GetParameter("ftr")+GetParameter("fth")+digivalue*GetParameter("fa"))/2.+sqrt( pow( (GetParameter("fa")*GetParameter("ftr")-GetParameter("fth")-digivalue*GetParameter("fa")),2) / 4. + GetParameter("fa")* GetParameter("fth") * GetParameter("ftr"));
225 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t GetParameter(TString param)
virtual void PndSdsChargeConversion::EndExecute ( )
inlinevirtualinherited

Definition at line 21 of file PndSdsChargeConversion.h.

Referenced by PndSdsHybridHitProducer::Exec().

21 {};
Double_t PndSdsChargeConversion::GetParameter ( TString  param)
inlineinherited

Definition at line 37 of file PndSdsChargeConversion.h.

References PndSdsChargeConversion::fParams, and PndSdsChargeConversion::it.

Referenced by ChargeToDigiValue(), DigiValueToCharge(), GetPileUpTime(), GetRelativeError(), GetTimeWalk(), and PndSdsTotChargeConversion().

37  {
38  it=fParams.find(param);
39  if (it == fParams.end()){
40  Error("GetParameter(TString param)","No parameter named: %s",param.Data());
41  return -1;
42  }
43  return it->second;
44  };
std::map< TString, Double_t >::iterator it
std::map< TString, Double_t > fParams
Double_t PndSdsTotChargeConversion::GetPileUpTime ( Double_t  charge)
virtual

returns the time the capacitor is loaded and therefore the time this MVD pixel/strip is blind for other events

Definition at line 214 of file PndSdsTotChargeConversion.cxx.

References PndSdsChargeConversion::GetParameter().

214  { //returns the time the detector is not sensitive for other events
215  return (GetParameter("ftr") + fcharge / GetParameter("fa"));
216 }
Double_t GetParameter(TString param)
Double_t PndSdsTotChargeConversion::GetRelativeError ( Double_t  Charge)
virtual

Implements PndSdsChargeConversion.

Definition at line 96 of file PndSdsTotChargeConversion.cxx.

References a, Double_t, PndSdsChargeConversion::GetParameter(), Qt, and sqrt().

97 {
98  // formula from D.Pohl/FZJ his sources?
99  // dQ_rec a / (Q_t - a*t_c)/2 + (Q - Q_t)(t_c/Q - 1/a)*a/2 \.
100  // ------ = - * dt_max * | 1 + ---------------------------------------------------------------------- |
101  // Q_rec 2 \ sqrt{ [ (Q_t - a*t_c)/2 + (Q - Q_t)(t_c/Q - 1/a)*a/2 ]^2 + a*Q_t*t_c } /
102  //
103  // a 1 / 2Qt - Qt*Qc/Q - Q \.
104  // = - * ----- * | 1 + --------------------------------------- |
105  // 2 f_clk \ sqrt{ [2Qt - Qt*Qc/Q - Q]^2 + 4*Qc*Qt } /
106  //
107 
108  Double_t Q = Charge;
109  Qt = GetParameter("fth"); // threshold
110  Double_t a = GetParameter("fa"); // const current
111  Double_t tc = GetParameter("ftr");// time to load capacitor fully
112  Double_t Qc = a*tc; // storable capacitor charge
113  Double_t temp = 2.*Qt - Qt*Qc/Q - Q;
114  temp = temp/(sqrt(temp*temp + 4*Qc*Qt));
115  temp = 0.5*a*(1+temp)/GetParameter("fclk");
116  return temp;
117 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Int_t a
Definition: anaLmdDigi.C:126
Double_t
Double_t GetParameter(TString param)
Double_t PndSdsTotChargeConversion::GetTimeStamp ( Double_t  tof,
Double_t  charge,
Double_t  MCEventTime 
)
virtual

absolute time stamp of a hit in ns (clock is taken into account)

Implements PndSdsChargeConversion.

Definition at line 126 of file PndSdsTotChargeConversion.cxx.

References DigitizeTime(), Double_t, ftimestep, ftimewalk, fVerboseLevel, GetTimeWalk(), and Qt.

127 {
128  ftimewalk=GetTimeWalk(Charge);
129 
130  Double_t totaltime = ftimewalk;
131  Double_t eventtime = MCEventTime;
132  Double_t flighttime = time;
133 
134  totaltime += flighttime; // [ns]
135  totaltime += eventtime; // [ns]
136 
137  Double_t digitizedtime = DigitizeTime(totaltime);
138 
139  if (fVerboseLevel>2){
140  std::cout<<" +++threshold: "<< Qt <<" "<<std::endl;
141  std::cout<<" charge: "<< Charge <<" "<<std::endl;
142  std::cout<<" time since event: "<< time <<" "<<std::endl;
143  std::cout<<" event time: "<< MCEventTime << std::endl;
144  std::cout<<" timewalk: "<< ftimewalk <<std::endl;
145  std::cout<<" total time: "<< totaltime <<std::endl;
146  std::cout<<" time step: "<< ftimestep<<std::endl;
147  std::cout<<" digitized total time:"<< digitizedtime << "+++"<<std::endl;
148  }
149  return digitizedtime ; //digitalisiert
150  // return totaltime; // nicht digitalisiert
151 }
virtual Double_t GetTimeWalk(Double_t Charge)
Double_t DigitizeTime(Double_t time)
returns the time in [ns] but binned to clock units
Double_t
virtual Double_t PndSdsTotChargeConversion::GetTimeStampErrorAfterCorrection ( )
inlinevirtual

Reimplemented from PndSdsChargeConversion.

Definition at line 53 of file PndSdsTotChargeConversion.h.

References ftimestep, and sqrt().

53  {
54  return ftimestep/sqrt(12);
55  }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
virtual Double_t PndSdsTotChargeConversion::GetTimeStep ( )
inlinevirtual

Reimplemented from PndSdsChargeConversion.

Definition at line 57 of file PndSdsTotChargeConversion.h.

References ftimestep.

Double_t PndSdsTotChargeConversion::GetTimeWalk ( Double_t  Charge)
virtual

Reimplemented from PndSdsChargeConversion.

Definition at line 164 of file PndSdsTotChargeConversion.cxx.

References Double_t, ftimewalk, fVerboseLevel, PndSdsChargeConversion::GetParameter(), Qt, and PndSdsChargeConversion::SetParameter().

Referenced by GetTimeStamp().

164  { // [ns]
165  if (GetParameter("fa") <= 0){
166  if (fVerboseLevel>0)
167  Error("GetTimeWalk(Double_t charge)","const. current is less or equal zero -> now set to 60 e/ns");
168  SetParameter("fa",60.);
169  }
170 
171  Double_t Q = Charge;
172 
173  if (Qt < 0){
174  if (fVerboseLevel>0)
175  Error("GetTimeWalk(Double_t charge)","threshold is less than zero -> now set to 0 eV");
176  Qt = 0.;
177  }
178 
179  if ((Q <= Qt) or (Q <= 0)){
180  if (fVerboseLevel>0)
181  Warning("GetTimeWalk(Double_t charge)","charge is equal or less than threshold -> zero TOT -> infinity TimeWalk");
182  Q = 1.;
183  Qt = 100000.;
184  ftimewalk = GetParameter("ftr");
185  return ftimewalk;
186  }
187 
188 
189  Qt = GetParameter("fth");
190  ftimewalk = (GetParameter("ftr")*Qt/Q);
191 // ftimewalk += ftimestep;
192  return ftimewalk;
193 }
Double_t
Double_t GetParameter(TString param)
void SetParameter(TString param, Double_t value)
Double_t PndSdsTotChargeConversion::GetTotWC ( )
private

Definition at line 195 of file PndSdsTotChargeConversion.cxx.

References fstarttime, fstoptime, ftimestep, t1e, and t2e.

Referenced by ChargeToDigiValue().

195  { //calculates start time, stop time with a clock
196  fstarttime = (Int_t) ( t1e / ftimestep ) * ftimestep + ftimestep; //quantization of the start signal
197  fstoptime = (Int_t) ( t2e / ftimestep ) * ftimestep + ftimestep; //quantization of the stop signal
198  /*
199  std::cout<<" start point exact: "<<t1e<<std::endl;
200  std::cout<<" stop point exact: "<<t2e<<std::endl;
201  std::cout<<" time step is: "<<ftimestep<<" ns"<<std::endl;
202  std::cout<<" fclockfrequency is: "<<GetParameter("fclk")<<" MHz"<<std::endl;
203  std::cout<<" time offset is: "<<ftimeoffset<<" ns"<<std::endl;
204  std::cout<<" start point is: "<<fstarttime<<" ns"<<std::endl;
205  std::cout<<" stop point is: "<<fstoptime<<" ns"<<std::endl;
206  */
207  return (fstoptime-fstarttime);
208 }
void PndSdsChargeConversion::SetParameter ( TString  param,
Double_t  value 
)
inlineinherited

Definition at line 45 of file PndSdsChargeConversion.h.

References PndSdsChargeConversion::fParams.

Referenced by ChargeToDigiValue(), GetTimeWalk(), and PndSdsTotChargeConversion().

45  {
46  if (value < 0 ) Error("SetParameter(TString param, Double_t value)","invalid value for param: %s", param.Data());
47  fParams.insert(std::pair<TString, Double_t>(param, value));
48  };
std::map< TString, Double_t > fParams
void PndSdsTotChargeConversion::StartExecute ( )
virtual

Reimplemented from PndSdsChargeConversion.

Definition at line 210 of file PndSdsTotChargeConversion.cxx.

References fRand, ftimeoffset, and ftimestep.

Referenced by PndSdsTotChargeConversion().

210  { //function called for different events to set different time offsets
211  ftimeoffset = fRand.Uniform(ftimestep);
212 }

Member Data Documentation

TRandom2 PndSdsTotChargeConversion::fRand
private

Definition at line 74 of file PndSdsTotChargeConversion.h.

Referenced by StartExecute().

Double_t PndSdsTotChargeConversion::fstarttime
private

Definition at line 67 of file PndSdsTotChargeConversion.h.

Referenced by GetTotWC().

Double_t PndSdsTotChargeConversion::fstoptime
private

Definition at line 68 of file PndSdsTotChargeConversion.h.

Referenced by GetTotWC().

Double_t PndSdsTotChargeConversion::fthreshold
private

Definition at line 63 of file PndSdsTotChargeConversion.h.

Double_t PndSdsTotChargeConversion::ftimeoffset
private

Definition at line 69 of file PndSdsTotChargeConversion.h.

Referenced by ChargeToDigiValue(), and StartExecute().

Double_t PndSdsTotChargeConversion::ftimestep
private
Double_t PndSdsTotChargeConversion::ftimewalk
private

Definition at line 70 of file PndSdsTotChargeConversion.h.

Referenced by GetTimeStamp(), and GetTimeWalk().

Int_t PndSdsTotChargeConversion::fVerboseLevel
private
Double_t PndSdsTotChargeConversion::Qt
private
Double_t PndSdsTotChargeConversion::t1e
private

Definition at line 65 of file PndSdsTotChargeConversion.h.

Referenced by ChargeToDigiValue(), and GetTotWC().

Double_t PndSdsTotChargeConversion::t2e
private

Definition at line 65 of file PndSdsTotChargeConversion.h.

Referenced by ChargeToDigiValue(), and GetTotWC().


The documentation for this class was generated from the following files: