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