1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //#include <Riostream.h>
28 #include <TObjArray.h>
29 #include <TObjString.h>
30 #include <TTimeStamp.h>
32 #include "AliCDBMetaData.h"
33 #include "AliCDBEntry.h"
35 #include "AliTOFChannelOnline.h"
36 #include "AliTOFChannelOnlineStatus.h"
37 #include "AliTOFDataDCS.h"
38 #include "AliTOFGeometry.h"
39 #include "AliTOFPreprocessor.h"
40 #include "AliTOFFEEReader.h"
44 //class AliTOFGeometry;
46 // TOF preprocessor class.
47 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
48 // processes them. The result is then written to the CDB.
49 // analogously, it takes data form DAQ (both at Run level and inclusive -
50 // of all the runs - level, processes them, and stores both Reference Data
51 // and Online Calibration files in the CDB.
52 // Processing of Pulser/Noise Run data and of TOF FEE DCS map
56 // return=1 : no DCS input data Map
57 // return=2 : no DCS input data processing
58 // return=3 : no DCS processed data was stored in Ref Data
59 // return=4 : no DAQ input for Ref Data
60 // return=5 : failed to store DAQ Ref Data
61 // return=6 : failed to retrieve DAQ data for calibration
62 // return=7 : problems in processing histos in the input DAQ file
63 // return=8 : failed to store Online Delays
64 // return=9 : failed to store Reference Data for Pulser
65 // return=10: failed to retrieve Pulser data
66 // return=11: failed to store Pulser map in OCDB
67 // return=12: failed to store Reference Data for Noise
68 // return=13: failed to retrieve Noise data
69 // return=14: failed to store Noise map in OCDB
70 // return=15: failed to retrieve FEE data from FXS
71 // return=16: failed to retrieve FEE data from OCDB
72 // return=17: failed to store FEE data in OCDB
73 // return=18: failed to store FEE reference data in OCDB
75 ClassImp(AliTOFPreprocessor)
77 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
78 const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel
79 const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay
81 //_____________________________________________________________________________
83 AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
84 AliPreprocessor("TOF", shuttle),
95 AddRunType("PHYSICS");
101 //_____________________________________________________________________________
103 AliTOFPreprocessor::~AliTOFPreprocessor()
129 //______________________________________________________________________________
130 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
133 // Creates AliTOFDataDCS object
135 AliPreprocessor::Initialize(run, startTime, endTime);
137 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
138 TTimeStamp(startTime).AsString(),
139 TTimeStamp(endTime).AsString()));
141 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
142 fData->SetFDRFlag(fFDRFlag);
144 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
145 fCal = new TObjArray(fNChannels);
147 for (Int_t ich = 0; ich<fNChannels; ich ++){
148 AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
149 fCal->AddAt(calChOnline,ich);
151 fCalStatus = new TObjArray(fNChannels);
152 fCalStatus->SetOwner();
153 for (Int_t ich = 0; ich<fNChannels; ich ++){
154 AliTOFChannelOnlineStatus * calChOnlineStatus = new AliTOFChannelOnlineStatus();
155 fCalStatus->AddAt(calChOnlineStatus,ich);
157 fFEEStatus = new TObjArray(fNChannels);
158 fFEEStatus->SetOwner();
159 for (Int_t ich = 0; ich<fNChannels; ich ++){
160 AliTOFChannelOnlineStatus * calChOnlineStatus = new AliTOFChannelOnlineStatus();
161 fFEEStatus->AddAt(calChOnlineStatus,ich);
164 //_____________________________________________________________________________
165 Bool_t AliTOFPreprocessor::ProcessDCS(){
167 // check whether DCS should be processed or not...
169 TString runType = GetRunType();
170 Log(Form("RunType %s",runType.Data()));
172 if (runType != "PHYSICS"){
178 //_____________________________________________________________________________
180 UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap)
182 // Fills data into a AliTOFDataDCS object
185 Log("Processing DCS DP");
186 TH1::AddDirectory(0);
188 Bool_t resultDCSMap=kFALSE;
189 Bool_t resultDCSStore=kFALSE;
194 Log("No DCS map found: TOF exiting from Shuttle");
195 return 1;// return error Code for DCS input data not found
198 // The processing of the DCS input data is forwarded to AliTOFDataDCS
199 resultDCSMap=fData->ProcessData(*dcsAliasMap);
201 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
202 return 2;// return error Code for processed DCS data not stored
205 AliCDBMetaData metaDataDCS;
206 metaDataDCS.SetBeamPeriod(0);
207 metaDataDCS.SetResponsible("Chiara Zampolli");
208 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
209 AliInfo("Storing DCS Data");
210 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
211 if (!resultDCSStore){
212 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
213 return 3;// return error Code for processed DCS data not stored
221 //_____________________________________________________________________________
223 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
225 // Processing data from DAQ for online calibration
227 Log("Processing DAQ delays");
229 TH1::AddDirectory(0);
231 Bool_t resultDAQRef=kFALSE;
232 Bool_t resultTOFPP=kFALSE;
238 //retrieving data at Run level
239 TList* list = GetFileSources(kDAQ, "RUNLevel");
240 if (list !=0x0 && list->GetEntries()!=0)
242 AliInfo("The following sources produced files with the id RUNLevel");
244 for (Int_t jj=0;jj<list->GetEntries();jj++){
245 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
246 AliInfo(Form("found source %s", str->String().Data()));
247 // file to be stored run per run
248 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
249 if (fileNameRun.Length()>0){
250 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
251 daqFile = new TFile(fileNameRun.Data(),"READ");
252 fh2 = (TH2S*) daqFile->Get("htof");
253 AliCDBMetaData metaDataHisto;
254 metaDataHisto.SetBeamPeriod(0);
255 metaDataHisto.SetResponsible("Chiara Zampolli");
256 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
257 AliInfo("Storing Reference Data");
258 resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto);
260 Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
261 return 5;//return error code for failure in storing Ref Data
268 Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
269 return 4;//return error code for failure in retrieving Ref Data
275 Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
276 return 4;//return error code for failure in retrieving Ref Data
281 //Total files, with cumulative histos
283 TList* listTot = GetFileSources(kDAQ, "DELAYS");
284 if (listTot !=0x0 && listTot->GetEntries()!=0)
286 AliInfo("The following sources produced files with the id DELAYS");
288 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
289 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
290 AliInfo(Form("found source %s", str->String().Data()));
292 // file with summed histos, to extract calib params
293 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
294 if (fileName.Length()>0){
295 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
297 daqFile = new TFile(fileName.Data(),"READ");
299 fh2 = (TH2S*) daqFile->Get("htoftot");
301 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
303 return 7; //return error code for histograms not existing/junky
306 static const Int_t kSize=fh2->GetNbinsX();
307 static const Int_t kNBins=fh2->GetNbinsY();
308 static const Double_t kXBinmin=fh2->GetYaxis()->GetBinLowEdge(1);
309 if (kSize != fNChannels){
310 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
312 return 7; //return error code for histograms not existing/junky
314 Int_t nNotStatistics = 0; // number of channel with not enough statistics
315 for (Int_t ich=0;ich<kSize;ich++){
316 /* check whether channel has been read out during current run.
317 * if the status is bad it means it has not been read out.
318 * in this case skip channel in order to not affect the mean */
319 if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ich))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad){
320 AliDebug(2,Form(" Channel %i found bad according to FEEmap, skipping from delay computing",ich));
323 AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
324 TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
325 for (Int_t ibin=0;ibin<kNBins;ibin++){
326 h1->SetBinContent(ibin+1,fh2->GetBinContent(ich+1,ibin+1));
328 if(h1->Integral()<fgkIntegralThr) {
330 if (!fFDRFlag) Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
335 if (!fFDRFlag) { // not computing delays if in FDR runs
337 Float_t minContent=h1->Integral()*fgkThrPar;
338 Int_t nbinsX = h1->GetNbinsX();
340 for (Int_t j=1; j<=nbinsX; j++){
342 h1->GetBinContent(j) +
343 h1->GetBinContent(j+1)+
344 h1->GetBinContent(j+2)+
345 h1->GetBinContent(j+3))>minContent){
351 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
352 // Now calculate the mean over the interval.
356 for(Int_t k=0;k<fgkBinRangeAve;k++){
357 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
358 nent=nent+h1->GetBinContent(startBin+k);
359 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
361 mean= mean/nent; //<x>
362 sumw2=sumw2/nent; //<x^2>
364 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
365 if (ich<fNChannels) {
366 AliTOFChannelOnline * ch = (AliTOFChannelOnline *)fCal->At(ich);
367 ch->SetDelay((Double_t)mean*AliTOFGeometry::TdcBinWidth()*1.E-3); // delay in ns
368 // ch->SetStatus(1); // calibrated channel, removed for the time being from AliTOFChannelOnline
374 if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
380 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
381 return 6;//return error code for problems in retrieving DAQ data
387 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
388 return 6; //return error code for problems in retrieving DAQ data
392 AliCDBMetaData metaData;
393 metaData.SetBeamPeriod(0);
394 metaData.SetResponsible("Chiara Zampolli");
395 metaData.SetComment("This preprocessor fills a TObjArray object.");
396 AliInfo("Storing Calibration Data");
397 resultTOFPP = Store("Calib","ParOnline",fCal, &metaData,0,kTRUE);
399 Log("Some problems occurred while storing online object resulting from DAQ data processing");
400 return 8;//return error code for problems in storing DAQ data
405 //_____________________________________________________________________________
407 UInt_t AliTOFPreprocessor::ProcessPulserData()
409 // Processing Pulser Run data for TOF channel status
411 Log("Processing Pulser");
413 TH1::AddDirectory(0);
415 Bool_t resultPulserRef=kFALSE;
416 Bool_t resultPulser=kFALSE;
418 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
419 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
420 for (Int_t ibin =1;ibin<=kSize;ibin++){
421 htofPulser->SetBinContent(ibin,-1);
424 // retrieving last stored pulser object, and copying
426 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Pulser");
428 TObjArray *currentCalStatus = (TObjArray*)cdbEntry->GetObject();
429 for (Int_t ich = 0; ich<fNChannels; ich ++){
430 AliTOFChannelOnlineStatus * calChOnlineSt = (AliTOFChannelOnlineStatus*)fCalStatus->At(ich);
431 calChOnlineSt->SetStatus(((AliTOFChannelOnlineStatus*)currentCalStatus->At(ich))->GetStatus());
440 //retrieving Pulser data
441 TList* listPulser = GetFileSources(kDAQ, "PULSER");
442 if (listPulser !=0x0 && listPulser->GetEntries()!=0)
444 AliInfo("The following sources produced files with the id PULSER");
446 for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
447 TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
448 AliInfo(Form("found source %s", str->String().Data()));
449 // file to be stored run per run
450 TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
451 if (fileNamePulser.Length()>0){
452 // storing refernce data
453 AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
454 daqFile = new TFile(fileNamePulser.Data(),"READ");
455 h1 = (TH1S*) daqFile->Get("hTOFpulser");
456 for (Int_t ibin=0;ibin<kSize;ibin++){
457 if ((h1->GetBinContent(ibin+1))!=-1){
458 if ((htofPulser->GetBinContent(ibin+1))==-1){
459 htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
462 Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
470 Int_t nreadNotEmpty=0;
471 for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
473 /* check whether channel has been read out during current run.
474 * if the status is bad it means it has not been read out.
475 * in this case skip channel in order to not affect the mean */
476 if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ientry-1))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
479 if (h1->GetBinContent(ientry)==-1) continue;
481 if (h1->GetBinContent(ientry)>0) {
483 AliDebug(1,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
485 mean+=h1->GetBinContent(ientry);
491 AliDebug(1,Form(" nread = %i , mean = %f",nread,mean));
492 for (Int_t ich =0;ich<fNChannels;ich++){
493 AliTOFChannelOnlineStatus * chSt = (AliTOFChannelOnlineStatus *)fCalStatus->At(ich);
494 if (h1->GetBinContent(ich+1)==-1) continue;
495 AliDebug(1,Form(" channel %i ",ich));
496 AliDebug(1,Form(" channel status before pulser = %i",(Int_t)chSt->GetStatus()));
498 /* check whether channel has been read out during current run.
499 * if the status is bad it means it has not been read out.
500 * in this case skip channel in order to leave its status
502 if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ich))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
505 if (h1->GetBinContent(ich+1)<0.05*mean){
506 chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFPulserBad); // bad status for pulser
507 AliDebug(1,Form(" channel status after pulser = %i",(Int_t)chSt->GetStatus()));
510 chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFPulserOk); // bad status for pulser
511 AliDebug(1,Form(" channel status after pulser = %i",(Int_t)chSt->GetStatus()));
516 Log("No channels read!! No action taken, keeping old status");
525 Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle ");
526 return 10;//return error code for failure in retrieving Ref Data
534 Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle ");
535 return 10;//return error code for failure in retrieving Ref Data
540 AliCDBMetaData metaData;
541 metaData.SetBeamPeriod(0);
542 metaData.SetResponsible("Chiara Zampolli");
543 metaData.SetComment("This preprocessor fills a TObjArray object for Pulser data.");
544 AliInfo("Storing Calibration Data from Pulser Run");
545 resultPulser = Store("Calib","Pulser",fCalStatus, &metaData,0,kTRUE);
547 Log("Some problems occurred while storing online object resulting from Pulser data processing");
548 return 11;//return error code for problems in storing Pulser data
553 AliCDBMetaData metaDataHisto;
554 metaDataHisto.SetBeamPeriod(0);
555 metaDataHisto.SetResponsible("Chiara Zampolli");
557 sprintf(comment,"This preprocessor stores the result of the pulser run");
558 metaDataHisto.SetComment(comment);
559 AliInfo("Storing Reference Data");
560 resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
561 if (!resultPulserRef){
562 Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
563 return 9;//return error code for failure in storing Ref Data
571 //_____________________________________________________________________________
573 UInt_t AliTOFPreprocessor::ProcessNoiseData()
576 // Processing Noise Run data for TOF channel status
578 Log("Processing Noise");
580 TH1::AddDirectory(0);
582 Bool_t resultNoiseRef=kFALSE;
583 Bool_t resultNoise=kFALSE;
585 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
586 TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
587 for (Int_t ibin =1;ibin<=kSize;ibin++){
588 htofNoise->SetBinContent(ibin,-1);
591 // retrieving last stored noise object, and copying
593 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Noise");
595 TObjArray *currentCalStatus = (TObjArray*)cdbEntry->GetObject();
596 for (Int_t ich = 0; ich<fNChannels; ich ++){
597 AliTOFChannelOnlineStatus * calChOnlineSt = (AliTOFChannelOnlineStatus*)fCalStatus->At(ich);
598 calChOnlineSt->SetStatus(((AliTOFChannelOnlineStatus*)currentCalStatus->At(ich))->GetStatus());
607 //retrieving Noise data
608 TList* listNoise = GetFileSources(kDAQ, "NOISE");
609 if (listNoise !=0x0 && listNoise->GetEntries()!=0)
611 AliInfo("The following sources produced files with the id NOISE");
613 for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
614 TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
615 AliInfo(Form("found source %s", str->String().Data()));
616 // file to be stored run per run
617 TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
618 if (fileNameNoise.Length()>0){
619 // storing refernce data
620 AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
621 daqFile = new TFile(fileNameNoise.Data(),"READ");
622 h1 = (TH1F*) daqFile->Get("hTOFnoise");
623 for (Int_t ibin=0;ibin<kSize;ibin++){
624 if ((h1->GetBinContent(ibin+1))!=-1){
625 if ((htofNoise->GetBinContent(ibin+1))==-1){
626 htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
629 Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
634 for (Int_t ich =0;ich<fNChannels;ich++){
635 AliTOFChannelOnlineStatus * chSt = (AliTOFChannelOnlineStatus *)fCalStatus->At(ich);
636 if (h1->GetBinContent(ich+1)==-1) continue;
637 AliDebug(1,Form( " channel %i",ich));
638 AliDebug(1,Form( " channel status before noise = %i",(Int_t)chSt->GetStatus()));
640 /* check whether channel has been read out during current run.
641 * if the status is bad it means it has not been read out.
642 * in this case skip channel in order to leave its status
644 if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ich))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
647 if (h1->GetBinContent(ich+1)>=1){ // setting limit for noise to 1 kHz
648 chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFNoiseBad); // bad status for noise
649 AliDebug(1,Form( " channel status after noise = %i",(Int_t)chSt->GetStatus()));
652 chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFNoiseOk); // bad status for noise
653 AliDebug(1,Form(" channel status after noise = %i",(Int_t)chSt->GetStatus()));
664 Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle ");
665 return 13;//return error code for failure in retrieving Ref Data
672 Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle ");
673 return 13;//return error code for failure in retrieving Ref Data
680 AliCDBMetaData metaData;
681 metaData.SetBeamPeriod(0);
682 metaData.SetResponsible("Chiara Zampolli");
683 metaData.SetComment("This preprocessor fills a TObjArray object for Noise data.");
684 AliInfo("Storing Calibration Data from Noise Run");
685 resultNoise = Store("Calib","Noise",fCalStatus, &metaData,0,kTRUE);
687 Log("Some problems occurred while storing online object resulting from Noise data processing");
688 return 14;//return error code for problems in storing Noise data
693 AliCDBMetaData metaDataHisto;
694 metaDataHisto.SetBeamPeriod(0);
695 metaDataHisto.SetResponsible("Chiara Zampolli");
697 sprintf(comment,"This preprocessor stores the result of the noise run, TOF exiting from Shuttle ");
698 metaDataHisto.SetComment(comment);
699 AliInfo("Storing Reference Data");
700 resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
701 if (!resultNoiseRef){
702 Log("some problems occurred::No Reference Data for noise stored");
703 return 12;//return error code for failure in storing Ref Data
709 //_____________________________________________________________________________
711 UInt_t AliTOFPreprocessor::ProcessFEEData()
713 // Processing Pulser Run data for TOF channel status
714 // dummy for the time being
716 Log("Processing FEE");
718 Bool_t updateOCDB = kFALSE;
719 AliTOFFEEReader feeReader;
720 AliTOFChannelOnlineStatus *currentChannel = NULL, *storedChannel = NULL;
721 TObjArray *currentFEE = fFEEStatus;
723 TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
725 /* load current TOF FEE config from DCS FXS, parse,
726 * fill current FEE histogram and set FEE status */
728 const char * nameFile = GetFile(kDCS,"TofFeeMap","");
729 AliInfo(Form("nameFile = %s",nameFile));
730 if (nameFile == NULL) {
733 feeReader.LoadFEEConfig(nameFile);
734 feeReader.ParseFEEConfig();
735 /* loop over channels */
736 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++) {
737 currentChannel = (AliTOFChannelOnlineStatus *)currentFEE->At(iChannel);
740 /* channel enabled. set FEE channel status ok */
741 if (feeReader.IsChannelEnabled(iChannel)) {
742 currentChannel->SetStatus(AliTOFChannelOnlineStatus::kTOFHWOk);
743 hCurrentFEE.SetBinContent(iChannel + 1, 1);
745 /* channel disabled. set FEE channel status bad */
747 currentChannel->SetStatus(AliTOFChannelOnlineStatus::kTOFHWBad);
751 /* load stored TOF FEE from OCDB and compare it with current FEE.
752 * if stored FEE is different from current FEE set update flag.
753 * if there is no stored FEE in OCDB set update flag */
755 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","FEE");
756 /* no CDB entry found. set update flag */
757 if (cdbEntry == NULL) {
760 /* CDB entry OK. loop over channels */
762 TObjArray *storedFEE = (TObjArray *)cdbEntry->GetObject();
763 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
764 currentChannel = (AliTOFChannelOnlineStatus *)currentFEE->At(iChannel);
765 storedChannel = (AliTOFChannelOnlineStatus *)storedFEE->At(iChannel);
766 /* compare current FEE channel status with stored one
767 * if different set update flag and break loop */
768 if (currentChannel->GetStatus() != storedChannel->GetStatus()) {
775 /* check whether we don't have to store reference data.
776 * in this case we return without errors. */
778 /* store reference data */
779 AliCDBMetaData metaDataHisto;
780 metaDataHisto.SetBeamPeriod(0);
781 metaDataHisto.SetResponsible("Roberto Preghenella");
782 metaDataHisto.SetComment("This preprocessor stores the FEE referece data of the current run.");
783 AliInfo("Storing FEE reference data");
784 /* store FEE reference data */
785 if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
787 Log("problems while storing FEE reference data");
788 return 18; /* error return code for problems while storing FEE reference data */
792 /* check whether we don't need to update OCDB.
793 * in this case we can return without errors and
794 * the current FEE is stored in the fFEEStatus TObjArray. */
796 AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
797 return 0; /* return ok */
800 /* update the OCDB with the current FEE since even
801 * a little difference has been detected. */
803 AliCDBMetaData metaData;
804 metaData.SetBeamPeriod(0);
805 metaData.SetResponsible("Roberto Preghenella");
806 metaData.SetComment("This preprocessor fills a TObjArray object for FEE data.");
807 AliInfo("Storing FEE data from current run");
809 if (!Store("Calib", "FEE", fFEEStatus, &metaData, 0, kTRUE)) {
811 Log("problems while storing FEE data object");
812 return 17; /* return error code for problems while storing FEE data */
815 /* everything fine. return */
821 //_____________________________________________________________________________
823 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
829 TString runType = GetRunType();
830 Log(Form("RunType %s",runType.Data()));
834 /* always process FEE data */
835 Int_t iresultFEE = ProcessFEEData();
839 if (runType == "PULSER") {
840 Int_t iresultPulser = ProcessPulserData();
841 return iresultPulser;
844 if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined
845 Int_t iresultNoise = ProcessNoiseData();
849 if (runType == "PHYSICS") {
850 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
851 if (iresultDCS != 0) {
855 Int_t iresultDAQ = ProcessOnlineDelays();