Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to disable eta/p cut for Geant4 primary #25251

Merged
merged 1 commit into from Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions SimG4Core/Generators/interface/Generator.h
Expand Up @@ -46,6 +46,7 @@ class Generator
bool fPtransCut;
bool fEtaCuts;
bool fPhiCuts;
bool fFiductialCuts;
double theMinPhiCut;
double theMaxPhiCut;
double theMinEtaCut;
Expand Down
40 changes: 22 additions & 18 deletions SimG4Core/Generators/src/Generator.cc
Expand Up @@ -54,6 +54,8 @@ Generator::Generator(const ParameterSet & p) :

double theDecLenCut = p.getParameter<double>("LDecLenCut")*cm;

fFiductialCuts = (fPCuts || fPtransCut || fEtaCuts || fPhiCuts);

pdgFilter.resize(0);
if ( p.exists("PDGselection") ) {
pdgFilterSel = (p.getParameter<edm::ParameterSet>("PDGselection")).
Expand Down Expand Up @@ -85,14 +87,15 @@ Generator::Generator(const ParameterSet & p) :
/ ( 2*exp(-theEtaCutForHector) ) );

edm::LogVerbatim("SimG4CoreGenerator")
<< " Rdecaycut= " << theRDecLenCut/cm
<< "SimG4Core/Generator: Rdecaycut= " << theRDecLenCut/cm
<< " cm; Zdecaycut= " << theDecLenCut/cm
<< "Z_min= " << Z_lmin/cm << " cm; Z_max= " << Z_lmax
<< " cm; Z_hector = " << Z_hector << " cm\n"
<< "ApplyPCuts: " << fPCuts << " ApplyPtransCut: " << fPtransCut
<< " ApplyEtaCuts: " << fEtaCuts
<< " ApplyPhiCuts: " << fPhiCuts
<< " ApplyLumiMonitorCuts: " << lumi;
<< " ApplyCuts: " << fFiductialCuts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@civanch trivial issue, why this space?

Copy link
Contributor Author

@civanch civanch Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos , it is formatting a new line to have clear printout - just before is "\n" symbol.

<< " PCuts: " << fPCuts << " PtransCut: " << fPtransCut
<< " EtaCut: " << fEtaCuts
<< " PhiCut: " << fPhiCuts
<< " LumiMonitorCut: " << lumi;
if(lumi) { fLumiFilter->Describe(); }
}

Expand Down Expand Up @@ -130,13 +133,9 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
(*(evt->vertices_begin()))->position().z(),
(*(evt->vertices_begin()))->position().t());

if(verbose > 0) {
edm::LogVerbatim("SimG4CoreGenerator") << &evt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@civanch this might help in understanding the generator structure to be imported, was it disturbing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos , when we debug various problems it become useful to enable edm::LogVerbatim to see list of primary vertexes/particles. Here I tried make the printout to be easier to find in a long log and more convenient for reading. The old style "verbose" variable requires change of g4SimHits parameter (but save a drop of CPU). With this change debugging is a bit easier, however, this is a minor thing.

LogDebug("SimG4CoreGenerator") << "Primary Vertex = ("
<< vtx_->x() << ","
<< vtx_->y() << ","
<< vtx_->z() << ")";
}
edm::LogVerbatim("SimG4CoreGenerator")
<< "Generator: primary Vertex = ("
<< vtx_->x() << ", " << vtx_->y() << ", " << vtx_->z() << ")";

unsigned int ng4vtx = 0;

Expand Down Expand Up @@ -243,12 +242,13 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
}

edm::LogVerbatim("SimG4CoreGenerator")
<< " pdg= " << pdg
<< "Generator: pdg= " << pdg
<< " status= " << status
<< " hasPreDefinedDecay: " << hasDecayVertex
<< " isExotic: " << isExotic(pdg)
<< " isExoticNotDet: " << isExoticNonDetectable(pdg)
<< " isInTheList: " << IsInTheFilterList(pdg);
<< " isInTheList: " << IsInTheFilterList(pdg)
<< "\n (x,y,z,t): (" << x1 << ","<< y1 << "," << z1 << "," << t1 << ")";

if (status > 3 && isExotic(pdg) && (!(isExoticNonDetectable(pdg))) ) {
status = hasDecayVertex ? 2 : 1;
Expand All @@ -275,7 +275,8 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
decay_length = std::sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
}

bool toBeAdded = false;
bool toBeAdded = (fFiductialCuts) ? false : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@civanch with the default g4SimHits settings this should preserve the standard behaviour...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiocos , no differences in all tests is observed. Normally we have eta/p cuts, so the code behaves in the same way as before.


double px = (*pitr)->momentum().px();
double py = (*pitr)->momentum().py();
double pz = (*pitr)->momentum().pz();
Expand Down Expand Up @@ -310,7 +311,7 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)

// Particles of status 1 trasnported along the beam pipe for forward
// detectors (HECTOR) always pass to Geant4 without cuts
if( 1 == status &&
if( 1 == status &&
std::abs(zimpact) >= Z_hector && rimpact2 <= theDecRCut2) {
toBeAdded = true;
if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
Expand All @@ -319,7 +320,7 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
} else {

// Standard case: particles not decayed by the generator
if(1 == status &&
if(1 == status &&
(std::abs(zimpact) < Z_hector || rimpact2 > theDecRCut2)) {

// Ptot cut for all particles
Expand Down Expand Up @@ -396,7 +397,7 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
delete g4prim;
continue;
}
g4prim->SetCharge(charge);
g4prim->SetCharge(charge);
}

// V.I. do not use SetWeight but the same code
Expand All @@ -410,6 +411,9 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt)
}
if ( verbose > 1 ) g4prim->Print();
g4vtx->SetPrimary(g4prim);
edm::LogVerbatim("SimG4CoreGenerator")
<< "Generator: new particle pdg= " << pdg << " Ptot(GeV/c)= " << ptot
<< " Pt= " << std::sqrt(px*px + py*py);
}
}

Expand Down