fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / AliITSOnlineSDDInjectors.h
CommitLineData
348f80b7 1#ifndef ALIITSONLINESDDINJECTORS_H
2#define ALIITSONLINESDDINJECTORS_H
3
4
84df0230 5/* $Id$ */
9f026db8 6
348f80b7 7///////////////////////////////////////////////////////////////////
8// //
9// Class used for SDD injector analysis //
10// Origin: F.Prino, Torino, prino@to.infn.it //
11// //
12///////////////////////////////////////////////////////////////////
9f026db8 13
0e5e647a 14#include "AliITSOnlineSDD.h"
348f80b7 15
9f026db8 16
e5b2f7f2 17class TH1F;
348f80b7 18class TH2F;
19class TGraphErrors;
20class AliITSOnlineSDDInjectors : public AliITSOnlineSDD {
21
22 public:
23 AliITSOnlineSDDInjectors();
979b5a5f 24 AliITSOnlineSDDInjectors(Int_t nddl, Int_t ncarlos, Int_t sid);
348f80b7 25 virtual ~AliITSOnlineSDDInjectors();
26
b255f56d 27
9f026db8 28 void SetThresholds(Float_t tl, Float_t th){
29 fLowThreshold=tl;
30 fHighThreshold=th;
31 }
32 void SetInjLineRange(Int_t jlin, Int_t tbmin, Int_t tbmax){
33 fTbMin[jlin]=tbmin;
34 fTbMax[jlin]=tbmax;
35 }
b255f56d 36 void Set20MHzConfig(){
37 SetInjLineRange(0,10,20);
38 SetInjLineRange(1,50,70);
39 SetInjLineRange(2,100,120);
40 SetTimeStep(50.);
41 }
42 void Set40MHzConfig(){
43 SetInjLineRange(0,20,50);
44 SetInjLineRange(1,90,160);
45 SetInjLineRange(2,170,240);
46 SetTimeStep(25.);
47 }
915c0469 48 void SetPolDegree(Int_t n){fPolDegree=n;}
9f026db8 49 void SetMinDriftSpeed(Float_t vmin){fMinDriftSpeed=vmin;}
50 void SetMaxDriftSpeed(Float_t vmax){fMaxDriftSpeed=vmax;}
51 void SetMaxDriftSpeedErr(Float_t maxval){
52 fMaxDriftSpeedErr=maxval;
348f80b7 53 }
9f026db8 54 void SetFitLimits(Int_t firstpad,Int_t lastpad){
55 fFirstPadForFit=firstpad;
56 fLastPadForFit=lastpad;
348f80b7 57 }
915c0469 58 void SetPadStatusCutForFit(Int_t cutval=4){
9f026db8 59 fPadStatusCutForFit=cutval;
348f80b7 60 }
9f026db8 61 void SetDefaults();
2ca27861 62 void SetTimeStep(Double_t tstep) {
f4e26d31 63 fTimeStep=tstep;
64 }
784a52ed 65 void SetUseTimeZeroSignal(Bool_t useTZ=kTRUE){
66 fUseTimeZeroSignal=useTZ;
67 }
1397fe91 68 void SetUseLine(Int_t iLine, Bool_t use=kTRUE){
69 if(iLine>=0 && iLine<kInjLines) fUseLine[iLine]=use;
70 }
e5b2f7f2 71 TH1F* GetMeanDriftSpeedVsPadHisto() const;
9f026db8 72 TGraphErrors* GetTimeVsDistGraph(Int_t jpad) const;
73 TGraphErrors* GetDriftSpeedGraph() const;
84df0230 74 TGraphErrors* GetSelectedDriftSpeedGraph(Int_t minAcceptStatus) const;
2ca27861 75 Double_t* GetDriftSpeedFitParam()const{ return fParam;}
76 Double_t GetDriftSpeed(Int_t jpad) const{return fDriftSpeed[jpad];}
77 Double_t GetDriftSpeedErr(Int_t jpad) const{return fDriftSpeedErr[jpad];}
78 Double_t GetTimeBinZero() const{return fTbZero;}
9f026db8 79
2ca27861 80 Double_t GetTimeStep() const{return fTimeStep;}
9f026db8 81 Int_t GetAnodeNumber(Int_t iInjPad) const;
82 Int_t GetInjPadNumberFromAnode(Int_t nAnode) const;
83 Int_t GetInjPadStatus(Int_t jpad) const;
84 Int_t GetAnodeStatus(Int_t nAnode) const{
85 Int_t jpad=GetInjPadNumberFromAnode(nAnode);
86 return GetInjPadStatus(jpad);
87 }
2ca27861 88 Double_t GetCentroid(Int_t jpad, Int_t jlin) const {
9f026db8 89 if(jpad<kInjPads && jlin<kInjLines) return fCentroid[jpad][jlin];
c668f182 90 else return -9999.;
91 }
9f026db8 92 Bool_t IsInjectorGood(Int_t jpad, Int_t jlin) const {
93 if(jpad<kInjPads && jlin<kInjLines) return fGoodInj[jpad][jlin];
c668f182 94 else return 0;
95 }
9f026db8 96 void PrintInjectorStatus();
348f80b7 97 void PrintCentroids();
4c82df4c 98 void WriteToASCII(Int_t evNumb, UInt_t timeStamp, Int_t optAppend=0);
50d25e98 99 void WriteInjectorStatusToASCII();
456ec396 100 Bool_t WriteToROOT(TFile *fil) const;
348f80b7 101
2ca27861 102 void Reset();
103 void AnalyzeEvent(TH2F* his);
104 void AddEvent(TH2F* his);
348f80b7 105 void FindGoodInjectors();
106 void FindCentroids();
9f026db8 107 void CalcDriftSpeed(Int_t jpad);
348f80b7 108 void CalcTimeBinZero();
9f026db8 109 void FitDriftSpeedVsAnode();
3bc883e9 110 void PolyFit(Int_t degree=3);
2ca27861 111 Double_t GetMeanDriftSpeed(Int_t ipad) const{
e89a0633 112 if(fNEventsInPad[ipad]==0) return 0.;
113 return fSumDriftSpeed[ipad]/(Double_t)fNEventsInPad[ipad];
2ca27861 114 }
115 Double_t GetRMSDriftSpeed(Int_t ipad) const;
e89a0633 116 Double_t GetMeanPadStatusCut(Int_t ipad) const{
117 if(fNEventsInPad[ipad]==0) return 0.;
118 return (Double_t)fSumPadStatusCut[ipad]/(Double_t)fNEventsInPad[ipad];
119 }
120 Double_t GetMeanPadStatus(Int_t ipad) const{
121 if(fNEvents==0) return 0.;
122 return (Double_t)fSumPadStatus[ipad]/(Double_t)fNEvents;
123 }
124
2ca27861 125 void FitMeanDriftSpeedVsAnode();
348f80b7 126
127 protected:
128 void SetPositions();
129 private:
130
9f026db8 131 enum {kInjPads = 33};
132 enum {kInjLines = 3};
348f80b7 133
134 AliITSOnlineSDDInjectors(const AliITSOnlineSDDInjectors& source);
135 AliITSOnlineSDDInjectors& operator = (const AliITSOnlineSDDInjectors& source);
9f026db8 136 static const Float_t fgkSaturation; // ADC saturation value (1008)
137 static const Float_t fgkDefaultLThreshold; // Default for fLowThreshold
138 static const Float_t fgkDefaultHThreshold; // Default for fHighThreshold
139 static const Float_t fgkDefaultMinSpeed; // Default for fMinDriftSpeed
140 static const Float_t fgkDefaultMaxSpeed; // Default for fMaxDriftSpeed
141 static const Float_t fgkDefaultMaxErr; // Default for fMaxDriftSpeedErr
915c0469 142 static const Int_t fgkDefaultPolDegree; // Default for fPolDegree
f4e26d31 143 static const Float_t fgkDefaultTimeStep; // Default for fTimeStep
9f026db8 144 static const UShort_t fgkDefaultTbMin[kInjLines]; // Defaults for fTbMin
145 static const UShort_t fgkDefaultTbMax[kInjLines]; // Defaults for fTbMax
146
147
148 TH2F* fHisto; // histogram of channel counts
2ca27861 149 Double_t fTbZero; // Time zero for injector event
150 Double_t fRMSTbZero; // Error on time zero
151 Double_t fPosition[kInjLines]; // Coordinates of injector lines
e89a0633 152 UShort_t fTbMin[kInjLines]; // Minimum time bin for each line
153 UShort_t fTbMax[kInjLines]; // Maximum time bin for each line
154 Bool_t fGoodInj[kInjPads][kInjLines]; // array of good injectors
2ca27861 155 Double_t fCentroid[kInjPads][kInjLines]; // array of time bin centroids
156 Double_t fRMSCentroid[kInjPads][kInjLines]; // array of time rms of injectors
157 Double_t fDriftSpeed[kInjPads]; // drift speed
158 Double_t fDriftSpeedErr[kInjPads]; // error on drift speed
e89a0633 159 Int_t fNEvents; // number of events
160 Int_t fNEventsInPad[kInjPads]; // number of events per pad
2ca27861 161 Double_t fSumDriftSpeed[kInjPads]; // drift speed summed over events
162 Double_t fSumSqDriftSpeed[kInjPads]; // drift speed^2 sum
e89a0633 163 Int_t fSumPadStatus[kInjPads]; // pad status sum
164 Int_t fSumPadStatusCut[kInjPads]; // pad status (> cut) sum
2ca27861 165
e89a0633 166 Double_t *fParam; // parameters of polinomial fit to
9f026db8 167 // drift speed vs. anode number
e89a0633 168 Int_t fPolDegree; // Degree of polynomial fit
169 Int_t fActualPolDegree; // Degree actually used (<=fPolDegree)
9f026db8 170 Float_t fMinDriftSpeed; // Minimum value for drift speed
171 Float_t fMaxDriftSpeed; // Maximum value for drift speed
172 Float_t fMaxDriftSpeedErr; // Maximum value for error on drift speed
173 Float_t fLowThreshold; // Low threshold for injector signal
174 Float_t fHighThreshold; // High threshold for injector signal
175
1397fe91 176 Bool_t fUseLine[kInjLines]; // Flag to use/not use a line
9f026db8 177 Int_t fFirstPadForFit; // first injector pad used in fit
178 Int_t fLastPadForFit; // last injector pad used in fit
179 Int_t fPadStatusCutForFit; // minimum value of pad status for fit
180
2ca27861 181 Double_t fTimeStep; // time bin value (25 or 50 ns)
784a52ed 182 Bool_t fUseTimeZeroSignal; // flag for usage of time zero signal
183 // in drift speed calculation
9f026db8 184
e89a0633 185 ClassDef(AliITSOnlineSDDInjectors,8)
348f80b7 186};
187#endif