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

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

Public Member Functions

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

Protected Member Functions

float InitTMVAPion () const
 

Detailed Description

Definition at line 38 of file NDXSecTrackPID.h.

Constructor & Destructor Documentation

ana::GetBestPionID::GetBestPionID ( )
inline

Definition at line 41 of file NDXSecTrackPID.h.

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

41 {}

Member Function Documentation

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

Definition at line 613 of file NDXSecTrackPID.cxx.

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

614  {
615  if(!fReaderBDTPion) fReaderBDTPion = new TMVA::Reader( "!Color:!Silent" );
616  const char* path = getenv("SRT_PUBLIC_CONTEXT");
617  std::string pidlib = std::string(path) + "/NDAna/numucc_ccPi/PionFeatureID_BDT.weights.xml";
618  fReaderBDTPion->AddVariable("TrackStartGap", &TMVAvars[4]);
619  fReaderBDTPion->AddVariable("nGaps/ProjLength", &TMVAvars[5]);
620  fReaderBDTPion->AddVariable("ScatLL", &TMVAvars[1]);
621  fReaderBDTPion->AddVariable("DedxLL", &TMVAvars[0]);
622  fReaderBDTPion->AddVariable("Avededxlast10cm", &TMVAvars[2]);
623  fReaderBDTPion->AddVariable("Avededxlast40cm", &TMVAvars[3]);
624  fReaderBDTPion->BookMVA("BDTGPion", pidlib);
625  return -5.0f;
626  }
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::GetBestPionID::operator() ( const caf::SRProxy sr) const

Definition at line 187 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.

188  {
189 
190  float highestpid = -999.0;
191  float pionbdtvalue = -999.0;
192 
194  float dedxll = -999.0, scatll = -999.0;
195  float fAvededxlast10cm = -999.0;
196  float fAvededxlast40cm = -999.0;
197  float fTrackStartGap = -999.0;
198  float fGapDensity = -999.0;
199 
200  int nkals = sr->trk.kalman.ntracks;
201 
202  for (int itrk = 0; itrk < nkals; ++itrk){
203  if (sr->trk.kalman.tracks[itrk].rempid == -1) continue;
204  if (itrk==GetBestTrack()(sr)) continue;
205 
206  scatll = sr->trk.kalman.tracks[itrk].scatllh2017;
207  dedxll = sr->trk.kalman.tracks[itrk].dedxllh2017;
208 
209  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm == -5) continue;
210  if (sr->trk.kalman.tracks[itrk].avedEdxlast30cm == -5) continue;
211  if (sr->trk.kalman.tracks[itrk].avedEdxlast20cm == -5) continue;
212  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm == -5) continue;
213 
214  if (sr->trk.kalman.tracks[itrk].avedEdxlast10cm > 30){
215  fAvededxlast10cm = 30;
216  }else{
217  fAvededxlast10cm = sr->trk.kalman.tracks[itrk].avedEdxlast10cm;
218  }
219 
220  if (sr->trk.kalman.tracks[itrk].avedEdxlast40cm > 30){
221  fAvededxlast40cm = 30;
222  }else{
223  fAvededxlast40cm = sr->trk.kalman.tracks[itrk].avedEdxlast40cm;
224  }
225 
226  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());
227  TVector3 trkpos(sr->trk.kalman.tracks[itrk].start.X(),sr->trk.kalman.tracks[itrk].start.Y(),sr->trk.kalman.tracks[itrk].start.Z());
228  float trackstartgap = (vtxpos-trkpos).Mag();
229  TVector3 trkvec = sr->trk.kalman.tracks[itrk].dir;
230  float angle = trkvec.Angle(beamDirND);
231  float length = sr->trk.kalman.tracks[itrk].len;
232  float coslength = length*cos(angle);
233  float ngaps = sr->trk.kalman.tracks[itrk].nplanegap;
234 
235  fTrackStartGap=trackstartgap;
236  fGapDensity=ngaps/coslength;
237 
238  TMVAvars[0] = dedxll;
239  TMVAvars[1] = scatll;
240  TMVAvars[2] = fAvededxlast10cm;
241  TMVAvars[3] = fAvededxlast40cm;
242  TMVAvars[4] = fTrackStartGap;
243  TMVAvars[5] = fGapDensity;
244 
246 
247  pionbdtvalue = fReaderBDTPion->EvaluateMVA("BDTGPion");
248 
249  if (pionbdtvalue > highestpid){
250  highestpid = pionbdtvalue;
251  }else continue;
252 
253  }
254  return highestpid;
255  }
Double_t angle
Definition: plot.C:86
caf::Proxy< unsigned int > idxremid
Definition: SRProxy.h:1776
caf::Proxy< size_t > ntracks
Definition: SRProxy.h:1777
length
Definition: demo0.py:21
caf::Proxy< caf::SRTrackBranch > trk
Definition: SRProxy.h:2144
static float TMVAvars[4]
Definition: NDNCPi0Xsec.cxx:10
static TMVA::Reader * fReaderBDTPion
const TVector3 beamDirND
float InitTMVAPion() const
caf::Proxy< caf::SRKalman > kalman
Definition: SRProxy.h:1796
float Mag() const
T cos(T number)
Definition: d0nt_math.hpp:78
caf::Proxy< std::vector< caf::SRKalmanTrack > > tracks
Definition: SRProxy.h:1779

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