16 std::vector<art::Ptr<recob::Hit>>
hits;
17 std::vector<int> clsIDs;
21 bool comparePFP(
const pfpStuff& l,
const pfpStuff&
r)
26 double const lz = l.hits.size();
27 double const rz = r.hits.size();
30 constexpr
int hitthres = 80;
32 if (lz > hitthres && rz <= hitthres)
return false;
34 if (lz <= hitthres && rz > hitthres)
return true;
43 : fCalorimetryAlg(pset.
get<
fhicl::ParameterSet>(
"CalorimetryAlg"))
44 , fProjectionMatchingAlg(pset.
get<
fhicl::ParameterSet>(
"ProjectionMatchingAlg"))
63 std::vector<pfpStuff> allpfps;
67 for (
size_t i = 0; i < pfplist.size(); ++i) {
70 thispfp.clsIDs.clear();
71 thispfp.pfp = pfplist[i];
73 std::vector<art::Ptr<recob::Vertex>> thisvtxlist = vtxpfp_fm.at(pfplist[i].key());
74 if (thisvtxlist.size()) thispfp.vtx = thisvtxlist[0];
77 if (thistrklist.size()) thispfp.trk = thistrklist[0];
80 std::vector<int> clustersize;
82 for (
size_t j = 0; j < thisclusterlist.size(); ++j) {
84 thispfp.clsIDs.push_back(thisclusterlist[j]->ID());
86 std::vector<art::Ptr<recob::Hit>> thishitlist = cls_fm.at(thisclusterlist[j].key());
87 clustersize.push_back((
int)thishitlist.size());
89 for (
size_t k = 0; k < thishitlist.size(); ++k) {
90 thispfp.hits.push_back(thishitlist[k]);
95 if (clustersize.size() == 3) {
96 if (!thispfp.vtx)
continue;
97 if (!thispfp.trk)
continue;
99 allpfps.push_back(thispfp);
102 int wire = plane_2.WireCoordinate(thispfp.vtx->position());
104 std::cout <<
"pfp " << thispfp.pfp->Self() + 1 <<
" cluster sizes " << clustersize[0] <<
":" 105 << clustersize[1] <<
":" << clustersize[2] <<
" vertex " << thispfp.vtx->ID()
106 <<
" " << tick <<
":" << wire <<
" z " << thispfp.vtx->position().Z()
113 std::sort(allpfps.begin(), allpfps.end(), comparePFP);
114 std::reverse(allpfps.begin(), allpfps.end());
116 std::cout <<
"sorted pfps: ";
117 for (
size_t i = 0; i < allpfps.size(); ++i)
118 std::cout << allpfps[i].pfp->Self() + 1 <<
" ";
119 std::cout << std::endl;
121 bool showerCandidate =
false;
124 for (
size_t i = 0; i < allpfps.size(); ++i) {
130 std::vector<art::Ptr<recob::Hit>> pfphits = allpfps[i].hits;
131 std::vector<art::Ptr<recob::Cluster>> pfpcls = clspfp_fm.at(allpfps[i].pfp.key());
133 std::cout <<
"pfp " << allpfps[i].pfp->Self() + 1 <<
" hits " << pfphits.size() << std::endl;
140 if (pfptrk->
Vertex().Z() < pfptrk->
End().Z()) {
150 double pullTolerance = 0.7;
152 double minDistVert = 15;
158 if (pfphits.size() < 30)
continue;
159 if (pfphits.size() > 500)
continue;
161 if (pfphits.size() < 90) {
165 if (pfphits.size() > 400)
167 else if (pfphits.size() > 100)
171 for (
size_t ii = 0; ii < pfphits.size(); ++ii) {
176 double showerHitPull = 0;
182 std::map<geo::PlaneID, double> trk_tick1;
183 std::map<geo::PlaneID, double> trk_wire1;
186 std::map<geo::PlaneID, double> trk_tick2;
187 std::map<geo::PlaneID, double> trk_wire2;
189 for (
auto const& plane : wireReadoutGeom.Iterate<
geo::PlaneGeo>()) {
190 auto const& planeid = plane.ID();
192 trk_wire1[planeid] = plane.WireCoordinate(pfpStart);
194 trk_wire2[planeid] = plane.WireCoordinate(pfpPt2);
197 for (
size_t j = 0; j < clusterlist.size(); ++j) {
198 std::vector<art::Ptr<recob::Hit>> cls_hitlist = cls_fm.at(clusterlist[j].key());
200 if (clusterlist[j]->ID() > 0 && cls_hitlist.size() > 10)
continue;
201 if (cls_hitlist.size() > 50)
continue;
203 bool isGoodCluster =
false;
207 for (
size_t k = 0; k < allpfps[i].clsIDs.size(); ++k) {
208 if (allpfps[i].clsIDs[k] == clusterlist[j]->ID()) skipit =
true;
210 if (skipit)
continue;
212 for (
size_t jj = 0; jj < cls_hitlist.size(); ++jj) {
213 int isGoodHit =
goodHit(clockData,
223 if (isGoodHit == -1) {
224 isGoodCluster =
false;
227 else if (isGoodHit == 1) {
228 isGoodCluster =
true;
235 for (
size_t jj = 0; jj < cls_hitlist.size(); ++jj) {
238 int showerHitPullAdd = 0;
249 showerHitPull += showerHitPullAdd;
258 showerHitPull /= nShowerHits;
260 std::cout <<
"shower hits " <<
showerHits.size() <<
" " << nShowerHits <<
" shower pull " 261 << showerHitPull << std::endl;
263 if (nShowerHits > tolerance &&
std::abs(showerHitPull) < pullTolerance) {
264 showerCandidate =
true;
265 std::cout <<
"SHOWER CANDIDATE" << std::endl;
267 if (nShowerHits > 400) maxDist *= 2;
268 for (
size_t k = 0; k < hitlist.size(); ++k) {
269 std::vector<art::Ptr<recob::Cluster>> hit_clslist = hitcls_fm.at(hitlist[k].key());
270 if (hit_clslist.size())
continue;
272 int isGoodHit =
goodHit(clockData,
286 for (
size_t k = 0; k < clusterlist.size(); ++k) {
287 std::vector<art::Ptr<recob::Hit>> cls_hitlist = cls_fm.at(clusterlist[k].key());
288 if (clusterlist[k]->ID() > 0 && cls_hitlist.size() > 50)
continue;
290 double thisDist = maxDist;
291 double thisMin = minDistVert;
293 if (cls_hitlist.size() < 10) {
297 else if (cls_hitlist.size() < 30)
304 for (
size_t kk = 0; kk < cls_hitlist.size(); ++kk) {
306 int isGoodHit =
goodHit(clockData,
315 if (isGoodHit == -1) {
319 else if (isGoodHit == 1) {
324 double fracGood = (double)ngoodhits / nhits;
326 bool isGoodTrack = fracGood > 0.4;
329 for (
size_t kk = 0; kk < cls_hitlist.size(); ++kk) {
338 if (showerCandidate) {
339 std::cout <<
"THIS IS THE SHOWER PFP: " << allpfps[i].pfp->Self() + 1 << std::endl;
345 if (showerCandidate)
return 1;
358 double const maxDist,
359 double const minDistVert,
360 std::map<geo::PlaneID, double>
const& trk_wire1,
361 std::map<geo::PlaneID, double>
const& trk_tick1,
362 std::map<geo::PlaneID, double>
const& trk_wire2,
363 std::map<geo::PlaneID, double>
const& trk_tick2)
const 388 double const minDistVert,
389 std::map<geo::PlaneID, double>
const& trk_wire1,
390 std::map<geo::PlaneID, double>
const& trk_tick1,
391 std::map<geo::PlaneID, double>
const& trk_wire2,
392 std::map<geo::PlaneID, double>
const& trk_tick2,
399 double UnitsPerTick = tickToDist / wirePitch;
402 double y0 = hit->
PeakTime() * UnitsPerTick;
404 double x1 = trk_wire1.at(hit->
WireID());
405 double y1 = trk_tick1.at(hit->
WireID()) * UnitsPerTick;
407 double x2 = trk_wire2.at(hit->
WireID());
408 double y2 = trk_tick2.at(hit->
WireID()) * UnitsPerTick;
410 double distToVert = std::hypot(x0 - x1, y0 - y1);
411 if (distToVert < minDistVert)
return -1;
416 else if (distToVert < 100)
421 double a = std::hypot(x2 - x1, y2 - y1);
422 double b = std::hypot(x0 - x1, y0 - y1);
423 double c = std::hypot(x0 - x2, y0 - y2);
424 double costheta = -(pow(c, 2) - pow(a, 2) - pow(b, 2)) / (2 * a * b);
425 if (costheta < 0)
return -1;
428 std::abs((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) / std::hypot(y2 - y1, x2 - x1);
430 if (dist < maxDist) {
431 if (((y2 - y1) * x0 - (x2 - x1) * y0 + x2 * y1 - y2 * x1) > 0)
448 for (
size_t i = 0; i < showerhits.size(); ++i) {
449 if (hit.
key() == showerhits[i].key())
return false;
std::vector< double > totalEnergyErr
bool addShowerHit(art::Ptr< recob::Hit > hit, std::vector< art::Ptr< recob::Hit >> showerhits) const
Float_t y1[n_points_granero]
Float_t x1[n_points_granero]
std::vector< double > dEdx
double Temperature() const
In kelvin.
constexpr auto abs(T v)
Returns the absolute value of the argument.
Vector_t VertexDirection() const
Access to track direction at different points.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
WireID_t Wire
Index of the wire within its plane.
geo::WireID const & WireID() const
Initial tdc tick for hit.
int makeShowers(detinfo::DetectorClocksData const &dataClock, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::PFParticle >> const &pfplist, std::vector< art::Ptr< recob::Cluster >> const &clusterlist, std::vector< art::Ptr< recob::Hit >> const &hitlist, art::FindManyP< recob::Hit > const &cls_fm, art::FindManyP< recob::Cluster > const &clspfp_fm, art::FindManyP< recob::Vertex > const &vtxpfp_fm, art::FindManyP< recob::Cluster > const &hitcls_fm, art::FindManyP< recob::Track > const &trkpfp_fm)
Float_t y2[n_points_geant4]
double Efield(unsigned int planegap=0) const
kV/cm
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
key_type key() const noexcept
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Point_t const & Vertex() const
Access to track position at different points.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
double ConvertXToTicks(double X, int p, int t, int c) const
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
Declaration of cluster object.
Definition of data types for geometry description.
Detector simulation of raw signals on wires.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
float PeakTime() const
Time of the signal peak, in tick units.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Contains all timing reference information for the detector.
Vector_t EndDirection() const
Access to track direction at different points.
std::vector< double > totalEnergy
Point_t const & End() const
Access to track position at different points.
int goodHit(detinfo::DetectorClocksData const &dataClock, detinfo::DetectorPropertiesData const &detProp, art::Ptr< recob::Hit > const &, double maxDist, double minDistVert, std::map< geo::PlaneID, double > const &trk_wire1, std::map< geo::PlaneID, double > const &trk_tick1, std::map< geo::PlaneID, double > const &trk_wire2, std::map< geo::PlaneID, double > const &trk_tick2) const
Float_t x2[n_points_geant4]
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
std::vector< art::Ptr< recob::Hit > > showerHits
std::vector< double > dEdxErr
const Point_t & position() const
Return vertex 3D position.