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