Public Member Functions | Private Attributes | List of all members
pizero::Cone Class Reference

#include <Cone.h>

Public Member Functions

 Cone (const art::Event &evt, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TVector3 &newStart, const TVector3 &newDir, const double newLen)
 
TVector3 start () const
 
TVector3 end () const
 
TVector3 direction () const
 
double length () const
 
double width () const
 
std::vector< const recob::Hit * > hits () const
 
std::vector< const recob::SpacePoint * > spacepoints () const
 
double energy (calo::CalorimetryAlg caloAlg) const
 
double completeness (const simb::MCParticle &mcpart, const std::string hitLabel="hitpdune") const
 
double purity (const simb::MCParticle &mcpart) const
 

Private Attributes

const art::Eventm_evt
 
detinfo::DetectorClocksData const * m_clockdata
 
detinfo::DetectorPropertiesData const * m_detprop
 
TVector3 m_start
 
TVector3 m_direction
 
double m_length
 
double m_ang = 15.0/360 * 2*3.1415926
 
double m_width = 1
 
double m_startoffset = 10
 
std::vector< const recob::Hit * > m_hits
 
std::vector< const recob::SpacePoint * > m_spacepoints
 

Detailed Description

Definition at line 22 of file Cone.h.

Constructor & Destructor Documentation

pizero::Cone::Cone ( const art::Event evt,
detinfo::DetectorClocksData const &  clockData,
detinfo::DetectorPropertiesData const &  detProp,
const TVector3 &  newStart,
const TVector3 &  newDir,
const double  newLen 
)
inline

Definition at line 38 of file Cone.h.

43  :
44  m_evt(&evt),
45  m_clockdata(&clockData),
46  m_detprop(&detProp),
47  m_start(newStart), m_direction(newDir.Unit()), m_length(newLen)
48  {
49  // Move the start back by a constant to catch all hits.
52  // Determine the width of the cone at the end.
53  m_width = m_length * tan(m_ang);
54 
55  // Get all spacepoints in the event.
56  std::string spsLabel = "pandora";
57  auto spHandle = m_evt->getHandle<std::vector<recob::SpacePoint> >(spsLabel);
58  if (!spHandle) { return; }
59  // Get associations between the spacepoints and hits.
60  const art::FindManyP<recob::Hit> sphits(spHandle, *m_evt, spsLabel);
61 
62  // Loop through spacepoints to test whether they're in the cone.
63  for(const recob::SpacePoint& sp : *spHandle) {
64  const TVector3 pos(sp.XYZ());
65  // 0 <= projection <= cone length
66  const double proj = (pos-m_start).Dot(m_direction);
67  if(proj < 0 || proj > m_length) continue;
68  // Cone radius at projection.
69  const double cradius = (proj/m_length)*m_width/2;
70  // rejection < cone radius
71  const double rej = ((pos-m_start) - proj*m_direction).Mag();
72  if(rej > cradius) continue;
73 
74  // This spacepoint is inside the cone. Put it among the results.
75  for(const art::Ptr<recob::Hit>& hit : sphits.at(sp.ID())) {
76  m_hits.push_back(&*hit);
77  }
78  m_spacepoints.push_back(&sp);
79  }
80  }
detinfo::DetectorPropertiesData const * m_detprop
Definition: Cone.h:26
TVector3 m_start
Definition: Cone.h:27
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
double m_length
Definition: Cone.h:29
double m_width
Definition: Cone.h:31
TVector3 m_direction
Definition: Cone.h:28
double m_ang
Definition: Cone.h:30
const art::Event * m_evt
Definition: Cone.h:24
Detector simulation of raw signals on wires.
std::vector< const recob::Hit * > m_hits
Definition: Cone.h:34
double m_startoffset
Definition: Cone.h:32
std::vector< const recob::SpacePoint * > m_spacepoints
Definition: Cone.h:35
detinfo::DetectorClocksData const * m_clockdata
Definition: Cone.h:25

Member Function Documentation

double pizero::Cone::completeness ( const simb::MCParticle mcpart,
const std::string  hitLabel = "hitpdune" 
) const
inline

Definition at line 100 of file Cone.h.

101  {
102  // Get all hits in the event.
103  auto hitHandle = m_evt->getHandle<std::vector<recob::Hit> >(hitLabel);
104  if(!hitHandle) {
105  std::cout << "pizero::Cone::completeness: could not find hits in event.\n";
106  return 0;
107  }
108 
109  // Check for each hit whether it came from the MCParticle and if so,
110  // whether it fell inside the cone.
112  double sharedHits = 0;
113  double MChits = 0;
114  for(const recob::Hit& hit : *hitHandle) {
115  for(const int trackId : bt_serv->HitToTrackIds(*m_clockdata, hit)) {
116  if(std::abs(trackId) == std::abs(mcpart.TrackId())) {
117  // Hit is in MCParticle.
118  ++MChits;
119  // Check if hit in cone.
120  for(const recob::Hit* chit : m_hits) {
121  // Compare the time and place of hit for lack of ID
122  if(chit->PeakTime() - hit.PeakTime() < 1e-5 &&
123  chit->Channel() == hit.Channel()) {
124  ++sharedHits;
125  // std::cout << "Found shared hit!\n";
126  break;
127  }
128  }
129  break;
130  } // if hit is from MCP
131  } // for trackID in hit
132  } // for hit in event
133 
134  return MChits==0? 0: sharedHits/MChits;
135 } // Cone::completeness
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::vector< int > HitToTrackIds(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
int TrackId() const
Definition: MCParticle.h:210
T abs(T value)
const double e
const art::Event * m_evt
Definition: Cone.h:24
Detector simulation of raw signals on wires.
std::vector< const recob::Hit * > m_hits
Definition: Cone.h:34
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
detinfo::DetectorClocksData const * m_clockdata
Definition: Cone.h:25
TVector3 pizero::Cone::direction ( ) const
inline

Definition at line 85 of file Cone.h.

85 { return m_direction; }
TVector3 m_direction
Definition: Cone.h:28
TVector3 pizero::Cone::end ( void  ) const
inline

Definition at line 84 of file Cone.h.

84 { return m_start + m_direction*m_length; }
TVector3 m_start
Definition: Cone.h:27
double m_length
Definition: Cone.h:29
TVector3 m_direction
Definition: Cone.h:28
double pizero::Cone::energy ( calo::CalorimetryAlg  caloAlg) const
inline

Definition at line 91 of file Cone.h.

91  {
93  return shUtil.EstimateEnergyFromHitCharge(*m_clockdata, *m_detprop, m_hits, caloAlg)[2];
94  }
detinfo::DetectorPropertiesData const * m_detprop
Definition: Cone.h:26
std::vector< double > EstimateEnergyFromHitCharge(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< const recob::Hit * > &hits, calo::CalorimetryAlg caloAlg)
std::vector< const recob::Hit * > m_hits
Definition: Cone.h:34
detinfo::DetectorClocksData const * m_clockdata
Definition: Cone.h:25
std::vector<const recob::Hit*> pizero::Cone::hits ( void  ) const
inline

Definition at line 88 of file Cone.h.

88 { return m_hits; }
std::vector< const recob::Hit * > m_hits
Definition: Cone.h:34
double pizero::Cone::length ( ) const
inline

Definition at line 86 of file Cone.h.

86 { return m_length; }
double m_length
Definition: Cone.h:29
double pizero::Cone::purity ( const simb::MCParticle mcpart) const
inline

Definition at line 137 of file Cone.h.

137  {
138  unsigned sharedHits = 0;
140  for(const recob::Hit* hit : m_hits) {
141  for(const int trackId : bt_serv->HitToTrackIds(*m_clockdata, *hit)) {
142  if(std::abs(trackId) == std::abs(mcpart.TrackId())) {
143  ++sharedHits;
144  break;
145  }
146  }
147  }
148 
149  return (double)sharedHits / m_hits.size();
150 }
std::vector< int > HitToTrackIds(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
int TrackId() const
Definition: MCParticle.h:210
T abs(T value)
Detector simulation of raw signals on wires.
std::vector< const recob::Hit * > m_hits
Definition: Cone.h:34
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
detinfo::DetectorClocksData const * m_clockdata
Definition: Cone.h:25
std::vector<const recob::SpacePoint*> pizero::Cone::spacepoints ( ) const
inline

Definition at line 89 of file Cone.h.

89 { return m_spacepoints; }
std::vector< const recob::SpacePoint * > m_spacepoints
Definition: Cone.h:35
TVector3 pizero::Cone::start ( void  ) const
inline

Definition at line 83 of file Cone.h.

83 { return m_start; }
TVector3 m_start
Definition: Cone.h:27
double pizero::Cone::width ( ) const
inline

Definition at line 87 of file Cone.h.

87 { return m_width; }
double m_width
Definition: Cone.h:31

Member Data Documentation

double pizero::Cone::m_ang = 15.0/360 * 2*3.1415926
private

Definition at line 30 of file Cone.h.

detinfo::DetectorClocksData const* pizero::Cone::m_clockdata
private

Definition at line 25 of file Cone.h.

detinfo::DetectorPropertiesData const* pizero::Cone::m_detprop
private

Definition at line 26 of file Cone.h.

TVector3 pizero::Cone::m_direction
private

Definition at line 28 of file Cone.h.

const art::Event* pizero::Cone::m_evt
private

Definition at line 24 of file Cone.h.

std::vector<const recob::Hit*> pizero::Cone::m_hits
private

Definition at line 34 of file Cone.h.

double pizero::Cone::m_length
private

Definition at line 29 of file Cone.h.

std::vector<const recob::SpacePoint*> pizero::Cone::m_spacepoints
private

Definition at line 35 of file Cone.h.

TVector3 pizero::Cone::m_start
private

Definition at line 27 of file Cone.h.

double pizero::Cone::m_startoffset = 10
private

Definition at line 32 of file Cone.h.

double pizero::Cone::m_width = 1
private

Definition at line 31 of file Cone.h.


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