Set fRecPoints to zero in default constructor.
[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
16/*
17$Log$
d2c4ec78 18Revision 1.9 2000/10/30 09:03:59 morsch
19Prototype for PMD reconstructed hits (AliPMDRecPoint) added.
20
4fa198c6 21Revision 1.8 2000/10/20 06:24:40 fca
22Put the PMD at the right position in the event display
23
d651cc98 24Revision 1.7 2000/10/02 21:28:12 fca
25Removal of useless dependecies via forward declarations
26
94de3818 27Revision 1.6 2000/01/19 17:17:06 fca
28Introducing a list of lists of hits -- more hits allowed for detector now
29
1cedd08a 30Revision 1.5 1999/09/29 09:24:27 fca
31Introduction of the Copyright and cvs Log
32
4c039060 33*/
34
fe4da5cc 35///////////////////////////////////////////////////////////////////////////////
6edc06da 36//
fe4da5cc 37// //
38// Photon Multiplicity Detector //
39// This class contains the basic functions for the Photon Multiplicity //
40// Detector. Functions specific to one particular geometry are //
41// contained in the derived classes //
42// //
43//Begin_Html
44/*
1439f98e 45<img src="picts/AliPMDClass.gif">
fe4da5cc 46</pre>
47<br clear=left>
48<font size=+2 color=red>
49<p>The responsible person for this module is
50<a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
51</font>
52<pre>
53*/
54//End_Html
55// //
56///////////////////////////////////////////////////////////////////////////////
57
58#include <TBRIK.h>
59#include <TNode.h>
4fa198c6 60#include <TTree.h>
94de3818 61#include <TGeometry.h>
4fa198c6 62#include <TClonesArray.h>
94de3818 63
fe4da5cc 64#include "AliPMD.h"
65#include "AliRun.h"
6edc06da 66#include "AliMC.h"
fe4da5cc 67#include "AliConst.h"
4fa198c6 68#include "AliPMDRecPoint.h"
69
fe4da5cc 70ClassImp(AliPMD)
71
72//_____________________________________________________________________________
73AliPMD::AliPMD()
74{
75 //
76 // Default constructor
77 //
78 fIshunt = 0;
d2c4ec78 79 fRecPoints = NULL;
fe4da5cc 80}
81
82//_____________________________________________________________________________
83AliPMD::AliPMD(const char *name, const char *title)
84 : AliDetector(name,title)
85{
86 //
87 // Default constructor
88 //
89
90 //
91 // Allocate the array of hits
92 fHits = new TClonesArray("AliPMDhit", 405);
1cedd08a 93 gAlice->AddHitList(fHits);
4fa198c6 94
95 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
96 fNRecPoints = 0;
fe4da5cc 97
4fa198c6 98
fe4da5cc 99 fIshunt = 1;
100
101 fPar[0] = 1;
102 fPar[1] = 1;
103 fPar[2] = 0.8;
104 fPar[3] = 0.02;
105 fIn[0] = 6;
106 fIn[1] = 20;
107 fIn[2] = 600;
108 fIn[3] = 27;
109 fIn[4] = 27;
110 fGeo[0] = 0;
111 fGeo[1] = 0.2;
112 fGeo[2] = 4;
113 fPadSize[0] = 0.8;
114 fPadSize[1] = 1.0;
115 fPadSize[2] = 1.2;
116 fPadSize[3] = 1.5;
117}
118
4fa198c6 119AliPMD::~AliPMD()
120{
121 //
122 // Default constructor
123 //
124 delete fRecPoints;
125 fNRecPoints=0;
126}
127
fe4da5cc 128//_____________________________________________________________________________
129void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
130{
131 //
132 // Add a PMD hit
133 //
134 TClonesArray &lhits = *fHits;
135 AliPMDhit *newcell, *curcell;
6edc06da 136// printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d\n",
137// hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3]);
fe4da5cc 138 newcell = new AliPMDhit(fIshunt, track, vol, hits);
139 Int_t i;
140 for (i=0; i<fNhits; i++) {
141 //
142 // See if this cell has already been hit
143 curcell=(AliPMDhit*) lhits[i];
144 if (*curcell==*newcell) {
6edc06da 145// printf("Cell with same numbers found\n") ; curcell->Print();
fe4da5cc 146 *curcell = *curcell+*newcell;
6edc06da 147// printf("Cell after addition\n") ; curcell->Print();
fe4da5cc 148 delete newcell;
149 return;
150 }
151 }
152 new(lhits[fNhits++]) AliPMDhit(newcell);
153 delete newcell;
154}
155
156//_____________________________________________________________________________
157void AliPMD::BuildGeometry()
158{
159 //
160 // Build simple ROOT TNode geometry for event display
161 //
162
163 TNode *Node, *Top;
164 const int kColorPMD = kRed;
165
166 //
167 Top=gAlice->GetGeometry()->GetNode("alice");
168
169 // PMD
170 new TBRIK("S_PMD","PMD box","void",300,300,5);
171 Top->cd();
d651cc98 172 Node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
fe4da5cc 173 Node->SetLineColor(kColorPMD);
174 fNodes->Add(Node);
175}
176
177//_____________________________________________________________________________
178Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t )
179{
180 //
181 // Distance from mouse to detector on the screen
182 // dummy routine
183 //
184 return 9999;
185}
186
187//_____________________________________________________________________________
188void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
189{
190 //
191 // Set PMD parameters
192 //
193 fPar[0] = p1;
194 fPar[1] = p2;
195 fPar[2] = p3;
196 fPar[3] = p4;
197}
198
199//_____________________________________________________________________________
200void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
201{
202 //
203 // Set PMD parameters
204 //
205 fIn[0] = p1;
206 fIn[1] = p2;
207 fIn[2] = p3;
208 fIn[3] = p4;
209 fIn[4] = p5;
210}
211
212//_____________________________________________________________________________
213void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
214{
215 //
216 // Set geometry parameters
217 //
218 fGeo[0] = p1;
219 fGeo[1] = p2;
220 fGeo[2] = p3;
221}
222
223//_____________________________________________________________________________
224void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
225{
226 //
227 // Set pad size
228 //
229 fPadSize[0] = p1;
230 fPadSize[1] = p2;
231 fPadSize[2] = p3;
232 fPadSize[3] = p4;
233}
234
235//_____________________________________________________________________________
236void AliPMD::StepManager()
237{
238 //
239 // Called at every step in PMD
240 //
241}
242
4fa198c6 243void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
244{
245 //
246 // Add a PMD reconstructed hit to the list
247 //
248 TClonesArray &lrecpoints = *fRecPoints;
249 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
250}
251
252void AliPMD::MakeBranch(Option_t* option)
253{
254 // Create Tree branches for the PMD
255 printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
256
257 const Int_t kBufferSize = 4000;
258 char branchname[30];
259
260 AliDetector::MakeBranch(option);
261
262 sprintf(branchname,"%sRecPoints",GetName());
263 if (fRecPoints && gAlice->TreeR()) {
264 gAlice->TreeR()->Branch(branchname, &fRecPoints, kBufferSize);
265 printf("Making Branch %s for reconstructed hits\n",branchname);
266 }
267}
268
269
270void AliPMD::SetTreeAddress()
271{
272 // Set branch address for the TreeR
273 char branchname[30];
274 AliDetector::SetTreeAddress();
275
276 TBranch *branch;
277 TTree *treeR = gAlice->TreeR();
278
279 sprintf(branchname,"%s",GetName());
280 if (treeR && fRecPoints) {
281 branch = treeR->GetBranch(branchname);
282 if (branch) branch->SetAddress(&fRecPoints);
283 }
284}
285
286void AliPMD::ResetHits()
287{
288 //
289 // Reset number of hits and the hits array
290 //
291 fNRecPoints = 0;
292 if (fRecPoints) fRecPoints->Clear();
293}
294
fe4da5cc 295///////////////////////////////////////////////////////////////////////////////
296// //
297// Photon Multiplicity Detector Version 1 //
298// //
299//Begin_Html
300/*
1439f98e 301<img src="picts/AliPMDv1Class.gif">
fe4da5cc 302*/
303//End_Html
304// //
305///////////////////////////////////////////////////////////////////////////////
306
4fa198c6 307
308
fe4da5cc 309ClassImp(AliPMDhit)
310
311//_____________________________________________________________________________
6edc06da 312AliPMDhit::AliPMDhit(Int_t shunt,Int_t track, Int_t *vol, Float_t *hits):
fe4da5cc 313 AliHit(shunt, track)
314{
315 //
316 // Add a PMD hit
317 //
318 Int_t i;
6edc06da 319 for (i=0;i<5;i++) fVolume[i] = vol[i];
fe4da5cc 320 fX=hits[0];
321 fY=hits[1];
322 fZ=hits[2];
323 fEnergy=hits[3];
324}
6edc06da 325