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