]>
Commit | Line | Data |
---|---|---|
c9fe8530 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
9edefa04 | 16 | /* $Id$ */ |
9d883ed9 | 17 | |
3aaf7a5f | 18 | |
a174d599 | 19 | //#include <Riostream.h> |
20 | //#include <stdio.h> | |
21 | //#include <stdlib.h> | |
c9fe8530 | 22 | |
9edefa04 | 23 | #include <TFile.h> |
9edefa04 | 24 | #include <TH2S.h> |
25 | #include <TMath.h> | |
26 | #include <TObjArray.h> | |
27 | #include <TObjString.h> | |
28 | #include <TTimeStamp.h> | |
c9fe8530 | 29 | |
30 | #include "AliCDBMetaData.h" | |
7fffa85b | 31 | #include "AliCDBEntry.h" |
c9fe8530 | 32 | #include "AliLog.h" |
17149e6b | 33 | #include "AliTOFChannelOnlineArray.h" |
34 | #include "AliTOFChannelOnlineStatusArray.h" | |
9edefa04 | 35 | #include "AliTOFDataDCS.h" |
10056aa6 | 36 | #include "AliTOFGeometry.h" |
9edefa04 | 37 | #include "AliTOFPreprocessor.h" |
db83b789 | 38 | #include "AliTOFFEEReader.h" |
3dda26a0 | 39 | #include "AliTOFRawStream.h" |
40 | #include "AliTOFCableLengthMap.h" | |
b06d5296 | 41 | #include "AliTOFcalibHisto.h" |
3dda26a0 | 42 | |
c9fe8530 | 43 | |
c9fe8530 | 44 | // TOF preprocessor class. |
45 | // It takes data from DCS and passes them to the class AliTOFDataDCS, which | |
46 | // processes them. The result is then written to the CDB. | |
17149e6b | 47 | // Analogously, it takes data form DAQ (both at Run level and inclusive - |
c9fe8530 | 48 | // of all the runs - level, processes them, and stores both Reference Data |
49 | // and Online Calibration files in the CDB. | |
17149e6b | 50 | // Processing of Pulser/Noise Run data and of TOF FEE DCS map included also. |
7fffa85b | 51 | |
52 | // return codes: | |
53 | // return=0 : all ok | |
54 | // return=1 : no DCS input data Map | |
55 | // return=2 : no DCS input data processing | |
56 | // return=3 : no DCS processed data was stored in Ref Data | |
57 | // return=4 : no DAQ input for Ref Data | |
58 | // return=5 : failed to store DAQ Ref Data | |
59 | // return=6 : failed to retrieve DAQ data for calibration | |
60 | // return=7 : problems in processing histos in the input DAQ file | |
61 | // return=8 : failed to store Online Delays | |
62 | // return=9 : failed to store Reference Data for Pulser | |
63 | // return=10: failed to retrieve Pulser data | |
64 | // return=11: failed to store Pulser map in OCDB | |
65 | // return=12: failed to store Reference Data for Noise | |
66 | // return=13: failed to retrieve Noise data | |
67 | // return=14: failed to store Noise map in OCDB | |
db83b789 | 68 | // return=15: failed to retrieve FEE data from FXS |
69 | // return=16: failed to retrieve FEE data from OCDB | |
70 | // return=17: failed to store FEE data in OCDB | |
71 | // return=18: failed to store FEE reference data in OCDB | |
17149e6b | 72 | // return=20: failed in retrieving status variable |
c9fe8530 | 73 | |
74 | ClassImp(AliTOFPreprocessor) | |
75 | ||
7fffa85b | 76 | const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean |
77 | const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel | |
78 | const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay | |
c9fe8530 | 79 | |
80 | //_____________________________________________________________________________ | |
81 | ||
708db10b | 82 | AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) : |
83 | AliPreprocessor("TOF", shuttle), | |
c9fe8530 | 84 | fData(0), |
c9fe8530 | 85 | fCal(0), |
10056aa6 | 86 | fNChannels(0), |
7fffa85b | 87 | fStoreRefData(kTRUE), |
17149e6b | 88 | fFDRFlag(kFALSE), |
013ac2dd | 89 | fStatus(0), |
90 | fMatchingWindow(0) | |
c9fe8530 | 91 | { |
92 | // constructor | |
370aeff7 | 93 | AddRunType("PHYSICS"); |
94 | AddRunType("PULSER"); | |
95 | AddRunType("NOISE"); | |
10056aa6 | 96 | |
c9fe8530 | 97 | } |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | ||
101 | AliTOFPreprocessor::~AliTOFPreprocessor() | |
102 | { | |
103 | // destructor | |
104 | } | |
105 | ||
106 | //______________________________________________________________________________ | |
107 | void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
108 | UInt_t endTime) | |
109 | { | |
110 | // Creates AliTOFDataDCS object | |
111 | ||
112 | AliPreprocessor::Initialize(run, startTime, endTime); | |
113 | ||
ff326f84 | 114 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run, |
c9fe8530 | 115 | TTimeStamp(startTime).AsString(), |
ff326f84 | 116 | TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString())); |
c9fe8530 | 117 | |
ff326f84 | 118 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery()); |
10056aa6 | 119 | fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX(); |
c9fe8530 | 120 | } |
7fffa85b | 121 | //_____________________________________________________________________________ |
122 | Bool_t AliTOFPreprocessor::ProcessDCS(){ | |
123 | ||
124 | // check whether DCS should be processed or not... | |
c9fe8530 | 125 | |
7fffa85b | 126 | TString runType = GetRunType(); |
127 | Log(Form("RunType %s",runType.Data())); | |
128 | ||
55454922 | 129 | if (runType != "PHYSICS"){ |
7fffa85b | 130 | return kFALSE; |
131 | } | |
132 | ||
133 | return kTRUE; | |
134 | } | |
c9fe8530 | 135 | //_____________________________________________________________________________ |
136 | ||
ee3e792b | 137 | UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap) |
c9fe8530 | 138 | { |
139 | // Fills data into a AliTOFDataDCS object | |
140 | ||
7fffa85b | 141 | |
142 | Log("Processing DCS DP"); | |
708db10b | 143 | TH1::AddDirectory(0); |
5936ab02 | 144 | |
7885c291 | 145 | Bool_t resultDCSMap=kFALSE; |
146 | Bool_t resultDCSStore=kFALSE; | |
c9fe8530 | 147 | |
148 | // processing DCS | |
149 | ||
4856f488 | 150 | fData->SetFDRFlag(fFDRFlag); |
151 | ||
c9fe8530 | 152 | if (!dcsAliasMap){ |
5936ab02 | 153 | Log("No DCS map found: TOF exiting from Shuttle"); |
e88f3330 | 154 | if (fData){ |
155 | delete fData; | |
156 | fData = 0; | |
157 | } | |
5936ab02 | 158 | return 1;// return error Code for DCS input data not found |
c9fe8530 | 159 | } |
160 | else { | |
4856f488 | 161 | |
c9fe8530 | 162 | // The processing of the DCS input data is forwarded to AliTOFDataDCS |
7885c291 | 163 | resultDCSMap=fData->ProcessData(*dcsAliasMap); |
164 | if(!resultDCSMap){ | |
165 | Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle"); | |
e88f3330 | 166 | if (fData){ |
167 | delete fData; | |
168 | fData = 0; | |
169 | } | |
5936ab02 | 170 | return 2;// return error Code for processed DCS data not stored |
c9fe8530 | 171 | } |
7885c291 | 172 | else{ |
173 | AliCDBMetaData metaDataDCS; | |
174 | metaDataDCS.SetBeamPeriod(0); | |
175 | metaDataDCS.SetResponsible("Chiara Zampolli"); | |
176 | metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); | |
177 | AliInfo("Storing DCS Data"); | |
b0d8f3fc | 178 | resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS); |
7885c291 | 179 | if (!resultDCSStore){ |
b0d8f3fc | 180 | Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle"); |
e88f3330 | 181 | if (fData){ |
182 | delete fData; | |
183 | fData = 0; | |
184 | } | |
7885c291 | 185 | return 3;// return error Code for processed DCS data not stored |
b0d8f3fc | 186 | // in reference data |
7885c291 | 187 | |
188 | } | |
189 | } | |
c9fe8530 | 190 | } |
e88f3330 | 191 | if (fData){ |
192 | delete fData; | |
193 | fData = 0; | |
194 | } | |
195 | ||
ee3e792b | 196 | return 0; |
197 | } | |
198 | //_____________________________________________________________________________ | |
199 | ||
200 | UInt_t AliTOFPreprocessor::ProcessOnlineDelays() | |
201 | { | |
7fffa85b | 202 | // Processing data from DAQ for online calibration |
203 | ||
965fa008 | 204 | Bool_t updateOCDB = kFALSE; |
7fffa85b | 205 | Log("Processing DAQ delays"); |
ee3e792b | 206 | |
17149e6b | 207 | // reading configuration map |
208 | TString compDelays = "kFALSE"; | |
209 | Int_t deltaStartingRun = fRun; | |
210 | Int_t startingRun = fRun-deltaStartingRun; | |
211 | Int_t binRangeAve = fgkBinRangeAve; | |
212 | Double_t integralThr = fgkIntegralThr; | |
213 | Double_t thrPar = fgkThrPar; | |
214 | ||
215 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config"); | |
216 | if (!cdbEntry) { | |
217 | Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun)); | |
218 | } | |
219 | else { | |
220 | TMap *configMap = (TMap*)cdbEntry->GetObject(); | |
221 | if (!configMap){ | |
222 | Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun)); | |
223 | } | |
224 | else{ | |
225 | TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays"); | |
226 | if (strDelays) { | |
227 | compDelays = (TString) strDelays->GetString(); | |
228 | } | |
229 | else { | |
230 | Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data())); | |
231 | } | |
232 | TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun"); | |
233 | if (strRun) { | |
234 | TString tmpstr = strRun->GetString(); | |
235 | startingRun = tmpstr.Atoi(); | |
236 | deltaStartingRun = fRun - startingRun; | |
237 | } | |
238 | else { | |
239 | Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun)); | |
240 | } | |
241 | TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve"); | |
242 | if (strBinRangeAve) { | |
243 | TString tmpstr = strBinRangeAve->GetString(); | |
244 | binRangeAve = tmpstr.Atoi(); | |
245 | } | |
246 | else { | |
247 | Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve)); | |
248 | } | |
249 | TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr"); | |
250 | if (strIntegralThr) { | |
251 | TString tmpstr = strIntegralThr->GetString(); | |
252 | integralThr = tmpstr.Atof(); | |
253 | } | |
254 | else { | |
255 | Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr)); | |
256 | } | |
257 | TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar"); | |
258 | if (strThrPar) { | |
259 | TString tmpstr = strThrPar->GetString(); | |
260 | thrPar = tmpstr.Atof(); | |
261 | } | |
262 | else { | |
263 | Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar)); | |
264 | } | |
265 | } | |
266 | } | |
267 | if (compDelays == "kTRUE") fFDRFlag = kFALSE; | |
268 | else fFDRFlag = kTRUE; | |
269 | ||
e88f3330 | 270 | delete cdbEntry; |
271 | cdbEntry = 0x0; | |
272 | ||
17149e6b | 273 | Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun)); |
274 | ||
965fa008 | 275 | /* init array with current calibration, if any */ |
276 | fCal = new AliTOFChannelOnlineArray(fNChannels); | |
277 | AliTOFChannelOnlineArray *curCal = NULL; | |
278 | ||
279 | AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay"); | |
280 | if (!cdbEntry2 || !cdbEntry2->GetObject()) { | |
281 | /* no CDB entry found. set update flag */ | |
282 | Log(" ************ WARNING ************"); | |
283 | Log("No CDB ParOnlineDelay entry found, creating a new one!"); | |
284 | Log(" *********************************"); | |
285 | updateOCDB = kTRUE; | |
286 | } | |
287 | else { | |
288 | Log("Found previous ParOnlineDelay entry. Using it to init calibration"); | |
289 | curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject(); | |
290 | for (Int_t i = 0; i < fNChannels; i++) | |
291 | fCal->SetDelay(i, curCal->GetDelay(i)); | |
292 | } | |
293 | ||
17149e6b | 294 | |
ee3e792b | 295 | TH1::AddDirectory(0); |
296 | ||
297 | Bool_t resultDAQRef=kFALSE; | |
7fffa85b | 298 | Bool_t resultTOFPP=kFALSE; |
e88f3330 | 299 | TH2S *h2 = 0x0; |
c9fe8530 | 300 | // processing DAQ |
7885c291 | 301 | |
c9fe8530 | 302 | TFile * daqFile=0x0; |
7885c291 | 303 | |
5936ab02 | 304 | if(fStoreRefData){ |
305 | //retrieving data at Run level | |
17149e6b | 306 | TList* list = GetFileSources(kDAQ, "RUNLevel"); |
307 | if (list !=0x0 && list->GetEntries()!=0) | |
308 | { | |
309 | AliInfo("The following sources produced files with the id RUNLevel"); | |
310 | list->Print(); | |
311 | for (Int_t jj=0;jj<list->GetEntries();jj++){ | |
312 | TObjString * str = dynamic_cast<TObjString*> (list->At(jj)); | |
313 | AliInfo(Form("found source %s", str->String().Data())); | |
314 | // file to be stored run per run | |
315 | TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName()); | |
316 | if (fileNameRun.Length()>0){ | |
317 | AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data())); | |
318 | daqFile = new TFile(fileNameRun.Data(),"READ"); | |
e88f3330 | 319 | h2 = (TH2S*) daqFile->Get("htof"); |
17149e6b | 320 | AliCDBMetaData metaDataHisto; |
321 | metaDataHisto.SetBeamPeriod(0); | |
322 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
323 | metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data."); | |
324 | AliInfo("Storing Reference Data"); | |
e88f3330 | 325 | resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto); |
17149e6b | 326 | if (!resultDAQRef){ |
327 | Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle"); | |
e88f3330 | 328 | delete h2; |
329 | delete list; | |
330 | delete fCal; | |
331 | fCal=0x0; | |
17149e6b | 332 | return 5;//return error code for failure in storing Ref Data |
333 | } | |
334 | daqFile->Close(); | |
335 | delete daqFile; | |
336 | } | |
337 | ||
338 | else{ | |
339 | Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle "); | |
e88f3330 | 340 | delete list; |
341 | delete fCal; | |
342 | fCal=0x0; | |
17149e6b | 343 | return 4;//return error code for failure in retrieving Ref Data |
344 | } | |
345 | } | |
346 | delete list; | |
347 | } | |
5936ab02 | 348 | else{ |
17149e6b | 349 | Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle "); |
e88f3330 | 350 | delete fCal; |
351 | fCal=0x0; | |
17149e6b | 352 | return 4;//return error code for failure in retrieving Ref Data |
353 | } | |
9bc469d1 | 354 | } |
355 | ||
9bc469d1 | 356 | |
17149e6b | 357 | //Total files, with cumulative histos |
5936ab02 | 358 | |
9bc469d1 | 359 | TList* listTot = GetFileSources(kDAQ, "DELAYS"); |
bf76be9c | 360 | if (listTot !=0x0 && listTot->GetEntries()!=0) |
17149e6b | 361 | { |
362 | AliInfo("The following sources produced files with the id DELAYS"); | |
363 | listTot->Print(); | |
364 | for (Int_t jj=0;jj<listTot->GetEntries();jj++){ | |
365 | TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj)); | |
366 | AliInfo(Form("found source %s", str->String().Data())); | |
367 | ||
368 | // file with summed histos, to extract calib params | |
369 | TString fileName = GetFile(kDAQ, "DELAYS", str->GetName()); | |
370 | if (fileName.Length()>0){ | |
371 | AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
372 | ||
373 | daqFile = new TFile(fileName.Data(),"READ"); | |
e88f3330 | 374 | if (h2) delete h2; |
375 | h2 = (TH2S*) daqFile->Get("htoftot"); | |
376 | if (!h2){ | |
17149e6b | 377 | Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle"); |
e88f3330 | 378 | delete listTot; |
17149e6b | 379 | delete daqFile; |
e88f3330 | 380 | delete fCal; |
381 | fCal=0x0; | |
17149e6b | 382 | return 7; //return error code for histograms not existing/junky |
383 | } | |
384 | else { | |
e88f3330 | 385 | static const Int_t kSize=h2->GetNbinsX(); |
386 | static const Int_t kNBins=h2->GetNbinsY(); | |
387 | static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1); | |
17149e6b | 388 | if (kSize != fNChannels){ |
389 | Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle"); | |
e88f3330 | 390 | delete listTot; |
391 | delete h2; | |
17149e6b | 392 | delete daqFile; |
e88f3330 | 393 | delete fCal; |
394 | fCal=0x0; | |
17149e6b | 395 | return 7; //return error code for histograms not existing/junky |
396 | } | |
397 | Int_t nNotStatistics = 0; // number of channel with not enough statistics | |
3dda26a0 | 398 | |
b06d5296 | 399 | /* FDR flag set. do not compute delays, use nominal cable delays */ |
3dda26a0 | 400 | if (fFDRFlag) { |
401 | ||
402 | Log(" Not computing delays according to flag set in Config entry in OCDB!"); | |
b06d5296 | 403 | FillWithCosmicCalibration(fCal); |
965fa008 | 404 | |
405 | /* check whether the new calibration is different from the previous one */ | |
406 | if (curCal) { /* well, check also whether we have a previous calibration */ | |
407 | for (Int_t i = 0; i < fNChannels; i++) { | |
408 | if (fCal->GetDelay(i) != curCal->GetDelay(i)) { | |
409 | updateOCDB = kTRUE; | |
410 | break; | |
411 | } | |
412 | } | |
413 | } | |
414 | else /* otherwise update OCDB */ | |
415 | updateOCDB = kTRUE; | |
416 | ||
3dda26a0 | 417 | } |
17149e6b | 418 | |
419 | else { // computing delays if not in FDR runs | |
965fa008 | 420 | |
421 | updateOCDB = kTRUE; /* always update OCDB when computing delays */ | |
422 | ||
17149e6b | 423 | for (Int_t ich=0;ich<kSize;ich++){ |
424 | /* check whether channel has been read out during current run. | |
425 | * if the status is bad it means it has not been read out. | |
426 | * in this case skip channel in order to not affect the mean */ | |
427 | if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){ | |
428 | AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich))); | |
429 | continue; | |
430 | } | |
431 | AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich)); | |
432 | TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5); | |
433 | for (Int_t ibin=0;ibin<kNBins;ibin++){ | |
e88f3330 | 434 | h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1)); |
17149e6b | 435 | } |
436 | if(h1->Integral()<integralThr) { | |
437 | nNotStatistics++; | |
438 | Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs | |
439 | delete h1; | |
440 | h1=0x0; | |
441 | continue; | |
442 | } | |
443 | Bool_t found=kFALSE; | |
444 | Float_t minContent=h1->Integral()*thrPar; | |
445 | Int_t nbinsX = h1->GetNbinsX(); | |
446 | Int_t startBin=1; | |
447 | for (Int_t j=1; j<=nbinsX; j++){ | |
448 | if (( | |
449 | h1->GetBinContent(j) + | |
450 | h1->GetBinContent(j+1)+ | |
451 | h1->GetBinContent(j+2)+ | |
452 | h1->GetBinContent(j+3))>minContent){ | |
453 | found=kTRUE; | |
454 | startBin=j; | |
455 | break; | |
456 | } | |
457 | } | |
458 | if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich)); | |
459 | // Now calculate the mean over the interval. | |
460 | Double_t mean = 0; | |
461 | Double_t sumw2 = 0; | |
462 | Double_t nent = 0; | |
463 | for(Int_t k=0;k<binRangeAve;k++){ | |
464 | mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k); | |
465 | nent=nent+h1->GetBinContent(startBin+k); | |
466 | sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k)); | |
467 | } | |
468 | mean= mean/nent; //<x> | |
469 | sumw2=sumw2/nent; //<x^2> | |
470 | Double_t rmsmean= 0; | |
471 | rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent); | |
472 | if (ich<fNChannels) { | |
473 | Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns | |
474 | fCal->SetDelay(ich,delay); // delay in ns | |
475 | AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich)); | |
476 | } | |
477 | delete h1; | |
478 | h1=0x0; | |
479 | } | |
480 | } | |
481 | if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics)); | |
482 | } | |
e88f3330 | 483 | delete h2; |
17149e6b | 484 | daqFile->Close(); |
485 | delete daqFile; | |
486 | } | |
487 | else{ | |
488 | Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle"); | |
e88f3330 | 489 | delete listTot; |
490 | delete fCal; | |
491 | fCal=0x0; | |
17149e6b | 492 | return 6;//return error code for problems in retrieving DAQ data |
493 | } | |
7fffa85b | 494 | } |
17149e6b | 495 | delete listTot; |
c9fe8530 | 496 | } |
c9fe8530 | 497 | else{ |
9d883ed9 | 498 | Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle"); |
e88f3330 | 499 | delete fCal; |
500 | fCal=0x0; | |
7885c291 | 501 | return 6; //return error code for problems in retrieving DAQ data |
c9fe8530 | 502 | } |
503 | ||
965fa008 | 504 | /* check whether we don't need to update OCDB. |
505 | * in this case we can return without errors and | |
506 | * the current FEE is stored in the fStatus object. */ | |
507 | if (!updateOCDB) { | |
508 | AliInfo("update OCDB flag not set. Do not overwrite stored file."); | |
509 | return 0; /* return ok */ | |
510 | } | |
511 | ||
c9fe8530 | 512 | daqFile=0; |
7fffa85b | 513 | AliCDBMetaData metaData; |
514 | metaData.SetBeamPeriod(0); | |
515 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 516 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays."); |
7fffa85b | 517 | AliInfo("Storing Calibration Data"); |
17149e6b | 518 | resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE); |
7fffa85b | 519 | if(!resultTOFPP){ |
520 | Log("Some problems occurred while storing online object resulting from DAQ data processing"); | |
e88f3330 | 521 | delete fCal; |
522 | fCal=0x0; | |
7fffa85b | 523 | return 8;//return error code for problems in storing DAQ data |
524 | } | |
9d883ed9 | 525 | |
e88f3330 | 526 | if (fCal){ |
527 | delete fCal; | |
528 | fCal = 0; | |
529 | } | |
530 | ||
5936ab02 | 531 | return 0; |
c9fe8530 | 532 | } |
ee3e792b | 533 | //_____________________________________________________________________________ |
534 | ||
535 | UInt_t AliTOFPreprocessor::ProcessPulserData() | |
536 | { | |
7fffa85b | 537 | // Processing Pulser Run data for TOF channel status |
538 | ||
539 | Log("Processing Pulser"); | |
ee3e792b | 540 | |
17149e6b | 541 | if (fStatus==0x0){ |
542 | AliError("No valid fStatus found, some errors must have occurred!!"); | |
543 | return 20; | |
544 | } | |
ee3e792b | 545 | |
17149e6b | 546 | TH1::AddDirectory(0); |
547 | ||
ee3e792b | 548 | Bool_t resultPulserRef=kFALSE; |
7fffa85b | 549 | Bool_t resultPulser=kFALSE; |
17149e6b | 550 | |
a174d599 | 551 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
552 | TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5); | |
553 | for (Int_t ibin =1;ibin<=kSize;ibin++){ | |
17149e6b | 554 | htofPulser->SetBinContent(ibin,-1); |
7fffa85b | 555 | } |
17149e6b | 556 | |
ee3e792b | 557 | // processing pulser |
558 | ||
559 | TFile * daqFile=0x0; | |
560 | TH1S *h1=0x0; | |
561 | ||
562 | //retrieving Pulser data | |
563 | TList* listPulser = GetFileSources(kDAQ, "PULSER"); | |
bf76be9c | 564 | if (listPulser !=0x0 && listPulser->GetEntries()!=0) |
e88f3330 | 565 | { |
566 | AliInfo("The following sources produced files with the id PULSER"); | |
567 | listPulser->Print(); | |
568 | Int_t nPulser = 0; | |
569 | for (Int_t jj=0;jj<listPulser->GetEntries();jj++){ | |
570 | Int_t nPulserSource = 0; | |
571 | TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj)); | |
572 | AliInfo(Form("found source %s", str->String().Data())); | |
573 | // file to be stored run per run | |
574 | TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName()); | |
575 | if (fileNamePulser.Length()>0){ | |
576 | // storing refernce data | |
577 | AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data())); | |
578 | daqFile = new TFile(fileNamePulser.Data(),"READ"); | |
579 | h1 = (TH1S*) daqFile->Get("hTOFpulser"); | |
580 | for (Int_t ibin=0;ibin<kSize;ibin++){ | |
581 | if ((h1->GetBinContent(ibin+1))!=-1){ | |
582 | if ((htofPulser->GetBinContent(ibin+1))==-1){ | |
583 | htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)); | |
584 | } | |
585 | else { | |
586 | Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin)); | |
587 | } | |
588 | } | |
589 | } | |
590 | ||
591 | // elaborating infos | |
592 | Double_t mean =0; | |
593 | Int_t nread=0; | |
594 | Int_t nreadNotEmpty=0; | |
595 | for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){ | |
596 | ||
597 | AliDebug(3,Form(" channel %i pulser status before pulser = %i, with global status = %i",ientry,(Int_t)fStatus->GetPulserStatus(ientry),(Int_t)fStatus->GetStatus(ientry))); | |
598 | /* check whether channel has been read out during current run. | |
599 | * if the status is bad it means it has not been read out. | |
600 | * in this case skip channel in order to not affect the mean */ | |
601 | if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
602 | continue; | |
603 | nPulser++; | |
604 | nPulserSource++; | |
605 | if (h1->GetBinContent(ientry)==-1) continue; | |
606 | else { | |
607 | if (h1->GetBinContent(ientry)>0) { | |
608 | nreadNotEmpty++; | |
609 | AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty)); | |
610 | } | |
611 | mean+=h1->GetBinContent(ientry); | |
612 | nread++; | |
613 | } | |
614 | } | |
615 | if (nread!=0) { | |
616 | mean/=nread; | |
617 | AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean)); | |
618 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
619 | if (h1->GetBinContent(ich+1)==-1) continue; | |
620 | AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich))); | |
621 | ||
622 | /* check whether channel has been read out during current run. | |
623 | * if the status is bad it means it has not been read out. | |
624 | * in this case skip channel in order to leave its status | |
625 | * unchanged */ | |
626 | if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
627 | continue; | |
628 | ||
629 | if (h1->GetBinContent(ich+1)<0.05*mean){ | |
630 | fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser | |
631 | AliDebug(2,Form( " channel %i pulser status after pulser = %i (bad, content = %f), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),h1->GetBinContent(ich+1),(Int_t)fStatus->GetStatus(ich))); | |
632 | } | |
633 | else { | |
634 | fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser | |
635 | AliDebug(2,Form( " channel %i pulser status after pulser = %i (good), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),(Int_t)fStatus->GetStatus(ich))); | |
636 | } | |
637 | } | |
638 | } | |
639 | else { | |
640 | Log("No channels read!! No action taken, keeping old status"); | |
641 | } | |
642 | ||
643 | daqFile->Close(); | |
644 | delete daqFile; | |
645 | delete h1; | |
17149e6b | 646 | } |
1a1486e7 | 647 | |
e88f3330 | 648 | else{ |
649 | Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle "); | |
650 | delete listPulser; | |
651 | delete htofPulser; | |
652 | htofPulser = 0x0; | |
653 | if (fStatus){ | |
654 | delete fStatus; | |
655 | fStatus = 0; | |
656 | } | |
657 | return 10;//return error code for failure in retrieving Ref Data | |
1a1486e7 | 658 | } |
e88f3330 | 659 | AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource)); |
1a1486e7 | 660 | } |
e88f3330 | 661 | AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser)); |
662 | delete listPulser; | |
ee3e792b | 663 | } |
7fffa85b | 664 | |
ee3e792b | 665 | else{ |
17149e6b | 666 | Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle "); |
e88f3330 | 667 | delete htofPulser; |
668 | htofPulser = 0x0; | |
669 | if (fStatus){ | |
670 | delete fStatus; | |
671 | fStatus = 0; | |
672 | } | |
17149e6b | 673 | return 10;//return error code for failure in retrieving Ref Data |
ee3e792b | 674 | } |
17149e6b | 675 | |
7fffa85b | 676 | //storing in OCDB |
17149e6b | 677 | |
7fffa85b | 678 | AliCDBMetaData metaData; |
679 | metaData.SetBeamPeriod(0); | |
680 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 681 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run."); |
7fffa85b | 682 | AliInfo("Storing Calibration Data from Pulser Run"); |
17149e6b | 683 | resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE); |
7fffa85b | 684 | if(!resultPulser){ |
685 | Log("Some problems occurred while storing online object resulting from Pulser data processing"); | |
e88f3330 | 686 | delete htofPulser; |
687 | htofPulser = 0x0; | |
688 | if (fStatus){ | |
689 | delete fStatus; | |
690 | fStatus = 0; | |
691 | } | |
7fffa85b | 692 | return 11;//return error code for problems in storing Pulser data |
693 | } | |
694 | ||
ee3e792b | 695 | if(fStoreRefData){ |
696 | ||
697 | AliCDBMetaData metaDataHisto; | |
698 | metaDataHisto.SetBeamPeriod(0); | |
699 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
700 | char comment[200]; | |
17149e6b | 701 | sprintf(comment,"This preprocessor stores the Ref data from a pulser run."); |
ee3e792b | 702 | metaDataHisto.SetComment(comment); |
703 | AliInfo("Storing Reference Data"); | |
db83b789 | 704 | resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto); |
ee3e792b | 705 | if (!resultPulserRef){ |
7fffa85b | 706 | Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle"); |
e88f3330 | 707 | delete htofPulser; |
708 | htofPulser = 0x0; | |
709 | if (fStatus){ | |
710 | delete fStatus; | |
711 | fStatus = 0; | |
712 | } | |
7fffa85b | 713 | return 9;//return error code for failure in storing Ref Data |
ee3e792b | 714 | } |
715 | } | |
716 | ||
717 | daqFile=0; | |
718 | ||
e88f3330 | 719 | delete htofPulser; |
720 | htofPulser = 0x0; | |
721 | ||
722 | if (fStatus){ | |
723 | delete fStatus; | |
724 | fStatus = 0; | |
725 | } | |
726 | ||
ee3e792b | 727 | return 0; |
728 | } | |
729 | //_____________________________________________________________________________ | |
730 | ||
731 | UInt_t AliTOFPreprocessor::ProcessNoiseData() | |
732 | { | |
7fffa85b | 733 | |
734 | // Processing Noise Run data for TOF channel status | |
735 | ||
736 | Log("Processing Noise"); | |
ee3e792b | 737 | |
17149e6b | 738 | if (fStatus==0x0){ |
739 | AliError("No valid fStatus found, some errors must have occurred!!"); | |
740 | return 20; | |
741 | } | |
742 | ||
013ac2dd | 743 | Float_t noiseThr = 1; // setting default threshold for noise to 1 Hz |
744 | // reading config map | |
745 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise"); | |
746 | if (!cdbEntry) { | |
747 | Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr)); | |
748 | } | |
749 | else { | |
750 | TMap *configMap = (TMap*)cdbEntry->GetObject(); | |
751 | if (!configMap){ | |
752 | Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr)); | |
753 | } | |
754 | else{ | |
755 | TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr"); | |
756 | if (strNoiseThr) { | |
757 | TString tmpstr = strNoiseThr->GetString(); | |
758 | noiseThr = tmpstr.Atoi(); | |
759 | } | |
760 | else { | |
761 | Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr)); | |
762 | } | |
763 | } | |
764 | } | |
765 | ||
766 | delete cdbEntry; | |
767 | cdbEntry = 0x0; | |
768 | ||
ee3e792b | 769 | TH1::AddDirectory(0); |
770 | ||
771 | Bool_t resultNoiseRef=kFALSE; | |
7fffa85b | 772 | Bool_t resultNoise=kFALSE; |
ee3e792b | 773 | |
a174d599 | 774 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
17149e6b | 775 | TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5); |
a174d599 | 776 | for (Int_t ibin =1;ibin<=kSize;ibin++){ |
17149e6b | 777 | htofNoise->SetBinContent(ibin,-1); |
ee3e792b | 778 | } |
17149e6b | 779 | |
ee3e792b | 780 | // processing noise |
781 | ||
782 | TFile * daqFile=0x0; | |
783 | TH1F * h1=0x0; | |
784 | ||
013ac2dd | 785 | // useful counters |
786 | Int_t nNoise = 0; | |
787 | Int_t nNoisyChannels = 0; | |
788 | Int_t nNotNoisyChannels = 0; | |
789 | Int_t nChannelsFromDA = 0; | |
790 | Int_t nMatchingWindowNullNonZero = 0; | |
791 | Int_t nMatchingWindowNullEqualZero = 0; | |
792 | ||
793 | // retrieving Noise data | |
ee3e792b | 794 | TList* listNoise = GetFileSources(kDAQ, "NOISE"); |
bf76be9c | 795 | if (listNoise !=0x0 && listNoise->GetEntries()!=0) |
e88f3330 | 796 | { |
797 | AliInfo("The following sources produced files with the id NOISE"); | |
798 | listNoise->Print(); | |
e88f3330 | 799 | for (Int_t jj=0;jj<listNoise->GetEntries();jj++){ |
800 | Int_t nNoiseSource = 0; | |
801 | TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj)); | |
802 | AliInfo(Form("found source %s", str->String().Data())); | |
803 | // file to be stored run per run | |
804 | TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName()); | |
805 | if (fileNameNoise.Length()>0){ | |
806 | // storing reference data | |
807 | AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data())); | |
808 | daqFile = new TFile(fileNameNoise.Data(),"READ"); | |
809 | h1 = (TH1F*) daqFile->Get("hTOFnoise"); | |
810 | for (Int_t ibin=0;ibin<kSize;ibin++){ | |
811 | if ((h1->GetBinContent(ibin+1))!=-1){ | |
013ac2dd | 812 | nNoiseSource++; |
813 | // checking the matching window for current channel | |
814 | if (fMatchingWindow[ibin] == 0){ | |
fc143ab2 | 815 | Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin)); |
013ac2dd | 816 | if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++; |
817 | if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++; | |
818 | continue; | |
819 | } | |
e88f3330 | 820 | if ((htofNoise->GetBinContent(ibin+1))==-1){ |
013ac2dd | 821 | htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9)); |
822 | if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1))); | |
e88f3330 | 823 | } |
824 | else { | |
825 | Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin)); | |
826 | } | |
827 | } | |
828 | } | |
013ac2dd | 829 | |
830 | Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource)); | |
e88f3330 | 831 | daqFile->Close(); |
832 | delete daqFile; | |
833 | delete h1; | |
013ac2dd | 834 | daqFile = 0x0; |
835 | h1 = 0x0; | |
836 | ||
e88f3330 | 837 | } |
e88f3330 | 838 | else{ |
839 | Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle "); | |
840 | delete listNoise; | |
013ac2dd | 841 | listNoise = 0x0; |
e88f3330 | 842 | delete htofNoise; |
843 | htofNoise = 0x0; | |
844 | if (fStatus){ | |
845 | delete fStatus; | |
846 | fStatus = 0; | |
847 | } | |
013ac2dd | 848 | if (fMatchingWindow){ |
849 | delete [] fMatchingWindow; | |
850 | fMatchingWindow = 0; | |
851 | } | |
e88f3330 | 852 | return 13;//return error code for failure in retrieving Ref Data |
853 | } | |
013ac2dd | 854 | } |
ee3e792b | 855 | } |
013ac2dd | 856 | |
e88f3330 | 857 | else{ |
858 | Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle "); | |
859 | delete htofNoise; | |
860 | htofNoise = 0x0; | |
861 | if (fStatus){ | |
862 | delete fStatus; | |
863 | fStatus = 0; | |
ee3e792b | 864 | } |
013ac2dd | 865 | if (fMatchingWindow){ |
866 | delete [] fMatchingWindow; | |
867 | fMatchingWindow = 0; | |
868 | } | |
7fffa85b | 869 | return 13;//return error code for failure in retrieving Ref Data |
ee3e792b | 870 | } |
871 | ||
013ac2dd | 872 | // elaborating infos to set NOISE status |
873 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
874 | if (htofNoise->GetBinContent(ich+1)== -1) continue; | |
875 | ||
876 | nChannelsFromDA++; | |
877 | ||
878 | AliDebug(3,Form(" channel %i noise status before noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich))); | |
879 | //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich))); | |
880 | ||
881 | /* check whether channel has been read out during current run. | |
882 | * if the status is bad it means it has not been read out. | |
883 | * in this case skip channel in order to leave its status | |
884 | * unchanged */ | |
885 | ||
886 | if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
887 | continue; | |
888 | ||
889 | nNoise++; | |
890 | if (htofNoise->GetBinContent(ich+1) >= noiseThr){ | |
891 | fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise | |
892 | AliDebug(3,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich))); | |
893 | nNoisyChannels++; | |
894 | } | |
895 | else { | |
896 | fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise | |
897 | AliDebug(3,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich))); | |
898 | nNotNoisyChannels++; | |
899 | } | |
900 | } | |
901 | ||
902 | Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA)); | |
903 | Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise)); | |
904 | Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels)); | |
905 | Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels)); | |
906 | Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero)); | |
907 | Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero)); | |
908 | ||
909 | delete listNoise; | |
910 | ||
911 | //daqFile=0; | |
e88f3330 | 912 | |
7fffa85b | 913 | //storing in OCDB |
e88f3330 | 914 | |
7fffa85b | 915 | AliCDBMetaData metaData; |
916 | metaData.SetBeamPeriod(0); | |
917 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 918 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run."); |
7fffa85b | 919 | AliInfo("Storing Calibration Data from Noise Run"); |
17149e6b | 920 | resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE); |
7fffa85b | 921 | if(!resultNoise){ |
922 | Log("Some problems occurred while storing online object resulting from Noise data processing"); | |
e88f3330 | 923 | delete htofNoise; |
924 | htofNoise = 0x0; | |
925 | if (fStatus){ | |
926 | delete fStatus; | |
927 | fStatus = 0; | |
928 | } | |
013ac2dd | 929 | if (fMatchingWindow){ |
930 | delete [] fMatchingWindow; | |
931 | fMatchingWindow = 0; | |
932 | } | |
7fffa85b | 933 | return 14;//return error code for problems in storing Noise data |
934 | } | |
935 | ||
ee3e792b | 936 | if(fStoreRefData){ |
937 | ||
938 | AliCDBMetaData metaDataHisto; | |
939 | metaDataHisto.SetBeamPeriod(0); | |
940 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
941 | char comment[200]; | |
17149e6b | 942 | sprintf(comment,"This preprocessor stores the Ref data from a noise run. "); |
ee3e792b | 943 | metaDataHisto.SetComment(comment); |
944 | AliInfo("Storing Reference Data"); | |
db83b789 | 945 | resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto); |
ee3e792b | 946 | if (!resultNoiseRef){ |
947 | Log("some problems occurred::No Reference Data for noise stored"); | |
e88f3330 | 948 | delete htofNoise; |
949 | htofNoise = 0x0; | |
950 | if (fStatus){ | |
951 | delete fStatus; | |
952 | fStatus = 0; | |
953 | } | |
013ac2dd | 954 | if (fMatchingWindow){ |
955 | delete [] fMatchingWindow; | |
956 | fMatchingWindow = 0; | |
957 | } | |
7fffa85b | 958 | return 12;//return error code for failure in storing Ref Data |
ee3e792b | 959 | } |
960 | } | |
961 | ||
e88f3330 | 962 | delete htofNoise; |
963 | htofNoise = 0x0; | |
964 | ||
965 | if (fStatus){ | |
966 | delete fStatus; | |
967 | fStatus = 0; | |
968 | } | |
969 | ||
013ac2dd | 970 | if (fMatchingWindow){ |
971 | delete [] fMatchingWindow; | |
972 | fMatchingWindow = 0; | |
973 | } | |
974 | ||
ee3e792b | 975 | return 0; |
976 | } | |
977 | //_____________________________________________________________________________ | |
978 | ||
db83b789 | 979 | UInt_t AliTOFPreprocessor::ProcessFEEData() |
ee3e792b | 980 | { |
7fffa85b | 981 | // Processing Pulser Run data for TOF channel status |
982 | // dummy for the time being | |
ee3e792b | 983 | |
db83b789 | 984 | Log("Processing FEE"); |
985 | ||
986 | Bool_t updateOCDB = kFALSE; | |
987 | AliTOFFEEReader feeReader; | |
17149e6b | 988 | |
db83b789 | 989 | TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels); |
990 | ||
991 | /* load current TOF FEE config from DCS FXS, parse, | |
992 | * fill current FEE histogram and set FEE status */ | |
993 | ||
fceb731d | 994 | const char * nameFile = GetFile(kDCS,"TofFeeLightMap",""); |
db83b789 | 995 | AliInfo(Form("nameFile = %s",nameFile)); |
996 | if (nameFile == NULL) { | |
997 | return 15; | |
998 | } | |
fceb731d | 999 | feeReader.LoadFEElightConfig(nameFile); |
1000 | Int_t parseFee = feeReader.ParseFEElightConfig(); | |
1001 | AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee)); | |
db83b789 | 1002 | /* load stored TOF FEE from OCDB and compare it with current FEE. |
1003 | * if stored FEE is different from current FEE set update flag. | |
1004 | * if there is no stored FEE in OCDB set update flag */ | |
1005 | ||
013ac2dd | 1006 | fMatchingWindow = new Int_t[fNChannels]; |
1007 | ||
17149e6b | 1008 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status"); |
1009 | if (!cdbEntry) { | |
1010 | /* no CDB entry found. set update flag */ | |
1011 | Log(" ************ WARNING ************"); | |
1012 | Log("No CDB Status entry found, creating a new one!"); | |
1013 | Log(" *********************************"); | |
1014 | fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); | |
1015 | updateOCDB = kTRUE; | |
db83b789 | 1016 | } |
db83b789 | 1017 | else { |
e88f3330 | 1018 | if (cdbEntry) cdbEntry->SetOwner(kFALSE); |
17149e6b | 1019 | /* CDB entry OK. loop over channels */ |
1020 | fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject(); | |
e88f3330 | 1021 | delete cdbEntry; |
1022 | cdbEntry = 0x0; | |
db83b789 | 1023 | } |
17149e6b | 1024 | for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){ |
1025 | //AliDebug(2,Form("********** channel %i",iChannel)); | |
1026 | /* compare current FEE channel status with stored one | |
1027 | * if different set update flag and break loop */ | |
1028 | //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); | |
013ac2dd | 1029 | fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel); |
17149e6b | 1030 | if (feeReader.IsChannelEnabled(iChannel)) { |
1031 | hCurrentFEE.SetBinContent(iChannel + 1, 1); | |
1032 | if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){ | |
1033 | updateOCDB = kTRUE; | |
1034 | fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk); | |
013ac2dd | 1035 | AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); |
17149e6b | 1036 | } |
1037 | } | |
1038 | else { | |
1039 | if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){ | |
1040 | updateOCDB = kTRUE; | |
1041 | fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad); | |
013ac2dd | 1042 | AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); |
17149e6b | 1043 | } |
1044 | } | |
1045 | } | |
1046 | ||
db83b789 | 1047 | |
1048 | /* check whether we don't have to store reference data. | |
1049 | * in this case we return without errors. */ | |
1050 | if (fStoreRefData) { | |
1051 | /* store reference data */ | |
1052 | AliCDBMetaData metaDataHisto; | |
1053 | metaDataHisto.SetBeamPeriod(0); | |
1054 | metaDataHisto.SetResponsible("Roberto Preghenella"); | |
17149e6b | 1055 | metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run."); |
db83b789 | 1056 | AliInfo("Storing FEE reference data"); |
1057 | /* store FEE reference data */ | |
1058 | if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) { | |
1059 | /* failed */ | |
1060 | Log("problems while storing FEE reference data"); | |
e88f3330 | 1061 | if (fStatus){ |
1062 | delete fStatus; | |
1063 | fStatus = 0; | |
1064 | } | |
db83b789 | 1065 | return 18; /* error return code for problems while storing FEE reference data */ |
1066 | } | |
1067 | } | |
1068 | ||
1069 | /* check whether we don't need to update OCDB. | |
1070 | * in this case we can return without errors and | |
17149e6b | 1071 | * the current FEE is stored in the fStatus object. */ |
db83b789 | 1072 | if (!updateOCDB) { |
1073 | AliInfo("TOF FEE config has not changed. Do not overwrite stored file."); | |
1074 | return 0; /* return ok */ | |
1075 | } | |
1076 | ||
17149e6b | 1077 | TString runType = GetRunType(); |
1078 | if (runType != "PHYSICS") { | |
1079 | AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType())); | |
1080 | return 0; /* return ok */ | |
1081 | } | |
1082 | ||
db83b789 | 1083 | /* update the OCDB with the current FEE since even |
1084 | * a little difference has been detected. */ | |
1085 | ||
1086 | AliCDBMetaData metaData; | |
1087 | metaData.SetBeamPeriod(0); | |
1088 | metaData.SetResponsible("Roberto Preghenella"); | |
17149e6b | 1089 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE data."); |
1090 | AliInfo("Storing Status data from current run after FEE parsing"); | |
db83b789 | 1091 | /* store FEE data */ |
17149e6b | 1092 | if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) { |
db83b789 | 1093 | /* failed */ |
1094 | Log("problems while storing FEE data object"); | |
e88f3330 | 1095 | if (fStatus){ |
1096 | delete fStatus; | |
1097 | fStatus = 0; | |
1098 | } | |
db83b789 | 1099 | return 17; /* return error code for problems while storing FEE data */ |
1100 | } | |
1101 | ||
1102 | /* everything fine. return */ | |
ee3e792b | 1103 | |
e88f3330 | 1104 | if (fStatus){ |
1105 | delete fStatus; | |
1106 | fStatus = 0; | |
1107 | } | |
1108 | ||
7fffa85b | 1109 | return 0; |
1110 | ||
1111 | } | |
1112 | ||
1113 | //_____________________________________________________________________________ | |
1114 | ||
1115 | UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap) | |
1116 | { | |
a174d599 | 1117 | // |
1118 | // | |
1119 | // | |
7fffa85b | 1120 | |
1121 | TString runType = GetRunType(); | |
1122 | Log(Form("RunType %s",runType.Data())); | |
bf76be9c | 1123 | |
ee3e792b | 1124 | // processing |
1125 | ||
db83b789 | 1126 | /* always process FEE data */ |
1127 | Int_t iresultFEE = ProcessFEEData(); | |
1128 | if (iresultFEE != 0) | |
1129 | return iresultFEE; | |
1130 | ||
7fffa85b | 1131 | if (runType == "PULSER") { |
1132 | Int_t iresultPulser = ProcessPulserData(); | |
1133 | return iresultPulser; | |
1134 | } | |
17149e6b | 1135 | |
7fffa85b | 1136 | if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined |
1137 | Int_t iresultNoise = ProcessNoiseData(); | |
1138 | return iresultNoise; | |
1139 | } | |
1140 | ||
1141 | if (runType == "PHYSICS") { | |
4856f488 | 1142 | Int_t iresultDAQ = ProcessOnlineDelays(); |
1143 | if (iresultDAQ != 0) { | |
7fffa85b | 1144 | return iresultDAQ; |
1145 | } | |
4856f488 | 1146 | else { |
1147 | Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap); | |
1148 | return iresultDCS; | |
1149 | } | |
ee3e792b | 1150 | } |
1151 | ||
7fffa85b | 1152 | // storing |
ee3e792b | 1153 | return 0; |
1154 | } | |
c9fe8530 | 1155 | |
1156 | ||
b06d5296 | 1157 | //_____________________________________________________________________________ |
1158 | ||
1159 | void | |
1160 | AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal) | |
1161 | { | |
1162 | /* | |
1163 | * fill with cosmic calibration | |
1164 | */ | |
1165 | ||
1166 | Log(" Using cosmic-ray calibration."); | |
1167 | ||
1168 | AliTOFcalibHisto calibHisto; | |
97a29b32 | 1169 | calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE); |
1170 | Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName())); | |
b06d5296 | 1171 | Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName())); |
1172 | calibHisto.LoadCalibPar(); | |
1173 | ||
1174 | /* loop over channel index */ | |
1175 | for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) { | |
9155334b | 1176 | cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex)); |
b06d5296 | 1177 | } |
1178 | ||
1179 | } | |
1180 | ||
b06d5296 | 1181 | //_____________________________________________________________________________ |
1182 | ||
1183 | void | |
1184 | AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal) | |
1185 | { | |
1186 | /* | |
1187 | * fill with cosmic calibration | |
1188 | */ | |
1189 | ||
1190 | Log(" Using cable-length map."); | |
1191 | AliTOFRawStream tofrs; | |
1192 | Int_t det[5], dummy, index; | |
1193 | Float_t cableTimeShift; | |
1194 | ||
1195 | /* temporarly disable warnings */ | |
1196 | AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel(); | |
1197 | AliLog::SetGlobalLogLevel(AliLog::kError); | |
1198 | ||
1199 | /* loop over EO indeces */ | |
1200 | for (Int_t iddl = 0; iddl < 72; iddl++) | |
1201 | for (Int_t islot = 3; islot <= 12; islot++) | |
1202 | for (Int_t ichain = 0; ichain < 2; ichain++) | |
1203 | for (Int_t itdc = 0; itdc < 15; itdc++) | |
1204 | for (Int_t ichannel = 0; ichannel < 8; ichannel++) { | |
1205 | ||
1206 | /* get DO index */ | |
1207 | tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det); | |
1208 | ||
1209 | /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */ | |
1210 | dummy = det[3]; | |
1211 | det[3] = det[4]; | |
1212 | det[4] = dummy; | |
1213 | ||
1214 | /* check DO index */ | |
1215 | if (det[0] < 0 || det[0] > 17 || | |
1216 | det[1] < 0 || det[1] > 4 || | |
1217 | det[2] < 0 || det[2] > 18 || | |
1218 | det[3] < 0 || det[3] > 1 || | |
1219 | det[4] < 0 || det[4] > 47) | |
1220 | continue; | |
1221 | ||
1222 | /* get channel index */ | |
1223 | index = AliTOFGeometry::GetIndex(det); | |
1224 | ||
1225 | /* get cable time shift */ | |
1226 | cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc); | |
1227 | ||
1228 | /* set delay */ | |
1229 | if (index<fNChannels) { | |
1230 | cal->SetDelay(index,cableTimeShift); // delay in ns | |
1231 | AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index)); | |
1232 | } | |
1233 | ||
1234 | } /* loop over EO indeces */ | |
1235 | ||
1236 | /* re-enable warnings */ | |
1237 | AliLog::SetGlobalLogLevel(logLevel); | |
1238 | ||
1239 | } | |
1240 | ||
1241 |