]>
Commit | Line | Data |
---|---|---|
b9746a9e | 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 | **************************************************************************/ | |
b2b13ee2 | 15 | //-----------------------------------------------------// |
16 | // // | |
8599803d | 17 | // Source File : PMDDigitizer.cxx, Version 00 // |
b2b13ee2 | 18 | // // |
19 | // Date : September 20 2002 // | |
20 | // // | |
21 | //-----------------------------------------------------// | |
22 | ||
36031625 | 23 | #include <Riostream.h> |
b2b13ee2 | 24 | #include <TBRIK.h> |
25 | #include <TNode.h> | |
26 | #include <TTree.h> | |
27 | #include <TGeometry.h> | |
28 | #include <TObjArray.h> | |
29 | #include <TClonesArray.h> | |
30 | #include <TFile.h> | |
31 | #include <TNtuple.h> | |
32 | #include <TParticle.h> | |
33 | ||
ecee2a1a | 34 | #include "AliLog.h" |
b2b13ee2 | 35 | #include "AliRun.h" |
36 | #include "AliPMD.h" | |
c35544fe | 37 | #include "AliPMDhit.h" |
b2b13ee2 | 38 | #include "AliHit.h" |
39 | #include "AliDetector.h" | |
40 | #include "AliRunLoader.h" | |
41 | #include "AliLoader.h" | |
42 | #include "AliConfig.h" | |
43 | #include "AliMagF.h" | |
44 | #include "AliRunDigitizer.h" | |
7088dbe9 | 45 | #include "AliDigitizer.h" |
b2b13ee2 | 46 | #include "AliHeader.h" |
47 | ||
48 | #include "AliPMDcell.h" | |
49 | #include "AliPMDsdigit.h" | |
50 | #include "AliPMDdigit.h" | |
51 | #include "AliPMDDigitizer.h" | |
5d12ce38 | 52 | #include "AliMC.h" |
b2b13ee2 | 53 | |
54 | ClassImp(AliPMDDigitizer) | |
a7d110b8 | 55 | |
01960205 | 56 | AliPMDDigitizer::AliPMDDigitizer() : |
57 | fRunLoader(0), | |
58 | fPMDHit(0), | |
59 | fPMD(0), | |
60 | fPMDLoader(0), | |
ebd83c56 | 61 | fSDigits(0), |
62 | fDigits(0), | |
63 | fCell(0), | |
01960205 | 64 | fNsdigit(0), |
65 | fNdigit(0), | |
66 | fDetNo(0), | |
67 | fZPos(361.5)// in units of cm, This is the default position of PMD | |
b2b13ee2 | 68 | { |
36031625 | 69 | // Default Constructor |
70 | // | |
36031625 | 71 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 72 | { |
36031625 | 73 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 74 | { |
36031625 | 75 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 76 | { |
77 | fCPV[i][j][k] = 0.; | |
36031625 | 78 | fPRE[i][j][k] = 0.; |
01960205 | 79 | fPRECounter[i][j][k] = 0; |
80 | fPRETrackNo[i][j][k] = -1; | |
81 | fCPVTrackNo[i][j][k] = -1; | |
b2b13ee2 | 82 | } |
83 | } | |
84 | } | |
85 | ||
b2b13ee2 | 86 | } |
7088dbe9 | 87 | //____________________________________________________________________________ |
88 | AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager) | |
ebd83c56 | 89 | :AliDigitizer(manager), |
90 | fRunLoader(0), | |
91 | fPMDHit(0), | |
92 | fPMD(0), | |
93 | fPMDLoader(0), | |
94 | fSDigits(new TClonesArray("AliPMDsdigit", 1000)), | |
95 | fDigits(new TClonesArray("AliPMDdigit", 1000)), | |
96 | fCell(0), | |
ebd83c56 | 97 | fNsdigit(0), |
98 | fNdigit(0), | |
99 | fDetNo(0), | |
100 | fZPos(361.5)// in units of cm, This is the default position of PMD | |
7088dbe9 | 101 | { |
102 | // ctor which should be used | |
103 | ||
ebd83c56 | 104 | for (Int_t i = 0; i < fgkTotUM; i++) |
105 | { | |
106 | for (Int_t j = 0; j < fgkRow; j++) | |
107 | { | |
108 | for (Int_t k = 0; k < fgkCol; k++) | |
109 | { | |
110 | fCPV[i][j][k] = 0.; | |
111 | fPRE[i][j][k] = 0.; | |
112 | fPRECounter[i][j][k] = 0; | |
113 | fPRETrackNo[i][j][k] = -1; | |
114 | fCPVTrackNo[i][j][k] = -1; | |
115 | } | |
116 | } | |
117 | } | |
7088dbe9 | 118 | } |
119 | //____________________________________________________________________________ | |
b2b13ee2 | 120 | AliPMDDigitizer::~AliPMDDigitizer() |
121 | { | |
36031625 | 122 | // Default Destructor |
123 | // | |
01960205 | 124 | if (fSDigits) { |
125 | fSDigits->Delete(); | |
126 | delete fSDigits; | |
127 | fSDigits=0; | |
128 | } | |
129 | if (fDigits) { | |
130 | fDigits->Delete(); | |
131 | delete fDigits; | |
132 | fDigits=0; | |
133 | } | |
ebd83c56 | 134 | fCell.Delete(); |
b2b13ee2 | 135 | } |
136 | // | |
137 | // Member functions | |
138 | // | |
7088dbe9 | 139 | //____________________________________________________________________________ |
85a5290f | 140 | void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option) |
b2b13ee2 | 141 | { |
36031625 | 142 | // Loads galice.root file and corresponding header, kinematics |
143 | // hits and sdigits or digits depending on the option | |
144 | // | |
f540341d | 145 | |
e191bb57 | 146 | TString evfoldname = AliConfig::GetDefaultEventFolderName(); |
f540341d | 147 | fRunLoader = AliRunLoader::GetRunLoader(evfoldname); |
148 | if (!fRunLoader) | |
e191bb57 | 149 | fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(), |
f540341d | 150 | "UPDATE"); |
b2b13ee2 | 151 | |
152 | if (!fRunLoader) | |
153 | { | |
ecee2a1a | 154 | AliError(Form("Can not open session for file %s.",file)); |
b2b13ee2 | 155 | } |
156 | ||
f540341d | 157 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); |
158 | if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); | |
159 | if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics(); | |
b2b13ee2 | 160 | |
b208c6a3 | 161 | gAlice = fRunLoader->GetAliRun(); |
b2b13ee2 | 162 | |
ecee2a1a | 163 | if (gAlice) |
164 | { | |
165 | AliDebug(1,"Alirun object found"); | |
166 | } | |
167 | else | |
168 | { | |
169 | AliError("Could not found Alirun object"); | |
170 | } | |
f540341d | 171 | |
b208c6a3 | 172 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); |
36031625 | 173 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
174 | if (fPMDLoader == 0x0) | |
b2b13ee2 | 175 | { |
ecee2a1a | 176 | AliError("Can not find PMDLoader"); |
b2b13ee2 | 177 | } |
178 | ||
179 | const char *cHS = strstr(option,"HS"); | |
180 | const char *cHD = strstr(option,"HD"); | |
181 | const char *cSD = strstr(option,"SD"); | |
182 | ||
183 | if (cHS) | |
184 | { | |
36031625 | 185 | fPMDLoader->LoadHits("READ"); |
186 | fPMDLoader->LoadSDigits("recreate"); | |
b2b13ee2 | 187 | } |
188 | else if (cHD) | |
189 | { | |
36031625 | 190 | fPMDLoader->LoadHits("READ"); |
191 | fPMDLoader->LoadDigits("recreate"); | |
b2b13ee2 | 192 | } |
193 | else if (cSD) | |
194 | { | |
36031625 | 195 | fPMDLoader->LoadSDigits("READ"); |
196 | fPMDLoader->LoadDigits("recreate"); | |
b2b13ee2 | 197 | } |
b2b13ee2 | 198 | } |
7088dbe9 | 199 | //____________________________________________________________________________ |
b2b13ee2 | 200 | void AliPMDDigitizer::Hits2SDigits(Int_t ievt) |
201 | { | |
36031625 | 202 | // This reads the PMD Hits tree and assigns the right track number |
203 | // to a cell and stores in the summable digits tree | |
204 | // | |
b2b13ee2 | 205 | |
36031625 | 206 | const Int_t kPi0 = 111; |
207 | const Int_t kGamma = 22; | |
b2b13ee2 | 208 | Int_t npmd; |
209 | Int_t trackno; | |
b2b13ee2 | 210 | Int_t smnumber; |
211 | Int_t trackpid; | |
212 | Int_t mtrackno; | |
213 | Int_t mtrackpid; | |
214 | ||
215 | Float_t xPos, yPos, zPos; | |
8599803d | 216 | Int_t xpad = -1, ypad = -1; |
b2b13ee2 | 217 | Float_t edep; |
218 | Float_t vx = -999.0, vy = -999.0, vz = -999.0; | |
219 | ||
a7d110b8 | 220 | |
ebd83c56 | 221 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 222 | ResetSDigit(); |
223 | ||
ecee2a1a | 224 | AliDebug(1,Form("Event Number = %d",ievt)); |
b2b13ee2 | 225 | Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); |
ecee2a1a | 226 | AliDebug(1,Form("Number of Particles = %d",nparticles)); |
b2b13ee2 | 227 | fRunLoader->GetEvent(ievt); |
b2b13ee2 | 228 | // ------------------------------------------------------- // |
229 | // Pointer to specific detector hits. | |
230 | // Get pointers to Alice detectors and Hits containers | |
231 | ||
ebd83c56 | 232 | TTree* treeH = fPMDLoader->TreeH(); |
b2b13ee2 | 233 | |
ebd83c56 | 234 | Int_t ntracks = (Int_t) treeH->GetEntries(); |
ecee2a1a | 235 | AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); |
ebd83c56 | 236 | TTree* treeS = fPMDLoader->TreeS(); |
237 | if (treeS == 0x0) | |
b2b13ee2 | 238 | { |
36031625 | 239 | fPMDLoader->MakeTree("S"); |
ebd83c56 | 240 | treeS = fPMDLoader->TreeS(); |
b2b13ee2 | 241 | } |
242 | Int_t bufsize = 16000; | |
ebd83c56 | 243 | treeS->Branch("PMDSDigit", &fSDigits, bufsize); |
b2b13ee2 | 244 | |
ebd83c56 | 245 | TClonesArray* hits = 0; |
246 | if (fPMD) hits = fPMD->Hits(); | |
b2b13ee2 | 247 | |
248 | // Start loop on tracks in the hits containers | |
a7d110b8 | 249 | |
b2b13ee2 | 250 | for (Int_t track=0; track<ntracks;track++) |
251 | { | |
b208c6a3 | 252 | gAlice->ResetHits(); |
ebd83c56 | 253 | treeH->GetEvent(track); |
36031625 | 254 | if (fPMD) |
b2b13ee2 | 255 | { |
ebd83c56 | 256 | npmd = hits->GetEntriesFast(); |
b2b13ee2 | 257 | for (int ipmd = 0; ipmd < npmd; ipmd++) |
258 | { | |
ebd83c56 | 259 | fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); |
36031625 | 260 | trackno = fPMDHit->GetTrack(); |
b2b13ee2 | 261 | // get kinematics of the particles |
36031625 | 262 | |
ebd83c56 | 263 | TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); |
264 | trackpid = mparticle->GetPdgCode(); | |
b2b13ee2 | 265 | |
266 | Int_t igatr = -999; | |
267 | Int_t ichtr = -999; | |
8599803d | 268 | Int_t igapid = -999; |
b2b13ee2 | 269 | Int_t imo; |
270 | Int_t igen = 0; | |
36031625 | 271 | Int_t idmo = -999; |
8599803d | 272 | |
36031625 | 273 | Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; |
8599803d | 274 | if (mparticle->GetFirstMother() == -1) |
275 | { | |
36031625 | 276 | tracknoOld = trackno; |
277 | trackpidOld = trackpid; | |
278 | statusOld = -1; | |
8599803d | 279 | } |
8599803d | 280 | Int_t igstatus = 0; |
b2b13ee2 | 281 | while((imo = mparticle->GetFirstMother()) >= 0) |
282 | { | |
283 | igen++; | |
36031625 | 284 | |
b208c6a3 | 285 | mparticle = gAlice->GetMCApp()->Particle(imo); |
36031625 | 286 | idmo = mparticle->GetPdgCode(); |
b2b13ee2 | 287 | |
288 | vx = mparticle->Vx(); | |
289 | vy = mparticle->Vy(); | |
290 | vz = mparticle->Vz(); | |
291 | ||
36031625 | 292 | //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); |
293 | //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); | |
294 | if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.) | |
b2b13ee2 | 295 | { |
296 | igatr = imo; | |
36031625 | 297 | igapid = idmo; |
8599803d | 298 | igstatus = 1; |
299 | } | |
300 | if(igstatus == 0) | |
301 | { | |
36031625 | 302 | if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) |
8599803d | 303 | { |
304 | igatr = imo; | |
36031625 | 305 | igapid = idmo; |
8599803d | 306 | } |
b2b13ee2 | 307 | } |
308 | ichtr = imo; | |
309 | } | |
310 | ||
36031625 | 311 | if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) |
b2b13ee2 | 312 | { |
313 | mtrackno = igatr; | |
8599803d | 314 | mtrackpid = igapid; |
b2b13ee2 | 315 | } |
316 | else | |
317 | { | |
318 | mtrackno = ichtr; | |
36031625 | 319 | mtrackpid = idmo; |
b2b13ee2 | 320 | } |
36031625 | 321 | if (statusOld == -1) |
8599803d | 322 | { |
36031625 | 323 | mtrackno = tracknoOld; |
324 | mtrackpid = trackpidOld; | |
8599803d | 325 | } |
36031625 | 326 | xPos = fPMDHit->X(); |
327 | yPos = fPMDHit->Y(); | |
328 | zPos = fPMDHit->Z(); | |
7088dbe9 | 329 | |
c35544fe | 330 | edep = fPMDHit->GetEnergy(); |
331 | Int_t vol1 = fPMDHit->GetVolume(1); // Column | |
332 | Int_t vol2 = fPMDHit->GetVolume(2); // Row | |
333 | Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule | |
334 | Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule | |
335 | ||
8599803d | 336 | // -----------------------------------------// |
337 | // For Super Module 1 & 2 // | |
338 | // nrow = 96, ncol = 48 // | |
339 | // For Super Module 3 & 4 // | |
340 | // nrow = 48, ncol = 96 // | |
341 | // -----------------------------------------// | |
b2b13ee2 | 342 | |
36031625 | 343 | smnumber = (vol6-1)*6 + vol3; |
8599803d | 344 | |
36031625 | 345 | if (vol6 == 1 || vol6 == 2) |
8599803d | 346 | { |
36031625 | 347 | xpad = vol1; |
348 | ypad = vol2; | |
8599803d | 349 | } |
36031625 | 350 | else if (vol6 == 3 || vol6 == 4) |
b2b13ee2 | 351 | { |
36031625 | 352 | xpad = vol2; |
353 | ypad = vol1; | |
b2b13ee2 | 354 | } |
b2b13ee2 | 355 | |
ecee2a1a | 356 | AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep)); |
8599803d | 357 | Float_t zposition = TMath::Abs(zPos); |
358 | if (zposition < fZPos) | |
b2b13ee2 | 359 | { |
360 | // CPV | |
361 | fDetNo = 1; | |
362 | } | |
8599803d | 363 | else if (zposition > fZPos) |
b2b13ee2 | 364 | { |
365 | // PMD | |
366 | fDetNo = 0; | |
367 | } | |
8599803d | 368 | Int_t smn = smnumber - 1; |
369 | Int_t ixx = xpad - 1; | |
370 | Int_t iyy = ypad - 1; | |
b2b13ee2 | 371 | if (fDetNo == 0) |
372 | { | |
36031625 | 373 | fPRE[smn][ixx][iyy] += edep; |
374 | fPRECounter[smn][ixx][iyy]++; | |
b2b13ee2 | 375 | |
ebd83c56 | 376 | AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); |
b2b13ee2 | 377 | |
ebd83c56 | 378 | fCell.Add(cell); |
b2b13ee2 | 379 | } |
380 | else if(fDetNo == 1) | |
381 | { | |
8599803d | 382 | fCPV[smn][ixx][iyy] += edep; |
383 | fCPVTrackNo[smn][ixx][iyy] = mtrackno; | |
b2b13ee2 | 384 | } |
385 | } | |
386 | } | |
387 | } // Track Loop ended | |
8599803d | 388 | |
b2b13ee2 | 389 | TrackAssignment2Cell(); |
b2b13ee2 | 390 | ResetCell(); |
391 | ||
392 | Float_t deltaE = 0.; | |
393 | Int_t detno = 0; | |
b2b13ee2 | 394 | Int_t trno = -1; |
b2b13ee2 | 395 | |
396 | for (Int_t idet = 0; idet < 2; idet++) | |
397 | { | |
36031625 | 398 | for (Int_t ism = 0; ism < fgkTotUM; ism++) |
b2b13ee2 | 399 | { |
36031625 | 400 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) |
b2b13ee2 | 401 | { |
36031625 | 402 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) |
b2b13ee2 | 403 | { |
b2b13ee2 | 404 | if (idet == 0) |
405 | { | |
36031625 | 406 | deltaE = fPRE[ism][jrow][kcol]; |
407 | trno = fPRETrackNo[ism][jrow][kcol]; | |
b2b13ee2 | 408 | detno = 0; |
409 | } | |
410 | else if (idet == 1) | |
411 | { | |
412 | deltaE = fCPV[ism][jrow][kcol]; | |
413 | trno = fCPVTrackNo[ism][jrow][kcol]; | |
414 | detno = 1; | |
415 | } | |
416 | if (deltaE > 0.) | |
417 | { | |
7088dbe9 | 418 | AddSDigit(trno,detno,ism,jrow,kcol,deltaE); |
b2b13ee2 | 419 | } |
420 | } | |
421 | } | |
ebd83c56 | 422 | treeS->Fill(); |
b2b13ee2 | 423 | ResetSDigit(); |
424 | } | |
425 | } | |
36031625 | 426 | fPMDLoader->WriteSDigits("OVERWRITE"); |
b2b13ee2 | 427 | ResetCellADC(); |
428 | ||
b2b13ee2 | 429 | } |
7088dbe9 | 430 | //____________________________________________________________________________ |
b2b13ee2 | 431 | |
432 | void AliPMDDigitizer::Hits2Digits(Int_t ievt) | |
433 | { | |
36031625 | 434 | // This reads the PMD Hits tree and assigns the right track number |
435 | // to a cell and stores in the digits tree | |
436 | // | |
437 | const Int_t kPi0 = 111; | |
438 | const Int_t kGamma = 22; | |
b2b13ee2 | 439 | Int_t npmd; |
440 | Int_t trackno; | |
b2b13ee2 | 441 | Int_t smnumber; |
442 | Int_t trackpid; | |
443 | Int_t mtrackno; | |
444 | Int_t mtrackpid; | |
445 | ||
446 | Float_t xPos, yPos, zPos; | |
8599803d | 447 | Int_t xpad = -1, ypad = -1; |
b2b13ee2 | 448 | Float_t edep; |
449 | Float_t vx = -999.0, vy = -999.0, vz = -999.0; | |
450 | ||
ebd83c56 | 451 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
b2b13ee2 | 452 | ResetDigit(); |
453 | ||
ecee2a1a | 454 | AliDebug(1,Form("Event Number = %d",ievt)); |
b2b13ee2 | 455 | Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); |
ecee2a1a | 456 | AliDebug(1,Form("Number of Particles = %d", nparticles)); |
b2b13ee2 | 457 | fRunLoader->GetEvent(ievt); |
b2b13ee2 | 458 | // ------------------------------------------------------- // |
459 | // Pointer to specific detector hits. | |
460 | // Get pointers to Alice detectors and Hits containers | |
461 | ||
b208c6a3 | 462 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); |
36031625 | 463 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b2b13ee2 | 464 | |
36031625 | 465 | if (fPMDLoader == 0x0) |
b2b13ee2 | 466 | { |
ecee2a1a | 467 | AliError("Can not find PMD or PMDLoader"); |
b2b13ee2 | 468 | } |
ebd83c56 | 469 | TTree* treeH = fPMDLoader->TreeH(); |
470 | Int_t ntracks = (Int_t) treeH->GetEntries(); | |
ecee2a1a | 471 | AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); |
36031625 | 472 | fPMDLoader->LoadDigits("recreate"); |
ebd83c56 | 473 | TTree* treeD = fPMDLoader->TreeD(); |
474 | if (treeD == 0x0) | |
b2b13ee2 | 475 | { |
36031625 | 476 | fPMDLoader->MakeTree("D"); |
ebd83c56 | 477 | treeD = fPMDLoader->TreeD(); |
b2b13ee2 | 478 | } |
479 | Int_t bufsize = 16000; | |
ebd83c56 | 480 | treeD->Branch("PMDDigit", &fDigits, bufsize); |
b2b13ee2 | 481 | |
ebd83c56 | 482 | TClonesArray* hits = 0; |
483 | if (fPMD) hits = fPMD->Hits(); | |
b2b13ee2 | 484 | |
485 | // Start loop on tracks in the hits containers | |
486 | ||
487 | for (Int_t track=0; track<ntracks;track++) | |
488 | { | |
b208c6a3 | 489 | gAlice->ResetHits(); |
ebd83c56 | 490 | treeH->GetEvent(track); |
b2b13ee2 | 491 | |
36031625 | 492 | if (fPMD) |
b2b13ee2 | 493 | { |
ebd83c56 | 494 | npmd = hits->GetEntriesFast(); |
b2b13ee2 | 495 | for (int ipmd = 0; ipmd < npmd; ipmd++) |
496 | { | |
ebd83c56 | 497 | fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); |
36031625 | 498 | trackno = fPMDHit->GetTrack(); |
b2b13ee2 | 499 | |
500 | // get kinematics of the particles | |
501 | ||
ebd83c56 | 502 | TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); |
503 | trackpid = mparticle->GetPdgCode(); | |
b2b13ee2 | 504 | |
505 | Int_t igatr = -999; | |
506 | Int_t ichtr = -999; | |
8599803d | 507 | Int_t igapid = -999; |
b2b13ee2 | 508 | Int_t imo; |
509 | Int_t igen = 0; | |
36031625 | 510 | Int_t idmo = -999; |
8599803d | 511 | |
36031625 | 512 | Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; |
8599803d | 513 | if (mparticle->GetFirstMother() == -1) |
514 | { | |
36031625 | 515 | tracknoOld = trackno; |
516 | trackpidOld = trackpid; | |
517 | statusOld = -1; | |
8599803d | 518 | } |
519 | ||
520 | Int_t igstatus = 0; | |
b2b13ee2 | 521 | while((imo = mparticle->GetFirstMother()) >= 0) |
522 | { | |
523 | igen++; | |
36031625 | 524 | |
b208c6a3 | 525 | mparticle = gAlice->GetMCApp()->Particle(imo); |
36031625 | 526 | idmo = mparticle->GetPdgCode(); |
b2b13ee2 | 527 | |
528 | vx = mparticle->Vx(); | |
529 | vy = mparticle->Vy(); | |
530 | vz = mparticle->Vz(); | |
531 | ||
36031625 | 532 | //printf("==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); |
533 | //fprintf(fpw1,"==> Mother ID %5d %5d %5d Vertex: %13.3f %13.3f %13.3f\n", igen, imo, idmo, vx, vy, vz); | |
534 | if ((idmo == kGamma || idmo == -11 || idmo == 11) && vx == 0. && vy == 0. && vz == 0.) | |
b2b13ee2 | 535 | { |
536 | igatr = imo; | |
36031625 | 537 | igapid = idmo; |
8599803d | 538 | igstatus = 1; |
539 | } | |
540 | if(igstatus == 0) | |
541 | { | |
36031625 | 542 | if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) |
8599803d | 543 | { |
544 | igatr = imo; | |
36031625 | 545 | igapid = idmo; |
8599803d | 546 | } |
b2b13ee2 | 547 | } |
548 | ichtr = imo; | |
549 | } | |
550 | ||
36031625 | 551 | if (idmo == kPi0 && vx == 0. && vy == 0. && vz == 0.) |
b2b13ee2 | 552 | { |
553 | mtrackno = igatr; | |
8599803d | 554 | mtrackpid = igapid; |
b2b13ee2 | 555 | } |
556 | else | |
557 | { | |
558 | mtrackno = ichtr; | |
36031625 | 559 | mtrackpid = idmo; |
b2b13ee2 | 560 | } |
36031625 | 561 | if (statusOld == -1) |
8599803d | 562 | { |
36031625 | 563 | mtrackno = tracknoOld; |
564 | mtrackpid = trackpidOld; | |
8599803d | 565 | } |
b2b13ee2 | 566 | |
36031625 | 567 | xPos = fPMDHit->X(); |
568 | yPos = fPMDHit->Y(); | |
569 | zPos = fPMDHit->Z(); | |
7088dbe9 | 570 | |
c35544fe | 571 | edep = fPMDHit->GetEnergy(); |
572 | Int_t vol1 = fPMDHit->GetVolume(1); // Column | |
573 | Int_t vol2 = fPMDHit->GetVolume(2); // Row | |
574 | Int_t vol3 = fPMDHit->GetVolume(3); // UnitModule | |
575 | Int_t vol6 = fPMDHit->GetVolume(6); // SuperModule | |
8599803d | 576 | |
577 | // -----------------------------------------// | |
578 | // For Super Module 1 & 2 // | |
579 | // nrow = 96, ncol = 48 // | |
580 | // For Super Module 3 & 4 // | |
581 | // nrow = 48, ncol = 96 // | |
582 | // -----------------------------------------// | |
b2b13ee2 | 583 | |
36031625 | 584 | smnumber = (vol6-1)*6 + vol3; |
8599803d | 585 | |
36031625 | 586 | if (vol6 == 1 || vol6 == 2) |
b2b13ee2 | 587 | { |
36031625 | 588 | xpad = vol1; |
589 | ypad = vol2; | |
8599803d | 590 | } |
36031625 | 591 | else if (vol6 == 3 || vol6 == 4) |
8599803d | 592 | { |
36031625 | 593 | xpad = vol2; |
594 | ypad = vol1; | |
b2b13ee2 | 595 | } |
b2b13ee2 | 596 | |
ecee2a1a | 597 | AliDebug(2,Form("ZPosition = %f Edeposition = %d",zPos,edep)); |
8599803d | 598 | Float_t zposition = TMath::Abs(zPos); |
599 | ||
600 | if (zposition < fZPos) | |
b2b13ee2 | 601 | { |
602 | // CPV | |
603 | fDetNo = 1; | |
604 | } | |
8599803d | 605 | else if (zposition > fZPos) |
b2b13ee2 | 606 | { |
607 | // PMD | |
608 | fDetNo = 0; | |
609 | } | |
8599803d | 610 | |
611 | Int_t smn = smnumber - 1; | |
612 | Int_t ixx = xpad - 1; | |
613 | Int_t iyy = ypad - 1; | |
614 | if (fDetNo == 0) | |
b2b13ee2 | 615 | { |
36031625 | 616 | fPRE[smn][ixx][iyy] += edep; |
617 | fPRECounter[smn][ixx][iyy]++; | |
8599803d | 618 | |
ebd83c56 | 619 | AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); |
8599803d | 620 | |
ebd83c56 | 621 | fCell.Add(cell); |
b2b13ee2 | 622 | } |
8599803d | 623 | else if(fDetNo == 1) |
b2b13ee2 | 624 | { |
8599803d | 625 | fCPV[smn][ixx][iyy] += edep; |
626 | fCPVTrackNo[smn][ixx][iyy] = mtrackno; | |
b2b13ee2 | 627 | } |
628 | } | |
629 | } | |
630 | } // Track Loop ended | |
631 | ||
632 | TrackAssignment2Cell(); | |
633 | ResetCell(); | |
634 | ||
7088dbe9 | 635 | Float_t adc; |
b2b13ee2 | 636 | Float_t deltaE = 0.; |
637 | Int_t detno = 0; | |
b2b13ee2 | 638 | Int_t trno = 1; |
b2b13ee2 | 639 | |
640 | for (Int_t idet = 0; idet < 2; idet++) | |
641 | { | |
36031625 | 642 | for (Int_t ism = 0; ism < fgkTotUM; ism++) |
b2b13ee2 | 643 | { |
36031625 | 644 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) |
b2b13ee2 | 645 | { |
36031625 | 646 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) |
b2b13ee2 | 647 | { |
b2b13ee2 | 648 | if (idet == 0) |
649 | { | |
36031625 | 650 | deltaE = fPRE[ism][jrow][kcol]; |
651 | trno = fPRETrackNo[ism][jrow][kcol]; | |
b2b13ee2 | 652 | detno = 0; |
653 | } | |
654 | else if (idet == 1) | |
655 | { | |
656 | deltaE = fCPV[ism][jrow][kcol]; | |
8599803d | 657 | trno = fCPVTrackNo[ism][jrow][kcol]; |
b2b13ee2 | 658 | detno = 1; |
659 | } | |
660 | if (deltaE > 0.) | |
661 | { | |
7088dbe9 | 662 | MeV2ADC(deltaE,adc); |
663 | AddDigit(trno,detno,ism,jrow,kcol,adc); | |
b2b13ee2 | 664 | } |
665 | } // column loop | |
666 | } // row loop | |
03965b13 | 667 | treeD->Fill(); |
668 | ResetDigit(); | |
b2b13ee2 | 669 | } // supermodule loop |
b2b13ee2 | 670 | } // detector loop |
03965b13 | 671 | |
36031625 | 672 | fPMDLoader->WriteDigits("OVERWRITE"); |
b2b13ee2 | 673 | ResetCellADC(); |
ecee2a1a | 674 | |
b2b13ee2 | 675 | } |
7088dbe9 | 676 | //____________________________________________________________________________ |
b2b13ee2 | 677 | |
678 | ||
679 | void AliPMDDigitizer::SDigits2Digits(Int_t ievt) | |
680 | { | |
36031625 | 681 | // This reads the PMD sdigits tree and converts energy deposition |
682 | // in a cell to ADC and stores in the digits tree | |
683 | // | |
ecee2a1a | 684 | |
b2b13ee2 | 685 | fRunLoader->GetEvent(ievt); |
686 | ||
ebd83c56 | 687 | TTree* treeS = fPMDLoader->TreeS(); |
b2b13ee2 | 688 | AliPMDsdigit *pmdsdigit; |
ebd83c56 | 689 | TBranch *branch = treeS->GetBranch("PMDSDigit"); |
ecee2a1a | 690 | if(!branch) |
691 | { | |
692 | AliError("PMD Sdigit branch does not exist"); | |
693 | return; | |
694 | } | |
ebd83c56 | 695 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 696 | branch->SetAddress(&fSDigits); |
697 | ||
ebd83c56 | 698 | TTree* treeD = fPMDLoader->TreeD(); |
699 | if (treeD == 0x0) | |
b2b13ee2 | 700 | { |
36031625 | 701 | fPMDLoader->MakeTree("D"); |
ebd83c56 | 702 | treeD = fPMDLoader->TreeD(); |
b2b13ee2 | 703 | } |
704 | Int_t bufsize = 16000; | |
ebd83c56 | 705 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
706 | treeD->Branch("PMDDigit", &fDigits, bufsize); | |
b2b13ee2 | 707 | |
708 | Int_t trno, det, smn; | |
7088dbe9 | 709 | Int_t irow, icol; |
b2b13ee2 | 710 | Float_t edep, adc; |
711 | ||
ebd83c56 | 712 | Int_t nmodules = (Int_t) treeS->GetEntries(); |
ecee2a1a | 713 | AliDebug(1,Form("Number of modules = %d",nmodules)); |
b2b13ee2 | 714 | |
715 | for (Int_t imodule = 0; imodule < nmodules; imodule++) | |
716 | { | |
ebd83c56 | 717 | treeS->GetEntry(imodule); |
b2b13ee2 | 718 | Int_t nentries = fSDigits->GetLast(); |
ecee2a1a | 719 | AliDebug(2,Form("Number of entries per module = %d",nentries+1)); |
b2b13ee2 | 720 | for (Int_t ient = 0; ient < nentries+1; ient++) |
721 | { | |
722 | pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); | |
723 | trno = pmdsdigit->GetTrackNumber(); | |
724 | det = pmdsdigit->GetDetector(); | |
725 | smn = pmdsdigit->GetSMNumber(); | |
7088dbe9 | 726 | irow = pmdsdigit->GetRow(); |
727 | icol = pmdsdigit->GetColumn(); | |
b2b13ee2 | 728 | edep = pmdsdigit->GetCellEdep(); |
729 | ||
730 | MeV2ADC(edep,adc); | |
7088dbe9 | 731 | AddDigit(trno,det,smn,irow,icol,adc); |
b2b13ee2 | 732 | } |
ebd83c56 | 733 | treeD->Fill(); |
b2b13ee2 | 734 | ResetDigit(); |
735 | } | |
36031625 | 736 | fPMDLoader->WriteDigits("OVERWRITE"); |
ecee2a1a | 737 | |
b2b13ee2 | 738 | } |
7088dbe9 | 739 | //____________________________________________________________________________ |
740 | void AliPMDDigitizer::Exec(Option_t *option) | |
741 | { | |
742 | // Does the event merging and digitization | |
7088dbe9 | 743 | const char *cdeb = strstr(option,"deb"); |
744 | if(cdeb) | |
745 | { | |
ecee2a1a | 746 | AliDebug(100," *** PMD Exec is called ***"); |
7088dbe9 | 747 | } |
ecee2a1a | 748 | |
7088dbe9 | 749 | Int_t ninputs = fManager->GetNinputs(); |
ecee2a1a | 750 | AliDebug(1,Form("Number of files to be processed = %d",ninputs)); |
7088dbe9 | 751 | ResetCellADC(); |
752 | ||
753 | for (Int_t i = 0; i < ninputs; i++) | |
754 | { | |
755 | Int_t troffset = fManager->GetMask(i); | |
756 | MergeSDigits(i, troffset); | |
757 | } | |
b2b13ee2 | 758 | |
7088dbe9 | 759 | fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); |
760 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); | |
761 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); | |
762 | if (fPMDLoader == 0x0) | |
763 | { | |
ecee2a1a | 764 | AliError("Can not find PMD or PMDLoader"); |
7088dbe9 | 765 | } |
06f2c79d | 766 | fPMDLoader->LoadDigits("update"); |
ebd83c56 | 767 | TTree* treeD = fPMDLoader->TreeD(); |
768 | if (treeD == 0x0) | |
7088dbe9 | 769 | { |
770 | fPMDLoader->MakeTree("D"); | |
ebd83c56 | 771 | treeD = fPMDLoader->TreeD(); |
7088dbe9 | 772 | } |
773 | Int_t bufsize = 16000; | |
ebd83c56 | 774 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
775 | treeD->Branch("PMDDigit", &fDigits, bufsize); | |
7088dbe9 | 776 | |
777 | Float_t adc; | |
778 | Float_t deltaE = 0.; | |
779 | Int_t detno = 0; | |
780 | Int_t trno = 1; | |
781 | ||
782 | for (Int_t idet = 0; idet < 2; idet++) | |
783 | { | |
784 | for (Int_t ism = 0; ism < fgkTotUM; ism++) | |
785 | { | |
786 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) | |
787 | { | |
788 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) | |
789 | { | |
790 | if (idet == 0) | |
791 | { | |
792 | deltaE = fPRE[ism][jrow][kcol]; | |
793 | trno = fPRETrackNo[ism][jrow][kcol]; | |
794 | detno = 0; | |
795 | } | |
796 | else if (idet == 1) | |
797 | { | |
798 | deltaE = fCPV[ism][jrow][kcol]; | |
799 | trno = fCPVTrackNo[ism][jrow][kcol]; | |
800 | detno = 1; | |
801 | } | |
802 | if (deltaE > 0.) | |
803 | { | |
804 | MeV2ADC(deltaE,adc); | |
805 | AddDigit(trno,detno,ism,jrow,kcol,adc); | |
806 | } | |
807 | } // column loop | |
808 | } // row loop | |
ebd83c56 | 809 | treeD->Fill(); |
7088dbe9 | 810 | ResetDigit(); |
811 | } // supermodule loop | |
812 | } // detector loop | |
7088dbe9 | 813 | fPMDLoader->WriteDigits("OVERWRITE"); |
06f2c79d | 814 | fPMDLoader->UnloadDigits(); |
815 | ResetCellADC(); | |
7088dbe9 | 816 | } |
817 | //____________________________________________________________________________ | |
818 | ||
819 | void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset) | |
820 | { | |
821 | // merging sdigits | |
822 | fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber)); | |
823 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); | |
824 | fPMDLoader->LoadSDigits("read"); | |
ebd83c56 | 825 | TTree* treeS = fPMDLoader->TreeS(); |
7088dbe9 | 826 | AliPMDsdigit *pmdsdigit; |
ebd83c56 | 827 | TBranch *branch = treeS->GetBranch("PMDSDigit"); |
828 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); | |
7088dbe9 | 829 | branch->SetAddress(&fSDigits); |
830 | ||
831 | Int_t itrackno, idet, ism; | |
832 | Int_t ixp, iyp; | |
833 | Float_t edep; | |
834 | ||
ebd83c56 | 835 | Int_t nmodules = (Int_t) treeS->GetEntries(); |
ecee2a1a | 836 | AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules)); |
837 | AliDebug(1,Form("Track Offset = %d",troffset)); | |
7088dbe9 | 838 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
839 | { | |
ebd83c56 | 840 | treeS->GetEntry(imodule); |
7088dbe9 | 841 | Int_t nentries = fSDigits->GetLast(); |
ecee2a1a | 842 | AliDebug(2,Form("Number of Entries per Module = %d",nentries)); |
7088dbe9 | 843 | for (Int_t ient = 0; ient < nentries+1; ient++) |
844 | { | |
845 | pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); | |
846 | itrackno = pmdsdigit->GetTrackNumber(); | |
847 | idet = pmdsdigit->GetDetector(); | |
848 | ism = pmdsdigit->GetSMNumber(); | |
849 | ixp = pmdsdigit->GetRow(); | |
850 | iyp = pmdsdigit->GetColumn(); | |
851 | edep = pmdsdigit->GetCellEdep(); | |
852 | ||
853 | if (idet == 0) | |
854 | { | |
855 | if (fPRE[ism][ixp][iyp] < edep) | |
856 | { | |
857 | fPRETrackNo[ism][ixp][iyp] = troffset + itrackno; | |
858 | } | |
859 | fPRE[ism][ixp][iyp] += edep; | |
860 | } | |
861 | else if (idet == 1) | |
862 | { | |
863 | if (fCPV[ism][ixp][iyp] < edep) | |
864 | { | |
865 | fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno; | |
866 | } | |
867 | fCPV[ism][ixp][iyp] += edep; | |
868 | } | |
869 | } | |
870 | } | |
871 | ||
872 | } | |
873 | // ---------------------------------------------------------------------- | |
b2b13ee2 | 874 | void AliPMDDigitizer::TrackAssignment2Cell() |
875 | { | |
b2b13ee2 | 876 | // |
75bb524e | 877 | // This block assigns the cell id when there are |
b2b13ee2 | 878 | // multiple tracks in a cell according to the |
879 | // energy deposition | |
880 | // | |
75bb524e | 881 | Bool_t jsort = false; |
8599803d | 882 | |
b2b13ee2 | 883 | Int_t i, j, k; |
884 | ||
36031625 | 885 | Float_t *fracEdp; |
886 | Float_t *trEdp; | |
75bb524e | 887 | Int_t *status1; |
888 | Int_t *status2; | |
889 | Int_t *trnarray; | |
36031625 | 890 | Int_t ****pmdTrack; |
891 | Float_t ****pmdEdep; | |
b2b13ee2 | 892 | |
36031625 | 893 | pmdTrack = new Int_t ***[fgkTotUM]; |
894 | pmdEdep = new Float_t ***[fgkTotUM]; | |
895 | for (i=0; i<fgkTotUM; i++) | |
b2b13ee2 | 896 | { |
36031625 | 897 | pmdTrack[i] = new Int_t **[fgkRow]; |
898 | pmdEdep[i] = new Float_t **[fgkRow]; | |
b2b13ee2 | 899 | } |
900 | ||
36031625 | 901 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 902 | { |
36031625 | 903 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 904 | { |
36031625 | 905 | pmdTrack[i][j] = new Int_t *[fgkCol]; |
906 | pmdEdep[i][j] = new Float_t *[fgkCol]; | |
b2b13ee2 | 907 | } |
908 | } | |
909 | ||
36031625 | 910 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 911 | { |
36031625 | 912 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 913 | { |
36031625 | 914 | for (k = 0; k < fgkCol; k++) |
b2b13ee2 | 915 | { |
36031625 | 916 | Int_t nn = fPRECounter[i][j][k]; |
b2b13ee2 | 917 | if(nn > 0) |
918 | { | |
36031625 | 919 | pmdTrack[i][j][k] = new Int_t[nn]; |
920 | pmdEdep[i][j][k] = new Float_t[nn]; | |
b2b13ee2 | 921 | } |
922 | else | |
923 | { | |
924 | nn = 1; | |
36031625 | 925 | pmdTrack[i][j][k] = new Int_t[nn]; |
926 | pmdEdep[i][j][k] = new Float_t[nn]; | |
b2b13ee2 | 927 | } |
36031625 | 928 | fPRECounter[i][j][k] = 0; |
b2b13ee2 | 929 | } |
930 | } | |
931 | } | |
932 | ||
933 | ||
ebd83c56 | 934 | Int_t nentries = fCell.GetEntries(); |
b2b13ee2 | 935 | |
936 | Int_t mtrackno, ism, ixp, iyp; | |
937 | Float_t edep; | |
938 | ||
939 | for (i = 0; i < nentries; i++) | |
940 | { | |
ebd83c56 | 941 | AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i); |
b2b13ee2 | 942 | |
ebd83c56 | 943 | mtrackno = cell->GetTrackNumber(); |
944 | ism = cell->GetSMNumber(); | |
945 | ixp = cell->GetX(); | |
946 | iyp = cell->GetY(); | |
947 | edep = cell->GetEdep(); | |
36031625 | 948 | Int_t nn = fPRECounter[ism][ixp][iyp]; |
36031625 | 949 | pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno; |
950 | pmdEdep[ism][ixp][iyp][nn] = edep; | |
951 | fPRECounter[ism][ixp][iyp]++; | |
b2b13ee2 | 952 | } |
953 | ||
954 | Int_t iz, il; | |
955 | Int_t im, ix, iy; | |
956 | Int_t nn; | |
957 | ||
36031625 | 958 | for (im=0; im<fgkTotUM; im++) |
b2b13ee2 | 959 | { |
36031625 | 960 | for (ix=0; ix<fgkRow; ix++) |
b2b13ee2 | 961 | { |
36031625 | 962 | for (iy=0; iy<fgkCol; iy++) |
b2b13ee2 | 963 | { |
36031625 | 964 | nn = fPRECounter[im][ix][iy]; |
b2b13ee2 | 965 | if (nn > 1) |
966 | { | |
967 | // This block handles if a cell is fired | |
968 | // many times by many tracks | |
75bb524e | 969 | status1 = new Int_t[nn]; |
970 | status2 = new Int_t[nn]; | |
971 | trnarray = new Int_t[nn]; | |
b2b13ee2 | 972 | for (iz = 0; iz < nn; iz++) |
973 | { | |
36031625 | 974 | status1[iz] = pmdTrack[im][ix][iy][iz]; |
b2b13ee2 | 975 | } |
75bb524e | 976 | TMath::Sort(nn,status1,status2,jsort); |
36031625 | 977 | Int_t trackOld = -99999; |
978 | Int_t track, trCount = 0; | |
b2b13ee2 | 979 | for (iz = 0; iz < nn; iz++) |
980 | { | |
75bb524e | 981 | track = status1[status2[iz]]; |
36031625 | 982 | if (trackOld != track) |
b2b13ee2 | 983 | { |
36031625 | 984 | trnarray[trCount] = track; |
985 | trCount++; | |
b2b13ee2 | 986 | } |
36031625 | 987 | trackOld = track; |
b2b13ee2 | 988 | } |
6eb80a7c | 989 | delete [] status1; |
990 | delete [] status2; | |
36031625 | 991 | Float_t totEdp = 0.; |
992 | trEdp = new Float_t[trCount]; | |
993 | fracEdp = new Float_t[trCount]; | |
994 | for (il = 0; il < trCount; il++) | |
b2b13ee2 | 995 | { |
36031625 | 996 | trEdp[il] = 0.; |
75bb524e | 997 | track = trnarray[il]; |
b2b13ee2 | 998 | for (iz = 0; iz < nn; iz++) |
999 | { | |
36031625 | 1000 | if (track == pmdTrack[im][ix][iy][iz]) |
b2b13ee2 | 1001 | { |
36031625 | 1002 | trEdp[il] += pmdEdep[im][ix][iy][iz]; |
b2b13ee2 | 1003 | } |
1004 | } | |
36031625 | 1005 | totEdp += trEdp[il]; |
b2b13ee2 | 1006 | } |
36031625 | 1007 | Int_t ilOld = 0; |
1008 | Float_t fracOld = 0.; | |
b2b13ee2 | 1009 | |
36031625 | 1010 | for (il = 0; il < trCount; il++) |
b2b13ee2 | 1011 | { |
36031625 | 1012 | fracEdp[il] = trEdp[il]/totEdp; |
1013 | if (fracOld < fracEdp[il]) | |
b2b13ee2 | 1014 | { |
36031625 | 1015 | fracOld = fracEdp[il]; |
1016 | ilOld = il; | |
b2b13ee2 | 1017 | } |
1018 | } | |
36031625 | 1019 | fPRETrackNo[im][ix][iy] = trnarray[ilOld]; |
6eb80a7c | 1020 | delete [] fracEdp; |
1021 | delete [] trEdp; | |
1022 | delete [] trnarray; | |
b2b13ee2 | 1023 | } |
1024 | else if (nn == 1) | |
1025 | { | |
1026 | // This only handles if a cell is fired | |
1027 | // by only one track | |
1028 | ||
36031625 | 1029 | fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0]; |
b2b13ee2 | 1030 | |
1031 | } | |
1032 | else if (nn ==0) | |
1033 | { | |
1034 | // This is if no cell is fired | |
36031625 | 1035 | fPRETrackNo[im][ix][iy] = -999; |
b2b13ee2 | 1036 | } |
1037 | } // end of iy | |
1038 | } // end of ix | |
1039 | } // end of im | |
1040 | ||
1041 | // Delete all the pointers | |
1042 | ||
36031625 | 1043 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1044 | { |
36031625 | 1045 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1046 | { |
36031625 | 1047 | for (k = 0; k < fgkCol; k++) |
b2b13ee2 | 1048 | { |
36031625 | 1049 | delete [] pmdTrack[i][j][k]; |
1050 | delete [] pmdEdep[i][j][k]; | |
b2b13ee2 | 1051 | } |
1052 | } | |
1053 | } | |
1054 | ||
36031625 | 1055 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1056 | { |
36031625 | 1057 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1058 | { |
36031625 | 1059 | delete [] pmdTrack[i][j]; |
1060 | delete [] pmdEdep[i][j]; | |
b2b13ee2 | 1061 | } |
1062 | } | |
1063 | ||
36031625 | 1064 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1065 | { |
36031625 | 1066 | delete [] pmdTrack[i]; |
1067 | delete [] pmdEdep[i]; | |
b2b13ee2 | 1068 | } |
6eb80a7c | 1069 | delete [] pmdTrack; |
1070 | delete [] pmdEdep; | |
b2b13ee2 | 1071 | // |
1072 | // End of the cell id assignment | |
1073 | // | |
1074 | } | |
7088dbe9 | 1075 | //____________________________________________________________________________ |
a7d110b8 | 1076 | void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const |
b2b13ee2 | 1077 | { |
36031625 | 1078 | // This converts the simulated edep to ADC according to the |
1079 | // Test Beam Data | |
b2b13ee2 | 1080 | // To be done |
36031625 | 1081 | // |
b8e69f1f | 1082 | |
b8e69f1f | 1083 | // PS Test in September 2003 |
1084 | // MeV - ADC conversion for 10bit ADC | |
1085 | ||
1086 | const Float_t kConstant = 7.181; | |
1087 | const Float_t kErConstant = 0.6899; | |
1088 | const Float_t kSlope = 35.93; | |
1089 | const Float_t kErSlope = 0.306; | |
1090 | ||
1091 | //gRandom->SetSeed(); | |
1092 | ||
1093 | Float_t cons = gRandom->Gaus(kConstant,kErConstant); | |
1094 | Float_t slop = gRandom->Gaus(kSlope,kErSlope); | |
1095 | ||
1096 | Float_t adc10bit = slop*mev*0.001 + cons; | |
1097 | ||
1098 | // 12 bit adc | |
1099 | ||
1100 | Int_t adc12bit = (Int_t) (4.0*adc10bit); | |
1101 | ||
1102 | if(adc12bit < 3000) | |
1103 | { | |
1104 | adc = (Float_t) adc12bit; | |
1105 | } | |
1106 | else if (adc12bit >= 3000) | |
1107 | { | |
1108 | adc = 3000.0; | |
1109 | } | |
1110 | ||
b2b13ee2 | 1111 | } |
7088dbe9 | 1112 | //____________________________________________________________________________ |
b2b13ee2 | 1113 | void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t det, Int_t smnumber, |
7088dbe9 | 1114 | Int_t irow, Int_t icol, Float_t adc) |
b2b13ee2 | 1115 | { |
36031625 | 1116 | // Add SDigit |
1117 | // | |
ebd83c56 | 1118 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 1119 | TClonesArray &lsdigits = *fSDigits; |
7088dbe9 | 1120 | new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,det,smnumber,irow,icol,adc); |
b2b13ee2 | 1121 | } |
7088dbe9 | 1122 | //____________________________________________________________________________ |
b2b13ee2 | 1123 | |
1124 | void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t det, Int_t smnumber, | |
7088dbe9 | 1125 | Int_t irow, Int_t icol, Float_t adc) |
b2b13ee2 | 1126 | { |
36031625 | 1127 | // Add Digit |
1128 | // | |
ebd83c56 | 1129 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
b2b13ee2 | 1130 | TClonesArray &ldigits = *fDigits; |
7088dbe9 | 1131 | new(ldigits[fNdigit++]) AliPMDdigit(trnumber,det,smnumber,irow,icol,adc); |
b2b13ee2 | 1132 | } |
7088dbe9 | 1133 | //____________________________________________________________________________ |
b2b13ee2 | 1134 | |
b2b13ee2 | 1135 | void AliPMDDigitizer::SetZPosition(Float_t zpos) |
1136 | { | |
1137 | fZPos = zpos; | |
1138 | } | |
7088dbe9 | 1139 | //____________________________________________________________________________ |
b2b13ee2 | 1140 | Float_t AliPMDDigitizer::GetZPosition() const |
1141 | { | |
1142 | return fZPos; | |
1143 | } | |
7088dbe9 | 1144 | //____________________________________________________________________________ |
b2b13ee2 | 1145 | |
1146 | void AliPMDDigitizer::ResetCell() | |
1147 | { | |
36031625 | 1148 | // clears the cell array and also the counter |
1149 | // for each cell | |
1150 | // | |
ebd83c56 | 1151 | fCell.Delete(); |
36031625 | 1152 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1153 | { |
36031625 | 1154 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 1155 | { |
36031625 | 1156 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 1157 | { |
36031625 | 1158 | fPRECounter[i][j][k] = 0; |
b2b13ee2 | 1159 | } |
1160 | } | |
1161 | } | |
1162 | } | |
7088dbe9 | 1163 | //____________________________________________________________________________ |
b2b13ee2 | 1164 | void AliPMDDigitizer::ResetSDigit() |
1165 | { | |
36031625 | 1166 | // Clears SDigits |
b2b13ee2 | 1167 | fNsdigit = 0; |
ebd83c56 | 1168 | if (fSDigits) fSDigits->Delete(); |
b2b13ee2 | 1169 | } |
7088dbe9 | 1170 | //____________________________________________________________________________ |
b2b13ee2 | 1171 | void AliPMDDigitizer::ResetDigit() |
1172 | { | |
36031625 | 1173 | // Clears Digits |
b2b13ee2 | 1174 | fNdigit = 0; |
ebd83c56 | 1175 | if (fDigits) fDigits->Delete(); |
b2b13ee2 | 1176 | } |
7088dbe9 | 1177 | //____________________________________________________________________________ |
b2b13ee2 | 1178 | |
1179 | void AliPMDDigitizer::ResetCellADC() | |
1180 | { | |
7088dbe9 | 1181 | // Clears individual cells edep and track number |
36031625 | 1182 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1183 | { |
36031625 | 1184 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 1185 | { |
36031625 | 1186 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 1187 | { |
1188 | fCPV[i][j][k] = 0.; | |
36031625 | 1189 | fPRE[i][j][k] = 0.; |
7088dbe9 | 1190 | fPRETrackNo[i][j][k] = 0; |
1191 | fCPVTrackNo[i][j][k] = 0; | |
b2b13ee2 | 1192 | } |
1193 | } | |
1194 | } | |
1195 | } | |
7088dbe9 | 1196 | //____________________________________________________________________________ |
b2b13ee2 | 1197 | |
1198 | void AliPMDDigitizer::UnLoad(Option_t *option) | |
1199 | { | |
36031625 | 1200 | // Unloads all the root files |
1201 | // | |
b2b13ee2 | 1202 | const char *cS = strstr(option,"S"); |
1203 | const char *cD = strstr(option,"D"); | |
1204 | ||
1205 | fRunLoader->UnloadgAlice(); | |
1206 | fRunLoader->UnloadHeader(); | |
1207 | fRunLoader->UnloadKinematics(); | |
1208 | ||
1209 | if (cS) | |
1210 | { | |
36031625 | 1211 | fPMDLoader->UnloadHits(); |
b2b13ee2 | 1212 | } |
1213 | if (cD) | |
1214 | { | |
36031625 | 1215 | fPMDLoader->UnloadHits(); |
1216 | fPMDLoader->UnloadSDigits(); | |
b2b13ee2 | 1217 | } |
1218 | } |