Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "SimG4Core/Application/interface/SteppingAction.h"
00008 #include "SimG4Core/Application/interface/GFlashEMShowerModel.h"
00009
00010 #include "SimGeneral/GFlash/interface/GflashEMShowerProfile.h"
00011 #include "SimGeneral/GFlash/interface/GflashHit.h"
00012
00013 #include "G4Electron.hh"
00014 #include "G4Positron.hh"
00015 #include "G4VProcess.hh"
00016 #include "G4VPhysicalVolume.hh"
00017 #include "G4LogicalVolume.hh"
00018 #include "G4TransportationManager.hh"
00019 #include "G4EventManager.hh"
00020 #include "G4FastSimulationManager.hh"
00021 #include "G4TouchableHandle.hh"
00022 #include "G4VSensitiveDetector.hh"
00023
00024 GFlashEMShowerModel::GFlashEMShowerModel(const G4String& modelName,
00025 G4Envelope* envelope,
00026 const edm::ParameterSet& parSet)
00027 : G4VFastSimulationModel(modelName, envelope), theParSet(parSet)
00028 {
00029 theWatcherOn = parSet.getParameter<bool>("watcherOn");
00030
00031 theProfile = new GflashEMShowerProfile(parSet);
00032 theRegion = const_cast<const G4Region*>(envelope);
00033
00034 theGflashStep = new G4Step();
00035 theGflashTouchableHandle = new G4TouchableHistory();
00036 theGflashNavigator = new G4Navigator();
00037
00038 }
00039
00040
00041
00042 GFlashEMShowerModel::~GFlashEMShowerModel()
00043 {
00044 delete theProfile;
00045 delete theGflashStep;
00046 }
00047
00048 G4bool
00049 GFlashEMShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
00050 {
00051 return ( &particleType == G4Electron::Electron() ||
00052 &particleType == G4Positron::Positron() );
00053 }
00054
00055
00056 G4bool GFlashEMShowerModel::ModelTrigger(const G4FastTrack & fastTrack )
00057 {
00058
00059 if(fastTrack.GetPrimaryTrack()->GetKineticEnergy() < GeV) { return false; }
00060 if(excludeDetectorRegion(fastTrack)) { return false; }
00061
00062
00063
00064 G4TouchableHistory* touch =
00065 (G4TouchableHistory*)(fastTrack.GetPrimaryTrack()->GetTouchable());
00066 G4VPhysicalVolume* pCurrentVolume = touch->GetVolume();
00067 if( pCurrentVolume == 0) { return false; }
00068
00069 G4LogicalVolume* lv = pCurrentVolume->GetLogicalVolume();
00070 if(lv->GetRegion() != theRegion) { return false; }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 return true;
00084
00085 }
00086
00087
00088 void GFlashEMShowerModel::DoIt(const G4FastTrack& fastTrack,
00089 G4FastStep& fastStep)
00090 {
00091
00092 fastStep.KillPrimaryTrack();
00093 fastStep.ProposePrimaryTrackPathLength(0.0);
00094
00095
00096
00097 G4double energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy()/GeV;
00098 G4double globalTime =
00099 fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetGlobalTime();
00100 G4double charge =
00101 fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint()->GetCharge();
00102 G4ThreeVector position = fastTrack.GetPrimaryTrack()->GetPosition()/cm;
00103 G4ThreeVector momentum = fastTrack.GetPrimaryTrack()->GetMomentum()/GeV;
00104 G4int showerType = Gflash::findShowerType(position);
00105
00106
00107
00108 theProfile->initialize(showerType,energy,globalTime,charge,
00109 position,momentum);
00110 theProfile->parameterization();
00111
00112
00113 makeHits(fastTrack);
00114 }
00115
00116
00117 void GFlashEMShowerModel::makeHits(const G4FastTrack& fastTrack)
00118 {
00119 std::vector<GflashHit>& gflashHitList = theProfile->getGflashHitList();
00120
00121 theGflashStep->SetTrack(const_cast<G4Track*>(fastTrack.GetPrimaryTrack()));
00122
00123 theGflashStep->GetPostStepPoint()
00124 ->SetProcessDefinedStep(const_cast<G4VProcess*>(fastTrack.GetPrimaryTrack()
00125 ->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()));
00126 theGflashNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume());
00127
00128 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
00129 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
00130
00131 for(; spotIter != spotIterEnd; spotIter++){
00132
00133
00134
00135 theGflashNavigator->LocateGlobalPointAndUpdateTouchableHandle(spotIter->getPosition(),G4ThreeVector(0,0,0),theGflashTouchableHandle, false);
00136 updateGflashStep(spotIter->getPosition(),spotIter->getTime());
00137
00138
00139 if(theWatcherOn) {
00140 SteppingAction* userSteppingAction = (SteppingAction*) G4EventManager::GetEventManager()->GetUserSteppingAction();
00141 userSteppingAction->m_g4StepSignal(theGflashStep);
00142 }
00143
00144
00145
00146
00147 G4VPhysicalVolume* aCurrentVolume =
00148 theGflashStep->GetPreStepPoint()->GetPhysicalVolume();
00149 if( aCurrentVolume == 0 ) { continue; }
00150
00151 G4LogicalVolume* lv = aCurrentVolume->GetLogicalVolume();
00152 if(lv->GetRegion() != theRegion) { continue; }
00153
00154 theGflashStep->GetPreStepPoint()->SetSensitiveDetector(aCurrentVolume->GetLogicalVolume()->GetSensitiveDetector());
00155 G4VSensitiveDetector* aSensitive = theGflashStep->GetPreStepPoint()->GetSensitiveDetector();
00156
00157 if( aSensitive == 0 ) { continue; }
00158
00159 theGflashStep->SetTotalEnergyDeposit(spotIter->getEnergy());
00160 aSensitive->Hit(theGflashStep);
00161 }
00162 }
00163
00164
00165 void GFlashEMShowerModel::updateGflashStep(const G4ThreeVector& spotPosition,
00166 G4double timeGlobal)
00167 {
00168 theGflashStep->GetPostStepPoint()->SetGlobalTime(timeGlobal);
00169 theGflashStep->GetPreStepPoint()->SetPosition(spotPosition);
00170 theGflashStep->GetPostStepPoint()->SetPosition(spotPosition);
00171 theGflashStep->GetPreStepPoint()->SetTouchableHandle(theGflashTouchableHandle);
00172 }
00173
00174
00175 G4bool GFlashEMShowerModel::excludeDetectorRegion(const G4FastTrack& fastTrack)
00176 {
00177 G4bool isExcluded=false;
00178
00179
00180
00181 G4double eta = fastTrack.GetPrimaryTrack()->GetPosition().pseudoRapidity();
00182 if(std::fabs(eta) > 1.392 && std::fabs(eta) < 1.566) { return true; }
00183
00184 return isExcluded;
00185 }
00186
00187
00188