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