PngCVNVars.h
Go to the documentation of this file.
1 #pragma once
2 
3 // Vars Specific to the nue analysis go here.
4 #include "CAFAna/Core/Var.h"
5 #include "CAFAna/Core/MultiVar.h"
6 
8 
9 namespace ana
10 {
11 
12  int PDG_cvnmax(std::map<int,double> ScorePDGmap){
13  double val_max = 0;
14  unsigned int currentPDG = 0;
15  for(auto it = ScorePDGmap.cbegin(); it != ScorePDGmap.cend(); ++it ) {
16  if (it ->second > val_max) {
17  currentPDG = it->first;
18  val_max = it->second;
19  }
20  }
21  return currentPDG;
22  }
23 
24  // --------------------------------------------------------
25  // PID Usage Functions
26  // --------------------------------------------------------
27 
28  const int kElectronPDG = 11;
29  const int kMuonPDG = 13;
30  const int kGammaPDG = 22;
31  const int kPizeroPDG = 111;
32  const int kPionPDG = 211;
33  const int kProtonPDG = 2212;
34 
35  // Bins for clasification matrix
36  const std::map<int,int> CMbinPDG =
37  {{11, 0},
38  {22, 1},
39  {13, 2},
40  {211, 3},
41  {2212, 4},
42  {0, 5}//other
43  };
44 
45  // --------------------------------------------------------
46  // Simple PID & truth
47  // --------------------------------------------------------
48 
49  // Prong CVN ID where ID = max score
50  extern const MultiVar kPid_cvnmax;
51 
52  // True Prong PDG
53  extern const MultiVar kPid_true;
54 
55  // --------------------------------------------------------
56  // Bins for classification matrix
57  // --------------------------------------------------------
58 
59 
60  // Prong CVN ID bin for matrix where ID = max score
61  extern const MultiVar kPid_cvnmax_bin;
62 
63  // True Prong PDG bin for matrix
64  extern const MultiVar kPid_true_bin;
65 
66 
67  // --------------------------------------------------------
68  // CVN Score for each category
69  // --------------------------------------------------------
70  struct CVNPng
71  {
72  CVNPng(int ret): fRet(ret) {}
73 
74  std::vector<double> operator()(const caf::SRProxy* sr) const;
75 
76  double CVN(const caf::SRCVNParticleResultProxy& cvn) const;
77 
78  int fRet;
79  };
80 
81  const MultiVar kPcvn_el(CVNPng(kElectronPDG));
82  const MultiVar kPcvn_mu(CVNPng(kMuonPDG ));
83  const MultiVar kPcvn_pr(CVNPng(kProtonPDG ));
84  const MultiVar kPcvn_pi(CVNPng(kPionPDG ));
85  const MultiVar kPcvn_ga(CVNPng(kGammaPDG ));
86  const MultiVar kPcvn_ot(CVNPng(0 ));
87 
88  // --------------------------------------------------------
89  // CVN Scores with truth selections
90  // --------------------------------------------------------
91 
92  struct CVNPngTruthSel: public CVNPng
93  {
94  CVNPngTruthSel(int sel, int ret): CVNPng(ret), fSel(sel) {}
95 
96  std::vector<double> operator()(const caf::SRProxy* sr) const;
97 
98  int PDG(const caf::SRParticleTruthProxy& truth) const;
99 
100  int fSel;
101  };
102 
103  const MultiVar kPcvn_el_mc_el(CVNPngTruthSel(kElectronPDG, kElectronPDG));
104  const MultiVar kPcvn_mu_mc_el(CVNPngTruthSel(kElectronPDG, kMuonPDG ));
105  const MultiVar kPcvn_pr_mc_el(CVNPngTruthSel(kElectronPDG, kProtonPDG ));
106  const MultiVar kPcvn_pi_mc_el(CVNPngTruthSel(kElectronPDG, kPionPDG ));
107  const MultiVar kPcvn_ga_mc_el(CVNPngTruthSel(kElectronPDG, kGammaPDG ));
108  const MultiVar kPcvn_ot_mc_el(CVNPngTruthSel(kElectronPDG, 0 ));
109 
110  const MultiVar kPcvn_el_mc_mu(CVNPngTruthSel(kMuonPDG, kElectronPDG));
111  const MultiVar kPcvn_mu_mc_mu(CVNPngTruthSel(kMuonPDG, kMuonPDG ));
112  const MultiVar kPcvn_pr_mc_mu(CVNPngTruthSel(kMuonPDG, kProtonPDG ));
113  const MultiVar kPcvn_pi_mc_mu(CVNPngTruthSel(kMuonPDG, kPionPDG ));
114  const MultiVar kPcvn_ga_mc_mu(CVNPngTruthSel(kMuonPDG, kGammaPDG ));
115  const MultiVar kPcvn_ot_mc_mu(CVNPngTruthSel(kMuonPDG, 0 ));
116 
117  const MultiVar kPcvn_el_mc_pr(CVNPngTruthSel(kProtonPDG, kElectronPDG));
118  const MultiVar kPcvn_mu_mc_pr(CVNPngTruthSel(kProtonPDG, kMuonPDG ));
119  const MultiVar kPcvn_pr_mc_pr(CVNPngTruthSel(kProtonPDG, kProtonPDG ));
120  const MultiVar kPcvn_pi_mc_pr(CVNPngTruthSel(kProtonPDG, kPionPDG ));
121  const MultiVar kPcvn_ga_mc_pr(CVNPngTruthSel(kProtonPDG, kGammaPDG ));
122  const MultiVar kPcvn_ot_mc_pr(CVNPngTruthSel(kProtonPDG, 0 ));
123 
124  const MultiVar kPcvn_el_mc_pi(CVNPngTruthSel(kPionPDG, kElectronPDG));
125  const MultiVar kPcvn_mu_mc_pi(CVNPngTruthSel(kPionPDG, kMuonPDG ));
126  const MultiVar kPcvn_pr_mc_pi(CVNPngTruthSel(kPionPDG, kProtonPDG ));
127  const MultiVar kPcvn_pi_mc_pi(CVNPngTruthSel(kPionPDG, kPionPDG ));
128  const MultiVar kPcvn_ga_mc_pi(CVNPngTruthSel(kPionPDG, kGammaPDG ));
129  const MultiVar kPcvn_ot_mc_pi(CVNPngTruthSel(kPionPDG, 0 ));
130 
131  const MultiVar kPcvn_el_mc_ga(CVNPngTruthSel(kGammaPDG, kElectronPDG));
132  const MultiVar kPcvn_mu_mc_ga(CVNPngTruthSel(kGammaPDG, kMuonPDG ));
133  const MultiVar kPcvn_pr_mc_ga(CVNPngTruthSel(kGammaPDG, kProtonPDG ));
134  const MultiVar kPcvn_pi_mc_ga(CVNPngTruthSel(kGammaPDG, kPionPDG ));
135  const MultiVar kPcvn_ga_mc_ga(CVNPngTruthSel(kGammaPDG, kGammaPDG ));
136  const MultiVar kPcvn_ot_mc_ga(CVNPngTruthSel(kGammaPDG, 0 ));
137 
138  const MultiVar kPcvn_el_mc_ot(CVNPngTruthSel(0, kElectronPDG));
139  const MultiVar kPcvn_mu_mc_ot(CVNPngTruthSel(0, kMuonPDG ));
140  const MultiVar kPcvn_pr_mc_ot(CVNPngTruthSel(0, kProtonPDG ));
141  const MultiVar kPcvn_pi_mc_ot(CVNPngTruthSel(0, kPionPDG ));
142  const MultiVar kPcvn_ga_mc_ot(CVNPngTruthSel(0, kGammaPDG ));
143  const MultiVar kPcvn_ot_mc_ot(CVNPngTruthSel(0, 0 ));
144 
145 } // namespace
const MultiVar kPcvn_ot_mc_el(CVNPngTruthSel(kElectronPDG, 0 ))
const MultiVar kPid_true_bin([](const caf::SRProxy *sr){std::vector< double > truepdgbin;for(unsigned int p=0;p< sr->vtx.elastic.fuzzyk.png.size();p++){auto &png=sr->vtx.elastic.fuzzyk.png[p];double thispdg=png.truth.pdg;if((int) png.truth.pdg!=kElectronPDG && (int) png.truth.pdg!=kMuonPDG && (int) png.truth.pdg!=kProtonPDG && (int) png.truth.pdg!=kPionPDG && (int) png.truth.pdg!=kGammaPDG) thispdg=0;truepdgbin.push_back((double) CMbinPDG.at(std::abs(thispdg)));}return truepdgbin;})
Definition: PngCVNVars.h:64
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const MultiVar kPcvn_ga_mc_mu(CVNPngTruthSel(kMuonPDG, kGammaPDG ))
const MultiVar kPcvn_el_mc_el(CVNPngTruthSel(kElectronPDG, kElectronPDG))
const MultiVar kPid_cvnmax([](const caf::SRProxy *sr){std::vector< double > pdg;for(unsigned int p=0;p< sr->vtx.elastic.fuzzyk.png.size();p++){auto &pcvn=sr->vtx.elastic.fuzzyk.png[p].cvnpart;std::map< int, double > valPDG;valPDG.emplace(kMuonPDG , pcvn.muonid);valPDG.emplace(kPizeroPDG, pcvn.pizeroid);valPDG.emplace(kPionPDG , pcvn.pionid);valPDG.emplace(kGammaPDG , pcvn.photonid);valPDG.emplace(kProtonPDG, pcvn.protonid);valPDG.emplace(kElectronPDG, pcvn.electronid);valPDG.emplace(0 , pcvn.otherid);pdg.push_back(PDG_cvnmax(valPDG));}return pdg;})
Definition: PngCVNVars.h:50
set< int >::iterator it
const MultiVar kPcvn_ot_mc_pi(CVNPngTruthSel(kPionPDG, 0 ))
const MultiVar kPcvn_ot_mc_mu(CVNPngTruthSel(kMuonPDG, 0 ))
const MultiVar kPcvn_pr(CVNPng(kProtonPDG))
const MultiVar kPcvn_mu_mc_mu(CVNPngTruthSel(kMuonPDG, kMuonPDG ))
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
const MultiVar kPcvn_pr_mc_pr(CVNPngTruthSel(kProtonPDG, kProtonPDG))
const MultiVar kPcvn_el_mc_pi(CVNPngTruthSel(kPionPDG, kElectronPDG))
const MultiVar kPcvn_mu_mc_ot(CVNPngTruthSel(0, kMuonPDG ))
const MultiVar kPcvn_el(CVNPng(kElectronPDG))
const int kPizeroPDG
Definition: PngCVNVars.h:31
const MultiVar kPcvn_ot_mc_ga(CVNPngTruthSel(kGammaPDG, 0 ))
Proxy for caf::SRParticleTruth.
Definition: SRProxy.h:622
const MultiVar kPcvn_ga_mc_ot(CVNPngTruthSel(0, kGammaPDG ))
const MultiVar kPcvn_el_mc_ga(CVNPngTruthSel(kGammaPDG, kElectronPDG))
Defines an enumeration for prong classification.
const MultiVar kPcvn_pr_mc_ot(CVNPngTruthSel(0, kProtonPDG))
std::vector< double > operator()(const caf::SRProxy *sr) const
Definition: PngCVNVars.cxx:93
const MultiVar kPcvn_el_mc_mu(CVNPngTruthSel(kMuonPDG, kElectronPDG))
const MultiVar kPcvn_ot_mc_pr(CVNPngTruthSel(kProtonPDG, 0 ))
const MultiVar kPcvn_ot(CVNPng(0 ))
const MultiVar kPcvn_mu_mc_pr(CVNPngTruthSel(kProtonPDG, kMuonPDG ))
double CVN(const caf::SRCVNParticleResultProxy &cvn) const
Definition: PngCVNVars.cxx:103
const MultiVar kPcvn_mu_mc_el(CVNPngTruthSel(kElectronPDG, kMuonPDG ))
const MultiVar kPcvn_el_mc_pr(CVNPngTruthSel(kProtonPDG, kElectronPDG))
const MultiVar kPcvn_mu(CVNPng(kMuonPDG ))
int PDG_cvnmax(std::map< int, double > ScorePDGmap)
Definition: PngCVNVars.h:12
const MultiVar kPcvn_mu_mc_ga(CVNPngTruthSel(kGammaPDG, kMuonPDG ))
const MultiVar kPcvn_pi(CVNPng(kPionPDG ))
const MultiVar kPcvn_ga_mc_ga(CVNPngTruthSel(kGammaPDG, kGammaPDG ))
const std::map< int, int > CMbinPDG
Definition: PngCVNVars.h:36
caf::StandardRecord * sr
const MultiVar kPcvn_ga_mc_pi(CVNPngTruthSel(kPionPDG, kGammaPDG ))
const MultiVar kPcvn_pi_mc_pr(CVNPngTruthSel(kProtonPDG, kPionPDG ))
const int kElectronPDG
Definition: PngCVNVars.h:28
const MultiVar kPcvn_ot_mc_ot(CVNPngTruthSel(0, 0 ))
const int kMuonPDG
Definition: PngCVNVars.h:29
const int kProtonPDG
Definition: PngCVNVars.h:33
const int kGammaPDG
Definition: PngCVNVars.h:30
const MultiVar kPid_true([](const caf::SRProxy *sr){std::vector< double > truepdg;for(unsigned int p=0;p< sr->vtx.elastic.fuzzyk.png.size();p++){auto &png=sr->vtx.elastic.fuzzyk.png[p];truepdg.push_back(png.truth.pdg);}return truepdg;})
Definition: PngCVNVars.h:53
const MultiVar kPcvn_ga_mc_pr(CVNPngTruthSel(kProtonPDG, kGammaPDG ))
const MultiVar kPcvn_mu_mc_pi(CVNPngTruthSel(kPionPDG, kMuonPDG ))
const MultiVar kPcvn_ga_mc_el(CVNPngTruthSel(kElectronPDG, kGammaPDG ))
const MultiVar kPcvn_pr_mc_el(CVNPngTruthSel(kElectronPDG, kProtonPDG))
const MultiVar kPcvn_ga(CVNPng(kGammaPDG ))
const MultiVar kPcvn_pi_mc_el(CVNPngTruthSel(kElectronPDG, kPionPDG ))
Proxy for caf::SRCVNParticleResult.
Definition: SRProxy.h:1843
const MultiVar kPcvn_pi_mc_mu(CVNPngTruthSel(kMuonPDG, kPionPDG ))
const MultiVar kPcvn_pr_mc_ga(CVNPngTruthSel(kGammaPDG, kProtonPDG))
const int kPionPDG
Definition: PngCVNVars.h:32
const MultiVar kPcvn_el_mc_ot(CVNPngTruthSel(0, kElectronPDG))
const MultiVar kPcvn_pr_mc_pi(CVNPngTruthSel(kPionPDG, kProtonPDG))
CVNPngTruthSel(int sel, int ret)
Definition: PngCVNVars.h:94
const MultiVar kPcvn_pi_mc_ot(CVNPngTruthSel(0, kPionPDG ))
const MultiVar kPcvn_pi_mc_ga(CVNPngTruthSel(kGammaPDG, kPionPDG ))
const MultiVar kPcvn_pi_mc_pi(CVNPngTruthSel(kPionPDG, kPionPDG ))
const MultiVar kPid_cvnmax_bin([](const caf::SRProxy *sr){std::vector< double > pdgbin;for(unsigned int p=0;p< sr->vtx.elastic.fuzzyk.png.size();p++){auto &pcvn=sr->vtx.elastic.fuzzyk.png[p].cvnpart;std::map< int, double > valPDG;valPDG.emplace(kMuonPDG , pcvn.muonid);valPDG.emplace(kPizeroPDG, pcvn.pizeroid);valPDG.emplace(kPionPDG , pcvn.pionid);valPDG.emplace(kGammaPDG , pcvn.photonid);valPDG.emplace(kProtonPDG, pcvn.protonid);valPDG.emplace(kElectronPDG, pcvn.electronid);valPDG.emplace(0 , pcvn.otherid);int thispdg=PDG_cvnmax(valPDG);pdgbin.push_back((double) CMbinPDG.at(thispdg));}return pdgbin;})
Definition: PngCVNVars.h:61
const MultiVar kPcvn_pr_mc_mu(CVNPngTruthSel(kMuonPDG, kProtonPDG))
CVNPng(int ret)
Definition: PngCVNVars.h:72