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