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