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