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

#include <PiZeroProcess.h>

Public Member Functions

 PiZeroProcess (const simb::MCParticle &mcp, const art::Event &evt, const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, std::string showerLabel)
 
 PiZeroProcess (const recob::Shower &shower, const art::Event &evt, const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, std::string showerLabel)
 
 ~PiZeroProcess ()
 
void reset ()
 
const simb::MCParticlepi0 () const
 
const ShowerProcessshowerProcess1 () const
 
const ShowerProcessshowerProcess2 () const
 
const simb::MCParticlephoton1 () const
 
const simb::MCParticlephoton2 () const
 
const recob::Showershower1 () const
 
const recob::Showershower2 () const
 
const recob::Tracktrack1 () const
 
const recob::Tracktrack2 () const
 
const Conecone1 () const
 
const Conecone2 () const
 
const art::Eventevt () const
 
std::string showerLabel () const
 
bool allMCSet () const
 
bool allRecoSet () const
 
void setPi0 (const simb::MCParticle &newPi0)
 
void createBranches (TTree *tree)
 
void fillMCInfo ()
 
void fillRecoInfo (calo::CalorimetryAlg caloAlg)
 

Public Attributes

bool _haveMCInfo
 
bool _haveRecoInfo
 

Private Attributes

std::unique_ptr< ShowerProcess_shProcess1
 
std::unique_ptr< ShowerProcess_shProcess2
 
const simb::MCParticle_pi0 = 0x0
 
const art::Event_evt
 
const detinfo::DetectorClocksData_clockData
 
const detinfo::DetectorPropertiesData_detProp
 
const std::string _showerLabel
 
art::ServiceHandle< cheat::ParticleInventoryServicepi_serv
 
protoana::ProtoDUNETruthUtils truthUtils
 

Detailed Description

Definition at line 95 of file PiZeroProcess.h.

Constructor & Destructor Documentation

pizero::PiZeroProcess::PiZeroProcess ( const simb::MCParticle mcp,
const art::Event evt,
const detinfo::DetectorClocksData clockData,
const detinfo::DetectorPropertiesData detProp,
std::string  showerLabel 
)

Definition at line 191 of file PiZeroProcess.h.

194  :
195  _evt(evt), _clockData(clockData), _detProp{detProp}, _showerLabel(showerLabel)
196 {
197  if(mcp.PdgCode() == 111) {
198  // Got a pi0.
199  setPi0(mcp);
200  } else if(mcp.PdgCode() == 22) {
201  // Got a photon. Find the mother and run through the above process again.
202  if(mcp.Mother() == 0) return;
203  const simb::MCParticle* mcpmom = pi_serv->TrackIdToParticle_P(mcp.Mother());
204  if(mcpmom->PdgCode() == 111) setPi0(*mcpmom);
205  }
206 
207  // Quit if the system did not manage to find appropriate MCParticles.
208  if(!allMCSet()) return;
209 }
int PdgCode() const
Definition: MCParticle.h:212
const detinfo::DetectorPropertiesData & _detProp
const simb::MCParticle * TrackIdToParticle_P(int id) const
int Mother() const
Definition: MCParticle.h:213
const std::string _showerLabel
const detinfo::DetectorClocksData & _clockData
const art::Event & _evt
bool allMCSet() const
void setPi0(const simb::MCParticle &newPi0)
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
std::string showerLabel() const
pizero::PiZeroProcess::PiZeroProcess ( const recob::Shower shower,
const art::Event evt,
const detinfo::DetectorClocksData clockData,
const detinfo::DetectorPropertiesData detProp,
std::string  showerLabel 
)

Definition at line 212 of file PiZeroProcess.h.

215  :
216  _evt(evt), _clockData(clockData), _detProp{detProp}, _showerLabel(showerLabel)
217 {
218  // Get the event's showers.
219  auto showerHandle = _evt.getHandle<std::vector<recob::Shower> >(_showerLabel);
220  if (!showerHandle) return;
221  if(showerHandle->size() < 2) return;
222 
223  // For each shower, find the one which is closest to intersecting.
224  double min_dist = 100000;
225  const recob::Shower* shMatch = 0x0;
226  for(const recob::Shower& potMatch : *showerHandle) {
227  if(&potMatch == &shower) continue;
228 
229  const double this_dist = pizero::ClosestDistance(&shower, &potMatch);
230  if(this_dist < min_dist) {
231  min_dist = this_dist;
232  shMatch = &potMatch;
233  }
234  }
235  TVector3 reco_pi0_location = pizero::ClosestPoint(&shower, shMatch);
236 
237  // Find closest MC pi0 match to the reconstructed pi0 vertex.
238  double reco_mismatch = 100000;
239  const simb::MCParticle* min_pi0 = 0;
240  for(auto const& p : pi_serv->ParticleList()) {
241  const simb::MCParticle* true_pi0 = p.second;
242  // std::cout << "Particle PDG: " << true_pi0->PdgCode() << '\n';
243  if(true_pi0->PdgCode() != 111) continue;
244 
245  const double this_dist = (true_pi0->Position().Vect() - reco_pi0_location).Mag();
246  if(this_dist < reco_mismatch) {
247  reco_mismatch = this_dist;
248  min_pi0 = true_pi0;
249  }
250  }
251  if(min_pi0 == 0) return;
252 
253  // Fill internal data fields with the found pointers.
254  setPi0(*min_pi0);
255  // Check whether we have all necessary pointers.
256  if(!allMCSet()) {
257  _pi0 = 0x0;
258  _shProcess1 = 0x0;
259  _shProcess2 = 0x0;
260  // _photon1 = 0x0;
261  // _photon2 = 0x0;
262  // _shower1 = 0x0;
263  // _shower2 = 0x0;
264  return;
265  }
266  // // Use truth utilities to see which shower matches the first photon best.
267  // for(auto const& p : truthUtils.GetRecoShowerListFromMCParticle(*_photon1, _evt, _showerLabel)) {
268  // if(p.first->Length() - shower.Length() < 1e-5) {
269  // _shower1 = &shower;
270  // _shower2 = shMatch;
271  // break;
272  // } else if(p.first->Length() - shMatch->Length() < 1e-5) {
273  // _shower1 = shMatch;
274  // _shower2 = &shower;
275  // break;
276  // }
277  // }
278 }
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:219
int PdgCode() const
Definition: MCParticle.h:212
TVector3 ClosestPoint(const TVector3 &a, const TVector3 &adir, const TVector3 &b, const TVector3 &bdir)
Definition: PiZeroProcess.h:42
const detinfo::DetectorPropertiesData & _detProp
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
const std::string _showerLabel
const detinfo::DetectorClocksData & _clockData
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const art::Event & _evt
bool allMCSet() const
void setPi0(const simb::MCParticle &newPi0)
p
Definition: test.py:223
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
const sim::ParticleList & ParticleList() const
const simb::MCParticle * _pi0
double ClosestDistance(const TVector3 &a, const TVector3 &adir, const TVector3 &b, const TVector3 &bdir)
Definition: PiZeroProcess.h:67
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
std::string showerLabel() const
pizero::PiZeroProcess::~PiZeroProcess ( )
inline

Definition at line 128 of file PiZeroProcess.h.

128 {};

Member Function Documentation

bool pizero::PiZeroProcess::allMCSet ( ) const

Definition at line 281 of file PiZeroProcess.h.

281  {
282  return (pi0() != 0x0) && (photon1() != 0x0) && (photon2() != 0x0);
283 }
const simb::MCParticle * photon1() const
const simb::MCParticle * pi0() const
const simb::MCParticle * photon2() const
bool pizero::PiZeroProcess::allRecoSet ( ) const

Definition at line 284 of file PiZeroProcess.h.

284  {
285  return (shower1() != 0x0) && (shower2() != 0x0);
286 }
const recob::Shower * shower2() const
const recob::Shower * shower1() const
const Cone* pizero::PiZeroProcess::cone1 ( ) const
inline

Definition at line 162 of file PiZeroProcess.h.

162  {
163  return _shProcess1? _shProcess1->cone(): 0x0;
164  }
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const Cone* pizero::PiZeroProcess::cone2 ( ) const
inline

Definition at line 165 of file PiZeroProcess.h.

165  {
166  return _shProcess2? _shProcess2->cone(): 0x0;
167  }
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
void pizero::PiZeroProcess::createBranches ( TTree *  tree)
const art::Event* pizero::PiZeroProcess::evt ( ) const
inline

Definition at line 168 of file PiZeroProcess.h.

168 { return &_evt; }
const art::Event & _evt
void pizero::PiZeroProcess::fillMCInfo ( )
void pizero::PiZeroProcess::fillRecoInfo ( calo::CalorimetryAlg  caloAlg)
const simb::MCParticle* pizero::PiZeroProcess::photon1 ( ) const
inline

Definition at line 144 of file PiZeroProcess.h.

144  {
145  return _shProcess1? _shProcess1->mcparticle(): 0x0;
146  }
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const simb::MCParticle* pizero::PiZeroProcess::photon2 ( ) const
inline

Definition at line 147 of file PiZeroProcess.h.

147  {
148  return _shProcess2? _shProcess2->mcparticle(): 0x0;
149  }
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
const simb::MCParticle* pizero::PiZeroProcess::pi0 ( ) const
inline

Definition at line 137 of file PiZeroProcess.h.

137 { return _pi0; }
const simb::MCParticle * _pi0
void pizero::PiZeroProcess::reset ( )
void pizero::PiZeroProcess::setPi0 ( const simb::MCParticle newPi0)

Definition at line 289 of file PiZeroProcess.h.

289  {
290  _pi0 = &newPi0;
291  if (_pi0->NumberDaughters() == 2) { // Skip rare decays for now.
292  // Find the associated photons through particle inventory.
295  // Set photon1 to be the more energetic one.
296  if(photon1->E() < photon2->E()) std::swap(photon1, photon2);
297  // Fill the showerProcesses.
298  _shProcess1 = std::make_unique<ShowerProcess>(*photon1, _evt, _clockData, _detProp);
299  _shProcess2 = std::make_unique<ShowerProcess>(*photon2, _evt, _clockData, _detProp);
300  }
301 }
double E(const int i=0) const
Definition: MCParticle.h:233
const detinfo::DetectorPropertiesData & _detProp
const simb::MCParticle * TrackIdToParticle_P(int id) const
const detinfo::DetectorClocksData & _clockData
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const art::Event & _evt
int NumberDaughters() const
Definition: MCParticle.h:217
int Daughter(const int i) const
Definition: MCParticle.cxx:112
const simb::MCParticle * photon1() const
void swap(Handle< T > &a, Handle< T > &b)
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
const simb::MCParticle * _pi0
const simb::MCParticle * photon2() const
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
const recob::Shower* pizero::PiZeroProcess::shower1 ( ) const
inline

Definition at line 150 of file PiZeroProcess.h.

150  {
151  return _shProcess1? _shProcess1->shower(): 0x0;
152  }
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const recob::Shower* pizero::PiZeroProcess::shower2 ( ) const
inline

Definition at line 153 of file PiZeroProcess.h.

153  {
154  return _shProcess2? _shProcess2->shower(): 0x0;
155  }
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
std::string pizero::PiZeroProcess::showerLabel ( ) const
inline

Definition at line 169 of file PiZeroProcess.h.

169 { return _showerLabel; }
const std::string _showerLabel
const ShowerProcess* pizero::PiZeroProcess::showerProcess1 ( ) const
inline

Definition at line 138 of file PiZeroProcess.h.

138  {
139  return &*_shProcess1;
140  }
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const ShowerProcess* pizero::PiZeroProcess::showerProcess2 ( ) const
inline

Definition at line 141 of file PiZeroProcess.h.

141  {
142  return &*_shProcess2;
143  }
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99
const recob::Track* pizero::PiZeroProcess::track1 ( ) const
inline

Definition at line 156 of file PiZeroProcess.h.

156  {
157  return _shProcess1? _shProcess1->track(): 0x0;
158  }
std::unique_ptr< ShowerProcess > _shProcess1
Definition: PiZeroProcess.h:98
const recob::Track* pizero::PiZeroProcess::track2 ( ) const
inline

Definition at line 159 of file PiZeroProcess.h.

159  {
160  return _shProcess2? _shProcess2->track(): 0x0;
161  }
std::unique_ptr< ShowerProcess > _shProcess2
Definition: PiZeroProcess.h:99

Member Data Documentation

const detinfo::DetectorClocksData& pizero::PiZeroProcess::_clockData
private

Definition at line 108 of file PiZeroProcess.h.

const detinfo::DetectorPropertiesData& pizero::PiZeroProcess::_detProp
private

Definition at line 109 of file PiZeroProcess.h.

const art::Event& pizero::PiZeroProcess::_evt
private

Definition at line 107 of file PiZeroProcess.h.

bool pizero::PiZeroProcess::_haveMCInfo

Definition at line 128 of file PiZeroProcess.h.

bool pizero::PiZeroProcess::_haveRecoInfo

Definition at line 131 of file PiZeroProcess.h.

const simb::MCParticle* pizero::PiZeroProcess::_pi0 = 0x0
private

Definition at line 103 of file PiZeroProcess.h.

const std::string pizero::PiZeroProcess::_showerLabel
private

Definition at line 110 of file PiZeroProcess.h.

std::unique_ptr<ShowerProcess> pizero::PiZeroProcess::_shProcess1
private

Definition at line 98 of file PiZeroProcess.h.

std::unique_ptr<ShowerProcess> pizero::PiZeroProcess::_shProcess2
private

Definition at line 99 of file PiZeroProcess.h.

art::ServiceHandle<cheat::ParticleInventoryService> pizero::PiZeroProcess::pi_serv
private

Definition at line 113 of file PiZeroProcess.h.

protoana::ProtoDUNETruthUtils pizero::PiZeroProcess::truthUtils
private

Definition at line 114 of file PiZeroProcess.h.


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