]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMD.cxx
CreateDigitizer made const (T.Kuhr)
[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
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
6edc06da 19//
fe4da5cc 20// //
21// Photon Multiplicity Detector //
22// This class contains the basic functions for the Photon Multiplicity //
23// Detector. Functions specific to one particular geometry are //
24// contained in the derived classes //
25// //
26//Begin_Html
27/*
1439f98e 28<img src="picts/AliPMDClass.gif">
fe4da5cc 29</pre>
30<br clear=left>
31<font size=+2 color=red>
32<p>The responsible person for this module is
33<a href="mailto:sub@vecdec.veccal.ernet.in">Subhasis Chattopadhyay</a>.
34</font>
35<pre>
36*/
37//End_Html
38// //
39///////////////////////////////////////////////////////////////////////////////
40
41#include <TBRIK.h>
4fa198c6 42#include <TClonesArray.h>
2ab0c725 43#include <TFile.h>
88cb7938 44#include <TGeometry.h>
45#include <TNode.h>
46#include <TTree.h>
47#include <TVirtualMC.h>
94de3818 48
fe4da5cc 49#include "AliConst.h"
88cb7938 50#include "AliLoader.h"
895a906e 51#include "AliPMDLoader.h"
88cb7938 52#include "AliPMD.h"
4fa198c6 53#include "AliPMDRecPoint.h"
88cb7938 54#include "AliRun.h"
5d12ce38 55#include "AliMC.h"
85a5290f 56#include "AliPMDDigitizer.h"
895a906e 57#include "AliPMDhit.h"
fe743527 58#include "AliPMDClusterFinder.h"
59#include "AliPMDtracker.h"
60#include "AliESDPmdTrack.h"
61#include "AliESD.h"
4fa198c6 62
fe4da5cc 63ClassImp(AliPMD)
64
65//_____________________________________________________________________________
66AliPMD::AliPMD()
67{
68 //
69 // Default constructor
70 //
71 fIshunt = 0;
0cc62300 72
427f8f1d 73 fRecPoints = 0;
2ab0c725 74
fe4da5cc 75}
76
77//_____________________________________________________________________________
78AliPMD::AliPMD(const char *name, const char *title)
79 : AliDetector(name,title)
80{
81 //
82 // Default constructor
83 //
84
85 //
86 // Allocate the array of hits
87 fHits = new TClonesArray("AliPMDhit", 405);
5d12ce38 88 gAlice->GetMCApp()->AddHitList(fHits);
4fa198c6 89
90 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
91 fNRecPoints = 0;
fe4da5cc 92
4fa198c6 93
4187e4de 94 fIshunt = 0;
fe4da5cc 95
96 fPar[0] = 1;
97 fPar[1] = 1;
98 fPar[2] = 0.8;
99 fPar[3] = 0.02;
100 fIn[0] = 6;
101 fIn[1] = 20;
102 fIn[2] = 600;
103 fIn[3] = 27;
104 fIn[4] = 27;
105 fGeo[0] = 0;
106 fGeo[1] = 0.2;
107 fGeo[2] = 4;
108 fPadSize[0] = 0.8;
109 fPadSize[1] = 1.0;
110 fPadSize[2] = 1.2;
111 fPadSize[3] = 1.5;
112}
113
1661e612 114AliLoader* AliPMD::MakeLoader(const char* topfoldername)
115{
895a906e 116 // Makes PMD Loader
1661e612 117
895a906e 118 fLoader = new AliPMDLoader(GetName(),topfoldername);
1661e612 119
895a906e 120 if (fLoader)
121 {
122 cout<<"Success"<<endl;
123 }
124 else
125 {
126 cout<<"Failure"<<endl;
127 }
1661e612 128
895a906e 129 return fLoader;
1661e612 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;
41c97e7a 149 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
150 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
151 // vol[4],vol[5],vol[6],vol[7]);
152
fe4da5cc 153 newcell = new AliPMDhit(fIshunt, track, vol, hits);
154 Int_t i;
155 for (i=0; i<fNhits; i++) {
156 //
157 // See if this cell has already been hit
158 curcell=(AliPMDhit*) lhits[i];
159 if (*curcell==*newcell) {
6edc06da 160// printf("Cell with same numbers found\n") ; curcell->Print();
fe4da5cc 161 *curcell = *curcell+*newcell;
6edc06da 162// printf("Cell after addition\n") ; curcell->Print();
fe4da5cc 163 delete newcell;
164 return;
165 }
166 }
167 new(lhits[fNhits++]) AliPMDhit(newcell);
168 delete newcell;
169}
170
171//_____________________________________________________________________________
172void AliPMD::BuildGeometry()
173{
174 //
175 // Build simple ROOT TNode geometry for event display
176 //
177
895a906e 178 TNode *node, *top;
fe4da5cc 179 const int kColorPMD = kRed;
180
181 //
895a906e 182 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 183
184 // PMD
185 new TBRIK("S_PMD","PMD box","void",300,300,5);
895a906e 186 top->cd();
187 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
188 node->SetLineColor(kColorPMD);
189 fNodes->Add(node);
fe4da5cc 190}
191
192//_____________________________________________________________________________
895a906e 193Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 194{
195 //
196 // Distance from mouse to detector on the screen
197 // dummy routine
198 //
199 return 9999;
200}
201
202//_____________________________________________________________________________
203void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
204{
205 //
206 // Set PMD parameters
207 //
208 fPar[0] = p1;
209 fPar[1] = p2;
210 fPar[2] = p3;
211 fPar[3] = p4;
212}
213
214//_____________________________________________________________________________
215void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
216{
217 //
218 // Set PMD parameters
219 //
220 fIn[0] = p1;
221 fIn[1] = p2;
222 fIn[2] = p3;
223 fIn[3] = p4;
224 fIn[4] = p5;
225}
226
227//_____________________________________________________________________________
228void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
229{
230 //
231 // Set geometry parameters
232 //
233 fGeo[0] = p1;
234 fGeo[1] = p2;
235 fGeo[2] = p3;
236}
237
238//_____________________________________________________________________________
239void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
240{
241 //
242 // Set pad size
243 //
244 fPadSize[0] = p1;
245 fPadSize[1] = p2;
246 fPadSize[2] = p3;
247 fPadSize[3] = p4;
248}
249
250//_____________________________________________________________________________
251void AliPMD::StepManager()
252{
253 //
254 // Called at every step in PMD
255 //
256}
257
4fa198c6 258void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
259{
260 //
261 // Add a PMD reconstructed hit to the list
262 //
263 TClonesArray &lrecpoints = *fRecPoints;
264 new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
265}
266
88cb7938 267void AliPMD::MakeBranch(Option_t* option)
4fa198c6 268{
269 // Create Tree branches for the PMD
4fa198c6 270
5cf7bbad 271 const char *cR = strstr(option,"R");
88cb7938 272 const char *cH = strstr(option,"H");
273 if (cH && fLoader->TreeH() && (fHits == 0x0))
274 fHits = new TClonesArray("AliPMDhit", 405);
2ab0c725 275
88cb7938 276 AliDetector::MakeBranch(option);
4fa198c6 277
88cb7938 278 if (cR && fLoader->TreeR()) {
279 printf("Make Branch - TreeR address %p\n",fLoader->TreeR());
2ab0c725 280
281 const Int_t kBufferSize = 4000;
282 char branchname[30];
283
284 sprintf(branchname,"%sRecPoints",GetName());
88cb7938 285 if (fRecPoints == 0x0) {
286 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
2ab0c725 287 }
88cb7938 288 MakeBranchInTree(fLoader->TreeR(), branchname, &fRecPoints, kBufferSize,0);
2ab0c725 289 }
4fa198c6 290}
291
292
293void AliPMD::SetTreeAddress()
294{
295 // Set branch address for the TreeR
296 char branchname[30];
88cb7938 297
1da4d0d9 298 if (fLoader->TreeH() && fHits==0x0)
88cb7938 299 fHits = new TClonesArray("AliPMDhit", 405);
300
4fa198c6 301 AliDetector::SetTreeAddress();
302
303 TBranch *branch;
88cb7938 304 TTree *treeR = fLoader->TreeR();
4fa198c6 305
306 sprintf(branchname,"%s",GetName());
88cb7938 307 if (treeR) {
308 branch = treeR->GetBranch(branchname);
309 if (branch)
310 {
311 if (fRecPoints == 0x0) {
312 fRecPoints = new TClonesArray("AliPMDRecPoint",10000);
313 }
314 branch->SetAddress(&fRecPoints);
315 }
4fa198c6 316 }
317}
318
319void AliPMD::ResetHits()
320{
321 //
322 // Reset number of hits and the hits array
323 //
d3b63a89 324 AliDetector::ResetHits();
325 fNRecPoints = 0;
326 if (fRecPoints) fRecPoints->Clear();
4fa198c6 327}
85a5290f 328//____________________________________________________________________________
329void AliPMD::Hits2SDigits()
330{
331// create summable digits
332
333 AliRunLoader* runLoader = fLoader->GetRunLoader();
334 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
335 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
336 "HS");
40be8527 337 pmdDigitizer->SetZPosition(361.5);
85a5290f 338
339 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
340 pmdDigitizer->Hits2SDigits(iEvent);
341 }
342 fLoader->UnloadHits();
343 fLoader->UnloadSDigits();
344 delete pmdDigitizer;
345}
53043784 346//____________________________________________________________________________
347void AliPMD::SDigits2Digits()
348{
349 // creates sdigits to digits
350}
351//____________________________________________________________________________
352void AliPMD::Hits2Digits()
353{
354// create digits
355
356 AliRunLoader* runLoader = fLoader->GetRunLoader();
357 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
358 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
359 "HD");
360 pmdDigitizer->SetZPosition(361.5);
361
362 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
363 pmdDigitizer->Hits2Digits(iEvent);
364 }
365 fLoader->UnloadHits();
366 fLoader->UnloadDigits();
367 delete pmdDigitizer;
368
369}
370//____________________________________________________________________________
fe743527 371void AliPMD::Reconstruct() const
372{
373// create reconstructed points
374
375 AliRunLoader* runLoader = fLoader->GetRunLoader();
376 AliPMDClusterFinder *pmdClus = new AliPMDClusterFinder();
377 pmdClus->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),"DR");
378 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++)
379 {
380 pmdClus->Digits2RecPoints(iEvent);
381 }
382
383 fLoader->UnloadRecPoints();
384 fLoader->UnloadDigits();
53043784 385
fe743527 386 delete pmdClus;
387
388}
389// ---------------------------------------------------------------------------
390void AliPMD::FillESD(AliESD* esd) const
391{
392
393 AliRunLoader* runLoader = fLoader->GetRunLoader();
394 fLoader->LoadRecPoints("READ");
395 Int_t ievent = runLoader->GetEventNumber();
396 runLoader->GetEvent(ievent);
397 AliLoader *pmdloader = runLoader->GetLoader("PMDLoader");
398 TTree *treeR = pmdloader->TreeR();
399 AliPMDtracker *pmdtracker = new AliPMDtracker();
400 pmdtracker->LoadClusters(treeR);
401 pmdtracker->Clusters2Tracks(esd);
402 delete pmdtracker;
403
404 fLoader->UnloadRecPoints();
405}
406
407// ---------------------------------------------------------------------------
53043784 408AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager)
409{
410 return new AliPMDDigitizer(manager);
411}
fe743527 412// ---------------------------------------------------------------------------
413
53043784 414