1 /**************************************************************************
2 * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliTPCPreprocessor.h"
18 #include "AliShuttleInterface.h"
20 #include "AliCDBMetaData.h"
21 #include "AliDCSValue.h"
23 #include "AliTPCSensorTempArray.h"
24 #include "AliTPCROC.h"
25 #include "AliTPCCalROC.h"
26 #include "AliTPCCalPad.h"
27 #include "AliTPCCalibPedestal.h"
32 #include <TTimeStamp.h>
34 const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
35 const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
36 const TString kPedestalRunType = "PEDESTAL_RUN"; // pedestal run identifier
39 // This class is the SHUTTLE preprocessor for the TPC detector.
40 // It contains several components, this far the part containing
41 // temperatures is implemented
44 ClassImp(AliTPCPreprocessor)
46 //______________________________________________________________________________________________
47 AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
48 AliPreprocessor("TPC",shuttle),
49 fConfEnv(0), fTemp(0), fPressure(0), fConfigOK(kTRUE), fROC(0)
52 fROC = AliTPCROC::Instance();
54 //______________________________________________________________________________________________
55 // AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) :
56 // AliPreprocessor(org),
57 // fConfEnv(0), fTemp(0), fPressure(0), fConfigOK(kTRUE)
59 // // copy constructor not implemented
60 // // -- missing underlying copy constructor in AliPreprocessor
62 // Fatal("AliTPCPreprocessor", "copy constructor not implemented");
64 // // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
67 //______________________________________________________________________________________________
68 AliTPCPreprocessor::~AliTPCPreprocessor()
75 //______________________________________________________________________________________________
76 AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
78 Fatal("operator =", "assignment operator not implemented");
83 //______________________________________________________________________________________________
84 void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
87 // Creates AliTestDataDCS object
89 AliPreprocessor::Initialize(run, startTime, endTime);
91 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
92 TTimeStamp(startTime).AsString(),
93 TTimeStamp(endTime).AsString()));
95 // Preprocessor configuration
97 AliCDBEntry* entry = GetFromOCDB("Config", "Temperature");
98 if (entry) fConfEnv = (TEnv*) entry->GetObject();
100 AliWarning(Form("Preprocessor Config OCDB entry missing.\n"));
101 Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n");
104 // Temperature sensors
107 entry = GetFromOCDB("Config", "Temperature");
108 if (entry) confTree = (TTree*) entry->GetObject();
110 AliError(Form("Temperature Config OCDB entry missing.\n"));
111 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
115 fTemp = new AliTPCSensorTempArray(fStartTime, fEndTime, confTree);
116 fTemp->SetValCut(kValCutTemp);
117 fTemp->SetDiffCut(kDiffCutTemp);
123 entry = GetFromOCDB("Config", "Pressure");
124 if (entry) confTree = (TTree*) entry->GetObject();
126 AliError(Form("Pressure Config OCDB entry missing.\n"));
127 Log("AliTPCPreprocsessor: Pressure Config OCDB entry missing.\n");
131 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, confTree);
135 //______________________________________________________________________________________________
136 UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
138 // Fills data into TPC calibrations objects
140 // Amanda servers provide information directly through dcsAliasMap
142 if (!dcsAliasMap) return 9;
143 if (dcsAliasMap->GetEntries() == 0 ) return 9;
144 if (!fConfigOK) return 9;
146 TString runType = GetRunType();
148 // Temperature sensors are processed by AliTPCCalTemp
151 UInt_t tempResult = MapTemperature(dcsAliasMap);
152 UInt_t result=tempResult;
156 UInt_t pressureResult = MapPressure(dcsAliasMap);
157 result += pressureResult;
159 // Other calibration information will be retrieved through FXS files
161 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
162 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
164 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
165 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
168 if(runType == kPedestalRunType) {
169 Int_t pedestalSource = AliShuttleInterface::kDAQ;
170 TString source = fConfEnv->GetValue("Pedestal","DAQ");
172 if ( source == "HLT" ) pedestalSource = AliShuttleInterface::kHLT;
173 UInt_t pedestalResult = ExtractPedestals(pedestalSource);
174 result += pedestalResult;
181 //______________________________________________________________________________________________
182 UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
185 // extract DCS temperature maps. Perform fits to save space
188 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
190 fTemp->MakeSplineFit(map);
191 AliInfo(Form("Temperature values extracted, fits performed.\n"));
193 AliError(Form("No temperature map extracted.\n"));
194 Log("AliTPCPreprocsessor: no temperature map extracted. \n");
198 // Now store the final CDB file
201 AliCDBMetaData metaData;
202 metaData.SetBeamPeriod(0);
203 metaData.SetResponsible("Haavard Helstrup");
204 metaData.SetComment("Preprocessor AliTPC data base entries.");
206 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
207 if ( !storeOK ) result=1;
214 //______________________________________________________________________________________________
216 UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
219 // extract DCS temperature maps. Perform fits to save space
222 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
224 fPressure->MakeSplineFit(map);
225 AliInfo(Form("Pressure values extracted, fits performed.\n"));
227 AliError(Form("No atmospheric pressure map extracted.\n"));
228 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
232 // Now store the final CDB file
235 AliCDBMetaData metaData;
236 metaData.SetBeamPeriod(0);
237 metaData.SetResponsible("Haavard Helstrup");
238 metaData.SetComment("Preprocessor AliTPC data base entries.");
240 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
241 if ( !storeOK ) result=1;
250 //______________________________________________________________________________________________
252 UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS)
255 // Read pedestal file from file exchage server
256 // Keep original entry from OCDB in case no new pedestals are available
258 AliTPCCalPad *calPadPed=0;
259 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
260 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
261 if ( calPadPed==NULL ) {
262 AliWarning(Form("No previous TPC pedestal entry available.\n"));
263 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
264 calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean");
267 AliTPCCalPad *calPadRMS=0;
268 entry = GetFromOCDB("Calib", "Noise");
269 if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject();
270 if ( calPadRMS==NULL ) {
271 AliWarning(Form("No previous TPC noise entry available.\n"));
272 Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n");
273 calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS");
279 Int_t nSectors = fROC->GetNSectors();
280 TList* list = GetFileSources(sourceFXS,"pedestals");
283 // loop through all files from LDCs
286 while (list->At(index)!=NULL) {
287 TObjString* fileNameEntry = (TObjString*) list->At(index);
288 if (fileNameEntry!=NULL) {
289 TString fileName = GetFile(sourceFXS, "pedestals",
290 fileNameEntry->GetString().Data());
291 TFile *f = TFile::Open(fileName);
292 AliTPCCalibPedestal *calPed;
293 f->GetObject("AliTPCCalibPedestal",calPed);
295 // replace entries for the sectors available in the present file
297 for (Int_t sector=0; sector<nSectors; sector++) {
298 AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE);
299 if ( rocPed ) calPadPed->SetCalROC(rocPed,sector);
300 AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE);
301 if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector);
307 // Store updated pedestal entry to OCDB
309 AliCDBMetaData metaData;
310 metaData.SetBeamPeriod(0);
311 metaData.SetResponsible("Haavard Helstrup");
312 metaData.SetComment("Preprocessor AliTPC data base entries.");
314 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
315 if ( !storeOK ) ++result;
316 storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE);
317 if ( !storeOK ) ++result;
324 //______________________________________________________________________________________________