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