]>
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 | ||
54c85ef7 | 344 | if((ldc==0) || (ldc==1) || (ldc==2) || (ldc==9) || (ldc==10) || (ldc==11)) ldc = 1; |
345 | if((ldc==3) || (ldc==4) || (ldc==5) || (ldc==12) || (ldc==13) || (ldc==14)) ldc = 2; | |
346 | if((ldc==6) || (ldc==7) || (ldc==8) || (ldc==15) || (ldc==16) || (ldc==17)) ldc = 3; | |
347 | ||
8dd14606 | 348 | // store as reference data |
349 | TString name("PadStatus"); | |
54c85ef7 | 350 | name += ldc; |
8dd14606 | 351 | if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ |
352 | Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); | |
353 | error = kTRUE; | |
354 | } | |
289cc637 | 355 | |
8dd14606 | 356 | } // calPed |
357 | } // fileNameEntry | |
358 | ++index; | |
359 | }// while (list) | |
c8ab4518 | 360 | |
8dd14606 | 361 | Log(Form("%d elements found in the list for the pedestal",(Int_t)index)); |
362 | if(index==0){ | |
6ace5fe2 | 363 | delete listpad; |
8dd14606 | 364 | return kTRUE; |
6ace5fe2 | 365 | } |
c8ab4518 | 366 | |
8dd14606 | 367 | // |
5029ad25 | 368 | // Create pedestal |
8dd14606 | 369 | // |
c8ab4518 | 370 | |
8dd14606 | 371 | // Create Pad Status |
372 | AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus(); | |
5029ad25 | 373 | // Create Noise |
374 | //Make the AliTRDCalPad | |
375 | AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); | |
376 | //Make the AliTRDCalDet correspondant | |
377 | AliTRDCalDet *calDet = calPedSum.CreateCalDet(); | |
378 | ||
379 | // | |
380 | // Take the noise and Pad status from the previous OCDB | |
381 | // | |
382 | ||
383 | AliTRDCalPad *calPadPrevious=0; | |
384 | AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise"); | |
385 | if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject(); | |
386 | if ( calPadPrevious==NULL ) { | |
387 | Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n"); | |
388 | calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise"); | |
389 | } | |
390 | ||
391 | AliTRDCalPadStatus *calPadStatusPrevious=0; | |
392 | entry = GetFromOCDB("Calib", "PadStatus"); | |
393 | if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject(); | |
394 | if ( calPadStatusPrevious==NULL ) { | |
395 | Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n"); | |
396 | calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus"); | |
397 | for (Int_t idet=0; idet<540; ++idet) | |
398 | { | |
399 | AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet); | |
400 | for(Int_t k = 0; k < calROC->GetNchannels(); k++){ | |
401 | calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); | |
402 | } | |
403 | } | |
404 | } | |
405 | ||
406 | ||
407 | // Loop over detectors for check | |
408 | for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) { | |
409 | ||
410 | // noise | |
411 | AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det); | |
412 | AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det); | |
413 | ||
414 | // padstatus | |
415 | AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det); | |
416 | AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det); | |
417 | ||
418 | ||
419 | // loop over first half and second half chamber | |
420 | for(Int_t half = 0; half < 2; half++){ | |
421 | ||
422 | Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half); | |
37b0cf5e | 423 | //printf("There are data for the detector %d the half %d: %d\n",det,half,data); |
5029ad25 | 424 | if(!data){ |
425 | // look if data in the OCDB | |
426 | Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half); | |
427 | // if no data at all, set to default value | |
428 | if(!dataPrevious){ | |
429 | SetDefaultStatus(*calROCStatus,(Bool_t)half); | |
430 | SetDefaultNoise(*calROCNoise,(Bool_t)half); | |
431 | } | |
432 | else{ | |
433 | // if data, set to previous value | |
434 | SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half); | |
435 | SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half); | |
436 | } | |
437 | } | |
438 | } | |
439 | } | |
440 | ||
441 | // | |
442 | // Store | |
443 | // | |
444 | ||
8dd14606 | 445 | AliCDBMetaData md3; |
446 | md3.SetObjectClassName("AliTRDCalPadStatus"); | |
447 | md3.SetResponsible("Raphaelle Bailhache"); | |
448 | md3.SetBeamPeriod(1); | |
449 | md3.SetComment("TRD calib test"); | |
450 | if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){ | |
451 | Log("Error storing the pedestal"); | |
452 | delete listpad; | |
453 | return kTRUE; | |
a5e1169e | 454 | } |
289cc637 | 455 | |
289cc637 | 456 | AliCDBMetaData md4; |
457 | md4.SetObjectClassName("AliTRDCalPad"); | |
458 | md4.SetResponsible("Raphaelle Bailhache"); | |
459 | md4.SetBeamPeriod(1); | |
460 | md4.SetComment("TRD calib test"); | |
461 | if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){ | |
462 | Log("Error storing the pedestal"); | |
463 | delete listpad; | |
464 | return kTRUE; | |
465 | } | |
5029ad25 | 466 | |
289cc637 | 467 | AliCDBMetaData md5; |
468 | md5.SetObjectClassName("AliTRDCalDet"); | |
469 | md5.SetResponsible("Raphaelle Bailhache"); | |
470 | md5.SetBeamPeriod(1); | |
471 | md5.SetComment("TRD calib test"); | |
472 | if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){ | |
473 | Log("Error storing the pedestal"); | |
474 | delete listpad; | |
475 | return kTRUE; | |
476 | } | |
477 | ||
8dd14606 | 478 | delete listpad; |
479 | return error; | |
5029ad25 | 480 | |
481 | } | |
c893147d | 482 | |
5029ad25 | 483 | //__________________________________________________________________ |
c893147d | 484 | Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus |
485 | , Bool_t second) | |
486 | { | |
a5e1169e | 487 | |
5029ad25 | 488 | // |
489 | // Data for this half chamber | |
490 | // | |
491 | ||
492 | Bool_t data = kFALSE; | |
493 | Int_t nCols = calROCStatus->GetNcols(); | |
494 | Int_t nCol0 = 0; | |
495 | Int_t nColE = (Int_t) nCols/2 - 2; | |
496 | if(second) { | |
497 | nCol0 = nColE + 4; | |
498 | nColE = nCols; | |
499 | } | |
f2a468d7 | 500 | |
501 | Int_t totalnumberofpads = 0; | |
502 | Int_t totalnumberofdata = 0; | |
503 | ||
5029ad25 | 504 | for(Int_t col = nCol0; col < nColE; col++){ |
505 | for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){ | |
f2a468d7 | 506 | totalnumberofpads++; |
5029ad25 | 507 | //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row)); |
37b0cf5e | 508 | if(!calROCStatus->GetStatus(col,row)) { |
5029ad25 | 509 | data = kTRUE; |
f2a468d7 | 510 | totalnumberofdata++; |
5029ad25 | 511 | } |
512 | } | |
5029ad25 | 513 | } |
f2a468d7 | 514 | if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE; |
5029ad25 | 515 | |
516 | return data; | |
517 | ||
518 | } | |
519 | //__________________________________________________________________ | |
520 | void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){ | |
521 | ||
522 | // | |
523 | // default status for this half chamber | |
524 | // | |
525 | ||
526 | Int_t nCols = calROCStatus.GetNcols(); | |
527 | Int_t nCol0 = 0; | |
528 | Int_t nColE = (Int_t) nCols/2; | |
529 | if(second) { | |
530 | nCol0 = nColE; | |
531 | nColE = nCols; | |
532 | } | |
533 | for(Int_t col = nCol0; col < nColE; col++){ | |
534 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
535 | calROCStatus.SetStatus(col,row,0); | |
536 | } | |
537 | } | |
538 | } | |
539 | //__________________________________________________________________ | |
540 | void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){ | |
541 | ||
542 | // | |
543 | // previous status for this half chamber | |
544 | // | |
545 | ||
546 | Int_t nCols = calROCStatus.GetNcols(); | |
547 | Int_t nCol0 = 0; | |
548 | Int_t nColE = (Int_t) nCols/2; | |
549 | if(second) { | |
550 | nCol0 = nColE; | |
551 | nColE = nCols; | |
552 | } | |
553 | for(Int_t col = nCol0; col < nColE; col++){ | |
554 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
555 | calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row)); | |
556 | } | |
557 | } | |
6ace5fe2 | 558 | } |
5029ad25 | 559 | //__________________________________________________________________ |
560 | void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){ | |
561 | ||
562 | // | |
563 | // default noise for this half chamber | |
564 | // | |
c8ab4518 | 565 | |
5029ad25 | 566 | Int_t nCols = calROCNoise.GetNcols(); |
567 | Int_t nCol0 = 0; | |
568 | Int_t nColE = (Int_t) nCols/2; | |
569 | if(second) { | |
570 | nCol0 = nColE; | |
571 | nColE = nCols; | |
572 | } | |
573 | for(Int_t col = nCol0; col < nColE; col++){ | |
574 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
575 | calROCNoise.SetValue(col,row,0.12); | |
576 | } | |
577 | } | |
578 | } | |
579 | //__________________________________________________________________ | |
580 | void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){ | |
581 | ||
582 | // | |
583 | // previous noise for this half chamber | |
584 | // | |
585 | ||
586 | Int_t nCols = calROCNoise.GetNcols(); | |
587 | Int_t nCol0 = 0; | |
588 | Int_t nColE = (Int_t) nCols/2; | |
589 | if(second) { | |
590 | nCol0 = nColE; | |
591 | nColE = nCols; | |
592 | } | |
593 | for(Int_t col = nCol0; col < nColE; col++){ | |
594 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
595 | calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row)); | |
596 | } | |
597 | } | |
598 | } | |
6ace5fe2 | 599 | //______________________________________________________________________________________________ |
8dd14606 | 600 | Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() |
6ace5fe2 | 601 | { |
e5c60cc7 | 602 | // |
6ace5fe2 | 603 | // Drift velocity DA running on monitoring servers at the DAQ |
e5c60cc7 | 604 | // |
605 | ||
8dd14606 | 606 | Bool_t error = kFALSE; |
6ace5fe2 | 607 | |
608 | // Objects for HLT and DAQ zusammen | |
3a0f6479 | 609 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
6ace5fe2 | 610 | AliCDBMetaData metaData; |
611 | metaData.SetBeamPeriod(0); | |
612 | metaData.SetResponsible("Raphaelle Bailhache"); | |
613 | metaData.SetComment("TRD calib test"); | |
3a0f6479 | 614 | // Store the infos for the detector |
6ace5fe2 | 615 | AliCDBMetaData md1; |
616 | md1.SetObjectClassName("AliTRDCalDet"); | |
617 | md1.SetResponsible("Raphaelle Bailhache"); | |
618 | md1.SetBeamPeriod(0); | |
619 | md1.SetComment("TRD calib test"); | |
3a0f6479 | 620 | // Store the infos for the pads |
6ace5fe2 | 621 | AliCDBMetaData md2; |
622 | md2.SetObjectClassName("AliTRDCalPad"); | |
623 | md2.SetResponsible("Raphaelle Bailhache"); | |
624 | md2.SetBeamPeriod(0); | |
625 | md2.SetComment("TRD calib test"); | |
3a0f6479 | 626 | |
6ace5fe2 | 627 | // Take the file from the DAQ file exchange server |
628 | TList *listdaq = GetFileSources(kDAQ,"VDRIFT"); | |
8dd14606 | 629 | if (!listdaq) { |
6ace5fe2 | 630 | Log("No list found for vdrift (DAQ)"); |
8dd14606 | 631 | return kTRUE; |
632 | } | |
633 | ||
634 | if(listdaq->GetSize() !=1){ | |
635 | Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize())); | |
636 | delete listdaq; | |
637 | return kTRUE; | |
6ace5fe2 | 638 | } |
8dd14606 | 639 | |
640 | TObjString* fileNameEntry = (TObjString*) listdaq->At(0); | |
641 | if(fileNameEntry != NULL){ | |
642 | TString fileName = GetFile(kDAQ, "VDRIFT", | |
643 | fileNameEntry->GetString().Data()); | |
644 | if(fileName.Length() ==0){ | |
645 | Log("Error retrieving the file vdrift (DAQ)"); | |
646 | delete listdaq; | |
647 | return kTRUE; | |
648 | } | |
649 | TFile *filedaq = TFile::Open(fileName); | |
650 | TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d"); | |
651 | if (histodriftvelocity) { | |
652 | ||
653 | // store as reference data | |
654 | if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
655 | Log("Error storing 2D Profile for vdrift from the DAQ"); | |
656 | error = kTRUE; | |
657 | } | |
658 | ||
659 | // analyse | |
660 | ||
661 | Log("Take the PH reference data. Now we will try to fit\n"); | |
662 | calibra->SetMinEntries(2000); // If there is less than 2000 | |
663 | calibra->AnalysePH(histodriftvelocity); | |
664 | ||
665 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
666 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
667 | Int_t nbfit = calibra->GetNumberFit(); | |
668 | Int_t nbE = calibra->GetNumberEnt(); | |
669 | ||
670 | // if enough statistics store the results | |
671 | if ((nbtg > 0) && | |
64942b85 | 672 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 673 | // create the cal objects |
64942b85 | 674 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
675 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
8dd14606 | 676 | TObjArray object = calibra->GetVectorFit(); |
677 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
678 | TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); | |
679 | object = calibra->GetVectorFit2(); | |
680 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
681 | TObject *objtime0pad = calibra->CreatePadObjectT0(); | |
682 | calibra->ResetVectorFit(); | |
683 | // store | |
684 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
685 | Log("Error storing the calibration object for the chamber vdrift (DAQ)"); | |
686 | error = kTRUE; | |
687 | } | |
688 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
689 | Log("Error storing the calibration object for the chamber t0 (DAQ)"); | |
690 | error = kTRUE; | |
691 | } | |
692 | if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
693 | Log("Error storing the calibration object for the local drift velocity (DAQ)"); | |
694 | error = kTRUE; | |
695 | } | |
696 | if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
697 | Log("Error storing the calibration object for the local time0 (DAQ)"); | |
698 | error = kTRUE; | |
699 | } | |
700 | } | |
701 | else{ | |
702 | Log("Not enough statistics for the average pulse height (DAQ)"); | |
703 | } | |
704 | } // histo here | |
705 | }// if fileNameEntry | |
706 | ||
707 | delete listdaq; | |
708 | return error; | |
709 | ||
6ace5fe2 | 710 | } |
c8ab4518 | 711 | |
6ace5fe2 | 712 | //______________________________________________________________________________________________ |
8dd14606 | 713 | Bool_t AliTRDPreprocessor::ExtractHLT() |
6ace5fe2 | 714 | { |
e5c60cc7 | 715 | // |
6ace5fe2 | 716 | // Gain, vdrift and PRF calibration running on HLT |
f5bb5557 | 717 | // return kTRUE if NULL pointer to the list |
e5c60cc7 | 718 | // |
3a0f6479 | 719 | |
8dd14606 | 720 | Bool_t error = kFALSE; |
721 | ||
6ace5fe2 | 722 | // Objects for HLT and DAQ zusammen |
723 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
724 | AliCDBMetaData metaData; | |
725 | metaData.SetBeamPeriod(0); | |
726 | metaData.SetResponsible("Raphaelle Bailhache"); | |
727 | metaData.SetComment("TRD calib test"); | |
728 | // Store the infos for the detector | |
729 | AliCDBMetaData md1; | |
730 | md1.SetObjectClassName("AliTRDCalDet"); | |
731 | md1.SetResponsible("Raphaelle Bailhache"); | |
732 | md1.SetBeamPeriod(0); | |
733 | md1.SetComment("TRD calib test"); | |
734 | // Store the infos for the pads | |
735 | AliCDBMetaData md2; | |
736 | md2.SetObjectClassName("AliTRDCalPad"); | |
737 | md2.SetResponsible("Raphaelle Bailhache"); | |
738 | md2.SetBeamPeriod(0); | |
739 | md2.SetComment("TRD calib test"); | |
6ace5fe2 | 740 | |
741 | // Take the file from the HLT file exchange server | |
742 | TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF"); | |
8dd14606 | 743 | if (!listhlt) { |
6ace5fe2 | 744 | Log("No list found for the HLT"); |
8dd14606 | 745 | return kTRUE; |
746 | } | |
747 | ||
748 | if(listhlt->GetSize() != 1) { | |
749 | Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize())); | |
750 | delete listhlt; | |
751 | return kTRUE; | |
6ace5fe2 | 752 | } |
3a0f6479 | 753 | |
8dd14606 | 754 | TObjString* fileNameEntry = (TObjString*) listhlt->At(0); |
755 | if(fileNameEntry != NULL){ | |
756 | TString fileName = GetFile(kHLT, "GAINDRIFTPRF", | |
757 | fileNameEntry->GetString().Data()); | |
758 | if(fileName.Length() ==0){ | |
759 | Log("Error retrieving the file (HLT)"); | |
760 | delete listhlt; | |
761 | return kTRUE; | |
762 | } | |
763 | // Take the file | |
764 | TFile *filehlt = TFile::Open(fileName); | |
765 | ||
8dd14606 | 766 | // gain |
767 | TH2I *histogain = (TH2I *) filehlt->Get("CH2d"); | |
768 | histogain->SetDirectory(0); | |
769 | if (histogain) { | |
770 | // store the reference data | |
771 | if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){ | |
772 | Log("Error storing 2D histos for gain"); | |
773 | error = kTRUE; | |
774 | } | |
775 | // analyse | |
776 | Log("Take the CH reference data. Now we will try to fit\n"); | |
64942b85 | 777 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit |
8dd14606 | 778 | calibra->AnalyseCH(histogain); |
779 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
780 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
781 | Int_t nbfit = calibra->GetNumberFit(); | |
782 | Int_t nbE = calibra->GetNumberEnt(); | |
783 | // enough statistics | |
784 | if ((nbtg > 0) && | |
64942b85 | 785 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 786 | // create the cal objects |
64942b85 | 787 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
8dd14606 | 788 | TObjArray object = calibra->GetVectorFit(); |
413153cb | 789 | AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object); |
8dd14606 | 790 | TObject *objgainpad = calibra->CreatePadObjectGain(); |
791 | // store them | |
792 | if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){ | |
793 | Log("Error storing the calibration object for the chamber gain"); | |
794 | error = kTRUE; | |
795 | } | |
796 | if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ | |
797 | Log("Error storing the calibration object for the local gain factor"); | |
798 | error = kTRUE; | |
799 | } | |
800 | } | |
801 | calibra->ResetVectorFit(); | |
802 | }// if histogain | |
803 | ||
8dd14606 | 804 | // vdrift |
805 | fVdriftHLT = kFALSE; | |
806 | TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d"); | |
807 | histodriftvelocity->SetDirectory(0); | |
808 | if (histodriftvelocity) { | |
809 | // store the reference data | |
810 | if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
811 | Log("Error storing 2D Profile for average pulse height (HLT)"); | |
812 | error = kTRUE; | |
813 | } | |
814 | // analyse | |
815 | Log("Take the PH reference data. Now we will try to fit\n"); | |
64942b85 | 816 | calibra->SetMinEntries(800*20); // If there is less than 20000 |
8dd14606 | 817 | calibra->AnalysePH(histodriftvelocity); |
818 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
819 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
820 | Int_t nbfit = calibra->GetNumberFit(); | |
821 | Int_t nbE = calibra->GetNumberEnt(); | |
822 | // enough statistics | |
823 | if ((nbtg > 0) && | |
64942b85 | 824 | (nbfit >= 0.5*nbE)) { |
8dd14606 | 825 | // create the cal objects |
64942b85 | 826 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
827 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); | |
8dd14606 | 828 | TObjArray object = calibra->GetVectorFit(); |
829 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
830 | TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); | |
831 | object = calibra->GetVectorFit2(); | |
832 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
833 | TObject *objtime0pad = calibra->CreatePadObjectT0(); | |
834 | // store them | |
835 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
836 | Log("Error storing the calibration object for the chamber vdrift (HLT)"); | |
837 | error = kTRUE; | |
838 | } | |
839 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
840 | Log("Error storing the calibration object for the chamber t0 (HLT)"); | |
841 | error = kTRUE; | |
842 | } | |
843 | if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
844 | Log("Error storing the calibration object for the local drift velocity (HLT)"); | |
845 | error = kTRUE; | |
846 | } | |
847 | if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
848 | Log("Error storing the calibration object for the local time0 (HLT)"); | |
849 | error = kTRUE; | |
850 | } | |
851 | fVdriftHLT = kTRUE; | |
852 | } | |
853 | calibra->ResetVectorFit(); | |
854 | }// if TProfile2D | |
855 | ||
8dd14606 | 856 | // prf |
857 | TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d"); | |
858 | histoprf->SetDirectory(0); | |
859 | if (histoprf) { | |
860 | // store reference data | |
861 | if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){ | |
862 | Log("Error storing the 2D Profile for Pad Response Function"); | |
863 | error = kTRUE; | |
864 | } | |
865 | // analyse | |
866 | Log("Take the PRF reference data. Now we will try to fit\n"); | |
867 | calibra->SetMinEntries(600); // If there is less than 20000 | |
868 | calibra->AnalysePRFMarianFit(histoprf); | |
869 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
870 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
871 | Int_t nbfit = calibra->GetNumberFit(); | |
872 | Int_t nbE = calibra->GetNumberEnt(); | |
873 | // enough statistics | |
874 | if ((nbtg > 0) && | |
875 | (nbfit >= 0.95*nbE)) { | |
876 | // create cal pad objects | |
877 | TObjArray object = calibra->GetVectorFit(); | |
878 | TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); | |
879 | // store them | |
880 | if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){ | |
881 | Log("Error storing the calibration object for the Pad Response Function"); | |
882 | error = kTRUE; | |
883 | } | |
884 | } | |
885 | calibra->ResetVectorFit(); | |
886 | }// if PRF | |
887 | }// if fileNameEntry | |
888 | ||
889 | delete listhlt; | |
890 | return error; | |
891 | ||
e5c60cc7 | 892 | } |
fdfee371 | 893 | |
894 | //_____________________________________________________________________________ | |
895 | UInt_t AliTRDPreprocessor::ProcessDCSConfigData() | |
896 | { | |
897 | // | |
898 | // process the configuration of FEE, PTR and GTU | |
e74c968f | 899 | // reteive XML filei(s) from the DCS FXS |
900 | // parse it/them and store TObjArrays in the CDB | |
901 | // | |
fdfee371 | 902 | // return 0 for success, otherwise: |
e74c968f | 903 | // 5 : could not get the SOR file from the FXS |
904 | // 6 : could not get the EOR file from the FXS | |
905 | // 7 : | |
eaceaf51 | 906 | // 8 : something wrong with the SOR file |
907 | // 9 : something wrong with the EOR file | |
908 | // 10 : SOR XML is not well-formed | |
909 | // 11 : EOR XML is not well-formed | |
910 | // 12 : ERROR in XML SAX validation: something wrong with the content | |
e74c968f | 911 | // 13 : |
912 | // 14 : ERROR while creating calibration objects in the handler | |
913 | // 15 : error while storing data in the CDB | |
fdfee371 | 914 | // |
915 | ||
eaceaf51 | 916 | Log("Processing the DCS config summary files."); |
fdfee371 | 917 | |
e74c968f | 918 | // get the XML files |
919 | Log("Requesting the 2 summaryfiles from the FXS.."); | |
eaceaf51 | 920 | const char *xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR",""); |
921 | const char *xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR",""); | |
e74c968f | 922 | // for the time being just request BOTH files from the FXS |
923 | // THEN it can be created online (otherwise the FXS would be messed up) | |
924 | // the next step is to actually read BOTH files and store their informations | |
925 | if (xmlFileS == NULL) { | |
926 | Log(Form("ERROR: SOR File %s not found!",xmlFileS)); | |
6b36d985 | 927 | return 5; |
eaceaf51 | 928 | } else if (xmlFileE == NULL) { |
929 | Log(Form("ERROR: EOR File %s not found!",xmlFileE)); | |
e74c968f | 930 | return 6; |
931 | } else { | |
eaceaf51 | 932 | Log(Form("Both Files (%s and %s) found.",xmlFileS,xmlFileE)); |
6b36d985 | 933 | } |
e74c968f | 934 | |
eaceaf51 | 935 | // test the files |
936 | std::ifstream fileTestS, fileTestE; | |
937 | fileTestS.open(xmlFileS, std::ios_base::binary | std::ios_base::in); | |
938 | fileTestE.open(xmlFileE, std::ios_base::binary | std::ios_base::in); | |
939 | if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) { | |
940 | Log(Form("ERROR: File %s not valid!",xmlFileS)); | |
e74c968f | 941 | return 8; |
6b36d985 | 942 | } |
eaceaf51 | 943 | if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) { |
944 | Log(Form("ERROR: File %s not valid!",xmlFileE)); | |
945 | return 9; | |
946 | } | |
947 | fileTestS.seekg(0, std::ios_base::end); | |
948 | fileTestE.seekg(0, std::ios_base::end); | |
949 | if (static_cast<int>(fileTestS.tellg()) < 2) { | |
950 | Log(Form("ERROR: File %s is empty!",xmlFileS)); | |
e74c968f | 951 | return 8; |
fdfee371 | 952 | } |
eaceaf51 | 953 | if (static_cast<int>(fileTestE.tellg()) < 2) { |
954 | Log(Form("ERROR: File %s is empty!",xmlFileE)); | |
955 | return 9; | |
956 | } | |
957 | Log("Files are tested valid."); | |
fdfee371 | 958 | |
6b36d985 | 959 | // make a robust XML validation |
960 | TSAXParser testParser; | |
eaceaf51 | 961 | if (testParser.ParseFile(xmlFileS) < 0 ) { |
962 | Log("ERROR: XML content (SOR) is not well-formed."); | |
e74c968f | 963 | return 10; |
eaceaf51 | 964 | } else if (testParser.ParseFile(xmlFileE) < 0 ) { |
965 | Log("ERROR: XML content (EOR) is not well-formed."); | |
966 | return 11; | |
6b36d985 | 967 | } |
eaceaf51 | 968 | Log("XML contents are well-formed."); |
969 | ||
fdfee371 | 970 | // create parser and parse |
eaceaf51 | 971 | TSAXParser saxParserS, saxParserE; |
972 | AliTRDSaxHandler saxHandlerS, saxHandlerE; | |
973 | saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS); | |
974 | saxParserS.ParseFile(xmlFileS); | |
975 | saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE); | |
976 | saxParserE.ParseFile(xmlFileE); | |
fdfee371 | 977 | |
978 | // report errors if present | |
eaceaf51 | 979 | if ((saxParserS.GetParseCode() == 0) && (saxParserE.GetParseCode() == 0)) { |
980 | Log("XML file validation OK."); | |
fdfee371 | 981 | } else { |
eaceaf51 | 982 | Log(Form("ERROR in XML file validation. Parsecodes: SOR: %s, EOR: %s", saxParserS.GetParseCode(), saxParserE.GetParseCode())); |
e74c968f | 983 | return 12; |
fdfee371 | 984 | } |
eaceaf51 | 985 | if ((saxHandlerS.GetHandlerStatus() == 0) && (saxHandlerE.GetHandlerStatus() == 0)) { |
6b36d985 | 986 | Log("SAX handler reports no errors."); |
987 | } else { | |
eaceaf51 | 988 | Log(Form("ERROR while creating calibration objects. Error codes: SOR: %s, EOR: %s", saxHandlerS.GetHandlerStatus(), saxHandlerE.GetHandlerStatus())); |
e74c968f | 989 | return 14; |
fdfee371 | 990 | } |
991 | ||
992 | // get the calibration object storing the data from the handler | |
eaceaf51 | 993 | AliTRDCalDCS* fCalDCSObjSOR = saxHandlerS.GetCalDCSObj(); |
994 | AliTRDCalDCS* fCalDCSObjEOR = saxHandlerE.GetCalDCSObj(); | |
995 | fCalDCSObjSOR->EvaluateGlobalParameters(); | |
996 | fCalDCSObjEOR->EvaluateGlobalParameters(); | |
997 | ||
998 | // put both objects in one TObjArray to store them | |
999 | TObjArray* fCalObjArray = new TObjArray(2); | |
1000 | fCalObjArray->SetOwner(); | |
1001 | fCalObjArray->AddAt(fCalDCSObjSOR,0); | |
1002 | fCalObjArray->AddAt(fCalDCSObjEOR,1); | |
6af58a56 | 1003 | |
fdfee371 | 1004 | // store the DCS calib data in the CDB |
1005 | AliCDBMetaData metaData1; | |
1006 | metaData1.SetBeamPeriod(0); | |
1007 | metaData1.SetResponsible("Frederick Kramer"); | |
eaceaf51 | 1008 | metaData1.SetComment("DCS configuration data in two AliTRDCalDCS objects in one TObjArray (0:SOR, 1:EOR)."); |
1009 | if (!Store("Calib", "DCS", fCalObjArray, &metaData1, 0, kTRUE)) { | |
fdfee371 | 1010 | Log("problems while storing DCS config data object"); |
e74c968f | 1011 | return 15; |
6b36d985 | 1012 | } else { |
1013 | Log("DCS config data object stored."); | |
fdfee371 | 1014 | } |
1015 | ||
eaceaf51 | 1016 | //delete fCalObjArray; |
6b36d985 | 1017 | |
eaceaf51 | 1018 | Log("Processing of the DCS config summary file DONE."); |
fdfee371 | 1019 | return 0; |
1020 | } |