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 "AliPMDDDLRawData.h"
62 //_____________________________________________________________________________
66 // Default constructor
74 //_____________________________________________________________________________
75 AliPMD::AliPMD(const char *name, const char *title)
76 : AliDetector(name,title)
79 // Default constructor
83 // Allocate the array of hits
84 fHits = new TClonesArray("AliPMDhit", 405);
85 gAlice->GetMCApp()->AddHitList(fHits);
87 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
111 AliLoader* AliPMD::MakeLoader(const char* topfoldername)
115 fLoader = new AliPMDLoader(GetName(),topfoldername);
119 cout<<"Success"<<endl;
123 cout<<"Failure"<<endl;
132 // Default constructor
138 //_____________________________________________________________________________
139 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
144 TClonesArray &lhits = *fHits;
145 AliPMDhit *newcell, *curcell;
146 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
147 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
148 // vol[4],vol[5],vol[6],vol[7]);
150 newcell = new AliPMDhit(fIshunt, track, vol, hits);
152 for (i=0; i<fNhits; i++) {
154 // See if this cell has already been hit
155 curcell=(AliPMDhit*) lhits[i];
156 if (*curcell==*newcell) {
157 // printf("Cell with same numbers found\n") ; curcell->Print();
158 *curcell = *curcell+*newcell;
159 // printf("Cell after addition\n") ; curcell->Print();
164 new(lhits[fNhits++]) AliPMDhit(newcell);
168 //_____________________________________________________________________________
169 void AliPMD::BuildGeometry()
172 // Build simple ROOT TNode geometry for event display
176 const int kColorPMD = kRed;
179 top=gAlice->GetGeometry()->GetNode("alice");
182 new TBRIK("S_PMD","PMD box","void",300,300,5);
184 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
185 node->SetLineColor(kColorPMD);
189 //_____________________________________________________________________________
190 Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t ) const
193 // Distance from mouse to detector on the screen
199 //_____________________________________________________________________________
200 void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
203 // Set PMD parameters
211 //_____________________________________________________________________________
212 void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
215 // Set PMD parameters
224 //_____________________________________________________________________________
225 void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
228 // Set geometry parameters
235 //_____________________________________________________________________________
236 void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
247 //_____________________________________________________________________________
248 void AliPMD::StepManager()
251 // Called at every step in PMD
255 void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
258 // Add a PMD reconstructed hit to the list
260 TClonesArray &lrecpoints = *fRecPoints;
261 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
264 void AliPMD::MakeBranch(Option_t* option)
266 // Create Tree branches for the PMD
268 const char *cR = strstr(option,"R");
269 const char *cH = strstr(option,"H");
270 if (cH && fLoader->TreeH() && (fHits == 0x0))
271 fHits = new TClonesArray("AliPMDhit", 405);
273 AliDetector::MakeBranch(option);
275 if (cR && fLoader->TreeR()) {
276 printf("Make Branch - TreeR address %p\n",(void*)fLoader->TreeR());
278 const Int_t kBufferSize = 4000;
281 sprintf(branchname,"%sRecPoints",GetName());
282 if (fRecPoints == 0x0) {
283 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
285 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
290 void AliPMD::SetTreeAddress()
292 // Set branch address for the TreeR
295 if (fLoader->TreeH() && fHits==0x0)
296 fHits = new TClonesArray("AliPMDhit", 405);
298 AliDetector::SetTreeAddress();
301 TTree *treeR = fLoader->TreeR();
303 sprintf(branchname,"%s",GetName());
305 branch = treeR->GetBranch(branchname);
308 if (fRecPoints == 0x0) {
309 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
311 branch->SetAddress(&fRecPoints);
316 void AliPMD::ResetHits()
319 // Reset number of hits and the hits array
321 AliDetector::ResetHits();
323 if (fRecPoints) fRecPoints->Clear();
325 //____________________________________________________________________________
326 void AliPMD::Hits2SDigits()
328 // create summable digits
330 AliRunLoader* runLoader = fLoader->GetRunLoader();
331 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
332 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
334 pmdDigitizer->SetZPosition(361.5);
336 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
337 pmdDigitizer->Hits2SDigits(iEvent);
339 fLoader->UnloadHits();
340 fLoader->UnloadSDigits();
343 //____________________________________________________________________________
344 void AliPMD::SDigits2Digits()
346 // creates sdigits to digits
348 //____________________________________________________________________________
349 void AliPMD::Hits2Digits()
353 AliRunLoader* runLoader = fLoader->GetRunLoader();
354 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
355 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
357 pmdDigitizer->SetZPosition(361.5);
359 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
360 pmdDigitizer->Hits2Digits(iEvent);
362 fLoader->UnloadHits();
363 fLoader->UnloadDigits();
367 // ---------------------------------------------------------------------------
368 AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager) const
370 return new AliPMDDigitizer(manager);
372 // ---------------------------------------------------------------------------
373 void AliPMD::Digits2Raw()
375 // convert digits of the current event to raw data
377 fLoader->LoadDigits();
378 TTree* digits = fLoader->TreeD();
380 Error("Digits2Raw", "no digits tree");
384 AliPMDDDLRawData rawWriter;
385 rawWriter.WritePMDRawData(digits);
387 fLoader->UnloadDigits();