BPFPId.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////
2 //
3 // \file BPFPId.cxx
4 // \brief PId object created by BPFPId_module.cc.
5 // \version
6 // \author Michael Baird - mbaird42@fnal.gov & Jonathan Davies jpdavies@sussex.ac.uk
7 //
8 ///////////////////////////////////////////////////////////
9 
11 
13 #include "cetlib_except/exception.h"
14 #include <iostream>
15 
16 namespace bpfit
17 {
18 
19 ///////////////////////////////////////////////////////////
20 
21  BPFPId::BPFPId() : rb::PID()
22  {
23  SetDefaults();
24  }
25 
26 ///////////////////////////////////////////////////////////
27 
28  BPFPId::BPFPId(int pdg, double val) : rb::PID(pdg, val)
29  {
30  SetDefaults();
31  }
32 
33 ///////////////////////////////////////////////////////////
34 
36  {
37  SetLength(-5.0);
38  SetChi2T(1.0e9);
39  SetdEdXLL(-1.0e9);
40  SetHitRatio(-5.0);
41  }
42 
43 ///////////////////////////////////////////////////////////
44 
45  unsigned int HighestPIDTrack(
46  const std::vector< art::Ptr<rb::Track> >& sliceTracks,
47  const std::string& bpfpidModuleLabel,
48  const int & pdg,
49  const art::Event& e)
50  {
51  int bestTrack = -1;
52  double highestPID = -2.0;
53  // double bestTrackLength = 0.0;
54  // double bestStartZ = std::numeric_limits<double>::max();
55  // double bestADC = std::numeric_limits<double>::max();
56 
57  art::FindManyP<bpfit::BPFPId> tracksToBPFPId(sliceTracks, e, bpfpidModuleLabel);
58 
59  for(size_t c = 0; c < sliceTracks.size(); ++c){
60  geo::View_t view = sliceTracks[c]->View();
61  //Only use 3D tracks
62  if (view != geo::kXorY){
63  continue;
64  } //End of loop over 2d tracks
65 
66  if(tracksToBPFPId.isValid()){
67  std::vector<art::Ptr<bpfit::BPFPId > > trackBPFPId = tracksToBPFPId.at(c);
68  // If the PID is lower, we can bail, nothing to update
69  if(trackBPFPId.size() == 0) continue;
70  if(trackBPFPId.at(0)->Pdg() != pdg) continue;
71  if(trackBPFPId.at(0)->Value() > highestPID){
72 
73  highestPID = trackBPFPId.at(0)->Value();
74  // bestTrackLength = sliceTracks[c]->TotalLength();
75  // bestStartZ = sliceTracks[c]->Start().Z();
76  // bestADC = sliceTracks[c]->TotalADC();
77  bestTrack = c;
78  }
79  //else -- handle a tie between two BPFPId scores //FIXME
80 
81 
82  }//End of valid BPFPId object
83 
84  }//End of for loop over tracks
85 
86 
87  if (bestTrack < 0)
88  return 999;
89 
90  return (unsigned int)bestTrack;
91 
92  }
93 ///////////////////////////////////////////////////////////
94 
95 }//namespace bpfit
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
void SetdEdXLL(double dEdXLL)
Definition: BPFPId.h:38
PID()
Definition: PID.cxx:13
void SetHitRatio(double hitRatio)
Definition: BPFPId.h:39
void SetLength(double length)
Definition: BPFPId.h:36
void SetChi2T(double chi2T)
Definition: BPFPId.h:37
unsigned int HighestPIDTrack(const std::vector< art::Ptr< rb::Track > > &sliceTracks, const std::string &bpfpidModuleLabel, const int &pdg, const art::Event &e)
Definition: BPFPId.cxx:45
Perform a "2 point" Hough transform on a collection of hits.
void SetDefaults()
Set fLength, fChi2T, fdEdXLL and fHitRatio to default values.
Definition: BPFPId.cxx:35
Float_t e
Definition: plot.C:35
enum BeamMode string