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

Public Member Functions

 ShowerTrackFinderCheater (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 

Private Attributes

shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg
 
const bool fDebugEVD
 
const art::InputTag fPFParticleLabel
 
const art::InputTag fHitModuleLabel
 
const std::string fTrueParticleIntputLabel
 
const std::string fShowerStartPositionInputTag
 
const std::string fShowerDirectionInputTag
 
const std::string fInitialTrackHitsOutputLabel
 
const std::string fInitialTrackSpacePointsOutputLabel
 

Additional Inherited Members

- Private Member Functions inherited from ShowerRecoTools::IShowerTool
 IShowerTool (const fhicl::ParameterSet &pset)
 
virtual ~IShowerTool () noexcept=default
 
int RunShowerTool (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, std::string evd_display_name_append="")
 
virtual void InitialiseProducers ()
 
void SetPtr (art::ProducesCollector *collector)
 
void InitaliseProducerPtr (reco::shower::ShowerProducedPtrsHolder &uniqueproducerPtrs)
 
virtual int AddAssociations (const art::Ptr< recob::PFParticle > &pfpPtr, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)
 
const shower::LArPandoraShowerAlgGetLArPandoraShowerAlg () const
 
template<class T >
art::Ptr< T > GetProducedElementPtr (std::string Name, reco::shower::ShowerElementHolder &ShowerEleHolder, int iter=-1)
 
template<class T >
void InitialiseProduct (std::string Name, std::string InstanceName="")
 
template<class T , class A , class B >
void AddSingle (A &a, B &b, std::string Name)
 
int GetVectorPtrSize (std::string Name)
 
void PrintPtrs ()
 
void PrintPtr (std::string Name)
 

Detailed Description

Definition at line 21 of file ShowerTrackFinderCheater_tool.cc.

Constructor & Destructor Documentation

ShowerRecoTools::ShowerTrackFinderCheater::ShowerTrackFinderCheater ( const fhicl::ParameterSet &  pset)

Definition at line 47 of file ShowerTrackFinderCheater_tool.cc.

48  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
49  , fLArPandoraShowerCheatingAlg(pset.get<fhicl::ParameterSet>("LArPandoraShowerCheatingAlg"))
50  , fDebugEVD(pset.get<bool>("DebugEVD"))
51  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
52  , fHitModuleLabel(pset.get<art::InputTag>("HitModuleLabel"))
53  , fTrueParticleIntputLabel(pset.get<std::string>("TrueParticleIntputLabel"))
54  , fShowerStartPositionInputTag(pset.get<std::string>("ShowerStartPositionInputTag"))
55  , fShowerDirectionInputTag(pset.get<std::string>("ShowerDirectionInputTag"))
56  , fInitialTrackHitsOutputLabel(pset.get<std::string>("InitialTrackHitsOutputLabel"))
58  pset.get<std::string>("InitialTrackSpacePointsOutputLabel"))
59  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29
shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg

Member Function Documentation

int ShowerRecoTools::ShowerTrackFinderCheater::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event &  Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 62 of file ShowerTrackFinderCheater_tool.cc.

65  {
66 
67  const simb::MCParticle* trueParticle;
68 
69  //Get the hits from the shower:
70  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
71  auto const clockData =
72  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
73 
74  //Get the clusters
75  auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
76  art::FindManyP<recob::Cluster> fmc(pfpHandle, Event, fPFParticleLabel);
77  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
78 
79  //Get the hit association
80  art::FindManyP<recob::Hit> fmhc(clusHandle, Event, fPFParticleLabel);
81 
82  std::vector<art::Ptr<recob::Hit>> showerHits;
83  for (auto const& cluster : clusters) {
84 
85  //Get the hits
86  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(cluster.key());
87  showerHits.insert(showerHits.end(), hits.begin(), hits.end());
88  }
89 
90  if (ShowerEleHolder.CheckElement(fTrueParticleIntputLabel)) {
91  ShowerEleHolder.GetElement(fTrueParticleIntputLabel, trueParticle);
92  }
93  else {
94 
95  //Could store these in the shower element holder and just calculate once?
96  std::map<int, const simb::MCParticle*> trueParticles =
98  std::map<int, std::vector<int>> showersMothers =
100 
101  //Get the true particle from the shower
102  std::pair<int, double> ShowerTrackInfo =
104  clockData, showersMothers, showerHits, 2);
105 
106  if (ShowerTrackInfo.first == -99999) {
107  mf::LogError("ShowerStartPosition") << "True Shower Not Found";
108  return 1;
109  }
110  trueParticle = trueParticles[ShowerTrackInfo.first];
111  ShowerEleHolder.SetElement(trueParticle, fTrueParticleIntputLabel);
112  }
113 
114  if (!trueParticle) {
115  mf::LogError("ShowerDirectionCheater") << "True shower not found, returning";
116  return 1;
117  }
118 
119  //This is all based on the shower vertex being known. If it is not lets not do the track
120  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputTag)) {
121  mf::LogError("ShowerTrackFinderCheater") << "Start position not set, returning " << std::endl;
122  return 1;
123  }
124  if (!ShowerEleHolder.CheckElement(fShowerDirectionInputTag)) {
125  mf::LogError("ShowerTrackFinderCheater") << "Direction not set, returning " << std::endl;
126  return 1;
127  }
128 
129  TVector3 ShowerStartPosition = {-999, -999, -999};
130  ShowerEleHolder.GetElement(fShowerStartPositionInputTag, ShowerStartPosition);
131 
132  TVector3 ShowerDirection = {-999, -999, -999};
133  ShowerEleHolder.GetElement(fShowerDirectionInputTag, ShowerDirection);
134 
135  auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
136 
137  // Get the hits associated with the space points
138  art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event, fPFParticleLabel);
139  if (!fmsph.isValid()) {
140  throw cet::exception("ShowerTrackFinderCheater")
141  << "Spacepoint and hit association not valid. Stopping.";
142  }
143 
144  std::vector<int> trueParticleIdVec;
145 
146  // If we have an electron, take the hits from the primary only
147  // This will also cover the cases Pandora misclassify a track as a shower
148  if (trueParticle->PdgCode() != 22) { trueParticleIdVec.push_back(trueParticle->TrackId()); }
149  else {
150  // To check if we are rolling up showers, check the number of daughters the photon has
151  const int nDaughters = trueParticle->NumberDaughters();
152  if (nDaughters == 0) {
153  // If we roll up showers, we have no choice but to take all of the hits from the photon
154  trueParticleIdVec.push_back(-trueParticle->TrackId());
155  }
156  else {
157  // If we do not roll up the showers, take all of the primary daughters
158  for (int i = 0; i < nDaughters; i++) {
159  trueParticleIdVec.push_back(trueParticle->Daughter(i));
160  }
161  }
162  }
163 
164  std::vector<art::Ptr<recob::Hit>> trackHits;
165  std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
166 
167  //Get the hits from the true particle
168  for (auto hit : showerHits) {
169  int trueHitId = fLArPandoraShowerCheatingAlg.TrueParticleID(clockData, hit);
170  if (std::find(trueParticleIdVec.cbegin(), trueParticleIdVec.cend(), trueHitId) !=
171  trueParticleIdVec.cend()) {
172  trackHits.push_back(hit);
173  std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(hit.key());
174  if (sps.size() == 1) { trackSpacePoints.push_back(sps.front()); }
175  }
176  }
177 
178  if (trackHits.empty() || trackSpacePoints.empty())
179  mf::LogWarning("ShowerTrackFinderCheater")
180  << "Creating intial track with " << trackHits.size() << " hits and "
181  << trackSpacePoints.size() << " spacepoints" << std::endl;
182 
183  ShowerEleHolder.SetElement(trackHits, fInitialTrackHitsOutputLabel);
184  ShowerEleHolder.SetElement(trackSpacePoints, fInitialTrackSpacePointsOutputLabel);
185 
186  if (fDebugEVD) {
188  clockData, trueParticle, Event, ShowerEleHolder, pfparticle);
189  }
190 
191  return 0;
192  }
process_name cluster
Definition: cheaterreco.fcl:51
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
process_name hit
Definition: cheaterreco.fcl:51
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
bool CheckElement(const std::string &Name) const
void CheatDebugEVD(detinfo::DetectorClocksData const &clockData, const simb::MCParticle *trueParticle, art::Event const &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, const art::Ptr< recob::PFParticle > &pfparticle) const
int GetElement(const std::string &Name, T &Element) const
int TrueParticleID(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &hit) const
std::pair< int, double > TrueParticleIDFromTrueChain(detinfo::DetectorClocksData const &clockData, std::map< int, std::vector< int >> const &ShowersMothers, std::vector< art::Ptr< recob::Hit >> const &hits, int planeid) const
shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg

Member Data Documentation

const bool ShowerRecoTools::ShowerTrackFinderCheater::fDebugEVD
private

Definition at line 36 of file ShowerTrackFinderCheater_tool.cc.

const art::InputTag ShowerRecoTools::ShowerTrackFinderCheater::fHitModuleLabel
private

Definition at line 38 of file ShowerTrackFinderCheater_tool.cc.

const std::string ShowerRecoTools::ShowerTrackFinderCheater::fInitialTrackHitsOutputLabel
private

Definition at line 43 of file ShowerTrackFinderCheater_tool.cc.

const std::string ShowerRecoTools::ShowerTrackFinderCheater::fInitialTrackSpacePointsOutputLabel
private

Definition at line 44 of file ShowerTrackFinderCheater_tool.cc.

shower::LArPandoraShowerCheatingAlg ShowerRecoTools::ShowerTrackFinderCheater::fLArPandoraShowerCheatingAlg
private

Definition at line 33 of file ShowerTrackFinderCheater_tool.cc.

const art::InputTag ShowerRecoTools::ShowerTrackFinderCheater::fPFParticleLabel
private

Definition at line 37 of file ShowerTrackFinderCheater_tool.cc.

const std::string ShowerRecoTools::ShowerTrackFinderCheater::fShowerDirectionInputTag
private

Definition at line 42 of file ShowerTrackFinderCheater_tool.cc.

const std::string ShowerRecoTools::ShowerTrackFinderCheater::fShowerStartPositionInputTag
private

Definition at line 41 of file ShowerTrackFinderCheater_tool.cc.

const std::string ShowerRecoTools::ShowerTrackFinderCheater::fTrueParticleIntputLabel
private

Definition at line 40 of file ShowerTrackFinderCheater_tool.cc.


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