]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMD.cxx
fVolume dimension changed 5->8
[u/mrichter/AliRoot.git] / PMD / AliPMD.cxx
CommitLineData
4c039060 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 **************************************************************************/
15
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
6edc06da 19//
fe4da5cc 20// //
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 //
25// //
26//Begin_Html
27/*
1439f98e 28<img src="picts/AliPMDClass.gif">
fe4da5cc 29</pre>
30<br clear=left>
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>.
34</font>
35<pre>
36*/
37//End_Html
38// //
39///////////////////////////////////////////////////////////////////////////////
40
41#include <TBRIK.h>
4fa198c6 42#include <TClonesArray.h>
2ab0c725 43#include <TFile.h>
88cb7938 44#include <TGeometry.h>
45#include <TNode.h>
46#include <TTree.h>
47#include <TVirtualMC.h>
94de3818 48
fe4da5cc 49#include "AliConst.h"
88cb7938 50#include "AliLoader.h"
51#include "AliPMD.h"
4fa198c6 52#include "AliPMDRecPoint.h"
88cb7938 53#include "AliRun.h"
4fa198c6 54
fe4da5cc 55ClassImp(AliPMD)
56
57//_____________________________________________________________________________
58AliPMD::AliPMD()
59{
60 //
61 // Default constructor
62 //
63 fIshunt = 0;
0cc62300 64
427f8f1d 65 fRecPoints = 0;
2ab0c725 66
fe4da5cc 67}
68
69//_____________________________________________________________________________
70AliPMD::AliPMD(const char *name, const char *title)
71 : AliDetector(name,title)
72{
73 //
74 // Default constructor
75 //
76
77 //
78 // Allocate the array of hits
79 fHits = new TClonesArray("AliPMDhit", 405);
1cedd08a 80 gAlice->AddHitList(fHits);
4fa198c6 81
82 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
83 fNRecPoints = 0;
fe4da5cc 84
4fa198c6 85
4187e4de 86 fIshunt = 0;
fe4da5cc 87
88 fPar[0] = 1;
89 fPar[1] = 1;
90 fPar[2] = 0.8;
91 fPar[3] = 0.02;
92 fIn[0] = 6;
93 fIn[1] = 20;
94 fIn[2] = 600;
95 fIn[3] = 27;
96 fIn[4] = 27;
97 fGeo[0] = 0;
98 fGeo[1] = 0.2;
99 fGeo[2] = 4;
100 fPadSize[0] = 0.8;
101 fPadSize[1] = 1.0;
102 fPadSize[2] = 1.2;
103 fPadSize[3] = 1.5;
104}
105
1661e612 106AliLoader* AliPMD::MakeLoader(const char* topfoldername)
107{
108 cout<<"AliPMD::MakeLoader ";
109
110 fLoader = new AliPMDLoader(GetName(),topfoldername);
111
112 if (fLoader)
113 {
114 cout<<"Success"<<endl;
115 }
116 else
117 {
118 cout<<"Failure"<<endl;
119 }
120
121 return fLoader;
122}
123
4fa198c6 124AliPMD::~AliPMD()
125{
126 //
127 // Default constructor
128 //
129 delete fRecPoints;
130 fNRecPoints=0;
131}
132
fe4da5cc 133//_____________________________________________________________________________
134void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
135{
136 //
137 // Add a PMD hit
138 //
139 TClonesArray &lhits = *fHits;
140 AliPMDhit *newcell, *curcell;
41c97e7a 141 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
142 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
143 // vol[4],vol[5],vol[6],vol[7]);
144
fe4da5cc 145 newcell = new AliPMDhit(fIshunt, track, vol, hits);
146 Int_t i;
147 for (i=0; i<fNhits; i++) {
148 //
149 // See if this cell has already been hit
150 curcell=(AliPMDhit*) lhits[i];
151 if (*curcell==*newcell) {
6edc06da 152// printf("Cell with same numbers found\n") ; curcell->Print();
fe4da5cc 153 *curcell = *curcell+*newcell;
6edc06da 154// printf("Cell after addition\n") ; curcell->Print();
fe4da5cc 155 delete newcell;
156 return;
157 }
158 }
159 new(lhits[fNhits++]) AliPMDhit(newcell);
160 delete newcell;
161}
162
163//_____________________________________________________________________________
164void AliPMD::BuildGeometry()
165{
166 //
167 // Build simple ROOT TNode geometry for event display
168 //
169
170 TNode *Node, *Top;
171 const int kColorPMD = kRed;
172
173 //
174 Top=gAlice->GetGeometry()->GetNode("alice");
175
176 // PMD
177 new TBRIK("S_PMD","PMD box","void",300,300,5);
178 Top->cd();
d651cc98 179 Node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
fe4da5cc 180 Node->SetLineColor(kColorPMD);
181 fNodes->Add(Node);
182}
183
184//_____________________________________________________________________________
185Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t )
186{
187 //
188 // Distance from mouse to detector on the screen
189 // dummy routine
190 //
191 return 9999;
192}
193
194//_____________________________________________________________________________
195void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
196{
197 //
198 // Set PMD parameters
199 //
200 fPar[0] = p1;
201 fPar[1] = p2;
202 fPar[2] = p3;
203 fPar[3] = p4;
204}
205
206//_____________________________________________________________________________
207void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
208{
209 //
210 // Set PMD parameters
211 //
212 fIn[0] = p1;
213 fIn[1] = p2;
214 fIn[2] = p3;
215 fIn[3] = p4;
216 fIn[4] = p5;
217}
218
219//_____________________________________________________________________________
220void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
221{
222 //
223 // Set geometry parameters
224 //
225 fGeo[0] = p1;
226 fGeo[1] = p2;
227 fGeo[2] = p3;
228}
229
230//_____________________________________________________________________________
231void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
232{
233 //
234 // Set pad size
235 //
236 fPadSize[0] = p1;
237 fPadSize[1] = p2;
238 fPadSize[2] = p3;
239 fPadSize[3] = p4;
240}
241
242//_____________________________________________________________________________
243void AliPMD::StepManager()
244{
245 //
246 // Called at every step in PMD
247 //
248}
249
4fa198c6 250void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
251{
252 //
253 // Add a PMD reconstructed hit to the list
254 //
255 TClonesArray &lrecpoints = *fRecPoints;
256 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
257}
258
88cb7938 259void AliPMD::MakeBranch(Option_t* option)
4fa198c6 260{
261 // Create Tree branches for the PMD
4fa198c6 262
5cf7bbad 263 const char *cR = strstr(option,"R");
88cb7938 264 const char *cH = strstr(option,"H");
265 if (cH && fLoader->TreeH() && (fHits == 0x0))
266 fHits = new TClonesArray("AliPMDhit", 405);
2ab0c725 267
88cb7938 268 AliDetector::MakeBranch(option);
4fa198c6 269
88cb7938 270 if (cR && fLoader->TreeR()) {
271 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
2ab0c725 272
273 const Int_t kBufferSize = 4000;
274 char branchname[30];
275
276 sprintf(branchname,"%sRecPoints",GetName());
88cb7938 277 if (fRecPoints == 0x0) {
278 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
2ab0c725 279 }
88cb7938 280 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
2ab0c725 281 }
4fa198c6 282}
283
284
285void AliPMD::SetTreeAddress()
286{
287 // Set branch address for the TreeR
288 char branchname[30];
88cb7938 289
1da4d0d9 290 if (fLoader->TreeH() && fHits==0x0)
88cb7938 291 fHits = new TClonesArray("AliPMDhit", 405);
292
4fa198c6 293 AliDetector::SetTreeAddress();
294
295 TBranch *branch;
88cb7938 296 TTree *treeR = fLoader->TreeR();
4fa198c6 297
298 sprintf(branchname,"%s",GetName());
88cb7938 299 if (treeR) {
300 branch = treeR->GetBranch(branchname);
301 if (branch)
302 {
303 if (fRecPoints == 0x0) {
304 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
305 }
306 branch->SetAddress(&fRecPoints);
307 }
4fa198c6 308 }
309}
310
311void AliPMD::ResetHits()
312{
313 //
314 // Reset number of hits and the hits array
315 //
d3b63a89 316 AliDetector::ResetHits();
317 fNRecPoints = 0;
318 if (fRecPoints) fRecPoints->Clear();
4fa198c6 319}
320
fe4da5cc 321///////////////////////////////////////////////////////////////////////////////
322// //
323// Photon Multiplicity Detector Version 1 //
324// //
325//Begin_Html
326/*
1439f98e 327<img src="picts/AliPMDv1Class.gif">
fe4da5cc 328*/
329//End_Html
330// //
331///////////////////////////////////////////////////////////////////////////////
332
4fa198c6 333
334
fe4da5cc 335ClassImp(AliPMDhit)
336
337//_____________________________________________________________________________
6edc06da 338AliPMDhit::AliPMDhit(Int_t shunt,Int_t track, Int_t *vol, Float_t *hits):
fe4da5cc 339 AliHit(shunt, track)
340{
341 //
342 // Add a PMD hit
343 //
344 Int_t i;
41c97e7a 345 for (i=0;i<8;i++) fVolume[i] = vol[i];
fe4da5cc 346 fX=hits[0];
347 fY=hits[1];
348 fZ=hits[2];
349 fEnergy=hits[3];
350}
6edc06da 351