16 #include "G4FastSimulationManager.hh"
17 #include "G4TransportationManager.hh"
18 #include "G4TouchableHandle.hh"
19 #include "G4VSensitiveDetector.hh"
20 #include "G4VPhysicalVolume.hh"
21 #include "G4EventManager.hh"
23 #include "G4PionMinus.hh"
24 #include "G4PionPlus.hh"
25 #include "G4KaonMinus.hh"
26 #include "G4KaonPlus.hh"
27 #include "G4Proton.hh"
28 #include "G4AntiProton.hh"
29 #include "G4VProcess.hh"
33 using namespace CLHEP;
36 : G4VFastSimulationModel(modelName, envelope), theParSet(parSet)
63 &particleType == G4PionMinus::PionMinusDefinition() ||
64 &particleType == G4PionPlus::PionPlusDefinition() ||
65 &particleType == G4KaonMinus::KaonMinusDefinition() ||
66 &particleType == G4KaonPlus::KaonPlusDefinition() ||
67 &particleType == G4AntiProton::AntiProtonDefinition() ||
68 &particleType == G4Proton::ProtonDefinition() ;
81 G4bool trigger =
false;
87 if(fastTrack.GetPrimaryTrack()->GetTrackStatus() == fPostponeToNextEvent ) {
105 fastStep.KillPrimaryTrack();
106 fastStep.ProposePrimaryTrackPathLength(0.0);
109 G4ParticleDefinition* particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
118 G4double
energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy()/
GeV;
119 G4double globalTime = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetGlobalTime();
120 G4double
charge = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint()->GetCharge();
121 G4ThreeVector
position = fastTrack.GetPrimaryTrack()->GetPosition()/cm;
122 G4ThreeVector momentum = fastTrack.GetPrimaryTrack()->GetMomentum()/
GeV;
138 theGflashStep->SetTrack(const_cast<G4Track*>(fastTrack.GetPrimaryTrack()));
139 theGflashStep->GetPostStepPoint()->SetProcessDefinedStep(const_cast<G4VProcess*>
140 (fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()));
141 theGflashNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume());
143 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
144 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
146 for( ; spotIter != spotIterEnd; spotIter++){
148 theGflashNavigator->LocateGlobalPointAndUpdateTouchableHandle(spotIter->getPosition(),G4ThreeVector(0,0,0),
159 G4VPhysicalVolume* aCurrentVolume =
theGflashStep->GetPreStepPoint()->GetPhysicalVolume();
160 if( aCurrentVolume == 0 )
continue;
162 G4LogicalVolume* lv = aCurrentVolume->GetLogicalVolume();
163 if(lv->GetRegion()->GetName() !=
"CaloRegion")
continue;
165 theGflashStep->GetPreStepPoint()->SetSensitiveDetector(aCurrentVolume->GetLogicalVolume()->GetSensitiveDetector());
166 G4VSensitiveDetector* aSensitive =
theGflashStep->GetPreStepPoint()->GetSensitiveDetector();
168 if( aSensitive == 0 )
continue;
170 G4String nameCalor = aCurrentVolume->GetName();
171 nameCalor.assign(nameCalor,0,2);
172 G4double samplingWeight = 1.0;
173 if(nameCalor ==
"HB" ) {
176 else if(nameCalor==
"HE" || nameCalor ==
"HT") {
179 theGflashStep->SetTotalEnergyDeposit(spotIter->getEnergy()*samplingWeight);
188 theGflashStep->GetPostStepPoint()->SetGlobalTime(timeGlobal);
190 theGflashStep->GetPostStepPoint()->SetPosition(spotPosition);
198 G4StepPoint* preStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint();
199 G4StepPoint* postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
201 G4String procName = postStep->GetProcessDefinedStep()->GetProcessName();
202 G4ParticleDefinition* particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
206 if((particleType == G4PionPlus::PionPlusDefinition() && procName ==
"WrappedPionPlusInelastic") ||
207 (particleType == G4PionMinus::PionMinusDefinition() && procName ==
"WrappedPionMinusInelastic") ||
208 (particleType == G4KaonPlus::KaonPlusDefinition() && procName ==
"WrappedKaonPlusInelastic") ||
209 (particleType == G4KaonMinus::KaonMinusDefinition() && procName ==
"WrappedKaonMinusInelastic") ||
210 (particleType == G4AntiProton::AntiProtonDefinition() && procName ==
"WrappedAntiProtonInelastic") ||
211 (particleType == G4Proton::ProtonDefinition() && procName ==
"WrappedProtonInelastic")) {
216 const G4TrackVector* fSecondaryVector = fastTrack.GetPrimaryTrack()->GetStep()->GetSecondary();
217 G4double leadingEnergy = 0.0;
223 for (
unsigned int isec = 0 ; isec < fSecondaryVector->size() ; isec++) {
224 G4Track* fSecondaryTrack = (*fSecondaryVector)[isec];
225 G4double secondaryEnergy = fSecondaryTrack->GetKineticEnergy();
227 if(secondaryEnergy > leadingEnergy ) {
228 leadingEnergy = secondaryEnergy;
232 if((preStep->GetTotalEnergy()!=0) &&
241 theHisto->
deltaStep->Fill((postStep->GetPosition() - preStep->GetPosition()).getRho()/cm);
253 G4bool isExcluded=
false;
258 G4double
eta = fastTrack.GetPrimaryTrack()->GetPosition().pseudoRapidity() ;
259 if(std::fabs(eta) > 1.392 && std::fabs(eta) < 1.566) {
261 edm::LogInfo(
"SimGeneralGFlash") <<
"GflashHadronShowerModel: excluding region of eta = " <<
eta;
266 G4StepPoint* postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
269 G4double distOut = 9999.0;
291 if(isExcluded && verbosity > 0) {
292 std::cout <<
"GflashHadronShowerModel: skipping kCalor = " << kCalor <<
293 " DistanceToOut " << distOut <<
" from (" << (postStep->GetPosition()).getRho()/cm <<
294 ":" << (postStep->GetPosition()).getZ()/cm <<
") of KE = " << fastTrack.GetPrimaryTrack()->GetKineticEnergy()/
GeV << std::endl;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const double MinDistanceToOut
static GflashHistogram * instance()
G4bool ModelTrigger(const G4FastTrack &)
const double Zmax[kNumberCalorimeter]
SimActivityRegistry::G4StepSignal m_g4StepSignal
GflashKaonMinusShowerProfile * theKaonMinusProfile
GflashAntiProtonShowerProfile * theAntiProtonProfile
~GflashHadronShowerModel()
void updateGflashStep(const G4ThreeVector &position, G4double time)
void makeHits(const G4FastTrack &fastTrack)
G4Navigator * theGflashNavigator
void DoIt(const G4FastTrack &, G4FastStep &)
GflashHadronShowerProfile * theProfile
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector &position)
virtual void loadParameters()
const double energyCutOff
const double EtaMin[kNumberCalorimeter]
int findShowerType(const Gflash3Vector &position)
G4TouchableHandle theGflashTouchableHandle
void hadronicParameterization()
G4bool isFirstInelasticInteraction(const G4FastTrack &fastTrack)
const double Zmin[kNumberCalorimeter]
const double QuasiElasticLike
const double scaleSensitiveHE
G4bool excludeDetectorRegion(const G4FastTrack &fastTrack)
GflashHistogram * theHisto
static int position[264][3]
GflashKaonPlusShowerProfile * theKaonPlusProfile
edm::ParameterSet theParSet
GflashPiKShowerProfile * thePiKProfile
std::vector< GflashHit > & getGflashHitList()
GflashProtonShowerProfile * theProtonProfile
const double Rmax[kNumberCalorimeter]
const double scaleSensitiveHB
G4bool IsApplicable(const G4ParticleDefinition &)
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum)
GflashHadronShowerModel(G4String modelName, G4Region *envelope, const edm::ParameterSet &parSet)