]>
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> |
ea932f75 | 25 | #include <TH1F.h> |
26 | #include <TCanvas.h> | |
9edefa04 | 27 | #include <TMath.h> |
28 | #include <TObjArray.h> | |
29 | #include <TObjString.h> | |
30 | #include <TTimeStamp.h> | |
c9fe8530 | 31 | |
32 | #include "AliCDBMetaData.h" | |
7fffa85b | 33 | #include "AliCDBEntry.h" |
c9fe8530 | 34 | #include "AliLog.h" |
17149e6b | 35 | #include "AliTOFChannelOnlineArray.h" |
36 | #include "AliTOFChannelOnlineStatusArray.h" | |
9edefa04 | 37 | #include "AliTOFDataDCS.h" |
ea932f75 | 38 | #include "AliTOFLvHvDataPoints.h" |
10056aa6 | 39 | #include "AliTOFGeometry.h" |
9edefa04 | 40 | #include "AliTOFPreprocessor.h" |
db83b789 | 41 | #include "AliTOFFEEReader.h" |
3dda26a0 | 42 | #include "AliTOFRawStream.h" |
43 | #include "AliTOFCableLengthMap.h" | |
b06d5296 | 44 | #include "AliTOFcalibHisto.h" |
69355034 | 45 | #include "AliTOFFEEDump.h" |
104ba366 | 46 | #include "TChain.h" |
47 | #include "AliTOFDeltaBCOffset.h" | |
48 | #include "AliTOFCTPLatency.h" | |
49 | #include "AliTOFT0Fill.h" | |
50 | #include "AliTOFT0FillOnlineCalib.h" | |
51 | #include "AliTOFHitField.h" | |
52 | #include "AliTOFChannelOffline.h" | |
53 | #include "TF1.h" | |
54 | #include "TGeoManager.h" | |
55 | #include "AliGeomManager.h" | |
c9fe8530 | 56 | |
c9fe8530 | 57 | // TOF preprocessor class. |
58 | // It takes data from DCS and passes them to the class AliTOFDataDCS, which | |
59 | // processes them. The result is then written to the CDB. | |
17149e6b | 60 | // Analogously, it takes data form DAQ (both at Run level and inclusive - |
c9fe8530 | 61 | // of all the runs - level, processes them, and stores both Reference Data |
62 | // and Online Calibration files in the CDB. | |
17149e6b | 63 | // Processing of Pulser/Noise Run data and of TOF FEE DCS map included also. |
7fffa85b | 64 | |
65 | // return codes: | |
66 | // return=0 : all ok | |
67 | // return=1 : no DCS input data Map | |
68 | // return=2 : no DCS input data processing | |
69 | // return=3 : no DCS processed data was stored in Ref Data | |
70 | // return=4 : no DAQ input for Ref Data | |
71 | // return=5 : failed to store DAQ Ref Data | |
72 | // return=6 : failed to retrieve DAQ data for calibration | |
73 | // return=7 : problems in processing histos in the input DAQ file | |
74 | // return=8 : failed to store Online Delays | |
75 | // return=9 : failed to store Reference Data for Pulser | |
76 | // return=10: failed to retrieve Pulser data | |
77 | // return=11: failed to store Pulser map in OCDB | |
78 | // return=12: failed to store Reference Data for Noise | |
79 | // return=13: failed to retrieve Noise data | |
80 | // return=14: failed to store Noise map in OCDB | |
db83b789 | 81 | // return=15: failed to retrieve FEE data from FXS |
82 | // return=16: failed to retrieve FEE data from OCDB | |
83 | // return=17: failed to store FEE data in OCDB | |
84 | // return=18: failed to store FEE reference data in OCDB | |
17149e6b | 85 | // return=20: failed in retrieving status variable |
c9fe8530 | 86 | |
87 | ClassImp(AliTOFPreprocessor) | |
88 | ||
7fffa85b | 89 | const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean |
90 | const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel | |
91 | const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay | |
c9fe8530 | 92 | |
93 | //_____________________________________________________________________________ | |
94 | ||
708db10b | 95 | AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) : |
96 | AliPreprocessor("TOF", shuttle), | |
c9fe8530 | 97 | fData(0), |
ea932f75 | 98 | fHVLVmaps(0), |
c9fe8530 | 99 | fCal(0), |
10056aa6 | 100 | fNChannels(0), |
7fffa85b | 101 | fStoreRefData(kTRUE), |
17149e6b | 102 | fFDRFlag(kFALSE), |
013ac2dd | 103 | fStatus(0), |
02ede0c4 | 104 | fMatchingWindow(0), |
ea932f75 | 105 | fLatencyWindow(0), |
106 | fIsStatusMapChanged(0) | |
c9fe8530 | 107 | { |
108 | // constructor | |
370aeff7 | 109 | AddRunType("PHYSICS"); |
110 | AddRunType("PULSER"); | |
111 | AddRunType("NOISE"); | |
10056aa6 | 112 | |
c9fe8530 | 113 | } |
114 | ||
115 | //_____________________________________________________________________________ | |
116 | ||
117 | AliTOFPreprocessor::~AliTOFPreprocessor() | |
118 | { | |
119 | // destructor | |
120 | } | |
121 | ||
122 | //______________________________________________________________________________ | |
123 | void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
124 | UInt_t endTime) | |
125 | { | |
126 | // Creates AliTOFDataDCS object | |
127 | ||
128 | AliPreprocessor::Initialize(run, startTime, endTime); | |
129 | ||
ff326f84 | 130 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run, |
c9fe8530 | 131 | TTimeStamp(startTime).AsString(), |
ff326f84 | 132 | TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString())); |
c9fe8530 | 133 | |
ff326f84 | 134 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery()); |
ea932f75 | 135 | fHVLVmaps = new AliTOFLvHvDataPoints(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery()); |
10056aa6 | 136 | fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX(); |
c9fe8530 | 137 | } |
7fffa85b | 138 | //_____________________________________________________________________________ |
139 | Bool_t AliTOFPreprocessor::ProcessDCS(){ | |
140 | ||
141 | // check whether DCS should be processed or not... | |
c9fe8530 | 142 | |
7fffa85b | 143 | TString runType = GetRunType(); |
144 | Log(Form("RunType %s",runType.Data())); | |
145 | ||
55454922 | 146 | if (runType != "PHYSICS"){ |
7fffa85b | 147 | return kFALSE; |
148 | } | |
149 | ||
150 | return kTRUE; | |
151 | } | |
c9fe8530 | 152 | //_____________________________________________________________________________ |
153 | ||
104ba366 | 154 | UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap) |
c9fe8530 | 155 | { |
156 | // Fills data into a AliTOFDataDCS object | |
157 | ||
7fffa85b | 158 | |
159 | Log("Processing DCS DP"); | |
708db10b | 160 | TH1::AddDirectory(0); |
5936ab02 | 161 | |
7885c291 | 162 | Bool_t resultDCSMap=kFALSE; |
163 | Bool_t resultDCSStore=kFALSE; | |
c9fe8530 | 164 | |
165 | // processing DCS | |
166 | ||
4856f488 | 167 | fData->SetFDRFlag(fFDRFlag); |
168 | ||
c9fe8530 | 169 | if (!dcsAliasMap){ |
5936ab02 | 170 | Log("No DCS map found: TOF exiting from Shuttle"); |
e88f3330 | 171 | if (fData){ |
172 | delete fData; | |
173 | fData = 0; | |
174 | } | |
5936ab02 | 175 | return 1;// return error Code for DCS input data not found |
c9fe8530 | 176 | } |
177 | else { | |
4856f488 | 178 | |
c9fe8530 | 179 | // The processing of the DCS input data is forwarded to AliTOFDataDCS |
7885c291 | 180 | resultDCSMap=fData->ProcessData(*dcsAliasMap); |
181 | if(!resultDCSMap){ | |
182 | Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle"); | |
e88f3330 | 183 | if (fData){ |
184 | delete fData; | |
185 | fData = 0; | |
186 | } | |
5936ab02 | 187 | return 2;// return error Code for processed DCS data not stored |
c9fe8530 | 188 | } |
7885c291 | 189 | else{ |
190 | AliCDBMetaData metaDataDCS; | |
191 | metaDataDCS.SetBeamPeriod(0); | |
192 | metaDataDCS.SetResponsible("Chiara Zampolli"); | |
193 | metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); | |
194 | AliInfo("Storing DCS Data"); | |
b0d8f3fc | 195 | resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS); |
7885c291 | 196 | if (!resultDCSStore){ |
b0d8f3fc | 197 | Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle"); |
e88f3330 | 198 | if (fData){ |
199 | delete fData; | |
200 | fData = 0; | |
201 | } | |
7885c291 | 202 | return 3;// return error Code for processed DCS data not stored |
b0d8f3fc | 203 | // in reference data |
7885c291 | 204 | |
205 | } | |
206 | } | |
c9fe8530 | 207 | } |
e88f3330 | 208 | if (fData){ |
209 | delete fData; | |
210 | fData = 0; | |
211 | } | |
212 | ||
ee3e792b | 213 | return 0; |
214 | } | |
215 | //_____________________________________________________________________________ | |
216 | ||
104ba366 | 217 | UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap) |
ea932f75 | 218 | { |
219 | // | |
220 | //Fills data into a AliTOFLvHvDataPoints object | |
221 | // Merges fStatus object with LV and HV status at SOR | |
222 | // Updates fStatus object with LV and HV status | |
223 | // at EOR in case of correct end of run | |
224 | // at last but two value in case of end-of-run caused by TOF detector. | |
225 | // | |
226 | ||
227 | Log("Processing HV and LV DCS DPs"); | |
228 | TH1::AddDirectory(0); | |
229 | ||
230 | Bool_t resultDCSMap=kFALSE; | |
231 | ||
232 | // processing DCS | |
233 | ||
234 | fHVLVmaps->SetFDRFlag(fFDRFlag); | |
235 | ||
236 | if (!dcsAliasMap){ | |
237 | Log("No DCS map found: TOF exiting from Shuttle"); | |
238 | if (fHVLVmaps){ | |
239 | delete fHVLVmaps; | |
240 | fHVLVmaps = 0; | |
241 | } | |
242 | return 1;// return error Code for DCS input data not found | |
243 | } | |
244 | else { | |
245 | ||
246 | // The processing of the DCS input data is forwarded to AliTOFDataDCS | |
a762046b | 247 | if (0) { // AdC |
ea932f75 | 248 | resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap); |
249 | if (!resultDCSMap) { | |
250 | Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle"); | |
251 | if (fHVLVmaps) { | |
252 | delete fHVLVmaps; | |
253 | fHVLVmaps = 0; | |
254 | } | |
255 | return 2;// return error Code for processed DCS data not stored | |
256 | } | |
257 | else { | |
258 | ||
259 | // check with plots. Start... | |
260 | /* | |
261 | TH1F *hROsor = new TH1F("hROsor","RO status map at SOR",91*96*18,-0.5,91*96*18-0.5); | |
262 | for (Int_t ii=1; ii<=91*96*18; ii++) hROsor->SetBinContent(ii,-1); | |
263 | for (Int_t ii=0; ii<91*96*18; ii++) { | |
264 | if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
265 | hROsor->SetBinContent(ii+1,0); | |
266 | else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk) | |
267 | hROsor->SetBinContent(ii+1,1); | |
268 | } | |
269 | ||
270 | TH1F *hROandHVandLVsor = new TH1F("hROandHVandLVsor","RO.and.HV.andLV status map at SOR",91*96*18,-0.5,91*96*18-0.5); | |
271 | for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVsor->SetBinContent(ii,-1); | |
272 | TH1F *hROandHVandLVeor = new TH1F("hROandHVandLVeor","RO.and.HV.andLV status map at EOR",91*96*18,-0.5,91*96*18-0.5); | |
273 | for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVeor->SetBinContent(ii,-1); | |
274 | */ | |
275 | ||
276 | AliTOFDCSmaps * lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtSOR(); // Get LV.and.HV status map at SOR | |
277 | for (Int_t index=0; index<fNChannels; index++) { | |
278 | if ( ( lvANDhvMap->GetCellValue(index)==0 && | |
279 | fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWBad ) || | |
280 | ( lvANDhvMap->GetCellValue(index)==1 && | |
281 | fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) { | |
282 | fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad); | |
283 | fIsStatusMapChanged=kTRUE; | |
284 | } | |
285 | } | |
104ba366 | 286 | |
ea932f75 | 287 | // check with plots. Start... |
288 | /* | |
289 | for (Int_t ii=0; ii<91*96*18; ii++) { | |
290 | if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
291 | hROandHVandLVsor->SetBinContent(ii+1,0); | |
292 | else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk) | |
293 | hROandHVandLVsor->SetBinContent(ii+1,1); | |
294 | } | |
295 | */ | |
296 | ||
297 | lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtEOR(); // Get LV.and.HV status map at EOR | |
298 | for (Int_t index=0; index<fNChannels; index++) { | |
299 | if ( ( lvANDhvMap->GetCellValue(index)==0 && | |
300 | fStatus->GetHWStatus(index)!=AliTOFChannelOnlineStatusArray::kTOFHWBad ) || | |
301 | ( lvANDhvMap->GetCellValue(index)==1 && | |
302 | fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) { | |
303 | fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad); | |
304 | fIsStatusMapChanged=kTRUE; | |
305 | } | |
306 | } | |
307 | ||
308 | // check with plots. Start... | |
309 | /* | |
310 | for (Int_t ii=0; ii<91*96*18; ii++) { | |
311 | if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
312 | hROandHVandLVeor->SetBinContent(ii+1,0); | |
313 | else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk) | |
314 | hROandHVandLVeor->SetBinContent(ii+1,1); | |
315 | } | |
316 | ||
317 | TCanvas *canvas = new TCanvas("canvas","",10,10,1000,1000); | |
318 | canvas->SetFillColor(0); | |
319 | canvas->Divide(2,2); | |
320 | canvas->cd(1); | |
321 | hROsor->SetLineWidth(2); | |
322 | hROsor->Draw(); | |
323 | canvas->cd(2); | |
324 | hROandHVandLVsor->SetLineWidth(2); | |
325 | hROandHVandLVsor->Draw(); | |
326 | canvas->cd(3); | |
327 | hROandHVandLVeor->SetLineWidth(2); | |
328 | hROandHVandLVeor->Draw(); | |
329 | canvas->cd(); | |
330 | */ | |
331 | ||
332 | } | |
a762046b | 333 | } // AdC |
ea932f75 | 334 | } |
335 | ||
336 | ||
337 | /* check whether we don't need to update OCDB. | |
338 | * in this case we can return without errors. */ | |
339 | ||
340 | if (!fIsStatusMapChanged) { | |
341 | AliInfo("TOF FEE config has not changed. Do not overwrite stored file."); | |
342 | return 0; // return ok | |
343 | } | |
344 | ||
345 | TString runType = GetRunType(); | |
346 | if (runType != "PHYSICS") { | |
347 | AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType())); | |
348 | return 0; // return ok | |
349 | } | |
350 | ||
351 | // update the OCDB with the current FEE.and.HV.and.LV | |
352 | // since even a little difference has been detected. | |
353 | ||
354 | AliCDBMetaData metaData; | |
355 | metaData.SetBeamPeriod(0); | |
356 | metaData.SetResponsible("Roberto Preghenella"); | |
a762046b | 357 | //metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.HV.and.LV data."); // AdC |
358 | //AliInfo("Storing Status data from current run. Collected RO.and.HV.and.LV infos @ EOR"); // AdC | |
359 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.LV data."); | |
360 | AliInfo("Storing Status data from current run. Collected RO.and.LV infos @ SOR"); | |
ea932f75 | 361 | // store FEE data |
362 | if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) { | |
363 | // failed | |
364 | Log("problems while storing RO.and.HV.and.LV Status data object"); | |
365 | if (fStatus){ | |
366 | delete fStatus; | |
367 | fStatus = 0; | |
368 | } | |
369 | if (fHVLVmaps) { | |
370 | delete fHVLVmaps; | |
371 | fHVLVmaps = 0; | |
372 | } | |
373 | return 17; // return error code for problems while storing FEE data | |
374 | } | |
375 | ||
376 | // everything fine. return | |
377 | ||
378 | if (fStatus){ | |
379 | delete fStatus; | |
380 | fStatus = 0; | |
381 | } | |
382 | ||
383 | if (fHVLVmaps) { | |
384 | delete fHVLVmaps; | |
385 | fHVLVmaps = 0; | |
386 | } | |
387 | ||
388 | return 0; | |
389 | } | |
104ba366 | 390 | |
ea932f75 | 391 | //_____________________________________________________________________________ |
392 | ||
ee3e792b | 393 | UInt_t AliTOFPreprocessor::ProcessOnlineDelays() |
394 | { | |
7fffa85b | 395 | // Processing data from DAQ for online calibration |
396 | ||
965fa008 | 397 | Bool_t updateOCDB = kFALSE; |
7fffa85b | 398 | Log("Processing DAQ delays"); |
ee3e792b | 399 | |
17149e6b | 400 | // reading configuration map |
401 | TString compDelays = "kFALSE"; | |
402 | Int_t deltaStartingRun = fRun; | |
403 | Int_t startingRun = fRun-deltaStartingRun; | |
404 | Int_t binRangeAve = fgkBinRangeAve; | |
405 | Double_t integralThr = fgkIntegralThr; | |
406 | Double_t thrPar = fgkThrPar; | |
407 | ||
408 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config"); | |
409 | if (!cdbEntry) { | |
410 | Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun)); | |
411 | } | |
412 | else { | |
413 | TMap *configMap = (TMap*)cdbEntry->GetObject(); | |
414 | if (!configMap){ | |
415 | Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun)); | |
416 | } | |
417 | else{ | |
418 | TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays"); | |
419 | if (strDelays) { | |
420 | compDelays = (TString) strDelays->GetString(); | |
421 | } | |
422 | else { | |
423 | Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data())); | |
424 | } | |
425 | TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun"); | |
426 | if (strRun) { | |
427 | TString tmpstr = strRun->GetString(); | |
428 | startingRun = tmpstr.Atoi(); | |
429 | deltaStartingRun = fRun - startingRun; | |
430 | } | |
431 | else { | |
432 | Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun)); | |
433 | } | |
434 | TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve"); | |
435 | if (strBinRangeAve) { | |
436 | TString tmpstr = strBinRangeAve->GetString(); | |
437 | binRangeAve = tmpstr.Atoi(); | |
438 | } | |
439 | else { | |
440 | Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve)); | |
441 | } | |
442 | TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr"); | |
443 | if (strIntegralThr) { | |
444 | TString tmpstr = strIntegralThr->GetString(); | |
445 | integralThr = tmpstr.Atof(); | |
446 | } | |
447 | else { | |
448 | Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr)); | |
449 | } | |
450 | TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar"); | |
451 | if (strThrPar) { | |
452 | TString tmpstr = strThrPar->GetString(); | |
453 | thrPar = tmpstr.Atof(); | |
454 | } | |
455 | else { | |
456 | Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar)); | |
457 | } | |
458 | } | |
459 | } | |
460 | if (compDelays == "kTRUE") fFDRFlag = kFALSE; | |
461 | else fFDRFlag = kTRUE; | |
462 | ||
e88f3330 | 463 | delete cdbEntry; |
464 | cdbEntry = 0x0; | |
465 | ||
17149e6b | 466 | Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun)); |
467 | ||
965fa008 | 468 | /* init array with current calibration, if any */ |
469 | fCal = new AliTOFChannelOnlineArray(fNChannels); | |
470 | AliTOFChannelOnlineArray *curCal = NULL; | |
471 | ||
472 | AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay"); | |
473 | if (!cdbEntry2 || !cdbEntry2->GetObject()) { | |
474 | /* no CDB entry found. set update flag */ | |
475 | Log(" ************ WARNING ************"); | |
476 | Log("No CDB ParOnlineDelay entry found, creating a new one!"); | |
477 | Log(" *********************************"); | |
478 | updateOCDB = kTRUE; | |
479 | } | |
480 | else { | |
481 | Log("Found previous ParOnlineDelay entry. Using it to init calibration"); | |
482 | curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject(); | |
483 | for (Int_t i = 0; i < fNChannels; i++) | |
484 | fCal->SetDelay(i, curCal->GetDelay(i)); | |
485 | } | |
486 | ||
17149e6b | 487 | |
ee3e792b | 488 | TH1::AddDirectory(0); |
489 | ||
490 | Bool_t resultDAQRef=kFALSE; | |
7fffa85b | 491 | Bool_t resultTOFPP=kFALSE; |
e88f3330 | 492 | TH2S *h2 = 0x0; |
c9fe8530 | 493 | // processing DAQ |
7885c291 | 494 | |
c9fe8530 | 495 | TFile * daqFile=0x0; |
7885c291 | 496 | |
5936ab02 | 497 | if(fStoreRefData){ |
498 | //retrieving data at Run level | |
17149e6b | 499 | TList* list = GetFileSources(kDAQ, "RUNLevel"); |
500 | if (list !=0x0 && list->GetEntries()!=0) | |
501 | { | |
502 | AliInfo("The following sources produced files with the id RUNLevel"); | |
503 | list->Print(); | |
504 | for (Int_t jj=0;jj<list->GetEntries();jj++){ | |
505 | TObjString * str = dynamic_cast<TObjString*> (list->At(jj)); | |
506 | AliInfo(Form("found source %s", str->String().Data())); | |
507 | // file to be stored run per run | |
508 | TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName()); | |
509 | if (fileNameRun.Length()>0){ | |
510 | AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data())); | |
511 | daqFile = new TFile(fileNameRun.Data(),"READ"); | |
e88f3330 | 512 | h2 = (TH2S*) daqFile->Get("htof"); |
17149e6b | 513 | AliCDBMetaData metaDataHisto; |
514 | metaDataHisto.SetBeamPeriod(0); | |
515 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
516 | metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data."); | |
517 | AliInfo("Storing Reference Data"); | |
e88f3330 | 518 | resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto); |
17149e6b | 519 | if (!resultDAQRef){ |
520 | Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle"); | |
e88f3330 | 521 | delete h2; |
522 | delete list; | |
523 | delete fCal; | |
524 | fCal=0x0; | |
17149e6b | 525 | return 5;//return error code for failure in storing Ref Data |
526 | } | |
527 | daqFile->Close(); | |
528 | delete daqFile; | |
529 | } | |
530 | ||
531 | else{ | |
532 | Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle "); | |
e88f3330 | 533 | delete list; |
534 | delete fCal; | |
535 | fCal=0x0; | |
17149e6b | 536 | return 4;//return error code for failure in retrieving Ref Data |
537 | } | |
538 | } | |
539 | delete list; | |
540 | } | |
5936ab02 | 541 | else{ |
17149e6b | 542 | Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle "); |
e88f3330 | 543 | delete fCal; |
544 | fCal=0x0; | |
17149e6b | 545 | return 4;//return error code for failure in retrieving Ref Data |
546 | } | |
9bc469d1 | 547 | } |
548 | ||
9bc469d1 | 549 | |
17149e6b | 550 | //Total files, with cumulative histos |
5936ab02 | 551 | |
9bc469d1 | 552 | TList* listTot = GetFileSources(kDAQ, "DELAYS"); |
bf76be9c | 553 | if (listTot !=0x0 && listTot->GetEntries()!=0) |
17149e6b | 554 | { |
555 | AliInfo("The following sources produced files with the id DELAYS"); | |
556 | listTot->Print(); | |
557 | for (Int_t jj=0;jj<listTot->GetEntries();jj++){ | |
558 | TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj)); | |
559 | AliInfo(Form("found source %s", str->String().Data())); | |
560 | ||
561 | // file with summed histos, to extract calib params | |
562 | TString fileName = GetFile(kDAQ, "DELAYS", str->GetName()); | |
563 | if (fileName.Length()>0){ | |
564 | AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
565 | ||
566 | daqFile = new TFile(fileName.Data(),"READ"); | |
e88f3330 | 567 | if (h2) delete h2; |
568 | h2 = (TH2S*) daqFile->Get("htoftot"); | |
569 | if (!h2){ | |
17149e6b | 570 | Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle"); |
e88f3330 | 571 | delete listTot; |
17149e6b | 572 | delete daqFile; |
e88f3330 | 573 | delete fCal; |
574 | fCal=0x0; | |
17149e6b | 575 | return 7; //return error code for histograms not existing/junky |
576 | } | |
577 | else { | |
e88f3330 | 578 | static const Int_t kSize=h2->GetNbinsX(); |
579 | static const Int_t kNBins=h2->GetNbinsY(); | |
580 | static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1); | |
17149e6b | 581 | if (kSize != fNChannels){ |
582 | Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle"); | |
e88f3330 | 583 | delete listTot; |
584 | delete h2; | |
17149e6b | 585 | delete daqFile; |
e88f3330 | 586 | delete fCal; |
587 | fCal=0x0; | |
17149e6b | 588 | return 7; //return error code for histograms not existing/junky |
589 | } | |
590 | Int_t nNotStatistics = 0; // number of channel with not enough statistics | |
3dda26a0 | 591 | |
b06d5296 | 592 | /* FDR flag set. do not compute delays, use nominal cable delays */ |
3dda26a0 | 593 | if (fFDRFlag) { |
594 | ||
595 | Log(" Not computing delays according to flag set in Config entry in OCDB!"); | |
b06d5296 | 596 | FillWithCosmicCalibration(fCal); |
965fa008 | 597 | |
598 | /* check whether the new calibration is different from the previous one */ | |
599 | if (curCal) { /* well, check also whether we have a previous calibration */ | |
600 | for (Int_t i = 0; i < fNChannels; i++) { | |
601 | if (fCal->GetDelay(i) != curCal->GetDelay(i)) { | |
602 | updateOCDB = kTRUE; | |
603 | break; | |
604 | } | |
605 | } | |
606 | } | |
607 | else /* otherwise update OCDB */ | |
608 | updateOCDB = kTRUE; | |
609 | ||
3dda26a0 | 610 | } |
17149e6b | 611 | |
612 | else { // computing delays if not in FDR runs | |
965fa008 | 613 | |
614 | updateOCDB = kTRUE; /* always update OCDB when computing delays */ | |
615 | ||
17149e6b | 616 | for (Int_t ich=0;ich<kSize;ich++){ |
617 | /* check whether channel has been read out during current run. | |
618 | * if the status is bad it means it has not been read out. | |
619 | * in this case skip channel in order to not affect the mean */ | |
620 | if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){ | |
621 | AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich))); | |
622 | continue; | |
623 | } | |
624 | AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich)); | |
625 | TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5); | |
626 | for (Int_t ibin=0;ibin<kNBins;ibin++){ | |
e88f3330 | 627 | h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1)); |
17149e6b | 628 | } |
629 | if(h1->Integral()<integralThr) { | |
630 | nNotStatistics++; | |
631 | Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs | |
632 | delete h1; | |
633 | h1=0x0; | |
634 | continue; | |
635 | } | |
636 | Bool_t found=kFALSE; | |
637 | Float_t minContent=h1->Integral()*thrPar; | |
638 | Int_t nbinsX = h1->GetNbinsX(); | |
639 | Int_t startBin=1; | |
640 | for (Int_t j=1; j<=nbinsX; j++){ | |
641 | if (( | |
642 | h1->GetBinContent(j) + | |
643 | h1->GetBinContent(j+1)+ | |
644 | h1->GetBinContent(j+2)+ | |
645 | h1->GetBinContent(j+3))>minContent){ | |
646 | found=kTRUE; | |
647 | startBin=j; | |
648 | break; | |
649 | } | |
650 | } | |
651 | if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich)); | |
652 | // Now calculate the mean over the interval. | |
653 | Double_t mean = 0; | |
654 | Double_t sumw2 = 0; | |
655 | Double_t nent = 0; | |
656 | for(Int_t k=0;k<binRangeAve;k++){ | |
657 | mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k); | |
658 | nent=nent+h1->GetBinContent(startBin+k); | |
659 | sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k)); | |
660 | } | |
661 | mean= mean/nent; //<x> | |
662 | sumw2=sumw2/nent; //<x^2> | |
663 | Double_t rmsmean= 0; | |
664 | rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent); | |
665 | if (ich<fNChannels) { | |
666 | Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns | |
667 | fCal->SetDelay(ich,delay); // delay in ns | |
668 | AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich)); | |
669 | } | |
670 | delete h1; | |
671 | h1=0x0; | |
672 | } | |
673 | } | |
674 | if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics)); | |
675 | } | |
e88f3330 | 676 | delete h2; |
17149e6b | 677 | daqFile->Close(); |
678 | delete daqFile; | |
679 | } | |
680 | else{ | |
681 | Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle"); | |
e88f3330 | 682 | delete listTot; |
683 | delete fCal; | |
684 | fCal=0x0; | |
17149e6b | 685 | return 6;//return error code for problems in retrieving DAQ data |
686 | } | |
7fffa85b | 687 | } |
17149e6b | 688 | delete listTot; |
c9fe8530 | 689 | } |
c9fe8530 | 690 | else{ |
9d883ed9 | 691 | Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle"); |
e88f3330 | 692 | delete fCal; |
693 | fCal=0x0; | |
7885c291 | 694 | return 6; //return error code for problems in retrieving DAQ data |
c9fe8530 | 695 | } |
696 | ||
965fa008 | 697 | /* check whether we don't need to update OCDB. |
698 | * in this case we can return without errors and | |
699 | * the current FEE is stored in the fStatus object. */ | |
700 | if (!updateOCDB) { | |
701 | AliInfo("update OCDB flag not set. Do not overwrite stored file."); | |
702 | return 0; /* return ok */ | |
703 | } | |
704 | ||
c9fe8530 | 705 | daqFile=0; |
7fffa85b | 706 | AliCDBMetaData metaData; |
707 | metaData.SetBeamPeriod(0); | |
708 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 709 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays."); |
7fffa85b | 710 | AliInfo("Storing Calibration Data"); |
17149e6b | 711 | resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE); |
7fffa85b | 712 | if(!resultTOFPP){ |
713 | Log("Some problems occurred while storing online object resulting from DAQ data processing"); | |
e88f3330 | 714 | delete fCal; |
715 | fCal=0x0; | |
7fffa85b | 716 | return 8;//return error code for problems in storing DAQ data |
717 | } | |
9d883ed9 | 718 | |
e88f3330 | 719 | if (fCal){ |
720 | delete fCal; | |
721 | fCal = 0; | |
722 | } | |
723 | ||
5936ab02 | 724 | return 0; |
c9fe8530 | 725 | } |
104ba366 | 726 | |
727 | //_____________________________________________________________________________ | |
728 | ||
729 | UInt_t | |
730 | AliTOFPreprocessor::ProcessT0Fill() | |
731 | { | |
732 | // Processing data from DAQ for T0-fill measurement | |
733 | ||
734 | Log("Processing T0-fill"); | |
735 | ||
736 | #if 0 | |
737 | /* instance and setup CDB manager */ | |
738 | AliCDBManager *cdb = AliCDBManager::Instance(); | |
739 | /* load geometry */ | |
740 | if (!gGeoManager) AliGeomManager::LoadGeometry(); | |
741 | #endif | |
742 | ||
743 | /* get params from OCDB */ | |
744 | AliCDBEntry *cdbe = NULL; | |
745 | ||
746 | /* get T0-fill calibration params */ | |
747 | cdbe = GetFromOCDB("Calib", "T0FillOnlineCalib"); | |
748 | if (!cdbe) { | |
749 | Log("cannot get \"T0FillOnlineCalib\" entry from OCDB"); | |
750 | return 21; | |
751 | } | |
752 | AliTOFT0FillOnlineCalib *t0FillOnlineCalibObject = (AliTOFT0FillOnlineCalib *)cdbe->GetObject(); | |
753 | if (!t0FillOnlineCalibObject) { | |
754 | Log("cannot get \"T0FillOnlineCalib\" object from CDB entry"); | |
755 | return 21; | |
756 | } | |
757 | Float_t t0FillCalibOffset = t0FillOnlineCalibObject->GetOffset(); | |
758 | Float_t t0FillCalibCoefficient = t0FillOnlineCalibObject->GetCoefficient(); | |
759 | Log(Form("got \"T0FillOnlineCalib\" object: offset=%f coeff=%f", t0FillCalibOffset, t0FillCalibCoefficient)); | |
760 | ||
761 | /* get online status from OCDB */ | |
762 | cdbe = GetFromOCDB("Calib", "Status"); | |
763 | if (!cdbe) { | |
764 | Log("cannot get \"Status\" entry from OCDB"); | |
765 | return 21; | |
766 | } | |
767 | AliTOFChannelOnlineStatusArray *statusArray = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject(); | |
768 | if (!statusArray) { | |
769 | Log("cannot get \"Status\" object from CDB entry"); | |
770 | return 21; | |
771 | } | |
772 | Log("got \"Status\" object"); | |
773 | ||
774 | /* get offline calibration from OCDB */ | |
775 | cdbe = GetFromOCDB("Calib", "ParOffline"); | |
776 | if (!cdbe) { | |
777 | Log("cannot get \"ParOffline\" entry from OCDB"); | |
778 | return 21; | |
779 | } | |
780 | TObjArray *offlineArray = (TObjArray *)cdbe->GetObject(); | |
781 | AliTOFChannelOffline *channelOffline; | |
782 | if (!offlineArray) { | |
783 | Log("cannot get \"ParOffline\" object from CDB entry"); | |
784 | return 21; | |
785 | } | |
786 | Log("got \"ParOffline\" object"); | |
787 | ||
788 | /* get deltaBC offset from OCDB */ | |
789 | cdbe = GetFromOCDB("Calib", "DeltaBCOffset"); | |
790 | if (!cdbe) { | |
791 | Log("cannot get \"DeltaBCOffset\" entry from OCDB"); | |
792 | return 21; | |
793 | } | |
794 | AliTOFDeltaBCOffset *deltaBCOffsetObject = (AliTOFDeltaBCOffset *)cdbe->GetObject(); | |
795 | if (!deltaBCOffsetObject) { | |
796 | Log("cannot get \"DeltaBCOffset\" object from CDB entry"); | |
797 | return 21; | |
798 | } | |
799 | Int_t deltaBCOffset = deltaBCOffsetObject->GetDeltaBCOffset(); | |
800 | Log(Form("got \"DeltaBCOffset\" object: deltaBCOffset=%d (BC bins)", deltaBCOffset)); | |
801 | ||
802 | /* get CTP latency from OCDB */ | |
803 | cdbe = GetFromOCDB("Calib", "CTPLatency"); | |
804 | if (!cdbe) { | |
805 | Log("cannot get \"CTPLatency\" entry from OCDB"); | |
806 | return 21; | |
807 | } | |
808 | AliTOFCTPLatency *ctpLatencyObject = (AliTOFCTPLatency *)cdbe->GetObject(); | |
809 | if (!ctpLatencyObject) { | |
810 | Log("cannot get \"CTPLatency\" object from CDB entry"); | |
811 | return 21; | |
812 | } | |
813 | Float_t ctpLatency = ctpLatencyObject->GetCTPLatency(); | |
814 | Log(Form("got \"CTPLatency\" object: ctpLatency=%f (ps)", ctpLatency)); | |
815 | ||
816 | /* get file sources from FXS */ | |
817 | TList *fileList = GetFileSources(kDAQ, "HITS"); | |
818 | if (!fileList || fileList->GetEntries() == 0) { | |
819 | Log("cannot get DAQ source file list or empty list"); | |
820 | return 21; | |
821 | } | |
822 | Log(Form("got DAQ source file list: %d files", fileList->GetEntries())); | |
823 | fileList->Print(); | |
824 | ||
825 | /* create tree chain using file sources */ | |
826 | TChain chain("hitTree"); | |
827 | for (Int_t ifile = 0; ifile < fileList->GetEntries(); ifile++) { | |
828 | TObjString *str = (TObjString *)fileList->At(ifile); | |
829 | TString filename = GetFile(kDAQ, "HITS", str->GetName()); | |
830 | chain.Add(filename); | |
831 | Log(Form("file added to input chain: source=%s, filename=%s", str->String().Data(), filename.Data())); | |
832 | } | |
833 | Int_t nhits = chain.GetEntries(); | |
834 | Log(Form("input chain ready: %d hits", nhits)); | |
835 | ||
836 | /* setup input chain */ | |
837 | AliTOFHitField *hit = new AliTOFHitField(); | |
838 | chain.SetBranchAddress("hit", &hit); | |
839 | ||
840 | /* create calib histo and geometry */ | |
841 | AliTOFcalibHisto calibHisto; | |
842 | calibHisto.LoadCalibHisto(); | |
843 | AliTOFGeometry tofGeo; | |
844 | ||
845 | /* constants */ | |
846 | Float_t c = TMath::C() * 1.e2 / 1.e12; /* cm/ps */ | |
847 | Float_t c_1 = 1. / c; | |
848 | /* variables */ | |
849 | Int_t index, timebin, totbin, deltaBC, l0l1latency, det[5]; | |
850 | Float_t timeps, totns, corrps, length, timeexp, timezero, pos[3], latencyWindow; | |
851 | ||
852 | /* histos */ | |
853 | TH1F *hT0Fill = new TH1F("hT0Fill", "T0 fill;t - t_{exp}^{(c)} (ps);", 2000, -24400., 24400.); | |
854 | ||
855 | /* loop over hits */ | |
856 | for (Int_t ihit = 0; ihit < nhits; ihit++) { | |
857 | ||
858 | /* get entry */ | |
859 | chain.GetEntry(ihit); | |
860 | ||
861 | /* get hit info */ | |
862 | index = hit->GetIndex(); | |
863 | timebin = hit->GetTimeBin(); | |
864 | totbin = hit->GetTOTBin(); | |
865 | deltaBC = hit->GetDeltaBC(); | |
866 | l0l1latency = hit->GetL0L1Latency(); | |
867 | latencyWindow = statusArray->GetLatencyWindow(index) * 1.e3; | |
868 | ||
869 | /* convert time in ps and tot in ns */ | |
870 | timeps = timebin * AliTOFGeometry::TdcBinWidth(); | |
871 | totns = totbin * AliTOFGeometry::ToTBinWidth() * 1.e-3; | |
872 | /* get calibration correction in ps */ | |
873 | channelOffline = (AliTOFChannelOffline *)offlineArray->At(index); | |
874 | if (totns < AliTOFGeometry::SlewTOTMin()) totns = AliTOFGeometry::SlewTOTMin(); | |
875 | if (totns > AliTOFGeometry::SlewTOTMax()) totns = AliTOFGeometry::SlewTOTMax(); | |
876 | corrps = 0.; | |
877 | for (Int_t ipar = 0; ipar < 6; ipar++) corrps += channelOffline->GetSlewPar(ipar) * TMath::Power(totns, ipar); | |
878 | corrps *= 1.e3; | |
879 | /* perform time correction */ | |
880 | timeps = timeps + (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth() + l0l1latency * AliTOFGeometry::BunchCrossingBinWidth() + ctpLatency - latencyWindow - corrps; | |
881 | /* compute length and expected time */ | |
882 | tofGeo.GetVolumeIndices(index, det); | |
883 | tofGeo.GetPosPar(det, pos); | |
884 | length = 0.; | |
885 | for (Int_t i = 0; i < 3; i++) length += pos[i] * pos[i]; | |
886 | length = TMath::Sqrt(length); | |
887 | timeexp = length * c_1; | |
888 | /* compute time zero */ | |
889 | timezero = timeps - timeexp; | |
890 | ||
891 | /* fill histos */ | |
892 | hT0Fill->Fill(timezero); | |
893 | } | |
894 | ||
895 | /* rebin until maximum bin has required minimum entries */ | |
896 | Int_t maxBin = hT0Fill->GetMaximumBin(); | |
17f2cd01 | 897 | Float_t maxBinContent = hT0Fill->GetBinContent(maxBin); |
104ba366 | 898 | Float_t binWidth = hT0Fill->GetBinWidth(maxBin); |
899 | while (maxBinContent < 400 && binWidth < 90.) { | |
900 | hT0Fill->Rebin(2); | |
901 | maxBin = hT0Fill->GetMaximumBin(); | |
902 | maxBinContent = hT0Fill->GetBinContent(maxBin); | |
903 | binWidth = hT0Fill->GetBinWidth(maxBin); | |
904 | } | |
905 | Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin); | |
906 | ||
907 | /* rough landau fit of the edge */ | |
908 | TF1 *landau = (TF1 *)gROOT->GetFunction("landau"); | |
909 | landau->SetParameter(1, maxBinCenter); | |
910 | Float_t fitMin = maxBinCenter - 1000.; /* fit from 10 ns before max */ | |
911 | Float_t fitMax = maxBinCenter + binWidth; /* fit until a bin width above max */ | |
912 | hT0Fill->Fit("landau", "q0", "", fitMin, fitMax); | |
913 | /* get rough landau mean and sigma to set a better fit range */ | |
914 | Float_t mean = landau->GetParameter(1); | |
915 | Float_t sigma = landau->GetParameter(2); | |
916 | /* better landau fit of the edge */ | |
917 | fitMin = maxBinCenter - 3. * sigma; | |
918 | fitMax = mean; | |
919 | hT0Fill->Fit("landau", "q0", "", fitMin, fitMax); | |
920 | /* print params */ | |
921 | mean = landau->GetParameter(1); | |
922 | sigma = landau->GetParameter(2); | |
923 | Float_t meane = landau->GetParError(1); | |
924 | Float_t sigmae = landau->GetParError(2); | |
925 | Log(Form("edge fit: mean = %f +- %f ps", mean, meane)); | |
926 | Log(Form("edge fit: sigma = %f +- %f ps", sigma, sigmae)); | |
927 | Float_t edge = mean - 3. * sigma; | |
928 | Float_t edgee = TMath::Sqrt(meane * meane + 3. * sigmae * 3. * sigmae); | |
929 | Log(Form("edge fit: edge = %f +- %f ps", edge, edgee)); | |
930 | /* apply calibration to get T0-fill from egde */ | |
931 | Float_t t0Fill = edge * t0FillCalibCoefficient + t0FillCalibOffset; | |
932 | Log(Form("estimated T0-fill: %f ps", t0Fill)); | |
933 | ||
934 | /* create T0-fill object */ | |
935 | AliTOFT0Fill *t0FillObject = new AliTOFT0Fill(); | |
936 | t0FillObject->SetT0Fill(t0Fill); | |
937 | ||
938 | /* store reference data */ | |
939 | if(fStoreRefData){ | |
940 | AliCDBMetaData metaDataHisto; | |
941 | metaDataHisto.SetBeamPeriod(0); | |
942 | metaDataHisto.SetResponsible("Roberto Preghenella"); | |
943 | metaDataHisto.SetComment("online T0-fill histogram"); | |
944 | if (!StoreReferenceData("Calib","T0Fill", hT0Fill, &metaDataHisto)) { | |
945 | Log("error while storing reference data"); | |
946 | delete hT0Fill; | |
947 | delete hit; | |
948 | delete t0FillObject; | |
949 | return 21; | |
950 | } | |
951 | Log("reference data successfully stored"); | |
952 | } | |
953 | ||
954 | AliCDBMetaData metaData; | |
955 | metaData.SetBeamPeriod(0); | |
956 | metaData.SetResponsible("Roberto Preghenella"); | |
957 | metaData.SetComment("online T0-fill measurement"); | |
958 | if (!Store("Calib", "T0Fill", t0FillObject, &metaData, 0, kFALSE)) { | |
959 | Log("error while storing T0-fill object"); | |
960 | delete hT0Fill; | |
961 | delete hit; | |
962 | delete t0FillObject; | |
963 | return 21; | |
964 | } | |
965 | Log("T0-fill object successfully stored"); | |
966 | ||
967 | delete hT0Fill; | |
968 | delete hit; | |
969 | delete t0FillObject; | |
970 | return 0; | |
971 | ||
972 | } | |
973 | ||
974 | ||
ee3e792b | 975 | //_____________________________________________________________________________ |
976 | ||
977 | UInt_t AliTOFPreprocessor::ProcessPulserData() | |
978 | { | |
7fffa85b | 979 | // Processing Pulser Run data for TOF channel status |
980 | ||
981 | Log("Processing Pulser"); | |
ee3e792b | 982 | |
17149e6b | 983 | if (fStatus==0x0){ |
984 | AliError("No valid fStatus found, some errors must have occurred!!"); | |
985 | return 20; | |
986 | } | |
ee3e792b | 987 | |
17149e6b | 988 | TH1::AddDirectory(0); |
989 | ||
ee3e792b | 990 | Bool_t resultPulserRef=kFALSE; |
7fffa85b | 991 | Bool_t resultPulser=kFALSE; |
17149e6b | 992 | |
a174d599 | 993 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
994 | TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5); | |
995 | for (Int_t ibin =1;ibin<=kSize;ibin++){ | |
17149e6b | 996 | htofPulser->SetBinContent(ibin,-1); |
7fffa85b | 997 | } |
17149e6b | 998 | |
ee3e792b | 999 | // processing pulser |
1000 | ||
1001 | TFile * daqFile=0x0; | |
1002 | TH1S *h1=0x0; | |
1003 | ||
1004 | //retrieving Pulser data | |
1005 | TList* listPulser = GetFileSources(kDAQ, "PULSER"); | |
bf76be9c | 1006 | if (listPulser !=0x0 && listPulser->GetEntries()!=0) |
e88f3330 | 1007 | { |
1008 | AliInfo("The following sources produced files with the id PULSER"); | |
1009 | listPulser->Print(); | |
1010 | Int_t nPulser = 0; | |
1011 | for (Int_t jj=0;jj<listPulser->GetEntries();jj++){ | |
1012 | Int_t nPulserSource = 0; | |
1013 | TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj)); | |
1014 | AliInfo(Form("found source %s", str->String().Data())); | |
1015 | // file to be stored run per run | |
1016 | TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName()); | |
1017 | if (fileNamePulser.Length()>0){ | |
1018 | // storing refernce data | |
1019 | AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data())); | |
1020 | daqFile = new TFile(fileNamePulser.Data(),"READ"); | |
1021 | h1 = (TH1S*) daqFile->Get("hTOFpulser"); | |
1022 | for (Int_t ibin=0;ibin<kSize;ibin++){ | |
1023 | if ((h1->GetBinContent(ibin+1))!=-1){ | |
1024 | if ((htofPulser->GetBinContent(ibin+1))==-1){ | |
1025 | htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)); | |
1026 | } | |
1027 | else { | |
1028 | Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin)); | |
1029 | } | |
1030 | } | |
1031 | } | |
1032 | ||
1033 | // elaborating infos | |
1034 | Double_t mean =0; | |
1035 | Int_t nread=0; | |
1036 | Int_t nreadNotEmpty=0; | |
1037 | for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){ | |
1038 | ||
1039 | 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))); | |
1040 | /* check whether channel has been read out during current run. | |
1041 | * if the status is bad it means it has not been read out. | |
1042 | * in this case skip channel in order to not affect the mean */ | |
1043 | if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
1044 | continue; | |
1045 | nPulser++; | |
1046 | nPulserSource++; | |
1047 | if (h1->GetBinContent(ientry)==-1) continue; | |
1048 | else { | |
1049 | if (h1->GetBinContent(ientry)>0) { | |
1050 | nreadNotEmpty++; | |
1051 | AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty)); | |
1052 | } | |
1053 | mean+=h1->GetBinContent(ientry); | |
1054 | nread++; | |
1055 | } | |
1056 | } | |
1057 | if (nread!=0) { | |
1058 | mean/=nread; | |
1059 | AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean)); | |
1060 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
1061 | if (h1->GetBinContent(ich+1)==-1) continue; | |
1062 | AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich))); | |
1063 | ||
1064 | /* check whether channel has been read out during current run. | |
1065 | * if the status is bad it means it has not been read out. | |
1066 | * in this case skip channel in order to leave its status | |
1067 | * unchanged */ | |
1068 | if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
1069 | continue; | |
1070 | ||
1071 | if (h1->GetBinContent(ich+1)<0.05*mean){ | |
1072 | fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser | |
1073 | 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))); | |
1074 | } | |
1075 | else { | |
1076 | fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser | |
1077 | 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))); | |
1078 | } | |
1079 | } | |
1080 | } | |
1081 | else { | |
1082 | Log("No channels read!! No action taken, keeping old status"); | |
1083 | } | |
1084 | ||
1085 | daqFile->Close(); | |
1086 | delete daqFile; | |
1087 | delete h1; | |
17149e6b | 1088 | } |
1a1486e7 | 1089 | |
e88f3330 | 1090 | else{ |
1091 | Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle "); | |
1092 | delete listPulser; | |
1093 | delete htofPulser; | |
1094 | htofPulser = 0x0; | |
1095 | if (fStatus){ | |
1096 | delete fStatus; | |
1097 | fStatus = 0; | |
1098 | } | |
1099 | return 10;//return error code for failure in retrieving Ref Data | |
1a1486e7 | 1100 | } |
e88f3330 | 1101 | AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource)); |
1a1486e7 | 1102 | } |
e88f3330 | 1103 | AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser)); |
1104 | delete listPulser; | |
ee3e792b | 1105 | } |
7fffa85b | 1106 | |
ee3e792b | 1107 | else{ |
17149e6b | 1108 | Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle "); |
e88f3330 | 1109 | delete htofPulser; |
1110 | htofPulser = 0x0; | |
1111 | if (fStatus){ | |
1112 | delete fStatus; | |
1113 | fStatus = 0; | |
1114 | } | |
17149e6b | 1115 | return 10;//return error code for failure in retrieving Ref Data |
ee3e792b | 1116 | } |
17149e6b | 1117 | |
7fffa85b | 1118 | //storing in OCDB |
17149e6b | 1119 | |
7fffa85b | 1120 | AliCDBMetaData metaData; |
1121 | metaData.SetBeamPeriod(0); | |
1122 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 1123 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run."); |
7fffa85b | 1124 | AliInfo("Storing Calibration Data from Pulser Run"); |
17149e6b | 1125 | resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE); |
7fffa85b | 1126 | if(!resultPulser){ |
1127 | Log("Some problems occurred while storing online object resulting from Pulser data processing"); | |
e88f3330 | 1128 | delete htofPulser; |
1129 | htofPulser = 0x0; | |
1130 | if (fStatus){ | |
1131 | delete fStatus; | |
1132 | fStatus = 0; | |
1133 | } | |
7fffa85b | 1134 | return 11;//return error code for problems in storing Pulser data |
1135 | } | |
1136 | ||
ee3e792b | 1137 | if(fStoreRefData){ |
1138 | ||
1139 | AliCDBMetaData metaDataHisto; | |
1140 | metaDataHisto.SetBeamPeriod(0); | |
1141 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
1142 | char comment[200]; | |
17149e6b | 1143 | sprintf(comment,"This preprocessor stores the Ref data from a pulser run."); |
ee3e792b | 1144 | metaDataHisto.SetComment(comment); |
1145 | AliInfo("Storing Reference Data"); | |
db83b789 | 1146 | resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto); |
ee3e792b | 1147 | if (!resultPulserRef){ |
7fffa85b | 1148 | Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle"); |
e88f3330 | 1149 | delete htofPulser; |
1150 | htofPulser = 0x0; | |
1151 | if (fStatus){ | |
1152 | delete fStatus; | |
1153 | fStatus = 0; | |
1154 | } | |
7fffa85b | 1155 | return 9;//return error code for failure in storing Ref Data |
ee3e792b | 1156 | } |
1157 | } | |
1158 | ||
1159 | daqFile=0; | |
1160 | ||
e88f3330 | 1161 | delete htofPulser; |
1162 | htofPulser = 0x0; | |
1163 | ||
1164 | if (fStatus){ | |
1165 | delete fStatus; | |
1166 | fStatus = 0; | |
1167 | } | |
1168 | ||
ee3e792b | 1169 | return 0; |
1170 | } | |
1171 | //_____________________________________________________________________________ | |
1172 | ||
1173 | UInt_t AliTOFPreprocessor::ProcessNoiseData() | |
1174 | { | |
7fffa85b | 1175 | |
1176 | // Processing Noise Run data for TOF channel status | |
1177 | ||
1178 | Log("Processing Noise"); | |
ee3e792b | 1179 | |
17149e6b | 1180 | if (fStatus==0x0){ |
1181 | AliError("No valid fStatus found, some errors must have occurred!!"); | |
1182 | return 20; | |
1183 | } | |
1184 | ||
013ac2dd | 1185 | Float_t noiseThr = 1; // setting default threshold for noise to 1 Hz |
1186 | // reading config map | |
1187 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise"); | |
1188 | if (!cdbEntry) { | |
1189 | Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr)); | |
1190 | } | |
1191 | else { | |
1192 | TMap *configMap = (TMap*)cdbEntry->GetObject(); | |
1193 | if (!configMap){ | |
1194 | Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr)); | |
1195 | } | |
1196 | else{ | |
1197 | TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr"); | |
1198 | if (strNoiseThr) { | |
1199 | TString tmpstr = strNoiseThr->GetString(); | |
1200 | noiseThr = tmpstr.Atoi(); | |
1201 | } | |
1202 | else { | |
1203 | Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr)); | |
1204 | } | |
1205 | } | |
1206 | } | |
1207 | ||
1208 | delete cdbEntry; | |
1209 | cdbEntry = 0x0; | |
1210 | ||
ee3e792b | 1211 | TH1::AddDirectory(0); |
1212 | ||
1213 | Bool_t resultNoiseRef=kFALSE; | |
7fffa85b | 1214 | Bool_t resultNoise=kFALSE; |
ee3e792b | 1215 | |
a174d599 | 1216 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
17149e6b | 1217 | TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5); |
a174d599 | 1218 | for (Int_t ibin =1;ibin<=kSize;ibin++){ |
17149e6b | 1219 | htofNoise->SetBinContent(ibin,-1); |
ee3e792b | 1220 | } |
17149e6b | 1221 | |
ee3e792b | 1222 | // processing noise |
1223 | ||
1224 | TFile * daqFile=0x0; | |
1225 | TH1F * h1=0x0; | |
1226 | ||
013ac2dd | 1227 | // useful counters |
1228 | Int_t nNoise = 0; | |
1229 | Int_t nNoisyChannels = 0; | |
1230 | Int_t nNotNoisyChannels = 0; | |
1231 | Int_t nChannelsFromDA = 0; | |
1232 | Int_t nMatchingWindowNullNonZero = 0; | |
1233 | Int_t nMatchingWindowNullEqualZero = 0; | |
1234 | ||
1235 | // retrieving Noise data | |
ee3e792b | 1236 | TList* listNoise = GetFileSources(kDAQ, "NOISE"); |
bf76be9c | 1237 | if (listNoise !=0x0 && listNoise->GetEntries()!=0) |
e88f3330 | 1238 | { |
1239 | AliInfo("The following sources produced files with the id NOISE"); | |
1240 | listNoise->Print(); | |
e88f3330 | 1241 | for (Int_t jj=0;jj<listNoise->GetEntries();jj++){ |
1242 | Int_t nNoiseSource = 0; | |
1243 | TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj)); | |
1244 | AliInfo(Form("found source %s", str->String().Data())); | |
1245 | // file to be stored run per run | |
1246 | TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName()); | |
1247 | if (fileNameNoise.Length()>0){ | |
1248 | // storing reference data | |
1249 | AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data())); | |
1250 | daqFile = new TFile(fileNameNoise.Data(),"READ"); | |
1251 | h1 = (TH1F*) daqFile->Get("hTOFnoise"); | |
1252 | for (Int_t ibin=0;ibin<kSize;ibin++){ | |
1253 | if ((h1->GetBinContent(ibin+1))!=-1){ | |
013ac2dd | 1254 | nNoiseSource++; |
1255 | // checking the matching window for current channel | |
1256 | if (fMatchingWindow[ibin] == 0){ | |
fc143ab2 | 1257 | Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin)); |
013ac2dd | 1258 | if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++; |
1259 | if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++; | |
1260 | continue; | |
1261 | } | |
e88f3330 | 1262 | if ((htofNoise->GetBinContent(ibin+1))==-1){ |
013ac2dd | 1263 | htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9)); |
1264 | if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1))); | |
e88f3330 | 1265 | } |
1266 | else { | |
1267 | Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin)); | |
1268 | } | |
1269 | } | |
1270 | } | |
013ac2dd | 1271 | |
1272 | Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource)); | |
e88f3330 | 1273 | daqFile->Close(); |
1274 | delete daqFile; | |
1275 | delete h1; | |
013ac2dd | 1276 | daqFile = 0x0; |
1277 | h1 = 0x0; | |
1278 | ||
e88f3330 | 1279 | } |
e88f3330 | 1280 | else{ |
1281 | Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle "); | |
1282 | delete listNoise; | |
013ac2dd | 1283 | listNoise = 0x0; |
e88f3330 | 1284 | delete htofNoise; |
1285 | htofNoise = 0x0; | |
1286 | if (fStatus){ | |
1287 | delete fStatus; | |
1288 | fStatus = 0; | |
1289 | } | |
013ac2dd | 1290 | if (fMatchingWindow){ |
1291 | delete [] fMatchingWindow; | |
1292 | fMatchingWindow = 0; | |
1293 | } | |
e88f3330 | 1294 | return 13;//return error code for failure in retrieving Ref Data |
1295 | } | |
013ac2dd | 1296 | } |
ee3e792b | 1297 | } |
013ac2dd | 1298 | |
e88f3330 | 1299 | else{ |
1300 | Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle "); | |
1301 | delete htofNoise; | |
1302 | htofNoise = 0x0; | |
1303 | if (fStatus){ | |
1304 | delete fStatus; | |
1305 | fStatus = 0; | |
ee3e792b | 1306 | } |
013ac2dd | 1307 | if (fMatchingWindow){ |
1308 | delete [] fMatchingWindow; | |
1309 | fMatchingWindow = 0; | |
1310 | } | |
7fffa85b | 1311 | return 13;//return error code for failure in retrieving Ref Data |
ee3e792b | 1312 | } |
1313 | ||
013ac2dd | 1314 | // elaborating infos to set NOISE status |
1315 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
1316 | if (htofNoise->GetBinContent(ich+1)== -1) continue; | |
1317 | ||
1318 | nChannelsFromDA++; | |
1319 | ||
1320 | 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))); | |
1321 | //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich))); | |
1322 | ||
1323 | /* check whether channel has been read out during current run. | |
1324 | * if the status is bad it means it has not been read out. | |
1325 | * in this case skip channel in order to leave its status | |
1326 | * unchanged */ | |
1327 | ||
1328 | if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad) | |
1329 | continue; | |
1330 | ||
1331 | nNoise++; | |
1332 | if (htofNoise->GetBinContent(ich+1) >= noiseThr){ | |
1333 | fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise | |
1334 | 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))); | |
1335 | nNoisyChannels++; | |
1336 | } | |
1337 | else { | |
1338 | fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise | |
1339 | 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))); | |
1340 | nNotNoisyChannels++; | |
1341 | } | |
1342 | } | |
1343 | ||
1344 | Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA)); | |
1345 | Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise)); | |
1346 | Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels)); | |
1347 | Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels)); | |
1348 | Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero)); | |
1349 | Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero)); | |
1350 | ||
1351 | delete listNoise; | |
1352 | ||
1353 | //daqFile=0; | |
e88f3330 | 1354 | |
7fffa85b | 1355 | //storing in OCDB |
e88f3330 | 1356 | |
7fffa85b | 1357 | AliCDBMetaData metaData; |
1358 | metaData.SetBeamPeriod(0); | |
1359 | metaData.SetResponsible("Chiara Zampolli"); | |
17149e6b | 1360 | metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run."); |
7fffa85b | 1361 | AliInfo("Storing Calibration Data from Noise Run"); |
17149e6b | 1362 | resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE); |
7fffa85b | 1363 | if(!resultNoise){ |
1364 | Log("Some problems occurred while storing online object resulting from Noise data processing"); | |
e88f3330 | 1365 | delete htofNoise; |
1366 | htofNoise = 0x0; | |
1367 | if (fStatus){ | |
1368 | delete fStatus; | |
1369 | fStatus = 0; | |
1370 | } | |
013ac2dd | 1371 | if (fMatchingWindow){ |
1372 | delete [] fMatchingWindow; | |
1373 | fMatchingWindow = 0; | |
1374 | } | |
7fffa85b | 1375 | return 14;//return error code for problems in storing Noise data |
1376 | } | |
1377 | ||
ee3e792b | 1378 | if(fStoreRefData){ |
1379 | ||
1380 | AliCDBMetaData metaDataHisto; | |
1381 | metaDataHisto.SetBeamPeriod(0); | |
1382 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
1383 | char comment[200]; | |
17149e6b | 1384 | sprintf(comment,"This preprocessor stores the Ref data from a noise run. "); |
ee3e792b | 1385 | metaDataHisto.SetComment(comment); |
1386 | AliInfo("Storing Reference Data"); | |
db83b789 | 1387 | resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto); |
ee3e792b | 1388 | if (!resultNoiseRef){ |
1389 | Log("some problems occurred::No Reference Data for noise stored"); | |
e88f3330 | 1390 | delete htofNoise; |
1391 | htofNoise = 0x0; | |
1392 | if (fStatus){ | |
1393 | delete fStatus; | |
1394 | fStatus = 0; | |
1395 | } | |
013ac2dd | 1396 | if (fMatchingWindow){ |
1397 | delete [] fMatchingWindow; | |
1398 | fMatchingWindow = 0; | |
1399 | } | |
7fffa85b | 1400 | return 12;//return error code for failure in storing Ref Data |
ee3e792b | 1401 | } |
1402 | } | |
1403 | ||
e88f3330 | 1404 | delete htofNoise; |
1405 | htofNoise = 0x0; | |
1406 | ||
1407 | if (fStatus){ | |
1408 | delete fStatus; | |
1409 | fStatus = 0; | |
1410 | } | |
1411 | ||
013ac2dd | 1412 | if (fMatchingWindow){ |
1413 | delete [] fMatchingWindow; | |
1414 | fMatchingWindow = 0; | |
1415 | } | |
1416 | ||
ee3e792b | 1417 | return 0; |
1418 | } | |
1419 | //_____________________________________________________________________________ | |
1420 | ||
db83b789 | 1421 | UInt_t AliTOFPreprocessor::ProcessFEEData() |
ee3e792b | 1422 | { |
7fffa85b | 1423 | // Processing Pulser Run data for TOF channel status |
1424 | // dummy for the time being | |
ee3e792b | 1425 | |
db83b789 | 1426 | Log("Processing FEE"); |
1427 | ||
ea932f75 | 1428 | //Bool_t updateOCDB = kFALSE; |
db83b789 | 1429 | AliTOFFEEReader feeReader; |
17149e6b | 1430 | |
db83b789 | 1431 | TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels); |
1432 | ||
69355034 | 1433 | /* load current TOF FEE(dump) from DCS FXS, |
1434 | * setup TOFFEEdump object */ | |
1435 | ||
1436 | const char * toffeeFileName = GetFile(kDCS,"TofFeeMap",""); | |
1437 | AliInfo(Form("toffee file name = %s", toffeeFileName)); | |
1438 | if (toffeeFileName == NULL) { | |
1439 | return 15; | |
1440 | } | |
1441 | AliTOFFEEDump feedump; | |
1442 | feedump.ReadFromFile(toffeeFileName); | |
1443 | ||
1444 | /* load current TOF FEE(light) config from DCS FXS, parse, | |
db83b789 | 1445 | * fill current FEE histogram and set FEE status */ |
1446 | ||
fceb731d | 1447 | const char * nameFile = GetFile(kDCS,"TofFeeLightMap",""); |
69355034 | 1448 | AliInfo(Form("toffeeLight file name = %s",nameFile)); |
db83b789 | 1449 | if (nameFile == NULL) { |
1450 | return 15; | |
1451 | } | |
fceb731d | 1452 | feeReader.LoadFEElightConfig(nameFile); |
1453 | Int_t parseFee = feeReader.ParseFEElightConfig(); | |
1454 | AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee)); | |
db83b789 | 1455 | /* load stored TOF FEE from OCDB and compare it with current FEE. |
1456 | * if stored FEE is different from current FEE set update flag. | |
1457 | * if there is no stored FEE in OCDB set update flag */ | |
1458 | ||
013ac2dd | 1459 | fMatchingWindow = new Int_t[fNChannels]; |
02ede0c4 | 1460 | fLatencyWindow = new Int_t[fNChannels]; |
1461 | ||
17149e6b | 1462 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status"); |
1463 | if (!cdbEntry) { | |
1464 | /* no CDB entry found. set update flag */ | |
1465 | Log(" ************ WARNING ************"); | |
1466 | Log("No CDB Status entry found, creating a new one!"); | |
1467 | Log(" *********************************"); | |
1468 | fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); | |
ea932f75 | 1469 | //updateOCDB = kTRUE; |
1470 | fIsStatusMapChanged = kTRUE; | |
db83b789 | 1471 | } |
db83b789 | 1472 | else { |
e88f3330 | 1473 | if (cdbEntry) cdbEntry->SetOwner(kFALSE); |
17149e6b | 1474 | /* CDB entry OK. loop over channels */ |
1475 | fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject(); | |
e88f3330 | 1476 | delete cdbEntry; |
1477 | cdbEntry = 0x0; | |
134e5594 | 1478 | /* cehck whether status object has latency window data */ |
1479 | if (!fStatus->HasLatencyWindow()) { | |
1480 | /* create new status object and update OCDB */ | |
1481 | Log(" ************ WARNING ************"); | |
1482 | Log("CDB Status entry found but has no latency window data, creating a new one!"); | |
1483 | Log(" *********************************"); | |
1484 | delete fStatus; | |
1485 | fStatus = new AliTOFChannelOnlineStatusArray(fNChannels); | |
ea932f75 | 1486 | //updateOCDB = kTRUE; |
1487 | fIsStatusMapChanged = kTRUE; | |
134e5594 | 1488 | } |
db83b789 | 1489 | } |
17149e6b | 1490 | for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){ |
1491 | //AliDebug(2,Form("********** channel %i",iChannel)); | |
1492 | /* compare current FEE channel status with stored one | |
1493 | * if different set update flag and break loop */ | |
1494 | //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); | |
013ac2dd | 1495 | fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel); |
02ede0c4 | 1496 | fLatencyWindow[iChannel] = feeReader.GetLatencyWindow(iChannel); |
17149e6b | 1497 | if (feeReader.IsChannelEnabled(iChannel)) { |
1498 | hCurrentFEE.SetBinContent(iChannel + 1, 1); | |
1499 | if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){ | |
ea932f75 | 1500 | //updateOCDB = kTRUE; |
1501 | fIsStatusMapChanged = kTRUE; | |
17149e6b | 1502 | fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk); |
013ac2dd | 1503 | AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); |
17149e6b | 1504 | } |
02ede0c4 | 1505 | if (fStatus->GetLatencyWindow(iChannel)!=fLatencyWindow[iChannel]){ |
ea932f75 | 1506 | //updateOCDB = kTRUE; |
1507 | fIsStatusMapChanged = kTRUE; | |
02ede0c4 | 1508 | fStatus->SetLatencyWindow(iChannel,fLatencyWindow[iChannel]); |
1509 | AliDebug(3,Form( " changed latency window: channel %i latency window after FEE = %i",iChannel,fStatus->GetLatencyWindow(iChannel))); | |
1510 | } | |
17149e6b | 1511 | } |
1512 | else { | |
1513 | if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){ | |
ea932f75 | 1514 | //updateOCDB = kTRUE; |
1515 | fIsStatusMapChanged = kTRUE; | |
17149e6b | 1516 | fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad); |
013ac2dd | 1517 | AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel))); |
17149e6b | 1518 | } |
1519 | } | |
1520 | } | |
1521 | ||
db83b789 | 1522 | |
1523 | /* check whether we don't have to store reference data. | |
1524 | * in this case we return without errors. */ | |
1525 | if (fStoreRefData) { | |
69355034 | 1526 | /* store reference data */ |
1527 | AliCDBMetaData metaDataHisto; | |
1528 | metaDataHisto.SetBeamPeriod(0); | |
1529 | metaDataHisto.SetResponsible("Roberto Preghenella"); | |
1530 | metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run."); | |
1531 | AliInfo("Storing FEE reference data"); | |
1532 | /* store FEE reference data */ | |
1533 | if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) { | |
1534 | /* failed */ | |
1535 | Log("problems while storing FEE reference data"); | |
1536 | if (fStatus){ | |
1537 | delete fStatus; | |
1538 | fStatus = 0; | |
1539 | } | |
1540 | return 18; /* error return code for problems while storing FEE reference data */ | |
1541 | } | |
1542 | ||
1543 | /* store TOF FEE dump reference data */ | |
1544 | AliCDBMetaData metaDatadump; | |
1545 | metaDatadump.SetBeamPeriod(0); | |
1546 | metaDatadump.SetResponsible("Roberto Preghenella"); | |
1547 | metaDatadump.SetComment("This preprocessor stores the TOF FEE dump Ref data of the current run."); | |
1548 | AliInfo("Storing TOF FEE dump reference data"); | |
1549 | /* store FEE reference data */ | |
1550 | if (!StoreReferenceData("Calib", "FEEDump", &feedump, &metaDatadump)) { | |
1551 | /* failed */ | |
1552 | Log("problems while storing TOF FEE dump reference data"); | |
1553 | return 18; /* error return code for problems while storing FEE reference data */ | |
1554 | } | |
db83b789 | 1555 | } |
1556 | ||
7fffa85b | 1557 | return 0; |
1558 | ||
1559 | } | |
1560 | ||
1561 | //_____________________________________________________________________________ | |
1562 | ||
104ba366 | 1563 | UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap) |
7fffa85b | 1564 | { |
a174d599 | 1565 | // |
ea932f75 | 1566 | // Main AliTOFPreprocessor method called by SHUTTLE |
a174d599 | 1567 | // |
7fffa85b | 1568 | |
1569 | TString runType = GetRunType(); | |
1570 | Log(Form("RunType %s",runType.Data())); | |
bf76be9c | 1571 | |
ee3e792b | 1572 | // processing |
1573 | ||
db83b789 | 1574 | /* always process FEE data */ |
1575 | Int_t iresultFEE = ProcessFEEData(); | |
1576 | if (iresultFEE != 0) | |
1577 | return iresultFEE; | |
1578 | ||
7fffa85b | 1579 | if (runType == "PULSER") { |
1580 | Int_t iresultPulser = ProcessPulserData(); | |
1581 | return iresultPulser; | |
1582 | } | |
17149e6b | 1583 | |
7fffa85b | 1584 | if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined |
1585 | Int_t iresultNoise = ProcessNoiseData(); | |
1586 | return iresultNoise; | |
1587 | } | |
104ba366 | 1588 | |
7fffa85b | 1589 | if (runType == "PHYSICS") { |
104ba366 | 1590 | // Int_t iresultDAQ = ProcessOnlineDelays(); |
1591 | Int_t iresultDAQ = ProcessT0Fill(); | |
4856f488 | 1592 | if (iresultDAQ != 0) { |
7fffa85b | 1593 | return iresultDAQ; |
1594 | } | |
4856f488 | 1595 | else { |
1596 | Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap); | |
ea932f75 | 1597 | Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap); |
1598 | return iresultDCS+iResultHVandLVdps; | |
4856f488 | 1599 | } |
ee3e792b | 1600 | } |
1601 | ||
7fffa85b | 1602 | // storing |
ee3e792b | 1603 | return 0; |
1604 | } | |
c9fe8530 | 1605 | |
1606 | ||
b06d5296 | 1607 | //_____________________________________________________________________________ |
1608 | ||
1609 | void | |
1610 | AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal) | |
1611 | { | |
1612 | /* | |
1613 | * fill with cosmic calibration | |
1614 | */ | |
1615 | ||
1616 | Log(" Using cosmic-ray calibration."); | |
1617 | ||
1618 | AliTOFcalibHisto calibHisto; | |
97a29b32 | 1619 | calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE); |
1620 | Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName())); | |
b06d5296 | 1621 | Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName())); |
1622 | calibHisto.LoadCalibPar(); | |
1623 | ||
1624 | /* loop over channel index */ | |
1625 | for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) { | |
9155334b | 1626 | cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex)); |
b06d5296 | 1627 | } |
1628 | ||
1629 | } | |
1630 | ||
b06d5296 | 1631 | //_____________________________________________________________________________ |
1632 | ||
1633 | void | |
1634 | AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal) | |
1635 | { | |
1636 | /* | |
1637 | * fill with cosmic calibration | |
1638 | */ | |
1639 | ||
1640 | Log(" Using cable-length map."); | |
1641 | AliTOFRawStream tofrs; | |
1642 | Int_t det[5], dummy, index; | |
1643 | Float_t cableTimeShift; | |
1644 | ||
1645 | /* temporarly disable warnings */ | |
1646 | AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel(); | |
1647 | AliLog::SetGlobalLogLevel(AliLog::kError); | |
1648 | ||
1649 | /* loop over EO indeces */ | |
1650 | for (Int_t iddl = 0; iddl < 72; iddl++) | |
1651 | for (Int_t islot = 3; islot <= 12; islot++) | |
1652 | for (Int_t ichain = 0; ichain < 2; ichain++) | |
1653 | for (Int_t itdc = 0; itdc < 15; itdc++) | |
1654 | for (Int_t ichannel = 0; ichannel < 8; ichannel++) { | |
1655 | ||
1656 | /* get DO index */ | |
1657 | tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det); | |
1658 | ||
1659 | /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */ | |
1660 | dummy = det[3]; | |
1661 | det[3] = det[4]; | |
1662 | det[4] = dummy; | |
1663 | ||
1664 | /* check DO index */ | |
1665 | if (det[0] < 0 || det[0] > 17 || | |
1666 | det[1] < 0 || det[1] > 4 || | |
1667 | det[2] < 0 || det[2] > 18 || | |
1668 | det[3] < 0 || det[3] > 1 || | |
1669 | det[4] < 0 || det[4] > 47) | |
1670 | continue; | |
1671 | ||
1672 | /* get channel index */ | |
1673 | index = AliTOFGeometry::GetIndex(det); | |
1674 | ||
1675 | /* get cable time shift */ | |
1676 | cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc); | |
1677 | ||
1678 | /* set delay */ | |
1679 | if (index<fNChannels) { | |
1680 | cal->SetDelay(index,cableTimeShift); // delay in ns | |
1681 | AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index)); | |
1682 | } | |
1683 | ||
1684 | } /* loop over EO indeces */ | |
1685 | ||
1686 | /* re-enable warnings */ | |
1687 | AliLog::SetGlobalLogLevel(logLevel); | |
1688 | ||
1689 | } | |
1690 | ||
1691 |