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