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

Public Member Functions

 ShowerLengthPercentile (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
- Public 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)
 

Private Attributes

float fPercentile
 
art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerStartPositionInputLabel
 
std::string fShowerDirectionInputLabel
 
std::string fShowerLengthOutputLabel
 
std::string fShowerOpeningAngleOutputLabel
 

Additional Inherited Members

- Protected Member Functions inherited from ShowerRecoTools::IShowerTool
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 19 of file ShowerLengthPercentile_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 40 of file ShowerLengthPercentile_tool.cc.

41  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
42  , fPercentile(pset.get<float>("Percentile"))
43  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
44  , fVerbose(pset.get<int>("Verbose"))
45  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
46  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
47  , fShowerLengthOutputLabel(pset.get<std::string>("ShowerLengthOutputLabel"))
48  , fShowerOpeningAngleOutputLabel(pset.get<std::string>("ShowerOpeningAngleOutputLabel"))
49  {}
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:29

Member Function Documentation

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

Implements ShowerRecoTools::IShowerTool.

Definition at line 52 of file ShowerLengthPercentile_tool.cc.

55  {
56 
57  //Get the start position
58  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
59  if (fVerbose)
60  mf::LogError("ShowerLengthPercentile") << "Start position not set, returning " << std::endl;
61  return 1;
62  }
63  //Only consider hits in the same tpcs as the vertex.
64  TVector3 ShowerStartPosition = {-999, -999, -999};
65  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
66 
67  // Get the assocated pfParicle Handle
68  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
69 
70  // Get the spacepoint - PFParticle assn
71  const art::FindManyP<recob::SpacePoint>& fmspp =
72  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(pfpHandle, Event, fPFParticleLabel);
73 
74  // Get the SpacePoints
75  std::vector<art::Ptr<recob::SpacePoint>> spacePoints = fmspp.at(pfparticle.key());
76  if (spacePoints.empty()) {
77  if (fVerbose)
78  mf::LogError("ShowerLengthPercentile") << "No Spacepoints, returning" << std::endl;
79  return 1;
80  }
81 
82  if (!ShowerEleHolder.CheckElement(fShowerDirectionInputLabel)) {
83  if (fVerbose)
84  mf::LogError("ShowerLengthPercentile") << "Direction not set, returning " << std::endl;
85  return 1;
86  }
87 
88  TVector3 ShowerDirection = {-999, -999, -999};
89  ShowerEleHolder.GetElement(fShowerDirectionInputLabel, ShowerDirection);
90 
91  //Order the spacepoints
93  spacePoints, ShowerStartPosition, ShowerDirection);
94 
95  //Find the length as the value that contains % of the hits
96  int lengthIter = fPercentile * spacePoints.size();
97 
98  //Find the length
100  spacePoints[lengthIter], ShowerStartPosition, ShowerDirection);
101  double ShowerMaxProjection = IShowerTool::GetLArPandoraShowerAlg().SpacePointProjection(
102  spacePoints[spacePoints.size() - 1], ShowerStartPosition, ShowerDirection);
103 
104  double ShowerLengthError = ShowerMaxProjection - ShowerLength;
105 
106  //Order the spacepoints in perpendicular
108  spacePoints, ShowerStartPosition, ShowerDirection);
109 
110  //Find the length as the value that contains % of the hits
111  int perpIter = fPercentile * spacePoints.size();
112 
113  //Find the width of the shower
115  spacePoints[perpIter], ShowerStartPosition, ShowerDirection);
116  // double ShowerMaxWidth = IShowerTool::GetLArPandoraShowerAlg().SpacePointPerpendicular(
117  // spacePoints[spacePoints.size() -1], ShowerStartPosition, ShowerDirection);
118 
119  double ShowerAngle = std::atan(ShowerWidth / ShowerLength);
120  double ShowerAngleError = -999; //TODO: Do properly
121 
122  // Fill the shower element holder
123  ShowerEleHolder.SetElement(ShowerLength, ShowerLengthError, fShowerLengthOutputLabel);
124  ShowerEleHolder.SetElement(ShowerAngle, ShowerAngleError, fShowerOpeningAngleOutputLabel);
125 
126  return 0;
127  }
void OrderShowerSpacePointsPerpendicular(std::vector< art::Ptr< recob::SpacePoint >> &showersps, TVector3 const &vertex, TVector3 const &direction) const
void OrderShowerSpacePoints(std::vector< art::Ptr< recob::SpacePoint >> &showersps, TVector3 const &vertex, TVector3 const &direction) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
bool CheckElement(const std::string &Name) const
double SpacePointProjection(art::Ptr< recob::SpacePoint > const &sp, TVector3 const &vertex, TVector3 const &direction) const
int GetElement(const std::string &Name, T &Element) const
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:88
double SpacePointPerpendicular(art::Ptr< recob::SpacePoint > const &sp, TVector3 const &vertex, TVector3 const &direction) const

Member Data Documentation

float ShowerRecoTools::ShowerLengthPercentile::fPercentile
private

Definition at line 30 of file ShowerLengthPercentile_tool.cc.

art::InputTag ShowerRecoTools::ShowerLengthPercentile::fPFParticleLabel
private

Definition at line 32 of file ShowerLengthPercentile_tool.cc.

std::string ShowerRecoTools::ShowerLengthPercentile::fShowerDirectionInputLabel
private

Definition at line 35 of file ShowerLengthPercentile_tool.cc.

std::string ShowerRecoTools::ShowerLengthPercentile::fShowerLengthOutputLabel
private

Definition at line 36 of file ShowerLengthPercentile_tool.cc.

std::string ShowerRecoTools::ShowerLengthPercentile::fShowerOpeningAngleOutputLabel
private

Definition at line 37 of file ShowerLengthPercentile_tool.cc.

std::string ShowerRecoTools::ShowerLengthPercentile::fShowerStartPositionInputLabel
private

Definition at line 34 of file ShowerLengthPercentile_tool.cc.

int ShowerRecoTools::ShowerLengthPercentile::fVerbose
private

Definition at line 33 of file ShowerLengthPercentile_tool.cc.


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