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 17 of file ShowerLengthPercentile_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file ShowerLengthPercentile_tool.cc.

39  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
40  , fPercentile(pset.get<float>("Percentile"))
41  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
42  , fVerbose(pset.get<int>("Verbose"))
43  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
44  , fShowerDirectionInputLabel(pset.get<std::string>("ShowerDirectionInputLabel"))
45  , fShowerLengthOutputLabel(pset.get<std::string>("ShowerLengthOutputLabel"))
46  , fShowerOpeningAngleOutputLabel(pset.get<std::string>("ShowerOpeningAngleOutputLabel"))
47  {}
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:28

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 50 of file ShowerLengthPercentile_tool.cc.

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

Member Data Documentation

float ShowerRecoTools::ShowerLengthPercentile::fPercentile
private

Definition at line 28 of file ShowerLengthPercentile_tool.cc.

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

Definition at line 30 of file ShowerLengthPercentile_tool.cc.

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

Definition at line 33 of file ShowerLengthPercentile_tool.cc.

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

Definition at line 34 of file ShowerLengthPercentile_tool.cc.

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

Definition at line 35 of file ShowerLengthPercentile_tool.cc.

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

Definition at line 32 of file ShowerLengthPercentile_tool.cc.

int ShowerRecoTools::ShowerLengthPercentile::fVerbose
private

Definition at line 31 of file ShowerLengthPercentile_tool.cc.


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