Invert C-side sectors in TPC (Matevz)
[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// //
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
e5c60cc7 35#include <TFile.h>
36#include <TProfile2D.h>
e5c60cc7 37#include <TStopwatch.h>
38#include <TObjString.h>
39#include <TString.h>
40#include <TList.h>
41#include <TCollection.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"
3a0f6479 53#include "Cal/AliTRDCalDet.h"
54#include "Cal/AliTRDCalPadStatus.h"
fdfee371 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{
97 //
a5e1169e 98 // Process DCS and calibration part for HLT
99 //
100
8dd14606 101 TString runType = GetRunType();
102 Log(Form("runtype %s\n",runType.Data()));
65ffd646 103
fdfee371 104 // always process the configuration data
105/* Int_t resultDCSC = */ProcessDCSConfigData(); // for testing!
106 // if there was an error, return with its code
107// if (resultDCSC != 0) return resultDCSC; // for testing!
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 // HLT if On
116 //TString runPar = GetRunParameter("HLTStatus");
8dd14606 117 //if(runPar=="1") {
f5bb5557 118 if(GetHLTStatus()) {
fdfee371 119 /*if(*/ExtractHLT()/*) return 1*/; // for testing!
f5bb5557 120 }
121 // DAQ if HLT failed
8dd14606 122 if(!fVdriftHLT) {
fdfee371 123 /*if(*/ExtractDriftVelocityDAQ()/*) return 1*/; // for testing!
8dd14606 124 }
65ffd646 125 // DCS
126 if(ProcessDCS(dcsAliasMap)) return 1;
6ace5fe2 127 }
8dd14606 128
129 return 0;
6ace5fe2 130
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
146}
6ace5fe2 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 //
54c85ef7 269
270 //
271 // The reference data are stored in:
272 // PadStatus1 for sm-00-01-02-09-10-11
273 // PadStatus2 for sm-03-04-05-12-13-14
274 // PadStatus3 for sm-06-07-08-15-16-17
275 // PadStatus0 if nothing found..means problems
276 //
8dd14606 277
278 Bool_t error = kFALSE;
6ace5fe2 279
280 // Init a AliTRDCalibPadStatus
281 AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
282
283 AliCDBMetaData metaData;
284 metaData.SetBeamPeriod(0);
285 metaData.SetResponsible("Raphaelle Bailhache");
286 metaData.SetComment("TRD calib test");
287
288 // Sum the contributions of the LDCs
289 TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
8dd14606 290 if (!listpad) {
291 Log("No list found for the PEDESTRAL Run");
292 return kTRUE;
293 }
294
c8ab4518 295 // loop through all files from LDCs
8dd14606 296 UInt_t index = 0;
297 while (listpad->At(index)!=NULL) {
298 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
299 if (fileNameEntry != NULL)
300 {
6ace5fe2 301 TString fileName = GetFile(kDAQ, "PADSTATUS",
302 fileNameEntry->GetString().Data());
8dd14606 303 if(fileName.Length() ==0){
6ace5fe2 304 Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
8dd14606 305 delete listpad;
306 return kTRUE;
cd4fc278 307 }
8dd14606 308
309 TFile *f = TFile::Open(fileName);
310 AliTRDCalibPadStatus *calPed;
311 f->GetObject("calibpadstatus",calPed);
312
313 if(calPed){
314
54c85ef7 315 Int_t ldc = 0;
289cc637 316
8dd14606 317 // analyse
289cc637 318 //calPed->AnalyseHisto();
319
320 // Add to the calPedSum
321 for (Int_t idet=0; idet<540; idet++) {
322 AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE);
323 if ( rocMean ) {
324 calPedSum.SetCalRocMean(rocMean,idet);
54c85ef7 325 ldc = (Int_t) (idet / 30);
289cc637 326 }
327 AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
328 if ( rocRMS ) {
329 calPedSum.SetCalRocRMS(rocRMS,idet);
330 }
e4db522f 331 AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE);
332 if ( rocMeand ) {
333 calPedSum.SetCalRocMeand(rocMeand,idet);
334 }
335 AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE);
336 if ( rocRMSd ) {
337 calPedSum.SetCalRocRMSd(rocRMSd,idet);
338 }
289cc637 339 }// det loop
340
54c85ef7 341 if((ldc==0) || (ldc==1) || (ldc==2) || (ldc==9) || (ldc==10) || (ldc==11)) ldc = 1;
342 if((ldc==3) || (ldc==4) || (ldc==5) || (ldc==12) || (ldc==13) || (ldc==14)) ldc = 2;
343 if((ldc==6) || (ldc==7) || (ldc==8) || (ldc==15) || (ldc==16) || (ldc==17)) ldc = 3;
344
8dd14606 345 // store as reference data
346 TString name("PadStatus");
54c85ef7 347 name += ldc;
8dd14606 348 if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
349 Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
350 error = kTRUE;
351 }
289cc637 352
8dd14606 353 } // calPed
354 } // fileNameEntry
355 ++index;
356 }// while (list)
c8ab4518 357
8dd14606 358 Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
359 if(index==0){
6ace5fe2 360 delete listpad;
8dd14606 361 return kTRUE;
6ace5fe2 362 }
c8ab4518 363
8dd14606 364 //
365 // Store pedestal entry to OCDB
366 //
c8ab4518 367
8dd14606 368 // Create Pad Status
369 AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
370 AliCDBMetaData md3;
371 md3.SetObjectClassName("AliTRDCalPadStatus");
372 md3.SetResponsible("Raphaelle Bailhache");
373 md3.SetBeamPeriod(1);
374 md3.SetComment("TRD calib test");
375 if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){
376 Log("Error storing the pedestal");
377 delete listpad;
378 return kTRUE;
a5e1169e 379 }
289cc637 380
381 // Create Noise
382 //Make the AliTRDCalPad
383 AliTRDCalPad *calPad2 = calPedSum.CreateCalPad();
384 AliCDBMetaData md4;
385 md4.SetObjectClassName("AliTRDCalPad");
386 md4.SetResponsible("Raphaelle Bailhache");
387 md4.SetBeamPeriod(1);
388 md4.SetComment("TRD calib test");
389 if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){
390 Log("Error storing the pedestal");
391 delete listpad;
392 return kTRUE;
393 }
394 //Make the AliTRDCalDet correspondant
395 AliTRDCalDet *calDet = calPedSum.CreateCalDet();
396 AliCDBMetaData md5;
397 md5.SetObjectClassName("AliTRDCalDet");
398 md5.SetResponsible("Raphaelle Bailhache");
399 md5.SetBeamPeriod(1);
400 md5.SetComment("TRD calib test");
401 if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){
402 Log("Error storing the pedestal");
403 delete listpad;
404 return kTRUE;
405 }
406
8dd14606 407 delete listpad;
408 return error;
a5e1169e 409
6ace5fe2 410}
c8ab4518 411
6ace5fe2 412//______________________________________________________________________________________________
8dd14606 413Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
6ace5fe2 414{
a5e1169e 415 //
6ace5fe2 416 // Drift velocity DA running on monitoring servers at the DAQ
e5c60cc7 417 //
418
8dd14606 419 Bool_t error = kFALSE;
6ace5fe2 420
421 // Objects for HLT and DAQ zusammen
3a0f6479 422 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
6ace5fe2 423 AliCDBMetaData metaData;
424 metaData.SetBeamPeriod(0);
425 metaData.SetResponsible("Raphaelle Bailhache");
426 metaData.SetComment("TRD calib test");
3a0f6479 427 // Store the infos for the detector
6ace5fe2 428 AliCDBMetaData md1;
429 md1.SetObjectClassName("AliTRDCalDet");
430 md1.SetResponsible("Raphaelle Bailhache");
431 md1.SetBeamPeriod(0);
432 md1.SetComment("TRD calib test");
3a0f6479 433 // Store the infos for the pads
6ace5fe2 434 AliCDBMetaData md2;
435 md2.SetObjectClassName("AliTRDCalPad");
436 md2.SetResponsible("Raphaelle Bailhache");
437 md2.SetBeamPeriod(0);
438 md2.SetComment("TRD calib test");
3a0f6479 439
6ace5fe2 440 // Take the file from the DAQ file exchange server
441 TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
8dd14606 442 if (!listdaq) {
6ace5fe2 443 Log("No list found for vdrift (DAQ)");
8dd14606 444 return kTRUE;
445 }
446
447 if(listdaq->GetSize() !=1){
448 Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
449 delete listdaq;
450 return kTRUE;
6ace5fe2 451 }
8dd14606 452
453 TObjString* fileNameEntry = (TObjString*) listdaq->At(0);
454 if(fileNameEntry != NULL){
455 TString fileName = GetFile(kDAQ, "VDRIFT",
456 fileNameEntry->GetString().Data());
457 if(fileName.Length() ==0){
458 Log("Error retrieving the file vdrift (DAQ)");
459 delete listdaq;
460 return kTRUE;
461 }
462 TFile *filedaq = TFile::Open(fileName);
463 TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
464 if (histodriftvelocity) {
465
466 // store as reference data
467 if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
468 Log("Error storing 2D Profile for vdrift from the DAQ");
469 error = kTRUE;
470 }
471
472 // analyse
473
474 Log("Take the PH reference data. Now we will try to fit\n");
475 calibra->SetMinEntries(2000); // If there is less than 2000
476 calibra->AnalysePH(histodriftvelocity);
477
478 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
479 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
480 Int_t nbfit = calibra->GetNumberFit();
481 Int_t nbE = calibra->GetNumberEnt();
482
483 // if enough statistics store the results
484 if ((nbtg > 0) &&
485 (nbfit >= 0.95*nbE)) {
486 // create the cal objects
487 TObjArray object = calibra->GetVectorFit();
488 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
489 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
490 object = calibra->GetVectorFit2();
491 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
492 TObject *objtime0pad = calibra->CreatePadObjectT0();
493 calibra->ResetVectorFit();
494 // store
495 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
496 Log("Error storing the calibration object for the chamber vdrift (DAQ)");
497 error = kTRUE;
498 }
499 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
500 Log("Error storing the calibration object for the chamber t0 (DAQ)");
501 error = kTRUE;
502 }
503 if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
504 Log("Error storing the calibration object for the local drift velocity (DAQ)");
505 error = kTRUE;
506 }
507 if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
508 Log("Error storing the calibration object for the local time0 (DAQ)");
509 error = kTRUE;
510 }
511 }
512 else{
513 Log("Not enough statistics for the average pulse height (DAQ)");
514 }
515 } // histo here
516 }// if fileNameEntry
517
518 delete listdaq;
519 return error;
520
6ace5fe2 521}
c8ab4518 522
6ace5fe2 523//______________________________________________________________________________________________
8dd14606 524Bool_t AliTRDPreprocessor::ExtractHLT()
6ace5fe2 525{
e5c60cc7 526 //
6ace5fe2 527 // Gain, vdrift and PRF calibration running on HLT
f5bb5557 528 // return kTRUE if NULL pointer to the list
e5c60cc7 529 //
3a0f6479 530
8dd14606 531 Bool_t error = kFALSE;
532
6ace5fe2 533 // Objects for HLT and DAQ zusammen
534 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
535 AliCDBMetaData metaData;
536 metaData.SetBeamPeriod(0);
537 metaData.SetResponsible("Raphaelle Bailhache");
538 metaData.SetComment("TRD calib test");
539 // Store the infos for the detector
540 AliCDBMetaData md1;
541 md1.SetObjectClassName("AliTRDCalDet");
542 md1.SetResponsible("Raphaelle Bailhache");
543 md1.SetBeamPeriod(0);
544 md1.SetComment("TRD calib test");
545 // Store the infos for the pads
546 AliCDBMetaData md2;
547 md2.SetObjectClassName("AliTRDCalPad");
548 md2.SetResponsible("Raphaelle Bailhache");
549 md2.SetBeamPeriod(0);
550 md2.SetComment("TRD calib test");
6ace5fe2 551
552 // Take the file from the HLT file exchange server
553 TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
8dd14606 554 if (!listhlt) {
6ace5fe2 555 Log("No list found for the HLT");
8dd14606 556 return kTRUE;
557 }
558
559 if(listhlt->GetSize() != 1) {
560 Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
561 delete listhlt;
562 return kTRUE;
6ace5fe2 563 }
3a0f6479 564
8dd14606 565 TObjString* fileNameEntry = (TObjString*) listhlt->At(0);
566 if(fileNameEntry != NULL){
567 TString fileName = GetFile(kHLT, "GAINDRIFTPRF",
568 fileNameEntry->GetString().Data());
569 if(fileName.Length() ==0){
570 Log("Error retrieving the file (HLT)");
571 delete listhlt;
572 return kTRUE;
573 }
574 // Take the file
575 TFile *filehlt = TFile::Open(fileName);
576
8dd14606 577 // gain
578 TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
579 histogain->SetDirectory(0);
580 if (histogain) {
581 // store the reference data
582 if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
583 Log("Error storing 2D histos for gain");
584 error = kTRUE;
585 }
586 // analyse
587 Log("Take the CH reference data. Now we will try to fit\n");
588 calibra->SetMinEntries(1000); // If there is less than 1000 entries in the histo: no fit
589 calibra->AnalyseCH(histogain);
590 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
591 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
592 Int_t nbfit = calibra->GetNumberFit();
593 Int_t nbE = calibra->GetNumberEnt();
594 // enough statistics
595 if ((nbtg > 0) &&
596 (nbfit >= 0.95*nbE)) {
597 // create the cal objects
598 TObjArray object = calibra->GetVectorFit();
413153cb 599 AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object);
8dd14606 600 TObject *objgainpad = calibra->CreatePadObjectGain();
601 // store them
602 if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){
603 Log("Error storing the calibration object for the chamber gain");
604 error = kTRUE;
605 }
606 if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){
607 Log("Error storing the calibration object for the local gain factor");
608 error = kTRUE;
609 }
610 }
611 calibra->ResetVectorFit();
612 }// if histogain
613
8dd14606 614 // vdrift
615 fVdriftHLT = kFALSE;
616 TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
617 histodriftvelocity->SetDirectory(0);
618 if (histodriftvelocity) {
619 // store the reference data
620 if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
621 Log("Error storing 2D Profile for average pulse height (HLT)");
622 error = kTRUE;
623 }
624 // analyse
625 Log("Take the PH reference data. Now we will try to fit\n");
626 calibra->SetMinEntries(1000*20); // If there is less than 20000
627 calibra->AnalysePH(histodriftvelocity);
628 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
629 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
630 Int_t nbfit = calibra->GetNumberFit();
631 Int_t nbE = calibra->GetNumberEnt();
632 // enough statistics
633 if ((nbtg > 0) &&
634 (nbfit >= 0.95*nbE)) {
635 // create the cal objects
636 TObjArray object = calibra->GetVectorFit();
637 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
638 TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
639 object = calibra->GetVectorFit2();
640 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
641 TObject *objtime0pad = calibra->CreatePadObjectT0();
642 // store them
643 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
644 Log("Error storing the calibration object for the chamber vdrift (HLT)");
645 error = kTRUE;
646 }
647 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
648 Log("Error storing the calibration object for the chamber t0 (HLT)");
649 error = kTRUE;
650 }
651 if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
652 Log("Error storing the calibration object for the local drift velocity (HLT)");
653 error = kTRUE;
654 }
655 if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
656 Log("Error storing the calibration object for the local time0 (HLT)");
657 error = kTRUE;
658 }
659 fVdriftHLT = kTRUE;
660 }
661 calibra->ResetVectorFit();
662 }// if TProfile2D
663
8dd14606 664 // prf
665 TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
666 histoprf->SetDirectory(0);
667 if (histoprf) {
668 // store reference data
669 if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
670 Log("Error storing the 2D Profile for Pad Response Function");
671 error = kTRUE;
672 }
673 // analyse
674 Log("Take the PRF reference data. Now we will try to fit\n");
675 calibra->SetMinEntries(600); // If there is less than 20000
676 calibra->AnalysePRFMarianFit(histoprf);
677 Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
678 + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
679 Int_t nbfit = calibra->GetNumberFit();
680 Int_t nbE = calibra->GetNumberEnt();
681 // enough statistics
682 if ((nbtg > 0) &&
683 (nbfit >= 0.95*nbE)) {
684 // create cal pad objects
685 TObjArray object = calibra->GetVectorFit();
686 TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
687 // store them
688 if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){
689 Log("Error storing the calibration object for the Pad Response Function");
690 error = kTRUE;
691 }
692 }
693 calibra->ResetVectorFit();
694 }// if PRF
695 }// if fileNameEntry
696
697 delete listhlt;
698 return error;
699
e5c60cc7 700}
fdfee371 701
702//_____________________________________________________________________________
703UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
704{
705 //
706 // process the configuration of FEE, PTR and GTU
707 // reteive XML file from the DCS FXS
708 // parse it and store TObjArrays in the CDB
709 // return 0 for success, otherwise:
710 // 5: could not get the file from the FXS
711 // 6: ERROR in XML validation: something wrong with the file
712 // 7: ERROR while creating calibration objects in the handler
713 // 8: error while storing data in the CDB
714 // > 100: SaxHandler error code
715 //
716
717 Log("Processing the DCS config summary file.");
718
719 // get the XML file
720 const char * xmlFile = GetFile(kDCS,"CONFIGSUMMARY","");
721 if (xmlFile == NULL) {
722 return 5;
723 Log(Form("File %s not found!",xmlFile));
724 }
725
726 // create parser and parse
727 TSAXParser saxParser;
728 AliTRDSaxHandler saxHandler;
729 saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler);
730 saxParser.ParseFile(xmlFile);
731
732 // report errors if present
733 if (saxParser.GetParseCode() == 0) {
734 Log("XML file validation OK");
735 } else {
736 Log(Form("ERROR in XML file validation. Parsecode: %s", saxParser.GetParseCode()));
737 return 6;
738 }
739 if (saxHandler.GetHandlerStatus() != 0) {
740 Log(Form("ERROR while creating calibration objects. Error code: %s", saxHandler.GetHandlerStatus()));
741 return 7;
742 }
743
744 // get the calibration object storing the data from the handler
745 AliTRDCalDCS* fCalDCSObj = saxHandler.GetCalDCSObj();
746
747 // store the DCS calib data in the CDB
748 AliCDBMetaData metaData1;
749 metaData1.SetBeamPeriod(0);
750 metaData1.SetResponsible("Frederick Kramer");
751 metaData1.SetComment("DCS configuration data in one AliTRDCalDCS object.");
752 if (!Store("Calib", "DCSCONFIG", fCalDCSObj, &metaData1, 0, kTRUE)) {
753 Log("problems while storing DCS config data object");
754 return 8;
755 }
756
757 return 0;
758}
759