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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/NDAna/numucc_ccPi/NDXSecTrackPID.h"

Public Member Functions

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

Protected Member Functions

float InitTMVAPion () const
 
float InitTMVAProton () const
 
float InitTMVAGamma () const
 

Detailed Description

Definition at line 25 of file NDXSecTrackPID.h.

Constructor & Destructor Documentation

ana::GetPionTrack::GetPionTrack ( )
inline

Member Function Documentation

float ana::GetPionTrack::InitTMVAGamma ( ) const
protected

Definition at line 598 of file NDXSecTrackPID.cxx.

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

599  {
600  const char* path = getenv("SRT_PUBLIC_CONTEXT");
601  if(!fReaderBDTGamma) fReaderBDTGamma = new TMVA::Reader( "!Color:!Silent" );
602  std::string pidlib2 = std::string(path) + "/NDAna/numucc_ccPi/GammaFeatureID_BDT.weights.xml";
603  fReaderBDTGamma->AddVariable("TrackStartGap", &TMVAvars[4]);
604  fReaderBDTGamma->AddVariable("ScatLL", &TMVAvars[1]);
605  fReaderBDTGamma->AddVariable("DedxLL", &TMVAvars[0]);
606  fReaderBDTGamma->AddVariable("Avededxlast10cm", &TMVAvars[2]);
607  fReaderBDTGamma->AddVariable("Avededxlast40cm", &TMVAvars[3]);
608  fReaderBDTGamma->AddVariable("nGaps/ProjLength", &TMVAvars[5]);
609  fReaderBDTGamma->BookMVA("BDTGGamma", pidlib2);
610  return -5.0f;
611  }
static TMVA::Reader * fReaderBDTGamma
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::GetPionTrack::InitTMVAPion ( ) const
protected

Definition at line 569 of file NDXSecTrackPID.cxx.

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

570  {
571  if(!fReaderBDTPion) fReaderBDTPion = new TMVA::Reader( "!Color:!Silent" );
572  const char* path = getenv("SRT_PUBLIC_CONTEXT");
573  std::string pidlib = std::string(path) + "/NDAna/numucc_ccPi/PionFeatureID_BDT.weights.xml";
574  fReaderBDTPion->AddVariable("TrackStartGap", &TMVAvars[4]);
575  fReaderBDTPion->AddVariable("nGaps/ProjLength", &TMVAvars[5]);
576  fReaderBDTPion->AddVariable("ScatLL", &TMVAvars[1]);
577  fReaderBDTPion->AddVariable("DedxLL", &TMVAvars[0]);
578  fReaderBDTPion->AddVariable("Avededxlast10cm", &TMVAvars[2]);
579  fReaderBDTPion->AddVariable("Avededxlast40cm", &TMVAvars[3]);
580  fReaderBDTPion->BookMVA("BDTGPion", pidlib);
581  return -5.0f;
582  }
std::string getenv(std::string const &name)
static float TMVAvars[4]
Definition: NDNCPi0Xsec.cxx:10
static TMVA::Reader * fReaderBDTPion
const std::string path
Definition: plot_BEN.C:43
enum BeamMode string
float ana::GetPionTrack::InitTMVAProton ( ) const
protected

Definition at line 584 of file NDXSecTrackPID.cxx.

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

585  {
586  const char* path = getenv("SRT_PUBLIC_CONTEXT");
587  if(!fReaderBDTProton) fReaderBDTProton = new TMVA::Reader( "!Color:!Silent" );
588  std::string pidlib1 = std::string(path) + "/NDAna/numucc_ccPi/ProtonFeatureID_BDT.weights.xml";
589  fReaderBDTProton->AddVariable("TrackStartGap", &TMVAvars[4]);
590  fReaderBDTProton->AddVariable("ScatLL", &TMVAvars[1]);
591  fReaderBDTProton->AddVariable("DedxLL", &TMVAvars[0]);
592  fReaderBDTProton->AddVariable("Avededxlast10cm", &TMVAvars[2]);
593  fReaderBDTProton->AddVariable("Avededxlast40cm", &TMVAvars[3]);
594  fReaderBDTProton->AddVariable("nGaps/ProjLength", &TMVAvars[5]);
595  fReaderBDTProton->BookMVA("BDTGProton", pidlib1);
596  return -5.0f;
597  }
static TMVA::Reader * fReaderBDTProton
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::GetPionTrack::operator() ( const caf::SRProxy sr) const

Definition at line 106 of file NDXSecTrackPID.cxx.

References angle, std::cos(), make_root_from_grid_output::dedxll, caf::Proxy< caf::SRKalman >::idxremid, ana::GetPionID::InitTMVAGamma(), ana::GetPionID::InitTMVAPion(), ana::GetPionID::InitTMVAProton(), caf::Proxy< caf::SRTrackBranch >::kalman, demo0::length, Mag(), caf::Proxy< caf::SRKalman >::ntracks, make_root_from_grid_output::scatll, caf::Proxy< caf::SRKalman >::tracks, and caf::Proxy< caf::StandardRecord >::trk.

107  {
108 
109  float highestpid = -999.0;
110  int imax = -1; //this can be used as your track index with highest PID score.
111  float pionbdtvalue = -999.0;
112  float protonbdtvalue = -999.0;
113  float gammabdtvalue = -999.0;
114 
118  float dedxll = -999.0, scatll = -999.0;
119  float fAvededxlast10cm = -999.0;
120  float fAvededxlast40cm = -999.0;
121  float fTrackStartGap = -999.0;
122  float fGapDensity = -999.0;
123 
124  int nkals = sr->trk.kalman.ntracks;
125 
126  for (int itrk = 0; itrk < nkals; ++itrk){
127  if (sr->trk.kalman.tracks[itrk].rempid == -1) continue;
128  if (itrk==GetBestTrack()(sr)) continue;
129 
130  scatll = sr->trk.kalman.tracks[itrk].scatllh2017;
131  dedxll = sr->trk.kalman.tracks[itrk].dedxllh2017;
132 
133  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm == -5) continue;
134  if (sr->trk.kalman.tracks[itrk].avedEdxlast30cm == -5) continue;
135  if (sr->trk.kalman.tracks[itrk].avedEdxlast20cm == -5) continue;
136  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm == -5) continue;
137 
138  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm > 30){
139  fAvededxlast10cm = 30;
140  }else{
141  fAvededxlast10cm = sr->trk.kalman.tracks[itrk].avedEdxlast10cm;
142  }
143 
144  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm > 30){
145  fAvededxlast40cm = 30;
146  }else{
147  fAvededxlast40cm = sr->trk.kalman.tracks[itrk].avedEdxlast40cm;
148  }
149 
150  TVector3 vtxpos(sr->trk.kalman.tracks[sr->trk.kalman.idxremid].start.X(),sr->trk.kalman.tracks[sr->trk.kalman.idxremid].start.Y(),sr->trk.kalman.tracks[sr->trk.kalman.idxremid].start.Z());
151  TVector3 trkpos(sr->trk.kalman.tracks[itrk].start.X(),sr->trk.kalman.tracks[itrk].start.Y(),sr->trk.kalman.tracks[itrk].start.Z());
152  float trackstartgap = (vtxpos-trkpos).Mag();
153  TVector3 trkvec = sr->trk.kalman.tracks[itrk].dir;
154  float angle = trkvec.Angle(beamDirND);
155  float length = sr->trk.kalman.tracks[itrk].len;
156  float coslength = length*cos(angle);
157  float ngaps = sr->trk.kalman.tracks[itrk].nplanegap;
158 
159  fTrackStartGap=trackstartgap;
160  fGapDensity=ngaps/coslength;
161 
162  TMVAvars[0] = dedxll;
163  TMVAvars[1] = scatll;
164  TMVAvars[2] = fAvededxlast10cm;
165  TMVAvars[3] = fAvededxlast40cm;
166  TMVAvars[4] = fTrackStartGap;
167  TMVAvars[5] = fGapDensity;
168 
172 
173  pionbdtvalue = fReaderBDTPion->EvaluateMVA("BDTGPion");
174  protonbdtvalue = fReaderBDTProton->EvaluateMVA("BDTGProton");
175  gammabdtvalue = fReaderBDTGamma->EvaluateMVA("BDTGGamma");
176 
177  if (pionbdtvalue > protonbdtvalue && pionbdtvalue > gammabdtvalue && pionbdtvalue > highestpid){
178  imax = itrk;
179  highestpid = pionbdtvalue;
180  }else continue;
181  }
182  return imax;
183  }
float InitTMVAGamma() const
static TMVA::Reader * fReaderBDTGamma
Double_t angle
Definition: plot.C:86
caf::Proxy< unsigned int > idxremid
Definition: SRProxy.h:1777
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1778
float InitTMVAPion() const
static TMVA::Reader * fReaderBDTProton
length
Definition: demo0.py:21
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
float InitTMVAProton() const
static float TMVAvars[4]
Definition: NDNCPi0Xsec.cxx:10
static TMVA::Reader * fReaderBDTPion
const TVector3 beamDirND
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1797
float Mag() const
T cos(T number)
Definition: d0nt_math.hpp:78
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1780

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