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

Public Member Functions

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

Private Attributes

int fVerbose
 
bool fUsePandoraVertex
 
art::InputTag fHitModuleLabel
 
art::InputTag fPFParticleLabel
 
std::string fInitialTrackHitsInputLabel
 
std::string fShowerStartPositionInputLabel
 
std::string fInitialTrackInputLabel
 
std::string fShowerDirectionOutputLabel
 

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

Constructor & Destructor Documentation

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

Definition at line 41 of file ShowerTrackHitDirection_tool.cc.

42  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
43  , fVerbose(pset.get<int>("Verbose"))
44  , fUsePandoraVertex(pset.get<bool>("UsePandoraVertex"))
45  , fHitModuleLabel(pset.get<art::InputTag>("HitModuleLabel"))
46  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
47  , fInitialTrackHitsInputLabel(pset.get<std::string>("InitialTrackHitsInputLabel"))
48  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
49  , fInitialTrackInputLabel(pset.get<std::string>("InitialTrackInputLabel"))
50  , fShowerDirectionOutputLabel(pset.get<std::string>("ShowerDirectionOutputLabel"))
51  {}
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::ShowerTrackHitDirection::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 54 of file ShowerTrackHitDirection_tool.cc.

57  {
58 
59  //Check the Track Hits has been defined
60  if (!ShowerEleHolder.CheckElement(fInitialTrackHitsInputLabel)) {
61  if (fVerbose)
62  mf::LogError("ShowerTrackHitDirection") << "Initial track hits not set" << std::endl;
63  return 0;
64  }
65 
66  //Check the start position is set.
68  if (fVerbose)
69  mf::LogError("ShowerTrackHitDirection")
70  << "Start position not set, returning " << std::endl;
71  return 0;
72  }
73 
74  //Get the start poistion
75  TVector3 StartPosition = {-999, -999, -99};
76  if (fUsePandoraVertex) {
77  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, StartPosition);
78  }
79  else {
80  //Check the Tracks has been defined
81  if (!ShowerEleHolder.CheckElement(fInitialTrackInputLabel)) {
82  if (fVerbose)
83  mf::LogError("ShowerTrackHitDirection") << "Initial track not set" << std::endl;
84  return 0;
85  }
86  recob::Track InitialTrack;
87  ShowerEleHolder.GetElement(fInitialTrackInputLabel, InitialTrack);
88  geo::Point_t Start_point = InitialTrack.Start();
89  StartPosition = {Start_point.X(), Start_point.Y(), Start_point.Z()};
90  }
91 
92  //Get the spacepoints associated to hits
93  auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
94 
95  //Get the spacepoint handle. We need to do this in 3D.
96  const art::FindManyP<recob::SpacePoint>& fmsp =
97  ShowerEleHolder.GetFindManyP<recob::SpacePoint>(hitHandle, Event, fPFParticleLabel);
98 
99  //Get the initial track hits.
100  std::vector<art::Ptr<recob::Hit>> InitialTrackHits;
101  ShowerEleHolder.GetElement(fInitialTrackHitsInputLabel, InitialTrackHits);
102 
103  //Calculate the mean direction and the the standard deviation
104  float sumX = 0, sumX2 = 0;
105  float sumY = 0, sumY2 = 0;
106  float sumZ = 0, sumZ2 = 0;
107 
108  //Get the spacepoints associated to the track hit
109  std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
110  for (auto const hit : InitialTrackHits) {
111  std::vector<art::Ptr<recob::SpacePoint>> sps = fmsp.at(hit.key());
112  for (auto const sp : sps) {
113  intitaltrack_sp.push_back(sp);
114 
115  //Get the direction relative to the start positon
116  TVector3 pos = IShowerTool::GetLArPandoraShowerAlg().SpacePointPosition(sp) - StartPosition;
117  if (pos.Mag() == 0) { continue; }
118 
119  sumX = pos.X();
120  sumX2 += pos.X() * pos.X();
121  sumY = pos.Y();
122  sumY2 += pos.Y() * pos.Y();
123  sumZ = pos.Z();
124  sumZ2 += pos.Z() * pos.Z();
125  }
126  }
127 
128  float NumSps = intitaltrack_sp.size();
129  TVector3 Mean = {sumX / NumSps, sumY / NumSps, sumZ / NumSps};
130  Mean = Mean.Unit();
131 
132  float RMSX = 999;
133  float RMSY = 999;
134  float RMSZ = 999;
135  if (sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))) > 0) {
136  RMSX = std::sqrt(sumX2 / NumSps - ((sumX / NumSps) * ((sumX / NumSps))));
137  }
138  if (sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))) > 0) {
139  RMSY = std::sqrt(sumY2 / NumSps - ((sumY / NumSps) * ((sumY / NumSps))));
140  }
141  if (sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))) > 0) {
142  RMSZ = std::sqrt(sumZ2 / NumSps - ((sumZ / NumSps) * ((sumZ / NumSps))));
143  }
144 
145  //Loop over the spacepoints and remove ones the relative direction is not within one sigma.
146  TVector3 Direction_Mean = {0, 0, 0};
147  int N = 0;
148  for (auto const sp : intitaltrack_sp) {
149  TVector3 Direction =
151  if ((std::abs((Direction - Mean).X()) < 1 * RMSX) &&
152  (std::abs((Direction - Mean).Y()) < 1 * RMSY) &&
153  (std::abs((Direction - Mean).Z()) < 1 * RMSZ)) {
154  if (Direction.Mag() == 0) { continue; }
155  ++N;
156  Direction_Mean += Direction;
157  }
158  }
159 
160  if (N > 0) {
161  //Take the mean value
162  TVector3 Direction = Direction_Mean.Unit();
163  ShowerEleHolder.SetElement(Direction, fShowerDirectionOutputLabel);
164  }
165  else {
166  if (fVerbose)
167  mf::LogError("ShowerTrackHitDirection")
168  << "None of the points are within 1 sigma" << std::endl;
169  return 1;
170  }
171  return 0;
172  }
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
T abs(T value)
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:123
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
Detector simulation of raw signals on wires.
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:87
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
Direction
Definition: AssnsIter.h:13
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
QTextStream & endl(QTextStream &s)
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const

Member Data Documentation

art::InputTag ShowerRecoTools::ShowerTrackHitDirection::fHitModuleLabel
private

Definition at line 32 of file ShowerTrackHitDirection_tool.cc.

std::string ShowerRecoTools::ShowerTrackHitDirection::fInitialTrackHitsInputLabel
private

Definition at line 35 of file ShowerTrackHitDirection_tool.cc.

std::string ShowerRecoTools::ShowerTrackHitDirection::fInitialTrackInputLabel
private

Definition at line 37 of file ShowerTrackHitDirection_tool.cc.

art::InputTag ShowerRecoTools::ShowerTrackHitDirection::fPFParticleLabel
private

Definition at line 33 of file ShowerTrackHitDirection_tool.cc.

std::string ShowerRecoTools::ShowerTrackHitDirection::fShowerDirectionOutputLabel
private

Definition at line 38 of file ShowerTrackHitDirection_tool.cc.

std::string ShowerRecoTools::ShowerTrackHitDirection::fShowerStartPositionInputLabel
private

Definition at line 36 of file ShowerTrackHitDirection_tool.cc.

bool ShowerRecoTools::ShowerTrackHitDirection::fUsePandoraVertex
private

Definition at line 30 of file ShowerTrackHitDirection_tool.cc.

int ShowerRecoTools::ShowerTrackHitDirection::fVerbose
private

Definition at line 29 of file ShowerTrackHitDirection_tool.cc.


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