1 #include"G4ParticleTable.hh" 2 #include "Randomize.hh" 12 #include "SimG4Core/CustomPhysics/interface/G4ProcessHelper.hh" 17 using namespace CLHEP;
21 particleTable = G4ParticleTable::GetParticleTable();
23 theProton = particleTable->FindParticle(
"proton");
24 theNeutron = particleTable->FindParticle(
"neutron");
30 std::ifstream process_stream (processDefFilePath.c_str());
36 suppressionfactor = p.
getParameter<
double>(
"reggeSuppression");
37 hadronlifetime = p.
getParameter<
double>(
"hadronLifeTime");
42 <<
"ProcessHelper: Read in physics parameters:" 43 <<
"\n Resonant = "<< resonant
44 <<
"\n ResonanceEnergy = "<<ek_0/
GeV<<
" GeV" 45 <<
"\n Gamma = "<<gamma/
GeV<<
" GeV" 46 <<
"\n Amplitude = "<<amplitude/millibarn<<
" millibarn" 47 <<
"ReggeSuppression = "<<100*suppressionfactor<<
" %" 48 <<
"HadronLifeTime = "<<hadronlifetime<<
" s" 49 <<
"ReggeModel = "<< reggemodel
50 <<
"Mixing = "<< mixing*100 <<
" %";
56 while(getline(process_stream,line)){
57 std::vector<G4String> tokens;
59 ReadAndParse(line,tokens,
"#");
61 G4String incident = tokens[0];
63 G4ParticleDefinition* incidentDef = particleTable->FindParticle(incident);
65 G4int incidentPDG = incidentDef->GetPDGEncoding();
66 known_particles[incidentDef]=
true;
68 G4String
target = tokens[1];
70 <<
"ProcessHelper: Incident "<<incident
75 for (
size_t i = 2;
i != tokens.size();
i++){
76 G4String
part = tokens[
i];
77 if (particleTable->contains(part))
79 prod.push_back(particleTable->FindParticle(part)->GetPDGEncoding());
81 G4Exception(
"G4ProcessHelper",
"UnkownParticle", FatalException,
82 "Initialization: The reaction product list contained an unknown particle");
85 if (target ==
"proton")
87 pReactionMap[incidentPDG].push_back(prod);
88 }
else if (target ==
"neutron") {
89 nReactionMap[incidentPDG].push_back(prod);
91 G4Exception(
"G4ProcessHelper",
"IllegalTarget", FatalException,
92 "Initialization: The reaction product list contained an illegal target particle");
96 process_stream.close();
102 <<
"ProcessHelper: Lifetime of "<<part->GetParticleName()<<
" set to " 103 <<particle->GetPDGLifeTime()/
s<<
" s;" 104 <<
" isStable: "<<particle->GetPDGStable();
109 G4bool G4ProcessHelper::ApplicabilityTester(
const G4ParticleDefinition& aPart){
110 const G4ParticleDefinition* aP = &aPart;
111 if (known_particles[aP])
return true;
115 G4double G4ProcessHelper::GetInclusiveCrossSection(
const G4DynamicParticle *aParticle,
116 const G4Element *anElement){
123 G4int thePDGCode = aParticle->GetDefinition()->GetPDGEncoding();
124 double boost = (aParticle->GetKineticEnergy()+aParticle->GetMass())/aParticle->GetMass();
126 G4double theXsec = 0;
127 G4String
name = aParticle->GetDefinition()->GetParticleName();
132 theXsec = 24 * millibarn;
136 for (std::vector<G4int>::iterator it = nq.begin();
141 if (*it == 1 || *it == 2) theXsec += 12 * millibarn;
142 if (*it == 3) theXsec += 6 * millibarn;
148 double R = Regge(boost);
149 double P = Pom(boost);
168 double e_0 = ek_0 + aParticle->GetDefinition()->GetPDGMass();
170 e_0 =
sqrt(aParticle->GetDefinition()->GetPDGMass()*aParticle->GetDefinition()->GetPDGMass()
171 + theProton->GetPDGMass()*theProton->GetPDGMass()
172 + 2.*e_0*theProton->GetPDGMass());
175 double sqrts=
sqrt(aParticle->GetDefinition()->GetPDGMass()*aParticle->GetDefinition()->GetPDGMass()
176 + theProton->GetPDGMass()*theProton->GetPDGMass() + 2*aParticle->GetTotalEnergy()*theProton->GetPDGMass());
178 double res_result = amplitude*(gamma*gamma/4.)/((sqrts-e_0)*(sqrts-e_0)+(gamma*gamma/4.));
180 theXsec += res_result;
185 return theXsec *
pow(anElement->GetN(),0.7)*1.25;
188 ReactionProduct G4ProcessHelper::GetFinalState(
const G4Track& aTrack, G4ParticleDefinition*& aTarget){
190 const G4DynamicParticle* aDynamicParticle = aTrack.GetDynamicParticle();
197 G4Material* aMaterial = aTrack.GetMaterial();
198 const G4ElementVector* theElementVector = aMaterial->GetElementVector() ;
199 const G4double* NbOfAtomsPerVolume = aMaterial->GetVecNbOfAtomsPerVolume();
201 G4double NumberOfProtons=0;
202 G4double NumberOfNucleons=0;
204 for (
size_t elm=0 ; elm < aMaterial->GetNumberOfElements() ; elm++ )
207 NumberOfProtons += NbOfAtomsPerVolume[elm]*(*theElementVector)[elm]->GetZ();
209 NumberOfNucleons += NbOfAtomsPerVolume[elm]*(*theElementVector)[elm]->GetN();
212 if(G4UniformRand()<NumberOfProtons/NumberOfNucleons)
214 theReactionMap = &pReactionMap;
215 theTarget = theProton;
217 theReactionMap = &nReactionMap;
218 theTarget = theNeutron;
222 G4int theIncidentPDG = aDynamicParticle->GetDefinition()->GetPDGEncoding();
226 && G4UniformRand()*mixing>0.5
227 &&aDynamicParticle->GetDefinition()->GetPDGCharge()==0.
231 theIncidentPDG *= -1;
235 bool baryonise=
false;
238 && G4UniformRand()>0.9
248 ReactionProductList* aReactionProductList = &((*theReactionMap)[theIncidentPDG]);
260 ReactionProductList theReactionProductList;
261 std::vector<bool> theChargeChangeList;
263 for (ReactionProductList::iterator prod_it = aReactionProductList->begin();
264 prod_it != aReactionProductList->end();
266 G4int secondaries = prod_it->size();
268 if(ReactionIsPossible(*prod_it,aDynamicParticle)
270 (baryonise&&ReactionGivesBaryon(*prod_it))
272 (!baryonise&&!ReactionGivesBaryon(*prod_it))
281 theReactionProductList.push_back(*prod_it);
282 if (secondaries == 2){
284 }
else if (secondaries ==3) {
287 G4cerr <<
"ReactionProduct has unsupported number of secondaries: "<<secondaries<<G4endl;
295 if (theReactionProductList.empty()) G4Exception(
"G4ProcessHelper",
"NoProcessPossible", FatalException,
296 "GetFinalState: No process could be selected from the given list.");
301 int n_rps = theReactionProductList.size();
302 int select = (
int)( G4UniformRand()*n_rps);
304 return theReactionProductList[
select];
310 G4double p23 = 1-p22;
312 std::vector<G4double> Probabilities;
313 std::vector<G4bool> TwotoThreeFlag;
315 G4double CumulatedProbability = 0;
319 for (
unsigned int i = 0;
i != theReactionProductList.size();
i++){
320 if (theReactionProductList[
i].
size() == 2) {
321 CumulatedProbability += p22/N22;
322 TwotoThreeFlag.push_back(
false);
324 CumulatedProbability += p23/N23;
325 TwotoThreeFlag.push_back(
true);
327 Probabilities.push_back(CumulatedProbability);
333 for (std::vector<G4double>::iterator it = Probabilities.begin();
334 it != Probabilities.end();
337 *it /= CumulatedProbability;
344 G4bool selected =
false;
350 while(!selected && tries < 100){
352 G4double dice = G4UniformRand();
354 while(dice>Probabilities[i] && i<theReactionProductList.size()){
361 if(!TwotoThreeFlag[i]) {
366 if (PhaseSpace(theReactionProductList[i],aDynamicParticle)>G4UniformRand()) selected =
true;
370 if(selected&&particleTable->FindParticle(theReactionProductList[i][0])->GetPDGCharge()!=aDynamicParticle->GetDefinition()->GetPDGCharge())
378 if(G4UniformRand()<suppressionfactor) selected =
false;
383 if(tries>=100)
G4cerr<<
"Could not select process!!!!"<<G4endl;
389 if (theReactionProductList[i].
size()==2) {
395 checkfraction = (1.0*n_22)/(n_22+n_23);
399 return theReactionProductList[
i];
402 G4double G4ProcessHelper::ReactionProductMass(
const ReactionProduct& aReaction,
const G4DynamicParticle* aDynamicParticle){
404 G4double E_incident = aDynamicParticle->GetTotalEnergy();
407 G4double m_1 = aDynamicParticle->GetDefinition()->GetPDGMass();
408 G4double m_2 = theTarget->GetPDGMass();
410 G4double sqrts =
sqrt(m_1*m_1 + m_2*(m_2 + 2 * E_incident));
413 G4double M_after = 0;
414 for (ReactionProduct::const_iterator r_it = aReaction.begin(); r_it !=aReaction.end(); r_it++){
416 M_after += particleTable->FindParticle(*r_it)->GetPDGMass();
419 return sqrts - M_after;
422 G4bool G4ProcessHelper::ReactionIsPossible(
const ReactionProduct& aReaction,
const G4DynamicParticle* aDynamicParticle){
423 if (ReactionProductMass(aReaction,aDynamicParticle)>0)
return true;
427 G4bool G4ProcessHelper::ReactionGivesBaryon(
const ReactionProduct& aReaction){
428 for (ReactionProduct::const_iterator it = aReaction.begin();it!=aReaction.end();it++)
433 G4double G4ProcessHelper::PhaseSpace(
const ReactionProduct& aReaction,
const G4DynamicParticle* aDynamicParticle){
434 G4double qValue = ReactionProductMass(aReaction,aDynamicParticle);
436 return (phi/(1+phi));
439 void G4ProcessHelper::ReadAndParse(
const G4String&
str,
440 std::vector<G4String>& tokens,
441 const G4String& delimiters)
448 while (G4String::npos != pos || G4String::npos != lastPos)
451 G4String
temp = str.substr(lastPos, pos - lastPos);
452 while(temp.c_str()[0] ==
' ') temp.erase(0,1);
453 while(temp[temp.size()-1] ==
' ') temp.erase(temp.size()-1,1);
455 tokens.push_back(temp);
457 lastPos = str.find_first_not_of(delimiters, pos);
459 pos = str.find_first_of(delimiters, lastPos);
463 double G4ProcessHelper::Regge(
const double boost)
465 double a=2.165635078566177;
466 double b=0.1467453738547229;
467 double c=-0.9607903711871166;
468 return 1.5*
exp(a+b/boost+c*
log(boost));
472 double G4ProcessHelper::Pom(
const double boost)
474 double a=4.138224000651535;
475 double b=1.50377557581421;
476 double c=-0.05449742257808247;
477 double d=0.0008221235048211401;
478 return a + b*
sqrt(boost) + c*boost + d*
pow(boost,1.5);
T getParameter(std::string const &) const
static bool s_isRGlueball(int pdg)
static bool s_isSbaryon(int pdg)
static bool s_isRMeson(int pdg)
static bool s_isMesonino(int pdg)
static bool s_isRBaryon(int pdg)
static std::vector< int > s_containedQuarks(int pdg)
std::pair< OmniClusterRef, TrackingParticleRef > P
static const std::vector< G4ParticleDefinition * > & GetCustomParticles()
std::string fullPath() const
Power< A, B >::type pow(const A &a, const B &b)