Take out the XML parser for the time being
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessor.cxx
CommitLineData
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// //
28// Author: //
29// R. Bailhache (R.Bailhache@gsi.de) //
cd4fc278 30// W. Monange (w.monange@gsi.de) //
ec55623f 31// //
32////////////////////////////////////////////////////////////////////////////
e5c60cc7 33
e5c60cc7 34#include <TFile.h>
35#include <TProfile2D.h>
e5c60cc7 36#include <TStopwatch.h>
37#include <TObjString.h>
38#include <TString.h>
39#include <TList.h>
40#include <TCollection.h>
3d8c1d84 41//#include <TSAXParser.h>
e5c60cc7 42
43#include "AliCDBMetaData.h"
e5c60cc7 44#include "AliLog.h"
45
c8ab4518 46#include "AliTRDPreprocessor.h"
3a0f6479 47#include "AliTRDSensorArray.h"
67c25e8d 48#include "AliTRDCalibraFit.h"
49#include "AliTRDCalibraMode.h"
3a0f6479 50#include "AliTRDCalibPadStatus.h"
3d8c1d84 51//#include "AliTRDSaxHandler.h"
52
3a0f6479 53#include "Cal/AliTRDCalDet.h"
54#include "Cal/AliTRDCalPadStatus.h"
197b835e 55#include "Cal/AliTRDCalDCS.h"
e5c60cc7 56
e5c60cc7 57ClassImp(AliTRDPreprocessor)
58
59//______________________________________________________________________________________________
ec55623f 60AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle)
c8ab4518 61 :AliPreprocessor("TRD", shuttle)
62 ,fVdriftHLT(0)
e5c60cc7 63{
64 //
65 // Constructor
66 //
67
2efb65b5 68 AddRunType("PHYSICS");
69 AddRunType("STANDALONE");
70 AddRunType("PEDESTAL");
71
e5c60cc7 72}
73
74//______________________________________________________________________________________________
75AliTRDPreprocessor::~AliTRDPreprocessor()
76{
77 //
78 // Destructor
79 //
80
81}
82
83//______________________________________________________________________________________________
84void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
85{
86 //
87 // Initialization routine for the TRD preprocessor
88 //
89
90 AliPreprocessor::Initialize(run,startTime,endTime);
91
92}
93
94//______________________________________________________________________________________________
a5e1169e 95UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
e5c60cc7 96{
a5e1169e 97 //
98 // Process DCS and calibration part for HLT
99 //
100
8dd14606 101 TString runType = GetRunType();
102 Log(Form("runtype %s\n",runType.Data()));
197b835e 103
104 // always process the configuration data
105 Int_t resultDCSC = ProcessDCSConfigData();
106 // if there was an error, return with its code
107 if (resultDCSC != 0) return resultDCSC;
108
b70c68da 109 if (runType=="PEDESTAL"){
8dd14606 110 if(ExtractPedestals()) return 1;
111 return 0;
112 }
a5e1169e 113
b70c68da 114 if ((runType=="PHYSICS") || (runType=="STANDALONE")){
f5bb5557 115 // DCS
116 if(ProcessDCS(dcsAliasMap)) return 1;
117 // HLT if On
118 //TString runPar = GetRunParameter("HLTStatus");
8dd14606 119 //if(runPar=="1") {
f5bb5557 120 if(GetHLTStatus()) {
121 if(ExtractHLT()) return 1;
122 }
123 // DAQ if HLT failed
8dd14606 124 if(!fVdriftHLT) {
125 if(ExtractDriftVelocityDAQ()) return 1;
126 }
6ace5fe2 127 }
8dd14606 128
129 return 0;
6ace5fe2 130
f5bb5557 131}
c8ab4518 132
f5bb5557 133//______________________________________________________________________________
134Bool_t AliTRDPreprocessor::ProcessDCS()
135{
c8ab4518 136 //
137 // Default process DCS method
138 //
f5bb5557 139
140 TString runType = GetRunType();
b70c68da 141 if ((runType == "PHYSICS") || (runType == "STANDALONE")) {
c8ab4518 142 return kTRUE;
143 }
f5bb5557 144 return kFALSE;
145
6ace5fe2 146}
147
6ace5fe2 148//______________________________________________________________________________
c8ab4518 149Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap)
6ace5fe2 150{
c8ab4518 151 //
152 // Process DCS method
153 //
154
155 Bool_t error = kFALSE;
6ace5fe2 156
a5e1169e 157 AliCDBMetaData metaData;
158 metaData.SetBeamPeriod(0);
159 metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
160 metaData.SetComment("TRD calib test");
c8ab4518 161
162 Log("****** DCS ******\n");
cd4fc278 163
8dd14606 164 TObjArray * list=AliTRDSensorArray::GetList ();
cd4fc278 165
166 if (list == 0x0) {
6ace5fe2 167 Log ("Error during AliTRDSensorArray::GetList");
168 Log ("DCS will not be processing");
8dd14606 169 return kTRUE;
6ace5fe2 170 }
171
172 Int_t nEntries = list->GetEntries ();
173 Log (Form ("%d alias loaded", nEntries));
cd4fc278 174
6ace5fe2 175 Bool_t * results=new Bool_t [nEntries];
176 Int_t * nGraph=new Int_t [nEntries];
cd4fc278 177
6ace5fe2 178 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
cd4fc278 179
6ace5fe2 180 AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
cd4fc278 181
6ace5fe2 182 oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
183 oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
cd4fc278 184
c8ab4518 185 Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
cd4fc278 186
6ace5fe2 187 TMap * map;
188
189 map=oneTRDDCS->ExtractDCS (dcsAliasMap);
cd4fc278 190
6ace5fe2 191 nGraph [iAlias] = map->GetEntries ();
cd4fc278 192
6ace5fe2 193 if (nGraph [iAlias] == 0) {
194 Log("No TGraph for this dcsDatapointAlias : not stored");
195 results [iAlias] = kFALSE;
2ff01398 196 error = kTRUE;
6ace5fe2 197 continue;
198 }
cd4fc278 199
6ace5fe2 200 oneTRDDCS->SetGraph(map);
201 results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kTRUE);
202 delete map;
203
204 //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData);
205
6ace5fe2 206 if (!results[iAlias]) {
8dd14606 207 AliError("Problem during StoreRef DCS");
208 error=kTRUE;
6ace5fe2 209 }
210
6ace5fe2 211 //BEGIN TEST (should not be removed ...)
212 /*
213 oneTRDDCS->ClearGraph();
214 oneTRDDCS->ClearFit();
215 oneTRDDCS->SetDiffCut2 (0.1);
216 map=oneTRDDCS->ExtractDCS (dcsAliasMap);
217 oneTRDDCS->SetGraph (map);
218 Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE);
219 delete map;
220
221
222 if(iAlias==1 || iAlias==19) continue;
223
224 oneTRDDCS->ClearGraph();
225 oneTRDDCS->ClearFit();
226 oneTRDDCS->SetDiffCut2(0);
227 map=oneTRDDCS->ExtractDCS(dcsAliasMap);
228 oneTRDDCS->MakeSplineFit(map);
229 Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE);
230 delete map;
231
232
233 oneTRDDCS->ClearGraph();
234 oneTRDDCS->ClearFit();
235 oneTRDDCS->SetDiffCut2 (0.1);
236 map=oneTRDDCS->ExtractDCS (dcsAliasMap);
237 oneTRDDCS->MakeSplineFit(map);
238 Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE);
239 delete map;
240 */
241 //END TEST
242
6ace5fe2 243 }
cd4fc278 244
6ace5fe2 245 Log (" Summury of DCS :\n");
246 Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph"));
247 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
248 AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
249 Log (Form ("%30s %10s %4d",
250 oneTRDDCS->GetStoreName ().Data (),
251 results[iAlias] ? "ok" : "X",
252 nGraph [iAlias]));
253 }
254 Log ("*********** End of DCS **********");
255
256 delete results;
257 delete nGraph;
258
8dd14606 259 return error;
c8ab4518 260
6ace5fe2 261}
262
263//______________________________________________________________________________________________
8dd14606 264Bool_t AliTRDPreprocessor::ExtractPedestals()
6ace5fe2 265{
266 //
267 // Pedestal running on LDCs at the DAQ
268 //
8dd14606 269
270 Bool_t error = kFALSE;
6ace5fe2 271
272 // Init a AliTRDCalibPadStatus
273 AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
274
275 AliCDBMetaData metaData;
276 metaData.SetBeamPeriod(0);
277 metaData.SetResponsible("Raphaelle Bailhache");
278 metaData.SetComment("TRD calib test");
279
280 // Sum the contributions of the LDCs
281 TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
8dd14606 282 if (!listpad) {
283 Log("No list found for the PEDESTRAL Run");
284 return kTRUE;
285 }
286
c8ab4518 287 // loop through all files from LDCs
8dd14606 288 UInt_t index = 0;
289 while (listpad->At(index)!=NULL) {
290 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
291 if (fileNameEntry != NULL)
292 {
6ace5fe2 293 TString fileName = GetFile(kDAQ, "PADSTATUS",
294 fileNameEntry->GetString().Data());
8dd14606 295 if(fileName.Length() ==0){
6ace5fe2 296 Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
8dd14606 297 delete listpad;
298 return kTRUE;
cd4fc278 299 }
8dd14606 300
301 TFile *f = TFile::Open(fileName);
302 AliTRDCalibPadStatus *calPed;
303 f->GetObject("calibpadstatus",calPed);
304
305 if(calPed){
306
289cc637 307 Int_t sm = -1;
308
8dd14606 309 // analyse
289cc637 310 //calPed->AnalyseHisto();
311
312 // Add to the calPedSum
313 for (Int_t idet=0; idet<540; idet++) {
314 AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE);
315 if ( rocMean ) {
316 calPedSum.SetCalRocMean(rocMean,idet);
317 sm = (Int_t) (idet / 30);
318 }
319 AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
320 if ( rocRMS ) {
321 calPedSum.SetCalRocRMS(rocRMS,idet);
322 }
e4db522f 323 AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE);
324 if ( rocMeand ) {
325 calPedSum.SetCalRocMeand(rocMeand,idet);
326 }
327 AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE);
328 if ( rocRMSd ) {
329 calPedSum.SetCalRocRMSd(rocRMSd,idet);
330 }
289cc637 331 }// det loop
332
8dd14606 333 // store as reference data
334 TString name("PadStatus");
289cc637 335 name += sm;
8dd14606 336 if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
337 Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
338 error = kTRUE;
339 }
289cc637 340
8dd14606 341 } // calPed
342 } // fileNameEntry
343 ++index;
344 }// while (list)
c8ab4518 345
8dd14606 346 Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
347 if(index==0){
6ace5fe2 348 delete listpad;
8dd14606 349 return kTRUE;
6ace5fe2 350 }
c8ab4518 351
8dd14606 352 //
353 // Store pedestal entry to OCDB
354 //
c8ab4518 355
8dd14606 356 // Create Pad Status
357 AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
358 AliCDBMetaData md3;
359 md3.SetObjectClassName("AliTRDCalPadStatus");
360 md3.SetResponsible("Raphaelle Bailhache");
361 md3.SetBeamPeriod(1);
362 md3.SetComment("TRD calib test");
363 if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){
364 Log("Error storing the pedestal");
365 delete listpad;
366 return kTRUE;
a5e1169e 367 }
289cc637 368
369 // Create Noise
370 //Make the AliTRDCalPad
371 AliTRDCalPad *calPad2 = calPedSum.CreateCalPad();
372 AliCDBMetaData md4;
373 md4.SetObjectClassName("AliTRDCalPad");
374 md4.SetResponsible("Raphaelle Bailhache");
375 md4.SetBeamPeriod(1);
376 md4.SetComment("TRD calib test");
377 if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){
378 Log("Error storing the pedestal");
379 delete listpad;
380 return kTRUE;
381 }
382 //Make the AliTRDCalDet correspondant
383 AliTRDCalDet *calDet = calPedSum.CreateCalDet();
384 AliCDBMetaData md5;
385 md5.SetObjectClassName("AliTRDCalDet");
386 md5.SetResponsible("Raphaelle Bailhache");
387 md5.SetBeamPeriod(1);
388 md5.SetComment("TRD calib test");
389 if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){
390 Log("Error storing the pedestal");
391 delete listpad;
392 return kTRUE;
393 }
394
8dd14606 395 delete listpad;
396 return error;
a5e1169e 397
6ace5fe2 398}
c8ab4518 399
6ace5fe2 400//______________________________________________________________________________________________
8dd14606 401Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
6ace5fe2 402{
e5c60cc7 403 //
6ace5fe2 404 // Drift velocity DA running on monitoring servers at the DAQ
e5c60cc7 405 //
406
8dd14606 407 Bool_t error = kFALSE;
6ace5fe2 408
409 // Objects for HLT and DAQ zusammen
3a0f6479 410 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
6ace5fe2 411 AliCDBMetaData metaData;
412 metaData.SetBeamPeriod(0);
413 metaData.SetResponsible("Raphaelle Bailhache");
414 metaData.SetComment("TRD calib test");
3a0f6479 415 // Store the infos for the detector
6ace5fe2 416 AliCDBMetaData md1;
417 md1.SetObjectClassName("AliTRDCalDet");
418 md1.SetResponsible("Raphaelle Bailhache");
419 md1.SetBeamPeriod(0);
420 md1.SetComment("TRD calib test");
3a0f6479 421 // Store the infos for the pads
6ace5fe2 422 AliCDBMetaData md2;
423 md2.SetObjectClassName("AliTRDCalPad");
424 md2.SetResponsible("Raphaelle Bailhache");
425 md2.SetBeamPeriod(0);
426 md2.SetComment("TRD calib test");
3a0f6479 427
6ace5fe2 428 // Take the file from the DAQ file exchange server
429 TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
8dd14606 430 if (!listdaq) {
6ace5fe2 431 Log("No list found for vdrift (DAQ)");
8dd14606 432 return kTRUE;
433 }
434
435 if(listdaq->GetSize() !=1){
436 Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
437 delete listdaq;
438 return kTRUE;
6ace5fe2 439 }
8dd14606 440
441 TObjString* fileNameEntry = (TObjString*) listdaq->At(0);
442 if(fileNameEntry != NULL){
443 TString fileName = GetFile(kDAQ, "VDRIFT",
444 fileNameEntry->GetString().Data());
445 if(fileName.Length() ==0){
446 Log("Error retrieving the file vdrift (DAQ)");
447 delete listdaq;
448 return kTRUE;
449 }
450 TFile *filedaq = TFile::Open(fileName);
451 TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
452 if (histodriftvelocity) {
453
454 // store as reference data
455 if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
456 Log("Error storing 2D Profile for vdrift from the DAQ");
457 error = kTRUE;
458 }
459
460 // analyse
461
462 Log("Take the PH reference data. Now we will try to fit\n");
463 calibra->SetMinEntries(2000); // If there is less than 2000
464 calibra->AnalysePH(histodriftvelocity);
465
466 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
467 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
468 Int_t nbfit = calibra->GetNumberFit();
469 Int_t nbE = calibra->GetNumberEnt();
470
471 // if enough statistics store the results
472 if ((nbtg > 0) &&
473 (nbfit >= 0.95*nbE)) {
474 // create the cal objects
475 TObjArray object = calibra->GetVectorFit();
476 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
477 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
478 object = calibra->GetVectorFit2();
479 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
480 TObject *objtime0pad = calibra->CreatePadObjectT0();
481 calibra->ResetVectorFit();
482 // store
483 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
484 Log("Error storing the calibration object for the chamber vdrift (DAQ)");
485 error = kTRUE;
486 }
487 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
488 Log("Error storing the calibration object for the chamber t0 (DAQ)");
489 error = kTRUE;
490 }
491 if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
492 Log("Error storing the calibration object for the local drift velocity (DAQ)");
493 error = kTRUE;
494 }
495 if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
496 Log("Error storing the calibration object for the local time0 (DAQ)");
497 error = kTRUE;
498 }
499 }
500 else{
501 Log("Not enough statistics for the average pulse height (DAQ)");
502 }
503 } // histo here
504 }// if fileNameEntry
505
506 delete listdaq;
507 return error;
508
6ace5fe2 509}
c8ab4518 510
6ace5fe2 511//______________________________________________________________________________________________
8dd14606 512Bool_t AliTRDPreprocessor::ExtractHLT()
6ace5fe2 513{
e5c60cc7 514 //
6ace5fe2 515 // Gain, vdrift and PRF calibration running on HLT
f5bb5557 516 // return kTRUE if NULL pointer to the list
e5c60cc7 517 //
3a0f6479 518
8dd14606 519 Bool_t error = kFALSE;
520
6ace5fe2 521 // Objects for HLT and DAQ zusammen
522 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
523 AliCDBMetaData metaData;
524 metaData.SetBeamPeriod(0);
525 metaData.SetResponsible("Raphaelle Bailhache");
526 metaData.SetComment("TRD calib test");
527 // Store the infos for the detector
528 AliCDBMetaData md1;
529 md1.SetObjectClassName("AliTRDCalDet");
530 md1.SetResponsible("Raphaelle Bailhache");
531 md1.SetBeamPeriod(0);
532 md1.SetComment("TRD calib test");
533 // Store the infos for the pads
534 AliCDBMetaData md2;
535 md2.SetObjectClassName("AliTRDCalPad");
536 md2.SetResponsible("Raphaelle Bailhache");
537 md2.SetBeamPeriod(0);
538 md2.SetComment("TRD calib test");
6ace5fe2 539
540 // Take the file from the HLT file exchange server
541 TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
8dd14606 542 if (!listhlt) {
6ace5fe2 543 Log("No list found for the HLT");
8dd14606 544 return kTRUE;
545 }
546
547 if(listhlt->GetSize() != 1) {
548 Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
549 delete listhlt;
550 return kTRUE;
6ace5fe2 551 }
3a0f6479 552
8dd14606 553 TObjString* fileNameEntry = (TObjString*) listhlt->At(0);
554 if(fileNameEntry != NULL){
555 TString fileName = GetFile(kHLT, "GAINDRIFTPRF",
556 fileNameEntry->GetString().Data());
557 if(fileName.Length() ==0){
558 Log("Error retrieving the file (HLT)");
559 delete listhlt;
560 return kTRUE;
561 }
562 // Take the file
563 TFile *filehlt = TFile::Open(fileName);
564
8dd14606 565 // gain
566 TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
567 histogain->SetDirectory(0);
568 if (histogain) {
569 // store the reference data
570 if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
571 Log("Error storing 2D histos for gain");
572 error = kTRUE;
573 }
574 // analyse
575 Log("Take the CH reference data. Now we will try to fit\n");
576 calibra->SetMinEntries(1000); // If there is less than 1000 entries in the histo: no fit
577 calibra->AnalyseCH(histogain);
578 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
579 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
580 Int_t nbfit = calibra->GetNumberFit();
581 Int_t nbE = calibra->GetNumberEnt();
582 // enough statistics
583 if ((nbtg > 0) &&
584 (nbfit >= 0.95*nbE)) {
585 // create the cal objects
586 TObjArray object = calibra->GetVectorFit();
413153cb 587 AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object);
8dd14606 588 TObject *objgainpad = calibra->CreatePadObjectGain();
589 // store them
590 if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){
591 Log("Error storing the calibration object for the chamber gain");
592 error = kTRUE;
593 }
594 if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){
595 Log("Error storing the calibration object for the local gain factor");
596 error = kTRUE;
597 }
598 }
599 calibra->ResetVectorFit();
600 }// if histogain
601
8dd14606 602 // vdrift
603 fVdriftHLT = kFALSE;
604 TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
605 histodriftvelocity->SetDirectory(0);
606 if (histodriftvelocity) {
607 // store the reference data
608 if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
609 Log("Error storing 2D Profile for average pulse height (HLT)");
610 error = kTRUE;
611 }
612 // analyse
613 Log("Take the PH reference data. Now we will try to fit\n");
614 calibra->SetMinEntries(1000*20); // If there is less than 20000
615 calibra->AnalysePH(histodriftvelocity);
616 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
617 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
618 Int_t nbfit = calibra->GetNumberFit();
619 Int_t nbE = calibra->GetNumberEnt();
620 // enough statistics
621 if ((nbtg > 0) &&
622 (nbfit >= 0.95*nbE)) {
623 // create the cal objects
624 TObjArray object = calibra->GetVectorFit();
625 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
626 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
627 object = calibra->GetVectorFit2();
628 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
629 TObject *objtime0pad = calibra->CreatePadObjectT0();
630 // store them
631 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
632 Log("Error storing the calibration object for the chamber vdrift (HLT)");
633 error = kTRUE;
634 }
635 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
636 Log("Error storing the calibration object for the chamber t0 (HLT)");
637 error = kTRUE;
638 }
639 if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
640 Log("Error storing the calibration object for the local drift velocity (HLT)");
641 error = kTRUE;
642 }
643 if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
644 Log("Error storing the calibration object for the local time0 (HLT)");
645 error = kTRUE;
646 }
647 fVdriftHLT = kTRUE;
648 }
649 calibra->ResetVectorFit();
650 }// if TProfile2D
651
8dd14606 652 // prf
653 TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
654 histoprf->SetDirectory(0);
655 if (histoprf) {
656 // store reference data
657 if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
658 Log("Error storing the 2D Profile for Pad Response Function");
659 error = kTRUE;
660 }
661 // analyse
662 Log("Take the PRF reference data. Now we will try to fit\n");
663 calibra->SetMinEntries(600); // If there is less than 20000
664 calibra->AnalysePRFMarianFit(histoprf);
665 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
666 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
667 Int_t nbfit = calibra->GetNumberFit();
668 Int_t nbE = calibra->GetNumberEnt();
669 // enough statistics
670 if ((nbtg > 0) &&
671 (nbfit >= 0.95*nbE)) {
672 // create cal pad objects
673 TObjArray object = calibra->GetVectorFit();
674 TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
675 // store them
676 if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){
677 Log("Error storing the calibration object for the Pad Response Function");
678 error = kTRUE;
679 }
680 }
681 calibra->ResetVectorFit();
682 }// if PRF
683 }// if fileNameEntry
684
685 delete listhlt;
686 return error;
687
e5c60cc7 688}
197b835e 689
690//_____________________________________________________________________________
691UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
692{
693 //
694 // process the configuration of FEE, PTR and GTU
695 // reteive XML file from the DCS FXS
696 // parse it and store TObjArrays in the CDB
697 // return 0 for success, otherwise:
698 // 5: could not get the file from the FXS
699 // 6: ERROR in XML validation: something wrong with the file
700 // 7: ERROR while creating calibration objects in the handler
701 // 8: error while storing data in the CDB
702 //
703
704 Log("Processing the DCS config summary file.");
705
706 // get the XML file
707 const char * nameFile = GetFile(kDCS,"CONFIGSUMMARY","");
708 if (nameFile == NULL) {
709 return 5;
710 Log(Form("File %s not found!",nameFile));
711 }
712
3d8c1d84 713// // create parser and parse
714// TSAXParser saxParser;
715// AliTRDSaxHandler saxHandler;
716// saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler);
717// saxParser.ParseFile(nameFile);
718
719// // report errors if present
720// if (saxParser.GetParseCode() == 0) {
721// Log("XML file validation OK");
722// } else {
723// Log(Form("ERROR in XML file validation. Parsecode: %s", saxParser.GetParseCode()));
724// return 6;
725// }
726// if (saxHandler.GetHandlerStatus() != 0) {
727// Log(Form("ERROR while creating calibration objects. Error code: %s", saxHandler.GetHandlerStatus()));
728// return 7;
729// }
730
731// // get the calibration object storing the data from the handler
732// AliTRDCalDCS* fCalDCSObj = saxHandler.GetCalDCSObj();
733
734// // store the DCS calib data in the CDB
735// AliCDBMetaData metaData1;
736// metaData1.SetBeamPeriod(0);
737// metaData1.SetResponsible("Frederick Kramer");
738// metaData1.SetComment("DCS configuration data in one AliTRDCalDCS object.");
739// if (!Store("Calib", "DCSCONFIG", fCalDCSObj, &metaData1, 0, kTRUE)) {
740// Log("problems while storing DCS config data object");
741// return 8;
742// }
197b835e 743
744 return 0;
745}
746