11 #include "nusimdata/SimulationBase/MCParticle.h"
17 #include "art/Framework/Services/Registry/ServiceHandle.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "canvas/Persistency/Common/FindManyP.h"
20 #include "canvas/Persistency/Common/FindOneP.h"
21 #include "fhiclcpp/ParameterSet.h"
22 #include "cetlib/search_path.h"
23 #include "cetlib_except/exception.h"
25 #include "TPrincipal.h"
26 #include "Fit/Fitter.h"
27 #include "Math/Functor.h"
34 : fCaloAlg(pset.
get<fhicl::ParameterSet>(
"CalorimetryAlg")), fReader(
"")
36 fHitLabel = pset.get<std::string>(
"HitLabel");
52 fMVAMethods = pset.get<std::vector<std::string>>(
"MVAMethods");
53 std::vector<std::string> weightFileBnames = pset.get<std::vector<std::string>>(
"WeightFiles");
55 cet::search_path searchPath(
"FW_SEARCH_PATH");
56 for (
auto fileIter = weightFileBnames.begin(); fileIter != weightFileBnames.end(); ++fileIter) {
57 std::string fileWithPath;
58 if (!searchPath.find_file(*fileIter, fileWithPath)) {
61 throw cet::exception(
"MVAPID") <<
"Unable to find weight file " << *fileIter
62 <<
" in search path " << searchPath.to_string() << std::endl;
68 std::cerr <<
"Mismatch in number of MVA methods and weight files!" << std::endl;
72 for (
unsigned int iMethod = 0; iMethod !=
fMVAMethods.size(); ++iMethod) {
80 const double fiducialDist = 5.0;
82 if (pos.X() > (fDetMinX + fiducialDist) && pos.X() < (fDetMaxX - fiducialDist) &&
83 pos.Y() > (fDetMinY + fiducialDist) && pos.Y() < (fDetMaxY - fiducialDist) &&
84 pos.Z() > (fDetMinZ + fiducialDist) && pos.Z() < (fDetMaxZ - fiducialDist))
94 art::ServiceHandle<geo::Geometry const> geom;
101 fDetMaxZ = -999999.9;
103 for (
unsigned int t = 0; t < geom->TotalNTPC(); t++) {
104 if (geom->TPC(t).MinX() < fDetMinX) fDetMinX = geom->TPC(t).MinX();
105 if (geom->TPC(t).MaxX() > fDetMaxX) fDetMaxX = geom->TPC(t).MaxX();
106 if (geom->TPC(t).MinY() < fDetMinY) fDetMinY = geom->TPC(t).MinY();
107 if (geom->TPC(t).MaxY() > fDetMaxY) fDetMaxY = geom->TPC(t).MaxY();
108 if (geom->TPC(t).MinZ() < fDetMinZ) fDetMinZ = geom->TPC(t).MinZ();
109 if (geom->TPC(t).MaxZ() > fDetMaxZ) fDetMaxZ = geom->TPC(t).MaxZ();
117 art::ServiceHandle<geo::Geometry const> geom;
119 fNormToWiresY.clear();
120 fNormToWiresZ.clear();
127 std::string
id = std::string(plane.ID());
128 int pcryo =
id.find(
"C");
129 int ptpc =
id.find(
"T");
130 int pplane =
id.find(
"P");
131 std::string scryo =
id.substr(pcryo + 2, 2);
132 std::string stpc =
id.substr(ptpc + 2, 2);
133 std::string splane =
id.substr(pplane + 2, 2);
134 int icryo = std::stoi(scryo);
135 int itpc = std::stoi(stpc);
136 int iplane = std::stoi(splane);
137 planeKey = icryo * geom->NTPC(0) * geom->Nplanes(0, 0) + itpc * geom->Nplanes(0, 0) +
139 fNormToWiresY.insert(
140 std::make_pair(planeKey, -plane.Wire(0).Direction().Z()));
141 fNormToWiresZ.insert(
142 std::make_pair(planeKey, plane.Wire(0).Direction().Y()));
148 std::vector<anab::MVAPIDResult>& result,
149 art::Assns<recob::Track, anab::MVAPIDResult, void>& trackAssns,
150 art::Assns<recob::Shower, anab::MVAPIDResult, void>& showerAssns)
152 auto const clockData =
153 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
155 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
156 this->PrepareEvent(evt, clockData);
158 for (
auto trackIter = fTracks.begin(); trackIter != fTracks.end(); ++trackIter) {
161 std::vector<double> eVals, eVecs;
163 this->RunPCA(fTracksToHits[*trackIter], eVals, eVecs);
165 if (eVals[0] < 0.0001)
168 evalRatio = std::sqrt(eVals[1] * eVals[1] + eVals[2] * eVals[2]) / eVals[0];
169 this->FitAndSortTrack(*trackIter, isStoppingReco, sortedObj);
170 double coreHaloRatio, concentration, conicalness;
171 this->_Var_Shape(sortedObj, coreHaloRatio, concentration, conicalness);
172 double dEdxStart = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0., 0.05);
173 double dEdxEnd = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0.9, 1.0);
174 double dEdxPenultimate = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0.8, 0.9);
176 fResHolder.isTrack = 1;
177 fResHolder.isStoppingReco = isStoppingReco;
178 fResHolder.nSpacePoints = sortedObj.
hitMap.size();
179 fResHolder.trackID = (*trackIter)->ID();
180 fResHolder.evalRatio = evalRatio;
181 fResHolder.concentration = concentration;
182 fResHolder.coreHaloRatio = coreHaloRatio;
183 fResHolder.conicalness = conicalness;
184 fResHolder.dEdxStart = dEdxStart;
185 fResHolder.dEdxEnd = dEdxEnd;
186 if (dEdxPenultimate < 0.1)
187 fResHolder.dEdxEndRatio = 1.0;
189 fResHolder.dEdxEndRatio = dEdxEnd / dEdxPenultimate;
190 fResHolder.length = sortedObj.
length;
192 for (
auto methodIter = fMVAMethods.begin(); methodIter != fMVAMethods.end(); ++methodIter) {
193 fResHolder.mvaOutput[*methodIter] = fReader.EvaluateMVA(*methodIter);
195 result.push_back(fResHolder);
199 for (
auto showerIter = fShowers.begin(); showerIter != fShowers.end(); ++showerIter) {
202 std::vector<double> eVals, eVecs;
205 this->RunPCA(fShowersToHits[*showerIter], eVals, eVecs);
208 if (eVals[0] < 0.0001)
211 evalRatio = std::sqrt(eVals[1] * eVals[1] + eVals[2] * eVals[2]) / eVals[0];
213 this->SortShower(*showerIter, isStoppingReco, sortedObj);
215 double coreHaloRatio, concentration, conicalness;
216 this->_Var_Shape(sortedObj, coreHaloRatio, concentration, conicalness);
217 double dEdxStart = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0., 0.05);
218 double dEdxEnd = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0.9, 1.0);
219 double dEdxPenultimate = CalcSegmentdEdxFrac(clockData,
detProp, sortedObj, 0.8, 0.9);
221 fResHolder.isTrack = 0;
222 fResHolder.isStoppingReco = isStoppingReco;
223 fResHolder.nSpacePoints = sortedObj.
hitMap.size();
225 (*showerIter)->ID() + 1000;
227 fResHolder.evalRatio = evalRatio;
228 fResHolder.concentration = concentration;
229 fResHolder.coreHaloRatio = coreHaloRatio;
230 fResHolder.conicalness = conicalness;
231 fResHolder.dEdxStart = dEdxStart;
232 fResHolder.dEdxEnd = dEdxEnd;
233 if (dEdxPenultimate < 0.1)
234 fResHolder.dEdxEndRatio = 1.0;
236 fResHolder.dEdxEndRatio = dEdxEnd / dEdxPenultimate;
237 fResHolder.length = sortedObj.
length;
239 for (
auto methodIter = fMVAMethods.begin(); methodIter != fMVAMethods.end(); ++methodIter) {
240 fResHolder.mvaOutput[*methodIter] = fReader.EvaluateMVA(*methodIter);
242 result.push_back(fResHolder);
252 fSpacePoints.clear();
255 fSpacePointsToHits.clear();
256 fHitsToSpacePoints.clear();
257 fTracksToHits.clear();
258 fTracksToSpacePoints.clear();
259 fShowersToHits.clear();
260 fShowersToSpacePoints.clear();
264 art::Handle<std::vector<recob::Hit>> hitsHandle;
265 evt.getByLabel(fHitLabel, hitsHandle);
267 for (
unsigned int iHit = 0; iHit < hitsHandle->size(); ++iHit) {
268 const art::Ptr<recob::Hit>
hit(hitsHandle, iHit);
269 fHits.push_back(hit);
272 art::Handle<std::vector<recob::Track>> tracksHandle;
273 evt.getByLabel(fTrackLabel, tracksHandle);
275 for (
unsigned int iTrack = 0; iTrack < tracksHandle->size(); ++iTrack) {
276 const art::Ptr<recob::Track>
track(tracksHandle, iTrack);
277 fTracks.push_back(track);
280 art::Handle<std::vector<recob::Shower>> showersHandle;
281 evt.getByLabel(fShowerLabel, showersHandle);
283 for (
unsigned int iShower = 0; iShower < showersHandle->size(); ++iShower) {
284 const art::Ptr<recob::Shower>
shower(showersHandle, iShower);
285 fShowers.push_back(shower);
288 art::Handle<std::vector<recob::SpacePoint>> spHandle;
289 evt.getByLabel(fSpacePointLabel, spHandle);
291 for (
unsigned int iSP = 0; iSP < spHandle->size(); ++iSP) {
292 const art::Ptr<recob::SpacePoint> spacePoint(spHandle, iSP);
293 fSpacePoints.push_back(spacePoint);
296 art::FindManyP<recob::Hit> findTracksToHits(fTracks, evt, fTrackLabel);
297 art::FindManyP<recob::Hit> findShowersToHits(fShowers, evt, fShowerLabel);
298 art::FindOneP<recob::Hit> findSPToHits(fSpacePoints, evt, fSpacePointLabel);
300 for (
unsigned int iSP = 0; iSP < fSpacePoints.size(); ++iSP) {
301 const art::Ptr<recob::SpacePoint> spacePoint = fSpacePoints.at(iSP);
303 const art::Ptr<recob::Hit>
hit = findSPToHits.at(iSP);
304 fSpacePointsToHits[spacePoint] =
hit;
305 fHitsToSpacePoints[
hit] = spacePoint;
308 for (
unsigned int iTrack = 0; iTrack < fTracks.size(); ++iTrack) {
309 const art::Ptr<recob::Track>
track = fTracks.at(iTrack);
311 const std::vector<art::Ptr<recob::Hit>> trackHits = findTracksToHits.at(iTrack);
313 for (
unsigned int iHit = 0; iHit < trackHits.size(); ++iHit) {
314 const art::Ptr<recob::Hit>
hit = trackHits.at(iHit);
315 fTracksToHits[
track].push_back(hit);
316 if (fHitsToSpacePoints.count(hit)) {
317 fTracksToSpacePoints[
track].push_back(fHitsToSpacePoints.at(hit));
322 for (
unsigned int iShower = 0; iShower < fShowers.size(); ++iShower) {
323 const art::Ptr<recob::Shower>
shower = fShowers.at(iShower);
324 const std::vector<art::Ptr<recob::Hit>> showerHits = findShowersToHits.at(iShower);
326 for (
unsigned int iHit = 0; iHit < showerHits.size(); ++iHit) {
327 const art::Ptr<recob::Hit>
hit = showerHits.at(iHit);
328 fShowersToHits[
shower].push_back(hit);
329 if (fHitsToSpacePoints.count(hit)) {
330 fShowersToSpacePoints[
shower].push_back(fHitsToSpacePoints.at(hit));
336 art::Handle<std::vector<simb::MCParticle>> partHandle;
337 evt.getByLabel(fTrackingLabel, partHandle);
339 if (partHandle->size() == 0 || partHandle->at(0).TrackId() != 1) {
340 std::cout <<
"Error, ID of first track in largeant list is not 0" << std::endl;
343 fVertex4Vect = partHandle->at(0).Position();
353 sortedTrack.
hitMap.clear();
354 TVector3 trackPoint, trackDir;
355 this->LinFit(track, trackPoint, trackDir);
357 TVector3 nearestPointStart, nearestPointEnd;
362 if ((track->End<TVector3>() - fVertex4Vect.Vect()).Mag() >
363 (track->Vertex<TVector3>() - fVertex4Vect.Vect()).Mag()) {
366 trackDir * (trackDir.Dot(track->Vertex<TVector3>() - trackPoint) / trackDir.Mag2());
367 nearestPointEnd = trackPoint + trackDir * (trackDir.Dot(track->End<TVector3>() - trackPoint) /
369 isStoppingReco = this->IsInActiveVol(track->End<TVector3>());
374 trackDir * (trackDir.Dot(track->End<TVector3>() - trackPoint) / trackDir.Mag2());
377 trackDir * (trackDir.Dot(track->Vertex<TVector3>() - trackPoint) / trackDir.Mag2());
378 isStoppingReco = this->IsInActiveVol(track->Vertex<TVector3>());
383 if (track->End<TVector3>().Z() >=
384 track->Vertex<TVector3>().Z()) {
387 trackDir * (trackDir.Dot(track->Vertex<TVector3>() - trackPoint) / trackDir.Mag2());
388 nearestPointEnd = trackPoint + trackDir * (trackDir.Dot(track->End<TVector3>() - trackPoint) /
390 isStoppingReco = this->IsInActiveVol(track->End<TVector3>());
395 trackDir * (trackDir.Dot(track->End<TVector3>() - trackPoint) / trackDir.Mag2());
398 trackDir * (trackDir.Dot(track->Vertex<TVector3>() - trackPoint) / trackDir.Mag2());
399 isStoppingReco = this->IsInActiveVol(track->Vertex<TVector3>());
402 if (trackDir.Z() <= 0) {
403 trackDir.SetX(-trackDir.X());
404 trackDir.SetY(-trackDir.Y());
405 trackDir.SetZ(-trackDir.Z());
409 sortedTrack.
start = nearestPointStart;
410 sortedTrack.
end = nearestPointEnd;
411 sortedTrack.
dir = trackDir;
412 sortedTrack.
length = (nearestPointEnd - nearestPointStart).Mag();
414 std::vector<art::Ptr<recob::Hit>> hits = fTracksToHits[
track];
416 for (
auto hitIter = hits.begin(); hitIter != hits.end(); ++hitIter) {
418 if (!fHitsToSpacePoints.count(*hitIter))
continue;
419 art::Ptr<recob::SpacePoint> sp = fHitsToSpacePoints.at(*hitIter);
421 TVector3 nearestPoint =
422 trackPoint + trackDir * (trackDir.Dot(TVector3(sp->XYZ()) - trackPoint) / trackDir.Mag2());
423 double lengthAlongTrack = (nearestPointStart - nearestPoint).Mag();
424 sortedTrack.
hitMap.insert(std::pair<
double, art::Ptr<recob::Hit>>(lengthAlongTrack, *hitIter));
435 sortedShower.
hitMap.clear();
437 std::vector<art::Ptr<recob::Hit>> hits = fShowersToHits[
shower];
439 TVector3 showerEnd(0, 0, 0);
440 double furthestHitFromStart = -999.9;
441 for (
auto hitIter = hits.begin(); hitIter != hits.end(); ++hitIter) {
443 if (!fHitsToSpacePoints.count(*hitIter))
continue;
444 art::Ptr<recob::SpacePoint> sp = fHitsToSpacePoints.at(*hitIter);
445 if ((TVector3(sp->XYZ()) - shower->ShowerStart()).Mag() > furthestHitFromStart) {
446 showerEnd = TVector3(sp->XYZ());
447 furthestHitFromStart = (TVector3(sp->XYZ()) - shower->ShowerStart()).Mag();
451 TVector3 showerPoint, showerDir;
452 this->LinFitShower(shower, showerPoint, showerDir);
454 TVector3 nearestPointStart, nearestPointEnd;
459 if ((showerEnd - fVertex4Vect.Vect()).Mag() >
460 (shower->ShowerStart() - fVertex4Vect.Vect()).Mag()) {
463 showerDir * (showerDir.Dot(shower->ShowerStart() - showerPoint) / showerDir.Mag2());
465 showerPoint + showerDir * (showerDir.Dot(showerEnd - showerPoint) / showerDir.Mag2());
466 isStoppingReco = this->IsInActiveVol(showerEnd);
470 showerPoint + showerDir * (showerDir.Dot(showerEnd - showerPoint) / showerDir.Mag2());
473 showerDir * (showerDir.Dot(shower->ShowerStart() - showerPoint) / showerDir.Mag2());
474 isStoppingReco = this->IsInActiveVol(shower->ShowerStart());
479 if (showerEnd.Z() >= shower->ShowerStart().Z()) {
482 showerDir * (showerDir.Dot(shower->ShowerStart() - showerPoint) / showerDir.Mag2());
484 showerPoint + showerDir * (showerDir.Dot(showerEnd - showerPoint) / showerDir.Mag2());
485 isStoppingReco = this->IsInActiveVol(showerEnd);
489 showerPoint + showerDir * (showerDir.Dot(showerEnd - showerPoint) / showerDir.Mag2());
492 showerDir * (showerDir.Dot(shower->ShowerStart() - showerPoint) / showerDir.Mag2());
493 isStoppingReco = this->IsInActiveVol(shower->ShowerStart());
496 if (showerDir.Z() <= 0) {
497 showerDir.SetX(-showerDir.X());
498 showerDir.SetY(-showerDir.Y());
499 showerDir.SetZ(-showerDir.Z());
503 sortedShower.
start = nearestPointStart;
504 sortedShower.
end = nearestPointEnd;
505 sortedShower.
dir = showerDir;
506 sortedShower.
length = (nearestPointEnd - nearestPointStart).Mag();
508 for (
auto hitIter = hits.begin(); hitIter != hits.end(); ++hitIter) {
510 if (!fHitsToSpacePoints.count(*hitIter))
continue;
511 art::Ptr<recob::SpacePoint> sp = fHitsToSpacePoints.at(*hitIter);
513 TVector3 nearestPoint =
515 showerDir * (showerDir.Dot(TVector3(sp->XYZ()) - showerPoint) / showerDir.Mag2());
516 double lengthAlongShower = (nearestPointStart - nearestPoint).Mag();
517 sortedShower.
hitMap.insert(
518 std::pair<
double, art::Ptr<recob::Hit>>(lengthAlongShower, *hitIter));
523 std::vector<double>& eVals,
524 std::vector<double>& eVecs)
526 TPrincipal* principal =
new TPrincipal(3,
"D");
528 for (
auto hitIter = hits.begin(); hitIter != hits.end(); ++hitIter) {
530 if (fHitsToSpacePoints.count(*hitIter)) {
531 principal->AddRow(fHitsToSpacePoints.at(*hitIter)->XYZ());
536 principal->MakePrincipals();
538 for (
unsigned int i = 0; i < 3; ++i) {
539 eVals.push_back(principal->GetEigenValues()->GetMatrixArray()[i]);
542 for (
unsigned int i = 0; i < 9; ++i) {
543 eVecs.push_back(principal->GetEigenVectors()->GetMatrixArray()[i]);
548 double& coreHaloRatio,
549 double& concentration,
553 static const unsigned int conMinHits = 3;
554 static const double minCharge = 0.1;
555 static const double conFracRange = 0.2;
556 static const double MoliereRadius = 10.1;
557 static const double MoliereRadiusFraction = 0.2;
559 double totalCharge = 0;
560 double totalChargeStart = 0;
561 double totalChargeEnd = 0;
563 double chargeCore = 0;
564 double chargeHalo = 0;
565 double chargeCon = 0;
566 unsigned int nHits = 0;
569 double chargeConStart = 0;
570 double chargeConEnd = 0;
571 unsigned int nHitsConStart = 0;
572 unsigned int nHitsConEnd = 0;
574 for (
auto hitIter = track.
hitMap.begin(); hitIter != track.
hitMap.end(); ++hitIter) {
575 if (fHitsToSpacePoints.count(hitIter->second)) {
576 art::Ptr<recob::SpacePoint> sp = fHitsToSpacePoints.at(hitIter->second);
578 double distFromTrackFit = ((TVector3(sp->XYZ()) - track.
start).Cross(track.
dir)).Mag();
582 if (distFromTrackFit < MoliereRadiusFraction * MoliereRadius)
583 chargeCore += hitIter->second->Integral();
585 chargeHalo += hitIter->second->Integral();
587 totalCharge += hitIter->second->Integral();
589 chargeCon += hitIter->second->Integral() / std::max(1.
E-2, distFromTrackFit);
590 if (hitIter->first / track.
length < conFracRange) {
591 chargeConStart += distFromTrackFit * distFromTrackFit * hitIter->second->Integral();
593 totalChargeStart += hitIter->second->Integral();
595 else if (1. - hitIter->first / track.
length < conFracRange) {
596 chargeConEnd += distFromTrackFit * distFromTrackFit * hitIter->second->Integral();
598 totalChargeEnd += hitIter->second->Integral();
603 coreHaloRatio = chargeHalo /
TMath::Max(1.0
E-3, chargeCore);
604 coreHaloRatio =
TMath::Min(100.0, coreHaloRatio);
605 concentration = chargeCon / totalCharge;
606 if (nHitsConStart >= conMinHits && nHitsConEnd >= conMinHits && totalChargeEnd > minCharge &&
607 sqrt(chargeConStart) > minCharge && totalChargeStart > minCharge) {
608 conicalness = (sqrt(chargeConEnd) / totalChargeEnd) / (sqrt(chargeConStart) / totalChargeStart);
623 double trackLength = (track.
end - track.
start).Mag();
624 return CalcSegmentdEdxDist(clock_data, det_prop, track, start * trackLength, end * trackLength);
634 double trackLength = (track.
end - track.
start).Mag();
635 return CalcSegmentdEdxDist(clock_data, det_prop, track, trackLength - distAtEnd, trackLength);
645 art::ServiceHandle<geo::Geometry const> geom;
647 double totaldEdx = 0;
648 unsigned int nHits = 0;
651 for (
auto hitIter = track.
hitMap.begin(); hitIter != track.
hitMap.end(); ++hitIter) {
653 if (hitIter->first < start)
continue;
654 if (hitIter->first >= end)
break;
656 art::Ptr<recob::Hit>
hit = hitIter->second;
660 geom->WirePitch(hit->WireID().Plane,
662 double xComponent, pitch3D;
667 int planeKey = hit->WireID().Cryostat * geom->NTPC(0) * geom->Nplanes(0, 0) +
668 hit->WireID().TPC * geom->Nplanes(0, 0) + hit->WireID().Plane;
670 if (fNormToWiresY.count(planeKey) && fNormToWiresZ.count(planeKey)) {
671 TVector3 normToWires(0.0, fNormToWiresY.at(planeKey), fNormToWiresZ.at(planeKey));
673 geom->WirePitch(hit->WireID().Plane, hit->WireID().TPC) / fabs(dir.Dot(normToWires));
676 xComponent = yzPitch * dir[0] / sqrt(dir[1] * dir[1] + dir[2] * dir[2]);
677 pitch3D = sqrt(xComponent * xComponent + yzPitch * yzPitch);
679 double dEdx = fCaloAlg.dEdx_AREA(clock_data, det_prop, *hit, pitch3D, fEventT0);
686 return nHits ? totaldEdx / nHits : 0;
693 const std::vector<art::Ptr<recob::SpacePoint>>& sp = fTracksToSpacePoints.at(track);
696 unsigned int iPt = 0;
697 for (
auto spIter = sp.begin(); spIter != sp.end(); ++spIter) {
698 TVector3 point = (*spIter)->XYZ();
699 grFit.SetPoint(iPt++, point.X(), point.Y(), point.Z());
703 ROOT::Fit::Fitter fitter;
707 ROOT::Math::Functor fcn(sdist, 6);
710 TVector3 trackStart = track->Vertex<TVector3>();
711 TVector3 trackEnd = track->End<TVector3>();
712 trackDir = (trackEnd - trackStart).Unit();
714 TVector3 x0 = trackStart - trackDir;
715 TVector3 u = trackDir;
717 double pStart[6] = {x0.X(), u.X(), x0.Y(), u.Y(), x0.Z(), u.Z()};
719 fitter.SetFCN(fcn, pStart);
721 bool ok = fitter.FitFCN();
723 trackPoint.SetXYZ(x0.X(), x0.Y(), x0.Z());
724 trackDir.SetXYZ(u.X(), u.Y(), u.Z());
725 trackDir = trackDir.Unit();
729 const ROOT::Fit::FitResult& result = fitter.Result();
730 const double* parFit = result.GetParams();
731 trackPoint.SetXYZ(parFit[0], parFit[2], parFit[4]);
732 trackDir.SetXYZ(parFit[1], parFit[3], parFit[5]);
733 trackDir = trackDir.Unit();
740 TVector3& showerPoint,
744 const std::vector<art::Ptr<recob::SpacePoint>>& sp = fShowersToSpacePoints.at(shower);
747 unsigned int iPt = 0;
748 for (
auto spIter = sp.begin(); spIter != sp.end(); ++spIter) {
749 TVector3 point = (*spIter)->XYZ();
750 grFit.SetPoint(iPt++, point.X(), point.Y(), point.Z());
754 ROOT::Fit::Fitter fitter;
758 ROOT::Math::Functor fcn(sdist, 6);
761 TVector3 showerStart = shower->ShowerStart();
762 showerDir = shower->Direction().Unit();
764 TVector3 x0 = showerStart - showerDir;
765 TVector3 u = showerDir;
767 double pStart[6] = {x0.X(), u.X(), x0.Y(), u.Y(), x0.Z(), u.Z()};
769 fitter.SetFCN(fcn, pStart);
771 bool ok = fitter.FitFCN();
773 showerPoint.SetXYZ(x0.X(), x0.Y(), x0.Z());
774 showerDir.SetXYZ(u.X(), u.Y(), u.Z());
775 showerDir = showerDir.Unit();
779 const ROOT::Fit::FitResult& result = fitter.Result();
780 const double* parFit = result.GetParams();
781 showerPoint.SetXYZ(parFit[0], parFit[2], parFit[4]);
782 showerDir.SetXYZ(parFit[1], parFit[3], parFit[5]);
783 showerDir = showerDir.Unit();
anab::MVAPIDResult fResHolder
double CalcSegmentdEdxDistAtEnd(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const mvapid::MVAAlg::SortedObj &track, double distAtEnd)
int LinFit(const art::Ptr< recob::Track > track, TVector3 &trackPoint, TVector3 &trackDir)
void RunPCA(std::vector< art::Ptr< recob::Hit >> &hits, std::vector< double > &eVals, std::vector< double > &eVecs)
BEGIN_PROLOG could also be cerr
std::vector< std::string > fMVAMethods
Declaration of signal hit object.
int IsInActiveVol(const TVector3 &pos)
process_name use argoneut_mc_hitfinder track
std::string fSpacePointLabel
void PrepareEvent(const art::Event &event, const detinfo::DetectorClocksData &clockData)
MVAAlg(fhicl::ParameterSet const &pset)
void RunPID(art::Event &evt, std::vector< anab::MVAPIDResult > &result, art::Assns< recob::Track, anab::MVAPIDResult, void > &trackAssns, art::Assns< recob::Shower, anab::MVAPIDResult, void > &showerAssns)
int LinFitShower(const art::Ptr< recob::Shower > shower, TVector3 &showerPoint, TVector3 &showerDir)
void SortShower(art::Ptr< recob::Shower > shower, int &isStoppingReco, mvapid::MVAAlg::SortedObj &sortedShower)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::map< double, const art::Ptr< recob::Hit > > hitMap
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
auto end(FixedBins< T, C > const &) noexcept
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Provides recob::Track data product.
std::string fTrackingLabel
double CalcSegmentdEdxFrac(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const SortedObj &track, double start, double end)
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.
Contains all timing reference information for the detector.
void _Var_Shape(const SortedObj &track, double &coreHaloRatio, double &concentration, double &conicalness)
int trigger_offset(DetectorClocksData const &data)
void FitAndSortTrack(art::Ptr< recob::Track > track, int &isStoppingReco, SortedObj &sortedObj)
double CalcSegmentdEdxDist(const detinfo::DetectorClocksData &clock_data, const detinfo::DetectorPropertiesData &det_prop, const SortedObj &track, double start, double end)
art framework interface to geometry description
BEGIN_PROLOG could also be cout
std::vector< std::string > fWeightFiles