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"
34 : G4VFastSimulationModel(modelName, envelope), theParSet(parSet)
61 &particleType == G4PionMinus::PionMinusDefinition() ||
62 &particleType == G4PionPlus::PionPlusDefinition() ||
63 &particleType == G4KaonMinus::KaonMinusDefinition() ||
64 &particleType == G4KaonPlus::KaonPlusDefinition() ||
65 &particleType == G4AntiProton::AntiProtonDefinition() ||
66 &particleType == G4Proton::ProtonDefinition() ;
79 G4bool trigger =
false;
85 if(fastTrack.GetPrimaryTrack()->GetTrackStatus() == fPostponeToNextEvent ) {
103 fastStep.KillPrimaryTrack();
104 fastStep.ProposePrimaryTrackPathLength(0.0);
107 G4ParticleDefinition* particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
116 G4double
energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy()/GeV;
117 G4double globalTime = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetGlobalTime();
118 G4double
charge = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint()->GetCharge();
119 G4ThreeVector
position = fastTrack.GetPrimaryTrack()->GetPosition()/cm;
120 G4ThreeVector momentum = fastTrack.GetPrimaryTrack()->GetMomentum()/GeV;
136 theGflashStep->SetTrack(const_cast<G4Track*>(fastTrack.GetPrimaryTrack()));
137 theGflashStep->GetPostStepPoint()->SetProcessDefinedStep(const_cast<G4VProcess*>
138 (fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()));
139 theGflashNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume());
141 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
142 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
144 for( ; spotIter != spotIterEnd; spotIter++){
146 theGflashNavigator->LocateGlobalPointAndUpdateTouchableHandle(spotIter->getPosition(),G4ThreeVector(0,0,0),
157 G4VPhysicalVolume* aCurrentVolume =
theGflashStep->GetPreStepPoint()->GetPhysicalVolume();
158 if( aCurrentVolume == 0 )
continue;
160 G4LogicalVolume* lv = aCurrentVolume->GetLogicalVolume();
161 if(lv->GetRegion()->GetName() !=
"CaloRegion")
continue;
163 theGflashStep->GetPreStepPoint()->SetSensitiveDetector(aCurrentVolume->GetLogicalVolume()->GetSensitiveDetector());
164 G4VSensitiveDetector* aSensitive =
theGflashStep->GetPreStepPoint()->GetSensitiveDetector();
166 if( aSensitive == 0 )
continue;
168 G4String nameCalor = aCurrentVolume->GetName();
169 nameCalor.assign(nameCalor,0,2);
170 G4double samplingWeight = 1.0;
171 if(nameCalor ==
"HB" ) {
174 else if(nameCalor==
"HE" || nameCalor ==
"HT") {
177 theGflashStep->SetTotalEnergyDeposit(spotIter->getEnergy()*samplingWeight);
186 theGflashStep->GetPostStepPoint()->SetGlobalTime(timeGlobal);
188 theGflashStep->GetPostStepPoint()->SetPosition(spotPosition);
196 G4StepPoint* preStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPreStepPoint();
197 G4StepPoint* postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
199 G4String procName = postStep->GetProcessDefinedStep()->GetProcessName();
200 G4ParticleDefinition* particleType = fastTrack.GetPrimaryTrack()->GetDefinition();
204 if((particleType == G4PionPlus::PionPlusDefinition() && procName ==
"WrappedPionPlusInelastic") ||
205 (particleType == G4PionMinus::PionMinusDefinition() && procName ==
"WrappedPionMinusInelastic") ||
206 (particleType == G4KaonPlus::KaonPlusDefinition() && procName ==
"WrappedKaonPlusInelastic") ||
207 (particleType == G4KaonMinus::KaonMinusDefinition() && procName ==
"WrappedKaonMinusInelastic") ||
208 (particleType == G4AntiProton::AntiProtonDefinition() && procName ==
"WrappedAntiProtonInelastic") ||
209 (particleType == G4Proton::ProtonDefinition() && procName ==
"WrappedProtonInelastic")) {
214 const G4TrackVector* fSecondaryVector = fastTrack.GetPrimaryTrack()->GetStep()->GetSecondary();
215 G4double leadingEnergy = 0.0;
221 for (
unsigned int isec = 0 ; isec < fSecondaryVector->size() ; isec++) {
222 G4Track* fSecondaryTrack = (*fSecondaryVector)[isec];
223 G4double secondaryEnergy = fSecondaryTrack->GetKineticEnergy();
225 if(secondaryEnergy > leadingEnergy ) {
226 leadingEnergy = secondaryEnergy;
230 if((preStep->GetTotalEnergy()!=0) &&
239 theHisto->
deltaStep->Fill((postStep->GetPosition() - preStep->GetPosition()).getRho()/cm);
241 theHisto->
energyLoss->Fill(fabs(fastTrack.GetPrimaryTrack()->GetStep()->GetDeltaEnergy()/GeV));
251 G4bool isExcluded=
false;
256 G4double
eta = fastTrack.GetPrimaryTrack()->GetPosition().pseudoRapidity() ;
257 if(std::fabs(eta) > 1.392 && std::fabs(eta) < 1.566) {
259 edm::LogInfo(
"SimGeneralGFlash") <<
"GflashHadronShowerModel: excluding region of eta = " <<
eta;
264 G4StepPoint* postStep = fastTrack.GetPrimaryTrack()->GetStep()->GetPostStepPoint();
267 G4double distOut = 9999.0;
289 if(isExcluded && verbosity > 0) {
290 std::cout <<
"GflashHadronShowerModel: skipping kCalor = " << kCalor <<
291 " DistanceToOut " << distOut <<
" from (" << (postStep->GetPosition()).getRho()/cm <<
292 ":" << (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()
void updateGflashStep(G4ThreeVector position, G4double time)
G4bool ModelTrigger(const G4FastTrack &)
const double Zmax[kNumberCalorimeter]
bool isFirst(HepMC::GenParticle *x)
SimActivityRegistry::G4StepSignal m_g4StepSignal
GflashKaonMinusShowerProfile * theKaonMinusProfile
GflashAntiProtonShowerProfile * theAntiProtonProfile
~GflashHadronShowerModel()
GflashHadronShowerModel(G4String modelName, G4Region *envelope, edm::ParameterSet parSet)
void makeHits(const G4FastTrack &fastTrack)
G4Navigator * theGflashNavigator
void DoIt(const G4FastTrack &, G4FastStep &)
GflashHadronShowerProfile * theProfile
virtual void loadParameters()
int findShowerType(const Gflash3Vector position)
const double energyCutOff
const double EtaMin[kNumberCalorimeter]
G4TouchableHandle theGflashTouchableHandle
void hadronicParameterization()
G4bool isFirstInelasticInteraction(const G4FastTrack &fastTrack)
const double Zmin[kNumberCalorimeter]
const double QuasiElasticLike
const double scaleSensitiveHE
G4bool excludeDetectorRegion(const G4FastTrack &fastTrack)
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector position)
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)