28 #include "art_root_io/TFileService.h" 29 #include "art_root_io/TFileDirectory.h" 35 #include "TDatabasePDG.h" 42 #include "TStopwatch.h" 60 namespace simb {
class MCTruth; }
1261 produces< std::vector<simb::MCTruth> >();
1262 produces< sumdata::RunData, art::InRun >();
1288 fGenerated[0] = tfs->make<TH1F>(
"fGenerated_necc",
"", 100, 0.0, 20.0);
1289 fGenerated[1] = tfs->make<TH1F>(
"fGenerated_nebcc",
"", 100, 0.0, 20.0);
1290 fGenerated[2] = tfs->make<TH1F>(
"fGenerated_nmcc",
"", 100, 0.0, 20.0);
1291 fGenerated[3] = tfs->make<TH1F>(
"fGenerated_nmbcc",
"", 100, 0.0, 20.0);
1292 fGenerated[4] = tfs->make<TH1F>(
"fGenerated_nnc",
"", 100, 0.0, 20.0);
1293 fGenerated[5] = tfs->make<TH1F>(
"fGenerated_nbnc",
"", 100, 0.0, 20.0);
1295 fDCosX = tfs->make<TH1F>(
"fDCosX",
";dx/ds", 200, -1., 1.);
1296 fDCosY = tfs->make<TH1F>(
"fDCosY",
";dy/ds", 200, -1., 1.);
1297 fDCosZ = tfs->make<TH1F>(
"fDCosZ",
";dz/ds", 200, -1., 1.);
1299 fMuMomentum = tfs->make<TH1F>(
"fMuMomentum",
";p_{#mu} (GeV/c)", 500, 0., 50.);
1300 fMuDCosX = tfs->make<TH1F>(
"fMuDCosX",
";dx/ds;", 200, -1., 1.);
1301 fMuDCosY = tfs->make<TH1F>(
"fMuDCosY",
";dy/ds;", 200, -1., 1.);
1302 fMuDCosZ = tfs->make<TH1F>(
"fMuDCosZ",
";dz/ds;", 200, -1., 1.);
1304 fEMomentum = tfs->make<TH1F>(
"fEMomentum",
";p_{e} (GeV/c)", 500, 0., 50.);
1305 fEDCosX = tfs->make<TH1F>(
"fEDCosX",
";dx/ds;", 200, -1., 1.);
1306 fEDCosY = tfs->make<TH1F>(
"fEDCosY",
";dy/ds;", 200, -1., 1.);
1307 fEDCosZ = tfs->make<TH1F>(
"fEDCosZ",
";dz/ds;", 200, -1., 1.);
1309 fCCMode = tfs->make<TH1F>(
"fCCMode",
";CC Interaction Mode;", 5, 0., 5.);
1310 fCCMode->GetXaxis()->SetBinLabel(1,
"QE");
1311 fCCMode->GetXaxis()->SetBinLabel(2,
"Res");
1312 fCCMode->GetXaxis()->SetBinLabel(3,
"DIS");
1313 fCCMode->GetXaxis()->SetBinLabel(4,
"Coh");
1314 fCCMode->GetXaxis()->SetBinLabel(5,
"kInverseMuDecay");
1315 fCCMode->GetXaxis()->CenterLabels();
1317 fNCMode = tfs->make<TH1F>(
"fNCMode",
";NC Interaction Mode;", 5, 0., 5.);
1318 fNCMode->GetXaxis()->SetBinLabel(1,
"QE");
1319 fNCMode->GetXaxis()->SetBinLabel(2,
"Res");
1320 fNCMode->GetXaxis()->SetBinLabel(3,
"DIS");
1321 fNCMode->GetXaxis()->SetBinLabel(4,
"Coh");
1322 fNCMode->GetXaxis()->SetBinLabel(5,
"kNuElectronElastic");
1323 fNCMode->GetXaxis()->CenterLabels();
1325 fWeight = tfs->make<TH1F>(
"fWeight",
";Weight1;", 20, 1.E-42, 1.E-38);
1326 fWeightNW = tfs->make<TH1F>(
"fWeightNW",
";Weight2;", 20, 1.E-42, 1.E-38);
1328 fDyn = tfs->make<TH1F>(
"fDyn",
";Canonical Interaction Mode;", 13, 0., 13.);
1329 fDyn->GetXaxis()->SetBinLabel(1,
"CCQE");
1330 fDyn->GetXaxis()->SetBinLabel(2,
"NCelastic");
1331 fDyn->GetXaxis()->SetBinLabel(3,
"CCResp2ppi+");
1332 fDyn->GetXaxis()->SetBinLabel(4,
"CCResn2ppi0");
1333 fDyn->GetXaxis()->SetBinLabel(5,
"CCResn2npi+");
1334 fDyn->GetXaxis()->SetBinLabel(6,
"NCResp2ppi0");
1335 fDyn->GetXaxis()->SetBinLabel(7,
"NCResp2npi+");
1336 fDyn->GetXaxis()->SetBinLabel(8,
"NCResn2npi0");
1337 fDyn->GetXaxis()->SetBinLabel(9,
"NCResn2ppi-");
1338 fDyn->GetXaxis()->SetBinLabel(10,
"CC-DIS");
1339 fDyn->GetXaxis()->SetBinLabel(11,
"NC-DIS");
1340 fDyn->GetXaxis()->SetBinLabel(12,
"NC-COH");
1341 fDyn->GetXaxis()->SetBinLabel(13,
"CC-COH");
1342 fDyn->GetXaxis()->CenterLabels();
1344 fDynNew = tfs->make<TH1F>(
"fDynNew",
";New Style Accounting Mode;", 10, 0., 10.);
1345 fDynNew->GetXaxis()->SetBinLabel(1,
"1mu0p0pi");
1346 fDynNew->GetXaxis()->SetBinLabel(2,
"1mu1p0pi");
1347 fDynNew->GetXaxis()->SetBinLabel(3,
"1muge2p0pi");
1348 fDynNew->GetXaxis()->SetBinLabel(4,
"1mu0p1pi");
1349 fDynNew->GetXaxis()->SetBinLabel(5,
"1mu1p1pi");
1350 fDynNew->GetXaxis()->SetBinLabel(6,
"1muge2p1pi");
1351 fDynNew->GetXaxis()->SetBinLabel(7,
"1mu0p2pi");
1352 fDynNew->GetXaxis()->SetBinLabel(8,
"1muge1p2pi");
1353 fDynNew->GetXaxis()->SetBinLabel(9,
"NC");
1354 fDynNew->GetXaxis()->SetBinLabel(10,
"Other");
1355 fDynNew->GetXaxis()->CenterLabels();
1357 fDynNewThresh = tfs->make<TH1F>(
"fDynNewThresh",
";New Style Accounting Mode (Tp>50MeV);", 10, 0., 10.);
1370 f2DynNew = tfs->make<TH2F>(
"f2DynNew",
";Old vs New Style Accounting Mode;", 13, 0.,13., 10,0.,10.);
1372 f2DynNew->GetXaxis()->SetBinLabel(1,
"CCQE");
1373 f2DynNew->GetXaxis()->SetBinLabel(2,
"NCelastic");
1374 f2DynNew->GetXaxis()->SetBinLabel(3,
"CCResp2ppi+");
1375 f2DynNew->GetXaxis()->SetBinLabel(4,
"CCResn2ppi0");
1376 f2DynNew->GetXaxis()->SetBinLabel(5,
"CCResn2npi+");
1377 f2DynNew->GetXaxis()->SetBinLabel(6,
"NCResp2ppi0");
1378 f2DynNew->GetXaxis()->SetBinLabel(7,
"NCResp2npi+");
1379 f2DynNew->GetXaxis()->SetBinLabel(8,
"NCResn2npi0");
1380 f2DynNew->GetXaxis()->SetBinLabel(9,
"NCResn2ppi-");
1381 f2DynNew->GetXaxis()->SetBinLabel(10,
"CC-DIS");
1382 f2DynNew->GetXaxis()->SetBinLabel(11,
"NC-DIS");
1383 f2DynNew->GetXaxis()->SetBinLabel(12,
"NC-COH");
1384 f2DynNew->GetXaxis()->SetBinLabel(13,
"CC-COH");
1385 f2DynNew->GetXaxis()->CenterLabels();
1386 f2DynNew->GetYaxis()->SetBinLabel(1,
"1mu0p0pi");
1387 f2DynNew->GetYaxis()->SetBinLabel(2,
"1mu1p0pi");
1388 f2DynNew->GetYaxis()->SetBinLabel(3,
"1muge2p0pi");
1389 f2DynNew->GetYaxis()->SetBinLabel(4,
"1mu0p1pi");
1390 f2DynNew->GetYaxis()->SetBinLabel(5,
"1mu1p1pi");
1391 f2DynNew->GetYaxis()->SetBinLabel(6,
"1muge2p1pi");
1392 f2DynNew->GetYaxis()->SetBinLabel(7,
"1mu0p2pi");
1393 f2DynNew->GetYaxis()->SetBinLabel(8,
"1muge1p2pi");
1394 f2DynNew->GetYaxis()->SetBinLabel(9,
"NC");
1395 f2DynNew->GetYaxis()->SetBinLabel(10,
"Other");
1396 f2DynNew->GetYaxis()->CenterLabels();
1398 f2DynNewThresh = tfs->make<TH2F>(
"f2DynNewThresh",
";Old vs New Style Accounting Mode;", 13, 0.,13., 10, 0.,10.);
1427 fECons = tfs->make<TH1F>(
"fECons",
";#Delta E(#nu,lepton);", 500, -5., 5.);
1433 int xdiv = TMath::Nint(2*x/5.);
1434 int ydiv = TMath::Nint(2*y/5.);
1435 int zdiv = TMath::Nint(2*z/5.);
1437 fVertexX = tfs->make<TH1F>(
"fVertexX",
";x (cm)", xdiv, -
x,
x);
1438 fVertexY = tfs->make<TH1F>(
"fVertexY",
";y (cm)", ydiv, -
y,
y);
1439 fVertexZ = tfs->make<TH1F>(
"fVertexZ",
";z (cm)", zdiv, -0.2*
z,
z);
1441 fVertexXY = tfs->make<TH2F>(
"fVertexXY",
";x (cm);y (cm)", xdiv, -
x,
x, ydiv, -
y,
y);
1442 fVertexXZ = tfs->make<TH2F>(
"fVertexXZ",
";z (cm);x (cm)", zdiv, -0.2*
z,
z, xdiv, -
x,
x);
1443 fVertexYZ = tfs->make<TH2F>(
"fVertexYZ",
";z (cm);y (cm)", zdiv, -0.2*
z,
z, ydiv, -
y,
y);
1446 TClass::GetClass(
"line")->GetStreamerInfo(1);
1451 std::cout <<
" Num entries in TTree is " <<
ch->GetEntries() <<
std::endl;
1457 std::cout <<
"NuWroGen: Here's the output of the .txt file" <<
std::endl;
1458 std::ifstream xsecTxtFile((
fFileName+
".txt").c_str());
1459 unsigned int cntline(0);
1461 if (xsecTxtFile.is_open())
1463 while ( xsecTxtFile.good() )
1465 getline (xsecTxtFile,line);
1466 cout << line <<
endl;
1467 if (cntline==0) { cntline++;
continue;}
1468 stringstream ss(line);
1473 tokens.push_back(buf);
1476 if (tokens.
size() && line.length())
1478 else xsecTxtFile.close();
1482 else std::cout <<
"Unable to open file";
1513 std::cout<<
"------------------------------------------------------------------------------"<<
std::endl;
1524 int FirstMother = -1;
1531 int targetnucleusPdg = -9999;
1532 int hitquarkPdg = -9999;
1534 TLorentzVector Neutrino;
1535 TLorentzVector Lepton;
1536 TLorentzVector Target;
1538 TLorentzVector Hadron4mom;
1544 double Tcosx, Tcosy, Tcosz, Tenergy;
1545 TLorentzVector Tpos;
1548 std::unique_ptr< std::vector<simb::MCTruth> > truthcol(
new std::vector<simb::MCTruth>);
1575 if(partnumber == -1)
1585 TLorentzVector
pos(X0, Y0, Z0, 0);
1596 TLorentzVector mom(
NuWroTTree->in[0].x/1000.,
1600 mcpartNu.AddTrajectoryPoint(pos,mom);
1601 truth.
Add(mcpartNu);
1605 while(ii<NuWroTTree->post.size())
1616 TLorentzVector mom(
NuWroTTree->post[ii].x/1000.,
1620 mcpart.AddTrajectoryPoint(pos,mom);
1639 Tmass = std::sqrt(
std::abs(Tenergy*Tenergy - Tcosx*Tcosx
1640 - Tcosy*Tcosy - Tcosz*Tcosz))/1000.;
1642 Tenergy = Tmass-0.1;
1644 Tcosx =0.; Tcosy = 0.; Tcosz = 0.;
1658 TLorentzVector Tmom;
1659 Tmom.SetPxPyPzE(Tcosx/1000., Tcosy/1000., Tcosz/1000., Tenergy);
1670 q = Neutrino - Lepton;
1675 double x = Q2/((2*Target*q));
1676 double y = (Target*q)/(Neutrino*Target);
1693 truthcol->push_back(truth);
1702 int code = StatusCode;
1708 ParticleStatusName =
"kIStInitialState";
1711 ParticleStatusName =
"kIStFinalState";
1714 ParticleStatusName =
"kIStNucleonTarget";
1717 ParticleStatusName =
"Status Unknown";
1729 ReactionChannelName =
"kCC";
1731 ReactionChannelName =
"kNC";
1732 else std::cout<<
"Current mode unknown!! "<<
std::endl;
1735 ReactionChannelName +=
"_kQE";
1737 ReactionChannelName +=
"_kRes";
1739 ReactionChannelName +=
"_kDIS";
1741 ReactionChannelName +=
"_kCoh";
1743 ReactionChannelName +=
"_kNuElectronElastic";
1745 ReactionChannelName +=
"_kInverseMuDecay";
1746 else std::cout<<
"interaction mode unknown!! "<<
std::endl;
1748 return ReactionChannelName;
1769 if (
id==-1) abort();
1787 double mom = nu.
P();
1845 const TDatabasePDG* databasePDG = TDatabasePDG::Instance();
1851 if (part.PdgCode() == 18040)
1852 name =
"Ar40 18040";
1853 else if (part.PdgCode() != -99999 )
1855 name = databasePDG->GetParticle(part.PdgCode())->GetName();
1858 int code = part.StatusCode();
1860 double mass = part.Mass();
1861 double energy = part.E();
1862 double Ek = (energy-mass);
1877 if(
std::abs(part.PdgCode()) == 11){
1879 fEDCosX->Fill(part.Px()/part.P());
1880 fEDCosY->Fill(part.Py()/part.P());
1881 fEDCosZ->Fill(part.Pz()/part.P());
1882 fECons->Fill(nu.
E() - part.E());
1885 else if(
std::abs(part.PdgCode()) == 13){
1887 fMuDCosX->Fill(part.Px()/part.P());
1888 fMuDCosY->Fill(part.Py()/part.P());
1889 fMuDCosZ->Fill(part.Pz()/part.P());
1890 fECons->Fill(nu.
E() - part.E());
1899 double binNewThresh(0.0);
1909 unsigned int p(0),
n(0), pip(0), pim(0), pi0(0);
1910 while(ii<NuWroTTree->post.size())
1920 else if (
NuWroTTree->flag.cc && pi0 &&
p) bin = 4.;
1921 else if (
NuWroTTree->flag.cc && pip &&
n) bin = 5.;
1922 else if (
NuWroTTree->flag.nc && pi0 &&
p) bin = 6.;
1923 else if (
NuWroTTree->flag.nc && pip &&
n) bin = 7.;
1924 else if (
NuWroTTree->flag.nc && pi0 &&
n) bin = 8.;
1925 else if (
NuWroTTree->flag.nc && pim &&
p) bin = 9.;
1927 std::cout <<
"NuWroGen: bin=0 events, cc?" <<
NuWroTTree->flag.cc <<
" nc?: " <<
NuWroTTree->flag.nc <<
" Num protons: " <<
p <<
" Num pi+s: " << pip <<
" Num pi-s: " << pim <<
" Num pi0s: " << pi0 <<
" Num neutrons: " <<
n <<
std::endl;
1931 unsigned int p(0),
n(0), pip(0), pim(0), pi0(0), pThresh(0.);
1932 while(ii<NuWroTTree->post.size())
1940 (
NuWroTTree->out[ii].t/1000.-0.939)>0.050) pThresh++;
1944 if (
NuWroTTree->flag.cc &&
p==0 && (pip+pim)==0) binNew = 1;
1945 else if (
NuWroTTree->flag.cc &&
p==1 && (pip+pim)==0) binNew = 2;
1946 else if (
NuWroTTree->flag.cc &&
p>=2 && (pip+pim)==0) binNew = 3;
1947 else if (
NuWroTTree->flag.cc &&
p==0 && (pip+pim)==1) binNew = 4;
1948 else if (
NuWroTTree->flag.cc &&
p==1 && (pip+pim)==1) binNew = 5;
1949 else if (
NuWroTTree->flag.cc &&
p>=2 && (pip+pim)==1) binNew = 6;
1950 else if (
NuWroTTree->flag.cc &&
p==0 && (pip+pim)>=2) binNew = 7;
1951 else if (
NuWroTTree->flag.cc &&
p>=1 && (pip+pim)>=2) binNew = 8;
1955 if (
NuWroTTree->flag.cc && pThresh==0 && (pip+pim)==0) binNewThresh = 1;
1956 else if (
NuWroTTree->flag.cc && pThresh==1 && (pip+pim)==0) binNewThresh = 2;
1957 else if (
NuWroTTree->flag.cc && pThresh>=2 && (pip+pim)==0) binNewThresh = 3;
1958 else if (
NuWroTTree->flag.cc && pThresh==0 && (pip+pim)==1) binNewThresh = 4;
1959 else if (
NuWroTTree->flag.cc && pThresh==1 && (pip+pim)==1) binNewThresh = 5;
1960 else if (
NuWroTTree->flag.cc && pThresh>=2 && (pip+pim)==1) binNewThresh = 6;
1961 else if (
NuWroTTree->flag.cc && pThresh==0 && (pip+pim)>=2) binNewThresh = 7;
1962 else if (
NuWroTTree->flag.cc && pThresh>=1 && (pip+pim)>=2) binNewThresh = 8;
1963 else if (
NuWroTTree->flag.nc ) binNewThresh = 9;
1964 else binNewThresh = 10;
1967 double N_ArAtoms(70.*1000*1000/40*6.022e23);
1969 double FluxNorm(5.19
e-10 * (540./460.)*(540./460.));
1971 double NumEvtsRunThisJob(10000.);
1976 double wt =
fxsecTotal * N_ArAtoms * nucleiPerAtom * 6.e20 * FluxNorm / NumEvtsRunThisJob;
1977 fDyn->Fill(bin-0.5,wt);
1980 f2DynNew->Fill(bin-0.5,binNew-0.5,wt);
double E(const int i=0) const
TH1F * fEDCosZ
direction cosine of outgoing e 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.
TH2F * fVertexYZ
vertex location in yz
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
double Q2(const Interaction *const i)
void SetOrigin(simb::Origin_t origin)
TH1F * fCCMode
CC interaction mode.
const simb::MCParticle & Nu() const
TH2F * fVertexXY
vertex location in xy
std::string ReactionChannel(int ccnc, int mode)
double Px(const int i=0) const
A module to check the results from the Monte Carlo generator.
TH1F * fWeightNW
NuWro Wt.
void beginRun(art::Run &run)
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
std::string ParticleStatus(int StatusCode)
art framework interface to geometry description
TH1F * fDCosX
direction cosine in x
TH1F * fGenerated[6]
Spectra as generated.
void produce(art::Event &evt)
std::string fNuWroModuleLabel
keep track of how long it takes to run the job
TH2F * fVertexXZ
vertex location in xz
TH1F * fNCMode
CC interaction mode.
TH1F * fEDCosY
direction cosine of outgoing e in y
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)
virtual void reconfigure(fhicl::ParameterSet const &pset)
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
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.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
CodeOutputInterface * code
TH1F * fVertexY
vertex location of generated events in y
TH1F * fVertexZ
vertex location of generated events in z
Base utilities and modules for event generation and detector simulation.
Q_EXPORT QTSManip setw(int w)
const simb::MCParticle & GetParticle(int i) const
std::ifstream * fEventFile
TH1F * fDCosY
direction cosine in y
double Vx(const int i=0) const
TH1F * fECons
histogram to determine if energy is conserved in the event
TH1F * fEDCosX
direction cosine of outgoing e in x
void Add(simb::MCParticle const &part)
void FillHistograms(const simb::MCTruth &mc)
TH1F * fDCosZ
direction cosine in z
void line(double t, double *p, double &x, double &y, double &z)
double Pz(const int i=0) const
QTextStream & bin(QTextStream &s)
double Vz(const int i=0) const
std::vector< double > fxsecFluxWtd
TH1F * fMuDCosX
direction cosine of outgoing mu in x
TH1F * fDyn
mode in detail
TH1F * fMuDCosY
direction cosine of outgoing mu in y
TH1F * fEMomentum
momentum of outgoing electrons
Event generator information.
Event generator information.
LArSoft geometry interface.
Event Generation using GENIE, cosmics or single particles.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
TH1F * fMuMomentum
momentum of outgoing muons
TH1F * fVertexX
vertex location of generated events in x
double Vy(const int i=0) const
QTextStream & endl(QTextStream &s)
TH1F * fMuDCosZ
direction cosine of outgoing mu in z
void reconfigure(fhicl::ParameterSet const &p)