Classes | Functions
muonid Namespace Reference

A PID for muons. More...

Classes

class  MuonID
 
class  MuonIDProd
 

Functions

unsigned int HighestPIDTrack (const std::vector< art::Ptr< rb::Track > > &sliceTracks, const std::string &muonidModuleLabel, const art::Event &e)
 
unsigned int HighestPIDTrack (std::vector< art::Ptr< rb::Track > > const &sliceTracks, art::InputTag const &muonidTag, art::Event const &e)
 

Detailed Description

A PID for muons.

Function Documentation

unsigned int muonid::HighestPIDTrack ( const std::vector< art::Ptr< rb::Track > > &  sliceTracks,
const std::string muonidModuleLabel,
const art::Event e 
)

Function which finds index of the best MuonID track among a vector of tracks. Requires the event to fetch associated MuonID objects and the module label

Definition at line 27 of file MuonID.cxx.

References getGoodRuns4SAM::tag.

Referenced by caf::CAFMaker::produce().

30  {
31  art::InputTag tag(muonidModuleLabel);
32  return muonid::HighestPIDTrack(sliceTracks, tag, e);
33  }
unsigned int HighestPIDTrack(const std::vector< art::Ptr< rb::Track > > &sliceTracks, const std::string &muonidModuleLabel, const art::Event &e)
Definition: MuonID.cxx:27
unsigned int muonid::HighestPIDTrack ( std::vector< art::Ptr< rb::Track > > const &  sliceTracks,
art::InputTag const &  muonidTag,
art::Event const &  e 
)

Definition at line 36 of file MuonID.cxx.

References plot_validation_datamc::c, allTimeWatchdog::endl, geo::kXorY, cet::sqlite::max(), rb::PID::Value(), and POTSpillRate::view.

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  }
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double Value() const
Definition: PID.h:22
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:66
Definition: fwd.h:29