]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/Macros/DumpOCDBtoTree.C
end-of-line normalization
[u/mrichter/AliRoot.git] / TRD / Macros / DumpOCDBtoTree.C
CommitLineData
5478d397 1 ////////////////////////////////////////////
2 // Author: Ionut Cristian Arsene //
3 // email: iarsene@mail.cern.ch //
4 ////////////////////////////////////////////
5 // Use this macro to create ROOT trees with time dependent information from the TRD OCDB
6 //
7 // Usage:
8 //
9 // void DumpOCDBtoTree(const Char_t* outFilename,
10 // const Char_t* runListFilename,
11 // Int_t firstRun = -1, Int_t lastRun = -1,
12 // const Char_t* storageURI = "alien://folder=/alice/data/2010/OCDB/",
13 // Bool_t getHVInfo = kTRUE,
14 // Bool_t getCalibrationInfo = kFALSE,
15 // Bool_t getGasInfo = kFALSE,
16 // Bool_t getStatusInfo = kFALSE,
17 // Bool_t getGoofieInfo = kFALSE,
18 // Bool_t getDCSInfo = kFALSE,
19 // Bool_t getGRPInfo = kTRUE)
20 //
21 // * runListFilename - name of an ascii file containing run numbers
22 // * outFilename - name of the root file where the TRD OCDB information tree to be stored
23 // * firstRun, lastRun - lowest and highest run numbers (from the ascii file) to be dumped
24 // if these numbers are not specified (-1) all run numbers in the input ascii file will
25 // be used. If the run list file is not specified then all runs in this interval
26 // will be queried
27 // * getHVInfo - flag to switch on/off HV information (HV anode and drift currents/voltages)
28 // * getCalibrationInfo- flag to switch on/off calibration information (gain, pedestal, T0, vdrift, pad status)
29 // * getGasInfo - flag to switch on/off gas related information (gas composition, overpressure, temperature)
30 // * getStatusInfo - flag to switch on/off status information (trd_chamberStatus)
31 // * getGoofieInfo - flag to switch on/off goofie information (gain, HV, pressure, temperature, drift velocity,
32 // gas composition)
33 // * getDCSInfo - flag to switch on/off DCS information
34 // * getGRPInfo - flag to switch on/off GRP information --> there will be no time information in the output tree
01de2c40 35 // * storageURI - path of the OCDB database (if it is on alien, be sure to have a valid/active token)
5478d397 36
37
38 #include <iostream>
39 #include <fstream>
40 #include <string>
41 #include <exception>
42 #include "TError.h"
43 #include "TVectorD.h"
44 #include "TTreeStream.h"
45 #include "TObjString.h"
46 #include "TTimeStamp.h"
47 #include "TH1.h"
48 #include "TMath.h"
49 #include "TObjArray.h"
50 #include "TFile.h"
51 #include "TSystem.h"
52 #include "TGrid.h"
53 #include "AliCDBManager.h"
54 #include "AliCDBStorage.h"
55 #include "AliCDBEntry.h"
56 #include "AliTRDcalibDB.h"
57 #include "AliGRPObject.h"
58 #include "AliDCSSensor.h"
59 #include "AliTRDSensorArray.h"
60 #include "AliTRDCalDet.h"
61 #include "AliTRDCalPad.h"
62 #include "AliTRDCalROC.h"
63 #include "AliTRDCalPadStatus.h"
64 #include "AliTRDCalChamberStatus.h"
65 #include "AliTRDCalSingleChamberStatus.h"
66 #include "AliTRDCalDCS.h"
67 #include "AliTRDCalDCSFEE.h"
ef619721 68 #include "AliTRDCalDCSv2.h"
69 #include "AliTRDCalDCSFEEv2.h"
5478d397 70 using namespace std;
71
72 // global variables
73 // histograms used for extracting the mean and RMS of calibration parameters
74 TH1F *gRunWiseHisto;
75 TH1F *gSuperModuleWiseHisto;
76 TH1F *gChamberWiseHisto;
77
78 // global constants
79 const Int_t gkSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, 0, 1, 1, // (1-installed)
80 1, 1, 0, 0, 0, 0, 0, 0, 1};
81 AliCDBStorage *storage = NULL;
82 AliCDBManager *manager = NULL;
83 Int_t currRun(0);
84 void MakeRunListFromOCDB(const Char_t* directory, const Char_t* outfile, Bool_t fromAlien=kFALSE);
85 void ProcessTRDSensorArray(AliTRDSensorArray*, TTimeStamp, TVectorD&);
86 void ProcessTRDCalibArray(AliTRDCalDet*, AliTRDCalPad*, TString, Double_t&, Double_t&,
87 TVectorD&, TVectorD&, TVectorD&, TVectorD&);
88 void ProcessTRDstatus(AliTRDCalChamberStatus*, AliTRDCalPadStatus*, Float_t&, TVectorD&, TVectorD&);
ef619721 89 void ProcessTRDCalDCSFEE(TObject*, TObject*, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Bool_t&,
5478d397 90 TVectorD&, TVectorD&);
91 AliCDBEntry* GetCDBentry(const Char_t *path, Bool_t owner=kTRUE);
92 //__________________________________________________________________________________________
93 void DumpOCDBtoTree(const Char_t* outFilename,
94 const Char_t* runListFilename,
95 Int_t firstRun = -1, Int_t lastRun = -1,
96 const Char_t* storageURI = "alien://folder=/alice/data/2010/OCDB/",
97 Bool_t getHVInfo = kTRUE,
98 Bool_t getCalibrationInfo = kFALSE,
e87f8c2f 99 Bool_t getGasInfo = kFALSE,
5478d397 100 Bool_t getStatusInfo = kFALSE,
101 Bool_t getGoofieInfo = kFALSE,
102 Bool_t getDCSInfo = kFALSE,
103 Bool_t getGRPInfo = kTRUE) {
9bf458e3 104 //
105 // Main function to steer the extraction of TRD OCDB information
106 //
107
108
109 TTimeStamp jobStartTime;
110 // if the storage is on alien than we need to do some extra stuff
5478d397 111 TString storageString(storageURI);
9bf458e3 112 if(storageString.Contains("alien://")) {
113 TGrid::Connect("alien://");
114 }
115 // initialize the OCDB manager
5478d397 116 manager = AliCDBManager::Instance();
117 manager->SetDefaultStorage(storageURI);
118 manager->SetCacheFlag(kTRUE);
119 storage = manager->GetDefaultStorage();
120 AliCDBEntry *entry = NULL;
121
9bf458e3 122 // initialize the tree
123 TTreeSRedirector *treeStreamer = new TTreeSRedirector(outFilename);
5478d397 124
9bf458e3 125 // initialize the histograms used for extracting the mean and RMS
126 gRunWiseHisto = new TH1F("runHisto", "runHisto", 200, -10.0, 10.0);
127 gSuperModuleWiseHisto = new TH1F("smHisto", "smHisto", 200, -10.0, 10.0);
128 gChamberWiseHisto = new TH1F("chamberHisto", "chamberHisto", 200, -10.0, 10.0);
129
130 // open the ascii file with run numbers
131 ifstream in;
132 if(runListFilename[0]!='\0')
133 in.open(runListFilename);
134
135 // if a run list file was not specified then use the run range
9bf458e3 136 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1)
5478d397 137 currRun = firstRun-1;
9bf458e3 138
139 TVectorD runs;
140 TVectorD rejectedRuns;
141 TTimeStamp loopStartTime;
142
143 // loop over runs
144 while(1) {
145 // check if we still have run numbers in the file or provided range
146 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1) {
147 currRun++;
148 if(currRun>lastRun) break;
149 }
150 if(runListFilename[0]!='\0') {
151 if(in.eof()) break;
152 if(!(in>>currRun)) continue;
153 if(currRun < (firstRun==-1 ? 0 : firstRun) ||
5478d397 154 currRun > (lastRun==-1 ? 999999999 : lastRun)) continue;
9bf458e3 155 }
156
5478d397 157 printf("\n\tRUN[%d]\n", currRun);
9bf458e3 158 // check if the run was processed already
159 Bool_t runProcessed = kFALSE;
160 for(Int_t iRun=0; iRun<runs.GetNoElements(); iRun++) {
161 if(runs[iRun]==currRun) runProcessed = kTRUE;
162 }
163 if(runProcessed) {
164 cout << "Run processed already" << endl;
165 continue;
166 }
9bf458e3 167 manager->SetRun(currRun);
168
5478d397 169 // Get the GRP data. Only runs with a corresponding GRP entry in the OCDB
9bf458e3 170 // will be processed.
171 time_t startTime = 0;
172 time_t endTime = 0;
173 TObjString runType("UNKNOWN");
e87f8c2f 174 AliDCSSensor *cavern_pressure = 0x0;
175 AliDCSSensor *surface_pressure = 0x0;
9bf458e3 176 UInt_t detectorMask = 0;
5478d397 177 if(getGRPInfo){
178 if(!(entry = GetCDBentry("GRP/GRP/Data", 0))) {
179 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
180 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
181 continue;
e87f8c2f 182 }
9bf458e3 183 }
5478d397 184 AliGRPObject* grpObject = dynamic_cast<AliGRPObject*>(entry->GetObject());
9bf458e3 185 if(grpObject) {
186 startTime = grpObject->GetTimeStart();
187 endTime = grpObject->GetTimeEnd();
188 runType = grpObject->GetRunType().Data();
189 cavern_pressure = grpObject->GetCavernAtmosPressure();
190 surface_pressure = grpObject->GetSurfaceAtmosPressure();
191 detectorMask = grpObject->GetDetectorMask();
192 TTimeStamp start(grpObject->GetTimeStart());
193 TTimeStamp end(grpObject->GetTimeEnd());
5478d397 194 cout << " Start time: " << start.GetDate()/10000 << "/"
195 << (start.GetDate()/100)-(start.GetDate()/10000)*100 << "/"
196 << start.GetDate()%100 << " "
197 << start.GetTime()/10000 << ":"
198 << (start.GetTime()/100)-(start.GetTime()/10000)*100 << ":"
199 << start.GetTime()%100 << endl;
200 cout << " End time: " << end.GetDate()/10000 << "/"
201 << (end.GetDate()/100)-(end.GetDate()/10000)*100 << "/"
202 << end.GetDate()%100 << " "
203 << end.GetTime()/10000 << ":"
204 << (end.GetTime()/100)-(end.GetTime()/10000)*100 << ":"
205 << end.GetTime()%100 << endl;
206 cout << " Run type = " << grpObject->GetRunType().Data() << endl;
207 } else {
e87f8c2f 208 if(getGRPInfo) {
5478d397 209 cout << "No GRP info available --> skiping this run!" << endl;
210 // add the run number to the list of rejected runs
211 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
212 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
213 continue;
e87f8c2f 214 }
9bf458e3 215 }
216
217 // remove runs with zero time duration
e87f8c2f 218 if(getGRPInfo && startTime==endTime) {
9bf458e3 219 if(grpObject) delete grpObject;
220 // add the run number to the list of rejected runs
221 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
222 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
223 continue;
224 }
225
226 // time step for time dependent information (change this if you need something else)
227 UInt_t dTime = TMath::Max((endTime-startTime)/20, Long_t(5*60));
228
229 // get monitoring information
230 AliTRDSensorArray *anodeISensors = 0;
231 AliTRDSensorArray *anodeUSensors = 0;
232 AliTRDSensorArray *driftISensors = 0;
233 AliTRDSensorArray *driftUSensors = 0;
234 AliTRDSensorArray *temperatureSensors = 0;
235 AliTRDSensorArray *chamberStatusSensors = 0;
236 AliTRDSensorArray *overpressureSensors = 0;
237 AliTRDSensorArray *gasCO2Sensors = 0;
238 AliTRDSensorArray *gasH2OSensors = 0;
239 AliTRDSensorArray *gasO2Sensors = 0;
e87f8c2f 240 // AliTRDSensorArray *adcClkPhaseSensors = 0;
9bf458e3 241
e87f8c2f 242 if(getHVInfo) {
9bf458e3 243 // anode hv currents (per chamber)
5478d397 244 if((entry = GetCDBentry("TRD/Calib/trd_hvAnodeImon"))) anodeISensors = (AliTRDSensorArray*)entry->GetObject();
9bf458e3 245 // anode hv voltages (per chamber)
5478d397 246 if((entry = GetCDBentry("TRD/Calib/trd_hvAnodeUmon"))) anodeUSensors = (AliTRDSensorArray*)entry->GetObject();
9bf458e3 247 // drift hv currents (per chamber)
5478d397 248 if((entry = GetCDBentry("TRD/Calib/trd_hvDriftImon"))) driftISensors = (AliTRDSensorArray*)entry->GetObject();
9bf458e3 249 // drift hv voltages (per chamber)
5478d397 250 if((entry = GetCDBentry("TRD/Calib/trd_hvDriftUmon"))) driftUSensors = (AliTRDSensorArray*)entry->GetObject();
e87f8c2f 251 } // end if(getHVInfo)
252
253 if(getStatusInfo) {
9bf458e3 254 // chamber status (from sensors)
5478d397 255 if((entry = GetCDBentry("TRD/Calib/trd_chamberStatus"))) chamberStatusSensors = (AliTRDSensorArray*)entry->GetObject();
e87f8c2f 256 } // end if(getStatusInfo)
257
258 if(getGasInfo) {
259 // temperatures from chamber sensors (per chamber)
5478d397 260 if((entry = GetCDBentry("TRD/Calib/trd_envTemp"))) temperatureSensors = (AliTRDSensorArray*)entry->GetObject();
261
9bf458e3 262 // gas overpressure (per whole TRD)
5478d397 263 if((entry = GetCDBentry("TRD/Calib/trd_gasOverpressure"))) overpressureSensors = (AliTRDSensorArray*)entry->GetObject();
264
9bf458e3 265 // gas CO2 fraction (whole TRD)
5478d397 266 if((entry = GetCDBentry("TRD/Calib/trd_gasCO2"))) gasCO2Sensors = (AliTRDSensorArray*)entry->GetObject();
267
9bf458e3 268 // gas H2O fraction (whole TRD)
5478d397 269 if((entry = GetCDBentry("TRD/Calib/trd_gasH2O"))) gasH2OSensors = (AliTRDSensorArray*)entry->GetObject();
270
9bf458e3 271 // gas O2 fraction (whole TRD)
5478d397 272 if((entry = GetCDBentry("TRD/Calib/trd_gasO2"))) gasO2Sensors = (AliTRDSensorArray*)entry->GetObject();
273
9bf458e3 274 // ADC Clk phase (whole TRD)
5478d397 275 /*
9bf458e3 276 entry = manager->Get("TRD/Calib/trd_adcClkPhase");
277 if(entry) {
5478d397 278 entry->SetOwner(kTRUE);
279 adcClkPhaseSensors = (AliTRDSensorArray*)entry->GetObject();
9bf458e3 280 }
5478d397 281 */
e87f8c2f 282 } // end if getGasInfo
9bf458e3 283
284
285 // get calibration information
286 // process gains
287 AliTRDCalDet *chamberGainFactor = 0;
288 AliTRDCalPad *padGainFactor = 0;
289 Double_t runMeanGain=0.0, runRMSGain=0.0;
290 TVectorD chamberMeanGain(AliTRDcalibDB::kNdet);
291 TVectorD chamberRMSGain(AliTRDcalibDB::kNdet);
292 TVectorD smMeanGain(AliTRDcalibDB::kNsector);
293 TVectorD smRMSGain(AliTRDcalibDB::kNsector);
294 TString parName("Gain");
295 if(getCalibrationInfo) {
5478d397 296 if((entry = GetCDBentry("TRD/Calib/ChamberGainFactor", 0))) chamberGainFactor = (AliTRDCalDet*)entry->GetObject();
297
298 if((entry = GetCDBentry("TRD/Calib/LocalGainFactor", 0))) padGainFactor = (AliTRDCalPad*)entry->GetObject();
299
300 ProcessTRDCalibArray(chamberGainFactor, padGainFactor,
301 parName,
302 runMeanGain, runRMSGain,
303 chamberMeanGain, chamberRMSGain,
304 smMeanGain, smRMSGain);
9bf458e3 305 }
306
307 // process pedestals
308 AliTRDCalDet *chamberNoise = 0;
309 AliTRDCalPad *padNoise = 0;
310 Double_t runMeanNoise=0.0, runRMSNoise=0.0;
311 TVectorD chamberMeanNoise(AliTRDcalibDB::kNdet);
312 TVectorD chamberRMSNoise(AliTRDcalibDB::kNdet);
313 TVectorD smMeanNoise(AliTRDcalibDB::kNsector);
314 TVectorD smRMSNoise(AliTRDcalibDB::kNsector);
315 parName = "Noise";
316 if(getCalibrationInfo) {
5478d397 317 if((entry = GetCDBentry("TRD/Calib/DetNoise", 0))) chamberNoise = (AliTRDCalDet*)entry->GetObject();
318
319 if((entry = GetCDBentry("TRD/Calib/PadNoise", 0))) padNoise = (AliTRDCalPad*)entry->GetObject();
320
321 ProcessTRDCalibArray(chamberNoise, padNoise,
322 parName,
323 runMeanNoise, runRMSNoise,
324 chamberMeanNoise, chamberRMSNoise,
325 smMeanNoise, smRMSNoise);
9bf458e3 326 }
327
328 // process drift velocity
329 AliTRDCalDet *chamberVdrift = 0;
330 AliTRDCalPad *padVdrift = 0;
331 Double_t runMeanVdrift=0.0, runRMSVdrift=0.0;
332 TVectorD chamberMeanVdrift(AliTRDcalibDB::kNdet);
333 TVectorD chamberRMSVdrift(AliTRDcalibDB::kNdet);
334 TVectorD smMeanVdrift(AliTRDcalibDB::kNsector);
335 TVectorD smRMSVdrift(AliTRDcalibDB::kNsector);
336 parName = "Vdrift";
337 if(getCalibrationInfo) {
5478d397 338 if((entry = GetCDBentry("TRD/Calib/ChamberVdrift", 0))) chamberVdrift = (AliTRDCalDet*)entry->GetObject();
339
340 if((entry = GetCDBentry("TRD/Calib/LocalVdrift", 0))) padVdrift = (AliTRDCalPad*)entry->GetObject();
341
342 ProcessTRDCalibArray(chamberVdrift, padVdrift,
343 parName,
344 runMeanVdrift, runRMSVdrift,
345 chamberMeanVdrift, chamberRMSVdrift,
346 smMeanVdrift, smRMSVdrift);
9bf458e3 347 }
5478d397 348
9bf458e3 349 // process T0
350 AliTRDCalDet *chamberT0 = 0;
351 AliTRDCalPad *padT0 = 0;
352 Double_t runMeanT0=0.0, runRMST0=0.0;
353 TVectorD chamberMeanT0(AliTRDcalibDB::kNdet);
354 TVectorD chamberRMST0(AliTRDcalibDB::kNdet);
355 TVectorD smMeanT0(AliTRDcalibDB::kNsector);
356 TVectorD smRMST0(AliTRDcalibDB::kNsector);
357 parName = "T0";
358 if(getCalibrationInfo) {
5478d397 359 if((entry = GetCDBentry("TRD/Calib/ChamberT0", 0))) chamberT0 = (AliTRDCalDet*)entry->GetObject();
360
361 if((entry = GetCDBentry("TRD/Calib/LocalT0", 0))) padT0 = (AliTRDCalPad*)entry->GetObject();
362
363 ProcessTRDCalibArray(chamberT0, padT0,
364 parName,
365 runMeanT0, runRMST0,
366 chamberMeanT0, chamberRMST0,
367 smMeanT0, smRMST0);
368 }
9bf458e3 369
370 // process pad and chamber status
371 AliTRDCalChamberStatus* chamberStatus = 0;
372 AliTRDCalPadStatus *padStatus = 0;
373 Float_t runBadPadFraction=0.0;
374 TVectorD chamberBadPadFraction(AliTRDcalibDB::kNdet);
375 TVectorD chamberStatusValues(AliTRDcalibDB::kNdet);
376 if(getCalibrationInfo) {
5478d397 377 if((entry = GetCDBentry("TRD/Calib/ChamberStatus", 0))) chamberStatus = (AliTRDCalChamberStatus*)entry->GetObject();
378
379 if((entry = GetCDBentry("TRD/Calib/PadStatus", 0))) padStatus = (AliTRDCalPadStatus*)entry->GetObject();
380
381 ProcessTRDstatus(chamberStatus, padStatus,
382 runBadPadFraction, chamberBadPadFraction,
383 chamberStatusValues);
9bf458e3 384 }
385
386 // get Goofie information
387 AliTRDSensorArray *goofieGainSensors = 0x0;
388 AliTRDSensorArray *goofieHvSensors = 0x0;
389 AliTRDSensorArray *goofiePressureSensors = 0x0;
390 AliTRDSensorArray *goofieTempSensors = 0x0;
391 AliTRDSensorArray *goofieVelocitySensors = 0x0;
392 AliTRDSensorArray *goofieCO2Sensors = 0x0;
393 AliTRDSensorArray *goofieN2Sensors = 0x0;
394
395 if(getGoofieInfo) {
396 // goofie gain
5478d397 397 if((entry = GetCDBentry("TRD/Calib/trd_goofieGain"))) goofieGainSensors = (AliTRDSensorArray*)entry->GetObject();
398
9bf458e3 399 // goofie HV
5478d397 400 if((entry = GetCDBentry("TRD/Calib/trd_goofieHv"))) goofieHvSensors = (AliTRDSensorArray*)entry->GetObject();
401
9bf458e3 402 // goofie pressure
5478d397 403 if((entry = GetCDBentry("TRD/Calib/trd_goofiePressure"))) goofiePressureSensors = (AliTRDSensorArray*)entry->GetObject();
404
9bf458e3 405 // goofie temperature
5478d397 406 if((entry = GetCDBentry("TRD/Calib/trd_goofieTemp"))) goofieTempSensors = (AliTRDSensorArray*)entry->GetObject();
407
9bf458e3 408 // goofie drift velocity
5478d397 409 if((entry = GetCDBentry("TRD/Calib/trd_goofieVelocity"))) goofieVelocitySensors = (AliTRDSensorArray*)entry->GetObject();
410
9bf458e3 411 // goofie CO2
5478d397 412 if((entry = GetCDBentry("TRD/Calib/trd_goofieCO2"))) goofieCO2Sensors = (AliTRDSensorArray*)entry->GetObject();
413
9bf458e3 414 // goofie N2
5478d397 415 if((entry = GetCDBentry("TRD/Calib/trd_goofieN2"))) goofieN2Sensors = (AliTRDSensorArray*)entry->GetObject();
9bf458e3 416 } // end if getGoofieInfo
417
418 // process the DCS FEE arrays
5478d397 419 Int_t nSB1 = 0; Int_t nSB2 = 0; Int_t nSB3 = 0; Int_t nSB4 = 0; Int_t nSB5 = 0;
9bf458e3 420 Int_t nChanged = 0;
421 Bool_t sorAndEor = kFALSE;
422 TVectorD statusArraySOR(AliTRDcalibDB::kNdet);
423 TVectorD statusArrayEOR(AliTRDcalibDB::kNdet);
424 Int_t dcsFeeGlobalNTimeBins = -1;
425 Int_t dcsFeeGlobalConfigTag = -1;
426 Int_t dcsFeeGlobalSingleHitThres = -1;
427 Int_t dcsFeeGlobalThreePadClustThres = -1;
428 Int_t dcsFeeGlobalSelectiveNoSZ = -1;
429 Int_t dcsFeeGlobalTCFilterWeight = -1;
430 Int_t dcsFeeGlobalTCFilterShortDecPar = -1;
431 Int_t dcsFeeGlobalTCFilterLongDecPar = -1;
432 Int_t dcsFeeGlobalModeFastStatNoise = -1;
433 TObjString dcsFeeGlobalConfigVersion("");
434 TObjString dcsFeeGlobalConfigName("");
435 TObjString dcsFeeGlobalFilterType("");
436 TObjString dcsFeeGlobalReadoutParam("");
437 TObjString dcsFeeGlobalTestPattern("");
438 TObjString dcsFeeGlobalTrackletMode("");
439 TObjString dcsFeeGlobalTrackletDef("");
440 TObjString dcsFeeGlobalTriggerSetup("");
441 TObjString dcsFeeGlobalAddOptions("");
442 if(getDCSInfo) {
443 TObjArray *objArrayCDB = 0;
ef619721 444 TObject* calDCSsor = 0x0;
01de2c40 445 TObject* calDCSeor = 0x0;
5478d397 446 if((entry = GetCDBentry("TRD/Calib/DCS"))) objArrayCDB = (TObjArray*)entry->GetObject();
447 if(objArrayCDB) {
448 objArrayCDB->SetOwner(kTRUE);
ef619721 449 calDCSsor = objArrayCDB->At(0);
450 calDCSeor = objArrayCDB->At(1);
5478d397 451
452 ProcessTRDCalDCSFEE(calDCSsor, calDCSeor,
453 nSB1, nSB2, nSB3, nSB4, nSB5,
454 nChanged, sorAndEor, statusArraySOR, statusArrayEOR);
9bf458e3 455 }
9bf458e3 456 if(calDCSsor || calDCSeor) {
ef619721 457 TObject *caldcs = 0;
5478d397 458 if(calDCSsor) caldcs = calDCSsor;
459 else caldcs = calDCSeor;
ef619721 460 Int_t calVer = 0;
461 if (!strcmp(caldcs->ClassName(),"AliTRDCalDCS")) calVer = 1;
462 if (!strcmp(caldcs->ClassName(),"AliTRDCalDCSv2")) calVer = 2;
463 if (calVer == 1) {
464 dcsFeeGlobalNTimeBins = ((AliTRDCalDCS*)caldcs)->GetGlobalNumberOfTimeBins();
465 dcsFeeGlobalConfigTag = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigTag();
466 dcsFeeGlobalSingleHitThres = ((AliTRDCalDCS*)caldcs)->GetGlobalSingleHitThres();
467 dcsFeeGlobalThreePadClustThres = ((AliTRDCalDCS*)caldcs)->GetGlobalThreePadClustThres();
468 dcsFeeGlobalSelectiveNoSZ = ((AliTRDCalDCS*)caldcs)->GetGlobalSelectiveNoZS();
469 dcsFeeGlobalTCFilterWeight = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterWeight();
470 dcsFeeGlobalTCFilterShortDecPar = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterShortDecPar();
471 dcsFeeGlobalTCFilterLongDecPar = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterLongDecPar();
472 dcsFeeGlobalModeFastStatNoise = ((AliTRDCalDCS*)caldcs)->GetGlobalModeFastStatNoise();
473 dcsFeeGlobalConfigVersion = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigVersion().Data();
474 dcsFeeGlobalConfigName = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigName().Data();
475 dcsFeeGlobalFilterType = ((AliTRDCalDCS*)caldcs)->GetGlobalFilterType().Data();
476 dcsFeeGlobalReadoutParam = ((AliTRDCalDCS*)caldcs)->GetGlobalReadoutParam().Data();
477 dcsFeeGlobalTestPattern = ((AliTRDCalDCS*)caldcs)->GetGlobalTestPattern().Data();
478 dcsFeeGlobalTrackletMode = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletMode().Data();
01de2c40 479 dcsFeeGlobalTrackletDef = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletDef().Data();
ef619721 480 dcsFeeGlobalTriggerSetup = ((AliTRDCalDCS*)caldcs)->GetGlobalTriggerSetup().Data();
481 dcsFeeGlobalAddOptions = ((AliTRDCalDCS*)caldcs)->GetGlobalAddOptions().Data();
482 }
483 if (calVer == 2) {
484 dcsFeeGlobalNTimeBins = ((AliTRDCalDCSv2*)caldcs)->GetGlobalNumberOfTimeBins();
485 dcsFeeGlobalConfigTag = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigTag();
486 dcsFeeGlobalSingleHitThres = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSingleHitThres();
487 dcsFeeGlobalThreePadClustThres = ((AliTRDCalDCSv2*)caldcs)->GetGlobalThreePadClustThres();
488 dcsFeeGlobalSelectiveNoSZ = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSelectiveNoZS();
489 dcsFeeGlobalTCFilterWeight = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterWeight();
490 dcsFeeGlobalTCFilterShortDecPar = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterShortDecPar();
491 dcsFeeGlobalTCFilterLongDecPar = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterLongDecPar();
492 dcsFeeGlobalModeFastStatNoise = ((AliTRDCalDCSv2*)caldcs)->GetGlobalModeFastStatNoise();
493 dcsFeeGlobalConfigVersion = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigVersion().Data();
494 dcsFeeGlobalConfigName = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigName().Data();
495 dcsFeeGlobalFilterType = ((AliTRDCalDCSv2*)caldcs)->GetGlobalFilterType().Data();
496 dcsFeeGlobalReadoutParam = ((AliTRDCalDCSv2*)caldcs)->GetGlobalReadoutParam().Data();
497 dcsFeeGlobalTestPattern = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTestPattern().Data();
498 dcsFeeGlobalTrackletMode = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletMode().Data();
01de2c40 499 dcsFeeGlobalTrackletDef = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletDef().Data();
ef619721 500 dcsFeeGlobalTriggerSetup = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTriggerSetup().Data();
501 dcsFeeGlobalAddOptions = ((AliTRDCalDCSv2*)caldcs)->GetGlobalAddOptions().Data();
502 }
9bf458e3 503 }
504 if(objArrayCDB) objArrayCDB->RemoveAll();
505 } // end if(getDCSInfo)
5478d397 506
9bf458e3 507
508 // loop over time steps
e87f8c2f 509 for(UInt_t iTime = (getGRPInfo ? startTime : 0); iTime<=(getGRPInfo ? endTime : 0); iTime += (getGRPInfo ? dTime : 1)) {
9bf458e3 510 // time stamp
511 TTimeStamp iStamp(iTime);
5478d397 512 cout << "time step " << iStamp.GetDate()/10000 << "/"
513 << (iStamp.GetDate()/100)-(iStamp.GetDate()/10000)*100 << "/"
514 << iStamp.GetDate()%100 << " "
515 << iStamp.GetTime()/10000 << ":"
516 << (iStamp.GetTime()/100)-(iStamp.GetTime()/10000)*100 << ":"
517 << iStamp.GetTime()%100 << endl;
518
9bf458e3 519 // cavern pressure
520 Float_t pressure = -99.;
e87f8c2f 521 Bool_t inside=kFALSE;
5478d397 522 if(cavern_pressure) pressure = cavern_pressure->Eval(iStamp,inside);
523
9bf458e3 524 // surface pressure
525 Float_t surfacePressure = -99.;
5478d397 526 if(surface_pressure) surfacePressure = surface_pressure->Eval(iStamp,inside);
527
9bf458e3 528 // anode I sensors
529 TVectorD anodeIValues(AliTRDcalibDB::kNdet);
5478d397 530 if(anodeISensors) ProcessTRDSensorArray(anodeISensors, iStamp, anodeIValues);
531
9bf458e3 532 // anode U sensors
533 TVectorD anodeUValues(AliTRDcalibDB::kNdet);
5478d397 534 if(anodeUSensors) ProcessTRDSensorArray(anodeUSensors, iStamp, anodeUValues);
535
9bf458e3 536 // drift I sensors
537 TVectorD driftIValues(AliTRDcalibDB::kNdet);
5478d397 538 if(driftISensors) ProcessTRDSensorArray(driftISensors, iStamp, driftIValues);
539
9bf458e3 540 // drift U sensors
541 TVectorD driftUValues(AliTRDcalibDB::kNdet);
5478d397 542 if(driftUSensors) ProcessTRDSensorArray(driftUSensors, iStamp, driftUValues);
543
9bf458e3 544 // chamber temperatures
545 TVectorD envTempValues(AliTRDcalibDB::kNdet);
5478d397 546 if(temperatureSensors) ProcessTRDSensorArray(temperatureSensors, iStamp, envTempValues);
9bf458e3 547
548 // chamber status sensors
549 TVectorD statusValues(AliTRDcalibDB::kNdet);
5478d397 550 if(chamberStatusSensors) ProcessTRDSensorArray(chamberStatusSensors, iStamp, statusValues);
9bf458e3 551
552 // gas overpressure
553 TVectorD overpressureValues(overpressureSensors ? overpressureSensors->NumSensors() : 0);
5478d397 554 if(overpressureSensors) ProcessTRDSensorArray(overpressureSensors, iStamp, overpressureValues);
555
9bf458e3 556 // gas CO2
557 TVectorD gasCO2Values(gasCO2Sensors ? gasCO2Sensors->NumSensors() : 0);
5478d397 558 if(gasCO2Sensors) ProcessTRDSensorArray(gasCO2Sensors, iStamp, gasCO2Values);
559
9bf458e3 560 // gas H2O
561 TVectorD gasH2OValues(gasH2OSensors ? gasH2OSensors->NumSensors() : 0);
5478d397 562 if(gasH2OSensors) ProcessTRDSensorArray(gasH2OSensors, iStamp, gasH2OValues);
563
9bf458e3 564 // gas O2
565 TVectorD gasO2Values(gasO2Sensors ? gasO2Sensors->NumSensors() : 0);
5478d397 566 if(gasO2Sensors) ProcessTRDSensorArray(gasO2Sensors, iStamp, gasO2Values);
567
9bf458e3 568 // ADC Clk phase
569 //TVectorD adcClkPhaseValues(adcClkPhaseSensors ? adcClkPhaseSensors->NumSensors() : 0);
5478d397 570 //if(adcClkPhaseSensors) ProcessTRDSensorArray(adcClkPhaseSensors, iStamp, adcClkPhaseValues);
9bf458e3 571
572 // goofie gain
573 TVectorD goofieGainValues(goofieGainSensors ? goofieGainSensors->NumSensors() : 0);
5478d397 574 if(goofieGainSensors) ProcessTRDSensorArray(goofieGainSensors, iStamp, goofieGainValues);
9bf458e3 575
576 // goofie HV
577 TVectorD goofieHvValues(goofieHvSensors ? goofieHvSensors->NumSensors() : 0);
5478d397 578 if(goofieHvSensors) ProcessTRDSensorArray(goofieHvSensors, iStamp, goofieHvValues);
9bf458e3 579
580 // goofie pressure
581 TVectorD goofiePressureValues(goofiePressureSensors ? goofiePressureSensors->NumSensors() : 0);
5478d397 582 if(goofiePressureSensors) ProcessTRDSensorArray(goofiePressureSensors, iStamp, goofiePressureValues);
583
9bf458e3 584 // goofie temperature
585 TVectorD goofieTempValues(goofieTempSensors ? goofieTempSensors->NumSensors() : 0);
5478d397 586 if(goofieTempSensors) ProcessTRDSensorArray(goofieTempSensors, iStamp, goofieTempValues);
587
9bf458e3 588 // goofie drift velocity
589 TVectorD goofieVelocityValues(goofieVelocitySensors ? goofieVelocitySensors->NumSensors() : 0);
5478d397 590 if(goofieVelocitySensors) ProcessTRDSensorArray(goofieVelocitySensors, iStamp, goofieVelocityValues);
591
9bf458e3 592 // goofie CO2
593 TVectorD goofieCO2Values(goofieCO2Sensors ? goofieCO2Sensors->NumSensors() : 0);
5478d397 594 if(goofieCO2Sensors) ProcessTRDSensorArray(goofieCO2Sensors, iStamp, goofieCO2Values);
595
9bf458e3 596 // goofie N2
597 TVectorD goofieN2Values(goofieN2Sensors ? goofieN2Sensors->NumSensors() : 0);
5478d397 598 if(goofieN2Sensors) ProcessTRDSensorArray(goofieN2Sensors, iStamp, goofieN2Values);
599
9bf458e3 600 // fill the tree
601 (*treeStreamer)<< "trdTree"
5478d397 602 << "run=" << currRun
603 << "time=" << iTime
604 << "runType.=" << &runType;
e87f8c2f 605 if(getGRPInfo) {
5478d397 606 (*treeStreamer)<< "trdTree"
607 << "startTimeGRP=" << startTime
608 << "endTimeGRP=" << endTime
609 << "cavernPressure=" << pressure
610 << "surfacePressure=" << surfacePressure
611 << "detectorMask=" << detectorMask;
e87f8c2f 612 }
613 if(getHVInfo) {
5478d397 614 (*treeStreamer)<< "trdTree"
615 << "hvAnodeI.=" << &anodeIValues
616 << "hvAnodeU.=" << &anodeUValues
617 << "hvDriftI.=" << &driftIValues
618 << "hvDriftU.=" << &driftUValues;
e87f8c2f 619 }
620 if(getStatusInfo) {
5478d397 621 (*treeStreamer)<< "trdTree"
622 << "sensorStatusValues.=" << &statusValues;
e87f8c2f 623 }
624 if(getGasInfo) {
5478d397 625 (*treeStreamer)<< "trdTree"
626 << "envTemp.=" << &envTempValues
627 << "gasOverPressure.=" << &overpressureValues
628 << "gasCO2.=" << &gasCO2Values
629 << "gasH2O.=" << &gasH2OValues
630 << "gasO2.=" << &gasO2Values;
631 //<< "adcClkPhase.=" << &adcClkPhaseValues;
9bf458e3 632 }
633 if(getGoofieInfo) {
5478d397 634 (*treeStreamer)<< "trdTree"
635 << "goofieGain.=" << &goofieGainValues
636 << "goofieHV.=" << &goofieHvValues
637 << "goofiePressure.=" << &goofiePressureValues
638 << "goofieTemp.=" << &goofieTempValues
639 << "goofieVelocity.=" << &goofieVelocityValues
640 << "goofieCO2.=" << &goofieCO2Values
641 << "goofieN2.=" << &goofieN2Values;
9bf458e3 642 }
643 if(getCalibrationInfo) {
5478d397 644 (*treeStreamer)<< "trdTree"
645 << "runMeanGain=" << runMeanGain
646 << "runRMSGain=" << runRMSGain
647 << "smMeanGain.=" << &smMeanGain
648 << "smRMSGain.=" << &smRMSGain
649 << "chamberMeanGain.=" << &chamberMeanGain
650 << "chamberRMSGain.=" << &chamberRMSGain
651 << "runMeanNoise=" << runMeanNoise
652 << "runRMSNoise=" << runRMSNoise
653 << "smMeanNoise.=" << &smMeanNoise
654 << "smRMSNoise.=" << &smRMSNoise
655 << "chamberMeanNoise.=" << &chamberMeanNoise
656 << "chamberRMSNoise.=" << &chamberRMSNoise
657 << "runMeanVdrift=" << runMeanVdrift
658 << "runRMSVdrift=" << runRMSVdrift
659 << "smMeanVdrift.=" << &smMeanVdrift
660 << "smRMSVdrift.=" << &smRMSVdrift
661 << "chamberMeanVdrift.=" << &chamberMeanVdrift
662 << "chamberRMSVdrift.=" << &chamberRMSVdrift
663 << "runMeanT0=" << runMeanT0
664 << "runRMST0=" << runRMST0
665 << "smMeanT0.=" << &smMeanT0
666 << "smRMST0.=" << &smRMST0
667 << "chamberMeanT0.=" << &chamberMeanT0
668 << "chamberRMST0.=" << &chamberRMST0
669 << "runBadPadFraction=" << runBadPadFraction
670 << "chamberBadPadFraction.=" << &chamberBadPadFraction
671 << "chamberStatusValues.=" << &chamberStatusValues;
9bf458e3 672 }
673 if(getDCSInfo) {
5478d397 674 (*treeStreamer)<< "trdTree"
675 << "dcsFeeGlobalNTimeBins=" << dcsFeeGlobalNTimeBins
676 << "dcsFeeGlobalConfigTag=" << dcsFeeGlobalConfigTag
677 << "dcsFeeGlobalSingleHitThres=" << dcsFeeGlobalSingleHitThres
678 << "dcsFeeGlobalThreePadClustThres=" << dcsFeeGlobalThreePadClustThres
679 << "dcsFeeGlobalSelectiveNoSZ=" << dcsFeeGlobalSelectiveNoSZ
680 << "dcsFeeGlobalTCFilterWeight=" << dcsFeeGlobalTCFilterWeight
681 << "dcsFeeGlobalTCFilterShortDecPar=" << dcsFeeGlobalTCFilterShortDecPar
682 << "dcsFeeGlobalTCFilterLongDecPar=" << dcsFeeGlobalTCFilterLongDecPar
683 << "dcsFeeGlobalModeFastStatNoise=" << dcsFeeGlobalModeFastStatNoise
684 // << "dcsFeeGlobalConfigVersion.=" << &dcsFeeGlobalConfigVersion
685 // << "dcsFeeGlobalConfigName.=" << &dcsFeeGlobalConfigName
686 // << "dcsFeeGlobalFilterType.=" << &dcsFeeGlobalFilterType
687 // << "dcsFeeGlobalReadoutParam.=" << &dcsFeeGlobalReadoutParam
688 // << "dcsFeeGlobalTestPattern.=" << &dcsFeeGlobalTestPattern
689 // << "dcsFeeGlobalTrackletMode.=" << &dcsFeeGlobalTrackletMode
690 // << "dcsFeeGlobalTrackletDef.=" << &dcsFeeGlobalTrackletDef
691 // << "dcsFeeGlobalTriggerSetup.=" << &dcsFeeGlobalTriggerSetup
692 // << "dcsFeeGlobalAddOptions.=" << &dcsFeeGlobalAddOptions
693 << "statusDCSFEESOR.=" << &statusArraySOR
694 << "statusDCSFEEEOR.=" << &statusArrayEOR
695 << "SORandEOR=" << sorAndEor
696 << "nChanged=" << nChanged
697 << "nSB1=" << nSB1
698 << "nSB2=" << nSB2
699 << "nSB3=" << nSB3
700 << "nSB4=" << nSB4
701 << "nSB5=" << nSB5;
9bf458e3 702 }
703 (*treeStreamer)<< "trdTree"
5478d397 704 << "\n";
9bf458e3 705 } // end loop over time steps
706
707 // add the run number to the list of runs
708 runs.ResizeTo(runs.GetNoElements()+1);
709 runs[runs.GetNoElements()-1] = currRun;
710
711 // do some cleaning
712 if(grpObject) delete grpObject;
713 if(anodeISensors) anodeISensors->Clear();
714 if(anodeUSensors) anodeUSensors->Clear();
715 if(driftISensors) driftISensors->Clear();
716 if(driftUSensors) driftUSensors->Clear();
717 if(temperatureSensors) temperatureSensors->Clear();
718 if(overpressureSensors) overpressureSensors->Clear();
719 if(gasCO2Sensors) gasCO2Sensors->Clear();
720 if(gasH2OSensors) gasH2OSensors->Clear();
721 if(gasO2Sensors) gasO2Sensors->Clear();
722 //if(adcClkPhaseSensors) adcClkPhaseSensors->Clear();
723 if(goofieGainSensors) goofieGainSensors->Clear();
724 if(goofieHvSensors) goofieHvSensors->Clear();
725 if(goofiePressureSensors) goofiePressureSensors->Clear();
726 if(goofieTempSensors) goofieTempSensors->Clear();
727 if(goofieVelocitySensors) goofieVelocitySensors->Clear();
728 if(goofieCO2Sensors) goofieCO2Sensors->Clear();
729 if(goofieN2Sensors) goofieN2Sensors->Clear();
730 if(chamberGainFactor) delete chamberGainFactor;
731 if(padGainFactor) delete padGainFactor;
732 if(chamberNoise) delete chamberNoise;
733 if(padNoise) delete padNoise;
734 if(chamberVdrift) delete chamberVdrift;
735 if(padVdrift) delete padVdrift;
736 if(chamberT0) delete chamberT0;
737 if(padT0) delete padT0;
738 if(chamberStatus) delete chamberStatus;
739 if(padStatus) delete padStatus;
740 } // end while (loop over runs)
741 TTimeStamp loopEndTime;
742
743 treeStreamer->GetFile()->cd();
744 runs.Write("runs");
745 delete treeStreamer;
746
747 // output some job informations
748 TTimeStamp jobEndTime;
749 cout << "=============================================" << endl;
750 cout << "Job launched at : " << jobStartTime.AsString() << endl;
751 cout << "Loop over runs started at: " << loopStartTime.AsString() << endl;
752 cout << "Loop over runs ended at : " << loopEndTime.AsString() << endl;
753 cout << "Job ended at : " << jobEndTime.AsString() << endl;
5478d397 754 cout << "Initialization duration : "
755 << loopStartTime.GetSec() - jobStartTime.GetSec() << " seconds" << endl;
756 cout << "Loop over runs duration : "
757 << loopEndTime.GetSec() - loopStartTime.GetSec() << " seconds" << endl;
9bf458e3 758 cout << "Post loop : "
5478d397 759 << jobEndTime.GetSec() - loopEndTime.GetSec() << " seconds" << endl;
9bf458e3 760 cout << "Running time per processed run: "
5478d397 761 << (loopEndTime.GetSec()-loopStartTime.GetSec())/(runs.GetNoElements()>0 ? Double_t(runs.GetNoElements()) : 1.0)
762 << " sec./run" << endl;
9bf458e3 763 cout << "Running time per input run: "
5478d397 764 << (loopEndTime.GetSec()-loopStartTime.GetSec())/((rejectedRuns.GetNoElements()+runs.GetNoElements())>0 ? Double_t(runs.GetNoElements()+rejectedRuns.GetNoElements()) : 1.0)
765 << " sec./run" << endl;
9bf458e3 766
767 // print the runs that had problems
768 cout << "number of rejected runs: " << rejectedRuns.GetNoElements() << endl;
769 cout << "rejected run numbers" << endl;
770 cout << "********************" << endl;
771 for(Int_t iRun=0; iRun<rejectedRuns.GetNoElements(); iRun++) {
772 cout << rejectedRuns[iRun] << " ";
773 if(iRun%10==0) cout << endl;
774 }
775 cout << "=============================================" << endl;
776 return;
5478d397 777 }
9bf458e3 778
5478d397 779 //__________________________________________________________________________________________
780 void ProcessTRDSensorArray(AliTRDSensorArray *sensorArray, TTimeStamp timeStamp, TVectorD &values) {
9bf458e3 781 // Fill a vector with sensor values for a given time stamp
782 // The sensor->Eval() method makes interpolation inside the covered time interval
783 // and returns the value at the closest time limit (start or end) outside the covered time range
784 AliDCSSensor *sensor;
e87f8c2f 785 Bool_t inside=kFALSE;
9bf458e3 786 for(Int_t i=0; i<sensorArray->NumSensors(); i++) {
787 sensor = sensorArray->GetSensorNum(i);
5478d397 788 if(sensor && sensor->GetGraph())
e87f8c2f 789 values[i] = sensor->Eval(timeStamp,inside);
9bf458e3 790 else
791 values[i] = -99.;
792 }
793 return;
5478d397 794 }
795
796 //__________________________________________________________________________________________
797 void ProcessTRDCalibArray(AliTRDCalDet* chamberCalib, AliTRDCalPad *padCalib,
798 TString parName,
799 Double_t &runValue, Double_t &runRMS,
800 TVectorD &chamberValues, TVectorD &chamberValuesRMS,
801 TVectorD &superModuleValues, TVectorD &superModuleValuesRMS) {
9bf458e3 802 // Process the calibrations for a given run.
803 // Calculates the run and chamber wise averages
804 //
805
806 // check if the calibration parameter is multiplicative or additive
807 Bool_t multiplicative = kTRUE;
808 if(!parName.CompareTo("T0")) multiplicative = kFALSE;
809
810 // first iteration (calculate all averages and RMS without discrimination on the SM average)
811 gRunWiseHisto->Reset();
812 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
813 // reset the super module histogram
814 gSuperModuleWiseHisto->Reset();
815 // check if SM is installed
816 if(!gkSuperModuleStatus[iSM]) continue;
5478d397 817 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
818 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
819 iChamber++) { // loop over chambers in this supermodule
9bf458e3 820 // get the chamber value
821 Float_t chamberValue = chamberCalib->GetValue(iChamber);
822 // get the ROC object
823 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
5478d397 824 if(!chamberROC)
825 continue;
9bf458e3 826 gChamberWiseHisto->Reset();
827 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels
5478d397 828 // calculate the calibration parameter for this pad
829 Float_t padValue;
830 if(multiplicative)
831 padValue = chamberValue * chamberROC->GetValue(iChannel);
832 else
833 padValue = chamberValue + chamberROC->GetValue(iChannel);
834 // fill the run, SM and chamber wise histograms
835 gChamberWiseHisto->Fill(padValue);
836 // if the parameter is Noise then check if the pad value is not a default one
837 // Default value is now 1.2!!!! Check with Raphaelle for more informations
838 if(parName.Contains("Noise") &&
839 TMath::Abs(padValue-1.2)<0.00001) continue;
840 gSuperModuleWiseHisto->Fill(padValue);
841 gRunWiseHisto->Fill(padValue);
9bf458e3 842 } // end loop over channels
843 // get the chamber wise mean and RMS
844 chamberValues[iChamber] = gChamberWiseHisto->GetMean();
845 chamberValuesRMS[iChamber] = gChamberWiseHisto->GetRMS();
846 } // end loop over chambers
847 // SM wise mean and RMS
848 superModuleValues[iSM] = gSuperModuleWiseHisto->GetMean();
849 superModuleValuesRMS[iSM] = gSuperModuleWiseHisto->GetRMS();
850 } // end loop over supermodules
851 // run wise mean and RMS
852 runValue = gRunWiseHisto->GetMean();
853 runRMS = gRunWiseHisto->GetRMS();
854
855 // Noise and Gain are finished processing
856 if(parName.Contains("Noise") || parName.Contains("Gain"))
857 return;
858 // second iteration (calculate SM and run wise averages and RMS for Vdrift and T0)
859 // The pads with calib parameter equal to the SM average are discarded (default value)
860 gRunWiseHisto->Reset();
861 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
862 gSuperModuleWiseHisto->Reset();
863 // eliminate the uninstalled super modules
864 if(!gkSuperModuleStatus[iSM]) continue;
5478d397 865 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
866 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
867 iChamber++) { // loop over chambers
9bf458e3 868 // the chamber value
869 Float_t chamberValue = chamberCalib->GetValue(iChamber);
870 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
5478d397 871 if(!chamberROC)
872 continue;
873
9bf458e3 874 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels in a chamber
5478d397 875 // get the pad value
876 Float_t padValue;
877 if(multiplicative)
878 padValue = chamberValue * chamberROC->GetValue(iChannel);
879 else
880 padValue = chamberValue + chamberROC->GetValue(iChannel);
881 // eliminate from the average and RMS calculation all pads which
882 // have the calib parameter equal with the SM average
883 if((parName.Contains("Vdrift") || parName.Contains("T0")) &&
884 TMath::Abs(padValue-superModuleValues[iSM])<0.00001) continue;
885 gSuperModuleWiseHisto->Fill(padValue);
886 gRunWiseHisto->Fill(padValue);
9bf458e3 887 } // end loop over channels
5478d397 888 } // end loop over chambers
9bf458e3 889 superModuleValues[iSM] = gSuperModuleWiseHisto->GetMean();
890 superModuleValuesRMS[iSM] = gSuperModuleWiseHisto->GetRMS();
891 } // end loop over super modules
892 runValue = gRunWiseHisto->GetMean();
893 runRMS = gRunWiseHisto->GetRMS();
894 return;
5478d397 895 }
9bf458e3 896
5478d397 897 //__________________________________________________________________________________________
898 void ProcessTRDstatus(AliTRDCalChamberStatus* chamberStatus, AliTRDCalPadStatus* padStatus,
899 Float_t &runBadPadFraction, TVectorD &chamberBadPadFraction,
900 TVectorD &chamberStatusValues) {
9bf458e3 901 // Process the pad status. Calculates the fraction of pads with non 0 status
902 // run and chamber wise
903 //
904 Int_t runPadStatusNot0 = 0;
905 Int_t runPadStatusAll = 0;
906
907 Int_t superModuleStatus[18] = {1, 1, 0, 0, 0, 0, 0, 1, 1,
5478d397 908 1, 1, 0, 0, 0, 0, 0, 0, 1};
9bf458e3 909
910 // loop over chambers
911 for(Int_t iChamber=0; iChamber < AliTRDcalibDB::kNdet; iChamber++) {
912 // check if the chamber is in an installed sector;
913 Int_t sm = AliTRDgeometry::GetSector(iChamber);
914 if(!superModuleStatus[sm]) continue;
915
916 chamberStatusValues[iChamber] = chamberStatus->GetStatus(iChamber);
917 AliTRDCalSingleChamberStatus *singleChamberStatus = padStatus->GetCalROC(iChamber);
918 if(!singleChamberStatus)
919 continue;
920 Int_t chamberPadStatusNot0 = 0;
921 Int_t chamberPadStatusAll = 0;
922 // loop over channels in a chamber
923 for(Int_t iChannel = 0; iChannel < singleChamberStatus->GetNchannels(); iChannel++) {
924 if(singleChamberStatus->GetStatus(iChannel) > 0) {
5478d397 925 chamberPadStatusNot0++;
926 runPadStatusNot0++;
9bf458e3 927 }
928 chamberPadStatusAll++;
929 runPadStatusAll++;
930 }
5478d397 931 chamberBadPadFraction[iChamber] = (chamberPadStatusAll>0 ?
932 Float_t(chamberPadStatusNot0)/Float_t(chamberPadStatusAll) : -99.);
9bf458e3 933 }
934 runBadPadFraction = (runPadStatusAll>0 ? Float_t(runPadStatusNot0)/Float_t(runPadStatusAll) : -99.);
935 return;
5478d397 936 }
9bf458e3 937
5478d397 938 //__________________________________________________________________________________________
ef619721 939 void ProcessTRDCalDCSFEE(TObject *caldcsSOR, TObject *caldcsEOR,
5478d397 940 Int_t &nsb1, Int_t &nsb2, Int_t &nsb3, Int_t &nsb4, Int_t &nsb5,
941 Int_t &nChanged, Bool_t &sorAndEor,
942 TVectorD &statusArraySOR, TVectorD &statusArrayEOR) {
9bf458e3 943 //
944 // Process the DCS information
945 //
946 sorAndEor = kTRUE;
947 if(!caldcsSOR && !caldcsEOR) {
948 sorAndEor = kFALSE;
949 return;
950 }
951 else if(caldcsSOR && !caldcsEOR) {
952 sorAndEor = kFALSE;
953 }
954 else if(!caldcsSOR && caldcsEOR) {
955 caldcsSOR = caldcsEOR;
956 sorAndEor = kFALSE;
957 }
958
ef619721 959 Int_t calVer = 0;
960 if (!strcmp(caldcsSOR->ClassName(),"AliTRDCalDCS")) calVer = 1;
961 if (!strcmp(caldcsSOR->ClassName(),"AliTRDCalDCSv2")) calVer = 2;
962 Int_t feeArrSiz = 0;
963 if (calVer == 1) feeArrSiz = ((AliTRDCalDCS*)caldcsSOR)->GetFEEArr()->GetSize();
964 if (calVer == 2) feeArrSiz = ((AliTRDCalDCSv2*)caldcsSOR)->GetFEEArr()->GetSize();
965
9bf458e3 966 nsb1 = 0; nsb2 = 0; nsb3 = 0; nsb4 = 0; nsb5 = 0; nChanged = 0;
ef619721 967 for(Int_t iROC=0; iROC<AliTRDcalibDB::kNdet && iROC<feeArrSiz; iROC++) {
968 TObject* dcsSorFee;
969 TObject* dcsEorFee;
970 if (calVer == 1) {
971 dcsSorFee = ((AliTRDCalDCS*)caldcsSOR)->GetCalDCSFEEObj(iROC);
972 dcsEorFee = ((AliTRDCalDCS*)caldcsEOR)->GetCalDCSFEEObj(iROC);
973 } else if (calVer == 2) {
974 dcsSorFee = ((AliTRDCalDCSv2*)caldcsSOR)->GetCalDCSFEEObj(iROC);
975 dcsEorFee = ((AliTRDCalDCSv2*)caldcsEOR)->GetCalDCSFEEObj(iROC);
976 } else continue;
977
9bf458e3 978 if(dcsSorFee) {
ef619721 979 if (calVer == 1) statusArraySOR[iROC] = ((AliTRDCalDCSFEE*)dcsSorFee)->GetStatusBit();
980 if (calVer == 2) statusArraySOR[iROC] = ((AliTRDCalDCSFEEv2*)dcsSorFee)->GetStatusBit();
9bf458e3 981 if(statusArraySOR[iROC] == 1) nsb1++;
982 if(statusArraySOR[iROC] == 2) nsb2++;
983 if(statusArraySOR[iROC] == 3) nsb3++;
984 if(statusArraySOR[iROC] == 4) nsb4++;
985 if(statusArraySOR[iROC] == 5) nsb5++;
986 }
987 if(dcsEorFee) {
ef619721 988 if (calVer == 1) statusArrayEOR[iROC] = ((AliTRDCalDCSFEE*)dcsEorFee)->GetStatusBit();
989 if (calVer == 2) statusArrayEOR[iROC] = ((AliTRDCalDCSFEEv2*)dcsEorFee)->GetStatusBit();
9bf458e3 990 }
991 if(sorAndEor) {
992 if((statusArraySOR[iROC]-statusArrayEOR[iROC]) != 0) nChanged++;
5478d397 993 }
9bf458e3 994 }
995 return;
5478d397 996 }
9bf458e3 997
5478d397 998 //__________________________________________________________________________________________
999 void MakeRunListFromOCDB(const Char_t* directory, const Char_t* outfile, Bool_t fromAlien) {
9bf458e3 1000 //
1001 // For a given OCDB path dump the list of available run numbers
1002 //
1003 if(fromAlien)
1004 gSystem->Exec(Form("alien_ls %s > temp.txt", directory));
1005 else
1006 gSystem->Exec(Form("ls %s > temp.txt", directory));
1007
1008 ifstream inBuffer("temp.txt");
1009 if(!inBuffer.is_open()) {
1010 cout << "File temp.txt not opened! Exiting" << endl;
1011 return;
1012 }
1013 ofstream outBuffer(outfile);
1014 if(!outBuffer.is_open()) {
1015 cout << "File runList.txt cannot be opened! Exiting" << endl;
1016 return;
1017 }
1018
1019 while(!inBuffer.eof()) {
1020 char inputLine[128];
1021 inBuffer.getline(inputLine, 128, '\n');
1022 int runLow, runHigh;
1023 const char* tempLine = inputLine;
1024 sscanf(tempLine, "Run%d_%d_v1_s0.root", &runLow, &runHigh);
1025 outBuffer << runLow << endl;
1026 }
1027
1028 inBuffer.close();
1029 outBuffer.close();
1030 gSystem->Exec("rm temp.txt");
1031 return;
5478d397 1032 }
1033
1034 //__________________________________________________________________________________________
1035 AliCDBEntry* GetCDBentry(const Char_t *path, Bool_t owner)
1036 {
01de2c40 1037 TString spath = path;
1038 ::Info("GetCDBentry", Form("QUERY RUN [%d] for \"%s\".", currRun, spath.Data()));
5478d397 1039 AliCDBEntry *entry(NULL);
01de2c40 1040 storage->QueryCDB(currRun, spath.Data());
5478d397 1041 if(!storage->GetQueryCDBList()->GetEntries()){
01de2c40 1042 ::Error("GetCDBentry", Form("Missing \"%s\" in run %d.", spath.Data(), currRun));
5478d397 1043 return NULL;
01de2c40 1044 } else entry = manager->Get(spath.Data());
5478d397 1045 if(!entry) return NULL;
1046
1047 entry->SetOwner(owner);
1048 ::Info("GetCDBentry", Form("FOUND ENTRY @ [%p].", (void*)entry));
1049 return entry;
ef619721 1050 }