LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerRecoTools::ShowerTrajPointdEdx Class Reference
Inheritance diagram for ShowerRecoTools::ShowerTrajPointdEdx:
ShowerRecoTools::IShowerTool

Public Member Functions

 ShowerTrajPointdEdx (const fhicl::ParameterSet &pset)
 
int CalculateElement (const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
 
void FinddEdxLength (std::vector< double > &dEdx_vec, std::vector< double > &dEdx_val)
 

Private Member Functions

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)
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeom
 
calo::CalorimetryAlg fCalorimetryAlg
 
float fMinAngleToWire
 
float fShapingTime
 
float fMinDistCutOff
 
float fMaxDist
 
float MaxDist
 
float fdEdxTrackLength
 
float dEdxTrackLength
 
float fdEdxCut
 
bool fUseMedian
 
bool fCutStartPosition
 
bool fT0Correct
 
bool fSCECorrectPitch
 
bool fSCECorrectEField
 
bool fSCEInputCorrected
 
bool fSumHitSnippets
 
art::InputTag fPFParticleLabel
 
int fVerbose
 
std::string fShowerStartPositionInputLabel
 
std::string fInitialTrackHitsInputLabel
 
std::string fInitialTrackSpacePointsInputLabel
 
std::string fInitialTrackInputLabel
 
std::string fShowerdEdxOutputLabel
 
std::string fShowerBestPlaneOutputLabel
 
std::string fShowerdEdxVecOutputLabel
 

Detailed Description

Definition at line 32 of file ShowerTrajPointdEdx_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 87 of file ShowerTrajPointdEdx_tool.cc.

References fSCECorrectEField, fSCECorrectPitch, and fSCEInputCorrected.

88  : IShowerTool(pset.get<fhicl::ParameterSet>("BaseTools"))
89  , fCalorimetryAlg(pset.get<fhicl::ParameterSet>("CalorimetryAlg"))
90  , fMinAngleToWire(pset.get<float>("MinAngleToWire"))
91  , fShapingTime(pset.get<float>("ShapingTime"))
92  , fMinDistCutOff(pset.get<float>("MinDistCutOff"))
93  , fMaxDist(pset.get<float>("MaxDist"))
94  , fdEdxTrackLength(pset.get<float>("dEdxTrackLength"))
95  , fdEdxCut(pset.get<float>("dEdxCut"))
96  , fUseMedian(pset.get<bool>("UseMedian"))
97  , fCutStartPosition(pset.get<bool>("CutStartPosition"))
98  , fT0Correct(pset.get<bool>("T0Correct"))
99  , fSCECorrectPitch(pset.get<bool>("SCECorrectPitch"))
100  , fSCECorrectEField(pset.get<bool>("SCECorrectEField"))
101  , fSCEInputCorrected(pset.get<bool>("SCEInputCorrected"))
102  , fSumHitSnippets(pset.get<bool>("SumHitSnippets"))
103  , fPFParticleLabel(pset.get<art::InputTag>("PFParticleLabel"))
104  , fVerbose(pset.get<int>("Verbose"))
105  , fShowerStartPositionInputLabel(pset.get<std::string>("ShowerStartPositionInputLabel"))
106  , fInitialTrackHitsInputLabel(pset.get<std::string>("InitialTrackHitsInputLabel"))
107  , fInitialTrackSpacePointsInputLabel(pset.get<std::string>("InitialTrackSpacePointsInputLabel"))
108  , fInitialTrackInputLabel(pset.get<std::string>("InitialTrackInputLabel"))
109  , fShowerdEdxOutputLabel(pset.get<std::string>("ShowerdEdxOutputLabel"))
110  , fShowerBestPlaneOutputLabel(pset.get<std::string>("ShowerBestPlaneOutputLabel"))
111  , fShowerdEdxVecOutputLabel(pset.get<std::string>("ShowerdEdxVecOutputLabel"))
112  {
114  throw cet::exception("ShowerTrajPointdEdx")
115  << "Can only correct for SCE if input is already corrected" << std::endl;
116  }
117  }
T get(std::string const &key) const
Definition: ParameterSet.h:314
IShowerTool(const fhicl::ParameterSet &pset)
Definition: IShowerTool.h:33
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Function Documentation

virtual int ShowerRecoTools::IShowerTool::AddAssociations ( const art::Ptr< recob::PFParticle > &  pfpPtr,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
inlinevirtualinherited
template<class T , class A , class B >
void ShowerRecoTools::IShowerTool::AddSingle ( A &  a,
B &  b,
std::string  Name 
)
inlineprotectedinherited

Definition at line 152 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::AddSingle().

153  {
154  UniquePtrs->AddSingle<T>(a, b, Name);
155  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void AddSingle(A &a, B &b, const std::string &Name)
int ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder 
)
overridevirtual

Implements ShowerRecoTools::IShowerTool.

Definition at line 119 of file ShowerTrajPointdEdx_tool.cc.

References util::abs(), geo::TPCID::asTPCID(), reco::shower::ShowerElementHolder::CheckElement(), tca::dEdx(), calo::CalorimetryAlg::dEdx_AREA(), dEdxTrackLength, recob::Track::DirectionAtPoint(), larg4::dist(), fCalorimetryAlg, fCutStartPosition, fdEdxTrackLength, fGeom, FinddEdxLength(), geo::GeometryCore::FindTPCAtPosition(), fInitialTrackHitsInputLabel, fInitialTrackInputLabel, fInitialTrackSpacePointsInputLabel, recob::Track::FlagsAtPoint(), fMaxDist, fMinAngleToWire, fMinDistCutOff, fPFParticleLabel, fSCECorrectEField, fSCECorrectPitch, fShapingTime, fShowerBestPlaneOutputLabel, fShowerdEdxOutputLabel, fShowerdEdxVecOutputLabel, fShowerStartPositionInputLabel, fSumHitSnippets, fT0Correct, fUseMedian, fVerbose, reco::shower::ShowerElementHolder::GetElement(), reco::shower::ShowerElementHolder::GetFindManyP(), geo::PlaneGeo::GetIncreasingWireDirection(), ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg(), art::ProductRetriever::getValidHandle(), hits(), recob::Hit::Integral(), geo::GeometryCore::Iterate(), art::Ptr< T >::key(), recob::Track::LocationAtPoint(), MaxDist, geo::GeometryCore::MaxPlanes(), recob::TrajectoryPointFlagTraits::NoPoint, recob::Track::NumberTrajectoryPoints(), shower::LArPandoraShowerAlg::OrganizeHits(), recob::Hit::PeakTime(), geo::PlaneID::Plane, geo::GeometryCore::Plane(), shower::LArPandoraShowerAlg::SCECorrectEField(), shower::LArPandoraShowerAlg::SCECorrectPitch(), reco::shower::ShowerElementHolder::SetElement(), geo::TPCID::TPC, recob::Hit::WireID(), and geo::GeometryCore::WirePitch().

122  {
123 
124  MaxDist = fMaxDist;
126 
127  // Shower dEdx calculation
128  if (!ShowerEleHolder.CheckElement(fShowerStartPositionInputLabel)) {
129  if (fVerbose)
130  mf::LogError("ShowerTrajPointdEdx") << "Start position not set, returning " << std::endl;
131  return 1;
132  }
133  if (!ShowerEleHolder.CheckElement(fInitialTrackSpacePointsInputLabel)) {
134  if (fVerbose)
135  mf::LogError("ShowerTrajPointdEdx")
136  << "Initial Track Spacepoints is not set returning" << std::endl;
137  return 1;
138  }
139  if (!ShowerEleHolder.CheckElement(fInitialTrackInputLabel)) {
140  if (fVerbose) mf::LogError("ShowerTrajPointdEdx") << "Initial Track is not set" << std::endl;
141  return 1;
142  }
143 
144  //Get the initial track hits
145  std::vector<art::Ptr<recob::SpacePoint>> tracksps;
146  ShowerEleHolder.GetElement(fInitialTrackSpacePointsInputLabel, tracksps);
147 
148  if (tracksps.empty()) {
149  if (fVerbose)
150  mf::LogWarning("ShowerTrajPointdEdx") << "no spacepointsin the initial track" << std::endl;
151  return 0;
152  }
153 
154  // Get the spacepoints
155  auto const spHandle = Event.getValidHandle<std::vector<recob::SpacePoint>>(fPFParticleLabel);
156 
157  // Get the hits associated with the space points
158  const art::FindManyP<recob::Hit>& fmsp =
159  ShowerEleHolder.GetFindManyP<recob::Hit>(spHandle, Event, fPFParticleLabel);
160 
161  //Only consider hits in the same tpcs as the vertex.
162  geo::Point_t ShowerStartPosition = {-999, -999, -999};
163  ShowerEleHolder.GetElement(fShowerStartPositionInputLabel, ShowerStartPosition);
164  geo::TPCID vtxTPC = fGeom->FindTPCAtPosition(ShowerStartPosition);
165 
166  //Get the initial track
167  recob::Track InitialTrack;
168  ShowerEleHolder.GetElement(fInitialTrackInputLabel, InitialTrack);
169 
170  double pfpT0Time(0); // If no T0 found, assume the particle happened at trigger time (0)
171  if (fT0Correct) {
172  auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(fPFParticleLabel);
173  const art::FindManyP<anab::T0>& fmpfpt0 =
174  ShowerEleHolder.GetFindManyP<anab::T0>(pfpHandle, Event, fPFParticleLabel);
175  std::vector<art::Ptr<anab::T0>> pfpT0Vec = fmpfpt0.at(pfparticle.key());
176  if (pfpT0Vec.size() == 1) { pfpT0Time = pfpT0Vec.front()->Time(); }
177  }
178 
179  //Don't care that I could use a vector.
180  std::map<int, std::vector<double>> dEdx_vec;
181  std::map<int, std::vector<double>> dEdx_vecErr;
182  std::map<int, int> num_hits;
183 
184  for (unsigned i = 0; i != fGeom->MaxPlanes(); ++i) {
185  dEdx_vec[i] = {};
186  dEdx_vecErr[i] = {};
187  num_hits[i] = 0;
188  }
189 
190  auto const clockData =
192  auto const detProp =
194 
195  std::map<art::Ptr<recob::Hit>, std::vector<art::Ptr<recob::Hit>>> hitSnippets;
196  if (fSumHitSnippets) {
197  std::vector<art::Ptr<recob::Hit>> trackHits;
198  ShowerEleHolder.GetElement(fInitialTrackHitsInputLabel, trackHits);
199 
200  hitSnippets = IShowerTool::GetLArPandoraShowerAlg().OrganizeHits(trackHits);
201  }
202 
203  //Loop over the spacepoints
204  for (auto const& sp : tracksps) {
205 
206  //Get the associated hit
207  std::vector<art::Ptr<recob::Hit>> hits = fmsp.at(sp.key());
208  if (hits.empty()) {
209  if (fVerbose)
210  mf::LogWarning("ShowerTrajPointdEdx")
211  << "no hit for the spacepoint. This suggest the find many is wrong." << std::endl;
212  continue;
213  }
214  const art::Ptr<recob::Hit> hit = hits[0];
215 
216  if (fSumHitSnippets && !hitSnippets.count(hit)) continue;
217 
218  double wirepitch = fGeom->WirePitch((geo::PlaneID)hit->WireID());
219 
220  //Only consider hits in the same tpc
221  geo::PlaneID planeid = hit->WireID();
222  geo::TPCID TPC = planeid.asTPCID();
223  if (TPC != vtxTPC) { continue; }
224 
225  //Ignore spacepoints within a few wires of the vertex.
226  auto const pos = sp->position();
227  double dist_from_start = (pos - ShowerStartPosition).R();
228 
229  if (fCutStartPosition) {
230  if (dist_from_start < fMinDistCutOff * wirepitch) { continue; }
231 
232  if (dist_from_start > dEdxTrackLength) { continue; }
233  }
234 
235  //Find the closest trajectory point of the track. These should be in order if the user has used ShowerTrackTrajToSpacePoint_tool but the sake of gernicness I'll get the cloest sp.
236  unsigned int index = 999;
237  double MinDist = 999;
238  for (unsigned int traj = 0; traj < InitialTrack.NumberTrajectoryPoints(); ++traj) {
239 
240  //ignore bogus info.
241  auto flags = InitialTrack.FlagsAtPoint(traj);
242  if (flags.isSet(recob::TrajectoryPointFlagTraits::NoPoint)) { continue; }
243 
244  geo::Point_t const TrajPosition = InitialTrack.LocationAtPoint(traj);
245 
246  auto const dist = (pos - TrajPosition).R();
247 
248  if (dist < MinDist && dist < MaxDist * wirepitch) {
249  MinDist = dist;
250  index = traj;
251  }
252  }
253 
254  //If there is no matching trajectory point then bail.
255  if (index == 999) { continue; }
256 
257  geo::Point_t const TrajPosition = InitialTrack.LocationAtPoint(index);
258  geo::Point_t const TrajPositionStart = InitialTrack.LocationAtPoint(0);
259 
260  //Ignore values with 0 mag from the start position
261  if ((TrajPosition - TrajPositionStart).R() == 0) { continue; }
262  if ((TrajPosition - ShowerStartPosition).R() == 0) { continue; }
263 
264  if ((TrajPosition - TrajPositionStart).R() < fMinDistCutOff * wirepitch) { continue; }
265 
266  //Get the direction of the trajectory point
267  geo::Vector_t const TrajDirection = InitialTrack.DirectionAtPoint(index);
268 
269  //If the direction is in the same direction as the wires within some tolerance the hit finding struggles. Let remove these.
270  // Note that we project in the YZ plane to make sure we are not cutting on
271  // the angle into the wire planes, that should be done by the shaping time cut
272  geo::Vector_t const TrajDirectionYZ{0, TrajDirection.Y(), TrajDirection.Z()};
273  auto const PlaneDirection = fGeom->Plane(planeid).GetIncreasingWireDirection();
274 
275  if (std::abs((TMath::Pi() / 2 - Angle(TrajDirectionYZ, PlaneDirection))) < fMinAngleToWire) {
276  if (fVerbose) mf::LogWarning("ShowerTrajPointdEdx") << "remove from angle cut" << std::endl;
277  continue;
278  }
279 
280  //If the direction is too much into the wire plane then the shaping amplifer cuts the charge. Lets remove these events.
281  double velocity = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
282  double distance_in_x = TrajDirection.X() * (wirepitch / TrajDirection.Dot(PlaneDirection));
283  double time_taken = std::abs(distance_in_x / velocity);
284 
285  //Shaping time doesn't seem to exist in a global place so add it as a fcl.
286  if (fShapingTime < time_taken) {
287  if (fVerbose) mf::LogWarning("ShowerTrajPointdEdx") << "move for shaping time" << std::endl;
288  continue;
289  }
290 
291  if ((TrajPosition - TrajPositionStart).R() > dEdxTrackLength) { continue; }
292 
293  //Iterate the number of hits on the plane
294  ++num_hits[planeid.Plane];
295 
296  //If we still exist then we can be used in the calculation. Calculate the 3D pitch
297  double trackpitch = (TrajDirection * (wirepitch / TrajDirection.Dot(PlaneDirection))).R();
298 
299  if (fSCECorrectPitch) {
301  trackpitch, pos, TrajDirection.Unit(), hit->WireID().TPC);
302  }
303 
304  //Calculate the dQdx
305  double dQdx = hit->Integral();
306  if (fSumHitSnippets) {
307  for (const art::Ptr<recob::Hit> secondaryHit : hitSnippets[hit])
308  dQdx += secondaryHit->Integral();
309  }
310  dQdx /= trackpitch;
311 
312  //Calculate the dEdx
313  double localEField = detProp.Efield();
314  if (fSCECorrectEField) {
315  localEField = IShowerTool::GetLArPandoraShowerAlg().SCECorrectEField(localEField, pos);
316  }
317  double dEdx = fCalorimetryAlg.dEdx_AREA(
318  clockData, detProp, dQdx, hit->PeakTime(), planeid.Plane, pfpT0Time, localEField);
319 
320  //Add the value to the dEdx
321  dEdx_vec[planeid.Plane].push_back(dEdx);
322  }
323 
324  //Choose max hits based on hitnum
325  int max_hits = 0;
326  int best_plane = -std::numeric_limits<int>::max();
327  for (auto const& [plane, numHits] : num_hits) {
328  if (fVerbose > 2) std::cout << "Plane: " << plane << " with size: " << numHits << std::endl;
329  if (numHits > max_hits) {
330  best_plane = plane;
331  max_hits = numHits;
332  }
333  }
334 
335  if (best_plane < 0) {
336  if (fVerbose)
337  mf::LogError("ShowerTrajPointdEdx") << "No hits in any plane, returning " << std::endl;
338  return 1;
339  }
340 
341  //Search for blow ups and gradient changes.
342  //Electrons have a very flat dEdx as function of energy till ~10MeV.
343  //If there is a sudden jump particle has probably split
344  //If there is very large dEdx we have either calculated it wrong (probably) or the Electron is coming to end.
345  //Assumes hits are ordered!
346  std::map<int, std::vector<double>> dEdx_vec_cut;
347  for (geo::PlaneID plane_id : fGeom->Iterate<geo::PlaneID>()) {
348  dEdx_vec_cut[plane_id.Plane] = {};
349  }
350 
351  for (auto& dEdx_plane : dEdx_vec) {
352  FinddEdxLength(dEdx_plane.second, dEdx_vec_cut[dEdx_plane.first]);
353  }
354 
355  //Never have the stats to do a landau fit and get the most probable value. User decides if they want the median value or the mean.
356  std::vector<double> dEdx_val;
357  std::vector<double> dEdx_valErr;
358  for (auto const& dEdx_plane : dEdx_vec_cut) {
359 
360  if ((dEdx_plane.second).empty()) {
361  dEdx_val.push_back(-999);
362  dEdx_valErr.push_back(-999);
363  continue;
364  }
365 
366  if (fUseMedian) {
367  dEdx_val.push_back(TMath::Median((dEdx_plane.second).size(), &(dEdx_plane.second)[0]));
368  }
369  else {
370  //Else calculate the mean value.
371  double dEdx_mean = 0;
372  for (auto const& dEdx : dEdx_plane.second) {
373  if (dEdx > 10 || dEdx < 0) { continue; }
374  dEdx_mean += dEdx;
375  }
376  dEdx_val.push_back(dEdx_mean / (float)(dEdx_plane.second).size());
377  }
378  }
379 
380  if (fVerbose > 1) {
381  std::cout << "#Best Plane: " << best_plane << std::endl;
382  for (unsigned int plane = 0; plane < dEdx_vec.size(); plane++) {
383  std::cout << "#Plane: " << plane << " #" << std::endl;
384  std::cout << "#Median: " << dEdx_val[plane] << " #" << std::endl;
385  if (fVerbose > 2) {
386  for (auto const& dEdx : dEdx_vec_cut[plane]) {
387  std::cout << "dEdx: " << dEdx << std::endl;
388  }
389  }
390  }
391  }
392 
393  //Need to sort out errors sensibly.
394  ShowerEleHolder.SetElement(dEdx_val, dEdx_valErr, fShowerdEdxOutputLabel);
395  ShowerEleHolder.SetElement(best_plane, fShowerBestPlaneOutputLabel);
396  ShowerEleHolder.SetElement(dEdx_vec_cut, fShowerdEdxVecOutputLabel);
397  return 0;
398  }
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
Definition: GeometryCore.h:541
double SCECorrectPitch(double const &pitch, geo::Point_t const &pos, geo::Vector_t const &dir, unsigned int const &TPC) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
static constexpr Flag_t NoPoint
The trajectory point is not defined.
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
Definition: Track.h:160
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
constexpr auto abs(T v)
Returns the absolute value of the argument.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:244
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
Definition: T0.h:16
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::ServiceHandle< geo::Geometry > fGeom
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
void hits()
Definition: readHits.C:15
TPCID FindTPCAtPosition(Point_t const &point) const
Returns the ID of the TPC at specified location.
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
key_type key() const noexcept
Definition: Ptr.h:166
std::map< art::Ptr< recob::Hit >, std::vector< art::Ptr< recob::Hit > > > OrganizeHits(const std::vector< art::Ptr< recob::Hit >> &hits) const
bool CheckElement(const std::string &Name) const
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
int GetElement(const std::string &Name, T &Element) const
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
Detector simulation of raw signals on wires.
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
Definition: geo_types.h:438
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:180
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:220
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
void FinddEdxLength(std::vector< double > &dEdx_vec, std::vector< double > &dEdx_val)
Vector_t const & GetIncreasingWireDirection() const
Returns the direction of increasing wires.
Definition: PlaneGeo.h:418
PointFlags_t const & FlagsAtPoint(size_t i) const
Access to i-th TrajectoryPoint or its Flags.
Definition: Track.h:152
Vector_t DirectionAtPoint(size_t i) const
Access to track direction at different points.
Definition: Track.h:168
double SCECorrectEField(double const &EField, geo::Point_t const &pos) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:399
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 >> &handle, const art::Event &evt, const art::InputTag &moduleTag)
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
void ShowerRecoTools::ShowerTrajPointdEdx::FinddEdxLength ( std::vector< double > &  dEdx_vec,
std::vector< double > &  dEdx_val 
)

Definition at line 400 of file ShowerTrajPointdEdx_tool.cc.

References tca::dEdx(), DEFINE_ART_CLASS_TOOL, fdEdxCut, and fVerbose.

Referenced by CalculateElement().

402  {
403 
404  //As default do not apply this cut.
405  if (fdEdxCut > 10) {
406  dEdx_val = dEdx_vec;
407  return;
408  }
409 
410  //Can only do this with 4 hits.
411  if (dEdx_vec.size() < 4) {
412  dEdx_val = dEdx_vec;
413  return;
414  }
415 
416  bool upperbound = false;
417 
418  //See if we are in the upper bound or upper bound defined by the cut.
419  int upperbound_int = 0;
420  if (dEdx_vec[0] > fdEdxCut) { ++upperbound_int; }
421  if (dEdx_vec[1] > fdEdxCut) { ++upperbound_int; }
422  if (dEdx_vec[2] > fdEdxCut) { ++upperbound_int; }
423  if (upperbound_int > 1) { upperbound = true; }
424 
425  dEdx_val.push_back(dEdx_vec[0]);
426  dEdx_val.push_back(dEdx_vec[1]);
427  dEdx_val.push_back(dEdx_vec[2]);
428 
429  for (unsigned int dEdx_iter = 2; dEdx_iter < dEdx_vec.size(); ++dEdx_iter) {
430 
431  //The Function of dEdx as a function of E is flat above ~10 MeV.
432  //We are looking for a jump up (or down) above the ladau width in the dEx
433  //to account account for pair production.
434  //Dom Estimates that the somwhere above 0.28 MeV will be a good cut but 999 will prevent this stage.
435  double dEdx = dEdx_vec[dEdx_iter];
436 
437  //We are really poo at physics and so attempt to find the pair production
438  if (upperbound) {
439  if (dEdx > fdEdxCut) {
440  dEdx_val.push_back(dEdx);
441  if (fVerbose > 1) std::cout << "Adding dEdx: " << dEdx << std::endl;
442  continue;
443  }
444  else {
445  //Maybe its a landau fluctation lets try again.
446  if (dEdx_iter < dEdx_vec.size() - 1) {
447  if (dEdx_vec[dEdx_iter + 1] > fdEdxCut) {
448  if (fVerbose > 1)
449  std::cout << "Next dEdx hit is good removing hit" << dEdx << std::endl;
450  continue;
451  }
452  }
453  //I'll let one more value
454  if (dEdx_iter < dEdx_vec.size() - 2) {
455  if (dEdx_vec[dEdx_iter + 2] > fdEdxCut) {
456  if (fVerbose > 1)
457  std::cout << "Next Next dEdx hit is good removing hit" << dEdx << std::endl;
458  continue;
459  }
460  }
461  //We are hopefully we have one of our electrons has died.
462  break;
463  }
464  }
465  else {
466  if (dEdx < fdEdxCut) {
467  dEdx_val.push_back(dEdx);
468  if (fVerbose > 1) std::cout << "Adding dEdx: " << dEdx << std::endl;
469  continue;
470  }
471  else {
472  //Maybe its a landau fluctation lets try again.
473  if (dEdx_iter < dEdx_vec.size() - 1) {
474  if (dEdx_vec[dEdx_iter + 1] > fdEdxCut) {
475  if (fVerbose > 1)
476  std::cout << "Next dEdx hit is good removing hit " << dEdx << std::endl;
477  continue;
478  }
479  }
480  //I'll let one more value
481  if (dEdx_iter < dEdx_vec.size() - 2) {
482  if (dEdx_vec[dEdx_iter + 2] > fdEdxCut) {
483  if (fVerbose > 1)
484  std::cout << "Next Next dEdx hit is good removing hit " << dEdx << std::endl;
485  continue;
486  }
487  }
488  //We are hopefully in the the pair production zone.
489  break;
490  }
491  }
492  }
493  return;
494  }
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
const shower::LArPandoraShowerAlg& ShowerRecoTools::IShowerTool::GetLArPandoraShowerAlg ( ) const
inlineprotectedinherited

Definition at line 82 of file IShowerTool.h.

Referenced by ShowerRecoTools::ShowerLengthPercentile::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPCAPropergationStartPosition::CalculateElement(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPFPVertexStartPosition::CalculateElement(), ShowerRecoTools::ShowerDirectionCheater::CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateElement(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::CalculateElement(), CalculateElement(), ShowerRecoTools::ShowerPCADirection::CalculateShowerPCA(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::FindInitialTrackHits(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::FindTrackSpacePoints(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::FitSegmentAndCalculateResidual(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneFrontOfSPSPool(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::PruneTrack(), ShowerRecoTools::ShowerIncrementalTrackHitFinder::RunTestOfIncrementalSpacePointFinder(), ShowerRecoTools::ShowerTrackPCADirection::ShowerPCAVector(), and ShowerRecoTools::ShowerIncrementalTrackHitFinder::ShowerPCAVector().

83  {
84  return fLArPandoraShowerAlg;
85  };
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
Definition: IShowerTool.h:92
template<class T >
art::Ptr<T> ShowerRecoTools::IShowerTool::GetProducedElementPtr ( std::string  Name,
reco::shower::ShowerElementHolder ShowerEleHolder,
int  iter = -1 
)
inlineprotectedinherited

Definition at line 102 of file IShowerTool.h.

References reco::shower::ShowerElementHolder::CheckElement(), reco::shower::ShowerProducedPtrsHolder::CheckUniqueProduerPtr(), reco::shower::ShowerProducedPtrsHolder::GetArtPtr(), and reco::shower::ShowerElementHolder::GetShowerNumber().

105  {
106 
107  //Check the element has been set
108  bool check_element = ShowerEleHolder.CheckElement(Name);
109  if (!check_element) {
110  throw cet::exception("IShowerTool") << "tried to get a element that does not exist. Failed "
111  "at making the art ptr for Element: "
112  << Name << std::endl;
113  }
114 
115  //Check the unique ptr has been set.
116  bool check_ptr = UniquePtrs->CheckUniqueProduerPtr(Name);
117  if (!check_ptr) {
118  throw cet::exception("IShowerTool")
119  << "tried to get a ptr that does not exist. Failed at making the art ptr for Element"
120  << Name;
121  }
122 
123  //Check if the user has defined an index if not just use the current shower index/
124  int index;
125  if (iter != -1) { index = iter; }
126  else {
127  index = ShowerEleHolder.GetShowerNumber();
128  }
129 
130  //Make the ptr
131  return UniquePtrs->GetArtPtr<T>(Name, index);
132  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
bool CheckUniqueProduerPtr(const std::string &Name) const
bool CheckElement(const std::string &Name) const
art::Ptr< T > GetArtPtr(const std::string &Name, const int &iter) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int ShowerRecoTools::IShowerTool::GetVectorPtrSize ( std::string  Name)
inlineprotectedinherited
void ShowerRecoTools::IShowerTool::InitaliseProducerPtr ( reco::shower::ShowerProducedPtrsHolder uniqueproducerPtrs)
inlineinherited

Definition at line 68 of file IShowerTool.h.

69  {
70  UniquePtrs = &uniqueproducerPtrs;
71  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
virtual void ShowerRecoTools::IShowerTool::InitialiseProducers ( )
inlinevirtualinherited
template<class T >
void ShowerRecoTools::IShowerTool::InitialiseProduct ( std::string  Name,
std::string  InstanceName = "" 
)
inlineprotectedinherited

Definition at line 137 of file IShowerTool.h.

References art::ProducesCollector::produces(), and reco::shower::ShowerProducedPtrsHolder::SetShowerUniqueProduerPtr().

138  {
139 
140  if (collectorPtr == nullptr) {
141  mf::LogWarning("IShowerTool") << "The art::ProducesCollector ptr has not been set";
142  return;
143  }
144 
145  collectorPtr->produces<T>(InstanceName);
146  UniquePtrs->SetShowerUniqueProduerPtr(type<T>(), Name, InstanceName);
147  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int SetShowerUniqueProduerPtr(type< T >, const std::string &Name, const std::string &Instance="")
void ShowerRecoTools::IShowerTool::PrintPtr ( std::string  Name)
inlineprotectedinherited

Definition at line 162 of file IShowerTool.h.

References reco::shower::ShowerProducedPtrsHolder::PrintPtr().

Referenced by ShowerRecoTools::ShowerExampleTool::CalculateElement().

162 { UniquePtrs->PrintPtr(Name); }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:85
void PrintPtr(const std::string &Name) const
void ShowerRecoTools::IShowerTool::PrintPtrs ( )
inlineprotectedinherited
int ShowerRecoTools::IShowerTool::RunShowerTool ( const art::Ptr< recob::PFParticle > &  pfparticle,
art::Event Event,
reco::shower::ShowerElementHolder ShowerEleHolder,
std::string  evd_display_name_append = "" 
)
inlineinherited

Definition at line 46 of file IShowerTool.h.

50  {
51 
52  int calculation_status = CalculateElement(pfparticle, Event, ShowerEleHolder);
53  if (calculation_status != 0) return calculation_status;
54  if (fRunEventDisplay) {
56  pfparticle, Event, ShowerEleHolder, evd_display_name_append);
57  }
58  return calculation_status;
59  }
void DebugEVD(art::Ptr< recob::PFParticle > const &pfparticle, art::Event const &Event, const reco::shower::ShowerElementHolder &ShowerEleHolder, std::string const &evd_disp_name_append="") const
virtual int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder)=0
const shower::LArPandoraShowerAlg & GetLArPandoraShowerAlg() const
Definition: IShowerTool.h:82
void ShowerRecoTools::IShowerTool::SetPtr ( art::ProducesCollector collector)
inlineinherited

Definition at line 65 of file IShowerTool.h.

65 { collectorPtr = collector; }
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:97

Member Data Documentation

float ShowerRecoTools::ShowerTrajPointdEdx::dEdxTrackLength
private

Definition at line 59 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

calo::CalorimetryAlg ShowerRecoTools::ShowerTrajPointdEdx::fCalorimetryAlg
private

Definition at line 47 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fCutStartPosition
private

Definition at line 64 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fdEdxCut
private

Definition at line 62 of file ShowerTrajPointdEdx_tool.cc.

Referenced by FinddEdxLength().

float ShowerRecoTools::ShowerTrajPointdEdx::fdEdxTrackLength
private

Definition at line 59 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

art::ServiceHandle<geo::Geometry> ShowerRecoTools::ShowerTrajPointdEdx::fGeom
private

Definition at line 46 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fInitialTrackHitsInputLabel
private

Definition at line 79 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fInitialTrackInputLabel
private

Definition at line 81 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fInitialTrackSpacePointsInputLabel
private

Definition at line 80 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMaxDist
private

Definition at line 57 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMinAngleToWire
private

Definition at line 50 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMinDistCutOff
private

Definition at line 55 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

art::InputTag ShowerRecoTools::ShowerTrajPointdEdx::fPFParticleLabel
private

Definition at line 75 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCECorrectEField
private

Definition at line 69 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and ShowerTrajPointdEdx().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCECorrectPitch
private

Definition at line 67 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and ShowerTrajPointdEdx().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCEInputCorrected
private

Definition at line 71 of file ShowerTrajPointdEdx_tool.cc.

Referenced by ShowerTrajPointdEdx().

float ShowerRecoTools::ShowerTrajPointdEdx::fShapingTime
private

Definition at line 53 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fShowerBestPlaneOutputLabel
private

Definition at line 83 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fShowerdEdxOutputLabel
private

Definition at line 82 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fShowerdEdxVecOutputLabel
private

Definition at line 84 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

std::string ShowerRecoTools::ShowerTrajPointdEdx::fShowerStartPositionInputLabel
private

Definition at line 78 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSumHitSnippets
private

Definition at line 73 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fT0Correct
private

Definition at line 66 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fUseMedian
private

Definition at line 63 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerTrajPointdEdx::fVerbose
private

Definition at line 76 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and FinddEdxLength().

float ShowerRecoTools::ShowerTrajPointdEdx::MaxDist
private

Definition at line 57 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().


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