]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PMD/AliPMD.cxx
macro to make ESD
[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>
88cb7938 43#include <TGeometry.h>
44#include <TNode.h>
45#include <TTree.h>
46#include <TVirtualMC.h>
94de3818 47
88cb7938 48#include "AliLoader.h"
895a906e 49#include "AliPMDLoader.h"
88cb7938 50#include "AliPMD.h"
88cb7938 51#include "AliRun.h"
5d12ce38 52#include "AliMC.h"
85a5290f 53#include "AliPMDDigitizer.h"
895a906e 54#include "AliPMDhit.h"
c39d2a93 55#include "AliPMDDDLRawData.h"
4fa198c6 56
fe4da5cc 57ClassImp(AliPMD)
58
59//_____________________________________________________________________________
60AliPMD::AliPMD()
61{
62 //
63 // Default constructor
64 //
65 fIshunt = 0;
0cc62300 66
fe4da5cc 67}
68
69//_____________________________________________________________________________
70AliPMD::AliPMD(const char *name, const char *title)
71 : AliDetector(name,title)
72{
73 //
74 // Default constructor
75 //
76
77 //
78 // Allocate the array of hits
79 fHits = new TClonesArray("AliPMDhit", 405);
5d12ce38 80 gAlice->GetMCApp()->AddHitList(fHits);
4fa198c6 81
4fa198c6 82
4187e4de 83 fIshunt = 0;
fe4da5cc 84
85 fPar[0] = 1;
86 fPar[1] = 1;
87 fPar[2] = 0.8;
88 fPar[3] = 0.02;
89 fIn[0] = 6;
90 fIn[1] = 20;
91 fIn[2] = 600;
92 fIn[3] = 27;
93 fIn[4] = 27;
94 fGeo[0] = 0;
95 fGeo[1] = 0.2;
96 fGeo[2] = 4;
97 fPadSize[0] = 0.8;
98 fPadSize[1] = 1.0;
99 fPadSize[2] = 1.2;
100 fPadSize[3] = 1.5;
101}
102
1661e612 103AliLoader* AliPMD::MakeLoader(const char* topfoldername)
104{
895a906e 105 // Makes PMD Loader
1661e612 106
895a906e 107 fLoader = new AliPMDLoader(GetName(),topfoldername);
1661e612 108
895a906e 109 if (fLoader)
110 {
111 cout<<"Success"<<endl;
112 }
113 else
114 {
115 cout<<"Failure"<<endl;
116 }
1661e612 117
895a906e 118 return fLoader;
1661e612 119}
120
4fa198c6 121AliPMD::~AliPMD()
122{
123 //
30fdb6d0 124 // Destructor
4fa198c6 125 //
4fa198c6 126}
127
fe4da5cc 128//_____________________________________________________________________________
129void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
130{
131 //
132 // Add a PMD hit
133 //
134 TClonesArray &lhits = *fHits;
135 AliPMDhit *newcell, *curcell;
41c97e7a 136 // printf("PMD++ Adding energy %f, prim %d, vol %d %d %d %d %d %d %d %d\n",
137 // hits[3],gAlice->GetPrimary(track-1),vol[0],vol[1],vol[2],vol[3],
138 // vol[4],vol[5],vol[6],vol[7]);
139
fe4da5cc 140 newcell = new AliPMDhit(fIshunt, track, vol, hits);
141 Int_t i;
142 for (i=0; i<fNhits; i++) {
143 //
144 // See if this cell has already been hit
145 curcell=(AliPMDhit*) lhits[i];
146 if (*curcell==*newcell) {
6edc06da 147// printf("Cell with same numbers found\n") ; curcell->Print();
fe4da5cc 148 *curcell = *curcell+*newcell;
6edc06da 149// printf("Cell after addition\n") ; curcell->Print();
fe4da5cc 150 delete newcell;
151 return;
152 }
153 }
154 new(lhits[fNhits++]) AliPMDhit(newcell);
155 delete newcell;
156}
157
158//_____________________________________________________________________________
159void AliPMD::BuildGeometry()
160{
161 //
162 // Build simple ROOT TNode geometry for event display
163 //
164
895a906e 165 TNode *node, *top;
fe4da5cc 166 const int kColorPMD = kRed;
167
168 //
895a906e 169 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 170
171 // PMD
172 new TBRIK("S_PMD","PMD box","void",300,300,5);
895a906e 173 top->cd();
174 node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
175 node->SetLineColor(kColorPMD);
176 fNodes->Add(node);
fe4da5cc 177}
178
179//_____________________________________________________________________________
895a906e 180Int_t AliPMD::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 181{
182 //
183 // Distance from mouse to detector on the screen
184 // dummy routine
185 //
186 return 9999;
187}
188
189//_____________________________________________________________________________
190void AliPMD::SetPAR(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
191{
192 //
193 // Set PMD parameters
194 //
195 fPar[0] = p1;
196 fPar[1] = p2;
197 fPar[2] = p3;
198 fPar[3] = p4;
199}
200
201//_____________________________________________________________________________
202void AliPMD::SetIN(Float_t p1, Float_t p2, Float_t p3,Float_t p4,Float_t p5)
203{
204 //
205 // Set PMD parameters
206 //
207 fIn[0] = p1;
208 fIn[1] = p2;
209 fIn[2] = p3;
210 fIn[3] = p4;
211 fIn[4] = p5;
212}
213
214//_____________________________________________________________________________
215void AliPMD::SetGEO(Float_t p1, Float_t p2, Float_t p3)
216{
217 //
218 // Set geometry parameters
219 //
220 fGeo[0] = p1;
221 fGeo[1] = p2;
222 fGeo[2] = p3;
223}
224
225//_____________________________________________________________________________
226void AliPMD::SetPadSize(Float_t p1, Float_t p2, Float_t p3,Float_t p4)
227{
228 //
229 // Set pad size
230 //
231 fPadSize[0] = p1;
232 fPadSize[1] = p2;
233 fPadSize[2] = p3;
234 fPadSize[3] = p4;
235}
236
237//_____________________________________________________________________________
238void AliPMD::StepManager()
239{
240 //
241 // Called at every step in PMD
242 //
243}
244
88cb7938 245void AliPMD::MakeBranch(Option_t* option)
4fa198c6 246{
247 // Create Tree branches for the PMD
4fa198c6 248
88cb7938 249 const char *cH = strstr(option,"H");
250 if (cH && fLoader->TreeH() && (fHits == 0x0))
251 fHits = new TClonesArray("AliPMDhit", 405);
2ab0c725 252
88cb7938 253 AliDetector::MakeBranch(option);
4fa198c6 254}
255
256
257void AliPMD::SetTreeAddress()
258{
30fdb6d0 259 // Set branch address
260
1da4d0d9 261 if (fLoader->TreeH() && fHits==0x0)
88cb7938 262 fHits = new TClonesArray("AliPMDhit", 405);
263
4fa198c6 264 AliDetector::SetTreeAddress();
4fa198c6 265}
266
85a5290f 267//____________________________________________________________________________
268void AliPMD::Hits2SDigits()
269{
270// create summable digits
271
272 AliRunLoader* runLoader = fLoader->GetRunLoader();
273 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
274 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
275 "HS");
40be8527 276 pmdDigitizer->SetZPosition(361.5);
85a5290f 277
278 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
279 pmdDigitizer->Hits2SDigits(iEvent);
280 }
281 fLoader->UnloadHits();
282 fLoader->UnloadSDigits();
283 delete pmdDigitizer;
284}
53043784 285//____________________________________________________________________________
286void AliPMD::SDigits2Digits()
287{
288 // creates sdigits to digits
289}
290//____________________________________________________________________________
291void AliPMD::Hits2Digits()
292{
293// create digits
294
295 AliRunLoader* runLoader = fLoader->GetRunLoader();
296 AliPMDDigitizer* pmdDigitizer = new AliPMDDigitizer;
297 pmdDigitizer->OpengAliceFile(fLoader->GetRunLoader()->GetFileName().Data(),
298 "HD");
299 pmdDigitizer->SetZPosition(361.5);
300
301 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
302 pmdDigitizer->Hits2Digits(iEvent);
303 }
304 fLoader->UnloadHits();
305 fLoader->UnloadDigits();
306 delete pmdDigitizer;
307
308}
fe743527 309// ---------------------------------------------------------------------------
dfaeee5f 310AliDigitizer* AliPMD::CreateDigitizer(AliRunDigitizer* manager) const
53043784 311{
312 return new AliPMDDigitizer(manager);
313}
fe743527 314// ---------------------------------------------------------------------------
c39d2a93 315void AliPMD::Digits2Raw()
316{
317// convert digits of the current event to raw data
318
319 fLoader->LoadDigits();
320 TTree* digits = fLoader->TreeD();
321 if (!digits) {
322 Error("Digits2Raw", "no digits tree");
323 return;
324 }
325
326 AliPMDDDLRawData rawWriter;
327 rawWriter.WritePMDRawData(digits);
328
329 fLoader->UnloadDigits();
330}
331
fe743527 332
53043784 333