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