Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:05

0001 /** \file LaserSteppingAction.cc
0002  *
0003  *
0004  *  $Date: 2007/06/11 14:44:29 $
0005  *  $Revision: 1.3 $
0006  *  \author Maarten Thomas
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   // some debug info
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   // Set the EnergyDeposit if the photon is absorbed by a active sensor
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       // use different energy deposit for the discs depending on the z-position
0062       // to simulate the variable laser power Disc 1 TEC2TEC
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       }  // Disc 1 TEC2TEC
0079       // Disc 1
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       }  // Disc 1
0086       // Disc 2 TEC2TEC
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       }  // Disc 2 TEC2TEC
0103       // Disc 2
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       }  // Disc 2
0110       // Disc 3 TEC2TEC
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       }  // Disc 3 TEC2TEC
0127       // Disc 3
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       }  // Disc 3
0134       // Disc 4 TEC2TEC
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       }  // Disc 4 TEC2TEC
0151       // Disc 4
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       }  // Disc 4
0158       // Disc 5 TEC2TEC
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       }  // Disc 5 TEC2TEC
0175       // Disc 5
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       }  // Disc 5
0182       // Disc 6
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       }  // Disc 6
0189       // Disc 7
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       }  // Disc 7
0196       // Disc 8
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       }  // Disc 8
0203       // Disc 9
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       }  // Disc 9
0210       // Beams in Barrel
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       }  // Beams in the Barrel
0217       else {
0218         // apparently we are not in a detector which should be hit by a
0219         // LaserBeam therefore set the EnergyDeposit to zero and do not create a
0220         // SimHit
0221         theStep->ResetTotalEnergyDeposit();
0222       }
0223     }
0224   }
0225   // kill the photon if it goes through a module in the outer barrel detector.
0226   // In practice on the back of a module is a thin layer of Aluminium that
0227   // absorbs the photons, so hits will only be created in the first layer of the
0228   // TOB. In the current geometry this Aluminium layer is not included. This
0229   // should also avoid unwanted reflections (which then create hits in the TIB
0230   // at the wrong positions)
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   // do the same for photons that a) go through a module in the inner barrel
0242   // detector or b) are reflected at the surface of a TIB module. The photons in
0243   // case b) can create hits in the TOB at the wrong z positions :-(
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   // avoid reflections at Disc 1 of TEC- which enter again the Barrel Volume.
0255   // These Photons create hits at the wrong positions in TIB and TOB
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   // kill photons in the barrel which go in the wrong (i.e. +z) direction; they
0266   // create unwanted hits due to reflections ...
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   // check if it is alive
0278   if (theTrack->GetTrackStatus() != fAlive) {
0279     LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
0280                                                     "is not alive! -> return ";
0281     return;
0282   }
0283 
0284   // check if it is a primary
0285   if (theTrack->GetParentID() != 0) {
0286     LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track "
0287                                                     "is not a primary! -> return ";
0288     return;
0289   }
0290 
0291   // check if it is a optical photon
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     // check in which volume it is
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 }