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