249 std::unique_ptr<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>> assn(
new art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>);
250 std::unique_ptr<std::vector<recob::Hit>> outHits(
new std::vector<recob::Hit>);
253 std::unique_ptr<art::Assns<recob::Hit, recob::Wire>> wireAssn(
new art::Assns<recob::Hit, recob::Wire>);
255 std::unique_ptr<art::Assns<recob::Hit, raw::RawDigit>> digitAssn(
new art::Assns<recob::Hit, raw::RawDigit>);
258 art::PtrMaker<recob::Hit> hitPtrMaker{
e};
261 art::Handle<std::vector<recob::Track>> track_handle;
264 std::vector<art::Ptr<recob::Track>>
tracks;
265 art::fill_ptr_vector(tracks, track_handle);
267 std::vector<art::Ptr<recob::Wire>> wires;
268 std::vector<art::Ptr<raw::RawDigit>> digits;
271 auto const& wire_handle =
e.getValidHandle<std::vector<recob::Wire>>(
fWireLabel);
272 art::fill_ptr_vector(wires, wire_handle);
276 auto const& digit_handle =
e.getValidHandle<std::vector<raw::RawDigit>>(l);
277 art::fill_ptr_vector(digits, digit_handle);
281 art::FindManyP<anab::T0> fmT0(tracks,
e,
fT0Label);
284 auto const dclock = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(
e);
286 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
e, dclock);
289 art::ServiceHandle<sim::LArG4Parameters const> g4param;
291 std::set<unsigned> channels;
293 for (
unsigned i = 0; i < tracks.size(); i++) {
297 double track_t0 = 0.;
299 const std::vector<art::Ptr<anab::T0>> &
t0 = fmT0.at(i);
301 track_t0 = t0.at(0)->Time() / 1e3 ;
309 int lastWire = -100000;
327 TVector3 thispoint (thispoint_p.X(), thispoint_p.Y(), thispoint_p.Z());
328 TVector3 nextpoint (nextpoint_p.X(), nextpoint_p.Y(), nextpoint_p.Z());
337 int wireStart = std::nearbyint((thiswirecoord >= nextwirecoord) ? std::floor(thiswirecoord) : std::ceil(thiswirecoord));
338 int wireEnd = std::nearbyint((thiswirecoord >= nextwirecoord) ? std::floor(nextwirecoord) : std::ceil(nextwirecoord));
341 if (wireStart == wireEnd)
continue;
344 if (!(wireStart >= 0 && wireStart < (
int)geo->
Plane(planeID).
Nwires())) {
346 "Can't find wire for track trajectory position at: " <<
347 thispoint.X() <<
" " << thispoint.Y() <<
" " << thispoint.Z() <<
348 ". Returned start wire is " << wireStart <<
" (max: " << geo->
Plane(planeID).
Nwires() <<
")" << std::endl;
351 if (!(wireEnd >= 0 && wireEnd <= (
int)geo->
Plane(planeID).
Nwires())) {
353 "Can't find wire for track trajectory position at: " <<
354 nextpoint.X() <<
" " << nextpoint.Y() <<
" " << nextpoint.Z() <<
355 ". Returned end wire is " << wireEnd <<
" (max: " << geo->
Plane(planeID).
Nwires() <<
")" << std::endl;
360 if (wireStart == lastWire) {
361 if (wireStart < wireEnd) wireStart ++;
366 if (wireStart == wireEnd)
continue;
369 float x = thispoint.X();
371 TVector3
dir(dir_v.X(), dir_v.Y(), dir_v.Z());
376 float time = dprop.ConvertXToTicks(x, planeID) + track_t0 * geo->
TPC(planeID).
DriftDir()[0] / dclock.TPCClock().TickPeriod();
384 double cosgamma =
std::abs(std::sin(angleToVert)*
dir.Y() + std::cos(angleToVert)*
dir.Z());
385 double effpitch = geo->
WirePitch() / cosgamma;
389 float tdrift = xdrift / dprop.DriftVelocity();
392 double proj_length =
abs(effpitch *
dir.X() / sqrt(1 -
dir.X() *
dir.X()));
394 proj_length = std::min(proj_length,
abs(track.
Length() *
dir.X()));
397 double window = (proj_length / dprop.DriftVelocity()) / dclock.TPCClock().TickPeriod();
402 window += (
fLongitudinalDiffusionScale*sqrt(2*tdrift*g4param->LongitudinalDiffusion()) / dprop.DriftVelocity()) / dclock.TPCClock().TickPeriod();
405 raw::TDCtick_t startTick = std::nearbyint(std::floor(time - window / 2.));
406 raw::TDCtick_t endTick = std::nearbyint(std::ceil(time + window / 2.));
408 int incl = wireStart < wireEnd ? 1 : -1;
409 for (
int wire = wireStart; wire != wireEnd; wire += incl) {
422 if (channels.count(channel))
continue;
424 channels.insert(channel);
433 for (
unsigned i_rwire = 0; i_rwire < wires.size(); i_rwire++) {
434 if (channel == wires[i_rwire]->Channel()) {
435 wire_ind = (int)i_rwire;
439 assoc_ind = wire_ind;
442 thisHit =
MakeHit(*wires.at(wire_ind), wireID, geo, startTick, endTick);
447 for (
unsigned i_digit = 0; i_digit < digits.size(); i_digit++) {
448 if (channel == digits[i_digit]->Channel()) {
449 digit_ind = (int)i_digit;
453 assoc_ind = digit_ind;
456 thisHit =
MakeHit(*digits.at(digit_ind), wireID, geo, startTick, endTick);
466 outHits->push_back(thisHit);
469 art::Ptr<recob::Hit> thisHitPtr = hitPtrMaker(outHits->size()-1);
470 assn->addSingle(tracks[i], thisHitPtr, thisHitMeta);
472 wireAssn->addSingle(thisHitPtr, wires[assoc_ind]);
475 digitAssn->addSingle(thisHitPtr, digits[assoc_ind]);
482 e.put(std::move(outHits));
483 e.put(std::move(assn));
485 e.put(std::move(wireAssn));
488 e.put(std::move(digitAssn));
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
Vector DriftDir() const
Returns the direction of the drift (vector pointing toward the planes).
art::InputTag fTrackLabel
float fTransverseDiffusionScale
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
ClusterModuleLabel join with tracks
process_name opflash particleana ie x
geo::WireID WireID() const
Point_t const & LocationAtPoint(size_t i) const
recob::Hit MakeHit(const recob::Wire &wire, const geo::WireID &wireID, const geo::GeometryCore *geo, raw::TDCtick_t startTick, raw::TDCtick_t endTick) const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
static constexpr WireID_t InvalidID
Special code for an invalid ID.
WireID_t Wire
Index of the wire within its plane.
process_name use argoneut_mc_hitfinder track
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
int TDCtick_t
Type representing a TDC tick.
tracking::Vector_t Vector_t
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.
float fLongitudinalDiffusionScale
double Length(size_t p=0) const
Access to various track properties.
Description of geometry of one entire detector.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
std::vector< art::InputTag > fDigitLabels
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
float fSignalShapingWindow
size_t NextValidPoint(size_t index) const
static constexpr size_t InvalidIndex
Value returned on failed index queries.
unsigned int Nwires() const
Number of wires in this plane.
tracking::Point_t Point_t
unsigned int WireID_t
Type for the ID number.
Vector_t DirectionAtPoint(size_t i) const
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
2D representation of charge deposited in the TDC/wire plane
const double * PlaneLocation(unsigned int p) const
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
BEGIN_PROLOG could also be cout
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
The data type to uniquely identify a cryostat.