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