]>
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$ | |
18 | */ | |
19 | ||
20 | #include "AliTOFPreprocessor.h" | |
21 | ||
22 | #include "AliCDBMetaData.h" | |
23 | #include "AliLog.h" | |
24 | #include "AliTOFDataDCS.h" | |
25 | #include "TFile.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" | |
32 | #include "TH1F.h" | |
33 | ||
34 | class TF1; | |
35 | class AliDCSValue; | |
36 | class AliTOFGeometry; | |
37 | ||
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. | |
44 | ||
45 | ||
46 | ClassImp(AliTOFPreprocessor) | |
47 | ||
48 | const Int_t AliTOFPreprocessor::fgkBinRangeAve = 13; // number of bins where to calculate the mean | |
49 | ||
50 | //_____________________________________________________________________________ | |
51 | ||
52 | AliTOFPreprocessor::AliTOFPreprocessor(const char* detector, AliShuttleInterface* shuttle) : | |
53 | AliPreprocessor(detector, shuttle), | |
54 | fData(0), | |
55 | fArray(0), | |
56 | fCal(0), | |
57 | fTOFGeometry(0) | |
58 | { | |
59 | // constructor | |
60 | } | |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | ||
64 | AliTOFPreprocessor::~AliTOFPreprocessor() | |
65 | { | |
66 | // destructor | |
67 | } | |
68 | ||
69 | //______________________________________________________________________________ | |
70 | void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime, | |
71 | UInt_t endTime) | |
72 | { | |
73 | // Creates AliTOFDataDCS object | |
74 | ||
75 | AliPreprocessor::Initialize(run, startTime, endTime); | |
76 | ||
77 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, | |
78 | TTimeStamp(startTime).AsString(), | |
79 | TTimeStamp(endTime).AsString())); | |
80 | ||
81 | fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime); | |
82 | fArray = new TObjArray(); | |
83 | fTOFGeometry = new AliTOFGeometryV5(); | |
84 | fCal = new AliTOFCalOnline(fTOFGeometry); | |
85 | fCal->CreateArray(); | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | ||
90 | UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap) | |
91 | { | |
92 | // Fills data into a AliTOFDataDCS object | |
93 | ||
94 | UInt_t resultDCS=0; | |
95 | UInt_t resultDAQ=0; | |
96 | UInt_t resultDAQRef=0; | |
97 | UInt_t result=0; | |
98 | ||
99 | // processing DCS | |
100 | ||
101 | if (!dcsAliasMap){ | |
102 | AliInfo(Form("No DCS map found ")); | |
103 | } | |
104 | else { | |
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); | |
111 | result+=resultDCS; | |
112 | if (!resultDCS){ | |
113 | AliInfo(Form("some problems occurred while storing DCS data processing results")); | |
114 | } | |
115 | } | |
116 | ||
117 | // processing DAQ | |
118 | ||
119 | TFile * daqFile=0x0; | |
120 | TList* list = GetFileSources(kDAQ, "DELAYS"); | |
121 | ||
122 | if (list) | |
123 | { | |
124 | AliInfo("The following sources produced files with the id DELAYS"); | |
125 | list->Print(); | |
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()); | |
131 | if (fileNameRun){ | |
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; | |
141 | if (!resultDAQRef){ | |
142 | AliInfo(Form("some problems occurred::No Reference Data stored")); | |
143 | } | |
144 | daqFile->Close(); | |
145 | delete daqFile; | |
146 | } | |
147 | ||
148 | else{ | |
149 | AliError(Form("The file %s does not exist",fileNameRun)); | |
150 | } | |
151 | ||
152 | // file with summed histos, to extract calib params | |
153 | const char *fileName = GetFile(kDAQ, "DELAYS", str->GetName()); | |
154 | if (fileName){ | |
155 | AliInfo(Form("Got the file %s, now we can extract some values.", fileName)); | |
156 | ||
157 | daqFile = new TFile(fileName,"READ"); | |
158 | fArray = (TObjArray*) daqFile->Get("ciccio"); | |
159 | if (!fArray){ | |
160 | AliInfo(Form("some problems occurred:: No histo array retrieved")); | |
161 | } | |
162 | ||
163 | else { | |
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++){ | |
169 | Bool_t found=kFALSE; | |
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(); | |
175 | Int_t startBin=1; | |
176 | for (Int_t j=1; j<=nbinsX; j++){ | |
177 | if (( | |
178 | h1->GetBinContent(j) + | |
179 | h1->GetBinContent(j+1)+ | |
180 | h1->GetBinContent(j+2)+ | |
181 | h1->GetBinContent(j+3))>minContent){ | |
182 | found=kTRUE; | |
183 | startBin=j; | |
184 | break; | |
185 | } | |
186 | } | |
187 | if(!found) AliInfo(Form("WARNING!!! no start of fit found for histo # %i",i)); | |
188 | // Now calculate the mean over the interval. | |
189 | Double_t mean = 0; | |
190 | Double_t sumw2 = 0; | |
191 | Double_t nent = 0; | |
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)); | |
196 | } | |
197 | ||
198 | mean= mean/nent; //<x> | |
199 | sumw2=sumw2/nent; //<x^2> | |
200 | Double_t rmsmean= 0; | |
201 | rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent); | |
202 | if (i<npads) { | |
203 | AliTOFChannelOnline * ch = fCal->GetChannel(i); | |
204 | ch->SetDelay(mean); | |
205 | } | |
206 | } | |
207 | delete h1; | |
208 | h1=0; | |
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 |