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