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