34 class CosmicPFParticleTagger;
58 auto const*
geo = lar::providerFrom<geo::Geometry>();
78 const double driftVelocity = detp.DriftVelocity(detp.Efield(), detp.Temperature());
81 2 *
geo->DetHalfWidth() / (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>>();
94 std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagTrackVector(
95 new std::vector<anab::CosmicTag>);
96 std::unique_ptr<art::Assns<anab::CosmicTag, recob::Track>> assnOutCosmicTagTrack(
98 std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> assnOutCosmicTagPFParticle(
105 if (!pfParticleHandle.
isValid()) {
126 art::FindManyP<recob::Track> pfPartToTrackAssns(pfParticleHandle, evt,
fTrackModuleLabel);
132 for (
size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++) {
136 std::vector<art::Ptr<recob::Track>> trackVec = pfPartToTrackAssns.at(pfPartIdx);
139 if (trackVec.empty()) {
141 std::vector<float> tempPt1, tempPt2;
142 tempPt1.push_back(-999);
143 tempPt1.push_back(-999);
144 tempPt1.push_back(-999);
145 tempPt2.push_back(-999);
146 tempPt2.push_back(-999);
147 tempPt2.push_back(-999);
149 util::CreateAssn(*
this, evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
158 std::vector<art::Ptr<recob::Hit>> hitVec = hitsSpill.at(track1.
key());
161 auto vertexPosition = track1->
Vertex();
163 auto endPosition = track1->
End();
169 if (trackVec.size() > 1) {
170 for (
size_t trackIdx = 1; trackIdx < trackVec.size(); trackIdx++) {
173 auto trackStart = track->
Vertex();
174 auto trackEnd = track->
End();
177 double arcLStartToStart = (trackStart - vertexPosition).Dot(vertexDirection);
178 double arcLStartToEnd = (trackEnd - vertexPosition).Dot(vertexDirection);
180 if (arcLStartToStart < 0. || arcLStartToEnd < 0.) {
181 if (arcLStartToStart < arcLStartToEnd)
182 vertexPosition = trackStart;
184 vertexPosition = trackEnd;
188 double arcLEndToStart = (trackStart - endPosition).Dot(vertexDirection);
189 double arcLEndToEnd = (trackEnd - endPosition).Dot(vertexDirection);
191 if (arcLEndToStart > 0. || arcLEndToEnd > 0.) {
192 if (arcLEndToStart > arcLEndToEnd)
193 endPosition = trackStart;
195 endPosition = trackEnd;
200 hitVec.end(), hitsSpill.at(track.
key()).
begin(), hitsSpill.at(track.
key()).
end());
205 float trackEndPt1_X = vertexPosition.X();
206 float trackEndPt1_Y = vertexPosition.Y();
207 float trackEndPt1_Z = vertexPosition.Z();
208 float trackEndPt2_X = endPosition.X();
209 float trackEndPt2_Y = endPosition.Y();
210 float trackEndPt2_Z = endPosition.Z();
217 for (
unsigned int p = 0;
p < hitVec.size();
p++) {
218 int peakLessRms = hitVec[
p]->PeakTimeMinusRMS();
219 int peakPlusRms = hitVec[
p]->PeakTimePlusRMS();
221 if (peakLessRms < fMinTickDrift || peakPlusRms >
fMaxTickDrift) {
239 unsigned boundaryMask[] = {0, 0};
247 boundaryMask[0] = 0x1;
249 boundaryMask[0] = 0x2;
252 boundaryMask[1] = 0x1;
254 boundaryMask[1] = 0x2;
259 boundaryMask[0] = 0x10;
261 boundaryMask[0] = 0x20;
264 boundaryMask[1] = 0x10;
266 boundaryMask[1] = 0x20;
271 boundaryMask[0] = 0x100;
273 boundaryMask[0] = 0x200;
276 boundaryMask[1] = 0x100;
278 boundaryMask[1] = 0x200;
280 unsigned trackMask = boundaryMask[0] | boundaryMask[1];
283 for (
int idx = 0; idx < 12; idx++)
284 if (trackMask & (0
x1 << idx)) nBitsSet++;
289 if ((trackMask & 0x300) != 0x300) {
291 if ((trackMask & 0
x3) == 0x3)
293 else if ((trackMask & 0x30) == 0x30)
295 else if ((trackMask & 0x3) && (trackMask & 0x30))
297 else if ((trackMask & 0x3) && (trackMask & 0x300))
309 else if (nBitsSet > 0) {
313 else if (trackMask & 0x30)
315 else if (trackMask & 0x300)
320 std::vector<float> endPt1;
321 std::vector<float> endPt2;
322 endPt1.push_back(trackEndPt1_X);
323 endPt1.push_back(trackEndPt1_Y);
324 endPt1.push_back(trackEndPt1_Z);
325 endPt2.push_back(trackEndPt2_X);
326 endPt2.push_back(trackEndPt2_Y);
327 endPt2.push_back(trackEndPt2_Z);
329 float cosmicScore = isCosmic > 0 ? 1. : 0.;
334 else if (isCosmic == 4)
338 cosmicTagTrackVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
340 util::CreateAssn(*
this, evt, *cosmicTagTrackVector, trackVec, *assnOutCosmicTagTrack);
343 util::CreateAssn(*
this, evt, *cosmicTagTrackVector, pfParticle, *assnOutCosmicTagPFParticle);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
enum anab::cosmic_tag_id CosmicTagID_t
EDProducer(fhicl::ParameterSet const &pset)
Vector_t VertexDirection() const
std::string fTrackModuleLabel
art framework interface to geometry description
bool isValid() const noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define DEFINE_ART_MODULE(klass)
std::string fPFParticleModuleLabel
key_type key() const noexcept
Point_t const & Vertex() const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
void produce(art::Event &e) override
Declaration of signal hit object.
Provides recob::Track data product.
CosmicPFParticleTagger(fhicl::ParameterSet const &p)
Point_t const & End() const
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.
LArSoft geometry interface.
int fMaxOutOfTime
Max hits that can be out of time before rejecting.