1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
21 // Photon Multiplicity Detector //
22 // This class contains the basic functions for the Photon Multiplicity //
23 // Detector. Functions specific to one particular geometry are //
24 // contained in the derived classes //
28 <img src="picts/AliPMDClass.gif">
31 <font size=+2 color=red>
32 <p>The responsible person for this module is
33 <a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
39 ///////////////////////////////////////////////////////////////////////////////
42 #include <TClonesArray.h>
44 #include <TGeometry.h>
47 #include <TVirtualMC.h>
50 #include "AliLoader.h"
52 #include "AliPMDRecPoint.h"
55 #include "AliPMDDigitizer.h"
59 //_____________________________________________________________________________
63 // Default constructor
71 //_____________________________________________________________________________
72 AliPMD::AliPMD(const char *name, const char *title)
73 : AliDetector(name,title)
76 // Default constructor
80 // Allocate the array of hits
81 fHits = new TClonesArray("AliPMDhit", 405);
82 gAlice->GetMCApp()->AddHitList(fHits);
84 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
108 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
110 cout<<"AliPMD::MakeLoader ";
112 fLoader = new AliPMDLoader(GetName(),topfoldername);
116 cout<<"Success"<<endl;
120 cout<<"Failure"<<endl;
129 // Default constructor
135 //_____________________________________________________________________________
136 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
141 TClonesArray &lhits = *fHits;
142 AliPMDhit *newcell, *curcell;
143 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
144 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
145 // vol[4],vol[5],vol[6],vol[7]);
147 newcell = new AliPMDhit(fIshunt, track, vol, hits);
149 for (i=0; i<fNhits; i++) {
151 // See if this cell has already been hit
152 curcell=(AliPMDhit*) lhits[i];
153 if (*curcell==*newcell) {
154 // printf("Cell with same numbers found\n") ; curcell->Print();
155 *curcell = *curcell+*newcell;
156 // printf("Cell after addition\n") ; curcell->Print();
161 new(lhits[fNhits++]) AliPMDhit(newcell);
165 //_____________________________________________________________________________
166 void AliPMD::BuildGeometry()
169 // Build simple ROOT TNode geometry for event display
173 const int kColorPMD = kRed;
176 Top=gAlice->GetGeometry()->GetNode("alice");
179 new TBRIK("S_PMD","PMD box","void",300,300,5);
181 Node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
182 Node->SetLineColor(kColorPMD);
186 //_____________________________________________________________________________
187 Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t )
190 // Distance from mouse to detector on the screen
196 //_____________________________________________________________________________
197 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
200 // Set PMD parameters
208 //_____________________________________________________________________________
209 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
212 // Set PMD parameters
221 //_____________________________________________________________________________
222 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
225 // Set geometry parameters
232 //_____________________________________________________________________________
233 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
244 //_____________________________________________________________________________
245 void AliPMD::StepManager()
248 // Called at every step in PMD
252 void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
255 // Add a PMD reconstructed hit to the list
257 TClonesArray &lrecpoints = *fRecPoints;
258 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
261 void AliPMD::MakeBranch(Option_t* option)
263 // Create Tree branches for the PMD
265 const char *cR = strstr(option,"R");
266 const char *cH = strstr(option,"H");
267 if (cH && fLoader->TreeH() && (fHits == 0x0))
268 fHits = new TClonesArray("AliPMDhit", 405);
270 AliDetector::MakeBranch(option);
272 if (cR && fLoader->TreeR()) {
273 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
275 const Int_t kBufferSize = 4000;
278 sprintf(branchname,"%sRecPoints",GetName());
279 if (fRecPoints == 0x0) {
280 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
282 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
287 void AliPMD::SetTreeAddress()
289 // Set branch address for the TreeR
292 if (fLoader->TreeH() && fHits==0x0)
293 fHits = new TClonesArray("AliPMDhit", 405);
295 AliDetector::SetTreeAddress();
298 TTree *treeR = fLoader->TreeR();
300 sprintf(branchname,"%s",GetName());
302 branch = treeR->GetBranch(branchname);
305 if (fRecPoints == 0x0) {
306 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
308 branch->SetAddress(&fRecPoints);
313 void AliPMD::ResetHits()
316 // Reset number of hits and the hits array
318 AliDetector::ResetHits();
320 if (fRecPoints) fRecPoints->Clear();
323 ///////////////////////////////////////////////////////////////////////////////
325 // Photon Multiplicity Detector Version 1 //
329 <img src="picts/AliPMDv1Class.gif">
333 ///////////////////////////////////////////////////////////////////////////////
339 //_____________________________________________________________________________
340 AliPMDhit::AliPMDhit(Int_t shunt,Int_t track, Int_t *vol, Float_t *hits):
347 for (i=0;i<8;i++) fVolume[i] = vol[i];
355 //____________________________________________________________________________
356 void AliPMD::Hits2SDigits()
358 // create summable digits
360 AliRunLoader* runLoader = fLoader->GetRunLoader();
361 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
362 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
364 pmdDigitizer->SetZPosition(365.0);
366 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
367 pmdDigitizer->Hits2SDigits(iEvent);
369 fLoader->UnloadHits();
370 fLoader->UnloadSDigits();