]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCPreprocessor.cxx
Remove obsolete DA (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessor.cxx
1 /**************************************************************************
2  * Copyright(c) 2007, 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
17 #include "AliTPCPreprocessor.h"
18 #include "AliShuttleInterface.h"
19
20 #include "AliCDBMetaData.h"
21 #include "AliDCSValue.h"
22 #include "AliLog.h"
23 #include "AliTPCSensorTempArray.h"
24 #include "AliTPCROC.h"
25 #include "AliTPCCalROC.h"
26 #include "AliTPCCalPad.h"
27 #include "AliTPCCalibPedestal.h"
28 #include "AliTPCCalibPulser.h"
29 #include "AliTPCCalibCE.h"
30 #include "TFile.h"
31 #include "TTree.h"
32 #include "TGraph.h" 
33 #include "TEnv.h"
34 #include "TParameter.h"
35
36 #include <TTimeStamp.h>
37
38 const Int_t kValCutTemp = 100;               // discard temperatures > 100 degrees
39 const Int_t kDiffCutTemp = 5;                // discard temperature differences > 5 degrees
40 const TString kPedestalRunType = "PEDESTAL";  // pedestal run identifier
41 const TString kPulserRunType = "PULSER";   // pulser run identifier
42 const TString kPhysicsRunType = "PHYSICS";   // physics run identifier
43 const TString kStandAloneRunType = "STANDALONE"; // standalone run identifier
44 const TString kDaqRunType = "DAQ"; // DAQ run identifier
45 const TString kAmandaTemp = "tpc_PT_%d.Temperature"; // Amanda string for temperature entries
46 //const Double_t kFitFraction = 0.7;                 // Fraction of DCS sensor fits required              
47 const Double_t kFitFraction = -1.0;          // Don't require minimum number of fits in commissioning run 
48
49 //
50 // This class is the SHUTTLE preprocessor for the TPC detector.
51 //
52
53 ClassImp(AliTPCPreprocessor)
54
55 //______________________________________________________________________________________________
56 AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
57   AliPreprocessor("TPC",shuttle),
58   fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE), fROC(0)
59 {
60   // constructor
61   fROC = AliTPCROC::Instance();
62 }
63 //______________________________________________________________________________________________
64 // AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) :
65 //   AliPreprocessor(org),
66 //   fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE)
67 // {
68 //   // copy constructor not implemented
69 //   //   -- missing underlying copy constructor in AliPreprocessor
70 //
71 //   Fatal("AliTPCPreprocessor", "copy constructor not implemented");
72 //
73 // //  fTemp = new AliTPCSensorTempArray(*(org.fTemp));
74 // }
75
76 //______________________________________________________________________________________________
77 AliTPCPreprocessor::~AliTPCPreprocessor()
78 {
79   // destructor
80
81   delete fTemp;
82   delete fHighVoltage;
83 }
84 //______________________________________________________________________________________________
85 AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
86 {
87   Fatal("operator =", "assignment operator not implemented");
88   return *this;
89 }
90
91
92 //______________________________________________________________________________________________
93 void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
94         UInt_t endTime)
95 {
96   // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start
97
98   UInt_t startTimeLocal = startTime-1800;
99
100   AliPreprocessor::Initialize(run, startTimeLocal, endTime);
101
102         AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
103                 TTimeStamp(startTime).AsString(),
104                 TTimeStamp(endTime).AsString()));
105
106   // Preprocessor configuration
107
108         AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
109         if (entry) fConfEnv = (TEnv*) entry->GetObject();
110         if ( fConfEnv==0 ) {
111            Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
112            fConfigOK = kFALSE;
113            return;
114         }
115
116   // Temperature sensors
117
118        TTree *confTree = 0;
119
120        TString tempConf = fConfEnv->GetValue("Temperature","ON");
121        tempConf.ToUpper();
122        if (tempConf != "OFF" ) {
123         entry = GetFromOCDB("Config", "Temperature");
124         if (entry) confTree = (TTree*) entry->GetObject();
125         if ( confTree==0 ) {
126            Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
127            fConfigOK = kFALSE;
128            return;
129         }
130         fTemp = new AliTPCSensorTempArray(startTimeLocal, fEndTime, confTree, kAmandaTemp);
131         fTemp->SetValCut(kValCutTemp);
132         fTemp->SetDiffCut(kDiffCutTemp);
133        }
134
135   // High voltage measurements
136
137       TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
138       hvConf.ToUpper();
139       if (hvConf != "OFF" ) { 
140         confTree=0;
141         entry=0;
142         entry = GetFromOCDB("Config", "HighVoltage");
143         if (entry) confTree = (TTree*) entry->GetObject();
144         if ( confTree==0 ) {
145            Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
146            fConfigOK = kFALSE;
147            return;
148         }
149         fHighVoltage = new AliDCSSensorArray(startTimeLocal, fEndTime, confTree);
150       }
151 }
152
153 //______________________________________________________________________________________________
154 UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
155 {
156   // Fills data into TPC calibrations objects
157
158   // Amanda servers provide information directly through dcsAliasMap
159
160   
161   if (!fConfigOK) return 9;
162   UInt_t result = 0;
163   TObjArray *resultArray = new TObjArray();
164   TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
165   errorHandling.ToUpper();
166   TObject * status;
167
168   UInt_t dcsResult=0;
169   if (errorHandling == "OFF" ) {
170     if (!dcsAliasMap) dcsResult=1;
171     if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;  
172     status = new TParameter<int>("dcsResult",dcsResult);
173     resultArray->Add(status);
174   } else {
175     if (!dcsAliasMap) return 9;
176     if (dcsAliasMap->GetEntries() == 0 ) return 9;
177   }
178
179
180   
181
182   TString runType = GetRunType();
183
184   // Temperature sensors are processed by AliTPCCalTemp
185
186   TString tempConf = fConfEnv->GetValue("Temperature","ON");
187   tempConf.ToUpper();
188   if (tempConf != "OFF" ) {
189     UInt_t tempResult = MapTemperature(dcsAliasMap);
190     result=tempResult;
191     status = new TParameter<int>("tempResult",tempResult);
192     resultArray->Add(status);
193   }
194
195   // High Voltage recordings
196
197
198   TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
199   hvConf.ToUpper();
200   if (hvConf != "OFF" ) { 
201    UInt_t hvResult = MapHighVoltage(dcsAliasMap);
202    result+=hvResult;
203    status = new TParameter<int>("hvResult",hvResult);
204    resultArray->Add(status);
205  }
206
207   // Other calibration information will be retrieved through FXS files
208   //  examples:
209   //    TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
210   //    const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
211   //
212   //    TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
213   //    const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
214
215   // pedestal entries
216
217   if(runType == kPedestalRunType) {
218     Int_t numSources = 1;
219     Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
220     TString source = fConfEnv->GetValue("Pedestal","DAQ");
221     source.ToUpper();
222     if (source != "OFF" ) { 
223      if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
224      if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
225      if (source == "HLTDAQ" ) {
226          numSources=2;
227          pedestalSource[0] = AliShuttleInterface::kHLT;
228          pedestalSource[1] = AliShuttleInterface::kDAQ;
229      }
230      if (source == "DAQHLT" ) numSources=2;
231      UInt_t pedestalResult=0;
232      for (Int_t i=0; i<numSources; i++ ) {      
233        UInt_t pedestalResult = ExtractPedestals(pedestalSource[i]);
234        if ( pedestalResult == 0 ) break;
235      }
236      result += pedestalResult;
237      status = new TParameter<int>("pedestalResult",pedestalResult);
238      resultArray->Add(status);
239     }
240   }
241
242   // pulser trigger processing
243
244   if(runType == kPulserRunType) {
245     Int_t numSources = 1;
246     Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
247     TString source = fConfEnv->GetValue("Pulser","DAQ");
248     source.ToUpper();
249     if ( source != "OFF") { 
250      if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
251      if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
252      if (source == "HLTDAQ" ) {
253          numSources=2;
254          pulserSource[0] = AliShuttleInterface::kHLT;
255          pulserSource[1] = AliShuttleInterface::kDAQ;
256      }
257      if (source == "DAQHLT" ) numSources=2;
258      UInt_t pulserResult=0;
259      for (Int_t i=0; i<numSources; i++ ) {      
260        pulserResult = ExtractPulser(pulserSource[i]);
261        if ( pulserResult == 0 ) break;
262      }
263      result += pulserResult;
264      status = new TParameter<int>("pulserResult",pulserResult);
265      resultArray->Add(status);
266     }
267   }
268
269
270
271   // Central Electrode processing
272
273   if( runType == kPhysicsRunType || runType == kStandAloneRunType || 
274       runType == kDaqRunType ) {    
275
276     Int_t numSources = 1;
277     Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
278     TString source = fConfEnv->GetValue("CE","DAQ");
279     source.ToUpper();
280     if ( source != "OFF" ) { 
281      if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
282      if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
283      if (source == "HLTDAQ" ) {
284         numSources=2;
285         ceSource[0] = AliShuttleInterface::kHLT;
286         ceSource[1] = AliShuttleInterface::kDAQ;
287      }
288      if (source == "DAQHLT" ) numSources=2;
289      UInt_t ceResult=0;
290      for (Int_t i=0; i<numSources; i++ ) {      
291        ceResult = ExtractCE(ceSource[i]);
292        if ( ceResult == 0 ) break;
293      }
294      result += ceResult;
295      status = new TParameter<int>("ceResult",ceResult);
296      resultArray->Add(status);
297     }
298   }
299   
300   if (errorHandling == "OFF" ) {
301     AliCDBMetaData metaData;
302     metaData.SetBeamPeriod(0);
303     metaData.SetResponsible("Haavard Helstrup");
304     metaData.SetComment("Preprocessor AliTPC status.");
305     Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
306     resultArray->Delete();
307     return 0;
308   } else { 
309     return result;
310   }
311 }
312 //______________________________________________________________________________________________
313 UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
314 {
315
316    // extract DCS temperature maps. Perform fits to save space
317
318   UInt_t result=0;
319   TMap *map = fTemp->ExtractDCS(dcsAliasMap);
320   if (map) {
321     fTemp->MakeSplineFit(map);
322     Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); 
323     if (fitFraction > kFitFraction ) {
324       AliInfo(Form("Temperature values extracted, fits performed.\n"));
325     } else { 
326       Log ("Too few temperature maps fitted. \n");
327       result = 9;
328     }
329   } else {
330     Log("No temperature map extracted. \n");
331     result=9;
332   }
333   delete map;
334   // Now store the final CDB file
335
336   if ( result == 0 ) {
337         AliCDBMetaData metaData;
338         metaData.SetBeamPeriod(0);
339         metaData.SetResponsible("Haavard Helstrup");
340         metaData.SetComment("Preprocessor AliTPC data base entries.");
341
342         Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
343         if ( !storeOK )  result=1;
344
345    }
346
347    return result;
348
349 }
350
351 //______________________________________________________________________________________________
352 UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
353 {
354
355    // extract DCS HV maps. Perform fits to save space
356
357   UInt_t result=0;
358   TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
359   if (map) {
360     fHighVoltage->MakeSplineFit(map);
361     Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); 
362     if (fitFraction > kFitFraction ) {
363       AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
364     } else { 
365       Log ("Too few high voltage recordings fitted. \n");
366       result = 9;
367     }
368   } else {
369     Log("No high voltage recordings extracted. \n");
370     result=9;
371   }
372   delete map;
373   // Now store the final CDB file
374
375   if ( result == 0 ) {
376         AliCDBMetaData metaData;
377         metaData.SetBeamPeriod(0);
378         metaData.SetResponsible("Haavard Helstrup");
379         metaData.SetComment("Preprocessor AliTPC data base entries.");
380
381         Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
382         if ( !storeOK )  result=1;
383
384    }
385
386    return result;
387
388 }
389
390
391 //______________________________________________________________________________________________
392
393 UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
394 {
395  //
396  //  Read pedestal file from file exchage server
397  //  Keep original entry from OCDB in case no new pedestals are available
398  //
399  AliTPCCalPad *calPadPed=0;
400  AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
401  if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
402  if ( calPadPed==NULL ) {
403      Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
404      calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
405  }
406
407  AliTPCCalPad *calPadRMS=0;
408  entry = GetFromOCDB("Calib", "Noise");
409  if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
410  if ( calPadRMS==NULL ) {
411      Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
412      calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
413  }
414
415
416  UInt_t result=0;
417
418  Int_t nSectors = fROC->GetNSectors();
419  TList* list = GetFileSources(sourceFXS,"pedestals");
420  
421  if (list && list->GetEntries()>0) {
422
423 //  loop through all files from LDCs
424
425     Bool_t changed=false;
426     UInt_t index = 0;
427     while (list->At(index)!=NULL) {
428      TObjString* fileNameEntry = (TObjString*) list->At(index);
429      if (fileNameEntry!=NULL) {
430         TString fileName = GetFile(sourceFXS, "pedestals",
431                                          fileNameEntry->GetString().Data());
432         TFile *f = TFile::Open(fileName);
433         if (!f) {
434           Log ("Error opening pedestal file.");
435           result =2;
436           break;
437         }
438         AliTPCCalibPedestal *calPed;
439         f->GetObject("AliTPCCalibPedestal",calPed);
440         if ( !calPed ) {
441           Log ("No pedestal calibration object in file.");
442           result = 2;
443           break;
444         }
445
446         //  replace entries for the sectors available in the present file
447
448         changed=true;
449         for (Int_t sector=0; sector<nSectors; sector++) {
450            AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
451            if ( rocPed )  calPadPed->SetCalROC(rocPed,sector);
452            AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
453            if ( rocRMS )  calPadRMS->SetCalROC(rocRMS,sector);
454         }
455       }
456      ++index;
457     }  // while(list)
458 //
459 //  Store updated pedestal entry to OCDB
460 //
461     if (changed) {
462      AliCDBMetaData metaData;
463      metaData.SetBeamPeriod(0);
464      metaData.SetResponsible("Haavard Helstrup");
465      metaData.SetComment("Preprocessor AliTPC data base entries."); 
466  
467      Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
468      if ( !storeOK ) ++result;
469      storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
470      if ( !storeOK ) ++result;
471     }
472   } else {
473     Log ("Error: no entries in input file list!");
474     result = 1;
475   }
476
477   return result;
478 }
479
480 //______________________________________________________________________________________________
481
482
483 UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
484 {
485  //
486  //  Read pulser calibration file from file exchage server
487  //  Keep original entry from OCDB in case no new pulser calibration is available
488  //
489  TObjArray    *pulserObjects=0;
490  AliTPCCalPad *pulserTmean=0;
491  AliTPCCalPad *pulserTrms=0;
492  AliTPCCalPad *pulserQmean=0;
493  AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
494  if (entry) pulserObjects = (TObjArray*)entry->GetObject();
495  if ( pulserObjects==NULL ) {
496      Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
497      pulserObjects = new TObjArray;    
498  }
499
500  pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
501  if ( !pulserTmean ) {
502     pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
503     pulserObjects->Add(pulserTmean);
504  }
505  pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
506  if ( !pulserTrms )  { 
507     pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
508     pulserObjects->Add(pulserTrms);
509  }
510  pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
511  if ( !pulserQmean )  { 
512     pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
513     pulserObjects->Add(pulserQmean);
514  }
515
516
517  UInt_t result=0;
518
519  Int_t nSectors = fROC->GetNSectors();
520  TList* list = GetFileSources(sourceFXS,"pulser");
521  
522  if (list && list->GetEntries()>0) {
523
524 //  loop through all files from LDCs
525
526     Bool_t changed=false;
527     UInt_t index = 0;
528     while (list->At(index)!=NULL) {
529      TObjString* fileNameEntry = (TObjString*) list->At(index);
530      if (fileNameEntry!=NULL) {
531         TString fileName = GetFile(sourceFXS, "pulser",
532                                          fileNameEntry->GetString().Data());
533         TFile *f = TFile::Open(fileName);
534         if (!f) {
535           Log ("Error opening pulser file.");
536           result =2;
537           break;
538         }
539         AliTPCCalibPulser *calPulser;
540         f->GetObject("AliTPCCalibPulser",calPulser);
541         if ( !calPulser ) {
542           Log ("No pulser calibration object in file.");
543           result = 2;
544           break;
545         }
546
547         //  replace entries for the sectors available in the present file
548
549         changed=true;
550         for (Int_t sector=0; sector<nSectors; sector++) {
551            AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
552            if ( rocTmean )  pulserTmean->SetCalROC(rocTmean,sector);
553            AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
554            if ( rocTrms )  pulserTrms->SetCalROC(rocTrms,sector);
555            AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
556            if ( rocQmean )  pulserQmean->SetCalROC(rocQmean,sector);
557         }
558       }
559      ++index;
560     }  // while(list)
561 //
562 //  Store updated pedestal entry to OCDB
563 //
564     if (changed) {
565      AliCDBMetaData metaData;
566      metaData.SetBeamPeriod(0);
567      metaData.SetResponsible("Haavard Helstrup");
568      metaData.SetComment("Preprocessor AliTPC data base entries.");
569
570      Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
571      if ( !storeOK ) ++result;
572     }  
573   } else {
574     Log ("Error: no entries in input file list!");
575     result = 1;
576   }
577
578   return result;
579 }
580
581 UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
582 {
583  //
584  //  Read Central Electrode file from file exchage server
585  //  Keep original entry from OCDB in case no new CE calibration is available
586  //
587  TObjArray    *ceObjects=0;
588  AliTPCCalPad *ceTmean=0;
589  AliTPCCalPad *ceTrms=0;
590  AliTPCCalPad *ceQmean=0;
591  TObjArray    *rocTtime=0;  
592  TObjArray    *rocQtime=0;  
593
594  AliCDBEntry* entry = GetFromOCDB("Calib", "CE");
595  if (entry) ceObjects = (TObjArray*)entry->GetObject();
596  if ( ceObjects==NULL ) {
597      Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n");
598      ceObjects = new TObjArray;    
599  }
600
601  Int_t nSectors = fROC->GetNSectors();
602
603  ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean");
604  if ( !ceTmean ) {
605     ceTmean = new AliTPCCalPad("CETmean","CETmean");
606     ceObjects->Add(ceTmean);
607  }
608  ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms");
609  if ( !ceTrms )  { 
610     ceTrms = new AliTPCCalPad("CETrms","CETrms");
611     ceObjects->Add(ceTrms);
612  }
613  ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean");
614  if ( !ceQmean )  { 
615     ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
616     ceObjects->Add(ceQmean);
617  }
618  //!new from here please have a look!!!
619  rocTtime = (TObjArray*)ceObjects->FindObject("rocTtime");
620  if ( !rocTtime ) {
621      rocTtime = new TObjArray(nSectors);
622      rocTtime->SetName("rocTtime");
623      ceObjects->Add(rocTtime);
624  }
625  
626  rocQtime = (TObjArray*)ceObjects->FindObject("rocQtime");
627  if ( !rocQtime ) {
628      rocQtime = new TObjArray(nSectors);
629      rocQtime->SetName("rocQtime");
630      ceObjects->Add(rocQtime);
631  }
632
633
634  UInt_t result=0;
635
636  TList* list = GetFileSources(sourceFXS,"CE");
637  
638  if (list && list->GetEntries()>0) {
639
640 //  loop through all files from LDCs
641
642     UInt_t index = 0;
643     while (list->At(index)!=NULL) {
644      TObjString* fileNameEntry = (TObjString*) list->At(index);
645      if (fileNameEntry!=NULL) {
646         TString fileName = GetFile(sourceFXS, "CE",
647                                          fileNameEntry->GetString().Data());
648         TFile *f = TFile::Open(fileName);
649         if (!f) {
650           Log ("Error opening central electrode file.");
651           result =2;
652           break;
653         }
654         AliTPCCalibCE *calCE;
655         f->GetObject("AliTPCCalibCE",calCE);
656
657         //  replace entries for the sectors available in the present file
658
659         for (Int_t sector=0; sector<nSectors; sector++) {
660            AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
661            if ( rocTmean )  ceTmean->SetCalROC(rocTmean,sector);
662            AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
663            if ( rocTrms )  ceTrms->SetCalROC(rocTrms,sector);
664            AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
665            if ( rocQmean )  ceQmean->SetCalROC(rocQmean,sector);
666            TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
667            if ( grT ) rocTtime->AddAt(grT,sector);         
668            TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
669            if ( grQ ) rocTtime->AddAt(grQ,sector);         
670         }
671       }
672      ++index;
673     }  // while(list)
674 //
675 //  Store updated pedestal entry to OCDB
676 //
677     AliCDBMetaData metaData;
678     metaData.SetBeamPeriod(0);
679     metaData.SetResponsible("Haavard Helstrup");
680     metaData.SetComment("Preprocessor AliTPC data base entries.");
681
682     Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
683     if ( !storeOK ) ++result;
684     
685   } else {
686     Log ("Error: no entries!");
687     result = 1;
688   }
689
690   return result;
691 }