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