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

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

Public Member Functions

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

Protected Member Functions

float InitTMVAPion () const
 

Detailed Description

Definition at line 47 of file NDXSecTrackPID.h.

Constructor & Destructor Documentation

ana::GetBestPionTrack::GetBestPionTrack ( )
inline

Definition at line 50 of file NDXSecTrackPID.h.

References ana::GetPionID::InitTMVAPion(), ana::GetPionID::operator()(), and sr.

50 {}

Member Function Documentation

float ana::GetBestPionTrack::InitTMVAPion ( ) const
protected

Definition at line 628 of file NDXSecTrackPID.cxx.

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

629  {
630  if(!fReaderBDTPion) fReaderBDTPion = new TMVA::Reader( "!Color:!Silent" );
631  const char* path = getenv("SRT_PUBLIC_CONTEXT");
632  std::string pidlib = std::string(path) + "/NDAna/numucc_ccPi/PionFeatureID_BDT.weights.xml";
633  fReaderBDTPion->AddVariable("TrackStartGap", &TMVAvars[4]);
634  fReaderBDTPion->AddVariable("nGaps/ProjLength", &TMVAvars[5]);
635  fReaderBDTPion->AddVariable("ScatLL", &TMVAvars[1]);
636  fReaderBDTPion->AddVariable("DedxLL", &TMVAvars[0]);
637  fReaderBDTPion->AddVariable("Avededxlast10cm", &TMVAvars[2]);
638  fReaderBDTPion->AddVariable("Avededxlast40cm", &TMVAvars[3]);
639  fReaderBDTPion->BookMVA("BDTGPion", pidlib);
640  return -5.0f;
641  }
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::GetBestPionTrack::operator() ( const caf::SRProxy sr) const

Definition at line 258 of file NDXSecTrackPID.cxx.

References angle, std::cos(), make_root_from_grid_output::dedxll, caf::Proxy< caf::SRKalman >::idxremid, ana::GetPionID::InitTMVAPion(), 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.

259  {
260 
261  float highestpid = -999.0;
262  int imax = -1; //this can be used as your track index with highest PID score.
263  float pionbdtvalue = -999.0;
264 
266  float dedxll = -999.0, scatll = -999.0;
267  float fAvededxlast10cm = -999.0;
268  float fAvededxlast40cm = -999.0;
269  float fTrackStartGap = -999.0;
270  float fGapDensity = -999.0;
271 
272  int nkals = sr->trk.kalman.ntracks;
273 
274  for (int itrk = 0; itrk < nkals; ++itrk){
275  if (sr->trk.kalman.tracks[itrk].rempid == -1) continue;
276  if (itrk==GetBestTrack()(sr)) continue;
277 
278  scatll = sr->trk.kalman.tracks[itrk].scatllh2017;
279  dedxll = sr->trk.kalman.tracks[itrk].dedxllh2017;
280 
281  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm == -5) continue;
282  if (sr->trk.kalman.tracks[itrk].avedEdxlast30cm == -5) continue;
283  if (sr->trk.kalman.tracks[itrk].avedEdxlast20cm == -5) continue;
284  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm == -5) continue;
285 
286  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm > 30){
287  fAvededxlast10cm = 30;
288  }else{
289  fAvededxlast10cm = sr->trk.kalman.tracks[itrk].avedEdxlast10cm;
290  }
291 
292  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm > 30){
293  fAvededxlast40cm = 30;
294  }else{
295  fAvededxlast40cm = sr->trk.kalman.tracks[itrk].avedEdxlast40cm;
296  }
297 
298  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());
299  TVector3 trkpos(sr->trk.kalman.tracks[itrk].start.X(),sr->trk.kalman.tracks[itrk].start.Y(),sr->trk.kalman.tracks[itrk].start.Z());
300  float trackstartgap = (vtxpos-trkpos).Mag();
301  TVector3 trkvec = sr->trk.kalman.tracks[itrk].dir;
302  float angle = trkvec.Angle(beamDirND);
303  float length = sr->trk.kalman.tracks[itrk].len;
304  float coslength = length*cos(angle);
305  float ngaps = sr->trk.kalman.tracks[itrk].nplanegap;
306 
307  fTrackStartGap=trackstartgap;
308  fGapDensity=ngaps/coslength;
309 
310  TMVAvars[0] = dedxll;
311  TMVAvars[1] = scatll;
312  TMVAvars[2] = fAvededxlast10cm;
313  TMVAvars[3] = fAvededxlast40cm;
314  TMVAvars[4] = fTrackStartGap;
315  TMVAvars[5] = fGapDensity;
316 
318 
319  pionbdtvalue = fReaderBDTPion->EvaluateMVA("BDTGPion");
320 
321  if (pionbdtvalue > highestpid){
322  imax = itrk;
323  highestpid = pionbdtvalue;
324  }else continue;
325  }
326  return imax;
327  }
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
length
Definition: demo0.py:21
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2145
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: