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 // 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 geometry
32 // +----------+ +----------+
33 // | AliFMDv1 | | AliFMDv1 |
34 // +----------+ +----------+
36 // +----+--------------+
38 // | +------------+ 1 +---------------+
39 // | +- | AliFMDRing |<>--| AliFMDPolygon |
40 // V 2 | +------------+ +---------------+
43 // +--------+<>--+ V 1..2
44 // 3 | +-------------------+
45 // +-| AliFMDSubDetector |
46 // +-------------------+
49 // +-------------+-------------+
51 // +---------+ +---------+ +---------+
52 // | AliFMD1 | | AliFMD2 | | AliFMD3 |
53 // +---------+ +---------+ +---------+
57 // This defines the interface for the various parts of AliROOT that
58 // uses the FMD, like AliFMDDigitizer, AliFMDReconstructor, and so
62 // This is a concrete implementation of the AliFMD interface.
63 // It is the responsibility of this class to create the FMD
64 // geometry, process hits in the FMD, and serve hits and digits to
65 // the various clients.
67 // It uses the objects of class AliFMDSubDetector to do the various
68 // stuff for FMD1, 2, and 3
71 // This class contains all stuff needed to do with a ring. It's
72 // used by the AliFMDSubDetector objects to instantise inner and
73 // outer rings. The AliFMDRing objects are shared by the
74 // AliFMDSubDetector objects, and owned by the AliFMDv1 object.
77 // The code I lifted from TGeoPolygon to help with the geometry of
78 // the modules, as well as to decide wether a hit is actually with
79 // in the real module shape. The point is, that the shape of the
80 // various ring modules are really polygons (much like the lid of a
81 // coffin), but it's segmented at constant radius. That is very
82 // hard to implement using GEANT 3.21 shapes, so instead the
83 // modules are implemented as TUBS (tube sections), and in the step
84 // procedure we do the test whether the track was inside the real
85 // shape of the module.
87 // * AliFMD1, AliFMD2, and AliFMD3
88 // These are specialisation of AliFMDSubDetector, that contains the
89 // particularities of each of the sub-detector system. It is
90 // envisioned that the classes should also define the support
91 // volumes and material for each of the detectors.
93 // The responsible person for this module is Alla Maevskaia
94 // <Alla.Maevskaia@cern.ch>.
96 // Many modifications by Christian Holm Christensen <cholm@nbi.dk>
99 #ifndef ROOT_TClonesArray
100 #include <TClonesArray.h>
102 #ifndef ROOT_TGeomtry
103 # include <TGeometry.h>
114 #ifndef ROOT_TVirtualMC
115 # include <TVirtualMC.h>
117 #ifndef ROOT_TBrowser
118 # include <TBrowser.h>
124 #ifndef ALIRUNDIGITIZER_H
125 # include "AliRunDigitizer.h"
128 # include "AliLoader.h"
140 # include "AliMagF.h"
145 #ifndef ALIFMDDIGIG_H
146 # include "AliFMDDigit.h"
149 # include "AliFMDHit.h"
151 #ifndef ALIFMDDIGITIZER_H
152 # include "AliFMDDigitizer.h"
155 # include "AliFMD1.h"
158 # include "AliFMD2.h"
161 # include "AliFMD3.h"
163 #ifndef ALIALTROBUFFER_H
164 # include "AliAltroBuffer.h"
167 //____________________________________________________________________
170 //____________________________________________________________________
180 fPrintboardRotationId(0),
181 fIdentityRotationId(0),
189 // Default constructor for class AliFMD
191 AliDebug(0, "Default CTOR");
197 //____________________________________________________________________
198 AliFMD::AliFMD(const char *name, const char *title, bool detailed)
199 : AliDetector (name, title),
208 fPrintboardRotationId(0),
209 fIdentityRotationId(0),
217 // Standard constructor for Forward Multiplicity Detector
219 AliDebug(0, "Standard CTOR");
221 // Initialise Hit array
223 gAlice->GetMCApp()->AddHitList(fHits);
225 // (S)Digits for the detectors disk
229 // CHC: What is this?
231 SetMarkerColor(kRed);
232 SetLineColor(kYellow);
235 // Create sub-volume managers
236 fInner = new AliFMDRing('I', detailed);
237 fOuter = new AliFMDRing('O', detailed);
238 fFMD1 = new AliFMD1();
239 fFMD2 = new AliFMD2();
240 fFMD3 = new AliFMD3();
242 // Specify parameters of sub-volume managers
243 fFMD1->SetInner(fInner);
246 fFMD2->SetInner(fInner);
247 fFMD2->SetOuter(fOuter);
249 fFMD3->SetInner(fInner);
250 fFMD3->SetOuter(fOuter);
257 fInner->SetLowR(4.3);
258 fInner->SetHighR(17.2);
259 fInner->SetWaferRadius(13.4/2);
260 fInner->SetTheta(36/2);
261 fInner->SetNStrips(512);
262 fInner->SetSiThickness(.03);
263 fInner->SetPrintboardThickness(.11);
264 fInner->SetBondingWidth(.5);
266 fOuter->SetLowR(15.6);
267 fOuter->SetHighR(28.0);
268 fOuter->SetWaferRadius(13.4/2);
269 fOuter->SetTheta(18/2);
270 fOuter->SetNStrips( 256);
271 fOuter->SetSiThickness(.03);
272 fOuter->SetPrintboardThickness(.1);
273 fOuter->SetBondingWidth(.5);
276 fFMD1->SetHoneycombThickness(1);
277 fFMD1->SetInnerZ(340.0);
279 fFMD2->SetHoneycombThickness(1);
280 fFMD2->SetInnerZ(83.4);
281 fFMD2->SetOuterZ(75.2);
283 fFMD3->SetHoneycombThickness(1);
284 fFMD3->SetInnerZ(-62.8);
285 fFMD3->SetOuterZ(-75.2);
288 //____________________________________________________________________
291 // Destructor for base class AliFMD
309 //====================================================================
311 // GEometry ANd Traking
313 //____________________________________________________________________
315 AliFMD::CreateGeometry()
318 // Create the geometry of Forward Multiplicity Detector. The actual
319 // construction of the geometry is delegated to the class AliFMDRing
320 // and AliFMDSubDetector and the relevant derived classes.
322 // The flow of this member function is:
324 // FOR rings fInner and fOuter DO
325 // AliFMDRing::Init();
328 // Set up hybrud card support (leg) volume shapes
330 // FOR rings fInner and fOuter DO
331 // AliFMDRing::SetupGeometry();
334 // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO
335 // AliFMDSubDetector::SetupGeomtry();
338 // FOR subdetectors fFMD1, fFMD2, and fFMD3 DO
339 // AliFMDSubDetector::Geomtry();
343 // DebugGuard guard("AliFMD::CreateGeometry");
344 AliDebug(10, "Creating geometry");
352 par[0] = fLegRadius - .1;
354 par[2] = fLegLength / 2;
356 fShortLegId = gMC->Gsvolu(name.Data(),"TUBE",(*fIdtmed)[kPlasticId],par,3);
358 par[2] += fModuleSpacing / 2;
360 fLongLegId = gMC->Gsvolu(name.Data(),"TUBE",(*fIdtmed)[kPlasticId],par,3);
362 fInner->SetupGeometry((*fIdtmed)[kAirId],
365 fPrintboardRotationId,
366 fIdentityRotationId);
367 fOuter->SetupGeometry((*fIdtmed)[kAirId],
370 fPrintboardRotationId,
371 fIdentityRotationId);
373 fFMD1->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
374 fFMD2->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
375 fFMD3->SetupGeometry((*fIdtmed)[kAirId], (*fIdtmed)[kKaptionId]);
377 fFMD1->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
378 fFMD2->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
379 fFMD3->Geometry("ALIC", fPrintboardRotationId, fIdentityRotationId);
382 //____________________________________________________________________
383 void AliFMD::CreateMaterials()
385 // Register various materials and tracking mediums with the
388 // Currently defined materials and mediums are
390 // FMD Air Normal air
391 // FMD Si Active silicon of sensors
392 // FMD Carbon Normal carbon used in support, etc.
393 // FMD Kapton Carbon used in Honeycomb
394 // FMD PCB Printed circuit board material
395 // FMD Plastic Material for support legs
397 // Also defined are two rotation matricies.
399 // DebugGuard guard("AliFMD::CreateMaterials");
400 AliDebug(10, "Creating materials");
404 Double_t density = 0;
405 Double_t radiationLength = 0;
406 Double_t absorbtionLength = 999;
407 Int_t fieldType = gAlice->Field()->Integ(); // Field type
408 Double_t maxField = gAlice->Field()->Max(); // Field max.
409 Double_t maxBending = 0; // Max Angle
410 Double_t maxStepSize = 0.001; // Max step size
411 Double_t maxEnergyLoss = 1; // Max Delta E
412 Double_t precision = 0.001; // Precision
413 Double_t minStepSize = 0.001; // Minimum step size
418 density = fSiDensity;
419 radiationLength = 9.36;
425 AliMaterial(id, "FMD Si$", a, z, density, radiationLength, absorbtionLength);
426 AliMedium(kSiId, "FMD Si$",id,1,fieldType,maxField,maxBending,
427 maxStepSize,maxEnergyLoss,precision,minStepSize);
434 radiationLength = 18.8;
440 AliMaterial(id, "FMD Carbon$", a, z, density, radiationLength,
442 AliMedium(kCarbonId, "FMD Carbon$",id,0,fieldType,maxField,maxBending,
443 maxStepSize,maxEnergyLoss,precision,minStepSize);
447 Float_t as[] = { 12.0107, 14.0067, 15.9994,
448 1.00794, 28.0855, 107.8682 };
449 Float_t zs[] = { 6., 7., 8.,
451 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
452 0.004367771, 0.844665, 0.09814344903 };
459 AliMixture(id, "FMD Si Chip$", as, zs, density, 6, ws);
460 AliMedium(kSiChipId, "FMD Si Chip$", id, 0, fieldType, maxField,
461 maxBending, maxStepSize, maxEnergyLoss, precision, minStepSize);
467 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
468 Float_t zs[] = { 1., 6., 7., 8.};
469 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
476 AliMixture(id, "FMD Kaption$", as, zs, density, 4, ws);
477 AliMedium(kKaptionId, "FMD Kaption$",id,0,fieldType,maxField,maxBending,
478 maxStepSize,maxEnergyLoss,precision,minStepSize);
483 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
484 Float_t zs[] = { 6., 7., 8., 18. };
485 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
492 AliMixture(id, "FMD Air$", as, zs, density, 4, ws);
493 AliMedium(kAirId, "FMD Air$", id,0,fieldType,maxField,maxBending,
494 maxStepSize,maxEnergyLoss,precision,minStepSize);
499 Float_t zs[] = { 14., 20., 13., 12.,
503 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
504 10.811, 47.867, 22.98977, 39.0983,
505 55.845, 18.9984, 15.9994, 12.0107,
507 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
508 0.01397570, 0.00287685, 0.00445114, 0.00498089,
509 0.00209828, 0.00420000, 0.36043788, 0.27529426,
510 0.01415852, 0.03427566};
517 AliMixture(id, "FMD PCB$", as, zs, density, 14, ws);
518 AliMedium(kPcbId, "FMD PCB$", id,1,fieldType,maxField,maxBending,
519 maxStepSize,maxEnergyLoss,precision,minStepSize);
524 Float_t as[] = { 1.01, 12.01 };
525 Float_t zs[] = { 1., 6. };
526 Float_t ws[] = { 1., 1. };
533 AliMixture(id, "FMD Plastic$", as, zs, density, -2, ws);
534 AliMedium(kPlasticId, "FMD Plastic$", id,0,fieldType,maxField,maxBending,
535 maxStepSize,maxEnergyLoss,precision,minStepSize);
537 AliMatrix(fPrintboardRotationId, 90, 90, 0, 90, 90, 0);
538 AliMatrix(fIdentityRotationId, 90, 0, 90, 90, 0, 0);
541 //____________________________________________________________________
546 // Initialis the FMD after it has been built
550 std::cout << "\n" << ClassName() << ": " << std::flush;
551 for (i = 0; i < 35; i++) std::cout << "*";
552 std::cout << " FMD_INIT ";
553 for (i = 0; i < 35; i++) std::cout << "*";
554 std::cout << "\n" << ClassName() << ": " << std::flush;
556 // Here the FMD initialisation code (if any!)
557 for (i = 0; i < 80; i++) std::cout << "*";
558 std::cout << std::endl;
564 //====================================================================
566 // Graphics and event display
568 //____________________________________________________________________
570 AliFMD::BuildGeometry()
573 // Build simple ROOT TNode geometry for event display
575 // Build a simplified geometry of the FMD used for event display
577 // The actual building of the TNodes is done by
578 // AliFMDSubDetector::SimpleGeometry.
579 AliDebug(10, "Creating a simplified geometry");
581 TNode* top = gAlice->GetGeometry()->GetNode("alice");
583 fFMD1->SimpleGeometry(fNodes, top, GetLineColor(), 0);
584 fFMD2->SimpleGeometry(fNodes, top, GetLineColor(), 0);
585 fFMD3->SimpleGeometry(fNodes, top, GetLineColor(), 0);
588 //____________________________________________________________________
590 AliFMD::DrawDetector()
593 // Draw a shaded view of the Forward multiplicity detector
595 // DebugGuard guard("AliFMD::DrawDetector");
596 AliDebug(10, "Draw detector");
598 //Set ALIC mother transparent
599 gMC->Gsatt("ALIC","SEEN",0);
601 //Set volumes visible
609 gMC->Gdopt("hide", "on");
610 gMC->Gdopt("shad", "on");
611 gMC->Gsatt("*", "fill", 7);
612 gMC->SetClipBox(".");
613 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
615 gMC->Gdraw("alic", 40, 30, 0, 12, 12, .055, .055);
616 gMC->Gdhead(1111, "Forward Multiplicity Detector");
617 gMC->Gdman(16, 10, "MAN");
618 gMC->Gdopt("hide", "off");
621 //____________________________________________________________________
623 AliFMD::DistanceToPrimitive(Int_t, Int_t)
626 // Calculate the distance from the mouse to the FMD on the screen
632 //====================================================================
634 // Hit and Digit managment
636 //____________________________________________________________________
638 AliFMD::MakeBranch(Option_t * option)
640 // Create Tree branches for the FMD.
644 // H Make a branch of TClonesArray of AliFMDHit's
645 // D Make a branch of TClonesArray of AliFMDDigit's
646 // S Make a branch of TClonesArray of AliFMDSDigit's
648 const Int_t kBufferSize = 16000;
649 TString branchname(GetName());
652 if (opt.Contains("H", TString::kIgnoreCase)) {
654 AliDetector::MakeBranch(option);
656 if (opt.Contains("D", TString::kIgnoreCase)) {
658 MakeBranchInTree(fLoader->TreeD(), branchname.Data(),
659 &fDigits, kBufferSize, 0);
661 if (opt.Contains("S", TString::kIgnoreCase)) {
663 MakeBranchInTree(fLoader->TreeS(), branchname.Data(),
664 &fSDigits, kBufferSize, 0);
668 //____________________________________________________________________
670 AliFMD::SetTreeAddress()
672 // Set branch address for the Hits, Digits, and SDigits Tree.
673 if (fLoader->TreeH()) HitsArray();
674 AliDetector::SetTreeAddress();
676 TTree *treeD = fLoader->TreeD();
679 TBranch* branch = treeD->GetBranch ("FMD");
680 if (branch) branch->SetAddress(&fDigits);
683 TTree *treeS = fLoader->TreeS();
686 TBranch* branch = treeS->GetBranch ("FMD");
687 if (branch) branch->SetAddress(&fSDigits);
693 //____________________________________________________________________
695 AliFMD::SetHitsAddressBranch(TBranch *b)
697 // Set the TClonesArray to read hits into.
698 b->SetAddress(&fHits);
701 //____________________________________________________________________
703 AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
705 // Add a hit to the hits tree
707 // The information of the two arrays are decoded as
711 // ivol[0] [UShort_t ] Detector #
712 // ivol[1] [Char_t ] Ring ID
713 // ivol[2] [UShort_t ] Sector #
714 // ivol[3] [UShort_t ] Strip #
715 // hits[0] [Float_t ] Track's X-coordinate at hit
716 // hits[1] [Float_t ] Track's Y-coordinate at hit
717 // hits[3] [Float_t ] Track's Z-coordinate at hit
718 // hits[4] [Float_t ] X-component of track's momentum
719 // hits[5] [Float_t ] Y-component of track's momentum
720 // hits[6] [Float_t ] Z-component of track's momentum
721 // hits[7] [Float_t ] Energy deposited by track
722 // hits[8] [Int_t ] Track's particle Id #
723 // hits[9] [Float_t ] Time when the track hit
727 UShort_t(vol[0]), // Detector #
728 Char_t(vol[1]), // Ring ID
729 UShort_t(vol[2]), // Sector #
730 UShort_t(vol[3]), // Strip #
737 hits[6], // Energy loss
738 Int_t(hits[7]), // PDG
742 //____________________________________________________________________
744 AliFMD::AddHit(Int_t track,
760 // Add a hit to the list
765 // detector Detector # (1, 2, or 3)
766 // ring Ring ID ('I' or 'O')
767 // sector Sector # (For inner/outer rings: 0-19/0-39)
768 // strip Strip # (For inner/outer rings: 0-511/0-255)
769 // x Track's X-coordinate at hit
770 // y Track's Y-coordinate at hit
771 // z Track's Z-coordinate at hit
772 // px X-component of track's momentum
773 // py Y-component of track's momentum
774 // pz Z-component of track's momentum
775 // edep Energy deposited by track
776 // pdg Track's particle Id #
777 // t Time when the track hit
779 TClonesArray& a = *(HitsArray());
780 // Search through the list of already registered hits, and see if we
781 // find a hit with the same parameters. If we do, then don't create
782 // a new hit, but rather update the energy deposited in the hit.
783 // This is done, so that a FLUKA based simulation will get the
784 // number of hits right, not just the enerrgy deposition.
785 for (Int_t i = 0; i < fNhits; i++) {
786 if (!a.At(i)) continue;
787 AliFMDHit* hit = static_cast<AliFMDHit*>(a.At(i));
788 if (hit->Detector() == detector
789 && hit->Ring() == ring
790 && hit->Sector() == sector
791 && hit->Strip() == strip
792 && hit->Track() == track) {
793 Warning("AddHit", "already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
794 " adding energy (%f) to that hit (%f) -> %f",
795 detector, ring, sector, strip, track, edep, hit->Edep(),
797 hit->SetEdep(hit->Edep() + edep);
801 // If hit wasn't already registered, do so know.
802 new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, strip,
803 x, y, z, px, py, pz, edep, pdg, t);
807 //____________________________________________________________________
809 AliFMD::AddDigit(Int_t* digits)
811 // Add a digit to the Digit tree
815 // digits[0] [UShort_t] Detector #
816 // digits[1] [Char_t] Ring ID
817 // digits[2] [UShort_t] Sector #
818 // digits[3] [UShort_t] Strip #
819 // digits[4] [UShort_t] ADC Count
820 // digits[5] [Short_t] ADC Count, -1 if not used
821 // digits[6] [Short_t] ADC Count, -1 if not used
823 AddDigit(UShort_t(digits[0]), // Detector #
824 Char_t(digits[1]), // Ring ID
825 UShort_t(digits[2]), // Sector #
826 UShort_t(digits[3]), // Strip #
827 UShort_t(digits[4]), // ADC Count1
828 Short_t(digits[5]), // ADC Count2
829 Short_t(digits[6])); // ADC Count3
832 //____________________________________________________________________
834 AliFMD::AddDigit(UShort_t detector,
842 // add a real digit - as coming from data
846 // detector Detector # (1, 2, or 3)
847 // ring Ring ID ('I' or 'O')
848 // sector Sector # (For inner/outer rings: 0-19/0-39)
849 // strip Strip # (For inner/outer rings: 0-511/0-255)
850 // count1 ADC count (a 10-bit word)
851 // count2 ADC count (a 10-bit word), or -1 if not used
852 // count3 ADC count (a 10-bit word), or -1 if not used
853 TClonesArray& a = *(DigitsArray());
856 AliFMDDigit(detector, ring, sector, strip, count1, count2, count3);
859 //____________________________________________________________________
861 AliFMD::AddSDigit(Int_t* digits)
863 // Add a digit to the SDigit tree
867 // digits[0] [UShort_t] Detector #
868 // digits[1] [Char_t] Ring ID
869 // digits[2] [UShort_t] Sector #
870 // digits[3] [UShort_t] Strip #
871 // digits[4] [Float_t] Total energy deposited
872 // digits[5] [UShort_t] ADC Count
873 // digits[6] [Short_t] ADC Count, -1 if not used
874 // digits[7] [Short_t] ADC Count, -1 if not used
876 AddSDigit(UShort_t(digits[0]), // Detector #
877 Char_t(digits[1]), // Ring ID
878 UShort_t(digits[2]), // Sector #
879 UShort_t(digits[3]), // Strip #
880 Float_t(digits[4]), // Edep
881 UShort_t(digits[5]), // ADC Count1
882 Short_t(digits[6]), // ADC Count2
883 Short_t(digits[7])); // ADC Count3
886 //____________________________________________________________________
888 AliFMD::AddSDigit(UShort_t detector,
897 // add a summable digit
901 // detector Detector # (1, 2, or 3)
902 // ring Ring ID ('I' or 'O')
903 // sector Sector # (For inner/outer rings: 0-19/0-39)
904 // strip Strip # (For inner/outer rings: 0-511/0-255)
905 // edep Total energy deposited
906 // count1 ADC count (a 10-bit word)
907 // count2 ADC count (a 10-bit word), or -1 if not used
908 // count3 ADC count (a 10-bit word), or -1 if not used
910 TClonesArray& a = *(SDigitsArray());
913 AliFMDSDigit(detector, ring, sector, strip, edep, count1, count2, count3);
916 //____________________________________________________________________
918 AliFMD::ResetSDigits()
921 // Reset number of digits and the digits array for this detector
924 if (fSDigits) fSDigits->Clear();
928 //____________________________________________________________________
932 // Initialize hit array if not already, and return pointer to it.
934 fHits = new TClonesArray("AliFMDHit", 1000);
940 //____________________________________________________________________
942 AliFMD::DigitsArray()
944 // Initialize digit array if not already, and return pointer to it.
946 fDigits = new TClonesArray("AliFMDDigit", 1000);
952 //____________________________________________________________________
954 AliFMD::SDigitsArray()
956 // Initialize digit array if not already, and return pointer to it.
958 fSDigits = new TClonesArray("AliFMDSDigit", 1000);
964 //====================================================================
968 //____________________________________________________________________
970 AliFMD::Hits2Digits()
972 // Create AliFMDDigit's from AliFMDHit's. This is done by making a
973 // AliFMDDigitizer, and executing that code.
975 AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
976 manager->SetInputStream(0, "galice.root");
977 manager->SetOutputFile("H2Dfile");
979 /* AliDigitizer* dig =*/ CreateDigitizer(manager);
983 //____________________________________________________________________
985 AliFMD::Hits2SDigits()
987 // Create AliFMDSDigit's from AliFMDHit's. This is done by creating
988 // an AliFMDSDigitizer object, and executing it.
990 AliDigitizer* sdig = new AliFMDSDigitizer("galice.root");
995 //____________________________________________________________________
997 AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
999 // Create a digitizer object
1000 return new AliFMDDigitizer(manager);
1003 //====================================================================
1005 // Raw data simulation
1007 //__________________________________________________________________
1009 AliFMD::Digits2Raw()
1011 // Turn digits into raw data.
1013 // Digits are read from the Digit branch, and processed to make
1014 // three DDL files, one for each of the sub-detectors FMD1, FMD2,
1017 // The raw data files consists of a header, followed by ALTRO
1018 // formatted blocks.
1028 // An ALTRO formatted block, in the FMD context, consists of a
1029 // number of counts followed by a trailer.
1031 // +------------------+
1034 // | possible fillers |
1035 // +------------------+
1037 // +------------------+
1040 // The counts are listed backwards, that is, starting with the
1041 // latest count, and ending in the first.
1043 // Each count consist of 1 or more ADC samples of the VA1_ALICE
1044 // pre-amp. signal. Just how many samples are used depends on
1045 // whether the ALTRO over samples the pre-amp. Each sample is a
1046 // 10-bit word, and the samples are grouped into 40-bit blocks
1048 // +------------------------------------+
1049 // | S(n) | S(n-1) | S(n-2) | S(n-3) |
1050 // | ... | ... | ... | ... |
1051 // | S(2) | S(1) | AA | AA |
1052 // +------------------------------------+
1053 // Counts + possible filler
1055 // The trailer of the number of words of signales, the starting
1056 // strip number, the sector number, and the ring ID; each 10-bit
1057 // words, packed into 40-bits.
1059 // +------------------------------------+
1060 // | # words | start | sector | ring |
1061 // +------------------------------------+
1064 // Note, that this method assumes that the digits are ordered.
1066 AliFMD* fmd = static_cast<AliFMD*>(gAlice->GetDetector(GetName()));
1067 fLoader->LoadDigits();
1068 TTree* digitTree = fLoader->TreeD();
1070 Error("Digits2Raw", "no digit tree");
1074 TClonesArray* digits = new TClonesArray("AliFMDDigit", 1000);
1075 fmd->SetTreeAddress();
1076 TBranch* digitBranch = digitTree->GetBranch(GetName());
1078 Error("Digits2Raw", "no branch for %s", GetName());
1081 digitBranch->SetAddress(&digits);
1083 Int_t nEvents = Int_t(digitTree->GetEntries());
1084 for (Int_t event = 0; event < nEvents; event++) {
1086 digitTree->GetEvent(event);
1088 Int_t nDigits = digits->GetEntries();
1089 if (nDigits < 1) continue;
1092 UShort_t prevDetector = 0;
1093 Char_t prevRing = '\0';
1094 UShort_t prevSector = 0;
1095 // UShort_t prevStrip = 0;
1097 // The first seen strip number for a channel
1098 UShort_t startStrip = 0;
1100 // Which channel number in the ALTRO channel we're at
1101 UShort_t offset = 0;
1103 // How many times the ALTRO Samples one VA1_ALICE channel
1104 Int_t sampleRate = 1;
1106 // A buffer to hold 1 ALTRO channel - Normally, one ALTRO channel
1107 // holds 128 VA1_ALICE channels, sampled at a rate of `sampleRate'
1108 TArrayI channel(128 * sampleRate);
1111 AliAltroBuffer* altro = 0;
1113 // Loop over the digits in the event. Note, that we assume the
1114 // the digits are in order in the branch. If they were not, we'd
1115 // have to cache all channels before we could write the data to
1116 // the ALTRO buffer, or we'd have to set up a map of the digits.
1117 for (Int_t i = 0; i < nDigits; i++) {
1119 AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
1121 UShort_t det = digit->Detector();
1122 Char_t ring = digit->Ring();
1123 UShort_t sector = digit->Sector();
1124 UShort_t strip = digit->Strip();
1125 if (det != prevDetector) {
1126 AliDebug(10, Form("FMD: New DDL, was %d, now %d",
1127 kBaseDDL + prevDetector - 1,
1128 kBaseDDL + det - 1));
1129 // If an altro exists, delete the object, flushing the data to
1130 // disk, and closing the file.
1132 // When the first argument is false, we write the real
1134 AliDebug(10, Form("New altro: Write channel at %d Strip: %d "
1135 "Sector: %d Ring: %d",
1136 i, startStrip, prevSector, prevRing));
1137 // TPC to FMD translations
1140 // ----------+-----------
1145 altro->WriteChannel(Int_t(startStrip),
1147 Int_t((prevRing == 'I' ? 0 : 1)),
1148 channel.fN, channel.fArray, 0);
1150 altro->WriteDataHeader(kFALSE, kFALSE);
1156 // Need to open a new DDL!
1157 Int_t ddlId = kBaseDDL + det - 1;
1158 TString filename(Form("%s_%d.ddl", GetName(), ddlId));
1160 AliDebug(10, Form("New altro buffer with DDL file %s",
1162 AliDebug(10, Form("New altro at %d", i));
1163 // Create a new altro buffer - a `1' as the second argument
1164 // means `write mode'
1165 altro = new AliAltroBuffer(filename.Data(), 1);
1167 // Write a dummy (first argument is true) header to the DDL
1168 // file - later on, when we close the file, we write the real
1170 altro->WriteDataHeader(kTRUE, kFALSE);
1172 // Figure out the sample rate
1173 if (digit->Count2() > 0) sampleRate = 2;
1174 if (digit->Count3() > 0) sampleRate = 3;
1176 channel.Set(128 * sampleRate);
1179 prevSector = sector;
1182 else if (offset == 128
1183 || digit->Ring() != prevRing
1184 || digit->Sector() != prevSector) {
1185 // Force a new Altro channel
1186 AliDebug(10, Form("Flushing channel to disk because %s",
1187 (offset == 128 ? "channel is full" :
1188 (ring != prevRing ? "new ring up" :
1189 "new sector up"))));
1190 AliDebug(10, Form("New Channel: Write channel at %d Strip: %d "
1191 "Sector: %d Ring: %d",
1192 i, startStrip, prevSector, prevRing));
1193 altro->WriteChannel(Int_t(startStrip),
1195 Int_t((prevRing == 'I' ? 0 : 1)),
1196 channel.fN, channel.fArray, 0);
1197 // Reset and update channel variables
1202 prevSector = sector;
1205 // Store the counts of the ADC in the channel buffer
1206 channel[offset * sampleRate] = digit->Count1();
1208 channel[offset * sampleRate + 1] = digit->Count2();
1210 channel[offset * sampleRate + 2] = digit->Count3();
1213 // Finally, we need to close the final ALTRO buffer if it wasn't
1217 altro->WriteDataHeader(kFALSE, kFALSE);
1221 fLoader->UnloadDigits();
1224 //==================================================================
1226 // Various setter functions for the common paramters
1229 //__________________________________________________________________
1231 AliFMD::SetLegLength(Double_t length)
1233 // Set lenght of plastic legs that hold the hybrid (print board and
1234 // silicon sensor) onto the honeycomp support
1236 // DebugGuard guard("AliFMD::SetLegLength");
1237 AliDebug(10, "AliFMD::SetLegLength");
1238 fLegLength = length;
1239 fInner->SetLegLength(fLegLength);
1240 fOuter->SetLegLength(fLegLength);
1243 //__________________________________________________________________
1245 AliFMD::SetLegOffset(Double_t offset)
1247 // Set offset from edge of hybrid to plastic legs that hold the
1248 // hybrid (print board and silicon sensor) onto the honeycomp
1251 // DebugGuard guard("AliFMD::SetLegOffset");
1252 AliDebug(10, "AliFMD::SetLegOffset");
1253 fInner->SetLegOffset(offset);
1254 fOuter->SetLegOffset(offset);
1257 //__________________________________________________________________
1259 AliFMD::SetLegRadius(Double_t radius)
1261 // Set the diameter of the plastic legs that hold the hybrid (print
1262 // board and silicon sensor) onto the honeycomp support
1264 // DebugGuard guard("AliFMD::SetLegRadius");
1265 AliDebug(10, "AliFMD::SetLegRadius");
1266 fLegRadius = radius;
1267 fInner->SetLegRadius(fLegRadius);
1268 fOuter->SetLegRadius(fLegRadius);
1271 //__________________________________________________________________
1273 AliFMD::SetModuleSpacing(Double_t spacing)
1275 // Set the distance between the front and back sensor modules
1276 // (module staggering).
1278 // DebugGuard guard("AliFMD::SetModuleSpacing");
1279 AliDebug(10, "AliFMD::SetModuleSpacing");
1280 fModuleSpacing = spacing;
1281 fInner->SetModuleSpacing(fModuleSpacing);
1282 fOuter->SetModuleSpacing(fModuleSpacing);
1285 //====================================================================
1289 //__________________________________________________________________
1291 AliFMD::Browse(TBrowser* b)
1293 // Browse this object.
1295 AliDebug(10, "AliFMD::Browse");
1296 AliDetector::Browse(b);
1297 if (fInner) b->Add(fInner, "Inner Ring");
1298 if (fOuter) b->Add(fOuter, "Outer Ring");
1299 if (fFMD1) b->Add(fFMD1, "FMD1 SubDetector");
1300 if (fFMD2) b->Add(fFMD2, "FMD2 SubDetector");
1301 if (fFMD3) b->Add(fFMD3, "FMD3 SubDetector");
1305 //___________________________________________________________________