File indexing completed on 2024-04-06 11:56:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Alignment/LaserAlignmentSimulation/interface/LaserSteppingAction.h"
0010 #include "G4ParticleTypes.hh"
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013
0014 LaserSteppingAction::LaserSteppingAction(edm::ParameterSet const &theConf)
0015 : theDebugLevel(theConf.getUntrackedParameter<int>("DebugLevel", 0)),
0016 theEnergyLossScalingFactor(theConf.getUntrackedParameter<double>("EnergyLossScalingFactor", 1.0)) {}
0017
0018 LaserSteppingAction::~LaserSteppingAction() {}
0019
0020 void LaserSteppingAction::UserSteppingAction(const G4Step *myStep) {
0021 G4Step *theStep = const_cast<G4Step *>(myStep);
0022
0023 G4Track *theTrack = theStep->GetTrack();
0024
0025
0026 {
0027 G4TrackStatus isGood = theTrack->GetTrackStatus();
0028
0029 LogDebug("LaserAlignmentSimulationStepping")
0030 << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: "
0031 "the PreStep Material = "
0032 << theStep->GetPreStepPoint()->GetMaterial()->GetName()
0033 << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
0034 "AC1CMS: The Track Status = "
0035 << isGood;
0036 if (isGood == fStopAndKill)
0037 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
0038 "AC1CMS: Track Status = fStopAndKill ";
0039
0040 if (theStep->GetPreStepPoint()->GetProcessDefinedStep() != nullptr)
0041 LogDebug("LaserAlignmentSimulationStepping")
0042 << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
0043 "AC1CMS: PreStep Process = "
0044 << theStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
0045 if (theStep->GetPostStepPoint()->GetProcessDefinedStep() != nullptr)
0046 LogDebug("LaserAlignmentSimulationStepping")
0047 << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
0048 "AC1CMS: PostStep Process = "
0049 << theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
0050 }
0051
0052
0053
0054 if ((theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "OpAbsorption")) {
0055 LogDebug("LaserAlignmentStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step*)>: Photon "
0056 "was absorbed! ";
0057
0058 if (theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector()) {
0059 double EnergyLoss = theEnergyLossScalingFactor * theTrack->GetTotalEnergy();
0060
0061
0062
0063 if (((theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 &&
0064 theStep->GetPreStepPoint()->GetPosition().z() < 1382.5) ||
0065 (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 &&
0066 theStep->GetPreStepPoint()->GetPosition().z() > -1382.5)) &&
0067 (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
0068 theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
0069 (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
0070 theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
0071 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
0072 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
0073 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
0074 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
0075 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
0076 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
0077 theStep->AddTotalEnergyDeposit(EnergyLoss);
0078 }
0079
0080 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 &&
0081 theStep->GetPreStepPoint()->GetPosition().z() < 1382.5) ||
0082 (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 &&
0083 theStep->GetPreStepPoint()->GetPosition().z() > -1382.5)) {
0084 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2 * 0.2));
0085 }
0086
0087 else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 &&
0088 theStep->GetPreStepPoint()->GetPosition().z() < 1522.5) ||
0089 (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 &&
0090 theStep->GetPreStepPoint()->GetPosition().z() > -1522.5)) &&
0091 (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
0092 theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
0093 (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
0094 theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
0095 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
0096 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
0097 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
0098 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
0099 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
0100 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
0101 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
0102 }
0103
0104 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 &&
0105 theStep->GetPreStepPoint()->GetPosition().z() < 1522.5) ||
0106 (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 &&
0107 theStep->GetPreStepPoint()->GetPosition().z() > -1522.5)) {
0108 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
0109 }
0110
0111 else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 &&
0112 theStep->GetPreStepPoint()->GetPosition().z() < 1662.5) ||
0113 (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 &&
0114 theStep->GetPreStepPoint()->GetPosition().z() > -1662.5)) &&
0115 (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
0116 theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
0117 (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
0118 theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
0119 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
0120 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
0121 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
0122 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
0123 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
0124 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
0125 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
0126 }
0127
0128 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 &&
0129 theStep->GetPreStepPoint()->GetPosition().z() < 1662.5) ||
0130 (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 &&
0131 theStep->GetPreStepPoint()->GetPosition().z() > -1662.5)) {
0132 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
0133 }
0134
0135 else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 &&
0136 theStep->GetPreStepPoint()->GetPosition().z() < 1802.5) ||
0137 (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 &&
0138 theStep->GetPreStepPoint()->GetPosition().z() > -1802.5)) &&
0139 (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
0140 theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
0141 (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
0142 theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
0143 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
0144 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
0145 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
0146 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
0147 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
0148 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
0149 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
0150 }
0151
0152 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 &&
0153 theStep->GetPreStepPoint()->GetPosition().z() < 1802.5) ||
0154 (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 &&
0155 theStep->GetPreStepPoint()->GetPosition().z() > -1802.5)) {
0156 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
0157 }
0158
0159 else if (((theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 &&
0160 theStep->GetPreStepPoint()->GetPosition().z() < 1942.5) ||
0161 (theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 &&
0162 theStep->GetPreStepPoint()->GetPosition().z() > -1942.5)) &&
0163 (((theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 &&
0164 theStep->GetPreStepPoint()->GetPosition().phi() < 1.295) ||
0165 (theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 &&
0166 theStep->GetPreStepPoint()->GetPosition().phi() < 1.86) ||
0167 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 3.63 &&
0168 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 3.66) ||
0169 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.20 &&
0170 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.23) ||
0171 (theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI > 5.76 &&
0172 theStep->GetPreStepPoint()->GetPosition().phi() + 2.0 * M_PI < 5.80)))) {
0173 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2 * 0.2));
0174 }
0175
0176 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 &&
0177 theStep->GetPreStepPoint()->GetPosition().z() < 1942.5) ||
0178 (theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 &&
0179 theStep->GetPreStepPoint()->GetPosition().z() > -1942.5)) {
0180 theStep->AddTotalEnergyDeposit(EnergyLoss);
0181 }
0182
0183 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 1997.5 &&
0184 theStep->GetPreStepPoint()->GetPosition().z() < 2117.5) ||
0185 (theStep->GetPreStepPoint()->GetPosition().z() < -1997.5 &&
0186 theStep->GetPreStepPoint()->GetPosition().z() > -2117.5)) {
0187 theStep->AddTotalEnergyDeposit(EnergyLoss);
0188 }
0189
0190 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2187.5 &&
0191 theStep->GetPreStepPoint()->GetPosition().z() < 2307.5) ||
0192 (theStep->GetPreStepPoint()->GetPosition().z() < -2187.5 &&
0193 theStep->GetPreStepPoint()->GetPosition().z() > -2307.5)) {
0194 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2));
0195 }
0196
0197 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2392.5 &&
0198 theStep->GetPreStepPoint()->GetPosition().z() < 2512.5) ||
0199 (theStep->GetPreStepPoint()->GetPosition().z() < -2392.5 &&
0200 theStep->GetPreStepPoint()->GetPosition().z() > -2512.5)) {
0201 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
0202 }
0203
0204 else if ((theStep->GetPreStepPoint()->GetPosition().z() > 2607.5 &&
0205 theStep->GetPreStepPoint()->GetPosition().z() < 2727.5) ||
0206 (theStep->GetPreStepPoint()->GetPosition().z() < -2607.5 &&
0207 theStep->GetPreStepPoint()->GetPosition().z() > -2727.5)) {
0208 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2 * 0.2));
0209 }
0210
0211 else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
0212 theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
0213 (theStep->GetPreStepPoint()->GetPosition().perp() > 500.0 &&
0214 theStep->GetPreStepPoint()->GetPosition().perp() < 630.0)) {
0215 theStep->AddTotalEnergyDeposit(EnergyLoss / (0.2 * 0.2));
0216 }
0217 else {
0218
0219
0220
0221 theStep->ResetTotalEnergyDeposit();
0222 }
0223 }
0224 }
0225
0226
0227
0228
0229
0230
0231 else if (((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TOB_Wafer") &&
0232 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) {
0233 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
0234 theTrack->SetTrackStatus(fStopAndKill);
0235 } else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
0236 theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
0237 (theStep->GetPreStepPoint()->GetPosition().perp() > 630.0)) {
0238 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
0239 theTrack->SetTrackStatus(fStopAndKill);
0240 }
0241
0242
0243
0244 else if (((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TIB_Wafer") &&
0245 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) {
0246 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
0247 theTrack->SetTrackStatus(fStopAndKill);
0248 } else if ((theStep->GetPreStepPoint()->GetPosition().z() > -870.0 &&
0249 theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
0250 (theStep->GetPreStepPoint()->GetPosition().perp() < 500.0)) {
0251 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
0252 theTrack->SetTrackStatus(fStopAndKill);
0253 }
0254
0255
0256 else if ((((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
0257 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "T_Air")) ||
0258 ((theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
0259 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air"))) &&
0260 (theStep->GetPreStepPoint()->GetMomentum().z() != theStep->GetPostStepPoint()->GetMomentum().z()) &&
0261 (theStep->GetPostStepPoint()->GetPosition().z() == -1137.25)) {
0262 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
0263 theTrack->SetTrackStatus(fStopAndKill);
0264 }
0265
0266
0267 else if ((theStep->GetPostStepPoint()->GetPosition().z() > -1100.0) &&
0268 (theStep->GetPostStepPoint()->GetPosition().z() < 1100.0) &&
0269 (theStep->GetPostStepPoint()->GetMomentumDirection().z() > 0.8)) {
0270 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
0271 theTrack->SetTrackStatus(fStopAndKill);
0272 } else {
0273 LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping continuous ... ";
0274 }
0275
0276
0277
0278 if (theTrack->GetTrackStatus() != fAlive) {
0279 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
0280 "is not alive! -> return ";
0281 return;
0282 }
0283
0284
0285 if (theTrack->GetParentID() != 0) {
0286 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
0287 "is not a primary! -> return ";
0288 return;
0289 }
0290
0291
0292 if (theDebugLevel >= 4) {
0293 G4ParticleDefinition *theOpticalType = theTrack->GetDefinition();
0294 if (theOpticalType == G4OpticalPhoton::OpticalPhotonDefinition()) {
0295 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: "
0296 "Optical Photon found! ";
0297 }
0298
0299
0300 #ifdef EDM_ML_DEBUG
0301 G4StepPoint *thePreStepPoint = theStep->GetPreStepPoint();
0302 G4VPhysicalVolume *thePreStepPhysicalVolume = thePreStepPoint->GetPhysicalVolume();
0303 G4String thePreStepPhysicalVolumeName = thePreStepPhysicalVolume->GetName();
0304 G4Material *thePreStepMaterial = thePreStepPoint->GetMaterial();
0305
0306 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0307 "PreStep Position = "
0308 << thePreStepPoint->GetPosition()
0309 << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0310 "PreStep Physical Volume = "
0311 << thePreStepPhysicalVolumeName
0312 << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0313 "PreStep Material ="
0314 << thePreStepMaterial->GetName();
0315
0316 G4StepPoint *thePostStepPoint = theStep->GetPostStepPoint();
0317 G4VPhysicalVolume *thePostStepPhysicalVolume = thePostStepPoint->GetPhysicalVolume();
0318 G4String thePostStepPhysicalVolumeName = thePostStepPhysicalVolume->GetName();
0319 G4Material *thePostStepMaterial = thePostStepPoint->GetMaterial();
0320
0321 LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0322 "PostStep Position = "
0323 << thePostStepPoint->GetPosition()
0324 << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0325 "PostStep Physical Volume = "
0326 << thePostStepPhysicalVolumeName
0327 << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the "
0328 "PostStep Material = "
0329 << thePostStepMaterial->GetName();
0330 #endif
0331 }
0332 }