Enumerations | Functions | Variables
ana::muonid_classifier Namespace Reference

Enumerations

enum  EMuonIDReturnMode { kGetMuonID, kGetTrack }
 

Functions

float GetMuonIDSR (const caf::SRProxy *sr, const EMuonIDReturnMode return_mode)
 
float MuonID (const caf::SRProxy *sr)
 
float BestTrack (const caf::SRProxy *sr)
 
float InitTMVA ()
 
const Var kMuonID (muonid_classifier::MuonID)
 
const Var kBestMuonTrack (muonid_classifier::BestTrack)
 

Variables

float TMVAvars [4]
 
TMVA::Reader * readerBDT
 

Enumeration Type Documentation

Enumerator
kGetMuonID 
kGetTrack 

Definition at line 16 of file MuonID.h.

Function Documentation

float ana::muonid_classifier::BestTrack ( const caf::SRProxy sr)

Definition at line 56 of file MuonID.cxx.

References GetMuonIDSR(), and kGetTrack.

57  {
58  return ana::muonid_classifier::GetMuonIDSR(sr, ana::muonid_classifier::kGetTrack); // Check the MuonID and return highest scoring track
59  }
float GetMuonIDSR(const caf::SRProxy *sr, const EMuonIDReturnMode return_mode)
Definition: MuonID.cxx:13
float ana::muonid_classifier::GetMuonIDSR ( const caf::SRProxy sr,
const EMuonIDReturnMode  return_mode 
)

Definition at line 13 of file MuonID.cxx.

References make_root_from_grid_output::dedxll, InitTMVA(), caf::Proxy< caf::SRTrackBranch >::kalman, kGetTrack, min(), caf::Proxy< caf::SRKalman >::ntracks, make_root_from_grid_output::scatll, caf::Proxy< caf::SRKalman >::tracks, and caf::Proxy< caf::StandardRecord >::trk.

Referenced by BestTrack(), and MuonID().

14  {
15  if(!readerBDT) InitTMVA();
16 
17  float best_track = -999.0;
18  float muonid = -999.0;
19 
20  float dedxll = -999.0;
21  float scatll = -999.0;
22  float avgdedxlast10cm = -999.0;
23  float avgdedxlast40cm = -999.0;
24 
25  for (unsigned int itrk = 0; itrk < sr->trk.kalman.ntracks; ++itrk){
26  scatll = sr->trk.kalman.tracks[itrk].scatllh;
27  dedxll = sr->trk.kalman.tracks[itrk].dedxllh;
28 
29  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm < 0 or sr->trk.kalman.tracks[itrk].avedEdxlast40cm < 0) continue;
30 
31  avgdedxlast10cm = std::min(sr->trk.kalman.tracks[itrk].avedEdxlast10cm, float(30.));
32  avgdedxlast40cm = std::min(sr->trk.kalman.tracks[itrk].avedEdxlast40cm, float(30.));
33 
34  TMVAvars[0] = dedxll;
35  TMVAvars[1] = scatll;
36  TMVAvars[2] = avgdedxlast10cm;
37  TMVAvars[3] = avgdedxlast40cm;
38 
39  float newmuonid = readerBDT->EvaluateMVA("BDTG");
40  if (newmuonid > muonid){
41  best_track = itrk;
42  muonid = newmuonid;
43  }
44  }
45  // Check if we're returning the best track id, or the highest MuonID
46  if (return_mode == EMuonIDReturnMode::kGetTrack)
47  return best_track;
48  return muonid;
49  }
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1673
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:1988
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1692
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1675
TMVA::Reader * readerBDT
Definition: MuonID.cxx:10
float ana::muonid_classifier::InitTMVA ( )

Definition at line 62 of file MuonID.cxx.

References cet::getenv().

Referenced by GetMuonIDSR().

63  {
64  // Initialize the static members
65  readerBDT = 0;
66  TMVAvars[0] = -999;
67  TMVAvars[1] = -999;
68  TMVAvars[2] = -999;
69  TMVAvars[3] = -999;
70 
71  if(!readerBDT) readerBDT = new TMVA::Reader();
72  const std::string srt_public = getenv("SRT_PUBLIC_CONTEXT");
73  const std::string srt_private = getenv("SRT_PRIVATE_CONTEXT");
74  const std::string weightfile_loc = "/NDAna/Classifiers/MuonID.weights.xml";
75 
76  // Default to SRT_PRIVATE_CONTEXT, then SRT_PUBLIC_CONTEXT
77  std::string bdt_weight_path;
78  if (!gSystem->AccessPathName((srt_private + weightfile_loc).c_str()))
79  bdt_weight_path = srt_private + weightfile_loc;
80  else
81  bdt_weight_path = srt_public + weightfile_loc;
82 
83  readerBDT->AddVariable("DedxLL", &TMVAvars[0]);
84  readerBDT->AddVariable("ScatLL", &TMVAvars[1]);
85  readerBDT->AddVariable("Avededxlast10cm", &TMVAvars[2]);
86  readerBDT->AddVariable("Avededxlast40cm", &TMVAvars[3]);
87  readerBDT->BookMVA("BDTG", bdt_weight_path);
88  return -5.0f;
89  }
std::string getenv(std::string const &name)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
TMVA::Reader * readerBDT
Definition: MuonID.cxx:10
const Var ana::muonid_classifier::kBestMuonTrack ( muonid_classifier::BestTrack  )
const Var ana::muonid_classifier::kMuonID ( muonid_classifier::MuonID  )
float ana::muonid_classifier::MuonID ( const caf::SRProxy sr)

Definition at line 51 of file MuonID.cxx.

References GetMuonIDSR().

Referenced by vf::TrackEva::analyze().

52  {
53  return ana::muonid_classifier::GetMuonIDSR(sr); // Check the MuonID and return it
54  }
float GetMuonIDSR(const caf::SRProxy *sr, const EMuonIDReturnMode return_mode)
Definition: MuonID.cxx:13

Variable Documentation

TMVA::Reader* ana::muonid_classifier::readerBDT

Definition at line 10 of file MuonID.cxx.

float ana::muonid_classifier::TMVAvars[4]

Definition at line 9 of file MuonID.cxx.