]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCPreprocessor.cxx
13d1730c7210e5b173cd1dc36a2cfad6953e303d
[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 "AliTPCCalibRaw.h"
31 #include "AliTPCdataQA.h"
32 #include "ARVersion.h"
33 #include "TFile.h"
34 #include "TTree.h"
35 #include "TGraph.h" 
36 #include "TEnv.h"
37 #include "TParameter.h"
38
39 #include <TTimeStamp.h>
40
41 const Int_t kValCutTemp = 100;               // discard temperatures > 100 degrees
42 const Int_t kDiffCutTemp = 5;                // discard temperature differences > 5 degrees
43 const TString kPedestalRunType = "PEDESTAL";  // pedestal run identifier
44 const TString kPulserRunType = "PULSER";     // pulser run identifier
45 const TString kPhysicsRunType = "PHYSICS";   // physics run identifier
46 const TString kCosmicRunType = "COSMIC";     // cosmic run identifier
47 const TString kLaserRunType = "LASER";       // laser run identifier
48 const TString kDaqRunType = "DAQ"; // DAQ run identifier
49 const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
50 //const Double_t kFitFraction = 0.7;                 // Fraction of DCS sensor fits required              
51 const Double_t kFitFraction = -1.0;          // Don't require minimum number of fits in commissioning run 
52 const Int_t   kNumPressureSensors = 3;    // number of pressure sensors
53 const char* kPressureSensorNames[kNumPressureSensors] = {
54                    "CavernAtmosPressure",
55                    "CavernAtmosPressure2",
56                    "SurfaceAtmosPressure" };
57       
58
59 //
60 // This class is the SHUTTLE preprocessor for the TPC detector.
61 //
62
63 ClassImp(AliTPCPreprocessor)
64
65 //______________________________________________________________________________________________
66 AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
67   AliPreprocessor("TPC",shuttle),
68   fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
69   fPressure(0), fConfigOK(kTRUE), fROC(0)
70 {
71   // constructor
72   fROC = AliTPCROC::Instance();
73
74   // define run types to be processed
75   
76   AddRunType(kPedestalRunType);
77   AddRunType(kPulserRunType);
78   AddRunType(kPhysicsRunType);
79   AddRunType(kCosmicRunType);
80   AddRunType(kLaserRunType);
81   AddRunType(kDaqRunType);
82   
83 }
84 //______________________________________________________________________________________________
85  AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor&  ) :
86    AliPreprocessor("TPC",0),
87    fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
88    fPressure(0), fConfigOK(kTRUE), fROC(0)
89  {
90
91    Fatal("AliTPCPreprocessor", "copy constructor not implemented");
92 //
93 // //  fTemp = new AliTPCSensorTempArray(*(org.fTemp));
94  }
95
96 //______________________________________________________________________________________________
97 AliTPCPreprocessor::~AliTPCPreprocessor()
98 {
99   // destructor
100
101   delete fTemp;
102   delete fHighVoltage;
103   delete fHighVoltageStat;
104   delete fGoofie;
105   delete fPressure;
106 }
107 //______________________________________________________________________________________________
108 AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
109 {
110   Fatal("operator =", "assignment operator not implemented");
111   return *this;
112 }
113
114
115 //______________________________________________________________________________________________
116 void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
117         UInt_t endTime)
118 {
119
120   AliPreprocessor::Initialize(run, startTime, endTime);
121
122         AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
123                 TTimeStamp((time_t)startTime,0).AsString(),
124                 TTimeStamp((time_t)endTime,0).AsString()));
125
126   // Preprocessor configuration
127
128         AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
129         if (entry) fConfEnv = (TEnv*) entry->GetObject();
130         if ( fConfEnv==0 ) {
131            Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
132            fConfigOK = kFALSE;
133            return;
134         }
135
136   // Temperature sensors
137
138        TTree *confTree = 0;
139
140        TString tempConf = fConfEnv->GetValue("Temperature","ON");
141        tempConf.ToUpper();
142        if (tempConf != "OFF" ) {
143         entry = GetFromOCDB("Config", "Temperature");
144         if (entry) confTree = (TTree*) entry->GetObject();
145         if ( confTree==0 ) {
146            Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
147            fConfigOK = kFALSE;
148            return;
149         }
150         fTemp = new AliTPCSensorTempArray(startTime, endTime, confTree, kAmandaTemp);
151         fTemp->SetValCut(kValCutTemp);
152         fTemp->SetDiffCut(kDiffCutTemp);
153        }
154
155   // High voltage measurements
156
157       TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
158       hvConf.ToUpper();
159       if (hvConf != "OFF" ) { 
160         confTree=0;
161         entry=0;
162         entry = GetFromOCDB("Config", "HighVoltage");
163         if (entry) confTree = (TTree*) entry->GetObject();
164         if ( confTree==0 ) {
165            Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
166            fConfigOK = kFALSE;
167            return;
168         }
169         fHighVoltage = new AliDCSSensorArray(startTime, endTime, confTree);
170       }
171
172    // High voltage status values
173      
174       TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
175       hvStatConf.ToUpper();
176       if (hvStatConf != "OFF" ) { 
177         confTree=0;
178         entry=0;
179         entry = GetFromOCDB("Config", "HighVoltageStat");
180         if (entry) confTree = (TTree*) entry->GetObject();
181         if ( confTree==0 ) {
182            Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
183            fConfigOK = kFALSE;
184            return;
185         }
186         fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
187       }
188
189    // Goofie values
190      
191       TString goofieConf = fConfEnv->GetValue("Goofie","ON");
192       goofieConf.ToUpper();
193       if (goofieConf != "OFF" ) { 
194         confTree=0;
195         entry=0;
196         entry = GetFromOCDB("Config", "Goofie");
197         if (entry) confTree = (TTree*) entry->GetObject();
198         if ( confTree==0 ) {
199            Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
200            fConfigOK = kFALSE;
201            return;
202         }
203         fGoofie = new AliDCSSensorArray(startTime, endTime, confTree);
204       }
205
206    // Pressure values
207      
208        TString runType = GetRunType();
209
210        if( runType == kPhysicsRunType || 
211         runType == kLaserRunType ) {    
212        TString pressureConf = fConfEnv->GetValue("Pressure","ON");
213        pressureConf.ToUpper();
214        if (pressureConf != "OFF" ) { 
215          TClonesArray * array = new TClonesArray("AliDCSSensor",kNumPressureSensors); 
216          for(Int_t j = 0; j < kNumPressureSensors; j++) {
217            AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
218            sens->SetStringID(kPressureSensorNames[j]);
219          }
220          fPressure = new AliDCSSensorArray(startTime, endTime, array);
221        }
222      }
223 }
224
225 //______________________________________________________________________________________________
226 UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
227 {
228   // Fills data into TPC calibrations objects
229
230   // Amanda servers provide information directly through dcsAliasMap
231
232   
233   if (!fConfigOK) return 9;
234   UInt_t result = 0;
235   TObjArray *resultArray = new TObjArray();
236   TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
237   errorHandling.ToUpper();
238   TObject * status;
239
240   UInt_t dcsResult=0;
241   if (!dcsAliasMap) dcsResult=1;
242   if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;  
243   status = new TParameter<int>("dcsResult",dcsResult);
244   resultArray->Add(status);
245
246
247   TString runType = GetRunType();
248
249   if ( dcsResult == 0 ) {
250
251   // Temperature sensors are processed by AliTPCCalTemp
252
253     TString tempConf = fConfEnv->GetValue("Temperature","ON");
254     tempConf.ToUpper();
255     if (tempConf != "OFF" ) {
256       UInt_t tempResult = MapTemperature(dcsAliasMap);
257       result=tempResult;
258       status = new TParameter<int>("tempResult",tempResult);
259       resultArray->Add(status);
260     }
261
262   // High Voltage recordings
263
264
265     TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
266     hvConf.ToUpper();
267     if (hvConf != "OFF" ) { 
268      UInt_t hvResult = MapHighVoltage(dcsAliasMap);
269      result+=hvResult;
270      status = new TParameter<int>("hvResult",hvResult);
271      resultArray->Add(status);
272     }
273
274     // Goofie values
275
276
277     TString goofieConf = fConfEnv->GetValue("Goofie","ON");
278     goofieConf.ToUpper();
279     if (goofieConf != "OFF" ) { 
280      UInt_t goofieResult = MapGoofie(dcsAliasMap);
281      result+=goofieResult;
282      status = new TParameter<int>("goofieResult",goofieResult);
283      resultArray->Add(status);
284     }
285
286     // Pressure values
287
288     if( runType == kPhysicsRunType || 
289       runType == kLaserRunType ) {    
290
291       TString pressureConf = fConfEnv->GetValue("Pressure","ON");
292       pressureConf.ToUpper();
293       if (pressureConf != "OFF" ) { 
294        UInt_t pressureResult = MapPressure(dcsAliasMap);
295        status = new TParameter<int>("pressureResult",pressureResult);
296        resultArray->Add(status);
297       }
298     }
299   }
300   // Other calibration information will be retrieved through FXS files
301   //  examples:
302   //    TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
303   //    const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
304   //
305   //    TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
306   //    const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
307
308   // pedestal entries
309
310   if(runType == kPedestalRunType) {
311     Int_t numSources = 1;
312     Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
313     TString source = fConfEnv->GetValue("Pedestal","DAQ");
314     source.ToUpper();
315     if (source != "OFF" ) { 
316      if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
317      if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
318      if (source == "HLTDAQ" ) {
319          numSources=2;
320          pedestalSource[0] = AliShuttleInterface::kHLT;
321          pedestalSource[1] = AliShuttleInterface::kDAQ;
322      }
323      if (source == "DAQHLT" ) numSources=2;
324      UInt_t pedestalResult=0;
325      for (Int_t i=0; i<numSources; i++ ) {      
326        pedestalResult = ExtractPedestals(pedestalSource[i]);
327        if ( pedestalResult == 0 ) break;
328      }
329      result += pedestalResult;
330      status = new TParameter<int>("pedestalResult",pedestalResult);
331      resultArray->Add(status);
332     }
333   }
334
335   // pulser trigger processing
336
337   if(runType == kPulserRunType) {
338     Int_t numSources = 1;
339     Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
340     TString source = fConfEnv->GetValue("Pulser","DAQ");
341     source.ToUpper();
342     if ( source != "OFF") { 
343      if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
344      if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
345      if (source == "HLTDAQ" ) {
346          numSources=2;
347          pulserSource[0] = AliShuttleInterface::kHLT;
348          pulserSource[1] = AliShuttleInterface::kDAQ;
349      }
350      if (source == "DAQHLT" ) numSources=2;
351      UInt_t pulserResult=0;
352      for (Int_t i=0; i<numSources; i++ ) {      
353        pulserResult = ExtractPulser(pulserSource[i]);
354        if ( pulserResult == 0 ) break;
355      }
356      result += pulserResult;
357      status = new TParameter<int>("pulserResult",pulserResult);
358      resultArray->Add(status);
359     }
360   }
361
362
363 // raw calibration processing
364
365   if(runType == kPhysicsRunType) {
366     Int_t numSources = 1;
367     Int_t rawSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
368     TString source = fConfEnv->GetValue("Raw","DAQ");
369     source.ToUpper();
370     if ( source != "OFF") { 
371      if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
372      if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
373      if (source == "HLTDAQ" ) {
374          numSources=2;
375          rawSource[0] = AliShuttleInterface::kHLT;
376          rawSource[1] = AliShuttleInterface::kDAQ;
377      }
378      if (source == "DAQHLT" ) numSources=2;
379      UInt_t rawResult=0;
380      for (Int_t i=0; i<numSources; i++ ) {      
381        rawResult = ExtractRaw(rawSource[i]);
382        if ( rawResult == 0 ) break;
383      }
384      result += rawResult;
385      status = new TParameter<int>("rawResult",rawResult);
386      resultArray->Add(status);
387     }
388   }
389
390
391   // Altro configuration
392
393
394   TString altroConf = fConfEnv->GetValue("AltroConf","ON");
395   altroConf.ToUpper();
396   if (altroConf != "OFF" ) { 
397    UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS);
398    result+=altroResult;
399    status = new TParameter<int>("altroResult",altroResult);
400    resultArray->Add(status);
401  }
402
403
404   // Central Electrode processing
405
406   if( runType == kPhysicsRunType || 
407       runType == kLaserRunType ) {    
408
409     Int_t numSources = 1;
410     Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
411     TString source = fConfEnv->GetValue("CE","DAQ");
412     source.ToUpper();
413     if ( source != "OFF" ) { 
414      if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
415      if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
416      if (source == "HLTDAQ" ) {
417         numSources=2;
418         ceSource[0] = AliShuttleInterface::kHLT;
419         ceSource[1] = AliShuttleInterface::kDAQ;
420      }
421      if (source == "DAQHLT" ) numSources=2;
422      UInt_t ceResult=0;
423      for (Int_t i=0; i<numSources; i++ ) {      
424        ceResult = ExtractCE(ceSource[i]);
425        if ( ceResult == 0 ) break;
426      }
427
428    // only flag error if CE result is missing from LASER runs
429    //    -- for PHYSICS run do CE processing if data available
430    
431      if ( runType == kLaserRunType ) result += ceResult;
432      status = new TParameter<int>("ceResult",ceResult);
433      resultArray->Add(status);
434
435     numSources = 1;
436     Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
437     source = fConfEnv->GetValue("QA","DAQ");
438     source.ToUpper();
439     if ( source != "OFF" ) { 
440      if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
441      if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
442      if (source == "HLTDAQ" ) {
443         numSources=2;
444         qaSource[0] = AliShuttleInterface::kHLT;
445         qaSource[1] = AliShuttleInterface::kDAQ;
446      }
447      if (source == "DAQHLT" ) numSources=2;
448      UInt_t qaResult=0;
449      for (Int_t i=0; i<numSources; i++ ) {      
450        qaResult = ExtractQA(qaSource[i]);
451        if ( qaResult == 0 ) break;
452      }
453 //     result += qaResult;
454      if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
455      status = new TParameter<int>("qaResult",qaResult);
456      resultArray->Add(status);
457     }
458    }
459   }
460   
461   if (errorHandling == "OFF" ) {
462     AliCDBMetaData metaData;
463     metaData.SetBeamPeriod(0);
464     metaData.SetResponsible("Haavard Helstrup");
465     metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
466     metaData.SetComment("Preprocessor AliTPC status.");
467     Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
468     resultArray->Delete();
469     delete resultArray;
470     return 0;
471   } else { 
472     delete resultArray;
473     return result;
474   }
475 }
476 //______________________________________________________________________________________________
477 UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
478 {
479
480    // extract DCS temperature maps. Perform fits to save space
481
482   UInt_t result=0;
483   TMap *map = fTemp->ExtractDCS(dcsAliasMap);
484   if (map) {
485     fTemp->MakeSplineFit(map);
486     Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); 
487     if (fitFraction > kFitFraction ) {
488       AliInfo(Form("Temperature values extracted, fits performed.\n"));
489     } else { 
490       Log ("Too few temperature maps fitted. \n");
491       result = 9;
492     }
493   } else {
494     Log("No temperature map extracted. \n");
495     result=9;
496   }
497   delete map;
498   // Now store the final CDB file
499
500   if ( result == 0 ) {
501         AliCDBMetaData metaData;
502         metaData.SetBeamPeriod(0);
503         metaData.SetResponsible("Haavard Helstrup");
504         metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
505         metaData.SetComment("Preprocessor AliTPC data base entries.");
506
507         Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
508         if ( !storeOK )  result=1;
509
510    }
511
512    return result;
513
514 }
515 //______________________________________________________________________________________________
516 UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
517 {
518
519    // extract DCS pressure maps. Perform fits to save space
520
521   UInt_t result=0;
522   TMap *map = fPressure->ExtractDCS(dcsAliasMap);
523   if (map) {
524     fPressure->MakeSplineFit(map);
525     Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors(); 
526     if (fitFraction > kFitFraction ) {
527       AliInfo(Form("Temperature values extracted, fits performed.\n"));
528     } else { 
529       Log ("Too few pressure maps fitted. \n");
530       result = 9;
531     }
532   } else {
533     Log("No pressure map extracted. \n");
534     result=9;
535   }
536   delete map;
537   return result;
538 }
539
540 //______________________________________________________________________________________________
541 UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
542 {
543
544    // extract DCS HV maps. Perform fits to save space
545
546   UInt_t result=0;
547   TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
548   if (map) {
549     fHighVoltage->MakeSplineFit(map, kTRUE);   // keep both spline fits and original maps
550     Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); 
551     if (fitFraction > kFitFraction ) {
552       AliInfo(Form("High voltage recordings extracted, fits performed.\n"));
553     } else { 
554       Log ("Too few high voltage recordings fitted. \n");
555       result = 9;
556     }
557   } else {
558     Log("No high voltage recordings extracted. \n");
559     result=9;
560   }
561   delete map;
562
563   TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
564   hvStatConf.ToUpper();
565   if (hvStatConf != "OFF" ) { 
566     TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
567     if (map2) {
568       fHighVoltageStat->ClearFit();
569       fHighVoltageStat->SetGraph(map2);
570     } else {
571        Log("No high voltage status recordings extracted. \n");
572       result=9;
573     }
574     delete map2;
575
576     // add status maps to high voltage sensor array
577
578     fHighVoltage->AddSensors(fHighVoltageStat);
579    }
580   // Now store the final CDB file
581
582   if ( result == 0 ) {
583         AliCDBMetaData metaData;
584         metaData.SetBeamPeriod(0);
585         metaData.SetResponsible("Haavard Helstrup");
586         metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
587         metaData.SetComment("Preprocessor AliTPC data base entries.");
588
589         Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
590         if ( !storeOK )  result=1;
591
592    }
593
594    return result;
595
596 }
597
598 //______________________________________________________________________________________________
599 UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
600 {
601
602    // extract DCS Goofie maps. Do not perform fits (low update rate)
603
604   UInt_t result=0;
605
606   TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
607   if (map) {
608     fGoofie->ClearFit();
609     fGoofie->SetGraph(map);
610   } else {
611     Log("No Goofie recordings extracted. \n");
612     result=9;
613   }
614   delete map;
615
616   // Now store the final CDB file
617
618   if ( result == 0 ) {
619         AliCDBMetaData metaData;
620         metaData.SetBeamPeriod(0);
621         metaData.SetResponsible("Haavard Helstrup");
622         metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
623         metaData.SetComment("Preprocessor AliTPC data base entries.");
624
625         Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
626         if ( !storeOK )  result=1;
627
628    }
629
630    return result;
631
632 }
633
634
635 //______________________________________________________________________________________________
636
637 UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
638 {
639  //
640  //  Read pedestal file from file exchage server
641  //  Keep original entry from OCDB in case no new pedestals are available
642  //
643  AliTPCCalPad *calPadPed=0;
644  AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
645  if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
646  if ( calPadPed==NULL ) {
647      Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
648      calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
649  }
650
651  AliTPCCalPad *calPadRMS=0;
652  entry = GetFromOCDB("Calib", "PadNoise");
653  if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
654  if ( calPadRMS==NULL ) {
655      Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
656      calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
657  }
658
659
660  UInt_t result=0;
661
662  Int_t nSectors = fROC->GetNSectors();
663  TList* list = GetFileSources(sourceFXS,"pedestals");
664  
665  if (list && list->GetEntries()>0) {
666
667 //  loop through all files from LDCs
668
669     Bool_t changed=false;
670     UInt_t index = 0;
671     while (list->At(index)!=NULL) {
672      TObjString* fileNameEntry = (TObjString*) list->At(index);
673      if (fileNameEntry!=NULL) {
674         TString fileName = GetFile(sourceFXS, "pedestals",
675                                          fileNameEntry->GetString().Data());
676         TFile *f = TFile::Open(fileName);
677         if (!f) {
678           Log ("Error opening pedestal file.");
679           result =2;
680           break;
681         }
682         AliTPCCalibPedestal *calPed;
683         f->GetObject("tpcCalibPedestal",calPed);
684         if ( !calPed ) {
685           Log ("No pedestal calibration object in file.");
686           result = 2;
687           break;
688         }
689
690         //  replace entries for the sectors available in the present file
691
692         changed=true;
693         for (Int_t sector=0; sector<nSectors; sector++) {
694            AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
695            if ( rocPed )  calPadPed->SetCalROC(rocPed,sector);
696            AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
697            if ( rocRMS )  calPadRMS->SetCalROC(rocRMS,sector);
698         }
699         delete calPed; 
700         f->Close();
701       }
702      ++index;
703     }  // while(list)
704 //
705 //  Store updated pedestal entry to OCDB
706 //
707     if (changed) {
708      AliCDBMetaData metaData;
709      metaData.SetBeamPeriod(0);
710      metaData.SetResponsible("Haavard Helstrup");
711      metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
712      metaData.SetComment("Preprocessor AliTPC data base entries."); 
713  
714      Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
715      if ( !storeOK ) ++result;
716      storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
717      if ( !storeOK ) ++result;
718     }
719   } else {
720     Log ("Error: no entries in pedestal file list!");
721     result = 1;
722   }
723
724   delete calPadPed;
725   delete calPadRMS;
726
727   return result;
728 }
729
730 //______________________________________________________________________________________________
731
732
733 UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
734 {
735  //
736  //  Read pulser calibration file from file exchage server
737  //  Keep original entry from OCDB in case no new pulser calibration is available
738  //
739  TObjArray    *pulserObjects=0;
740  AliTPCCalPad *pulserTmean=0;
741  AliTPCCalPad *pulserTrms=0;
742  AliTPCCalPad *pulserQmean=0;
743  AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
744  if (entry) pulserObjects = (TObjArray*)entry->GetObject();
745  if ( pulserObjects==NULL ) {
746      Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
747      pulserObjects = new TObjArray;    
748  }
749
750  pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean");
751  if ( !pulserTmean ) {
752     pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
753     pulserObjects->Add(pulserTmean);
754  }
755  pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms");
756  if ( !pulserTrms )  { 
757     pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
758     pulserObjects->Add(pulserTrms);
759  }
760  pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean");
761  if ( !pulserQmean )  { 
762     pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
763     pulserObjects->Add(pulserQmean);
764  }
765
766
767  UInt_t result=0;
768
769  Int_t nSectors = fROC->GetNSectors();
770  TList* list = GetFileSources(sourceFXS,"pulser");
771  
772  if (list && list->GetEntries()>0) {
773
774 //  loop through all files from LDCs
775
776     Bool_t changed=false;
777     UInt_t index = 0;
778     while (list->At(index)!=NULL) {
779      TObjString* fileNameEntry = (TObjString*) list->At(index);
780      if (fileNameEntry!=NULL) {
781         TString fileName = GetFile(sourceFXS, "pulser",
782                                          fileNameEntry->GetString().Data());
783         TFile *f = TFile::Open(fileName);
784         if (!f) {
785           Log ("Error opening pulser file.");
786           result =2;
787           break;
788         }
789         AliTPCCalibPulser *calPulser;
790         f->GetObject("tpcCalibPulser",calPulser);
791         if ( !calPulser ) {
792           Log ("No pulser calibration object in file.");
793           result = 2;
794           break;
795         }
796
797         //  replace entries for the sectors available in the present file
798
799         changed=true;
800         for (Int_t sector=0; sector<nSectors; sector++) {
801            AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
802            if ( rocTmean )  pulserTmean->SetCalROC(rocTmean,sector);
803            AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
804            if ( rocTrms )  pulserTrms->SetCalROC(rocTrms,sector);
805            AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
806            if ( rocQmean )  pulserQmean->SetCalROC(rocQmean,sector);
807         }
808        delete calPulser;
809        f->Close();
810       }
811      ++index;
812     }  // while(list)
813 //
814 //  Store updated pedestal entry to OCDB
815 //
816     if (changed) {
817      AliCDBMetaData metaData;
818      metaData.SetBeamPeriod(0);
819      metaData.SetResponsible("Haavard Helstrup");
820      metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
821      metaData.SetComment("Preprocessor AliTPC data base entries.");
822
823      Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE);
824      if ( !storeOK ) ++result;
825     }  
826   } else {
827     Log ("Error: no entries in pulser file list!");
828     result = 1;
829   }
830   pulserObjects->Delete();
831   delete pulserObjects;
832
833   return result;
834 }
835
836 //______________________________________________________________________________________________
837
838
839 UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
840 {
841  //
842  //  Read Raw calibration file from file exchage server
843  //
844  
845  UInt_t result=0;
846  TObjArray* rawArray = new TObjArray;
847
848  TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
849  
850  if (list && list->GetEntries()>0) {
851
852 //  loop through all files
853
854     UInt_t index = 0;
855     while (list->At(index)!=NULL) {
856      TObjString* fileNameEntry = (TObjString*) list->At(index);
857      if (fileNameEntry!=NULL) {
858         TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
859                                          fileNameEntry->GetString().Data());
860         TFile *f = TFile::Open(fileName);
861         if (!f) {
862           Log ("Error opening raw file.");
863           result =2;
864           break;
865         }
866         AliTPCCalibRaw *calRaw;
867         f->GetObject("tpcCalibRaw",calRaw);
868         if ( !calRaw ) {
869           Log ("No raw calibration object in file.");
870           result = 2;
871           break;
872         }
873        rawArray->Add(calRaw);
874        f->Close();
875       }
876      ++index;
877     }  // while(list)
878 //
879 //  Store updated pedestal entry to OCDB
880 //
881      AliCDBMetaData metaData;
882      metaData.SetBeamPeriod(0);
883      metaData.SetResponsible("Haavard Helstrup");
884      metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
885      metaData.SetComment("Preprocessor AliTPC data base entries.");
886
887      Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE);
888      if ( !storeOK ) ++result;
889   } else {
890     Log ("Error: no entries in raw file list!");
891     result = 1;
892   }
893   
894   rawArray->Delete();
895   delete rawArray;
896
897   return result;
898 }
899 //______________________________________________________________________________________________
900
901 UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
902 {
903  //
904  //  Read Central Electrode file from file exchage server
905  //  
906  //
907  AliTPCCalPad *ceTmean=0;
908  AliTPCCalPad *ceTrms=0;
909  AliTPCCalPad *ceQmean=0;
910  TObjArray    *rocTtime=0;  
911  TObjArray    *rocQtime=0;  
912
913  TObjArray    *ceObjects= new TObjArray;
914   
915
916  Int_t nSectors = fROC->GetNSectors();
917
918  ceTmean = new AliTPCCalPad("CETmean","CETmean");
919  ceObjects->Add(ceTmean);
920
921  ceTrms = new AliTPCCalPad("CETrms","CETrms");
922  ceObjects->Add(ceTrms);
923
924  ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
925  ceObjects->Add(ceQmean);
926  
927  rocTtime = new TObjArray(nSectors+2);   // also make room for A and C side average
928  rocTtime->SetName("rocTtime");
929  ceObjects->Add(rocTtime);
930  
931  rocQtime = new TObjArray(nSectors);
932  rocQtime->SetName("rocQtime");
933  ceObjects->Add(rocQtime);
934
935 // Temperature maps 
936
937  if (fTemp) {
938     fTemp->SetNameTitle("TempMap","TempMap");
939     ceObjects->Add(fTemp);
940  }
941
942 // Pressure maps
943
944  if (fPressure) {
945    AliDCSSensor *sensor=0;
946    for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
947       sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
948       sensor->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);       
949       ceObjects->Add(sensor);
950    }
951  }   
952
953  UInt_t result=0;
954
955  TList* list = GetFileSources(sourceFXS,"CE");
956  
957  if (list && list->GetEntries()>0) {
958
959 //  loop through all files from LDCs
960
961     UInt_t index = 0;
962     while (list->At(index)!=NULL) {
963      TObjString* fileNameEntry = (TObjString*) list->At(index);
964      if (fileNameEntry!=NULL) {
965         TString fileName = GetFile(sourceFXS, "CE",
966                                          fileNameEntry->GetString().Data());
967         TFile *f = TFile::Open(fileName);
968         if (!f) {
969           Log ("Error opening central electrode file.");
970           result =2;
971           break;
972         }
973         AliTPCCalibCE *calCE;
974         f->GetObject("tpcCalibCE",calCE);
975
976         if (!calCE) {
977           Log ("No valid calibCE object.");
978           result=2;
979           break;
980         }
981         //  replace entries for the sectors available in the present file
982
983         for (Int_t sector=0; sector<nSectors; sector++) {
984            AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
985            if ( rocTmean )  ceTmean->SetCalROC(rocTmean,sector);
986            AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
987            if ( rocTrms )  ceTrms->SetCalROC(rocTrms,sector);
988            AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
989            if ( rocQmean )  ceQmean->SetCalROC(rocQmean,sector);
990            TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
991            if ( grT ) rocTtime->AddAt(grT,sector);         
992            TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
993            if ( grQ ) rocQtime->AddAt(grQ,sector);         
994         }
995
996        TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
997        if ( grT ) rocTtime->AddAt(grT,nSectors);         
998        grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
999        if ( grT ) rocTtime->AddAt(grT,nSectors+1);         
1000
1001
1002        delete calCE;
1003        f->Close();
1004       }
1005      ++index;
1006     }  // while(list)
1007 //
1008 //  Store updated pedestal entry to OCDB
1009 //
1010     AliCDBMetaData metaData;
1011     metaData.SetBeamPeriod(0);
1012     metaData.SetResponsible("Haavard Helstrup");
1013     metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1014     metaData.SetComment("Preprocessor AliTPC data base entries.");
1015
1016     Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
1017     if ( !storeOK ) ++result;
1018     
1019   } else {
1020     Log ("Error: no CE entries available from FXS!");
1021     result = 1;
1022   }
1023
1024   ceObjects->Delete();
1025   delete ceObjects;
1026   
1027   return result;
1028 }
1029 //______________________________________________________________________________________________
1030
1031 UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1032 {
1033  //
1034  //  Read Quality Assurance file from file exchage server
1035  //
1036  
1037  UInt_t result=0;
1038
1039  TList* list = GetFileSources(sourceFXS,"QA");
1040  
1041  if (list && list->GetEntries()>0) {
1042
1043 //  only one QA objetc should be available!
1044
1045     AliTPCdataQA *calQA;
1046
1047     UInt_t nentries = list->GetEntries();  
1048     UInt_t index=0;
1049     if ( nentries > 1) Log ( "More than one QA entry. First one processed");      
1050     TObjString* fileNameEntry = (TObjString*) list->At(index);
1051     if (fileNameEntry!=NULL) {
1052         TString fileName = GetFile(sourceFXS, "QA",
1053                                          fileNameEntry->GetString().Data());
1054         TFile *f = TFile::Open(fileName);
1055         if (!f) {
1056           Log ("Error opening QA file.");
1057           result =2;          
1058         } else {
1059           f->GetObject("tpcCalibQA",calQA);
1060           if ( calQA ) {      
1061 //
1062 //  Store updated pedestal entry to OCDB
1063 //
1064            AliCDBMetaData metaData;
1065            metaData.SetBeamPeriod(0);
1066            metaData.SetResponsible("Haavard Helstrup");
1067            metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1068            metaData.SetComment("Preprocessor AliTPC data base entries.");
1069
1070            Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
1071            if ( !storeOK ) ++result;
1072
1073            delete calQA;
1074           }
1075         }
1076     } else {
1077     Log ("Error: no QA files on FXS!");
1078     result = 2;
1079     }
1080   } else {
1081     Log ("Error: no QA entries in FXS list!");
1082     result = 1;
1083   }
1084   return result;
1085 }
1086
1087 //______________________________________________________________________________________________
1088
1089
1090 UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS)
1091 {
1092  //
1093  //  Read pulser calibration file from file exchage server
1094  //  Keep original entry from OCDB in case no new pulser calibration is available
1095  //
1096  TObjArray    *altroObjects=0;
1097  AliTPCCalPad *acqStart=0;
1098  AliTPCCalPad *zsThr=0;
1099  AliTPCCalPad *acqStop=0;
1100  AliTPCCalPad *FPED=0;
1101  AliTPCCalPad *masked=0;
1102  AliTPCCalPad *k1=0, *k2=0, *k3=0;
1103  AliTPCCalPad *l1=0, *l2=0, *l3=0;
1104  TMap *mapRCUconfig=0;
1105
1106  AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
1107  if (entry) altroObjects = (TObjArray*)entry->GetObject();
1108  if ( altroObjects==NULL ) {
1109      Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1110      altroObjects = new TObjArray;    
1111  }
1112
1113  acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1114  if ( !acqStart ) {
1115     acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1116     altroObjects->Add(acqStart);
1117  }
1118  zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1119  if ( !zsThr )  { 
1120     zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1121     altroObjects->Add(zsThr);
1122  }
1123  FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1124  if ( !FPED )  { 
1125     FPED = new AliTPCCalPad("FPED","FPED");
1126     altroObjects->Add(FPED);
1127  }
1128  acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1129  if ( !acqStop ) {
1130     acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1131     altroObjects->Add(acqStop);
1132  }
1133  masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1134  if ( !masked )  { 
1135     masked = new AliTPCCalPad("Masked","Masked");
1136     altroObjects->Add(masked);
1137  }
1138  k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1139  if ( !k1 )  { 
1140     k1 = new AliTPCCalPad("K1","K1");
1141     altroObjects->Add(k1);
1142  }
1143  k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1144  if ( !k2 )  { 
1145     k2 = new AliTPCCalPad("K2","K2");
1146     altroObjects->Add(k2);
1147  }
1148  k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1149  if ( !k3 )  { 
1150     k3 = new AliTPCCalPad("K3","K3");
1151     altroObjects->Add(k3);
1152  }
1153  l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1154  if ( !l1 )  { 
1155     l1 = new AliTPCCalPad("L1","L1");
1156     altroObjects->Add(l1);
1157  }
1158  l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1159  if ( !l2 )  { 
1160     l2 = new AliTPCCalPad("L2","L2");
1161     altroObjects->Add(l2);
1162  }
1163  l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1164  if ( !l3 )  { 
1165     l3 = new AliTPCCalPad("L3","L3");
1166     altroObjects->Add(l3);
1167  }
1168  mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1169  if (!mapRCUconfig) {
1170     mapRCUconfig = new TMap();
1171     mapRCUconfig->SetName("RCUconfig");
1172     altroObjects->Add(mapRCUconfig);
1173  }
1174
1175
1176  UInt_t result=0;
1177  TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1178
1179  Int_t nSectors = fROC->GetNSectors();
1180  Bool_t changed=false;
1181  for ( Int_t id=0; id<2; id++) {
1182    TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1183  
1184    if (list && list->GetEntries()>0) {
1185       if (altroObjects == 0 ) altroObjects = new TObjArray;
1186
1187 //  loop through all files from LDCs
1188
1189     UInt_t index = 0;
1190     while (list->At(index)!=NULL) {
1191      TObjString* fileNameEntry = (TObjString*) list->At(index);
1192      if (fileNameEntry!=NULL) {
1193         TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1194                                          fileNameEntry->GetString().Data());
1195         TFile *f = TFile::Open(fileName);
1196         if (!f) {
1197           char message[40];
1198           sprintf(message,"Error opening Altro configuration file, id = %d",id);
1199           Log (message);
1200           result =2;
1201           break;
1202         }
1203         TObjArray *altroFXS;
1204         f->GetObject("AltroConfig",altroFXS);
1205         if ( !altroFXS ) {
1206           Log ("No Altro configuration object in file.");
1207           result = 2;
1208           break;
1209         }
1210
1211         //  replace entries for the sectors available in the present file
1212         AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1213         AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1214         AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1215         AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1216         AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
1217         AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1218         AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1219         AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1220         AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1221         AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1222         AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1223         TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1224         TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1225         
1226         changed=true;
1227         for (Int_t sector=0; sector<nSectors; sector++) {
1228             
1229            if (acqStartFXS) {
1230               AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1231               if ( rocAcqStart )  acqStart->SetCalROC(rocAcqStart,sector);
1232            }
1233            if (zsThrFXS ) {
1234               AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1235               if ( rocZsThr )  zsThr->SetCalROC(rocZsThr,sector);
1236            }
1237            if (acqStopFXS) {
1238               AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1239               if ( rocAcqStop )  acqStop->SetCalROC(rocAcqStop,sector);
1240            }
1241            if (FPEDFXS ) {
1242               AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
1243               if ( rocFPED )  FPED->SetCalROC(rocFPED,sector);
1244            }
1245            if (maskedFXS) {
1246               AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1247               if ( rocMasked )  masked->SetCalROC(rocMasked,sector);
1248            }
1249            if (k1FXS) {
1250               AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1251               if ( rocK1 )  k1->SetCalROC(rocK1,sector);
1252            }
1253            if (k2FXS) {
1254               AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1255               if ( rocK2 )  k2->SetCalROC(rocK2,sector);
1256            }
1257            if (k3FXS) {
1258               AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1259               if ( rocK3 )  k3->SetCalROC(rocK3,sector);
1260            }
1261            if (l1FXS) {
1262               AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1263               if ( rocL1 )  l1->SetCalROC(rocL1,sector);
1264            }
1265            if (l2FXS) {
1266               AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1267               if ( rocL2 )  l2->SetCalROC(rocL2,sector);
1268            }
1269            if (l3FXS) {
1270               AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1271               if ( rocL3 )  l3->SetCalROC(rocL3,sector);
1272            }
1273          }
1274          if (mapRCUconfigFXS) {
1275           Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1276           TObjString* keyFXS;
1277           TVectorF* vecFXS;
1278           TVectorF* vec;              // nSectors = 72  (total number of inner/outer sectors)
1279           for (Int_t i=0; i<mapEntries; ++i) {
1280             keyFXS=(TObjString*)mapFXSiter->Next();
1281             vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1282             vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1283             if (!vec) {
1284               vec = new TVectorF(3*nSectors);
1285               *vec = -1;
1286               mapRCUconfig->Add(keyFXS,vec);
1287             }
1288             if (vec->GetNoElements() != 3*nSectors ) {
1289               vec->ResizeTo(3*nSectors);
1290             }
1291             if (id==0) {                        // A side
1292               vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1293               vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1294             } else {                             // C side
1295               vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1296               vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1297             }
1298           }
1299         }
1300        delete altroFXS;
1301        f->Close();
1302       }
1303      ++index;
1304      }  // while(list)
1305     } else {
1306       Log ("Error: no entries in AltroConfig file list!");
1307       result = 1;
1308     }
1309
1310    }   // for - id
1311 //
1312 //  Store updated pedestal entry to OCDB
1313 //
1314     if (changed) {
1315      AliCDBMetaData metaData;
1316      metaData.SetBeamPeriod(0);
1317      metaData.SetResponsible("Haavard Helstrup");
1318      metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
1319      metaData.SetComment("Preprocessor AliTPC data base entries.");
1320
1321      Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
1322      if ( !storeOK ) ++result;
1323     }  
1324
1325   altroObjects->Delete();
1326   delete altroObjects;
1327   
1328   return result;
1329 }