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
9 //DumpOCDBtoTree(const Char_t* runListFilename, const Char_t* outFilename,
10 // Int_t firstRun = -1, Int_t lastRun = -1,
11 // Bool_t getMonitoringInfo = kTRUE,
12 // Bool_t getCalibrationInfo = kTRUE,
13 // Bool_t getGoofieInfo = kTRUE,
14 // Bool_t getDCSInfo = kFALSE,
15 // const Char_t* storage = "local:///lustre/alice/alien/alice/data/2010/OCDB/")
17 // * runListFilename - name of an ascii file containing run numbers
18 // * outFilename - name of the root file where the TRD OCDB information tree to be stored
19 // * firstRun, lastRun - lowest and highest run numbers (from the ascii file) to be dumped
20 // if these numbers are not specified (-1) all run numbers in the input ascii file will
21 // be used. If the run list file is not specified then all runs in this interval
23 // * getMonitoringInfo - flag to switch on/off monitoring information (HV, temperatures, gas pressure,
24 // gas composition, ADC clock phase, chamber status)
25 // * getCalibrationInfo- flag to switch on/off calibration information (gain, pedestal, T0, vdrift, pad status)
26 // * getGoofieInfo - flag to switch on/off goofie information (gain, HV, pressure, temperature, drift velocity,
28 // * getDCSInfo - flag to switch on/off DCS information ()
29 // * storage - path of the OCDB database (if it is on alien, be sure to have a valid/active token)
37 #include "TTreeStream.h"
38 #include "TObjString.h"
39 #include "TTimeStamp.h"
42 #include "TObjArray.h"
46 #include "AliCDBManager.h"
47 #include "AliCDBEntry.h"
48 #include "AliTRDcalibDB.h"
49 #include "AliGRPObject.h"
50 #include "AliDCSSensor.h"
51 #include "AliTRDSensorArray.h"
52 #include "AliTRDCalDet.h"
53 #include "AliTRDCalPad.h"
54 #include "AliTRDCalROC.h"
55 #include "AliTRDCalPadStatus.h"
56 #include "AliTRDCalChamberStatus.h"
57 #include "AliTRDCalSingleChamberStatus.h"
58 #include "AliTRDCalDCS.h"
59 #include "AliTRDCalDCSFEE.h"
63 // histograms used for extracting the mean and RMS of calibration parameters
65 TH1F *gSuperModuleWiseHisto;
66 TH1F *gChamberWiseHisto;
69 const Int_t gkSuperModuleStatus[18] = {1, 1, 0, 0, 0, 0, 0, 1, 1, // (1-installed)
70 1, 1, 0, 0, 0, 0, 0, 0, 1};
72 void MakeRunListFromOCDB(const Char_t* directory, const Char_t* outfile, Bool_t fromAlien=kFALSE);
73 void ProcessTRDSensorArray(AliTRDSensorArray*, TTimeStamp, TVectorD&);
74 void ProcessTRDCalibArray(AliTRDCalDet*, AliTRDCalPad*, TString, Double_t&, Double_t&,
75 TVectorD&, TVectorD&, TVectorD&, TVectorD&);
76 void ProcessTRDstatus(AliTRDCalChamberStatus*, AliTRDCalPadStatus*, Float_t&, TVectorD&, TVectorD&);
77 void ProcessTRDCalDCSFEE(AliTRDCalDCS*, AliTRDCalDCS*, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Bool_t&,
78 TVectorD&, TVectorD&);
80 //__________________________________________________________________________________________
81 void DumpOCDBtoTree(const Char_t* runListFilename,
82 const Char_t* outFilename,
83 Int_t firstRun = -1, Int_t lastRun = -1,
84 Bool_t getMonitoringInfo = kTRUE,
85 Bool_t getCalibrationInfo = kTRUE,
86 Bool_t getGoofieInfo = kTRUE,
87 Bool_t getDCSInfo = kFALSE,
88 const Char_t* storage = "alien://folder=/alice/data/2010/OCDB/") {
90 // Main function to steer the extraction of TRD OCDB information
94 TTimeStamp jobStartTime;
95 // if the storage is on alien than we need to do some extra stuff
96 TString storageString(storage);
97 if(storageString.Contains("alien://")) {
98 TGrid::Connect("alien://");
100 // initialize the OCDB manager
101 AliCDBManager *manager = AliCDBManager::Instance();
102 manager->SetDefaultStorage(storage);
104 // initialize the tree
105 TTreeSRedirector *treeStreamer = new TTreeSRedirector(outFilename);
107 // initialize the histograms used for extracting the mean and RMS
108 gRunWiseHisto = new TH1F("runHisto", "runHisto", 200, -10.0, 10.0);
109 gSuperModuleWiseHisto = new TH1F("smHisto", "smHisto", 200, -10.0, 10.0);
110 gChamberWiseHisto = new TH1F("chamberHisto", "chamberHisto", 200, -10.0, 10.0);
112 // open the ascii file with run numbers
114 if(runListFilename[0]!='\0')
115 in.open(runListFilename);
117 // if a run list file was not specified then use the run range
119 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1)
120 currRun = firstRun-1;
123 TVectorD rejectedRuns;
124 TTimeStamp loopStartTime;
128 // check if we still have run numbers in the file or provided range
129 if(runListFilename[0]=='\0' && firstRun!=-1 && lastRun!=-1) {
131 if(currRun>lastRun) break;
133 if(runListFilename[0]!='\0') {
135 if(!(in>>currRun)) continue;
136 if(currRun < (firstRun==-1 ? 0 : firstRun) ||
137 currRun > (lastRun==-1 ? 999999999 : lastRun))
141 cout << "run = " << currRun << endl;
142 // check if the run was processed already
143 Bool_t runProcessed = kFALSE;
144 for(Int_t iRun=0; iRun<runs.GetNoElements(); iRun++) {
145 if(runs[iRun]==currRun) runProcessed = kTRUE;
148 cout << "Run processed already" << endl;
152 manager->SetRun(currRun);
154 // Get the GRP data. Only runs with a corresponding GRP entry in the OCDB
155 // will be processed.
156 time_t startTime = 0;
158 TObjString runType("UNKNOWN");
159 AliDCSSensor *cavern_pressure;
160 AliDCSSensor *surface_pressure;
161 UInt_t detectorMask = 0;
162 AliCDBEntry *entry = manager->Get("GRP/GRP/Data");
164 entry->SetOwner(kFALSE);
166 AliGRPObject* grpObject = 0;
168 grpObject = dynamic_cast<AliGRPObject*>(entry->GetObject());
170 // add the run number to the list of rejected runs
171 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
172 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
176 startTime = grpObject->GetTimeStart();
177 endTime = grpObject->GetTimeEnd();
178 runType = grpObject->GetRunType().Data();
179 cavern_pressure = grpObject->GetCavernAtmosPressure();
180 surface_pressure = grpObject->GetSurfaceAtmosPressure();
181 detectorMask = grpObject->GetDetectorMask();
182 TTimeStamp start(grpObject->GetTimeStart());
183 TTimeStamp end(grpObject->GetTimeEnd());
184 cout << "Start time: " << start.GetDate()/10000 << "/"
185 << (start.GetDate()/100)-(start.GetDate()/10000)*100 << "/"
186 << start.GetDate()%100 << " "
187 << start.GetTime()/10000 << ":"
188 << (start.GetTime()/100)-(start.GetTime()/10000)*100 << ":"
189 << start.GetTime()%100 << endl;
190 cout << "End time: " << end.GetDate()/10000 << "/"
191 << (end.GetDate()/100)-(end.GetDate()/10000)*100 << "/"
192 << end.GetDate()%100 << " "
193 << end.GetTime()/10000 << ":"
194 << (end.GetTime()/100)-(end.GetTime()/10000)*100 << ":"
195 << end.GetTime()%100 << endl;
196 cout << "Run type = " << grpObject->GetRunType().Data() << endl;
199 // add the run number to the list of rejected runs
200 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
201 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
205 // remove runs with zero time duration
206 if(startTime==endTime) {
207 if(grpObject) delete grpObject;
208 // add the run number to the list of rejected runs
209 rejectedRuns.ResizeTo(rejectedRuns.GetNoElements()+1);
210 rejectedRuns[rejectedRuns.GetNoElements()-1] = currRun;
214 // time step for time dependent information (change this if you need something else)
215 UInt_t dTime = TMath::Max((endTime-startTime)/20, Long_t(5*60));
217 // get monitoring information
218 AliTRDSensorArray *anodeISensors = 0;
219 AliTRDSensorArray *anodeUSensors = 0;
220 AliTRDSensorArray *driftISensors = 0;
221 AliTRDSensorArray *driftUSensors = 0;
222 AliTRDSensorArray *temperatureSensors = 0;
223 AliTRDSensorArray *chamberStatusSensors = 0;
224 AliTRDSensorArray *overpressureSensors = 0;
225 AliTRDSensorArray *gasCO2Sensors = 0;
226 AliTRDSensorArray *gasH2OSensors = 0;
227 AliTRDSensorArray *gasO2Sensors = 0;
228 // AliTRDSensorArray *adcClkPhaseSensors = 0;
230 if(getMonitoringInfo) {
231 // anode hv currents (per chamber)
232 entry = manager->Get("TRD/Calib/trd_hvAnodeImon");
234 entry->SetOwner(kTRUE);
235 anodeISensors = (AliTRDSensorArray*)entry->GetObject();
238 // anode hv voltages (per chamber)
239 entry = manager->Get("TRD/Calib/trd_hvAnodeUmon");
241 entry->SetOwner(kTRUE);
242 anodeUSensors = (AliTRDSensorArray*)entry->GetObject();
245 // drift hv currents (per chamber)
246 entry = manager->Get("TRD/Calib/trd_hvDriftImon");
248 entry->SetOwner(kTRUE);
249 driftISensors = (AliTRDSensorArray*)entry->GetObject();
252 // drift hv voltages (per chamber)
253 entry = manager->Get("TRD/Calib/trd_hvDriftUmon");
255 entry->SetOwner(kTRUE);
256 driftUSensors = (AliTRDSensorArray*)entry->GetObject();
259 // temperatures from chamber sensors (per chamber)
260 entry = manager->Get("TRD/Calib/trd_envTemp");
262 entry->SetOwner(kTRUE);
263 temperatureSensors = (AliTRDSensorArray*)entry->GetObject();
266 // chamber status (from sensors)
267 entry = manager->Get("TRD/Calib/trd_chamberStatus");
269 entry->SetOwner(kTRUE);
270 chamberStatusSensors = (AliTRDSensorArray*)entry->GetObject();
273 // gas overpressure (per whole TRD)
274 entry = manager->Get("TRD/Calib/trd_gasOverpressure");
276 entry->SetOwner(kTRUE);
277 overpressureSensors = (AliTRDSensorArray*)entry->GetObject();
280 // gas CO2 fraction (whole TRD)
281 entry = manager->Get("TRD/Calib/trd_gasCO2");
283 entry->SetOwner(kTRUE);
284 gasCO2Sensors = (AliTRDSensorArray*)entry->GetObject();
287 // gas H2O fraction (whole TRD)
288 entry = manager->Get("TRD/Calib/trd_gasH2O");
290 entry->SetOwner(kTRUE);
291 gasH2OSensors = (AliTRDSensorArray*)entry->GetObject();
294 // gas O2 fraction (whole TRD)
295 entry = manager->Get("TRD/Calib/trd_gasO2");
297 entry->SetOwner(kTRUE);
298 gasO2Sensors = (AliTRDSensorArray*)entry->GetObject();
301 // ADC Clk phase (whole TRD)
303 entry = manager->Get("TRD/Calib/trd_adcClkPhase");
305 entry->SetOwner(kTRUE);
306 adcClkPhaseSensors = (AliTRDSensorArray*)entry->GetObject();
309 } // end if getMonitoringInfo
312 // get calibration information
314 AliTRDCalDet *chamberGainFactor = 0;
315 AliTRDCalPad *padGainFactor = 0;
316 Double_t runMeanGain=0.0, runRMSGain=0.0;
317 TVectorD chamberMeanGain(AliTRDcalibDB::kNdet);
318 TVectorD chamberRMSGain(AliTRDcalibDB::kNdet);
319 TVectorD smMeanGain(AliTRDcalibDB::kNsector);
320 TVectorD smRMSGain(AliTRDcalibDB::kNsector);
321 TString parName("Gain");
322 if(getCalibrationInfo) {
323 entry = manager->Get("TRD/Calib/ChamberGainFactor");
325 entry->SetOwner(kFALSE);
326 chamberGainFactor = (AliTRDCalDet*)entry->GetObject();
328 entry = manager->Get("TRD/Calib/LocalGainFactor");
330 entry->SetOwner(kFALSE);
331 padGainFactor = (AliTRDCalPad*)entry->GetObject();
333 ProcessTRDCalibArray(chamberGainFactor, padGainFactor,
335 runMeanGain, runRMSGain,
336 chamberMeanGain, chamberRMSGain,
337 smMeanGain, smRMSGain);
341 AliTRDCalDet *chamberNoise = 0;
342 AliTRDCalPad *padNoise = 0;
343 Double_t runMeanNoise=0.0, runRMSNoise=0.0;
344 TVectorD chamberMeanNoise(AliTRDcalibDB::kNdet);
345 TVectorD chamberRMSNoise(AliTRDcalibDB::kNdet);
346 TVectorD smMeanNoise(AliTRDcalibDB::kNsector);
347 TVectorD smRMSNoise(AliTRDcalibDB::kNsector);
349 if(getCalibrationInfo) {
350 entry = manager->Get("TRD/Calib/DetNoise");
352 entry->SetOwner(kFALSE);
353 chamberNoise = (AliTRDCalDet*)entry->GetObject();
355 entry = manager->Get("TRD/Calib/PadNoise");
357 entry->SetOwner(kFALSE);
358 padNoise = (AliTRDCalPad*)entry->GetObject();
360 ProcessTRDCalibArray(chamberNoise, padNoise,
362 runMeanNoise, runRMSNoise,
363 chamberMeanNoise, chamberRMSNoise,
364 smMeanNoise, smRMSNoise);
367 // process drift velocity
368 AliTRDCalDet *chamberVdrift = 0;
369 AliTRDCalPad *padVdrift = 0;
370 Double_t runMeanVdrift=0.0, runRMSVdrift=0.0;
371 TVectorD chamberMeanVdrift(AliTRDcalibDB::kNdet);
372 TVectorD chamberRMSVdrift(AliTRDcalibDB::kNdet);
373 TVectorD smMeanVdrift(AliTRDcalibDB::kNsector);
374 TVectorD smRMSVdrift(AliTRDcalibDB::kNsector);
376 if(getCalibrationInfo) {
377 entry = manager->Get("TRD/Calib/ChamberVdrift");
379 entry->SetOwner(kFALSE);
380 chamberVdrift = (AliTRDCalDet*)entry->GetObject();
382 entry = manager->Get("TRD/Calib/LocalVdrift");
384 entry->SetOwner(kFALSE);
385 padVdrift = (AliTRDCalPad*)entry->GetObject();
387 ProcessTRDCalibArray(chamberVdrift, padVdrift,
389 runMeanVdrift, runRMSVdrift,
390 chamberMeanVdrift, chamberRMSVdrift,
391 smMeanVdrift, smRMSVdrift);
395 AliTRDCalDet *chamberT0 = 0;
396 AliTRDCalPad *padT0 = 0;
397 Double_t runMeanT0=0.0, runRMST0=0.0;
398 TVectorD chamberMeanT0(AliTRDcalibDB::kNdet);
399 TVectorD chamberRMST0(AliTRDcalibDB::kNdet);
400 TVectorD smMeanT0(AliTRDcalibDB::kNsector);
401 TVectorD smRMST0(AliTRDcalibDB::kNsector);
403 if(getCalibrationInfo) {
404 entry = manager->Get("TRD/Calib/ChamberT0");
406 entry->SetOwner(kFALSE);
407 chamberT0 = (AliTRDCalDet*)entry->GetObject();
409 entry = manager->Get("TRD/Calib/LocalT0");
411 entry->SetOwner(kFALSE);
412 padT0 = (AliTRDCalPad*)entry->GetObject();
414 ProcessTRDCalibArray(chamberT0, padT0,
417 chamberMeanT0, chamberRMST0,
421 // process pad and chamber status
422 AliTRDCalChamberStatus* chamberStatus = 0;
423 AliTRDCalPadStatus *padStatus = 0;
424 Float_t runBadPadFraction=0.0;
425 TVectorD chamberBadPadFraction(AliTRDcalibDB::kNdet);
426 TVectorD chamberStatusValues(AliTRDcalibDB::kNdet);
427 if(getCalibrationInfo) {
428 entry = manager->Get("TRD/Calib/ChamberStatus");
430 entry->SetOwner(kFALSE);
431 chamberStatus = (AliTRDCalChamberStatus*)entry->GetObject();
433 entry = manager->Get("TRD/Calib/PadStatus");
435 entry->SetOwner(kFALSE);
436 padStatus = (AliTRDCalPadStatus*)entry->GetObject();
438 ProcessTRDstatus(chamberStatus, padStatus,
439 runBadPadFraction, chamberBadPadFraction,
440 chamberStatusValues);
443 // get Goofie information
444 AliTRDSensorArray *goofieGainSensors = 0x0;
445 AliTRDSensorArray *goofieHvSensors = 0x0;
446 AliTRDSensorArray *goofiePressureSensors = 0x0;
447 AliTRDSensorArray *goofieTempSensors = 0x0;
448 AliTRDSensorArray *goofieVelocitySensors = 0x0;
449 AliTRDSensorArray *goofieCO2Sensors = 0x0;
450 AliTRDSensorArray *goofieN2Sensors = 0x0;
454 entry = manager->Get("TRD/Calib/trd_goofieGain");
456 entry->SetOwner(kTRUE);
457 goofieGainSensors = (AliTRDSensorArray*)entry->GetObject();
460 entry = manager->Get("TRD/Calib/trd_goofieHv");
462 entry->SetOwner(kTRUE);
463 goofieHvSensors = (AliTRDSensorArray*)entry->GetObject();
466 entry = manager->Get("TRD/Calib/trd_goofiePressure");
468 entry->SetOwner(kTRUE);
469 goofiePressureSensors = (AliTRDSensorArray*)entry->GetObject();
471 // goofie temperature
472 entry = manager->Get("TRD/Calib/trd_goofieTemp");
474 entry->SetOwner(kTRUE);
475 goofieTempSensors = (AliTRDSensorArray*)entry->GetObject();
477 // goofie drift velocity
478 entry = manager->Get("TRD/Calib/trd_goofieVelocity");
480 entry->SetOwner(kTRUE);
481 goofieVelocitySensors = (AliTRDSensorArray*)entry->GetObject();
484 entry = manager->Get("TRD/Calib/trd_goofieCO2");
486 entry->SetOwner(kTRUE);
487 goofieCO2Sensors = (AliTRDSensorArray*)entry->GetObject();
490 entry = manager->Get("TRD/Calib/trd_goofieN2");
492 entry->SetOwner(kTRUE);
493 goofieN2Sensors = (AliTRDSensorArray*)entry->GetObject();
495 } // end if getGoofieInfo
497 // process the DCS FEE arrays
498 Int_t nSB1 = 0; Int_t nSB2 = 0; Int_t nSB3 = 0; Int_t nSB4 = 0; Int_t nSB5 = 0;
500 Bool_t sorAndEor = kFALSE;
501 TVectorD statusArraySOR(AliTRDcalibDB::kNdet);
502 TVectorD statusArrayEOR(AliTRDcalibDB::kNdet);
503 Int_t dcsFeeGlobalNTimeBins = -1;
504 Int_t dcsFeeGlobalConfigTag = -1;
505 Int_t dcsFeeGlobalSingleHitThres = -1;
506 Int_t dcsFeeGlobalThreePadClustThres = -1;
507 Int_t dcsFeeGlobalSelectiveNoSZ = -1;
508 Int_t dcsFeeGlobalTCFilterWeight = -1;
509 Int_t dcsFeeGlobalTCFilterShortDecPar = -1;
510 Int_t dcsFeeGlobalTCFilterLongDecPar = -1;
511 Int_t dcsFeeGlobalModeFastStatNoise = -1;
512 TObjString dcsFeeGlobalConfigVersion("");
513 TObjString dcsFeeGlobalConfigName("");
514 TObjString dcsFeeGlobalFilterType("");
515 TObjString dcsFeeGlobalReadoutParam("");
516 TObjString dcsFeeGlobalTestPattern("");
517 TObjString dcsFeeGlobalTrackletMode("");
518 TObjString dcsFeeGlobalTrackletDef("");
519 TObjString dcsFeeGlobalTriggerSetup("");
520 TObjString dcsFeeGlobalAddOptions("");
522 TObjArray *objArrayCDB = 0;
523 AliTRDCalDCS* calDCSsor = 0x0;
524 AliTRDCalDCS* calDCSeor = 0x0;
525 entry = manager->Get("TRD/Calib/DCS");
527 entry->SetOwner(kTRUE);
528 objArrayCDB = (TObjArray*)entry->GetObject();
530 objArrayCDB->SetOwner(kTRUE);
531 calDCSsor = (AliTRDCalDCS*)objArrayCDB->At(0);
532 calDCSeor = (AliTRDCalDCS*)objArrayCDB->At(1);
535 ProcessTRDCalDCSFEE(calDCSsor, calDCSeor,
536 nSB1, nSB2, nSB3, nSB4, nSB5,
537 nChanged, sorAndEor, statusArraySOR, statusArrayEOR);
539 if(calDCSsor || calDCSeor) {
540 AliTRDCalDCS *caldcs = 0;
541 if(calDCSsor) caldcs = calDCSsor;
542 else caldcs = calDCSeor;
543 dcsFeeGlobalNTimeBins = caldcs->GetGlobalNumberOfTimeBins();
544 dcsFeeGlobalConfigTag = caldcs->GetGlobalConfigTag();
545 dcsFeeGlobalSingleHitThres = caldcs->GetGlobalSingleHitThres();
546 dcsFeeGlobalThreePadClustThres = caldcs->GetGlobalThreePadClustThres();
547 dcsFeeGlobalSelectiveNoSZ = caldcs->GetGlobalSelectiveNoZS();
548 dcsFeeGlobalTCFilterWeight = caldcs->GetGlobalTCFilterWeight();
549 dcsFeeGlobalTCFilterShortDecPar = caldcs->GetGlobalTCFilterShortDecPar();
550 dcsFeeGlobalTCFilterLongDecPar = caldcs->GetGlobalTCFilterLongDecPar();
551 dcsFeeGlobalModeFastStatNoise = caldcs->GetGlobalModeFastStatNoise();
552 dcsFeeGlobalConfigVersion = caldcs->GetGlobalConfigVersion().Data();
553 dcsFeeGlobalConfigName = caldcs->GetGlobalConfigName().Data();
554 dcsFeeGlobalFilterType = caldcs->GetGlobalFilterType().Data();
555 dcsFeeGlobalReadoutParam = caldcs->GetGlobalReadoutParam().Data();
556 dcsFeeGlobalTestPattern = caldcs->GetGlobalTestPattern().Data();
557 dcsFeeGlobalTrackletMode = caldcs->GetGlobalTrackletMode().Data();
558 dcsFeeGlobalTrackletDef = caldcs->GetGlobalTrackletDef().Data();
559 dcsFeeGlobalTriggerSetup = caldcs->GetGlobalTriggerSetup().Data();
560 dcsFeeGlobalAddOptions = caldcs->GetGlobalAddOptions().Data();
562 if(objArrayCDB) objArrayCDB->RemoveAll();
563 } // end if(getDCSInfo)
566 // loop over time steps
567 for(UInt_t iTime = startTime; iTime<=endTime; iTime += dTime) {
569 TTimeStamp iStamp(iTime);
570 cout << "time step " << iStamp.GetDate()/10000 << "/"
571 << (iStamp.GetDate()/100)-(iStamp.GetDate()/10000)*100 << "/"
572 << iStamp.GetDate()%100 << " "
573 << iStamp.GetTime()/10000 << ":"
574 << (iStamp.GetTime()/100)-(iStamp.GetTime()/10000)*100 << ":"
575 << iStamp.GetTime()%100 << endl;
578 Float_t pressure = -99.;
580 pressure = cavern_pressure->Eval(iStamp);
583 Float_t surfacePressure = -99.;
585 surfacePressure = surface_pressure->Eval(iStamp);
588 TVectorD anodeIValues(AliTRDcalibDB::kNdet);
590 ProcessTRDSensorArray(anodeISensors, iStamp, anodeIValues);
593 TVectorD anodeUValues(AliTRDcalibDB::kNdet);
595 ProcessTRDSensorArray(anodeUSensors, iStamp, anodeUValues);
598 TVectorD driftIValues(AliTRDcalibDB::kNdet);
600 ProcessTRDSensorArray(driftISensors, iStamp, driftIValues);
603 TVectorD driftUValues(AliTRDcalibDB::kNdet);
605 ProcessTRDSensorArray(driftUSensors, iStamp, driftUValues);
607 // chamber temperatures
608 TVectorD envTempValues(AliTRDcalibDB::kNdet);
609 if(temperatureSensors)
610 ProcessTRDSensorArray(temperatureSensors, iStamp, envTempValues);
612 // chamber status sensors
613 TVectorD statusValues(AliTRDcalibDB::kNdet);
614 if(chamberStatusSensors)
615 ProcessTRDSensorArray(chamberStatusSensors, iStamp, statusValues);
618 TVectorD overpressureValues(overpressureSensors ? overpressureSensors->NumSensors() : 0);
619 if(overpressureSensors)
620 ProcessTRDSensorArray(overpressureSensors, iStamp, overpressureValues);
623 TVectorD gasCO2Values(gasCO2Sensors ? gasCO2Sensors->NumSensors() : 0);
625 ProcessTRDSensorArray(gasCO2Sensors, iStamp, gasCO2Values);
628 TVectorD gasH2OValues(gasH2OSensors ? gasH2OSensors->NumSensors() : 0);
630 ProcessTRDSensorArray(gasH2OSensors, iStamp, gasH2OValues);
633 TVectorD gasO2Values(gasO2Sensors ? gasO2Sensors->NumSensors() : 0);
635 ProcessTRDSensorArray(gasO2Sensors, iStamp, gasO2Values);
638 //TVectorD adcClkPhaseValues(adcClkPhaseSensors ? adcClkPhaseSensors->NumSensors() : 0);
639 //if(adcClkPhaseSensors)
640 // ProcessTRDSensorArray(adcClkPhaseSensors, iStamp, adcClkPhaseValues);
643 TVectorD goofieGainValues(goofieGainSensors ? goofieGainSensors->NumSensors() : 0);
644 if(goofieGainSensors)
645 ProcessTRDSensorArray(goofieGainSensors, iStamp, goofieGainValues);
648 TVectorD goofieHvValues(goofieHvSensors ? goofieHvSensors->NumSensors() : 0);
650 ProcessTRDSensorArray(goofieHvSensors, iStamp, goofieHvValues);
653 TVectorD goofiePressureValues(goofiePressureSensors ? goofiePressureSensors->NumSensors() : 0);
654 if(goofiePressureSensors)
655 ProcessTRDSensorArray(goofiePressureSensors, iStamp, goofiePressureValues);
657 // goofie temperature
658 TVectorD goofieTempValues(goofieTempSensors ? goofieTempSensors->NumSensors() : 0);
659 if(goofieTempSensors)
660 ProcessTRDSensorArray(goofieTempSensors, iStamp, goofieTempValues);
662 // goofie drift velocity
663 TVectorD goofieVelocityValues(goofieVelocitySensors ? goofieVelocitySensors->NumSensors() : 0);
664 if(goofieVelocitySensors)
665 ProcessTRDSensorArray(goofieVelocitySensors, iStamp, goofieVelocityValues);
668 TVectorD goofieCO2Values(goofieCO2Sensors ? goofieCO2Sensors->NumSensors() : 0);
670 ProcessTRDSensorArray(goofieCO2Sensors, iStamp, goofieCO2Values);
673 TVectorD goofieN2Values(goofieN2Sensors ? goofieN2Sensors->NumSensors() : 0);
675 ProcessTRDSensorArray(goofieN2Sensors, iStamp, goofieN2Values);
679 (*treeStreamer)<< "trdTree"
682 << "startTimeGRP=" << startTime
683 << "endTimeGRP=" << endTime
684 << "runType.=" << &runType
685 << "cavernPressure=" << pressure
686 << "surfacePressure=" << surfacePressure
687 << "detectorMask=" << detectorMask;
688 if(getMonitoringInfo) {
689 (*treeStreamer)<< "trdTree"
690 << "hvAnodeI.=" << &anodeIValues
691 << "hvAnodeU.=" << &anodeUValues
692 << "hvDriftI.=" << &driftIValues
693 << "hvDriftU.=" << &driftUValues
694 << "envTemp.=" << &envTempValues
695 << "sensorStatusValues.=" << &statusValues
696 << "gasOverPressure.=" << &overpressureValues
697 << "gasCO2.=" << &gasCO2Values
698 << "gasH2O.=" << &gasH2OValues
699 << "gasO2.=" << &gasO2Values;
700 //<< "adcClkPhase.=" << &adcClkPhaseValues;
703 (*treeStreamer)<< "trdTree"
704 << "goofieGain.=" << &goofieGainValues
705 << "goofieHV.=" << &goofieHvValues
706 << "goofiePressure.=" << &goofiePressureValues
707 << "goofieTemp.=" << &goofieTempValues
708 << "goofieVelocity.=" << &goofieVelocityValues
709 << "goofieCO2.=" << &goofieCO2Values
710 << "goofieN2.=" << &goofieN2Values;
712 if(getCalibrationInfo) {
713 (*treeStreamer)<< "trdTree"
714 << "runMeanGain=" << runMeanGain
715 << "runRMSGain=" << runRMSGain
716 << "smMeanGain.=" << &smMeanGain
717 << "smRMSGain.=" << &smRMSGain
718 << "chamberMeanGain.=" << &chamberMeanGain
719 << "chamberRMSGain.=" << &chamberRMSGain
720 << "runMeanNoise=" << runMeanNoise
721 << "runRMSNoise=" << runRMSNoise
722 << "smMeanNoise.=" << &smMeanNoise
723 << "smRMSNoise.=" << &smRMSNoise
724 << "chamberMeanNoise.=" << &chamberMeanNoise
725 << "chamberRMSNoise.=" << &chamberRMSNoise
726 << "runMeanVdrift=" << runMeanVdrift
727 << "runRMSVdrift=" << runRMSVdrift
728 << "smMeanVdrift.=" << &smMeanVdrift
729 << "smRMSVdrift.=" << &smRMSVdrift
730 << "chamberMeanVdrift.=" << &chamberMeanVdrift
731 << "chamberRMSVdrift.=" << &chamberRMSVdrift
732 << "runMeanT0=" << runMeanT0
733 << "runRMST0=" << runRMST0
734 << "smMeanT0.=" << &smMeanT0
735 << "smRMST0.=" << &smRMST0
736 << "chamberMeanT0.=" << &chamberMeanT0
737 << "chamberRMST0.=" << &chamberRMST0
738 << "runBadPadFraction=" << runBadPadFraction
739 << "chamberBadPadFraction.=" << &chamberBadPadFraction
740 << "chamberStatusValues.=" << &chamberStatusValues;
743 (*treeStreamer)<< "trdTree"
744 << "dcsFeeGlobalNTimeBins=" << dcsFeeGlobalNTimeBins
745 << "dcsFeeGlobalConfigTag=" << dcsFeeGlobalConfigTag
746 << "dcsFeeGlobalSingleHitThres=" << dcsFeeGlobalSingleHitThres
747 << "dcsFeeGlobalThreePadClustThres=" << dcsFeeGlobalThreePadClustThres
748 << "dcsFeeGlobalSelectiveNoSZ=" << dcsFeeGlobalSelectiveNoSZ
749 << "dcsFeeGlobalTCFilterWeight=" << dcsFeeGlobalTCFilterWeight
750 << "dcsFeeGlobalTCFilterShortDecPar=" << dcsFeeGlobalTCFilterShortDecPar
751 << "dcsFeeGlobalTCFilterLongDecPar=" << dcsFeeGlobalTCFilterLongDecPar
752 << "dcsFeeGlobalModeFastStatNoise=" << dcsFeeGlobalModeFastStatNoise
753 // << "dcsFeeGlobalConfigVersion.=" << &dcsFeeGlobalConfigVersion
754 // << "dcsFeeGlobalConfigName.=" << &dcsFeeGlobalConfigName
755 // << "dcsFeeGlobalFilterType.=" << &dcsFeeGlobalFilterType
756 // << "dcsFeeGlobalReadoutParam.=" << &dcsFeeGlobalReadoutParam
757 // << "dcsFeeGlobalTestPattern.=" << &dcsFeeGlobalTestPattern
758 // << "dcsFeeGlobalTrackletMode.=" << &dcsFeeGlobalTrackletMode
759 // << "dcsFeeGlobalTrackletDef.=" << &dcsFeeGlobalTrackletDef
760 // << "dcsFeeGlobalTriggerSetup.=" << &dcsFeeGlobalTriggerSetup
761 // << "dcsFeeGlobalAddOptions.=" << &dcsFeeGlobalAddOptions
762 << "statusDCSFEESOR.=" << &statusArraySOR
763 << "statusDCSFEEEOR.=" << &statusArrayEOR
764 << "SORandEOR=" << sorAndEor
765 << "nChanged=" << nChanged
772 (*treeStreamer)<< "trdTree"
774 } // end loop over time steps
776 // add the run number to the list of runs
777 runs.ResizeTo(runs.GetNoElements()+1);
778 runs[runs.GetNoElements()-1] = currRun;
781 if(grpObject) delete grpObject;
782 if(anodeISensors) anodeISensors->Clear();
783 if(anodeUSensors) anodeUSensors->Clear();
784 if(driftISensors) driftISensors->Clear();
785 if(driftUSensors) driftUSensors->Clear();
786 if(temperatureSensors) temperatureSensors->Clear();
787 if(overpressureSensors) overpressureSensors->Clear();
788 if(gasCO2Sensors) gasCO2Sensors->Clear();
789 if(gasH2OSensors) gasH2OSensors->Clear();
790 if(gasO2Sensors) gasO2Sensors->Clear();
791 //if(adcClkPhaseSensors) adcClkPhaseSensors->Clear();
792 if(goofieGainSensors) goofieGainSensors->Clear();
793 if(goofieHvSensors) goofieHvSensors->Clear();
794 if(goofiePressureSensors) goofiePressureSensors->Clear();
795 if(goofieTempSensors) goofieTempSensors->Clear();
796 if(goofieVelocitySensors) goofieVelocitySensors->Clear();
797 if(goofieCO2Sensors) goofieCO2Sensors->Clear();
798 if(goofieN2Sensors) goofieN2Sensors->Clear();
799 if(chamberGainFactor) delete chamberGainFactor;
800 if(padGainFactor) delete padGainFactor;
801 if(chamberNoise) delete chamberNoise;
802 if(padNoise) delete padNoise;
803 if(chamberVdrift) delete chamberVdrift;
804 if(padVdrift) delete padVdrift;
805 if(chamberT0) delete chamberT0;
806 if(padT0) delete padT0;
807 if(chamberStatus) delete chamberStatus;
808 if(padStatus) delete padStatus;
809 } // end while (loop over runs)
810 TTimeStamp loopEndTime;
812 treeStreamer->GetFile()->cd();
816 // output some job informations
817 TTimeStamp jobEndTime;
818 cout << "=============================================" << endl;
819 cout << "Job launched at : " << jobStartTime.AsString() << endl;
820 cout << "Loop over runs started at: " << loopStartTime.AsString() << endl;
821 cout << "Loop over runs ended at : " << loopEndTime.AsString() << endl;
822 cout << "Job ended at : " << jobEndTime.AsString() << endl;
823 cout << "Initialization duration : "
824 << loopStartTime.GetSec() - jobStartTime.GetSec() << " seconds" << endl;
825 cout << "Loop over runs duration : "
826 << loopEndTime.GetSec() - loopStartTime.GetSec() << " seconds" << endl;
827 cout << "Post loop : "
828 << jobEndTime.GetSec() - loopEndTime.GetSec() << " seconds" << endl;
829 cout << "Running time per processed run: "
830 << (loopEndTime.GetSec()-loopStartTime.GetSec())/(runs.GetNoElements()>0 ? Double_t(runs.GetNoElements()) : 1.0)
831 << " sec./run" << endl;
832 cout << "Running time per input run: "
833 << (loopEndTime.GetSec()-loopStartTime.GetSec())/((rejectedRuns.GetNoElements()+runs.GetNoElements())>0 ? Double_t(runs.GetNoElements()+rejectedRuns.GetNoElements()) : 1.0)
834 << " sec./run" << endl;
836 // print the runs that had problems
837 cout << "number of rejected runs: " << rejectedRuns.GetNoElements() << endl;
838 cout << "rejected run numbers" << endl;
839 cout << "********************" << endl;
840 for(Int_t iRun=0; iRun<rejectedRuns.GetNoElements(); iRun++) {
841 cout << rejectedRuns[iRun] << " ";
842 if(iRun%10==0) cout << endl;
844 cout << "=============================================" << endl;
848 //__________________________________________________________________________________________
849 void ProcessTRDSensorArray(AliTRDSensorArray *sensorArray, TTimeStamp timeStamp, TVectorD &values) {
850 // Fill a vector with sensor values for a given time stamp
851 // The sensor->Eval() method makes interpolation inside the covered time interval
852 // and returns the value at the closest time limit (start or end) outside the covered time range
853 AliDCSSensor *sensor;
854 for(Int_t i=0; i<sensorArray->NumSensors(); i++) {
855 sensor = sensorArray->GetSensorNum(i);
856 if(sensor && sensor->GetGraph())
857 values[i] = sensor->Eval(timeStamp);
864 //__________________________________________________________________________________________
865 void ProcessTRDCalibArray(AliTRDCalDet* chamberCalib, AliTRDCalPad *padCalib,
867 Double_t &runValue, Double_t &runRMS,
868 TVectorD &chamberValues, TVectorD &chamberValuesRMS,
869 TVectorD &superModuleValues, TVectorD &superModuleValuesRMS) {
870 // Process the calibrations for a given run.
871 // Calculates the run and chamber wise averages
874 // check if the calibration parameter is multiplicative or additive
875 Bool_t multiplicative = kTRUE;
876 if(!parName.CompareTo("T0")) multiplicative = kFALSE;
878 // first iteration (calculate all averages and RMS without discrimination on the SM average)
879 gRunWiseHisto->Reset();
880 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
881 // reset the super module histogram
882 gSuperModuleWiseHisto->Reset();
883 // check if SM is installed
884 if(!gkSuperModuleStatus[iSM]) continue;
885 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
886 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
887 iChamber++) { // loop over chambers in this supermodule
888 // get the chamber value
889 Float_t chamberValue = chamberCalib->GetValue(iChamber);
890 // get the ROC object
891 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
894 gChamberWiseHisto->Reset();
895 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels
896 // calculate the calibration parameter for this pad
899 padValue = chamberValue * chamberROC->GetValue(iChannel);
901 padValue = chamberValue + chamberROC->GetValue(iChannel);
902 // fill the run, SM and chamber wise histograms
903 gChamberWiseHisto->Fill(padValue);
904 // if the parameter is Noise then check if the pad value is not a default one
905 // Default value is now 1.2!!!! Check with Raphaelle for more informations
906 if(parName.Contains("Noise") &&
907 TMath::Abs(padValue-1.2)<0.00001) continue;
908 gSuperModuleWiseHisto->Fill(padValue);
909 gRunWiseHisto->Fill(padValue);
910 } // end loop over channels
911 // get the chamber wise mean and RMS
912 chamberValues[iChamber] = gChamberWiseHisto->GetMean();
913 chamberValuesRMS[iChamber] = gChamberWiseHisto->GetRMS();
914 } // end loop over chambers
915 // SM wise mean and RMS
916 superModuleValues[iSM] = gSuperModuleWiseHisto->GetMean();
917 superModuleValuesRMS[iSM] = gSuperModuleWiseHisto->GetRMS();
918 } // end loop over supermodules
919 // run wise mean and RMS
920 runValue = gRunWiseHisto->GetMean();
921 runRMS = gRunWiseHisto->GetRMS();
923 // Noise and Gain are finished processing
924 if(parName.Contains("Noise") || parName.Contains("Gain"))
926 // second iteration (calculate SM and run wise averages and RMS for Vdrift and T0)
927 // The pads with calib parameter equal to the SM average are discarded (default value)
928 gRunWiseHisto->Reset();
929 for(Int_t iSM = 0; iSM<AliTRDcalibDB::kNsector; iSM++) { // loop over supermodules
930 gSuperModuleWiseHisto->Reset();
931 // eliminate the uninstalled super modules
932 if(!gkSuperModuleStatus[iSM]) continue;
933 for(Int_t iChamber=iSM*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
934 iChamber < (iSM+1)*AliTRDcalibDB::kNstack*AliTRDcalibDB::kNlayer;
935 iChamber++) { // loop over chambers
937 Float_t chamberValue = chamberCalib->GetValue(iChamber);
938 AliTRDCalROC *chamberROC = padCalib->GetCalROC(iChamber);
942 for(Int_t iChannel = 0; iChannel < chamberROC->GetNchannels(); iChannel++){ // loop over channels in a chamber
946 padValue = chamberValue * chamberROC->GetValue(iChannel);
948 padValue = chamberValue + chamberROC->GetValue(iChannel);
949 // eliminate from the average and RMS calculation all pads which
950 // have the calib parameter equal with the SM average
951 if((parName.Contains("Vdrift") || parName.Contains("T0")) &&
952 TMath::Abs(padValue-superModuleValues[iSM])<0.00001) continue;
953 gSuperModuleWiseHisto->Fill(padValue);
954 gRunWiseHisto->Fill(padValue);
955 } // end loop over channels
956 } // end loop over chambers
957 superModuleValues[iSM] = gSuperModuleWiseHisto->GetMean();
958 superModuleValuesRMS[iSM] = gSuperModuleWiseHisto->GetRMS();
959 } // end loop over super modules
960 runValue = gRunWiseHisto->GetMean();
961 runRMS = gRunWiseHisto->GetRMS();
965 //__________________________________________________________________________________________
966 void ProcessTRDstatus(AliTRDCalChamberStatus* chamberStatus, AliTRDCalPadStatus* padStatus,
967 Float_t &runBadPadFraction, TVectorD &chamberBadPadFraction,
968 TVectorD &chamberStatusValues) {
969 // Process the pad status. Calculates the fraction of pads with non 0 status
970 // run and chamber wise
972 Int_t runPadStatusNot0 = 0;
973 Int_t runPadStatusAll = 0;
975 Int_t superModuleStatus[18] = {1, 1, 0, 0, 0, 0, 0, 1, 1,
976 1, 1, 0, 0, 0, 0, 0, 0, 1};
978 // loop over chambers
979 for(Int_t iChamber=0; iChamber < AliTRDcalibDB::kNdet; iChamber++) {
980 // check if the chamber is in an installed sector;
981 Int_t sm = AliTRDgeometry::GetSector(iChamber);
982 if(!superModuleStatus[sm]) continue;
984 chamberStatusValues[iChamber] = chamberStatus->GetStatus(iChamber);
985 AliTRDCalSingleChamberStatus *singleChamberStatus = padStatus->GetCalROC(iChamber);
986 if(!singleChamberStatus)
988 Int_t chamberPadStatusNot0 = 0;
989 Int_t chamberPadStatusAll = 0;
990 // loop over channels in a chamber
991 for(Int_t iChannel = 0; iChannel < singleChamberStatus->GetNchannels(); iChannel++) {
992 if(singleChamberStatus->GetStatus(iChannel) > 0) {
993 chamberPadStatusNot0++;
996 chamberPadStatusAll++;
999 chamberBadPadFraction[iChamber] = (chamberPadStatusAll>0 ?
1000 Float_t(chamberPadStatusNot0)/Float_t(chamberPadStatusAll) : -99.);
1002 runBadPadFraction = (runPadStatusAll>0 ? Float_t(runPadStatusNot0)/Float_t(runPadStatusAll) : -99.);
1006 //__________________________________________________________________________________________
1007 void ProcessTRDCalDCSFEE(AliTRDCalDCS *caldcsSOR, AliTRDCalDCS *caldcsEOR,
1008 Int_t &nsb1, Int_t &nsb2, Int_t &nsb3, Int_t &nsb4, Int_t &nsb5,
1009 Int_t &nChanged, Bool_t &sorAndEor,
1010 TVectorD &statusArraySOR, TVectorD &statusArrayEOR) {
1012 // Process the DCS information
1015 if(!caldcsSOR && !caldcsEOR) {
1019 else if(caldcsSOR && !caldcsEOR) {
1022 else if(!caldcsSOR && caldcsEOR) {
1023 caldcsSOR = caldcsEOR;
1027 nsb1 = 0; nsb2 = 0; nsb3 = 0; nsb4 = 0; nsb5 = 0; nChanged = 0;
1028 for(Int_t iROC=0; iROC<AliTRDcalibDB::kNdet && iROC<caldcsSOR->GetFEEArr()->GetSize(); iROC++) {
1029 AliTRDCalDCSFEE *dcsSorFee = caldcsSOR->GetCalDCSFEEObj(iROC);
1030 AliTRDCalDCSFEE *dcsEorFee = caldcsEOR->GetCalDCSFEEObj(iROC);
1032 statusArraySOR[iROC] = dcsSorFee->GetStatusBit();
1033 if(statusArraySOR[iROC] == 1) nsb1++;
1034 if(statusArraySOR[iROC] == 2) nsb2++;
1035 if(statusArraySOR[iROC] == 3) nsb3++;
1036 if(statusArraySOR[iROC] == 4) nsb4++;
1037 if(statusArraySOR[iROC] == 5) nsb5++;
1040 statusArrayEOR[iROC] = dcsEorFee->GetStatusBit();
1043 if((statusArraySOR[iROC]-statusArrayEOR[iROC]) != 0) nChanged++;
1049 //__________________________________________________________________________________________
1050 void MakeRunListFromOCDB(const Char_t* directory, const Char_t* outfile, Bool_t fromAlien) {
1052 // For a given OCDB path dump the list of available run numbers
1055 gSystem->Exec(Form("alien_ls %s > temp.txt", directory));
1057 gSystem->Exec(Form("ls %s > temp.txt", directory));
1059 ifstream inBuffer("temp.txt");
1060 if(!inBuffer.is_open()) {
1061 cout << "File temp.txt not opened! Exiting" << endl;
1064 ofstream outBuffer(outfile);
1065 if(!outBuffer.is_open()) {
1066 cout << "File runList.txt cannot be opened! Exiting" << endl;
1070 while(!inBuffer.eof()) {
1071 char inputLine[128];
1072 inBuffer.getline(inputLine, 128, '\n');
1073 int runLow, runHigh;
1074 const char* tempLine = inputLine;
1075 sscanf(tempLine, "Run%d_%d_v1_s0.root", &runLow, &runHigh);
1076 outBuffer << runLow << endl;
1081 gSystem->Exec("rm temp.txt");