]>
Commit | Line | Data |
---|---|---|
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" | |
a7dce0bc | 24 | #include "AliTPCROC.h" |
25 | #include "AliTPCCalROC.h" | |
26 | #include "AliTPCCalPad.h" | |
27 | #include "AliTPCCalibPedestal.h" | |
9f016d99 | 28 | #include "AliTPCCalibPulser.h" |
29 | #include "AliTPCCalibCE.h" | |
9e66a8dd | 30 | #include "TFile.h" |
7b54c8e9 | 31 | #include "TTree.h" |
bb30a935 | 32 | #include "TGraph.h" |
7b54c8e9 | 33 | #include "TEnv.h" |
bb30a935 | 34 | #include "TParameter.h" |
54472e4f | 35 | |
36 | #include <TTimeStamp.h> | |
37 | ||
a7dce0bc | 38 | const Int_t kValCutTemp = 100; // discard temperatures > 100 degrees |
39 | const Int_t kDiffCutTemp = 5; // discard temperature differences > 5 degrees | |
bb30a935 | 40 | const TString kPedestalRunType = "PEDESTAL"; // pedestal run identifier |
41 | const TString kPulserRunType = "PULSER"; // pulser run identifier | |
bdffc5fb | 42 | const TString kPhysicsRunType = "PHYSICS"; // physics run identifier |
9c754ce7 | 43 | const TString kStandAloneRunType = "STANDALONE"; // standalone run identifier |
44 | const TString kDaqRunType = "DAQ"; // DAQ run identifier | |
67a165ed | 45 | const TString kAmandaTemp = "tpc_PT_%d.Temperature"; // Amanda string for temperature entries |
bee89eeb | 46 | //const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required |
68b512ca | 47 | const Double_t kFitFraction = -1.0; // Don't require minimum number of fits in commissioning run |
72df5829 | 48 | |
54472e4f | 49 | // |
50 | // This class is the SHUTTLE preprocessor for the TPC detector. | |
54472e4f | 51 | // |
52 | ||
53 | ClassImp(AliTPCPreprocessor) | |
54 | ||
55 | //______________________________________________________________________________________________ | |
6d07bf74 | 56 | AliTPCPreprocessor::AliTPCPreprocessor(AliShuttleInterface* shuttle) : |
57 | AliPreprocessor("TPC",shuttle), | |
bdffc5fb | 58 | fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE), fROC(0) |
54472e4f | 59 | { |
60 | // constructor | |
a7dce0bc | 61 | fROC = AliTPCROC::Instance(); |
54472e4f | 62 | } |
72df5829 | 63 | //______________________________________________________________________________________________ |
64 | // AliTPCPreprocessor::AliTPCPreprocessor(const AliTPCPreprocessor& org) : | |
65 | // AliPreprocessor(org), | |
bdffc5fb | 66 | // fConfEnv(0), fTemp(0), fHighVoltage(0), fConfigOK(kTRUE) |
72df5829 | 67 | // { |
68 | // // copy constructor not implemented | |
f7f602cc | 69 | // // -- missing underlying copy constructor in AliPreprocessor |
70 | // | |
72df5829 | 71 | // Fatal("AliTPCPreprocessor", "copy constructor not implemented"); |
f7f602cc | 72 | // |
73 | // // fTemp = new AliTPCSensorTempArray(*(org.fTemp)); | |
72df5829 | 74 | // } |
54472e4f | 75 | |
76 | //______________________________________________________________________________________________ | |
77 | AliTPCPreprocessor::~AliTPCPreprocessor() | |
78 | { | |
79 | // destructor | |
a7dce0bc | 80 | |
54472e4f | 81 | delete fTemp; |
bdffc5fb | 82 | delete fHighVoltage; |
54472e4f | 83 | } |
72df5829 | 84 | //______________________________________________________________________________________________ |
85 | AliTPCPreprocessor& AliTPCPreprocessor::operator = (const AliTPCPreprocessor& ) | |
86 | { | |
87 | Fatal("operator =", "assignment operator not implemented"); | |
88 | return *this; | |
89 | } | |
90 | ||
54472e4f | 91 | |
92 | //______________________________________________________________________________________________ | |
93 | void AliTPCPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
94 | UInt_t endTime) | |
95 | { | |
bb30a935 | 96 | // Creates AliTestDataDCS object -- start maps half an hour beforre actual run start |
54472e4f | 97 | |
bb30a935 | 98 | UInt_t startTimeLocal = startTime-1800; |
99 | ||
100 | AliPreprocessor::Initialize(run, startTimeLocal, endTime); | |
54472e4f | 101 | |
102 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
103 | TTimeStamp(startTime).AsString(), | |
104 | TTimeStamp(endTime).AsString())); | |
105 | ||
7b54c8e9 | 106 | // Preprocessor configuration |
107 | ||
37092b2b | 108 | AliCDBEntry* entry = GetFromOCDB("Config", "Preprocessor"); |
7b54c8e9 | 109 | if (entry) fConfEnv = (TEnv*) entry->GetObject(); |
110 | if ( fConfEnv==0 ) { | |
7b54c8e9 | 111 | Log("AliTPCPreprocsessor: Preprocessor Config OCDB entry missing.\n"); |
37092b2b | 112 | fConfigOK = kFALSE; |
113 | return; | |
7b54c8e9 | 114 | } |
115 | ||
18eade96 | 116 | // Temperature sensors |
117 | ||
136e44f7 | 118 | TTree *confTree = 0; |
119 | ||
120 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); | |
121 | tempConf.ToUpper(); | |
122 | if (tempConf != "OFF" ) { | |
7b54c8e9 | 123 | entry = GetFromOCDB("Config", "Temperature"); |
f7f602cc | 124 | if (entry) confTree = (TTree*) entry->GetObject(); |
18eade96 | 125 | if ( confTree==0 ) { |
18eade96 | 126 | Log("AliTPCPreprocsessor: Temperature Config OCDB entry missing.\n"); |
127 | fConfigOK = kFALSE; | |
f7f602cc | 128 | return; |
18eade96 | 129 | } |
bb30a935 | 130 | fTemp = new AliTPCSensorTempArray(startTimeLocal, fEndTime, confTree, kAmandaTemp); |
18eade96 | 131 | fTemp->SetValCut(kValCutTemp); |
132 | fTemp->SetDiffCut(kDiffCutTemp); | |
136e44f7 | 133 | } |
18eade96 | 134 | |
bdffc5fb | 135 | // High voltage measurements |
136 | ||
136e44f7 | 137 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); |
138 | hvConf.ToUpper(); | |
139 | if (hvConf != "OFF" ) { | |
bdffc5fb | 140 | confTree=0; |
141 | entry=0; | |
142 | entry = GetFromOCDB("Config", "HighVoltage"); | |
143 | if (entry) confTree = (TTree*) entry->GetObject(); | |
144 | if ( confTree==0 ) { | |
145 | Log("AliTPCPreprocsessor: High Voltage Config OCDB entry missing.\n"); | |
146 | fConfigOK = kFALSE; | |
147 | return; | |
148 | } | |
bb30a935 | 149 | fHighVoltage = new AliDCSSensorArray(startTimeLocal, fEndTime, confTree); |
bdffc5fb | 150 | } |
54472e4f | 151 | } |
152 | ||
153 | //______________________________________________________________________________________________ | |
154 | UInt_t AliTPCPreprocessor::Process(TMap* dcsAliasMap) | |
155 | { | |
156 | // Fills data into TPC calibrations objects | |
157 | ||
54472e4f | 158 | // Amanda servers provide information directly through dcsAliasMap |
159 | ||
bb30a935 | 160 | |
a7dce0bc | 161 | if (!fConfigOK) return 9; |
136e44f7 | 162 | UInt_t result = 0; |
bb30a935 | 163 | TObjArray *resultArray = new TObjArray(); |
164 | TString errorHandling = fConfEnv->GetValue("ErrorHandling","ON"); | |
165 | errorHandling.ToUpper(); | |
166 | TObject * status; | |
167 | ||
168 | UInt_t dcsResult=0; | |
169 | if (errorHandling == "OFF" ) { | |
170 | if (!dcsAliasMap) dcsResult=1; | |
171 | if (dcsAliasMap->GetEntries() == 0 ) dcsResult=1; | |
172 | status = new TParameter<int>("dcsResult",dcsResult); | |
173 | resultArray->Add(status); | |
174 | } else { | |
175 | if (!dcsAliasMap) return 9; | |
176 | if (dcsAliasMap->GetEntries() == 0 ) return 9; | |
177 | } | |
178 | ||
179 | ||
180 | ||
a7dce0bc | 181 | |
182 | TString runType = GetRunType(); | |
183 | ||
54472e4f | 184 | // Temperature sensors are processed by AliTPCCalTemp |
72df5829 | 185 | |
136e44f7 | 186 | TString tempConf = fConfEnv->GetValue("Temperature","ON"); |
187 | tempConf.ToUpper(); | |
188 | if (tempConf != "OFF" ) { | |
189 | UInt_t tempResult = MapTemperature(dcsAliasMap); | |
190 | result=tempResult; | |
bb30a935 | 191 | status = new TParameter<int>("tempResult",tempResult); |
192 | resultArray->Add(status); | |
136e44f7 | 193 | } |
18eade96 | 194 | |
bdffc5fb | 195 | // High Voltage recordings |
196 | ||
197 | ||
136e44f7 | 198 | TString hvConf = fConfEnv->GetValue("HighVoltage","ON"); |
199 | hvConf.ToUpper(); | |
200 | if (hvConf != "OFF" ) { | |
201 | UInt_t hvResult = MapHighVoltage(dcsAliasMap); | |
202 | result+=hvResult; | |
bb30a935 | 203 | status = new TParameter<int>("hvResult",hvResult); |
204 | resultArray->Add(status); | |
bdffc5fb | 205 | } |
f7f602cc | 206 | |
54472e4f | 207 | // Other calibration information will be retrieved through FXS files |
a7dce0bc | 208 | // examples: |
54472e4f | 209 | // TList* fileSourcesDAQ = GetFile(AliShuttleInterface::kDAQ, "pedestals"); |
210 | // const char* fileNamePed = GetFile(AliShuttleInterface::kDAQ, "pedestals", "LDC1"); | |
211 | // | |
212 | // TList* fileSourcesHLT = GetFile(AliShuttleInterface::kHLT, "calib"); | |
213 | // const char* fileNameHLT = GetFile(AliShuttleInterface::kHLT, "calib", "LDC1"); | |
214 | ||
9f016d99 | 215 | // pedestal entries |
54472e4f | 216 | |
a7dce0bc | 217 | if(runType == kPedestalRunType) { |
68b512ca | 218 | Int_t numSources = 1; |
219 | Int_t pedestalSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
7b54c8e9 | 220 | TString source = fConfEnv->GetValue("Pedestal","DAQ"); |
221 | source.ToUpper(); | |
136e44f7 | 222 | if (source != "OFF" ) { |
223 | if ( source == "HLT") pedestalSource[0] = AliShuttleInterface::kHLT; | |
224 | if (!GetHLTStatus()) pedestalSource[0] = AliShuttleInterface::kDAQ; | |
225 | if (source == "HLTDAQ" ) { | |
226 | numSources=2; | |
227 | pedestalSource[0] = AliShuttleInterface::kHLT; | |
228 | pedestalSource[1] = AliShuttleInterface::kDAQ; | |
229 | } | |
230 | if (source == "DAQHLT" ) numSources=2; | |
231 | UInt_t pedestalResult=0; | |
232 | for (Int_t i=0; i<numSources; i++ ) { | |
233 | UInt_t pedestalResult = ExtractPedestals(pedestalSource[i]); | |
234 | if ( pedestalResult == 0 ) break; | |
235 | } | |
236 | result += pedestalResult; | |
bb30a935 | 237 | status = new TParameter<int>("pedestalResult",pedestalResult); |
238 | resultArray->Add(status); | |
68b512ca | 239 | } |
a7dce0bc | 240 | } |
241 | ||
9f016d99 | 242 | // pulser trigger processing |
243 | ||
68b512ca | 244 | if(runType == kPulserRunType) { |
245 | Int_t numSources = 1; | |
246 | Int_t pulserSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
9f016d99 | 247 | TString source = fConfEnv->GetValue("Pulser","DAQ"); |
248 | source.ToUpper(); | |
136e44f7 | 249 | if ( source != "OFF") { |
250 | if ( source == "HLT") pulserSource[0] = AliShuttleInterface::kHLT; | |
251 | if (!GetHLTStatus()) pulserSource[0] = AliShuttleInterface::kDAQ; | |
252 | if (source == "HLTDAQ" ) { | |
253 | numSources=2; | |
254 | pulserSource[0] = AliShuttleInterface::kHLT; | |
255 | pulserSource[1] = AliShuttleInterface::kDAQ; | |
256 | } | |
257 | if (source == "DAQHLT" ) numSources=2; | |
258 | UInt_t pulserResult=0; | |
259 | for (Int_t i=0; i<numSources; i++ ) { | |
260 | pulserResult = ExtractPulser(pulserSource[i]); | |
261 | if ( pulserResult == 0 ) break; | |
262 | } | |
263 | result += pulserResult; | |
bb30a935 | 264 | status = new TParameter<int>("pulserResult",pulserResult); |
265 | resultArray->Add(status); | |
68b512ca | 266 | } |
9f016d99 | 267 | } |
268 | ||
68b512ca | 269 | |
270 | ||
9f016d99 | 271 | // Central Electrode processing |
272 | ||
9c754ce7 | 273 | if( runType == kPhysicsRunType || runType == kStandAloneRunType || |
274 | runType == kDaqRunType ) { | |
68b512ca | 275 | |
276 | Int_t numSources = 1; | |
277 | Int_t ceSource[2] = {AliShuttleInterface::kDAQ,AliShuttleInterface::kHLT} ; | |
9f016d99 | 278 | TString source = fConfEnv->GetValue("CE","DAQ"); |
279 | source.ToUpper(); | |
136e44f7 | 280 | if ( source != "OFF" ) { |
281 | if ( source == "HLT") ceSource[0] = AliShuttleInterface::kHLT; | |
282 | if (!GetHLTStatus()) ceSource[0] = AliShuttleInterface::kDAQ; | |
283 | if (source == "HLTDAQ" ) { | |
68b512ca | 284 | numSources=2; |
285 | ceSource[0] = AliShuttleInterface::kHLT; | |
286 | ceSource[1] = AliShuttleInterface::kDAQ; | |
136e44f7 | 287 | } |
288 | if (source == "DAQHLT" ) numSources=2; | |
289 | UInt_t ceResult=0; | |
290 | for (Int_t i=0; i<numSources; i++ ) { | |
291 | ceResult = ExtractCE(ceSource[i]); | |
292 | if ( ceResult == 0 ) break; | |
293 | } | |
294 | result += ceResult; | |
bb30a935 | 295 | status = new TParameter<int>("ceResult",ceResult); |
296 | resultArray->Add(status); | |
68b512ca | 297 | } |
9f016d99 | 298 | } |
136e44f7 | 299 | |
136e44f7 | 300 | if (errorHandling == "OFF" ) { |
bb30a935 | 301 | AliCDBMetaData metaData; |
302 | metaData.SetBeamPeriod(0); | |
303 | metaData.SetResponsible("Haavard Helstrup"); | |
304 | metaData.SetComment("Preprocessor AliTPC status."); | |
305 | Store("Calib", "PreprocStatus", resultArray, &metaData, 0, kFALSE); | |
306 | resultArray->Delete(); | |
307 | return 0; | |
136e44f7 | 308 | } else { |
bb30a935 | 309 | return result; |
136e44f7 | 310 | } |
54472e4f | 311 | } |
312 | //______________________________________________________________________________________________ | |
313 | UInt_t AliTPCPreprocessor::MapTemperature(TMap* dcsAliasMap) | |
314 | { | |
315 | ||
316 | // extract DCS temperature maps. Perform fits to save space | |
317 | ||
72df5829 | 318 | UInt_t result=0; |
54472e4f | 319 | TMap *map = fTemp->ExtractDCS(dcsAliasMap); |
320 | if (map) { | |
321 | fTemp->MakeSplineFit(map); | |
68b512ca | 322 | Double_t fitFraction = 1.0*fTemp->NumFits()/fTemp->NumSensors(); |
67a165ed | 323 | if (fitFraction > kFitFraction ) { |
324 | AliInfo(Form("Temperature values extracted, fits performed.\n")); | |
325 | } else { | |
326 | Log ("Too few temperature maps fitted. \n"); | |
327 | result = 9; | |
328 | } | |
54472e4f | 329 | } else { |
67a165ed | 330 | Log("No temperature map extracted. \n"); |
72df5829 | 331 | result=9; |
54472e4f | 332 | } |
333 | delete map; | |
334 | // Now store the final CDB file | |
a7dce0bc | 335 | |
336 | if ( result == 0 ) { | |
72df5829 | 337 | AliCDBMetaData metaData; |
54472e4f | 338 | metaData.SetBeamPeriod(0); |
339 | metaData.SetResponsible("Haavard Helstrup"); | |
340 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
341 | ||
a7dce0bc | 342 | Bool_t storeOK = Store("Calib", "Temperature", fTemp, &metaData, 0, kFALSE); |
343 | if ( !storeOK ) result=1; | |
344 | ||
72df5829 | 345 | } |
54472e4f | 346 | |
347 | return result; | |
7b54c8e9 | 348 | |
54472e4f | 349 | } |
7b54c8e9 | 350 | |
bdffc5fb | 351 | //______________________________________________________________________________________________ |
352 | UInt_t AliTPCPreprocessor::MapHighVoltage(TMap* dcsAliasMap) | |
353 | { | |
354 | ||
355 | // extract DCS HV maps. Perform fits to save space | |
356 | ||
357 | UInt_t result=0; | |
358 | TMap *map = fHighVoltage->ExtractDCS(dcsAliasMap); | |
359 | if (map) { | |
360 | fHighVoltage->MakeSplineFit(map); | |
68b512ca | 361 | Double_t fitFraction = 1.0*fHighVoltage->NumFits()/fHighVoltage->NumSensors(); |
bdffc5fb | 362 | if (fitFraction > kFitFraction ) { |
136e44f7 | 363 | AliInfo(Form("High voltage recordings extracted, fits performed.\n")); |
bdffc5fb | 364 | } else { |
365 | Log ("Too few high voltage recordings fitted. \n"); | |
366 | result = 9; | |
367 | } | |
368 | } else { | |
369 | Log("No high voltage recordings extracted. \n"); | |
370 | result=9; | |
371 | } | |
372 | delete map; | |
373 | // Now store the final CDB file | |
374 | ||
375 | if ( result == 0 ) { | |
376 | AliCDBMetaData metaData; | |
377 | metaData.SetBeamPeriod(0); | |
378 | metaData.SetResponsible("Haavard Helstrup"); | |
379 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
380 | ||
381 | Bool_t storeOK = Store("Calib", "HighVoltage", fHighVoltage, &metaData, 0, kFALSE); | |
382 | if ( !storeOK ) result=1; | |
383 | ||
384 | } | |
385 | ||
386 | return result; | |
387 | ||
388 | } | |
389 | ||
7b54c8e9 | 390 | |
a7dce0bc | 391 | //______________________________________________________________________________________________ |
7b54c8e9 | 392 | |
393 | UInt_t AliTPCPreprocessor::ExtractPedestals(Int_t sourceFXS) | |
a7dce0bc | 394 | { |
395 | // | |
396 | // Read pedestal file from file exchage server | |
397 | // Keep original entry from OCDB in case no new pedestals are available | |
398 | // | |
399 | AliTPCCalPad *calPadPed=0; | |
400 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pedestals"); | |
401 | if (entry) calPadPed = (AliTPCCalPad*)entry->GetObject(); | |
402 | if ( calPadPed==NULL ) { | |
a7dce0bc | 403 | Log("AliTPCPreprocsessor: No previous TPC pedestal entry available.\n"); |
7b54c8e9 | 404 | calPadPed = new AliTPCCalPad("PedestalsMean","PedestalsMean"); |
405 | } | |
406 | ||
407 | AliTPCCalPad *calPadRMS=0; | |
d63b9ad7 | 408 | entry = GetFromOCDB("Calib", "PadNoise"); |
7b54c8e9 | 409 | if (entry) calPadRMS = (AliTPCCalPad*)entry->GetObject(); |
410 | if ( calPadRMS==NULL ) { | |
7b54c8e9 | 411 | Log("AliTPCPreprocsessor: No previous TPC noise entry available.\n"); |
412 | calPadRMS = new AliTPCCalPad("PedestalsRMS","PedestalsRMS"); | |
a7dce0bc | 413 | } |
414 | ||
7b54c8e9 | 415 | |
a7dce0bc | 416 | UInt_t result=0; |
417 | ||
418 | Int_t nSectors = fROC->GetNSectors(); | |
7b54c8e9 | 419 | TList* list = GetFileSources(sourceFXS,"pedestals"); |
9f016d99 | 420 | |
421 | if (list && list->GetEntries()>0) { | |
a7dce0bc | 422 | |
423 | // loop through all files from LDCs | |
424 | ||
bdffc5fb | 425 | Bool_t changed=false; |
a7dce0bc | 426 | UInt_t index = 0; |
427 | while (list->At(index)!=NULL) { | |
428 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
429 | if (fileNameEntry!=NULL) { | |
7b54c8e9 | 430 | TString fileName = GetFile(sourceFXS, "pedestals", |
a7dce0bc | 431 | fileNameEntry->GetString().Data()); |
432 | TFile *f = TFile::Open(fileName); | |
9f016d99 | 433 | if (!f) { |
434 | Log ("Error opening pedestal file."); | |
435 | result =2; | |
436 | break; | |
437 | } | |
a7dce0bc | 438 | AliTPCCalibPedestal *calPed; |
439 | f->GetObject("AliTPCCalibPedestal",calPed); | |
67a165ed | 440 | if ( !calPed ) { |
441 | Log ("No pedestal calibration object in file."); | |
442 | result = 2; | |
443 | break; | |
444 | } | |
a7dce0bc | 445 | |
446 | // replace entries for the sectors available in the present file | |
447 | ||
bdffc5fb | 448 | changed=true; |
c9c23d80 | 449 | for (Int_t sector=0; sector<nSectors; sector++) { |
7b54c8e9 | 450 | AliTPCCalROC *rocPed=calPed->GetCalRocPedestal(sector, kFALSE); |
451 | if ( rocPed ) calPadPed->SetCalROC(rocPed,sector); | |
452 | AliTPCCalROC *rocRMS=calPed->GetCalRocRMS(sector, kFALSE); | |
453 | if ( rocRMS ) calPadRMS->SetCalROC(rocRMS,sector); | |
a7dce0bc | 454 | } |
455 | } | |
456 | ++index; | |
457 | } // while(list) | |
458 | // | |
459 | // Store updated pedestal entry to OCDB | |
460 | // | |
bdffc5fb | 461 | if (changed) { |
462 | AliCDBMetaData metaData; | |
463 | metaData.SetBeamPeriod(0); | |
464 | metaData.SetResponsible("Haavard Helstrup"); | |
465 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
466 | ||
467 | Bool_t storeOK = Store("Calib", "Pedestals", calPadPed, &metaData, 0, kTRUE); | |
468 | if ( !storeOK ) ++result; | |
469 | storeOK = Store("Calib", "PadNoise", calPadRMS, &metaData, 0, kTRUE); | |
470 | if ( !storeOK ) ++result; | |
471 | } | |
9f016d99 | 472 | } else { |
67a165ed | 473 | Log ("Error: no entries in input file list!"); |
9f016d99 | 474 | result = 1; |
7b54c8e9 | 475 | } |
a7dce0bc | 476 | |
a7dce0bc | 477 | return result; |
478 | } | |
7b54c8e9 | 479 | |
480 | //______________________________________________________________________________________________ | |
481 | ||
482 | ||
9f016d99 | 483 | UInt_t AliTPCPreprocessor::ExtractPulser(Int_t sourceFXS) |
484 | { | |
485 | // | |
486 | // Read pulser calibration file from file exchage server | |
487 | // Keep original entry from OCDB in case no new pulser calibration is available | |
488 | // | |
489 | TObjArray *pulserObjects=0; | |
490 | AliTPCCalPad *pulserTmean=0; | |
491 | AliTPCCalPad *pulserTrms=0; | |
492 | AliTPCCalPad *pulserQmean=0; | |
493 | AliCDBEntry* entry = GetFromOCDB("Calib", "Pulser"); | |
494 | if (entry) pulserObjects = (TObjArray*)entry->GetObject(); | |
495 | if ( pulserObjects==NULL ) { | |
496 | Log("AliTPCPreprocsessor: No previous TPC pulser entry available.\n"); | |
497 | pulserObjects = new TObjArray; | |
498 | } | |
499 | ||
500 | pulserTmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserTmean"); | |
501 | if ( !pulserTmean ) { | |
502 | pulserTmean = new AliTPCCalPad("PulserTmean","PulserTmean"); | |
503 | pulserObjects->Add(pulserTmean); | |
504 | } | |
505 | pulserTrms = (AliTPCCalPad*)pulserObjects->FindObject("PulserTrms"); | |
506 | if ( !pulserTrms ) { | |
507 | pulserTrms = new AliTPCCalPad("PulserTrms","PulserTrms"); | |
508 | pulserObjects->Add(pulserTrms); | |
509 | } | |
510 | pulserQmean = (AliTPCCalPad*)pulserObjects->FindObject("PulserQmean"); | |
511 | if ( !pulserQmean ) { | |
512 | pulserQmean = new AliTPCCalPad("PulserQmean","PulserQmean"); | |
513 | pulserObjects->Add(pulserQmean); | |
514 | } | |
515 | ||
516 | ||
517 | UInt_t result=0; | |
518 | ||
519 | Int_t nSectors = fROC->GetNSectors(); | |
520 | TList* list = GetFileSources(sourceFXS,"pulser"); | |
521 | ||
522 | if (list && list->GetEntries()>0) { | |
523 | ||
524 | // loop through all files from LDCs | |
525 | ||
bdffc5fb | 526 | Bool_t changed=false; |
9f016d99 | 527 | UInt_t index = 0; |
528 | while (list->At(index)!=NULL) { | |
529 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
530 | if (fileNameEntry!=NULL) { | |
531 | TString fileName = GetFile(sourceFXS, "pulser", | |
532 | fileNameEntry->GetString().Data()); | |
533 | TFile *f = TFile::Open(fileName); | |
534 | if (!f) { | |
535 | Log ("Error opening pulser file."); | |
536 | result =2; | |
537 | break; | |
538 | } | |
539 | AliTPCCalibPulser *calPulser; | |
540 | f->GetObject("AliTPCCalibPulser",calPulser); | |
67a165ed | 541 | if ( !calPulser ) { |
542 | Log ("No pulser calibration object in file."); | |
543 | result = 2; | |
544 | break; | |
545 | } | |
9f016d99 | 546 | |
547 | // replace entries for the sectors available in the present file | |
548 | ||
bdffc5fb | 549 | changed=true; |
9f016d99 | 550 | for (Int_t sector=0; sector<nSectors; sector++) { |
551 | AliTPCCalROC *rocTmean=calPulser->GetCalRocT0(sector); | |
552 | if ( rocTmean ) pulserTmean->SetCalROC(rocTmean,sector); | |
553 | AliTPCCalROC *rocTrms=calPulser->GetCalRocRMS(sector); | |
554 | if ( rocTrms ) pulserTrms->SetCalROC(rocTrms,sector); | |
555 | AliTPCCalROC *rocQmean=calPulser->GetCalRocQ(sector); | |
556 | if ( rocQmean ) pulserQmean->SetCalROC(rocQmean,sector); | |
557 | } | |
558 | } | |
559 | ++index; | |
560 | } // while(list) | |
561 | // | |
562 | // Store updated pedestal entry to OCDB | |
563 | // | |
bdffc5fb | 564 | if (changed) { |
565 | AliCDBMetaData metaData; | |
566 | metaData.SetBeamPeriod(0); | |
567 | metaData.SetResponsible("Haavard Helstrup"); | |
568 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
569 | ||
570 | Bool_t storeOK = Store("Calib", "Pulser", pulserObjects, &metaData, 0, kTRUE); | |
571 | if ( !storeOK ) ++result; | |
572 | } | |
9f016d99 | 573 | } else { |
67a165ed | 574 | Log ("Error: no entries in input file list!"); |
9f016d99 | 575 | result = 1; |
576 | } | |
577 | ||
578 | return result; | |
579 | } | |
580 | ||
581 | UInt_t AliTPCPreprocessor::ExtractCE(Int_t sourceFXS) | |
582 | { | |
583 | // | |
584 | // Read Central Electrode file from file exchage server | |
585 | // Keep original entry from OCDB in case no new CE calibration is available | |
586 | // | |
587 | TObjArray *ceObjects=0; | |
588 | AliTPCCalPad *ceTmean=0; | |
589 | AliTPCCalPad *ceTrms=0; | |
590 | AliTPCCalPad *ceQmean=0; | |
bb30a935 | 591 | TObjArray *rocTtime=0; |
592 | TObjArray *rocQtime=0; | |
593 | ||
9f016d99 | 594 | AliCDBEntry* entry = GetFromOCDB("Calib", "CE"); |
595 | if (entry) ceObjects = (TObjArray*)entry->GetObject(); | |
596 | if ( ceObjects==NULL ) { | |
597 | Log("AliTPCPreprocsessor: No previous TPC central electrode entry available.\n"); | |
598 | ceObjects = new TObjArray; | |
599 | } | |
600 | ||
bb30a935 | 601 | Int_t nSectors = fROC->GetNSectors(); |
602 | ||
9f016d99 | 603 | ceTmean = (AliTPCCalPad*)ceObjects->FindObject("CETmean"); |
604 | if ( !ceTmean ) { | |
605 | ceTmean = new AliTPCCalPad("CETmean","CETmean"); | |
606 | ceObjects->Add(ceTmean); | |
607 | } | |
608 | ceTrms = (AliTPCCalPad*)ceObjects->FindObject("CETrms"); | |
609 | if ( !ceTrms ) { | |
610 | ceTrms = new AliTPCCalPad("CETrms","CETrms"); | |
611 | ceObjects->Add(ceTrms); | |
612 | } | |
613 | ceQmean = (AliTPCCalPad*)ceObjects->FindObject("CEQmean"); | |
614 | if ( !ceQmean ) { | |
615 | ceQmean = new AliTPCCalPad("CEQmean","CEQmean"); | |
616 | ceObjects->Add(ceQmean); | |
617 | } | |
38fcad6d | 618 | //!new from here please have a look!!! |
619 | rocTtime = (TObjArray*)ceObjects->FindObject("rocTtime"); | |
620 | if ( !rocTtime ) { | |
bb30a935 | 621 | rocTtime = new TObjArray(nSectors); |
38fcad6d | 622 | rocTtime->SetName("rocTtime"); |
623 | ceObjects->Add(rocTtime); | |
624 | } | |
bb30a935 | 625 | |
626 | rocQtime = (TObjArray*)ceObjects->FindObject("rocQtime"); | |
38fcad6d | 627 | if ( !rocQtime ) { |
bb30a935 | 628 | rocQtime = new TObjArray(nSectors); |
38fcad6d | 629 | rocQtime->SetName("rocQtime"); |
630 | ceObjects->Add(rocQtime); | |
631 | } | |
9f016d99 | 632 | |
633 | ||
634 | UInt_t result=0; | |
635 | ||
9f016d99 | 636 | TList* list = GetFileSources(sourceFXS,"CE"); |
637 | ||
638 | if (list && list->GetEntries()>0) { | |
639 | ||
640 | // loop through all files from LDCs | |
641 | ||
642 | UInt_t index = 0; | |
643 | while (list->At(index)!=NULL) { | |
644 | TObjString* fileNameEntry = (TObjString*) list->At(index); | |
645 | if (fileNameEntry!=NULL) { | |
646 | TString fileName = GetFile(sourceFXS, "CE", | |
647 | fileNameEntry->GetString().Data()); | |
648 | TFile *f = TFile::Open(fileName); | |
649 | if (!f) { | |
650 | Log ("Error opening central electrode file."); | |
651 | result =2; | |
652 | break; | |
653 | } | |
654 | AliTPCCalibCE *calCE; | |
655 | f->GetObject("AliTPCCalibCE",calCE); | |
656 | ||
657 | // replace entries for the sectors available in the present file | |
658 | ||
659 | for (Int_t sector=0; sector<nSectors; sector++) { | |
660 | AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector); | |
661 | if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector); | |
662 | AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector); | |
663 | if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector); | |
664 | AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector); | |
38fcad6d | 665 | if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector); |
bb30a935 | 666 | TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph |
667 | if ( grT ) rocTtime->AddAt(grT,sector); | |
668 | TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph | |
669 | if ( grQ ) rocTtime->AddAt(grQ,sector); | |
9f016d99 | 670 | } |
671 | } | |
672 | ++index; | |
673 | } // while(list) | |
674 | // | |
675 | // Store updated pedestal entry to OCDB | |
676 | // | |
677 | AliCDBMetaData metaData; | |
678 | metaData.SetBeamPeriod(0); | |
679 | metaData.SetResponsible("Haavard Helstrup"); | |
680 | metaData.SetComment("Preprocessor AliTPC data base entries."); | |
681 | ||
682 | Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE); | |
683 | if ( !storeOK ) ++result; | |
684 | ||
685 | } else { | |
686 | Log ("Error: no entries!"); | |
687 | result = 1; | |
688 | } | |
689 | ||
690 | return result; | |
691 | } |