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