]>
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> |
a174d599 | 23 | //#include <TH1.h> |
24 | //#include <TH1F.h> | |
25 | //#include <TH1S.h> | |
9edefa04 | 26 | #include <TH2S.h> |
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" |
c9fe8530 | 35 | #include "AliTOFChannelOnline.h" |
7fffa85b | 36 | #include "AliTOFChannelOnlineStatus.h" |
9edefa04 | 37 | #include "AliTOFDataDCS.h" |
10056aa6 | 38 | #include "AliTOFGeometry.h" |
9edefa04 | 39 | #include "AliTOFPreprocessor.h" |
c9fe8530 | 40 | |
a174d599 | 41 | //class TF1; |
42 | //class AliDCSValue; | |
43 | //class AliTOFGeometry; | |
c9fe8530 | 44 | |
45 | // TOF preprocessor class. | |
46 | // It takes data from DCS and passes them to the class AliTOFDataDCS, which | |
47 | // processes them. The result is then written to the CDB. | |
48 | // analogously, it takes data form DAQ (both at Run level and inclusive - | |
49 | // of all the runs - level, processes them, and stores both Reference Data | |
50 | // and Online Calibration files in the CDB. | |
7fffa85b | 51 | // Processing of Pulser/Noise Run data and of TOF FEE DCS map |
52 | ||
53 | // return codes: | |
54 | // return=0 : all ok | |
55 | // return=1 : no DCS input data Map | |
56 | // return=2 : no DCS input data processing | |
57 | // return=3 : no DCS processed data was stored in Ref Data | |
58 | // return=4 : no DAQ input for Ref Data | |
59 | // return=5 : failed to store DAQ Ref Data | |
60 | // return=6 : failed to retrieve DAQ data for calibration | |
61 | // return=7 : problems in processing histos in the input DAQ file | |
62 | // return=8 : failed to store Online Delays | |
63 | // return=9 : failed to store Reference Data for Pulser | |
64 | // return=10: failed to retrieve Pulser data | |
65 | // return=11: failed to store Pulser map in OCDB | |
66 | // return=12: failed to store Reference Data for Noise | |
67 | // return=13: failed to retrieve Noise data | |
68 | // return=14: failed to store Noise map in OCDB | |
c9fe8530 | 69 | |
70 | ClassImp(AliTOFPreprocessor) | |
71 | ||
7fffa85b | 72 | const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean |
73 | const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel | |
74 | const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay | |
c9fe8530 | 75 | |
76 | //_____________________________________________________________________________ | |
77 | ||
708db10b | 78 | AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) : |
79 | AliPreprocessor("TOF", shuttle), | |
c9fe8530 | 80 | fData(0), |
708db10b | 81 | fh2(0), |
c9fe8530 | 82 | fCal(0), |
7fffa85b | 83 | fCalStatus(0), |
10056aa6 | 84 | fNChannels(0), |
7fffa85b | 85 | fStoreRefData(kTRUE), |
86 | fFDRFlag(kTRUE) | |
c9fe8530 | 87 | { |
88 | // constructor | |
10056aa6 | 89 | |
c9fe8530 | 90 | } |
91 | ||
92 | //_____________________________________________________________________________ | |
93 | ||
94 | AliTOFPreprocessor::~AliTOFPreprocessor() | |
95 | { | |
96 | // destructor | |
7981612d | 97 | if (fData){ |
98 | delete fData; | |
99 | fData = 0; | |
100 | } | |
101 | if (fh2){ | |
102 | delete fh2; | |
103 | fh2 = 0; | |
104 | } | |
105 | if (fCal){ | |
64f2148a | 106 | // fCal->Clear(); |
7981612d | 107 | delete fCal; |
108 | fCal = 0; | |
109 | } | |
7fffa85b | 110 | if (fCalStatus){ |
111 | delete fCalStatus; | |
112 | fCalStatus = 0; | |
113 | } | |
c9fe8530 | 114 | } |
115 | ||
116 | //______________________________________________________________________________ | |
117 | void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
118 | UInt_t endTime) | |
119 | { | |
120 | // Creates AliTOFDataDCS object | |
121 | ||
122 | AliPreprocessor::Initialize(run, startTime, endTime); | |
123 | ||
124 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
125 | TTimeStamp(startTime).AsString(), | |
126 | TTimeStamp(endTime).AsString())); | |
127 | ||
128 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime); | |
7fffa85b | 129 | fData->SetFDRFlag(fFDRFlag); |
708db10b | 130 | fh2 = 0x0; |
10056aa6 | 131 | fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX(); |
132 | fCal = new TObjArray(fNChannels); | |
133 | fCal->SetOwner(); | |
134 | for (Int_t ich = 0; ich<fNChannels; ich ++){ | |
135 | AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline(); | |
136 | fCal->AddAt(calChOnline,ich); | |
137 | } | |
7fffa85b | 138 | fCalStatus = new TObjArray(fNChannels); |
139 | fCalStatus->SetOwner(); | |
140 | for (Int_t ich = 0; ich<fNChannels; ich ++){ | |
141 | AliTOFChannelOnlineStatus * calChOnlineStatus = new AliTOFChannelOnlineStatus(); | |
142 | fCalStatus->AddAt(calChOnlineStatus,ich); | |
143 | } | |
c9fe8530 | 144 | } |
7fffa85b | 145 | //_____________________________________________________________________________ |
146 | Bool_t AliTOFPreprocessor::ProcessDCS(){ | |
147 | ||
148 | // check whether DCS should be processed or not... | |
c9fe8530 | 149 | |
7fffa85b | 150 | TString runType = GetRunType(); |
151 | Log(Form("RunType %s",runType.Data())); | |
152 | ||
55454922 | 153 | if (runType != "PHYSICS"){ |
7fffa85b | 154 | return kFALSE; |
155 | } | |
156 | ||
157 | return kTRUE; | |
158 | } | |
c9fe8530 | 159 | //_____________________________________________________________________________ |
160 | ||
ee3e792b | 161 | UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap) |
c9fe8530 | 162 | { |
163 | // Fills data into a AliTOFDataDCS object | |
164 | ||
7fffa85b | 165 | |
166 | Log("Processing DCS DP"); | |
708db10b | 167 | TH1::AddDirectory(0); |
5936ab02 | 168 | |
7885c291 | 169 | Bool_t resultDCSMap=kFALSE; |
170 | Bool_t resultDCSStore=kFALSE; | |
c9fe8530 | 171 | |
172 | // processing DCS | |
173 | ||
174 | if (!dcsAliasMap){ | |
5936ab02 | 175 | Log("No DCS map found: TOF exiting from Shuttle"); |
176 | return 1;// return error Code for DCS input data not found | |
c9fe8530 | 177 | } |
178 | else { | |
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"); | |
5936ab02 | 183 | return 2;// return error Code for processed DCS data not stored |
c9fe8530 | 184 | } |
7885c291 | 185 | else{ |
186 | AliCDBMetaData metaDataDCS; | |
187 | metaDataDCS.SetBeamPeriod(0); | |
188 | metaDataDCS.SetResponsible("Chiara Zampolli"); | |
189 | metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); | |
190 | AliInfo("Storing DCS Data"); | |
b0d8f3fc | 191 | resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS); |
7885c291 | 192 | if (!resultDCSStore){ |
b0d8f3fc | 193 | Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle"); |
7885c291 | 194 | return 3;// return error Code for processed DCS data not stored |
b0d8f3fc | 195 | // in reference data |
7885c291 | 196 | |
197 | } | |
198 | } | |
c9fe8530 | 199 | } |
ee3e792b | 200 | return 0; |
201 | } | |
202 | //_____________________________________________________________________________ | |
203 | ||
204 | UInt_t AliTOFPreprocessor::ProcessOnlineDelays() | |
205 | { | |
7fffa85b | 206 | // Processing data from DAQ for online calibration |
207 | ||
208 | Log("Processing DAQ delays"); | |
ee3e792b | 209 | |
210 | TH1::AddDirectory(0); | |
211 | ||
212 | Bool_t resultDAQRef=kFALSE; | |
7fffa85b | 213 | Bool_t resultTOFPP=kFALSE; |
c9fe8530 | 214 | // processing DAQ |
7885c291 | 215 | |
c9fe8530 | 216 | TFile * daqFile=0x0; |
7885c291 | 217 | |
5936ab02 | 218 | if(fStoreRefData){ |
219 | //retrieving data at Run level | |
220 | TList* list = GetFileSources(kDAQ, "RUNLevel"); | |
5a83e79b | 221 | if (list->GetEntries()!=0) |
5936ab02 | 222 | { |
223 | AliInfo("The following sources produced files with the id RUNLevel"); | |
224 | list->Print(); | |
225 | for (Int_t jj=0;jj<list->GetEntries();jj++){ | |
226 | TObjString * str = dynamic_cast<TObjString*> (list->At(jj)); | |
227 | AliInfo(Form("found source %s", str->String().Data())); | |
228 | // file to be stored run per run | |
229 | TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName()); | |
230 | if (fileNameRun.Length()>0){ | |
231 | AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data())); | |
232 | daqFile = new TFile(fileNameRun.Data(),"READ"); | |
233 | fh2 = (TH2S*) daqFile->Get("htof"); | |
234 | AliCDBMetaData metaDataHisto; | |
235 | metaDataHisto.SetBeamPeriod(0); | |
236 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
237 | metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data."); | |
238 | AliInfo("Storing Reference Data"); | |
239 | resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto); | |
240 | if (!resultDAQRef){ | |
241 | Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle"); | |
7885c291 | 242 | return 5;//return error code for failure in storing Ref Data |
5936ab02 | 243 | } |
244 | daqFile->Close(); | |
245 | delete daqFile; | |
246 | } | |
247 | ||
248 | else{ | |
249 | Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle "); | |
7885c291 | 250 | return 4;//return error code for failure in retrieving Ref Data |
c9fe8530 | 251 | } |
c9fe8530 | 252 | } |
ee3e792b | 253 | delete list; |
9bc469d1 | 254 | } |
5936ab02 | 255 | else{ |
256 | Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle "); | |
7885c291 | 257 | return 4;//return error code for failure in retrieving Ref Data |
5936ab02 | 258 | } |
9bc469d1 | 259 | } |
260 | ||
9bc469d1 | 261 | |
5936ab02 | 262 | //Total files, with cumulative histos |
263 | ||
9bc469d1 | 264 | TList* listTot = GetFileSources(kDAQ, "DELAYS"); |
5a83e79b | 265 | if (listTot->GetEntries()!=0) |
9bc469d1 | 266 | { |
267 | AliInfo("The following sources produced files with the id DELAYS"); | |
268 | listTot->Print(); | |
269 | for (Int_t jj=0;jj<listTot->GetEntries();jj++){ | |
270 | TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj)); | |
271 | AliInfo(Form("found source %s", str->String().Data())); | |
272 | ||
c9fe8530 | 273 | // file with summed histos, to extract calib params |
9bc469d1 | 274 | TString fileName = GetFile(kDAQ, "DELAYS", str->GetName()); |
275 | if (fileName.Length()>0){ | |
276 | AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data())); | |
c9fe8530 | 277 | |
9bc469d1 | 278 | daqFile = new TFile(fileName.Data(),"READ"); |
64f2148a | 279 | if (fh2) delete fh2; |
708db10b | 280 | fh2 = (TH2S*) daqFile->Get("htoftot"); |
281 | if (!fh2){ | |
9d883ed9 | 282 | Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle"); |
283 | delete daqFile; | |
7885c291 | 284 | return 7; //return error code for histograms not existing/junky |
c9fe8530 | 285 | } |
c9fe8530 | 286 | else { |
3a3ece53 | 287 | static const Int_t kSize=fh2->GetNbinsX(); |
288 | static const Int_t kNBins=fh2->GetNbinsY(); | |
289 | static const Double_t kXBinmin=fh2->GetYaxis()->GetBinLowEdge(1); | |
10056aa6 | 290 | if (kSize != fNChannels){ |
9d883ed9 | 291 | Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle"); |
292 | delete daqFile; | |
7885c291 | 293 | return 7; //return error code for histograms not existing/junky |
9bc469d1 | 294 | } |
3a3ece53 | 295 | for (Int_t ich=0;ich<kSize;ich++){ |
296 | TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5); | |
297 | for (Int_t ibin=0;ibin<kNBins;ibin++){ | |
708db10b | 298 | h1->SetBinContent(ibin+1,fh2->GetBinContent(ich+1,ibin+1)); |
299 | } | |
7fffa85b | 300 | if(h1->Integral()<fgkIntegralThr) { |
301 | Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); | |
302 | delete h1; | |
303 | h1=0x0; | |
304 | continue; | |
c9fe8530 | 305 | } |
7fffa85b | 306 | if (!fFDRFlag) { // not computing delays if in FDR runs |
307 | Bool_t found=kFALSE; | |
308 | Float_t minContent=h1->Integral()*fgkThrPar; | |
309 | Int_t nbinsX = h1->GetNbinsX(); | |
310 | Int_t startBin=1; | |
311 | for (Int_t j=1; j<=nbinsX; j++){ | |
312 | if (( | |
313 | h1->GetBinContent(j) + | |
314 | h1->GetBinContent(j+1)+ | |
315 | h1->GetBinContent(j+2)+ | |
316 | h1->GetBinContent(j+3))>minContent){ | |
317 | found=kTRUE; | |
318 | startBin=j; | |
319 | break; | |
320 | } | |
321 | } | |
322 | if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich)); | |
323 | // Now calculate the mean over the interval. | |
324 | Double_t mean = 0; | |
325 | Double_t sumw2 = 0; | |
326 | Double_t nent = 0; | |
327 | for(Int_t k=0;k<fgkBinRangeAve;k++){ | |
328 | mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k); | |
329 | nent=nent+h1->GetBinContent(startBin+k); | |
330 | sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k)); | |
331 | } | |
332 | mean= mean/nent; //<x> | |
333 | sumw2=sumw2/nent; //<x^2> | |
334 | Double_t rmsmean= 0; | |
335 | rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent); | |
336 | if (ich<fNChannels) { | |
337 | AliTOFChannelOnline * ch = (AliTOFChannelOnline *)fCal->At(ich); | |
338 | ch->SetDelay((Double_t)mean*AliTOFGeometry::TdcBinWidth()*1.E-3); // delay in ns | |
339 | // ch->SetStatus(1); // calibrated channel, removed for the time being from AliTOFChannelOnline | |
340 | } | |
c9fe8530 | 341 | } |
708db10b | 342 | delete h1; |
343 | h1=0x0; | |
c9fe8530 | 344 | } |
c9fe8530 | 345 | } |
346 | daqFile->Close(); | |
347 | delete daqFile; | |
c9fe8530 | 348 | } |
349 | else{ | |
9d883ed9 | 350 | Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle"); |
7885c291 | 351 | return 6;//return error code for problems in retrieving DAQ data |
c9fe8530 | 352 | } |
353 | } | |
ee3e792b | 354 | delete listTot; |
c9fe8530 | 355 | } |
356 | else{ | |
9d883ed9 | 357 | Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle"); |
7885c291 | 358 | return 6; //return error code for problems in retrieving DAQ data |
c9fe8530 | 359 | } |
360 | ||
c9fe8530 | 361 | daqFile=0; |
7fffa85b | 362 | AliCDBMetaData metaData; |
363 | metaData.SetBeamPeriod(0); | |
364 | metaData.SetResponsible("Chiara Zampolli"); | |
365 | metaData.SetComment("This preprocessor fills a TObjArray object."); | |
366 | AliInfo("Storing Calibration Data"); | |
367 | resultTOFPP = Store("Calib","ParOnline",fCal, &metaData,0,kTRUE); | |
368 | if(!resultTOFPP){ | |
369 | Log("Some problems occurred while storing online object resulting from DAQ data processing"); | |
370 | return 8;//return error code for problems in storing DAQ data | |
371 | } | |
9d883ed9 | 372 | |
5936ab02 | 373 | return 0; |
c9fe8530 | 374 | } |
ee3e792b | 375 | //_____________________________________________________________________________ |
376 | ||
377 | UInt_t AliTOFPreprocessor::ProcessPulserData() | |
378 | { | |
7fffa85b | 379 | // Processing Pulser Run data for TOF channel status |
380 | ||
381 | Log("Processing Pulser"); | |
ee3e792b | 382 | |
383 | TH1::AddDirectory(0); | |
384 | ||
385 | Bool_t resultPulserRef=kFALSE; | |
7fffa85b | 386 | Bool_t resultPulser=kFALSE; |
ee3e792b | 387 | |
a174d599 | 388 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
389 | TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5); | |
390 | for (Int_t ibin =1;ibin<=kSize;ibin++){ | |
ee3e792b | 391 | htofPulser->SetBinContent(ibin,-1); |
392 | } | |
393 | ||
7fffa85b | 394 | // retrieving last stored pulser object, and copying |
395 | ||
396 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Pulser"); | |
397 | if (cdbEntry!=0x0){ | |
398 | TObjArray *currentCalStatus = (TObjArray*)cdbEntry->GetObject(); | |
399 | for (Int_t ich = 0; ich<fNChannels; ich ++){ | |
400 | AliTOFChannelOnlineStatus * calChOnlineSt = (AliTOFChannelOnlineStatus*)fCalStatus->At(ich); | |
401 | calChOnlineSt->SetStatus(((AliTOFChannelOnlineStatus*)currentCalStatus->At(ich))->GetStatus()); | |
402 | } | |
403 | } | |
404 | ||
ee3e792b | 405 | // processing pulser |
406 | ||
407 | TFile * daqFile=0x0; | |
408 | TH1S *h1=0x0; | |
409 | ||
410 | //retrieving Pulser data | |
411 | TList* listPulser = GetFileSources(kDAQ, "PULSER"); | |
5a83e79b | 412 | if (listPulser->GetEntries()!=0) |
ee3e792b | 413 | { |
414 | AliInfo("The following sources produced files with the id PULSER"); | |
415 | listPulser->Print(); | |
416 | for (Int_t jj=0;jj<listPulser->GetEntries();jj++){ | |
417 | TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj)); | |
418 | AliInfo(Form("found source %s", str->String().Data())); | |
419 | // file to be stored run per run | |
420 | TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName()); | |
421 | if (fileNamePulser.Length()>0){ | |
422 | // storing refernce data | |
423 | AliInfo(Form("Got the file %s, now we can store the Reference Data for pulser for the current Run.", fileNamePulser.Data())); | |
424 | daqFile = new TFile(fileNamePulser.Data(),"READ"); | |
425 | h1 = (TH1S*) daqFile->Get("hTOFpulser"); | |
a174d599 | 426 | for (Int_t ibin=0;ibin<kSize;ibin++){ |
ee3e792b | 427 | if ((h1->GetBinContent(ibin+1))!=-1){ |
428 | if ((htofPulser->GetBinContent(ibin+1))==-1){ | |
429 | htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)); | |
430 | } | |
431 | else { | |
432 | Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin)); | |
433 | } | |
434 | } | |
435 | } | |
436 | // elaborating infos | |
437 | Double_t mean =0; | |
438 | Int_t nread=0; | |
439 | Int_t nreadNotEmpty=0; | |
440 | for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){ | |
441 | if (h1->GetBinContent(ientry)==-1) continue; | |
442 | else { | |
443 | if (h1->GetBinContent(ientry)>0) { | |
444 | nreadNotEmpty++; | |
445 | AliDebug(1,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty)); | |
446 | } | |
447 | mean+=h1->GetBinContent(ientry); | |
448 | nread++; | |
449 | } | |
450 | } | |
451 | mean/=nread; | |
452 | AliDebug(1,Form(" nread = %i , mean = %f",nread,mean)); | |
453 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
7fffa85b | 454 | AliTOFChannelOnlineStatus * chSt = (AliTOFChannelOnlineStatus *)fCalStatus->At(ich); |
ee3e792b | 455 | if (h1->GetBinContent(ich+1)==-1) continue; |
456 | AliDebug(1,Form(" channel %i ",ich)); | |
7fffa85b | 457 | AliDebug(1,Form(" channel status before pulser = %i",(Int_t)chSt->GetStatus())); |
ee3e792b | 458 | if (h1->GetBinContent(ich+1)<0.05*mean){ |
7fffa85b | 459 | chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFPulserBad); // bad status for pulser |
460 | AliDebug(1,Form(" channel status after pulser = %i",(Int_t)chSt->GetStatus())); | |
ee3e792b | 461 | } |
462 | else { | |
7fffa85b | 463 | chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFPulserOk); // bad status for pulser |
464 | AliDebug(1,Form(" channel status after pulser = %i",(Int_t)chSt->GetStatus())); | |
ee3e792b | 465 | } |
466 | } | |
467 | ||
468 | daqFile->Close(); | |
469 | delete daqFile; | |
470 | delete h1; | |
471 | } | |
472 | ||
473 | else{ | |
7fffa85b | 474 | Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle "); |
475 | return 10;//return error code for failure in retrieving Ref Data | |
ee3e792b | 476 | } |
477 | ||
478 | } | |
479 | delete listPulser; | |
480 | } | |
7fffa85b | 481 | |
ee3e792b | 482 | else{ |
7fffa85b | 483 | Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle "); |
484 | return 10;//return error code for failure in retrieving Ref Data | |
ee3e792b | 485 | } |
7fffa85b | 486 | |
487 | //storing in OCDB | |
488 | ||
489 | AliCDBMetaData metaData; | |
490 | metaData.SetBeamPeriod(0); | |
491 | metaData.SetResponsible("Chiara Zampolli"); | |
492 | metaData.SetComment("This preprocessor fills a TObjArray object for Pulser data."); | |
493 | AliInfo("Storing Calibration Data from Pulser Run"); | |
494 | resultPulser = Store("Calib","PulserData",fCalStatus, &metaData,0,kTRUE); | |
495 | if(!resultPulser){ | |
496 | Log("Some problems occurred while storing online object resulting from Pulser data processing"); | |
497 | return 11;//return error code for problems in storing Pulser data | |
498 | } | |
499 | ||
ee3e792b | 500 | if(fStoreRefData){ |
501 | ||
502 | AliCDBMetaData metaDataHisto; | |
503 | metaDataHisto.SetBeamPeriod(0); | |
504 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
505 | char comment[200]; | |
506 | sprintf(comment,"This preprocessor stores the result of the pulser run"); | |
507 | metaDataHisto.SetComment(comment); | |
508 | AliInfo("Storing Reference Data"); | |
509 | resultPulserRef = StoreReferenceData("Calib","Pulser",htofPulser, &metaDataHisto); | |
510 | if (!resultPulserRef){ | |
7fffa85b | 511 | Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle"); |
512 | return 9;//return error code for failure in storing Ref Data | |
ee3e792b | 513 | } |
514 | } | |
515 | ||
516 | daqFile=0; | |
517 | ||
518 | return 0; | |
519 | } | |
520 | //_____________________________________________________________________________ | |
521 | ||
522 | UInt_t AliTOFPreprocessor::ProcessNoiseData() | |
523 | { | |
7fffa85b | 524 | |
525 | // Processing Noise Run data for TOF channel status | |
526 | ||
527 | Log("Processing Noise"); | |
ee3e792b | 528 | |
529 | TH1::AddDirectory(0); | |
530 | ||
531 | Bool_t resultNoiseRef=kFALSE; | |
7fffa85b | 532 | Bool_t resultNoise=kFALSE; |
ee3e792b | 533 | |
a174d599 | 534 | static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors(); |
535 | TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5); | |
536 | for (Int_t ibin =1;ibin<=kSize;ibin++){ | |
ee3e792b | 537 | htofNoise->SetBinContent(ibin,-1); |
538 | } | |
539 | ||
7fffa85b | 540 | // retrieving last stored noise object, and copying |
541 | ||
542 | AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Noise"); | |
543 | if (cdbEntry!=0x0){ | |
544 | TObjArray *currentCalStatus = (TObjArray*)cdbEntry->GetObject(); | |
545 | for (Int_t ich = 0; ich<fNChannels; ich ++){ | |
546 | AliTOFChannelOnlineStatus * calChOnlineSt = (AliTOFChannelOnlineStatus*)fCalStatus->At(ich); | |
547 | calChOnlineSt->SetStatus(((AliTOFChannelOnlineStatus*)currentCalStatus->At(ich))->GetStatus()); | |
548 | } | |
549 | } | |
550 | ||
ee3e792b | 551 | // processing noise |
552 | ||
553 | TFile * daqFile=0x0; | |
554 | TH1F * h1=0x0; | |
555 | ||
556 | //retrieving Noise data | |
557 | TList* listNoise = GetFileSources(kDAQ, "NOISE"); | |
5a83e79b | 558 | if (listNoise->GetEntries()!=0) |
ee3e792b | 559 | { |
560 | AliInfo("The following sources produced files with the id NOISE"); | |
561 | listNoise->Print(); | |
562 | for (Int_t jj=0;jj<listNoise->GetEntries();jj++){ | |
563 | TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj)); | |
564 | AliInfo(Form("found source %s", str->String().Data())); | |
565 | // file to be stored run per run | |
566 | TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName()); | |
567 | if (fileNameNoise.Length()>0){ | |
568 | // storing refernce data | |
569 | AliInfo(Form("Got the file %s, now we can store the Reference Data for noise for the current Run.", fileNameNoise.Data())); | |
570 | daqFile = new TFile(fileNameNoise.Data(),"READ"); | |
571 | h1 = (TH1F*) daqFile->Get("hTOFnoise"); | |
a174d599 | 572 | for (Int_t ibin=0;ibin<kSize;ibin++){ |
ee3e792b | 573 | if ((h1->GetBinContent(ibin+1))!=-1){ |
574 | if ((htofNoise->GetBinContent(ibin+1))==-1){ | |
575 | htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)); | |
576 | } | |
577 | else { | |
578 | Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin)); | |
579 | } | |
580 | } | |
581 | } | |
582 | // elaborating infos | |
583 | for (Int_t ich =0;ich<fNChannels;ich++){ | |
7fffa85b | 584 | AliTOFChannelOnlineStatus * chSt = (AliTOFChannelOnlineStatus *)fCalStatus->At(ich); |
ee3e792b | 585 | if (h1->GetBinContent(ich+1)==-1) continue; |
586 | AliDebug(1,Form( " channel %i",ich)); | |
7fffa85b | 587 | AliDebug(1,Form( " channel status before noise = %i",(Int_t)chSt->GetStatus())); |
ee3e792b | 588 | if (h1->GetBinContent(ich+1)>=1){ // setting limit for noise to 1 kHz |
7fffa85b | 589 | chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFNoiseBad); // bad status for noise |
590 | AliDebug(1,Form( " channel status after noise = %i",(Int_t)chSt->GetStatus())); | |
ee3e792b | 591 | } |
592 | else { | |
7fffa85b | 593 | chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFNoiseOk); // bad status for noise |
594 | AliDebug(1,Form(" channel status after noise = %i",(Int_t)chSt->GetStatus())); | |
ee3e792b | 595 | } |
596 | } | |
597 | ||
598 | daqFile->Close(); | |
599 | delete daqFile; | |
7fffa85b | 600 | delete h1; |
601 | ||
ee3e792b | 602 | } |
603 | ||
604 | else{ | |
7fffa85b | 605 | Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle "); |
606 | return 13;//return error code for failure in retrieving Ref Data | |
ee3e792b | 607 | } |
608 | ||
609 | } | |
610 | delete listNoise; | |
611 | } | |
612 | else{ | |
7fffa85b | 613 | Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle "); |
614 | return 13;//return error code for failure in retrieving Ref Data | |
ee3e792b | 615 | } |
616 | ||
617 | daqFile=0; | |
618 | ||
7fffa85b | 619 | //storing in OCDB |
620 | ||
621 | AliCDBMetaData metaData; | |
622 | metaData.SetBeamPeriod(0); | |
623 | metaData.SetResponsible("Chiara Zampolli"); | |
624 | metaData.SetComment("This preprocessor fills a TObjArray object for Noise data."); | |
625 | AliInfo("Storing Calibration Data from Noise Run"); | |
626 | resultNoise = Store("Calib","NoiseData",fCalStatus, &metaData,0,kTRUE); | |
627 | if(!resultNoise){ | |
628 | Log("Some problems occurred while storing online object resulting from Noise data processing"); | |
629 | return 14;//return error code for problems in storing Noise data | |
630 | } | |
631 | ||
ee3e792b | 632 | if(fStoreRefData){ |
633 | ||
634 | AliCDBMetaData metaDataHisto; | |
635 | metaDataHisto.SetBeamPeriod(0); | |
636 | metaDataHisto.SetResponsible("Chiara Zampolli"); | |
637 | char comment[200]; | |
7fffa85b | 638 | sprintf(comment,"This preprocessor stores the result of the noise run, TOF exiting from Shuttle "); |
ee3e792b | 639 | metaDataHisto.SetComment(comment); |
640 | AliInfo("Storing Reference Data"); | |
641 | resultNoiseRef = StoreReferenceData("Calib","Noise",htofNoise, &metaDataHisto); | |
642 | if (!resultNoiseRef){ | |
643 | Log("some problems occurred::No Reference Data for noise stored"); | |
7fffa85b | 644 | return 12;//return error code for failure in storing Ref Data |
ee3e792b | 645 | } |
646 | } | |
647 | ||
648 | return 0; | |
649 | } | |
650 | //_____________________________________________________________________________ | |
651 | ||
7fffa85b | 652 | UInt_t AliTOFPreprocessor::ProcessHWData() |
ee3e792b | 653 | { |
7fffa85b | 654 | // Processing Pulser Run data for TOF channel status |
655 | // dummy for the time being | |
ee3e792b | 656 | |
7fffa85b | 657 | Log("Processing HW"); |
ee3e792b | 658 | |
7fffa85b | 659 | return 0; |
660 | ||
661 | } | |
662 | ||
663 | //_____________________________________________________________________________ | |
664 | ||
665 | UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap) | |
666 | { | |
a174d599 | 667 | // |
668 | // | |
669 | // | |
7fffa85b | 670 | |
671 | TString runType = GetRunType(); | |
672 | Log(Form("RunType %s",runType.Data())); | |
ee3e792b | 673 | |
674 | // processing | |
675 | ||
7fffa85b | 676 | if (runType == "PULSER") { |
677 | Int_t iresultPulser = ProcessPulserData(); | |
678 | return iresultPulser; | |
679 | } | |
ee3e792b | 680 | |
7fffa85b | 681 | if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined |
682 | Int_t iresultNoise = ProcessNoiseData(); | |
683 | return iresultNoise; | |
684 | } | |
685 | ||
686 | if (runType == "PHYSICS") { | |
687 | Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap); | |
688 | if (iresultDCS != 0) { | |
689 | return iresultDCS; | |
690 | } | |
691 | else { | |
692 | Int_t iresultDAQ = ProcessOnlineDelays(); | |
693 | return iresultDAQ; | |
694 | } | |
ee3e792b | 695 | } |
696 | ||
7fffa85b | 697 | // storing |
ee3e792b | 698 | return 0; |
699 | } | |
c9fe8530 | 700 | |
701 |