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"
51 #include "AliPMDLoader.h"
53 #include "AliPMDRecPoint.h"
56 #include "AliPMDDigitizer.h"
57 #include "AliPMDhit.h"
61 //_____________________________________________________________________________
65 // Default constructor
73 //_____________________________________________________________________________
74 AliPMD::AliPMD(const char *name, const char *title)
75 : AliDetector(name,title)
78 // Default constructor
82 // Allocate the array of hits
83 fHits = new TClonesArray("AliPMDhit", 405);
84 gAlice->GetMCApp()->AddHitList(fHits);
86 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
110 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
114 fLoader = new AliPMDLoader(GetName(),topfoldername);
118 cout<<"Success"<<endl;
122 cout<<"Failure"<<endl;
131 // Default constructor
137 //_____________________________________________________________________________
138 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
143 TClonesArray &lhits = *fHits;
144 AliPMDhit *newcell, *curcell;
145 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
146 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
147 // vol[4],vol[5],vol[6],vol[7]);
149 newcell = new AliPMDhit(fIshunt, track, vol, hits);
151 for (i=0; i<fNhits; i++) {
153 // See if this cell has already been hit
154 curcell=(AliPMDhit*) lhits[i];
155 if (*curcell==*newcell) {
156 // printf("Cell with same numbers found\n") ; curcell->Print();
157 *curcell = *curcell+*newcell;
158 // printf("Cell after addition\n") ; curcell->Print();
163 new(lhits[fNhits++]) AliPMDhit(newcell);
167 //_____________________________________________________________________________
168 void AliPMD::BuildGeometry()
171 // Build simple ROOT TNode geometry for event display
175 const int kColorPMD = kRed;
178 top=gAlice->GetGeometry()->GetNode("alice");
181 new TBRIK("S_PMD","PMD box","void",300,300,5);
183 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
184 node->SetLineColor(kColorPMD);
188 //_____________________________________________________________________________
189 Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t ) const
192 // Distance from mouse to detector on the screen
198 //_____________________________________________________________________________
199 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
202 // Set PMD parameters
210 //_____________________________________________________________________________
211 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
214 // Set PMD parameters
223 //_____________________________________________________________________________
224 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
227 // Set geometry parameters
234 //_____________________________________________________________________________
235 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
246 //_____________________________________________________________________________
247 void AliPMD::StepManager()
250 // Called at every step in PMD
254 void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
257 // Add a PMD reconstructed hit to the list
259 TClonesArray &lrecpoints = *fRecPoints;
260 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
263 void AliPMD::MakeBranch(Option_t* option)
265 // Create Tree branches for the PMD
267 const char *cR = strstr(option,"R");
268 const char *cH = strstr(option,"H");
269 if (cH && fLoader->TreeH() && (fHits == 0x0))
270 fHits = new TClonesArray("AliPMDhit", 405);
272 AliDetector::MakeBranch(option);
274 if (cR && fLoader->TreeR()) {
275 printf("Make Branch - TreeR address %p\n",(void*)fLoader->TreeR());
277 const Int_t kBufferSize = 4000;
280 sprintf(branchname,"%sRecPoints",GetName());
281 if (fRecPoints == 0x0) {
282 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
284 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
289 void AliPMD::SetTreeAddress()
291 // Set branch address for the TreeR
294 if (fLoader->TreeH() && fHits==0x0)
295 fHits = new TClonesArray("AliPMDhit", 405);
297 AliDetector::SetTreeAddress();
300 TTree *treeR = fLoader->TreeR();
302 sprintf(branchname,"%s",GetName());
304 branch = treeR->GetBranch(branchname);
307 if (fRecPoints == 0x0) {
308 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
310 branch->SetAddress(&fRecPoints);
315 void AliPMD::ResetHits()
318 // Reset number of hits and the hits array
320 AliDetector::ResetHits();
322 if (fRecPoints) fRecPoints->Clear();
324 //____________________________________________________________________________
325 void AliPMD::Hits2SDigits()
327 // create summable digits
329 AliRunLoader* runLoader = fLoader->GetRunLoader();
330 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
331 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
333 pmdDigitizer->SetZPosition(361.5);
335 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
336 pmdDigitizer->Hits2SDigits(iEvent);
338 fLoader->UnloadHits();
339 fLoader->UnloadSDigits();
342 //____________________________________________________________________________
343 void AliPMD::SDigits2Digits()
345 // creates sdigits to digits
347 //____________________________________________________________________________
348 void AliPMD::Hits2Digits()
352 AliRunLoader* runLoader = fLoader->GetRunLoader();
353 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
354 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
356 pmdDigitizer->SetZPosition(361.5);
358 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
359 pmdDigitizer->Hits2Digits(iEvent);
361 fLoader->UnloadHits();
362 fLoader->UnloadDigits();
366 // ---------------------------------------------------------------------------
367 AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager) const
369 return new AliPMDDigitizer(manager);
371 // ---------------------------------------------------------------------------