]>
Commit | Line | Data |
---|---|---|
ed228cbc | 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 | ||
01709453 | 16 | //-----------------------------------------------------// |
17 | // // | |
18 | // Date : August 05 2003 // | |
19 | // This reads the file PMD.digits.root(TreeD), // | |
20 | // calls the Clustering algorithm and stores the // | |
21 | // clustering output in PMD.RecPoints.root(TreeR) // | |
22 | // // | |
23 | //-----------------------------------------------------// | |
24 | ||
25 | #include <Riostream.h> | |
01709453 | 26 | #include <TTree.h> |
01709453 | 27 | #include <TObjArray.h> |
28 | #include <TClonesArray.h> | |
01709453 | 29 | |
7e9508a7 | 30 | #include "AliLog.h" |
01709453 | 31 | #include "AliRunLoader.h" |
32 | #include "AliLoader.h" | |
5f55af10 | 33 | #include "AliRawReader.h" |
01709453 | 34 | |
35 | #include "AliPMDdigit.h" | |
36 | #include "AliPMDClusterFinder.h" | |
37 | #include "AliPMDClustering.h" | |
5c5cadd5 | 38 | #include "AliPMDClusteringV1.h" |
01709453 | 39 | #include "AliPMDcluster.h" |
96377d57 | 40 | #include "AliPMDrecpoint1.h" |
5c5cadd5 | 41 | #include "AliPMDrechit.h" |
5f55af10 | 42 | #include "AliPMDRawStream.h" |
09a06455 | 43 | #include "AliPMDCalibData.h" |
df42ab21 | 44 | #include "AliPMDddldata.h" |
09a06455 | 45 | |
46 | #include "AliCDBManager.h" | |
47 | #include "AliCDBEntry.h" | |
01709453 | 48 | |
7e9508a7 | 49 | |
50 | ||
01709453 | 51 | ClassImp(AliPMDClusterFinder) |
b208c6a3 | 52 | |
7e9508a7 | 53 | AliPMDClusterFinder::AliPMDClusterFinder(): |
54 | fRunLoader(0), | |
55 | fPMDLoader(0), | |
a48edddd | 56 | fCalibData(GetCalibData()), |
7e9508a7 | 57 | fTreeD(0), |
58 | fTreeR(0), | |
59 | fDigits(new TClonesArray("AliPMDdigit", 1000)), | |
60 | fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)), | |
5c5cadd5 | 61 | fRechits(new TClonesArray("AliPMDrechit", 1000)), |
7e9508a7 | 62 | fNpoint(0), |
5c5cadd5 | 63 | fNhit(0), |
a48edddd | 64 | fDetNo(0), |
7e9508a7 | 65 | fEcut(0.) |
66 | { | |
67 | // | |
68 | // Constructor | |
69 | // | |
70 | } | |
71 | // ------------------------------------------------------------------------- // | |
dfaeee5f | 72 | AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader): |
73 | fRunLoader(runLoader), | |
74 | fPMDLoader(runLoader->GetLoader("PMDLoader")), | |
a48edddd | 75 | fCalibData(GetCalibData()), |
1758e4fe | 76 | fTreeD(0), |
77 | fTreeR(0), | |
ebd83c56 | 78 | fDigits(new TClonesArray("AliPMDdigit", 1000)), |
1758e4fe | 79 | fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)), |
5c5cadd5 | 80 | fRechits(new TClonesArray("AliPMDrechit", 1000)), |
1758e4fe | 81 | fNpoint(0), |
5c5cadd5 | 82 | fNhit(0), |
a48edddd | 83 | fDetNo(0), |
1758e4fe | 84 | fEcut(0.) |
01709453 | 85 | { |
b208c6a3 | 86 | // |
dfaeee5f | 87 | // Constructor |
b208c6a3 | 88 | // |
a48edddd | 89 | } |
90 | // ------------------------------------------------------------------------- // | |
91 | AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & /*finder*/): | |
92 | TObject(/*finder*/) | |
93 | { | |
94 | // copy constructor | |
95 | AliError("Copy constructor not allowed"); | |
96 | } | |
97 | // ------------------------------------------------------------------------- // | |
98 | AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/) | |
99 | { | |
100 | // assignment op | |
101 | AliError("Assignment Operator not allowed"); | |
102 | return *this; | |
01709453 | 103 | } |
1758e4fe | 104 | // ------------------------------------------------------------------------- // |
01709453 | 105 | AliPMDClusterFinder::~AliPMDClusterFinder() |
106 | { | |
b208c6a3 | 107 | // Destructor |
ebd83c56 | 108 | if (fDigits) |
109 | { | |
110 | fDigits->Delete(); | |
111 | delete fDigits; | |
112 | fDigits=0; | |
113 | } | |
1758e4fe | 114 | if (fRecpoints) |
115 | { | |
116 | fRecpoints->Delete(); | |
117 | delete fRecpoints; | |
118 | fRecpoints=0; | |
119 | } | |
5c5cadd5 | 120 | if (fRechits) |
121 | { | |
122 | fRechits->Delete(); | |
123 | delete fRechits; | |
124 | fRechits=0; | |
125 | } | |
01709453 | 126 | } |
1758e4fe | 127 | // ------------------------------------------------------------------------- // |
b208c6a3 | 128 | |
01709453 | 129 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt) |
130 | { | |
b208c6a3 | 131 | // Converts digits to recpoints after running clustering |
132 | // algorithm on CPV plane and PREshower plane | |
133 | // | |
ed228cbc | 134 | Int_t det = 0,smn = 0; |
01709453 | 135 | Int_t xpos,ypos; |
136 | Float_t adc; | |
1758e4fe | 137 | Int_t ismn; |
01709453 | 138 | Int_t idet; |
5c5cadd5 | 139 | Float_t clusdata[6]; |
ed228cbc | 140 | |
141 | TObjArray *pmdcont = new TObjArray(); | |
5c5cadd5 | 142 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); |
7e9508a7 | 143 | |
ed228cbc | 144 | pmdclust->SetEdepCut(fEcut); |
01709453 | 145 | |
146 | fRunLoader->GetEvent(ievt); | |
7e9508a7 | 147 | |
01b56f5c | 148 | |
b208c6a3 | 149 | fTreeD = fPMDLoader->TreeD(); |
150 | if (fTreeD == 0x0) | |
01709453 | 151 | { |
7e9508a7 | 152 | AliFatal("AliPMDClusterFinder: Can not get TreeD"); |
153 | ||
01709453 | 154 | } |
155 | AliPMDdigit *pmddigit; | |
b208c6a3 | 156 | TBranch *branch = fTreeD->GetBranch("PMDDigit"); |
01709453 | 157 | branch->SetAddress(&fDigits); |
158 | ||
159 | ResetRecpoint(); | |
01b56f5c | 160 | |
b208c6a3 | 161 | fTreeR = fPMDLoader->TreeR(); |
162 | if (fTreeR == 0x0) | |
01709453 | 163 | { |
b208c6a3 | 164 | fPMDLoader->MakeTree("R"); |
165 | fTreeR = fPMDLoader->TreeR(); | |
01709453 | 166 | } |
167 | ||
168 | Int_t bufsize = 16000; | |
5c5cadd5 | 169 | TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
170 | TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); | |
01709453 | 171 | |
b208c6a3 | 172 | Int_t nmodules = (Int_t) fTreeD->GetEntries(); |
01b56f5c | 173 | |
01709453 | 174 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
175 | { | |
ed228cbc | 176 | ResetCellADC(); |
b208c6a3 | 177 | fTreeD->GetEntry(imodule); |
01709453 | 178 | Int_t nentries = fDigits->GetLast(); |
179 | for (Int_t ient = 0; ient < nentries+1; ient++) | |
180 | { | |
181 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); | |
182 | ||
183 | det = pmddigit->GetDetector(); | |
184 | smn = pmddigit->GetSMNumber(); | |
5e6a9312 | 185 | xpos = pmddigit->GetRow(); |
186 | ypos = pmddigit->GetColumn(); | |
01709453 | 187 | adc = pmddigit->GetADC(); |
09a06455 | 188 | |
189 | // CALIBRATION | |
190 | Float_t gain = fCalibData->GetGainFact(det,smn,xpos,ypos); | |
09a06455 | 191 | // printf("adc = %d gain = %f\n",adc,gain); |
192 | ||
193 | adc = adc*gain; | |
194 | ||
195 | ||
ed228cbc | 196 | //Int_t trno = pmddigit->GetTrackNumber(); |
ed228cbc | 197 | fCellADC[xpos][ypos] = (Double_t) adc; |
01709453 | 198 | } |
01709453 | 199 | |
ed228cbc | 200 | idet = det; |
1758e4fe | 201 | ismn = smn; |
8616b098 | 202 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
ed228cbc | 203 | |
204 | Int_t nentries1 = pmdcont->GetEntries(); | |
7e9508a7 | 205 | |
206 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
207 | ||
ed228cbc | 208 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
01709453 | 209 | { |
ebd83c56 | 210 | AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1); |
1758e4fe | 211 | idet = pmdcl->GetDetector(); |
212 | ismn = pmdcl->GetSMN(); | |
213 | clusdata[0] = pmdcl->GetClusX(); | |
214 | clusdata[1] = pmdcl->GetClusY(); | |
215 | clusdata[2] = pmdcl->GetClusADC(); | |
216 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 217 | clusdata[4] = pmdcl->GetClusSigmaX(); |
218 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
01b56f5c | 219 | |
1758e4fe | 220 | AddRecPoint(idet,ismn,clusdata); |
5c5cadd5 | 221 | |
5c5cadd5 | 222 | Int_t ncell = (Int_t) clusdata[3]; |
223 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
224 | { | |
225 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
226 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
227 | AddRecHit(celldataX, celldataY); | |
228 | } | |
229 | branch2->Fill(); | |
230 | ResetRechit(); | |
ed228cbc | 231 | } |
232 | pmdcont->Clear(); | |
233 | ||
5c5cadd5 | 234 | branch1->Fill(); |
ed228cbc | 235 | ResetRecpoint(); |
236 | ||
237 | } // modules | |
238 | ||
01709453 | 239 | ResetCellADC(); |
e1287360 | 240 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b208c6a3 | 241 | fPMDLoader->WriteRecPoints("OVERWRITE"); |
01709453 | 242 | |
243 | // delete the pointers | |
244 | delete pmdclust; | |
245 | delete pmdcont; | |
246 | ||
7e9508a7 | 247 | } |
248 | // ------------------------------------------------------------------------- // | |
249 | ||
250 | void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader, | |
251 | TTree *clustersTree) | |
252 | { | |
253 | // Converts RAW data to recpoints after running clustering | |
254 | // algorithm on CPV and PREshower plane | |
255 | // | |
256 | ||
5c5cadd5 | 257 | Float_t clusdata[6]; |
df42ab21 | 258 | TObjArray pmdddlcont; |
7e9508a7 | 259 | |
260 | TObjArray *pmdcont = new TObjArray(); | |
5c5cadd5 | 261 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); |
7e9508a7 | 262 | |
263 | pmdclust->SetEdepCut(fEcut); | |
264 | ||
265 | ResetRecpoint(); | |
266 | ||
267 | Int_t bufsize = 16000; | |
5c5cadd5 | 268 | TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); |
269 | ||
270 | TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); | |
7e9508a7 | 271 | |
272 | const Int_t kDDL = 6; | |
273 | const Int_t kRow = 48; | |
274 | const Int_t kCol = 96; | |
275 | ||
276 | Int_t idet = 0; | |
277 | Int_t iSMN = 0; | |
278 | ||
279 | for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++) | |
280 | { | |
281 | if (indexDDL < 4) | |
282 | { | |
283 | iSMN = 6; | |
284 | } | |
285 | else if (indexDDL >= 4) | |
286 | { | |
287 | iSMN = 12; | |
288 | } | |
289 | Int_t ***precpvADC; | |
290 | precpvADC = new int **[iSMN]; | |
291 | for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow]; | |
292 | for (Int_t i=0; i<iSMN;i++) | |
293 | { | |
294 | for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol]; | |
295 | } | |
296 | for (Int_t i = 0; i < iSMN; i++) | |
297 | { | |
298 | for (Int_t j = 0; j < kRow; j++) | |
299 | { | |
300 | for (Int_t k = 0; k < kCol; k++) | |
301 | { | |
302 | precpvADC[i][j][k] = 0; | |
303 | } | |
304 | } | |
305 | } | |
306 | ResetCellADC(); | |
307 | rawReader->Reset(); | |
308 | AliPMDRawStream pmdinput(rawReader); | |
362c9d61 | 309 | rawReader->Select("PMD", indexDDL, indexDDL); |
df42ab21 | 310 | pmdinput.DdlData(&pmdddlcont); |
311 | Int_t indexsmn = 0; | |
312 | Int_t ientries = pmdddlcont.GetEntries(); | |
313 | for (Int_t ient = 0; ient < ientries; ient++) | |
7e9508a7 | 314 | { |
df42ab21 | 315 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient); |
7e9508a7 | 316 | |
df42ab21 | 317 | Int_t det = pmdddl->GetDetector(); |
318 | Int_t smn = pmdddl->GetSMN(); | |
319 | //Int_t mcm = pmdddl->GetMCM(); | |
320 | //Int_t chno = pmdddl->GetChannel(); | |
321 | Int_t row = pmdddl->GetRow(); | |
322 | Int_t col = pmdddl->GetColumn(); | |
323 | Int_t sig = pmdddl->GetSignal(); | |
09a06455 | 324 | |
df42ab21 | 325 | Float_t sig1 = (Float_t) sig; |
09a06455 | 326 | // CALIBRATION |
327 | Float_t gain = fCalibData->GetGainFact(det,smn,row,col); | |
df42ab21 | 328 | //printf("sig = %d gain = %f\n",sig,gain); |
09a06455 | 329 | sig = (Int_t) (sig1*gain); |
7e9508a7 | 330 | |
331 | if (indexDDL < 4) | |
332 | { | |
333 | if (det != 0) | |
334 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
335 | indexDDL, det)); | |
336 | indexsmn = smn - indexDDL * 6; | |
337 | } | |
338 | else if (indexDDL == 4) | |
339 | { | |
340 | if (det != 1) | |
341 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
342 | indexDDL, det)); | |
343 | if (smn < 6) | |
344 | { | |
345 | indexsmn = smn; | |
346 | } | |
df42ab21 | 347 | else if (smn >= 18 && smn < 24) |
7e9508a7 | 348 | { |
df42ab21 | 349 | indexsmn = smn - 12; |
7e9508a7 | 350 | } |
351 | } | |
352 | else if (indexDDL == 5) | |
353 | { | |
354 | if (det != 1) | |
355 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
356 | indexDDL, det)); | |
357 | if (smn >= 6 && smn < 12) | |
358 | { | |
359 | indexsmn = smn - 6; | |
360 | } | |
df42ab21 | 361 | else if (smn >= 12 && smn < 18) |
7e9508a7 | 362 | { |
df42ab21 | 363 | indexsmn = smn - 6; |
7e9508a7 | 364 | } |
365 | } | |
366 | precpvADC[indexsmn][row][col] = sig; | |
df42ab21 | 367 | } |
368 | ||
369 | pmdddlcont.Clear(); | |
7e9508a7 | 370 | |
371 | Int_t ismn = 0; | |
372 | for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++) | |
373 | { | |
374 | ResetCellADC(); | |
375 | for (Int_t irow = 0; irow < kRow; irow++) | |
376 | { | |
377 | for (Int_t icol = 0; icol < kCol; icol++) | |
378 | { | |
379 | fCellADC[irow][icol] = | |
380 | (Double_t) precpvADC[indexsmn][irow][icol]; | |
381 | } // row | |
382 | } // col | |
df42ab21 | 383 | |
7e9508a7 | 384 | if (indexDDL < 4) |
385 | { | |
386 | ismn = indexsmn + indexDDL * 6; | |
387 | idet = 0; | |
388 | } | |
389 | else if (indexDDL == 4) | |
390 | { | |
391 | if (indexsmn < 6) | |
392 | { | |
393 | ismn = indexsmn; | |
394 | } | |
395 | else if (indexsmn >= 6 && indexsmn < 12) | |
396 | { | |
df42ab21 | 397 | ismn = indexsmn + 12; |
7e9508a7 | 398 | } |
399 | idet = 1; | |
400 | } | |
401 | else if (indexDDL == 5) | |
402 | { | |
403 | if (indexsmn < 6) | |
404 | { | |
405 | ismn = indexsmn + 6; | |
406 | } | |
407 | else if (indexsmn >= 6 && indexsmn < 12) | |
408 | { | |
df42ab21 | 409 | ismn = indexsmn + 6; |
7e9508a7 | 410 | } |
411 | idet = 1; | |
412 | } | |
413 | ||
7e9508a7 | 414 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
415 | Int_t nentries1 = pmdcont->GetEntries(); | |
416 | ||
417 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
418 | ||
419 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) | |
420 | { | |
421 | AliPMDcluster *pmdcl = | |
422 | (AliPMDcluster*)pmdcont->UncheckedAt(ient1); | |
423 | idet = pmdcl->GetDetector(); | |
424 | ismn = pmdcl->GetSMN(); | |
425 | clusdata[0] = pmdcl->GetClusX(); | |
426 | clusdata[1] = pmdcl->GetClusY(); | |
427 | clusdata[2] = pmdcl->GetClusADC(); | |
428 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 429 | clusdata[4] = pmdcl->GetClusSigmaX(); |
430 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
7e9508a7 | 431 | |
432 | AddRecPoint(idet,ismn,clusdata); | |
09a06455 | 433 | |
5c5cadd5 | 434 | Int_t ncell = (Int_t) clusdata[3]; |
435 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
436 | { | |
437 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
438 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
439 | AddRecHit(celldataX, celldataY); | |
440 | } | |
441 | branch2->Fill(); | |
442 | ResetRechit(); | |
443 | ||
7e9508a7 | 444 | } |
445 | pmdcont->Clear(); | |
446 | ||
5c5cadd5 | 447 | branch1->Fill(); |
7e9508a7 | 448 | ResetRecpoint(); |
449 | ||
450 | ||
451 | } // smn | |
452 | ||
453 | for (Int_t i=0; i<iSMN; i++) | |
454 | { | |
455 | for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j]; | |
456 | } | |
457 | for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i]; | |
458 | delete precpvADC; | |
459 | } // DDL Loop | |
460 | ||
461 | ResetCellADC(); | |
462 | ||
463 | // delete the pointers | |
464 | delete pmdclust; | |
465 | delete pmdcont; | |
466 | ||
01709453 | 467 | } |
1758e4fe | 468 | // ------------------------------------------------------------------------- // |
5f55af10 | 469 | |
470 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader) | |
471 | { | |
01b56f5c | 472 | // Converts RAW data to recpoints after running clustering |
473 | // algorithm on CPV and PREshower plane | |
5f55af10 | 474 | // |
475 | ||
5c5cadd5 | 476 | Float_t clusdata[6]; |
df42ab21 | 477 | TObjArray pmdddlcont; |
5f55af10 | 478 | TObjArray *pmdcont = new TObjArray(); |
5c5cadd5 | 479 | |
480 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); | |
7e9508a7 | 481 | |
5f55af10 | 482 | pmdclust->SetEdepCut(fEcut); |
483 | ||
484 | fRunLoader->GetEvent(ievt); | |
485 | ||
486 | ResetRecpoint(); | |
01b56f5c | 487 | |
5f55af10 | 488 | fTreeR = fPMDLoader->TreeR(); |
489 | if (fTreeR == 0x0) | |
490 | { | |
491 | fPMDLoader->MakeTree("R"); | |
492 | fTreeR = fPMDLoader->TreeR(); | |
493 | } | |
5f55af10 | 494 | Int_t bufsize = 16000; |
5c5cadd5 | 495 | TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
496 | TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); | |
01b56f5c | 497 | |
498 | const Int_t kDDL = 6; | |
5f55af10 | 499 | const Int_t kRow = 48; |
500 | const Int_t kCol = 96; | |
5f55af10 | 501 | |
01b56f5c | 502 | Int_t idet = 0; |
503 | Int_t iSMN = 0; | |
504 | ||
505 | for (Int_t indexDDL = 0; indexDDL < kDDL; indexDDL++) | |
5f55af10 | 506 | { |
01b56f5c | 507 | if (indexDDL < 4) |
5f55af10 | 508 | { |
01b56f5c | 509 | iSMN = 6; |
5f55af10 | 510 | } |
01b56f5c | 511 | else if (indexDDL >= 4) |
5f55af10 | 512 | { |
01b56f5c | 513 | iSMN = 12; |
5f55af10 | 514 | } |
01b56f5c | 515 | Int_t ***precpvADC; |
516 | precpvADC = new int **[iSMN]; | |
517 | for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow]; | |
518 | for (Int_t i=0; i<iSMN;i++) | |
5f55af10 | 519 | { |
01b56f5c | 520 | for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol]; |
5f55af10 | 521 | } |
01b56f5c | 522 | for (Int_t i = 0; i < iSMN; i++) |
523 | { | |
524 | for (Int_t j = 0; j < kRow; j++) | |
525 | { | |
526 | for (Int_t k = 0; k < kCol; k++) | |
527 | { | |
528 | precpvADC[i][j][k] = 0; | |
529 | } | |
530 | } | |
531 | } | |
532 | ResetCellADC(); | |
533 | rawReader->Reset(); | |
534 | AliPMDRawStream pmdinput(rawReader); | |
362c9d61 | 535 | rawReader->Select("PMD", indexDDL, indexDDL); |
df42ab21 | 536 | |
537 | pmdinput.DdlData(&pmdddlcont); | |
538 | ||
539 | Int_t indexsmn = 0; | |
540 | Int_t ientries = pmdddlcont.GetEntries(); | |
541 | for (Int_t ient = 0; ient < ientries; ient++) | |
01b56f5c | 542 | { |
df42ab21 | 543 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient); |
544 | ||
545 | Int_t det = pmdddl->GetDetector(); | |
546 | Int_t smn = pmdddl->GetSMN(); | |
547 | //Int_t mcm = pmdddl->GetMCM(); | |
548 | //Int_t chno = pmdddl->GetChannel(); | |
549 | Int_t row = pmdddl->GetRow(); | |
550 | Int_t col = pmdddl->GetColumn(); | |
551 | Int_t sig = pmdddl->GetSignal(); | |
09a06455 | 552 | |
553 | Float_t sig1 = (Float_t) sig; | |
554 | // CALIBRATION | |
555 | Float_t gain = fCalibData->GetGainFact(det,smn,row,col); | |
df42ab21 | 556 | //printf("sig = %d gain = %f\n",sig,gain); |
09a06455 | 557 | sig = (Int_t) (sig1*gain); |
df42ab21 | 558 | |
5f55af10 | 559 | |
01b56f5c | 560 | if (indexDDL < 4) |
561 | { | |
562 | if (det != 0) | |
7e9508a7 | 563 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
564 | indexDDL, det)); | |
01b56f5c | 565 | indexsmn = smn - indexDDL * 6; |
566 | } | |
567 | else if (indexDDL == 4) | |
568 | { | |
569 | if (det != 1) | |
7e9508a7 | 570 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
571 | indexDDL, det)); | |
01b56f5c | 572 | if (smn < 6) |
573 | { | |
574 | indexsmn = smn; | |
575 | } | |
df42ab21 | 576 | else if (smn >= 18 && smn < 24) |
01b56f5c | 577 | { |
df42ab21 | 578 | indexsmn = smn - 12; |
01b56f5c | 579 | } |
580 | } | |
581 | else if (indexDDL == 5) | |
582 | { | |
583 | if (det != 1) | |
7e9508a7 | 584 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
585 | indexDDL, det)); | |
01b56f5c | 586 | if (smn >= 6 && smn < 12) |
587 | { | |
588 | indexsmn = smn - 6; | |
589 | } | |
df42ab21 | 590 | else if (smn >= 12 && smn < 18) |
01b56f5c | 591 | { |
df42ab21 | 592 | indexsmn = smn - 6; |
01b56f5c | 593 | } |
594 | } | |
595 | precpvADC[indexsmn][row][col] = sig; | |
df42ab21 | 596 | |
597 | } | |
598 | ||
599 | pmdddlcont.Clear(); | |
01b56f5c | 600 | |
601 | Int_t ismn = 0; | |
602 | for (Int_t indexsmn = 0; indexsmn < iSMN; indexsmn++) | |
5f55af10 | 603 | { |
01b56f5c | 604 | ResetCellADC(); |
5f55af10 | 605 | for (Int_t irow = 0; irow < kRow; irow++) |
606 | { | |
607 | for (Int_t icol = 0; icol < kCol; icol++) | |
608 | { | |
01b56f5c | 609 | fCellADC[irow][icol] = |
610 | (Double_t) precpvADC[indexsmn][irow][icol]; | |
5f55af10 | 611 | } // row |
612 | } // col | |
df42ab21 | 613 | |
614 | ||
01b56f5c | 615 | if (indexDDL < 4) |
616 | { | |
617 | ismn = indexsmn + indexDDL * 6; | |
618 | idet = 0; | |
619 | } | |
620 | else if (indexDDL == 4) | |
621 | { | |
622 | if (indexsmn < 6) | |
623 | { | |
624 | ismn = indexsmn; | |
625 | } | |
626 | else if (indexsmn >= 6 && indexsmn < 12) | |
627 | { | |
df42ab21 | 628 | ismn = indexsmn + 12; |
01b56f5c | 629 | } |
630 | idet = 1; | |
631 | } | |
632 | else if (indexDDL == 5) | |
633 | { | |
634 | if (indexsmn < 6) | |
635 | { | |
636 | ismn = indexsmn + 6; | |
637 | } | |
638 | else if (indexsmn >= 6 && indexsmn < 12) | |
639 | { | |
df42ab21 | 640 | ismn = indexsmn + 6; |
01b56f5c | 641 | } |
642 | idet = 1; | |
643 | } | |
644 | ||
5f55af10 | 645 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
646 | Int_t nentries1 = pmdcont->GetEntries(); | |
7e9508a7 | 647 | |
648 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
649 | ||
5f55af10 | 650 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
651 | { | |
652 | AliPMDcluster *pmdcl = | |
653 | (AliPMDcluster*)pmdcont->UncheckedAt(ient1); | |
654 | idet = pmdcl->GetDetector(); | |
655 | ismn = pmdcl->GetSMN(); | |
656 | clusdata[0] = pmdcl->GetClusX(); | |
657 | clusdata[1] = pmdcl->GetClusY(); | |
658 | clusdata[2] = pmdcl->GetClusADC(); | |
659 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 660 | clusdata[4] = pmdcl->GetClusSigmaX(); |
661 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
01b56f5c | 662 | |
5f55af10 | 663 | AddRecPoint(idet,ismn,clusdata); |
5c5cadd5 | 664 | |
5c5cadd5 | 665 | Int_t ncell = (Int_t) clusdata[3]; |
666 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
667 | { | |
668 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
669 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
670 | AddRecHit(celldataX, celldataY); | |
671 | } | |
672 | branch2->Fill(); | |
673 | ResetRechit(); | |
674 | ||
5f55af10 | 675 | } |
676 | pmdcont->Clear(); | |
677 | ||
5c5cadd5 | 678 | branch1->Fill(); |
5f55af10 | 679 | ResetRecpoint(); |
01b56f5c | 680 | |
681 | ||
5f55af10 | 682 | } // smn |
5f55af10 | 683 | |
01b56f5c | 684 | for (Int_t i=0; i<iSMN; i++) |
685 | { | |
686 | for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j]; | |
687 | } | |
688 | for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i]; | |
689 | delete precpvADC; | |
690 | } // DDL Loop | |
691 | ||
5f55af10 | 692 | ResetCellADC(); |
01b56f5c | 693 | |
5f55af10 | 694 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
695 | fPMDLoader->WriteRecPoints("OVERWRITE"); | |
696 | ||
697 | // delete the pointers | |
698 | delete pmdclust; | |
699 | delete pmdcont; | |
700 | ||
5f55af10 | 701 | } |
702 | // ------------------------------------------------------------------------- // | |
ed228cbc | 703 | void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut) |
704 | { | |
705 | fEcut = ecut; | |
706 | } | |
1758e4fe | 707 | // ------------------------------------------------------------------------- // |
1758e4fe | 708 | void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata) |
01709453 | 709 | { |
b208c6a3 | 710 | // Add Reconstructed points |
711 | // | |
01709453 | 712 | TClonesArray &lrecpoints = *fRecpoints; |
ed228cbc | 713 | AliPMDrecpoint1 *newrecpoint; |
1758e4fe | 714 | newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata); |
ed228cbc | 715 | new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint); |
01709453 | 716 | delete newrecpoint; |
717 | } | |
1758e4fe | 718 | // ------------------------------------------------------------------------- // |
5c5cadd5 | 719 | void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY) |
720 | { | |
721 | // Add associated cell hits to the Reconstructed points | |
722 | // | |
723 | TClonesArray &lrechits = *fRechits; | |
724 | AliPMDrechit *newrechit; | |
725 | newrechit = new AliPMDrechit(celldataX, celldataY); | |
726 | new(lrechits[fNhit++]) AliPMDrechit(newrechit); | |
727 | delete newrechit; | |
728 | } | |
729 | // ------------------------------------------------------------------------- // | |
01709453 | 730 | void AliPMDClusterFinder::ResetCellADC() |
731 | { | |
b208c6a3 | 732 | // Reset the individual cell ADC value to zero |
733 | // | |
5e6a9312 | 734 | for(Int_t irow = 0; irow < fgkRow; irow++) |
01709453 | 735 | { |
5e6a9312 | 736 | for(Int_t icol = 0; icol < fgkCol; icol++) |
01709453 | 737 | { |
ed228cbc | 738 | fCellADC[irow][icol] = 0.; |
01709453 | 739 | } |
740 | } | |
741 | } | |
1758e4fe | 742 | // ------------------------------------------------------------------------- // |
01709453 | 743 | |
744 | void AliPMDClusterFinder::ResetRecpoint() | |
745 | { | |
b208c6a3 | 746 | // Clear the list of reconstructed points |
01709453 | 747 | fNpoint = 0; |
748 | if (fRecpoints) fRecpoints->Clear(); | |
749 | } | |
1758e4fe | 750 | // ------------------------------------------------------------------------- // |
5c5cadd5 | 751 | void AliPMDClusterFinder::ResetRechit() |
752 | { | |
753 | // Clear the list of reconstructed points | |
754 | fNhit = 0; | |
755 | if (fRechits) fRechits->Clear(); | |
756 | } | |
757 | // ------------------------------------------------------------------------- // | |
55601d47 | 758 | void AliPMDClusterFinder::Load() |
759 | { | |
ebd83c56 | 760 | // Load all the *.root files |
55601d47 | 761 | // |
762 | fPMDLoader->LoadDigits("READ"); | |
763 | fPMDLoader->LoadRecPoints("recreate"); | |
764 | } | |
765 | // ------------------------------------------------------------------------- // | |
01b56f5c | 766 | void AliPMDClusterFinder::LoadClusters() |
767 | { | |
768 | // Load all the *.root files | |
769 | // | |
770 | fPMDLoader->LoadRecPoints("recreate"); | |
771 | } | |
772 | // ------------------------------------------------------------------------- // | |
ebd83c56 | 773 | void AliPMDClusterFinder::UnLoad() |
01709453 | 774 | { |
b208c6a3 | 775 | // Unload all the *.root files |
776 | // | |
ebd83c56 | 777 | fPMDLoader->UnloadDigits(); |
778 | fPMDLoader->UnloadRecPoints(); | |
01709453 | 779 | } |
1758e4fe | 780 | // ------------------------------------------------------------------------- // |
01b56f5c | 781 | void AliPMDClusterFinder::UnLoadClusters() |
782 | { | |
783 | // Unload all the *.root files | |
784 | // | |
785 | fPMDLoader->UnloadRecPoints(); | |
786 | } | |
787 | // ------------------------------------------------------------------------- // | |
09a06455 | 788 | |
789 | AliPMDCalibData* AliPMDClusterFinder::GetCalibData() const | |
790 | { | |
791 | // The run number will be centralized in AliCDBManager, | |
792 | // you don't need to set it here! | |
793 | // Added by ZA | |
794 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Data"); | |
795 | ||
796 | if(!entry){ | |
797 | AliWarning("Calibration object retrieval failed! Dummy calibration will be used."); | |
798 | ||
799 | // this just remembers the actual default storage. No problem if it is null. | |
800 | AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage(); | |
801 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
802 | ||
803 | entry = AliCDBManager::Instance()->Get("PMD/Calib/Data"); | |
804 | ||
805 | // now reset the original default storage to AliCDBManager... | |
806 | AliCDBManager::Instance()->SetDefaultStorage(origStorage); | |
807 | } | |
808 | ||
809 | AliPMDCalibData *calibdata=0; | |
810 | if (entry) calibdata = (AliPMDCalibData*) entry->GetObject(); | |
811 | ||
812 | if (!calibdata) AliError("No calibration data from calibration database !"); | |
813 | ||
814 | return calibdata; | |
815 | } |