bugfix: moving call to AliTPCcalibDB::SetExBField to DoInit() It was not executed...
[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
17class AliDCSSensorArray;
18class AliTPCcalibDB;
19class AliTPCCalPad;
20class AliTPCmapper;
6e7d7dc4 21class AliTPCCalibRaw;
817766d5 22class TGraph;
a23ba1c3 23class TGraphErrors;
24class TTreeSRedirector;
892226be 25
26class AliTPCcalibDButil : public TObject
29 AliTPCcalibDButil();
30 virtual ~AliTPCcalibDButil();
32 void UpdateFromCalibDB();
33 //data processing functions
7390f655 34 void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC,
2cb269df 35 Int_t &noutliersCE, Double_t & chi2A, Double_t &chi2C, AliTPCCalPad *outCE=0);
892226be 36 void ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
37 TVectorD &vecQEntries, TVectorD &vecQMean, TVectorD &vecQRMS, TVectorD &vecQMedian,
38 Float_t &driftTimeA, Float_t &driftTimeC );
39 void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
40 TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
41 Int_t &nonMaskedZero);
42 void ProcessPulser(TVectorD &vMeanTime);
43 void ProcessALTROConfig(Int_t &nMasked);
44 void ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
7390f655 45 //processing functions using reference data
46 void ProcessPedestalVariations(TVectorF &pedestalDeviations);
47 void ProcessNoiseVariations(TVectorF &noiseDeviations);
48 void ProcessPulserVariations(TVectorF &pulserQdeviations, Float_t &varQMean, Int_t &npadsOutOneTB, Int_t &npadsOffAdd);
892226be 49 //getter preprocess information
50 Int_t GetNPulserOutliers() const {return fNpulserOutliers;}
51 Float_t GetMeanAltro(const AliTPCCalROC *roc, const Int_t row, const Int_t pad, AliTPCCalROC *rocOut=0x0);
52 AliTPCCalPad *GetPulserOutlierMap() const {return fPulserOutlier;}
53 //setters for pad by pad information
54 void SetPulserData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
55 {fPulserTmean=tmean; fPulserTrms=trms; fPulserQmean=qmean;}
56 void SetCEData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
57 {fCETmean=tmean; fCETrms=trms; fCEQmean=qmean;}
58 void SetNoisePedestal(AliTPCCalPad *noise, AliTPCCalPad *pedestal=0x0)
59 {fPadNoise=noise; fPedestals=pedestal;}
60 void SetALTROData(AliTPCCalPad *masked)
61 {fALTROMasked=masked;}
62 void SetGoofieArray(AliDCSSensorArray *arr) {fGoofieArray=arr;}
7390f655 63 //setters for pad by pad information
64 void SetRefFile(const char* filename);
65 void SetRefPulserData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
66 {fRefPulserTmean=tmean; fRefPulserTrms=trms; fRefPulserQmean=qmean;}
67 void SetRefCEData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
68 {fRefCETmean=tmean; fRefCETrms=trms; fRefCEQmean=qmean;}
69 void SetRefNoisePedestal(AliTPCCalPad *noise, AliTPCCalPad *pedestal=0x0)
70 {fRefPadNoise=noise; fRefPedestals=pedestal;}
71 void SetRefALTROData(AliTPCCalPad *masked)
72 {fRefALTROMasked=masked;}
892226be 74 //creation of derived pad by pad calibration data
2cb269df 75 AliTPCCalPad *CreatePadTime0(Int_t model, Double_t &gyA, Double_t &gyC, Double_t &chi2A, Double_t &chi2C);
892226be 76 //
2cb269df 77 // create outlyer maps
78 //
79 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);
80 AliTPCCalPad *CreatePulserOutlyerMap(Int_t &noutliersPulser, AliTPCCalPad *pulserOut=0, Float_t cutTime=3, Float_t cutnRMSQ=5, Float_t cutnRMSrms=5);
81 //
82 AliTPCCalPad *CreatePadTime0CE(TVectorD &fitResultsA, TVectorD&fitResultsC, Int_t &nOut, Double_t &chi2A, Double_t &chi2C, const char *dumpfile=0);
83 //
892226be 85 void UpdatePulserOutlierMap();
7390f655 86 void UpdateRefPulserOutlierMap();
87 void PulserOutlierMap(AliTPCCalPad *pulOut, const AliTPCCalPad *pulT, const AliTPCCalPad *pulQ);
817766d5 88
89 //
90 // graph tools
91 //
a23ba1c3 92 static Double_t GetLaserTime0(Int_t run, Int_t timeStamp, Int_t deltaT, Int_t side);
93 static TGraph* FilterGraphMedian(TGraph * graph, Float_t sigmaCut, Double_t &medianY);
94 static TGraph* FilterGraphMedianAbs(TGraph * graph, Float_t cut, Double_t &medianY);
95 static TGraphErrors* FilterGraphMedianErr(TGraphErrors * graph, Float_t sigmaCut,Double_t &medianY);
96 //
97 static void Sort(TGraph *graph);
98 static void SmoothGraph(TGraph *graph, Double_t delta);
817766d5 99 static Int_t GetNearest(TGraph *graph, Double_t xref, Double_t &dx, Double_t &y);
a23ba1c3 100 static Double_t EvalGraphConst(TGraph *graph, Double_t xref);
1e722a63 101 //
102 // Filter sensors
103 //
104 static Float_t FilterSensor(AliDCSSensor * sensor, Double_t ymin, Double_t ymax, Double_t maxdy, Double_t sigmaCut);
a23ba1c3 106
1e722a63 107 static void FilterCE(Double_t deltaT=100, Double_t cutAbs=10, Double_t cutSigma=4., TTreeSRedirector *pcstream=0);
108 static void FilterTracks(Int_t run, Double_t cutSigma=20., TTreeSRedirector *pcstream=0);
109 static Float_t FilterTemperature(AliTPCSensorTempArray *tempArray, Double_t ymin=15, Double_t ymax=22, Double_t sigmaCut=5);
a23ba1c3 110
1fabc823 111 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 112 static Double_t GetTriggerOffsetTPC(Int_t run, Int_t timeStamp, Double_t deltaT=86400, Double_t deltaTLaser=3600, Int_t valType=0);
113 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);
114 static Double_t GetVDriftTPCLaserTracks(Double_t &dist,Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2);
115 static Double_t GetVDriftTPCCE(Double_t &dist, Int_t run, Int_t timeStamp, Double_t deltaT=43200, Int_t side=2);
116 Int_t MakeRunList(Int_t startRun, Int_t stopRun); // find the list of usable runs
117 Int_t FindRunTPC(Int_t itime, Bool_t debug=kFALSE);
892226be 118private:
119 AliTPCcalibDB *fCalibDB; //pointer to calibDB object
120 AliTPCCalPad *fPadNoise; //noise information
121 AliTPCCalPad *fPedestals; //pedestal information
122 AliTPCCalPad *fPulserTmean; //pulser mean time information
123 AliTPCCalPad *fPulserTrms; //pulser rms time information
124 AliTPCCalPad *fPulserQmean; //pulser mean q information
125 AliTPCCalPad *fPulserOutlier; //pulser outlier map
126 AliTPCCalPad *fCETmean; //central electrode mean time information
127 AliTPCCalPad *fCETrms; //central electrode rms time information
128 AliTPCCalPad *fCEQmean; //central electrode mean q information
129 AliTPCCalPad *fALTROMasked; //ALTRO masked channels information
130 //
6e7d7dc4 131 AliTPCCalibRaw *fCalibRaw; //raw calibration object
7390f655 132 //reference data
133 AliTPCCalPad *fRefPadNoise; //Reference noise information
134 AliTPCCalPad *fRefPedestals; //Reference pedestal information
135 AliTPCCalPad *fRefPulserTmean; //Reference pulser mean time information
136 AliTPCCalPad *fRefPulserTrms; //Reference pulser rms time information
137 AliTPCCalPad *fRefPulserQmean; //Reference pulser mean q information
138 AliTPCCalPad *fRefPulserOutlier; //Reference pulser outlier map
139 AliTPCCalPad *fRefCETmean; //Reference central electrode mean time information
140 AliTPCCalPad *fRefCETrms; //Reference central electrode rms time information
141 AliTPCCalPad *fRefCEQmean; //Reference central electrode mean q information
142 AliTPCCalPad *fRefALTROMasked; //Reference ALTRO masked channels information
143 //
144 AliTPCCalibRaw *fRefCalibRaw; //Reference raw calibration object
6e7d7dc4 146 //
892226be 147 AliDCSSensorArray* fGoofieArray; //Goofie Data
148 //
149 AliTPCmapper *fMapper; //TPC mapping handler
150 Int_t fNpulserOutliers; //number of outliers from Pulser calibration
152 Float_t fIrocTimeOffset; //timing offset between IROC and OROC in timebins
153 Float_t fCETmaxLimitAbs; //maximum variation in CE data before pads will be treated as outliers
154 Float_t fPulTmaxLimitAbs; //maximum variation of Pulser Signals (time) before pads will be treated as outliers
155 Float_t fPulQmaxLimitAbs; //maximum variation of Pulser Signals (charge) before pads will be treated as outliers
156 Float_t fPulQminLimit; //minimum charge value for Pulser Signals before pads will be treated as outliers
a23ba1c3 157
158 //
159 // helpers to get the run number for given time stamps
160 //
161 // filters
892226be 162
a23ba1c3 163public:
164 TArrayI fRuns; // run list with OCDB info
165 TArrayI fRunsStart; // start time for given run
166 TArrayI fRunsStop; // stop time for given run
892226be 168 AliTPCcalibDButil (const AliTPCcalibDButil& );
169 AliTPCcalibDButil& operator= (const AliTPCcalibDButil& );
172 ClassDef(AliTPCcalibDButil,0)