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

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

Public Member Functions

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

Protected Member Functions

float InitTMVA () const
 

Detailed Description

Definition at line 18 of file NDXSecBPFMuonPID.h.

Constructor & Destructor Documentation

ana::GetBPFMuonID::GetBPFMuonID ( )
inline

Definition at line 20 of file NDXSecBPFMuonPID.h.

References InitTMVA(), operator()(), and sr.

20 {}

Member Function Documentation

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

Definition at line 122 of file NDXSecBPFMuonPID.cxx.

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

Referenced by ana::GetBestBPFTrack::GetBestBPFTrack(), GetBPFMuonID(), operator()(), and ana::GetBestBPFTrack::operator()().

123  {
124  if(!fReaderBDT) fReaderBDT = new TMVA::Reader( "!Color:!Silent" );
125  // const char* path = getenv("SRT_PUBLIC_CONTEXT");
126  const char* path = getenv("SRT_PRIVATE_CONTEXT");
127  std::string pidlib = std::string(path) + "/NDAna/numucc_0Pi/BPF_MuonID_BDTG.weights.xml";
128 
129  fReaderBDT->AddVariable("DedxLL", &TMVAvars[0]);
130  fReaderBDT->AddVariable("Chi2Scat", &TMVAvars[1]);
131  fReaderBDT->AddVariable("Avededxlast10cm", &TMVAvars[2]);
132  fReaderBDT->AddVariable("Avededxlast40cm", &TMVAvars[3]);
133  fReaderBDT->AddSpectator("HitRatio", &TMVAvars[4]);
134  fReaderBDT->BookMVA("BDTG_1k", pidlib);
135  return -5.0f;
136  }
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::GetBPFMuonID::operator() ( const caf::SRProxy sr) const

Definition at line 11 of file NDXSecBPFMuonPID.cxx.

References abs(), make_root_from_grid_output::dedxll, caf::Proxy< caf::SRVertexBranch >::elastic, caf::Proxy< caf::SRElastic >::fuzzyk, 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.

Referenced by ana::GetBestBPFTrack::GetBestBPFTrack(), and GetBPFMuonID().

11  {
12 
13  float heighstpid = -2.0;
14  float bdtvalue = -2.0;
15 
16  if(!fReaderBDT) InitTMVA();
17  float dedxll = -999.0;
18  float chi2scat = -999.0;
19  float fAvededxlast10cm = -999.0;
20  float fAvededxlast40cm = -999.0;
21  float fHitRatio = -999.0;
22 
23  if(sr->vtx.elastic.size() == 0)return heighstpid;
24 
25  int npngs = sr->vtx.elastic[0].fuzzyk.png.size();
26 
27  for(int p = 0; p < npngs; p++){
28  auto &pbpf = sr->vtx.elastic[0].fuzzyk.png[p].bpf;
29  for(unsigned int k = 0; k < pbpf.size(); k++){
30  if(abs(pbpf[k].pdg) != 13) continue;
31 
32  dedxll = pbpf[k].dEdXLL;
33  chi2scat = pbpf[k].chi2Scat;
34  if (pbpf[k].avedEdxlast10cm == -5) continue;
35  if (pbpf[k].avedEdxlast40cm == -5) continue;
36  fAvededxlast10cm = pbpf[k].avedEdxlast10cm;
37  fAvededxlast40cm = pbpf[k].avedEdxlast40cm;
38  fHitRatio = pbpf[k].hitRatio;
39 
40  //Check for any nan or inf:
41  bool is_inf = (isinf(dedxll)!=0) || (isinf(chi2scat)!=0) || (isinf(fAvededxlast10cm)!=0) || (isinf(fAvededxlast40cm)!=0);
42  bool is_nan = (dedxll != dedxll) || (chi2scat != chi2scat) || (fAvededxlast10cm != fAvededxlast10cm) ||
43  (fAvededxlast40cm != fAvededxlast40cm);
44  if(is_nan || is_inf) continue;
45 
46  TMVAvars[0] = dedxll;
47  TMVAvars[1] = chi2scat;
48  TMVAvars[2] = fAvededxlast10cm;
49  TMVAvars[3] = fAvededxlast40cm;
50  TMVAvars[4] = fHitRatio;
51 
52  if(!fReaderBDT) InitTMVA();
53  bdtvalue = fReaderBDT->EvaluateMVA("BDTG_1k");
54 
55  if (bdtvalue > heighstpid){
56  heighstpid = bdtvalue;
57  }
58  else continue;
59 
60  } //end loop on bpfs
61  }//end loop prongs
62 
63 
64  return heighstpid;
65  }
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)
float InitTMVA() const
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: