]>
Commit | Line | Data |
---|---|---|
24e8f6b2 | 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 | //Root includes | |
18 | #include <TObjArray.h> | |
19 | #include <TH1F.h> | |
20 | #include <TString.h> | |
21 | #include <TMath.h> | |
22 | #include <TF1.h> | |
23 | #include <TRandom.h> | |
24 | #include <TDirectory.h> | |
25 | #include <TFile.h> | |
26 | #include "TTreeStream.h" | |
27 | ||
28 | //AliRoot includes | |
9d7353e3 | 29 | #include "AliDAQ.h" |
30 | #include "AliLog.h" | |
24e8f6b2 | 31 | #include "AliRawReader.h" |
32 | #include "AliPMDRawStream.h" | |
33 | #include "AliPMDddldata.h" | |
722ccc67 | 34 | #include "AliBitPacking.h" |
24e8f6b2 | 35 | //header file |
36 | #include "AliPMDCalibPedestal.h" | |
37 | ||
38 | ||
39 | ClassImp(AliPMDCalibPedestal) | |
40 | ||
41 | ||
42 | AliPMDCalibPedestal::AliPMDCalibPedestal() : | |
70202332 | 43 | TObject(), |
44 | fRunNumber(-1), | |
45 | fEventNumber(0) | |
24e8f6b2 | 46 | { |
47 | // | |
48 | // default constructor | |
49 | // | |
50 | ||
0ab3a530 | 51 | for (int i = 0; i < kDet; i++) |
24e8f6b2 | 52 | { |
0ab3a530 | 53 | for (int j = 0; j < kMaxSMN; j++) |
24e8f6b2 | 54 | { |
0ab3a530 | 55 | for (int k = 0; k < kMaxRow; k++) |
24e8f6b2 | 56 | { |
0ab3a530 | 57 | for (int l = 0; l < kMaxCol; l++) |
24e8f6b2 | 58 | { |
0ab3a530 | 59 | fPedVal[i][j][k][l] = 0.; |
60 | fPedValSq[i][j][k][l] = 0.; | |
61 | fPedCount[i][j][k][l] = 0.; | |
70202332 | 62 | } |
63 | } | |
64 | } | |
65 | } | |
66 | ||
67 | for (int i = 0; i < 6; i++) | |
68 | { | |
69 | for (int j = 0; j < 51; j++) | |
70 | { | |
71 | for (int k = 0; k < 25; k++) | |
72 | { | |
73 | for (int l = 0; l < 64; l++) | |
74 | { | |
75 | fPedChain[i][j][k][l] = -1; | |
24e8f6b2 | 76 | } |
77 | } | |
78 | } | |
79 | } | |
80 | ||
81 | ||
82 | } | |
83 | //_____________________________________________________________________ | |
84 | AliPMDCalibPedestal::AliPMDCalibPedestal(const AliPMDCalibPedestal &ped) : | |
70202332 | 85 | TObject(ped), |
86 | fRunNumber(ped.fRunNumber), | |
87 | fEventNumber(ped.fEventNumber) | |
24e8f6b2 | 88 | { |
89 | // | |
90 | // copy constructor | |
91 | // | |
0ab3a530 | 92 | for (int i = 0; i < kDet; i++) |
24e8f6b2 | 93 | { |
0ab3a530 | 94 | for (int j = 0; j < kMaxSMN; j++) |
24e8f6b2 | 95 | { |
0ab3a530 | 96 | for (int k = 0; k < kMaxRow; k++) |
24e8f6b2 | 97 | { |
0ab3a530 | 98 | for (int l = 0; l < kMaxCol; l++) |
24e8f6b2 | 99 | { |
0ab3a530 | 100 | fPedVal[i][j][k][l] = ped.fPedVal[i][j][k][l]; |
101 | fPedValSq[i][j][k][l] = ped.fPedValSq[i][j][k][l]; | |
102 | fPedCount[i][j][k][l] = ped.fPedCount[i][j][k][l]; | |
70202332 | 103 | } |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | for (int i = 0; i < 6; i++) | |
109 | { | |
110 | for (int j = 0; j < 51; j++) | |
111 | { | |
112 | for (int k = 0; k < 25; k++) | |
113 | { | |
114 | for (int l = 0; l < 64; l++) | |
115 | { | |
116 | fPedChain[i][j][k][l] = -1; | |
24e8f6b2 | 117 | } |
118 | } | |
119 | } | |
120 | } | |
121 | ||
122 | } | |
123 | //_____________________________________________________________________ | |
124 | AliPMDCalibPedestal& AliPMDCalibPedestal::operator = (const AliPMDCalibPedestal &source) | |
125 | { | |
126 | // | |
127 | // assignment operator | |
128 | // | |
129 | if (&source == this) return *this; | |
130 | new (this) AliPMDCalibPedestal(source); | |
131 | ||
132 | return *this; | |
133 | } | |
134 | //_____________________________________________________________________ | |
135 | AliPMDCalibPedestal::~AliPMDCalibPedestal() | |
136 | { | |
137 | // | |
138 | // destructor | |
139 | // | |
24e8f6b2 | 140 | } |
141 | //_____________________________________________________________________ | |
70202332 | 142 | Bool_t AliPMDCalibPedestal::ProcessEvent(AliRawReader *rawReader, TObjArray *pmdddlcont) |
24e8f6b2 | 143 | { |
144 | // | |
145 | // Event processing loop - AliRawReader | |
146 | // | |
9d7353e3 | 147 | |
148 | const Int_t kDDL = AliDAQ::NumberOfDdls("PMD"); | |
149 | ||
be8b7039 | 150 | UInt_t detsmnrowcol = 0; |
151 | UInt_t pbus = 0, mcm = 0, chno = 0; | |
722ccc67 | 152 | |
70202332 | 153 | fRunNumber = rawReader->GetRunNumber(); |
154 | ||
24e8f6b2 | 155 | AliPMDRawStream rawStream(rawReader); |
156 | ||
70202332 | 157 | fEventNumber++; |
158 | ||
722ccc67 | 159 | Int_t iddl = -1; |
160 | Int_t numberofDDLs = 0; | |
24e8f6b2 | 161 | |
70202332 | 162 | while ((iddl = rawStream.DdlData(pmdddlcont)) >=0) { |
722ccc67 | 163 | numberofDDLs++; |
70202332 | 164 | Int_t ientries = pmdddlcont->GetEntries(); |
722ccc67 | 165 | //printf("iddl = %d ientries = %d\n",iddl, ientries); |
166 | for (Int_t ient = 0; ient < ientries; ient++) | |
24e8f6b2 | 167 | { |
70202332 | 168 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient); |
24e8f6b2 | 169 | |
170 | Int_t det = pmdddl->GetDetector(); | |
171 | Int_t smn = pmdddl->GetSMN(); | |
24e8f6b2 | 172 | Int_t row = pmdddl->GetRow(); |
173 | Int_t col = pmdddl->GetColumn(); | |
0ab3a530 | 174 | Float_t sig = (Float_t) pmdddl->GetSignal(); |
24e8f6b2 | 175 | |
722ccc67 | 176 | pbus = (UInt_t) pmdddl->GetPatchBusId(); |
177 | mcm = (UInt_t) pmdddl->GetMCM(); | |
178 | chno = (UInt_t) pmdddl->GetChannel(); | |
179 | ||
70202332 | 180 | detsmnrowcol = 0; |
181 | AliBitPacking::PackWord(det,detsmnrowcol,0,7); | |
182 | AliBitPacking::PackWord(smn,detsmnrowcol,8,15); | |
183 | AliBitPacking::PackWord(row,detsmnrowcol,16,23); | |
184 | AliBitPacking::PackWord(col,detsmnrowcol,24,31); | |
722ccc67 | 185 | |
70202332 | 186 | if (fPedChain[iddl][pbus][mcm][chno] == -1) |
187 | fPedChain[iddl][pbus][mcm][chno] = (Int_t)detsmnrowcol; | |
722ccc67 | 188 | |
722ccc67 | 189 | |
0ab3a530 | 190 | fPedVal[det][smn][row][col] += sig; |
191 | fPedValSq[det][smn][row][col] += sig*sig; | |
192 | fPedCount[det][smn][row][col]++; | |
24e8f6b2 | 193 | } |
70202332 | 194 | pmdddlcont->Delete(); |
24e8f6b2 | 195 | } |
70202332 | 196 | |
722ccc67 | 197 | if (numberofDDLs < kDDL) |
198 | return kFALSE; | |
199 | return kTRUE; | |
24e8f6b2 | 200 | } |
201 | //_____________________________________________________________________ | |
202 | ||
9d7353e3 | 203 | void AliPMDCalibPedestal::Analyse(TTree *pedtree) |
24e8f6b2 | 204 | { |
205 | // | |
206 | // Calculate pedestal Mean and RMS | |
207 | // | |
722ccc67 | 208 | |
be8b7039 | 209 | UInt_t detsmnrowcol = 0; |
210 | Int_t det = 0, sm = 0, row = 0, col = 0; | |
211 | Int_t idet = 0, ism = 0, irow = 0, icol = 0; | |
8b3f4c83 | 212 | Float_t mean = 0., rms = 0.; |
f012b991 | 213 | Double_t meansq = 0., diff = 0.; |
70202332 | 214 | |
722ccc67 | 215 | FILE *fpw0 = fopen("pedestal2304.ped","w"); |
216 | FILE *fpw1 = fopen("pedestal2305.ped","w"); | |
217 | FILE *fpw2 = fopen("pedestal2306.ped","w"); | |
218 | FILE *fpw3 = fopen("pedestal2307.ped","w"); | |
219 | FILE *fpw4 = fopen("pedestal2308.ped","w"); | |
220 | FILE *fpw5 = fopen("pedestal2309.ped","w"); | |
221 | ||
70202332 | 222 | fprintf(fpw0,"//=============================================\n"); |
223 | fprintf(fpw0,"// Pedestal file Calculated by Online DA\n"); | |
224 | fprintf(fpw0,"//=============================================\n"); | |
225 | fprintf(fpw0,"// RUN :%d\n",fRunNumber); | |
226 | fprintf(fpw0,"// Statistics :%d\n",fEventNumber); | |
227 | fprintf(fpw0,"//---------------------------------------------\n"); | |
228 | fprintf(fpw0,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
229 | fprintf(fpw0,"//---------------------------------------------\n"); | |
230 | ||
231 | fprintf(fpw1,"//=============================================\n"); | |
232 | fprintf(fpw1,"// Pedestal file Calculated by Online DA\n"); | |
233 | fprintf(fpw1,"//=============================================\n"); | |
234 | fprintf(fpw1,"// RUN :%d\n",fRunNumber); | |
235 | fprintf(fpw1,"// Statistics :%d\n",fEventNumber); | |
236 | fprintf(fpw1,"//---------------------------------------------\n"); | |
237 | fprintf(fpw1,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
238 | ||
239 | fprintf(fpw2,"//=============================================\n"); | |
240 | fprintf(fpw2,"// Pedestal file Calculated by Online DA\n"); | |
241 | fprintf(fpw2,"//=============================================\n"); | |
242 | fprintf(fpw2,"// RUN :%d\n",fRunNumber); | |
243 | fprintf(fpw2,"// Statistics :%d\n",fEventNumber); | |
244 | fprintf(fpw2,"//---------------------------------------------\n"); | |
245 | fprintf(fpw2,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
246 | fprintf(fpw2,"//---------------------------------------------\n"); | |
247 | ||
248 | fprintf(fpw3,"//=============================================\n"); | |
249 | fprintf(fpw3,"// Pedestal file Calculated by Online DA\n"); | |
250 | fprintf(fpw3,"//=============================================\n"); | |
251 | fprintf(fpw3,"// RUN :%d\n",fRunNumber); | |
252 | fprintf(fpw3,"// Statistics :%d\n",fEventNumber); | |
253 | fprintf(fpw3,"//---------------------------------------------\n"); | |
254 | fprintf(fpw3,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
255 | fprintf(fpw3,"//---------------------------------------------\n"); | |
256 | ||
257 | fprintf(fpw4,"//=============================================\n"); | |
258 | fprintf(fpw4,"// Pedestal file Calculated by Online DA\n"); | |
259 | fprintf(fpw4,"//=============================================\n"); | |
260 | fprintf(fpw4,"// RUN :%d\n",fRunNumber); | |
261 | fprintf(fpw4,"// Statistics :%d\n",fEventNumber); | |
262 | fprintf(fpw4,"//---------------------------------------------\n"); | |
263 | fprintf(fpw4,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
264 | fprintf(fpw4,"//---------------------------------------------\n"); | |
265 | ||
266 | fprintf(fpw5,"//=============================================\n"); | |
267 | fprintf(fpw5,"// Pedestal file Calculated by Online DA\n"); | |
268 | fprintf(fpw5,"//=============================================\n"); | |
269 | fprintf(fpw5,"// RUN :%d\n",fRunNumber); | |
270 | fprintf(fpw5,"// Statistics :%d\n",fEventNumber); | |
271 | fprintf(fpw5,"//---------------------------------------------\n"); | |
272 | fprintf(fpw5,"//format:CHAIN_NO FEE_ID CHANNEL MEAN SIGMA\n"); | |
273 | fprintf(fpw5,"//---------------------------------------------\n"); | |
274 | ||
275 | ||
276 | for(Int_t iddl = 0; iddl < 6; iddl++) | |
277 | { | |
278 | for(Int_t ibus = 1; ibus < 51; ibus++) | |
279 | { | |
280 | for(Int_t imcm = 1; imcm < 25; imcm++) | |
281 | { | |
282 | for(Int_t ich = 0; ich < 64; ich++) | |
283 | { | |
284 | ||
285 | if (fPedChain[iddl][ibus][imcm][ich] != -1) | |
286 | { | |
287 | detsmnrowcol = (UInt_t)fPedChain[iddl][ibus][imcm][ich]; | |
288 | ||
289 | idet = detsmnrowcol & 0x00FF; | |
290 | ism = (detsmnrowcol >> 8) & 0x00FF; | |
291 | irow = (detsmnrowcol >> 16) & 0x00FF; | |
292 | icol = (detsmnrowcol >> 24) & 0x00FF; | |
293 | ||
294 | mean = 0.; | |
295 | rms = 0.; | |
296 | if (fPedCount[idet][ism][irow][icol] > 0) | |
297 | { | |
298 | mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol]; | |
299 | ||
300 | meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol]; | |
301 | ||
302 | diff = meansq - mean*mean; | |
303 | if (diff > 0.) | |
304 | { | |
305 | rms = sqrt(diff); | |
306 | } | |
307 | else | |
308 | { | |
309 | rms = 0.; | |
310 | } | |
311 | ||
312 | ||
313 | if (iddl == 0) | |
314 | { | |
315 | fprintf(fpw0,"%d %d %d %f %f\n", | |
316 | ibus, imcm, ich, mean, rms); | |
317 | } | |
318 | else if (iddl == 1) | |
319 | { | |
320 | fprintf(fpw1,"%d %d %d %f %f\n", | |
321 | ibus, imcm, ich, mean, rms); | |
322 | } | |
323 | else if (iddl == 2) | |
324 | { | |
325 | fprintf(fpw2,"%d %d %d %f %f\n", | |
326 | ibus, imcm, ich, mean, rms); | |
327 | } | |
328 | else if (iddl == 3) | |
329 | { | |
330 | fprintf(fpw3,"%d %d %d %f %f\n", | |
331 | ibus, imcm, ich, mean, rms); | |
332 | } | |
333 | else if (iddl == 4) | |
334 | { | |
335 | fprintf(fpw4,"%d %d %d %f %f\n", | |
336 | ibus, imcm, ich, mean, rms); | |
337 | } | |
338 | else if (iddl == 5) | |
339 | { | |
340 | fprintf(fpw5,"%d %d %d %f %f\n", | |
341 | ibus, imcm, ich, mean, rms); | |
342 | } | |
343 | } | |
344 | } | |
345 | } | |
346 | } | |
347 | } | |
348 | } | |
349 | ||
0ab3a530 | 350 | |
70202332 | 351 | fclose(fpw0); |
352 | fclose(fpw1); | |
353 | fclose(fpw2); | |
354 | fclose(fpw3); | |
355 | fclose(fpw4); | |
356 | fclose(fpw5); | |
722ccc67 | 357 | |
0ab3a530 | 358 | pedtree->Branch("det",&det,"det/I"); |
359 | pedtree->Branch("sm",&sm,"sm/I"); | |
360 | pedtree->Branch("row",&row,"row/I"); | |
361 | pedtree->Branch("col",&col,"col/I"); | |
362 | pedtree->Branch("mean",&mean,"mean/F"); | |
363 | pedtree->Branch("rms",&rms,"rms/F"); | |
364 | ||
70202332 | 365 | for (idet = 0; idet < kDet; idet++) |
366 | { | |
367 | for (ism = 0; ism < kMaxSMN; ism++) | |
368 | { | |
369 | for (irow = 0; irow < kMaxRow; irow++) | |
370 | { | |
371 | for (icol = 0; icol < kMaxCol; icol++) | |
372 | { | |
0ab3a530 | 373 | det = idet; |
374 | sm = ism; | |
375 | row = irow; | |
376 | col = icol; | |
722ccc67 | 377 | mean = 0.; |
378 | rms = 0.; | |
70202332 | 379 | |
0ab3a530 | 380 | if (fPedCount[idet][ism][irow][icol] > 0) |
70202332 | 381 | { |
382 | mean = fPedVal[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol]; | |
383 | ||
384 | meansq = fPedValSq[idet][ism][irow][icol]/fPedCount[idet][ism][irow][icol]; | |
385 | ||
0ab3a530 | 386 | diff = meansq - mean*mean; |
387 | if (diff > 0.) | |
70202332 | 388 | { |
0ab3a530 | 389 | rms = sqrt(diff); |
70202332 | 390 | } |
0ab3a530 | 391 | else |
70202332 | 392 | { |
0ab3a530 | 393 | rms = 0.; |
70202332 | 394 | } |
722ccc67 | 395 | pedtree->Fill(); |
70202332 | 396 | } |
722ccc67 | 397 | |
70202332 | 398 | } |
399 | } | |
400 | } | |
401 | } | |
24e8f6b2 | 402 | } |
722ccc67 | 403 | // ------------------------------------------------------------------- |