]>
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 | **************************************************************************/ | |
88cb7938 | 15 | |
16 | /* $Id$ */ | |
17 | ||
e802be3e | 18 | //____________________________________________________________________ |
4347b38f | 19 | // |
37c4363a | 20 | // Forward Multiplicity Detector based on Silicon wafers. This class |
21 | // contains the base procedures for the Forward Multiplicity detector | |
1a1fdef7 | 22 | // Detector consists of 3 sub-detectors FMD1, FMD2, and FMD3, each of |
23 | // which has 1 or 2 rings of silicon sensors. | |
37c4363a | 24 | // |
25 | // This is the base class for all FMD manager classes. | |
26 | // | |
4347b38f | 27 | // The actual code is done by various separate classes. Below is |
28 | // diagram showing the relationship between the various FMD classes | |
1a1fdef7 | 29 | // that handles the simulation |
4347b38f | 30 | // |
31 | // | |
32 | // +----------+ +----------+ | |
1a1fdef7 | 33 | // | AliFMDv1 | | AliFMDv0 | |
4347b38f | 34 | // +----------+ +----------+ |
1a1fdef7 | 35 | // | | +-----------------+ |
36 | // +----+--------------+ +--| AliFMDDigitizer | | |
37 | // | | +-----------------+ | |
38 | // | +---------------------+ | | |
39 | // | +- | AliFMDBaseDigitizer |<--+ | |
40 | // V 1 | +---------------------+ | | |
41 | // +--------+<>--+ | +------------------+ | |
42 | // | AliFMD | +--| AliFMDSDigitizer | | |
43 | // +--------+<>--+ +------------------+ | |
44 | // 1 | +-----------------+ | |
45 | // +-| AliFMDSimulator | | |
46 | // +-----------------+ | |
4347b38f | 47 | // ^ |
48 | // | | |
49 | // +-------------+-------------+ | |
1a1fdef7 | 50 | // | | |
51 | // +--------------------+ +-------------------+ | |
52 | // | AliFMDGeoSimulator | | AliFMDG3Simulator | | |
53 | // +--------------------+ +---------+---------+ | |
4347b38f | 54 | // |
55 | // | |
56 | // * AliFMD | |
57 | // This defines the interface for the various parts of AliROOT that | |
1a1fdef7 | 58 | // uses the FMD, like AliFMDSimulator, AliFMDDigitizer, |
59 | // AliFMDReconstructor, and so on. | |
60 | // | |
61 | // * AliFMDv0 | |
62 | // This is a concrete implementation of the AliFMD interface. | |
63 | // It is the responsibility of this class to create the FMD | |
64 | // geometry. | |
4347b38f | 65 | // |
66 | // * AliFMDv1 | |
67 | // This is a concrete implementation of the AliFMD interface. | |
68 | // It is the responsibility of this class to create the FMD | |
69 | // geometry, process hits in the FMD, and serve hits and digits to | |
70 | // the various clients. | |
71 | // | |
1a1fdef7 | 72 | // * AliFMDSimulator |
73 | // This is the base class for the FMD simulation tasks. The | |
74 | // simulator tasks are responsible to implment the geoemtry, and | |
75 | // process hits. | |
4347b38f | 76 | // |
1a1fdef7 | 77 | // * AliFMDGeoSimulator |
78 | // This is a concrete implementation of the AliFMDSimulator that | |
79 | // uses the TGeo classes directly only. | |
37c4363a | 80 | // |
1a1fdef7 | 81 | // * AliFMDG3Simulator |
82 | // This is a concrete implementation of the AliFMDSimulator that | |
83 | // uses the TVirtualMC interface with GEANT 3.21-like messages. | |
37c4363a | 84 | // |
fe4da5cc | 85 | |
56b1929b | 86 | // These files are not in the same directory, so there's no reason to |
87 | // ask the preprocessor to search in the current directory for these | |
88 | // files by including them with `#include "..."' | |
1a1fdef7 | 89 | #include <math.h> // __CMATH__ |
56b1929b | 90 | #include <TClonesArray.h> // ROOT_TClonesArray |
91 | #include <TGeometry.h> // ROOT_TGeomtry | |
92 | #include <TNode.h> // ROOT_TNode | |
1a1fdef7 | 93 | #include <TXTRU.h> // ROOT_TXTRU |
94 | #include <TRotMatrix.h> // ROOT_TRotMatrix | |
56b1929b | 95 | #include <TTUBE.h> // ROOT_TTUBE |
96 | #include <TTree.h> // ROOT_TTree | |
56b1929b | 97 | #include <TBrowser.h> // ROOT_TBrowser |
98 | #include <TMath.h> // ROOT_TMath | |
1a1fdef7 | 99 | #include <TVirtualMC.h> // ROOT_TVirtualMC |
56b1929b | 100 | |
101 | #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H | |
102 | #include <AliLoader.h> // ALILOADER_H | |
103 | #include <AliRun.h> // ALIRUN_H | |
104 | #include <AliMC.h> // ALIMC_H | |
105 | #include <AliLog.h> // ALILOG_H | |
e802be3e | 106 | #include "AliFMD.h" // ALIFMD_H |
107 | #include "AliFMDDigit.h" // ALIFMDDIGIG_H | |
108 | #include "AliFMDHit.h" // ALIFMDHIT_H | |
1a1fdef7 | 109 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H |
110 | #include "AliFMDDetector.h" // ALIFMDDETECTOR_H | |
111 | #include "AliFMDRing.h" // ALIFMDRING_H | |
e802be3e | 112 | #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H |
1a1fdef7 | 113 | #include "AliFMDSimulator.h" // ALIFMDSIMULATOR_H |
114 | #include "AliFMDG3Simulator.h" // ALIFMDG3SIMULATOR_H | |
115 | #include "AliFMDGeoSimulator.h" // ALIFMDGEOSIMULATOR_H | |
e802be3e | 116 | #include "AliFMDRawWriter.h" // ALIFMDRAWWRITER_H |
88cb7938 | 117 | |
4347b38f | 118 | //____________________________________________________________________ |
925e6570 | 119 | ClassImp(AliFMD) |
1a1fdef7 | 120 | #if 0 |
121 | ; // This is to keep Emacs from indenting the next line | |
122 | #endif | |
7e54281f | 123 | |
4347b38f | 124 | //____________________________________________________________________ |
125 | AliFMD::AliFMD() | |
90da4514 | 126 | : AliDetector(), |
127 | fSDigits(0), | |
afddaa11 | 128 | fNsdigits(0), |
1a1fdef7 | 129 | fDetailed(kTRUE), |
130 | fSimulator(0) | |
fe4da5cc | 131 | { |
132 | // | |
133 | // Default constructor for class AliFMD | |
134 | // | |
1a1fdef7 | 135 | AliDebug(10, "\tDefault CTOR"); |
dc8af42e | 136 | fHits = 0; |
137 | fDigits = 0; | |
4347b38f | 138 | fIshunt = 0; |
fe4da5cc | 139 | } |
dc8af42e | 140 | |
56b1929b | 141 | //____________________________________________________________________ |
142 | AliFMD::AliFMD(const AliFMD& other) | |
143 | : AliDetector(other), | |
56b1929b | 144 | fSDigits(other.fSDigits), |
145 | fNsdigits(other.fNsdigits), | |
1a1fdef7 | 146 | fDetailed(other.fDetailed), |
147 | fSimulator(other.fSimulator) | |
56b1929b | 148 | { |
149 | // Copy constructor | |
150 | } | |
151 | ||
4347b38f | 152 | //____________________________________________________________________ |
1a1fdef7 | 153 | AliFMD::AliFMD(const char *name, const char *title) |
4347b38f | 154 | : AliDetector (name, title), |
afddaa11 | 155 | fSDigits(0), |
156 | fNsdigits(0), | |
1a1fdef7 | 157 | fDetailed(kTRUE), |
158 | fSimulator(0) | |
fe4da5cc | 159 | { |
160 | // | |
161 | // Standard constructor for Forward Multiplicity Detector | |
162 | // | |
1a1fdef7 | 163 | AliDebug(10, "\tStandard CTOR"); |
dc8af42e | 164 | |
fe4da5cc | 165 | // Initialise Hit array |
4347b38f | 166 | HitsArray(); |
167 | gAlice->GetMCApp()->AddHitList(fHits); | |
d1280e40 | 168 | |
4347b38f | 169 | // (S)Digits for the detectors disk |
170 | DigitsArray(); | |
171 | SDigitsArray(); | |
172 | ||
173 | // CHC: What is this? | |
dc8af42e | 174 | fIshunt = 0; |
4347b38f | 175 | SetMarkerColor(kRed); |
176 | SetLineColor(kYellow); | |
fe4da5cc | 177 | } |
d28dcc0d | 178 | |
4347b38f | 179 | //____________________________________________________________________ |
dc8af42e | 180 | AliFMD::~AliFMD () |
d28dcc0d | 181 | { |
4347b38f | 182 | // Destructor for base class AliFMD |
183 | if (fHits) { | |
184 | fHits->Delete(); | |
185 | delete fHits; | |
186 | fHits = 0; | |
187 | } | |
188 | if (fDigits) { | |
189 | fDigits->Delete(); | |
190 | delete fDigits; | |
191 | fDigits = 0; | |
192 | } | |
193 | if (fSDigits) { | |
194 | fSDigits->Delete(); | |
195 | delete fSDigits; | |
196 | fSDigits = 0; | |
197 | } | |
198 | } | |
199 | ||
56b1929b | 200 | //____________________________________________________________________ |
201 | AliFMD& | |
202 | AliFMD::operator=(const AliFMD& other) | |
203 | { | |
204 | AliDetector::operator=(other); | |
56b1929b | 205 | fSDigits = other.fSDigits; |
206 | fNsdigits = other.fNsdigits; | |
1a1fdef7 | 207 | fDetailed = other.fDetailed; |
208 | fSimulator = other.fSimulator; | |
209 | ||
56b1929b | 210 | return *this; |
211 | } | |
212 | ||
4347b38f | 213 | //==================================================================== |
214 | // | |
215 | // GEometry ANd Traking | |
216 | // | |
217 | //____________________________________________________________________ | |
218 | void | |
219 | AliFMD::CreateGeometry() | |
220 | { | |
4347b38f | 221 | // |
37c4363a | 222 | // Create the geometry of Forward Multiplicity Detector. The actual |
223 | // construction of the geometry is delegated to the class AliFMDRing | |
224 | // and AliFMDSubDetector and the relevant derived classes. | |
225 | // | |
226 | // The flow of this member function is: | |
227 | // | |
228 | // FOR rings fInner and fOuter DO | |
229 | // AliFMDRing::Init(); | |
230 | // END FOR | |
231 | // | |
232 | // Set up hybrud card support (leg) volume shapes | |
233 | // | |
234 | // FOR rings fInner and fOuter DO | |
235 | // AliFMDRing::SetupGeometry(); | |
236 | // END FOR | |
237 | // | |
238 | // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO | |
239 | // AliFMDSubDetector::SetupGeomtry(); | |
240 | // END FOR | |
241 | // | |
242 | // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO | |
243 | // AliFMDSubDetector::Geomtry(); | |
244 | // END FOR | |
1a1fdef7 | 245 | // |
246 | if (!fSimulator) { | |
247 | AliFatal("Simulator object not made yet!"); | |
248 | return; | |
249 | } | |
250 | fSimulator->DefineGeometry(); | |
4347b38f | 251 | } |
252 | ||
253 | //____________________________________________________________________ | |
254 | void AliFMD::CreateMaterials() | |
255 | { | |
256 | // Register various materials and tracking mediums with the | |
257 | // backend. | |
258 | // | |
824466d5 | 259 | AliDebug(10, "\tCreating materials"); |
56b1929b | 260 | |
1a1fdef7 | 261 | if (fSimulator) { |
262 | AliFatal("Simulator object already instantised!"); | |
263 | return; | |
4347b38f | 264 | } |
1a1fdef7 | 265 | AliFMDGeometry* geometry = AliFMDGeometry::Instance(); |
266 | geometry->Init(); | |
afa207e5 | 267 | // TVirtualMC* mc = TVirtualMC::GetMC(); |
268 | // Bool_t geo = mc->IsRootGeometrySupported(); | |
269 | // if (geo) | |
270 | // fSimulator = new AliFMDGeoSimulator(this, fDetailed); | |
271 | // else | |
1a1fdef7 | 272 | fSimulator = new AliFMDG3Simulator(this, fDetailed); |
4347b38f | 273 | |
1a1fdef7 | 274 | fSimulator->DefineMaterials(); |
d28dcc0d | 275 | } |
dc8af42e | 276 | |
4347b38f | 277 | //____________________________________________________________________ |
278 | void | |
279 | AliFMD::Init() | |
fe4da5cc | 280 | { |
281 | // | |
4347b38f | 282 | // Initialis the FMD after it has been built |
283 | Int_t i; | |
284 | // | |
4951e003 | 285 | if (AliLog::GetGlobalDebugLevel()) { |
7c09877a | 286 | cout << "\n" << ClassName() << ": " << flush; |
287 | for (i = 0; i < 35; i++) cout << "*"; | |
288 | cout << " FMD_INIT "; | |
289 | for (i = 0; i < 35; i++) cout << "*"; | |
290 | cout << "\n" << ClassName() << ": " << flush; | |
4347b38f | 291 | // |
292 | // Here the FMD initialisation code (if any!) | |
7c09877a | 293 | for (i = 0; i < 80; i++) cout << "*"; |
294 | cout << endl; | |
4347b38f | 295 | } |
296 | // | |
fe4da5cc | 297 | // |
fe4da5cc | 298 | } |
dc8af42e | 299 | |
4347b38f | 300 | //==================================================================== |
301 | // | |
302 | // Graphics and event display | |
303 | // | |
304 | //____________________________________________________________________ | |
305 | void | |
306 | AliFMD::BuildGeometry() | |
b9a2d5e4 | 307 | { |
4347b38f | 308 | // |
309 | // Build simple ROOT TNode geometry for event display | |
310 | // | |
311 | // Build a simplified geometry of the FMD used for event display | |
312 | // | |
37c4363a | 313 | // The actual building of the TNodes is done by |
314 | // AliFMDSubDetector::SimpleGeometry. | |
824466d5 | 315 | AliDebug(10, "\tCreating a simplified geometry"); |
b9a2d5e4 | 316 | |
1a1fdef7 | 317 | AliFMDGeometry* fmd = AliFMDGeometry::Instance(); |
318 | ||
319 | static TXTRU* innerShape = 0; | |
320 | static TXTRU* outerShape = 0; | |
321 | static TObjArray* innerRot = 0; | |
322 | static TObjArray* outerRot = 0; | |
323 | ||
324 | if (!innerShape || !outerShape) { | |
325 | // Make the shapes for the modules | |
326 | for (Int_t i = 0; i < 2; i++) { | |
327 | AliFMDRing* r = 0; | |
328 | switch (i) { | |
329 | case 0: r = fmd->GetRing('I'); break; | |
330 | case 1: r = fmd->GetRing('O'); break; | |
331 | } | |
332 | if (!r) { | |
333 | AliError(Form("no ring found for i=%d", i)); | |
334 | return; | |
335 | } | |
336 | Double_t siThick = r->GetSiThickness(); | |
337 | const Int_t nv = r->GetNVerticies(); | |
338 | Double_t theta = r->GetTheta(); | |
339 | Int_t nmod = r->GetNModules(); | |
340 | ||
341 | TXTRU* shape = new TXTRU(r->GetName(), r->GetTitle(), "void", nv, 2); | |
342 | for (Int_t j = 0; j < nv; j++) { | |
343 | TVector2* vv = r->GetVertex(nv - 1 - j); | |
344 | shape->DefineVertex(j, vv->X(), vv->Y()); | |
345 | } | |
346 | shape->DefineSection(0, -siThick / 2, 1, 0, 0); | |
347 | shape->DefineSection(1, +siThick / 2, 1, 0, 0); | |
348 | shape->SetLineColor(GetLineColor()); | |
349 | ||
350 | TObjArray* rots = new TObjArray(nmod); | |
351 | for (Int_t j = 0; j < nmod; j++) { | |
352 | Double_t th = (j + .5) * theta * 2; | |
353 | TString name(Form("FMD_ring_%c_rot_%02d", r->GetId(), j)); | |
354 | TString title(Form("FMD Ring %c Rotation # %d", r->GetId(), j)); | |
355 | TRotMatrix* rot = new TRotMatrix(name.Data(), title.Data(), | |
356 | 90, th, 90, fmod(90+th,360), 0, 0); | |
357 | rots->AddAt(rot, j); | |
358 | } | |
359 | ||
360 | switch (r->GetId()) { | |
361 | case 'i': | |
362 | case 'I': innerShape = shape; innerRot = rots; break; | |
363 | case 'o': | |
364 | case 'O': outerShape = shape; outerRot = rots; break; | |
365 | } | |
366 | } | |
367 | } | |
368 | ||
4347b38f | 369 | TNode* top = gAlice->GetGeometry()->GetNode("alice"); |
370 | ||
1a1fdef7 | 371 | for (Int_t i = 1; i <= 3; i++) { |
372 | AliFMDDetector* det = fmd->GetDetector(i); | |
373 | if (!det) { | |
374 | Warning("BuildGeometry", "FMD%d seems to be disabled", i); | |
375 | continue; | |
376 | } | |
377 | Double_t w = 0; | |
378 | Double_t rh = det->GetRing('I')->GetHighR(); | |
379 | Char_t id = 'I'; | |
380 | if (det->GetRing('O')) { | |
381 | w = TMath::Abs(det->GetRingZ('O') - det->GetRingZ('I')); | |
382 | id = (TMath::Abs(det->GetRingZ('O')) | |
383 | > TMath::Abs(det->GetRingZ('I')) ? 'O' : 'I'); | |
384 | rh = det->GetRing('O')->GetHighR(); | |
385 | } | |
386 | w += (det->GetRing(id)->GetModuleSpacing() + | |
387 | det->GetRing(id)->GetSiThickness()); | |
388 | TShape* shape = new TTUBE(det->GetName(), det->GetTitle(), "void", | |
389 | det->GetRing('I')->GetLowR(), rh, w / 2); | |
390 | Double_t z = (det->GetRingZ('I') - w / 2); | |
391 | if (z > 0) z += det->GetRing(id)->GetModuleSpacing(); | |
392 | top->cd(); | |
393 | TNode* node = new TNode(det->GetName(), det->GetTitle(), shape, | |
394 | 0, 0, z, 0); | |
395 | fNodes->Add(node); | |
396 | ||
397 | for (Int_t j = 0; j < 2; j++) { | |
398 | AliFMDRing* r = 0; | |
399 | TShape* rshape = 0; | |
400 | TObjArray* rots = 0; | |
401 | switch (j) { | |
402 | case 0: | |
403 | r = det->GetRing('I'); rshape = innerShape; rots = innerRot; break; | |
404 | case 1: | |
405 | r = det->GetRing('O'); rshape = outerShape; rots = outerRot; break; | |
406 | } | |
407 | if (!r) continue; | |
408 | ||
409 | Double_t siThick = r->GetSiThickness(); | |
410 | Int_t nmod = r->GetNModules(); | |
411 | Double_t modspace = r->GetModuleSpacing(); | |
412 | Double_t rz = - (z - det->GetRingZ(r->GetId())); | |
413 | ||
414 | for (Int_t k = 0; k < nmod; k++) { | |
415 | node->cd(); | |
416 | Double_t offz = (k % 2 == 1 ? modspace : 0); | |
417 | TRotMatrix* rot = static_cast<TRotMatrix*>(rots->At(k)); | |
418 | TString name(Form("%s%c_module_%02d", det->GetName(), r->GetId(),k)); | |
419 | TString title(Form("%s%c Module %d", det->GetName(), r->GetId(),k)); | |
420 | TNode* mnod = new TNode(name.Data(), title.Data(), rshape, | |
421 | 0, 0, rz - siThick / 2 | |
422 | + TMath::Sign(offz,z), rot); | |
423 | mnod->SetLineColor(GetLineColor()); | |
424 | fNodes->Add(mnod); | |
425 | } // for (Int_t k = 0 ; ...) | |
426 | } // for (Int_t j = 0 ; ...) | |
427 | } // for (Int_t i = 1 ; ...) | |
37c55dc0 | 428 | } |
88cb7938 | 429 | |
4347b38f | 430 | //____________________________________________________________________ |
431 | void | |
432 | AliFMD::DrawDetector() | |
fe4da5cc | 433 | { |
434 | // | |
37c4363a | 435 | // Draw a shaded view of the Forward multiplicity detector |
fe4da5cc | 436 | // |
4347b38f | 437 | // DebugGuard guard("AliFMD::DrawDetector"); |
824466d5 | 438 | AliDebug(10, "\tDraw detector"); |
4347b38f | 439 | |
1a1fdef7 | 440 | #if 0 |
4347b38f | 441 | //Set ALIC mother transparent |
442 | gMC->Gsatt("ALIC","SEEN",0); | |
4347b38f | 443 | // |
444 | gMC->Gdopt("hide", "on"); | |
445 | gMC->Gdopt("shad", "on"); | |
446 | gMC->Gsatt("*", "fill", 7); | |
447 | gMC->SetClipBox("."); | |
448 | gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000); | |
449 | gMC->DefaultRange(); | |
450 | gMC->Gdraw("alic", 40, 30, 0, 12, 12, .055, .055); | |
451 | gMC->Gdhead(1111, "Forward Multiplicity Detector"); | |
452 | gMC->Gdman(16, 10, "MAN"); | |
453 | gMC->Gdopt("hide", "off"); | |
1a1fdef7 | 454 | #endif |
fe4da5cc | 455 | } |
dc8af42e | 456 | |
4347b38f | 457 | //____________________________________________________________________ |
17323043 | 458 | Int_t |
4347b38f | 459 | AliFMD::DistanceToPrimitive(Int_t, Int_t) |
fe4da5cc | 460 | { |
461 | // | |
462 | // Calculate the distance from the mouse to the FMD on the screen | |
463 | // Dummy routine | |
464 | // | |
465 | return 9999; | |
466 | } | |
dc8af42e | 467 | |
4347b38f | 468 | //==================================================================== |
469 | // | |
470 | // Hit and Digit managment | |
471 | // | |
472 | //____________________________________________________________________ | |
473 | void | |
474 | AliFMD::MakeBranch(Option_t * option) | |
475 | { | |
476 | // Create Tree branches for the FMD. | |
37c4363a | 477 | // |
478 | // Options: | |
479 | // | |
480 | // H Make a branch of TClonesArray of AliFMDHit's | |
481 | // D Make a branch of TClonesArray of AliFMDDigit's | |
482 | // S Make a branch of TClonesArray of AliFMDSDigit's | |
483 | // | |
4347b38f | 484 | const Int_t kBufferSize = 16000; |
485 | TString branchname(GetName()); | |
486 | TString opt(option); | |
487 | ||
488 | if (opt.Contains("H", TString::kIgnoreCase)) { | |
489 | HitsArray(); | |
490 | AliDetector::MakeBranch(option); | |
491 | } | |
492 | if (opt.Contains("D", TString::kIgnoreCase)) { | |
493 | DigitsArray(); | |
494 | MakeBranchInTree(fLoader->TreeD(), branchname.Data(), | |
495 | &fDigits, kBufferSize, 0); | |
496 | } | |
497 | if (opt.Contains("S", TString::kIgnoreCase)) { | |
498 | SDigitsArray(); | |
499 | MakeBranchInTree(fLoader->TreeS(), branchname.Data(), | |
500 | &fSDigits, kBufferSize, 0); | |
501 | } | |
502 | } | |
503 | ||
504 | //____________________________________________________________________ | |
505 | void | |
506 | AliFMD::SetTreeAddress() | |
507 | { | |
afddaa11 | 508 | // Set branch address for the Hits, Digits, and SDigits Tree. |
4347b38f | 509 | if (fLoader->TreeH()) HitsArray(); |
510 | AliDetector::SetTreeAddress(); | |
511 | ||
512 | TTree *treeD = fLoader->TreeD(); | |
513 | if (treeD) { | |
514 | DigitsArray(); | |
515 | TBranch* branch = treeD->GetBranch ("FMD"); | |
516 | if (branch) branch->SetAddress(&fDigits); | |
517 | } | |
518 | ||
519 | TTree *treeS = fLoader->TreeS(); | |
520 | if (treeS) { | |
521 | SDigitsArray(); | |
522 | TBranch* branch = treeS->GetBranch ("FMD"); | |
523 | if (branch) branch->SetAddress(&fSDigits); | |
524 | } | |
525 | } | |
526 | ||
527 | ||
528 | ||
529 | //____________________________________________________________________ | |
530 | void | |
531 | AliFMD::SetHitsAddressBranch(TBranch *b) | |
b9a2d5e4 | 532 | { |
37c4363a | 533 | // Set the TClonesArray to read hits into. |
4347b38f | 534 | b->SetAddress(&fHits); |
b9a2d5e4 | 535 | } |
536 | ||
4347b38f | 537 | //____________________________________________________________________ |
538 | void | |
539 | AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
540 | { | |
541 | // Add a hit to the hits tree | |
542 | // | |
543 | // The information of the two arrays are decoded as | |
544 | // | |
545 | // Parameters | |
546 | // track Track # | |
547 | // ivol[0] [UShort_t ] Detector # | |
548 | // ivol[1] [Char_t ] Ring ID | |
549 | // ivol[2] [UShort_t ] Sector # | |
550 | // ivol[3] [UShort_t ] Strip # | |
551 | // hits[0] [Float_t ] Track's X-coordinate at hit | |
552 | // hits[1] [Float_t ] Track's Y-coordinate at hit | |
553 | // hits[3] [Float_t ] Track's Z-coordinate at hit | |
554 | // hits[4] [Float_t ] X-component of track's momentum | |
555 | // hits[5] [Float_t ] Y-component of track's momentum | |
556 | // hits[6] [Float_t ] Z-component of track's momentum | |
557 | // hits[7] [Float_t ] Energy deposited by track | |
558 | // hits[8] [Int_t ] Track's particle Id # | |
37c4363a | 559 | // hits[9] [Float_t ] Time when the track hit |
560 | // | |
561 | // | |
69b696b9 | 562 | AddHitByFields(track, |
563 | UShort_t(vol[0]), // Detector # | |
564 | Char_t(vol[1]), // Ring ID | |
565 | UShort_t(vol[2]), // Sector # | |
566 | UShort_t(vol[3]), // Strip # | |
567 | hits[0], // X | |
568 | hits[1], // Y | |
569 | hits[2], // Z | |
570 | hits[3], // Px | |
571 | hits[4], // Py | |
572 | hits[5], // Pz | |
573 | hits[6], // Energy loss | |
574 | Int_t(hits[7]), // PDG | |
575 | hits[8]); // Time | |
4347b38f | 576 | } |
577 | ||
578 | //____________________________________________________________________ | |
579 | void | |
69b696b9 | 580 | AliFMD::AddHitByFields(Int_t track, |
581 | UShort_t detector, | |
582 | Char_t ring, | |
583 | UShort_t sector, | |
584 | UShort_t strip, | |
585 | Float_t x, | |
586 | Float_t y, | |
587 | Float_t z, | |
588 | Float_t px, | |
589 | Float_t py, | |
590 | Float_t pz, | |
591 | Float_t edep, | |
592 | Int_t pdg, | |
593 | Float_t t) | |
b9a2d5e4 | 594 | { |
dc8af42e | 595 | // |
4347b38f | 596 | // Add a hit to the list |
dc8af42e | 597 | // |
4347b38f | 598 | // Parameters: |
599 | // | |
600 | // track Track # | |
601 | // detector Detector # (1, 2, or 3) | |
602 | // ring Ring ID ('I' or 'O') | |
603 | // sector Sector # (For inner/outer rings: 0-19/0-39) | |
604 | // strip Strip # (For inner/outer rings: 0-511/0-255) | |
605 | // x Track's X-coordinate at hit | |
606 | // y Track's Y-coordinate at hit | |
607 | // z Track's Z-coordinate at hit | |
608 | // px X-component of track's momentum | |
609 | // py Y-component of track's momentum | |
610 | // pz Z-component of track's momentum | |
611 | // edep Energy deposited by track | |
612 | // pdg Track's particle Id # | |
613 | // t Time when the track hit | |
614 | // | |
615 | TClonesArray& a = *(HitsArray()); | |
616 | // Search through the list of already registered hits, and see if we | |
617 | // find a hit with the same parameters. If we do, then don't create | |
618 | // a new hit, but rather update the energy deposited in the hit. | |
619 | // This is done, so that a FLUKA based simulation will get the | |
620 | // number of hits right, not just the enerrgy deposition. | |
621 | for (Int_t i = 0; i < fNhits; i++) { | |
622 | if (!a.At(i)) continue; | |
623 | AliFMDHit* hit = static_cast<AliFMDHit*>(a.At(i)); | |
624 | if (hit->Detector() == detector | |
625 | && hit->Ring() == ring | |
626 | && hit->Sector() == sector | |
627 | && hit->Strip() == strip | |
628 | && hit->Track() == track) { | |
37c4363a | 629 | Warning("AddHit", "already had a hit in FMD%d%c[%2d,%3d] for track # %d," |
630 | " adding energy (%f) to that hit (%f) -> %f", | |
631 | detector, ring, sector, strip, track, edep, hit->Edep(), | |
632 | hit->Edep() + edep); | |
4347b38f | 633 | hit->SetEdep(hit->Edep() + edep); |
634 | return; | |
635 | } | |
636 | } | |
637 | // If hit wasn't already registered, do so know. | |
638 | new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, strip, | |
639 | x, y, z, px, py, pz, edep, pdg, t); | |
640 | fNhits++; | |
b9a2d5e4 | 641 | } |
fe4da5cc | 642 | |
4347b38f | 643 | //____________________________________________________________________ |
644 | void | |
69b696b9 | 645 | AliFMD::AddDigit(Int_t* digits, Int_t*) |
fe4da5cc | 646 | { |
4347b38f | 647 | // Add a digit to the Digit tree |
648 | // | |
649 | // Paramters | |
fe4da5cc | 650 | // |
4347b38f | 651 | // digits[0] [UShort_t] Detector # |
652 | // digits[1] [Char_t] Ring ID | |
653 | // digits[2] [UShort_t] Sector # | |
654 | // digits[3] [UShort_t] Strip # | |
655 | // digits[4] [UShort_t] ADC Count | |
656 | // digits[5] [Short_t] ADC Count, -1 if not used | |
657 | // digits[6] [Short_t] ADC Count, -1 if not used | |
658 | // | |
69b696b9 | 659 | AddDigitByFields(UShort_t(digits[0]), // Detector # |
660 | Char_t(digits[1]), // Ring ID | |
661 | UShort_t(digits[2]), // Sector # | |
662 | UShort_t(digits[3]), // Strip # | |
663 | UShort_t(digits[4]), // ADC Count1 | |
664 | Short_t(digits[5]), // ADC Count2 | |
665 | Short_t(digits[6])); // ADC Count3 | |
4347b38f | 666 | } |
667 | ||
668 | //____________________________________________________________________ | |
669 | void | |
69b696b9 | 670 | AliFMD::AddDigitByFields(UShort_t detector, |
671 | Char_t ring, | |
672 | UShort_t sector, | |
673 | UShort_t strip, | |
674 | UShort_t count1, | |
675 | Short_t count2, | |
676 | Short_t count3) | |
4347b38f | 677 | { |
678 | // add a real digit - as coming from data | |
679 | // | |
680 | // Parameters | |
fe4da5cc | 681 | // |
4347b38f | 682 | // detector Detector # (1, 2, or 3) |
683 | // ring Ring ID ('I' or 'O') | |
684 | // sector Sector # (For inner/outer rings: 0-19/0-39) | |
685 | // strip Strip # (For inner/outer rings: 0-511/0-255) | |
686 | // count1 ADC count (a 10-bit word) | |
687 | // count2 ADC count (a 10-bit word), or -1 if not used | |
688 | // count3 ADC count (a 10-bit word), or -1 if not used | |
689 | TClonesArray& a = *(DigitsArray()); | |
690 | ||
691 | new (a[fNdigits++]) | |
692 | AliFMDDigit(detector, ring, sector, strip, count1, count2, count3); | |
693 | } | |
694 | ||
695 | //____________________________________________________________________ | |
696 | void | |
697 | AliFMD::AddSDigit(Int_t* digits) | |
698 | { | |
699 | // Add a digit to the SDigit tree | |
700 | // | |
701 | // Paramters | |
b9a2d5e4 | 702 | // |
4347b38f | 703 | // digits[0] [UShort_t] Detector # |
704 | // digits[1] [Char_t] Ring ID | |
705 | // digits[2] [UShort_t] Sector # | |
706 | // digits[3] [UShort_t] Strip # | |
707 | // digits[4] [Float_t] Total energy deposited | |
708 | // digits[5] [UShort_t] ADC Count | |
709 | // digits[6] [Short_t] ADC Count, -1 if not used | |
710 | // digits[7] [Short_t] ADC Count, -1 if not used | |
711 | // | |
69b696b9 | 712 | AddSDigitByFields(UShort_t(digits[0]), // Detector # |
713 | Char_t(digits[1]), // Ring ID | |
714 | UShort_t(digits[2]), // Sector # | |
715 | UShort_t(digits[3]), // Strip # | |
716 | Float_t(digits[4]), // Edep | |
717 | UShort_t(digits[5]), // ADC Count1 | |
718 | Short_t(digits[6]), // ADC Count2 | |
719 | Short_t(digits[7])); // ADC Count3 | |
4347b38f | 720 | } |
721 | ||
722 | //____________________________________________________________________ | |
723 | void | |
69b696b9 | 724 | AliFMD::AddSDigitByFields(UShort_t detector, |
725 | Char_t ring, | |
726 | UShort_t sector, | |
727 | UShort_t strip, | |
728 | Float_t edep, | |
729 | UShort_t count1, | |
730 | Short_t count2, | |
731 | Short_t count3) | |
4347b38f | 732 | { |
733 | // add a summable digit | |
734 | // | |
735 | // Parameters | |
b9a2d5e4 | 736 | // |
4347b38f | 737 | // detector Detector # (1, 2, or 3) |
738 | // ring Ring ID ('I' or 'O') | |
739 | // sector Sector # (For inner/outer rings: 0-19/0-39) | |
740 | // strip Strip # (For inner/outer rings: 0-511/0-255) | |
741 | // edep Total energy deposited | |
742 | // count1 ADC count (a 10-bit word) | |
743 | // count2 ADC count (a 10-bit word), or -1 if not used | |
744 | // count3 ADC count (a 10-bit word), or -1 if not used | |
37c4363a | 745 | // |
4347b38f | 746 | TClonesArray& a = *(SDigitsArray()); |
747 | ||
748 | new (a[fNsdigits++]) | |
749 | AliFMDSDigit(detector, ring, sector, strip, edep, count1, count2, count3); | |
fe4da5cc | 750 | } |
4347b38f | 751 | |
752 | //____________________________________________________________________ | |
753 | void | |
754 | AliFMD::ResetSDigits() | |
d28dcc0d | 755 | { |
4347b38f | 756 | // |
757 | // Reset number of digits and the digits array for this detector | |
758 | // | |
759 | fNsdigits = 0; | |
760 | if (fSDigits) fSDigits->Clear(); | |
761 | } | |
762 | ||
763 | ||
764 | //____________________________________________________________________ | |
765 | TClonesArray* | |
766 | AliFMD::HitsArray() | |
767 | { | |
768 | // Initialize hit array if not already, and return pointer to it. | |
769 | if (!fHits) { | |
770 | fHits = new TClonesArray("AliFMDHit", 1000); | |
771 | fNhits = 0; | |
772 | } | |
773 | return fHits; | |
774 | } | |
775 | ||
776 | //____________________________________________________________________ | |
777 | TClonesArray* | |
778 | AliFMD::DigitsArray() | |
779 | { | |
780 | // Initialize digit array if not already, and return pointer to it. | |
781 | if (!fDigits) { | |
782 | fDigits = new TClonesArray("AliFMDDigit", 1000); | |
783 | fNdigits = 0; | |
784 | } | |
785 | return fDigits; | |
786 | } | |
787 | ||
788 | //____________________________________________________________________ | |
789 | TClonesArray* | |
790 | AliFMD::SDigitsArray() | |
791 | { | |
792 | // Initialize digit array if not already, and return pointer to it. | |
793 | if (!fSDigits) { | |
794 | fSDigits = new TClonesArray("AliFMDSDigit", 1000); | |
795 | fNsdigits = 0; | |
796 | } | |
797 | return fSDigits; | |
798 | } | |
799 | ||
800 | //==================================================================== | |
801 | // | |
802 | // Digitization | |
803 | // | |
804 | //____________________________________________________________________ | |
805 | void | |
806 | AliFMD::Hits2Digits() | |
807 | { | |
37c4363a | 808 | // Create AliFMDDigit's from AliFMDHit's. This is done by making a |
809 | // AliFMDDigitizer, and executing that code. | |
810 | // | |
4347b38f | 811 | AliRunDigitizer* manager = new AliRunDigitizer(1, 1); |
812 | manager->SetInputStream(0, "galice.root"); | |
813 | manager->SetOutputFile("H2Dfile"); | |
dc8af42e | 814 | |
4347b38f | 815 | /* AliDigitizer* dig =*/ CreateDigitizer(manager); |
816 | manager->Exec(""); | |
99d864b7 | 817 | delete manager; |
4347b38f | 818 | } |
819 | ||
820 | //____________________________________________________________________ | |
821 | void | |
822 | AliFMD::Hits2SDigits() | |
823 | { | |
37c4363a | 824 | // Create AliFMDSDigit's from AliFMDHit's. This is done by creating |
825 | // an AliFMDSDigitizer object, and executing it. | |
826 | // | |
56b1929b | 827 | AliFMDSDigitizer* digitizer = new AliFMDSDigitizer("galice.root"); |
56b1929b | 828 | digitizer->Exec(""); |
99d864b7 | 829 | delete digitizer; |
4347b38f | 830 | } |
831 | ||
dc8af42e | 832 | |
4347b38f | 833 | //____________________________________________________________________ |
834 | AliDigitizer* | |
835 | AliFMD::CreateDigitizer(AliRunDigitizer* manager) const | |
836 | { | |
837 | // Create a digitizer object | |
56b1929b | 838 | AliFMDDigitizer* digitizer = new AliFMDDigitizer(manager); |
56b1929b | 839 | return digitizer; |
4347b38f | 840 | } |
b9a2d5e4 | 841 | |
4347b38f | 842 | //==================================================================== |
843 | // | |
844 | // Raw data simulation | |
845 | // | |
846 | //__________________________________________________________________ | |
847 | void | |
848 | AliFMD::Digits2Raw() | |
849 | { | |
37c4363a | 850 | // Turn digits into raw data. |
851 | // | |
e802be3e | 852 | // This uses the class AliFMDRawWriter to do the job. Please refer |
853 | // to that class for more information. | |
854 | AliFMDRawWriter writer(this); | |
855 | writer.Exec(); | |
b9a2d5e4 | 856 | } |
857 | ||
4347b38f | 858 | |
859 | //==================================================================== | |
860 | // | |
861 | // Utility | |
862 | // | |
863 | //__________________________________________________________________ | |
864 | void | |
865 | AliFMD::Browse(TBrowser* b) | |
866 | { | |
37c4363a | 867 | // Browse this object. |
868 | // | |
824466d5 | 869 | AliDebug(30, "\tBrowsing the FMD"); |
4347b38f | 870 | AliDetector::Browse(b); |
1a1fdef7 | 871 | if (fSimulator) b->Add(fSimulator); |
872 | b->Add(AliFMDGeometry::Instance()); | |
4347b38f | 873 | } |
874 | ||
4347b38f | 875 | //___________________________________________________________________ |
876 | // | |
877 | // EOF | |
878 | // |