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