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