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"
58 #include "AliPMDClusterFinder.h"
59 #include "AliPMDtracker.h"
60 #include "AliESDPmdTrack.h"
65 //_____________________________________________________________________________
69 // Default constructor
77 //_____________________________________________________________________________
78 AliPMD::AliPMD(const char *name, const char *title)
79 : AliDetector(name,title)
82 // Default constructor
86 // Allocate the array of hits
87 fHits = new TClonesArray("AliPMDhit", 405);
88 gAlice->GetMCApp()->AddHitList(fHits);
90 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
114 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
118 fLoader = new AliPMDLoader(GetName(),topfoldername);
122 cout<<"Success"<<endl;
126 cout<<"Failure"<<endl;
135 // Default constructor
141 //_____________________________________________________________________________
142 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
147 TClonesArray &lhits = *fHits;
148 AliPMDhit *newcell, *curcell;
149 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
150 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
151 // vol[4],vol[5],vol[6],vol[7]);
153 newcell = new AliPMDhit(fIshunt, track, vol, hits);
155 for (i=0; i<fNhits; i++) {
157 // See if this cell has already been hit
158 curcell=(AliPMDhit*) lhits[i];
159 if (*curcell==*newcell) {
160 // printf("Cell with same numbers found\n") ; curcell->Print();
161 *curcell = *curcell+*newcell;
162 // printf("Cell after addition\n") ; curcell->Print();
167 new(lhits[fNhits++]) AliPMDhit(newcell);
171 //_____________________________________________________________________________
172 void AliPMD::BuildGeometry()
175 // Build simple ROOT TNode geometry for event display
179 const int kColorPMD = kRed;
182 top=gAlice->GetGeometry()->GetNode("alice");
185 new TBRIK("S_PMD","PMD box","void",300,300,5);
187 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
188 node->SetLineColor(kColorPMD);
192 //_____________________________________________________________________________
193 Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t ) const
196 // Distance from mouse to detector on the screen
202 //_____________________________________________________________________________
203 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
206 // Set PMD parameters
214 //_____________________________________________________________________________
215 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
218 // Set PMD parameters
227 //_____________________________________________________________________________
228 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
231 // Set geometry parameters
238 //_____________________________________________________________________________
239 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
250 //_____________________________________________________________________________
251 void AliPMD::StepManager()
254 // Called at every step in PMD
258 void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
261 // Add a PMD reconstructed hit to the list
263 TClonesArray &lrecpoints = *fRecPoints;
264 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
267 void AliPMD::MakeBranch(Option_t* option)
269 // Create Tree branches for the PMD
271 const char *cR = strstr(option,"R");
272 const char *cH = strstr(option,"H");
273 if (cH && fLoader->TreeH() && (fHits == 0x0))
274 fHits = new TClonesArray("AliPMDhit", 405);
276 AliDetector::MakeBranch(option);
278 if (cR && fLoader->TreeR()) {
279 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
281 const Int_t kBufferSize = 4000;
284 sprintf(branchname,"%sRecPoints",GetName());
285 if (fRecPoints == 0x0) {
286 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
288 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
293 void AliPMD::SetTreeAddress()
295 // Set branch address for the TreeR
298 if (fLoader->TreeH() && fHits==0x0)
299 fHits = new TClonesArray("AliPMDhit", 405);
301 AliDetector::SetTreeAddress();
304 TTree *treeR = fLoader->TreeR();
306 sprintf(branchname,"%s",GetName());
308 branch = treeR->GetBranch(branchname);
311 if (fRecPoints == 0x0) {
312 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
314 branch->SetAddress(&fRecPoints);
319 void AliPMD::ResetHits()
322 // Reset number of hits and the hits array
324 AliDetector::ResetHits();
326 if (fRecPoints) fRecPoints->Clear();
328 //____________________________________________________________________________
329 void AliPMD::Hits2SDigits()
331 // create summable digits
333 AliRunLoader* runLoader = fLoader->GetRunLoader();
334 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
335 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
337 pmdDigitizer->SetZPosition(361.5);
339 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
340 pmdDigitizer->Hits2SDigits(iEvent);
342 fLoader->UnloadHits();
343 fLoader->UnloadSDigits();
346 //____________________________________________________________________________
347 void AliPMD::SDigits2Digits()
349 // creates sdigits to digits
351 //____________________________________________________________________________
352 void AliPMD::Hits2Digits()
356 AliRunLoader* runLoader = fLoader->GetRunLoader();
357 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
358 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
360 pmdDigitizer->SetZPosition(361.5);
362 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
363 pmdDigitizer->Hits2Digits(iEvent);
365 fLoader->UnloadHits();
366 fLoader->UnloadDigits();
370 //____________________________________________________________________________
371 void AliPMD::Reconstruct() const
373 // create reconstructed points
375 AliRunLoader* runLoader = fLoader->GetRunLoader();
376 AliPMDClusterFinder *pmdClus = new AliPMDClusterFinder();
377 pmdClus->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),"DR");
378 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++)
380 pmdClus->Digits2RecPoints(iEvent);
383 fLoader->UnloadRecPoints();
384 fLoader->UnloadDigits();
389 // ---------------------------------------------------------------------------
390 void AliPMD::FillESD(AliESD* esd) const
393 AliRunLoader* runLoader = fLoader->GetRunLoader();
394 fLoader->LoadRecPoints("READ");
395 Int_t ievent = runLoader->GetEventNumber();
396 runLoader->GetEvent(ievent);
397 AliLoader *pmdloader = runLoader->GetLoader("PMDLoader");
398 TTree *treeR = pmdloader->TreeR();
399 AliPMDtracker *pmdtracker = new AliPMDtracker();
400 pmdtracker->LoadClusters(treeR);
401 pmdtracker->Clusters2Tracks(esd);
404 fLoader->UnloadRecPoints();
407 // ---------------------------------------------------------------------------
408 AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager)
410 return new AliPMDDigitizer(manager);
412 // ---------------------------------------------------------------------------