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