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 **************************************************************************/
20 #include "AliTOFPreprocessor.h"
22 #include "AliCDBMetaData.h"
24 #include "AliTOFDataDCS.h"
26 #include "TObjArray.h"
27 #include "TObjString.h"
28 #include "AliTOFCalOnline.h"
29 #include "AliTOFChannelOnline.h"
30 #include "AliTOFGeometryV5.h"
31 #include "TTimeStamp.h"
38 // TOF preprocessor class.
39 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
40 // processes them. The result is then written to the CDB.
41 // analogously, it takes data form DAQ (both at Run level and inclusive -
42 // of all the runs - level, processes them, and stores both Reference Data
43 // and Online Calibration files in the CDB.
46 ClassImp(AliTOFPreprocessor)
48 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
50 //_____________________________________________________________________________
52 AliTOFPreprocessor::AliTOFPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
53 AliPreprocessor(detector, shuttle),
62 //_____________________________________________________________________________
64 AliTOFPreprocessor::~AliTOFPreprocessor()
69 //______________________________________________________________________________
70 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
73 // Creates AliTOFDataDCS object
75 AliPreprocessor::Initialize(run, startTime, endTime);
77 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
78 TTimeStamp(startTime).AsString(),
79 TTimeStamp(endTime).AsString()));
81 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
82 fArray = new TObjArray();
83 fTOFGeometry = new AliTOFGeometryV5();
84 fCal = new AliTOFCalOnline(fTOFGeometry);
88 //_____________________________________________________________________________
90 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
92 // Fills data into a AliTOFDataDCS object
96 UInt_t resultDAQRef=0;
102 AliInfo(Form("No DCS map found "));
105 // The processing of the DCS input data is forwarded to AliTOFDataDCS
106 fData->ProcessData(*dcsAliasMap);
107 AliCDBMetaData metaDataDCS;
108 metaDataDCS.SetBeamPeriod(0);
109 metaDataDCS.SetResponsible("Chiara Zampolli");
110 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); resultDCS = Store("Calib","DCSData",fData, &metaDataDCS);
113 AliInfo(Form("some problems occurred while storing DCS data processing results"));
120 TList* list = GetFileSources(kDAQ, "DELAYS");
124 AliInfo("The following sources produced files with the id DELAYS");
126 for (Int_t jj=0;jj<list->GetEntries();jj++){
127 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
128 AliInfo(Form("found source %s", str->String().Data()));
129 // file to be stored run per run
130 const char* fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
132 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun));
133 daqFile = new TFile(fileNameRun,"READ");
134 fArray = (TObjArray*) daqFile->Get("ciccio");
135 AliCDBMetaData metaDataHisto;
136 metaDataHisto.SetBeamPeriod(0);
137 metaDataHisto.SetResponsible("Chiara Zampolli");
138 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
139 resultDAQRef = StoreReferenceData("Calib","DAQData",fArray, &metaDataHisto);
140 result+=resultDAQRef*2;
142 AliInfo(Form("some problems occurred::No Reference Data stored"));
149 AliError(Form("The file %s does not exist",fileNameRun));
152 // file with summed histos, to extract calib params
153 const char *fileName = GetFile(kDAQ, "DELAYS", str->GetName());
155 AliInfo(Form("Got the file %s, now we can extract some values.", fileName));
157 daqFile = new TFile(fileName,"READ");
158 fArray = (TObjArray*) daqFile->Get("ciccio");
160 AliInfo(Form("some problems occurred:: No histo array retrieved"));
164 Int_t nentries=(Int_t)fArray->GetEntries();
165 AliInfo(Form(" il numero di entries e' = %i ", nentries));
166 Int_t npads = fCal->NPads();
167 TH1F *h1 = new TH1F();
168 for (Int_t i=0 ; i<nentries; i++){
170 h1 = (TH1F*)fArray->At(i);
171 Float_t minContent=h1->Integral()*0.01; //for the time being
172 //we use integral() since we simulate landau distribution
173 //Float_t minContent=h1->GetEntries()*0.01;
174 Int_t nbinsX = h1->GetNbinsX();
176 for (Int_t j=1; j<=nbinsX; j++){
178 h1->GetBinContent(j) +
179 h1->GetBinContent(j+1)+
180 h1->GetBinContent(j+2)+
181 h1->GetBinContent(j+3))>minContent){
187 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",i));
188 // Now calculate the mean over the interval.
192 for(Int_t k=0;k<fgkBinRangeAve;k++){
193 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
194 nent=nent+h1->GetBinContent(startBin+k);
195 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
198 mean= mean/nent; //<x>
199 sumw2=sumw2/nent; //<x^2>
201 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
203 AliTOFChannelOnline * ch = fCal->GetChannel(i);
212 AliCDBMetaData metaData;
213 metaData.SetBeamPeriod(0);
214 metaData.SetResponsible("Chiara Zampolli");
215 metaData.SetComment("This preprocessor fills an AliTOFCal object.");
216 resultDAQ = Store("Calib","OnlineDelay",fCal, &metaData);
217 result+=resultDAQ*2*2;
220 AliError(Form("The file %s does not exist",fileName));
225 AliInfo(Form("Problem: no list found"));