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 **************************************************************************/
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Sun Mar 26 17:59:18 2006
19 @brief Implementation of AliFMD base class
21 //____________________________________________________________________
23 // Forward Multiplicity Detector based on Silicon wafers. This class
24 // is the driver for especially simulation.
26 // The Forward Multiplicity Detector consists of 3 sub-detectors FMD1,
27 // FMD2, and FMD3, each of which has 1 or 2 rings of silicon sensors.
29 // This is the base class for all FMD manager classes.
31 // The actual code is done by various separate classes. Below is
32 // diagram showing the relationship between the various FMD classes
33 // that handles the simulation
36 // +----------+ +----------+
37 // | AliFMDv1 | | AliFMDv0 |
38 // +----------+ +----------+
39 // | | +-----------------+
40 // +----+--------------+ +--| AliFMDDigitizer |
41 // | | +-----------------+
42 // | +---------------------+ |
43 // | +--| AliFMDBaseDigitizer |<--+
44 // V 1 | +---------------------+ |
45 // +--------+<>--+ | +------------------+
46 // | AliFMD | +--| AliFMDSDigitizer |
47 // +--------+<>--+ +------------------+
48 // 1 | +---------------------+
49 // +--| AliFMDReconstructor |
50 // +---------------------+
53 // This defines the interface for the various parts of AliROOT that
54 // uses the FMD, like AliFMDSimulator, AliFMDDigitizer,
55 // AliFMDReconstructor, and so on.
58 // This is a concrete implementation of the AliFMD interface.
59 // It is the responsibility of this class to create the FMD
63 // This is a concrete implementation of the AliFMD interface.
64 // It is the responsibility of this class to create the FMD
65 // geometry, process hits in the FMD, and serve hits and digits to
66 // the various clients.
69 // This is the base class for the FMD simulation tasks. The
70 // simulator tasks are responsible to implment the geoemtry, and
73 // * AliFMDReconstructor
74 // This is a concrete implementation of the AliReconstructor that
75 // reconstructs pseudo-inclusive-multiplicities from digits (raw or
78 // Calibration and geometry parameters are managed by separate
79 // singleton managers. These are AliFMDGeometry and
80 // AliFMDParameters. Please refer to these classes for more
81 // information on these.
84 // These files are not in the same directory, so there's no reason to
85 // ask the preprocessor to search in the current directory for these
86 // files by including them with `#include "..."'
87 // #include <math.h> // __CMATH__
88 #include <TClonesArray.h> // ROOT_TClonesArray
89 #include <TGeometry.h> // ROOT_TGeomtry
90 #include <TNode.h> // ROOT_TNode
91 #include <TXTRU.h> // ROOT_TXTRU
92 #include <TRotMatrix.h> // ROOT_TRotMatrix
93 #include <TTUBE.h> // ROOT_TTUBE
94 #include <TTree.h> // ROOT_TTree
95 #include <TBrowser.h> // ROOT_TBrowser
96 // #include <TVirtualMC.h> // ROOT_TVirtualMC
97 #include <TVector2.h> // ROOT_TVector2
99 #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H
100 #include <AliLoader.h> // ALILOADER_H
101 #include <AliRun.h> // ALIRUN_H
102 #include <AliMC.h> // ALIMC_H
103 #include <AliMagF.h> // ALIMAGF_H
104 #include <AliLog.h> // ALILOG_H
105 #include "AliFMD.h" // ALIFMD_H
106 #include "AliFMDDigit.h" // ALIFMDDIGIT_H
107 #include "AliFMDSDigit.h" // ALIFMDSDIGIT_H
108 #include "AliFMDHit.h" // ALIFMDHIT_H
109 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
110 #include "AliFMDDetector.h" // ALIFMDDETECTOR_H
111 #include "AliFMDRing.h" // ALIFMDRING_H
112 #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H
113 #include "AliFMDSDigitizer.h" // ALIFMDSDIGITIZER_H
114 // #include "AliFMDGeometryBuilder.h"
115 #include "AliFMDRawWriter.h" // ALIFMDRAWWRITER_H
116 #include "AliFMDPoints.h" // ALIFMDPOINTS_H
118 //____________________________________________________________________
121 ; // This is to keep Emacs from indenting the next line
124 //____________________________________________________________________
133 // Default constructor for class AliFMD
135 AliDebug(10, "\tDefault CTOR");
140 fUseAssembly = kTRUE;
141 fBad = new TClonesArray("AliFMDHit");
144 //____________________________________________________________________
145 AliFMD::AliFMD(const AliFMD& other)
146 : AliDetector(other),
147 fSDigits(other.fSDigits),
148 fNsdigits(other.fNsdigits),
149 fDetailed(other.fDetailed),
153 fUseOld = other.fUseOld;
154 fUseAssembly = other.fUseAssembly;
157 //____________________________________________________________________
158 AliFMD::AliFMD(const char *name, const char *title)
159 : AliDetector (name, title),
166 // Standard constructor for Forward Multiplicity Detector
168 AliDebug(10, "\tStandard CTOR");
170 fUseAssembly = kFALSE;
171 fBad = new TClonesArray("AliFMDHit");
173 // Initialise Hit array
175 gAlice->GetMCApp()->AddHitList(fHits);
177 // (S)Digits for the detectors disk
181 // CHC: What is this?
183 SetMarkerColor(kRed);
184 SetLineColor(kYellow);
187 //____________________________________________________________________
190 // Destructor for base class AliFMD
213 //____________________________________________________________________
215 AliFMD::operator=(const AliFMD& other)
217 // Assignment operator
218 AliDetector::operator=(other);
219 fSDigits = other.fSDigits;
220 fNsdigits = other.fNsdigits;
221 fDetailed = other.fDetailed;
226 //====================================================================
228 // GEometry ANd Traking
230 //____________________________________________________________________
232 AliFMD::CreateGeometry()
235 // Create the geometry of Forward Multiplicity Detector. The actual
236 // construction of the geometry is delegated to the class
237 // AliFMDGeometryBuilder, invoked by the singleton manager
240 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
241 fmd->SetDetailed(fDetailed);
242 fmd->UseAssembly(fUseAssembly);
246 //____________________________________________________________________
247 void AliFMD::CreateMaterials()
249 // Define the materials and tracking mediums needed by the FMD
250 // simulation. These mediums are made by sending the messages
251 // AliMaterial, AliMixture, and AliMedium to the passed AliModule
252 // object module. The defined mediums are
254 // FMD Si$ Silicon (active medium in sensors)
255 // FMD C$ Carbon fibre (support cone for FMD3 and vacuum pipe)
256 // FMD Al$ Aluminium (honeycomb support plates)
257 // FMD PCB$ Printed Circuit Board (FEE board with VA1_3)
258 // FMD Chip$ Electronics chips (currently not used)
259 // FMD Air$ Air (Air in the FMD)
260 // FMD Plastic$ Plastic (Support legs for the hybrid cards)
262 // The geometry builder should really be the one that creates the
263 // materials, but the architecture of AliROOT makes that design
264 // akward. What should happen, was that the AliFMDGeometryBuilder
265 // made the mediums, and that this class retrives pointers from the
266 // TGeoManager, and registers the mediums here. Alas, it's not
269 AliDebug(10, "\tCreating materials");
270 // Get pointer to geometry singleton object.
271 AliFMDGeometry* geometry = AliFMDGeometry::Instance();
274 if (gGeoManager && gGeoManager->GetMedium("FMD Si$")) {
275 // We need to figure out the some stuff about the geometry
276 fmd->ExtractGeomInfo();
283 Double_t density = 0;
284 Double_t radiationLength = 0;
285 Double_t absorbtionLength = 999;
286 Int_t fieldType = gAlice->Field()->Integ(); // Field type
287 Double_t maxField = gAlice->Field()->Max(); // Field max.
288 Double_t maxBending = 0; // Max Angle
289 Double_t maxStepSize = 0.001; // Max step size
290 Double_t maxEnergyLoss = 1; // Max Delta E
291 Double_t precision = 0.001; // Precision
292 Double_t minStepSize = 0.001; // Minimum step size
297 density = geometry->GetSiDensity();
298 radiationLength = 9.36;
304 AliMaterial(id, "Si$", a, z, density, radiationLength, absorbtionLength);
305 AliMedium(kSiId, "Si$", id,1,fieldType,maxField,maxBending,
306 maxStepSize,maxEnergyLoss,precision,minStepSize);
313 radiationLength = 18.8;
319 AliMaterial(id, "Carbon$", a, z, density, radiationLength, absorbtionLength);
320 AliMedium(kCarbonId, "Carbon$", id,0,fieldType,maxField,maxBending,
321 maxStepSize,maxEnergyLoss,precision,minStepSize);
327 radiationLength = 8.9;
329 AliMaterial(id, "Aluminum$",a,z, density, radiationLength, absorbtionLength);
330 AliMedium(kAlId, "Aluminum$", id, 0, fieldType, maxField, maxBending,
331 maxStepSize, maxEnergyLoss, precision, minStepSize);
338 radiationLength = 1.43;
340 AliMaterial(id, "Copper$",
341 a, z, density, radiationLength, absorbtionLength);
342 AliMedium(kCopperId, "Copper$", id, 0, fieldType, maxField, maxBending,
343 maxStepSize, maxEnergyLoss, precision, minStepSize);
348 Float_t as[] = { 12.0107, 14.0067, 15.9994,
349 1.00794, 28.0855, 107.8682 };
350 Float_t zs[] = { 6., 7., 8.,
352 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
353 0.004367771, 0.844665, 0.09814344903 };
360 AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
361 AliMedium(kSiChipId, "Si Chip$", id, 0, fieldType, maxField, maxBending,
362 maxStepSize, maxEnergyLoss, precision, minStepSize);
367 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
368 Float_t zs[] = { 1., 6., 7., 8.};
369 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
376 AliMixture(id, "Kaption$", as, zs, density, 4, ws);
377 AliMedium(kKaptonId, "Kaption$", id,0,fieldType,maxField,maxBending,
378 maxStepSize,maxEnergyLoss,precision,minStepSize);
383 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
384 Float_t zs[] = { 6., 7., 8., 18. };
385 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
392 AliMixture(id, "Air$", as, zs, density, 4, ws);
393 AliMedium(kAirId, "Air$", id,0,fieldType,maxField,maxBending,
394 maxStepSize,maxEnergyLoss,precision,minStepSize);
399 Float_t zs[] = { 14., 20., 13., 12.,
403 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
404 10.811, 47.867, 22.98977, 39.0983,
405 55.845, 18.9984, 15.9994, 12.0107,
407 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
408 0.01397570, 0.00287685, 0.00445114, 0.00498089,
409 0.00209828, 0.00420000, 0.36043788, 0.27529426,
410 0.01415852, 0.03427566};
417 AliMixture(id, "PCB$", as, zs, density, 14, ws);
418 AliMedium(kPcbId, "PCB$", id,0,fieldType,maxField,maxBending,
419 maxStepSize,maxEnergyLoss,precision,minStepSize);
424 Float_t as[] = { 1.01, 12.01 };
425 Float_t zs[] = { 1., 6. };
426 Float_t ws[] = { 1., 1. };
433 AliMixture(id, "Plastic$", as, zs, density, -2, ws);
434 AliMedium(kPlasticId, "Plastic$", id,0,fieldType,maxField,maxBending,
435 maxStepSize,maxEnergyLoss,precision,minStepSize);
439 //____________________________________________________________________
443 // Initialize the detector
445 AliDebug(1, "Initialising FMD detector object");
446 // AliFMDGeometry* fmd = AliFMDGeometry::Instance();
447 // fmd->InitTransformations();
450 //____________________________________________________________________
452 AliFMD::FinishEvent()
454 // Called at the end of the an event in simulations. If the debug
455 // level is high enough, then the `bad' hits are printed.
457 if (AliLog::GetDebugLevel("FMD", "AliFMD") < 10) return;
458 if (fBad && fBad->GetEntries() > 0) {
459 AliWarning((Form("EndEvent", "got %d 'bad' hits", fBad->GetEntries())));
462 while ((hit = static_cast<AliFMDHit*>(next()))) hit->Print("D");
468 //====================================================================
470 // Graphics and event display
472 //____________________________________________________________________
474 AliFMD::BuildGeometry()
477 // Build simple ROOT TNode geometry for event display. With the new
478 // geometry modeller, TGeoManager, this seems rather redundant.
479 AliDebug(10, "\tCreating a simplified geometry");
481 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
483 static TXTRU* innerShape = 0;
484 static TXTRU* outerShape = 0;
485 static TObjArray* innerRot = 0;
486 static TObjArray* outerRot = 0;
488 if (!innerShape || !outerShape) {
489 // Make the shapes for the modules
490 for (Int_t i = 0; i < 2; i++) {
493 case 0: r = fmd->GetRing('I'); break;
494 case 1: r = fmd->GetRing('O'); break;
497 AliError(Form("no ring found for i=%d", i));
500 Double_t siThick = r->GetSiThickness();
501 const Int_t knv = r->GetNVerticies();
502 Double_t theta = r->GetTheta();
503 Int_t nmod = r->GetNModules();
505 TXTRU* shape = new TXTRU(r->GetName(), r->GetTitle(), "void", knv, 2);
506 for (Int_t j = 0; j < knv; j++) {
507 TVector2* vv = r->GetVertex(knv - 1 - j);
508 shape->DefineVertex(j, vv->X(), vv->Y());
510 shape->DefineSection(0, -siThick / 2, 1, 0, 0);
511 shape->DefineSection(1, +siThick / 2, 1, 0, 0);
512 shape->SetLineColor(GetLineColor());
514 TObjArray* rots = new TObjArray(nmod);
515 for (Int_t j = 0; j < nmod; j++) {
516 Double_t th = (j + .5) * theta * 2;
517 TString name(Form("FMD_ring_%c_rot_%02d", r->GetId(), j));
518 TString title(Form("FMD Ring %c Rotation # %d", r->GetId(), j));
519 TRotMatrix* rot = new TRotMatrix(name.Data(), title.Data(),
520 90, th, 90, fmod(90+th,360), 0, 0);
524 switch (r->GetId()) {
526 case 'I': innerShape = shape; innerRot = rots; break;
528 case 'O': outerShape = shape; outerRot = rots; break;
533 TNode* top = gAlice->GetGeometry()->GetNode("alice");
535 for (Int_t i = 1; i <= 3; i++) {
536 AliFMDDetector* det = fmd->GetDetector(i);
538 Warning("BuildGeometry", "FMD%d seems to be disabled", i);
542 Double_t rh = det->GetRing('I')->GetHighR();
544 if (det->GetRing('O')) {
545 w = TMath::Abs(det->GetRingZ('O') - det->GetRingZ('I'));
546 id = (TMath::Abs(det->GetRingZ('O'))
547 > TMath::Abs(det->GetRingZ('I')) ? 'O' : 'I');
548 rh = det->GetRing('O')->GetHighR();
550 w += (det->GetRing(id)->GetModuleSpacing() +
551 det->GetRing(id)->GetSiThickness());
552 TShape* shape = new TTUBE(det->GetName(), det->GetTitle(), "void",
553 det->GetRing('I')->GetLowR(), rh, w / 2);
554 Double_t z = (det->GetRingZ('I') - w / 2);
555 if (z > 0) z += det->GetRing(id)->GetModuleSpacing();
557 TNode* node = new TNode(det->GetName(), det->GetTitle(), shape,
561 for (Int_t j = 0; j < 2; j++) {
567 r = det->GetRing('I'); rshape = innerShape; rots = innerRot; break;
569 r = det->GetRing('O'); rshape = outerShape; rots = outerRot; break;
573 Double_t siThick = r->GetSiThickness();
574 Int_t nmod = r->GetNModules();
575 Double_t modspace = r->GetModuleSpacing();
576 Double_t rz = - (z - det->GetRingZ(r->GetId()));
578 for (Int_t k = 0; k < nmod; k++) {
580 Double_t offz = (k % 2 == 1 ? modspace : 0);
581 TRotMatrix* rot = static_cast<TRotMatrix*>(rots->At(k));
582 TString name(Form("%s%c_module_%02d", det->GetName(), r->GetId(),k));
583 TString title(Form("%s%c Module %d", det->GetName(), r->GetId(),k));
584 TNode* mnod = new TNode(name.Data(), title.Data(), rshape,
585 0, 0, rz - siThick / 2
586 + TMath::Sign(offz,z), rot);
587 mnod->SetLineColor(GetLineColor());
589 } // for (Int_t k = 0 ; ...)
590 } // for (Int_t j = 0 ; ...)
591 } // for (Int_t i = 1 ; ...)
594 //____________________________________________________________________
596 AliFMD::LoadPoints(Int_t /* track */)
598 // Store x, y, z of all hits in memory for display.
600 // Normally, the hits are drawn using TPolyMarker3D - however, that
601 // is not very useful for the FMD. Therefor, this member function
602 // is overloaded to make TMarker3D, via the class AliFMDPoints.
603 // AliFMDPoints is a local class.
606 AliError(Form("fHits == 0. Name is %s",GetName()));
609 Int_t nHits = fHits->GetEntriesFast();
613 Int_t tracks = gAlice->GetMCApp()->GetNtrack();
614 if (fPoints == 0) fPoints = new TObjArray(2 * tracks);
617 AliFMDGeometry* geom = AliFMDGeometry::Instance();
619 geom->InitTransformations();
621 // Now make markers for each hit
622 // AliInfo(Form("Drawing %d hits (have %d points) for track %d",
623 // nHits, fPoints->GetEntriesFast(), track));
624 for (Int_t ihit = 0; ihit < nHits; ihit++) {
625 AliFMDHit* hit = static_cast<AliFMDHit*>(fHits->At(ihit));
627 Double_t edep = hit->Edep();
628 Double_t m = hit->M();
629 Double_t poverm = (m == 0 ? 0 : hit->P());
630 Double_t absQ = TMath::Abs(hit->Q());
632 // This `if' is to debug abnormal energy depositions. We trigger on
633 // p/m approx larger than or equal to a MIP, and a large edep - more
634 // than 1 keV - a MIP is 100 eV.
635 if (edep > absQ * absQ && poverm > 1) bad = kTRUE;
637 AliFMDPoints* p1 = new AliFMDPoints(hit, GetMarkerColor());
638 // AliPoints* p1 = new AliPoints();
639 // p1->SetMarkerColor(GetMarkerColor());
640 // p1->SetMarkerSize(GetMarkerSize());
641 // p1->SetPoint(0, hit->X(), hit->Y(), hit->Z());
642 p1->SetDetector(this);
643 p1->SetParticle(hit->GetTrack());
644 fPoints->AddAt(p1, hit->GetTrack());
646 p1->SetMarkerColor(4);
647 // p1->SetMarkerSize(2 * GetMarkerSize());
651 geom->Detector2XYZ(hit->Detector(), hit->Ring(), hit->Sector(),
652 hit->Strip(), x, y, z);
653 AliFMDPoints* p = new AliFMDPoints(hit, 3);
654 // AliPoints* p = new AliPoints();
655 // p->SetMarkerColor(3);
656 // p->SetMarkerSize(GetMarkerSize());
657 // p->SetPoint(0, x, y, z);
658 p->SetDetector(this);
659 p->SetParticle(hit->GetTrack());
661 p->SetMarkerColor(3);
662 fPoints->AddAt(p, tracks+hit->GetTrack());
664 p->SetMarkerColor(5);
665 // p->SetMarkerSize(2 * GetMarkerSize());
667 // AliInfo(Form("Adding point at %d", tracks+hit->GetTrack()));
671 //____________________________________________________________________
673 AliFMD::DrawDetector()
675 // Draw a shaded view of the Forward multiplicity detector. This
676 // isn't really useful anymore.
677 AliDebug(10, "\tDraw detector");
680 //____________________________________________________________________
682 AliFMD::DistancetoPrimitive(Int_t, Int_t)
684 // Calculate the distance from the mouse to the FMD on the screen
690 //====================================================================
692 // Hit and Digit managment
694 //____________________________________________________________________
696 AliFMD::MakeBranch(Option_t * option)
698 // Create Tree branches for the FMD.
702 // H Make a branch of TClonesArray of AliFMDHit's
703 // D Make a branch of TClonesArray of AliFMDDigit's
704 // S Make a branch of TClonesArray of AliFMDSDigit's
706 const Int_t kBufferSize = 16000;
707 TString branchname(GetName());
710 if (opt.Contains("H", TString::kIgnoreCase)) {
712 AliDetector::MakeBranch(option);
714 if (opt.Contains("D", TString::kIgnoreCase)) {
716 MakeBranchInTree(fLoader->TreeD(), branchname.Data(),
717 &fDigits, kBufferSize, 0);
719 if (opt.Contains("S", TString::kIgnoreCase)) {
721 MakeBranchInTree(fLoader->TreeS(), branchname.Data(),
722 &fSDigits, kBufferSize, 0);
726 //____________________________________________________________________
728 AliFMD::SetTreeAddress()
730 // Set branch address for the Hits, Digits, and SDigits Tree.
731 if (fLoader->TreeH()) HitsArray();
732 AliDetector::SetTreeAddress();
734 TTree *treeD = fLoader->TreeD();
737 TBranch* branch = treeD->GetBranch ("FMD");
738 if (branch) branch->SetAddress(&fDigits);
741 TTree *treeS = fLoader->TreeS();
744 TBranch* branch = treeS->GetBranch ("FMD");
745 if (branch) branch->SetAddress(&fSDigits);
749 //____________________________________________________________________
751 AliFMD::SetHitsAddressBranch(TBranch *b)
753 // Set the TClonesArray to read hits into.
754 b->SetAddress(&fHits);
757 //____________________________________________________________________
759 AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
761 // Add a hit to the hits tree
763 // The information of the two arrays are decoded as
767 // ivol[0] [UShort_t ] Detector #
768 // ivol[1] [Char_t ] Ring ID
769 // ivol[2] [UShort_t ] Sector #
770 // ivol[3] [UShort_t ] Strip #
771 // hits[0] [Float_t ] Track's X-coordinate at hit
772 // hits[1] [Float_t ] Track's Y-coordinate at hit
773 // hits[3] [Float_t ] Track's Z-coordinate at hit
774 // hits[4] [Float_t ] X-component of track's momentum
775 // hits[5] [Float_t ] Y-component of track's momentum
776 // hits[6] [Float_t ] Z-component of track's momentum
777 // hits[7] [Float_t ] Energy deposited by track
778 // hits[8] [Int_t ] Track's particle Id #
779 // hits[9] [Float_t ] Time when the track hit
782 AddHitByFields(track,
783 UShort_t(vol[0]), // Detector #
784 Char_t(vol[1]), // Ring ID
785 UShort_t(vol[2]), // Sector #
786 UShort_t(vol[3]), // Strip #
793 hits[6], // Energy loss
794 Int_t(hits[7]), // PDG
798 //____________________________________________________________________
800 AliFMD::AddHitByFields(Int_t track,
817 // Add a hit to the list
822 // detector Detector # (1, 2, or 3)
823 // ring Ring ID ('I' or 'O')
824 // sector Sector # (For inner/outer rings: 0-19/0-39)
825 // strip Strip # (For inner/outer rings: 0-511/0-255)
826 // x Track's X-coordinate at hit
827 // y Track's Y-coordinate at hit
828 // z Track's Z-coordinate at hit
829 // px X-component of track's momentum
830 // py Y-component of track's momentum
831 // pz Z-component of track's momentum
832 // edep Energy deposited by track
833 // pdg Track's particle Id #
834 // t Time when the track hit
835 // l Track length through the material.
836 // stop Whether track was stopped or disappeared
838 TClonesArray& a = *(HitsArray());
839 // Search through the list of already registered hits, and see if we
840 // find a hit with the same parameters. If we do, then don't create
841 // a new hit, but rather update the energy deposited in the hit.
842 // This is done, so that a FLUKA based simulation will get the
843 // number of hits right, not just the enerrgy deposition.
845 for (Int_t i = 0; i < fNhits; i++) {
846 if (!a.At(i)) continue;
847 hit = static_cast<AliFMDHit*>(a.At(i));
848 if (hit->Detector() == detector
849 && hit->Ring() == ring
850 && hit->Sector() == sector
851 && hit->Strip() == strip
852 && hit->Track() == track) {
853 AliDebug(1, Form("already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
854 " adding energy (%f) to that hit (%f) -> %f",
855 detector, ring, sector, strip, track, edep, hit->Edep(),
856 hit->Edep() + edep));
857 hit->SetEdep(hit->Edep() + edep);
861 // If hit wasn't already registered, do so know.
862 hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector,
863 strip, x, y, z, px, py, pz, edep, pdg, t,
869 //____________________________________________________________________
871 AliFMD::AddDigit(Int_t* digits, Int_t*)
873 // Add a digit to the Digit tree
877 // digits[0] [UShort_t] Detector #
878 // digits[1] [Char_t] Ring ID
879 // digits[2] [UShort_t] Sector #
880 // digits[3] [UShort_t] Strip #
881 // digits[4] [UShort_t] ADC Count
882 // digits[5] [Short_t] ADC Count, -1 if not used
883 // digits[6] [Short_t] ADC Count, -1 if not used
885 AddDigitByFields(UShort_t(digits[0]), // Detector #
886 Char_t(digits[1]), // Ring ID
887 UShort_t(digits[2]), // Sector #
888 UShort_t(digits[3]), // Strip #
889 UShort_t(digits[4]), // ADC Count1
890 Short_t(digits[5]), // ADC Count2
891 Short_t(digits[6])); // ADC Count3
894 //____________________________________________________________________
896 AliFMD::AddDigitByFields(UShort_t detector,
904 // add a real digit - as coming from data
908 // detector Detector # (1, 2, or 3)
909 // ring Ring ID ('I' or 'O')
910 // sector Sector # (For inner/outer rings: 0-19/0-39)
911 // strip Strip # (For inner/outer rings: 0-511/0-255)
912 // count1 ADC count (a 10-bit word)
913 // count2 ADC count (a 10-bit word), or -1 if not used
914 // count3 ADC count (a 10-bit word), or -1 if not used
915 TClonesArray& a = *(DigitsArray());
918 AliFMDDigit(detector, ring, sector, strip, count1, count2, count3);
921 //____________________________________________________________________
923 AliFMD::AddSDigit(Int_t* digits)
925 // Add a digit to the SDigit tree
929 // digits[0] [UShort_t] Detector #
930 // digits[1] [Char_t] Ring ID
931 // digits[2] [UShort_t] Sector #
932 // digits[3] [UShort_t] Strip #
933 // digits[4] [Float_t] Total energy deposited
934 // digits[5] [UShort_t] ADC Count
935 // digits[6] [Short_t] ADC Count, -1 if not used
936 // digits[7] [Short_t] ADC Count, -1 if not used
938 AddSDigitByFields(UShort_t(digits[0]), // Detector #
939 Char_t(digits[1]), // Ring ID
940 UShort_t(digits[2]), // Sector #
941 UShort_t(digits[3]), // Strip #
942 Float_t(digits[4]), // Edep
943 UShort_t(digits[5]), // ADC Count1
944 Short_t(digits[6]), // ADC Count2
945 Short_t(digits[7])); // ADC Count3
948 //____________________________________________________________________
950 AliFMD::AddSDigitByFields(UShort_t detector,
959 // add a summable digit
963 // detector Detector # (1, 2, or 3)
964 // ring Ring ID ('I' or 'O')
965 // sector Sector # (For inner/outer rings: 0-19/0-39)
966 // strip Strip # (For inner/outer rings: 0-511/0-255)
967 // edep Total energy deposited
968 // count1 ADC count (a 10-bit word)
969 // count2 ADC count (a 10-bit word), or -1 if not used
970 // count3 ADC count (a 10-bit word), or -1 if not used
972 TClonesArray& a = *(SDigitsArray());
975 AliFMDSDigit(detector, ring, sector, strip, edep, count1, count2, count3);
978 //____________________________________________________________________
980 AliFMD::ResetSDigits()
982 // Reset number of digits and the digits array for this detector.
985 if (fSDigits) fSDigits->Clear();
989 //____________________________________________________________________
993 // Initialize hit array if not already, and return pointer to it.
995 fHits = new TClonesArray("AliFMDHit", 1000);
1001 //____________________________________________________________________
1003 AliFMD::DigitsArray()
1005 // Initialize digit array if not already, and return pointer to it.
1007 fDigits = new TClonesArray("AliFMDDigit", 1000);
1013 //____________________________________________________________________
1015 AliFMD::SDigitsArray()
1017 // Initialize digit array if not already, and return pointer to it.
1019 fSDigits = new TClonesArray("AliFMDSDigit", 1000);
1025 //====================================================================
1029 //____________________________________________________________________
1031 AliFMD::Hits2Digits()
1033 // Create AliFMDDigit's from AliFMDHit's. This is done by making a
1034 // AliFMDDigitizer, and executing that code.
1036 Warning("Hits2Digits", "Try not to use this method.\n"
1037 "Instead, use AliSimulator");
1038 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
1039 manager->SetInputStream(0, "galice.root");
1040 manager->SetOutputFile("H2Dfile");
1042 /* AliDigitizer* dig =*/ CreateDigitizer(manager);
1047 //____________________________________________________________________
1049 AliFMD::Hits2SDigits()
1051 // Create AliFMDSDigit's from AliFMDHit's. This is done by creating
1052 // an AliFMDSDigitizer object, and executing it.
1054 AliFMDSDigitizer* digitizer = new AliFMDSDigitizer("galice.root");
1055 digitizer->Exec("");
1060 //____________________________________________________________________
1062 AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
1064 // Create a digitizer object
1065 AliFMDDigitizer* digitizer = new AliFMDDigitizer(manager);
1069 //====================================================================
1071 // Raw data simulation
1073 //__________________________________________________________________
1075 AliFMD::Digits2Raw()
1077 // Turn digits into raw data.
1079 // This uses the class AliFMDRawWriter to do the job. Please refer
1080 // to that class for more information.
1081 AliFMDRawWriter writer(this);
1086 //====================================================================
1090 //__________________________________________________________________
1092 AliFMD::Browse(TBrowser* b)
1094 // Browse this object.
1096 AliDebug(30, "\tBrowsing the FMD");
1097 AliDetector::Browse(b);
1098 b->Add(AliFMDGeometry::Instance());
1101 //___________________________________________________________________