]>
Commit | Line | Data |
---|---|---|
c9fe8530 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
56071a73 | 18 | Revision 1.1 2006/10/26 09:09:29 arcelli |
19 | prototype for the TOF Shuttle preprocessor (C.Zampolli) | |
20 | ||
c9fe8530 | 21 | */ |
22 | ||
23 | #include "AliTOFPreprocessor.h" | |
24 | ||
25 | #include "AliCDBMetaData.h" | |
26 | #include "AliLog.h" | |
27 | #include "AliTOFDataDCS.h" | |
28 | #include "TFile.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" | |
35 | #include "TH1F.h" | |
36 | ||
37 | class TF1; | |
38 | class AliDCSValue; | |
39 | class AliTOFGeometry; | |
40 | ||
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. | |
47 | ||
48 | ||
49 | ClassImp(AliTOFPreprocessor) | |
50 | ||
51 | const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | ||
55 | AliTOFPreprocessor::AliTOFPreprocessor(const char* detector, AliShuttleInterface* shuttle) : | |
56 | AliPreprocessor(detector, shuttle), | |
57 | fData(0), | |
58 | fArray(0), | |
59 | fCal(0), | |
60 | fTOFGeometry(0) | |
61 | { | |
62 | // constructor | |
63 | } | |
64 | ||
65 | //_____________________________________________________________________________ | |
66 | ||
67 | AliTOFPreprocessor::~AliTOFPreprocessor() | |
68 | { | |
69 | // destructor | |
70 | } | |
71 | ||
72 | //______________________________________________________________________________ | |
73 | void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
74 | UInt_t endTime) | |
75 | { | |
76 | // Creates AliTOFDataDCS object | |
77 | ||
78 | AliPreprocessor::Initialize(run, startTime, endTime); | |
79 | ||
80 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
81 | TTimeStamp(startTime).AsString(), | |
82 | TTimeStamp(endTime).AsString())); | |
83 | ||
84 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime); | |
56071a73 | 85 | fArray = 0x0; |
c9fe8530 | 86 | fTOFGeometry = new AliTOFGeometryV5(); |
87 | fCal = new AliTOFCalOnline(fTOFGeometry); | |
88 | fCal->CreateArray(); | |
89 | } | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | ||
93 | UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap) | |
94 | { | |
95 | // Fills data into a AliTOFDataDCS object | |
96 | ||
97 | UInt_t resultDCS=0; | |
98 | UInt_t resultDAQ=0; | |
99 | UInt_t resultDAQRef=0; | |
100 | UInt_t result=0; | |
101 | ||
102 | // processing DCS | |
103 | ||
104 | if (!dcsAliasMap){ | |
105 | AliInfo(Form("No DCS map found ")); | |
106 | } | |
107 | else { | |
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); | |
114 | result+=resultDCS; | |
115 | if (!resultDCS){ | |
116 | AliInfo(Form("some problems occurred while storing DCS data processing results")); | |
117 | } | |
118 | } | |
119 | ||
120 | // processing DAQ | |
121 | ||
122 | TFile * daqFile=0x0; | |
123 | TList* list = GetFileSources(kDAQ, "DELAYS"); | |
124 | ||
125 | if (list) | |
126 | { | |
127 | AliInfo("The following sources produced files with the id DELAYS"); | |
128 | list->Print(); | |
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()); | |
134 | if (fileNameRun){ | |
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; | |
144 | if (!resultDAQRef){ | |
145 | AliInfo(Form("some problems occurred::No Reference Data stored")); | |
146 | } | |
147 | daqFile->Close(); | |
148 | delete daqFile; | |
149 | } | |
150 | ||
151 | else{ | |
152 | AliError(Form("The file %s does not exist",fileNameRun)); | |
153 | } | |
154 | ||
155 | // file with summed histos, to extract calib params | |
156 | const char *fileName = GetFile(kDAQ, "DELAYS", str->GetName()); | |
157 | if (fileName){ | |
158 | AliInfo(Form("Got the file %s, now we can extract some values.", fileName)); | |
159 | ||
160 | daqFile = new TFile(fileName,"READ"); | |
161 | fArray = (TObjArray*) daqFile->Get("ciccio"); | |
162 | if (!fArray){ | |
163 | AliInfo(Form("some problems occurred:: No histo array retrieved")); | |
164 | } | |
165 | ||
166 | else { | |
167 | Int_t nentries=(Int_t)fArray->GetEntries(); | |
168 | AliInfo(Form(" il numero di entries e' = %i ", nentries)); | |
169 | Int_t npads = fCal->NPads(); | |
c9fe8530 | 170 | for (Int_t i=0 ; i<nentries; i++){ |
171 | Bool_t found=kFALSE; | |
56071a73 | 172 | TH1F * h1 = (TH1F*)fArray->At(i); |
c9fe8530 | 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(); | |
177 | Int_t startBin=1; | |
178 | for (Int_t j=1; j<=nbinsX; j++){ | |
179 | if (( | |
180 | h1->GetBinContent(j) + | |
181 | h1->GetBinContent(j+1)+ | |
182 | h1->GetBinContent(j+2)+ | |
183 | h1->GetBinContent(j+3))>minContent){ | |
184 | found=kTRUE; | |
185 | startBin=j; | |
186 | break; | |
187 | } | |
188 | } | |
189 | if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",i)); | |
190 | // Now calculate the mean over the interval. | |
191 | Double_t mean = 0; | |
192 | Double_t sumw2 = 0; | |
193 | Double_t nent = 0; | |
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)); | |
198 | } | |
199 | ||
200 | mean= mean/nent; //<x> | |
201 | sumw2=sumw2/nent; //<x^2> | |
202 | Double_t rmsmean= 0; | |
203 | rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent); | |
204 | if (i<npads) { | |
205 | AliTOFChannelOnline * ch = fCal->GetChannel(i); | |
206 | ch->SetDelay(mean); | |
207 | } | |
208 | } | |
c9fe8530 | 209 | } |
210 | daqFile->Close(); | |
211 | delete daqFile; | |
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; | |
218 | } | |
219 | else{ | |
220 | AliError(Form("The file %s does not exist",fileName)); | |
221 | } | |
222 | } | |
223 | } | |
224 | else{ | |
225 | AliInfo(Form("Problem: no list found")); | |
226 | } | |
227 | ||
228 | delete list; | |
229 | list = 0; | |
230 | daqFile=0; | |
231 | delete fData; | |
232 | fData = 0; | |
233 | delete fCal; | |
234 | fCal = 0; | |
235 | delete fArray; | |
236 | fArray = 0; | |
237 | return result; | |
238 | } | |
239 | ||
240 |