10 #ifndef EVGEN_NUANCEGEN_H 11 #define EVGEN_NUANCEGEN_H 29 #include "TDatabasePDG.h" 31 #include "TStopwatch.h" 126 produces< std::vector<simb::MCTruth> >();
127 produces< sumdata::RunData, art::InRun >();
130 fEventFile = std::make_unique<std::ifstream>(fNuanceFile.c_str());
133 <<
"Failed to open input file '" << fNuanceFile <<
"'.\n";
157 fGenerated[0] = tfs->
make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
158 fGenerated[1] = tfs->
make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
159 fGenerated[2] = tfs->
make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
160 fGenerated[3] = tfs->
make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
161 fGenerated[4] = tfs->
make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
162 fGenerated[5] = tfs->
make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
164 fDCosX = tfs->
make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
165 fDCosY = tfs->
make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
166 fDCosZ = tfs->
make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
168 fMuMomentum = tfs->
make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
169 fMuDCosX = tfs->
make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
170 fMuDCosY = tfs->
make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
171 fMuDCosZ = tfs->
make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
173 fEMomentum = tfs->
make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
174 fEDCosX = tfs->
make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
175 fEDCosY = tfs->
make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
176 fEDCosZ = tfs->
make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
178 fCCMode = tfs->
make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 5, 0., 5.);
179 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
180 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
181 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
182 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
183 fCCMode->GetXaxis()->SetBinLabel(5,
"kInverseMuDecay");
184 fCCMode->GetXaxis()->CenterLabels();
186 fNCMode = tfs->
make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 5, 0., 5.);
187 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
188 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
189 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
190 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
191 fNCMode->GetXaxis()->SetBinLabel(5,
"kNuElectronElastic");
192 fNCMode->GetXaxis()->CenterLabels();
195 fECons = tfs->
make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
201 int xdiv = TMath::Nint(2*x/5.);
202 int ydiv = TMath::Nint(2*y/5.);
203 int zdiv = TMath::Nint(2*z/5.);
207 fVertexZ = tfs->
make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.2*
z,
z);
209 fVertexXY = tfs->
make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -
x,
x, ydiv, -
y,
y);
210 fVertexXZ = tfs->
make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -
x,
x);
211 fVertexYZ = tfs->
make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
223 run.
put(std::move(runcol));
237 std::cout << std::endl;
238 std::cout<<
"------------------------------------------------------------------------------"<<std::endl;
242 std::cout <<
"event : " << evt.
id().
event() << std::endl;
247 double PDGCODE = -9999.;
248 double CHANNEL = -9999.;
254 std::string name, k, dollar;
258 std::string primary(
"primary");
259 int FirstMother = -1;
266 int targetnucleusPdg = -9999;
267 int hitquarkPdg = -9999;
270 TLorentzVector Neutrino;
271 TLorentzVector Lepton;
272 TLorentzVector Target;
274 TLorentzVector Hadron4mom;
276 double InvariantMass = -9999;
284 double Tcosx = 0., Tcosy = 0., Tcosz = 0., Tenergy = 0.;
294 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
298 std::cout <<
"NuanceFile: Problem reading nuance file" << std::endl;
301 std::istringstream
in;
305 in>>dollar>>name>>PDGCODE>>energy>>cosx>>cosy>>cosz>>partnumber;
309 if(name ==
"nuance"){
311 channel = int (CHANNEL);
356 if(name ==
"vertex"){
363 double PI = 3.14159265;
370 if(name ==
"track" && (PDGCODE == 2212 || PDGCODE == 2112 || PDGCODE == 18040 || PDGCODE == 11) && partnumber == -1){
371 Tpdg = int (PDGCODE);
373 if ( PDGCODE == 18040 ){
378 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
379 const TParticlePDG* definition = databasePDG->GetParticle(Tpdg);
380 Tmass = definition->Mass();
390 if(name ==
"track" && (
392 (partnumber == -1 && (PDGCODE != 2212 && PDGCODE != 2112 && PDGCODE != 18040 && PDGCODE != 11))
396 int pdgcode = int (PDGCODE);
399 if ( PDGCODE == 18040 )
403 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
404 const TParticlePDG* definition = databasePDG->GetParticle(pdgcode);
405 Mass = definition->Mass();
422 P = std::sqrt(pow(energy/1000,2.) - pow(Mass,2.));
431 TLorentzVector pos(X0, Y0, Z0, 0);
434 TLorentzVector mom(CosX*P, CosY*P, CosZ*P, energy/1000);
440 if(name ==
"track" && (abs(pdgcode) == 14 || abs(pdgcode) == 12) && partnumber == -1)
441 Neutrino.SetPxPyPzE(CosX*P, CosY*P, CosZ*P, energy/1000);
443 if(name ==
"track" && (abs(pdgcode) == 13 || abs(pdgcode) == 11 || abs(pdgcode) == 14 || abs(pdgcode) == 12) && partnumber == 0)
444 Lepton.SetPxPyPzE(CosX*P, CosY*P, CosZ*P, energy/1000);
467 Tmom.SetPxPyPzE(Tcosx, Tcosy, Tcosz, Tenergy/1000);
491 q = Neutrino - Lepton;
497 double W2 = M*M + 2*M*v - Q2;
498 InvariantMass = TMath::Sqrt(TMath::Max(0.,W2));
512 InvariantMass, x, y, Q2
517 truthcol->push_back(truth);
519 evt.
put(std::move(truthcol));
527 int code = StatusCode;
533 ParticleStatusName =
"kIStInitialState";
536 ParticleStatusName =
"kIStFinalState";
539 ParticleStatusName =
"kIStNucleonTarget";
542 ParticleStatusName =
"Status Unknown";
551 std::string ReactionChannelName=
" ";
554 ReactionChannelName =
"kCC";
556 ReactionChannelName =
"kNC";
557 else std::cout<<
"Current mode unknown!! "<<std::endl;
560 ReactionChannelName +=
"_kQE";
562 ReactionChannelName +=
"_kRes";
564 ReactionChannelName +=
"_kDIS";
566 ReactionChannelName +=
"_kCoh";
568 ReactionChannelName +=
"_kNuElectronElastic";
570 ReactionChannelName +=
"_kInverseMuDecay";
571 else std::cout<<
"interaction mode unknown!! "<<std::endl;
573 return ReactionChannelName;
613 if(std::abs(mom) > 0.){
660 std::cout <<
"-----------> Particles in the Stack = " << mc.
NParticles() << std::endl;
662 << std::setw(20) <<
"PARTICLE" 664 << std::setw(32) <<
"STATUS" 665 << std::setw(18) <<
"E (GeV)" 666 << std::setw(18) <<
"m (GeV/c2)" 667 << std::setw(18) <<
"Ek (GeV)" 668 << std::endl << std::endl;
670 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
676 if (
part.PdgCode() == 18040)
678 else if (
part.PdgCode() != -99999 )
680 name = databasePDG->GetParticle(
part.PdgCode())->GetName();
683 int code =
part.StatusCode();
685 double mass =
part.Mass();
687 double Ek = (energy-mass);
689 std::cout << std::setiosflags(
std::ios::left) << std::setw(20) << name
691 << std::setw(18)<< energy
692 << std::setw(18)<< mass
693 << std::setw(18)<< Ek <<std::endl;
703 if(abs(
part.PdgCode()) == 11){
711 else if(abs(
part.PdgCode()) == 13){
double E(const int i=0) const
TH1F * fVertexX
vertex location of generated events in x
neutral current quasi-elastic
TH2F * fVertexYZ
vertex location in yz
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
const simb::MCNeutrino & GetNeutrino() const
double Py(const int i=0) const
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
charged current deep inelastic scatter
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
NUANCEGen(fhicl::ParameterSet const &pset)
resonant charged current, nubar p -> l+ p pi-
void SetOrigin(simb::Origin_t origin)
neutrino electron elastic scatter
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
TH2F * fVertexXY
vertex location in xy
TH1F * fDCosY
direction cosine in y
const simb::MCParticle & Nu() const
TH1F * fEMomentum
momentum of outgoing electrons
double Px(const int i=0) const
TH1F * fECons
histogram to determine if energy is conserved in the event
offset to account for adding in Nuance codes to this enum
TH1F * fGenerated[6]
Spectra as generated.
TH1F * fNCMode
CC interaction mode.
TH2F * fVertexXZ
vertex location in xz
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
charged current quasi-elastic
std::string ParticleStatus(int StatusCode)
art::ProductID put(std::unique_ptr< PROD > &&)
void reconfigure(fhicl::ParameterSet const &p)
void Add(simb::MCParticle &part)
TH1F * fDCosZ
direction cosine in z
TH1F * fCCMode
CC interaction mode.
TH1F * fDCosX
direction cosine in x
ProductID put(std::unique_ptr< PROD > &&product)
TH1F * fEDCosX
direction cosine of outgoing e in x
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
#define DEFINE_ART_MODULE(klass)
resonant charged current, nu n -> l- n pi+
void FillHistograms(simb::MCTruth mc)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
TH1F * fMuDCosY
direction cosine of outgoing mu in y
std::string ReactionChannel(int ccnc, int mode)
double P(const int i=0) const
T get(std::string const &key) const
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
std::unique_ptr< std::ifstream > fEventFile
TH1F * fEDCosZ
direction cosine of outgoing e in z
void produce(art::Event &evt)
TH1F * fMuMomentum
momentum of outgoing muons
charged current deep inelastic scatter
resonant charged current, nu p -> l- p pi+
const simb::MCParticle & GetParticle(int i) const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
double Vx(const int i=0) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
double fBeamVerticalAngle
T * make(ARGS...args) const
charged current coherent pion
A module to check the results from the Monte Carlo generator.
double Pz(const int i=0) const
resonant charged current, nubar n -> l+ n pi-
TH1F * fMuDCosX
direction cosine of outgoing mu in x
double Vz(const int i=0) const
EventNumber_t event() const
TH1F * fEDCosY
direction cosine of outgoing e in y
Event generator information.
Event generator information.
Namespace collecting geometry-related classes utilities.
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
void beginRun(art::Run &run)
TH1F * fVertexY
vertex location of generated events in y
double Vy(const int i=0) const
std::string fNUANCEModuleLabel
keep track of how long it takes to run the job
art framework interface to geometry description
TH1F * fVertexZ
vertex location of generated events in z