CMS 3D CMS Logo

LaserSteppingAction.cc
Go to the documentation of this file.
1 
10 #include "G4ParticleTypes.hh"
11 
13 
15  : theDebugLevel(theConf.getUntrackedParameter<int>("DebugLevel", 0)),
16  theEnergyLossScalingFactor(theConf.getUntrackedParameter<double>("EnergyLossScalingFactor", 1.0)) {}
17 
19 
20 void LaserSteppingAction::UserSteppingAction(const G4Step *myStep) {
21  G4Step *theStep = const_cast<G4Step *>(myStep);
22 
23  G4Track *theTrack = theStep->GetTrack();
24 
25  // some debug info
26  {
27  G4TrackStatus isGood = theTrack->GetTrackStatus();
28 
29  LogDebug("LaserAlignmentSimulationStepping")
30  << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: "
31  "the PreStep Material = "
32  << theStep->GetPreStepPoint()->GetMaterial()->GetName()
33  << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
34  "AC1CMS: The Track Status = "
35  << isGood;
36  if (isGood == fStopAndKill)
37  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
38  "AC1CMS: Track Status = fStopAndKill ";
39 
40  if (theStep->GetPreStepPoint()->GetProcessDefinedStep() != nullptr)
41  LogDebug("LaserAlignmentSimulationStepping")
42  << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
43  "AC1CMS: PreStep Process = "
44  << theStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
45  if (theStep->GetPostStepPoint()->GetProcessDefinedStep() != nullptr)
46  LogDebug("LaserAlignmentSimulationStepping")
47  << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
48  "AC1CMS: PostStep Process = "
49  << theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
50  }
51 
52  // ***********************************************************************************************************
53  // Set the EnergyDeposit if the photon is absorbed by a active sensor
54  if ((theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "OpAbsorption")) {
55  LogDebug("LaserAlignmentStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step*)>: Photon "
56  "was absorbed! ";
57 
58  if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector()) {
59  double EnergyLoss = theEnergyLossScalingFactor * theTrack->GetTotalEnergy();
60 
61  // use different energy deposit for the discs depending on the z-position
62  // to simulate the variable laser power Disc 1 TEC2TEC
63  if (((theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 &&
64  theStep->GetPreStepPoint()->GetPosition().z() < 1382.5) ||
65  (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 &&
66  theStep->GetPreStepPoint()->GetPosition().z() > -1382.5)) &&
67  (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
68  theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
69  (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
70  theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
71  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
72  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
73  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
74  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
75  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
76  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
77  theStep->AddTotalEnergyDeposit(EnergyLoss);
78  } // Disc 1 TEC2TEC
79  // Disc 1
80  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 &&
81  theStep->GetPreStepPoint()->GetPosition().z() < 1382.5) ||
82  (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 &&
83  theStep->GetPreStepPoint()->GetPosition().z() > -1382.5)) {
84  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2 * 0.2));
85  } // Disc 1
86  // Disc 2 TEC2TEC
87  else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 &&
88  theStep->GetPreStepPoint()->GetPosition().z() < 1522.5) ||
89  (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 &&
90  theStep->GetPreStepPoint()->GetPosition().z() > -1522.5)) &&
91  (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
92  theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
93  (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
94  theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
95  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
96  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
97  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
98  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
99  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
100  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
101  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
102  } // Disc 2 TEC2TEC
103  // Disc 2
104  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 &&
105  theStep->GetPreStepPoint()->GetPosition().z() < 1522.5) ||
106  (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 &&
107  theStep->GetPreStepPoint()->GetPosition().z() > -1522.5)) {
108  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
109  } // Disc 2
110  // Disc 3 TEC2TEC
111  else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 &&
112  theStep->GetPreStepPoint()->GetPosition().z() < 1662.5) ||
113  (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 &&
114  theStep->GetPreStepPoint()->GetPosition().z() > -1662.5)) &&
115  (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
116  theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
117  (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
118  theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
119  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
120  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
121  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
122  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
123  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
124  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
125  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
126  } // Disc 3 TEC2TEC
127  // Disc 3
128  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 &&
129  theStep->GetPreStepPoint()->GetPosition().z() < 1662.5) ||
130  (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 &&
131  theStep->GetPreStepPoint()->GetPosition().z() > -1662.5)) {
132  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
133  } // Disc 3
134  // Disc 4 TEC2TEC
135  else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 &&
136  theStep->GetPreStepPoint()->GetPosition().z() < 1802.5) ||
137  (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 &&
138  theStep->GetPreStepPoint()->GetPosition().z() > -1802.5)) &&
139  (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
140  theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
141  (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
142  theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
143  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
144  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
145  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
146  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
147  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
148  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
149  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
150  } // Disc 4 TEC2TEC
151  // Disc 4
152  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 &&
153  theStep->GetPreStepPoint()->GetPosition().z() < 1802.5) ||
154  (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 &&
155  theStep->GetPreStepPoint()->GetPosition().z() > -1802.5)) {
156  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
157  } // Disc 4
158  // Disc 5 TEC2TEC
159  else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 &&
160  theStep->GetPreStepPoint()->GetPosition().z() < 1942.5) ||
161  (theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 &&
162  theStep->GetPreStepPoint()->GetPosition().z() > -1942.5)) &&
163  (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
164  theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
165  (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
166  theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
167  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
168  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
169  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
170  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
171  (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
172  theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
173  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2 * 0.2));
174  } // Disc 5 TEC2TEC
175  // Disc 5
176  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 &&
177  theStep->GetPreStepPoint()->GetPosition().z() < 1942.5) ||
178  (theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 &&
179  theStep->GetPreStepPoint()->GetPosition().z() > -1942.5)) {
180  theStep->AddTotalEnergyDeposit(EnergyLoss);
181  } // Disc 5
182  // Disc 6
183  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1997.5 &&
184  theStep->GetPreStepPoint()->GetPosition().z() < 2117.5) ||
185  (theStep->GetPreStepPoint()->GetPosition().z() < -1997.5 &&
186  theStep->GetPreStepPoint()->GetPosition().z() > -2117.5)) {
187  theStep->AddTotalEnergyDeposit(EnergyLoss);
188  } // Disc 6
189  // Disc 7
190  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2187.5 &&
191  theStep->GetPreStepPoint()->GetPosition().z() < 2307.5) ||
192  (theStep->GetPreStepPoint()->GetPosition().z() < -2187.5 &&
193  theStep->GetPreStepPoint()->GetPosition().z() > -2307.5)) {
194  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
195  } // Disc 7
196  // Disc 8
197  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2392.5 &&
198  theStep->GetPreStepPoint()->GetPosition().z() < 2512.5) ||
199  (theStep->GetPreStepPoint()->GetPosition().z() < -2392.5 &&
200  theStep->GetPreStepPoint()->GetPosition().z() > -2512.5)) {
201  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
202  } // Disc 8
203  // Disc 9
204  else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2607.5 &&
205  theStep->GetPreStepPoint()->GetPosition().z() < 2727.5) ||
206  (theStep->GetPreStepPoint()->GetPosition().z() < -2607.5 &&
207  theStep->GetPreStepPoint()->GetPosition().z() > -2727.5)) {
208  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
209  } // Disc 9
210  // Beams in Barrel
211  else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
212  theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
213  (theStep->GetPreStepPoint()->GetPosition().perp() > 500.0 &&
214  theStep->GetPreStepPoint()->GetPosition().perp() < 630.0)) {
215  theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
216  } // Beams in the Barrel
217  else {
218  // apparently we are not in a detector which should be hit by a
219  // LaserBeam therefore set the EnergyDeposit to zero and do not create a
220  // SimHit
221  theStep->ResetTotalEnergyDeposit();
222  }
223  }
224  }
225  // kill the photon if it goes through a module in the outer barrel detector.
226  // In practice on the back of a module is a thin layer of Aluminium that
227  // absorbs the photons, so hits will only be created in the first layer of the
228  // TOB. In the current geometry this Aluminium layer is not included. This
229  // should also avoid unwanted reflections (which then create hits in the TIB
230  // at the wrong positions)
231  else if (((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TOB_Wafer") &&
232  (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) {
233  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
234  theTrack->SetTrackStatus(fStopAndKill);
235  } else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
236  theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
237  (theStep->GetPreStepPoint()->GetPosition().perp() > 630.0)) {
238  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
239  theTrack->SetTrackStatus(fStopAndKill);
240  }
241  // do the same for photons that a) go through a module in the inner barrel
242  // detector or b) are reflected at the surface of a TIB module. The photons in
243  // case b) can create hits in the TOB at the wrong z positions :-(
244  else if (((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TIB_Wafer") &&
245  (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) {
246  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
247  theTrack->SetTrackStatus(fStopAndKill);
248  } else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
249  theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
250  (theStep->GetPreStepPoint()->GetPosition().perp() < 500.0)) {
251  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
252  theTrack->SetTrackStatus(fStopAndKill);
253  }
254  // avoid reflections at Disc 1 of TEC- which enter again the Barrel Volume.
255  // These Photons create hits at the wrong positions in TIB and TOB
256  else if ((((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
257  (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "T_Air")) ||
258  ((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
259  (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) &&
260  (theStep->GetPreStepPoint()->GetMomentum().z() != theStep->GetPostStepPoint()->GetMomentum().z()) &&
261  (theStep->GetPostStepPoint()->GetPosition().z() == -1137.25)) {
262  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
263  theTrack->SetTrackStatus(fStopAndKill);
264  }
265  // kill photons in the barrel which go in the wrong (i.e. +z) direction; they
266  // create unwanted hits due to reflections ...
267  else if ((theStep->GetPostStepPoint()->GetPosition().z() > -1100.0) &&
268  (theStep->GetPostStepPoint()->GetPosition().z() < 1100.0) &&
269  (theStep->GetPostStepPoint()->GetMomentumDirection().z() > 0.8)) {
270  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
271  theTrack->SetTrackStatus(fStopAndKill);
272  } else {
273  LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping continuous ... ";
274  }
275  // ***********************************************************************************************************
276 
277  // check if it is alive
278  if (theTrack->GetTrackStatus() != fAlive) {
279  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
280  "is not alive! -> return ";
281  return;
282  }
283 
284  // check if it is a primary
285  if (theTrack->GetParentID() != 0) {
286  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
287  "is not a primary! -> return ";
288  return;
289  }
290 
291  // check if it is a optical photon
292  if (theDebugLevel >= 4) {
293  G4ParticleDefinition *theOpticalType = theTrack->GetDefinition();
294  if (theOpticalType == G4OpticalPhoton::OpticalPhotonDefinition()) {
295  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
296  "Optical Photon found! ";
297  }
298 
299  // check in which volume it is
300 #ifdef EDM_ML_DEBUG
301  G4StepPoint *thePreStepPoint = theStep->GetPreStepPoint();
302  G4VPhysicalVolume *thePreStepPhysicalVolume = thePreStepPoint->GetPhysicalVolume();
303  G4String thePreStepPhysicalVolumeName = thePreStepPhysicalVolume->GetName();
304  G4Material *thePreStepMaterial = thePreStepPoint->GetMaterial();
305 
306  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
307  "PreStep Position = "
308  << thePreStepPoint->GetPosition()
309  << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
310  "PreStep Physical Volume = "
311  << thePreStepPhysicalVolumeName
312  << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
313  "PreStep Material ="
314  << thePreStepMaterial->GetName();
315 
316  G4StepPoint *thePostStepPoint = theStep->GetPostStepPoint();
317  G4VPhysicalVolume *thePostStepPhysicalVolume = thePostStepPoint->GetPhysicalVolume();
318  G4String thePostStepPhysicalVolumeName = thePostStepPhysicalVolume->GetName();
319  G4Material *thePostStepMaterial = thePostStepPoint->GetMaterial();
320 
321  LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
322  "PostStep Position = "
323  << thePostStepPoint->GetPosition()
324  << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
325  "PostStep Physical Volume = "
326  << thePostStepPhysicalVolumeName
327  << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
328  "PostStep Material = "
329  << thePostStepMaterial->GetName();
330 #endif
331  }
332 }
#define LogDebug(id)
#define M_PI
void UserSteppingAction(const G4Step *myStep) override
~LaserSteppingAction() override
destructor
LaserSteppingAction(edm::ParameterSet const &theConf)
constructor