Public Member Functions | Protected Member Functions | List of all members
ana::GetBestBPFTrack Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/NDAna/numucc_0Pi/NDXSecBPFMuonPID.h"

Public Member Functions

 GetBestBPFTrack ()
 
float operator() (const caf::SRProxy *sr) const
 

Protected Member Functions

float InitTMVA () const
 

Detailed Description

Definition at line 26 of file NDXSecBPFMuonPID.h.

Constructor & Destructor Documentation

ana::GetBestBPFTrack::GetBestBPFTrack ( )
inline

Definition at line 28 of file NDXSecBPFMuonPID.h.

References ana::GetBPFMuonID::InitTMVA(), ana::GetBPFMuonID::operator()(), and sr.

28 {}

Member Function Documentation

float ana::GetBestBPFTrack::InitTMVA ( ) const
protected

Definition at line 138 of file NDXSecBPFMuonPID.cxx.

References cet::getenv(), path, and string.

139  {
140  if(!fReaderBDT) fReaderBDT = new TMVA::Reader( "!Color:!Silent" );
141  const char* path = getenv("SRT_PRIVATE_CONTEXT");
142  std::string pidlib = std::string(path) + "/NDAna/numucc_0Pi/BPF_MuonID_BDTG.weights.xml";
143 
144  fReaderBDT->AddVariable("DedxLL", &TMVAvars[0]);
145  fReaderBDT->AddVariable("Chi2Scat", &TMVAvars[1]);
146  fReaderBDT->AddVariable("Avededxlast10cm", &TMVAvars[2]);
147  fReaderBDT->AddVariable("Avededxlast40cm", &TMVAvars[3]);
148  fReaderBDT->AddSpectator("HitRatio", &TMVAvars[4]);
149 
150  fReaderBDT->BookMVA("BDTG_1k", pidlib);
151  return -5.0f;
152  }
static TMVA::Reader * fReaderBDT
Definition: NDNCPi0Xsec.cxx:11
std::string getenv(std::string const &name)
static float TMVAvars[4]
Definition: NDNCPi0Xsec.cxx:10
const std::string path
Definition: plot_BEN.C:43
enum BeamMode string
float ana::GetBestBPFTrack::operator() ( const caf::SRProxy sr) const

Definition at line 68 of file NDXSecBPFMuonPID.cxx.

References abs(), make_root_from_grid_output::dedxll, caf::Proxy< caf::SRVertexBranch >::elastic, caf::Proxy< caf::SRElastic >::fuzzyk, ana::GetBPFMuonID::InitTMVA(), stan::math::is_inf(), stan::math::is_nan(), std::isinf(), make_root_from_grid_output::pdg, caf::Proxy< caf::SRFuzzyK >::png, and caf::Proxy< caf::StandardRecord >::vtx.

68  {
69 
70  float heighstpid = -2.0;
71  int imax = -1; //this can be used as your prong index with highest PID score.
72  float bdtvalue = -2.0;
73 
74  if(!fReaderBDT) InitTMVA();
75  float dedxll = -999.0;
76  float chi2scat = -999.0;
77  float fAvededxlast10cm = -999.0;
78  float fAvededxlast40cm = -999.0;
79  float fHitRatio = -999.0;
80 
81  if(sr->vtx.elastic.size() == 0)return imax;
82 
83  for(unsigned int p = 0; p < sr->vtx.elastic[0].fuzzyk.png.size(); p++){
84  auto &pbpf = sr->vtx.elastic[0].fuzzyk.png[p].bpf;
85  for(unsigned int k = 0; k < pbpf.size(); k++){
86  if(abs(pbpf[k].pdg) != 13) continue;
87 
88  dedxll = pbpf[k].dEdXLL;
89  chi2scat = pbpf[k].chi2Scat;
90  if (pbpf[k].avedEdxlast10cm == -5) continue;
91  if (pbpf[k].avedEdxlast40cm == -5) continue;
92  fAvededxlast10cm = pbpf[k].avedEdxlast10cm;
93  fAvededxlast40cm = pbpf[k].avedEdxlast40cm;
94  fHitRatio = pbpf[k].hitRatio;
95 
96  bool is_inf = (isinf(dedxll)!=0) || (isinf(chi2scat)!=0) || (isinf(fAvededxlast10cm)!=0) || (isinf(fAvededxlast40cm)!=0);
97  bool is_nan = (dedxll != dedxll) || (chi2scat != chi2scat) || (fAvededxlast10cm != fAvededxlast10cm) ||
98  (fAvededxlast40cm != fAvededxlast40cm);
99  if(is_nan || is_inf) continue;
100 
101  TMVAvars[0] = dedxll;
102  TMVAvars[1] = chi2scat;
103  TMVAvars[2] = fAvededxlast10cm;
104  TMVAvars[3] = fAvededxlast40cm;
105  TMVAvars[4] = fHitRatio;
106 
107  if(!fReaderBDT) InitTMVA();
108 
109  bdtvalue = fReaderBDT->EvaluateMVA("BDTG_1k");
110  if (bdtvalue > heighstpid){
111  imax = p;
112  heighstpid = bdtvalue;
113  }
114  else continue;
115  }//end loop on bpfs
116  }//end loop prongs
117 
118  return imax;
119  }
int isinf(const stan::math::var &a)
Definition: std_isinf.hpp:16
static TMVA::Reader * fReaderBDT
Definition: NDNCPi0Xsec.cxx:11
caf::Proxy< caf::SRFuzzyK > fuzzyk
Definition: SRProxy.h:2059
const char * p
Definition: xmltok.h:285
void abs(TH1 *hist)
caf::Proxy< caf::SRElastic > elastic
Definition: SRProxy.h:2118
caf::Proxy< std::vector< caf::SRFuzzyKProng > > png
Definition: SRProxy.h:2043
static float TMVAvars[4]
Definition: NDNCPi0Xsec.cxx:10
int is_inf(const fvar< T > &x)
Definition: is_inf.hpp:19
int is_nan(const fvar< T > &x)
Definition: is_nan.hpp:19
caf::Proxy< caf::SRVertexBranch > vtx
Definition: SRProxy.h:2146

The documentation for this class was generated from the following files: