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