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 <TBrowser.h> // ROOT_TBrowser
88 #include <TClonesArray.h> // ROOT_TClonesArray
89 #include <TGeoGlobalMagField.h> // ROOT_TGeoGlobalMagField
90 #include <TGeoManager.h> // ROOT_TGeoManager
91 #include <TRotMatrix.h> // ROOT_TRotMatrix
92 #include <TTree.h> // ROOT_TTree
93 #include <TVector2.h> // ROOT_TVector2
94 #include <TVirtualMC.h> // ROOT_TVirtualMC
95 #include <cmath> // __CMATH__
97 #include <AliRunDigitizer.h> // ALIRUNDIGITIZER_H
98 #include <AliLoader.h> // ALILOADER_H
99 #include <AliRun.h> // ALIRUN_H
100 #include <AliMC.h> // ALIMC_H
101 #include <AliMagF.h> // ALIMAGF_H
102 // #include <AliLog.h> // ALILOG_H
103 #include "AliFMDDebug.h" // Better debug macros
104 #include "AliFMD.h" // ALIFMD_H
105 #include "AliFMDDigit.h" // ALIFMDDIGIT_H
106 #include "AliFMDSDigit.h" // ALIFMDSDIGIT_H
107 #include "AliFMDHit.h" // ALIFMDHIT_H
108 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
109 #include "AliFMDDetector.h" // ALIFMDDETECTOR_H
110 #include "AliFMDRing.h" // ALIFMDRING_H
111 #include "AliFMDDigitizer.h" // ALIFMDDIGITIZER_H
112 #include "AliFMDHitDigitizer.h" // ALIFMDSDIGITIZER_H
113 // #define USE_SSDIGITIZER
114 //#ifdef USE_SSDIGITIZER
115 //# include "AliFMDSSDigitizer.h" // ALIFMDSDIGITIZER_H
117 // #include "AliFMDGeometryBuilder.h"
118 #include "AliFMDRawWriter.h" // ALIFMDRAWWRITER_H
119 #include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
120 #include "AliTrackReference.h"
121 #include "AliFMDStripIndex.h"
122 #include "AliFMDParameters.h"
123 #include "AliFMDReconstructor.h"
125 //____________________________________________________________________
128 ; // This is to keep Emacs from indenting the next line
131 //____________________________________________________________________
142 // Default constructor for class AliFMD
144 AliFMDDebug(10, ("\tDefault CTOR"));
148 fBad = new TClonesArray("AliFMDHit");
151 //____________________________________________________________________
152 AliFMD::AliFMD(const char *name, const char *title)
153 : AliDetector (name, title),
158 fUseAssembly(kFALSE),
162 // Standard constructor for Forward Multiplicity Detector
164 AliFMDDebug(10, ("\tStandard CTOR"));
165 fBad = new TClonesArray("AliFMDHit");
167 // Initialise Hit array
169 gAlice->GetMCApp()->AddHitList(fHits);
171 // (S)Digits for the detectors disk
175 // CHC: What is this?
177 //PH SetMarkerColor(kRed);
178 //PH SetLineColor(kYellow);
181 //____________________________________________________________________
184 // Destructor for base class AliFMD
208 //====================================================================
210 // GEometry ANd Traking
212 //____________________________________________________________________
214 AliFMD::CreateGeometry()
217 // Create the geometry of Forward Multiplicity Detector. The actual
218 // construction of the geometry is delegated to the class
219 // AliFMDGeometryBuilder, invoked by the singleton manager
222 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
223 fmd->SetDetailed(fDetailed);
224 fmd->UseAssembly(fUseAssembly);
228 //____________________________________________________________________
229 void AliFMD::CreateMaterials()
231 // Define the materials and tracking mediums needed by the FMD
232 // simulation. These mediums are made by sending the messages
233 // AliMaterial, AliMixture, and AliMedium to the passed AliModule
234 // object module. The defined mediums are
236 // FMD Si$ Silicon (active medium in sensors)
237 // FMD C$ Carbon fibre (support cone for FMD3 and vacuum pipe)
238 // FMD Al$ Aluminium (honeycomb support plates)
239 // FMD PCB$ Printed Circuit Board (FEE board with VA1_3)
240 // FMD Chip$ Electronics chips (currently not used)
241 // FMD Air$ Air (Air in the FMD)
242 // FMD Plastic$ Plastic (Support legs for the hybrid cards)
244 // The geometry builder should really be the one that creates the
245 // materials, but the architecture of AliROOT makes that design
246 // akward. What should happen, was that the AliFMDGeometryBuilder
247 // made the mediums, and that this class retrives pointers from the
248 // TGeoManager, and registers the mediums here. Alas, it's not
251 AliFMDDebug(10, ("\tCreating materials"));
252 // Get pointer to geometry singleton object.
253 AliFMDGeometry* geometry = AliFMDGeometry::Instance();
256 if (gGeoManager && gGeoManager->GetMedium("FMD Si$")) {
257 // We need to figure out the some stuff about the geometry
258 fmd->ExtractGeomInfo();
265 Double_t density = 0;
266 Double_t radiationLength = 0;
267 Double_t absorbtionLength = 999;
268 Int_t fieldType = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); // Field type
269 Double_t maxField = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); // Field max.
270 Double_t maxBending = 0; // Max Angle
271 Double_t maxStepSize = 0.001; // Max step size
272 Double_t maxEnergyLoss = 1; // Max Delta E
273 Double_t precision = 0.001; // Precision
274 Double_t minStepSize = 0.001; // Minimum step size
279 density = geometry->GetSiDensity();
280 radiationLength = 9.36;
286 AliMaterial(id, "Si$", a, z, density, radiationLength, absorbtionLength);
287 AliMedium(kSiId, "Si$", id,1,fieldType,maxField,maxBending,
288 maxStepSize,maxEnergyLoss,precision,minStepSize);
295 radiationLength = 18.8;
301 AliMaterial(id, "Carbon$", a, z, density, radiationLength, absorbtionLength);
302 AliMedium(kCarbonId, "Carbon$", id,0,fieldType,maxField,maxBending,
303 maxStepSize,maxEnergyLoss,precision,minStepSize);
309 radiationLength = 8.9;
311 AliMaterial(id, "Aluminum$",a,z, density, radiationLength, absorbtionLength);
312 AliMedium(kAlId, "Aluminum$", id, 0, fieldType, maxField, maxBending,
313 maxStepSize, maxEnergyLoss, precision, minStepSize);
320 radiationLength = 1.43;
322 AliMaterial(id, "Copper$",
323 a, z, density, radiationLength, absorbtionLength);
324 AliMedium(kCopperId, "Copper$", id, 0, fieldType, maxField, maxBending,
325 maxStepSize, maxEnergyLoss, precision, minStepSize);
330 Float_t as[] = { 12.0107, 14.0067, 15.9994,
331 1.00794, 28.0855, 107.8682 };
332 Float_t zs[] = { 6., 7., 8.,
334 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
335 0.004367771, 0.844665, 0.09814344903 };
342 AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
343 AliMedium(kSiChipId, "Si Chip$", id, 0, fieldType, maxField, maxBending,
344 maxStepSize, maxEnergyLoss, precision, minStepSize);
349 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
350 Float_t zs[] = { 1., 6., 7., 8.};
351 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
358 AliMixture(id, "Kaption$", as, zs, density, 4, ws);
359 AliMedium(kKaptonId, "Kaption$", id,0,fieldType,maxField,maxBending,
360 maxStepSize,maxEnergyLoss,precision,minStepSize);
365 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
366 Float_t zs[] = { 6., 7., 8., 18. };
367 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
374 AliMixture(id, "Air$", as, zs, density, 4, ws);
375 AliMedium(kAirId, "Air$", id,0,fieldType,maxField,maxBending,
376 maxStepSize,maxEnergyLoss,precision,minStepSize);
381 Float_t zs[] = { 14., 20., 13., 12.,
385 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
386 10.811, 47.867, 22.98977, 39.0983,
387 55.845, 18.9984, 15.9994, 12.0107,
389 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
390 0.01397570, 0.00287685, 0.00445114, 0.00498089,
391 0.00209828, 0.00420000, 0.36043788, 0.27529426,
392 0.01415852, 0.03427566};
399 AliMixture(id, "PCB$", as, zs, density, 14, ws);
400 AliMedium(kPcbId, "PCB$", id,0,fieldType,maxField,maxBending,
401 maxStepSize,maxEnergyLoss,precision,minStepSize);
406 Float_t as[] = { 55.847, 51.9961, 58.6934, 28.0855 };
407 Float_t zs[] = { 26., 24., 28., 14. };
408 Float_t ws[] = { .715, .18, .1, .005 };
411 AliMixture(id, "Steel$", as, zs, density, 4, ws);
412 AliMedium(kSteelId, "Steel$", id, 0, fieldType, maxField, maxBending,
413 maxStepSize, maxEnergyLoss, precision, minStepSize);
417 Float_t as[] = { 1.01, 12.01 };
418 Float_t zs[] = { 1., 6. };
419 Float_t ws[] = { 1., 1. };
426 AliMixture(id, "Plastic$", as, zs, density, -2, ws);
427 AliMedium(kPlasticId, "Plastic$", id,0,fieldType,maxField,maxBending,
428 maxStepSize,maxEnergyLoss,precision,minStepSize);
433 //____________________________________________________________________
435 AliFMD::SetTrackingParameters(Int_t imed,
438 Float_t neutral_hadron,
439 Float_t charged_hadron,
441 Float_t electron_bremstrahlung,
442 Float_t muon__bremstrahlung,
443 Float_t electron_delta,
448 Int_t compton_scattering,
453 Int_t multiple_scattering,
454 Int_t pair_production,
455 Int_t photon_production,
456 Int_t rayleigh_scattering)
459 TArrayI& idtmed = *(GetIdtmed());
460 Int_t iimed = idtmed[imed];
461 gMC->Gstpar(iimed, "CUTGAM", gamma);
462 gMC->Gstpar(iimed, "CUTELE", electron);
463 gMC->Gstpar(iimed, "CUTNEU", neutral_hadron);
464 gMC->Gstpar(iimed, "CUTHAD", charged_hadron);
465 gMC->Gstpar(iimed, "CUTMUO", muon);
466 gMC->Gstpar(iimed, "BCUTE", electron_bremstrahlung);
467 gMC->Gstpar(iimed, "BCUTM", muon__bremstrahlung);
468 gMC->Gstpar(iimed, "DCUTE", electron_delta);
469 gMC->Gstpar(iimed, "DCUTM", muon_delta);
470 gMC->Gstpar(iimed, "PPCUTM", muon_pair);
471 gMC->Gstpar(iimed, "ANNI", Float_t(annihilation));
472 gMC->Gstpar(iimed, "BREM", Float_t(bremstrahlung));
473 gMC->Gstpar(iimed, "COMP", Float_t(compton_scattering));
474 gMC->Gstpar(iimed, "DCAY", Float_t(decay));
475 gMC->Gstpar(iimed, "DRAY", Float_t(delta_ray));
476 gMC->Gstpar(iimed, "HADR", Float_t(hadronic));
477 gMC->Gstpar(iimed, "LOSS", Float_t(energy_loss));
478 gMC->Gstpar(iimed, "MULS", Float_t(multiple_scattering));
479 gMC->Gstpar(iimed, "PAIR", Float_t(pair_production));
480 gMC->Gstpar(iimed, "PHOT", Float_t(photon_production));
481 gMC->Gstpar(iimed, "RAYL", Float_t(rayleigh_scattering));
484 //____________________________________________________________________
488 // Initialize the detector
490 AliFMDDebug(1, ("Initialising FMD detector object"));
491 TVirtualMC* mc = TVirtualMC::GetMC();
492 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
493 const TArrayI& actGeo = fmd->ActiveIds();
494 TArrayI actVmc(actGeo.fN);
495 for (Int_t i = 0; i < actGeo.fN; i++) {
496 TGeoVolume *sens = gGeoManager->GetVolume(actGeo[i]);
498 AliError(Form("No TGeo volume for sensitive volume ID=%d",actGeo[i]));
501 actVmc[i] = mc->VolId(sens->GetName());
502 AliFMDDebug(1, ("Active vol id # %d: %d changed to %d",
503 i, actGeo[i], actVmc[i]));
505 fmd->SetActive(actVmc.fArray, actVmc.fN);
506 // fmd->InitTransformations();
509 //____________________________________________________________________
511 AliFMD::FinishEvent()
513 // Called at the end of the an event in simulations. If the debug
514 // level is high enough, then the `bad' hits are printed.
516 if (AliLog::GetDebugLevel("FMD", "AliFMD") < 10) return;
517 if (fBad && fBad->GetEntries() > 0) {
518 AliWarning((Form("EndEvent", "got %d 'bad' hits", fBad->GetEntries())));
521 while ((hit = static_cast<AliFMDHit*>(next()))) hit->Print("D");
528 //====================================================================
530 // Hit and Digit managment
532 //____________________________________________________________________
534 AliFMD::MakeBranch(Option_t * option)
536 // Create Tree branches for the FMD.
540 // H Make a branch of TClonesArray of AliFMDHit's
541 // D Make a branch of TClonesArray of AliFMDDigit's
542 // S Make a branch of TClonesArray of AliFMDSDigit's
544 const Int_t kBufferSize = 16000;
545 TString branchname(GetName());
548 if (opt.Contains("H", TString::kIgnoreCase)) {
550 AliDetector::MakeBranch(option);
552 if (opt.Contains("D", TString::kIgnoreCase)) {
554 MakeBranchInTree(fLoader->TreeD(), branchname.Data(),
555 &fDigits, kBufferSize, 0);
557 if (opt.Contains("S", TString::kIgnoreCase)) {
559 MakeBranchInTree(fLoader->TreeS(), branchname.Data(),
560 &fSDigits, kBufferSize, 0);
564 //____________________________________________________________________
566 AliFMD::SetTreeAddress()
568 // Set branch address for the Hits, Digits, and SDigits Tree.
569 if (fLoader->TreeH()) HitsArray();
570 AliDetector::SetTreeAddress();
572 TTree *treeD = fLoader->TreeD();
575 TBranch* branch = treeD->GetBranch ("FMD");
576 if (branch) branch->SetAddress(&fDigits);
579 TTree *treeS = fLoader->TreeS();
582 TBranch* branch = treeS->GetBranch ("FMD");
583 if (branch) branch->SetAddress(&fSDigits);
587 //____________________________________________________________________
589 AliFMD::SetHitsAddressBranch(TBranch *b)
591 // Set the TClonesArray to read hits into.
592 b->SetAddress(&fHits);
594 //____________________________________________________________________
596 AliFMD::SetSDigitsAddressBranch(TBranch *b)
598 // Set the TClonesArray to read hits into.
599 b->SetAddress(&fSDigits);
602 //____________________________________________________________________
604 AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
606 // Add a hit to the hits tree
608 // The information of the two arrays are decoded as
612 // ivol[0] [UShort_t ] Detector #
613 // ivol[1] [Char_t ] Ring ID
614 // ivol[2] [UShort_t ] Sector #
615 // ivol[3] [UShort_t ] Strip #
616 // hits[0] [Float_t ] Track's X-coordinate at hit
617 // hits[1] [Float_t ] Track's Y-coordinate at hit
618 // hits[3] [Float_t ] Track's Z-coordinate at hit
619 // hits[4] [Float_t ] X-component of track's momentum
620 // hits[5] [Float_t ] Y-component of track's momentum
621 // hits[6] [Float_t ] Z-component of track's momentum
622 // hits[7] [Float_t ] Energy deposited by track
623 // hits[8] [Int_t ] Track's particle Id #
624 // hits[9] [Float_t ] Time when the track hit
627 AddHitByFields(track,
628 UShort_t(vol[0]), // Detector #
629 Char_t(vol[1]), // Ring ID
630 UShort_t(vol[2]), // Sector #
631 UShort_t(vol[3]), // Strip #
638 hits[6], // Energy loss
639 Int_t(hits[7]), // PDG
643 //____________________________________________________________________
645 AliFMD::AddHitByFields(Int_t track,
662 // Add a hit to the list
667 // detector Detector # (1, 2, or 3)
668 // ring Ring ID ('I' or 'O')
669 // sector Sector # (For inner/outer rings: 0-19/0-39)
670 // strip Strip # (For inner/outer rings: 0-511/0-255)
671 // x Track's X-coordinate at hit
672 // y Track's Y-coordinate at hit
673 // z Track's Z-coordinate at hit
674 // px X-component of track's momentum
675 // py Y-component of track's momentum
676 // pz Z-component of track's momentum
677 // edep Energy deposited by track
678 // pdg Track's particle Id #
679 // t Time when the track hit
680 // l Track length through the material.
681 // stop Whether track was stopped or disappeared
683 TClonesArray& a = *(HitsArray());
684 // Search through the list of already registered hits, and see if we
685 // find a hit with the same parameters. If we do, then don't create
686 // a new hit, but rather update the energy deposited in the hit.
687 // This is done, so that a FLUKA based simulation will get the
688 // number of hits right, not just the enerrgy deposition.
690 for (Int_t i = 0; i < fNhits; i++) {
691 if (!a.At(i)) continue;
692 hit = static_cast<AliFMDHit*>(a.At(i));
693 if (hit->Detector() == detector
694 && hit->Ring() == ring
695 && hit->Sector() == sector
696 && hit->Strip() == strip
697 && hit->Track() == track) {
698 AliFMDDebug(1, ("already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
699 " adding energy (%f) to that hit (%f) -> %f",
700 detector, ring, sector, strip, track, edep, hit->Edep(),
701 hit->Edep() + edep));
702 hit->SetEdep(hit->Edep() + edep);
706 // If hit wasn't already registered, do so know.
707 hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector,
708 strip, x, y, z, px, py, pz, edep, pdg, t,
710 // gMC->AddTrackReference(track, 12);
715 AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
717 AliTrackReference* trackRef = AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kFMD);
718 UInt_t stripId = AliFMDStripIndex::Pack(detector,ring,sector,strip);
719 trackRef->SetUserId(stripId);
726 //____________________________________________________________________
728 AliFMD::AddDigit(Int_t* digits, Int_t*)
730 // Add a digit to the Digit tree
734 // digits[0] [UShort_t] Detector #
735 // digits[1] [Char_t] Ring ID
736 // digits[2] [UShort_t] Sector #
737 // digits[3] [UShort_t] Strip #
738 // digits[4] [UShort_t] ADC Count
739 // digits[5] [Short_t] ADC Count, -1 if not used
740 // digits[6] [Short_t] ADC Count, -1 if not used
742 AddDigitByFields(UShort_t(digits[0]), // Detector #
743 Char_t(digits[1]), // Ring ID
744 UShort_t(digits[2]), // Sector #
745 UShort_t(digits[3]), // Strip #
746 UShort_t(digits[4]), // ADC Count1
747 Short_t(digits[5]), // ADC Count2
748 Short_t(digits[6]), // ADC Count3
752 //____________________________________________________________________
754 AliFMD::AddDigitByFields(UShort_t detector,
765 // add a real digit - as coming from data
769 // detector Detector # (1, 2, or 3)
770 // ring Ring ID ('I' or 'O')
771 // sector Sector # (For inner/outer rings: 0-19/0-39)
772 // strip Strip # (For inner/outer rings: 0-511/0-255)
773 // count1 ADC count (a 10-bit word)
774 // count2 ADC count (a 10-bit word), or -1 if not used
775 // count3 ADC count (a 10-bit word), or -1 if not used
776 TClonesArray& a = *(DigitsArray());
778 AliFMDDebug(15, ("Adding digit # %5d/%5d for FMD%d%c[%2d,%3d]"
779 "=(%d,%d,%d,%d) with %d tracks",
780 fNdigits-1, a.GetEntriesFast(),
781 detector, ring, sector, strip,
782 count1, count2, count3, count4, nrefs));
784 AliFMDDigit(detector, ring, sector, strip,
785 count1, count2, count3, count4, nrefs, refs);
789 //____________________________________________________________________
791 AliFMD::AddSDigit(Int_t* digits)
793 // Add a digit to the SDigit tree
797 // digits[0] [UShort_t] Detector #
798 // digits[1] [Char_t] Ring ID
799 // digits[2] [UShort_t] Sector #
800 // digits[3] [UShort_t] Strip #
801 // digits[4] [Float_t] Total energy deposited
802 // digits[5] [UShort_t] ADC Count
803 // digits[6] [Short_t] ADC Count, -1 if not used
804 // digits[7] [Short_t] ADC Count, -1 if not used
806 AddSDigitByFields(UShort_t(digits[0]), // Detector #
807 Char_t(digits[1]), // Ring ID
808 UShort_t(digits[2]), // Sector #
809 UShort_t(digits[3]), // Strip #
810 Float_t(digits[4]), // Edep
811 UShort_t(digits[5]), // ADC Count1
812 Short_t(digits[6]), // ADC Count2
813 Short_t(digits[7]), // ADC Count3
814 Short_t(digits[8]), // ADC Count4
815 UShort_t(digits[9]), // N particles
816 UShort_t(digits[10])); // N primaries
819 //____________________________________________________________________
821 AliFMD::AddSDigitByFields(UShort_t detector,
834 // add a summable digit
838 // detector Detector # (1, 2, or 3)
839 // ring Ring ID ('I' or 'O')
840 // sector Sector # (For inner/outer rings: 0-19/0-39)
841 // strip Strip # (For inner/outer rings: 0-511/0-255)
842 // edep Total energy deposited
843 // count1 ADC count (a 10-bit word)
844 // count2 ADC count (a 10-bit word), or -1 if not used
845 // count3 ADC count (a 10-bit word), or -1 if not used
847 TClonesArray& a = *(SDigitsArray());
848 // AliFMDDebug(0, ("Adding sdigit # %d", fNsdigits));
850 AliFMDDebug(15, ("Adding sdigit # %5d/%5d for FMD%d%c[%2d,%3d]"
851 "=(%d,%d,%d,%d) with %d tracks %d primaries %d (%p)",
852 fNsdigits-1, a.GetEntriesFast(),
853 detector, ring, sector, strip,
854 count1, count2, count3, count4, ntot, nprim, refs));
856 AliFMDSDigit(detector, ring, sector, strip, edep,
857 count1, count2, count3, count4, ntot, nprim, refs);
860 //____________________________________________________________________
862 AliFMD::ResetSDigits()
864 // Reset number of digits and the digits array for this detector.
867 if (fSDigits) fSDigits->Clear();
871 //____________________________________________________________________
875 // Initialize hit array if not already, and return pointer to it.
877 fHits = new TClonesArray("AliFMDHit", 1000);
883 //____________________________________________________________________
885 AliFMD::DigitsArray()
887 // Initialize digit array if not already, and return pointer to it.
889 fDigits = new TClonesArray("AliFMDDigit", 1000);
895 //____________________________________________________________________
897 AliFMD::SDigitsArray()
899 // Initialize digit array if not already, and return pointer to it.
901 fSDigits = new TClonesArray("AliFMDSDigit", 1000);
907 //====================================================================
911 //____________________________________________________________________
913 AliFMD::Hits2Digits()
915 // Create AliFMDDigit's from AliFMDHit's. This is done by making a
916 // AliFMDDigitizer, and executing that code.
918 AliFMDHitDigitizer digitizer(this, AliFMDHitDigitizer::kDigits);
923 //____________________________________________________________________
925 AliFMD::Hits2SDigits()
927 // Create AliFMDSDigit's from AliFMDHit's. This is done by creating
928 // an AliFMDSDigitizer object, and executing it.
930 AliFMDHitDigitizer digitizer(this, AliFMDHitDigitizer::kSDigits);
936 //____________________________________________________________________
938 AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
940 // Create a digitizer object
942 /* This is what we probably _should_ do */
943 AliFMDBaseDigitizer* digitizer = 0;
945 #ifdef USE_SSDIGITIZER
946 digitizer = new AliFMDSSDigitizer(manager);
948 /* This is what we actually do, and will work */
950 AliInfo("SDigit->Digit conversion not really supported, "
951 "doing Hit->Digit conversion instead");
953 digitizer = new AliFMDDigitizer(manager);
958 //====================================================================
960 // Raw data simulation
962 //__________________________________________________________________
966 // Turn digits into raw data.
968 // This uses the class AliFMDRawWriter to do the job. Please refer
969 // to that class for more information.
970 AliFMDRawWriter writer(this);
974 //====================================================================
978 //__________________________________________________________________
980 AliFMD::Raw2SDigits(AliRawReader* reader)
982 // Turn digits into raw data.
984 // This uses the class AliFMDRawWriter to do the job. Please refer
985 // to that class for more information.
986 AliFMDParameters::Instance()->Init();
990 TClonesArray* sdigits = SDigits();
991 AliFMDReconstructor rec;
993 // The two boolean arguments
994 // Make sdigits instead of digits
995 // Subtract the pedestal off the signal
996 rec.Digitize(reader, sdigits);
998 // Bool_t ret = fmdReader.ReadAdcs(sdigits, kTRUE, kTRUE);
1000 UShort_t ns = sdigits->GetEntriesFast();
1001 for (UShort_t i = 0; i < ns; i++)
1002 sdigits->At(i)->Print("pl");
1004 AliFMDDebug(1, ("Got a total of %d SDigits", ns));
1006 fLoader->TreeS()->Fill();
1008 fLoader->WriteSDigits("OVERWRITE");
1014 //====================================================================
1018 //__________________________________________________________________
1020 AliFMD::Browse(TBrowser* b)
1022 // Browse this object.
1024 AliFMDDebug(30, ("\tBrowsing the FMD"));
1025 AliDetector::Browse(b);
1026 b->Add(AliFMDGeometry::Instance());
1029 //____________________________________________________________________
1031 AliFMD::AddAlignableVolumes() const
1034 // Create entries for alignable volumes associating the symbolic volume
1035 // name with the corresponding volume path. Needs to be syncronized with
1036 // eventual changes in the geometry.
1038 // This code was made by Raffaele Grosso <rgrosso@mail.cern.ch>. I
1039 // (cholm) will probably want to change it. For one, I think it
1040 // should be the job of the geometry manager to deal with this.
1041 AliInfo("Add FMD alignable volumes");
1042 AliFMDGeometry::Instance()->SetAlignableVolumes();
1044 for(size_t f = 1; f <= 3; f++){ // Detector 1,2,3
1045 for(size_t tb = 0; tb <2 ; tb++){ // Top/Bottom
1046 char stb = tb == 0 ? 'T' : 'B';
1047 unsigned min = tb == 0 ? 0 : 5;
1049 TString halfVol(Form("/ALIC_1/F%dM%c_%d", f, stb, f));
1050 TString halfSym(halfVol);
1051 if(!gGeoManager->SetAlignableEntry(halfSym.Data(),halfVol.Data()))
1052 AliFatal(Form("Alignable entry %s not created. "
1053 "Volume path %s not valid",
1054 halfSym.Data(),halfVol.Data()));
1055 for(size_t io = 0; io < 2; io++){ // inner, outer
1056 if (f==1 && io==1) continue; // Only one ring in FMD1
1057 if(tb == 1 && io==1) min=10;
1058 char sio = (io == 0 ? 'I' : 'O');
1059 unsigned nio = (io == 0 ? 3 : 9);
1060 unsigned max = (io == 0 ? 5 : 10) + min;
1062 for(size_t i = min; i < max; i++) { // Modules
1063 TString modVol(Form("%s/F%c%cV_7%d/F%cSE_%d", halfVol.Data(),
1064 sio, stb, nio, sio, i));
1065 TString modSym(modVol);
1066 if(!gGeoManager->SetAlignableEntry(modSym.Data(),modVol.Data()))
1067 AliFatal(Form("Alignable entry %s not created. "
1068 "Volume path %s not valid",
1069 modSym.Data(), modVol.Data()));
1076 //___________________________________________________________________