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