LArSoft  v10_04_05
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
 
geo::WireReadoutGeom const & fChannelMap = art::ServiceHandle<geo::WireReadout>()->Get()
 
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 34 of file ShowerTrajPointdEdx_tool.cc.

Constructor & Destructor Documentation

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

Definition at line 90 of file ShowerTrajPointdEdx_tool.cc.

References fSCECorrectEField, fSCECorrectPitch, and fSCEInputCorrected.

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

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

151  {
152  UniquePtrs->AddSingle<T>(a, b, Name);
153  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
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 122 of file ShowerTrajPointdEdx_tool.cc.

References util::abs(), geo::PlaneID::asTPCID(), reco::shower::ShowerElementHolder::CheckElement(), tca::dEdx(), calo::CalorimetryAlg::dEdx_AREA(), dEdxTrackLength, recob::Track::DirectionAtPoint(), larg4::dist(), fCalorimetryAlg, fChannelMap, 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::Iterable< IterationPolicy, Transform >::Iterate(), art::Ptr< T >::key(), recob::Track::LocationAtPoint(), MaxDist, geo::WireReadoutGeom::MaxPlanes(), recob::TrajectoryPointFlagTraits::NoPoint, recob::Track::NumberTrajectoryPoints(), shower::LArPandoraShowerAlg::OrganizeHits(), recob::Hit::PeakTime(), geo::WireReadoutGeom::Plane(), geo::PlaneID::Plane, shower::LArPandoraShowerAlg::SCECorrectEField(), shower::LArPandoraShowerAlg::SCECorrectPitch(), reco::shower::ShowerElementHolder::SetElement(), geo::TPCID::TPC, and recob::Hit::WireID().

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

Definition at line 403 of file ShowerTrajPointdEdx_tool.cc.

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

Referenced by CalculateElement().

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

Definition at line 80 of file IShowerTool.h.

Referenced by ShowerRecoTools::ShowerLengthPercentile::CalculateElement(), ShowerRecoTools::Shower3DCylinderTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPCAPropergationStartPosition::CalculateElement(), ShowerRecoTools::Shower2DLinearRegressionTrackHitFinder::CalculateElement(), ShowerRecoTools::ShowerPFPVertexStartPosition::CalculateElement(), ShowerRecoTools::ShowerUnidirectiondEdx::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().

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

Definition at line 100 of file IShowerTool.h.

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

103  {
104 
105  //Check the element has been set
106  bool check_element = ShowerEleHolder.CheckElement(Name);
107  if (!check_element) {
108  throw cet::exception("IShowerTool") << "tried to get a element that does not exist. Failed "
109  "at making the art ptr for Element: "
110  << Name << std::endl;
111  }
112 
113  //Check the unique ptr has been set.
114  bool check_ptr = UniquePtrs->CheckUniqueProduerPtr(Name);
115  if (!check_ptr) {
116  throw cet::exception("IShowerTool")
117  << "tried to get a ptr that does not exist. Failed at making the art ptr for Element"
118  << Name;
119  }
120 
121  //Check if the user has defined an index if not just use the current shower index/
122  int index;
123  if (iter != -1) { index = iter; }
124  else {
125  index = ShowerEleHolder.GetShowerNumber();
126  }
127 
128  //Make the ptr
129  return UniquePtrs->GetArtPtr<T>(Name, index);
130  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
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 66 of file IShowerTool.h.

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

Definition at line 135 of file IShowerTool.h.

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

136  {
137 
138  if (collectorPtr == nullptr) {
139  mf::LogWarning("IShowerTool") << "The art::ProducesCollector ptr has not been set";
140  return;
141  }
142 
143  collectorPtr->produces<T>(InstanceName);
144  UniquePtrs->SetShowerUniqueProduerPtr(type<T>(), Name, InstanceName);
145  }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:95
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 160 of file IShowerTool.h.

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

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

160 { UniquePtrs->PrintPtr(Name); }
reco::shower::ShowerProducedPtrsHolder * UniquePtrs
Definition: IShowerTool.h:83
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 44 of file IShowerTool.h.

48  {
49 
50  int calculation_status = CalculateElement(pfparticle, Event, ShowerEleHolder);
51  if (calculation_status != 0) return calculation_status;
52  if (fRunEventDisplay) {
54  pfparticle, Event, ShowerEleHolder, evd_display_name_append);
55  }
56  return calculation_status;
57  }
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:80
void ShowerRecoTools::IShowerTool::SetPtr ( art::ProducesCollector collector)
inlineinherited

Definition at line 63 of file IShowerTool.h.

63 { collectorPtr = collector; }
art::ProducesCollector * collectorPtr
Definition: IShowerTool.h:95

Member Data Documentation

float ShowerRecoTools::ShowerTrajPointdEdx::dEdxTrackLength
private

Definition at line 62 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 50 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

geo::WireReadoutGeom const& ShowerRecoTools::ShowerTrajPointdEdx::fChannelMap = art::ServiceHandle<geo::WireReadout>()->Get()
private

Definition at line 49 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fCutStartPosition
private

Definition at line 67 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fdEdxCut
private

Definition at line 65 of file ShowerTrajPointdEdx_tool.cc.

Referenced by FinddEdxLength().

float ShowerRecoTools::ShowerTrajPointdEdx::fdEdxTrackLength
private

Definition at line 62 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 48 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 82 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 84 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 83 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMaxDist
private

Definition at line 60 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMinAngleToWire
private

Definition at line 53 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

float ShowerRecoTools::ShowerTrajPointdEdx::fMinDistCutOff
private

Definition at line 58 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 78 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCECorrectEField
private

Definition at line 72 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and ShowerTrajPointdEdx().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCECorrectPitch
private

Definition at line 70 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and ShowerTrajPointdEdx().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSCEInputCorrected
private

Definition at line 74 of file ShowerTrajPointdEdx_tool.cc.

Referenced by ShowerTrajPointdEdx().

float ShowerRecoTools::ShowerTrajPointdEdx::fShapingTime
private

Definition at line 56 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 86 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 85 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 87 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

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

Definition at line 81 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fSumHitSnippets
private

Definition at line 76 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fT0Correct
private

Definition at line 69 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

bool ShowerRecoTools::ShowerTrajPointdEdx::fUseMedian
private

Definition at line 66 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().

int ShowerRecoTools::ShowerTrajPointdEdx::fVerbose
private

Definition at line 79 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement(), and FinddEdxLength().

float ShowerRecoTools::ShowerTrajPointdEdx::MaxDist
private

Definition at line 60 of file ShowerTrajPointdEdx_tool.cc.

Referenced by CalculateElement().


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