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