1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include <Riostream.h>
28 #include <TObjArray.h>
29 #include <TObjString.h>
30 #include <TTimeStamp.h>
32 #include "AliCDBMetaData.h"
34 #include "AliTOFCalOnline.h"
35 #include "AliTOFChannelOnline.h"
36 #include "AliTOFDataDCS.h"
37 #include "AliTOFGeometryV5.h"
38 #include "AliTOFPreprocessor.h"
44 // TOF preprocessor class.
45 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
46 // processes them. The result is then written to the CDB.
47 // analogously, it takes data form DAQ (both at Run level and inclusive -
48 // of all the runs - level, processes them, and stores both Reference Data
49 // and Online Calibration files in the CDB.
52 ClassImp(AliTOFPreprocessor)
54 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
55 const Double_t AliTOFPreprocessor::fgkThrPar = 0.013; // parameter used to trigger the calculation of the delay
57 //_____________________________________________________________________________
59 AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
60 AliPreprocessor("TOF", shuttle),
69 //_____________________________________________________________________________
71 AliTOFPreprocessor::~AliTOFPreprocessor()
84 //______________________________________________________________________________
85 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
88 // Creates AliTOFDataDCS object
90 AliPreprocessor::Initialize(run, startTime, endTime);
92 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
93 TTimeStamp(startTime).AsString(),
94 TTimeStamp(endTime).AsString()));
96 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
98 fTOFGeometry = new AliTOFGeometryV5();
99 fCal = new AliTOFCalOnline(fTOFGeometry);
103 //_____________________________________________________________________________
105 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
107 // Fills data into a AliTOFDataDCS object
109 TH1::AddDirectory(0);
112 UInt_t resultDAQRef=0;
118 Log("No DCS map found");
121 // The processing of the DCS input data is forwarded to AliTOFDataDCS
122 fData->ProcessData(*dcsAliasMap);
123 AliCDBMetaData metaDataDCS;
124 metaDataDCS.SetBeamPeriod(0);
125 metaDataDCS.SetResponsible("Chiara Zampolli");
126 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); resultDCS = Store("Calib","DCSData",fData, &metaDataDCS);
127 // result+=resultDCS;
129 Log("Some problems occurred while storing DCS data processing results");
138 //retrieving data at Run level
139 TList* list = GetFileSources(kDAQ, "RUNLevel");
142 AliInfo("The following sources produced files with the id RUNLevel");
144 for (Int_t jj=0;jj<list->GetEntries();jj++){
145 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
146 AliInfo(Form("found source %s", str->String().Data()));
147 // file to be stored run per run
148 TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
149 if (fileNameRun.Length()>0){
150 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun.Data()));
151 daqFile = new TFile(fileNameRun.Data(),"READ");
152 fh2 = (TH2S*) daqFile->Get("htof");
153 AliCDBMetaData metaDataHisto;
154 metaDataHisto.SetBeamPeriod(0);
155 metaDataHisto.SetResponsible("Chiara Zampolli");
156 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
157 resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto);
158 // result+=resultDAQRef*2;
160 Log("some problems occurred::No Reference Data stored, still going on (please check!)");
167 Log("The input data file from DAQ (run-level) was not found, still going on with Cumulative data file (please check!) ");
172 Log("The input data file list from DAQ (run-level) was not found, still going on with Cumulative data file (please check!) ");
175 //Total files, with summed histos
177 TList* listTot = GetFileSources(kDAQ, "DELAYS");
180 AliInfo("The following sources produced files with the id DELAYS");
182 for (Int_t jj=0;jj<listTot->GetEntries();jj++){
183 TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
184 AliInfo(Form("found source %s", str->String().Data()));
186 // file with summed histos, to extract calib params
187 TString fileName = GetFile(kDAQ, "DELAYS", str->GetName());
188 if (fileName.Length()>0){
189 AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
191 daqFile = new TFile(fileName.Data(),"READ");
192 fh2 = (TH2S*) daqFile->Get("htoftot");
194 Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
199 static const Int_t size=fh2->GetNbinsX();
200 static const Int_t nbins=fh2->GetNbinsY();
201 static const Double_t xbinmin=fh2->GetYaxis()->GetBinLowEdge(1);
202 Int_t npads = fCal->NPads();
204 Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
208 for (Int_t ich=0;ich<size;ich++){
209 TH1S *h1 = new TH1S("h1","h1",nbins,xbinmin-0.5,nbins*1.+xbinmin-0.5);
210 for (Int_t ibin=0;ibin<nbins;ibin++){
211 h1->SetBinContent(ibin+1,fh2->GetBinContent(ich+1,ibin+1));
214 Float_t minContent=h1->Integral()*fgkThrPar;
215 Int_t nbinsX = h1->GetNbinsX();
217 for (Int_t j=1; j<=nbinsX; j++){
219 h1->GetBinContent(j) +
220 h1->GetBinContent(j+1)+
221 h1->GetBinContent(j+2)+
222 h1->GetBinContent(j+3))>minContent){
228 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",ich));
229 // Now calculate the mean over the interval.
233 for(Int_t k=0;k<fgkBinRangeAve;k++){
234 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
235 nent=nent+h1->GetBinContent(startBin+k);
236 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
238 mean= mean/nent; //<x>
239 sumw2=sumw2/nent; //<x^2>
241 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
243 AliTOFChannelOnline * ch = fCal->GetChannel(ich);
252 AliCDBMetaData metaData;
253 metaData.SetBeamPeriod(0);
254 metaData.SetResponsible("Chiara Zampolli");
255 metaData.SetComment("This preprocessor fills an AliTOFCal object.");
256 resultDAQ = Store("Calib","OnlineDelay",fCal, &metaData);
258 Log("Some problems occurred while storing DAQ data processing results");
263 Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle");
269 Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
279 if(resultDCS ==2|| resultDAQ ==2) {