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
248 resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap);
250 Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
255 return 2;// return error Code for processed DCS data not stored
259 // check with plots. Start...
261 TH1F *hROsor = new TH1F("hROsor","RO status map at SOR",91*96*18,-0.5,91*96*18-0.5);
262 for (Int_t ii=1; ii<=91*96*18; ii++) hROsor->SetBinContent(ii,-1);
263 for (Int_t ii=0; ii<91*96*18; ii++) {
264 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
265 hROsor->SetBinContent(ii+1,0);
266 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
267 hROsor->SetBinContent(ii+1,1);
270 TH1F *hROandHVandLVsor = new TH1F("hROandHVandLVsor","RO.and.HV.andLV status map at SOR",91*96*18,-0.5,91*96*18-0.5);
271 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVsor->SetBinContent(ii,-1);
272 TH1F *hROandHVandLVeor = new TH1F("hROandHVandLVeor","RO.and.HV.andLV status map at EOR",91*96*18,-0.5,91*96*18-0.5);
273 for (Int_t ii=1; ii<=91*96*18; ii++) hROandHVandLVeor->SetBinContent(ii,-1);
276 AliTOFDCSmaps * lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtSOR(); // Get LV.and.HV status map at SOR
277 for (Int_t index=0; index<fNChannels; index++) {
278 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
279 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
280 ( lvANDhvMap->GetCellValue(index)==1 &&
281 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
282 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
283 fIsStatusMapChanged=kTRUE;
287 // check with plots. Start...
289 for (Int_t ii=0; ii<91*96*18; ii++) {
290 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
291 hROandHVandLVsor->SetBinContent(ii+1,0);
292 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
293 hROandHVandLVsor->SetBinContent(ii+1,1);
297 lvANDhvMap = (AliTOFDCSmaps*)fHVLVmaps->GetHVandLVmapAtEOR(); // Get LV.and.HV status map at EOR
298 for (Int_t index=0; index<fNChannels; index++) {
299 if ( ( lvANDhvMap->GetCellValue(index)==0 &&
300 fStatus->GetHWStatus(index)!=AliTOFChannelOnlineStatusArray::kTOFHWBad ) ||
301 ( lvANDhvMap->GetCellValue(index)==1 &&
302 fStatus->GetHWStatus(index) != AliTOFChannelOnlineStatusArray::kTOFHWOk ) ) {
303 fStatus->SetHWStatus(index, AliTOFChannelOnlineStatusArray::kTOFHWBad);
304 fIsStatusMapChanged=kTRUE;
308 // check with plots. Start...
310 for (Int_t ii=0; ii<91*96*18; ii++) {
311 if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWBad)
312 hROandHVandLVeor->SetBinContent(ii+1,0);
313 else if (fStatus->GetHWStatus(ii)==AliTOFChannelOnlineStatusArray::kTOFHWOk)
314 hROandHVandLVeor->SetBinContent(ii+1,1);
317 TCanvas *canvas = new TCanvas("canvas","",10,10,1000,1000);
318 canvas->SetFillColor(0);
321 hROsor->SetLineWidth(2);
324 hROandHVandLVsor->SetLineWidth(2);
325 hROandHVandLVsor->Draw();
327 hROandHVandLVeor->SetLineWidth(2);
328 hROandHVandLVeor->Draw();
337 /* check whether we don't need to update OCDB.
338 * in this case we can return without errors. */
340 if (!fIsStatusMapChanged) {
341 AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
342 return 0; // return ok
345 TString runType = GetRunType();
346 if (runType != "PHYSICS") {
347 AliInfo(Form("Run Type = %s, waiting to store status map",GetRunType()));
348 return 0; // return ok
351 // update the OCDB with the current FEE.and.HV.and.LV
352 // since even a little difference has been detected.
354 AliCDBMetaData metaData;
355 metaData.SetBeamPeriod(0);
356 metaData.SetResponsible("Roberto Preghenella");
357 //metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.HV.and.LV data."); // AdC
358 //AliInfo("Storing Status data from current run. Collected RO.and.HV.and.LV infos @ EOR"); // AdC
359 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object from FEE.and.LV data.");
360 AliInfo("Storing Status data from current run. Collected RO.and.LV infos @ SOR");
362 if (!Store("Calib", "Status", fStatus, &metaData, 0, kTRUE)) {
364 Log("problems while storing RO.and.HV.and.LV Status data object");
373 return 17; // return error code for problems while storing FEE data
376 // everything fine. return
391 //_____________________________________________________________________________
393 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
395 // Processing data from DAQ for online calibration
397 Bool_t updateOCDB = kFALSE;
398 Log("Processing DAQ delays");
400 // reading configuration map
401 TString compDelays = "kFALSE";
402 Int_t deltaStartingRun = fRun;
403 Int_t startingRun = fRun-deltaStartingRun;
404 Int_t binRangeAve = fgkBinRangeAve;
405 Double_t integralThr = fgkIntegralThr;
406 Double_t thrPar = fgkThrPar;
408 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Config");
410 Log(Form("No Configuration entry found in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
413 TMap *configMap = (TMap*)cdbEntry->GetObject();
415 Log(Form("No map found in Config entry in CDB, using default values: ComputingDelays = %s, StartingRun = %i",compDelays.Data(), startingRun));
418 TObjString *strDelays = (TObjString*)configMap->GetValue("ComputingDelays");
420 compDelays = (TString) strDelays->GetString();
423 Log(Form("No ComputingDelays value found in Map from Config entry in CDB, using default value: ComputingDelays = %s",compDelays.Data()));
425 TObjString *strRun = (TObjString*)configMap->GetValue("StartingRun");
427 TString tmpstr = strRun->GetString();
428 startingRun = tmpstr.Atoi();
429 deltaStartingRun = fRun - startingRun;
432 Log(Form("No StartingRun value found in Map from Config entry in CDB, using default value: StartingRun = %i",startingRun));
434 TObjString *strBinRangeAve = (TObjString*)configMap->GetValue("BinRangeAve");
435 if (strBinRangeAve) {
436 TString tmpstr = strBinRangeAve->GetString();
437 binRangeAve = tmpstr.Atoi();
440 Log(Form("No BinRangeAve value found in Map from Config entry in CDB, using default value: BinRangeAve = %i",binRangeAve));
442 TObjString *strIntegralThr = (TObjString*)configMap->GetValue("IntegralThr");
443 if (strIntegralThr) {
444 TString tmpstr = strIntegralThr->GetString();
445 integralThr = tmpstr.Atof();
448 Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
450 TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
452 TString tmpstr = strThrPar->GetString();
453 thrPar = tmpstr.Atof();
456 Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
460 if (compDelays == "kTRUE") fFDRFlag = kFALSE;
461 else fFDRFlag = kTRUE;
466 Log(Form("ComputingDelays = %s, StartingRun = %i",compDelays.Data(),startingRun));
468 /* init array with current calibration, if any */
469 fCal = new AliTOFChannelOnlineArray(fNChannels);
470 AliTOFChannelOnlineArray *curCal = NULL;
472 AliCDBEntry *cdbEntry2 = GetFromOCDB("Calib","ParOnlineDelay");
473 if (!cdbEntry2 || !cdbEntry2->GetObject()) {
474 /* no CDB entry found. set update flag */
475 Log(" ************ WARNING ************");
476 Log("No CDB ParOnlineDelay entry found, creating a new one!");
477 Log(" *********************************");
481 Log("Found previous ParOnlineDelay entry. Using it to init calibration");
482 curCal = (AliTOFChannelOnlineArray *)cdbEntry2->GetObject();
483 for (Int_t i = 0; i < fNChannels; i++)
484 fCal->SetDelay(i, curCal->GetDelay(i));
488 TH1::AddDirectory(0);
490 Bool_t resultDAQRef=kFALSE;
491 Bool_t resultTOFPP=kFALSE;
498 //retrieving data at Run level
499 TList* list = GetFileSources(kDAQ, "RUNLevel");
500 if (list !=0x0 && list->GetEntries()!=0)
502 AliInfo("The following sources produced files with the id RUNLevel");
504 for (Int_t jj=0;jj<list->GetEntries();jj++){
505 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
506 AliInfo(Form("found source %s", str->String().Data()));
507 // file to be stored run per run
508 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
509 if (fileNameRun.Length()>0){
510 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
511 daqFile = new TFile(fileNameRun.Data(),"READ");
512 h2 = (TH2S*) daqFile->Get("htof");
513 AliCDBMetaData metaDataHisto;
514 metaDataHisto.SetBeamPeriod(0);
515 metaDataHisto.SetResponsible("Chiara Zampolli");
516 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
517 AliInfo("Storing Reference Data");
518 resultDAQRef = StoreReferenceData("Calib","DAQData",h2, &metaDataHisto);
520 Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
525 return 5;//return error code for failure in storing Ref Data
532 Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle ");
536 return 4;//return error code for failure in retrieving Ref Data
542 Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle ");
545 return 4;//return error code for failure in retrieving Ref Data
550 //Total files, with cumulative histos
552 TList* listTot = GetFileSources(kDAQ, "DELAYS");
553 if (listTot !=0x0 && listTot->GetEntries()!=0)
555 AliInfo("The following sources produced files with the id DELAYS");
557 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
558 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
559 AliInfo(Form("found source %s", str->String().Data()));
561 // file with summed histos, to extract calib params
562 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
563 if (fileName.Length()>0){
564 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
566 daqFile = new TFile(fileName.Data(),"READ");
568 h2 = (TH2S*) daqFile->Get("htoftot");
570 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
575 return 7; //return error code for histograms not existing/junky
578 static const Int_t kSize=h2->GetNbinsX();
579 static const Int_t kNBins=h2->GetNbinsY();
580 static const Double_t kXBinmin=h2->GetYaxis()->GetBinLowEdge(1);
581 if (kSize != fNChannels){
582 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
588 return 7; //return error code for histograms not existing/junky
590 Int_t nNotStatistics = 0; // number of channel with not enough statistics
592 /* FDR flag set. do not compute delays, use nominal cable delays */
595 Log(" Not computing delays according to flag set in Config entry in OCDB!");
596 FillWithCosmicCalibration(fCal);
598 /* check whether the new calibration is different from the previous one */
599 if (curCal) { /* well, check also whether we have a previous calibration */
600 for (Int_t i = 0; i < fNChannels; i++) {
601 if (fCal->GetDelay(i) != curCal->GetDelay(i)) {
607 else /* otherwise update OCDB */
612 else { // computing delays if not in FDR runs
614 updateOCDB = kTRUE; /* always update OCDB when computing delays */
616 for (Int_t ich=0;ich<kSize;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 not affect the mean */
620 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad){
621 AliDebug(2,Form(" Channel %i found bad according to FEEmap, (HW status = %i), skipping from delay computing",ich, (Int_t)fStatus->GetHWStatus(ich)));
624 AliDebug(2,Form(" Channel %i found ok according to FEEmap, starting delay computing",ich));
625 TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
626 for (Int_t ibin=0;ibin<kNBins;ibin++){
627 h1->SetBinContent(ibin+1,h2->GetBinContent(ich+1,ibin+1));
629 if(h1->Integral()<integralThr) {
631 Log(Form(" Not enough statistics for bin %i, skipping this channel",ich)); // printing message only if not in FDR runs
637 Float_t minContent=h1->Integral()*thrPar;
638 Int_t nbinsX = h1->GetNbinsX();
640 for (Int_t j=1; j<=nbinsX; j++){
642 h1->GetBinContent(j) +
643 h1->GetBinContent(j+1)+
644 h1->GetBinContent(j+2)+
645 h1->GetBinContent(j+3))>minContent){
651 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
652 // Now calculate the mean over the interval.
656 for(Int_t k=0;k<binRangeAve;k++){
657 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
658 nent=nent+h1->GetBinContent(startBin+k);
659 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
661 mean= mean/nent; //<x>
662 sumw2=sumw2/nent; //<x^2>
664 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
665 if (ich<fNChannels) {
666 Float_t delay = mean*AliTOFGeometry::TdcBinWidth()*1.E-3; // delay in ns
667 fCal->SetDelay(ich,delay); // delay in ns
668 AliDebug(2,Form("Setting delay %f (ns) for channel %i",delay,ich));
674 if (nNotStatistics!=0) Log(Form("Too little statistics for %d channels!",nNotStatistics));
681 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
685 return 6;//return error code for problems in retrieving DAQ data
691 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
694 return 6; //return error code for problems in retrieving DAQ data
697 /* check whether we don't need to update OCDB.
698 * in this case we can return without errors and
699 * the current FEE is stored in the fStatus object. */
701 AliInfo("update OCDB flag not set. Do not overwrite stored file.");
702 return 0; /* return ok */
706 AliCDBMetaData metaData;
707 metaData.SetBeamPeriod(0);
708 metaData.SetResponsible("Chiara Zampolli");
709 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineArray object for online calibration - delays.");
710 AliInfo("Storing Calibration Data");
711 resultTOFPP = Store("Calib","ParOnlineDelay",fCal, &metaData,deltaStartingRun,kTRUE);
713 Log("Some problems occurred while storing online object resulting from DAQ data processing");
716 return 8;//return error code for problems in storing DAQ data
727 //_____________________________________________________________________________
730 AliTOFPreprocessor::ProcessT0Fill()
732 // Processing data from DAQ for T0-fill measurement
734 Log("Processing T0-fill");
737 /* instance and setup CDB manager */
738 AliCDBManager *cdb = AliCDBManager::Instance();
740 if (!gGeoManager) AliGeomManager::LoadGeometry();
743 /* get params from OCDB */
744 AliCDBEntry *cdbe = NULL;
746 /* get T0-fill calibration params */
747 cdbe = GetFromOCDB("Calib", "T0FillOnlineCalib");
749 Log("cannot get \"T0FillOnlineCalib\" entry from OCDB");
752 AliTOFT0FillOnlineCalib *t0FillOnlineCalibObject = (AliTOFT0FillOnlineCalib *)cdbe->GetObject();
753 if (!t0FillOnlineCalibObject) {
754 Log("cannot get \"T0FillOnlineCalib\" object from CDB entry");
757 Float_t t0FillCalibOffset = t0FillOnlineCalibObject->GetOffset();
758 Float_t t0FillCalibCoefficient = t0FillOnlineCalibObject->GetCoefficient();
759 Log(Form("got \"T0FillOnlineCalib\" object: offset=%f coeff=%f", t0FillCalibOffset, t0FillCalibCoefficient));
761 /* get online status from OCDB */
762 cdbe = GetFromOCDB("Calib", "Status");
764 Log("cannot get \"Status\" entry from OCDB");
767 AliTOFChannelOnlineStatusArray *statusArray = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
769 Log("cannot get \"Status\" object from CDB entry");
772 Log("got \"Status\" object");
774 /* get offline calibration from OCDB */
775 cdbe = GetFromOCDB("Calib", "ParOffline");
777 Log("cannot get \"ParOffline\" entry from OCDB");
780 TObjArray *offlineArray = (TObjArray *)cdbe->GetObject();
781 AliTOFChannelOffline *channelOffline;
783 Log("cannot get \"ParOffline\" object from CDB entry");
786 Log("got \"ParOffline\" object");
788 /* get deltaBC offset from OCDB */
789 cdbe = GetFromOCDB("Calib", "DeltaBCOffset");
791 Log("cannot get \"DeltaBCOffset\" entry from OCDB");
794 AliTOFDeltaBCOffset *deltaBCOffsetObject = (AliTOFDeltaBCOffset *)cdbe->GetObject();
795 if (!deltaBCOffsetObject) {
796 Log("cannot get \"DeltaBCOffset\" object from CDB entry");
799 Int_t deltaBCOffset = deltaBCOffsetObject->GetDeltaBCOffset();
800 Log(Form("got \"DeltaBCOffset\" object: deltaBCOffset=%d (BC bins)", deltaBCOffset));
802 /* get CTP latency from OCDB */
803 cdbe = GetFromOCDB("Calib", "CTPLatency");
805 Log("cannot get \"CTPLatency\" entry from OCDB");
808 AliTOFCTPLatency *ctpLatencyObject = (AliTOFCTPLatency *)cdbe->GetObject();
809 if (!ctpLatencyObject) {
810 Log("cannot get \"CTPLatency\" object from CDB entry");
813 Float_t ctpLatency = ctpLatencyObject->GetCTPLatency();
814 Log(Form("got \"CTPLatency\" object: ctpLatency=%f (ps)", ctpLatency));
816 /* get file sources from FXS */
817 TList *fileList = GetFileSources(kDAQ, "HITS");
818 if (!fileList || fileList->GetEntries() == 0) {
819 Log("cannot get DAQ source file list or empty list");
822 Log(Form("got DAQ source file list: %d files", fileList->GetEntries()));
825 /* create tree chain using file sources */
826 TChain chain("hitTree");
827 for (Int_t ifile = 0; ifile < fileList->GetEntries(); ifile++) {
828 TObjString *str = (TObjString *)fileList->At(ifile);
829 TString filename = GetFile(kDAQ, "HITS", str->GetName());
831 Log(Form("file added to input chain: source=%s, filename=%s", str->String().Data(), filename.Data()));
833 Int_t nhits = chain.GetEntries();
834 Log(Form("input chain ready: %d hits", nhits));
836 /* setup input chain */
837 AliTOFHitField *hit = new AliTOFHitField();
838 chain.SetBranchAddress("hit", &hit);
840 /* create calib histo and geometry */
841 AliTOFcalibHisto calibHisto;
842 calibHisto.LoadCalibHisto();
843 AliTOFGeometry tofGeo;
846 Float_t c = TMath::C() * 1.e2 / 1.e12; /* cm/ps */
847 Float_t c_1 = 1. / c;
849 Int_t index, timebin, totbin, deltaBC, l0l1latency, det[5];
850 Float_t timeps, totns, corrps, length, timeexp, timezero, pos[3], latencyWindow;
853 TH1F *hT0Fill = new TH1F("hT0Fill", "T0 fill;t - t_{exp}^{(c)} (ps);", 2000, -24400., 24400.);
856 for (Int_t ihit = 0; ihit < nhits; ihit++) {
859 chain.GetEntry(ihit);
862 index = hit->GetIndex();
863 timebin = hit->GetTimeBin();
864 totbin = hit->GetTOTBin();
865 deltaBC = hit->GetDeltaBC();
866 l0l1latency = hit->GetL0L1Latency();
867 latencyWindow = statusArray->GetLatencyWindow(index) * 1.e3;
869 /* convert time in ps and tot in ns */
870 timeps = timebin * AliTOFGeometry::TdcBinWidth();
871 totns = totbin * AliTOFGeometry::ToTBinWidth() * 1.e-3;
872 /* get calibration correction in ps */
873 channelOffline = (AliTOFChannelOffline *)offlineArray->At(index);
874 if (totns < AliTOFGeometry::SlewTOTMin()) totns = AliTOFGeometry::SlewTOTMin();
875 if (totns > AliTOFGeometry::SlewTOTMax()) totns = AliTOFGeometry::SlewTOTMax();
877 for (Int_t ipar = 0; ipar < 6; ipar++) corrps += channelOffline->GetSlewPar(ipar) * TMath::Power(totns, ipar);
879 /* perform time correction */
880 timeps = timeps + (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth() + l0l1latency * AliTOFGeometry::BunchCrossingBinWidth() + ctpLatency - latencyWindow - corrps;
881 /* compute length and expected time */
882 tofGeo.GetVolumeIndices(index, det);
883 tofGeo.GetPosPar(det, pos);
885 for (Int_t i = 0; i < 3; i++) length += pos[i] * pos[i];
886 length = TMath::Sqrt(length);
887 timeexp = length * c_1;
888 /* compute time zero */
889 timezero = timeps - timeexp;
892 hT0Fill->Fill(timezero);
895 /* rebin until maximum bin has required minimum entries */
896 Int_t maxBin = hT0Fill->GetMaximumBin();
897 Float_t maxBinContent = hT0Fill->GetBinContent(maxBin);
898 Float_t binWidth = hT0Fill->GetBinWidth(maxBin);
899 while (maxBinContent < 400 && binWidth < 90.) {
901 maxBin = hT0Fill->GetMaximumBin();
902 maxBinContent = hT0Fill->GetBinContent(maxBin);
903 binWidth = hT0Fill->GetBinWidth(maxBin);
905 Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin);
907 /* rough landau fit of the edge */
908 TF1 *landau = (TF1 *)gROOT->GetFunction("landau");
909 landau->SetParameter(1, maxBinCenter);
910 Float_t fitMin = maxBinCenter - 1000.; /* fit from 10 ns before max */
911 Float_t fitMax = maxBinCenter + binWidth; /* fit until a bin width above max */
912 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
913 /* get rough landau mean and sigma to set a better fit range */
914 Float_t mean = landau->GetParameter(1);
915 Float_t sigma = landau->GetParameter(2);
916 /* better landau fit of the edge */
917 fitMin = maxBinCenter - 3. * sigma;
919 hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
921 mean = landau->GetParameter(1);
922 sigma = landau->GetParameter(2);
923 Float_t meane = landau->GetParError(1);
924 Float_t sigmae = landau->GetParError(2);
925 Log(Form("edge fit: mean = %f +- %f ps", mean, meane));
926 Log(Form("edge fit: sigma = %f +- %f ps", sigma, sigmae));
927 Float_t edge = mean - 3. * sigma;
928 Float_t edgee = TMath::Sqrt(meane * meane + 3. * sigmae * 3. * sigmae);
929 Log(Form("edge fit: edge = %f +- %f ps", edge, edgee));
930 /* apply calibration to get T0-fill from egde */
931 Float_t t0Fill = edge * t0FillCalibCoefficient + t0FillCalibOffset;
932 Log(Form("estimated T0-fill: %f ps", t0Fill));
934 /* create T0-fill object */
935 AliTOFT0Fill *t0FillObject = new AliTOFT0Fill();
936 t0FillObject->SetT0Fill(t0Fill);
938 /* store reference data */
940 AliCDBMetaData metaDataHisto;
941 metaDataHisto.SetBeamPeriod(0);
942 metaDataHisto.SetResponsible("Roberto Preghenella");
943 metaDataHisto.SetComment("online T0-fill histogram");
944 if (!StoreReferenceData("Calib","T0Fill", hT0Fill, &metaDataHisto)) {
945 Log("error while storing reference data");
951 Log("reference data successfully stored");
954 AliCDBMetaData metaData;
955 metaData.SetBeamPeriod(0);
956 metaData.SetResponsible("Roberto Preghenella");
957 metaData.SetComment("online T0-fill measurement");
958 if (!Store("Calib", "T0Fill", t0FillObject, &metaData, 0, kFALSE)) {
959 Log("error while storing T0-fill object");
965 Log("T0-fill object successfully stored");
975 //_____________________________________________________________________________
977 UInt_t AliTOFPreprocessor::ProcessPulserData()
979 // Processing Pulser Run data for TOF channel status
981 Log("Processing Pulser");
984 AliError("No valid fStatus found, some errors must have occurred!!");
988 TH1::AddDirectory(0);
990 Bool_t resultPulserRef=kFALSE;
991 Bool_t resultPulser=kFALSE;
993 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
994 TH1S * htofPulser = new TH1S("hTOFpulser","histo with signals on TOF during pulser", kSize,-0.5,kSize-0.5);
995 for (Int_t ibin =1;ibin<=kSize;ibin++){
996 htofPulser->SetBinContent(ibin,-1);
1001 TFile * daqFile=0x0;
1004 //retrieving Pulser data
1005 TList* listPulser = GetFileSources(kDAQ, "PULSER");
1006 if (listPulser !=0x0 && listPulser->GetEntries()!=0)
1008 AliInfo("The following sources produced files with the id PULSER");
1009 listPulser->Print();
1011 for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
1012 Int_t nPulserSource = 0;
1013 TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
1014 AliInfo(Form("found source %s", str->String().Data()));
1015 // file to be stored run per run
1016 TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
1017 if (fileNamePulser.Length()>0){
1018 // storing refernce data
1019 AliInfo(Form("Got the file %s, now we can process pulser data.", fileNamePulser.Data()));
1020 daqFile = new TFile(fileNamePulser.Data(),"READ");
1021 h1 = (TH1S*) daqFile->Get("hTOFpulser");
1022 for (Int_t ibin=0;ibin<kSize;ibin++){
1023 if ((h1->GetBinContent(ibin+1))!=-1){
1024 if ((htofPulser->GetBinContent(ibin+1))==-1){
1025 htofPulser->SetBinContent(ibin+1,h1->GetBinContent(ibin+1));
1028 Log(Form("Something strange occurred during Pulser run, channel %i already read by another LDC, please check!",ibin));
1033 // elaborating infos
1036 Int_t nreadNotEmpty=0;
1037 for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
1039 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)));
1040 /* check whether channel has been read out during current run.
1041 * if the status is bad it means it has not been read out.
1042 * in this case skip channel in order to not affect the mean */
1043 if (fStatus->GetHWStatus(ientry-1) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1047 if (h1->GetBinContent(ientry)==-1) continue;
1049 if (h1->GetBinContent(ientry)>0) {
1051 AliDebug(2,Form(" channel %i is ok with entry = %f; so far %i channels added ",ientry-1,h1->GetBinContent(ientry),nreadNotEmpty));
1053 mean+=h1->GetBinContent(ientry);
1059 AliDebug(2,Form(" nread = %i , nreadNotEmpty = %i, mean = %f",nread,nreadNotEmpty,mean));
1060 for (Int_t ich =0;ich<fNChannels;ich++){
1061 if (h1->GetBinContent(ich+1)==-1) continue;
1062 AliDebug(3,Form(" channel %i pulser status before pulser = %i",ich,(Int_t)fStatus->GetPulserStatus(ich)));
1064 /* check whether channel has been read out during current run.
1065 * if the status is bad it means it has not been read out.
1066 * in this case skip channel in order to leave its status
1068 if (fStatus->GetHWStatus(ich) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1071 if (h1->GetBinContent(ich+1)<0.05*mean){
1072 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserBad); // bad status for pulser
1073 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)));
1076 fStatus->SetPulserStatus(ich,AliTOFChannelOnlineStatusArray::kTOFPulserOk); // good status for pulser
1077 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)));
1082 Log("No channels read!! No action taken, keeping old status");
1091 Log("The input data file from DAQ (pulser) was not found, TOF exiting from Shuttle ");
1099 return 10;//return error code for failure in retrieving Ref Data
1101 AliDebug(2,Form(" Number of channels processed during pulser run from source %i = %i",jj, nPulserSource));
1103 AliDebug(2,Form(" Number of channels processed during pulser run = %i",nPulser));
1108 Log("The input data file list from DAQ (pulser) was not found, TOF exiting from Shuttle ");
1115 return 10;//return error code for failure in retrieving Ref Data
1120 AliCDBMetaData metaData;
1121 metaData.SetBeamPeriod(0);
1122 metaData.SetResponsible("Chiara Zampolli");
1123 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Pulser run.");
1124 AliInfo("Storing Calibration Data from Pulser Run");
1125 resultPulser = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
1127 Log("Some problems occurred while storing online object resulting from Pulser data processing");
1134 return 11;//return error code for problems in storing Pulser data
1139 AliCDBMetaData metaDataHisto;
1140 metaDataHisto.SetBeamPeriod(0);
1141 metaDataHisto.SetResponsible("Chiara Zampolli");
1143 sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
1144 metaDataHisto.SetComment(comment);
1145 AliInfo("Storing Reference Data");
1146 resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
1147 if (!resultPulserRef){
1148 Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
1155 return 9;//return error code for failure in storing Ref Data
1171 //_____________________________________________________________________________
1173 UInt_t AliTOFPreprocessor::ProcessNoiseData()
1176 // Processing Noise Run data for TOF channel status
1178 Log("Processing Noise");
1181 AliError("No valid fStatus found, some errors must have occurred!!");
1185 Float_t noiseThr = 1; // setting default threshold for noise to 1 Hz
1186 // reading config map
1187 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
1189 Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
1192 TMap *configMap = (TMap*)cdbEntry->GetObject();
1194 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
1197 TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
1199 TString tmpstr = strNoiseThr->GetString();
1200 noiseThr = tmpstr.Atoi();
1203 Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
1211 TH1::AddDirectory(0);
1213 Bool_t resultNoiseRef=kFALSE;
1214 Bool_t resultNoise=kFALSE;
1216 static const Int_t kSize = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
1217 TH1F * htofNoise = new TH1F("hTOFnoise","histo with signals on TOF during noise", kSize,-0.5,kSize-0.5);
1218 for (Int_t ibin =1;ibin<=kSize;ibin++){
1219 htofNoise->SetBinContent(ibin,-1);
1224 TFile * daqFile=0x0;
1229 Int_t nNoisyChannels = 0;
1230 Int_t nNotNoisyChannels = 0;
1231 Int_t nChannelsFromDA = 0;
1232 Int_t nMatchingWindowNullNonZero = 0;
1233 Int_t nMatchingWindowNullEqualZero = 0;
1235 // retrieving Noise data
1236 TList* listNoise = GetFileSources(kDAQ, "NOISE");
1237 if (listNoise !=0x0 && listNoise->GetEntries()!=0)
1239 AliInfo("The following sources produced files with the id NOISE");
1241 for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
1242 Int_t nNoiseSource = 0;
1243 TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
1244 AliInfo(Form("found source %s", str->String().Data()));
1245 // file to be stored run per run
1246 TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
1247 if (fileNameNoise.Length()>0){
1248 // storing reference data
1249 AliInfo(Form("Got the file %s, now we can process noise data.", fileNameNoise.Data()));
1250 daqFile = new TFile(fileNameNoise.Data(),"READ");
1251 h1 = (TH1F*) daqFile->Get("hTOFnoise");
1252 for (Int_t ibin=0;ibin<kSize;ibin++){
1253 if ((h1->GetBinContent(ibin+1))!=-1){
1255 // checking the matching window for current channel
1256 if (fMatchingWindow[ibin] == 0){
1257 Log(Form("Matching window for channel %i null, but the channel was read by the LDC! skipping channel, BUT Please check!",ibin));
1258 if ((h1->GetBinContent(ibin+1))!=0) nMatchingWindowNullNonZero++;
1259 if ((h1->GetBinContent(ibin+1))==0) nMatchingWindowNullEqualZero++;
1262 if ((htofNoise->GetBinContent(ibin+1))==-1){
1263 htofNoise->SetBinContent(ibin+1,h1->GetBinContent(ibin+1)/(fMatchingWindow[ibin]*1.E-9));
1264 if ((h1->GetBinContent(ibin+1))!= 0) AliDebug(2,Form("Channel = %i, Matching window = %i, Content = %f", ibin, fMatchingWindow[ibin], htofNoise->GetBinContent(ibin+1)));
1267 Log(Form("Something strange occurred during Noise run, channel %i already read by another LDC, please check!",ibin));
1272 Log(Form(" Number of channels processed during noise run from source %i = %i",jj, nNoiseSource));
1281 Log("The input data file from DAQ (noise) was not found, TOF exiting from Shuttle ");
1290 if (fMatchingWindow){
1291 delete [] fMatchingWindow;
1292 fMatchingWindow = 0;
1294 return 13;//return error code for failure in retrieving Ref Data
1300 Log("The input data file list from DAQ (noise) was not found, TOF exiting from Shuttle ");
1307 if (fMatchingWindow){
1308 delete [] fMatchingWindow;
1309 fMatchingWindow = 0;
1311 return 13;//return error code for failure in retrieving Ref Data
1314 // elaborating infos to set NOISE status
1315 for (Int_t ich =0;ich<fNChannels;ich++){
1316 if (htofNoise->GetBinContent(ich+1)== -1) continue;
1320 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)));
1321 //AliDebug(2,Form( " channel %i status before noise = %i",ich,(Int_t)fStatus->GetNoiseStatus(ich)));
1323 /* check whether channel has been read out during current run.
1324 * if the status is bad it means it has not been read out.
1325 * in this case skip channel in order to leave its status
1328 if ((fStatus->GetHWStatus(ich)) == AliTOFChannelOnlineStatusArray::kTOFHWBad)
1332 if (htofNoise->GetBinContent(ich+1) >= noiseThr){
1333 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseBad); // bad status for noise
1334 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)));
1338 fStatus->SetNoiseStatus(ich,AliTOFChannelOnlineStatusArray::kTOFNoiseOk); // good status for noise
1339 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)));
1340 nNotNoisyChannels++;
1344 Log(Form(" Number of channels processed by DA during noise run, independetly from TOFFEE = %i",nChannelsFromDA));
1345 Log(Form(" Number of channels processed during noise run (that were ON according to TOFFEE) = %i",nNoise));
1346 Log(Form(" Number of noisy channels found during noise run = %i",nNoisyChannels));
1347 Log(Form(" Number of not noisy channels found during noise run = %i",nNotNoisyChannels));
1348 Log(Form(" Number of channels with matching window NULL (so skipped), but Non Zero content = %i",nMatchingWindowNullNonZero));
1349 Log(Form(" Number of channels with matching window NULL (so skipped), and Zero content = %i",nMatchingWindowNullEqualZero));
1357 AliCDBMetaData metaData;
1358 metaData.SetBeamPeriod(0);
1359 metaData.SetResponsible("Chiara Zampolli");
1360 metaData.SetComment("This preprocessor fills an AliTOFChannelOnlineStatusArray object after a Noise run.");
1361 AliInfo("Storing Calibration Data from Noise Run");
1362 resultNoise = Store("Calib","Status",fStatus, &metaData,0,kTRUE);
1364 Log("Some problems occurred while storing online object resulting from Noise data processing");
1371 if (fMatchingWindow){
1372 delete [] fMatchingWindow;
1373 fMatchingWindow = 0;
1375 return 14;//return error code for problems in storing Noise data
1380 AliCDBMetaData metaDataHisto;
1381 metaDataHisto.SetBeamPeriod(0);
1382 metaDataHisto.SetResponsible("Chiara Zampolli");
1384 sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
1385 metaDataHisto.SetComment(comment);
1386 AliInfo("Storing Reference Data");
1387 resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
1388 if (!resultNoiseRef){
1389 Log("some problems occurred::No Reference Data for noise stored");
1396 if (fMatchingWindow){
1397 delete [] fMatchingWindow;
1398 fMatchingWindow = 0;
1400 return 12;//return error code for failure in storing Ref Data
1412 if (fMatchingWindow){
1413 delete [] fMatchingWindow;
1414 fMatchingWindow = 0;
1419 //_____________________________________________________________________________
1421 UInt_t AliTOFPreprocessor::ProcessFEEData()
1423 // Processing Pulser Run data for TOF channel status
1424 // dummy for the time being
1426 Log("Processing FEE");
1428 //Bool_t updateOCDB = kFALSE;
1429 AliTOFFEEReader feeReader;
1431 TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
1433 /* load current TOF FEE(dump) from DCS FXS,
1434 * setup TOFFEEdump object */
1436 const char * toffeeFileName = GetFile(kDCS,"TofFeeMap","");
1437 AliInfo(Form("toffee file name = %s", toffeeFileName));
1438 if (toffeeFileName == NULL) {
1441 AliTOFFEEDump feedump;
1442 feedump.ReadFromFile(toffeeFileName);
1444 /* load current TOF FEE(light) config from DCS FXS, parse,
1445 * fill current FEE histogram and set FEE status */
1447 const char * nameFile = GetFile(kDCS,"TofFeeLightMap","");
1448 AliInfo(Form("toffeeLight file name = %s",nameFile));
1449 if (nameFile == NULL) {
1452 feeReader.LoadFEElightConfig(nameFile);
1453 Int_t parseFee = feeReader.ParseFEElightConfig();
1454 AliDebug(2,Form("%i enabled channels found in FEElight configuration",parseFee));
1455 /* load stored TOF FEE from OCDB and compare it with current FEE.
1456 * if stored FEE is different from current FEE set update flag.
1457 * if there is no stored FEE in OCDB set update flag */
1459 fMatchingWindow = new Int_t[fNChannels];
1460 fLatencyWindow = new Int_t[fNChannels];
1462 AliCDBEntry *cdbEntry = GetFromOCDB("Calib","Status");
1464 /* no CDB entry found. set update flag */
1465 Log(" ************ WARNING ************");
1466 Log("No CDB Status entry found, creating a new one!");
1467 Log(" *********************************");
1468 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
1469 //updateOCDB = kTRUE;
1470 fIsStatusMapChanged = kTRUE;
1473 if (cdbEntry) cdbEntry->SetOwner(kFALSE);
1474 /* CDB entry OK. loop over channels */
1475 fStatus = (AliTOFChannelOnlineStatusArray*) cdbEntry->GetObject();
1478 /* cehck whether status object has latency window data */
1479 if (!fStatus->HasLatencyWindow()) {
1480 /* create new status object and update OCDB */
1481 Log(" ************ WARNING ************");
1482 Log("CDB Status entry found but has no latency window data, creating a new one!");
1483 Log(" *********************************");
1485 fStatus = new AliTOFChannelOnlineStatusArray(fNChannels);
1486 //updateOCDB = kTRUE;
1487 fIsStatusMapChanged = kTRUE;
1490 for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
1491 //AliDebug(2,Form("********** channel %i",iChannel));
1492 /* compare current FEE channel status with stored one
1493 * if different set update flag and break loop */
1494 //AliDebug(2,Form( " channel %i status before FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1495 fMatchingWindow[iChannel] = feeReader.GetMatchingWindow(iChannel);
1496 fLatencyWindow[iChannel] = feeReader.GetLatencyWindow(iChannel);
1497 if (feeReader.IsChannelEnabled(iChannel)) {
1498 hCurrentFEE.SetBinContent(iChannel + 1, 1);
1499 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWOk){
1500 //updateOCDB = kTRUE;
1501 fIsStatusMapChanged = kTRUE;
1502 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWOk);
1503 AliDebug(3,Form( " changed into enabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1505 if (fStatus->GetLatencyWindow(iChannel)!=fLatencyWindow[iChannel]){
1506 //updateOCDB = kTRUE;
1507 fIsStatusMapChanged = kTRUE;
1508 fStatus->SetLatencyWindow(iChannel,fLatencyWindow[iChannel]);
1509 AliDebug(3,Form( " changed latency window: channel %i latency window after FEE = %i",iChannel,fStatus->GetLatencyWindow(iChannel)));
1513 if (fStatus->GetHWStatus(iChannel)!=AliTOFChannelOnlineStatusArray::kTOFHWBad){
1514 //updateOCDB = kTRUE;
1515 fIsStatusMapChanged = kTRUE;
1516 fStatus->SetHWStatus(iChannel,AliTOFChannelOnlineStatusArray::kTOFHWBad);
1517 AliDebug(3,Form( " changed into disabled: channel %i status after FEE = %i",iChannel,(Int_t)fStatus->GetHWStatus(iChannel)));
1523 /* check whether we don't have to store reference data.
1524 * in this case we return without errors. */
1525 if (fStoreRefData) {
1526 /* store reference data */
1527 AliCDBMetaData metaDataHisto;
1528 metaDataHisto.SetBeamPeriod(0);
1529 metaDataHisto.SetResponsible("Roberto Preghenella");
1530 metaDataHisto.SetComment("This preprocessor stores the FEE Ref data of the current run.");
1531 AliInfo("Storing FEE reference data");
1532 /* store FEE reference data */
1533 if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
1535 Log("problems while storing FEE reference data");
1540 return 18; /* error return code for problems while storing FEE reference data */
1543 /* store TOF FEE dump reference data */
1544 AliCDBMetaData metaDatadump;
1545 metaDatadump.SetBeamPeriod(0);
1546 metaDatadump.SetResponsible("Roberto Preghenella");
1547 metaDatadump.SetComment("This preprocessor stores the TOF FEE dump Ref data of the current run.");
1548 AliInfo("Storing TOF FEE dump reference data");
1549 /* store FEE reference data */
1550 if (!StoreReferenceData("Calib", "FEEDump", &feedump, &metaDatadump)) {
1552 Log("problems while storing TOF FEE dump reference data");
1553 return 18; /* error return code for problems while storing FEE reference data */
1561 //_____________________________________________________________________________
1563 UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap)
1566 // Main AliTOFPreprocessor method called by SHUTTLE
1569 TString runType = GetRunType();
1570 Log(Form("RunType %s",runType.Data()));
1574 /* always process FEE data */
1575 Int_t iresultFEE = ProcessFEEData();
1576 if (iresultFEE != 0)
1579 if (runType == "PULSER") {
1580 Int_t iresultPulser = ProcessPulserData();
1581 return iresultPulser;
1584 if (runType == "NOISE") { // for the time being associating noise runs with pedestal runs; proper run type to be defined
1585 Int_t iresultNoise = ProcessNoiseData();
1586 return iresultNoise;
1589 if (runType == "PHYSICS") {
1590 // Int_t iresultDAQ = ProcessOnlineDelays();
1591 Int_t iresultDAQ = ProcessT0Fill();
1592 if (iresultDAQ != 0) {
1596 Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
1597 Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap);
1598 return iresultDCS+iResultHVandLVdps;
1607 //_____________________________________________________________________________
1610 AliTOFPreprocessor::FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal)
1613 * fill with cosmic calibration
1616 Log(" Using cosmic-ray calibration.");
1618 AliTOFcalibHisto calibHisto;
1619 calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE);
1620 Log(Form(" loading calibration histograms from %s", calibHisto.GetCalibHistoFileName()));
1621 Log(Form(" loading calibration parameters from %s", calibHisto.GetCalibParFileName()));
1622 calibHisto.LoadCalibPar();
1624 /* loop over channel index */
1625 for (Int_t iIndex = 0; iIndex < fNChannels; iIndex++) {
1626 cal->SetDelay(iIndex, calibHisto.GetFullCorrection(iIndex));
1631 //_____________________________________________________________________________
1634 AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal)
1637 * fill with cosmic calibration
1640 Log(" Using cable-length map.");
1641 AliTOFRawStream tofrs;
1642 Int_t det[5], dummy, index;
1643 Float_t cableTimeShift;
1645 /* temporarly disable warnings */
1646 AliLog::EType_t logLevel = (AliLog::EType_t)AliLog::GetGlobalLogLevel();
1647 AliLog::SetGlobalLogLevel(AliLog::kError);
1649 /* loop over EO indeces */
1650 for (Int_t iddl = 0; iddl < 72; iddl++)
1651 for (Int_t islot = 3; islot <= 12; islot++)
1652 for (Int_t ichain = 0; ichain < 2; ichain++)
1653 for (Int_t itdc = 0; itdc < 15; itdc++)
1654 for (Int_t ichannel = 0; ichannel < 8; ichannel++) {
1657 tofrs.EquipmentId2VolumeId(iddl, islot, ichain, itdc, ichannel, det);
1659 /* swap det[3] and det[4] indeces (needed to obtain correct channel index) */
1664 /* check DO index */
1665 if (det[0] < 0 || det[0] > 17 ||
1666 det[1] < 0 || det[1] > 4 ||
1667 det[2] < 0 || det[2] > 18 ||
1668 det[3] < 0 || det[3] > 1 ||
1669 det[4] < 0 || det[4] > 47)
1672 /* get channel index */
1673 index = AliTOFGeometry::GetIndex(det);
1675 /* get cable time shift */
1676 cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);
1679 if (index<fNChannels) {
1680 cal->SetDelay(index,cableTimeShift); // delay in ns
1681 AliDebug(2,Form("Setting delay %f (ns) for channel %i",cableTimeShift,index));
1684 } /* loop over EO indeces */
1686 /* re-enable warnings */
1687 AliLog::SetGlobalLogLevel(logLevel);