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 class contains the detailed version of the FMD - that is, hits
26 // are produced during simulation.
28 // See also the class AliFMD for a more detailed explanation of the
31 #include <TVirtualMC.h> // ROOT_TVirtualMC
32 #include <AliRun.h> // ALIRUN_H
33 #include <AliMC.h> // ALIMC_H
34 #include <AliLog.h> // ALILOG_H
35 #include "AliFMDv1.h" // ALIFMDV1_H
37 #include "AliFMDGeometryBuilder.h"
38 #include "AliFMDGeometry.h"
39 #include "AliFMDDetector.h"
40 #include "AliFMDRing.h"
41 #include <TParticlePDG.h>
42 #include <TDatabasePDG.h>
43 #include "AliFMDHit.h"
45 #include "AliFMDSimulator.h" // ALIFMDSIMULATOR_H
46 #include "AliFMDG3Simulator.h" // ALIFMDG3SIMULATOR_H
47 #include "AliFMDGeoSimulator.h" // ALIFMDGEOSIMULATOR_H
48 #include "AliFMDG3OldSimulator.h" // ALIFMDG3OLDSIMULATOR_H
49 #include "AliFMDGeoOldSimulator.h" // ALIFMDGEOOLDSIMULATOR_H
52 //____________________________________________________________________
55 ; // This is here to keep Emacs for indenting the next line
60 //____________________________________________________________________
62 AliFMDv1::VMC2FMD(TLorentzVector& v, UShort_t& detector,
63 Char_t& ring, UShort_t& sector, UShort_t& strip) const
65 TVirtualMC* mc = TVirtualMC::GetMC();
66 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
70 Int_t moduleno; mc->CurrentVolOffID(fmd->GetModuleOff(), moduleno);
71 Int_t iring; mc->CurrentVolOffID(fmd->GetRingOff(), iring);
73 Int_t det; mc->CurrentVolOffID(fmd->GetDetectorOff(), det);
77 // Get the ring geometry
78 //Int_t nsec = fmd->GetDetector(detector)->GetRing(ring)->GetNSectors();
79 Int_t nstr = fmd->GetDetector(detector)->GetRing(ring)->GetNStrips();
80 Double_t lowr = fmd->GetDetector(detector)->GetRing(ring)->GetMinR();
81 Double_t theta = fmd->GetDetector(detector)->GetRing(ring)->GetTheta();
82 Double_t pitch = fmd->GetDetector(detector)->GetRing(ring)->GetPitch();
84 // Figure out the strip number
85 Double_t r = TMath::Sqrt(v.X() * v.X() + v.Y() * v.Y());
86 Int_t str = Int_t((r - lowr) / pitch);
87 if (str < 0 || str >= nstr) return kFALSE;
90 // Figure out the sector number
91 Double_t phi = TMath::ATan2(v.Y(), v.X()) * 180. / TMath::Pi();
92 if (phi < 0) phi = 360. + phi;
93 Double_t t = phi - 2 * moduleno * theta;
94 sector = 2 * moduleno;
95 if (t < 0 || t > 2 * theta) return kFALSE;
96 else if (t > theta) sector += 1;
98 AliDebug(40, Form("<1> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
99 detector, ring, sector, strip, mc->CurrentVolPath()));
103 //____________________________________________________________________
105 AliFMDv1::VMC2FMD(Int_t copy, TLorentzVector& v,
106 UShort_t& detector, Char_t& ring,
107 UShort_t& sector, UShort_t& strip) const
109 TVirtualMC* mc = TVirtualMC::GetMC();
110 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
113 Int_t sectordiv; mc->CurrentVolOffID(fmd->GetSectorOff(), sectordiv);
114 if (fmd->GetModuleOff() >= 0) {
115 Int_t module; mc->CurrentVolOffID(fmd->GetModuleOff(), module);
116 sector = 2 * module + sectordiv;
120 Int_t iring; mc->CurrentVolOffID(fmd->GetRingOff(), iring);
121 ring = Char_t(iring);
122 Int_t det; mc->CurrentVolOffID(fmd->GetDetectorOff(), det);
125 //Double_t rz = fmd->GetDetector(detector)->GetRingZ(ring);
126 AliFMDDetector* gdet = fmd->GetDetector(detector);
127 AliFMDRing* gring = gdet->GetRing(ring);
129 AliFatal(Form("Ring %c not found (%s)", ring, mc->CurrentVolPath()));
130 Int_t n = gring->GetNSectors();
133 Int_t s = ((n - sector + n / 2) % n) + 1;
134 AliDebug(1, Form("Recalculating sector to %d (=%d-%d+%d/2%%%d+1 z=%f)",
135 s, n, sector, n, n, rz));
139 if (sector < 1 || sector > n) {
140 AliWarning(Form("sector # %d out of range (0-%d)", sector-1, n-1));
144 // Get track position
145 mc->TrackPosition(v);
146 AliDebug(15, Form("<2> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
147 detector, ring, sector, strip, mc->CurrentVolPath()));
153 //____________________________________________________________________
155 AliFMDv1::StepManager()
157 // Member function that is executed each time a hit is made in the
158 // FMD. None-charged particles are ignored. Dead tracks are
161 // The procedure is as follows:
163 // - IF NOT track is alive THEN RETURN ENDIF
164 // - IF NOT particle is charged THEN RETURN ENDIF
165 // - IF NOT volume name is "STRI" or "STRO" THEN RETURN ENDIF
166 // - Get strip number (volume copy # minus 1)
167 // - Get phi division number (mother volume copy #)
168 // - Get module number (grand-mother volume copy #)
169 // - section # = 2 * module # + phi division # - 1
170 // - Get ring Id from volume name
171 // - Get detector # from grand-grand-grand-mother volume name
172 // - Get pointer to sub-detector object.
173 // - Get track position
174 // - IF track is entering volume AND track is inside real shape THEN
175 // - Reset energy deposited
176 // - Get track momentum
177 // - Get particle ID #
179 // - IF track is inside volume AND inside real shape THEN
180 /// - Update energy deposited
182 // - IF track is inside real shape AND (track is leaving volume,
183 // or it died, or it is stopped THEN
188 TVirtualMC* mc = TVirtualMC::GetMC();
189 if (!mc->IsTrackAlive()) return;
190 Double_t absQ = TMath::Abs(mc->TrackCharge());
191 if (absQ <= 0) return;
194 Int_t vol = mc->CurrentVolID(copy);
195 AliFMDGeometry* fmd = AliFMDGeometry::Instance();
196 if (!fmd->IsActive(vol)) {
197 AliDebug(50, Form("Not an FMD volume %d '%s'",vol,mc->CurrentVolName()));
206 if (fmd->IsDetailed()) {
207 if (!VMC2FMD(copy, v, detector, ring, sector, strip)) return;
209 if (!VMC2FMD(v, detector, ring, sector, strip)) return;
212 mc->TrackMomentum(p);
213 Int_t trackno = gAlice->GetMCApp()->GetCurrentTrackNumber();
214 Int_t pdg = mc->TrackPid();
215 Double_t mass = mc->TrackMass();
216 Double_t edep = mc->Edep() * 1000; // keV
217 Double_t poverm = (mass == 0 ? 0 : p.P() / mass);
218 Bool_t isBad = kFALSE;
220 // This `if' is to debug abnormal energy depositions. We trigger on
221 // p/m approx larger than or equal to a MIP, and a large edep - more
222 // than 1 keV - a MIP is 100 eV.
223 if (edep > absQ * absQ && poverm > 1) {
226 mc->StepProcesses(procs);
228 for (Int_t ip = 0; ip < procs.fN; ip++) {
229 if (ip != 0) processes.Append(",");
230 processes.Append(TMCProcessName[procs.fArray[ip]]);
232 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
233 TParticlePDG* particleType = pdgDB->GetParticle(pdg);
234 TString pname(particleType ? particleType->GetName() : "???");
236 if (mc->IsTrackEntering()) what.Append("entering ");
237 if (mc->IsTrackExiting()) what.Append("exiting ");
238 if (mc->IsTrackInside()) what.Append("inside ");
239 if (mc->IsTrackDisappeared()) what.Append("disappeared ");
240 if (mc->IsTrackStop()) what.Append("stopped ");
241 if (mc->IsNewTrack()) what.Append("new ");
242 if (mc->IsTrackAlive()) what.Append("alive ");
243 if (mc->IsTrackOut()) what.Append("out ");
245 Int_t mother = gAlice->GetMCApp()->GetPrimary(trackno);
246 AliWarning(Form("Track # %5d deposits a lot of energy\n"
248 " Momentum: (%7.4f,%7.4f,%7.4f)\n"
250 " Edep: %-14.7f keV (mother %d)\n"
251 " p/m: %-7.4f/%-7.4f = %-14.7f\n"
254 trackno, mc->CurrentVolPath(), p.X(), p.Y(), p.Z(),
255 pdg, pname.Data(), edep, mother, p.P(), mass,
256 poverm, processes.Data(), what.Data()));
259 // Check that the track is actually within the active area
260 Bool_t entering = mc->IsTrackEntering();
261 Bool_t inside = mc->IsTrackInside();
262 Bool_t out = (mc->IsTrackExiting()|| mc->IsTrackDisappeared()||
264 // Reset the energy deposition for this track, and update some of
267 AliDebug(15, Form("Track # %8d entering active FMD volume %s: "
268 "Edep=%f (%f,%f,%f)", trackno, mc->CurrentVolPath(),
269 edep, v.X(), v.Y(), v.Z()));
272 fCurrentDeltaE = edep;
273 fCurrentPdg = pdg; // mc->IdFromPDG(pdg);
275 // If the track is inside, then update the energy deposition
276 if (inside && fCurrentDeltaE >= 0) {
277 fCurrentDeltaE += edep;
278 AliDebug(15, Form("Track # %8d inside active FMD volume %s: Edep=%f, "
279 "Accumulated Edep=%f (%f,%f,%f)", trackno,
280 mc->CurrentVolPath(), edep, fCurrentDeltaE,
281 v.X(), v.Y(), v.Z()));
283 // The track exits the volume, or it disappeared in the volume, or
284 // the track is stopped because it no longer fulfills the cuts
285 // defined, then we create a hit.
287 if (fCurrentDeltaE >= 0) {
288 fCurrentDeltaE += edep;
289 AliDebug(15, Form("Track # %8d exiting active FMD volume %s: Edep=%g, "
290 "Accumulated Edep=%g (%f,%f,%f)", trackno,
291 mc->CurrentVolPath(), edep, fCurrentDeltaE,
292 v.X(), v.Y(), v.Z()));
293 TVector3 cur(v.Vect());
294 cur -= fCurrentV.Vect();
295 Double_t len = cur.Mag();
297 AddHitByFields(trackno, detector, ring, sector, strip,
298 fCurrentV.X(), fCurrentV.Y(), fCurrentV.Z(),
299 fCurrentP.X(), fCurrentP.Y(), fCurrentP.Z(),
300 fCurrentDeltaE, fCurrentPdg, fCurrentV.T(),
301 len, mc->IsTrackDisappeared()||mc->IsTrackStop());
304 new ((*fBad)[fBad->GetEntries()]) AliFMDHit(*h);
310 // Called for every step in the Forward Multiplicity Detector
312 // The message is deligated to AliFMDSimulator::Exec
315 AliFatal("No simulator object made");
318 fSimulator->Exec("");
321 //___________________________________________________________________