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>
25 #include <TObjArray.h>
26 #include <TObjString.h>
27 #include <TTimeStamp.h>
29 #include "AliCDBMetaData.h"
30 #include "AliCDBEntry.h"
32 #include "AliTOFChannelOnlineArray.h"
33 #include "AliTOFChannelOnlineStatusArray.h"
34 #include "AliTOFDataDCS.h"
35 #include "AliTOFGeometry.h"
36 #include "AliTOFPreprocessor.h"
37 #include "AliTOFFEEReader.h"
38 #include "AliTOFRawStream.h"
39 #include "AliTOFCableLengthMap.h"
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.
45 // Analogously, it takes data form DAQ (both at Run level and inclusive -
46 // of all the runs - level, processes them, and stores both Reference Data
47 // and Online Calibration files in the CDB.
48 // Processing of Pulser/Noise Run data and of TOF FEE DCS map included also.
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
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
70 // return=20: failed in retrieving status variable
72 ClassImp(AliTOFPreprocessor)
74 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
75 const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel
76 const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay
78 //_____________________________________________________________________________
80 AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
81 AliPreprocessor("TOF", shuttle),
90 AddRunType("PHYSICS");
96 //_____________________________________________________________________________
98 AliTOFPreprocessor::~AliTOFPreprocessor()
103 //______________________________________________________________________________
104 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
107 // Creates AliTOFDataDCS object
109 AliPreprocessor::Initialize(run, startTime, endTime);
111 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run,
112 TTimeStamp(startTime).AsString(),
113 TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
115 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
116 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
118 //_____________________________________________________________________________
119 Bool_t AliTOFPreprocessor::ProcessDCS(){
121 // check whether DCS should be processed or not...
123 TString runType = GetRunType();
124 Log(Form("RunType %s",runType.Data()));
126 if (runType != "PHYSICS"){
132 //_____________________________________________________________________________
134 UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap)
136 // Fills data into a AliTOFDataDCS object
139 Log("Processing DCS DP");
140 TH1::AddDirectory(0);
142 Bool_t resultDCSMap=kFALSE;
143 Bool_t resultDCSStore=kFALSE;
147 fData->SetFDRFlag(fFDRFlag);
150 Log("No DCS map found: TOF exiting from Shuttle");
155 return 1;// return error Code for DCS input data not found
159 // The processing of the DCS input data is forwarded to AliTOFDataDCS
160 resultDCSMap=fData->ProcessData(*dcsAliasMap);
162 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
167 return 2;// return error Code for processed DCS data not stored
170 AliCDBMetaData metaDataDCS;
171 metaDataDCS.SetBeamPeriod(0);
172 metaDataDCS.SetResponsible("Chiara Zampolli");
173 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
174 AliInfo("Storing DCS Data");
175 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
176 if (!resultDCSStore){
177 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
182 return 3;// return error Code for processed DCS data not stored
195 //_____________________________________________________________________________
197 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
199 // Processing data from DAQ for online calibration
201 Log("Processing DAQ delays");
203 // reading configuration map
204 TString compDelays = "kFALSE";
205 Int_t deltaStartingRun = fRun;
206 Int_t startingRun = fRun-deltaStartingRun;
207 Int_t binRangeAve = fgkBinRangeAve;
208 Double_t integralThr = fgkIntegralThr;
209 Double_t thrPar = fgkThrPar;
211 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config");
213 Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
216 TMap *configMap = (TMap*)cdbEntry->GetObject();
218 Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
221 TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays");
223 compDelays = (TString) strDelays->GetString();
226 Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data()));
228 TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun");
230 TString tmpstr = strRun->GetString();
231 startingRun = tmpstr.Atoi();
232 deltaStartingRun = fRun - startingRun;
235 Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun));
237 TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve");
238 if (strBinRangeAve) {
239 TString tmpstr = strBinRangeAve->GetString();
240 binRangeAve = tmpstr.Atoi();
243 Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve));
245 TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr");
246 if (strIntegralThr) {
247 TString tmpstr = strIntegralThr->GetString();
248 integralThr = tmpstr.Atof();
251 Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
253 TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
255 TString tmpstr = strThrPar->GetString();
256 thrPar = tmpstr.Atof();
259 Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
263 if (compDelays == "kTRUE") fFDRFlag = kFALSE;
264 else fFDRFlag = kTRUE;
269 Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
271 fCal = new AliTOFChannelOnlineArray(fNChannels);
273 TH1::AddDirectory(0);
275 Bool_t resultDAQRef=kFALSE;
276 Bool_t resultTOFPP=kFALSE;
283 //retrieving data at Run level
284 TList* list = GetFileSources(kDAQ, "RUNLevel");
285 if (list !=0x0 && list->GetEntries()!=0)
287 AliInfo("The following sources produced files with the id RUNLevel");
289 for (Int_t jj=0;jj<list->GetEntries();jj++){
290 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
291 AliInfo(Form("found source %s", str->String().Data()));
292 // file to be stored run per run
293 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
294 if (fileNameRun.Length()>0){
295 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
296 daqFile = new TFile(fileNameRun.Data(),"READ");
297 h2 = (TH2S*) daqFile->Get("htof");
298 AliCDBMetaData metaDataHisto;
299 metaDataHisto.SetBeamPeriod(0);
300 metaDataHisto.SetResponsible("Chiara Zampolli");
301 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
302 AliInfo("Storing Reference Data");
303 resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto);
305 Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
310 return 5;//return error code for failure in storing Ref Data
317 Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
321 return 4;//return error code for failure in retrieving Ref Data
327 Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
330 return 4;//return error code for failure in retrieving Ref Data
335 //Total files, with cumulative histos
337 TList* listTot = GetFileSources(kDAQ, "DELAYS");
338 if (listTot !=0x0 && listTot->GetEntries()!=0)
340 AliInfo("The following sources produced files with the id DELAYS");
342 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
343 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
344 AliInfo(Form("found source %s", str->String().Data()));
346 // file with summed histos, to extract calib params
347 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
348 if (fileName.Length()>0){
349 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
351 daqFile = new TFile(fileName.Data(),"READ");
353 h2 = (TH2S*) daqFile->Get("htoftot");
355 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
360 return 7; //return error code for histograms not existing/junky
363 static const Int_t kSize=h2->GetNbinsX();
364 static const Int_t kNBins=h2->GetNbinsY();
365 static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
366 if (kSize != fNChannels){
367 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
373 return 7; //return error code for histograms not existing/junky
375 Int_t nNotStatistics = 0; // number of channel with not enough statistics
377 /* FDR flag set. do not compute delays, use nominal cable delays */
380 Log(" Not computing delays according to flag set in Config entry in OCDB!");
381 Log(" Using nominal cable delays.");
383 AliTOFRawStream tofrs;
384 Int_t det[5], dummy, index;
385 Float_t cableTimeShift;
387 /* loop over EO indeces */
388 for (Int_t iddl = 0; iddl < 72; iddl++)
389 for (Int_t islot = 3; islot <= 12; islot++)
390 for (Int_t ichain = 0; ichain < 2; ichain++)
391 for (Int_t itdc = 0; itdc < 15; itdc++)
392 for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
395 tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
397 /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
403 if (det[0] < 0 || det[0] > 17 ||
404 det[1] < 0 || det[1] > 4 ||
405 det[2] < 0 || det[2] > 18 ||
406 det[3] < 0 || det[3] > 1 ||
407 det[4] < 0 || det[4] > 47)
410 /* get channel index */
411 index = AliTOFGeometry::GetIndex(det);
413 /* get cable time shift */
414 cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
417 if (index<fNChannels) {
418 fCal->SetDelay(index,cableTimeShift); // delay in ns
419 AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
422 } /* loop over EO indeces */
425 else { // computing delays if not in FDR runs
426 for (Int_t ich=0;ich<kSize;ich++){
427 /* check whether channel has been read out during current run.
428 * if the status is bad it means it has not been read out.
429 * in this case skip channel in order to not affect the mean */
430 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
431 AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
434 AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
435 TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
436 for (Int_t ibin=0;ibin<kNBins;ibin++){
437 h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
439 if(h1->Integral()<integralThr) {
441 Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
447 Float_t minContent=h1->Integral()*thrPar;
448 Int_t nbinsX = h1->GetNbinsX();
450 for (Int_t j=1; j<=nbinsX; j++){
452 h1->GetBinContent(j) +
453 h1->GetBinContent(j+1)+
454 h1->GetBinContent(j+2)+
455 h1->GetBinContent(j+3))>minContent){
461 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
462 // Now calculate the mean over the interval.
466 for(Int_t k=0;k<binRangeAve;k++){
467 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
468 nent=nent+h1->GetBinContent(startBin+k);
469 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
471 mean= mean/nent; //<x>
472 sumw2=sumw2/nent; //<x^2>
474 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
475 if (ich<fNChannels) {
476 Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
477 fCal->SetDelay(ich,delay); // delay in ns
478 AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
484 if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
491 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
495 return 6;//return error code for problems in retrieving DAQ data
501 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
504 return 6; //return error code for problems in retrieving DAQ data
508 AliCDBMetaData metaData;
509 metaData.SetBeamPeriod(0);
510 metaData.SetResponsible("Chiara Zampolli");
511 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays.");
512 AliInfo("Storing Calibration Data");
513 resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE);
515 Log("Some problems occurred while storing online object resulting from DAQ data processing");
518 return 8;//return error code for problems in storing DAQ data
528 //_____________________________________________________________________________
530 UInt_t AliTOFPreprocessor::ProcessPulserData()
532 // Processing Pulser Run data for TOF channel status
534 Log("Processing Pulser");
537 AliError("No valid fStatus found, some errors must have occurred!!");
541 TH1::AddDirectory(0);
543 Bool_t resultPulserRef=kFALSE;
544 Bool_t resultPulser=kFALSE;
546 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
547 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
548 for (Int_t ibin =1;ibin<=kSize;ibin++){
549 htofPulser->SetBinContent(ibin,-1);
557 //retrieving Pulser data
558 TList* listPulser = GetFileSources(kDAQ, "PULSER");
559 if (listPulser !=0x0 && listPulser->GetEntries()!=0)
561 AliInfo("The following sources produced files with the id PULSER");
564 for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
565 Int_t nPulserSource = 0;
566 TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
567 AliInfo(Form("found source %s", str->String().Data()));
568 // file to be stored run per run
569 TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
570 if (fileNamePulser.Length()>0){
571 // storing refernce data
572 AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
573 daqFile = new TFile(fileNamePulser.Data(),"READ");
574 h1 = (TH1S*) daqFile->Get("hTOFpulser");
575 for (Int_t ibin=0;ibin<kSize;ibin++){
576 if ((h1->GetBinContent(ibin+1))!=-1){
577 if ((htofPulser->GetBinContent(ibin+1))==-1){
578 htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
581 Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
589 Int_t nreadNotEmpty=0;
590 for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
592 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)));
593 /* check whether channel has been read out during current run.
594 * if the status is bad it means it has not been read out.
595 * in this case skip channel in order to not affect the mean */
596 if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
600 if (h1->GetBinContent(ientry)==-1) continue;
602 if (h1->GetBinContent(ientry)>0) {
604 AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
606 mean+=h1->GetBinContent(ientry);
612 AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean));
613 for (Int_t ich =0;ich<fNChannels;ich++){
614 if (h1->GetBinContent(ich+1)==-1) continue;
615 AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich)));
617 /* check whether channel has been read out during current run.
618 * if the status is bad it means it has not been read out.
619 * in this case skip channel in order to leave its status
621 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
624 if (h1->GetBinContent(ich+1)<0.05*mean){
625 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser
626 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)));
629 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser
630 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)));
635 Log("No channels read!! No action taken, keeping old status");
644 Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle ");
652 return 10;//return error code for failure in retrieving Ref Data
654 AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource));
656 AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser));
661 Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle ");
668 return 10;//return error code for failure in retrieving Ref Data
673 AliCDBMetaData metaData;
674 metaData.SetBeamPeriod(0);
675 metaData.SetResponsible("Chiara Zampolli");
676 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run.");
677 AliInfo("Storing Calibration Data from Pulser Run");
678 resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
680 Log("Some problems occurred while storing online object resulting from Pulser data processing");
687 return 11;//return error code for problems in storing Pulser data
692 AliCDBMetaData metaDataHisto;
693 metaDataHisto.SetBeamPeriod(0);
694 metaDataHisto.SetResponsible("Chiara Zampolli");
696 sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
697 metaDataHisto.SetComment(comment);
698 AliInfo("Storing Reference Data");
699 resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
700 if (!resultPulserRef){
701 Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
708 return 9;//return error code for failure in storing Ref Data
724 //_____________________________________________________________________________
726 UInt_t AliTOFPreprocessor::ProcessNoiseData()
729 // Processing Noise Run data for TOF channel status
731 Log("Processing Noise");
734 AliError("No valid fStatus found, some errors must have occurred!!");
738 TH1::AddDirectory(0);
740 Bool_t resultNoiseRef=kFALSE;
741 Bool_t resultNoise=kFALSE;
743 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
744 TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5);
745 for (Int_t ibin =1;ibin<=kSize;ibin++){
746 htofNoise->SetBinContent(ibin,-1);
754 //retrieving Noise data
755 TList* listNoise = GetFileSources(kDAQ, "NOISE");
756 if (listNoise !=0x0 && listNoise->GetEntries()!=0)
758 AliInfo("The following sources produced files with the id NOISE");
761 for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
762 Int_t nNoiseSource = 0;
763 TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
764 AliInfo(Form("found source %s", str->String().Data()));
765 // file to be stored run per run
766 TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
767 if (fileNameNoise.Length()>0){
768 // storing reference data
769 AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
770 daqFile = new TFile(fileNameNoise.Data(),"READ");
771 h1 = (TH1F*) daqFile->Get("hTOFnoise");
772 for (Int_t ibin=0;ibin<kSize;ibin++){
773 if ((h1->GetBinContent(ibin+1))!=-1){
774 if ((htofNoise->GetBinContent(ibin+1))==-1){
775 htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
778 Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
783 for (Int_t ich =0;ich<fNChannels;ich++){
784 if (h1->GetBinContent(ich+1)==-1) continue;
785 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)));
786 //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
788 /* check whether channel has been read out during current run.
789 * if the status is bad it means it has not been read out.
790 * in this case skip channel in order to leave its status
792 if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
797 if (h1->GetBinContent(ich+1)>=1){ // setting limit for noise to 1 kHz
798 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
799 AliDebug(2,Form( " channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
802 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
803 AliDebug(2,Form(" channel %i noise status after noise = %i, with global status = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich),(Int_t)fStatus->GetStatus(ich)));
814 Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle ");
822 return 13;//return error code for failure in retrieving Ref Data
825 AliDebug(2,Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
827 AliDebug(2,Form(" Number of channels processed during noise run = %i",nNoise));
831 Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle ");
838 return 13;//return error code for failure in retrieving Ref Data
845 AliCDBMetaData metaData;
846 metaData.SetBeamPeriod(0);
847 metaData.SetResponsible("Chiara Zampolli");
848 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run.");
849 AliInfo("Storing Calibration Data from Noise Run");
850 resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
852 Log("Some problems occurred while storing online object resulting from Noise data processing");
859 return 14;//return error code for problems in storing Noise data
864 AliCDBMetaData metaDataHisto;
865 metaDataHisto.SetBeamPeriod(0);
866 metaDataHisto.SetResponsible("Chiara Zampolli");
868 sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
869 metaDataHisto.SetComment(comment);
870 AliInfo("Storing Reference Data");
871 resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
872 if (!resultNoiseRef){
873 Log("some problems occurred::No Reference Data for noise stored");
880 return 12;//return error code for failure in storing Ref Data
894 //_____________________________________________________________________________
896 UInt_t AliTOFPreprocessor::ProcessFEEData()
898 // Processing Pulser Run data for TOF channel status
899 // dummy for the time being
901 Log("Processing FEE");
903 Bool_t updateOCDB = kFALSE;
904 AliTOFFEEReader feeReader;
906 TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
908 /* load current TOF FEE config from DCS FXS, parse,
909 * fill current FEE histogram and set FEE status */
911 const char * nameFile = GetFile(kDCS,"TofFeeMap","");
912 AliInfo(Form("nameFile = %s",nameFile));
913 if (nameFile == NULL) {
916 feeReader.LoadFEEConfig(nameFile);
917 Int_t parseFee = feeReader.ParseFEEConfig();
918 AliDebug(2,Form("%i enabled channels found in FEE configuration",parseFee));
919 /* load stored TOF FEE from OCDB and compare it with current FEE.
920 * if stored FEE is different from current FEE set update flag.
921 * if there is no stored FEE in OCDB set update flag */
923 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
925 /* no CDB entry found. set update flag */
926 Log(" ************ WARNING ************");
927 Log("No CDB Status entry found, creating a new one!");
928 Log(" *********************************");
929 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
933 if (cdbEntry) cdbEntry->SetOwner(kFALSE);
934 /* CDB entry OK. loop over channels */
935 fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
939 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
940 //AliDebug(2,Form("********** channel %i",iChannel));
941 /* compare current FEE channel status with stored one
942 * if different set update flag and break loop */
943 //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
944 if (feeReader.IsChannelEnabled(iChannel)) {
945 hCurrentFEE.SetBinContent(iChannel + 1, 1);
946 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
948 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
949 AliDebug(2,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
953 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
955 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
956 AliDebug(2,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
962 /* check whether we don't have to store reference data.
963 * in this case we return without errors. */
965 /* store reference data */
966 AliCDBMetaData metaDataHisto;
967 metaDataHisto.SetBeamPeriod(0);
968 metaDataHisto.SetResponsible("Roberto Preghenella");
969 metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
970 AliInfo("Storing FEE reference data");
971 /* store FEE reference data */
972 if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
974 Log("problems while storing FEE reference data");
979 return 18; /* error return code for problems while storing FEE reference data */
983 /* check whether we don't need to update OCDB.
984 * in this case we can return without errors and
985 * the current FEE is stored in the fStatus object. */
987 AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
988 return 0; /* return ok */
991 TString runType = GetRunType();
992 if (runType != "PHYSICS") {
993 AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
994 return 0; /* return ok */
997 /* update the OCDB with the current FEE since even
998 * a little difference has been detected. */
1000 AliCDBMetaData metaData;
1001 metaData.SetBeamPeriod(0);
1002 metaData.SetResponsible("Roberto Preghenella");
1003 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE data.");
1004 AliInfo("Storing Status data from current run after FEE parsing");
1005 /* store FEE data */
1006 if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
1008 Log("problems while storing FEE data object");
1013 return 17; /* return error code for problems while storing FEE data */
1016 /* everything fine. return */
1027 //_____________________________________________________________________________
1029 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
1035 TString runType = GetRunType();
1036 Log(Form("RunType %s",runType.Data()));
1040 /* always process FEE data */
1041 Int_t iresultFEE = ProcessFEEData();
1042 if (iresultFEE != 0)
1045 if (runType == "PULSER") {
1046 Int_t iresultPulser = ProcessPulserData();
1047 return iresultPulser;
1050 if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined
1051 Int_t iresultNoise = ProcessNoiseData();
1052 return iresultNoise;
1055 if (runType == "PHYSICS") {
1056 Int_t iresultDAQ = ProcessOnlineDelays();
1057 if (iresultDAQ != 0) {
1061 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);