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 5 Si volumes covered pseudorapidity interval
25 // The actual code is done by various separate classes. Below is
26 // diagram showing the relationship between the various FMD classes
27 // that handles the geometry
30 // +----------+ +----------+
31 // | AliFMDv1 | | AliFMDv1 |
32 // +----------+ +----------+
34 // +----+--------------+
36 // | +------------+ 1 +---------------+
37 // | +- | AliFMDRing |<>--| AliFMDPolygon |
38 // V 2 | +------------+ +---------------+
41 // +--------+<>--+ V 1..2
42 // 3 | +-------------------+
43 // +-| AliFMDSubDetector |
44 // +-------------------+
47 // +-------------+-------------+
49 // +---------+ +---------+ +---------+
50 // | AliFMD1 | | AliFMD2 | | AliFMD3 |
51 // +---------+ +---------+ +---------+
55 // This defines the interface for the various parts of AliROOT that
56 // uses the FMD, like AliFMDDigitizer, AliFMDReconstructor, and so
60 // This is a concrete implementation of the AliFMD interface.
61 // It is the responsibility of this class to create the FMD
62 // geometry, process hits in the FMD, and serve hits and digits to
63 // the various clients.
65 // It uses the objects of class AliFMDSubDetector to do the various
66 // stuff for FMD1, 2, and 3
69 // This class contains all stuff needed to do with a ring. It's
70 // used by the AliFMDSubDetector objects to instantise inner and
71 // outer rings. The AliFMDRing objects are shared by the
72 // AliFMDSubDetector objects, and owned by the AliFMDv1 object.
75 // The code I lifted from TGeoPolygon to help with the geometry of
76 // the modules, as well as to decide wether a hit is actually with
77 // in the real module shape. The point is, that the shape of the
78 // various ring modules are really polygons (much like the lid of a
79 // coffin), but it's segmented at constant radius. That is very
80 // hard to implement using GEANT 3.21 shapes, so instead the
81 // modules are implemented as TUBS (tube sections), and in the step
82 // procedure we do the test whether the track was inside the real
83 // shape of the module.
85 // * AliFMD1, AliFMD2, and AliFMD3
86 // These are specialisation of AliFMDSubDetector, that contains the
87 // particularities of each of the sub-detector system. It is
88 // envisioned that the classes should also define the support
89 // volumes and material for each of the detectors.
96 The responsible person for this module is
97 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
100 Many modifications by <a href="mailto:cholm@nbi.dk">Christian
101 Holm Christensen</a>.
107 #ifndef ROOT_TClonesArray
108 #include <TClonesArray.h>
110 #ifndef ROOT_TGeomtry
111 # include <TGeometry.h>
122 #ifndef ROOT_TVirtualMC
123 # include <TVirtualMC.h>
125 #ifndef ROOT_TBrowser
126 # include <TBrowser.h>
132 #ifndef ALIRUNDIGITIZER_H
133 # include "AliRunDigitizer.h"
136 # include "AliLoader.h"
148 # include "AliMagF.h"
153 #ifndef ALIFMDDIGIG_H
154 # include "AliFMDDigit.h"
157 # include "AliFMDHit.h"
159 #ifndef ALIFMDDIGITIZER_H
160 # include "AliFMDDigitizer.h"
163 # include "AliFMD1.h"
166 # include "AliFMD2.h"
169 # include "AliFMD3.h"
171 #ifndef ALIALTROBUFFER_H
172 # include "AliAltroBuffer.h"
175 //____________________________________________________________________
178 //____________________________________________________________________
187 // Default constructor for class AliFMD
189 AliDebug(0, "Default CTOR");
197 //____________________________________________________________________
198 AliFMD::AliFMD(const char *name, const char *title, bool detailed)
199 : AliDetector (name, title),
207 // Standard constructor for Forward Multiplicity Detector
209 AliDebug(0, "Standard CTOR");
211 // Initialise Hit array
213 gAlice->GetMCApp()->AddHitList(fHits);
215 // (S)Digits for the detectors disk
219 // CHC: What is this?
221 SetMarkerColor(kRed);
222 SetLineColor(kYellow);
225 // Create sub-volume managers
226 fInner = new AliFMDRing('I', detailed);
227 fOuter = new AliFMDRing('O', detailed);
228 fFMD1 = new AliFMD1();
229 fFMD2 = new AliFMD2();
230 fFMD3 = new AliFMD3();
232 // Specify parameters of sub-volume managers
233 fFMD1->SetInner(fInner);
236 fFMD2->SetInner(fInner);
237 fFMD2->SetOuter(fOuter);
239 fFMD3->SetInner(fInner);
240 fFMD3->SetOuter(fOuter);
247 fInner->SetLowR(4.3);
248 fInner->SetHighR(17.2);
249 fInner->SetWaferRadius(13.4/2);
250 fInner->SetTheta(36/2);
251 fInner->SetNStrips(512);
252 fInner->SetSiThickness(.03);
253 fInner->SetPrintboardThickness(.11);
254 fInner->SetBondingWidth(.5);
256 fOuter->SetLowR(15.6);
257 fOuter->SetHighR(28.0);
258 fOuter->SetWaferRadius(13.4/2);
259 fOuter->SetTheta(18/2);
260 fOuter->SetNStrips( 256);
261 fOuter->SetSiThickness(.03);
262 fOuter->SetPrintboardThickness(.1);
263 fOuter->SetBondingWidth(.5);
266 fFMD1->SetHoneycombThickness(1);
267 fFMD1->SetInnerZ(340.0);
269 fFMD2->SetHoneycombThickness(1);
270 fFMD2->SetInnerZ(83.4);
271 fFMD2->SetOuterZ(75.2);
273 fFMD3->SetHoneycombThickness(1);
274 fFMD3->SetInnerZ(-62.8);
275 fFMD3->SetOuterZ(-75.2);
278 //____________________________________________________________________
281 // Destructor for base class AliFMD
299 //====================================================================
301 // GEometry ANd Traking
303 //____________________________________________________________________
305 AliFMD::CreateGeometry()
308 // Create the geometry of Forward Multiplicity Detector version 0
310 // DebugGuard guard("AliFMD::CreateGeometry");
311 AliDebug(10, "Creating geometry");
319 par[0] = fLegRadius - .1;
321 par[2] = fLegLength / 2;
323 fShortLegId = gMC->Gsvolu(name.Data(),"TUBE",(*fIdtmed)[kPlasticId],par,3);
325 par[2] += fModuleSpacing / 2;
327 fLongLegId = gMC->Gsvolu(name.Data(),"TUBE",(*fIdtmed)[kPlasticId],par,3);
329 fInner->SetupGeometry((*fIdtmed)[kAirId],
332 fPrintboardRotationId,
333 fIdentityRotationId);
334 fOuter->SetupGeometry((*fIdtmed)[kAirId],
337 fPrintboardRotationId,
338 fIdentityRotationId);
340 fFMD1->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
341 fFMD2->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
342 fFMD3->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
344 fFMD1->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
345 fFMD2->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
346 fFMD3->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
349 //____________________________________________________________________
350 void AliFMD::CreateMaterials()
352 // Register various materials and tracking mediums with the
355 // Currently defined materials and mediums are
357 // FMD Air Normal air
358 // FMD Si Active silicon of sensors
359 // FMD Carbon Normal carbon used in support, etc.
360 // FMD Kapton Carbon used in Honeycomb
361 // FMD PCB Printed circuit board material
362 // FMD Plastic Material for support legs
364 // Also defined are two rotation matricies.
366 // DebugGuard guard("AliFMD::CreateMaterials");
367 AliDebug(10, "Creating materials");
371 Double_t density = 0;
372 Double_t radiationLength = 0;
373 Double_t absorbtionLength = 999;
374 Int_t fieldType = gAlice->Field()->Integ(); // Field type
375 Double_t maxField = gAlice->Field()->Max(); // Field max.
376 Double_t maxBending = 0; // Max Angle
377 Double_t maxStepSize = 0.001; // Max step size
378 Double_t maxEnergyLoss = 1; // Max Delta E
379 Double_t precision = 0.001; // Precision
380 Double_t minStepSize = 0.001; // Minimum step size
385 density = fSiDensity;
386 radiationLength = 9.36;
392 AliMaterial(id, "FMD Si$", a, z, density, radiationLength, absorbtionLength);
393 AliMedium(kSiId, "FMD Si$",id,1,fieldType,maxField,maxBending,
394 maxStepSize,maxEnergyLoss,precision,minStepSize);
401 radiationLength = 18.8;
407 AliMaterial(id, "FMD Carbon$", a, z, density, radiationLength,
409 AliMedium(kCarbonId, "FMD Carbon$",id,0,fieldType,maxField,maxBending,
410 maxStepSize,maxEnergyLoss,precision,minStepSize);
414 Float_t as[] = { 12.0107, 14.0067, 15.9994,
415 1.00794, 28.0855, 107.8682 };
416 Float_t zs[] = { 6., 7., 8.,
418 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
419 0.004367771, 0.844665, 0.09814344903 };
426 AliMixture(id, "FMD Si Chip$", as, zs, density, 6, ws);
427 AliMedium(kSiChipId, "FMD Si Chip$", id, 0, fieldType, maxField,
428 maxBending, maxStepSize, maxEnergyLoss, precision, minStepSize);
434 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
435 Float_t zs[] = { 1., 6., 7., 8.};
436 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
443 AliMixture(id, "FMD Kaption$", as, zs, density, 4, ws);
444 AliMedium(kKaptionId, "FMD Kaption$",id,0,fieldType,maxField,maxBending,
445 maxStepSize,maxEnergyLoss,precision,minStepSize);
450 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
451 Float_t zs[] = { 6., 7., 8., 18. };
452 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
459 AliMixture(id, "FMD Air$", as, zs, density, 4, ws);
460 AliMedium(kAirId, "FMD Air$", id,0,fieldType,maxField,maxBending,
461 maxStepSize,maxEnergyLoss,precision,minStepSize);
466 Float_t zs[] = { 14., 20., 13., 12.,
470 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
471 10.811, 47.867, 22.98977, 39.0983,
472 55.845, 18.9984, 15.9994, 12.0107,
474 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
475 0.01397570, 0.00287685, 0.00445114, 0.00498089,
476 0.00209828, 0.00420000, 0.36043788, 0.27529426,
477 0.01415852, 0.03427566};
484 AliMixture(id, "FMD PCB$", as, zs, density, 14, ws);
485 AliMedium(kPcbId, "FMD PCB$", id,1,fieldType,maxField,maxBending,
486 maxStepSize,maxEnergyLoss,precision,minStepSize);
491 Float_t as[] = { 1.01, 12.01 };
492 Float_t zs[] = { 1., 6. };
493 Float_t ws[] = { 1., 1. };
500 AliMixture(id, "FMD Plastic$", as, zs, density, -2, ws);
501 AliMedium(kPlasticId, "FMD Plastic$", id,0,fieldType,maxField,maxBending,
502 maxStepSize,maxEnergyLoss,precision,minStepSize);
504 AliMatrix(fPrintboardRotationId, 90, 90, 0, 90, 90, 0);
505 AliMatrix(fIdentityRotationId, 90, 0, 90, 90, 0, 0);
508 //____________________________________________________________________
513 // Initialis the FMD after it has been built
517 std::cout << "\n" << ClassName() << ": " << std::flush;
518 for (i = 0; i < 35; i++) std::cout << "*";
519 std::cout << " FMD_INIT ";
520 for (i = 0; i < 35; i++) std::cout << "*";
521 std::cout << "\n" << ClassName() << ": " << std::flush;
523 // Here the FMD initialisation code (if any!)
524 for (i = 0; i < 80; i++) std::cout << "*";
525 std::cout << std::endl;
531 //====================================================================
533 // Graphics and event display
535 //____________________________________________________________________
537 AliFMD::BuildGeometry()
540 // Build simple ROOT TNode geometry for event display
542 // Build a simplified geometry of the FMD used for event display
544 AliDebug(10, "Creating a simplified geometry");
546 TNode* top = gAlice->GetGeometry()->GetNode("alice");
548 fFMD1->SimpleGeometry(fNodes, top, GetLineColor(), 0);
549 fFMD2->SimpleGeometry(fNodes, top, GetLineColor(), 0);
550 fFMD3->SimpleGeometry(fNodes, top, GetLineColor(), 0);
553 //____________________________________________________________________
555 AliFMD::DrawDetector()
558 // Draw a shaded view of the Forward multiplicity detector version 0
560 // DebugGuard guard("AliFMD::DrawDetector");
561 AliDebug(10, "Draw detector");
563 //Set ALIC mother transparent
564 gMC->Gsatt("ALIC","SEEN",0);
566 //Set volumes visible
574 gMC->Gdopt("hide", "on");
575 gMC->Gdopt("shad", "on");
576 gMC->Gsatt("*", "fill", 7);
577 gMC->SetClipBox(".");
578 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
580 gMC->Gdraw("alic", 40, 30, 0, 12, 12, .055, .055);
581 gMC->Gdhead(1111, "Forward Multiplicity Detector");
582 gMC->Gdman(16, 10, "MAN");
583 gMC->Gdopt("hide", "off");
586 //____________________________________________________________________
588 AliFMD::DistanceToPrimitive(Int_t, Int_t)
591 // Calculate the distance from the mouse to the FMD on the screen
597 //====================================================================
599 // Hit and Digit managment
601 //____________________________________________________________________
603 AliFMD::MakeBranch(Option_t * option)
605 // Create Tree branches for the FMD.
606 const Int_t kBufferSize = 16000;
607 TString branchname(GetName());
610 if (opt.Contains("H", TString::kIgnoreCase)) {
612 AliDetector::MakeBranch(option);
614 if (opt.Contains("D", TString::kIgnoreCase)) {
616 MakeBranchInTree(fLoader->TreeD(), branchname.Data(),
617 &fDigits, kBufferSize, 0);
619 if (opt.Contains("S", TString::kIgnoreCase)) {
621 MakeBranchInTree(fLoader->TreeS(), branchname.Data(),
622 &fSDigits, kBufferSize, 0);
626 //____________________________________________________________________
628 AliFMD::SetTreeAddress()
630 // Set branch address for the Hits and Digits Tree.
632 if (fLoader->TreeH()) HitsArray();
633 AliDetector::SetTreeAddress();
635 TTree *treeD = fLoader->TreeD();
638 TBranch* branch = treeD->GetBranch ("FMD");
639 if (branch) branch->SetAddress(&fDigits);
642 TTree *treeS = fLoader->TreeS();
645 TBranch* branch = treeS->GetBranch ("FMD");
646 if (branch) branch->SetAddress(&fSDigits);
652 //____________________________________________________________________
654 AliFMD::SetHitsAddressBranch(TBranch *b)
656 b->SetAddress(&fHits);
659 //____________________________________________________________________
661 AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
663 // Add a hit to the hits tree
665 // The information of the two arrays are decoded as
669 // ivol[0] [UShort_t ] Detector #
670 // ivol[1] [Char_t ] Ring ID
671 // ivol[2] [UShort_t ] Sector #
672 // ivol[3] [UShort_t ] Strip #
673 // hits[0] [Float_t ] Track's X-coordinate at hit
674 // hits[1] [Float_t ] Track's Y-coordinate at hit
675 // hits[3] [Float_t ] Track's Z-coordinate at hit
676 // hits[4] [Float_t ] X-component of track's momentum
677 // hits[5] [Float_t ] Y-component of track's momentum
678 // hits[6] [Float_t ] Z-component of track's momentum
679 // hits[7] [Float_t ] Energy deposited by track
680 // hits[8] [Int_t ] Track's particle Id #
681 // hits[9] [Float_t ] Time when the track hit
683 UShort_t(vol[0]), // Detector #
684 Char_t(vol[1]), // Ring ID
685 UShort_t(vol[2]), // Sector #
686 UShort_t(vol[3]), // Strip #
693 hits[6], // Energy loss
694 Int_t(hits[7]), // PDG
698 //____________________________________________________________________
700 AliFMD::AddHit(Int_t track,
716 // Add a hit to the list
721 // detector Detector # (1, 2, or 3)
722 // ring Ring ID ('I' or 'O')
723 // sector Sector # (For inner/outer rings: 0-19/0-39)
724 // strip Strip # (For inner/outer rings: 0-511/0-255)
725 // x Track's X-coordinate at hit
726 // y Track's Y-coordinate at hit
727 // z Track's Z-coordinate at hit
728 // px X-component of track's momentum
729 // py Y-component of track's momentum
730 // pz Z-component of track's momentum
731 // edep Energy deposited by track
732 // pdg Track's particle Id #
733 // t Time when the track hit
735 TClonesArray& a = *(HitsArray());
736 // Search through the list of already registered hits, and see if we
737 // find a hit with the same parameters. If we do, then don't create
738 // a new hit, but rather update the energy deposited in the hit.
739 // This is done, so that a FLUKA based simulation will get the
740 // number of hits right, not just the enerrgy deposition.
741 for (Int_t i = 0; i < fNhits; i++) {
742 if (!a.At(i)) continue;
743 AliFMDHit* hit = static_cast<AliFMDHit*>(a.At(i));
744 if (hit->Detector() == detector
745 && hit->Ring() == ring
746 && hit->Sector() == sector
747 && hit->Strip() == strip
748 && hit->Track() == track) {
749 hit->SetEdep(hit->Edep() + edep);
753 // If hit wasn't already registered, do so know.
754 new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, strip,
755 x, y, z, px, py, pz, edep, pdg, t);
759 //____________________________________________________________________
761 AliFMD::AddDigit(Int_t* digits)
763 // Add a digit to the Digit tree
767 // digits[0] [UShort_t] Detector #
768 // digits[1] [Char_t] Ring ID
769 // digits[2] [UShort_t] Sector #
770 // digits[3] [UShort_t] Strip #
771 // digits[4] [UShort_t] ADC Count
772 // digits[5] [Short_t] ADC Count, -1 if not used
773 // digits[6] [Short_t] ADC Count, -1 if not used
775 AddDigit(UShort_t(digits[0]), // Detector #
776 Char_t(digits[1]), // Ring ID
777 UShort_t(digits[2]), // Sector #
778 UShort_t(digits[3]), // Strip #
779 UShort_t(digits[4]), // ADC Count1
780 Short_t(digits[5]), // ADC Count2
781 Short_t(digits[6])); // ADC Count3
784 //____________________________________________________________________
786 AliFMD::AddDigit(UShort_t detector,
794 // add a real digit - as coming from data
798 // detector Detector # (1, 2, or 3)
799 // ring Ring ID ('I' or 'O')
800 // sector Sector # (For inner/outer rings: 0-19/0-39)
801 // strip Strip # (For inner/outer rings: 0-511/0-255)
802 // count1 ADC count (a 10-bit word)
803 // count2 ADC count (a 10-bit word), or -1 if not used
804 // count3 ADC count (a 10-bit word), or -1 if not used
805 TClonesArray& a = *(DigitsArray());
808 AliFMDDigit(detector, ring, sector, strip, count1, count2, count3);
811 //____________________________________________________________________
813 AliFMD::AddSDigit(Int_t* digits)
815 // Add a digit to the SDigit tree
819 // digits[0] [UShort_t] Detector #
820 // digits[1] [Char_t] Ring ID
821 // digits[2] [UShort_t] Sector #
822 // digits[3] [UShort_t] Strip #
823 // digits[4] [Float_t] Total energy deposited
824 // digits[5] [UShort_t] ADC Count
825 // digits[6] [Short_t] ADC Count, -1 if not used
826 // digits[7] [Short_t] ADC Count, -1 if not used
828 AddSDigit(UShort_t(digits[0]), // Detector #
829 Char_t(digits[1]), // Ring ID
830 UShort_t(digits[2]), // Sector #
831 UShort_t(digits[3]), // Strip #
832 Float_t(digits[4]), // Edep
833 UShort_t(digits[5]), // ADC Count1
834 Short_t(digits[6]), // ADC Count2
835 Short_t(digits[7])); // ADC Count3
838 //____________________________________________________________________
840 AliFMD::AddSDigit(UShort_t detector,
849 // add a summable digit
853 // detector Detector # (1, 2, or 3)
854 // ring Ring ID ('I' or 'O')
855 // sector Sector # (For inner/outer rings: 0-19/0-39)
856 // strip Strip # (For inner/outer rings: 0-511/0-255)
857 // edep Total energy deposited
858 // count1 ADC count (a 10-bit word)
859 // count2 ADC count (a 10-bit word), or -1 if not used
860 // count3 ADC count (a 10-bit word), or -1 if not used
861 TClonesArray& a = *(SDigitsArray());
864 AliFMDSDigit(detector, ring, sector, strip, edep, count1, count2, count3);
867 //____________________________________________________________________
869 AliFMD::ResetSDigits()
872 // Reset number of digits and the digits array for this detector
875 if (fSDigits) fSDigits->Clear();
879 //____________________________________________________________________
883 // Initialize hit array if not already, and return pointer to it.
885 fHits = new TClonesArray("AliFMDHit", 1000);
891 //____________________________________________________________________
893 AliFMD::DigitsArray()
895 // Initialize digit array if not already, and return pointer to it.
897 fDigits = new TClonesArray("AliFMDDigit", 1000);
903 //____________________________________________________________________
905 AliFMD::SDigitsArray()
907 // Initialize digit array if not already, and return pointer to it.
909 fSDigits = new TClonesArray("AliFMDSDigit", 1000);
915 //====================================================================
919 //____________________________________________________________________
921 AliFMD::Hits2Digits()
923 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
924 manager->SetInputStream(0, "galice.root");
925 manager->SetOutputFile("H2Dfile");
927 /* AliDigitizer* dig =*/ CreateDigitizer(manager);
931 //____________________________________________________________________
933 AliFMD::Hits2SDigits()
935 AliDigitizer* sdig = new AliFMDSDigitizer("galice.root");
940 //____________________________________________________________________
942 AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
944 // Create a digitizer object
945 return new AliFMDDigitizer(manager);
948 //====================================================================
950 // Raw data simulation
952 //__________________________________________________________________
956 AliFMD* fmd = static_cast<AliFMD*>(gAlice->GetDetector(GetName()));
957 fLoader->LoadDigits();
958 TTree* digitTree = fLoader->TreeD();
960 Error("Digits2Raw", "no digit tree");
964 TClonesArray* digits = new TClonesArray("AliFMDDigit", 1000);
965 fmd->SetTreeAddress();
966 TBranch* digitBranch = digitTree->GetBranch(GetName());
968 Error("Digits2Raw", "no branch for %s", GetName());
971 digitBranch->SetAddress(&digits);
973 Int_t nEvents = Int_t(digitTree->GetEntries());
974 for (Int_t event = 0; event < nEvents; event++) {
976 digitTree->GetEvent(event);
978 Int_t nDigits = digits->GetEntries();
979 if (nDigits < 1) continue;
982 UShort_t prevDetector = 0;
983 Char_t prevRing = '\0';
984 UShort_t prevSector = 0;
985 // UShort_t prevStrip = 0;
987 // The first seen strip number for a channel
988 UShort_t startStrip = 0;
990 // Which channel number in the ALTRO channel we're at
993 // How many times the ALTRO Samples one VA1_ALICE channel
994 Int_t sampleRate = 1;
996 // A buffer to hold 1 ALTRO channel - Normally, one ALTRO channel
997 // holds 128 VA1_ALICE channels, sampled at a rate of `sampleRate'
998 TArrayI channel(128 * sampleRate);
1001 AliAltroBuffer* altro = 0;
1003 // Loop over the digits in the event. Note, that we assume the
1004 // the digits are in order in the branch. If they were not, we'd
1005 // have to cache all channels before we could write the data to
1006 // the ALTRO buffer, or we'd have to set up a map of the digits.
1007 for (Int_t i = 0; i < nDigits; i++) {
1009 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
1011 UShort_t det = digit->Detector();
1012 Char_t ring = digit->Ring();
1013 UShort_t sector = digit->Sector();
1014 UShort_t strip = digit->Strip();
1015 if (det != prevDetector) {
1016 AliDebug(10, Form("FMD: New DDL, was %d, now %d",
1017 kBaseDDL + prevDetector - 1,
1018 kBaseDDL + det - 1));
1019 // If an altro exists, delete the object, flushing the data to
1020 // disk, and closing the file.
1022 // When the first argument is false, we write the real
1024 AliDebug(10, Form("New altro: Write channel at %d Strip: %d "
1025 "Sector: %d Ring: %d",
1026 i, startStrip, prevSector, prevRing));
1027 // TPC to FMD translations
1030 // ----------+-----------
1035 altro->WriteChannel(Int_t(startStrip),
1037 Int_t((prevRing == 'I' ? 0 : 1)),
1038 channel.fN, channel.fArray, 0);
1040 altro->WriteDataHeader(kFALSE, kFALSE);
1046 // Need to open a new DDL!
1047 Int_t ddlId = kBaseDDL + det - 1;
1048 TString filename(Form("%s_%d.ddl", GetName(), ddlId));
1050 AliDebug(10, Form("New altro buffer with DDL file %s",
1052 AliDebug(10, Form("New altro at %d", i));
1053 // Create a new altro buffer - a `1' as the second argument
1054 // means `write mode'
1055 altro = new AliAltroBuffer(filename.Data(), 1);
1057 // Write a dummy (first argument is true) header to the DDL
1058 // file - later on, when we close the file, we write the real
1060 altro->WriteDataHeader(kTRUE, kFALSE);
1062 // Figure out the sample rate
1063 if (digit->Count2() > 0) sampleRate = 2;
1064 if (digit->Count3() > 0) sampleRate = 3;
1066 channel.Set(128 * sampleRate);
1069 prevSector = sector;
1072 else if (offset == 128
1073 || digit->Ring() != prevRing
1074 || digit->Sector() != prevSector) {
1075 // Force a new Altro channel
1076 AliDebug(10, Form("Flushing channel to disk because %s",
1077 (offset == 128 ? "channel is full" :
1078 (ring != prevRing ? "new ring up" :
1079 "new sector up"))));
1080 AliDebug(10, Form("New Channel: Write channel at %d Strip: %d "
1081 "Sector: %d Ring: %d",
1082 i, startStrip, prevSector, prevRing));
1083 altro->WriteChannel(Int_t(startStrip),
1085 Int_t((prevRing == 'I' ? 0 : 1)),
1086 channel.fN, channel.fArray, 0);
1087 // Reset and update channel variables
1092 prevSector = sector;
1095 // Store the counts of the ADC in the channel buffer
1096 channel[offset * sampleRate] = digit->Count1();
1098 channel[offset * sampleRate + 1] = digit->Count2();
1100 channel[offset * sampleRate + 2] = digit->Count3();
1103 // Finally, we need to close the final ALTRO buffer if it wasn't
1107 altro->WriteDataHeader(kFALSE, kFALSE);
1111 fLoader->UnloadDigits();
1114 //==================================================================
1116 // Various setter functions for the common paramters
1119 //__________________________________________________________________
1121 AliFMD::SetLegLength(Double_t length)
1123 // Set lenght of plastic legs that hold the hybrid (print board and
1124 // silicon sensor) onto the honeycomp support
1126 // DebugGuard guard("AliFMD::SetLegLength");
1127 AliDebug(10, "AliFMD::SetLegLength");
1128 fLegLength = length;
1129 fInner->SetLegLength(fLegLength);
1130 fOuter->SetLegLength(fLegLength);
1133 //__________________________________________________________________
1135 AliFMD::SetLegOffset(Double_t offset)
1137 // Set offset from edge of hybrid to plastic legs that hold the
1138 // hybrid (print board and silicon sensor) onto the honeycomp
1141 // DebugGuard guard("AliFMD::SetLegOffset");
1142 AliDebug(10, "AliFMD::SetLegOffset");
1143 fInner->SetLegOffset(offset);
1144 fOuter->SetLegOffset(offset);
1147 //__________________________________________________________________
1149 AliFMD::SetLegRadius(Double_t radius)
1151 // Set the diameter of the plastic legs that hold the hybrid (print
1152 // board and silicon sensor) onto the honeycomp support
1154 // DebugGuard guard("AliFMD::SetLegRadius");
1155 AliDebug(10, "AliFMD::SetLegRadius");
1156 fLegRadius = radius;
1157 fInner->SetLegRadius(fLegRadius);
1158 fOuter->SetLegRadius(fLegRadius);
1161 //__________________________________________________________________
1163 AliFMD::SetModuleSpacing(Double_t spacing)
1165 // Set the distance between the front and back sensor modules
1166 // (module staggering).
1168 // DebugGuard guard("AliFMD::SetModuleSpacing");
1169 AliDebug(10, "AliFMD::SetModuleSpacing");
1170 fModuleSpacing = spacing;
1171 fInner->SetModuleSpacing(fModuleSpacing);
1172 fOuter->SetModuleSpacing(fModuleSpacing);
1175 //====================================================================
1179 //__________________________________________________________________
1181 AliFMD::Browse(TBrowser* b)
1183 AliDebug(10, "AliFMD::Browse");
1184 AliDetector::Browse(b);
1185 if (fInner) b->Add(fInner, "Inner Ring");
1186 if (fOuter) b->Add(fOuter, "Outer Ring");
1187 if (fFMD1) b->Add(fFMD1, "FMD1 SubDetector");
1188 if (fFMD2) b->Add(fFMD2, "FMD2 SubDetector");
1189 if (fFMD3) b->Add(fFMD3, "FMD3 SubDetector");
1193 //********************************************************************
1197 //__________________________________________________________________
1201 //********************************************************************
1205 //__________________________________________________________________
1210 //_//____________________________________________________________________
1212 AliFMDv1::StepManager()
1215 // Called for every step in the Forward Multiplicity Detector
1217 // The procedure is as follows:
1219 // - IF NOT track is alive THEN RETURN ENDIF
1220 // - IF NOT particle is charged THEN RETURN ENDIF
1221 // - IF NOT volume name is "STRI" or "STRO" THEN RETURN ENDIF
1222 // - Get strip number (volume copy # minus 1)
1223 // - Get phi division number (mother volume copy #)
1224 // - Get module number (grand-mother volume copy #)
1225 // - section # = 2 * module # + phi division # - 1
1226 // - Get ring Id from volume name
1227 // - Get detector # from grand-grand-grand-mother volume name
1228 // - Get pointer to sub-detector object.
1229 // - Get track position
1230 // - IF track is entering volume AND track is inside real shape THEN
1231 // - Reset energy deposited
1232 // - Get track momentum
1233 // - Get particle ID #
1235 // - IF track is inside volume AND inside real shape THEN
1236 /// - Update energy deposited
1238 // - IF track is inside real shape AND (track is leaving volume,
1239 // or it died, or it is stopped THEN
1244 // DebugGuard guard("AliFMDv1::StepManager");
1245 AliDebug(10, "AliFMDv1::StepManager");
1248 // If the track is gone, return
1249 if (!gMC->IsTrackAlive()) return;
1251 // Only process charged particles
1252 if(TMath::Abs(gMC->TrackCharge()) <= 0) return;
1254 // Only do stuff is the track is in one of the strips.
1255 TString vol(gMC->CurrentVolName());
1256 if (!vol.Contains("STR")) return;
1259 // Get the strip number. Note, that GEANT numbers divisions from 1,
1260 // so we subtract one
1262 gMC->CurrentVolID(strip);
1265 // Get the phi division of the module
1266 Int_t phiDiv; // * The phi division number (1 or 2)
1267 gMC->CurrentVolOffID(1, phiDiv); // in the module
1269 // Active volume number - not used.
1271 // gMC->CurrentVolOffID(2, active);
1273 // Get the module number in the ring.
1275 gMC->CurrentVolOffID(3, module);
1277 // Ring copy number - the same as the detector number - not used
1278 // Int_t ringCopy; // * Ring copy number
1279 // gMC->CurrentVolOffID(4, ringCopy); // Same as detector number
1281 // Get the detector number from the path name
1282 Int_t detector = Int_t((gMC->CurrentVolOffName(5)[3]) - 48);
1284 // The sector number, calculated from module and phi division #
1285 Int_t sector = 2 * module + phiDiv - 1;
1287 // The ring ID is encoded in the volume name
1288 Char_t ring = vol[3];
1290 // Get a pointer to the sub detector structure
1291 AliFMDSubDetector* det = 0;
1293 case 1: det = fFMD1; break;
1294 case 2: det = fFMD2; break;
1295 case 3: det = fFMD3; break;
1299 // Get the current track position
1301 gMC->TrackPosition(v);
1302 // Check that the track is actually within the active area
1303 Bool_t isWithin = det->CheckHit(ring, module, v.X(), v.Y());
1304 Bool_t entering = gMC->IsTrackEntering() && isWithin;
1305 Bool_t inside = gMC->IsTrackInside() && isWithin;
1306 Bool_t out = (gMC->IsTrackExiting()
1307 || gMC->IsTrackDisappeared()
1308 || gMC->IsTrackStop()
1310 // Reset the energy deposition for this track, and update some of
1315 // Get production vertex and momentum of the track
1317 gMC->TrackMomentum(fCurrentP);
1318 fCurrentPdg = gMC->IdFromPDG(gMC->TrackPid());
1321 // fAnalyser->Update(detector, ring, isWithin, v.X(), v.Y());
1324 // If the track is inside, then update the energy deposition
1325 if (inside && fCurrentDeltaE >= 0)
1326 fCurrentDeltaE += 1000 * gMC->Edep();
1328 // The track exits the volume, or it disappeared in the volume, or
1329 // the track is stopped because it no longer fulfills the cuts
1330 // defined, then we create a hit.
1331 if (out && fCurrentDeltaE >= 0) {
1332 fCurrentDeltaE += 1000 * gMC->Edep();
1334 AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),
1335 detector, ring, sector, strip,
1336 fCurrentV.X(), fCurrentV.Y(), fCurrentV.Z(),
1337 fCurrentP.X(), fCurrentP.Y(), fCurrentP.Z(),
1338 fCurrentDeltaE, fCurrentPdg, fCurrentV.T());
1339 fCurrentDeltaE = -1;
1342 //___________________________________________________________________