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