CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Alignment/LaserAlignmentSimulation/src/LaserSteppingAction.cc

Go to the documentation of this file.
00001 
00009 #include "Alignment/LaserAlignmentSimulation/interface/LaserSteppingAction.h"
00010 #include "G4ParticleTypes.hh" 
00011 
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 LaserSteppingAction::LaserSteppingAction(edm::ParameterSet const& theConf) 
00015   : theDebugLevel(theConf.getUntrackedParameter<int>("DebugLevel",0)),
00016     theEnergyLossScalingFactor(theConf.getUntrackedParameter<double>("EnergyLossScalingFactor",1.0))
00017 {
00018 }
00019 
00020 LaserSteppingAction::~LaserSteppingAction()
00021 {
00022 }
00023 
00024 void LaserSteppingAction::UserSteppingAction(const G4Step * myStep)
00025 {
00026   G4Step * theStep = const_cast<G4Step*>(myStep);
00027 
00028   G4Track * theTrack = theStep->GetTrack();
00029 
00030   // some debug info
00031   {
00032     G4TrackStatus isGood = theTrack->GetTrackStatus();
00033     
00034     LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: the PreStep Material = " 
00035                                           << theStep->GetPreStepPoint()->GetMaterial()->GetName()
00036                                           << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: The Track Status = " << isGood;
00037     if ( isGood == fStopAndKill ) 
00038       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: Track Status = fStopAndKill ";
00039       
00040     if ( theStep->GetPreStepPoint()->GetProcessDefinedStep() != 0 )
00041       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: PreStep Process  = " 
00042                                             << theStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
00043     if ( theStep->GetPostStepPoint()->GetProcessDefinedStep() != 0 )
00044       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: AC1CMS: PostStep Process = " 
00045                                             << theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
00046   }
00047 
00048   // ***********************************************************************************************************
00049   // Set the EnergyDeposit if the photon is absorbed by a active sensor
00050   if ( ( theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()== "OpAbsorption" ) )
00051     {
00052       LogDebug("LaserAlignmentStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step*)>: Photon was absorbed! ";
00053       
00054       if ( theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector() )
00055         {
00056           double EnergyLoss = theEnergyLossScalingFactor * theTrack->GetTotalEnergy();
00057           
00058           // use different energy deposit for the discs depending on the z-position to simulate the variable laser power
00059           // Disc 1 TEC2TEC
00060           if ( ( (theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1382.5 )
00061                  || (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1382.5 ) )
00062                && ( ( ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.295 ) 
00063                       || ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.86 )
00064                       || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 3.63 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 3.66 )
00065                       || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.20 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.23 )
00066                       || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.76 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.80 ) ) ) )
00067             { theStep->AddTotalEnergyDeposit(EnergyLoss); } // Disc 1 TEC2TEC
00068           // Disc 1
00069           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1262.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1382.5 )
00070                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1262.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1382.5 ) )
00071             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2*0.2*0.2)); } // Disc 1
00072           // Disc 2 TEC2TEC
00073           else if ( ( (theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1522.5 )
00074                       || (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1522.5 ) )
00075                     && ( ( ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.295 ) 
00076                            || ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.86 )
00077                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 3.63 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 3.66 )
00078                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.20 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.23 )
00079                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.76 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.80 ) ) ) )
00080             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2)); } // Disc 2 TEC2TEC
00081           // Disc 2
00082           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1402.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1522.5 )
00083                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1402.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1522.5 ) )
00084             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2*0.2)); } // Disc 2
00085           // Disc 3 TEC2TEC
00086           else if ( ( (theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1662.5 )
00087                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1662.5 ) ) 
00088                     && ( ( ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.295 ) 
00089                            || ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.86 )
00090                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 3.63 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 3.66 )
00091                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.20 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.23 )
00092                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.76 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.80 ) ) ) )
00093             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2)); } // Disc 3 TEC2TEC
00094           // Disc 3
00095           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1542.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1662.5 )
00096                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1542.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1662.5 ) )
00097             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2)); } // Disc 3
00098           // Disc 4 TEC2TEC
00099           else if ( ( (theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1802.5 )
00100                       || (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1802.5 ) ) 
00101                     && ( ( ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.295 ) 
00102                            || ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.86 )
00103                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 3.63 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 3.66 )
00104                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.20 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.23 )
00105                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.76 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.80 ) ) ) )
00106             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2*0.2)); } // Disc 4 TEC2TEC
00107           // Disc 4
00108           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1682.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1802.5 )
00109                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1682.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1802.5 ) )
00110             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2)); } // Disc 4
00111           // Disc 5 TEC2TEC
00112           else if ( ( ( theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1942.5 )
00113                     || ( theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1942.5 ) )
00114                     && ( ( ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.285 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.295 ) 
00115                            || ( theStep->GetPreStepPoint()->GetPosition().phi() > 1.84 && theStep->GetPreStepPoint()->GetPosition().phi() < 1.86 )
00116                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 3.63 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 3.66 )
00117                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.20 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.23 )
00118                            || ( theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI > 5.76 && theStep->GetPreStepPoint()->GetPosition().phi() + 2.0*M_PI < 5.80 ) ) ) )
00119             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2*0.2*0.2)); } // Disc 5 TEC2TEC
00120           // Disc 5
00121           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1822.5 && theStep->GetPreStepPoint()->GetPosition().z() < 1942.5 )
00122                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1822.5 && theStep->GetPreStepPoint()->GetPosition().z() > -1942.5 ) )
00123             { theStep->AddTotalEnergyDeposit(EnergyLoss); } // Disc 5
00124           // Disc 6
00125           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 1997.5 && theStep->GetPreStepPoint()->GetPosition().z() < 2117.5 )
00126                     || (theStep->GetPreStepPoint()->GetPosition().z() < -1997.5 && theStep->GetPreStepPoint()->GetPosition().z() > -2117.5 ) )
00127             { theStep->AddTotalEnergyDeposit(EnergyLoss); } // Disc 6
00128           // Disc 7
00129           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 2187.5 && theStep->GetPreStepPoint()->GetPosition().z() < 2307.5 )
00130                     || (theStep->GetPreStepPoint()->GetPosition().z() < -2187.5 && theStep->GetPreStepPoint()->GetPosition().z() > -2307.5 ) )
00131             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2)); } // Disc 7
00132           // Disc 8
00133           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 2392.5 && theStep->GetPreStepPoint()->GetPosition().z() < 2512.5 )
00134                     || (theStep->GetPreStepPoint()->GetPosition().z() < -2392.5 && theStep->GetPreStepPoint()->GetPosition().z() > -2512.5 ) )
00135             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2)); } // Disc 8
00136           // Disc 9
00137           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > 2607.5 && theStep->GetPreStepPoint()->GetPosition().z() < 2727.5 )
00138                     || (theStep->GetPreStepPoint()->GetPosition().z() < -2607.5 && theStep->GetPreStepPoint()->GetPosition().z() > -2727.5 ) )
00139             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2*0.2)); } // Disc 9
00140           // Beams in Barrel
00141           else if ( (theStep->GetPreStepPoint()->GetPosition().z() > -870.0 && theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
00142                     (theStep->GetPreStepPoint()->GetPosition().perp() > 500.0 && theStep->GetPreStepPoint()->GetPosition().perp() < 630.0) )
00143             { theStep->AddTotalEnergyDeposit(EnergyLoss/(0.2*0.2)); } // Beams in the Barrel
00144           else
00145             { 
00146               // apparently we are not in a detector which should be hit by a LaserBeam
00147               // therefore set the EnergyDeposit to zero and do not create a SimHit
00148               theStep->ResetTotalEnergyDeposit(); 
00149             }
00150         }
00151     }
00152   // kill the photon if it goes through a module in the outer barrel detector. In practice on the back 
00153   // of a module is a thin layer of Aluminium that absorbs the photons, so hits will only be created in 
00154   // the first layer of the TOB. In the current geometry this Aluminium layer is not included. This should
00155   // also avoid unwanted reflections (which then create hits in the TIB at the wrong positions)
00156   else if ( ( (theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TOB_Wafer") &&
00157               (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air") ) )
00158     {
00159       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
00160       theTrack->SetTrackStatus(fStopAndKill);
00161     }
00162   else if ( (theStep->GetPreStepPoint()->GetPosition().z() > -870.0 && 
00163              theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
00164             (theStep->GetPreStepPoint()->GetPosition().perp() > 630.0) )
00165     {
00166       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
00167       theTrack->SetTrackStatus(fStopAndKill);
00168     }
00169   // do the same for photons that a) go through a module in the inner barrel detector or b) are reflected
00170   // at the surface of a TIB module. The photons in case b) can create hits in the TOB at the wrong z
00171   // positions :-(
00172   else if ( ( (theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TIB_Wafer") &&
00173               (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air") ) )
00174     {
00175       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
00176       theTrack->SetTrackStatus(fStopAndKill);
00177     }
00178   else if ( (theStep->GetPreStepPoint()->GetPosition().z() > -870.0 && 
00179              theStep->GetPreStepPoint()->GetPosition().z() < 1050.0) &&
00180             (theStep->GetPreStepPoint()->GetPosition().perp() < 500.0) )
00181     {
00182       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! ";
00183       theTrack->SetTrackStatus(fStopAndKill);
00184     }
00185   // avoid reflections at Disc 1 of TEC- which enter again the Barrel Volume. These Photons
00186   // create hits at the wrong positions in TIB and TOB
00187   else if ( ( ( (theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
00188                 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "T_Air")  ) ||
00189               ( (theStep->GetPreStepPoint()->GetMaterial()->GetName() == "TEC_Wafer") &&
00190                 (theStep->GetPostStepPoint()->GetMaterial()->GetName() == "Air") ) ) &&
00191             (theStep->GetPreStepPoint()->GetMomentum().z() != theStep->GetPostStepPoint()->GetMomentum().z() ) &&
00192             (theStep->GetPostStepPoint()->GetPosition().z() == -1137.25) )
00193     {
00194       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
00195       theTrack->SetTrackStatus(fStopAndKill);
00196     }
00197   // kill photons in the barrel which go in the wrong (i.e. +z) direction; they create unwanted hits
00198   // due to reflections ...
00199   else if ( ( theStep->GetPostStepPoint()->GetPosition().z() > -1100.0 )
00200             && ( theStep->GetPostStepPoint()->GetPosition().z() < 1100.0 )
00201             && ( theStep->GetPostStepPoint()->GetMomentumDirection().z() > 0.8 ) )
00202     {
00203       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping aborted! photon in wrong direction";
00204       theTrack->SetTrackStatus(fStopAndKill);
00205     }
00206   else
00207     {
00208       LogDebug("LaserAlignmentSimulationStepping") << " AC1CMS: stepping continuous ... ";
00209     }
00210   // ***********************************************************************************************************
00211 
00212 
00213   // check if it is alive
00214   if ( theTrack->GetTrackStatus() != fAlive ) 
00215     {
00216       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track is not alive! -> return ";
00217       return; 
00218     }
00219   
00220   // check if it is a primary
00221   if ( theTrack->GetParentID() != 0 ) 
00222     { 
00223       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Track is not a primary! -> return ";
00224       return; 
00225     }
00226 
00227   // check if it is a optical photon
00228   if ( theDebugLevel >= 4 )
00229     {
00230       G4ParticleDefinition * theOpticalType = theTrack->GetDefinition();
00231       if ( theOpticalType == G4OpticalPhoton::OpticalPhotonDefinition() )
00232         { 
00233           LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: Optical Photon found! ";
00234         }
00235 
00236       // check in which volume it is
00237       G4StepPoint * thePreStepPoint = theStep->GetPreStepPoint();
00238       G4VPhysicalVolume * thePreStepPhysicalVolume = thePreStepPoint->GetPhysicalVolume();
00239       G4String thePreStepPhysicalVolumeName = thePreStepPhysicalVolume->GetName();
00240       G4Material * thePreStepMaterial = thePreStepPoint->GetMaterial();
00241       
00242       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PreStep Position = " << thePreStepPoint->GetPosition()
00243                                             << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PreStep Physical Volume = " << thePreStepPhysicalVolumeName
00244                                             << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PreStep Material =" << thePreStepMaterial->GetName();
00245 
00246       G4StepPoint * thePostStepPoint = theStep->GetPostStepPoint();
00247       G4VPhysicalVolume * thePostStepPhysicalVolume = thePostStepPoint->GetPhysicalVolume();
00248       G4String thePostStepPhysicalVolumeName = thePostStepPhysicalVolume->GetName();
00249       G4Material * thePostStepMaterial = thePostStepPoint->GetMaterial();
00250       
00251       LogDebug("LaserAlignmentSimulationStepping") << "<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PostStep Position = " << thePostStepPoint->GetPosition()
00252                                             << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PostStep Physical Volume = " << thePostStepPhysicalVolumeName
00253                                             << "\n<LaserSteppingAction::UserSteppingAction(const G4Step *)>: the PostStep Material = " << thePostStepMaterial->GetName();
00254     }
00255 }