1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //____________________________________________________________________
20 // Forward Multiplicity Detector based on Silicon wafers. This class
21 // contains the base procedures for the Forward Multiplicity detector
22 // Detector consists of 3 sub-detectors FMD1, FMD2, and FMD3, each of
23 // which has 1 or 2 rings of silicon sensors.
25 // This is the base class for all FMD manager classes.
27 // The actual code is done by various separate classes. Below is
28 // diagram showing the relationship between the various FMD classes
29 // that handles the simulation
31 // +--------+ 1 +-----------------+
32 // | AliFMD |<>-----| AliFMDSimulator |
33 // +--------+ +-----------------+
36 // +-------------+-------------+
38 // +--------------------+ +-------------------+
39 // | AliFMDGeoSimulator | | AliFMDG3Simulator |
40 // +--------------------+ +-------------------+
43 // +----------------------+
44 // | AliFMDG3OldSimulator |
45 // +----------------------+
48 // This defines the interface for the various parts of AliROOT that
49 // uses the FMD, like AliFMDSimulator, AliFMDDigitizer,
50 // AliFMDReconstructor, and so on.
53 // This is the base class for the FMD simulation tasks. The
54 // simulator tasks are responsible to implment the geoemtry, and
57 // * AliFMDGeoSimulator
58 // This is a concrete implementation of the AliFMDSimulator that
59 // uses the TGeo classes directly only. This defines the active
60 // volume as an ONLY XTRU shape with a divided MANY TUBS shape
61 // inside to implement the particular shape of the silicon
64 // * AliFMDG3Simulator
65 // This is a concrete implementation of the AliFMDSimulator that
66 // uses the TVirtualMC interface with GEANT 3.21-like messages.
67 // This implements the active volume as a divided TUBS shape. Hits
68 // in the corners should be cut away at run time (but currently
71 // * AliFMDG3OldSimulator
72 // This is a concrete implementation of AliFMDSimulator. It
73 // approximates the of the rings as segmented disks.
75 #include "AliFMDSimulator.h" // ALIFMDSIMULATOR_H
76 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
77 #include "AliFMDDetector.h" // ALIFMDDETECTOR_H
78 #include "AliFMDRing.h" // ALIFMDRING_H
79 #include "AliFMD1.h" // ALIFMD1_H
80 #include "AliFMD2.h" // ALIFMD2_H
81 #include "AliFMD3.h" // ALIFMD3_H
82 #include "AliFMD.h" // ALIFMD_H
83 #include "AliFMDHit.h" // ALIFMDHIT_H
84 #include <AliRun.h> // ALIRUN_H
85 #include <AliMC.h> // ALIMC_H
86 #include <AliMagF.h> // ALIMAGF_H
87 #include <AliLog.h> // ALILOG_H
88 #include <TGeoVolume.h> // ROOT_TGeoVolume
89 #include <TGeoTube.h> // ROOT_TGeoTube
90 #include <TGeoPcon.h> // ROOT_TGeoPcon
91 #include <TGeoMaterial.h> // ROOT_TGeoMaterial
92 #include <TGeoMedium.h> // ROOT_TGeoMedium
93 #include <TGeoXtru.h> // ROOT_TGeoXtru
94 #include <TGeoPolygon.h> // ROOT_TGeoPolygon
95 #include <TGeoTube.h> // ROOT_TGeoTube
96 #include <TGeoManager.h> // ROOT_TGeoManager
97 #include <TTree.h> // ROOT_TTree
98 #include <TParticle.h> // ROOT_TParticle
99 #include <TLorentzVector.h> // ROOT_TLorentzVector
100 #include <TVector2.h> // ROOT_TVector2
101 #include <TVector3.h> // ROOT_TVector3
102 #include <TVirtualMC.h> // ROOT_TVirtualMC
103 #include <TArrayD.h> // ROOT_TArrayD
106 //====================================================================
107 ClassImp(AliFMDSimulator)
109 ; // This is here to keep Emacs for indenting the next line
112 //____________________________________________________________________
113 const Char_t* AliFMDSimulator::fgkActiveName = "F%cAC";
114 const Char_t* AliFMDSimulator::fgkSectorName = "F%cSE";
115 const Char_t* AliFMDSimulator::fgkStripName = "F%cST";
116 const Char_t* AliFMDSimulator::fgkModuleName = "F%cMO";
117 const Char_t* AliFMDSimulator::fgkPCBName = "F%cP%c";
118 const Char_t* AliFMDSimulator::fgkLongLegName = "F%cLL";
119 const Char_t* AliFMDSimulator::fgkShortLegName = "F%cSL";
120 const Char_t* AliFMDSimulator::fgkFrontVName = "F%cFV";
121 const Char_t* AliFMDSimulator::fgkBackVName = "F%cBV";
122 const Char_t* AliFMDSimulator::fgkRingName = "FMD%c";
123 const Char_t* AliFMDSimulator::fgkTopHCName = "F%d%cI";
124 const Char_t* AliFMDSimulator::fgkBotHCName = "F%d%cJ";
125 const Char_t* AliFMDSimulator::fgkTopIHCName = "F%d%cK";
126 const Char_t* AliFMDSimulator::fgkBotIHCName = "F%d%cL";
127 const Char_t* AliFMDSimulator::fgkNoseName = "F3SN";
128 const Char_t* AliFMDSimulator::fgkBackName = "F3SB";
129 const Char_t* AliFMDSimulator::fgkBeamName = "F3SL";
130 const Char_t* AliFMDSimulator::fgkFlangeName = "F3SF";
132 //____________________________________________________________________
133 AliFMDSimulator::AliFMDSimulator()
143 // Default constructor
146 //____________________________________________________________________
147 AliFMDSimulator::AliFMDSimulator(AliFMD* fmd, Bool_t detailed)
148 : TTask("FMDSimulator", "Forward Multiplicity Detector Simulator"),
158 // Normal constructor
162 // fmd Pointer to AliFMD object
163 // detailed Whether to make a detailed simulation or not
165 fBad = new TClonesArray("AliFMDHit");
169 //____________________________________________________________________
171 AliFMDSimulator::DefineMaterials()
173 // Define the materials and tracking mediums needed by the FMD
174 // simulation. These mediums are made by sending the messages
175 // AliMaterial, AliMixture, and AliMedium to the passed AliModule
176 // object module. The defined mediums are
178 // FMD Si$ Silicon (active medium in sensors)
179 // FMD C$ Carbon fibre (support cone for FMD3 and vacuum pipe)
180 // FMD Al$ Aluminium (honeycomb support plates)
181 // FMD PCB$ Printed Circuit Board (FEE board with VA1_3)
182 // FMD Chip$ Electronics chips (currently not used)
183 // FMD Air$ Air (Air in the FMD)
184 // FMD Plastic$ Plastic (Support legs for the hybrid cards)
186 // Pointers to TGeoMedium objects are retrived from the TGeoManager
187 // singleton. These pointers are later used when setting up the
189 AliDebug(10, "\tCreating materials");
190 // Get pointer to geometry singleton object.
191 AliFMDGeometry* geometry = AliFMDGeometry::Instance();
197 Double_t density = 0;
198 Double_t radiationLength = 0;
199 Double_t absorbtionLength = 999;
200 Int_t fieldType = gAlice->Field()->Integ(); // Field type
201 Double_t maxField = gAlice->Field()->Max(); // Field max.
202 Double_t maxBending = 0; // Max Angle
203 Double_t maxStepSize = 0.001; // Max step size
204 Double_t maxEnergyLoss = 1; // Max Delta E
205 Double_t precision = 0.001; // Precision
206 Double_t minStepSize = 0.001; // Minimum step size
211 density = geometry->GetSiDensity();
212 radiationLength = 9.36;
218 fFMD->AliMaterial(id, "Si$",
219 a, z, density, radiationLength, absorbtionLength);
220 fFMD->AliMedium(kSiId, "Si$",
221 id,1,fieldType,maxField,maxBending,
222 maxStepSize,maxEnergyLoss,precision,minStepSize);
229 radiationLength = 18.8;
235 fFMD->AliMaterial(id, "Carbon$",
236 a, z, density, radiationLength, absorbtionLength);
237 fFMD->AliMedium(kCarbonId, "Carbon$",
238 id,0,fieldType,maxField,maxBending,
239 maxStepSize,maxEnergyLoss,precision,minStepSize);
245 radiationLength = 8.9;
247 fFMD->AliMaterial(id, "Aluminum$",
248 a, z, density, radiationLength, absorbtionLength);
249 fFMD->AliMedium(kAlId, "Aluminum$",
250 id, 0, fieldType, maxField, maxBending,
251 maxStepSize, maxEnergyLoss, precision, minStepSize);
258 radiationLength = 1.43;
260 fFMD->AliMaterial(id, "Copper$",
261 a, z, density, radiationLength, absorbtionLength);
262 fFMD->AliMedium(kCopperId, "Copper$",
263 id, 0, fieldType, maxField, maxBending,
264 maxStepSize, maxEnergyLoss, precision, minStepSize);
269 Float_t as[] = { 12.0107, 14.0067, 15.9994,
270 1.00794, 28.0855, 107.8682 };
271 Float_t zs[] = { 6., 7., 8.,
273 Float_t ws[] = { 0.039730642, 0.001396798, 0.01169634,
274 0.004367771, 0.844665, 0.09814344903 };
281 fFMD->AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
282 fFMD->AliMedium(kSiChipId, "Si Chip$",
283 id, 0, fieldType, maxField, maxBending,
284 maxStepSize, maxEnergyLoss, precision, minStepSize);
289 Float_t as[] = { 1.00794, 12.0107, 14.010, 15.9994};
290 Float_t zs[] = { 1., 6., 7., 8.};
291 Float_t ws[] = { 0.026362, 0.69113, 0.07327, 0.209235};
298 fFMD->AliMixture(id, "Kaption$", as, zs, density, 4, ws);
299 fFMD->AliMedium(kKaptonId, "Kaption$",
300 id,0,fieldType,maxField,maxBending,
301 maxStepSize,maxEnergyLoss,precision,minStepSize);
306 Float_t as[] = { 12.0107, 14.0067, 15.9994, 39.948 };
307 Float_t zs[] = { 6., 7., 8., 18. };
308 Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 };
315 fFMD->AliMixture(id, "Air$", as, zs, density, 4, ws);
316 fFMD->AliMedium(kAirId, "Air$",
317 id,0,fieldType,maxField,maxBending,
318 maxStepSize,maxEnergyLoss,precision,minStepSize);
323 Float_t zs[] = { 14., 20., 13., 12.,
327 Float_t as[] = { 28.0855, 40.078, 26.981538, 24.305,
328 10.811, 47.867, 22.98977, 39.0983,
329 55.845, 18.9984, 15.9994, 12.0107,
331 Float_t ws[] = { 0.15144894, 0.08147477, 0.04128158, 0.00904554,
332 0.01397570, 0.00287685, 0.00445114, 0.00498089,
333 0.00209828, 0.00420000, 0.36043788, 0.27529426,
334 0.01415852, 0.03427566};
341 fFMD->AliMixture(id, "PCB$", as, zs, density, 14, ws);
342 fFMD->AliMedium(kPcbId, "PCB$",
343 id,0,fieldType,maxField,maxBending,
344 maxStepSize,maxEnergyLoss,precision,minStepSize);
349 Float_t as[] = { 1.01, 12.01 };
350 Float_t zs[] = { 1., 6. };
351 Float_t ws[] = { 1., 1. };
358 fFMD->AliMixture(id, "Plastic$", as, zs, density, -2, ws);
359 fFMD->AliMedium(kPlasticId, "Plastic$",
360 id,0,fieldType,maxField,maxBending,
361 maxStepSize,maxEnergyLoss,precision,minStepSize);
365 //____________________________________________________________________
367 AliFMDSimulator::IsActive(Int_t volId) const
369 for (Int_t i = 0; i < fActiveId.fN; i++)
370 if (volId == fActiveId[i]) return kTRUE;
374 //____________________________________________________________________
376 AliFMDSimulator::VMC2FMD(TLorentzVector& v, UShort_t& detector,
377 Char_t& ring, UShort_t& sector, UShort_t& strip)
379 TVirtualMC* mc = TVirtualMC::GetMC();
381 // Get track position
382 mc->TrackPosition(v);
383 Int_t moduleno; mc->CurrentVolOffID(fModuleOff, moduleno);
384 Int_t iring; mc->CurrentVolOffID(fRingOff, iring); ring = Char_t(iring);
385 Int_t det; mc->CurrentVolOffID(fDetectorOff, det); detector = det;
388 // Get the ring geometry
389 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
390 //Int_t nsec = fmd->GetDetector(detector)->GetRing(ring)->GetNSectors();
391 Int_t nstr = fmd->GetDetector(detector)->GetRing(ring)->GetNStrips();
392 Double_t lowr = fmd->GetDetector(detector)->GetRing(ring)->GetLowR();
393 Double_t highr= fmd->GetDetector(detector)->GetRing(ring)->GetHighR();
394 Double_t theta= fmd->GetDetector(detector)->GetRing(ring)->GetTheta();
396 // Figure out the strip number
397 Double_t r = TMath::Sqrt(v.X() * v.X() + v.Y() * v.Y());
398 Double_t pitch = (highr - lowr) / nstr;
399 Int_t str = Int_t((r - lowr) / pitch);
400 if (str < 0 || str >= nstr) return kFALSE;
403 // Figure out the sector number
404 Double_t phi = TMath::ATan2(v.Y(), v.X()) * 180. / TMath::Pi();
405 if (phi < 0) phi = 360. + phi;
406 Double_t t = phi - 2 * moduleno * theta;
407 sector = 2 * moduleno;
408 if (t < 0 || t > 2 * theta) return kFALSE;
409 else if (t > theta) sector += 1;
411 AliDebug(40, Form("<1> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
412 detector, ring, sector, strip, mc->CurrentVolPath()));
416 //____________________________________________________________________
418 AliFMDSimulator::VMC2FMD(Int_t copy, TLorentzVector& v,
419 UShort_t& detector, Char_t& ring,
420 UShort_t& sector, UShort_t& strip)
422 TVirtualMC* mc = TVirtualMC::GetMC();
425 Int_t sectordiv; mc->CurrentVolOffID(fSectorOff, sectordiv);
426 if (fModuleOff >= 0) {
427 Int_t module; mc->CurrentVolOffID(fModuleOff, module);
428 sector = 2 * module + sectordiv;
432 Int_t iring; mc->CurrentVolOffID(fRingOff, iring); ring = Char_t(iring);
433 Int_t det; mc->CurrentVolOffID(fDetectorOff, det); detector = det;
435 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
436 //Double_t rz = fmd->GetDetector(detector)->GetRingZ(ring);
437 Int_t n = fmd->GetDetector(detector)->GetRing(ring)->GetNSectors();
440 Int_t s = ((n - sector + n / 2) % n) + 1;
441 AliDebug(1, Form("Recalculating sector to %d (=%d-%d+%d/2%%%d+1 z=%f)",
442 s, n, sector, n, n, rz));
446 if (sector < 1 || sector > n) {
447 Warning("Step", "sector # %d out of range (0-%d)", sector-1, n-1);
451 // Get track position
452 mc->TrackPosition(v);
453 AliDebug(15, Form("<2> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
454 detector, ring, sector, strip, mc->CurrentVolPath()));
459 //____________________________________________________________________
461 AliFMDSimulator::Exec(Option_t* /* option */)
463 // Member function that is executed each time a hit is made in the
464 // FMD. None-charged particles are ignored. Dead tracks are
467 // The procedure is as follows:
469 // - IF NOT track is alive THEN RETURN ENDIF
470 // - IF NOT particle is charged THEN RETURN ENDIF
471 // - IF NOT volume name is "STRI" or "STRO" THEN RETURN ENDIF
472 // - Get strip number (volume copy # minus 1)
473 // - Get phi division number (mother volume copy #)
474 // - Get module number (grand-mother volume copy #)
475 // - section # = 2 * module # + phi division # - 1
476 // - Get ring Id from volume name
477 // - Get detector # from grand-grand-grand-mother volume name
478 // - Get pointer to sub-detector object.
479 // - Get track position
480 // - IF track is entering volume AND track is inside real shape THEN
481 // - Reset energy deposited
482 // - Get track momentum
483 // - Get particle ID #
485 // - IF track is inside volume AND inside real shape THEN
486 /// - Update energy deposited
488 // - IF track is inside real shape AND (track is leaving volume,
489 // or it died, or it is stopped THEN
493 TVirtualMC* mc = TVirtualMC::GetMC();
494 if (!mc->IsTrackAlive()) return;
495 Double_t absQ = TMath::Abs(mc->TrackCharge());
496 if (absQ <= 0) return;
499 Int_t vol = mc->CurrentVolID(copy);
500 if (!IsActive(vol)) {
501 AliDebug(50, Form("Not an FMD volume %d '%s'",vol,mc->CurrentVolName()));
511 if (!VMC2FMD(copy, v, detector, ring, sector, strip)) return;
513 if (!VMC2FMD(v, detector, ring, sector, strip)) return;
516 mc->TrackMomentum(p);
517 Int_t trackno = gAlice->GetMCApp()->GetCurrentTrackNumber();
518 Int_t pdg = mc->TrackPid();
519 Double_t mass = mc->TrackMass();
520 Double_t edep = mc->Edep() * 1000; // keV
521 Double_t poverm = (mass == 0 ? 0 : p.P() / mass);
522 Bool_t isBad = kFALSE;
524 // This `if' is to debug abnormal energy depositions. We trigger on
525 // p/m approx larger than or equal to a MIP, and a large edep - more
526 // than 1 keV - a MIP is 100 eV.
527 if (edep > absQ * absQ && poverm > 1) {
530 mc->StepProcesses(procs);
532 for (Int_t ip = 0; ip < procs.fN; ip++) {
533 if (ip != 0) processes.Append(",");
534 processes.Append(TMCProcessName[procs.fArray[ip]]);
536 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
537 TParticlePDG* particleType = pdgDB->GetParticle(pdg);
538 TString pname(particleType ? particleType->GetName() : "???");
540 if (mc->IsTrackEntering()) what.Append("entering ");
541 if (mc->IsTrackExiting()) what.Append("exiting ");
542 if (mc->IsTrackInside()) what.Append("inside ");
543 if (mc->IsTrackDisappeared()) what.Append("disappeared ");
544 if (mc->IsTrackStop()) what.Append("stopped ");
545 if (mc->IsNewTrack()) what.Append("new ");
546 if (mc->IsTrackAlive()) what.Append("alive ");
547 if (mc->IsTrackOut()) what.Append("out ");
549 Int_t mother = gAlice->GetMCApp()->GetPrimary(trackno);
550 Warning("Step", "Track # %5d deposits a lot of energy\n"
552 " Momentum: (%7.4f,%7.4f,%7.4f)\n"
554 " Edep: %-14.7f keV (mother %d)\n"
555 " p/m: %-7.4f/%-7.4f = %-14.7f\n"
558 trackno, mc->CurrentVolPath(), p.X(), p.Y(), p.Z(),
559 pdg, pname.Data(), edep, mother, p.P(), mass,
560 poverm, processes.Data(), what.Data());
563 // Check that the track is actually within the active area
564 Bool_t entering = mc->IsTrackEntering();
565 Bool_t inside = mc->IsTrackInside();
566 Bool_t out = (mc->IsTrackExiting()|| mc->IsTrackDisappeared()||
568 // Reset the energy deposition for this track, and update some of
571 AliDebug(15, Form("Track # %8d entering active FMD volume %s: "
572 "Edep=%f (%f,%f,%f)", trackno, mc->CurrentVolPath(),
573 edep, v.X(), v.Y(), v.Z()));
576 fCurrentDeltaE = edep;
577 fCurrentPdg = pdg; // mc->IdFromPDG(pdg);
579 // If the track is inside, then update the energy deposition
580 if (inside && fCurrentDeltaE >= 0) {
581 fCurrentDeltaE += edep;
582 AliDebug(15, Form("Track # %8d inside active FMD volume %s: Edep=%f, "
583 "Accumulated Edep=%f (%f,%f,%f)", trackno,
584 mc->CurrentVolPath(), edep, fCurrentDeltaE,
585 v.X(), v.Y(), v.Z()));
587 // The track exits the volume, or it disappeared in the volume, or
588 // the track is stopped because it no longer fulfills the cuts
589 // defined, then we create a hit.
591 if (fCurrentDeltaE >= 0) {
592 fCurrentDeltaE += edep;
593 AliDebug(15, Form("Track # %8d exiting active FMD volume %s: Edep=%g, "
594 "Accumulated Edep=%g (%f,%f,%f)", trackno,
595 mc->CurrentVolPath(), edep, fCurrentDeltaE,
596 v.X(), v.Y(), v.Z()));
598 fFMD->AddHitByFields(trackno, detector, ring, sector, strip,
599 fCurrentV.X(), fCurrentV.Y(), fCurrentV.Z(),
600 fCurrentP.X(), fCurrentP.Y(), fCurrentP.Z(),
601 fCurrentDeltaE, fCurrentPdg, fCurrentV.T());
604 new ((*fBad)[fBad->GetEntries()]) AliFMDHit(*h);
611 //____________________________________________________________________
613 AliFMDSimulator::EndEvent()
615 if (fBad && fBad->GetEntries() > 0) {
616 Warning("EndEvent", "got %d 'bad' hits", fBad->GetEntries());
619 while ((hit = static_cast<AliFMDHit*>(next())))
626 //____________________________________________________________________