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 **************************************************************************/
19 //#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 "AliTOFChannelOnlineArray.h"
36 #include "AliTOFChannelOnlineStatusArray.h"
37 #include "AliTOFDataDCS.h"
38 #include "AliTOFLvHvDataPoints.h"
39 #include "AliTOFGeometry.h"
40 #include "AliTOFPreprocessor.h"
41 #include "AliTOFFEEReader.h"
42 #include "AliTOFRawStream.h"
43 #include "AliTOFCableLengthMap.h"
44 #include "AliTOFcalibHisto.h"
45 #include "AliTOFFEEDump.h"
47 #include "AliTOFDeltaBCOffset.h"
48 #include "AliTOFCTPLatency.h"
49 #include "AliTOFT0Fill.h"
50 #include "AliTOFT0FillOnlineCalib.h"
51 #include "AliTOFHitField.h"
52 #include "AliTOFChannelOffline.h"
54 #include "TGeoManager.h"
55 #include "AliGeomManager.h"
57 // TOF preprocessor class.
58 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
59 // processes them. The result is then written to the CDB.
60 // Analogously, it takes data form DAQ (both at Run level and inclusive -
61 // of all the runs - level, processes them, and stores both Reference Data
62 // and Online Calibration files in the CDB.
63 // Processing of Pulser/Noise Run data and of TOF FEE DCS map included also.
67 // return=1 : no DCS input data Map
68 // return=2 : no DCS input data processing
69 // return=3 : no DCS processed data was stored in Ref Data
70 // return=4 : no DAQ input for Ref Data
71 // return=5 : failed to store DAQ Ref Data
72 // return=6 : failed to retrieve DAQ data for calibration
73 // return=7 : problems in processing histos in the input DAQ file
74 // return=8 : failed to store Online Delays
75 // return=9 : failed to store Reference Data for Pulser
76 // return=10: failed to retrieve Pulser data
77 // return=11: failed to store Pulser map in OCDB
78 // return=12: failed to store Reference Data for Noise
79 // return=13: failed to retrieve Noise data
80 // return=14: failed to store Noise map in OCDB
81 // return=15: failed to retrieve FEE data from FXS
82 // return=16: failed to retrieve FEE data from OCDB
83 // return=17: failed to store FEE data in OCDB
84 // return=18: failed to store FEE reference data in OCDB
85 // return=20: failed in retrieving status variable
87 ClassImp(AliTOFPreprocessor)
89 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
90 const Double_t AliTOFPreprocessor::fgkIntegralThr = 100; // min number of entries to perform computation of delay per channel
91 const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay
93 //_____________________________________________________________________________
95 AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
96 AliPreprocessor("TOF", shuttle),
101 fStoreRefData(kTRUE),
106 fIsStatusMapChanged(0)
109 AddRunType("PHYSICS");
110 AddRunType("PULSER");
115 //_____________________________________________________________________________
117 AliTOFPreprocessor::~AliTOFPreprocessor()
122 //______________________________________________________________________________
123 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
126 // Creates AliTOFDataDCS object
128 AliPreprocessor::Initialize(run, startTime, endTime);
130 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", run,
131 TTimeStamp(startTime).AsString(),
132 TTimeStamp(endTime).AsString(), ((TTimeStamp)GetStartTimeDCSQuery()).AsString(), ((TTimeStamp)GetEndTimeDCSQuery()).AsString()));
134 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
135 fHVLVmaps = new AliTOFLvHvDataPoints(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
136 fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
138 //_____________________________________________________________________________
139 Bool_t AliTOFPreprocessor::ProcessDCS(){
141 // check whether DCS should be processed or not...
143 TString runType = GetRunType();
144 Log(Form("RunType %s",runType.Data()));
146 if (runType != "PHYSICS"){
152 //_____________________________________________________________________________
154 UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap)
156 // Fills data into a AliTOFDataDCS object
159 Log("Processing DCS DP");
160 TH1::AddDirectory(0);
162 Bool_t resultDCSMap=kFALSE;
163 Bool_t resultDCSStore=kFALSE;
167 fData->SetFDRFlag(fFDRFlag);
170 Log("No DCS map found: TOF exiting from Shuttle");
175 return 1;// return error Code for DCS input data not found
179 // The processing of the DCS input data is forwarded to AliTOFDataDCS
180 resultDCSMap=fData->ProcessData(*dcsAliasMap);
182 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
187 return 2;// return error Code for processed DCS data not stored
190 AliCDBMetaData metaDataDCS;
191 metaDataDCS.SetBeamPeriod(0);
192 metaDataDCS.SetResponsible("Chiara Zampolli");
193 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
194 AliInfo("Storing DCS Data");
195 resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
196 if (!resultDCSStore){
197 Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
202 return 3;// return error Code for processed DCS data not stored
215 //_____________________________________________________________________________
217 UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
220 //Fills data into a AliTOFLvHvDataPoints object
221 // Merges fStatus object with LV and HV status at SOR
222 // Updates fStatus object with LV and HV status
223 // at EOR in case of correct end of run
224 // at last but two value in case of end-of-run caused by TOF detector.
227 Log("Processing HV and LV DCS DPs");
228 TH1::AddDirectory(0);
230 Bool_t resultDCSMap=kFALSE;
234 fHVLVmaps->SetFDRFlag(fFDRFlag);
237 Log("No DCS map found: TOF exiting from Shuttle");
242 return 1;// return error Code for DCS input data not found
246 // The processing of the DCS input data is forwarded to AliTOFDataDCS
247 resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap);
249 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
254 return 2;// return error Code for processed DCS data not stored
258 // check with plots. Start...
260 TH1F *hROsor = new TH1F("hROsor","RO status map at SOR",91*96*18,-0.5,91*96*18-0.5);
261 for (Int_t ii=1; ii<=91*96*18; ii++) hROsor->SetBinContent(ii,-1);
262 for (Int_t ii=0; ii<91*96*18; ii++) {
263 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
264 hROsor->SetBinContent(ii+1,0);
265 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
266 hROsor->SetBinContent(ii+1,1);
269 TH1F *hROandHVandLVsor = new TH1F("hROandHVandLVsor","RO.and.HV.andLV status map at SOR",91*96*18,-0.5,91*96*18-0.5);
270 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVsor->SetBinContent(ii,-1);
271 TH1F *hROandHVandLVeor = new TH1F("hROandHVandLVeor","RO.and.HV.andLV status map at EOR",91*96*18,-0.5,91*96*18-0.5);
272 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVeor->SetBinContent(ii,-1);
275 AliTOFDCSmaps * lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtSOR(); // Get LV.and.HV status map at SOR
276 for (Int_t index=0; index<fNChannels; index++) {
277 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
278 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
279 ( lvANDhvMap->GetCellValue(index)==1 &&
280 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
281 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
282 fIsStatusMapChanged=kTRUE;
286 // check with plots. Start...
288 for (Int_t ii=0; ii<91*96*18; ii++) {
289 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
290 hROandHVandLVsor->SetBinContent(ii+1,0);
291 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
292 hROandHVandLVsor->SetBinContent(ii+1,1);
296 lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtEOR(); // Get LV.and.HV status map at EOR
297 for (Int_t index=0; index<fNChannels; index++) {
298 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
299 fStatus->GetHWStatus(index)!=AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
300 ( lvANDhvMap->GetCellValue(index)==1 &&
301 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
302 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
303 fIsStatusMapChanged=kTRUE;
307 // check with plots. Start...
309 for (Int_t ii=0; ii<91*96*18; ii++) {
310 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
311 hROandHVandLVeor->SetBinContent(ii+1,0);
312 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
313 hROandHVandLVeor->SetBinContent(ii+1,1);
316 TCanvas *canvas = new TCanvas("canvas","",10,10,1000,1000);
317 canvas->SetFillColor(0);
320 hROsor->SetLineWidth(2);
323 hROandHVandLVsor->SetLineWidth(2);
324 hROandHVandLVsor->Draw();
326 hROandHVandLVeor->SetLineWidth(2);
327 hROandHVandLVeor->Draw();
335 /* check whether we don't need to update OCDB.
336 * in this case we can return without errors. */
338 if (!fIsStatusMapChanged) {
339 AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
340 return 0; // return ok
343 TString runType = GetRunType();
344 if (runType != "PHYSICS") {
345 AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
346 return 0; // return ok
349 // update the OCDB with the current FEE.and.HV.and.LV
350 // since even a little difference has been detected.
352 AliCDBMetaData metaData;
353 metaData.SetBeamPeriod(0);
354 metaData.SetResponsible("Roberto Preghenella");
355 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.HV.and.LV data.");
356 AliInfo("Storing Status data from current run. Collected RO.and.HV.and.LV infos @ EOR");
358 if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
360 Log("problems while storing RO.and.HV.and.LV Status data object");
369 return 17; // return error code for problems while storing FEE data
372 // everything fine. return
387 //_____________________________________________________________________________
389 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
391 // Processing data from DAQ for online calibration
393 Bool_t updateOCDB = kFALSE;
394 Log("Processing DAQ delays");
396 // reading configuration map
397 TString compDelays = "kFALSE";
398 Int_t deltaStartingRun = fRun;
399 Int_t startingRun = fRun-deltaStartingRun;
400 Int_t binRangeAve = fgkBinRangeAve;
401 Double_t integralThr = fgkIntegralThr;
402 Double_t thrPar = fgkThrPar;
404 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config");
406 Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
409 TMap *configMap = (TMap*)cdbEntry->GetObject();
411 Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
414 TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays");
416 compDelays = (TString) strDelays->GetString();
419 Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data()));
421 TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun");
423 TString tmpstr = strRun->GetString();
424 startingRun = tmpstr.Atoi();
425 deltaStartingRun = fRun - startingRun;
428 Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun));
430 TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve");
431 if (strBinRangeAve) {
432 TString tmpstr = strBinRangeAve->GetString();
433 binRangeAve = tmpstr.Atoi();
436 Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve));
438 TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr");
439 if (strIntegralThr) {
440 TString tmpstr = strIntegralThr->GetString();
441 integralThr = tmpstr.Atof();
444 Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
446 TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
448 TString tmpstr = strThrPar->GetString();
449 thrPar = tmpstr.Atof();
452 Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
456 if (compDelays == "kTRUE") fFDRFlag = kFALSE;
457 else fFDRFlag = kTRUE;
462 Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
464 /* init array with current calibration, if any */
465 fCal = new AliTOFChannelOnlineArray(fNChannels);
466 AliTOFChannelOnlineArray *curCal = NULL;
468 AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay");
469 if (!cdbEntry2 || !cdbEntry2->GetObject()) {
470 /* no CDB entry found. set update flag */
471 Log(" ************ WARNING ************");
472 Log("No CDB ParOnlineDelay entry found, creating a new one!");
473 Log(" *********************************");
477 Log("Found previous ParOnlineDelay entry. Using it to init calibration");
478 curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject();
479 for (Int_t i = 0; i < fNChannels; i++)
480 fCal->SetDelay(i, curCal->GetDelay(i));
484 TH1::AddDirectory(0);
486 Bool_t resultDAQRef=kFALSE;
487 Bool_t resultTOFPP=kFALSE;
494 //retrieving data at Run level
495 TList* list = GetFileSources(kDAQ, "RUNLevel");
496 if (list !=0x0 && list->GetEntries()!=0)
498 AliInfo("The following sources produced files with the id RUNLevel");
500 for (Int_t jj=0;jj<list->GetEntries();jj++){
501 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
502 AliInfo(Form("found source %s", str->String().Data()));
503 // file to be stored run per run
504 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
505 if (fileNameRun.Length()>0){
506 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
507 daqFile = new TFile(fileNameRun.Data(),"READ");
508 h2 = (TH2S*) daqFile->Get("htof");
509 AliCDBMetaData metaDataHisto;
510 metaDataHisto.SetBeamPeriod(0);
511 metaDataHisto.SetResponsible("Chiara Zampolli");
512 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
513 AliInfo("Storing Reference Data");
514 resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto);
516 Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
521 return 5;//return error code for failure in storing Ref Data
528 Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
532 return 4;//return error code for failure in retrieving Ref Data
538 Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
541 return 4;//return error code for failure in retrieving Ref Data
546 //Total files, with cumulative histos
548 TList* listTot = GetFileSources(kDAQ, "DELAYS");
549 if (listTot !=0x0 && listTot->GetEntries()!=0)
551 AliInfo("The following sources produced files with the id DELAYS");
553 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
554 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
555 AliInfo(Form("found source %s", str->String().Data()));
557 // file with summed histos, to extract calib params
558 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
559 if (fileName.Length()>0){
560 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
562 daqFile = new TFile(fileName.Data(),"READ");
564 h2 = (TH2S*) daqFile->Get("htoftot");
566 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
571 return 7; //return error code for histograms not existing/junky
574 static const Int_t kSize=h2->GetNbinsX();
575 static const Int_t kNBins=h2->GetNbinsY();
576 static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
577 if (kSize != fNChannels){
578 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
584 return 7; //return error code for histograms not existing/junky
586 Int_t nNotStatistics = 0; // number of channel with not enough statistics
588 /* FDR flag set. do not compute delays, use nominal cable delays */
591 Log(" Not computing delays according to flag set in Config entry in OCDB!");
592 FillWithCosmicCalibration(fCal);
594 /* check whether the new calibration is different from the previous one */
595 if (curCal) { /* well, check also whether we have a previous calibration */
596 for (Int_t i = 0; i < fNChannels; i++) {
597 if (fCal->GetDelay(i) != curCal->GetDelay(i)) {
603 else /* otherwise update OCDB */
608 else { // computing delays if not in FDR runs
610 updateOCDB = kTRUE; /* always update OCDB when computing delays */
612 for (Int_t ich=0;ich<kSize;ich++){
613 /* check whether channel has been read out during current run.
614 * if the status is bad it means it has not been read out.
615 * in this case skip channel in order to not affect the mean */
616 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
617 AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
620 AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
621 TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
622 for (Int_t ibin=0;ibin<kNBins;ibin++){
623 h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
625 if(h1->Integral()<integralThr) {
627 Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
633 Float_t minContent=h1->Integral()*thrPar;
634 Int_t nbinsX = h1->GetNbinsX();
636 for (Int_t j=1; j<=nbinsX; j++){
638 h1->GetBinContent(j) +
639 h1->GetBinContent(j+1)+
640 h1->GetBinContent(j+2)+
641 h1->GetBinContent(j+3))>minContent){
647 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
648 // Now calculate the mean over the interval.
652 for(Int_t k=0;k<binRangeAve;k++){
653 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
654 nent=nent+h1->GetBinContent(startBin+k);
655 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
657 mean= mean/nent; //<x>
658 sumw2=sumw2/nent; //<x^2>
660 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
661 if (ich<fNChannels) {
662 Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
663 fCal->SetDelay(ich,delay); // delay in ns
664 AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
670 if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
677 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
681 return 6;//return error code for problems in retrieving DAQ data
687 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
690 return 6; //return error code for problems in retrieving DAQ data
693 /* check whether we don't need to update OCDB.
694 * in this case we can return without errors and
695 * the current FEE is stored in the fStatus object. */
697 AliInfo("update OCDB flag not set. Do not overwrite stored file.");
698 return 0; /* return ok */
702 AliCDBMetaData metaData;
703 metaData.SetBeamPeriod(0);
704 metaData.SetResponsible("Chiara Zampolli");
705 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays.");
706 AliInfo("Storing Calibration Data");
707 resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE);
709 Log("Some problems occurred while storing online object resulting from DAQ data processing");
712 return 8;//return error code for problems in storing DAQ data
723 //_____________________________________________________________________________
726 AliTOFPreprocessor::ProcessT0Fill()
728 // Processing data from DAQ for T0-fill measurement
730 Log("Processing T0-fill");
733 /* instance and setup CDB manager */
734 AliCDBManager *cdb = AliCDBManager::Instance();
736 if (!gGeoManager) AliGeomManager::LoadGeometry();
739 /* get params from OCDB */
740 AliCDBEntry *cdbe = NULL;
742 /* get T0-fill calibration params */
743 cdbe = GetFromOCDB("Calib", "T0FillOnlineCalib");
745 Log("cannot get \"T0FillOnlineCalib\" entry from OCDB");
748 AliTOFT0FillOnlineCalib *t0FillOnlineCalibObject = (AliTOFT0FillOnlineCalib *)cdbe->GetObject();
749 if (!t0FillOnlineCalibObject) {
750 Log("cannot get \"T0FillOnlineCalib\" object from CDB entry");
753 Float_t t0FillCalibOffset = t0FillOnlineCalibObject->GetOffset();
754 Float_t t0FillCalibCoefficient = t0FillOnlineCalibObject->GetCoefficient();
755 Log(Form("got \"T0FillOnlineCalib\" object: offset=%f coeff=%f", t0FillCalibOffset, t0FillCalibCoefficient));
757 /* get online status from OCDB */
758 cdbe = GetFromOCDB("Calib", "Status");
760 Log("cannot get \"Status\" entry from OCDB");
763 AliTOFChannelOnlineStatusArray *statusArray = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
765 Log("cannot get \"Status\" object from CDB entry");
768 Log("got \"Status\" object");
770 /* get offline calibration from OCDB */
771 cdbe = GetFromOCDB("Calib", "ParOffline");
773 Log("cannot get \"ParOffline\" entry from OCDB");
776 TObjArray *offlineArray = (TObjArray *)cdbe->GetObject();
777 AliTOFChannelOffline *channelOffline;
779 Log("cannot get \"ParOffline\" object from CDB entry");
782 Log("got \"ParOffline\" object");
784 /* get deltaBC offset from OCDB */
785 cdbe = GetFromOCDB("Calib", "DeltaBCOffset");
787 Log("cannot get \"DeltaBCOffset\" entry from OCDB");
790 AliTOFDeltaBCOffset *deltaBCOffsetObject = (AliTOFDeltaBCOffset *)cdbe->GetObject();
791 if (!deltaBCOffsetObject) {
792 Log("cannot get \"DeltaBCOffset\" object from CDB entry");
795 Int_t deltaBCOffset = deltaBCOffsetObject->GetDeltaBCOffset();
796 Log(Form("got \"DeltaBCOffset\" object: deltaBCOffset=%d (BC bins)", deltaBCOffset));
798 /* get CTP latency from OCDB */
799 cdbe = GetFromOCDB("Calib", "CTPLatency");
801 Log("cannot get \"CTPLatency\" entry from OCDB");
804 AliTOFCTPLatency *ctpLatencyObject = (AliTOFCTPLatency *)cdbe->GetObject();
805 if (!ctpLatencyObject) {
806 Log("cannot get \"CTPLatency\" object from CDB entry");
809 Float_t ctpLatency = ctpLatencyObject->GetCTPLatency();
810 Log(Form("got \"CTPLatency\" object: ctpLatency=%f (ps)", ctpLatency));
812 /* get file sources from FXS */
813 TList *fileList = GetFileSources(kDAQ, "HITS");
814 if (!fileList || fileList->GetEntries() == 0) {
815 Log("cannot get DAQ source file list or empty list");
818 Log(Form("got DAQ source file list: %d files", fileList->GetEntries()));
821 /* create tree chain using file sources */
822 TChain chain("hitTree");
823 for (Int_t ifile = 0; ifile < fileList->GetEntries(); ifile++) {
824 TObjString *str = (TObjString *)fileList->At(ifile);
825 TString filename = GetFile(kDAQ, "HITS", str->GetName());
827 Log(Form("file added to input chain: source=%s, filename=%s", str->String().Data(), filename.Data()));
829 Int_t nhits = chain.GetEntries();
830 Log(Form("input chain ready: %d hits", nhits));
832 /* setup input chain */
833 AliTOFHitField *hit = new AliTOFHitField();
834 chain.SetBranchAddress("hit", &hit);
836 /* create calib histo and geometry */
837 AliTOFcalibHisto calibHisto;
838 calibHisto.LoadCalibHisto();
839 AliTOFGeometry tofGeo;
842 Float_t c = TMath::C() * 1.e2 / 1.e12; /* cm/ps */
843 Float_t c_1 = 1. / c;
845 Int_t index, timebin, totbin, deltaBC, l0l1latency, det[5];
846 Float_t timeps, totns, corrps, length, timeexp, timezero, pos[3], latencyWindow;
849 TH1F *hT0Fill = new TH1F("hT0Fill", "T0 fill;t - t_{exp}^{(c)} (ps);", 2000, -24400., 24400.);
852 for (Int_t ihit = 0; ihit < nhits; ihit++) {
855 chain.GetEntry(ihit);
858 index = hit->GetIndex();
859 timebin = hit->GetTimeBin();
860 totbin = hit->GetTOTBin();
861 deltaBC = hit->GetDeltaBC();
862 l0l1latency = hit->GetL0L1Latency();
863 latencyWindow = statusArray->GetLatencyWindow(index) * 1.e3;
865 /* convert time in ps and tot in ns */
866 timeps = timebin * AliTOFGeometry::TdcBinWidth();
867 totns = totbin * AliTOFGeometry::ToTBinWidth() * 1.e-3;
868 /* get calibration correction in ps */
869 channelOffline = (AliTOFChannelOffline *)offlineArray->At(index);
870 if (totns < AliTOFGeometry::SlewTOTMin()) totns = AliTOFGeometry::SlewTOTMin();
871 if (totns > AliTOFGeometry::SlewTOTMax()) totns = AliTOFGeometry::SlewTOTMax();
873 for (Int_t ipar = 0; ipar < 6; ipar++) corrps += channelOffline->GetSlewPar(ipar) * TMath::Power(totns, ipar);
875 /* perform time correction */
876 timeps = timeps + (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth() + l0l1latency * AliTOFGeometry::BunchCrossingBinWidth() + ctpLatency - latencyWindow - corrps;
877 /* compute length and expected time */
878 tofGeo.GetVolumeIndices(index, det);
879 tofGeo.GetPosPar(det, pos);
881 for (Int_t i = 0; i < 3; i++) length += pos[i] * pos[i];
882 length = TMath::Sqrt(length);
883 timeexp = length * c_1;
884 /* compute time zero */
885 timezero = timeps - timeexp;
888 hT0Fill->Fill(timezero);
891 /* rebin until maximum bin has required minimum entries */
892 Int_t maxBin = hT0Fill->GetMaximumBin();
893 Int_t maxBinContent = hT0Fill->GetBinContent(maxBin);
894 Float_t binWidth = hT0Fill->GetBinWidth(maxBin);
895 while (maxBinContent < 400 && binWidth < 90.) {
897 maxBin = hT0Fill->GetMaximumBin();
898 maxBinContent = hT0Fill->GetBinContent(maxBin);
899 binWidth = hT0Fill->GetBinWidth(maxBin);
901 Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin);
903 /* rough landau fit of the edge */
904 TF1 *landau = (TF1 *)gROOT->GetFunction("landau");
905 landau->SetParameter(1, maxBinCenter);
906 Float_t fitMin = maxBinCenter - 1000.; /* fit from 10 ns before max */
907 Float_t fitMax = maxBinCenter + binWidth; /* fit until a bin width above max */
908 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
909 /* get rough landau mean and sigma to set a better fit range */
910 Float_t mean = landau->GetParameter(1);
911 Float_t sigma = landau->GetParameter(2);
912 /* better landau fit of the edge */
913 fitMin = maxBinCenter - 3. * sigma;
915 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
917 mean = landau->GetParameter(1);
918 sigma = landau->GetParameter(2);
919 Float_t meane = landau->GetParError(1);
920 Float_t sigmae = landau->GetParError(2);
921 Log(Form("edge fit: mean = %f +- %f ps", mean, meane));
922 Log(Form("edge fit: sigma = %f +- %f ps", sigma, sigmae));
923 Float_t edge = mean - 3. * sigma;
924 Float_t edgee = TMath::Sqrt(meane * meane + 3. * sigmae * 3. * sigmae);
925 Log(Form("edge fit: edge = %f +- %f ps", edge, edgee));
926 /* apply calibration to get T0-fill from egde */
927 Float_t t0Fill = edge * t0FillCalibCoefficient + t0FillCalibOffset;
928 Log(Form("estimated T0-fill: %f ps", t0Fill));
930 /* create T0-fill object */
931 AliTOFT0Fill *t0FillObject = new AliTOFT0Fill();
932 t0FillObject->SetT0Fill(t0Fill);
934 /* store reference data */
936 AliCDBMetaData metaDataHisto;
937 metaDataHisto.SetBeamPeriod(0);
938 metaDataHisto.SetResponsible("Roberto Preghenella");
939 metaDataHisto.SetComment("online T0-fill histogram");
940 if (!StoreReferenceData("Calib","T0Fill", hT0Fill, &metaDataHisto)) {
941 Log("error while storing reference data");
947 Log("reference data successfully stored");
950 AliCDBMetaData metaData;
951 metaData.SetBeamPeriod(0);
952 metaData.SetResponsible("Roberto Preghenella");
953 metaData.SetComment("online T0-fill measurement");
954 if (!Store("Calib", "T0Fill", t0FillObject, &metaData, 0, kFALSE)) {
955 Log("error while storing T0-fill object");
961 Log("T0-fill object successfully stored");
971 //_____________________________________________________________________________
973 UInt_t AliTOFPreprocessor::ProcessPulserData()
975 // Processing Pulser Run data for TOF channel status
977 Log("Processing Pulser");
980 AliError("No valid fStatus found, some errors must have occurred!!");
984 TH1::AddDirectory(0);
986 Bool_t resultPulserRef=kFALSE;
987 Bool_t resultPulser=kFALSE;
989 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
990 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
991 for (Int_t ibin =1;ibin<=kSize;ibin++){
992 htofPulser->SetBinContent(ibin,-1);
1000 //retrieving Pulser data
1001 TList* listPulser = GetFileSources(kDAQ, "PULSER");
1002 if (listPulser !=0x0 && listPulser->GetEntries()!=0)
1004 AliInfo("The following sources produced files with the id PULSER");
1005 listPulser->Print();
1007 for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
1008 Int_t nPulserSource = 0;
1009 TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
1010 AliInfo(Form("found source %s", str->String().Data()));
1011 // file to be stored run per run
1012 TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
1013 if (fileNamePulser.Length()>0){
1014 // storing refernce data
1015 AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
1016 daqFile = new TFile(fileNamePulser.Data(),"READ");
1017 h1 = (TH1S*) daqFile->Get("hTOFpulser");
1018 for (Int_t ibin=0;ibin<kSize;ibin++){
1019 if ((h1->GetBinContent(ibin+1))!=-1){
1020 if ((htofPulser->GetBinContent(ibin+1))==-1){
1021 htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
1024 Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
1029 // elaborating infos
1032 Int_t nreadNotEmpty=0;
1033 for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
1035 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)));
1036 /* check whether channel has been read out during current run.
1037 * if the status is bad it means it has not been read out.
1038 * in this case skip channel in order to not affect the mean */
1039 if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1043 if (h1->GetBinContent(ientry)==-1) continue;
1045 if (h1->GetBinContent(ientry)>0) {
1047 AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
1049 mean+=h1->GetBinContent(ientry);
1055 AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean));
1056 for (Int_t ich =0;ich<fNChannels;ich++){
1057 if (h1->GetBinContent(ich+1)==-1) continue;
1058 AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich)));
1060 /* check whether channel has been read out during current run.
1061 * if the status is bad it means it has not been read out.
1062 * in this case skip channel in order to leave its status
1064 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1067 if (h1->GetBinContent(ich+1)<0.05*mean){
1068 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser
1069 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)));
1072 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser
1073 AliDebug(2,Form( " channel %i pulser status after pulser = %i (good), with global status = %i",ich,(Int_t)fStatus->GetPulserStatus(ich),(Int_t)fStatus->GetStatus(ich)));
1078 Log("No channels read!! No action taken, keeping old status");
1087 Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle ");
1095 return 10;//return error code for failure in retrieving Ref Data
1097 AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource));
1099 AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser));
1104 Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle ");
1111 return 10;//return error code for failure in retrieving Ref Data
1116 AliCDBMetaData metaData;
1117 metaData.SetBeamPeriod(0);
1118 metaData.SetResponsible("Chiara Zampolli");
1119 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run.");
1120 AliInfo("Storing Calibration Data from Pulser Run");
1121 resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
1123 Log("Some problems occurred while storing online object resulting from Pulser data processing");
1130 return 11;//return error code for problems in storing Pulser data
1135 AliCDBMetaData metaDataHisto;
1136 metaDataHisto.SetBeamPeriod(0);
1137 metaDataHisto.SetResponsible("Chiara Zampolli");
1139 sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
1140 metaDataHisto.SetComment(comment);
1141 AliInfo("Storing Reference Data");
1142 resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
1143 if (!resultPulserRef){
1144 Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
1151 return 9;//return error code for failure in storing Ref Data
1167 //_____________________________________________________________________________
1169 UInt_t AliTOFPreprocessor::ProcessNoiseData()
1172 // Processing Noise Run data for TOF channel status
1174 Log("Processing Noise");
1177 AliError("No valid fStatus found, some errors must have occurred!!");
1181 Float_t noiseThr = 1; // setting default threshold for noise to 1 Hz
1182 // reading config map
1183 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
1185 Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
1188 TMap *configMap = (TMap*)cdbEntry->GetObject();
1190 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
1193 TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
1195 TString tmpstr = strNoiseThr->GetString();
1196 noiseThr = tmpstr.Atoi();
1199 Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
1207 TH1::AddDirectory(0);
1209 Bool_t resultNoiseRef=kFALSE;
1210 Bool_t resultNoise=kFALSE;
1212 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
1213 TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5);
1214 for (Int_t ibin =1;ibin<=kSize;ibin++){
1215 htofNoise->SetBinContent(ibin,-1);
1220 TFile * daqFile=0x0;
1225 Int_t nNoisyChannels = 0;
1226 Int_t nNotNoisyChannels = 0;
1227 Int_t nChannelsFromDA = 0;
1228 Int_t nMatchingWindowNullNonZero = 0;
1229 Int_t nMatchingWindowNullEqualZero = 0;
1231 // retrieving Noise data
1232 TList* listNoise = GetFileSources(kDAQ, "NOISE");
1233 if (listNoise !=0x0 && listNoise->GetEntries()!=0)
1235 AliInfo("The following sources produced files with the id NOISE");
1237 for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
1238 Int_t nNoiseSource = 0;
1239 TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
1240 AliInfo(Form("found source %s", str->String().Data()));
1241 // file to be stored run per run
1242 TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
1243 if (fileNameNoise.Length()>0){
1244 // storing reference data
1245 AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
1246 daqFile = new TFile(fileNameNoise.Data(),"READ");
1247 h1 = (TH1F*) daqFile->Get("hTOFnoise");
1248 for (Int_t ibin=0;ibin<kSize;ibin++){
1249 if ((h1->GetBinContent(ibin+1))!=-1){
1251 // checking the matching window for current channel
1252 if (fMatchingWindow[ibin] == 0){
1253 Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin));
1254 if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;
1255 if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;
1258 if ((htofNoise->GetBinContent(ibin+1))==-1){
1259 htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9));
1260 if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1)));
1263 Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
1268 Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
1277 Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle ");
1286 if (fMatchingWindow){
1287 delete [] fMatchingWindow;
1288 fMatchingWindow = 0;
1290 return 13;//return error code for failure in retrieving Ref Data
1296 Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle ");
1303 if (fMatchingWindow){
1304 delete [] fMatchingWindow;
1305 fMatchingWindow = 0;
1307 return 13;//return error code for failure in retrieving Ref Data
1310 // elaborating infos to set NOISE status
1311 for (Int_t ich =0;ich<fNChannels;ich++){
1312 if (htofNoise->GetBinContent(ich+1)== -1) continue;
1316 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)));
1317 //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
1319 /* check whether channel has been read out during current run.
1320 * if the status is bad it means it has not been read out.
1321 * in this case skip channel in order to leave its status
1324 if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1328 if (htofNoise->GetBinContent(ich+1) >= noiseThr){
1329 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
1330 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)));
1334 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
1335 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)));
1336 nNotNoisyChannels++;
1340 Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA));
1341 Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise));
1342 Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels));
1343 Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels));
1344 Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero));
1345 Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero));
1353 AliCDBMetaData metaData;
1354 metaData.SetBeamPeriod(0);
1355 metaData.SetResponsible("Chiara Zampolli");
1356 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run.");
1357 AliInfo("Storing Calibration Data from Noise Run");
1358 resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
1360 Log("Some problems occurred while storing online object resulting from Noise data processing");
1367 if (fMatchingWindow){
1368 delete [] fMatchingWindow;
1369 fMatchingWindow = 0;
1371 return 14;//return error code for problems in storing Noise data
1376 AliCDBMetaData metaDataHisto;
1377 metaDataHisto.SetBeamPeriod(0);
1378 metaDataHisto.SetResponsible("Chiara Zampolli");
1380 sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
1381 metaDataHisto.SetComment(comment);
1382 AliInfo("Storing Reference Data");
1383 resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
1384 if (!resultNoiseRef){
1385 Log("some problems occurred::No Reference Data for noise stored");
1392 if (fMatchingWindow){
1393 delete [] fMatchingWindow;
1394 fMatchingWindow = 0;
1396 return 12;//return error code for failure in storing Ref Data
1408 if (fMatchingWindow){
1409 delete [] fMatchingWindow;
1410 fMatchingWindow = 0;
1415 //_____________________________________________________________________________
1417 UInt_t AliTOFPreprocessor::ProcessFEEData()
1419 // Processing Pulser Run data for TOF channel status
1420 // dummy for the time being
1422 Log("Processing FEE");
1424 //Bool_t updateOCDB = kFALSE;
1425 AliTOFFEEReader feeReader;
1427 TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
1429 /* load current TOF FEE(dump) from DCS FXS,
1430 * setup TOFFEEdump object */
1432 const char * toffeeFileName = GetFile(kDCS,"TofFeeMap","");
1433 AliInfo(Form("toffee file name = %s", toffeeFileName));
1434 if (toffeeFileName == NULL) {
1437 AliTOFFEEDump feedump;
1438 feedump.ReadFromFile(toffeeFileName);
1440 /* load current TOF FEE(light) config from DCS FXS, parse,
1441 * fill current FEE histogram and set FEE status */
1443 const char * nameFile = GetFile(kDCS,"TofFeeLightMap","");
1444 AliInfo(Form("toffeeLight file name = %s",nameFile));
1445 if (nameFile == NULL) {
1448 feeReader.LoadFEElightConfig(nameFile);
1449 Int_t parseFee = feeReader.ParseFEElightConfig();
1450 AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee));
1451 /* load stored TOF FEE from OCDB and compare it with current FEE.
1452 * if stored FEE is different from current FEE set update flag.
1453 * if there is no stored FEE in OCDB set update flag */
1455 fMatchingWindow = new Int_t[fNChannels];
1456 fLatencyWindow = new Int_t[fNChannels];
1458 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
1460 /* no CDB entry found. set update flag */
1461 Log(" ************ WARNING ************");
1462 Log("No CDB Status entry found, creating a new one!");
1463 Log(" *********************************");
1464 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
1465 //updateOCDB = kTRUE;
1466 fIsStatusMapChanged = kTRUE;
1469 if (cdbEntry) cdbEntry->SetOwner(kFALSE);
1470 /* CDB entry OK. loop over channels */
1471 fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
1474 /* cehck whether status object has latency window data */
1475 if (!fStatus->HasLatencyWindow()) {
1476 /* create new status object and update OCDB */
1477 Log(" ************ WARNING ************");
1478 Log("CDB Status entry found but has no latency window data, creating a new one!");
1479 Log(" *********************************");
1481 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
1482 //updateOCDB = kTRUE;
1483 fIsStatusMapChanged = kTRUE;
1486 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
1487 //AliDebug(2,Form("********** channel %i",iChannel));
1488 /* compare current FEE channel status with stored one
1489 * if different set update flag and break loop */
1490 //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1491 fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
1492 fLatencyWindow[iChannel] = feeReader.GetLatencyWindow(iChannel);
1493 if (feeReader.IsChannelEnabled(iChannel)) {
1494 hCurrentFEE.SetBinContent(iChannel + 1, 1);
1495 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
1496 //updateOCDB = kTRUE;
1497 fIsStatusMapChanged = kTRUE;
1498 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
1499 AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1501 if (fStatus->GetLatencyWindow(iChannel)!=fLatencyWindow[iChannel]){
1502 //updateOCDB = kTRUE;
1503 fIsStatusMapChanged = kTRUE;
1504 fStatus->SetLatencyWindow(iChannel,fLatencyWindow[iChannel]);
1505 AliDebug(3,Form( " changed latency window: channel %i latency window after FEE = %i",iChannel,fStatus->GetLatencyWindow(iChannel)));
1509 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
1510 //updateOCDB = kTRUE;
1511 fIsStatusMapChanged = kTRUE;
1512 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
1513 AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1519 /* check whether we don't have to store reference data.
1520 * in this case we return without errors. */
1521 if (fStoreRefData) {
1522 /* store reference data */
1523 AliCDBMetaData metaDataHisto;
1524 metaDataHisto.SetBeamPeriod(0);
1525 metaDataHisto.SetResponsible("Roberto Preghenella");
1526 metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
1527 AliInfo("Storing FEE reference data");
1528 /* store FEE reference data */
1529 if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
1531 Log("problems while storing FEE reference data");
1536 return 18; /* error return code for problems while storing FEE reference data */
1539 /* store TOF FEE dump reference data */
1540 AliCDBMetaData metaDatadump;
1541 metaDatadump.SetBeamPeriod(0);
1542 metaDatadump.SetResponsible("Roberto Preghenella");
1543 metaDatadump.SetComment("This preprocessor stores the TOF FEE dump Ref data of the current run.");
1544 AliInfo("Storing TOF FEE dump reference data");
1545 /* store FEE reference data */
1546 if (!StoreReferenceData("Calib", "FEEDump", &feedump, &metaDatadump)) {
1548 Log("problems while storing TOF FEE dump reference data");
1549 return 18; /* error return code for problems while storing FEE reference data */
1557 //_____________________________________________________________________________
1559 UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap)
1562 // Main AliTOFPreprocessor method called by SHUTTLE
1565 TString runType = GetRunType();
1566 Log(Form("RunType %s",runType.Data()));
1570 /* always process FEE data */
1571 Int_t iresultFEE = ProcessFEEData();
1572 if (iresultFEE != 0)
1575 if (runType == "PULSER") {
1576 Int_t iresultPulser = ProcessPulserData();
1577 return iresultPulser;
1580 if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined
1581 Int_t iresultNoise = ProcessNoiseData();
1582 return iresultNoise;
1585 if (runType == "PHYSICS") {
1586 // Int_t iresultDAQ = ProcessOnlineDelays();
1587 Int_t iresultDAQ = ProcessT0Fill();
1588 if (iresultDAQ != 0) {
1592 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
1593 Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap);
1594 return iresultDCS+iResultHVandLVdps;
1603 //_____________________________________________________________________________
1606 AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal)
1609 * fill with cosmic calibration
1612 Log(" Using cosmic-ray calibration.");
1614 AliTOFcalibHisto calibHisto;
1615 calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE);
1616 Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName()));
1617 Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName()));
1618 calibHisto.LoadCalibPar();
1620 /* loop over channel index */
1621 for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) {
1622 cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex));
1627 //_____________________________________________________________________________
1630 AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal)
1633 * fill with cosmic calibration
1636 Log(" Using cable-length map.");
1637 AliTOFRawStream tofrs;
1638 Int_t det[5], dummy, index;
1639 Float_t cableTimeShift;
1641 /* temporarly disable warnings */
1642 AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
1643 AliLog::SetGlobalLogLevel(AliLog::kError);
1645 /* loop over EO indeces */
1646 for (Int_t iddl = 0; iddl < 72; iddl++)
1647 for (Int_t islot = 3; islot <= 12; islot++)
1648 for (Int_t ichain = 0; ichain < 2; ichain++)
1649 for (Int_t itdc = 0; itdc < 15; itdc++)
1650 for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
1653 tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
1655 /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
1660 /* check DO index */
1661 if (det[0] < 0 || det[0] > 17 ||
1662 det[1] < 0 || det[1] > 4 ||
1663 det[2] < 0 || det[2] > 18 ||
1664 det[3] < 0 || det[3] > 1 ||
1665 det[4] < 0 || det[4] > 47)
1668 /* get channel index */
1669 index = AliTOFGeometry::GetIndex(det);
1671 /* get cable time shift */
1672 cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
1675 if (index<fNChannels) {
1676 cal->SetDelay(index,cableTimeShift); // delay in ns
1677 AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
1680 } /* loop over EO indeces */
1682 /* re-enable warnings */
1683 AliLog::SetGlobalLogLevel(logLevel);