36 class CosmicPFParticleTagger;
58 auto const& tpc = lar::providerFrom<geo::Geometry>()->TPC({0, 0});
78 const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature());
81 2 * tpc.HalfWidth() / (driftVelocity * fSamplingRate / 1000);
82 fMinTickDrift = clock_data.Time2Tick(clock_data.TriggerTime());
85 produces<std::vector<anab::CosmicTag>>();
86 produces<art::Assns<anab::CosmicTag, recob::Track>>();
87 produces<art::Assns<recob::PFParticle, anab::CosmicTag>>();
93 std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagTrackVector(
94 new std::vector<anab::CosmicTag>);
95 std::unique_ptr<art::Assns<anab::CosmicTag, recob::Track>> assnOutCosmicTagTrack(
97 std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> assnOutCosmicTagPFParticle(
104 if (!pfParticleHandle.
isValid()) {
105 evt.
put(std::move(cosmicTagTrackVector));
106 evt.
put(std::move(assnOutCosmicTagTrack));
115 evt.
put(std::move(cosmicTagTrackVector));
116 evt.
put(std::move(assnOutCosmicTagTrack));
131 for (
size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++) {
135 std::vector<art::Ptr<recob::Track>> trackVec = pfPartToTrackAssns.at(pfPartIdx);
138 if (trackVec.empty()) {
140 std::vector<float> tempPt1, tempPt2;
141 tempPt1.push_back(-999);
142 tempPt1.push_back(-999);
143 tempPt1.push_back(-999);
144 tempPt2.push_back(-999);
145 tempPt2.push_back(-999);
146 tempPt2.push_back(-999);
148 util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
157 std::vector<art::Ptr<recob::Hit>> hitVec = hitsSpill.at(track1.
key());
160 auto vertexPosition = track1->
Vertex();
162 auto endPosition = track1->
End();
168 if (trackVec.size() > 1) {
169 for (
size_t trackIdx = 1; trackIdx < trackVec.size(); trackIdx++) {
172 auto trackStart = track->
Vertex();
173 auto trackEnd = track->
End();
176 double arcLStartToStart = (trackStart - vertexPosition).Dot(vertexDirection);
177 double arcLStartToEnd = (trackEnd - vertexPosition).Dot(vertexDirection);
179 if (arcLStartToStart < 0. || arcLStartToEnd < 0.) {
180 if (arcLStartToStart < arcLStartToEnd)
181 vertexPosition = trackStart;
183 vertexPosition = trackEnd;
187 double arcLEndToStart = (trackStart - endPosition).Dot(vertexDirection);
188 double arcLEndToEnd = (trackEnd - endPosition).Dot(vertexDirection);
190 if (arcLEndToStart > 0. || arcLEndToEnd > 0.) {
191 if (arcLEndToStart > arcLEndToEnd)
192 endPosition = trackStart;
194 endPosition = trackEnd;
199 hitVec.end(), hitsSpill.at(track.
key()).
begin(), hitsSpill.at(track.
key()).
end());
204 float trackEndPt1_X = vertexPosition.X();
205 float trackEndPt1_Y = vertexPosition.Y();
206 float trackEndPt1_Z = vertexPosition.Z();
207 float trackEndPt2_X = endPosition.X();
208 float trackEndPt2_Y = endPosition.Y();
209 float trackEndPt2_Z = endPosition.Z();
216 for (
unsigned int p = 0; p < hitVec.size(); p++) {
217 int peakLessRms = hitVec[p]->PeakTimeMinusRMS();
218 int peakPlusRms = hitVec[p]->PeakTimePlusRMS();
220 if (peakLessRms < fMinTickDrift || peakPlusRms >
fMaxTickDrift) {
238 unsigned boundaryMask[] = {0, 0};
246 boundaryMask[0] = 0x1;
248 boundaryMask[0] = 0x2;
251 boundaryMask[1] = 0x1;
253 boundaryMask[1] = 0x2;
258 boundaryMask[0] = 0x10;
260 boundaryMask[0] = 0x20;
263 boundaryMask[1] = 0x10;
265 boundaryMask[1] = 0x20;
270 boundaryMask[0] = 0x100;
272 boundaryMask[0] = 0x200;
275 boundaryMask[1] = 0x100;
277 boundaryMask[1] = 0x200;
279 unsigned trackMask = boundaryMask[0] | boundaryMask[1];
282 for (
int idx = 0; idx < 12; idx++)
283 if (trackMask & (0
x1 << idx)) nBitsSet++;
288 if ((trackMask & 0x300) != 0x300) {
290 if ((trackMask & 0
x3) == 0x3)
292 else if ((trackMask & 0x30) == 0x30)
294 else if ((trackMask & 0x3) && (trackMask & 0x30))
296 else if ((trackMask & 0x3) && (trackMask & 0x300))
308 else if (nBitsSet > 0) {
312 else if (trackMask & 0x30)
314 else if (trackMask & 0x300)
319 std::vector<float> endPt1;
320 std::vector<float> endPt2;
321 endPt1.push_back(trackEndPt1_X);
322 endPt1.push_back(trackEndPt1_Y);
323 endPt1.push_back(trackEndPt1_Z);
324 endPt2.push_back(trackEndPt2_X);
325 endPt2.push_back(trackEndPt2_Y);
326 endPt2.push_back(trackEndPt2_Z);
328 float cosmicScore = isCosmic > 0 ? 1. : 0.;
333 else if (isCosmic == 4)
337 cosmicTagTrackVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
339 util::CreateAssn(evt, *cosmicTagTrackVector, trackVec, *assnOutCosmicTagTrack);
342 util::CreateAssn(evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
345 evt.
put(std::move(cosmicTagTrackVector));
346 evt.
put(std::move(assnOutCosmicTagTrack));
347 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.
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.
Provides recob::Track data product.
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.
art framework interface to geometry description
int fMaxOutOfTime
Max hits that can be out of time before rejecting.