Public Member Functions | Private Attributes | List of all members
ShowerRecoTools::ShowerStartPositionCheater Class Reference
Inheritance diagram for ShowerRecoTools::ShowerStartPositionCheater:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerStartPositionCheater (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 art::InputTag fPFParticleLabel
 
const art::InputTag fHitModuleLabel
 
const std::string fShowerStartPositionOutputLabel
 
const std::string fTrueParticleOutputLabel
 

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 18 of file ShowerStartPositionCheater_tool.cc.

Constructor & Destructor Documentation

ShowerRecoTools::ShowerStartPositionCheater::ShowerStartPositionCheater ( const fhicl::ParameterSet pset)

Definition at line 40 of file ShowerStartPositionCheater_tool.cc.

41  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
42  , fLArPandoraShowerCheatingAlg(pset.get<fhicl::ParameterSet>("LArPandoraShowerCheatingAlg"))
43  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
44  , fHitModuleLabel(pset.get<art::InputTag>("HitModuleLabel"))
45  , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
46  , fTrueParticleOutputLabel(pset.get<std::string>("TrueParticleOutputLabel"))
47  {}
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28

Member Function Documentation

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

Implements ShowerRecoTools::IShowerTool.

Definition at line 50 of file ShowerStartPositionCheater_tool.cc.

53  {
54 
55  //Could store these in the shower element holder and just calculate once?
56  std::map<int, const simb::MCParticle*> trueParticles =
58  std::map<int, std::vector<int>> showersMothers =
60 
61  //Get the hits from the shower:
62  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
63 
64  //Get the clusters
65  auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
66 
67  art::FindManyP<recob::Cluster> fmc(pfpHandle, Event, fPFParticleLabel);
68  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
69 
70  //Get the hit association
71  art::FindManyP<recob::Hit> fmhc(clusHandle, Event, fPFParticleLabel);
72 
73  std::vector<art::Ptr<recob::Hit>> showerHits;
74  for (auto const& cluster : clusters) {
75 
76  //Get the hits
77  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(cluster.key());
78  showerHits.insert(showerHits.end(), hits.begin(), hits.end());
79  }
80 
81  //Get the true particle from the shower
82  auto const clockData =
84 
85  std::pair<int, double> ShowerTrackInfo =
87  clockData, showersMothers, showerHits, 2);
88 
89  if (ShowerTrackInfo.first == -99999) {
90  mf::LogError("ShowerStartPositionCheater") << "True Shower Not Found";
91  return 1;
92  }
93 
94  const simb::MCParticle* trueParticle = trueParticles[ShowerTrackInfo.first];
95  if (!trueParticle) {
96  mf::LogError("ShowerDirectionCheater") << "True shower not found, returning";
97  return 1;
98  }
99 
100  ShowerEleHolder.SetElement(trueParticle, fTrueParticleOutputLabel);
101 
102  TVector3 trueStartPos = {-999, -999, -999};
103  // If the true particle is a photon, we need to be smarter.
104  // Select the first traj point where tne photon loses energy
105  if (abs(trueParticle->PdgCode()) == 22) {
106  double initialEnergy = trueParticle->E();
107  unsigned int TrajPoints = trueParticle->NumberTrajectoryPoints();
108  for (unsigned int trajPoint = 0; trajPoint < TrajPoints; trajPoint++) {
109  if (trueParticle->E(trajPoint) < initialEnergy) {
110  trueStartPos = trueParticle->Position(trajPoint).Vect();
111  break;
112  }
113  }
114  }
115  else {
116  trueStartPos = trueParticle->Position().Vect();
117  }
118 
119  TVector3 trueStartPosErr = {-999, -999, -999};
120  ShowerEleHolder.SetElement(trueStartPos, trueStartPosErr, fShowerStartPositionOutputLabel);
121 
122  return 0;
123  }
double E(const int i=0) const
Definition: MCParticle.h:233
unsigned int NumberTrajectoryPoints() const
Definition: MCParticle.h:218
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:219
int PdgCode() const
Definition: MCParticle.h:212
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
T abs(T value)
key_type key() const noexcept
Definition: Ptr.h:216
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg
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

Member Data Documentation

const art::InputTag ShowerRecoTools::ShowerStartPositionCheater::fHitModuleLabel
private

Definition at line 34 of file ShowerStartPositionCheater_tool.cc.

shower::LArPandoraShowerCheatingAlg ShowerRecoTools::ShowerStartPositionCheater::fLArPandoraShowerCheatingAlg
private

Definition at line 30 of file ShowerStartPositionCheater_tool.cc.

const art::InputTag ShowerRecoTools::ShowerStartPositionCheater::fPFParticleLabel
private

Definition at line 33 of file ShowerStartPositionCheater_tool.cc.

const std::string ShowerRecoTools::ShowerStartPositionCheater::fShowerStartPositionOutputLabel
private

Definition at line 36 of file ShowerStartPositionCheater_tool.cc.

const std::string ShowerRecoTools::ShowerStartPositionCheater::fTrueParticleOutputLabel
private

Definition at line 37 of file ShowerStartPositionCheater_tool.cc.


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