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