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 GetMuonIDKalmanTrack (const caf::SRKalmanTrack *kaltrk)
 
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 18 of file MuonID.h.

Function Documentation

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

Definition at line 79 of file MuonID.cxx.

References GetMuonIDSR(), and kGetTrack.

80  {
81  return ana::muonid_classifier::GetMuonIDSR(sr, ana::muonid_classifier::kGetTrack); // Check the MuonID and return highest scoring track
82  }
float GetMuonIDSR(const caf::SRProxy *sr, const EMuonIDReturnMode return_mode)
Definition: MuonID.cxx:13
float ana::muonid_classifier::GetMuonIDKalmanTrack ( const caf::SRKalmanTrack kaltrk)

Definition at line 51 of file MuonID.cxx.

References caf::SRTrack::avedEdxlast10cm, caf::SRTrack::avedEdxlast40cm, make_root_from_grid_output::dedxll, caf::SRKalmanTrack::dedxllh, InitTMVA(), std::min(), make_root_from_grid_output::scatll, and caf::SRKalmanTrack::scatllh.

52  {
53  if(!readerBDT) InitTMVA();
54 
55  float scatll = kaltrk->scatllh;
56  float dedxll = kaltrk->dedxllh;
57  float avgdedxlast10cm = -999.0;
58  float avgdedxlast40cm = -999.0;
59 
60  if (kaltrk->avedEdxlast10cm < 0 || kaltrk->avedEdxlast40cm < 0)
61  return -99.0;
62 
63  avgdedxlast10cm = std::min(kaltrk->avedEdxlast10cm, float(30.));
64  avgdedxlast40cm = std::min(kaltrk->avedEdxlast40cm, float(30.));
65 
66  TMVAvars[0] = dedxll;
67  TMVAvars[1] = scatll;
68  TMVAvars[2] = avgdedxlast10cm;
69  TMVAvars[3] = avgdedxlast40cm;
70 
71  return readerBDT->EvaluateMVA("BDTG");
72  }
float avedEdxlast40cm
Average dE/dx in the last 40 cm approximately.
Definition: SRTrack.h:75
float avedEdxlast10cm
Average dE/dx in the last 10 cm approximately.
Definition: SRTrack.h:72
T min(const caf::Proxy< T > &a, T b)
TMVA::Reader * readerBDT
Definition: MuonID.cxx:10
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, std::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:1778
A PID for muons.
Definition: FillPIDs.h:11
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1797
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1780
T min(const caf::Proxy< T > &a, T b)
TMVA::Reader * readerBDT
Definition: MuonID.cxx:10
float ana::muonid_classifier::InitTMVA ( )

Definition at line 85 of file MuonID.cxx.

References cet::getenv(), and string.

Referenced by GetMuonIDKalmanTrack(), and GetMuonIDSR().

86  {
87  // Initialize the static members
88  readerBDT = 0;
89  TMVAvars[0] = -999;
90  TMVAvars[1] = -999;
91  TMVAvars[2] = -999;
92  TMVAvars[3] = -999;
93 
94  if(!readerBDT) readerBDT = new TMVA::Reader();
95  const std::string srt_public = getenv("SRT_PUBLIC_CONTEXT");
96  const std::string srt_private = getenv("SRT_PRIVATE_CONTEXT");
97  const std::string weightfile_loc = "/NDAna/Classifiers/MuonID.weights.xml";
98 
99  // Default to SRT_PRIVATE_CONTEXT, then SRT_PUBLIC_CONTEXT
100  std::string bdt_weight_path;
101  if (!gSystem->AccessPathName((srt_private + weightfile_loc).c_str()))
102  bdt_weight_path = srt_private + weightfile_loc;
103  else
104  bdt_weight_path = srt_public + weightfile_loc;
105 
106  readerBDT->AddVariable("DedxLL", &TMVAvars[0]);
107  readerBDT->AddVariable("ScatLL", &TMVAvars[1]);
108  readerBDT->AddVariable("Avededxlast10cm", &TMVAvars[2]);
109  readerBDT->AddVariable("Avededxlast40cm", &TMVAvars[3]);
110  readerBDT->BookMVA("BDTG", bdt_weight_path);
111  return -5.0f;
112  }
std::string getenv(std::string const &name)
TMVA::Reader * readerBDT
Definition: MuonID.cxx:10
enum BeamMode string
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 74 of file MuonID.cxx.

References GetMuonIDSR().

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

75  {
76  return ana::muonid_classifier::GetMuonIDSR(sr); // Check the MuonID and return it
77  }
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.