]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPreprocessor.cxx
Corrections made for the fact that recpoint CS doesn't coincide with the module CS
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessor.cxx
CommitLineData
54472e4f 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
72df5829 16
54472e4f 17#include "AliTPCPreprocessor.h"
a7dce0bc 18#include "AliShuttleInterface.h"
54472e4f 19
20#include "AliCDBMetaData.h"
21#include "AliDCSValue.h"
22#include "AliLog.h"
23#include "AliTPCSensorTempArray.h"
18eade96 24#include "AliTPCDBPressure.h"
a7dce0bc 25#include "AliTPCROC.h"
26#include "AliTPCCalROC.h"
27#include "AliTPCCalPad.h"
28#include "AliTPCCalibPedestal.h"
54472e4f 29
30#include <TTimeStamp.h>
31
a7dce0bc 32const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees
33const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees
34const TString kPedestalRunType = "PEDESTAL_RUN"; // pedestal run identifier
72df5829 35
54472e4f 36//
37// This class is the SHUTTLE preprocessor for the TPC detector.
f7f602cc 38// It contains several components, this far the part containing
54472e4f 39// temperatures is implemented
40//
41
42ClassImp(AliTPCPreprocessor)
43
44//______________________________________________________________________________________________
6d07bf74 45AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) :
46 AliPreprocessor("TPC",shuttle),
a7dce0bc 47 fTemp(0), fPressure(0), fConfigOK(kTRUE), fROC(0)
54472e4f 48{
49 // constructor
a7dce0bc 50 fROC = AliTPCROC::Instance();
54472e4f 51}
72df5829 52//______________________________________________________________________________________________
53// AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) :
54// AliPreprocessor(org),
18eade96 55// fTemp(0), fPressure(0), fConfigOK(kTRUE)
72df5829 56// {
57// // copy constructor not implemented
f7f602cc 58// // -- missing underlying copy constructor in AliPreprocessor
59//
72df5829 60// Fatal("AliTPCPreprocessor", "copy constructor not implemented");
f7f602cc 61//
62// // fTemp = new AliTPCSensorTempArray(*(org.fTemp));
72df5829 63// }
54472e4f 64
65//______________________________________________________________________________________________
66AliTPCPreprocessor::~AliTPCPreprocessor()
67{
68 // destructor
a7dce0bc 69
54472e4f 70 delete fTemp;
18eade96 71 delete fPressure;
54472e4f 72}
72df5829 73//______________________________________________________________________________________________
74AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& )
75{
76 Fatal("operator =", "assignment operator not implemented");
77 return *this;
78}
79
54472e4f 80
81//______________________________________________________________________________________________
82void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime,
83 UInt_t endTime)
84{
85 // Creates AliTestDataDCS object
86
87 AliPreprocessor::Initialize(run, startTime, endTime);
88
89 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
90 TTimeStamp(startTime).AsString(),
91 TTimeStamp(endTime).AsString()));
92
18eade96 93 // Temperature sensors
94
f7f602cc 95 TTree *confTree = 0;
96 AliCDBEntry* entry = GetFromOCDB("Config", "Temperature");
97 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 98 if ( confTree==0 ) {
99 AliError(Form("Temperature Config OCDB entry missing.\n"));
100 Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n");
101 fConfigOK = kFALSE;
f7f602cc 102 return;
18eade96 103 }
104 fTemp = new AliTPCSensorTempArray(fStartTime, fEndTime, confTree);
105 fTemp->SetValCut(kValCutTemp);
106 fTemp->SetDiffCut(kDiffCutTemp);
f7f602cc 107
18eade96 108 // Pressure sensors
f7f602cc 109
a7dce0bc 110 confTree=0;
f7f602cc 111 entry=0;
a7dce0bc 112 entry = GetFromOCDB("Config", "Pressure");
f7f602cc 113 if (entry) confTree = (TTree*) entry->GetObject();
18eade96 114 if ( confTree==0 ) {
115 AliError(Form("Pressure Config OCDB entry missing.\n"));
116 Log("AliTPCPreprocsessor: Pressure Config OCDB entry missing.\n");
117 fConfigOK = kFALSE;
f7f602cc 118 return;
18eade96 119 }
120 fPressure = new AliDCSSensorArray(fStartTime, fEndTime, confTree);
18eade96 121
54472e4f 122}
123
124//______________________________________________________________________________________________
125UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap)
126{
127 // Fills data into TPC calibrations objects
128
54472e4f 129 // Amanda servers provide information directly through dcsAliasMap
130
a7dce0bc 131 if (!dcsAliasMap) return 9;
132 if (!fConfigOK) return 9;
133
134 TString runType = GetRunType();
135
54472e4f 136 // Temperature sensors are processed by AliTPCCalTemp
72df5829 137
18eade96 138
54472e4f 139 UInt_t tempResult = MapTemperature(dcsAliasMap);
140 UInt_t result=tempResult;
18eade96 141
142 // Pressure sensors
143
144 UInt_t pressureResult = MapPressure(dcsAliasMap);
145 result += pressureResult;
f7f602cc 146
54472e4f 147 // Other calibration information will be retrieved through FXS files
a7dce0bc 148 // examples:
54472e4f 149 // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals");
150 // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1");
151 //
152 // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib");
153 // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1");
154
155
a7dce0bc 156 if(runType == kPedestalRunType) {
157 UInt_t pedestalResult = ExtractPedestals();
158 result += pedestalResult;
159 }
160
161
54472e4f 162 return result;
163}
164//______________________________________________________________________________________________
165UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap)
166{
167
168 // extract DCS temperature maps. Perform fits to save space
169
72df5829 170 UInt_t result=0;
54472e4f 171 TMap *map = fTemp->ExtractDCS(dcsAliasMap);
172 if (map) {
173 fTemp->MakeSplineFit(map);
174 AliInfo(Form("Temperature values extracted, fits performed.\n"));
175 } else {
176 AliError(Form("No temperature map extracted.\n"));
177 Log("AliTPCPreprocsessor: no temperature map extracted. \n");
72df5829 178 result=9;
54472e4f 179 }
180 delete map;
181 // Now store the final CDB file
a7dce0bc 182
183 if ( result == 0 ) {
72df5829 184 AliCDBMetaData metaData;
54472e4f 185 metaData.SetBeamPeriod(0);
186 metaData.SetResponsible("Haavard Helstrup");
187 metaData.SetComment("Preprocessor AliTPC data base entries.");
188
a7dce0bc 189 Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE);
190 if ( !storeOK ) result=1;
191
72df5829 192 }
54472e4f 193
194 return result;
195}
18eade96 196//______________________________________________________________________________________________
197UInt_t AliTPCPreprocessor::MapPressure(TMap* dcsAliasMap)
198{
199
200 // extract DCS temperature maps. Perform fits to save space
201
202 UInt_t result=0;
203 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
204 if (map) {
205 fPressure->MakeSplineFit(map);
206 AliInfo(Form("Pressure values extracted, fits performed.\n"));
207 } else {
208 AliError(Form("No atmospheric pressure map extracted.\n"));
209 Log("AliTPCPreprocsessor: no atmospheric pressure map extracted. \n");
210 result=9;
211 }
212 delete map;
213 // Now store the final CDB file
a7dce0bc 214
215 if ( result == 0 ) {
18eade96 216 AliCDBMetaData metaData;
217 metaData.SetBeamPeriod(0);
218 metaData.SetResponsible("Haavard Helstrup");
219 metaData.SetComment("Preprocessor AliTPC data base entries.");
220
a7dce0bc 221 Bool_t storeOK = Store("Calib", "Pressure", fPressure, &metaData, 0, 0);
222 if ( !storeOK ) result=1;
223
18eade96 224 }
225
226 return result;
227}
a7dce0bc 228//______________________________________________________________________________________________
229UInt_t AliTPCPreprocessor::ExtractPedestals()
230{
231 //
232 // Read pedestal file from file exchage server
233 // Keep original entry from OCDB in case no new pedestals are available
234 //
235 AliTPCCalPad *calPadPed=0;
236 AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals");
237 if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject();
238 if ( calPadPed==NULL ) {
239 AliWarning(Form("No previous TPC pedestal entry available.\n"));
240 Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n");
241 calPadPed = new AliTPCCalPad();
242 }
243
244 UInt_t result=0;
245
246 Int_t nSectors = fROC->GetNSectors();
247 TList* list = GetFileSources(AliShuttleInterface::kDAQ,"pedestals");
248 if (list) {
249
250// loop through all files from LDCs
251
252 UInt_t index = 0;
253 while (list->At(index)!=NULL) {
254 TObjString* fileNameEntry = (TObjString*) list->At(index);
255 if (fileNameEntry!=NULL) {
256 TString fileName = GetFile(AliShuttleInterface::kDAQ, "pedestals",
257 fileNameEntry->GetString().Data());
258 TFile *f = TFile::Open(fileName);
259 AliTPCCalibPedestal *calPed;
260 f->GetObject("AliTPCCalibPedestal",calPed);
261
262 // replace entries for the sectors available in the present file
263
264 for (Int_t sector=0; sector<=nSectors; sector++) {
265 AliTPCCalROC *roc=calPed->GetCalRocPedestal(sector, kFALSE);
266 if ( roc ) calPadPed->SetCalROC(roc,sector);
267 }
268 }
269 ++index;
270 } // while(list)
271//
272// Store updated pedestal entry to OCDB
273//
274 AliCDBMetaData metaData;
275 metaData.SetBeamPeriod(0);
276 metaData.SetResponsible("Haavard Helstrup");
277 metaData.SetComment("Preprocessor AliTPC data base entries.");
278
279 Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE);
280 if ( !storeOK ) result=1;
281
282 } // if(list)
283 return result;
284}