7 namespace single_photon
14 std::vector<int> spacers =
Printer_header({
"#MCP",
" pdg",
" Status",
" trkID",
" Mother",
" Process",
" Process_End",
" Energy",
" Vertex(x, ",
" y, ",
" z )"});
15 for(
size_t j=0;j< mcParticleVector.size();j++){
17 const art::Ptr<simb::MCParticle> mcp = mcParticleVector[j];
62 art::Handle< std::vector<simb::MCFlux> > mcFluxHandle;
63 e.getByLabel(
"generator", mcFluxHandle);
64 if (!mcFluxHandle.isValid())
return;
65 std::vector< art::Ptr<simb::MCFlux> > mcFluxVec;
66 art::fill_ptr_vector(mcFluxVec, mcFluxHandle);
67 if (mcFluxVec.size() == 0){
68 std::cout <<
">> No MCFlux information" << std::endl;
72 art::Handle< std::vector<simb::MCTruth> > mcTruthHandle;
73 e.getByLabel(
"generator", mcTruthHandle);
74 if (!mcTruthHandle.isValid())
return;
75 std::vector< art::Ptr<simb::MCTruth> > mcTruthVec;
76 art::fill_ptr_vector(mcTruthVec, mcTruthHandle);
77 if (mcTruthVec.size() == 0){
78 std::cout <<
">> No MCTruth information" << std::endl;
82 art::Handle< std::vector< simb::GTruth > > gTruthHandle;
83 e.getByLabel(
"generator", gTruthHandle);
84 if (!gTruthHandle.isValid())
return;
85 std::vector< art::Ptr<simb::GTruth> > gTruthVec;
86 art::fill_ptr_vector(gTruthVec, gTruthHandle);
87 if (gTruthVec.size() == 0){
88 std::cout <<
">> No GTruth information" << std::endl;
92 const art::Ptr<simb::MCFlux> mcFlux = mcFluxVec.at(0);
93 const art::Ptr<simb::MCTruth> mcTruth = mcTruthVec.at(0);
94 const simb::MCParticle&
nu = mcTruth->GetNeutrino().Nu();
95 const art::Ptr<simb::GTruth> gTruth = gTruthVec.at(0);
129 const simb::MCParticle& mcParticle = mcTruth->GetParticle(i);
139 const simb::MCParticle& daughterMcParticle = mcTruth->GetParticle(j);
158 const simb::MCNeutrino& mcNeutrino = mcTruth->GetNeutrino();
226 std::cout<<
"SinglePhoton::AnalyzeEventWeight-eventweight_tree filled"<<std::endl;
254 std::vector<PandoraPFParticle> all_PPFPs,
255 std::map<
int, art::Ptr<simb::MCParticle>> & MCParticleToTrackIDMap,
256 std::map<art::Ptr<recob::Shower>, art::Ptr<simb::MCParticle> > & showerToMCParticleMap,
257 std::map<art::Ptr<recob::Track>, art::Ptr<simb::MCParticle> > &trackToMCParticleMap,
261 for(
size_t index=0; index< all_PPFPs.size(); ++index){
271 if(signal_def ==
"ncdelta"){
275 std::vector<int> matched_shower_ids;
282 if(parent == -1 && pdg ==22){
291 if (std::find(matched_shower_ids.begin(), matched_shower_ids.end(), matched_shower_id) == matched_shower_ids.end()){
292 matched_shower_ids.push_back(matched_shower_id);
318 std::vector<int> matched_track_ids;
326 if((parent == -1 ||parent == 12 || parent ==14 ) && pdg == 2212){
330 if (std::find(matched_track_ids.begin(), matched_track_ids.end(), matched_track_id) == matched_track_ids.end()){
331 matched_track_ids.push_back(matched_track_id);
380 std::map<int,std::string> is_delta_map = {
385 {-2224,
"Anti-Delta++"},
386 {-2214,
"Anti-Delta+"},
387 {-1114,
"Anti-Delta-"},
388 {-2114,
"Anti-Delta0"}};
393 std::cout<<
"AnalyzeMCTruths()\t||\t WARNING There is more than 1 MCTruth neutrino interaction. Just running over the first simb::MCTruth."<<std::endl;
395 std::cout<<
"AnalyzeMCTruths()\t||\t WARNING There is 0 MCTruth neutrino interaction. Break simb::MCTruth."<<std::endl;
401 std::vector<int> spacers =
Printer_header({
" NuPdg",
" CC=0",
" TruthVertex(x,",
" y, ",
", z )"});
403 const art::Ptr<simb::MCTruth> truth = mcTruthVector[i];
409 if(!truth->NeutrinoSet()){
431 std::vector<double> corrected(3);
457 std::vector<int> spacers =
Printer_header({
" pdg",
" TrkID",
" MotherID",
" Status",
" Energy"});
463 int tmp_n_photons_from_delta = 0;
464 int tmp_n_protons_from_delta = 0;
465 int tmp_n_neutrons_from_delta = 0;
472 const simb::MCParticle par = truth->GetParticle(j);
498 if(par.StatusCode() == 1){
510 if((par.StatusCode()==1 || par.StatusCode()==14 )){
511 const simb::MCParticle mother = truth->GetParticle(par.Mother());
513 if(is_delta_map.count(mother.PdgCode())>0 && mother.StatusCode()==3){
515 tmp_n_photons_from_delta ++;
524 if (par.StatusCode() == 1) {
536 if (par.StatusCode() == 1) {
542 if(par.StatusCode() == 1){
557 if(par.StatusCode()==14 ){
559 const simb::MCParticle mother = truth->GetParticle(par.Mother());
560 if(is_delta_map.count(mother.PdgCode())>0 && mother.StatusCode()==3){
562 tmp_n_protons_from_delta ++;
583 if(par.StatusCode()==14){
584 const simb::MCParticle mother = truth->GetParticle(par.Mother());
585 if(is_delta_map.count(mother.PdgCode())>0 && mother.StatusCode()==3){
587 tmp_n_neutrons_from_delta ++;
605 if(par.StatusCode() == 1){
635 std::cout<<
"AnalyzeMCTruths()\t||\t This event is ";
636 if(tmp_n_photons_from_delta==1 && tmp_n_protons_from_delta==1){
638 std::cout<<
"a 1g1p delta radiative event"<<std::endl;
639 }
else if(tmp_n_photons_from_delta==1 && tmp_n_neutrons_from_delta==1){
641 std::cout<<
"a 1g1n delta radiative event"<<std::endl;
643 std::cout<<
"NOT a 1g1p or 1g1n delta radiative decay"<<std::endl;;
708 simb::MCParticle nth_mother = mother;
709 int n_generation = 2;
713 while(nth_mother.StatusCode() != 0 || n_generation < 4){
715 if(nth_mother.Mother()<0)
break;
716 nth_mother = truth->GetParticle(nth_mother.Mother());
717 std::cout<<
"AnalyzeMCTruths()\t||\t ---- and "<<n_generation<<
"-mother "<<nth_mother.PdgCode()<<
" ("<<nth_mother.TrackId()<<
") and status_code "<<nth_mother.StatusCode()<<std::endl;
718 if( is_delta_map.count(nth_mother.PdgCode())>0 && nth_mother.StatusCode()==3){
719 std::cout<<
"AnalyzeMCTruths()\t||\t ------ Defintely From a Delta Decay! : "<<is_delta_map[nth_mother.PdgCode()]<<std::endl;
734 simb::MCParticle nth_mother = mother;
735 int n_generation = 2;
737 while(nth_mother.StatusCode() != 0 && n_generation < 4){
738 if(nth_mother.Mother()<0)
break;
739 nth_mother = truth->GetParticle(nth_mother.Mother());
740 if(
g_is_verbose)
std::cout<<
"AnalyzeMCTruths()\t||\t ---- and "<<n_generation<<
"-mother "<<nth_mother.PdgCode()<<
" ("<<nth_mother.TrackId()<<
") and status_code "<<nth_mother.StatusCode()<<std::endl;
741 if(is_delta_map.count(nth_mother.PdgCode())>0 && nth_mother.StatusCode()==3){
742 if(
g_is_verbose)
std::cout<<
"AnalyzeMCTruths()\t||\t ------ Defintely From a Delta Decay! : "<<is_delta_map[nth_mother.PdgCode()]<<std::endl;
760 std::map<size_t,size_t> mymap;
761 for(
size_t k = 0;
k < mcParticleVector.size();
k++){
762 const art::Ptr<simb::MCParticle> mcp = mcParticleVector[
k];
763 mymap[mcp->TrackId()] =
k;
769 for(
size_t k = 0;
k < mcParticleVector.size();
k++){
770 const art::Ptr<simb::MCParticle> mcp = mcParticleVector[
k];
772 if(
false)
std::cout <<
k <<
" Mother:"<< mcp->Mother() <<
" pdgcode: " << mcp->PdgCode() <<
" trkid: " << mcp->TrackId() <<
" statuscode: " << mcp->StatusCode() << std::endl;
775 if(mcp->PdgCode() == 111 && mcp->Mother() == 0 && mcp->NumberDaughters()==2 ){
778 const art::Ptr<simb::MCParticle> dau1 = mcParticleVector[mymap[mcp->Daughter(0)]];
779 const art::Ptr<simb::MCParticle> dau2 = mcParticleVector[mymap[mcp->Daughter(1)]];
781 if(
false)
std::cout<<
"On Dau1: "<<
" Mother:"<< dau1->Mother()<<
" pdgcode: "<<dau1->PdgCode()<<
" trkid: "<<dau1->TrackId()<<
" statuscode: "<<dau1->StatusCode()<<std::endl;
782 if(
false)
std::cout<<
"On Dau2: "<<
" Mother:"<< dau2->Mother()<<
" pdgcode: "<<dau2->PdgCode()<<
" trkid: "<<dau2->TrackId()<<
" statuscode: "<<dau2->StatusCode()<<std::endl;
784 double e1 = dau1->E();
785 double e2 = dau2->E();
787 std::vector<double> raw_1_End ={dau1->EndX(), dau1->EndY(), dau1->EndZ()};
788 std::vector<double> raw_1_Start ={dau1->Vx(), dau1->Vy(), dau1->Vz()};
790 std::vector<double> raw_2_End ={dau2->EndX(), dau2->EndY(), dau2->EndZ()};
791 std::vector<double> raw_2_Start ={dau2->Vx(), dau2->Vy(), dau2->Vz()};
793 std::vector<double> corrected_1_start(3), corrected_2_start(3);
794 std::vector<double> corrected_1_end(3), corrected_2_end(3);
802 for(
int p1=0;
p1<dau1->NumberDaughters();
p1++){
803 auto dd = mcParticleVector[mymap[dau1->Daughter(
p1)]];
804 std::cout<<
"Post1 "<<dd->PdgCode()<<
" "<<dd->TrackId()<<
" "<<dd->StatusCode()<<
" "<<dd->EndProcess()<<std::endl;
807 for(
int p1=0;
p1<dau2->NumberDaughters();
p1++){
808 auto dd = mcParticleVector[mymap[dau2->Daughter(
p1)]];
809 std::cout<<
"Post2 "<<dd->PdgCode()<<
" "<<dd->TrackId()<<
" "<<dd->StatusCode()<<
" "<<dd->EndProcess()<<
" "<<dd->E()<<std::endl;
849 if(npi0check>1)
std::cout<<
"WARNING WARNING!!!! there are "<<npi0check<<
" Pi0's in this event in geant4 that come from the nucleas"<<std::endl;
std::vector< bool > m_matched_signal_track_is_clearcosmic
double m_gtruth_fs_had_syst_p4_z
int m_subrun_number_eventweight
std::vector< double > m_mctruth_daughters_time
std::vector< double > m_mctruth_exiting_photon_pz
std::vector< double > m_mctruth_exiting_pi0_py
std::vector< int > m_mctruth_daughters_status_code
const bool get_IsNuSlice() const
std::vector< int > m_mctruth_daughters_pdg
double m_mctruth_lepton_E
double m_mctruth_particles_polx[100]
double m_mctruth_particles_e0[100]
std::vector< int > m_reco_slice_num_showers
std::vector< double > m_reco_shower_nuscore
int m_mctruth_num_exiting_delta0
std::vector< double > m_mctruth_pi0_leading_photon_mom
std::vector< int > m_mctruth_exiting_photon_from_delta_decay
int m_mctruth_delta_radiative_1g1p_or_1g1n
std::vector< bool > m_reco_shower_isclearcosmic
const int get_HasTrack() const
double m_gtruth_hit_nuc_p4_z
std::vector< double > m_geant4_px
double m_mctruth_particles_py0[100]
std::vector< int > m_mctruth_exiting_proton_trackID
double m_gtruth_hit_nuc_p4_E
void AnalyzeEventWeight(art::Event const &e, var_all &vars)
std::vector< double > m_mctruth_daughters_endz
std::vector< double > m_geant4_dz
int m_mctruth_particles_status_code[100]
std::vector< int > m_geant4_statuscode
double m_mctruth_leading_exiting_proton_energy
std::vector< double > m_matched_signal_shower_overlay_fraction
int m_gtruth_charm_hadron_pdg
std::vector< double > m_mctruth_pi0_subleading_photon_end
double m_mctruth_particles_pz0[100]
double m_mctruth_nu_vertex_y
int m_mctruth_pi0_subleading_photon_exiting_TPC
bool m_reco_1g1p_is_multiple_slices
int m_mctruth_is_delta_radiative
double m_gtruth_fs_had_syst_p4_y
std::vector< double > m_mctruth_exiting_photon_energy
bool m_multiple_matched_tracks
int m_mctruth_num_exiting_deltapp
std::vector< double > m_geant4_dy
int m_mctruth_neutrino_ccnc
double m_mctruth_reco_vertex_dist
std::vector< double > m_mctruth_exiting_pi0_pz
double m_mctruth_particles_poly[100]
std::vector< double > m_mctruth_exiting_proton_pz
double m_mctruth_neutrino_w
std::vector< int > m_mctruth_daughters_mother_trackID
double m_gtruth_probe_p4_E
double m_mctruth_particles_Gvt[100]
int m_mctruth_neutrino_interaction_type
std::vector< int > m_matched_signal_track_showers_in_slice
std::vector< double > m_mctruth_exiting_neutron_py
std::vector< double > m_sim_track_energy
std::vector< double > m_mctruth_exiting_pi0_mom
std::vector< int > m_sim_track_parent_pdg
std::vector< double > m_mctruth_exiting_proton_energy
double m_mctruth_particles_px0[100]
int m_mctruth_neutrino_mode
double m_mctruth_delta_photon_energy
double m_gtruth_probe_p4_x
bool m_multiple_matched_showers
std::vector< int > m_sim_track_trackID
void AnalyzeGeant4(const std::vector< art::Ptr< simb::MCParticle >> &mcParticleVector, var_all &vars)
std::vector< double > m_mctruth_daughters_startz
std::vector< int > m_mctruth_exiting_neutron_trackID
std::vector< bool > m_reco_shower_is_nuslice
std::vector< double > m_mctruth_pi0_subleading_photon_mom
int m_mctruth_neutrino_quark
int m_mctruth_neutrino_nucleon
std::vector< int > m_mctruth_exiting_neutron_mother_trackID
std::vector< int > m_matched_signal_shower_tracks_in_slice
std::vector< double > m_geant4_vx
int m_mctruth_pi0_leading_photon_exiting_TPC
int m_mctruth_num_exiting_photons
std::vector< double > m_mctruth_exiting_proton_py
std::vector< double > m_mctruth_exiting_photon_py
double m_gtruth_hit_nuc_pos
bool m_mctruth_is_reconstructable_1g1p
double m_mctruth_particles_Gvz[100]
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< int > m_mctruth_exiting_proton_mother_trackID
int m_mctruth_num_daughter_particles
std::vector< double > m_geant4_py
double s_exiting_photon_energy_threshold
std::vector< double > m_geant4_vy
std::vector< double > m_matched_signal_track_nuscore
std::vector< bool > m_reco_track_is_nuslice
bool m_no_matched_showers
std::vector< double > m_mctruth_daughters_pz
std::vector< int > m_mctruth_exiting_proton_from_delta_decay
std::vector< std::string > m_geant4_process
std::vector< bool > m_matched_signal_shower_is_nuslice
std::vector< int > m_mctruth_exiting_delta0_num_daughters
int m_mctruth_num_exiting_deltapm
std::vector< int > Printer_header(std::vector< std::string > headings)
std::vector< int > m_reco_track_sliceId
double m_gtruth_hit_nuc_p4_y
std::vector< double > m_mctruth_daughters_py
std::vector< int > m_matched_signal_track_tracks_in_slice
double m_mctruth_nu_vertex_x
std::vector< double > m_reco_shower_energy_max
std::vector< int > m_matched_signal_shower_showers_in_slice
std::vector< double > m_sim_shower_energy
std::vector< int > m_sim_shower_matched
std::vector< double > m_geant4_dx
double m_mctruth_particles_Gvx[100]
std::vector< double > m_reco_track_nuscore
double m_gtruth_fs_had_syst_p4_E
double m_mctruth_pi0_subleading_photon_energy
int m_mctruth_particles_daughters[100][100]
double m_mctruth_delta_proton_energy
std::vector< double > m_mctruth_exiting_proton_px
std::vector< double > m_mctruth_pi0_subleading_photon_start
std::vector< double > m_mctruth_daughters_endx
double m_gtruth_probe_p4_z
std::vector< double > m_geant4_pz
std::vector< double > m_geant4_vz
double m_gtruth_hit_nuc_p4_x
std::vector< std::string > m_mctruth_daughters_process
std::vector< int > m_sim_track_pdg
int m_gtruth_strange_hadron_pdg
std::vector< int > m_reco_shower_sliceId
double m_mctruth_neutrino_qsqr
bool isInTPCActive(std::vector< double > &vec, para_all ¶s)
std::vector< int > m_reco_slice_num_pfps
int m_mctruth_num_reconstructable_protons
int spacecharge_correction(const art::Ptr< simb::MCParticle > &mcparticle, std::vector< double > &corrected, std::vector< double > &input)
std::vector< double > m_geant4_E
int m_mctruth_interaction_type
double s_exiting_proton_energy_threshold
std::vector< double > m_mctruth_exiting_neutron_energy
double m_mctruth_particles_Gvy[100]
int m_mctruth_particles_mother[100]
std::vector< double > m_sim_shower_overlay_fraction
const int get_SliceID() const
double m_reco_1g1p_nuscore
double m_mctruth_neutrino_y
std::vector< int > m_matched_signal_shower_sliceId
std::vector< bool > m_matched_signal_track_is_nuslice
int m_gtruth_gphase_space
std::vector< int > m_sim_shower_trackID
std::vector< double > m_mctruth_exiting_pi0_px
std::vector< double > m_mctruth_daughters_endy
std::vector< double > m_mctruth_pi0_leading_photon_start
int m_mctruth_particles_rescatter[100]
int m_mctruth_num_exiting_neutrons
std::vector< std::string > m_geant4_end_process
std::vector< double > m_matched_signal_shower_true_E
std::vector< double > m_mctruth_exiting_pi0_E
int m_mctruth_particles_pdg_code[100]
int m_mctruth_num_exiting_protons
bool m_reco_1g0p_is_nuslice
std::string m_mctruth_pi0_leading_photon_end_process
std::vector< int > m_sim_shower_parent_pdg
std::vector< bool > m_reco_track_isclearcosmic
int m_mctruth_particles_track_Id[100]
void Printer_content(std::vector< std::string > nums, std::vector< int > spacers)
int m_mctruth_num_exiting_pipm
double m_gtruth_probe_p4_y
std::string to_string(WindowPattern const &pattern)
std::vector< std::string > m_mctruth_daughters_end_process
int m_mctruth_num_exiting_pi0
bool m_reco_1g1p_is_nuslice
std::vector< double > m_mctruth_exiting_neutron_px
std::vector< int > m_matched_signal_track_sliceId
std::string m_mctruth_pi0_subleading_photon_end_process
double m_mctruth_pi0_leading_photon_energy
int m_mctruth_particles_num_daughters[100]
std::vector< int > m_sim_track_matched
double m_gtruth_fs_had_syst_p4_x
std::vector< int > m_mctruth_exiting_photon_mother_trackID
std::vector< double > m_geant4_mass
std::vector< int > m_sim_shower_pdg
std::vector< double > m_mctruth_daughters_E
std::vector< double > m_mctruth_daughters_starty
const int get_HasShower() const
std::vector< bool > m_matched_signal_shower_is_clearcosmic
bool m_gtruth_is_sea_quark
std::vector< double > m_matched_signal_shower_nuscore
std::vector< double > m_mctruth_daughters_startx
std::vector< int > m_geant4_pdg
bool m_reco_1g1p_is_same_slice
std::vector< double > m_mctruth_exiting_photon_px
int m_run_number_eventweight
std::vector< int > m_reco_slice_num_tracks
double m_gtruth_diff_xsec
std::vector< int > m_geant4_mother
std::vector< double > m_geant4_costheta
std::vector< double > m_mctruth_daughters_px
std::vector< int > m_mctruth_daughters_trackID
std::vector< double > m_mctruth_daughters_endtime
double m_mctruth_neutrino_x
double m_gtruth_probability
double m_mctruth_particles_polz[100]
double m_reco_1g0p_nuscore
double m_mctruth_delta_neutron_energy
std::vector< int > m_mctruth_exiting_photon_trackID
void AnalyzeMCTruths(std::vector< art::Ptr< simb::MCTruth >> &mcTruthVector, std::vector< art::Ptr< simb::MCParticle >> &mcParticleVector, var_all &vars, para_all ¶s)
std::vector< double > m_mctruth_exiting_neutron_pz
void AnalyzeRecoMCSlices(std::string signal_def, std::vector< PandoraPFParticle > all_PPFPs, std::map< int, art::Ptr< simb::MCParticle >> &MCParticleToTrackIDMap, std::map< art::Ptr< recob::Shower >, art::Ptr< simb::MCParticle > > &showerToMCParticleMap, std::map< art::Ptr< recob::Track >, art::Ptr< simb::MCParticle > > &trackToMCParticleMap, var_all &vars, para_all ¶s)
bool m_mctruth_is_reconstructable_1g0p
std::vector< int > m_geant4_trackid
physics associatedGroupsWithLeft p1
BEGIN_PROLOG could also be cout
double m_mctruth_nu_vertex_z
std::vector< double > m_matched_signal_track_true_E
std::vector< double > m_mctruth_pi0_leading_photon_end
int m_mctruth_neutrino_target
int m_matched_signal_shower_num
int m_event_number_eventweight
int m_matched_signal_track_num