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