10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
60 void produce(art::Event&
e)
override;
83 fTrackLabel(
p.get<art::InputTag>(
"TrackLabel",
"pandoraTrack")),
84 fWireLabel(
p.get<art::InputTag>(
"WireLabel",
"calowire")),
85 fDigitLabels(
p.get<std::vector<art::InputTag>>(
"DigitLabels", {})),
86 fT0Label(
p.get<art::InputTag>(
"T0Label",
"")),
93 fCryostat(
p.get<
unsigned>(
"Cryostat", 0))
95 produces<std::vector<recob::Hit>>();
96 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
104 bool setstartTick =
false;
106 bool setendTick =
false;
107 float hitPeakTime = (startTick + endTick) / 2.;
108 float hitSigmaPeakTime = (endTick - startTick) / 2.;
109 float hitRMS = (endTick - startTick) / 2.;
110 float hitPeakAmplitude = 0.;
111 float hitSigmaPeakAmplitude = 0.;
112 float hitSumADC = 0.;
113 float hitIntegral = 0.;
114 float hitSigmaIntegral = 0.;
115 short int hitMultiplicity = 1;
116 short int hitLocalIndex = 0;
117 float hitGoodnessOfFit = -999999;
118 short int hitNDF = 0;
133 if (roiStart <= endTick && startTick <= roiEnd) {
135 if (roiStart < startTick && startTick <= roiEnd) range.move_head(startTick);
136 if (roiEnd > endTick && endTick >= roiStart) range.move_tail(endTick);
139 for (
float v: range) {
151 if (!setstartTick || thisStart < hitStartTick) {
152 hitStartTick = thisStart;
155 if (!setendTick || thisEnd > hitEndTick) {
156 hitEndTick = thisEnd;
163 if (!setstartTick || !setendTick)
return recob::Hit();
174 hitSigmaPeakAmplitude,
193 startTick = std::max(0, startTick);
194 endTick = std::min((
int)digit.
NADC()-1, endTick);
200 float hitPeakTime = (startTick + endTick) / 2.;
201 float hitSigmaPeakTime = (endTick - startTick) / 2.;
202 float hitRMS = (endTick - startTick) / 2.;
203 float hitPeakAmplitude = 0.;
204 float hitSigmaPeakAmplitude = 0.;
205 float hitSumADC = 0.;
206 float hitIntegral = 0.;
207 float hitSigmaIntegral = 0.;
208 short int hitMultiplicity = 1;
209 short int hitLocalIndex = 0;
210 float hitGoodnessOfFit = -999999;
211 short int hitNDF = 0;
216 for (
int i_adc = startTick; i_adc <= endTick; i_adc++) {
217 hitSumADC += digit.
ADC(i_adc);
218 hitIntegral += digit.
ADC(i_adc);
230 hitSigmaPeakAmplitude,
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;
262 e.getByLabel(fTrackLabel, 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);
275 for (
const art::InputTag &l: fDigitLabels) {
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.
Store parameters for running LArG4.
Data product for reconstructed trajectory in space.
Vector DriftDir() const
Returns the direction of the drift (vector pointing toward the planes).
art::InputTag fTrackLabel
float fTransverseDiffusionScale
Utilities related to art service access.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
Collection of charge vs time digitized from a single readout channel.
ClusterModuleLabel join with tracks
short ADC(int i) const
ADC vector element number i; no decompression is applied.
process_name opflash particleana ie x
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Declaration of signal hit object.
Point_t const & LocationAtPoint(size_t i) const
fUseWires(p.get< bool >("UseWires", true))
recob::Hit MakeHit(const recob::Wire &wire, const geo::WireID &wireID, const geo::GeometryCore *geo, raw::TDCtick_t startTick, raw::TDCtick_t endTick) const
fAppendExtraHit(p.get< bool >("AppendExtraHit", false))
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition of basic raw digits.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
static constexpr WireID_t InvalidID
Special code for an invalid ID.
fT0Label(p.get< art::InputTag >("T0Label",""))
WireID_t Wire
Index of the wire within its plane.
process_name use argoneut_mc_hitfinder track
fTransverseDiffusionScale(p.get< float >("TransverseDiffusionScale"))
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
TrackAreaHit(fhicl::ParameterSet const &p)
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.
Access the description of detector geometry.
float fLongitudinalDiffusionScale
Collection of exceptions for Geometry system.
double Length(size_t p=0) const
Access to various track properties.
enum geo::_plane_sigtype SigType_t
size_t NADC() const
Number of elements in the compressed ADC sample vector.
const RegionsOfInterest_t & SignalROI() const
Returns the list of regions of interest.
Data product for reconstructed trajectory in space.
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.
fLongitudinalDiffusionScale(p.get< float >("LongitudinalDiffusionScale"))
Provides recob::Track data product.
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.
fPrependExtraHit(p.get< bool >("PrependExtraHit", false))
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
Class holding the regions of interest of signal from a channel.
Range class, with range and data.
void produce(art::Event &e) override
unsigned int WireID_t
Type for the ID number.
Declaration of basic channel signal object.
TrackAreaHit & operator=(TrackAreaHit const &)=delete
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
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Class defining a sparse vector (holes are zeroes)
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.
fSignalShapingWindow(p.get< float >("SignalShapingWindow"))
art framework interface to geometry description
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.