All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sbn::ShowerCosmicDistance Class Reference
Inheritance diagram for sbn::ShowerCosmicDistance:

Public Member Functions

 ShowerCosmicDistance (fhicl::ParameterSet const &p)
 
 ShowerCosmicDistance (ShowerCosmicDistance const &)=delete
 
 ShowerCosmicDistance (ShowerCosmicDistance &&)=delete
 
ShowerCosmicDistanceoperator= (ShowerCosmicDistance const &)=delete
 
ShowerCosmicDistanceoperator= (ShowerCosmicDistance &&)=delete
 
void produce (art::Event &e) override
 

Private Member Functions

const std::vector< art::Ptr
< recob::PFParticle > > 
GetCosmicPFPs (const std::vector< art::Ptr< recob::PFParticle >> &pfps, const art::FindManyP< larpandoraobj::PFParticleMetadata > fmPFPMeta) const
 
const float FindShowerResidual (const recob::Shower &shower, const std::vector< art::Ptr< recob::PFParticle >> &cosmicPFPs, const art::FindManyP< recob::SpacePoint > &fmPFPSP) const
 

Private Attributes

const art::InputTag fPandoraLabel
 
const art::InputTag fShowerLabel
 
const float fMinShowerEnergy
 

Detailed Description

Definition at line 37 of file ShowerCosmicDistance_module.cc.

Constructor & Destructor Documentation

sbn::ShowerCosmicDistance::ShowerCosmicDistance ( fhicl::ParameterSet const &  p)
explicit

Definition at line 67 of file ShowerCosmicDistance_module.cc.

68  : EDProducer { p }
69  , fPandoraLabel(p.get<art::InputTag>("PandoraLabel"))
70  , fShowerLabel(p.get<art::InputTag>("ShowerLabel"))
71  , fMinShowerEnergy(p.get<float>("MinShowerEnergy"))
72 {
73  produces<std::vector<float>>();
74  produces<art::Assns<recob::Shower, float>>();
75 }
pdgs p
Definition: selectors.fcl:22
sbn::ShowerCosmicDistance::ShowerCosmicDistance ( ShowerCosmicDistance const &  )
delete
sbn::ShowerCosmicDistance::ShowerCosmicDistance ( ShowerCosmicDistance &&  )
delete

Member Function Documentation

const float sbn::ShowerCosmicDistance::FindShowerResidual ( const recob::Shower shower,
const std::vector< art::Ptr< recob::PFParticle >> &  cosmicPFPs,
const art::FindManyP< recob::SpacePoint > &  fmPFPSP 
) const
private

Definition at line 146 of file ShowerCosmicDistance_module.cc.

149 {
150  float res(std::numeric_limits<float>::max());
151  const TVector3 showerStart3(shower.ShowerStart());
152  const geo::Point_t showerStart(showerStart3.X(), showerStart3.Y(), showerStart3.Z());
153 
154  // Loop over the cosmic PFPs and find the closest
155  for (auto const& cosmicPFP : cosmicPFPs) {
156  auto const& pfpSPs(fmPFPSP.at(cosmicPFP.key()));
157  // Loop over all of the spacepoints in the PFP and find the closest
158  for (auto const& sp : pfpSPs) {
159  const float dist((showerStart - sp->position()).r());
160  res = std::min(res, dist);
161  }
162  }
163  return res;
164 }
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
const TVector3 & ShowerStart() const
Definition: Shower.h:192
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
esac echo uname r
const std::vector< art::Ptr< recob::PFParticle > > sbn::ShowerCosmicDistance::GetCosmicPFPs ( const std::vector< art::Ptr< recob::PFParticle >> &  pfps,
const art::FindManyP< larpandoraobj::PFParticleMetadata fmPFPMeta 
) const
private

Definition at line 121 of file ShowerCosmicDistance_module.cc.

124 {
125  std::vector<art::Ptr<recob::PFParticle>> cosmicPFPs;
126  for (auto const& pfp : pfps) {
127 
128  if (!pfp->IsPrimary())
129  continue;
130 
131  auto const& pfpMetaVec(fmPFPMeta.at(pfp.key()));
132  if (pfpMetaVec.size() != 1)
133  throw cet::exception("ShowerCosmicDistance") << "Wrong metadata entries for PFP: " << pfpMetaVec.size() << ". Stopping";
134 
135  // Ignore anything that is not a clear cosmic
136  if (!pfpMetaVec.front()->GetPropertiesMap().count("IsClearCosmic"))
137  continue;
138 
139  // TODO: Should expand to check for T0 tags from CRT/Flash matching
140 
141  cosmicPFPs.push_back(pfp);
142  }
143  return cosmicPFPs;
144 }
ShowerCosmicDistance& sbn::ShowerCosmicDistance::operator= ( ShowerCosmicDistance const &  )
delete
ShowerCosmicDistance& sbn::ShowerCosmicDistance::operator= ( ShowerCosmicDistance &&  )
delete
void sbn::ShowerCosmicDistance::produce ( art::Event &  e)
override

Definition at line 77 of file ShowerCosmicDistance_module.cc.

78 {
79  //Get the showers
80  auto const showerHandle = e.getValidHandle<std::vector<recob::Shower>>(fShowerLabel);
81  auto const pfpHandle = e.getValidHandle<std::vector<recob::PFParticle>>(fPandoraLabel);
82 
83  std::vector<art::Ptr<recob::Shower>> showers;
84  art::fill_ptr_vector(showers, showerHandle);
85 
86  std::vector<art::Ptr<recob::PFParticle>> pfps;
87  art::fill_ptr_vector(pfps, pfpHandle);
88 
89  const art::FindManyP<larpandoraobj::PFParticleMetadata> fmPFPMeta(pfpHandle, e, fPandoraLabel);
90  if (!fmPFPMeta.isValid()) {
91  throw cet::exception("ShowerCosmicDistance") << "PFP-Meta association is somehow not valid. Stopping";
92  return;
93  }
94  const art::FindManyP<recob::SpacePoint> fmPFPSP(pfpHandle, e, fPandoraLabel);
95  if (!fmPFPSP.isValid()) {
96  throw cet::exception("ShowerCosmicDistance") << "PFP-SP association is somehow not valid. Stopping";
97  return;
98  }
99 
100  const std::vector<art::Ptr<recob::PFParticle>> cosmicPFPs(GetCosmicPFPs(pfps, fmPFPMeta));
101 
102  std::unique_ptr<std::vector<float>> residualCol(std::make_unique<std::vector<float>>());
103  std::unique_ptr<art::Assns<recob::Shower, float>> residualAssns(std::make_unique<art::Assns<recob::Shower, float>>());
104 
105  for (auto const& shower : showers) {
106 
107  // To reduce the combinatorics, put a minumum energy cut on the showers we consider
108  if (shower->best_plane() < 0 || shower->Energy().at(shower->best_plane()) < fMinShowerEnergy)
109  continue;
110 
111  const float res(FindShowerResidual(*shower, cosmicPFPs, fmPFPSP));
112 
113  residualCol->push_back(res);
114  util::CreateAssn(*this, e, *residualCol, shower, *residualAssns);
115  }
116 
117  e.put(std::move(residualCol));
118  e.put(std::move(residualAssns));
119 }
const std::vector< art::Ptr< recob::PFParticle > > GetCosmicPFPs(const std::vector< art::Ptr< recob::PFParticle >> &pfps, const art::FindManyP< larpandoraobj::PFParticleMetadata > fmPFPMeta) const
process_name shower
Definition: cheaterreco.fcl:51
const float FindShowerResidual(const recob::Shower &shower, const std::vector< art::Ptr< recob::PFParticle >> &cosmicPFPs, const art::FindManyP< recob::SpacePoint > &fmPFPSP) const
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
do i e

Member Data Documentation

const float sbn::ShowerCosmicDistance::fMinShowerEnergy
private

Definition at line 57 of file ShowerCosmicDistance_module.cc.

const art::InputTag sbn::ShowerCosmicDistance::fPandoraLabel
private

Definition at line 54 of file ShowerCosmicDistance_module.cc.

const art::InputTag sbn::ShowerCosmicDistance::fShowerLabel
private

Definition at line 55 of file ShowerCosmicDistance_module.cc.


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