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