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 Revision 1.1 2006/10/26 09:09:29 arcelli
19 prototype for the TOF Shuttle preprocessor (C.Zampolli)
23 #include "AliTOFPreprocessor.h"
25 #include "AliCDBMetaData.h"
27 #include "AliTOFDataDCS.h"
29 #include "TObjArray.h"
30 #include "TObjString.h"
31 #include "AliTOFCalOnline.h"
32 #include "AliTOFChannelOnline.h"
33 #include "AliTOFGeometryV5.h"
34 #include "TTimeStamp.h"
41 // TOF preprocessor class.
42 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
43 // processes them. The result is then written to the CDB.
44 // analogously, it takes data form DAQ (both at Run level and inclusive -
45 // of all the runs - level, processes them, and stores both Reference Data
46 // and Online Calibration files in the CDB.
49 ClassImp(AliTOFPreprocessor)
51 const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean
53 //_____________________________________________________________________________
55 AliTOFPreprocessor::AliTOFPreprocessor(const char* detector, AliShuttleInterface* shuttle) :
56 AliPreprocessor(detector, shuttle),
65 //_____________________________________________________________________________
67 AliTOFPreprocessor::~AliTOFPreprocessor()
72 //______________________________________________________________________________
73 void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
76 // Creates AliTOFDataDCS object
78 AliPreprocessor::Initialize(run, startTime, endTime);
80 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
81 TTimeStamp(startTime).AsString(),
82 TTimeStamp(endTime).AsString()));
84 fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
86 fTOFGeometry = new AliTOFGeometryV5();
87 fCal = new AliTOFCalOnline(fTOFGeometry);
91 //_____________________________________________________________________________
93 UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
95 // Fills data into a AliTOFDataDCS object
99 UInt_t resultDAQRef=0;
105 AliInfo(Form("No DCS map found "));
108 // The processing of the DCS input data is forwarded to AliTOFDataDCS
109 fData->ProcessData(*dcsAliasMap);
110 AliCDBMetaData metaDataDCS;
111 metaDataDCS.SetBeamPeriod(0);
112 metaDataDCS.SetResponsible("Chiara Zampolli");
113 metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object."); resultDCS = Store("Calib","DCSData",fData, &metaDataDCS);
116 AliInfo(Form("some problems occurred while storing DCS data processing results"));
123 TList* list = GetFileSources(kDAQ, "DELAYS");
127 AliInfo("The following sources produced files with the id DELAYS");
129 for (Int_t jj=0;jj<list->GetEntries();jj++){
130 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
131 AliInfo(Form("found source %s", str->String().Data()));
132 // file to be stored run per run
133 const char* fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
135 AliInfo(Form("Got the file %s, now we can store the Reference Data for the current Run.", fileNameRun));
136 daqFile = new TFile(fileNameRun,"READ");
137 fArray = (TObjArray*) daqFile->Get("ciccio");
138 AliCDBMetaData metaDataHisto;
139 metaDataHisto.SetBeamPeriod(0);
140 metaDataHisto.SetResponsible("Chiara Zampolli");
141 metaDataHisto.SetComment("This preprocessor stores the array of histos object as Reference Data.");
142 resultDAQRef = StoreReferenceData("Calib","DAQData",fArray, &metaDataHisto);
143 result+=resultDAQRef*2;
145 AliInfo(Form("some problems occurred::No Reference Data stored"));
152 AliError(Form("The file %s does not exist",fileNameRun));
155 // file with summed histos, to extract calib params
156 const char *fileName = GetFile(kDAQ, "DELAYS", str->GetName());
158 AliInfo(Form("Got the file %s, now we can extract some values.", fileName));
160 daqFile = new TFile(fileName,"READ");
161 fArray = (TObjArray*) daqFile->Get("ciccio");
163 AliInfo(Form("some problems occurred:: No histo array retrieved"));
167 Int_t nentries=(Int_t)fArray->GetEntries();
168 AliInfo(Form(" il numero di entries e' = %i ", nentries));
169 Int_t npads = fCal->NPads();
170 for (Int_t i=0 ; i<nentries; i++){
172 TH1F * h1 = (TH1F*)fArray->At(i);
173 Float_t minContent=h1->Integral()*0.01; //for the time being
174 //we use integral() since we simulate landau distribution
175 //Float_t minContent=h1->GetEntries()*0.01;
176 Int_t nbinsX = h1->GetNbinsX();
178 for (Int_t j=1; j<=nbinsX; j++){
180 h1->GetBinContent(j) +
181 h1->GetBinContent(j+1)+
182 h1->GetBinContent(j+2)+
183 h1->GetBinContent(j+3))>minContent){
189 if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",i));
190 // Now calculate the mean over the interval.
194 for(Int_t k=0;k<fgkBinRangeAve;k++){
195 mean=mean+h1->GetBinCenter(startBin+k)*h1->GetBinContent(startBin+k);
196 nent=nent+h1->GetBinContent(startBin+k);
197 sumw2=sumw2+(h1->GetBinCenter(startBin+k))*(h1->GetBinCenter(startBin+k))*(h1->GetBinContent(startBin+k));
200 mean= mean/nent; //<x>
201 sumw2=sumw2/nent; //<x^2>
203 rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
205 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"));