123 <<
"Initial Track Spacepoints is not set returning" <<
std::endl;
132 std::vector<art::Ptr<recob::SpacePoint>> tracksps;
135 if (tracksps.empty()) {
145 const art::FindManyP<recob::Hit>& fmsp =
149 TVector3 ShowerStartPosition = {-999, -999, -999};
159 auto const pfpHandle = Event.getValidHandle<std::vector<recob::PFParticle>>(
fPFParticleLabel);
160 const art::FindManyP<anab::T0>& fmpfpt0 =
162 std::vector<art::Ptr<anab::T0>> pfpT0Vec = fmpfpt0.at(pfparticle.
key());
163 if (pfpT0Vec.size() == 1) { pfpT0Time = pfpT0Vec.front()->Time(); }
167 std::map<int, std::vector<double>> dEdx_vec;
168 std::map<int, std::vector<double>> dEdx_vecErr;
169 std::map<int, int> num_hits;
172 dEdx_vec[plane_id.Plane] = {};
173 dEdx_vecErr[plane_id.Plane] = {};
174 num_hits[plane_id.Plane] = 0;
177 auto const clockData =
183 for (
auto const sp : tracksps) {
186 std::vector<art::Ptr<recob::Hit>> hits = fmsp.at(sp.key());
190 <<
"no hit for the spacepoint. This suggest the find many is wrong." <<
std::endl;
199 if (TPC != vtxTPC) {
continue; }
203 double dist_from_start = (pos - ShowerStartPosition).Mag();
212 unsigned int index = 999;
213 double MinDist = 999;
217 TVector3 TrajPosition = {
218 TrajPositionPoint.X(), TrajPositionPoint.Y(), TrajPositionPoint.Z()};
224 const TVector3
dist = pos - TrajPosition;
226 if (dist.Mag() < MinDist && dist.Mag() <
MaxDist * wirepitch) {
227 MinDist = dist.Mag();
233 if (index == 999) {
continue; }
236 TVector3 TrajPosition = {TrajPositionPoint.X(), TrajPositionPoint.Y(), TrajPositionPoint.Z()};
239 TVector3 TrajPositionStart = {
240 TrajPositionStartPoint.X(), TrajPositionStartPoint.Y(), TrajPositionStartPoint.Z()};
243 if ((TrajPosition - TrajPositionStart).Mag() == 0) {
continue; }
244 if ((TrajPosition - ShowerStartPosition).Mag() == 0) {
continue; }
246 if ((TrajPosition - TrajPositionStart).Mag() <
fMinDistCutOff * wirepitch) {
continue; }
250 TVector3 TrajDirection = {
251 TrajDirection_vec.X(), TrajDirection_vec.Y(), TrajDirection_vec.Z()};
256 TVector3 TrajDirectionYZ = {0, TrajDirection_vec.Y(), TrajDirection_vec.Z()};
265 double velocity = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
266 double distance_in_x = TrajDirection.X() * (wirepitch / TrajDirection.Dot(PlaneDirection));
267 double time_taken =
std::abs(distance_in_x / velocity);
275 if ((TrajPosition - TrajPositionStart).Mag() >
dEdxTrackLength) {
continue; }
278 ++num_hits[planeid.
Plane];
281 double trackpitch = (TrajDirection * (wirepitch / TrajDirection.Dot(PlaneDirection))).Mag();
285 trackpitch, pos, TrajDirection.Unit(), hit->
WireID().
TPC);
289 double dQdx = hit->
Integral() / trackpitch;
292 double localEField = detProp.Efield();
297 clockData, detProp, dQdx, hit->
PeakTime(), planeid.
Plane, pfpT0Time, localEField);
300 dEdx_vec[planeid.
Plane].push_back(dEdx);
306 for (
auto const& [plane, numHits] : num_hits) {
307 if (
fVerbose > 2) std::cout <<
"Plane: " << plane <<
" with size: " << numHits <<
std::endl;
308 if (numHits > max_hits) {
314 if (best_plane < 0) {
325 std::map<int, std::vector<double>> dEdx_vec_cut;
327 dEdx_vec_cut[plane_id.Plane] = {};
330 for (
auto& dEdx_plane : dEdx_vec) {
331 FinddEdxLength(dEdx_plane.second, dEdx_vec_cut[dEdx_plane.first]);
335 std::vector<double> dEdx_val;
336 std::vector<double> dEdx_valErr;
337 for (
auto const& dEdx_plane : dEdx_vec_cut) {
339 if ((dEdx_plane.second).empty()) {
340 dEdx_val.push_back(-999);
341 dEdx_valErr.push_back(-999);
346 dEdx_val.push_back(TMath::Median((dEdx_plane.second).size(), &(dEdx_plane.second)[0]));
350 double dEdx_mean = 0;
351 for (
auto const& dEdx : dEdx_plane.second) {
352 if (dEdx > 10 || dEdx < 0) {
continue; }
355 dEdx_val.push_back(dEdx_mean / (
float)(dEdx_plane.second).size());
360 std::cout <<
"#Best Plane: " << best_plane <<
std::endl;
361 for (
unsigned int plane = 0; plane < dEdx_vec.size(); plane++) {
362 std::cout <<
"#Plane: " << plane <<
" #" <<
std::endl;
363 std::cout <<
"#Median: " << dEdx_val[plane] <<
" #" <<
std::endl;
365 for (
auto const& dEdx : dEdx_vec_cut[plane]) {
366 std::cout <<
"dEdx: " << dEdx <<
std::endl;
double SCECorrectPitch(double const &pitch, TVector3 const &pos, TVector3 const &dir, unsigned int const &TPC) const
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
static constexpr Flag_t NoPoint
The trajectory point is not defined.
geo::WireID WireID() const
Point_t const & LocationAtPoint(size_t i) const
The data type to uniquely identify a Plane.
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.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
double SCECorrectEField(double const &EField, TVector3 const &pos) const
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
double dEdx(float dqdx, float Efield)
key_type key() const noexcept
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool CheckElement(const std::string &Name) const
static int max(int a, int b)
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
int GetElement(const std::string &Name, T &Element) const
Detector simulation of raw signals on wires.
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
float PeakTime() const
Time of the signal peak, in tick units.
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
PointFlags_t const & FlagsAtPoint(size_t i) const
Vector_t DirectionAtPoint(size_t i) const
2D representation of charge deposited in the TDC/wire plane
TPCID_t TPC
Index of the TPC within its cryostat.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
QTextStream & endl(QTextStream &s)
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const