All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 21 of file ShowerStartPositionCheater_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 43 of file ShowerStartPositionCheater_tool.cc.

44  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
45  , fLArPandoraShowerCheatingAlg(pset.get<fhicl::ParameterSet>("LArPandoraShowerCheatingAlg"))
46  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
47  , fHitModuleLabel(pset.get<art::InputTag>("HitModuleLabel"))
48  , fShowerStartPositionOutputLabel(pset.get<std::string>("ShowerStartPositionOutputLabel"))
49  , fTrueParticleOutputLabel(pset.get<std::string>("TrueParticleOutputLabel"))
50  {}
shower::LArPandoraShowerCheatingAlg fLArPandoraShowerCheatingAlg
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

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

56  {
57 
58  //Could store these in the shower element holder and just calculate once?
59  std::map<int, const simb::MCParticle*> trueParticles =
61  std::map<int, std::vector<int>> showersMothers =
63 
64  //Get the hits from the shower:
65  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
66 
67  //Get the clusters
68  auto const clusHandle = Event.getValidHandle<std::vector<recob::Cluster>>(fPFParticleLabel);
69 
70  art::FindManyP<recob::Cluster> fmc(pfpHandle, Event, fPFParticleLabel);
71  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.key());
72 
73  //Get the hit association
74  art::FindManyP<recob::Hit> fmhc(clusHandle, Event, fPFParticleLabel);
75 
76  std::vector<art::Ptr<recob::Hit>> showerHits;
77  for (auto const& cluster : clusters) {
78 
79  //Get the hits
80  std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(cluster.key());
81  showerHits.insert(showerHits.end(), hits.begin(), hits.end());
82  }
83 
84  //Get the true particle from the shower
85  auto const clockData =
86  art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(Event);
87 
88  std::pair<int, double> ShowerTrackInfo =
90  clockData, showersMothers, showerHits, 2);
91 
92  if (ShowerTrackInfo.first == -99999) {
93  mf::LogError("ShowerStartPositionCheater") << "True Shower Not Found";
94  return 1;
95  }
96 
97  const simb::MCParticle* trueParticle = trueParticles[ShowerTrackInfo.first];
98  if (!trueParticle) {
99  mf::LogError("ShowerDirectionCheater") << "True shower not found, returning";
100  return 1;
101  }
102 
103  ShowerEleHolder.SetElement(trueParticle, fTrueParticleOutputLabel);
104 
105  TVector3 trueStartPos = {-999, -999, -999};
106  // If the true particle is a photon, we need to be smarter.
107  // Select the first traj point where tne photon loses energy
108  if (abs(trueParticle->PdgCode()) == 22) {
109  double initialEnergy = trueParticle->E();
110  unsigned int TrajPoints = trueParticle->NumberTrajectoryPoints();
111  for (unsigned int trajPoint = 0; trajPoint < TrajPoints; trajPoint++) {
112  if (trueParticle->E(trajPoint) < initialEnergy) {
113  trueStartPos = trueParticle->Position(trajPoint).Vect();
114  break;
115  }
116  }
117  }
118  else {
119  trueStartPos = trueParticle->Position().Vect();
120  }
121 
122  TVector3 trueStartPosErr = {-999, -999, -999};
123  ShowerEleHolder.SetElement(trueStartPos, trueStartPosErr, fShowerStartPositionOutputLabel);
124 
125  return 0;
126  }
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)
T abs(T value)
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
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 37 of file ShowerStartPositionCheater_tool.cc.

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

Definition at line 33 of file ShowerStartPositionCheater_tool.cc.

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

Definition at line 36 of file ShowerStartPositionCheater_tool.cc.

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

Definition at line 39 of file ShowerStartPositionCheater_tool.cc.

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

Definition at line 40 of file ShowerStartPositionCheater_tool.cc.


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