37 #include "TMathBase.h" 50 std::vector<double>
const fCuts;
65 ,
fCuts{pset.get<std::vector<double>>(
"Cuts")}
66 ,
fDCenter{pset.get<
double>(
"DCenter")}
67 ,
fDelay{pset.get<
double>(
"Delay")}
69 ,
fMaxIon{pset.get<
double>(
"MaxIon")}
83 double drift = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature()) *
89 unsigned int vPlane = geom->
Nplanes(tpcid) - 1;
91 unsigned int uPlane = vPlane - 1;
99 clusters.
reserve(clustHandle->size());
100 for (
unsigned int i = 0; i < clustHandle->size(); ++i) {
103 double indIon(0), colIon(0);
104 std::map<int, int> indMap;
105 std::map<int, int> colMap;
106 std::vector<std::pair<int, int>> rLook;
108 std::vector<std::vector<double>> tGoing;
109 std::vector<std::vector<double>> matched;
110 std::vector<double> pointTemp(6);
111 std::pair<int, int> pairTemp;
115 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(
cluster);
116 for (
unsigned int hit = 0;
hit < hits.size();
hit++) {
117 ionSum += hits[
hit]->PeakAmplitude();
119 if (clusters[
cluster]->View() == uView)
121 else if (clusters[
cluster]->View() == vView)
124 mf::LogInfo(
"MuonFilter") <<
"Ionizations: " << indIon <<
" " << colIon;
129 lineVec.
reserve(lines->size());
130 for (
unsigned int i = 0; i < lines->size(); ++i) {
134 for (
size_t cl = 0; cl < clusters.
size(); cl++) {
135 std::vector<art::Ptr<recob::Hit>>
hits = fmh.at(cl);
136 if (hits.size() > 0 && clusters[cl]->View() == uView)
137 inductionSegments.
push_back(clusters[cl]);
138 else if (hits.size() > 0 && clusters[cl]->View() == vView)
139 collectionSegments.
push_back(clusters[cl]);
145 if (inductionSegments.
size() == 0 || collectionSegments.
size() == 0) {
146 mf::LogInfo(
"MuonFilter") <<
"At least one plane with no track";
150 for (
unsigned int i = 0; i < inductionSegments.
size(); i++) {
151 if (indMap[i])
continue;
152 for (
unsigned int j = 0; j < collectionSegments.
size(); j++) {
153 if (colMap[j])
continue;
158 std::vector<art::Ptr<recob::Hit>> indHits = fmhi.at(i);
160 std::vector<art::Ptr<recob::Hit>> colHits = fmhc.at(j);
165 double trk2End = colSeg->
EndTick();
170 int const vPos2 = colSeg->
EndWire();
171 mf::LogInfo(
"MuonFilter") <<
"I J " << i <<
" " << j;
176 <<
"U's " << uPos1 <<
" " << uPos2 <<
"V's " << vPos1 <<
" " << vPos2 <<
" times " 177 << trk1End <<
" " << trk2End <<
" " << trk1Start <<
" " << trk2Start;
187 std::swap(uPos1, uPos2);
190 if ((TMath::Abs(trk1Start - trk2Start) >
fTolerance &&
191 TMath::Abs(trk1End - trk2End) >
fTolerance) &&
192 (TMath::Abs(trk1Start - trk2End) <
fTolerance &&
193 TMath::Abs(trk1End - trk2Start) <
fTolerance)) {
194 std::swap(trk1Start, trk1End);
195 std::swap(uPos1, uPos2);
199 <<
"Times: " << trk1Start <<
" " << trk2Start <<
" " << trk1End <<
" " << trk2End;
204 if ((TMath::Abs(trk1Start - trk2Start) <
fTolerance &&
205 TMath::Abs(trk1End - trk2End) <
fTolerance) &&
206 (TMath::Abs(uPos1 - vPos1) <=
fDeltaWire + 2 &&
207 TMath::Abs(uPos2 - vPos2) <=
fDeltaWire + 2)) {
213 double y1,
y2, z1, z2;
217 double const x1 = (trk1Start + trk2Start) / 2.0 * drift -
fDCenter;
218 double const x2 = (trk1End + trk2End) / 2.0 * drift -
fDCenter;
219 mf::LogInfo(
"MuonFilter") <<
"Match " << matchNum <<
" " << x1 <<
" " << y1 <<
" " << z1
220 <<
" " << x2 <<
" " << y2 <<
" " << z2;
221 bool x1edge, x2edge, y1edge, y2edge, z1edge, z2edge;
222 indMap[i] = matchNum;
223 colMap[j] = matchNum;
231 x1edge = (TMath::Abs(x1) -
fCuts[0] > 0);
232 x2edge = (TMath::Abs(x2) -
fCuts[0] > 0);
233 y1edge = (TMath::Abs(y1) -
fCuts[1] > 0);
234 y2edge = (TMath::Abs(y2) -
fCuts[1] > 0);
235 z1edge = (TMath::Abs(z1) -
fCuts[2] > 0);
236 z2edge = (TMath::Abs(z2) -
fCuts[2] > 0);
237 if ((x1edge || y1edge || z1edge) && (x2edge || y2edge || z2edge)) {
238 tGoing.push_back(pointTemp);
239 mf::LogInfo(
"MuonFilter") <<
"outside Removed induction ion: ";
241 for (
size_t h = 0; h < indHits.size(); h++) {
242 mf::LogInfo(
"MuonFilter") << indHits[h]->PeakAmplitude() <<
" ";
243 indIon -= indHits[h]->PeakAmplitude();
245 mf::LogInfo(
"MuonFilter") <<
"Removed collection ion: ";
247 for (
size_t h = 0; h < colHits.size(); h++) {
248 mf::LogInfo(
"MuonFilter") << colHits[h]->PeakAmplitude() <<
" ";
249 colIon -= colHits[h]->PeakAmplitude();
252 <<
"Ionization outside track I/C: " << indIon <<
" " << colIon;
254 else if ((x1edge || y1edge || z1edge) && !(x2edge || y2edge || z2edge) &&
256 tGoing.push_back(pointTemp);
257 mf::LogInfo(
"MuonFilter") <<
"stopping Removed induction ion: ";
258 for (
size_t h = 0; h < indHits.size(); h++) {
259 mf::LogInfo(
"MuonFilter") << indHits[h]->PeakAmplitude() <<
" ";
260 indIon -= indHits[h]->PeakAmplitude();
262 mf::LogInfo(
"MuonFilter") <<
"Removed collection ion: ";
263 for (
size_t h = 0; h < colHits.size(); h++) {
264 mf::LogInfo(
"MuonFilter") << colHits[h]->PeakAmplitude() <<
" ";
265 colIon -= colHits[h]->PeakAmplitude();
268 <<
"Ionization outside track I/C: " << indIon <<
" " << colIon;
271 pairTemp = std::make_pair(i, j);
272 mf::LogInfo(
"MuonFilter") <<
"rLook matchnum " << matchNum <<
" " << i <<
" " << j;
273 rLook.push_back(pairTemp);
274 matched.push_back(pointTemp);
283 for (
unsigned int i = 0; i < tGoing.size(); i++)
284 for (
unsigned int j = 0; j < matched.size(); j++) {
285 mf::LogInfo(
"MuonFilter") << tGoing.size() <<
" " << matched.size() <<
" " << i <<
" " << j;
287 if ((tGoing[i][2] <= matched[j][2]) && (tGoing[i][5] >= matched[j][5])) {
288 TVector3
a1(&tGoing[i][0]);
289 TVector3
a2(&tGoing[i][3]);
290 TVector3 b1(&matched[j][0]);
291 distance = TMath::Abs((((a1 - a2).Cross((a1 - a2).Cross(a1 - b1))).Unit()).Dot(a1 - b1));
292 mf::LogInfo(
"MuonFilter") <<
"distance " << distance;
295 <<
"Removing delta ion " << rLook.size() <<
" " << rLook[j].first <<
" " << matchNum;
296 std::vector<art::Ptr<recob::Hit>> temp = fmhi.at(rLook[j].first);
297 for (
unsigned int h = 0; h < temp.size(); h++)
298 indIon -= temp[h]->PeakAmplitude();
299 temp = fmhc.at(rLook[j].
second);
300 for (
unsigned int h = 0; h < temp.size(); h++)
301 colIon -= temp[h]->PeakAmplitude();
void reserve(size_type n)
bool filter(art::Event &evt) override
Float_t y1[n_points_granero]
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Float_t x1[n_points_granero]
Declaration of signal hit object.
float StartWire() const
Returns the wire coordinate of the start of the cluster.
std::vector< double > const fCuts
float EndTick() const
Returns the tick coordinate of the end of the cluster.
geo::PlaneID Plane() const
Returns the plane ID this cluster lies on.
Cluster finding and building.
Float_t y2[n_points_geant4]
int const fDeltaWire
allowed differences in wire number between 2 planes
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
std::string const fLineModuleLabel
#define DEFINE_ART_MODULE(klass)
MuonFilter(fhicl::ParameterSet const &)
void push_back(Ptr< U > const &p)
std::string const fClusterModuleLabel
The data type to uniquely identify a TPC.
Declaration of cluster object.
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Encapsulate the construction of a single detector plane.
EDFilter(fhicl::ParameterSet const &pset)
unsigned int Nplanes(TPCID const &tpcid=tpc_zero) const
Returns the total number of planes in the specified TPC.
bool IntersectionPoint(WireID const &wid1, WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
Float_t x2[n_points_geant4]
second_as<> second
Type of time stored in seconds, in double precision.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
float StartTick() const
Returns the tick coordinate of the start of the cluster.
art framework interface to geometry description
float EndWire() const
Returns the wire coordinate of the end of the cluster.