AliRoot Core  3dc7879 (3dc7879)
AliTPCPreprocessor.cxx
Go to the documentation of this file.
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 Double_t kHighVoltageDifference = 1e-4; // don't record High Voltage points
44  // differing by less than 1e-4 from
45  // previous point.
46 const Double_t kGasCompositionDifference = 1e-3; // don't record Gas Composition points
47  // differing by less than 1e-3 from
48  // previous point
49 const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier
50 const TString kPulserRunType = "PULSER"; // pulser run identifier
51 const TString kPhysicsRunType = "PHYSICS"; // physics run identifier
52 const TString kCosmicRunType = "COSMIC"; // cosmic run identifier
53 const TString kLaserRunType = "LASER"; // laser run identifier
54 const TString kDaqRunType = "DAQ"; // DAQ run identifier
55 const TString kStandaloneRunType = "STANDALONE"; // STANDALONE run identifier
56 const TString kAmandaTemp = "TPC_PT_%d_TEMPERATURE"; // Amanda string for temperature entries
57 const TString kAmandaDDL = "DDL%d"; // Amanda string for list of active DDLs
58 const Int_t kNumDDL = 216; // number of TPC DDLs
59 const Int_t kFirstDDL = 768; // identifier of first DDL
60 //const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
61 const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run
62 const Int_t kNumPressureSensors = 3; // number of pressure sensors
64  "CavernAtmosPressure",
65  "CavernAtmosPressure2",
66  "SurfaceAtmosPressure" };
67 const Int_t kMinCESectors = 32; // minimum number of sectors (per side)
68  // to accept CE calibration
69 
70 
71 //
72 // This class is the SHUTTLE preprocessor for the TPC detector.
73 //
74 
75 ClassImp(AliTPCPreprocessor)
76 
77 //______________________________________________________________________________________________
79  AliPreprocessor("TPC",shuttle),
80  fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
81  fPressure(0), fGasComposition(0), fConfigOK(kTRUE), fROC(0),
82  fForceSingleRun(kFALSE)
83 {
84  // constructor
85  fROC = AliTPCROC::Instance();
86 
87  // define run types to be processed
88 
89  AddRunType(kPedestalRunType);
90  AddRunType(kPulserRunType);
91  AddRunType(kPhysicsRunType);
92  AddRunType(kCosmicRunType);
93  AddRunType(kLaserRunType);
94  AddRunType(kDaqRunType);
95  AddRunType(kStandaloneRunType);
96 
97 }
98 //______________________________________________________________________________________________
100  AliPreprocessor("TPC",0),
101  fConfEnv(0), fTemp(0), fHighVoltage(0), fHighVoltageStat(0), fGoofie(0),
102  fPressure(0), fGasComposition(0), fConfigOK(kTRUE), fROC(0),
103  fForceSingleRun(kFALSE)
104  {
105 
106  Fatal("AliTPCPreprocessor", "copy constructor not implemented");
107 //
108 // // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
109  }
110 
111 //______________________________________________________________________________________________
113 {
114  // destructor
115 
116  delete fTemp;
117  delete fHighVoltage;
118  delete fHighVoltageStat;
119  delete fGoofie;
120  delete fGasComposition;
121  delete fPressure;
122 }
123 //______________________________________________________________________________________________
125 {
126  Fatal("operator =", "assignment operator not implemented");
127  return *this;
128 }
129 
130 
131 //______________________________________________________________________________________________
133  UInt_t endTime)
134 {
135 
136  AliPreprocessor::Initialize(run, startTime, endTime);
137 
138  AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
139  TTimeStamp((time_t)startTime,0).AsString(),
140  TTimeStamp((time_t)endTime,0).AsString()));
141 
142  // Preprocessor configuration
143 
144  AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor");
145  if (entry) fConfEnv = (TEnv*) entry->GetObject();
146  if ( fConfEnv==0 ) {
147  Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
148  fConfigOK = kFALSE;
149  return;
150  }
151 
152  // Temperature sensors
153 
154  TTree *confTree = 0;
155 
156  TString tempConf = fConfEnv->GetValue("Temperature","ON");
157  tempConf.ToUpper();
158  if (tempConf != "OFF" ) {
159  entry = GetFromOCDB("Config", "Temperature");
160  if (entry) confTree = (TTree*) entry->GetObject();
161  if ( confTree==0 ) {
162  Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
163  fConfigOK = kFALSE;
164  return;
165  }
166  fTemp = new AliTPCSensorTempArray(startTime, endTime, confTree, kAmandaTemp);
169  }
170 
171  // High voltage measurements
172 
173  TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
174  hvConf.ToUpper();
175  if (hvConf != "OFF" ) {
176  confTree=0;
177  entry=0;
178  entry = GetFromOCDB("Config", "HighVoltage");
179  if (entry) confTree = (TTree*) entry->GetObject();
180  if ( confTree==0 ) {
181  Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n");
182  fConfigOK = kFALSE;
183  return;
184  }
185  time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
186  time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
187  fHighVoltage = new AliDCSSensorArray (UInt_t(timeStart),
188  UInt_t(timeEnd), confTree);
189  }
190 
191  // High voltage status values
192 
193  TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
194  hvStatConf.ToUpper();
195  if (hvStatConf != "OFF" ) {
196  confTree=0;
197  entry=0;
198  entry = GetFromOCDB("Config", "HighVoltageStat");
199  if (entry) confTree = (TTree*) entry->GetObject();
200  if ( confTree==0 ) {
201  Log("AliTPCPreprocsessor: High Voltage Status Config OCDB entry missing.\n");
202  fConfigOK = kFALSE;
203  return;
204  }
205  fHighVoltageStat = new AliDCSSensorArray(startTime, endTime, confTree);
206  }
207 
208  // Goofie values
209 
210  TString goofieConf = fConfEnv->GetValue("Goofie","ON");
211  goofieConf.ToUpper();
212  if (goofieConf != "OFF" ) {
213  confTree=0;
214  entry=0;
215  entry = GetFromOCDB("Config", "Goofie");
216  if (entry) confTree = (TTree*) entry->GetObject();
217  if ( confTree==0 ) {
218  Log("AliTPCPreprocsessor: Goofie Config OCDB entry missing.\n");
219  fConfigOK = kFALSE;
220  return;
221  }
222  fGoofie = new AliDCSSensorArray(startTime, endTime, confTree);
223  }
224 
225 
226  // Gas composition measurements
227 
228  TString gasConf = fConfEnv->GetValue("GasComposition","OFF");
229  gasConf.ToUpper();
230  if (gasConf != "OFF" ) {
231  confTree=0;
232  entry=0;
233  entry = GetFromOCDB("Config", "GasComposition");
234  if (entry) confTree = (TTree*) entry->GetObject();
235  if ( confTree==0 ) {
236  Log("AliTPCPreprocsessor: Gas Composition Config OCDB entry missing.\n");
237  fConfigOK = kFALSE;
238  return;
239  }
240  time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
241  time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
242  fGasComposition = new AliDCSSensorArray (UInt_t(timeStart),
243  UInt_t(timeEnd), confTree);
244  }
245  // Pressure values
246 
247  TString runType = GetRunType();
248 
249  if( runType == kPhysicsRunType ||
250  runType == kLaserRunType || runType == kStandaloneRunType ) {
251  TString pressureConf = fConfEnv->GetValue("Pressure","ON");
252  pressureConf.ToUpper();
253  if (pressureConf != "OFF" ) {
254  TClonesArray * array = new TClonesArray("AliDCSSensor",kNumPressureSensors);
255  for(Int_t j = 0; j < kNumPressureSensors; j++) {
256  AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
258  }
259  fPressure = new AliDCSSensorArray(startTime, endTime, array);
260  }
261  }
262 }
263 
264 //______________________________________________________________________________________________
265 UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
266 {
267  // Fills data into TPC calibrations objects
268 
269  // Amanda servers provide information directly through dcsAliasMap
270 
271 
272  if (!fConfigOK) return 9;
273  UInt_t result = 0;
274  TObjArray *resultArray = new TObjArray();
275  TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON");
276  errorHandling.ToUpper();
277  TObject * status;
278 
279  UInt_t dcsResult=0;
280  if (!dcsAliasMap) {
281  dcsResult=1;
282  } else {
283  if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1;
284  }
285  status = new TParameter<int>("dcsResult",dcsResult);
286  resultArray->Add(status);
287 
288 
289  TString runType = GetRunType();
290 
291  if ( dcsResult == 0 ) {
292 
293  // Temperature sensors are processed by AliTPCCalTemp
294 
295  TString tempConf = fConfEnv->GetValue("Temperature","ON");
296  tempConf.ToUpper();
297  if (tempConf != "OFF" ) {
298  UInt_t tempResult = MapTemperature(dcsAliasMap);
299  if ( tempConf != "TRY") result+=tempResult;
300  status = new TParameter<int>("tempResult",tempResult);
301  resultArray->Add(status);
302  }
303 
304  // High Voltage recordings
305 
306 
307  TString hvConf = fConfEnv->GetValue("HighVoltage","ON");
308  hvConf.ToUpper();
309  if (hvConf != "OFF" ) {
310  UInt_t hvResult = MapHighVoltage(dcsAliasMap);
311  if (hvConf != "TRY") result+=hvResult;
312  status = new TParameter<int>("hvResult",hvResult);
313  resultArray->Add(status);
314  }
315 
316  // Goofie values
317 
318 
319  TString goofieConf = fConfEnv->GetValue("Goofie","ON");
320  goofieConf.ToUpper();
321  if (goofieConf != "OFF" ) {
322  UInt_t goofieResult = MapGoofie(dcsAliasMap);
323  if (goofieConf != "TRY") result+=goofieResult;
324  status = new TParameter<int>("goofieResult",goofieResult);
325  resultArray->Add(status);
326  }
327 
328 
329  // Gas composition recordings
330 
331 
332  TString gasConf = fConfEnv->GetValue("GasComposition","OFF");
333  gasConf.ToUpper();
334  if (gasConf != "OFF" ) {
335  UInt_t gasResult = MapGasComposition(dcsAliasMap);
336  if (gasConf != "TRY") result+=gasResult;
337  status = new TParameter<int>("gasResult",gasResult);
338  resultArray->Add(status);
339  }
340 
341  // Pressure values
342 
343  if( runType == kPhysicsRunType ||
344  runType == kLaserRunType || runType == kStandaloneRunType ) {
345 
346  TString pressureConf = fConfEnv->GetValue("Pressure","ON");
347  pressureConf.ToUpper();
348  if (pressureConf != "OFF" ) {
349  UInt_t pressureResult = MapPressure(dcsAliasMap);
350  status = new TParameter<int>("pressureResult",pressureResult);
351  resultArray->Add(status);
352  }
353  }
354  }
355  // Other calibration information will be retrieved through FXS files
356  // examples:
357  // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
358  // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
359  //
360  // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
361  // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
362 
363  // pedestal entries
364 
365  if(runType == kPedestalRunType) {
366  Int_t numSources = 1;
367  Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
368  TString source = fConfEnv->GetValue("Pedestal","DAQ");
369  source.ToUpper();
370  if (source != "OFF" ) {
371  if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT;
372  if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ;
373  if (source == "HLTDAQ" ) {
374  numSources=2;
375  pedestalSource[0] = AliShuttleInterface::kHLT;
376  pedestalSource[1] = AliShuttleInterface::kDAQ;
377  }
378  if (source == "DAQHLT" ) numSources=2;
379  UInt_t pedestalResult=0;
380  for (Int_t i=0; i<numSources; i++ ) {
381  pedestalResult = ExtractPedestals(pedestalSource[i]);
382  if ( pedestalResult == 0 ) break;
383  }
384  result += pedestalResult;
385  status = new TParameter<int>("pedestalResult",pedestalResult);
386  resultArray->Add(status);
387  }
388  }
389 
390  // pulser trigger processing
391 
392  if(runType == kPulserRunType) {
393  Int_t numSources = 1;
394  Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
395  TString source = fConfEnv->GetValue("Pulser","DAQ");
396  source.ToUpper();
397  if ( source != "OFF") {
398  if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT;
399  if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ;
400  if (source == "HLTDAQ" ) {
401  numSources=2;
402  pulserSource[0] = AliShuttleInterface::kHLT;
403  pulserSource[1] = AliShuttleInterface::kDAQ;
404  }
405  if (source == "DAQHLT" ) numSources=2;
406  if (source == "TRY" ) numSources=1;
407  UInt_t pulserResult=0;
408  for (Int_t i=0; i<numSources; i++ ) {
409  pulserResult = ExtractPulser(pulserSource[i]);
410  if ( pulserResult == 0 ) break;
411  }
412  if (source != "TRY") result += pulserResult;
413  status = new TParameter<int>("pulserResult",pulserResult);
414  resultArray->Add(status);
415  }
416  }
417 
418 
419 // raw calibration processing
420 
421  if(runType == kPhysicsRunType) {
422  Int_t numSources = 1;
424  TString source = fConfEnv->GetValue("Raw","DAQ");
425  source.ToUpper();
426  if ( source != "OFF") {
427  if ( source == "HLT") rawSource[0] = AliShuttleInterface::kHLT;
428  if (!GetHLTStatus()) rawSource[0] = AliShuttleInterface::kDAQ;
429  if (source == "HLTDAQ" ) {
430  numSources=2;
431  rawSource[0] = AliShuttleInterface::kHLT;
432  rawSource[1] = AliShuttleInterface::kDAQ;
433  }
434  if (source == "DAQHLT" ) numSources=2;
435  if (source == "TRY" ) numSources=1;
436  UInt_t rawResult=0;
437  for (Int_t i=0; i<numSources; i++ ) {
438  rawResult = ExtractRaw(rawSource[i]);
439  if ( rawResult == 0 ) break;
440  }
441  if (source != "TRY" )result += rawResult;
442  status = new TParameter<int>("rawResult",rawResult);
443  resultArray->Add(status);
444  }
445  }
446 
447 
448  // Altro configuration
449 
450 
451  TString altroConf = fConfEnv->GetValue("AltroConf","ON");
452  altroConf.ToUpper();
453  if (altroConf != "OFF" ) {
454  UInt_t altroResult = ExtractAltro(AliShuttleInterface::kDCS,dcsAliasMap);
455  if (altroConf != "TRY" ) result+=altroResult;
456  status = new TParameter<int>("altroResult",altroResult);
457  resultArray->Add(status);
458  }
459 
460 
461  // Central Electrode processing
462 
463  if( runType == kPhysicsRunType ||
464  runType == kLaserRunType ) {
465 
466  Int_t numSources = 1;
468  TString source = fConfEnv->GetValue("CE","DAQ");
469  source.ToUpper();
470  if ( source != "OFF" ) {
471  if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT;
472  if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ;
473  if (source == "HLTDAQ" ) {
474  numSources=2;
475  ceSource[0] = AliShuttleInterface::kHLT;
476  ceSource[1] = AliShuttleInterface::kDAQ;
477  }
478  if (source == "DAQHLT" ) numSources=2;
479  if (source == "TRY" ) numSources=1;
480  UInt_t ceResult=0;
481  for (Int_t i=0; i<numSources; i++ ) {
482  ceResult = ExtractCE(ceSource[i]);
483  if ( ceResult == 0 ) break;
484  }
485 
486  // only flag error if CE result is missing from LASER runs
487  // -- for PHYSICS run do CE processing if data available
488 
489  if ( runType == kLaserRunType && source != "TRY" && ceResult<10 ) result += ceResult;
490  status = new TParameter<int>("ceResult",ceResult);
491  resultArray->Add(status);
492 
493  numSources = 1;
494  Int_t qaSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ;
495  source = fConfEnv->GetValue("QA","DAQ");
496  source.ToUpper();
497  if ( source != "OFF" ) {
498  if ( source == "HLT") qaSource[0] = AliShuttleInterface::kHLT;
499  if (!GetHLTStatus()) qaSource[0] = AliShuttleInterface::kDAQ;
500  if (source == "HLTDAQ" ) {
501  numSources=2;
502  qaSource[0] = AliShuttleInterface::kHLT;
503  qaSource[1] = AliShuttleInterface::kDAQ;
504  }
505  if (source == "DAQHLT" ) numSources=2;
506  if (source == "TRY" ) numSources=1;
507  UInt_t qaResult=0;
508  for (Int_t i=0; i<numSources; i++ ) {
509  qaResult = ExtractQA(qaSource[i]);
510  if ( qaResult == 0 ) break;
511  }
512 // result += qaResult;
513  if ( qaResult !=0 ) Log ("ExtractQA failed, no QA entry available.");
514  status = new TParameter<int>("qaResult",qaResult);
515  resultArray->Add(status);
516  }
517  }
518  }
519 
520 // Store component status to OCDB
521 
522  AliCDBMetaData metaData;
523  metaData.SetBeamPeriod(0);
524  metaData.SetResponsible("Haavard Helstrup");
525  metaData.SetAliRootVersion(ALIROOT_VERSION);
526  metaData.SetComment("Preprocessor AliTPC status.");
527  Bool_t storeOK = Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE);
528  if (!storeOK) Log ("Unable to store preprocessor status entry");
529 
530  resultArray->Delete();
531  delete resultArray;
532 
533  if (errorHandling == "OFF" ) return 0;
534  return result;
535 
536 }
537 //______________________________________________________________________________________________
538 UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
539 {
540 
541  // extract DCS temperature maps. Perform fits to save space
542 
543  UInt_t result=0;
544  TMap *map = fTemp->ExtractDCS(dcsAliasMap);
545  if (map) {
546  fTemp->MakeSplineFit(map);
547  Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors();
548  if (fitFraction > kFitFraction ) {
549  AliInfo(Form("Temperature values extracted, fits performed.\n"));
550  } else {
551  Log ("Too few temperature maps fitted. \n");
552  result = 9;
553  }
554  } else {
555  Log("No temperature map extracted. \n");
556  result=9;
557  }
558  delete map;
559  // Now store the final CDB file
560 
561  if ( result == 0 ) {
562  AliCDBMetaData metaData;
563  metaData.SetBeamPeriod(0);
564  metaData.SetResponsible("Haavard Helstrup");
565  metaData.SetAliRootVersion(ALIROOT_VERSION);
566  metaData.SetComment("Preprocessor AliTPC data base entries.");
567 
568  Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
569  if ( !storeOK ) result=1;
570 
571  }
572 
573  return result;
574 
575 }
576 //______________________________________________________________________________________________
577 UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
578 {
579 
580  // extract DCS pressure maps. Perform fits to save space
581 
582  UInt_t result=0;
583  TMap *map = fPressure->ExtractDCS(dcsAliasMap);
584  if (map) {
585  fPressure->MakeSplineFit(map);
586  Double_t fitFraction = 1.0*fPressure->NumFits()/fPressure->NumSensors();
587  if (fitFraction > kFitFraction ) {
588  AliInfo(Form("Pressure values extracted, fits performed.\n"));
589  } else {
590  Log ("Too few pressure maps fitted. \n");
591  result = 9;
592  }
593  } else {
594  Log("No pressure map extracted. \n");
595  result=9;
596  }
597  delete map;
598  return result;
599 }
600 
601 //______________________________________________________________________________________________
602 UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap)
603 {
604 
605  // extract DCS HV maps. Perform fits to save space
606 
607  UInt_t result=0;
608  TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap);
609  if (map) {
611  fHighVoltage->SetGraph(map);
613  // don't keep new point if too similar to previous one
614  } else {
615  Log("No high voltage recordings extracted. \n");
616  result=9;
617  }
618  delete map;
619 
620  TString hvStatConf = fConfEnv->GetValue("HighVoltageStat","ON");
621  hvStatConf.ToUpper();
622  if (hvStatConf != "OFF" ) {
623  TMap *map2 = fHighVoltageStat->ExtractDCS(dcsAliasMap);
624  if (map2) {
626  fHighVoltageStat->SetGraph(map2);
627  } else {
628  Log("No high voltage status recordings extracted. \n");
629  result=9;
630  }
631  delete map2;
632 
633  // add status maps to high voltage sensor array
634 
636  }
637  // Now store the final CDB file
638 
639  if ( result == 0 ) {
640  AliCDBMetaData metaData;
641  metaData.SetBeamPeriod(0);
642  metaData.SetResponsible("Haavard Helstrup");
643  metaData.SetAliRootVersion(ALIROOT_VERSION);
644  metaData.SetComment("Preprocessor AliTPC data base entries.");
645 
646  Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE);
647  if ( !storeOK ) result=1;
648 
649  }
650 
651  return result;
652 
653 }
654 
655 //______________________________________________________________________________________________
656 UInt_t AliTPCPreprocessor::MapGoofie(TMap* dcsAliasMap)
657 {
658 
659  // extract DCS Goofie maps. Do not perform fits (low update rate)
660 
661  UInt_t result=0;
662 
663  TMap *map = fGoofie->ExtractDCS(dcsAliasMap);
664  if (map) {
665  fGoofie->ClearFit();
666  fGoofie->SetGraph(map);
667  } else {
668  Log("No Goofie recordings extracted. \n");
669  result=9;
670  }
671  delete map;
672 
673  // Now store the final CDB file
674 
675  if ( result == 0 ) {
676  AliCDBMetaData metaData;
677  metaData.SetBeamPeriod(0);
678  metaData.SetResponsible("Haavard Helstrup");
679  metaData.SetAliRootVersion(ALIROOT_VERSION);
680  metaData.SetComment("Preprocessor AliTPC data base entries.");
681 
682  Bool_t storeOK = Store("Calib", "Goofie", fGoofie, &metaData, 0, kFALSE);
683  if ( !storeOK ) result=1;
684 
685  }
686 
687  return result;
688 
689 }
690 
691 //______________________________________________________________________________________________
692 UInt_t AliTPCPreprocessor::MapGasComposition(TMap* dcsAliasMap)
693 {
694 
695  // extract DCS HV maps. Perform fits to save space
696 
697  UInt_t result=0;
698  TMap *map = fGasComposition->ExtractDCS(dcsAliasMap);
699  if (map) {
703  // don't keep new point if too similar to previous one
704  } else {
705  Log("No gas composition recordings extracted. \n");
706  result=9;
707  }
708  delete map;
709 
710  // Now store the final CDB file
711 
712  if ( result == 0 ) {
713  AliCDBMetaData metaData;
714  metaData.SetBeamPeriod(0);
715  metaData.SetResponsible("Haavard Helstrup");
716  metaData.SetAliRootVersion(ALIROOT_VERSION);
717  metaData.SetComment("Preprocessor AliTPC data base entries.");
718 
719  Bool_t storeOK = Store("Calib", "GasComposition", fGasComposition, &metaData, 0, kFALSE);
720  if ( !storeOK ) result=1;
721 
722  }
723 
724  return result;
725 
726 }
727 
728 
729 //______________________________________________________________________________________________
730 
732 {
733  //
734  // Read pedestal file from file exchage server
735  // Keep original entry from OCDB in case no new pedestals are available
736  //
737  AliTPCCalPad *calPadPedOCDB=0;
738  AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
739  if (entry) calPadPedOCDB = (AliTPCCalPad*)entry->GetObject();
740  if ( calPadPedOCDB==NULL ) {
741  Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
742  }
743 
744  AliTPCCalPad *calPadRMSOCDB=0;
745  entry = GetFromOCDB("Calib", "PadNoise");
746  if (entry) calPadRMSOCDB = (AliTPCCalPad*)entry->GetObject();
747  if ( calPadRMSOCDB==NULL ) {
748  Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
749  }
750 
751  AliTPCCalPad* calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
752  AliTPCCalPad* calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
753 
754 
755  UInt_t result=0;
756 
757  Int_t nSectors = fROC->GetNSectors();
758  TVectorD foundSectorsPed(nSectors);
759  foundSectorsPed=0;
760  TVectorD foundSectorsRMS(nSectors);
761  foundSectorsRMS=0;
762 
763  TList* list = GetFileSources(sourceFXS,"pedestals");
764 
765  if (list && list->GetEntries()>0) {
766 
767 // loop through all files from LDCs
768 
769  Bool_t changed=false;
770  UInt_t index = 0;
771  while (list->At(index)!=NULL) {
772  TObjString* fileNameEntry = (TObjString*) list->At(index);
773  if (fileNameEntry!=NULL) {
774  TString fileName = GetFile(sourceFXS, "pedestals",
775  fileNameEntry->GetString().Data());
776  TFile *f = TFile::Open(fileName);
777  if (!f) {
778  Log ("Error opening pedestal file.");
779  result =2;
780  break;
781  }
782  AliTPCCalibPedestal *calPed;
783  f->GetObject("tpcCalibPedestal",calPed);
784  if ( !calPed ) {
785  Log ("No pedestal calibration object in file.");
786  result = 2;
787  break;
788  }
789 
790  // replace entries for the sectors available in the present file
791 
792  changed=true;
793  for (Int_t sector=0; sector<nSectors; sector++) {
794  AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
795  if ( rocPed ) {
796  AliTPCCalROC* roc=calPadPed->GetCalROC(sector);
797  roc->Add(rocPed,1);
798  foundSectorsPed[sector]++;
799  }
800  AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
801  if ( rocRMS ) {
802  AliTPCCalROC* roc=calPadRMS->GetCalROC(sector);
803  roc->Add(rocRMS,1);
804  foundSectorsRMS[sector]++;
805  }
806  }
807  delete calPed;
808  f->Close();
809  }
810  ++index;
811  } // while(list)
812 
813 //
814 // Check if calibration is complete -- otherwise take from old OCDB entry
815 
816 // inner sectors
817  for (Int_t sector=0; sector<nSectors/2; sector++) {
818  if (foundSectorsPed[sector] < 1 ) {
819  if (calPadPedOCDB) {
820  AliTPCCalROC *rocOCDB=calPadPedOCDB->GetCalROC(sector);
821  calPadPed->SetCalROC(rocOCDB,sector);
822  } else {
823  const int mess_length=100;
824  char message[mess_length];
825  snprintf(message,mess_length,"Missing pedestals for sector %d - also not available from previous OCDB entry.\n",
826  sector);
827  Log (message);
828  result = 2;
829  }
830  }
831  if (foundSectorsRMS[sector] < 1 ) {
832  if (calPadRMSOCDB) {
833  AliTPCCalROC *rocOCDB=calPadRMSOCDB->GetCalROC(sector);
834  calPadRMS->SetCalROC(rocOCDB,sector);
835  } else {
836  const int mess_length=100;
837  char message[mess_length];
838  snprintf(message,mess_length,"Missing pedestal RMS for sector %d - also not available from previous OCDB entry.\n",
839  sector);
840  Log (message);
841  result = 2;
842  }
843  }
844  }
845 
846 // outer sectors -- two updates needed
847 
848  for (Int_t sector=nSectors/2; sector<nSectors; sector++) {
849  if (foundSectorsPed[sector] < 2 ) {
850  if (calPadPedOCDB) {
851  AliTPCCalROC *rocOCDB=calPadPedOCDB->GetCalROC(sector);
852  calPadPed->SetCalROC(rocOCDB,sector);
853  } else {
854  const int mess_length=100;
855  char message[mess_length];
856  snprintf(message,mess_length,"Missing pedestals for sector %d - also not available from previous OCDB entry.\n",
857  sector);
858  Log (message);
859  result = 2;
860  }
861 
862  }
863  if (foundSectorsRMS[sector] < 2 ) {
864  if (calPadRMSOCDB) {
865  AliTPCCalROC *rocOCDB=calPadRMSOCDB->GetCalROC(sector);
866  calPadRMS->SetCalROC(rocOCDB,sector);
867  } else {
868  const int mess_length=100;
869  char message[mess_length];
870  snprintf(message,mess_length,"Missing pedestal RMS for sector %d - also not available from previous OCDB entry.\n",
871  sector);
872  Log (message);
873  result = 2;
874  }
875 
876  }
877  }
878 
879 
880 //
881 // Store updated pedestal entry to OCDB
882 //
883  if (changed) {
884  AliCDBMetaData metaData;
885  metaData.SetBeamPeriod(0);
886  metaData.SetResponsible("Haavard Helstrup");
887  metaData.SetAliRootVersion(ALIROOT_VERSION);
888  metaData.SetComment("Preprocessor AliTPC data base entries.");
889 
890  Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE ^ fForceSingleRun);
891  if ( !storeOK ) ++result;
892  storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE ^ fForceSingleRun);
893  if ( !storeOK ) ++result;
894  }
895  } else {
896  Log ("Error: no entries in pedestal file list!");
897  result = 1;
898  }
899 
900  delete calPadPed;
901  delete calPadRMS;
902  delete calPadPedOCDB;
903  delete calPadRMSOCDB;
904 
905  return result;
906 }
907 
908 //______________________________________________________________________________________________
909 
910 
911 UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS)
912 {
913  //
914  // Read pulser calibration file from file exchage server
915  // Keep original entry from OCDB in case no new pulser calibration is available
916  //
917 
918  TObjArray *pulserObjects = new TObjArray;
919  TObjArray *pulserObjectsOCDB=0;
920  pulserObjects->SetOwner(kTRUE);
921 
922 
923  AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser");
924  if (entry) pulserObjectsOCDB = (TObjArray*)entry->GetObject();
925  if ( pulserObjectsOCDB==NULL ) {
926  Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n");
927  } else {
928  pulserObjectsOCDB->SetOwner(kTRUE);
929  }
930 
931  AliTPCCalPad *pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean");
932  pulserObjects->Add(pulserTmean);
933 
934  AliTPCCalPad *pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms");
935  pulserObjects->Add(pulserTrms);
936 
937  AliTPCCalPad *pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean");
938  pulserObjects->Add(pulserQmean);
939 
940 
941 
942  UInt_t result=0;
943 
944  Int_t nSectors = fROC->GetNSectors();
945  TVectorD foundTmean(nSectors);
946  foundTmean=0;
947  TVectorD foundTrms(nSectors);
948  foundTrms=0;
949  TVectorD foundQmean(nSectors);
950  foundQmean=0;
951 
952 
953  TList* list = GetFileSources(sourceFXS,"pulser");
954 
955  if (list && list->GetEntries()>0) {
956 
957 // loop through all files from LDCs
958 
959  Bool_t changed=false;
960  UInt_t index = 0;
961  while (list->At(index)!=NULL) {
962  TObjString* fileNameEntry = (TObjString*) list->At(index);
963  if (fileNameEntry!=NULL) {
964  TString fileName = GetFile(sourceFXS, "pulser",
965  fileNameEntry->GetString().Data());
966  TFile *f = TFile::Open(fileName);
967  if (!f) {
968  Log ("Error opening pulser file.");
969  result =2;
970  break;
971  }
972  AliTPCCalibPulser *calPulser;
973  f->GetObject("tpcCalibPulser",calPulser);
974  if ( !calPulser ) {
975  Log ("No pulser calibration object in file.");
976  result = 2;
977  break;
978  }
979 
980  // replace entries for the sectors available in the present file
981 
982  changed=true;
983  for (Int_t sector=0; sector<nSectors; sector++) {
984  AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector);
985  if ( rocTmean ) {
986  AliTPCCalROC* roc=pulserTmean->GetCalROC(sector);
987  roc->Add(rocTmean,1);
988  foundTmean[sector]++;
989  }
990  AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector);
991  if ( rocTrms ) {
992  AliTPCCalROC* roc=pulserTrms->GetCalROC(sector);
993  roc->Add(rocTrms,1);
994  foundTrms[sector]++;
995  }
996  AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector);
997  if ( rocQmean ) {
998  AliTPCCalROC* roc=pulserQmean->GetCalROC(sector);
999  roc->Add(rocQmean,1);
1000  foundQmean[sector]++;
1001  }
1002  }
1003  delete calPulser;
1004  f->Close();
1005  }
1006  ++index;
1007  } // while(list)
1008 
1009 
1010 
1011 
1012 if (pulserObjectsOCDB) {
1013  AliTPCCalPad* pulserTmeanOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserTmean");
1014  AliTPCCalPad* pulserTrmsOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserTrms");
1015  AliTPCCalPad* pulserQmeanOCDB = (AliTPCCalPad*)pulserObjectsOCDB->FindObject("PulserQmean");
1016 
1017 //
1018 // Check if calibration is complete -- otherwise take from old OCDB entry
1019 
1020 // inner sectors
1021  for (Int_t sector=0; sector<nSectors/2; sector++) {
1022  if (foundTmean[sector] < 1 ) {
1023  if (pulserTmeanOCDB) {
1024  AliTPCCalROC* rocOCDB = pulserTmeanOCDB->GetCalROC(sector);
1025  if ( rocOCDB ) pulserTmean->SetCalROC(rocOCDB,sector);
1026  }
1027  }
1028  if (foundTrms[sector] < 1 ) {
1029  if (pulserTrmsOCDB) {
1030  AliTPCCalROC* rocOCDB = pulserTrmsOCDB->GetCalROC(sector);
1031  if ( rocOCDB ) pulserTrms->SetCalROC(rocOCDB,sector);
1032  }
1033  }
1034  if (foundQmean[sector] < 1 ) {
1035  if (pulserQmeanOCDB) {
1036  AliTPCCalROC* rocOCDB = pulserQmeanOCDB->GetCalROC(sector);
1037  if ( rocOCDB ) pulserQmean->SetCalROC(rocOCDB,sector);
1038  }
1039  }
1040  }
1041 
1042 // outer sectors -- two updates needed
1043 
1044  for (Int_t sector=0; sector<nSectors/2; sector++) {
1045  if (foundTmean[sector] < 2 ) {
1046  if (pulserTmeanOCDB) {
1047  AliTPCCalROC* rocOCDB = pulserTmeanOCDB->GetCalROC(sector);
1048  if ( rocOCDB ) pulserTmean->SetCalROC(rocOCDB,sector);
1049  }
1050  }
1051  if (foundTrms[sector] < 2 ) {
1052  if (pulserTrmsOCDB) {
1053  AliTPCCalROC* rocOCDB = pulserTrmsOCDB->GetCalROC(sector);
1054  if ( rocOCDB ) pulserTrms->SetCalROC(rocOCDB,sector);
1055  }
1056  }
1057  if (foundQmean[sector] < 2 ) {
1058  if (pulserQmeanOCDB) {
1059  AliTPCCalROC* rocOCDB = pulserQmeanOCDB->GetCalROC(sector);
1060  if ( rocOCDB ) pulserQmean->SetCalROC(rocOCDB,sector);
1061  }
1062  }
1063 
1064  }
1065 }
1066 
1067 //
1068 // Store updated pedestal entry to OCDB
1069 //
1070  if (changed) {
1071  AliCDBMetaData metaData;
1072  metaData.SetBeamPeriod(0);
1073  metaData.SetResponsible("Haavard Helstrup");
1074  metaData.SetAliRootVersion(ALIROOT_VERSION);
1075  metaData.SetComment("Preprocessor AliTPC data base entries.");
1076 
1077  Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE ^ fForceSingleRun);
1078  if ( !storeOK ) ++result;
1079  }
1080  } else {
1081  Log ("Error: no entries in pulser file list!");
1082  result = 1;
1083  }
1084  pulserObjects->Delete();
1085  delete pulserObjects;
1086  if (pulserObjectsOCDB) {
1087  pulserObjectsOCDB->Delete();
1088  }
1089  delete pulserObjectsOCDB;
1090 
1091  return result;
1092 }
1093 
1094 //______________________________________________________________________________________________
1095 
1096 
1097 UInt_t AliTPCPreprocessor::ExtractRaw(Int_t sourceFXS)
1098 {
1099  //
1100  // Read Raw calibration file from file exchage server
1101  //
1102 
1103  UInt_t result=0;
1104  TObjArray* rawArray = new TObjArray;
1105  rawArray->SetOwner(kTRUE);
1106 
1107  TList* list = GetFileSources(sourceFXS,"tpcCalibRaw");
1108 
1109  if (list && list->GetEntries()>0) {
1110 
1111 // loop through all files
1112 
1113  UInt_t index = 0;
1114  while (list->At(index)!=NULL) {
1115  TObjString* fileNameEntry = (TObjString*) list->At(index);
1116  if (fileNameEntry!=NULL) {
1117  TString fileName = GetFile(sourceFXS, "tpcCalibRaw",
1118  fileNameEntry->GetString().Data());
1119  TFile *f = TFile::Open(fileName);
1120  if (!f) {
1121  Log ("Error opening raw file.");
1122  result =2;
1123  break;
1124  }
1125  AliTPCCalibRaw *calRaw;
1126  f->GetObject("tpcCalibRaw",calRaw);
1127  if ( !calRaw ) {
1128  Log ("No raw calibration object in file.");
1129  result = 2;
1130  break;
1131  }
1132  rawArray->Add(calRaw);
1133  f->Close();
1134  }
1135  ++index;
1136  } // while(list)
1137 //
1138 // Store updated pedestal entry to OCDB
1139 //
1140  AliCDBMetaData metaData;
1141  metaData.SetBeamPeriod(0);
1142  metaData.SetResponsible("Haavard Helstrup");
1143  metaData.SetAliRootVersion(ALIROOT_VERSION);
1144  metaData.SetComment("Preprocessor AliTPC data base entries.");
1145 
1146  Bool_t storeOK = Store("Calib", "Raw", rawArray, &metaData, 0, kTRUE ^ fForceSingleRun);
1147  if ( !storeOK ) ++result;
1148  } else {
1149  Log ("Error: no entries in raw file list!");
1150  result = 1;
1151  }
1152 
1153  rawArray->Delete();
1154  delete rawArray;
1155 
1156  return result;
1157 }
1158 //______________________________________________________________________________________________
1159 
1160 UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS)
1161 {
1162  //
1163  // Read Central Electrode file from file exchage server
1164  //
1165  //
1166  AliTPCCalPad *ceTmean=0;
1167  AliTPCCalPad *ceTrms=0;
1168  AliTPCCalPad *ceQmean=0;
1169  TObjArray *rocTtime=0;
1170  TObjArray *rocQtime=0;
1171 
1172  TObjArray *ceObjects= new TObjArray;
1173  ceObjects->SetOwner(kTRUE);
1174 
1175  Int_t nSectors = fROC->GetNSectors();
1176 
1177  ceTmean = new AliTPCCalPad("CETmean","CETmean");
1178  ceObjects->Add(ceTmean);
1179 
1180  ceTrms = new AliTPCCalPad("CETrms","CETrms");
1181  ceObjects->Add(ceTrms);
1182 
1183  ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
1184  ceObjects->Add(ceQmean);
1185 
1186  rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
1187  rocTtime->SetName("rocTtime");
1188  ceObjects->Add(rocTtime);
1189  rocTtime->SetOwner(kTRUE);
1190 
1191  rocQtime = new TObjArray(nSectors);
1192  rocQtime->SetName("rocQtime");
1193  ceObjects->Add(rocQtime);
1194  rocQtime->SetOwner(kTRUE);
1195 
1196  //=== new part
1197  TObjArray *arrFitGraphs=new TObjArray;
1198  arrFitGraphs->SetName("ceFitsDrift");
1199  ceObjects->Add(arrFitGraphs);
1200  arrFitGraphs->SetOwner(kTRUE);
1201 
1202 // Temperature maps
1203 
1204  if (fTemp) {
1206  tempMap->SetNameTitle("TempMap","TempMap");
1207  ceObjects->Add(tempMap);
1208  }
1209 
1210 // Pressure maps
1211 
1212  if (fPressure) {
1213  AliDCSSensor *sensor=0, *sensorCopy=0;
1214  for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
1215  sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
1216  if (sensor) {
1217  sensorCopy = new AliDCSSensor(*sensor);
1218  sensorCopy->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
1219  ceObjects->Add(sensorCopy);
1220  }
1221  }
1222  }
1223 
1224  UInt_t result=0;
1225 
1226  TList* list = GetFileSources(sourceFXS,"CE");
1227 
1228  if (list && list->GetEntries()>0) {
1229 
1230 // loop through all files from LDCs
1231 
1232  UInt_t index = 0;
1233  while (list->At(index)!=NULL) {
1234  TObjString* fileNameEntry = (TObjString*) list->At(index);
1235  if (fileNameEntry!=NULL) {
1236  TString fileName = GetFile(sourceFXS, "CE",
1237  fileNameEntry->GetString().Data());
1238  AliTPCCalibCE *calCE=AliTPCCalibCE::ReadFromFile(fileName.Data());
1239 
1240  if (!calCE) {
1241  Log ("No valid calibCE object.");
1242  result=2;
1243  break;
1244  }
1245  // replace entries for the sectors available in the present file
1246 
1247  for (Int_t sector=0; sector<nSectors; sector++) {
1248  AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
1249  if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
1250  AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
1251  if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
1252  AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
1253  if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
1254  TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
1255  if ( grT ) rocTtime->AddAt(grT,sector);
1256  TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
1257  if ( grQ ) rocQtime->AddAt(grQ,sector);
1258  }
1259 
1260  TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
1261  if ( grT ) {
1262  rocTtime->AddAt(grT,nSectors);
1263  } else {
1264  result=10;
1265  }
1266  grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
1267  if ( grT ) {
1268  rocTtime->AddAt(grT,nSectors+1);
1269  } else {
1270  result=10;
1271  }
1272 
1273  // calCE->Delete();
1274  delete calCE;
1275  }
1276  ++index;
1277  } // while(list)
1278 //
1279 // Check number of calibrated sectors per side
1280 //
1281  Int_t aside=0, cside=0;
1282  for (Int_t ind=0; ind<nSectors/4; ind++ ) {
1283  TGraph *grT=(TGraph*)rocTtime->At(ind);
1284  if (grT) aside++;
1285  grT=(TGraph*)rocTtime->At(ind+nSectors/2);
1286  if (grT) aside++;
1287  grT=(TGraph*)rocTtime->At(ind+nSectors/4);
1288  if (grT) cside++;
1289  grT=(TGraph*)rocTtime->At(ind+3*nSectors/4);
1290  if (grT) cside++;
1291  }
1292  if ( (aside<kMinCESectors) && (cside<kMinCESectors) ) {
1293  Log (Form("ExtractCE: Too few fitted sectors: Aside =%d, Cside=%d\n",
1294  aside, cside)) ;
1295  result=10;
1296  }
1297 
1298  //
1299  //=== New CE part
1300  // if it is validated this part needs to be modified again
1301  // currently its only processed if there is a valid standard CE object
1302  //
1303  list = GetFileSources(sourceFXS,"CEnew");
1304 
1305  if (result==0 && list && list->GetEntries()>0) {
1306 
1307 // loop through all files from LDCs
1308 
1309  UInt_t index2 = 0;
1310  while (list->At(index2)!=NULL) {
1311  TObjString* fileNameEntry = (TObjString*) list->At(index2);
1312  if (fileNameEntry!=NULL) {
1313  TString fileName = GetFile(sourceFXS, "CEnew",
1314  fileNameEntry->GetString().Data());
1315  AliTPCCalibCE *calCE=AliTPCCalibCE::ReadFromFile(fileName.Data());
1316 
1317  if (!calCE) {
1318  Log ("No valid new calibCE object.");
1319 // result=2;
1320  break;
1321  }
1322 
1323  TIter nextObj(calCE->GetArrFitGraphs());
1324  TObject *obj=0x0;
1325  while ( (obj=nextObj()) ){
1326  arrFitGraphs->Add(obj->Clone());
1327  }
1328 // calCE->Delete();
1329  delete calCE;
1330  }
1331  ++index2;
1332  }
1333  }
1334 
1335 //
1336 // Store updated pedestal entry to OCDB
1337 //
1338  AliCDBMetaData metaData;
1339  metaData.SetBeamPeriod(0);
1340  metaData.SetResponsible("Haavard Helstrup");
1341  metaData.SetAliRootVersion(ALIROOT_VERSION);
1342  metaData.SetComment("Preprocessor AliTPC data base entries.");
1343 
1344  if ( result == 0 ) {
1345  Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE ^ fForceSingleRun);
1346  if ( !storeOK ) ++result;
1347  } else {
1348  Log ("Warning: Average time graphs not available - no OCDB entry written");
1349  }
1350  } else {
1351  Log ("Error: no CE entries available from FXS!");
1352  result = 1;
1353  }
1354 
1355  ceObjects->Delete();
1356  delete ceObjects;
1357 
1358  return result;
1359 }
1360 //______________________________________________________________________________________________
1361 
1362 UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
1363 {
1364  //
1365  // Read Quality Assurance file from file exchage server
1366  //
1367 
1368  UInt_t result=0;
1369 
1370  TList* list = GetFileSources(sourceFXS,"QA");
1371 
1372  if (list && list->GetEntries()>0) {
1373 
1374 // only one QA object should be available!
1375 
1376  AliTPCdataQA *calQA;
1377 
1378  UInt_t nentries = list->GetEntries();
1379  UInt_t index=0;
1380  if ( nentries > 1) Log ( "More than one QA entry. First one processed");
1381  TObjString* fileNameEntry = (TObjString*) list->At(index);
1382  if (fileNameEntry!=NULL) {
1383  TString fileName = GetFile(sourceFXS, "QA",
1384  fileNameEntry->GetString().Data());
1385  TFile *f = TFile::Open(fileName);
1386  if (!f) {
1387  Log ("Error opening QA file.");
1388  result =2;
1389  } else {
1390  f->GetObject("tpcCalibQA",calQA);
1391  if ( calQA ) {
1392 //
1393 // Store updated pedestal entry to OCDB
1394 //
1395  AliCDBMetaData metaData;
1396  metaData.SetBeamPeriod(0);
1397  metaData.SetResponsible("Haavard Helstrup");
1398  metaData.SetAliRootVersion(ALIROOT_VERSION);
1399  metaData.SetComment("Preprocessor AliTPC data base entries.");
1400 
1401  Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
1402  if ( !storeOK ) ++result;
1403 
1404  delete calQA;
1405  }
1406  }
1407  } else {
1408  Log ("Error: no QA files on FXS!");
1409  result = 2;
1410  }
1411  } else {
1412  Log ("Error: no QA entries in FXS list!");
1413  result = 1;
1414  }
1415  return result;
1416 }
1417 
1418 //______________________________________________________________________________________________
1419 
1420 
1421 UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS, TMap* dcsMap)
1422 {
1423  //
1424  // Read Altro configuration file from file exchage server
1425  // Keep original entry from OCDB in case no new pulser calibration is available
1426  //
1427  TObjArray *altroObjects=0;
1428  AliTPCCalPad *acqStart=0;
1429  AliTPCCalPad *zsThr=0;
1430  AliTPCCalPad *acqStop=0;
1431  AliTPCCalPad *FPED=0;
1432  AliTPCCalPad *masked=0;
1433  AliTPCCalPad *k1=0, *k2=0, *k3=0;
1434  AliTPCCalPad *l1=0, *l2=0, *l3=0;
1435  TMap *mapRCUconfig=0;
1436 
1437  AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
1438  if (entry) altroObjects = (TObjArray*)entry->GetObject();
1439  if ( altroObjects==NULL ) {
1440  Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
1441  altroObjects = new TObjArray;
1442  }
1443  altroObjects->SetOwner(kTRUE);
1444 
1445  acqStart = (AliTPCCalPad*)altroObjects->FindObject("AcqStart");
1446  if ( !acqStart ) {
1447  acqStart = new AliTPCCalPad("AcqStart","AcqStart");
1448  altroObjects->Add(acqStart);
1449  }
1450  zsThr = (AliTPCCalPad*)altroObjects->FindObject("ZsThr");
1451  if ( !zsThr ) {
1452  zsThr = new AliTPCCalPad("ZsThr","ZsThr");
1453  altroObjects->Add(zsThr);
1454  }
1455  FPED = (AliTPCCalPad*)altroObjects->FindObject("FPED");
1456  if ( !FPED ) {
1457  FPED = new AliTPCCalPad("FPED","FPED");
1458  altroObjects->Add(FPED);
1459  }
1460  acqStop = (AliTPCCalPad*)altroObjects->FindObject("AcqStop");
1461  if ( !acqStop ) {
1462  acqStop = new AliTPCCalPad("AcqStop","AcqStop");
1463  altroObjects->Add(acqStop);
1464  }
1465  masked = (AliTPCCalPad*)altroObjects->FindObject("Masked");
1466  if ( !masked ) {
1467  masked = new AliTPCCalPad("Masked","Masked");
1468  altroObjects->Add(masked);
1469  }
1470  k1 = (AliTPCCalPad*)altroObjects->FindObject("K1");
1471  if ( !k1 ) {
1472  k1 = new AliTPCCalPad("K1","K1");
1473  altroObjects->Add(k1);
1474  }
1475  k2 = (AliTPCCalPad*)altroObjects->FindObject("K2");
1476  if ( !k2 ) {
1477  k2 = new AliTPCCalPad("K2","K2");
1478  altroObjects->Add(k2);
1479  }
1480  k3 = (AliTPCCalPad*)altroObjects->FindObject("K3");
1481  if ( !k3 ) {
1482  k3 = new AliTPCCalPad("K3","K3");
1483  altroObjects->Add(k3);
1484  }
1485  l1 = (AliTPCCalPad*)altroObjects->FindObject("L1");
1486  if ( !l1 ) {
1487  l1 = new AliTPCCalPad("L1","L1");
1488  altroObjects->Add(l1);
1489  }
1490  l2 = (AliTPCCalPad*)altroObjects->FindObject("L2");
1491  if ( !l2 ) {
1492  l2 = new AliTPCCalPad("L2","L2");
1493  altroObjects->Add(l2);
1494  }
1495  l3 = (AliTPCCalPad*)altroObjects->FindObject("L3");
1496  if ( !l3 ) {
1497  l3 = new AliTPCCalPad("L3","L3");
1498  altroObjects->Add(l3);
1499  }
1500  mapRCUconfig = (TMap*)altroObjects->FindObject("RCUconfig");
1501  if (!mapRCUconfig) {
1502  mapRCUconfig = new TMap();
1503  mapRCUconfig->SetName("RCUconfig");
1504  altroObjects->Add(mapRCUconfig);
1505  }
1506 
1507 
1508  UInt_t result=0;
1509  TString idFXS[2]={"AltroConfigA","AltroConfigC"};
1510 
1511  Int_t nSectors = fROC->GetNSectors();
1512  Bool_t changed=false;
1513  if (altroObjects == 0 ) altroObjects = new TObjArray;
1514  altroObjects->SetOwner(kTRUE);
1515 
1516 // extract list of active DDLs
1517 
1518  if (dcsMap) {
1519  Bool_t found;
1520  TString arrDDL(kNumDDL);
1521  arrDDL.Append('x',kNumDDL);
1522  for ( Int_t iDDL = 0; iDDL<kNumDDL; iDDL++ ) {
1523  TString stringID = Form (kAmandaDDL.Data(),iDDL+kFirstDDL);
1524  TPair *pair = (TPair*)dcsMap->FindObject(stringID.Data());
1525  found = false;
1526  if ( pair ) {
1527  TObjArray *valueSet=(TObjArray*)pair->Value();
1528  if ( valueSet) {
1529  AliDCSValue *val = (AliDCSValue*)valueSet->At(0);
1530  if (val) {
1531  found = val->GetBool();
1532  if (found){
1533  arrDDL[iDDL] = '1';
1534  } else {
1535  arrDDL[iDDL] = '0';
1536  }
1537  }
1538  }
1539  }
1540  }
1541  TObjString *ddlArray = new TObjString;
1542  ddlArray->SetString(arrDDL);
1543  TMap *activeDDL = new TMap;
1544  activeDDL->SetName("DDLArray");
1545  TObjString *key = new TObjString("DDLArray");
1546  activeDDL->Add(key,ddlArray);
1547  altroObjects->Add(activeDDL);
1548  changed=true;
1549  } else {
1550  Log ("ExtractAltro: No DCS map available. Active DDL list cannot be obtained.");
1551  result = 3;
1552  }
1553 
1554 // extract Altro configuration files
1555 
1556  for ( Int_t id=0; id<2; id++) {
1557  TList* list = GetFileSources(sourceFXS,idFXS[id].Data());
1558 
1559  if (list && list->GetEntries()>0) {
1560 
1561 // loop through all files from LDCs
1562 
1563  UInt_t index = 0;
1564  while (list->At(index)!=NULL) {
1565  TObjString* fileNameEntry = (TObjString*) list->At(index);
1566  if (fileNameEntry!=NULL) {
1567  TString fileName = GetFile(sourceFXS, idFXS[id].Data(),
1568  fileNameEntry->GetString().Data());
1569  TFile *f = TFile::Open(fileName);
1570  if (!f) {
1571  const int mess_length=40;
1572  char message[mess_length];
1573  snprintf(message,mess_length,"Error opening Altro configuration file, id = %d",id);
1574  Log (message);
1575  result =2;
1576  break;
1577  }
1578  TObjArray *altroFXS;
1579  f->GetObject("AltroConfig",altroFXS);
1580  if ( !altroFXS ) {
1581  Log ("No Altro configuration object in file.");
1582  result = 2;
1583  break;
1584  }
1585 
1586  // replace entries for the sectors available in the present file
1587  AliTPCCalPad *acqStartFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStart");
1588  AliTPCCalPad *zsThrFXS=(AliTPCCalPad*)altroFXS->FindObject("ZsThr");
1589  AliTPCCalPad *acqStopFXS=(AliTPCCalPad*)altroFXS->FindObject("AcqStop");
1590  AliTPCCalPad *FPEDFXS=(AliTPCCalPad*)altroFXS->FindObject("FPED");
1591  AliTPCCalPad *maskedFXS=(AliTPCCalPad*)altroFXS->FindObject("Masked");
1592  AliTPCCalPad *k1FXS=(AliTPCCalPad*)altroFXS->FindObject("K1");
1593  AliTPCCalPad *k2FXS=(AliTPCCalPad*)altroFXS->FindObject("K2");
1594  AliTPCCalPad *k3FXS=(AliTPCCalPad*)altroFXS->FindObject("K3");
1595  AliTPCCalPad *l1FXS=(AliTPCCalPad*)altroFXS->FindObject("L1");
1596  AliTPCCalPad *l2FXS=(AliTPCCalPad*)altroFXS->FindObject("L2");
1597  AliTPCCalPad *l3FXS=(AliTPCCalPad*)altroFXS->FindObject("L3");
1598  TMap *mapRCUconfigFXS = (TMap*)altroFXS->FindObject("RCUconfig");
1599  TIterator *mapFXSiter = mapRCUconfigFXS->MakeIterator();
1600 
1601  changed=true;
1602  for (Int_t sector=0; sector<nSectors; sector++) {
1603 
1604  if (acqStartFXS) {
1605  AliTPCCalROC *rocAcqStart=acqStartFXS->GetCalROC(sector);
1606  if ( rocAcqStart ) acqStart->SetCalROC(rocAcqStart,sector);
1607  }
1608  if (zsThrFXS ) {
1609  AliTPCCalROC *rocZsThr=zsThrFXS->GetCalROC(sector);
1610  if ( rocZsThr ) zsThr->SetCalROC(rocZsThr,sector);
1611  }
1612  if (acqStopFXS) {
1613  AliTPCCalROC *rocAcqStop=acqStopFXS->GetCalROC(sector);
1614  if ( rocAcqStop ) acqStop->SetCalROC(rocAcqStop,sector);
1615  }
1616  if (FPEDFXS ) {
1617  AliTPCCalROC *rocFPED=FPEDFXS->GetCalROC(sector);
1618  if ( rocFPED ) FPED->SetCalROC(rocFPED,sector);
1619  }
1620  if (maskedFXS) {
1621  AliTPCCalROC *rocMasked=maskedFXS->GetCalROC(sector);
1622  if ( rocMasked ) masked->SetCalROC(rocMasked,sector);
1623  }
1624  if (k1FXS) {
1625  AliTPCCalROC *rocK1=k1FXS->GetCalROC(sector);
1626  if ( rocK1 ) k1->SetCalROC(rocK1,sector);
1627  }
1628  if (k2FXS) {
1629  AliTPCCalROC *rocK2=k2FXS->GetCalROC(sector);
1630  if ( rocK2 ) k2->SetCalROC(rocK2,sector);
1631  }
1632  if (k3FXS) {
1633  AliTPCCalROC *rocK3=k3FXS->GetCalROC(sector);
1634  if ( rocK3 ) k3->SetCalROC(rocK3,sector);
1635  }
1636  if (l1FXS) {
1637  AliTPCCalROC *rocL1=l1FXS->GetCalROC(sector);
1638  if ( rocL1 ) l1->SetCalROC(rocL1,sector);
1639  }
1640  if (l2FXS) {
1641  AliTPCCalROC *rocL2=l2FXS->GetCalROC(sector);
1642  if ( rocL2 ) l2->SetCalROC(rocL2,sector);
1643  }
1644  if (l3FXS) {
1645  AliTPCCalROC *rocL3=l3FXS->GetCalROC(sector);
1646  if ( rocL3 ) l3->SetCalROC(rocL3,sector);
1647  }
1648  }
1649  if (mapRCUconfigFXS) {
1650  Int_t mapEntries = mapRCUconfigFXS->GetEntries();
1651  TObjString* keyFXS;
1652  TVectorF* vecFXS;
1653  TVectorF* vec; // nSectors = 72 (total number of inner/outer sectors)
1654  for (Int_t i=0; i<mapEntries; ++i) {
1655  keyFXS=(TObjString*)mapFXSiter->Next();
1656  vecFXS=(TVectorF*)mapRCUconfigFXS->GetValue(keyFXS);
1657  vec=(TVectorF*)mapRCUconfig->GetValue(keyFXS);
1658  if (!vec) {
1659  vec = new TVectorF(3*nSectors);
1660  *vec = -1;
1661  mapRCUconfig->Add(keyFXS,vec);
1662  }
1663  if (vec->GetNoElements() != 3*nSectors ) {
1664  vec->ResizeTo(3*nSectors);
1665  }
1666  if (id==0) { // A side
1667  vec->SetSub(0,vecFXS->GetSub(0,nSectors/2-1));
1668  vec->SetSub(nSectors,vecFXS->GetSub(nSectors,2*nSectors-1));
1669  } else { // C side
1670  vec->SetSub(nSectors/2,vecFXS->GetSub(nSectors/2,nSectors-1));
1671  vec->SetSub(2*nSectors,vecFXS->GetSub(2*nSectors,3*nSectors-1));
1672  }
1673  }
1674  }
1675  altroFXS->Delete();
1676  delete altroFXS;
1677  f->Close();
1678  }
1679  ++index;
1680  } // while(list)
1681  } else {
1682  Log ("Error: no entries in AltroConfig file list!");
1683  result = 1;
1684  }
1685 
1686  } // for - id
1687 //
1688 // Store updated pedestal entry to OCDB
1689 //
1690  if (changed) {
1691  AliCDBMetaData metaData;
1692  metaData.SetBeamPeriod(0);
1693  metaData.SetResponsible("Haavard Helstrup");
1694  metaData.SetAliRootVersion(ALIROOT_VERSION);
1695  metaData.SetComment("Preprocessor AliTPC data base entries.");
1696 
1697  Bool_t storeOK = Store("Calib", "AltroConfig", altroObjects, &metaData, 0, kFALSE);
1698  if ( !storeOK ) ++result;
1699  }
1700 
1701  altroObjects->Delete();
1702  delete altroObjects;
1703 
1704  return result;
1705 }
const TString kPedestalRunType
UInt_t MapPressure(TMap *dcsAliasMap)
AliTPCROC * fROC
TPC Read-Out configuration.
Bool_t Store(const char *pathLevel2, const char *pathLevel3, TObject *object, AliCDBMetaData *metaData, Int_t validityStart=0, Bool_t validityInfinite=kFALSE)
const char * GetRunParameter(const char *param)
TList * GetFileSources(Int_t system, const char *id=0)
UInt_t ExtractPedestals(Int_t sourceFXS)
AliTPCCalROC * GetCalRocRMS(Int_t sector, Bool_t force=kFALSE)
TFile * Open(const char *filename, Long64_t &nevents)
AliDCSSensorArray * fPressure
Pressure values from DCS.
AliTPCCalROC * GetCalROC(Int_t sector) const
Definition: AliTPCCalPad.h:39
Bool_t fForceSingleRun
Force single run validity for all object, required for manual reprocessing.
AliTPCPreprocessor & operator=(const AliTPCPreprocessor &rhs)
void Add(Float_t c1)
#define TObjArray
TVectorD vec
Definition: AnalyzeLaser.C:8
Int_t NumSensors() const
AliCDBEntry * GetFromOCDB(const char *pathLevel2, const char *pathLevel3)
void MakeSplineFit(TMap *map, Bool_t keepMap=kFALSE)
void SetCalROC(AliTPCCalROC *roc, Int_t sector=-1)
const TString kPhysicsRunType
Implementation of the TPC pedestal calibration.
const char * kPressureSensorNames[kNumPressureSensors]
const Int_t kDiffCutTemp
AliTPCCalROC * GetCalRocRMS(Int_t sector, Bool_t force=kFALSE)
void SetComment(const char *comment)
void SetGraph(TMap *map)
const TString kStandaloneRunType
void SetStringID(const TString &stringID)
Definition: AliDCSSensor.h:58
const char * GetFile(Int_t system, const char *id, const char *source)
TMap * ExtractDCS(TMap *dcsMap, Bool_t keepStart=kFALSE)
UInt_t ExtractCE(Int_t sourceFXS)
void SetResponsible(const char *yourName)
AliDCSSensor * GetSensor(Int_t IdDCS)
void AddSensors(AliDCSSensorArray *sensors)
const Int_t kNumDDL
const Int_t kNumPressureSensors
AliTPCPreprocessor(AliShuttleInterface *shuttle)
const Int_t kValCutTemp
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
const TString kPulserRunType
const TString kDaqRunType
TObjArray * array
Definition: AnalyzeLaser.C:12
AliDCSSensorArray * fGasComposition
Gas composition values from DCS.
Implementation of the TPC pulser calibration.
const TString kAmandaTemp
Bool_t fConfigOK
Identify succesful reading of OCDB Config.
const TString kLaserRunType
TObject * GetObject()
Definition: AliCDBEntry.h:56
UInt_t ExtractAltro(Int_t sourceFXS, TMap *dcsAliasMap)
void SetBeamPeriod(UInt_t period)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
AliDCSSensorArray * fGoofie
Goofie values from DCS.
const TString kAmandaDDL
AliTPCCalROC * GetCalRocPedestal(Int_t sector, Bool_t force=kFALSE)
#define AliInfo(message)
Definition: AliLog.h:484
AliTPCCalROC * GetCalRocQ(Int_t sector, Bool_t force=kFALSE)
UInt_t ExtractPulser(Int_t sourceFXS)
TEnv * fConfEnv
Preprocessor configuration map.
const Int_t kFirstDDL
AliTPCCalROC * GetCalRocT0(Int_t sector, Bool_t force=kFALSE)
test preprocessor that writes data to AliTestDataDCS
void Log(const char *message, UInt_t level=3)
void SetAliRootVersion(const char *version)
UInt_t MapGasComposition(TMap *dcsAliasMap)
UInt_t MapHighVoltage(TMap *dcsAliasMap)
const Int_t kMinCESectors
TPC calibration base class for one ROC.
Definition: AliTPCCalROC.h:20
UInt_t MapGoofie(TMap *dcsAliasMap)
void SetValCut(const Int_t valCut)
AliDCSSensorArray * fHighVoltageStat
DCS high voltage status.
virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
const char * GetRunType()
const Double_t kFitFraction
Definition: AliCDBEntry.h:18
virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
const Double_t kHighVoltageDifference
TF1 * f
Definition: interpolTest.C:21
Int_t NumFits() const
Bool_t GetBool() const
const Double_t kGasCompositionDifference
void SetDiffCut(const Int_t diffCut)
const TString kCosmicRunType
TPC calibration class for parameters which saved per pad.
AliDCSSensorArray * fHighVoltage
DCS high voltage measurements.
static AliTPCROC * Instance()
Definition: AliTPCROC.cxx:34
Implementation of the TPC Central Electrode calibration.
Definition: AliTPCCalibCE.h:29
AliTPCSensorTempArray * fTemp
CDB class for temperature sensors.
UInt_t GetNSectors() const
Definition: AliTPCROC.h:27
void RemoveGraphDuplicates(Double_t tolerance=1e-6)
UInt_t ExtractRaw(Int_t sourceFXS)
static AliTPCCalibCE * ReadFromFile(const Char_t *filename)
virtual UInt_t Process(TMap *dcsAliasMap)
UInt_t ExtractQA(Int_t sourceFXS)
UInt_t MapTemperature(TMap *dcsAliasMap)
Implementation of the TPC Raw drift velocity and Altro L1 Phase calibration.