1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //____________________________________________________________________
20 // Forward Multiplicity Detector based on Silicon wafers. This class
21 // contains the base procedures for the Forward Multiplicity detector
22 // Detector consists of 3 sub-detectors FMD1, FMD2, and FMD3, each of
23 // which has 1 or 2 rings of silicon sensors.
25 // This is the base class for all FMD manager classes.
27 // The actual code is done by various separate classes. Below is
28 // diagram showing the relationship between the various FMD classes
29 // that handles the simulation
32 // +----------+ +----------+
33 // | AliFMDv1 | | AliFMDv0 |
34 // +----------+ +----------+
35 // | | +-----------------+
36 // +----+--------------+ +--| AliFMDDigitizer |
37 // | | +-----------------+
38 // | +---------------------+ |
39 // | +--| AliFMDBaseDigitizer |<--+
40 // V 1 | +---------------------+ |
41 // +--------+<>--+ | +------------------+
42 // | AliFMD | +--| AliFMDSDigitizer |
43 // +--------+<>--+ +------------------+
44 // 1 | +-----------------+
45 // +--| AliFMDSimulator |
46 // +-----------------+
49 // +-------------+-------------+
51 // +--------------------+ +-------------------+
52 // | AliFMDGeoSimulator | | AliFMDG3Simulator |
53 // +--------------------+ +-------------------+
56 // +-----------------------+ +----------------------+
57 // | AliFMDGeoOldSimulator | | AliFMDG3OldSimulator |
58 // +-----------------------+ +----------------------+
62 // This defines the interface for the various parts of AliROOT that
63 // uses the FMD, like AliFMDSimulator, AliFMDDigitizer,
64 // AliFMDReconstructor, and so on.
67 // This is a concrete implementation of the AliFMD interface.
68 // It is the responsibility of this class to create the FMD
72 // This is a concrete implementation of the AliFMD interface.
73 // It is the responsibility of this class to create the FMD
74 // geometry, process hits in the FMD, and serve hits and digits to
75 // the various clients.
78 // This is the base class for the FMD simulation tasks. The
79 // simulator tasks are responsible to implment the geoemtry, and
82 // * AliFMDGeoSimulator
83 // This is a concrete implementation of the AliFMDSimulator that
84 // uses the TGeo classes directly only.
86 // * AliFMDG3Simulator
87 // This is a concrete implementation of the AliFMDSimulator that
88 // uses the TVirtualMC interface with GEANT 3.21-like messages.
91 // These files are not in the same directory, so there's no reason to
92 // ask the preprocessor to search in the current directory for these
93 // files by including them with `#include "..."'
94 #include <math.h> // __CMATH__
95 #include <TClonesArray.h> // ROOT_TClonesArray
96 #include <TGeometry.h> // ROOT_TGeomtry
97 #include <TNode.h> // ROOT_TNode
98 #include <TXTRU.h> // ROOT_TXTRU
99 #include <TRotMatrix.h> // ROOT_TRotMatrix
100 #include <TTUBE.h> // ROOT_TTUBE
101 #include <TTree.h> // ROOT_TTree
102 #include <TBrowser.h> // ROOT_TBrowser
103 #include <TMath.h> // ROOT_TMath
104 #include <TVirtualMC.h> // ROOT_TVirtualMC
106 #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H
107 #include <AliLoader.h> // ALILOADER_H
108 #include <AliRun.h> // ALIRUN_H
109 #include <AliMC.h> // ALIMC_H
110 #include "AliMagF.h" // ALIMAGF_H
111 #include <AliLog.h> // ALILOG_H
112 #include "AliFMD.h" // ALIFMD_H
113 #include "AliFMDDigit.h" // ALIFMDDIGIG_H
114 #include "AliFMDHit.h" // ALIFMDHIT_H
115 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
116 #include "AliFMDDetector.h" // ALIFMDDETECTOR_H
117 #include "AliFMDRing.h" // ALIFMDRING_H
118 #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H
120 #include "AliFMDSimulator.h" // ALIFMDSIMULATOR_H
121 #include "AliFMDG3Simulator.h" // ALIFMDG3SIMULATOR_H
122 #include "AliFMDGeoSimulator.h" // ALIFMDGEOSIMULATOR_H
123 #include "AliFMDG3OldSimulator.h" // ALIFMDG3OLDSIMULATOR_H
124 #include "AliFMDGeoOldSimulator.h" // ALIFMDGEOOLDSIMULATOR_H
126 #include "AliFMDGeometryBuilderSimple.h"
128 #include "AliFMDRawWriter.h" // ALIFMDRAWWRITER_H
129 #include <TVector2.h>
131 //____________________________________________________________________
134 ; // This is to keep Emacs from indenting the next line
137 //____________________________________________________________________
149 // Default constructor for class AliFMD
151 AliDebug(10, "\tDefault CTOR");
156 fUseAssembly = kTRUE;
157 fBad = new TClonesArray("AliFMDHit");
160 //____________________________________________________________________
161 AliFMD::AliFMD(const AliFMD& other)
162 : AliDetector(other),
163 fSDigits(other.fSDigits),
164 fNsdigits(other.fNsdigits),
165 fDetailed(other.fDetailed),
167 fSimulator(other.fSimulator),
172 fUseOld = other.fUseOld;
173 fUseAssembly = other.fUseAssembly;
176 //____________________________________________________________________
177 AliFMD::AliFMD(const char *name, const char *title)
178 : AliDetector (name, title),
188 // Standard constructor for Forward Multiplicity Detector
190 AliDebug(10, "\tStandard CTOR");
192 fUseAssembly = kFALSE;
193 fBad = new TClonesArray("AliFMDHit");
195 // Initialise Hit array
197 gAlice->GetMCApp()->AddHitList(fHits);
199 // (S)Digits for the detectors disk
203 // CHC: What is this?
205 SetMarkerColor(kRed);
206 SetLineColor(kYellow);
209 //____________________________________________________________________
212 // Destructor for base class AliFMD
235 //____________________________________________________________________
237 AliFMD::operator=(const AliFMD& other)
239 // Assignment operator
240 AliDetector::operator=(other);
241 fSDigits = other.fSDigits;
242 fNsdigits = other.fNsdigits;
243 fDetailed = other.fDetailed;
245 fSimulator = other.fSimulator;
251 //====================================================================
253 // GEometry ANd Traking
255 //____________________________________________________________________
257 AliFMD::CreateGeometry()
260 // Create the geometry of Forward Multiplicity Detector. The actual
261 // construction of the geometry is delegated to the class AliFMDRing
262 // and AliFMDSubDetector and the relevant derived classes.
264 // The flow of this member function is:
266 // FOR rings fInner and fOuter DO
267 // AliFMDRing::Init();
270 // Set up hybrud card support (leg) volume shapes
272 // FOR rings fInner and fOuter DO
273 // AliFMDRing::SetupGeometry();
276 // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO
277 // AliFMDSubDetector::SetupGeomtry();
280 // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO
281 // AliFMDSubDetector::Geomtry();
285 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
286 if (fUseOld) fmd->SetBuilder(new AliFMDGeometryBuilderSimple(fDetailed));
287 fmd->SetDetailed(fDetailed);
288 fmd->UseAssembly(fUseAssembly);
292 AliFatal("Simulator object not made yet!");
295 fSimulator->DefineGeometry();
299 //____________________________________________________________________
300 void AliFMD::CreateMaterials()
302 // Define the materials and tracking mediums needed by the FMD
303 // simulation. These mediums are made by sending the messages
304 // AliMaterial, AliMixture, and AliMedium to the passed AliModule
305 // object module. The defined mediums are
307 // FMD Si$ Silicon (active medium in sensors)
308 // FMD C$ Carbon fibre (support cone for FMD3 and vacuum pipe)
309 // FMD Al$ Aluminium (honeycomb support plates)
310 // FMD PCB$ Printed Circuit Board (FEE board with VA1_3)
311 // FMD Chip$ Electronics chips (currently not used)
312 // FMD Air$ Air (Air in the FMD)
313 // FMD Plastic$ Plastic (Support legs for the hybrid cards)
315 // Pointers to TGeoMedium objects are retrived from the TGeoManager
316 // singleton. These pointers are later used when setting up the
318 AliDebug(10, "\tCreating materials");
319 // Get pointer to geometry singleton object.
320 AliFMDGeometry* geometry = AliFMDGeometry::Instance();
323 if (gGeoManager && gGeoManager->GetMedium("FMD Si$")) {
324 // We need to figure out the some stuff about the geometry
325 fmd->ExtractGeomInfo();
333 Double_t density = 0;
334 Double_t radiationLength = 0;
335 Double_t absorbtionLength = 999;
336 Int_t fieldType = gAlice->Field()->Integ(); // Field type
337 Double_t maxField = gAlice->Field()->Max(); // Field max.
338 Double_t maxBending = 0; // Max Angle
339 Double_t maxStepSize = 0.001; // Max step size
340 Double_t maxEnergyLoss = 1; // Max Delta E
341 Double_t precision = 0.001; // Precision
342 Double_t minStepSize = 0.001; // Minimum step size
347 density = geometry->GetSiDensity();
348 radiationLength = 9.36;
354 AliMaterial(id, "Si$", a, z, density, radiationLength, absorbtionLength);
355 AliMedium(kSiId, "Si$", id,1,fieldType,maxField,maxBending,
356 maxStepSize,maxEnergyLoss,precision,minStepSize);
363 radiationLength = 18.8;
369 AliMaterial(id, "Carbon$", a, z, density, radiationLength, absorbtionLength);
370 AliMedium(kCarbonId, "Carbon$", id,0,fieldType,maxField,maxBending,
371 maxStepSize,maxEnergyLoss,precision,minStepSize);
377 radiationLength = 8.9;
379 AliMaterial(id, "Aluminum$",a,z, density, radiationLength, absorbtionLength);
380 AliMedium(kAlId, "Aluminum$", id, 0, fieldType, maxField, maxBending,
381 maxStepSize, maxEnergyLoss, precision, minStepSize);
388 radiationLength = 1.43;
390 AliMaterial(id, "Copper$",
391 a, z, density, radiationLength, absorbtionLength);
392 AliMedium(kCopperId, "Copper$", id, 0, fieldType, maxField, maxBending,
393 maxStepSize, maxEnergyLoss, precision, minStepSize);
398 Float_t as[] = { 12.0107, 14.0067, 15.9994,
399 1.00794, 28.0855, 107.8682 };
400 Float_t zs[] = { 6., 7., 8.,
402 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
403 0.004367771, 0.844665, 0.09814344903 };
410 AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
411 AliMedium(kSiChipId, "Si Chip$", id, 0, fieldType, maxField, maxBending,
412 maxStepSize, maxEnergyLoss, precision, minStepSize);
417 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
418 Float_t zs[] = { 1., 6., 7., 8.};
419 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
426 AliMixture(id, "Kaption$", as, zs, density, 4, ws);
427 AliMedium(kKaptonId, "Kaption$", id,0,fieldType,maxField,maxBending,
428 maxStepSize,maxEnergyLoss,precision,minStepSize);
433 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
434 Float_t zs[] = { 6., 7., 8., 18. };
435 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
442 AliMixture(id, "Air$", as, zs, density, 4, ws);
443 AliMedium(kAirId, "Air$", id,0,fieldType,maxField,maxBending,
444 maxStepSize,maxEnergyLoss,precision,minStepSize);
449 Float_t zs[] = { 14., 20., 13., 12.,
453 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
454 10.811, 47.867, 22.98977, 39.0983,
455 55.845, 18.9984, 15.9994, 12.0107,
457 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
458 0.01397570, 0.00287685, 0.00445114, 0.00498089,
459 0.00209828, 0.00420000, 0.36043788, 0.27529426,
460 0.01415852, 0.03427566};
467 AliMixture(id, "PCB$", as, zs, density, 14, ws);
468 AliMedium(kPcbId, "PCB$", id,0,fieldType,maxField,maxBending,
469 maxStepSize,maxEnergyLoss,precision,minStepSize);
474 Float_t as[] = { 1.01, 12.01 };
475 Float_t zs[] = { 1., 6. };
476 Float_t ws[] = { 1., 1. };
483 AliMixture(id, "Plastic$", as, zs, density, -2, ws);
484 AliMedium(kPlasticId, "Plastic$", id,0,fieldType,maxField,maxBending,
485 maxStepSize,maxEnergyLoss,precision,minStepSize);
488 AliDebug(10, "\tCreating materials");
491 AliFatal("Simulator object already instantised!");
494 TVirtualMC* mc = TVirtualMC::GetMC();
496 Bool_t geo = mc->IsRootGeometrySupported();
499 fSimulator = new AliFMDGeoOldSimulator(this, fDetailed);
501 fSimulator = new AliFMDGeoSimulator(this, fDetailed);
505 fSimulator = new AliFMDG3OldSimulator(this, fDetailed);
507 fSimulator = new AliFMDG3Simulator(this, fDetailed);
509 AliDebug(1, Form("using a %s as simulation backend",
510 fSimulator->IsA()->GetName()));
511 fSimulator->SetDetailed(fDetailed);
512 fSimulator->UseAssembly(fUseAssembly);
513 fSimulator->DefineMaterials();
517 //____________________________________________________________________
522 //____________________________________________________________________
524 AliFMD::FinishEvent()
527 if (fBad && fBad->GetEntries() > 0) {
528 AliWarning((Form("EndEvent", "got %d 'bad' hits", fBad->GetEntries())));
531 while ((hit = static_cast<AliFMDHit*>(next())))
536 if (fSimulator) fSimulator->EndEvent();
541 //====================================================================
543 // Graphics and event display
545 //____________________________________________________________________
547 AliFMD::BuildGeometry()
550 // Build simple ROOT TNode geometry for event display
552 // Build a simplified geometry of the FMD used for event display
554 // The actual building of the TNodes is done by
555 // AliFMDSubDetector::SimpleGeometry.
556 AliDebug(10, "\tCreating a simplified geometry");
558 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
560 static TXTRU* innerShape = 0;
561 static TXTRU* outerShape = 0;
562 static TObjArray* innerRot = 0;
563 static TObjArray* outerRot = 0;
565 if (!innerShape || !outerShape) {
566 // Make the shapes for the modules
567 for (Int_t i = 0; i < 2; i++) {
570 case 0: r = fmd->GetRing('I'); break;
571 case 1: r = fmd->GetRing('O'); break;
574 AliError(Form("no ring found for i=%d", i));
577 Double_t siThick = r->GetSiThickness();
578 const Int_t nv = r->GetNVerticies();
579 Double_t theta = r->GetTheta();
580 Int_t nmod = r->GetNModules();
582 TXTRU* shape = new TXTRU(r->GetName(), r->GetTitle(), "void", nv, 2);
583 for (Int_t j = 0; j < nv; j++) {
584 TVector2* vv = r->GetVertex(nv - 1 - j);
585 shape->DefineVertex(j, vv->X(), vv->Y());
587 shape->DefineSection(0, -siThick / 2, 1, 0, 0);
588 shape->DefineSection(1, +siThick / 2, 1, 0, 0);
589 shape->SetLineColor(GetLineColor());
591 TObjArray* rots = new TObjArray(nmod);
592 for (Int_t j = 0; j < nmod; j++) {
593 Double_t th = (j + .5) * theta * 2;
594 TString name(Form("FMD_ring_%c_rot_%02d", r->GetId(), j));
595 TString title(Form("FMD Ring %c Rotation # %d", r->GetId(), j));
596 TRotMatrix* rot = new TRotMatrix(name.Data(), title.Data(),
597 90, th, 90, fmod(90+th,360), 0, 0);
601 switch (r->GetId()) {
603 case 'I': innerShape = shape; innerRot = rots; break;
605 case 'O': outerShape = shape; outerRot = rots; break;
610 TNode* top = gAlice->GetGeometry()->GetNode("alice");
612 for (Int_t i = 1; i <= 3; i++) {
613 AliFMDDetector* det = fmd->GetDetector(i);
615 Warning("BuildGeometry", "FMD%d seems to be disabled", i);
619 Double_t rh = det->GetRing('I')->GetHighR();
621 if (det->GetRing('O')) {
622 w = TMath::Abs(det->GetRingZ('O') - det->GetRingZ('I'));
623 id = (TMath::Abs(det->GetRingZ('O'))
624 > TMath::Abs(det->GetRingZ('I')) ? 'O' : 'I');
625 rh = det->GetRing('O')->GetHighR();
627 w += (det->GetRing(id)->GetModuleSpacing() +
628 det->GetRing(id)->GetSiThickness());
629 TShape* shape = new TTUBE(det->GetName(), det->GetTitle(), "void",
630 det->GetRing('I')->GetLowR(), rh, w / 2);
631 Double_t z = (det->GetRingZ('I') - w / 2);
632 if (z > 0) z += det->GetRing(id)->GetModuleSpacing();
634 TNode* node = new TNode(det->GetName(), det->GetTitle(), shape,
638 for (Int_t j = 0; j < 2; j++) {
644 r = det->GetRing('I'); rshape = innerShape; rots = innerRot; break;
646 r = det->GetRing('O'); rshape = outerShape; rots = outerRot; break;
650 Double_t siThick = r->GetSiThickness();
651 Int_t nmod = r->GetNModules();
652 Double_t modspace = r->GetModuleSpacing();
653 Double_t rz = - (z - det->GetRingZ(r->GetId()));
655 for (Int_t k = 0; k < nmod; k++) {
657 Double_t offz = (k % 2 == 1 ? modspace : 0);
658 TRotMatrix* rot = static_cast<TRotMatrix*>(rots->At(k));
659 TString name(Form("%s%c_module_%02d", det->GetName(), r->GetId(),k));
660 TString title(Form("%s%c Module %d", det->GetName(), r->GetId(),k));
661 TNode* mnod = new TNode(name.Data(), title.Data(), rshape,
662 0, 0, rz - siThick / 2
663 + TMath::Sign(offz,z), rot);
664 mnod->SetLineColor(GetLineColor());
666 } // for (Int_t k = 0 ; ...)
667 } // for (Int_t j = 0 ; ...)
668 } // for (Int_t i = 1 ; ...)
671 //____________________________________________________________________
673 AliFMD::DrawDetector()
676 // Draw a shaded view of the Forward multiplicity detector
678 // DebugGuard guard("AliFMD::DrawDetector");
679 AliDebug(10, "\tDraw detector");
682 //Set ALIC mother transparent
683 gMC->Gsatt("ALIC","SEEN",0);
685 gMC->Gdopt("hide", "on");
686 gMC->Gdopt("shad", "on");
687 gMC->Gsatt("*", "fill", 7);
688 gMC->SetClipBox(".");
689 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
691 gMC->Gdraw("alic", 40, 30, 0, 12, 12, .055, .055);
692 gMC->Gdhead(1111, "Forward Multiplicity Detector");
693 gMC->Gdman(16, 10, "MAN");
694 gMC->Gdopt("hide", "off");
698 //____________________________________________________________________
700 AliFMD::DistanceToPrimitive(Int_t, Int_t)
703 // Calculate the distance from the mouse to the FMD on the screen
709 //====================================================================
711 // Hit and Digit managment
713 //____________________________________________________________________
715 AliFMD::MakeBranch(Option_t * option)
717 // Create Tree branches for the FMD.
721 // H Make a branch of TClonesArray of AliFMDHit's
722 // D Make a branch of TClonesArray of AliFMDDigit's
723 // S Make a branch of TClonesArray of AliFMDSDigit's
725 const Int_t kBufferSize = 16000;
726 TString branchname(GetName());
729 if (opt.Contains("H", TString::kIgnoreCase)) {
731 AliDetector::MakeBranch(option);
733 if (opt.Contains("D", TString::kIgnoreCase)) {
735 MakeBranchInTree(fLoader->TreeD(), branchname.Data(),
736 &fDigits, kBufferSize, 0);
738 if (opt.Contains("S", TString::kIgnoreCase)) {
740 MakeBranchInTree(fLoader->TreeS(), branchname.Data(),
741 &fSDigits, kBufferSize, 0);
745 //____________________________________________________________________
747 AliFMD::SetTreeAddress()
749 // Set branch address for the Hits, Digits, and SDigits Tree.
750 if (fLoader->TreeH()) HitsArray();
751 AliDetector::SetTreeAddress();
753 TTree *treeD = fLoader->TreeD();
756 TBranch* branch = treeD->GetBranch ("FMD");
757 if (branch) branch->SetAddress(&fDigits);
760 TTree *treeS = fLoader->TreeS();
763 TBranch* branch = treeS->GetBranch ("FMD");
764 if (branch) branch->SetAddress(&fSDigits);
770 //____________________________________________________________________
772 AliFMD::SetHitsAddressBranch(TBranch *b)
774 // Set the TClonesArray to read hits into.
775 b->SetAddress(&fHits);
778 //____________________________________________________________________
780 AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
782 // Add a hit to the hits tree
784 // The information of the two arrays are decoded as
788 // ivol[0] [UShort_t ] Detector #
789 // ivol[1] [Char_t ] Ring ID
790 // ivol[2] [UShort_t ] Sector #
791 // ivol[3] [UShort_t ] Strip #
792 // hits[0] [Float_t ] Track's X-coordinate at hit
793 // hits[1] [Float_t ] Track's Y-coordinate at hit
794 // hits[3] [Float_t ] Track's Z-coordinate at hit
795 // hits[4] [Float_t ] X-component of track's momentum
796 // hits[5] [Float_t ] Y-component of track's momentum
797 // hits[6] [Float_t ] Z-component of track's momentum
798 // hits[7] [Float_t ] Energy deposited by track
799 // hits[8] [Int_t ] Track's particle Id #
800 // hits[9] [Float_t ] Time when the track hit
803 AddHitByFields(track,
804 UShort_t(vol[0]), // Detector #
805 Char_t(vol[1]), // Ring ID
806 UShort_t(vol[2]), // Sector #
807 UShort_t(vol[3]), // Strip #
814 hits[6], // Energy loss
815 Int_t(hits[7]), // PDG
819 //____________________________________________________________________
821 AliFMD::AddHitByFields(Int_t track,
839 // Add a hit to the list
844 // detector Detector # (1, 2, or 3)
845 // ring Ring ID ('I' or 'O')
846 // sector Sector # (For inner/outer rings: 0-19/0-39)
847 // strip Strip # (For inner/outer rings: 0-511/0-255)
848 // x Track's X-coordinate at hit
849 // y Track's Y-coordinate at hit
850 // z Track's Z-coordinate at hit
851 // px X-component of track's momentum
852 // py Y-component of track's momentum
853 // pz Z-component of track's momentum
854 // edep Energy deposited by track
855 // pdg Track's particle Id #
856 // t Time when the track hit
857 // l Track length through the material.
858 // stop Whether track was stopped or disappeared
860 TClonesArray& a = *(HitsArray());
861 // Search through the list of already registered hits, and see if we
862 // find a hit with the same parameters. If we do, then don't create
863 // a new hit, but rather update the energy deposited in the hit.
864 // This is done, so that a FLUKA based simulation will get the
865 // number of hits right, not just the enerrgy deposition.
867 for (Int_t i = 0; i < fNhits; i++) {
868 if (!a.At(i)) continue;
869 hit = static_cast<AliFMDHit*>(a.At(i));
870 if (hit->Detector() == detector
871 && hit->Ring() == ring
872 && hit->Sector() == sector
873 && hit->Strip() == strip
874 && hit->Track() == track) {
875 AliDebug(1, Form("already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
876 " adding energy (%f) to that hit (%f) -> %f",
877 detector, ring, sector, strip, track, edep, hit->Edep(),
878 hit->Edep() + edep));
879 hit->SetEdep(hit->Edep() + edep);
883 // If hit wasn't already registered, do so know.
884 hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector,
885 strip, x, y, z, px, py, pz, edep, pdg, t,
891 //____________________________________________________________________
893 AliFMD::AddDigit(Int_t* digits, Int_t*)
895 // Add a digit to the Digit tree
899 // digits[0] [UShort_t] Detector #
900 // digits[1] [Char_t] Ring ID
901 // digits[2] [UShort_t] Sector #
902 // digits[3] [UShort_t] Strip #
903 // digits[4] [UShort_t] ADC Count
904 // digits[5] [Short_t] ADC Count, -1 if not used
905 // digits[6] [Short_t] ADC Count, -1 if not used
907 AddDigitByFields(UShort_t(digits[0]), // Detector #
908 Char_t(digits[1]), // Ring ID
909 UShort_t(digits[2]), // Sector #
910 UShort_t(digits[3]), // Strip #
911 UShort_t(digits[4]), // ADC Count1
912 Short_t(digits[5]), // ADC Count2
913 Short_t(digits[6])); // ADC Count3
916 //____________________________________________________________________
918 AliFMD::AddDigitByFields(UShort_t detector,
926 // add a real digit - as coming from data
930 // detector Detector # (1, 2, or 3)
931 // ring Ring ID ('I' or 'O')
932 // sector Sector # (For inner/outer rings: 0-19/0-39)
933 // strip Strip # (For inner/outer rings: 0-511/0-255)
934 // count1 ADC count (a 10-bit word)
935 // count2 ADC count (a 10-bit word), or -1 if not used
936 // count3 ADC count (a 10-bit word), or -1 if not used
937 TClonesArray& a = *(DigitsArray());
940 AliFMDDigit(detector, ring, sector, strip, count1, count2, count3);
943 //____________________________________________________________________
945 AliFMD::AddSDigit(Int_t* digits)
947 // Add a digit to the SDigit tree
951 // digits[0] [UShort_t] Detector #
952 // digits[1] [Char_t] Ring ID
953 // digits[2] [UShort_t] Sector #
954 // digits[3] [UShort_t] Strip #
955 // digits[4] [Float_t] Total energy deposited
956 // digits[5] [UShort_t] ADC Count
957 // digits[6] [Short_t] ADC Count, -1 if not used
958 // digits[7] [Short_t] ADC Count, -1 if not used
960 AddSDigitByFields(UShort_t(digits[0]), // Detector #
961 Char_t(digits[1]), // Ring ID
962 UShort_t(digits[2]), // Sector #
963 UShort_t(digits[3]), // Strip #
964 Float_t(digits[4]), // Edep
965 UShort_t(digits[5]), // ADC Count1
966 Short_t(digits[6]), // ADC Count2
967 Short_t(digits[7])); // ADC Count3
970 //____________________________________________________________________
972 AliFMD::AddSDigitByFields(UShort_t detector,
981 // add a summable digit
985 // detector Detector # (1, 2, or 3)
986 // ring Ring ID ('I' or 'O')
987 // sector Sector # (For inner/outer rings: 0-19/0-39)
988 // strip Strip # (For inner/outer rings: 0-511/0-255)
989 // edep Total energy deposited
990 // count1 ADC count (a 10-bit word)
991 // count2 ADC count (a 10-bit word), or -1 if not used
992 // count3 ADC count (a 10-bit word), or -1 if not used
994 TClonesArray& a = *(SDigitsArray());
997 AliFMDSDigit(detector, ring, sector, strip, edep, count1, count2, count3);
1000 //____________________________________________________________________
1002 AliFMD::ResetSDigits()
1005 // Reset number of digits and the digits array for this detector
1008 if (fSDigits) fSDigits->Clear();
1012 //____________________________________________________________________
1016 // Initialize hit array if not already, and return pointer to it.
1018 fHits = new TClonesArray("AliFMDHit", 1000);
1024 //____________________________________________________________________
1026 AliFMD::DigitsArray()
1028 // Initialize digit array if not already, and return pointer to it.
1030 fDigits = new TClonesArray("AliFMDDigit", 1000);
1036 //____________________________________________________________________
1038 AliFMD::SDigitsArray()
1040 // Initialize digit array if not already, and return pointer to it.
1042 fSDigits = new TClonesArray("AliFMDSDigit", 1000);
1048 //====================================================================
1052 //____________________________________________________________________
1054 AliFMD::Hits2Digits()
1056 // Create AliFMDDigit's from AliFMDHit's. This is done by making a
1057 // AliFMDDigitizer, and executing that code.
1059 Warning("Hits2Digits", "Try not to use this method.\n"
1060 "Instead, use AliSimulator");
1061 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
1062 manager->SetInputStream(0, "galice.root");
1063 manager->SetOutputFile("H2Dfile");
1065 /* AliDigitizer* dig =*/ CreateDigitizer(manager);
1070 //____________________________________________________________________
1072 AliFMD::Hits2SDigits()
1074 // Create AliFMDSDigit's from AliFMDHit's. This is done by creating
1075 // an AliFMDSDigitizer object, and executing it.
1077 AliFMDSDigitizer* digitizer = new AliFMDSDigitizer("galice.root");
1078 digitizer->Exec("");
1083 //____________________________________________________________________
1085 AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
1087 // Create a digitizer object
1088 AliFMDDigitizer* digitizer = new AliFMDDigitizer(manager);
1092 //====================================================================
1094 // Raw data simulation
1096 //__________________________________________________________________
1098 AliFMD::Digits2Raw()
1100 // Turn digits into raw data.
1102 // This uses the class AliFMDRawWriter to do the job. Please refer
1103 // to that class for more information.
1104 AliFMDRawWriter writer(this);
1109 //====================================================================
1113 //__________________________________________________________________
1115 AliFMD::Browse(TBrowser* b)
1117 // Browse this object.
1119 AliDebug(30, "\tBrowsing the FMD");
1120 AliDetector::Browse(b);
1122 if (fSimulator) b->Add(fSimulator);
1124 b->Add(AliFMDGeometry::Instance());
1127 //___________________________________________________________________