36 class CosmicPFParticleTagger;
60 auto const*
geo = lar::providerFrom<geo::Geometry>();
80 const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature());
83 2 *
geo->DetHalfWidth() / (driftVelocity * fSamplingRate / 1000);
84 fMinTickDrift = clock_data.Time2Tick(clock_data.TriggerTime());
87 produces<std::vector<anab::CosmicTag>>();
88 produces<art::Assns<anab::CosmicTag, recob::Track>>();
89 produces<art::Assns<recob::PFParticle, anab::CosmicTag>>();
95 std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagTrackVector(
96 new std::vector<anab::CosmicTag>);
97 std::unique_ptr<art::Assns<anab::CosmicTag, recob::Track>> assnOutCosmicTagTrack(
99 std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> assnOutCosmicTagPFParticle(
106 if (!pfParticleHandle.
isValid()) {
107 evt.
put(std::move(cosmicTagTrackVector));
108 evt.
put(std::move(assnOutCosmicTagTrack));
117 evt.
put(std::move(cosmicTagTrackVector));
118 evt.
put(std::move(assnOutCosmicTagTrack));
133 for (
size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++) {
137 std::vector<art::Ptr<recob::Track>> trackVec = pfPartToTrackAssns.at(pfPartIdx);
140 if (trackVec.empty()) {
142 std::vector<float> tempPt1, tempPt2;
143 tempPt1.push_back(-999);
144 tempPt1.push_back(-999);
145 tempPt1.push_back(-999);
146 tempPt2.push_back(-999);
147 tempPt2.push_back(-999);
148 tempPt2.push_back(-999);
150 util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
159 std::vector<art::Ptr<recob::Hit>> hitVec = hitsSpill.at(track1.
key());
162 auto vertexPosition = track1->
Vertex();
164 auto endPosition = track1->
End();
170 if (trackVec.size() > 1) {
171 for (
size_t trackIdx = 1; trackIdx < trackVec.size(); trackIdx++) {
174 auto trackStart = track->
Vertex();
175 auto trackEnd = track->
End();
178 double arcLStartToStart = (trackStart - vertexPosition).Dot(vertexDirection);
179 double arcLStartToEnd = (trackEnd - vertexPosition).Dot(vertexDirection);
181 if (arcLStartToStart < 0. || arcLStartToEnd < 0.) {
182 if (arcLStartToStart < arcLStartToEnd)
183 vertexPosition = trackStart;
185 vertexPosition = trackEnd;
189 double arcLEndToStart = (trackStart - endPosition).Dot(vertexDirection);
190 double arcLEndToEnd = (trackEnd - endPosition).Dot(vertexDirection);
192 if (arcLEndToStart > 0. || arcLEndToEnd > 0.) {
193 if (arcLEndToStart > arcLEndToEnd)
194 endPosition = trackStart;
196 endPosition = trackEnd;
201 hitVec.end(), hitsSpill.at(track.
key()).
begin(), hitsSpill.at(track.
key()).
end());
206 float trackEndPt1_X = vertexPosition.X();
207 float trackEndPt1_Y = vertexPosition.Y();
208 float trackEndPt1_Z = vertexPosition.Z();
209 float trackEndPt2_X = endPosition.X();
210 float trackEndPt2_Y = endPosition.Y();
211 float trackEndPt2_Z = endPosition.Z();
218 for (
unsigned int p = 0; p < hitVec.size(); p++) {
219 int peakLessRms = hitVec[p]->PeakTimeMinusRMS();
220 int peakPlusRms = hitVec[p]->PeakTimePlusRMS();
222 if (peakLessRms < fMinTickDrift || peakPlusRms >
fMaxTickDrift) {
240 unsigned boundaryMask[] = {0, 0};
248 boundaryMask[0] = 0x1;
250 boundaryMask[0] = 0x2;
253 boundaryMask[1] = 0x1;
255 boundaryMask[1] = 0x2;
260 boundaryMask[0] = 0x10;
262 boundaryMask[0] = 0x20;
265 boundaryMask[1] = 0x10;
267 boundaryMask[1] = 0x20;
272 boundaryMask[0] = 0x100;
274 boundaryMask[0] = 0x200;
277 boundaryMask[1] = 0x100;
279 boundaryMask[1] = 0x200;
281 unsigned trackMask = boundaryMask[0] | boundaryMask[1];
284 for (
int idx = 0; idx < 12; idx++)
285 if (trackMask & (0
x1 << idx)) nBitsSet++;
290 if ((trackMask & 0x300) != 0x300) {
292 if ((trackMask & 0
x3) == 0x3)
294 else if ((trackMask & 0x30) == 0x30)
296 else if ((trackMask & 0x3) && (trackMask & 0x30))
298 else if ((trackMask & 0x3) && (trackMask & 0x300))
310 else if (nBitsSet > 0) {
314 else if (trackMask & 0x30)
316 else if (trackMask & 0x300)
321 std::vector<float> endPt1;
322 std::vector<float> endPt2;
323 endPt1.push_back(trackEndPt1_X);
324 endPt1.push_back(trackEndPt1_Y);
325 endPt1.push_back(trackEndPt1_Z);
326 endPt2.push_back(trackEndPt2_X);
327 endPt2.push_back(trackEndPt2_Y);
328 endPt2.push_back(trackEndPt2_Z);
330 float cosmicScore = isCosmic > 0 ? 1. : 0.;
335 else if (isCosmic == 4)
339 cosmicTagTrackVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
341 util::CreateAssn(evt, *cosmicTagTrackVector, trackVec, *assnOutCosmicTagTrack);
344 util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
347 evt.
put(std::move(cosmicTagTrackVector));
348 evt.
put(std::move(assnOutCosmicTagTrack));
349 evt.
put(std::move(assnOutCosmicTagPFParticle));
Utilities related to art service access.
Float_t x1[n_points_granero]
enum anab::cosmic_tag_id CosmicTagID_t
Declaration of signal hit object.
EDProducer(fhicl::ParameterSet const &pset)
Float_t x3[n_points_geant4]
Vector_t VertexDirection() const
Access to track direction at different points.
std::string fTrackModuleLabel
bool isValid() const noexcept
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
#define DEFINE_ART_MODULE(klass)
std::string fPFParticleModuleLabel
key_type key() const noexcept
Point_t const & Vertex() const
Access to track position at different points.
Provides recob::Track data product.
void produce(art::Event &e) override
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Utility object to perform functions of association.
CosmicPFParticleTagger(fhicl::ParameterSet const &p)
Point_t const & End() const
Access to track position at different points.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Namespace collecting geometry-related classes utilities.
art framework interface to geometry description
int fMaxOutOfTime
Max hits that can be out of time before rejecting.