105 std::unique_ptr<std::vector<anab::CosmicTag>> cosmicTagPFParticleVector(
106 new std::vector<anab::CosmicTag>);
107 std::unique_ptr<art::Assns<recob::PCAxis, anab::CosmicTag>> assnOutCosmicTagPCAxis(
109 std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> assnOutCosmicTagPFParticle(
116 if (!pfParticleHandle.
isValid()) {
143 art::FindManyP<recob::SpacePoint> spacePointAssnVec(
154 for (
size_t pfPartIdx = 0; pfPartIdx != pfParticleHandle->size(); pfPartIdx++) {
158 std::vector<art::Ptr<recob::PCAxis>> pcAxisVec = pfPartToPCAxisAssns.at(pfPartIdx);
161 if (pcAxisVec.empty())
continue;
168 if (pcAxisVec.size() > 1 && pcAxisVec.front()->getID() > pcAxisVec.back()->getID())
186 double maxArcLen = 3. * eigenVal0;
189 TVector3 vertexPosition(
195 TVector3 pcAxisStart = vertexPosition - maxArcLen * vertexDirection;
196 TVector3 pcAxisEnd = vertexPosition + maxArcLen * vertexDirection;
199 float trackEndPt1_X = pcAxisStart[0];
200 float trackEndPt1_Y = pcAxisStart[1];
201 float trackEndPt1_Z = pcAxisStart[2];
202 float trackEndPt2_X = pcAxisEnd[0];
203 float trackEndPt2_Y = pcAxisEnd[1];
204 float trackEndPt2_Z = pcAxisEnd[2];
207 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(pfParticle.key());
212 for (
const auto&
cluster : clusterVec) {
214 std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(
cluster->ID());
222 for (
const auto&
hit : hitVec) {
224 std::cout <<
"***>> Hit key: " <<
hit.key() <<
", peak - RMS: " <<
hit->PeakTimeMinusRMS()
225 <<
", peak + RMS: " <<
hit->PeakTimePlusRMS()
238 std::vector<art::Ptr<recob::SpacePoint>> spacePointVec = spacePointAssnVec.at(pfParticle.key());
243 if (isCosmic == 0 && !spacePointVec.empty()) {
249 if (eigenVal0 > 0. && transRMS > 0.) {
256 double arcLengthToFirstHit(9999.);
257 double arcLengthToLastHit(-9999.);
259 for (
const auto spacePoint : spacePointVec) {
260 TVector3 spacePointPos(spacePoint->XYZ()[0], spacePoint->XYZ()[1], spacePoint->XYZ()[2]);
261 TVector3 deltaPos = spacePointPos - vertexPosition;
262 double arcLenToHit = deltaPos.Dot(vertexDirection);
264 if (arcLenToHit < arcLengthToFirstHit) {
265 arcLengthToFirstHit = arcLenToHit;
266 pcAxisStart = spacePointPos;
269 if (arcLenToHit > arcLengthToLastHit) {
270 arcLengthToLastHit = arcLenToHit;
271 pcAxisEnd = spacePointPos;
276 trackEndPt1_X = pcAxisStart[0];
277 trackEndPt1_Y = pcAxisStart[1];
278 trackEndPt1_Z = pcAxisStart[2];
279 trackEndPt2_X = pcAxisEnd[0];
280 trackEndPt2_Y = pcAxisEnd[1];
281 trackEndPt2_Z = pcAxisEnd[2];
288 bool nBdX[] = {
false,
false};
289 bool nBdY[] = {
false,
false};
290 bool nBdZ[] = {
false,
false};
319 bool exitEnd1 = nBdX[0] || nBdY[0];
320 bool exitEnd2 = nBdX[1] || nBdY[1];
328 if ((exitEnd1 && exitEnd2) || exitEndZ1 || exitEndZ2) {
330 if (nBdX[0] && nBdX[1])
332 else if (nBdY[0] && nBdY[1])
334 else if ((nBdX[0] || nBdX[1]) && (nBdY[0] || nBdY[1]))
336 else if ((nBdX[0] || nBdX[1]) && (nBdZ[0] || nBdZ[1]))
342 else if (nBdZ[0] && nBdZ[1]) {
347 else if ((nBdX[0] || nBdY[0] || nBdZ[0]) != (nBdX[1] || nBdY[1] || nBdZ[1])) {
349 if (nBdX[0] || nBdX[1])
351 else if (nBdY[0] || nBdY[1])
353 else if (nBdZ[0] || nBdZ[1])
359 std::vector<float> endPt1;
360 std::vector<float> endPt2;
361 endPt1.push_back(trackEndPt1_X);
362 endPt1.push_back(trackEndPt1_Y);
363 endPt1.push_back(trackEndPt1_Z);
364 endPt2.push_back(trackEndPt2_X);
365 endPt2.push_back(trackEndPt2_Y);
366 endPt2.push_back(trackEndPt2_Z);
368 float cosmicScore = isCosmic > 0 ? 1. : 0.;
373 else if (isCosmic == 4)
377 cosmicTagPFParticleVector->emplace_back(endPt1, endPt2, cosmicScore, tag_id);
380 *
this,
evt, *cosmicTagPFParticleVector, pfParticle, *assnOutCosmicTagPFParticle);
383 for (
const auto& axis : pcAxisVec) {
const EigenVectors & getEigenVectors() const
const double * getEigenValues() const
enum anab::cosmic_tag_id CosmicTagID_t
std::string fPFParticleModuleLabel
Cluster finding and building.
bool isValid() const noexcept
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.
Detector simulation of raw signals on wires.
const double * getAvePosition() const
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
QTextStream & endl(QTextStream &s)
std::string fPCAxisModuleLabel