Corrected UInt_t <-> Int_t conversion
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDButil.h
CommitLineData
8166d5d7 1#ifndef ALITPCCALIBDBUTIL_H
2#define ALITPCCALIBDBUTIL_H
892226be 3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7///////////////////////////////////////////////////////////////////////////////
8// //
9// Class providing the calculation of derived quantities (mean,rms,fits,...) //
10// of calibration entries //
11// //
12///////////////////////////////////////////////////////////////////////////////
13
14#include <TObject.h>
ea09e1dd 15#include <TArrayI.h>
1be09c9e 16#include <TVectorDfwd.h>
17#include <TVectorFfwd.h>
18#include <TMatrixDfwd.h>
892226be 19
949d8707 20class TGraph;
21class TMap;
892226be 22class AliDCSSensorArray;
23class AliTPCcalibDB;
24class AliTPCCalPad;
37f2177e 25class AliTPCCalROC;
892226be 26class AliTPCmapper;
6e7d7dc4 27class AliTPCCalibRaw;
949d8707 28class AliCDBEntry;
37f2177e 29class AliDCSSensor;
30class AliDCSSensorArray;
31class AliTPCSensorTempArray;
949d8707 32class AliTPCdataQA;
a23ba1c3 33class TGraphErrors;
34class TTreeSRedirector;
37f2177e 35class AliTPCCalROC;
a3b590cf 36class AliSplineFit;
8166d5d7 37
892226be 38class AliTPCcalibDButil : public TObject
39{
40public:
41 AliTPCcalibDButil();
42 virtual ~AliTPCcalibDButil();
43
44 void UpdateFromCalibDB();
45 //data processing functions
7390f655 46 void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC,
8166d5d7 47 Int_t &noutliersCE, Double_t & chi2A, Double_t &chi2C, AliTPCCalPad * const outCE=0);
892226be 48 void ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
49 TVectorD &vecQEntries, TVectorD &vecQMean, TVectorD &vecQRMS, TVectorD &vecQMedian,
50 Float_t &driftTimeA, Float_t &driftTimeC );
51 void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
52 TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
93425263 53 Int_t &nonMaskedZero, Int_t &nNaN);
abb20887 54 void ProcessQAData(TVectorD &vQaOcc, TVectorD &vQaQtot, TVectorD &vQaQmax);
892226be 55 void ProcessPulser(TVectorD &vMeanTime);
56 void ProcessALTROConfig(Int_t &nMasked);
57 void ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
949d8707 58
7390f655 59 //processing functions using reference data
60 void ProcessPedestalVariations(TVectorF &pedestalDeviations);
61 void ProcessNoiseVariations(TVectorF &noiseDeviations);
62 void ProcessPulserVariations(TVectorF &pulserQdeviations, Float_t &varQMean, Int_t &npadsOutOneTB, Int_t &npadsOffAdd);
949d8707 63
892226be 64 //getter preprocess information
65 Int_t GetNPulserOutliers() const {return fNpulserOutliers;}
8166d5d7 66 Float_t GetMeanAltro(const AliTPCCalROC *roc, const Int_t row, const Int_t pad, AliTPCCalROC * const rocOut=0x0);
892226be 67 AliTPCCalPad *GetPulserOutlierMap() const {return fPulserOutlier;}
949d8707 68
69 //getters ref data
70 TMap *GetReferenceMap() const {return fRefMap;}
c95e0219 71 Int_t GetReferenceRun(const char* type) const;
949d8707 72 const char* GetRefValidity() const {return fRefValidity.Data();}
73
74 AliTPCCalPad* GetRefPadNoise() const {return fRefPadNoise;}
75 AliTPCCalPad* GetRefPedestals() const {return fRefPedestals;}
76 AliTPCCalPad* GetRefPedestalMasked() const {return fRefPedestalMasked;}
77 AliTPCCalPad* GetRefPulserTmean() const {return fRefPulserTmean;}
78 AliTPCCalPad* GetRefPulserTrms() const {return fRefPulserTrms;}
79 AliTPCCalPad* GetRefPulserQmean() const {return fRefPulserQmean;}
80 AliTPCCalPad* GetRefPulserOutlier() const {return fRefPulserOutlier;}
81 AliTPCCalPad* GetRefPulserMasked() const {return fRefPulserMasked;}
82 AliTPCCalPad* GetRefCETmean() const {return fRefCETmean;}
83 AliTPCCalPad* GetRefCETrms() const {return fRefCETrms;}
84 AliTPCCalPad* GetRefCEQmean() const {return fRefCEQmean;}
85 AliTPCCalPad* GetRefCEMasked() const {return fRefCEMasked;}
86 AliTPCCalPad* GetRefALTROFPED() const {return fRefALTROFPED;}
87 AliTPCCalPad* GetRefALTROZsThr() const {return fRefALTROZsThr;}
88 AliTPCCalPad* GetRefALTROAcqStart() const {return fRefALTROAcqStart;}
89 AliTPCCalPad* GetRefALTROAcqStop() const {return fRefALTROAcqStop;}
90 AliTPCCalPad* GetRefALTROMasked() const {return fRefALTROMasked;}
91
92
892226be 93 //setters for pad by pad information
8166d5d7 94 void SetPulserData(AliTPCCalPad * const tmean, AliTPCCalPad * const trms=0x0, AliTPCCalPad * const qmean=0x0)
892226be 95 {fPulserTmean=tmean; fPulserTrms=trms; fPulserQmean=qmean;}
98a4cc77 96 void SetCEData(AliTPCCalPad *const tmean, AliTPCCalPad *const trms=0x0, AliTPCCalPad *const qmean=0x0)
892226be 97 {fCETmean=tmean; fCETrms=trms; fCEQmean=qmean;}
98a4cc77 98 void SetNoisePedestal(AliTPCCalPad *const noise, AliTPCCalPad *const pedestal=0x0)
892226be 99 {fPadNoise=noise; fPedestals=pedestal;}
98a4cc77 100 void SetALTROData(AliTPCCalPad *const masked)
892226be 101 {fALTROMasked=masked;}
98a4cc77 102 void SetGoofieArray(AliDCSSensorArray *const arr) {fGoofieArray=arr;}
949d8707 103
7390f655 104 //setters for pad by pad information
105 void SetRefFile(const char* filename);
949d8707 106 void SetReferenceRun(Int_t run=-1);
107 void UpdateRefDataFromOCDB();
98a4cc77 108 void SetRefPulserData(AliTPCCalPad *const tmean, AliTPCCalPad *const trms=0x0, AliTPCCalPad *const qmean=0x0)
7390f655 109 {fRefPulserTmean=tmean; fRefPulserTrms=trms; fRefPulserQmean=qmean;}
98a4cc77 110 void SetRefCEData(AliTPCCalPad *const tmean, AliTPCCalPad *const trms=0x0, AliTPCCalPad *const qmean=0x0)
7390f655 111 {fRefCETmean=tmean; fRefCETrms=trms; fRefCEQmean=qmean;}
98a4cc77 112 void SetRefNoisePedestal(AliTPCCalPad *const noise, AliTPCCalPad *const pedestal=0x0)
7390f655 113 {fRefPadNoise=noise; fRefPedestals=pedestal;}
98a4cc77 114 void SetRefALTROData(AliTPCCalPad *const masked)
7390f655 115 {fRefALTROMasked=masked;}
116
892226be 117 //creation of derived pad by pad calibration data
2cb269df 118 AliTPCCalPad *CreatePadTime0(Int_t model, Double_t &gyA, Double_t &gyC, Double_t &chi2A, Double_t &chi2C);
892226be 119 //
2cb269df 120 // create outlyer maps
121 //
8166d5d7 122 AliTPCCalPad *CreateCEOutlyerMap(Int_t &noutliersCE, AliTPCCalPad * const ceOut=0, Float_t minSignal=10, Float_t cutTrmsMin=0.9, Float_t cutTrmsMax=1.2, Float_t cutMaxDistT=0.7);
123 AliTPCCalPad *CreatePulserOutlyerMap(Int_t &noutliersPulser, AliTPCCalPad * const pulserOut=0, Float_t cutTime=3, Float_t cutnRMSQ=5, Float_t cutnRMSrms=5);
2cb269df 124 //
125 AliTPCCalPad *CreatePadTime0CE(TVectorD &fitResultsA, TVectorD&fitResultsC, Int_t &nOut, Double_t &chi2A, Double_t &chi2C, const char *dumpfile=0);
126 //
127
892226be 128 void UpdatePulserOutlierMap();
7390f655 129 void UpdateRefPulserOutlierMap();
130 void PulserOutlierMap(AliTPCCalPad *pulOut, const AliTPCCalPad *pulT, const AliTPCCalPad *pulQ);
817766d5 131
949d8707 132 const char* GetGUIRefTreeDefaultName();
133
134 Bool_t CreateGUIRefTree(const char* filename="");
817766d5 135 //
136 // graph tools
137 //
a23ba1c3 138 static Double_t GetLaserTime0(Int_t run, Int_t timeStamp, Int_t deltaT, Int_t side);
8166d5d7 139 static TGraph* FilterGraphMedian(TGraph * const graph, Float_t sigmaCut, Double_t &medianY);
a23ba1c3 140 static TGraph* FilterGraphMedianAbs(TGraph * graph, Float_t cut, Double_t &medianY);
141 static TGraphErrors* FilterGraphMedianErr(TGraphErrors * graph, Float_t sigmaCut,Double_t &medianY);
142 //
143 static void Sort(TGraph *graph);
144 static void SmoothGraph(TGraph *graph, Double_t delta);
817766d5 145 static Int_t GetNearest(TGraph *graph, Double_t xref, Double_t &dx, Double_t &y);
8166d5d7 146 static Double_t EvalGraphConst(TGraph * const graph, Double_t xref);
108a67db 147 static Double_t EvalGraphConst(AliSplineFit *graph, Double_t xref);
148
1e722a63 149 //
150 // Filter sensors
151 //
152 static Float_t FilterSensor(AliDCSSensor * sensor, Double_t ymin, Double_t ymax, Double_t maxdy, Double_t sigmaCut);
a980538f 153 //
154 // Filter AliRelAlignmentKalman - Alignment/Drift velocity
155 //
8166d5d7 156 static TMatrixD* MakeStatRelKalman(TObjArray * const array, Float_t minFraction, Int_t minStat, Float_t maxvd);
157 static TObjArray *SmoothRelKalman(TObjArray * const array,const TMatrixD & stat, Bool_t direction, Float_t sigmaCut);
158 static TObjArray *SmoothRelKalman(TObjArray * const arrayP, TObjArray * const arrayM);
159 static void FilterCE(Double_t deltaT=100, Double_t cutAbs=10, Double_t cutSigma=4., TTreeSRedirector * const pcstream=0);
160 static void FilterTracks(Int_t run, Double_t cutSigma=20., TTreeSRedirector * const pcstream=0);
1e722a63 161 static Float_t FilterTemperature(AliTPCSensorTempArray *tempArray, Double_t ymin=15, Double_t ymax=22, Double_t sigmaCut=5);
a23ba1c3 162
8166d5d7 163 static void FilterGoofie(AliDCSSensorArray * goofieArray, Double_t deltaT=2, Double_t cutSigma=4., Double_t minVdn=8.5, Double_t maxVdn=9.05, TTreeSRedirector * const pcstream=0);
a23ba1c3 164 static Double_t GetTriggerOffsetTPC(Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0);
165 static Double_t GetVDriftTPC(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0);
166 static Double_t GetVDriftTPCLaserTracks(Double_t &dist,Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2);
78f17711 167 static Double_t GetVDriftTPCLaserTracksOnline(Double_t &dist, Int_t /*run*/, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2);
a23ba1c3 168 static Double_t GetVDriftTPCCE(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2);
cc65e4f5 169 static Double_t GetVDriftTPCITS(Double_t &dist, Int_t run, Int_t timeStamp);
170 static Double_t GetTime0TPCITS(Double_t &dist, Int_t run, Int_t timeStamp);
a23ba1c3 171 Int_t MakeRunList(Int_t startRun, Int_t stopRun); // find the list of usable runs
172 Int_t FindRunTPC(Int_t itime, Bool_t debug=kFALSE);
b5db1171 173
174 AliTPCCalPad* GetRefCalPad(AliCDBEntry *entry, const char* objName);
175 AliTPCCalPad* GetRefCalPad(AliCDBEntry *entry);
176 AliTPCCalPad* GetAltroMasked(const char* cdbPath, const char* name);
177 Bool_t HasRefChanged(const char *cdbPath);
178 Int_t GetCurrentReferenceRun(const char* type) const;
179 AliCDBEntry* GetRefEntry(const char* cdbPath);
180
892226be 181private:
182 AliTPCcalibDB *fCalibDB; //pointer to calibDB object
183 AliTPCCalPad *fPadNoise; //noise information
184 AliTPCCalPad *fPedestals; //pedestal information
185 AliTPCCalPad *fPulserTmean; //pulser mean time information
186 AliTPCCalPad *fPulserTrms; //pulser rms time information
187 AliTPCCalPad *fPulserQmean; //pulser mean q information
188 AliTPCCalPad *fPulserOutlier; //pulser outlier map
189 AliTPCCalPad *fCETmean; //central electrode mean time information
190 AliTPCCalPad *fCETrms; //central electrode rms time information
191 AliTPCCalPad *fCEQmean; //central electrode mean q information
192 AliTPCCalPad *fALTROMasked; //ALTRO masked channels information
193 //
6e7d7dc4 194 AliTPCCalibRaw *fCalibRaw; //raw calibration object
949d8707 195 //
196 AliTPCdataQA *fDataQA; //data qa
7390f655 197 //reference data
949d8707 198 TMap *fRefMap; // latest map to reference information
199 TMap *fCurrentRefMap; // reference data map of entries currently loaded
200 TString fRefValidity; // validity range of reference data
201 //
7390f655 202 AliTPCCalPad *fRefPadNoise; //Reference noise information
203 AliTPCCalPad *fRefPedestals; //Reference pedestal information
949d8707 204 AliTPCCalPad *fRefPedestalMasked; //Reference masked channels in pedestal run
7390f655 205 AliTPCCalPad *fRefPulserTmean; //Reference pulser mean time information
206 AliTPCCalPad *fRefPulserTrms; //Reference pulser rms time information
207 AliTPCCalPad *fRefPulserQmean; //Reference pulser mean q information
208 AliTPCCalPad *fRefPulserOutlier; //Reference pulser outlier map
949d8707 209 AliTPCCalPad *fRefPulserMasked; //Reference masked channels in pulser run
7390f655 210 AliTPCCalPad *fRefCETmean; //Reference central electrode mean time information
211 AliTPCCalPad *fRefCETrms; //Reference central electrode rms time information
212 AliTPCCalPad *fRefCEQmean; //Reference central electrode mean q information
949d8707 213 AliTPCCalPad *fRefCEMasked; //Reference masked channels in laser run
214 AliTPCCalPad *fRefALTROFPED; //Reference fixed pedestal value
215 AliTPCCalPad *fRefALTROZsThr; //Reference zero suppression threshol
216 AliTPCCalPad *fRefALTROAcqStart; //Reference accquistion start time bin
217 AliTPCCalPad *fRefALTROAcqStop; //Reference accquistion stop time bin
7390f655 218 AliTPCCalPad *fRefALTROMasked; //Reference ALTRO masked channels information
219 //
220 AliTPCCalibRaw *fRefCalibRaw; //Reference raw calibration object
949d8707 221 //
222 AliTPCdataQA *fRefDataQA; //Reference data QA
6e7d7dc4 223 //
892226be 224 AliDCSSensorArray* fGoofieArray; //Goofie Data
225 //
226 AliTPCmapper *fMapper; //TPC mapping handler
227 Int_t fNpulserOutliers; //number of outliers from Pulser calibration
228
229 Float_t fIrocTimeOffset; //timing offset between IROC and OROC in timebins
230 Float_t fCETmaxLimitAbs; //maximum variation in CE data before pads will be treated as outliers
231 Float_t fPulTmaxLimitAbs; //maximum variation of Pulser Signals (time) before pads will be treated as outliers
232 Float_t fPulQmaxLimitAbs; //maximum variation of Pulser Signals (charge) before pads will be treated as outliers
233 Float_t fPulQminLimit; //minimum charge value for Pulser Signals before pads will be treated as outliers
a23ba1c3 234
235 //
236 // helpers to get the run number for given time stamps
237 //
238 // filters
892226be 239
a23ba1c3 240 TArrayI fRuns; // run list with OCDB info
241 TArrayI fRunsStart; // start time for given run
242 TArrayI fRunsStop; // stop time for given run
8166d5d7 243
892226be 244 AliTPCcalibDButil (const AliTPCcalibDButil& );
245 AliTPCcalibDButil& operator= (const AliTPCcalibDButil& );
246
949d8707 247
78f17711 248 static Double_t GetVDriftTPCLaserTracksCommon(Double_t &dist, Int_t timeStamp, Double_t deltaT, Int_t side, TObjArray * const array);
249
250
892226be 251 ClassDef(AliTPCcalibDButil,0)
252};
253
254
255#endif