]>
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> |
24c5571f | 24 | #include <TBRIK.h> |
25 | #include <TNode.h> | |
b2b13ee2 | 26 | #include <TTree.h> |
24c5571f | 27 | #include <TGeometry.h> |
b2b13ee2 | 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" |
35535af7 | 57 | #include "AliPMDPedestal.h" |
b2b13ee2 | 58 | #include "AliPMDDigitizer.h" |
09a06455 | 59 | |
b2b13ee2 | 60 | |
61 | ClassImp(AliPMDDigitizer) | |
a7d110b8 | 62 | |
01960205 | 63 | AliPMDDigitizer::AliPMDDigitizer() : |
64 | fRunLoader(0), | |
65 | fPMDHit(0), | |
66 | fPMD(0), | |
67 | fPMDLoader(0), | |
35535af7 | 68 | fCalibGain(GetCalibGain()), |
69 | fCalibPed(GetCalibPed()), | |
ebd83c56 | 70 | fSDigits(0), |
71 | fDigits(0), | |
4d59e381 | 72 | fCPVCell(0), |
ebd83c56 | 73 | fCell(0), |
01960205 | 74 | fNsdigit(0), |
75 | fNdigit(0), | |
76 | fDetNo(0), | |
2332574a | 77 | fZPos(361.5) // in units of cm, default position of PMD |
b2b13ee2 | 78 | { |
36031625 | 79 | // Default Constructor |
80 | // | |
36031625 | 81 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 82 | { |
36031625 | 83 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 84 | { |
36031625 | 85 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 86 | { |
920e13db | 87 | fCPV[i][j][k] = 0.; |
88 | fPRE[i][j][k] = 0.; | |
89 | fCPVCounter[i][j][k] = 0; | |
90 | fPRECounter[i][j][k] = 0; | |
91 | fCPVTrackNo[i][j][k] = -1; | |
92 | fPRETrackNo[i][j][k] = -1; | |
93 | fCPVTrackPid[i][j][k] = -1; | |
94 | fPRETrackPid[i][j][k] = -1; | |
b2b13ee2 | 95 | } |
96 | } | |
97 | } | |
2332574a | 98 | |
b2b13ee2 | 99 | } |
7088dbe9 | 100 | //____________________________________________________________________________ |
2332574a | 101 | AliPMDDigitizer::AliPMDDigitizer(const AliPMDDigitizer& digitizer): |
102 | AliDigitizer(digitizer), | |
103 | fRunLoader(0), | |
104 | fPMDHit(0), | |
105 | fPMD(0), | |
106 | fPMDLoader(0), | |
35535af7 | 107 | fCalibGain(GetCalibGain()), |
108 | fCalibPed(GetCalibPed()), | |
2332574a | 109 | fSDigits(0), |
110 | fDigits(0), | |
4d59e381 | 111 | fCPVCell(0), |
2332574a | 112 | fCell(0), |
113 | fNsdigit(0), | |
114 | fNdigit(0), | |
115 | fDetNo(0), | |
116 | fZPos(361.5) // in units of cm, default position of PMD | |
a48edddd | 117 | { |
118 | // copy constructor | |
119 | AliError("Copy constructor not allowed "); | |
120 | ||
121 | } | |
122 | //____________________________________________________________________________ | |
a48edddd | 123 | AliPMDDigitizer & AliPMDDigitizer::operator=(const AliPMDDigitizer& /*digitizer*/) |
124 | { | |
125 | // Assignment operator | |
126 | AliError("Assignement operator not allowed "); | |
127 | ||
128 | return *this; | |
129 | } | |
130 | //____________________________________________________________________________ | |
2332574a | 131 | AliPMDDigitizer::AliPMDDigitizer(AliRunDigitizer* manager): |
132 | AliDigitizer(manager), | |
ebd83c56 | 133 | fRunLoader(0), |
134 | fPMDHit(0), | |
135 | fPMD(0), | |
136 | fPMDLoader(0), | |
35535af7 | 137 | fCalibGain(GetCalibGain()), |
138 | fCalibPed(GetCalibPed()), | |
ebd83c56 | 139 | fSDigits(new TClonesArray("AliPMDsdigit", 1000)), |
140 | fDigits(new TClonesArray("AliPMDdigit", 1000)), | |
4d59e381 | 141 | fCPVCell(0), |
ebd83c56 | 142 | fCell(0), |
ebd83c56 | 143 | fNsdigit(0), |
144 | fNdigit(0), | |
145 | fDetNo(0), | |
146 | fZPos(361.5)// in units of cm, This is the default position of PMD | |
7088dbe9 | 147 | { |
148 | // ctor which should be used | |
149 | ||
09a06455 | 150 | |
ebd83c56 | 151 | for (Int_t i = 0; i < fgkTotUM; i++) |
152 | { | |
153 | for (Int_t j = 0; j < fgkRow; j++) | |
154 | { | |
155 | for (Int_t k = 0; k < fgkCol; k++) | |
156 | { | |
920e13db | 157 | fCPV[i][j][k] = 0.; |
158 | fPRE[i][j][k] = 0.; | |
159 | fCPVCounter[i][j][k] = 0; | |
160 | fPRECounter[i][j][k] = 0; | |
161 | fCPVTrackNo[i][j][k] = -1; | |
162 | fPRETrackNo[i][j][k] = -1; | |
163 | fCPVTrackPid[i][j][k] = -1; | |
164 | fPRETrackPid[i][j][k] = -1; | |
ebd83c56 | 165 | } |
166 | } | |
167 | } | |
7088dbe9 | 168 | } |
2332574a | 169 | |
7088dbe9 | 170 | //____________________________________________________________________________ |
b2b13ee2 | 171 | AliPMDDigitizer::~AliPMDDigitizer() |
172 | { | |
36031625 | 173 | // Default Destructor |
174 | // | |
01960205 | 175 | if (fSDigits) { |
176 | fSDigits->Delete(); | |
177 | delete fSDigits; | |
178 | fSDigits=0; | |
179 | } | |
180 | if (fDigits) { | |
181 | fDigits->Delete(); | |
182 | delete fDigits; | |
183 | fDigits=0; | |
184 | } | |
4d59e381 | 185 | fCPVCell.Delete(); |
ebd83c56 | 186 | fCell.Delete(); |
b2b13ee2 | 187 | } |
188 | // | |
189 | // Member functions | |
190 | // | |
7088dbe9 | 191 | //____________________________________________________________________________ |
85a5290f | 192 | void AliPMDDigitizer::OpengAliceFile(const char *file, Option_t *option) |
b2b13ee2 | 193 | { |
36031625 | 194 | // Loads galice.root file and corresponding header, kinematics |
195 | // hits and sdigits or digits depending on the option | |
196 | // | |
f540341d | 197 | |
e191bb57 | 198 | TString evfoldname = AliConfig::GetDefaultEventFolderName(); |
f540341d | 199 | fRunLoader = AliRunLoader::GetRunLoader(evfoldname); |
200 | if (!fRunLoader) | |
5e2cc5bc | 201 | fRunLoader = AliRunLoader::Open(file,AliConfig::GetDefaultEventFolderName(), "UPDATE"); |
b2b13ee2 | 202 | |
203 | if (!fRunLoader) | |
204 | { | |
ecee2a1a | 205 | AliError(Form("Can not open session for file %s.",file)); |
b2b13ee2 | 206 | } |
b2b13ee2 | 207 | |
be9188a5 | 208 | const char *cHS = strstr(option,"HS"); |
209 | const char *cHD = strstr(option,"HD"); | |
210 | const char *cSD = strstr(option,"SD"); | |
b2b13ee2 | 211 | |
be9188a5 | 212 | if(cHS || cHD) |
ecee2a1a | 213 | { |
be9188a5 | 214 | if (!fRunLoader->GetAliRun()) fRunLoader->LoadgAlice(); |
215 | if (!fRunLoader->TreeE()) fRunLoader->LoadHeader(); | |
216 | if (!fRunLoader->TreeK()) fRunLoader->LoadKinematics(); | |
217 | ||
218 | gAlice = fRunLoader->GetAliRun(); | |
219 | ||
220 | if (gAlice) | |
221 | { | |
222 | AliDebug(1,"Alirun object found"); | |
223 | } | |
224 | else | |
225 | { | |
226 | AliError("Could not found Alirun object"); | |
227 | } | |
f540341d | 228 | |
be9188a5 | 229 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); |
230 | } | |
231 | ||
36031625 | 232 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
233 | if (fPMDLoader == 0x0) | |
b2b13ee2 | 234 | { |
ecee2a1a | 235 | AliError("Can not find PMDLoader"); |
b2b13ee2 | 236 | } |
237 | ||
b2b13ee2 | 238 | |
239 | if (cHS) | |
240 | { | |
36031625 | 241 | fPMDLoader->LoadHits("READ"); |
242 | fPMDLoader->LoadSDigits("recreate"); | |
b2b13ee2 | 243 | } |
244 | else if (cHD) | |
245 | { | |
36031625 | 246 | fPMDLoader->LoadHits("READ"); |
247 | fPMDLoader->LoadDigits("recreate"); | |
b2b13ee2 | 248 | } |
249 | else if (cSD) | |
250 | { | |
36031625 | 251 | fPMDLoader->LoadSDigits("READ"); |
252 | fPMDLoader->LoadDigits("recreate"); | |
b2b13ee2 | 253 | } |
b2b13ee2 | 254 | } |
7088dbe9 | 255 | //____________________________________________________________________________ |
b2b13ee2 | 256 | void AliPMDDigitizer::Hits2SDigits(Int_t ievt) |
257 | { | |
36031625 | 258 | // This reads the PMD Hits tree and assigns the right track number |
259 | // to a cell and stores in the summable digits tree | |
260 | // | |
b2b13ee2 | 261 | |
36031625 | 262 | const Int_t kPi0 = 111; |
263 | const Int_t kGamma = 22; | |
b2b13ee2 | 264 | Int_t npmd; |
265 | Int_t trackno; | |
b2b13ee2 | 266 | Int_t smnumber; |
267 | Int_t trackpid; | |
268 | Int_t mtrackno; | |
269 | Int_t mtrackpid; | |
270 | ||
271 | Float_t xPos, yPos, zPos; | |
8599803d | 272 | Int_t xpad = -1, ypad = -1; |
b2b13ee2 | 273 | Float_t edep; |
274 | Float_t vx = -999.0, vy = -999.0, vz = -999.0; | |
275 | ||
a7d110b8 | 276 | |
ebd83c56 | 277 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 278 | ResetSDigit(); |
279 | ||
ecee2a1a | 280 | AliDebug(1,Form("Event Number = %d",ievt)); |
b2b13ee2 | 281 | Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); |
ecee2a1a | 282 | AliDebug(1,Form("Number of Particles = %d",nparticles)); |
8c24e5f2 | 283 | |
920e13db | 284 | // |
285 | ||
b2b13ee2 | 286 | fRunLoader->GetEvent(ievt); |
b2b13ee2 | 287 | // ------------------------------------------------------- // |
288 | // Pointer to specific detector hits. | |
289 | // Get pointers to Alice detectors and Hits containers | |
290 | ||
ebd83c56 | 291 | TTree* treeH = fPMDLoader->TreeH(); |
b2b13ee2 | 292 | |
ebd83c56 | 293 | Int_t ntracks = (Int_t) treeH->GetEntries(); |
ecee2a1a | 294 | AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); |
ebd83c56 | 295 | TTree* treeS = fPMDLoader->TreeS(); |
296 | if (treeS == 0x0) | |
b2b13ee2 | 297 | { |
36031625 | 298 | fPMDLoader->MakeTree("S"); |
ebd83c56 | 299 | treeS = fPMDLoader->TreeS(); |
b2b13ee2 | 300 | } |
301 | Int_t bufsize = 16000; | |
5e2cc5bc | 302 | treeS->Branch("PMDSDigit", &fSDigits, bufsize); |
b2b13ee2 | 303 | |
ebd83c56 | 304 | TClonesArray* hits = 0; |
305 | if (fPMD) hits = fPMD->Hits(); | |
b2b13ee2 | 306 | |
307 | // Start loop on tracks in the hits containers | |
a7d110b8 | 308 | |
5e2cc5bc | 309 | for (Int_t track=0; track<ntracks;track++) |
b2b13ee2 | 310 | { |
cad3294f | 311 | gAlice->GetMCApp()->ResetHits(); |
ebd83c56 | 312 | treeH->GetEvent(track); |
5e2cc5bc | 313 | if (fPMD) |
b2b13ee2 | 314 | { |
ebd83c56 | 315 | npmd = hits->GetEntriesFast(); |
4d59e381 | 316 | for (Int_t ipmd = 0; ipmd < npmd; ipmd++) |
b2b13ee2 | 317 | { |
ebd83c56 | 318 | fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); |
36031625 | 319 | trackno = fPMDHit->GetTrack(); |
b2b13ee2 | 320 | // get kinematics of the particles |
36031625 | 321 | |
ebd83c56 | 322 | TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); |
323 | trackpid = mparticle->GetPdgCode(); | |
4d59e381 | 324 | Int_t ks = mparticle->GetStatusCode(); |
b2b13ee2 | 325 | Int_t imo; |
36031625 | 326 | Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; |
4d59e381 | 327 | |
8599803d | 328 | if (mparticle->GetFirstMother() == -1) |
329 | { | |
36031625 | 330 | tracknoOld = trackno; |
331 | trackpidOld = trackpid; | |
332 | statusOld = -1; | |
8599803d | 333 | } |
8599803d | 334 | Int_t igstatus = 0; |
ffdc86b5 | 335 | |
336 | Int_t trnotemp = trackno; // Modified on 25th Nov 2009 | |
4d59e381 | 337 | if(ks==1||(imo = mparticle->GetFirstMother())<0 ){ |
338 | vx = mparticle->Vx(); | |
339 | vy = mparticle->Vy(); | |
340 | vz = mparticle->Vz(); | |
341 | ||
342 | if(trackpid==kGamma||trackpid==11||trackpid==-11|| | |
343 | trackpid==kPi0)igstatus=1; | |
344 | } | |
24c5571f | 345 | |
346 | ||
4d59e381 | 347 | while(((imo = mparticle->GetFirstMother()) >= 0)&& |
348 | (ks = mparticle->GetStatusCode() <1) ) | |
5f7ce82b | 349 | { |
b208c6a3 | 350 | mparticle = gAlice->GetMCApp()->Particle(imo); |
4d59e381 | 351 | trackpid = mparticle->GetPdgCode(); |
352 | ks = mparticle->GetStatusCode(); | |
b2b13ee2 | 353 | vx = mparticle->Vx(); |
354 | vy = mparticle->Vy(); | |
355 | vz = mparticle->Vz(); | |
24c5571f | 356 | |
ffdc86b5 | 357 | // Modified on 25th Nov 2009 |
358 | ||
359 | trnotemp = trackno; | |
360 | if(trackpid == 111) | |
361 | { | |
362 | trackno = trnotemp; | |
363 | } | |
364 | if(trackpid != 111) | |
365 | { | |
366 | trackno=imo; | |
5f7ce82b | 367 | } |
ffdc86b5 | 368 | // end of modification on 25th Nov 2009 |
369 | } | |
24c5571f | 370 | |
5f7ce82b | 371 | if(trackpid==kGamma||trackpid==11||trackpid==-11|| |
372 | trackpid==kPi0)igstatus=1; | |
373 | mtrackpid=trackpid; | |
374 | mtrackno=trackno; | |
375 | trackpid=trackpidOld; | |
376 | trackno=tracknoOld; | |
d934d257 | 377 | |
24c5571f | 378 | //-----------------end of modification---------------- |
ae909aed | 379 | Float_t ptime = fPMDHit->GetTime()*1e6; // time in microsec |
380 | if (ptime < 0. || ptime > 1.2) continue; | |
381 | ||
36031625 | 382 | xPos = fPMDHit->X(); |
383 | yPos = fPMDHit->Y(); | |
384 | zPos = fPMDHit->Z(); | |
ae909aed | 385 | |
c35544fe | 386 | edep = fPMDHit->GetEnergy(); |
387 | Int_t vol1 = fPMDHit->GetVolume(1); // Column | |
388 | Int_t vol2 = fPMDHit->GetVolume(2); // Row | |
24c5571f | 389 | Int_t vol7 = fPMDHit->GetVolume(4); // Serial Module No |
f117e3aa | 390 | |
c35544fe | 391 | |
8599803d | 392 | // -----------------------------------------// |
f117e3aa | 393 | // In new geometry after adding electronics // |
8599803d | 394 | // For Super Module 1 & 2 // |
8599803d | 395 | // nrow = 48, ncol = 96 // |
f117e3aa | 396 | // For Super Module 3 & 4 // |
397 | // nrow = 96, ncol = 48 // | |
8599803d | 398 | // -----------------------------------------// |
f117e3aa | 399 | |
24c5571f | 400 | if (vol7 < 24) |
401 | { | |
402 | smnumber = vol7; | |
403 | } | |
404 | else | |
405 | { | |
406 | smnumber = vol7 - 24; | |
407 | } | |
408 | Int_t vol8 = smnumber/6 + 1; // fake supermodule | |
8599803d | 409 | |
f117e3aa | 410 | if (vol8 == 1 || vol8 == 2) |
b2b13ee2 | 411 | { |
36031625 | 412 | xpad = vol2; |
413 | ypad = vol1; | |
b2b13ee2 | 414 | } |
f117e3aa | 415 | else if (vol8 == 3 || vol8 == 4) |
416 | { | |
417 | xpad = vol1; | |
418 | ypad = vol2; | |
419 | } | |
b2b13ee2 | 420 | |
ecee2a1a | 421 | AliDebug(2,Form("Zposition = %f Edeposition = %f",zPos,edep)); |
c505f70b | 422 | |
423 | if (vol7 < 24) | |
b2b13ee2 | 424 | { |
c505f70b | 425 | // PRE |
426 | fDetNo = 0; | |
b2b13ee2 | 427 | } |
c505f70b | 428 | else |
b2b13ee2 | 429 | { |
c505f70b | 430 | // CPV |
431 | fDetNo = 1; | |
b2b13ee2 | 432 | } |
ffdc86b5 | 433 | |
24c5571f | 434 | Int_t smn = smnumber; |
8599803d | 435 | Int_t ixx = xpad - 1; |
436 | Int_t iyy = ypad - 1; | |
b2b13ee2 | 437 | if (fDetNo == 0) |
438 | { | |
36031625 | 439 | fPRE[smn][ixx][iyy] += edep; |
440 | fPRECounter[smn][ixx][iyy]++; | |
b2b13ee2 | 441 | |
ebd83c56 | 442 | AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); |
ebd83c56 | 443 | fCell.Add(cell); |
b2b13ee2 | 444 | } |
445 | else if(fDetNo == 1) | |
446 | { | |
8599803d | 447 | fCPV[smn][ixx][iyy] += edep; |
4d59e381 | 448 | fCPVCounter[smn][ixx][iyy]++; |
449 | AliPMDcell* cpvcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); | |
450 | fCPVCell.Add(cpvcell); | |
b2b13ee2 | 451 | } |
452 | } | |
453 | } | |
454 | } // Track Loop ended | |
4d59e381 | 455 | TrackAssignment2CPVCell(); |
b2b13ee2 | 456 | TrackAssignment2Cell(); |
b2b13ee2 | 457 | ResetCell(); |
458 | ||
459 | Float_t deltaE = 0.; | |
460 | Int_t detno = 0; | |
b2b13ee2 | 461 | Int_t trno = -1; |
920e13db | 462 | Int_t trpid = -99; |
b2b13ee2 | 463 | |
464 | for (Int_t idet = 0; idet < 2; idet++) | |
465 | { | |
36031625 | 466 | for (Int_t ism = 0; ism < fgkTotUM; ism++) |
b2b13ee2 | 467 | { |
36031625 | 468 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) |
b2b13ee2 | 469 | { |
36031625 | 470 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) |
b2b13ee2 | 471 | { |
b2b13ee2 | 472 | if (idet == 0) |
473 | { | |
36031625 | 474 | deltaE = fPRE[ism][jrow][kcol]; |
475 | trno = fPRETrackNo[ism][jrow][kcol]; | |
b2b13ee2 | 476 | detno = 0; |
477 | } | |
478 | else if (idet == 1) | |
479 | { | |
480 | deltaE = fCPV[ism][jrow][kcol]; | |
481 | trno = fCPVTrackNo[ism][jrow][kcol]; | |
482 | detno = 1; | |
483 | } | |
484 | if (deltaE > 0.) | |
485 | { | |
8c24e5f2 | 486 | // Natasha |
487 | TParticle *mparticle = gAlice->GetMCApp()->Particle(trno); | |
488 | trpid = mparticle->GetPdgCode(); | |
920e13db | 489 | AddSDigit(trno,trpid,detno,ism,jrow,kcol,deltaE); |
b2b13ee2 | 490 | } |
491 | } | |
492 | } | |
ebd83c56 | 493 | treeS->Fill(); |
b2b13ee2 | 494 | ResetSDigit(); |
495 | } | |
496 | } | |
36031625 | 497 | fPMDLoader->WriteSDigits("OVERWRITE"); |
b2b13ee2 | 498 | ResetCellADC(); |
b2b13ee2 | 499 | } |
7088dbe9 | 500 | //____________________________________________________________________________ |
b2b13ee2 | 501 | |
502 | void AliPMDDigitizer::Hits2Digits(Int_t ievt) | |
503 | { | |
36031625 | 504 | // This reads the PMD Hits tree and assigns the right track number |
505 | // to a cell and stores in the digits tree | |
506 | // | |
507 | const Int_t kPi0 = 111; | |
508 | const Int_t kGamma = 22; | |
b2b13ee2 | 509 | Int_t npmd; |
510 | Int_t trackno; | |
b2b13ee2 | 511 | Int_t smnumber; |
512 | Int_t trackpid; | |
513 | Int_t mtrackno; | |
514 | Int_t mtrackpid; | |
515 | ||
516 | Float_t xPos, yPos, zPos; | |
8599803d | 517 | Int_t xpad = -1, ypad = -1; |
b2b13ee2 | 518 | Float_t edep; |
519 | Float_t vx = -999.0, vy = -999.0, vz = -999.0; | |
520 | ||
ebd83c56 | 521 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
b2b13ee2 | 522 | ResetDigit(); |
523 | ||
5e2cc5bc | 524 | AliDebug(1,Form("Event Number = %d",ievt)); |
b2b13ee2 | 525 | Int_t nparticles = fRunLoader->GetHeader()->GetNtrack(); |
ecee2a1a | 526 | AliDebug(1,Form("Number of Particles = %d", nparticles)); |
920e13db | 527 | |
b2b13ee2 | 528 | fRunLoader->GetEvent(ievt); |
b2b13ee2 | 529 | // ------------------------------------------------------- // |
530 | // Pointer to specific detector hits. | |
531 | // Get pointers to Alice detectors and Hits containers | |
532 | ||
b208c6a3 | 533 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); |
36031625 | 534 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b2b13ee2 | 535 | |
36031625 | 536 | if (fPMDLoader == 0x0) |
b2b13ee2 | 537 | { |
ecee2a1a | 538 | AliError("Can not find PMD or PMDLoader"); |
b2b13ee2 | 539 | } |
ebd83c56 | 540 | TTree* treeH = fPMDLoader->TreeH(); |
541 | Int_t ntracks = (Int_t) treeH->GetEntries(); | |
ecee2a1a | 542 | AliDebug(1,Form("Number of Tracks in the TreeH = %d", ntracks)); |
36031625 | 543 | fPMDLoader->LoadDigits("recreate"); |
ebd83c56 | 544 | TTree* treeD = fPMDLoader->TreeD(); |
545 | if (treeD == 0x0) | |
b2b13ee2 | 546 | { |
36031625 | 547 | fPMDLoader->MakeTree("D"); |
ebd83c56 | 548 | treeD = fPMDLoader->TreeD(); |
b2b13ee2 | 549 | } |
550 | Int_t bufsize = 16000; | |
5e2cc5bc | 551 | treeD->Branch("PMDDigit", &fDigits, bufsize); |
b2b13ee2 | 552 | |
ebd83c56 | 553 | TClonesArray* hits = 0; |
554 | if (fPMD) hits = fPMD->Hits(); | |
b2b13ee2 | 555 | |
556 | // Start loop on tracks in the hits containers | |
557 | ||
5e2cc5bc | 558 | for (Int_t track=0; track<ntracks;track++) |
b2b13ee2 | 559 | { |
cad3294f | 560 | gAlice->GetMCApp()->ResetHits(); |
ebd83c56 | 561 | treeH->GetEvent(track); |
b2b13ee2 | 562 | |
5e2cc5bc | 563 | if (fPMD) |
b2b13ee2 | 564 | { |
ebd83c56 | 565 | npmd = hits->GetEntriesFast(); |
4d59e381 | 566 | for (Int_t ipmd = 0; ipmd < npmd; ipmd++) |
b2b13ee2 | 567 | { |
ebd83c56 | 568 | fPMDHit = (AliPMDhit*) hits->UncheckedAt(ipmd); |
36031625 | 569 | trackno = fPMDHit->GetTrack(); |
b2b13ee2 | 570 | |
571 | // get kinematics of the particles | |
572 | ||
ebd83c56 | 573 | TParticle* mparticle = gAlice->GetMCApp()->Particle(trackno); |
574 | trackpid = mparticle->GetPdgCode(); | |
4d59e381 | 575 | Int_t ks = mparticle->GetStatusCode(); |
b2b13ee2 | 576 | Int_t imo; |
36031625 | 577 | Int_t tracknoOld=0, trackpidOld=0, statusOld = 0; |
8599803d | 578 | if (mparticle->GetFirstMother() == -1) |
579 | { | |
36031625 | 580 | tracknoOld = trackno; |
581 | trackpidOld = trackpid; | |
582 | statusOld = -1; | |
8599803d | 583 | } |
584 | ||
585 | Int_t igstatus = 0; | |
ffdc86b5 | 586 | |
587 | Int_t trnotemp = trackno; // modified on 25th Nov 2009 | |
4d59e381 | 588 | if(ks==1||(imo = mparticle->GetFirstMother())<0 ){ |
589 | vx = mparticle->Vx(); | |
590 | vy = mparticle->Vy(); | |
591 | vz = mparticle->Vz(); | |
592 | ||
593 | if(trackpid==kGamma||trackpid==11||trackpid==-11||trackpid==kPi0) | |
594 | igstatus=1; | |
595 | } | |
596 | ||
597 | ||
598 | while(((imo = mparticle->GetFirstMother()) >= 0)&& | |
599 | (ks = mparticle->GetStatusCode() <1) ) | |
b2b13ee2 | 600 | { |
b208c6a3 | 601 | mparticle = gAlice->GetMCApp()->Particle(imo); |
4d59e381 | 602 | trackpid = mparticle->GetPdgCode(); |
603 | ks = mparticle->GetStatusCode(); | |
b2b13ee2 | 604 | vx = mparticle->Vx(); |
605 | vy = mparticle->Vy(); | |
606 | vz = mparticle->Vz(); | |
24c5571f | 607 | |
ffdc86b5 | 608 | // Modified on 25th Nov 2009 |
609 | ||
610 | trnotemp = trackno; | |
611 | if(trackpid == 111) | |
612 | { | |
613 | trackno = trnotemp; | |
614 | } | |
615 | if(trackpid != 111) | |
616 | { | |
617 | trackno=imo; | |
d934d257 | 618 | } |
ffdc86b5 | 619 | } |
4d59e381 | 620 | |
621 | if(trackpid==kGamma||trackpid==11||trackpid==-11||trackpid==kPi0) | |
622 | igstatus=1; | |
623 | mtrackpid=trackpid; | |
624 | mtrackno=trackno; | |
625 | trackpid=trackpidOld; | |
626 | trackno=tracknoOld; | |
ae909aed | 627 | |
628 | Float_t ptime = fPMDHit->GetTime()*1e6; | |
629 | if (ptime < 0. || ptime > 1.2) continue; | |
b2b13ee2 | 630 | |
36031625 | 631 | xPos = fPMDHit->X(); |
632 | yPos = fPMDHit->Y(); | |
633 | zPos = fPMDHit->Z(); | |
f117e3aa | 634 | edep = fPMDHit->GetEnergy(); |
c35544fe | 635 | Int_t vol1 = fPMDHit->GetVolume(1); // Column |
636 | Int_t vol2 = fPMDHit->GetVolume(2); // Row | |
24c5571f | 637 | Int_t vol7 = fPMDHit->GetVolume(4); // Serial Module No |
8599803d | 638 | |
639 | // -----------------------------------------// | |
f117e3aa | 640 | // In new geometry after adding electronics // |
8599803d | 641 | // For Super Module 1 & 2 // |
8599803d | 642 | // nrow = 48, ncol = 96 // |
f117e3aa | 643 | // For Super Module 3 & 4 // |
644 | // nrow = 96, ncol = 48 // | |
8599803d | 645 | // -----------------------------------------// |
b2b13ee2 | 646 | |
24c5571f | 647 | if (vol7 < 24) |
648 | { | |
649 | smnumber = vol7; | |
650 | } | |
651 | else | |
652 | { | |
653 | smnumber = vol7 - 24; | |
654 | } | |
655 | Int_t vol8 = smnumber/6 + 1; // fake supermodule | |
8599803d | 656 | |
f117e3aa | 657 | if (vol8 == 1 || vol8 == 2) |
8599803d | 658 | { |
36031625 | 659 | xpad = vol2; |
660 | ypad = vol1; | |
b2b13ee2 | 661 | } |
f117e3aa | 662 | else if (vol8 == 3 || vol8 == 4) |
663 | { | |
664 | xpad = vol1; | |
665 | ypad = vol2; | |
666 | } | |
b2b13ee2 | 667 | |
66d5d07e | 668 | AliDebug(2,Form("ZPosition = %f Edeposition = %f",zPos,edep)); |
8599803d | 669 | |
c505f70b | 670 | if (vol7 < 24) |
671 | { | |
672 | // PRE | |
673 | fDetNo = 0; | |
674 | } | |
675 | else | |
b2b13ee2 | 676 | { |
b2b13ee2 | 677 | fDetNo = 1; |
678 | } | |
c505f70b | 679 | /* |
680 | if (zPos < fZPos) | |
b2b13ee2 | 681 | { |
c505f70b | 682 | // CPV |
683 | fDetNo = 1; | |
b2b13ee2 | 684 | } |
c505f70b | 685 | else if (zPos > fZPos) |
686 | { | |
687 | // PMD | |
688 | fDetNo = 0; | |
689 | } | |
690 | */ | |
24c5571f | 691 | Int_t smn = smnumber; |
8599803d | 692 | Int_t ixx = xpad - 1; |
693 | Int_t iyy = ypad - 1; | |
694 | if (fDetNo == 0) | |
b2b13ee2 | 695 | { |
36031625 | 696 | fPRE[smn][ixx][iyy] += edep; |
697 | fPRECounter[smn][ixx][iyy]++; | |
8599803d | 698 | |
ebd83c56 | 699 | AliPMDcell* cell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); |
8599803d | 700 | |
ebd83c56 | 701 | fCell.Add(cell); |
b2b13ee2 | 702 | } |
8599803d | 703 | else if(fDetNo == 1) |
b2b13ee2 | 704 | { |
8599803d | 705 | fCPV[smn][ixx][iyy] += edep; |
4d59e381 | 706 | fCPVCounter[smn][ixx][iyy]++; |
707 | AliPMDcell* cpvcell = new AliPMDcell(mtrackno,smn,ixx,iyy,edep); | |
708 | fCPVCell.Add(cpvcell); | |
b2b13ee2 | 709 | } |
710 | } | |
711 | } | |
712 | } // Track Loop ended | |
4d59e381 | 713 | TrackAssignment2CPVCell(); |
b2b13ee2 | 714 | TrackAssignment2Cell(); |
715 | ResetCell(); | |
716 | ||
50555ba1 | 717 | Float_t gain1; |
7088dbe9 | 718 | Float_t adc; |
b2b13ee2 | 719 | Float_t deltaE = 0.; |
720 | Int_t detno = 0; | |
b2b13ee2 | 721 | Int_t trno = 1; |
920e13db | 722 | Int_t trpid = -99; |
723 | ||
b2b13ee2 | 724 | for (Int_t idet = 0; idet < 2; idet++) |
5e2cc5bc | 725 | { |
36031625 | 726 | for (Int_t ism = 0; ism < fgkTotUM; ism++) |
5e2cc5bc | 727 | { |
36031625 | 728 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) |
5e2cc5bc | 729 | { |
36031625 | 730 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) |
5e2cc5bc | 731 | { |
b2b13ee2 | 732 | if (idet == 0) |
5e2cc5bc | 733 | { |
734 | deltaE = fPRE[ism][jrow][kcol]; | |
36031625 | 735 | trno = fPRETrackNo[ism][jrow][kcol]; |
920e13db | 736 | detno = 0; |
5e2cc5bc | 737 | } |
b2b13ee2 | 738 | else if (idet == 1) |
5e2cc5bc | 739 | { |
740 | deltaE = fCPV[ism][jrow][kcol]; | |
8599803d | 741 | trno = fCPVTrackNo[ism][jrow][kcol]; |
920e13db | 742 | detno = 1; |
5e2cc5bc | 743 | } |
b2b13ee2 | 744 | if (deltaE > 0.) |
5e2cc5bc | 745 | { |
7088dbe9 | 746 | MeV2ADC(deltaE,adc); |
5e2cc5bc | 747 | |
748 | // To decalibrate the adc values | |
749 | // | |
750 | gain1 = Gain(idet,ism,jrow,kcol); | |
751 | if (gain1 != 0.) | |
752 | { | |
753 | Int_t adcDecalib = (Int_t)(adc/gain1); | |
754 | adc = (Float_t) adcDecalib; | |
755 | } | |
756 | else if(gain1 == 0.) | |
757 | { | |
758 | adc = 0.; | |
759 | } | |
35535af7 | 760 | |
761 | // Pedestal Decalibration | |
762 | Int_t pedmeanrms = | |
763 | fCalibPed->GetPedMeanRms(idet,ism,jrow,kcol); | |
37edc588 | 764 | Int_t pedrms1 = (Int_t) pedmeanrms%100; |
35535af7 | 765 | Float_t pedrms = (Float_t)pedrms1/10.; |
766 | Float_t pedmean = | |
767 | (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
35535af7 | 768 | if (adc > 0.) |
769 | { | |
770 | adc += (pedmean + 3.0*pedrms); | |
8c24e5f2 | 771 | TParticle *mparticle |
772 | = gAlice->GetMCApp()->Particle(trno); | |
773 | trpid = mparticle->GetPdgCode(); | |
774 | ||
920e13db | 775 | AddDigit(trno,trpid,detno,ism,jrow,kcol,adc); |
35535af7 | 776 | } |
5e2cc5bc | 777 | } |
778 | } // column loop | |
779 | } // row loop | |
03965b13 | 780 | treeD->Fill(); |
781 | ResetDigit(); | |
5e2cc5bc | 782 | } // supermodule loop |
783 | } // detector loop | |
03965b13 | 784 | |
36031625 | 785 | fPMDLoader->WriteDigits("OVERWRITE"); |
b2b13ee2 | 786 | ResetCellADC(); |
920e13db | 787 | |
b2b13ee2 | 788 | } |
7088dbe9 | 789 | //____________________________________________________________________________ |
b2b13ee2 | 790 | |
791 | ||
792 | void AliPMDDigitizer::SDigits2Digits(Int_t ievt) | |
793 | { | |
36031625 | 794 | // This reads the PMD sdigits tree and converts energy deposition |
795 | // in a cell to ADC and stores in the digits tree | |
796 | // | |
ecee2a1a | 797 | |
b2b13ee2 | 798 | fRunLoader->GetEvent(ievt); |
799 | ||
ebd83c56 | 800 | TTree* treeS = fPMDLoader->TreeS(); |
b2b13ee2 | 801 | AliPMDsdigit *pmdsdigit; |
ebd83c56 | 802 | TBranch *branch = treeS->GetBranch("PMDSDigit"); |
ecee2a1a | 803 | if(!branch) |
804 | { | |
805 | AliError("PMD Sdigit branch does not exist"); | |
806 | return; | |
807 | } | |
ebd83c56 | 808 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 809 | branch->SetAddress(&fSDigits); |
810 | ||
ebd83c56 | 811 | TTree* treeD = fPMDLoader->TreeD(); |
812 | if (treeD == 0x0) | |
b2b13ee2 | 813 | { |
36031625 | 814 | fPMDLoader->MakeTree("D"); |
ebd83c56 | 815 | treeD = fPMDLoader->TreeD(); |
b2b13ee2 | 816 | } |
817 | Int_t bufsize = 16000; | |
ebd83c56 | 818 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
5e2cc5bc | 819 | treeD->Branch("PMDDigit", &fDigits, bufsize); |
b2b13ee2 | 820 | |
920e13db | 821 | Int_t trno, trpid, det, smn; |
7088dbe9 | 822 | Int_t irow, icol; |
b2b13ee2 | 823 | Float_t edep, adc; |
824 | ||
ebd83c56 | 825 | Int_t nmodules = (Int_t) treeS->GetEntries(); |
ecee2a1a | 826 | AliDebug(1,Form("Number of modules = %d",nmodules)); |
b2b13ee2 | 827 | |
828 | for (Int_t imodule = 0; imodule < nmodules; imodule++) | |
829 | { | |
5e2cc5bc | 830 | treeS->GetEntry(imodule); |
b2b13ee2 | 831 | Int_t nentries = fSDigits->GetLast(); |
ecee2a1a | 832 | AliDebug(2,Form("Number of entries per module = %d",nentries+1)); |
b2b13ee2 | 833 | for (Int_t ient = 0; ient < nentries+1; ient++) |
834 | { | |
835 | pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); | |
836 | trno = pmdsdigit->GetTrackNumber(); | |
920e13db | 837 | trpid = pmdsdigit->GetTrackPid(); |
b2b13ee2 | 838 | det = pmdsdigit->GetDetector(); |
839 | smn = pmdsdigit->GetSMNumber(); | |
7088dbe9 | 840 | irow = pmdsdigit->GetRow(); |
841 | icol = pmdsdigit->GetColumn(); | |
b2b13ee2 | 842 | edep = pmdsdigit->GetCellEdep(); |
843 | ||
844 | MeV2ADC(edep,adc); | |
5e2cc5bc | 845 | |
846 | // To decalibrte the adc values | |
847 | // | |
848 | Float_t gain1 = Gain(det,smn,irow,icol); | |
849 | if (gain1 != 0.) | |
850 | { | |
04a35d8d | 851 | Int_t adcDecalib = (Int_t)(adc/gain1); |
852 | adc = (Float_t) adcDecalib; | |
5e2cc5bc | 853 | } |
854 | else if(gain1 == 0.) | |
855 | { | |
856 | adc = 0.; | |
857 | } | |
35535af7 | 858 | // Pedestal Decalibration |
859 | Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,irow,icol); | |
37edc588 | 860 | Int_t pedrms1 = (Int_t) pedmeanrms%100; |
35535af7 | 861 | Float_t pedrms = (Float_t)pedrms1/10.; |
862 | Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
35535af7 | 863 | if(adc > 0.) |
864 | { | |
865 | adc += (pedmean + 3.0*pedrms); | |
920e13db | 866 | AddDigit(trno,trpid,det,smn,irow,icol,adc); |
35535af7 | 867 | } |
5e2cc5bc | 868 | |
b2b13ee2 | 869 | } |
ebd83c56 | 870 | treeD->Fill(); |
b2b13ee2 | 871 | ResetDigit(); |
872 | } | |
36031625 | 873 | fPMDLoader->WriteDigits("OVERWRITE"); |
ecee2a1a | 874 | |
b2b13ee2 | 875 | } |
7088dbe9 | 876 | //____________________________________________________________________________ |
877 | void AliPMDDigitizer::Exec(Option_t *option) | |
878 | { | |
879 | // Does the event merging and digitization | |
7088dbe9 | 880 | const char *cdeb = strstr(option,"deb"); |
881 | if(cdeb) | |
882 | { | |
ecee2a1a | 883 | AliDebug(100," *** PMD Exec is called ***"); |
7088dbe9 | 884 | } |
ecee2a1a | 885 | |
7088dbe9 | 886 | Int_t ninputs = fManager->GetNinputs(); |
ecee2a1a | 887 | AliDebug(1,Form("Number of files to be processed = %d",ninputs)); |
7088dbe9 | 888 | ResetCellADC(); |
889 | ||
890 | for (Int_t i = 0; i < ninputs; i++) | |
891 | { | |
892 | Int_t troffset = fManager->GetMask(i); | |
893 | MergeSDigits(i, troffset); | |
894 | } | |
b2b13ee2 | 895 | |
7088dbe9 | 896 | fRunLoader = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); |
897 | fPMD = (AliPMD*)gAlice->GetDetector("PMD"); | |
898 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); | |
899 | if (fPMDLoader == 0x0) | |
900 | { | |
ecee2a1a | 901 | AliError("Can not find PMD or PMDLoader"); |
7088dbe9 | 902 | } |
06f2c79d | 903 | fPMDLoader->LoadDigits("update"); |
ebd83c56 | 904 | TTree* treeD = fPMDLoader->TreeD(); |
905 | if (treeD == 0x0) | |
7088dbe9 | 906 | { |
907 | fPMDLoader->MakeTree("D"); | |
ebd83c56 | 908 | treeD = fPMDLoader->TreeD(); |
7088dbe9 | 909 | } |
910 | Int_t bufsize = 16000; | |
ebd83c56 | 911 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
5e2cc5bc | 912 | treeD->Branch("PMDDigit", &fDigits, bufsize); |
7088dbe9 | 913 | |
914 | Float_t adc; | |
915 | Float_t deltaE = 0.; | |
920e13db | 916 | Int_t detno = 0; |
917 | Int_t trno = 1; | |
918 | Int_t trpid = -99; | |
7088dbe9 | 919 | |
920 | for (Int_t idet = 0; idet < 2; idet++) | |
921 | { | |
922 | for (Int_t ism = 0; ism < fgkTotUM; ism++) | |
923 | { | |
924 | for (Int_t jrow = 0; jrow < fgkRow; jrow++) | |
925 | { | |
926 | for (Int_t kcol = 0; kcol < fgkCol; kcol++) | |
927 | { | |
928 | if (idet == 0) | |
929 | { | |
930 | deltaE = fPRE[ism][jrow][kcol]; | |
931 | trno = fPRETrackNo[ism][jrow][kcol]; | |
920e13db | 932 | trpid = fPRETrackPid[ism][jrow][kcol]; |
933 | detno = 0; | |
7088dbe9 | 934 | } |
935 | else if (idet == 1) | |
936 | { | |
937 | deltaE = fCPV[ism][jrow][kcol]; | |
938 | trno = fCPVTrackNo[ism][jrow][kcol]; | |
920e13db | 939 | trpid = fCPVTrackPid[ism][jrow][kcol]; |
940 | detno = 1; | |
7088dbe9 | 941 | } |
942 | if (deltaE > 0.) | |
943 | { | |
944 | MeV2ADC(deltaE,adc); | |
35535af7 | 945 | |
5f566ada | 946 | // |
35535af7 | 947 | // Gain decalibration |
5f566ada | 948 | // |
949 | Float_t gain1 = Gain(idet,ism,jrow,kcol); | |
35535af7 | 950 | |
5f566ada | 951 | if (gain1 != 0.) |
952 | { | |
953 | Int_t adcDecalib = (Int_t)(adc/gain1); | |
954 | adc = (Float_t) adcDecalib; | |
955 | } | |
956 | else if(gain1 == 0.) | |
957 | { | |
958 | adc = 0.; | |
959 | } | |
35535af7 | 960 | // Pedestal Decalibration |
961 | Int_t pedmeanrms = | |
962 | fCalibPed->GetPedMeanRms(idet,ism,jrow,kcol); | |
37edc588 | 963 | Int_t pedrms1 = (Int_t) pedmeanrms%100; |
35535af7 | 964 | Float_t pedrms = (Float_t)pedrms1/10.; |
965 | Float_t pedmean = | |
966 | (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
35535af7 | 967 | if (adc > 0.) |
968 | { | |
969 | adc += (pedmean + 3.0*pedrms); | |
920e13db | 970 | AddDigit(trno,trpid,detno,ism,jrow,kcol,adc); |
35535af7 | 971 | } |
5f566ada | 972 | |
7088dbe9 | 973 | } |
974 | } // column loop | |
975 | } // row loop | |
ebd83c56 | 976 | treeD->Fill(); |
7088dbe9 | 977 | ResetDigit(); |
978 | } // supermodule loop | |
979 | } // detector loop | |
5e2cc5bc | 980 | fPMDLoader->WriteDigits("OVERWRITE"); |
06f2c79d | 981 | fPMDLoader->UnloadDigits(); |
982 | ResetCellADC(); | |
7088dbe9 | 983 | } |
984 | //____________________________________________________________________________ | |
4d59e381 | 985 | void AliPMDDigitizer::TrackAssignment2CPVCell() |
986 | { | |
987 | // This block assigns the cell id when there are | |
988 | // multiple tracks in a cell according to the | |
989 | // energy deposition | |
990 | // This method added by Ajay | |
991 | Bool_t jsort = false; | |
992 | ||
993 | Int_t i, j, k; | |
994 | ||
995 | Int_t *status1; | |
996 | Int_t *status2; | |
997 | Int_t *trnarray; | |
998 | Float_t *fracEdp; | |
999 | Float_t *trEdp; | |
1000 | ||
1001 | Int_t ****cpvTrack; | |
1002 | Float_t ****cpvEdep; | |
1003 | ||
1004 | cpvTrack = new Int_t ***[fgkTotUM]; | |
1005 | cpvEdep = new Float_t ***[fgkTotUM]; | |
1006 | for (i=0; i<fgkTotUM; i++) | |
1007 | { | |
1008 | cpvTrack[i] = new Int_t **[fgkRow]; | |
1009 | cpvEdep[i] = new Float_t **[fgkRow]; | |
1010 | } | |
1011 | ||
1012 | for (i = 0; i < fgkTotUM; i++) | |
1013 | { | |
1014 | for (j = 0; j < fgkRow; j++) | |
1015 | { | |
1016 | cpvTrack[i][j] = new Int_t *[fgkCol]; | |
1017 | cpvEdep[i][j] = new Float_t *[fgkCol]; | |
1018 | } | |
1019 | } | |
1020 | for (i = 0; i < fgkTotUM; i++) | |
1021 | { | |
1022 | for (j = 0; j < fgkRow; j++) | |
1023 | { | |
1024 | for (k = 0; k < fgkCol; k++) | |
1025 | { | |
1026 | Int_t nn = fCPVCounter[i][j][k]; | |
1027 | if(nn > 0) | |
1028 | { | |
1029 | cpvTrack[i][j][k] = new Int_t[nn]; | |
1030 | cpvEdep[i][j][k] = new Float_t[nn]; | |
1031 | } | |
1032 | else | |
1033 | { | |
1034 | nn = 1; | |
1035 | cpvTrack[i][j][k] = new Int_t[nn]; | |
1036 | cpvEdep[i][j][k] = new Float_t[nn]; | |
1037 | } | |
1038 | fCPVCounter[i][j][k] = 0; | |
1039 | } | |
1040 | } | |
1041 | } | |
1042 | ||
1043 | ||
1044 | Int_t nentries = fCPVCell.GetEntries(); | |
1045 | ||
1046 | Int_t mtrackno, ism, ixp, iyp; | |
1047 | Float_t edep; | |
1048 | for (i = 0; i < nentries; i++) | |
1049 | { | |
1050 | AliPMDcell* cpvcell = (AliPMDcell*)fCPVCell.UncheckedAt(i); | |
1051 | ||
1052 | mtrackno = cpvcell->GetTrackNumber(); | |
1053 | ism = cpvcell->GetSMNumber(); | |
1054 | ixp = cpvcell->GetX(); | |
1055 | iyp = cpvcell->GetY(); | |
1056 | edep = cpvcell->GetEdep(); | |
1057 | Int_t nn = fCPVCounter[ism][ixp][iyp]; | |
1058 | cpvTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno; | |
1059 | cpvEdep[ism][ixp][iyp][nn] = edep; | |
1060 | fCPVCounter[ism][ixp][iyp]++; | |
1061 | } | |
1062 | ||
1063 | Int_t iz, il; | |
1064 | Int_t im, ix, iy; | |
1065 | Int_t nn; | |
1066 | for (im=0; im<fgkTotUM; im++) | |
1067 | { | |
1068 | for (ix=0; ix<fgkRow; ix++) | |
1069 | { | |
1070 | for (iy=0; iy<fgkCol; iy++) | |
1071 | { | |
1072 | nn = fCPVCounter[im][ix][iy]; | |
1073 | if (nn > 1) | |
1074 | { | |
1075 | // This block handles if a cell is fired | |
1076 | // many times by many tracks | |
1077 | status1 = new Int_t[nn]; | |
1078 | status2 = new Int_t[nn]; | |
1079 | trnarray = new Int_t[nn]; | |
1080 | for (iz = 0; iz < nn; iz++) | |
1081 | { | |
1082 | status1[iz] = cpvTrack[im][ix][iy][iz]; | |
1083 | } | |
1084 | TMath::Sort(nn,status1,status2,jsort); | |
1085 | Int_t trackOld = -99999; | |
1086 | Int_t track, trCount = 0; | |
1087 | for (iz = 0; iz < nn; iz++) | |
1088 | { | |
1089 | track = status1[status2[iz]]; | |
1090 | if (trackOld != track) | |
1091 | { | |
1092 | trnarray[trCount] = track; | |
1093 | trCount++; | |
1094 | } | |
1095 | trackOld = track; | |
1096 | } | |
1097 | delete [] status1; | |
1098 | delete [] status2; | |
1099 | Float_t totEdp = 0.; | |
1100 | trEdp = new Float_t[trCount]; | |
1101 | fracEdp = new Float_t[trCount]; | |
1102 | for (il = 0; il < trCount; il++) | |
1103 | { | |
1104 | trEdp[il] = 0.; | |
1105 | track = trnarray[il]; | |
1106 | for (iz = 0; iz < nn; iz++) | |
1107 | { | |
1108 | if (track == cpvTrack[im][ix][iy][iz]) | |
1109 | { | |
1110 | trEdp[il] += cpvEdep[im][ix][iy][iz]; | |
1111 | } | |
1112 | } | |
1113 | totEdp += trEdp[il]; | |
1114 | } | |
1115 | Int_t ilOld = 0; | |
1116 | Float_t fracOld = 0.; | |
1117 | ||
1118 | for (il = 0; il < trCount; il++) | |
1119 | { | |
1120 | fracEdp[il] = trEdp[il]/totEdp; | |
1121 | if (fracOld < fracEdp[il]) | |
1122 | { | |
1123 | fracOld = fracEdp[il]; | |
1124 | ilOld = il; | |
1125 | } | |
1126 | } | |
1127 | fCPVTrackNo[im][ix][iy] = trnarray[ilOld]; | |
1128 | delete [] fracEdp; | |
1129 | delete [] trEdp; | |
1130 | delete [] trnarray; | |
1131 | } | |
1132 | else if (nn == 1) | |
1133 | { | |
1134 | // This only handles if a cell is fired | |
1135 | // by only one track | |
1136 | ||
1137 | fCPVTrackNo[im][ix][iy] = cpvTrack[im][ix][iy][0]; | |
1138 | ||
1139 | } | |
1140 | else if (nn ==0) | |
1141 | { | |
1142 | // This is if no cell is fired | |
1143 | fCPVTrackNo[im][ix][iy] = -999; | |
1144 | } | |
1145 | } // end of iy | |
1146 | } // end of ix | |
1147 | } // end of im | |
1148 | ||
1149 | // Delete all the pointers | |
1150 | ||
1151 | for (i = 0; i < fgkTotUM; i++) | |
1152 | { | |
1153 | for (j = 0; j < fgkRow; j++) | |
1154 | { | |
1155 | for (k = 0; k < fgkCol; k++) | |
1156 | { | |
1157 | delete []cpvTrack[i][j][k]; | |
1158 | delete []cpvEdep[i][j][k]; | |
1159 | } | |
1160 | } | |
1161 | } | |
1162 | ||
1163 | for (i = 0; i < fgkTotUM; i++) | |
1164 | { | |
1165 | for (j = 0; j < fgkRow; j++) | |
1166 | { | |
1167 | delete [] cpvTrack[i][j]; | |
1168 | delete [] cpvEdep[i][j]; | |
1169 | } | |
1170 | } | |
1171 | ||
1172 | for (i = 0; i < fgkTotUM; i++) | |
1173 | { | |
1174 | delete [] cpvTrack[i]; | |
1175 | delete [] cpvEdep[i]; | |
1176 | } | |
1177 | delete [] cpvTrack; | |
1178 | delete [] cpvEdep; | |
1179 | ||
1180 | // | |
1181 | // End of the cell id assignment | |
1182 | // | |
1183 | } | |
1184 | //____________________________________________________________________________ | |
7088dbe9 | 1185 | |
1186 | void AliPMDDigitizer::MergeSDigits(Int_t filenumber, Int_t troffset) | |
1187 | { | |
1188 | // merging sdigits | |
1189 | fRunLoader = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(filenumber)); | |
1190 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); | |
1191 | fPMDLoader->LoadSDigits("read"); | |
ebd83c56 | 1192 | TTree* treeS = fPMDLoader->TreeS(); |
7088dbe9 | 1193 | AliPMDsdigit *pmdsdigit; |
ebd83c56 | 1194 | TBranch *branch = treeS->GetBranch("PMDSDigit"); |
1195 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); | |
7088dbe9 | 1196 | branch->SetAddress(&fSDigits); |
1197 | ||
920e13db | 1198 | Int_t itrackno, itrackpid, idet, ism; |
7088dbe9 | 1199 | Int_t ixp, iyp; |
1200 | Float_t edep; | |
ebd83c56 | 1201 | Int_t nmodules = (Int_t) treeS->GetEntries(); |
ecee2a1a | 1202 | AliDebug(1,Form("Number of Modules in the treeS = %d",nmodules)); |
1203 | AliDebug(1,Form("Track Offset = %d",troffset)); | |
7088dbe9 | 1204 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
1205 | { | |
5e2cc5bc | 1206 | treeS->GetEntry(imodule); |
7088dbe9 | 1207 | Int_t nentries = fSDigits->GetLast(); |
ecee2a1a | 1208 | AliDebug(2,Form("Number of Entries per Module = %d",nentries)); |
7088dbe9 | 1209 | for (Int_t ient = 0; ient < nentries+1; ient++) |
1210 | { | |
1211 | pmdsdigit = (AliPMDsdigit*)fSDigits->UncheckedAt(ient); | |
1212 | itrackno = pmdsdigit->GetTrackNumber(); | |
920e13db | 1213 | itrackpid = pmdsdigit->GetTrackPid(); |
7088dbe9 | 1214 | idet = pmdsdigit->GetDetector(); |
1215 | ism = pmdsdigit->GetSMNumber(); | |
1216 | ixp = pmdsdigit->GetRow(); | |
1217 | iyp = pmdsdigit->GetColumn(); | |
1218 | edep = pmdsdigit->GetCellEdep(); | |
7088dbe9 | 1219 | if (idet == 0) |
1220 | { | |
1221 | if (fPRE[ism][ixp][iyp] < edep) | |
1222 | { | |
1223 | fPRETrackNo[ism][ixp][iyp] = troffset + itrackno; | |
920e13db | 1224 | fPRETrackPid[ism][ixp][iyp] = itrackpid; |
7088dbe9 | 1225 | } |
1226 | fPRE[ism][ixp][iyp] += edep; | |
1227 | } | |
1228 | else if (idet == 1) | |
1229 | { | |
1230 | if (fCPV[ism][ixp][iyp] < edep) | |
1231 | { | |
1232 | fCPVTrackNo[ism][ixp][iyp] = troffset + itrackno; | |
920e13db | 1233 | fCPVTrackPid[ism][ixp][iyp] = itrackpid; |
7088dbe9 | 1234 | } |
1235 | fCPV[ism][ixp][iyp] += edep; | |
1236 | } | |
1237 | } | |
1238 | } | |
1239 | ||
1240 | } | |
1241 | // ---------------------------------------------------------------------- | |
b2b13ee2 | 1242 | void AliPMDDigitizer::TrackAssignment2Cell() |
1243 | { | |
b2b13ee2 | 1244 | // |
75bb524e | 1245 | // This block assigns the cell id when there are |
b2b13ee2 | 1246 | // multiple tracks in a cell according to the |
1247 | // energy deposition | |
1248 | // | |
75bb524e | 1249 | Bool_t jsort = false; |
8599803d | 1250 | |
b2b13ee2 | 1251 | Int_t i, j, k; |
1252 | ||
4d59e381 | 1253 | Int_t *status1; |
1254 | Int_t *status2; | |
1255 | Int_t *trnarray; | |
36031625 | 1256 | Float_t *fracEdp; |
1257 | Float_t *trEdp; | |
4d59e381 | 1258 | |
36031625 | 1259 | Int_t ****pmdTrack; |
1260 | Float_t ****pmdEdep; | |
b2b13ee2 | 1261 | |
36031625 | 1262 | pmdTrack = new Int_t ***[fgkTotUM]; |
1263 | pmdEdep = new Float_t ***[fgkTotUM]; | |
1264 | for (i=0; i<fgkTotUM; i++) | |
b2b13ee2 | 1265 | { |
36031625 | 1266 | pmdTrack[i] = new Int_t **[fgkRow]; |
1267 | pmdEdep[i] = new Float_t **[fgkRow]; | |
b2b13ee2 | 1268 | } |
1269 | ||
36031625 | 1270 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1271 | { |
36031625 | 1272 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1273 | { |
36031625 | 1274 | pmdTrack[i][j] = new Int_t *[fgkCol]; |
1275 | pmdEdep[i][j] = new Float_t *[fgkCol]; | |
b2b13ee2 | 1276 | } |
1277 | } | |
1278 | ||
36031625 | 1279 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1280 | { |
36031625 | 1281 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1282 | { |
36031625 | 1283 | for (k = 0; k < fgkCol; k++) |
b2b13ee2 | 1284 | { |
36031625 | 1285 | Int_t nn = fPRECounter[i][j][k]; |
b2b13ee2 | 1286 | if(nn > 0) |
1287 | { | |
36031625 | 1288 | pmdTrack[i][j][k] = new Int_t[nn]; |
1289 | pmdEdep[i][j][k] = new Float_t[nn]; | |
b2b13ee2 | 1290 | } |
1291 | else | |
1292 | { | |
1293 | nn = 1; | |
36031625 | 1294 | pmdTrack[i][j][k] = new Int_t[nn]; |
1295 | pmdEdep[i][j][k] = new Float_t[nn]; | |
5e2cc5bc | 1296 | } |
36031625 | 1297 | fPRECounter[i][j][k] = 0; |
b2b13ee2 | 1298 | } |
1299 | } | |
1300 | } | |
1301 | ||
1302 | ||
ebd83c56 | 1303 | Int_t nentries = fCell.GetEntries(); |
b2b13ee2 | 1304 | |
1305 | Int_t mtrackno, ism, ixp, iyp; | |
1306 | Float_t edep; | |
1307 | ||
1308 | for (i = 0; i < nentries; i++) | |
1309 | { | |
ebd83c56 | 1310 | AliPMDcell* cell = (AliPMDcell*)fCell.UncheckedAt(i); |
b2b13ee2 | 1311 | |
ebd83c56 | 1312 | mtrackno = cell->GetTrackNumber(); |
1313 | ism = cell->GetSMNumber(); | |
1314 | ixp = cell->GetX(); | |
1315 | iyp = cell->GetY(); | |
1316 | edep = cell->GetEdep(); | |
36031625 | 1317 | Int_t nn = fPRECounter[ism][ixp][iyp]; |
36031625 | 1318 | pmdTrack[ism][ixp][iyp][nn] = (Int_t) mtrackno; |
1319 | pmdEdep[ism][ixp][iyp][nn] = edep; | |
1320 | fPRECounter[ism][ixp][iyp]++; | |
b2b13ee2 | 1321 | } |
1322 | ||
1323 | Int_t iz, il; | |
1324 | Int_t im, ix, iy; | |
1325 | Int_t nn; | |
1326 | ||
36031625 | 1327 | for (im=0; im<fgkTotUM; im++) |
b2b13ee2 | 1328 | { |
36031625 | 1329 | for (ix=0; ix<fgkRow; ix++) |
b2b13ee2 | 1330 | { |
36031625 | 1331 | for (iy=0; iy<fgkCol; iy++) |
b2b13ee2 | 1332 | { |
36031625 | 1333 | nn = fPRECounter[im][ix][iy]; |
b2b13ee2 | 1334 | if (nn > 1) |
1335 | { | |
1336 | // This block handles if a cell is fired | |
1337 | // many times by many tracks | |
75bb524e | 1338 | status1 = new Int_t[nn]; |
1339 | status2 = new Int_t[nn]; | |
1340 | trnarray = new Int_t[nn]; | |
b2b13ee2 | 1341 | for (iz = 0; iz < nn; iz++) |
1342 | { | |
36031625 | 1343 | status1[iz] = pmdTrack[im][ix][iy][iz]; |
b2b13ee2 | 1344 | } |
75bb524e | 1345 | TMath::Sort(nn,status1,status2,jsort); |
36031625 | 1346 | Int_t trackOld = -99999; |
1347 | Int_t track, trCount = 0; | |
b2b13ee2 | 1348 | for (iz = 0; iz < nn; iz++) |
1349 | { | |
75bb524e | 1350 | track = status1[status2[iz]]; |
36031625 | 1351 | if (trackOld != track) |
b2b13ee2 | 1352 | { |
36031625 | 1353 | trnarray[trCount] = track; |
1354 | trCount++; | |
5e2cc5bc | 1355 | } |
36031625 | 1356 | trackOld = track; |
b2b13ee2 | 1357 | } |
6eb80a7c | 1358 | delete [] status1; |
1359 | delete [] status2; | |
36031625 | 1360 | Float_t totEdp = 0.; |
1361 | trEdp = new Float_t[trCount]; | |
1362 | fracEdp = new Float_t[trCount]; | |
1363 | for (il = 0; il < trCount; il++) | |
b2b13ee2 | 1364 | { |
36031625 | 1365 | trEdp[il] = 0.; |
75bb524e | 1366 | track = trnarray[il]; |
b2b13ee2 | 1367 | for (iz = 0; iz < nn; iz++) |
1368 | { | |
36031625 | 1369 | if (track == pmdTrack[im][ix][iy][iz]) |
b2b13ee2 | 1370 | { |
36031625 | 1371 | trEdp[il] += pmdEdep[im][ix][iy][iz]; |
b2b13ee2 | 1372 | } |
1373 | } | |
36031625 | 1374 | totEdp += trEdp[il]; |
b2b13ee2 | 1375 | } |
36031625 | 1376 | Int_t ilOld = 0; |
1377 | Float_t fracOld = 0.; | |
b2b13ee2 | 1378 | |
36031625 | 1379 | for (il = 0; il < trCount; il++) |
b2b13ee2 | 1380 | { |
36031625 | 1381 | fracEdp[il] = trEdp[il]/totEdp; |
1382 | if (fracOld < fracEdp[il]) | |
b2b13ee2 | 1383 | { |
36031625 | 1384 | fracOld = fracEdp[il]; |
1385 | ilOld = il; | |
b2b13ee2 | 1386 | } |
1387 | } | |
36031625 | 1388 | fPRETrackNo[im][ix][iy] = trnarray[ilOld]; |
6eb80a7c | 1389 | delete [] fracEdp; |
1390 | delete [] trEdp; | |
1391 | delete [] trnarray; | |
b2b13ee2 | 1392 | } |
1393 | else if (nn == 1) | |
1394 | { | |
1395 | // This only handles if a cell is fired | |
1396 | // by only one track | |
1397 | ||
36031625 | 1398 | fPRETrackNo[im][ix][iy] = pmdTrack[im][ix][iy][0]; |
b2b13ee2 | 1399 | |
1400 | } | |
1401 | else if (nn ==0) | |
1402 | { | |
1403 | // This is if no cell is fired | |
36031625 | 1404 | fPRETrackNo[im][ix][iy] = -999; |
b2b13ee2 | 1405 | } |
1406 | } // end of iy | |
1407 | } // end of ix | |
1408 | } // end of im | |
1409 | ||
1410 | // Delete all the pointers | |
1411 | ||
36031625 | 1412 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1413 | { |
36031625 | 1414 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1415 | { |
36031625 | 1416 | for (k = 0; k < fgkCol; k++) |
b2b13ee2 | 1417 | { |
36031625 | 1418 | delete [] pmdTrack[i][j][k]; |
1419 | delete [] pmdEdep[i][j][k]; | |
b2b13ee2 | 1420 | } |
1421 | } | |
1422 | } | |
1423 | ||
36031625 | 1424 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1425 | { |
36031625 | 1426 | for (j = 0; j < fgkRow; j++) |
b2b13ee2 | 1427 | { |
36031625 | 1428 | delete [] pmdTrack[i][j]; |
1429 | delete [] pmdEdep[i][j]; | |
b2b13ee2 | 1430 | } |
1431 | } | |
1432 | ||
36031625 | 1433 | for (i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1434 | { |
36031625 | 1435 | delete [] pmdTrack[i]; |
1436 | delete [] pmdEdep[i]; | |
b2b13ee2 | 1437 | } |
6eb80a7c | 1438 | delete [] pmdTrack; |
1439 | delete [] pmdEdep; | |
b2b13ee2 | 1440 | // |
1441 | // End of the cell id assignment | |
1442 | // | |
1443 | } | |
7088dbe9 | 1444 | //____________________________________________________________________________ |
a7d110b8 | 1445 | void AliPMDDigitizer::MeV2ADC(Float_t mev, Float_t & adc) const |
b2b13ee2 | 1446 | { |
36031625 | 1447 | // This converts the simulated edep to ADC according to the |
1448 | // Test Beam Data | |
ab67948f | 1449 | // PS Test in June 2010, Voltage @ 1300 V |
4d59e381 | 1450 | // KeV - ADC conversion for 12bit ADC |
7ba814f3 | 1451 | // MPV data used for the fit and taken here |
1452 | ||
ab67948f | 1453 | const Float_t kConstant = 16.807; |
1454 | const Float_t kErConstant = 6.62215; | |
1455 | const Float_t kSlope = 128.875; | |
1456 | const Float_t kErSlope = 6.21713; | |
4d59e381 | 1457 | |
b8e69f1f | 1458 | Float_t cons = gRandom->Gaus(kConstant,kErConstant); |
1459 | Float_t slop = gRandom->Gaus(kSlope,kErSlope); | |
4d59e381 | 1460 | |
1461 | Float_t adc12bit = slop*mev*0.001 + cons; | |
1462 | ||
7ba814f3 | 1463 | if (adc12bit < 0.) adc12bit = 0.; |
04a35d8d | 1464 | |
4d59e381 | 1465 | if(adc12bit < 1600.0) |
b8e69f1f | 1466 | { |
1467 | adc = (Float_t) adc12bit; | |
1468 | } | |
4d59e381 | 1469 | else if (adc12bit >= 1600.0) |
b8e69f1f | 1470 | { |
4d59e381 | 1471 | adc = 1600.0; |
b8e69f1f | 1472 | } |
b2b13ee2 | 1473 | } |
7088dbe9 | 1474 | //____________________________________________________________________________ |
920e13db | 1475 | void AliPMDDigitizer::AddSDigit(Int_t trnumber, Int_t trpid, Int_t det, |
1476 | Int_t smnumber, Int_t irow, Int_t icol, | |
1477 | Float_t adc) | |
b2b13ee2 | 1478 | { |
36031625 | 1479 | // Add SDigit |
1480 | // | |
ebd83c56 | 1481 | if (!fSDigits) fSDigits = new TClonesArray("AliPMDsdigit", 1000); |
b2b13ee2 | 1482 | TClonesArray &lsdigits = *fSDigits; |
920e13db | 1483 | new(lsdigits[fNsdigit++]) AliPMDsdigit(trnumber,trpid,det,smnumber,irow,icol,adc); |
b2b13ee2 | 1484 | } |
7088dbe9 | 1485 | //____________________________________________________________________________ |
b2b13ee2 | 1486 | |
920e13db | 1487 | void AliPMDDigitizer::AddDigit(Int_t trnumber, Int_t trpid, Int_t det, |
1488 | Int_t smnumber, Int_t irow, Int_t icol, | |
1489 | Float_t adc) | |
b2b13ee2 | 1490 | { |
36031625 | 1491 | // Add Digit |
1492 | // | |
ebd83c56 | 1493 | if (!fDigits) fDigits = new TClonesArray("AliPMDdigit", 1000); |
b2b13ee2 | 1494 | TClonesArray &ldigits = *fDigits; |
920e13db | 1495 | new(ldigits[fNdigit++]) AliPMDdigit(trnumber,trpid, det,smnumber,irow,icol,adc); |
b2b13ee2 | 1496 | } |
7088dbe9 | 1497 | //____________________________________________________________________________ |
b2b13ee2 | 1498 | |
b2b13ee2 | 1499 | void AliPMDDigitizer::SetZPosition(Float_t zpos) |
1500 | { | |
1501 | fZPos = zpos; | |
1502 | } | |
7088dbe9 | 1503 | //____________________________________________________________________________ |
b2b13ee2 | 1504 | Float_t AliPMDDigitizer::GetZPosition() const |
1505 | { | |
1506 | return fZPos; | |
1507 | } | |
7088dbe9 | 1508 | //____________________________________________________________________________ |
b2b13ee2 | 1509 | |
1510 | void AliPMDDigitizer::ResetCell() | |
1511 | { | |
36031625 | 1512 | // clears the cell array and also the counter |
1513 | // for each cell | |
1514 | // | |
4d59e381 | 1515 | fCPVCell.Delete(); |
ebd83c56 | 1516 | fCell.Delete(); |
36031625 | 1517 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1518 | { |
36031625 | 1519 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 1520 | { |
36031625 | 1521 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 1522 | { |
4d59e381 | 1523 | fCPVCounter[i][j][k] = 0; |
5e2cc5bc | 1524 | fPRECounter[i][j][k] = 0; |
b2b13ee2 | 1525 | } |
1526 | } | |
1527 | } | |
1528 | } | |
7088dbe9 | 1529 | //____________________________________________________________________________ |
b2b13ee2 | 1530 | void AliPMDDigitizer::ResetSDigit() |
1531 | { | |
36031625 | 1532 | // Clears SDigits |
b2b13ee2 | 1533 | fNsdigit = 0; |
ebd83c56 | 1534 | if (fSDigits) fSDigits->Delete(); |
b2b13ee2 | 1535 | } |
7088dbe9 | 1536 | //____________________________________________________________________________ |
b2b13ee2 | 1537 | void AliPMDDigitizer::ResetDigit() |
1538 | { | |
36031625 | 1539 | // Clears Digits |
b2b13ee2 | 1540 | fNdigit = 0; |
ebd83c56 | 1541 | if (fDigits) fDigits->Delete(); |
b2b13ee2 | 1542 | } |
7088dbe9 | 1543 | //____________________________________________________________________________ |
b2b13ee2 | 1544 | |
1545 | void AliPMDDigitizer::ResetCellADC() | |
1546 | { | |
7088dbe9 | 1547 | // Clears individual cells edep and track number |
36031625 | 1548 | for (Int_t i = 0; i < fgkTotUM; i++) |
b2b13ee2 | 1549 | { |
36031625 | 1550 | for (Int_t j = 0; j < fgkRow; j++) |
b2b13ee2 | 1551 | { |
36031625 | 1552 | for (Int_t k = 0; k < fgkCol; k++) |
b2b13ee2 | 1553 | { |
920e13db | 1554 | fCPV[i][j][k] = 0.; |
1555 | fPRE[i][j][k] = 0.; | |
1556 | fCPVTrackNo[i][j][k] = 0; | |
1557 | fPRETrackNo[i][j][k] = 0; | |
1558 | fCPVTrackPid[i][j][k] = -1; | |
1559 | fPRETrackPid[i][j][k] = -1; | |
b2b13ee2 | 1560 | } |
1561 | } | |
1562 | } | |
1563 | } | |
7088dbe9 | 1564 | //____________________________________________________________________________ |
b2b13ee2 | 1565 | |
1566 | void AliPMDDigitizer::UnLoad(Option_t *option) | |
1567 | { | |
36031625 | 1568 | // Unloads all the root files |
1569 | // | |
b2b13ee2 | 1570 | const char *cS = strstr(option,"S"); |
1571 | const char *cD = strstr(option,"D"); | |
1572 | ||
1573 | fRunLoader->UnloadgAlice(); | |
1574 | fRunLoader->UnloadHeader(); | |
1575 | fRunLoader->UnloadKinematics(); | |
1576 | ||
1577 | if (cS) | |
1578 | { | |
36031625 | 1579 | fPMDLoader->UnloadHits(); |
b2b13ee2 | 1580 | } |
1581 | if (cD) | |
1582 | { | |
36031625 | 1583 | fPMDLoader->UnloadHits(); |
1584 | fPMDLoader->UnloadSDigits(); | |
b2b13ee2 | 1585 | } |
1586 | } | |
09a06455 | 1587 | |
1588 | //---------------------------------------------------------------------- | |
1589 | Float_t AliPMDDigitizer::Gain(Int_t det, Int_t smn, Int_t row, Int_t col) const | |
1590 | { | |
1591 | // returns of the gain of the cell | |
1592 | // Added this method by ZA | |
1593 | ||
1594 | //cout<<" I am here in gain "<<fCalibData<< "smn,row, col "<<smn | |
1595 | //<<" "<<row<<" "<<col<<endl; | |
1596 | ||
35535af7 | 1597 | if(!fCalibGain) { |
09a06455 | 1598 | AliError("No calibration data loaded from CDB!!!"); |
50555ba1 | 1599 | return 1; |
09a06455 | 1600 | } |
1601 | ||
1602 | Float_t GainFact; | |
35535af7 | 1603 | GainFact = fCalibGain->GetGainFact(det,smn,row,col); |
09a06455 | 1604 | return GainFact; |
1605 | } | |
1606 | //---------------------------------------------------------------------- | |
35535af7 | 1607 | AliPMDCalibData* AliPMDDigitizer::GetCalibGain() const |
09a06455 | 1608 | { |
1609 | // The run number will be centralized in AliCDBManager, | |
1610 | // you don't need to set it here! | |
1611 | // Added this method by ZA | |
0dd3d6f9 | 1612 | // Cleaned up by Alberto |
35535af7 | 1613 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain"); |
09a06455 | 1614 | |
0dd3d6f9 | 1615 | if(!entry) AliFatal("Calibration object retrieval failed!"); |
09a06455 | 1616 | |
1617 | AliPMDCalibData *calibdata=0; | |
1618 | if (entry) calibdata = (AliPMDCalibData*) entry->GetObject(); | |
1619 | ||
0dd3d6f9 | 1620 | if (!calibdata) AliFatal("No calibration data from calibration database !"); |
09a06455 | 1621 | |
1622 | return calibdata; | |
1623 | } | |
35535af7 | 1624 | //---------------------------------------------------------------------- |
1625 | AliPMDPedestal* AliPMDDigitizer::GetCalibPed() const | |
1626 | { | |
1627 | // The run number will be centralized in AliCDBManager, | |
1628 | // you don't need to set it here! | |
1629 | ||
1630 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped"); | |
1631 | ||
1632 | if(!entry) AliFatal("Pedestal object retrieval failed!"); | |
1633 | ||
1634 | AliPMDPedestal *pedestal=0; | |
1635 | if (entry) pedestal = (AliPMDPedestal*) entry->GetObject(); | |
1636 | ||
1637 | if (!pedestal) AliFatal("No pedestal data from calibration database !"); | |
1638 | ||
1639 | return pedestal; | |
1640 | } |