MuonID.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file MuonID.cxx
3 // \brief BDT for muon / mubar identification
4 // \author Connor Johnson - Connor.Johnson@colostate.edu
5 ////////////////////////////////////////////////////////////////////////
6 #include "MuonID/MuonID.h"
7 
9 
10 namespace muonid
11 {
12  //......................................
14  : rb::PID()
15  {
16 
17  }
18 
19  //......................................
20  MuonID::MuonID(int pdg, double val)
21  : rb::PID(pdg,val)
22  {
23 
24  }
25 
26  //.....................................
27  unsigned int HighestPIDTrack(
28  const std::vector< art::Ptr<rb::Track> >& sliceTracks,
29  const std::string& muonidModuleLabel, const art::Event& e)
30  {
31  art::InputTag tag(muonidModuleLabel);
32  return muonid::HighestPIDTrack(sliceTracks, tag, e);
33  }
34 
35  //.....................................
36  unsigned int HighestPIDTrack(std::vector< art::Ptr<rb::Track> > const& sliceTracks,
37  art::InputTag const& muonidTag,
38  art::Event const& e)
39  {
40  int bestTrack = -1;
41  double highestPID = -2.0;
42  double bestTrackLength = 0.0;
43  double bestStartZ = std::numeric_limits<double>::max();
44  double bestADC = std::numeric_limits<double>::max();
45 
46  art::FindOneP<muonid::MuonID> tracksToMuonID(sliceTracks, e, muonidTag);
47 
48  for(size_t c = 0; c < sliceTracks.size(); ++c){
49 
50  geo::View_t view = sliceTracks[c]->View();
51 
52  //Only use 3D tracks
53  if (view != geo::kXorY){
54  continue;
55  } //End of loop over 2d tracks
56 
57  if(tracksToMuonID.isValid()){
58  art::Ptr<muonid::MuonID> trackMuonID = tracksToMuonID.at(c);
59 
60  // If the PID is lower, we can bail, nothing to update
61  if(trackMuonID->Value() < highestPID)
62  continue;
63 
64  if(trackMuonID->Value() == highestPID)
65  { // If the new guy is shorter, we can bail
66  if (sliceTracks[c]->TotalLength() < bestTrackLength) continue;
67 
68  // If equal, need to fall to the next level, low start Z
69  if (sliceTracks[c]->TotalLength() == bestTrackLength){
70 
71  // If start Z is higher, we can bail
72  if (sliceTracks[c]->Start().Z() > bestStartZ) continue;
73 
74  // If equal, need to fall to the next level, total ADC
75  // Use lower ADC
76  if (sliceTracks[c]->Start().Z() == bestStartZ){
77 
78  if(sliceTracks[c]->TotalADC() > bestADC) continue;
79 
80  if(sliceTracks[c]->TotalADC() == bestADC)
81  throw cet::exception("MuonID Matched Track Exception")<<std::endl
82  << "Can't break a tie between two MuonID/tracks. "
83  << "This should have never happened, but it did. " << std::endl;
84  }
85  }
86  }
87 
88  highestPID = trackMuonID->Value();
89  bestTrackLength = sliceTracks[c]->TotalLength();
90  bestStartZ = sliceTracks[c]->Start().Z();
91  bestADC = sliceTracks[c]->TotalADC();
92  bestTrack = c;
93 
94  }//End of valid MuonID object
95 
96  }//End of for loop over tracks
97 
98  if (bestTrack < 0)
99  return 999;
100 
101  return (unsigned int)bestTrack;
102  }
103 } // namespace muonid
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
PID()
Definition: PID.cxx:13
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
A PID for muons.
Definition: FillPIDs.h:11
double Value() const
Definition: PID.h:22
Perform a "2 point" Hough transform on a collection of hits.
Float_t e
Definition: plot.C:35
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
unsigned int HighestPIDTrack(const std::vector< art::Ptr< rb::Track > > &sliceTracks, const std::string &muonidModuleLabel, const art::Event &e)
Definition: MuonID.cxx:27
enum BeamMode string