]>
Commit | Line | Data |
---|---|---|
ec55623f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // This class is a first implementation for the TRD. // | |
21 | // It takes data from HLT and computes the parameters // | |
22 | // and stores both reference data and online calibration // | |
23 | // parameters in the CDB // | |
a5e1169e | 24 | // It alsotakes DCS data, does spline fits // |
25 | // and stores both reference data and spline fits results // | |
26 | // in the CDB // | |
ec55623f | 27 | // // |
fdfee371 | 28 | // Authors: // |
ec55623f | 29 | // R. Bailhache (R.Bailhache@gsi.de) // |
cd4fc278 | 30 | // W. Monange (w.monange@gsi.de) // |
fdfee371 | 31 | // F. Kramer (kramer@ikf.uni-frankfurt.de) // |
ec55623f | 32 | // // |
33 | //////////////////////////////////////////////////////////////////////////// | |
e5c60cc7 | 34 | |
c893147d | 35 | #include <fstream> |
36 | ||
e5c60cc7 | 37 | #include <TFile.h> |
38 | #include <TProfile2D.h> | |
e5c60cc7 | 39 | #include <TObjString.h> |
40 | #include <TString.h> | |
41 | #include <TList.h> | |
fdfee371 | 42 | #include <TSAXParser.h> |
e5c60cc7 | 43 | |
44 | #include "AliCDBMetaData.h" | |
e5c60cc7 | 45 | #include "AliLog.h" |
46 | ||
c8ab4518 | 47 | #include "AliTRDPreprocessor.h" |
3a0f6479 | 48 | #include "AliTRDSensorArray.h" |
67c25e8d | 49 | #include "AliTRDCalibraFit.h" |
50 | #include "AliTRDCalibraMode.h" | |
3a0f6479 | 51 | #include "AliTRDCalibPadStatus.h" |
fdfee371 | 52 | #include "AliTRDSaxHandler.h" |
c893147d | 53 | #include "AliTRDgeometry.h" |
5029ad25 | 54 | #include "Cal/AliTRDCalPad.h" |
3a0f6479 | 55 | #include "Cal/AliTRDCalPadStatus.h" |
fdfee371 | 56 | #include "Cal/AliTRDCalDCS.h" |
5029ad25 | 57 | #include "Cal/AliTRDCalSingleChamberStatus.h" |
58 | #include "Cal/AliTRDCalROC.h" | |
59 | ||
e5c60cc7 | 60 | ClassImp(AliTRDPreprocessor) |
61 | ||
62 | //______________________________________________________________________________________________ | |
ec55623f | 63 | AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle) |
c8ab4518 | 64 | :AliPreprocessor("TRD", shuttle) |
65 | ,fVdriftHLT(0) | |
e5c60cc7 | 66 | { |
67 | // | |
68 | // Constructor | |
69 | // | |
70 | ||
f9ed5395 | 71 | AddRunType("PHYSICS"); |
72 | AddRunType("STANDALONE"); | |
73 | AddRunType("PEDESTAL"); | |
74 | AddRunType("DAQ"); | |
75 | ||
e5c60cc7 | 76 | } |
77 | ||
78 | //______________________________________________________________________________________________ | |
79 | AliTRDPreprocessor::~AliTRDPreprocessor() | |
80 | { | |
81 | // | |
82 | // Destructor | |
83 | // | |
84 | ||
85 | } | |
86 | ||
87 | //______________________________________________________________________________________________ | |
88 | void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) | |
89 | { | |
90 | // | |
91 | // Initialization routine for the TRD preprocessor | |
92 | // | |
93 | ||
94 | AliPreprocessor::Initialize(run,startTime,endTime); | |
95 | ||
96 | } | |
97 | ||
98 | //______________________________________________________________________________________________ | |
a5e1169e | 99 | UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap) |
e5c60cc7 | 100 | { |
a5e1169e | 101 | // |
102 | // Process DCS and calibration part for HLT | |
103 | // | |
104 | ||
8dd14606 | 105 | TString runType = GetRunType(); |
106 | Log(Form("runtype %s\n",runType.Data())); | |
65ffd646 | 107 | |
fdfee371 | 108 | // always process the configuration data |
3821ce70 | 109 | Int_t DCSConfigReturn = ProcessDCSConfigData(); |
110 | if(DCSConfigReturn) return DCSConfigReturn; | |
f9ed5395 | 111 | |
b70c68da | 112 | if (runType=="PEDESTAL"){ |
8dd14606 | 113 | if(ExtractPedestals()) return 1; |
114 | return 0; | |
115 | } | |
a5e1169e | 116 | |
f9ed5395 | 117 | if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){ |
65ffd646 | 118 | // DCS |
207402fc | 119 | if(ProcessDCS(dcsAliasMap)) return 1; |
f9ed5395 | 120 | if(runType=="PHYSICS"){ |
121 | // HLT if On | |
122 | //TString runPar = GetRunParameter("HLTStatus"); | |
123 | //if(runPar=="1") { | |
124 | if(GetHLTStatus()) { | |
83bc2fc6 | 125 | //if(ExtractHLT()) return 1; // for testing! |
126 | ExtractHLT(); | |
f9ed5395 | 127 | } |
128 | // DAQ if HLT failed | |
129 | if(!fVdriftHLT) { | |
207402fc | 130 | if(ExtractDriftVelocityDAQ()) return 1; // for testing! |
f9ed5395 | 131 | } |
132 | } | |
6ace5fe2 | 133 | } |
8dd14606 | 134 | |
135 | return 0; | |
6ace5fe2 | 136 | |
f5bb5557 | 137 | } |
138 | //______________________________________________________________________________ | |
139 | Bool_t AliTRDPreprocessor::ProcessDCS() | |
140 | { | |
c8ab4518 | 141 | // |
142 | // Default process DCS method | |
143 | // | |
f5bb5557 | 144 | |
145 | TString runType = GetRunType(); | |
b70c68da | 146 | if ((runType == "PHYSICS") || (runType == "STANDALONE")) { |
c8ab4518 | 147 | return kTRUE; |
148 | } | |
f5bb5557 | 149 | return kFALSE; |
150 | ||
6ace5fe2 | 151 | } |
152 | ||
6ace5fe2 | 153 | //______________________________________________________________________________ |
c8ab4518 | 154 | Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) |
6ace5fe2 | 155 | { |
c8ab4518 | 156 | // |
157 | // Process DCS method | |
158 | // | |
159 | ||
160 | Bool_t error = kFALSE; | |
6ace5fe2 | 161 | |
a5e1169e | 162 | AliCDBMetaData metaData; |
163 | metaData.SetBeamPeriod(0); | |
164 | metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache"); | |
165 | metaData.SetComment("TRD calib test"); | |
c8ab4518 | 166 | |
167 | Log("****** DCS ******\n"); | |
cd4fc278 | 168 | |
8dd14606 | 169 | TObjArray * list=AliTRDSensorArray::GetList (); |
cd4fc278 | 170 | |
171 | if (list == 0x0) { | |
6ace5fe2 | 172 | Log ("Error during AliTRDSensorArray::GetList"); |
173 | Log ("DCS will not be processing"); | |
8dd14606 | 174 | return kTRUE; |
6ace5fe2 | 175 | } |
176 | ||
177 | Int_t nEntries = list->GetEntries (); | |
178 | Log (Form ("%d alias loaded", nEntries)); | |
cd4fc278 | 179 | |
6ace5fe2 | 180 | Bool_t * results=new Bool_t [nEntries]; |
181 | Int_t * nGraph=new Int_t [nEntries]; | |
cd4fc278 | 182 | |
6ace5fe2 | 183 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { |
cd4fc278 | 184 | |
6ace5fe2 | 185 | AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias); |
cd4fc278 | 186 | |
6ace5fe2 | 187 | oneTRDDCS->SetStartTime (TTimeStamp (fStartTime)); |
188 | oneTRDDCS->SetEndTime (TTimeStamp (fEndTime)); | |
cd4fc278 | 189 | |
c8ab4518 | 190 | Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ())); |
cd4fc278 | 191 | |
6ace5fe2 | 192 | TMap * map; |
193 | ||
194 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
cd4fc278 | 195 | |
6ace5fe2 | 196 | nGraph [iAlias] = map->GetEntries (); |
cd4fc278 | 197 | |
6ace5fe2 | 198 | if (nGraph [iAlias] == 0) { |
199 | Log("No TGraph for this dcsDatapointAlias : not stored"); | |
200 | results [iAlias] = kFALSE; | |
611a7239 | 201 | //error = kTRUE; |
6ace5fe2 | 202 | continue; |
203 | } | |
cd4fc278 | 204 | |
6ace5fe2 | 205 | oneTRDDCS->SetGraph(map); |
611a7239 | 206 | results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE); |
6ace5fe2 | 207 | delete map; |
208 | ||
209 | //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData); | |
210 | ||
6ace5fe2 | 211 | if (!results[iAlias]) { |
8dd14606 | 212 | AliError("Problem during StoreRef DCS"); |
611a7239 | 213 | //error=kTRUE; |
6ace5fe2 | 214 | } |
215 | ||
6ace5fe2 | 216 | //BEGIN TEST (should not be removed ...) |
217 | /* | |
218 | oneTRDDCS->ClearGraph(); | |
219 | oneTRDDCS->ClearFit(); | |
220 | oneTRDDCS->SetDiffCut2 (0.1); | |
221 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
222 | oneTRDDCS->SetGraph (map); | |
223 | Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE); | |
224 | delete map; | |
225 | ||
226 | ||
227 | if(iAlias==1 || iAlias==19) continue; | |
228 | ||
229 | oneTRDDCS->ClearGraph(); | |
230 | oneTRDDCS->ClearFit(); | |
231 | oneTRDDCS->SetDiffCut2(0); | |
232 | map=oneTRDDCS->ExtractDCS(dcsAliasMap); | |
233 | oneTRDDCS->MakeSplineFit(map); | |
234 | Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); | |
235 | delete map; | |
236 | ||
237 | ||
238 | oneTRDDCS->ClearGraph(); | |
239 | oneTRDDCS->ClearFit(); | |
240 | oneTRDDCS->SetDiffCut2 (0.1); | |
241 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
242 | oneTRDDCS->MakeSplineFit(map); | |
243 | Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); | |
244 | delete map; | |
245 | */ | |
246 | //END TEST | |
247 | ||
6ace5fe2 | 248 | } |
611a7239 | 249 | |
250 | // Check errors | |
251 | Int_t nbCount = 0; | |
252 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { | |
253 | if (results[iAlias]) { | |
254 | nbCount++; | |
255 | } | |
256 | } | |
257 | if(nbCount == 0) error = kTRUE; | |
258 | ||
cd4fc278 | 259 | |
6ace5fe2 | 260 | Log (" Summury of DCS :\n"); |
261 | Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph")); | |
262 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { | |
263 | AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias); | |
264 | Log (Form ("%30s %10s %4d", | |
265 | oneTRDDCS->GetStoreName ().Data (), | |
266 | results[iAlias] ? "ok" : "X", | |
267 | nGraph [iAlias])); | |
268 | } | |
269 | Log ("*********** End of DCS **********"); | |
270 | ||
271 | delete results; | |
272 | delete nGraph; | |
273 | ||
8dd14606 | 274 | return error; |
c8ab4518 | 275 | |
6ace5fe2 | 276 | } |
277 | ||
278 | //______________________________________________________________________________________________ | |
8dd14606 | 279 | Bool_t AliTRDPreprocessor::ExtractPedestals() |
6ace5fe2 | 280 | { |
281 | // | |
282 | // Pedestal running on LDCs at the DAQ | |
283 | // | |
54c85ef7 | 284 | |
285 | // | |
286 | // The reference data are stored in: | |
287 | // PadStatus1 for sm-00-01-02-09-10-11 | |
288 | // PadStatus2 for sm-03-04-05-12-13-14 | |
289 | // PadStatus3 for sm-06-07-08-15-16-17 | |
290 | // PadStatus0 if nothing found..means problems | |
291 | // | |
5029ad25 | 292 | |
8dd14606 | 293 | Bool_t error = kFALSE; |
6ace5fe2 | 294 | |
295 | // Init a AliTRDCalibPadStatus | |
296 | AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus(); | |
297 | ||
298 | AliCDBMetaData metaData; | |
299 | metaData.SetBeamPeriod(0); | |
300 | metaData.SetResponsible("Raphaelle Bailhache"); | |
301 | metaData.SetComment("TRD calib test"); | |
302 | ||
303 | // Sum the contributions of the LDCs | |
304 | TList * listpad = GetFileSources(kDAQ,"PADSTATUS"); | |
8dd14606 | 305 | if (!listpad) { |
306 | Log("No list found for the PEDESTRAL Run"); | |
307 | return kTRUE; | |
308 | } | |
309 | ||
c8ab4518 | 310 | // loop through all files from LDCs |
8dd14606 | 311 | UInt_t index = 0; |
312 | while (listpad->At(index)!=NULL) { | |
313 | TObjString* fileNameEntry = (TObjString*) listpad->At(index); | |
314 | if (fileNameEntry != NULL) | |
315 | { | |
6ace5fe2 | 316 | TString fileName = GetFile(kDAQ, "PADSTATUS", |
317 | fileNameEntry->GetString().Data()); | |
8dd14606 | 318 | if(fileName.Length() ==0){ |
6ace5fe2 | 319 | Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index)); |
8dd14606 | 320 | delete listpad; |
321 | return kTRUE; | |
cd4fc278 | 322 | } |
8dd14606 | 323 | |
324 | TFile *f = TFile::Open(fileName); | |
325 | AliTRDCalibPadStatus *calPed; | |
326 | f->GetObject("calibpadstatus",calPed); | |
327 | ||
328 | if(calPed){ | |
329 | ||
54c85ef7 | 330 | Int_t ldc = 0; |
289cc637 | 331 | |
8dd14606 | 332 | // analyse |
289cc637 | 333 | //calPed->AnalyseHisto(); |
334 | ||
335 | // Add to the calPedSum | |
336 | for (Int_t idet=0; idet<540; idet++) { | |
337 | AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE); | |
338 | if ( rocMean ) { | |
339 | calPedSum.SetCalRocMean(rocMean,idet); | |
54c85ef7 | 340 | ldc = (Int_t) (idet / 30); |
289cc637 | 341 | } |
342 | AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE); | |
343 | if ( rocRMS ) { | |
344 | calPedSum.SetCalRocRMS(rocRMS,idet); | |
345 | } | |
e4db522f | 346 | AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE); |
347 | if ( rocMeand ) { | |
348 | calPedSum.SetCalRocMeand(rocMeand,idet); | |
349 | } | |
350 | AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE); | |
351 | if ( rocRMSd ) { | |
352 | calPedSum.SetCalRocRMSd(rocRMSd,idet); | |
353 | } | |
289cc637 | 354 | }// det loop |
355 | ||
1ac4bb35 | 356 | if((ldc==0) || (ldc==1) || (ldc==2)) ldc = 1; |
357 | if((ldc==3) || (ldc==4) || (ldc==5)) ldc = 2; | |
358 | if((ldc==6) || (ldc==7) || (ldc==8)) ldc = 3; | |
359 | if((ldc==9) || (ldc==10) || (ldc==11)) ldc = 4; | |
360 | if((ldc==12) || (ldc==13) || (ldc==14)) ldc = 5; | |
361 | if((ldc==15) || (ldc==16) || (ldc==17)) ldc = 6; | |
54c85ef7 | 362 | |
8dd14606 | 363 | // store as reference data |
364 | TString name("PadStatus"); | |
54c85ef7 | 365 | name += ldc; |
8dd14606 | 366 | if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ |
367 | Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); | |
368 | error = kTRUE; | |
369 | } | |
289cc637 | 370 | |
8dd14606 | 371 | } // calPed |
372 | } // fileNameEntry | |
373 | ++index; | |
374 | }// while (list) | |
c8ab4518 | 375 | |
8dd14606 | 376 | Log(Form("%d elements found in the list for the pedestal",(Int_t)index)); |
377 | if(index==0){ | |
6ace5fe2 | 378 | delete listpad; |
8dd14606 | 379 | return kTRUE; |
6ace5fe2 | 380 | } |
c8ab4518 | 381 | |
8dd14606 | 382 | // |
5029ad25 | 383 | // Create pedestal |
8dd14606 | 384 | // |
c8ab4518 | 385 | |
8dd14606 | 386 | // Create Pad Status |
387 | AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus(); | |
5029ad25 | 388 | // Create Noise |
389 | //Make the AliTRDCalPad | |
390 | AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); | |
391 | //Make the AliTRDCalDet correspondant | |
392 | AliTRDCalDet *calDet = calPedSum.CreateCalDet(); | |
393 | ||
394 | // | |
395 | // Take the noise and Pad status from the previous OCDB | |
396 | // | |
397 | ||
398 | AliTRDCalPad *calPadPrevious=0; | |
399 | AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise"); | |
400 | if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject(); | |
401 | if ( calPadPrevious==NULL ) { | |
402 | Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n"); | |
403 | calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise"); | |
404 | } | |
405 | ||
406 | AliTRDCalPadStatus *calPadStatusPrevious=0; | |
407 | entry = GetFromOCDB("Calib", "PadStatus"); | |
408 | if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject(); | |
409 | if ( calPadStatusPrevious==NULL ) { | |
410 | Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n"); | |
411 | calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus"); | |
412 | for (Int_t idet=0; idet<540; ++idet) | |
413 | { | |
414 | AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet); | |
415 | for(Int_t k = 0; k < calROC->GetNchannels(); k++){ | |
416 | calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); | |
417 | } | |
418 | } | |
419 | } | |
420 | ||
421 | ||
422 | // Loop over detectors for check | |
423 | for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) { | |
424 | ||
425 | // noise | |
426 | AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det); | |
427 | AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det); | |
428 | ||
429 | // padstatus | |
430 | AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det); | |
431 | AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det); | |
432 | ||
433 | ||
434 | // loop over first half and second half chamber | |
435 | for(Int_t half = 0; half < 2; half++){ | |
436 | ||
437 | Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half); | |
37b0cf5e | 438 | //printf("There are data for the detector %d the half %d: %d\n",det,half,data); |
5029ad25 | 439 | if(!data){ |
440 | // look if data in the OCDB | |
441 | Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half); | |
442 | // if no data at all, set to default value | |
443 | if(!dataPrevious){ | |
444 | SetDefaultStatus(*calROCStatus,(Bool_t)half); | |
445 | SetDefaultNoise(*calROCNoise,(Bool_t)half); | |
446 | } | |
447 | else{ | |
448 | // if data, set to previous value | |
449 | SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half); | |
450 | SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half); | |
451 | } | |
452 | } | |
453 | } | |
454 | } | |
455 | ||
456 | // | |
457 | // Store | |
458 | // | |
459 | ||
8dd14606 | 460 | AliCDBMetaData md3; |
461 | md3.SetObjectClassName("AliTRDCalPadStatus"); | |
462 | md3.SetResponsible("Raphaelle Bailhache"); | |
463 | md3.SetBeamPeriod(1); | |
464 | md3.SetComment("TRD calib test"); | |
465 | if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){ | |
466 | Log("Error storing the pedestal"); | |
467 | delete listpad; | |
468 | return kTRUE; | |
a5e1169e | 469 | } |
289cc637 | 470 | |
289cc637 | 471 | AliCDBMetaData md4; |
472 | md4.SetObjectClassName("AliTRDCalPad"); | |
473 | md4.SetResponsible("Raphaelle Bailhache"); | |
474 | md4.SetBeamPeriod(1); | |
475 | md4.SetComment("TRD calib test"); | |
476 | if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){ | |
477 | Log("Error storing the pedestal"); | |
478 | delete listpad; | |
479 | return kTRUE; | |
480 | } | |
5029ad25 | 481 | |
289cc637 | 482 | AliCDBMetaData md5; |
483 | md5.SetObjectClassName("AliTRDCalDet"); | |
484 | md5.SetResponsible("Raphaelle Bailhache"); | |
485 | md5.SetBeamPeriod(1); | |
486 | md5.SetComment("TRD calib test"); | |
487 | if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){ | |
488 | Log("Error storing the pedestal"); | |
489 | delete listpad; | |
490 | return kTRUE; | |
491 | } | |
492 | ||
8dd14606 | 493 | delete listpad; |
494 | return error; | |
5029ad25 | 495 | |
496 | } | |
c893147d | 497 | |
5029ad25 | 498 | //__________________________________________________________________ |
c893147d | 499 | Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus |
500 | , Bool_t second) | |
501 | { | |
a5e1169e | 502 | |
5029ad25 | 503 | // |
504 | // Data for this half chamber | |
505 | // | |
506 | ||
507 | Bool_t data = kFALSE; | |
508 | Int_t nCols = calROCStatus->GetNcols(); | |
509 | Int_t nCol0 = 0; | |
510 | Int_t nColE = (Int_t) nCols/2 - 2; | |
511 | if(second) { | |
512 | nCol0 = nColE + 4; | |
513 | nColE = nCols; | |
514 | } | |
f2a468d7 | 515 | |
516 | Int_t totalnumberofpads = 0; | |
517 | Int_t totalnumberofdata = 0; | |
518 | ||
5029ad25 | 519 | for(Int_t col = nCol0; col < nColE; col++){ |
520 | for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){ | |
f2a468d7 | 521 | totalnumberofpads++; |
5029ad25 | 522 | //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row)); |
37b0cf5e | 523 | if(!calROCStatus->GetStatus(col,row)) { |
5029ad25 | 524 | data = kTRUE; |
f2a468d7 | 525 | totalnumberofdata++; |
5029ad25 | 526 | } |
527 | } | |
5029ad25 | 528 | } |
f2a468d7 | 529 | if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE; |
5029ad25 | 530 | |
531 | return data; | |
532 | ||
533 | } | |
534 | //__________________________________________________________________ | |
535 | void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){ | |
536 | ||
537 | // | |
538 | // default status for this half chamber | |
539 | // | |
540 | ||
541 | Int_t nCols = calROCStatus.GetNcols(); | |
542 | Int_t nCol0 = 0; | |
543 | Int_t nColE = (Int_t) nCols/2; | |
544 | if(second) { | |
545 | nCol0 = nColE; | |
546 | nColE = nCols; | |
547 | } | |
548 | for(Int_t col = nCol0; col < nColE; col++){ | |
549 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
550 | calROCStatus.SetStatus(col,row,0); | |
551 | } | |
552 | } | |
553 | } | |
554 | //__________________________________________________________________ | |
555 | void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){ | |
556 | ||
557 | // | |
558 | // previous status for this half chamber | |
559 | // | |
560 | ||
561 | Int_t nCols = calROCStatus.GetNcols(); | |
562 | Int_t nCol0 = 0; | |
563 | Int_t nColE = (Int_t) nCols/2; | |
564 | if(second) { | |
565 | nCol0 = nColE; | |
566 | nColE = nCols; | |
567 | } | |
568 | for(Int_t col = nCol0; col < nColE; col++){ | |
569 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
570 | calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row)); | |
571 | } | |
572 | } | |
6ace5fe2 | 573 | } |
5029ad25 | 574 | //__________________________________________________________________ |
575 | void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){ | |
576 | ||
577 | // | |
578 | // default noise for this half chamber | |
579 | // | |
c8ab4518 | 580 | |
5029ad25 | 581 | Int_t nCols = calROCNoise.GetNcols(); |
582 | Int_t nCol0 = 0; | |
583 | Int_t nColE = (Int_t) nCols/2; | |
584 | if(second) { | |
585 | nCol0 = nColE; | |
586 | nColE = nCols; | |
587 | } | |
588 | for(Int_t col = nCol0; col < nColE; col++){ | |
589 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
590 | calROCNoise.SetValue(col,row,0.12); | |
591 | } | |
592 | } | |
593 | } | |
594 | //__________________________________________________________________ | |
595 | void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){ | |
596 | ||
597 | // | |
598 | // previous noise for this half chamber | |
599 | // | |
600 | ||
601 | Int_t nCols = calROCNoise.GetNcols(); | |
602 | Int_t nCol0 = 0; | |
603 | Int_t nColE = (Int_t) nCols/2; | |
604 | if(second) { | |
605 | nCol0 = nColE; | |
606 | nColE = nCols; | |
607 | } | |
608 | for(Int_t col = nCol0; col < nColE; col++){ | |
609 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
610 | calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row)); | |
611 | } | |
612 | } | |
613 | } | |
6ace5fe2 | 614 | //______________________________________________________________________________________________ |
8dd14606 | 615 | Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() |
6ace5fe2 | 616 | { |
e5c60cc7 | 617 | // |
6ace5fe2 | 618 | // Drift velocity DA running on monitoring servers at the DAQ |
e5c60cc7 | 619 | // |
620 | ||
8dd14606 | 621 | Bool_t error = kFALSE; |
6ace5fe2 | 622 | |
623 | // Objects for HLT and DAQ zusammen | |
3a0f6479 | 624 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
6ace5fe2 | 625 | AliCDBMetaData metaData; |
626 | metaData.SetBeamPeriod(0); | |
627 | metaData.SetResponsible("Raphaelle Bailhache"); | |
628 | metaData.SetComment("TRD calib test"); | |
3a0f6479 | 629 | // Store the infos for the detector |
6ace5fe2 | 630 | AliCDBMetaData md1; |
631 | md1.SetObjectClassName("AliTRDCalDet"); | |
632 | md1.SetResponsible("Raphaelle Bailhache"); | |
633 | md1.SetBeamPeriod(0); | |
634 | md1.SetComment("TRD calib test"); | |
3a0f6479 | 635 | // Store the infos for the pads |
6ace5fe2 | 636 | AliCDBMetaData md2; |
637 | md2.SetObjectClassName("AliTRDCalPad"); | |
638 | md2.SetResponsible("Raphaelle Bailhache"); | |
639 | md2.SetBeamPeriod(0); | |
640 | md2.SetComment("TRD calib test"); | |
3a0f6479 | 641 | |
6ace5fe2 | 642 | // Take the file from the DAQ file exchange server |
643 | TList *listdaq = GetFileSources(kDAQ,"VDRIFT"); | |
8dd14606 | 644 | if (!listdaq) { |
6ace5fe2 | 645 | Log("No list found for vdrift (DAQ)"); |
8dd14606 | 646 | return kTRUE; |
647 | } | |
648 | ||
649 | if(listdaq->GetSize() !=1){ | |
650 | Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize())); | |
651 | delete listdaq; | |
652 | return kTRUE; | |
6ace5fe2 | 653 | } |
8dd14606 | 654 | |
655 | TObjString* fileNameEntry = (TObjString*) listdaq->At(0); | |
656 | if(fileNameEntry != NULL){ | |
657 | TString fileName = GetFile(kDAQ, "VDRIFT", | |
658 | fileNameEntry->GetString().Data()); | |
659 | if(fileName.Length() ==0){ | |
660 | Log("Error retrieving the file vdrift (DAQ)"); | |
661 | delete listdaq; | |
662 | return kTRUE; | |
663 | } | |
664 | TFile *filedaq = TFile::Open(fileName); | |
665 | TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d"); | |
666 | if (histodriftvelocity) { | |
667 | ||
668 | // store as reference data | |
669 | if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
670 | Log("Error storing 2D Profile for vdrift from the DAQ"); | |
671 | error = kTRUE; | |
672 | } | |
673 | ||
674 | // analyse | |
675 | ||
676 | Log("Take the PH reference data. Now we will try to fit\n"); | |
677 | calibra->SetMinEntries(2000); // If there is less than 2000 | |
678 | calibra->AnalysePH(histodriftvelocity); | |
679 | ||
680 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
681 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
682 | Int_t nbfit = calibra->GetNumberFit(); | |
683 | Int_t nbE = calibra->GetNumberEnt(); | |
684 | ||
685 | // if enough statistics store the results | |
686 | if ((nbtg > 0) && | |
64942b85 | 687 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 688 | // create the cal objects |
64942b85 | 689 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
690 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
8dd14606 | 691 | TObjArray object = calibra->GetVectorFit(); |
692 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
693 | TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); | |
694 | object = calibra->GetVectorFit2(); | |
695 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
696 | TObject *objtime0pad = calibra->CreatePadObjectT0(); | |
697 | calibra->ResetVectorFit(); | |
698 | // store | |
699 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
700 | Log("Error storing the calibration object for the chamber vdrift (DAQ)"); | |
701 | error = kTRUE; | |
702 | } | |
703 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
704 | Log("Error storing the calibration object for the chamber t0 (DAQ)"); | |
705 | error = kTRUE; | |
706 | } | |
707 | if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
708 | Log("Error storing the calibration object for the local drift velocity (DAQ)"); | |
709 | error = kTRUE; | |
710 | } | |
711 | if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
712 | Log("Error storing the calibration object for the local time0 (DAQ)"); | |
713 | error = kTRUE; | |
714 | } | |
715 | } | |
716 | else{ | |
717 | Log("Not enough statistics for the average pulse height (DAQ)"); | |
718 | } | |
719 | } // histo here | |
720 | }// if fileNameEntry | |
721 | ||
722 | delete listdaq; | |
723 | return error; | |
724 | ||
6ace5fe2 | 725 | } |
c8ab4518 | 726 | |
6ace5fe2 | 727 | //______________________________________________________________________________________________ |
8dd14606 | 728 | Bool_t AliTRDPreprocessor::ExtractHLT() |
6ace5fe2 | 729 | { |
e5c60cc7 | 730 | // |
6ace5fe2 | 731 | // Gain, vdrift and PRF calibration running on HLT |
f5bb5557 | 732 | // return kTRUE if NULL pointer to the list |
e5c60cc7 | 733 | // |
3a0f6479 | 734 | |
8dd14606 | 735 | Bool_t error = kFALSE; |
736 | ||
6ace5fe2 | 737 | // Objects for HLT and DAQ zusammen |
738 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
739 | AliCDBMetaData metaData; | |
740 | metaData.SetBeamPeriod(0); | |
741 | metaData.SetResponsible("Raphaelle Bailhache"); | |
742 | metaData.SetComment("TRD calib test"); | |
743 | // Store the infos for the detector | |
744 | AliCDBMetaData md1; | |
745 | md1.SetObjectClassName("AliTRDCalDet"); | |
746 | md1.SetResponsible("Raphaelle Bailhache"); | |
747 | md1.SetBeamPeriod(0); | |
748 | md1.SetComment("TRD calib test"); | |
749 | // Store the infos for the pads | |
750 | AliCDBMetaData md2; | |
751 | md2.SetObjectClassName("AliTRDCalPad"); | |
752 | md2.SetResponsible("Raphaelle Bailhache"); | |
753 | md2.SetBeamPeriod(0); | |
754 | md2.SetComment("TRD calib test"); | |
6ace5fe2 | 755 | |
756 | // Take the file from the HLT file exchange server | |
757 | TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF"); | |
8dd14606 | 758 | if (!listhlt) { |
6ace5fe2 | 759 | Log("No list found for the HLT"); |
8dd14606 | 760 | return kTRUE; |
761 | } | |
762 | ||
763 | if(listhlt->GetSize() != 1) { | |
764 | Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize())); | |
765 | delete listhlt; | |
766 | return kTRUE; | |
6ace5fe2 | 767 | } |
3a0f6479 | 768 | |
8dd14606 | 769 | TObjString* fileNameEntry = (TObjString*) listhlt->At(0); |
770 | if(fileNameEntry != NULL){ | |
771 | TString fileName = GetFile(kHLT, "GAINDRIFTPRF", | |
772 | fileNameEntry->GetString().Data()); | |
773 | if(fileName.Length() ==0){ | |
774 | Log("Error retrieving the file (HLT)"); | |
775 | delete listhlt; | |
776 | return kTRUE; | |
777 | } | |
778 | // Take the file | |
779 | TFile *filehlt = TFile::Open(fileName); | |
780 | ||
8dd14606 | 781 | // gain |
782 | TH2I *histogain = (TH2I *) filehlt->Get("CH2d"); | |
783 | histogain->SetDirectory(0); | |
784 | if (histogain) { | |
785 | // store the reference data | |
786 | if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){ | |
787 | Log("Error storing 2D histos for gain"); | |
788 | error = kTRUE; | |
789 | } | |
790 | // analyse | |
791 | Log("Take the CH reference data. Now we will try to fit\n"); | |
64942b85 | 792 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit |
8dd14606 | 793 | calibra->AnalyseCH(histogain); |
794 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
795 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
796 | Int_t nbfit = calibra->GetNumberFit(); | |
797 | Int_t nbE = calibra->GetNumberEnt(); | |
798 | // enough statistics | |
799 | if ((nbtg > 0) && | |
64942b85 | 800 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 801 | // create the cal objects |
64942b85 | 802 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
8dd14606 | 803 | TObjArray object = calibra->GetVectorFit(); |
413153cb | 804 | AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object); |
8dd14606 | 805 | TObject *objgainpad = calibra->CreatePadObjectGain(); |
806 | // store them | |
807 | if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){ | |
808 | Log("Error storing the calibration object for the chamber gain"); | |
809 | error = kTRUE; | |
810 | } | |
811 | if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ | |
812 | Log("Error storing the calibration object for the local gain factor"); | |
813 | error = kTRUE; | |
814 | } | |
815 | } | |
816 | calibra->ResetVectorFit(); | |
817 | }// if histogain | |
818 | ||
8dd14606 | 819 | // vdrift |
820 | fVdriftHLT = kFALSE; | |
821 | TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d"); | |
822 | histodriftvelocity->SetDirectory(0); | |
823 | if (histodriftvelocity) { | |
824 | // store the reference data | |
825 | if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
826 | Log("Error storing 2D Profile for average pulse height (HLT)"); | |
827 | error = kTRUE; | |
828 | } | |
829 | // analyse | |
830 | Log("Take the PH reference data. Now we will try to fit\n"); | |
64942b85 | 831 | calibra->SetMinEntries(800*20); // If there is less than 20000 |
8dd14606 | 832 | calibra->AnalysePH(histodriftvelocity); |
833 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
834 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
835 | Int_t nbfit = calibra->GetNumberFit(); | |
836 | Int_t nbE = calibra->GetNumberEnt(); | |
837 | // enough statistics | |
838 | if ((nbtg > 0) && | |
64942b85 | 839 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 840 | // create the cal objects |
64942b85 | 841 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
842 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
8dd14606 | 843 | TObjArray object = calibra->GetVectorFit(); |
844 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
845 | TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); | |
846 | object = calibra->GetVectorFit2(); | |
847 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
848 | TObject *objtime0pad = calibra->CreatePadObjectT0(); | |
849 | // store them | |
850 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
851 | Log("Error storing the calibration object for the chamber vdrift (HLT)"); | |
852 | error = kTRUE; | |
853 | } | |
854 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
855 | Log("Error storing the calibration object for the chamber t0 (HLT)"); | |
856 | error = kTRUE; | |
857 | } | |
858 | if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
859 | Log("Error storing the calibration object for the local drift velocity (HLT)"); | |
860 | error = kTRUE; | |
861 | } | |
862 | if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
863 | Log("Error storing the calibration object for the local time0 (HLT)"); | |
864 | error = kTRUE; | |
865 | } | |
866 | fVdriftHLT = kTRUE; | |
867 | } | |
868 | calibra->ResetVectorFit(); | |
869 | }// if TProfile2D | |
870 | ||
8dd14606 | 871 | // prf |
872 | TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d"); | |
873 | histoprf->SetDirectory(0); | |
874 | if (histoprf) { | |
875 | // store reference data | |
876 | if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){ | |
877 | Log("Error storing the 2D Profile for Pad Response Function"); | |
878 | error = kTRUE; | |
879 | } | |
880 | // analyse | |
881 | Log("Take the PRF reference data. Now we will try to fit\n"); | |
882 | calibra->SetMinEntries(600); // If there is less than 20000 | |
883 | calibra->AnalysePRFMarianFit(histoprf); | |
884 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
885 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
886 | Int_t nbfit = calibra->GetNumberFit(); | |
887 | Int_t nbE = calibra->GetNumberEnt(); | |
888 | // enough statistics | |
889 | if ((nbtg > 0) && | |
890 | (nbfit >= 0.95*nbE)) { | |
891 | // create cal pad objects | |
892 | TObjArray object = calibra->GetVectorFit(); | |
893 | TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); | |
894 | // store them | |
895 | if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){ | |
896 | Log("Error storing the calibration object for the Pad Response Function"); | |
897 | error = kTRUE; | |
898 | } | |
899 | } | |
900 | calibra->ResetVectorFit(); | |
901 | }// if PRF | |
902 | }// if fileNameEntry | |
903 | ||
904 | delete listhlt; | |
905 | return error; | |
906 | ||
e5c60cc7 | 907 | } |
fdfee371 | 908 | |
909 | //_____________________________________________________________________________ | |
910 | UInt_t AliTRDPreprocessor::ProcessDCSConfigData() | |
911 | { | |
912 | // | |
913 | // process the configuration of FEE, PTR and GTU | |
e74c968f | 914 | // reteive XML filei(s) from the DCS FXS |
915 | // parse it/them and store TObjArrays in the CDB | |
916 | // | |
fdfee371 | 917 | // return 0 for success, otherwise: |
8b9bf3e9 | 918 | // 5 : Could not get the (SOR and EOR) or SOR file from the FXS |
8f7e6c0b | 919 | // 8 : Both files are not valid |
eaceaf51 | 920 | // 10 : SOR XML is not well-formed |
921 | // 11 : EOR XML is not well-formed | |
8f7e6c0b | 922 | // 12 : ERROR in SOR XML SAX validation: something wrong with the content |
923 | // 12 : ERROR in EOR XML SAX validation: something wrong with the content | |
924 | // 14 : ERROR while creating SOR calibration objects in the handler | |
925 | // 15 : ERROR while creating EOR calibration objects in the handler | |
926 | // 16 : ERROR while storing data in the CDB | |
fdfee371 | 927 | // |
928 | ||
eaceaf51 | 929 | Log("Processing the DCS config summary files."); |
fdfee371 | 930 | |
e74c968f | 931 | // get the XML files |
932 | Log("Requesting the 2 summaryfiles from the FXS.."); | |
8b9bf3e9 | 933 | TString xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR",""); |
934 | TString xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR",""); | |
3821ce70 | 935 | // Request EOR and SOR files from the fxs, if both are not found exit |
936 | ||
f4200e67 | 937 | Bool_t fileExistE = kTRUE, fileExistS = kTRUE; |
3821ce70 | 938 | |
8f7e6c0b | 939 | // check if the files are there |
8b9bf3e9 | 940 | if (xmlFileS.IsNull()) { |
941 | Log(Form("Warning: SOR file %s not found!", xmlFileS.Data())); | |
f4200e67 | 942 | fileExistS = kFALSE; |
8b9bf3e9 | 943 | } else Log(Form("SOR file found: %s", xmlFileS.Data())); |
f4200e67 | 944 | |
8b9bf3e9 | 945 | if (xmlFileE.IsNull()) { |
946 | Log(Form("Warning: EOR file %s not found!", xmlFileE.Data())); | |
f4200e67 | 947 | fileExistE = kFALSE; |
8b9bf3e9 | 948 | } else Log(Form("EOR file found: %s", xmlFileE.Data())); |
f4200e67 | 949 | |
950 | if (fileExistS==0 && fileExistE==0) { | |
8b9bf3e9 | 951 | Log(Form("ERROR: SOR and EOR files not found: %s and %s", xmlFileS.Data(), xmlFileE.Data())); |
f4200e67 | 952 | return 5; |
6b36d985 | 953 | } |
3821ce70 | 954 | |
8f7e6c0b | 955 | // test the files |
3821ce70 | 956 | if (fileExistS) { |
f4200e67 | 957 | Log("Checking if SOR file is valid."); |
3821ce70 | 958 | std::ifstream fileTestS; |
8b9bf3e9 | 959 | fileTestS.open(xmlFileS.Data(), std::ios_base::binary | std::ios_base::in); |
3821ce70 | 960 | if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) { |
8b9bf3e9 | 961 | Log(Form("Warning: File %s not valid!",xmlFileS.Data())); |
f4200e67 | 962 | fileExistS = kFALSE; |
8b9bf3e9 | 963 | return 5; |
3821ce70 | 964 | } |
f4200e67 | 965 | Log("Checking if SOR file is not empty."); |
3821ce70 | 966 | fileTestS.seekg(0, std::ios_base::end); |
967 | if (static_cast<int>(fileTestS.tellg()) < 2) { | |
8b9bf3e9 | 968 | Log(Form("Warning: File %s is empty!",xmlFileS.Data())); |
f4200e67 | 969 | fileExistS = kFALSE; |
8b9bf3e9 | 970 | return 5; |
3821ce70 | 971 | } |
972 | } | |
f4200e67 | 973 | |
f4200e67 | 974 | |
3821ce70 | 975 | if (fileExistE) { |
f4200e67 | 976 | Log("Checking if EOR file is valid."); |
3821ce70 | 977 | std::ifstream fileTestE; |
8b9bf3e9 | 978 | fileTestE.open(xmlFileE.Data(), std::ios_base::binary | std::ios_base::in); |
3821ce70 | 979 | if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) { |
8b9bf3e9 | 980 | Log(Form("Warning: File %s not valid!",xmlFileE.Data())); |
f4200e67 | 981 | fileExistE = kFALSE; |
3821ce70 | 982 | } |
f4200e67 | 983 | Log("Checking if EOR file is not empty."); |
3821ce70 | 984 | fileTestE.seekg(0, std::ios_base::end); |
985 | if (static_cast<int>(fileTestE.tellg()) < 2) { | |
8b9bf3e9 | 986 | Log(Form("Warning: File %s is empty!",xmlFileE.Data())); |
f4200e67 | 987 | fileExistE = kFALSE; |
3821ce70 | 988 | } |
989 | } | |
f4200e67 | 990 | |
f4200e67 | 991 | if (fileExistS==0 && fileExistE==0) { |
8f7e6c0b | 992 | Log("ERROR: Both files (SOR/EOR) are not valid!"); |
993 | return 8; | |
994 | } | |
f4200e67 | 995 | |
8f7e6c0b | 996 | Log("One or both of the tested files are valid."); |
fdfee371 | 997 | |
6b36d985 | 998 | // make a robust XML validation |
999 | TSAXParser testParser; | |
8b9bf3e9 | 1000 | if (fileExistS && testParser.ParseFile(xmlFileS.Data()) < 0 ) { |
eaceaf51 | 1001 | Log("ERROR: XML content (SOR) is not well-formed."); |
e74c968f | 1002 | return 10; |
8b9bf3e9 | 1003 | } else if (fileExistE && testParser.ParseFile(xmlFileE.Data()) < 0 ) { |
eaceaf51 | 1004 | Log("ERROR: XML content (EOR) is not well-formed."); |
1005 | return 11; | |
6b36d985 | 1006 | } |
eaceaf51 | 1007 | Log("XML contents are well-formed."); |
3821ce70 | 1008 | |
fdfee371 | 1009 | // create parser and parse |
eaceaf51 | 1010 | TSAXParser saxParserS, saxParserE; |
1011 | AliTRDSaxHandler saxHandlerS, saxHandlerE; | |
3821ce70 | 1012 | if (fileExistS) { |
1013 | saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS); | |
8b9bf3e9 | 1014 | saxParserS.ParseFile(xmlFileS.Data()); |
3821ce70 | 1015 | } |
1016 | if (fileExistE) { | |
1017 | saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE); | |
8b9bf3e9 | 1018 | saxParserE.ParseFile(xmlFileE.Data()); |
3821ce70 | 1019 | } |
8f7e6c0b | 1020 | // report errors of the parser if present |
1021 | if (fileExistS && saxParserS.GetParseCode() != 0) { | |
1022 | Log(Form("ERROR in XML file validation. SOR Parse Code: %s", saxParserS.GetParseCode())); | |
e74c968f | 1023 | return 12; |
fdfee371 | 1024 | } |
8f7e6c0b | 1025 | if (fileExistE && saxParserE.GetParseCode() != 0) { |
1026 | Log(Form("ERROR in XML file validation. EOR Parse Code: %s", saxParserE.GetParseCode())); | |
1027 | return 13; | |
fdfee371 | 1028 | } |
8f7e6c0b | 1029 | Log("XML file validation OK."); |
1030 | // report errors of the handler if present | |
1031 | if (fileExistS && saxHandlerS.GetHandlerStatus() != 0) { | |
1032 | Log(Form("ERROR while creating calibration objects. SOR Error code: %s", saxHandlerS.GetHandlerStatus())); | |
1033 | return 14; | |
1034 | } | |
1035 | if (fileExistE && saxHandlerE.GetHandlerStatus() != 0) { | |
1036 | Log(Form("ERROR while creating calibration objects. EOR Error code: %s", saxHandlerE.GetHandlerStatus())); | |
1037 | return 15; | |
1038 | } | |
1039 | Log("SAX handler reports no errors."); | |
fdfee371 | 1040 | |
eaceaf51 | 1041 | // put both objects in one TObjArray to store them |
1042 | TObjArray* fCalObjArray = new TObjArray(2); | |
1043 | fCalObjArray->SetOwner(); | |
3821ce70 | 1044 | |
1045 | // get the calibration object storing the data from the handler | |
1046 | if (fileExistS) { | |
1047 | AliTRDCalDCS* fCalDCSObjSOR = saxHandlerS.GetCalDCSObj(); | |
1048 | fCalDCSObjSOR->EvaluateGlobalParameters(); | |
8f7e6c0b | 1049 | fCalDCSObjSOR->SetRunType(GetRunType()); |
1050 | fCalDCSObjSOR->SetStartTime(GetStartTimeDCSQuery()); | |
1051 | fCalDCSObjSOR->SetEndTime(GetEndTimeDCSQuery()); | |
3821ce70 | 1052 | fCalObjArray->AddAt(fCalDCSObjSOR,0); |
8f7e6c0b | 1053 | Log("TRDCalDCS object for SOR created."); |
3821ce70 | 1054 | } |
1055 | ||
1056 | if (fileExistE) { | |
1057 | AliTRDCalDCS* fCalDCSObjEOR = saxHandlerE.GetCalDCSObj(); | |
1058 | fCalDCSObjEOR->EvaluateGlobalParameters(); | |
8f7e6c0b | 1059 | fCalDCSObjEOR->SetRunType(GetRunType()); |
1060 | fCalDCSObjEOR->SetStartTime(GetStartTimeDCSQuery()); | |
1061 | fCalDCSObjEOR->SetEndTime(GetEndTimeDCSQuery()); | |
3821ce70 | 1062 | fCalObjArray->AddAt(fCalDCSObjEOR,1); |
8f7e6c0b | 1063 | Log("TRDCalDCS object for EOR created."); |
3821ce70 | 1064 | } |
1065 | ||
fdfee371 | 1066 | // store the DCS calib data in the CDB |
1067 | AliCDBMetaData metaData1; | |
1068 | metaData1.SetBeamPeriod(0); | |
1069 | metaData1.SetResponsible("Frederick Kramer"); | |
eaceaf51 | 1070 | metaData1.SetComment("DCS configuration data in two AliTRDCalDCS objects in one TObjArray (0:SOR, 1:EOR)."); |
1071 | if (!Store("Calib", "DCS", fCalObjArray, &metaData1, 0, kTRUE)) { | |
fdfee371 | 1072 | Log("problems while storing DCS config data object"); |
8f7e6c0b | 1073 | return 16; |
6b36d985 | 1074 | } else { |
1075 | Log("DCS config data object stored."); | |
fdfee371 | 1076 | } |
1077 | ||
eaceaf51 | 1078 | //delete fCalObjArray; |
6b36d985 | 1079 | |
8f7e6c0b | 1080 | Log("SUCCESS: Processing of the DCS config summary file DONE."); |
fdfee371 | 1081 | return 0; |
a9f8ce75 | 1082 | } |