skip clusters when the roc voltage is funny
[u/mrichter/AliRoot.git] / TPC / Base / AliTPCcalibDB.h
CommitLineData
c5bbaa2c 1#ifndef ALITPCCALIBDB_H
2#define ALITPCCALIBDB_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6///////////////////////////////////////////////////////////////////////////////
7// //
8// Class providing the calibration parameters by accessing the CDB //
9// //
10///////////////////////////////////////////////////////////////////////////////
11
12
418bbcaf 13class AliTPCTransform;
14class AliTPCExB;
c5bbaa2c 15#include "TObject.h"
bf85fe4d 16#include "TObjArray.h"
17#include "TArrayI.h"
18#include "TVectorD.h"
5312f439 19#include "TGraph.h"
20#include "AliTPCCalPad.h"
21#include "TString.h"
7390f655 22#include "AliSplineFit.h"
8de4c8a6 23#include "TMap.h"
bf85fe4d 24
9a836cc2 25class TGraphErrors;
54472e4f 26class AliTPCSensorTempArray;
e7e39fb5 27class AliDCSSensorArray;
c5bbaa2c 28class AliCDBEntry;
8477f500 29class AliTPCParam;
d6834f5f 30class AliTPCAltroMapping;
96305e49 31class AliTPCClusterParam;
0736ecae 32class AliTPCRecoParam;
bf85fe4d 33class AliDCSSensor;
34class AliDCSSensorArray;
da6c0bc9 35class AliTPCCalibVdrift;
8de77f00 36class AliGRPObject;
6e7d7dc4 37class AliTPCCalibRaw;
949d8707 38class AliTPCdataQA;
0a997b33 39class AliMagF;
1e722a63 40class AliTPCcalibDButil;
f14d21a1 41class AliCTPTimeParams;
cf5b0aa0 42class AliTPCCorrection;
68751c2c 43//class AliCDBStorage;
c5bbaa2c 44
45class AliTPCcalibDB : public TObject
46{
47 public:
48 static AliTPCcalibDB* Instance();
49 AliTPCcalibDB();
50 virtual ~AliTPCcalibDB();
51 static void Terminate();
52 void SetRun(Long64_t run);
5e1215d4 53 void Update(); //update entries
54 void UpdateRunInformations(Int_t run, Bool_t force=kFALSE);
56ce896d 55 void UpdateNonRec();
d4559772 56 Bool_t GetTailcancelationGraphs(Int_t sector, TGraphErrors ** graphRes, Float_t * indexAmpGraphs);
5e1215d4 57 //
5312f439 58 Long64_t GetRun() const {return fRun;}
5e1215d4 59 //
60 //
c5bbaa2c 61 //
92fb7d95 62 AliTPCTransform* GetTransform() const {return fTransform;}
63 AliTPCExB* GetExB() const {return fExB;}
f4d5fd21 64 void SetExBField(Float_t bz);
0a997b33 65 void SetExBField( const AliMagF* bmap);
3ac615eb 66 static AliTPCExB* GetExB(Float_t bz,Bool_t bdelete);
8de4c8a6 67 AliTPCCalPad* GetPadGainFactorOld() const {return fPadGainFactor;}
68 AliTPCCalPad* GetPadGainFactor() const {return fActiveChannelMap;}
69 AliTPCCalPad* GetActiveChannelMap() const { return fActiveChannelMap; }
92fb7d95 70 AliTPCCalPad* GetDedxGainFactor() const {return fDedxGainFactor;}
71 AliTPCCalPad* GetPadTime0() const {return fPadTime0;}
8b63d99c 72 AliTPCCalPad* GetDistortionMap(Int_t i) const;
cf5b0aa0 73 AliTPCCorrection * GetTPCComposedCorrection() const { return fComposedCorrection;}
78f17711 74 TObjArray * GetTPCComposedCorrectionArray() const { return fComposedCorrectionArray;}
cf5b0aa0 75 void SetTPCComposedCorrection(AliTPCCorrection *compCorr) { fComposedCorrection=compCorr;}
0b736a46 76 AliTPCCorrection * GetTPCComposedCorrection(Float_t field) const;
3f3549a3 77 AliTPCCorrection * GetTPCComposedCorrectionDelta() const;
78 Bool_t HasAlignmentOCDB() const { return fBHasAlignmentOCDB;}
0b736a46 79
92fb7d95 80 AliTPCCalPad* GetPadNoise() const {return fPadNoise;}
81 AliTPCCalPad* GetPedestals() const{return fPedestals;}
5312f439 82 //ALTRO config data
83 TObjArray* GetAltroConfigData() const {return fALTROConfigData;}
84 AliTPCCalPad* GetALTROAcqStart() const {return fALTROConfigData?static_cast<AliTPCCalPad*>(fALTROConfigData->FindObject("AcqStart")):0;}
85 AliTPCCalPad* GetALTROZsThr() const {return fALTROConfigData?static_cast<AliTPCCalPad*>(fALTROConfigData->FindObject("ZsThr")):0;}
86 AliTPCCalPad* GetALTROFPED() const {return fALTROConfigData?static_cast<AliTPCCalPad*>(fALTROConfigData->FindObject("FPED")):0;}
87 AliTPCCalPad* GetALTROAcqStop() const {return fALTROConfigData?static_cast<AliTPCCalPad*>(fALTROConfigData->FindObject("AcqStop")):0;}
88 AliTPCCalPad* GetALTROMasked() const {return fALTROConfigData?static_cast<AliTPCCalPad*>(fALTROConfigData->FindObject("Masked")):0;}
8de4c8a6 89 TMap* GetDDLMap() const {return fALTROConfigData?static_cast<TMap*>(fALTROConfigData->FindObject("DDLArray")):0;}
f14d21a1 90 TMap* GetRCUconfig() const {return fALTROConfigData?(TMap*)(fALTROConfigData->FindObject("RCUconfig")):0;}
91 Int_t GetRCUTriggerConfig() const;
92 Bool_t IsTrgL0();
93 Bool_t IsTrgL1();
94
4bef51b7 95 TObjArray* GetIonTailArray() const {return fIonTailArray;}
f14d21a1 96
5312f439 97 //Pulser data
98 TObjArray* GetPulserData() const {return fPulserData;}
99 AliTPCCalPad* GetPulserTmean() const {return fPulserData?static_cast<AliTPCCalPad*>(fPulserData->FindObject("PulserTmean")):0;}
100 AliTPCCalPad* GetPulserTrms() const {return fPulserData?static_cast<AliTPCCalPad*>(fPulserData->FindObject("PulserTrms")):0;}
101 AliTPCCalPad* GetPulserQmean() const {return fPulserData?static_cast<AliTPCCalPad*>(fPulserData->FindObject("PulserQmean")):0;}
6e7d7dc4 102 //CE data
5312f439 103 TObjArray* GetCEData() const {return fCEData;}
104 AliTPCCalPad* GetCETmean() const {return fCEData?static_cast<AliTPCCalPad*>(fCEData->FindObject("CETmean")):0;}
105 AliTPCCalPad* GetCETrms() const {return fCEData?static_cast<AliTPCCalPad*>(fCEData->FindObject("CETrms")):0;}
106 AliTPCCalPad* GetCEQmean() const {return fCEData?static_cast<AliTPCCalPad*>(fCEData->FindObject("CEQmean")):0;}
107 TObjArray* GetCErocTtime() const {return fCEData?static_cast<TObjArray*>(fCEData->FindObject("rocTtime")):0;}
108 TObjArray* GetCErocQtime() const {return fCEData?static_cast<TObjArray*>(fCEData->FindObject("rocQtime")):0;}
78f17711 109 TObjArray* GetCEfitsDrift()const {return fCEData?static_cast<TObjArray*>(fCEData->FindObject("ceFitsDrift")):0;}
5312f439 110 TGraph* GetCErocTgraph(const Int_t roc)const {return GetCErocTtime()?static_cast<TGraph*>(GetCErocTtime()->At(roc)):0;}
111 TGraph* GetCErocQgraph(const Int_t roc)const {return GetCErocQtime()?static_cast<TGraph*>(GetCErocQtime()->At(roc)):0;}
892226be 112 static Float_t GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0);
113 static Float_t GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0);
6e7d7dc4 114 //Raw calibration
115 AliTPCCalibRaw* GetCalibRaw() const {return fCalibRaw;}
4bef51b7 116
949d8707 117 //QA object
118 AliTPCdataQA* GetDataQA() const {return fDataQA;}
6e7d7dc4 119 //
92fb7d95 120 AliTPCSensorTempArray* GetTemperature() const {return fTemperature;}
121 AliTPCParam* GetParameters() const {return fParam;}
122 AliTPCAltroMapping ** GetMapping() const{ return fMapping;}
123 AliTPCClusterParam *GetClusterParam() const { return fClusterParam;}
124 TObjArray *GetTimeGainSplines() const { return fTimeGainSplines;}
d6834f5f 125 //
0736ecae 126 //Reco param getter
127 AliTPCRecoParam *GetRecoParam(Int_t i) const;
5312f439 128 //GRP information
8de77f00 129 static AliGRPObject * GetGRP(Int_t run);
0231c65f 130 static TMap * GetGRPMap(Int_t run);
da6c0bc9 131 static Float_t GetPressure(Int_t timeStamp, Int_t run, Int_t type=0);
5312f439 132 static Float_t GetL3Current(Int_t run, Int_t statType=0);
133 static Float_t GetBz(Int_t run);
134 static Char_t GetL3Polarity(Int_t run);
135 static TString GetRunType(Int_t run);
136 //
7fff7612 137 static Float_t GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits=-1);
138 static Float_t GetDCSSensorMeanValue(AliDCSSensorArray *arr, const char * sensorName, Int_t sigDigits=-1);
5312f439 139 //Voltage information
2073b7a5 140 static Float_t GetChamberHighVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0, Bool_t current=kFALSE);
7fff7612 141 static Float_t GetSkirtVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0);
142 static Float_t GetCoverVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0);
143 static Float_t GetGGoffsetVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0);
144 static Float_t GetGGnegVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0);
145 static Float_t GetGGposVoltage(Int_t run, Int_t sector, Int_t timeStamp=-1, Int_t sigDigits=0);
661f340b 146 //
147 Bool_t GetChamberHVStatus(UInt_t roc) const { return (roc<72)?fChamberHVStatus[roc]:kFALSE; }
148 Float_t GetChamberHighVoltageMedian(UInt_t roc) const { return (roc<72)?fChamberHVmedian[roc]:0.; }
149 Float_t GetChamberCurrentNominalHighVoltage(UInt_t roc) const { return (roc<72)?fCurrentNominalVoltage[roc]:0.; }
150 Float_t GetChamberGoodHighVoltageFraction(UInt_t roc) const { return (roc<72)?fChamberHVgoodFraction[roc]:0.; }
151 AliDCSSensor* GetChamberHVSensor(UInt_t roc) const { return (roc<72)?fHVsensors[roc]:0x0; }
00e32b66 152 Double_t GetGainCorrectionHVandPT(Int_t timeStamp, Int_t run, Int_t sector, Int_t deltaCache, Int_t mode);
661f340b 153 Bool_t IsDataTakingActive(time_t timeStamp);
154 //
5312f439 155 //Goofie Values
661f340b 156 //
7f7847fe 157 static Float_t GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type);
5312f439 158 //
64b48395 159 static Bool_t GetTemperatureFit(Int_t timeStamp, Int_t run, Int_t side,TVectorD& fit);
160 static Float_t GetTemperature(Int_t timeStamp, Int_t run, Int_t side);
da6c0bc9 161 static Double_t GetPTRelative(UInt_t timeSec, Int_t run, Int_t side);
162 AliDCSSensor * GetPressureSensor(Int_t run, Int_t type=0);
e2914767 163 //AliDCSSensor * GetVoltageSensor(Int_t run, Int_t type=0);
bf85fe4d 164 AliTPCSensorTempArray * GetTemperatureSensor(Int_t run);
165 AliDCSSensorArray * GetGoofieSensors(Int_t run);
e2914767 166 AliDCSSensorArray * GetVoltageSensors(Int_t run);
da6c0bc9 167 AliTPCCalibVdrift * GetVdrift(Int_t run);
661f340b 168 TObjArray * GetTimeGainSplinesRun(Int_t run);
7390f655 169 TObjArray* GetTimeVdriftSplineRun(Int_t run);
bf85fe4d 170 static Float_t GetGain(Int_t sector, Int_t row, Int_t pad);
171 //
661f340b 172 // Drift velocity information
173 //
17c90083 174 Double_t GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t mode);
175 Double_t GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t side, Int_t mode);
176 Double_t GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t mode);
e185e9d8 177 Double_t GetVDriftCorrectionDeltaZ(Int_t timeStamp, Int_t run, Int_t side, Int_t mode);
17c90083 178 //
7390f655 179 AliSplineFit* GetVdriftSplineFit(const char* name, Int_t run);
2cb269df 180 AliSplineFit* CreateVdriftSplineFit(const char* graphName, Int_t run);
7390f655 181 //
86df2b3a 182 static void CreateObjectList(const Char_t *filename, TObjArray *calibObjects);
183 static void MakeTree(const char * fileName, TObjArray * array, const char * mapFileName = 0, AliTPCCalPad* outlierPad = 0, Float_t ltmFraction = 0.9);
3ac615eb 184 static void RegisterExB(Int_t index, Float_t bz, Bool_t bdelete);
c5bbaa2c 185 //
bf85fe4d 186 //
8de4c8a6 187 //
72b94ffb 188 AliTPCCalPad* MakeDeadMap(Double_t notInMap=1, const char *nameMappingFile="$ALICE_ROOT/TPC/Calib/tpcMapping.root" );
e2914767 189 AliGRPObject * MakeGRPObjectFromMap(TMap *map);
f14d21a1 190 AliCTPTimeParams* GetCTPTimeParams() const {return fCTPTimeParams;}
5312f439 191 //Create a tree suited for diplaying with the AliTPCCalibViewerGUI
949d8707 192 Bool_t CreateGUITree(const char* filename="");
5312f439 193 static Bool_t CreateGUITree(Int_t run, const char* filename="");
7390f655 194 static Bool_t CreateRefFile(Int_t run, const char* filename="");
bf85fe4d 195 //
c5bbaa2c 196protected:
e2914767 197
c5bbaa2c 198 AliCDBEntry* GetCDBEntry(const char* cdbPath);
661f340b 199 void UpdateChamberHighVoltageData();
ba63ff39 200 Int_t InitDeadMap();
201
2b4c6ff5 202 Int_t fRun; // current run number
f5344549 203 AliTPCTransform *fTransform; // object responsible for spacial corrections
418bbcaf 204 AliTPCExB *fExB; // ExB correction factor
68751c2c 205// AliCDBStorage* fLocator; // Storage locator retrieved from AliCDBManager
c5bbaa2c 206 //
207 // calibration parameters per pad
208 //
418bbcaf 209 AliTPCCalPad* fPadGainFactor; // Gain calibration entry
8de4c8a6 210 AliTPCCalPad* fActiveChannelMap; // Map of active channels calculated on the fly
9f6e9f81 211 AliTPCCalPad* fDedxGainFactor; // Gain calibration entry - for dEdx
418bbcaf 212 AliTPCCalPad* fPadTime0; // Time0 calibration entry
2293155b 213 TObjArray *fDistortionMap; // distortion map
cf5b0aa0 214 AliTPCCorrection *fComposedCorrection; // general space point corrections
0b736a46 215 TObjArray * fComposedCorrectionArray; //space point corrections for different field setting
418bbcaf 216 AliTPCCalPad* fPadNoise; // Noise calibration entry
217 AliTPCCalPad* fPedestals; // Pedestal calibration entry
6e7d7dc4 218 AliTPCCalibRaw *fCalibRaw; // raw data calibration entry
949d8707 219 AliTPCdataQA *fDataQA; // qa object
5312f439 220 TObjArray *fALTROConfigData; // ALTRO configuration data
4bef51b7 221 TObjArray * fIonTailArray; // array of graphs with the ion tail
5312f439 222 TObjArray *fPulserData; // Calibration Pulser data
223 TObjArray *fCEData; // CE data
224 //
661f340b 225 // Chamber HV info
226 //
227 Bool_t fChamberHVStatus[72]; // Status of the Chamber, HV wise (on/off)
228 Float_t fChamberHVmedian[72]; // median chamber high voltage
229 Float_t fCurrentNominalVoltage[72]; // current nominal voltages
230 Float_t fChamberHVgoodFraction[72]; // fraction of time the chamber has a good HV (wrt. robust median)
231 AliDCSSensor *fHVsensors[72]; // HV sensors
232 TGraph *fGrRunState; // store information if run is active or paused
233 //
949d8707 234 //
235 //
418bbcaf 236 AliTPCSensorTempArray* fTemperature; // Temperature calibration entry
d6834f5f 237 AliTPCAltroMapping **fMapping; // Altro mapping
8477f500 238 //
239 //
0736ecae 240 AliTPCParam * fParam; // TPC parameters
96305e49 241 AliTPCClusterParam * fClusterParam; // TPC cluster error, shape and Q parameterization
0736ecae 242 TObjArray * fRecoParamList; // List of TPC reco param objects
243 TObjArray * fTimeGainSplines; // Array of AliSplineFits: at 0 MIP position in time ; at 1 Fermi Plateau from cosmics
c5bbaa2c 244 //
bf85fe4d 245 // Get the corssrun information
246 //
2b4c6ff5 247 TMap fTimeGainSplinesArray; //! array Array of AliSplineFits: at 0 MIP position in time ; at 1 Fermi Plateau from cosmics
248 TMap fGRPArray; //! array of GRPs - per run
249 TMap fGRPMaps; //! array of GRPs maps - per run - old data
250 TMap fGoofieArray; //! array of GOOFIE values -per run
251 TMap fVoltageArray; //! array of Chamber HV values -per run
252 TMap fTemperatureArray; //! array of temperature sensors - per run
253 TMap fVdriftArray; //! array of v drift interfaces
254 TMap fDriftCorrectionArray; //! array of drift correction
5e1215d4 255
a2c3785e 256 TArrayI fRunList; //! run list - indicates try to get the run param
3f3549a3 257 Bool_t fBHasAlignmentOCDB; // Flag - alignment from the Transformation class
bf85fe4d 258 //
418bbcaf 259 static AliTPCcalibDB* fgInstance; // singleton control
260 static Bool_t fgTerminated; // termination control
3ac615eb 261 static TObjArray fgExBArray; // array of ExB corrections
1e722a63 262 AliTPCcalibDButil *fDButil; // utility class
f14d21a1 263 //ctp info
264 AliCTPTimeParams *fCTPTimeParams; //CTP timing parameters
88a69e6f 265 Int_t fMode; //RCU trigger config mode
266
e4dce695 267 private:
f4a89669 268 AliTPCcalibDB (const AliTPCcalibDB& );
269 AliTPCcalibDB& operator= (const AliTPCcalibDB& );
2b4c6ff5 270
0736ecae 271 ClassDef(AliTPCcalibDB, 1)
c5bbaa2c 272};
273
c5bbaa2c 274#endif