35 this->reconfigure(pset);
40 fKSCut = pset.
get<
double >(
"KSCut");
41 fEnableU = pset.
get<
bool >(
"EnableU");
42 fEnableV = pset.
get<
bool >(
"EnableV");
43 fEnableZ = pset.
get<
bool >(
"EnableZ");
49 matchedclusters.clear();
58 std::vector< std::vector<TH1D*> > signals(nplanes);
60 std::vector< std::vector<unsigned int> > Cls(nplanes);
61 std::vector< std::vector<CluLen> > clulens(nplanes);
63 for (
size_t iclu = 0; iclu<clusterlist.size(); ++iclu){
67 float w0 = clusterlist[iclu]->StartWire();
68 float w1 = clusterlist[iclu]->EndWire();
69 float t0 = clusterlist[iclu]->StartTick();
70 float t1 = clusterlist[iclu]->EndTick();
74 clulen.
length = sqrt(pow((w0-w1)*wire_pitch,2)+pow(detprop->
ConvertTicksToX(t0,clusterlist[iclu]->Plane().Plane,clusterlist[iclu]->Plane().TPC,clusterlist[iclu]->Plane().Cryostat)-detprop->
ConvertTicksToX(t1,clusterlist[iclu]->Plane().Plane,clusterlist[iclu]->Plane().TPC,clusterlist[iclu]->Plane().Cryostat),2));
76 switch(clusterlist[iclu]->View()){
78 if (fEnableU) clulens[0].push_back(clulen);
81 if (fEnableV) clulens[1].push_back(clulen);
84 if (fEnableZ) clulens[2].push_back(clulen);
92 for (
size_t i = 0; i<clulens.size(); ++i){
94 for (
size_t j = 0; j<clulens[i].size(); ++j){
95 Cls[i].push_back(clulens[i][j].
index);
99 for (
int i = 0; i<nplanes; ++i){
100 for (
size_t ic = 0; ic < Cls[i].size(); ++ic){
101 TH1D sig(Form(
"sig_%d_%d",i,
int(ic)),Form(
"sig_%d_%d",i,
int(ic)),nts+100,-100,nts);
102 TH1D sigint(Form(
"sigint_%d_%d",i,
int(ic)),Form(
"sigint_%d_%d",i,
int(ic)),nts+100,-100,nts);
103 std::vector< art::Ptr<recob::Hit> > hitlist = fm.at(Cls[i][ic]);
104 std::sort(hitlist.begin(), hitlist.end(),
SortByWire);
106 for(
auto theHit = hitlist.begin(); theHit != hitlist.end(); theHit++){
108 double time = (*theHit)->PeakTime();
110 (*theHit)->WireID().TPC,
111 (*theHit)->WireID().Cryostat);
113 double charge = (*theHit)->Integral();
114 int bin = sig.FindBin(time);
115 sig.SetBinContent(bin,sig.GetBinContent(bin)+charge);
116 for (
int j = bin; j<=sig.GetNbinsX(); ++j){
117 sigint.SetBinContent(j,sigint.GetBinContent(j)+charge);
120 if (sigint.Integral()) sigint.Scale(1./sigint.GetBinContent(sigint.GetNbinsX()));
121 signals[i].push_back(
new TH1D(sigint));
126 std::vector<int> matched(clusterlist.size());
127 for (
size_t i = 0; i<clusterlist.size(); ++i) matched[i] = 0;
129 for (
int i = 0; i<nplanes-1; ++i){
130 for (
int j = i+1; j<nplanes; ++j){
131 for (
size_t c1 = 0;
c1<Cls[i].size(); ++
c1){
132 for (
size_t c2 = 0;
c2<Cls[j].size(); ++
c2){
135 if (clusterlist[Cls[i][
c1]]->View()==
136 clusterlist[Cls[j][
c2]]->View())
continue;
138 if (clusterlist[Cls[i][
c1]]->
Plane().Cryostat!=
139 clusterlist[Cls[j][
c2]]->
Plane().Cryostat)
continue;
140 if (clusterlist[Cls[i][
c1]]->
Plane().TPC!=
141 clusterlist[Cls[j][
c2]]->
Plane().TPC)
continue;
143 if (matched[Cls[i][
c1]]==1&&matched[Cls[j][
c2]]==1)
continue;
146 if (signals[i][
c1]->Integral()
147 &&signals[j][
c2]->Integral())
148 ks = signals[i][
c1]->KolmogorovTest(signals[j][
c2]);
150 mf::LogWarning(
"ClusterMatchTQ") <<
"One of the two clusters appears to be empty: "<<clusterlist[Cls[i][
c1]]->ID()<<
" "<<clusterlist[Cls[j][
c2]]->ID()<<
" "<<i<<
" "<<j<<
" "<<
c1<<
" "<<c2<<
" "<<signals[i][
c1]->Integral()<<
" "<<signals[j][
c2]->Integral();
159 for (
size_t l = 0; l<matchedclusters.size(); ++l){
160 for (
size_t m = 0; m<matchedclusters[l].size(); ++m){
161 if (matchedclusters[l][m]==Cls[i][
c1]){
165 else if (matchedclusters[l][m]==Cls[j][c2]){
173 bool matchview =
false;
175 for (
size_t ii = 0; ii<matchedclusters[imatch].size(); ++ii){
176 if (clusterlist[matchedclusters[imatch][ii]]->View()==
177 clusterlist[Cls[i][
c1]]->View()){
180 if (fm.at(Cls[i][
c1]).size()>fm.at(matchedclusters[imatch][ii]).size()){
181 matched[matchedclusters[imatch][ii]] = 0;
182 matchedclusters[imatch][ii] = Cls[i][
c1];
183 matched[Cls[i][
c1]] = 1;
188 matchedclusters[imatch].push_back(Cls[i][
c1]);
189 matched[Cls[i][
c1]] = 1;
193 bool matchview =
false;
194 for (
size_t jj = 0; jj<matchedclusters[imatch].size(); ++jj){
195 if (clusterlist[matchedclusters[imatch][jj]]->View()==
196 clusterlist[Cls[j][
c2]]->View()){
199 if (fm.at(Cls[j][c2]).size()>fm.at(matchedclusters[imatch][jj]).size()){
200 matched[matchedclusters[imatch][jj]] = 0;
201 matchedclusters[imatch][jj] = Cls[j][
c2];
202 matched[Cls[j][
c2]] = 1;
207 matchedclusters[imatch].push_back(Cls[j][c2]);
208 matched[Cls[j][
c2]] = 1;
213 std::vector<unsigned int>
tmp;
214 tmp.push_back(Cls[i][
c1]);
215 tmp.push_back(Cls[j][c2]);
216 matchedclusters.push_back(tmp);
217 matched[Cls[i][
c1]]=1;
218 matched[Cls[j][
c2]]=1;
226 for (
size_t i = 0; i<matchedclusters.size(); ++i){
227 if (matchedclusters[i].size())
mf::LogVerbatim(
"ClusterMatchTQ")<<
"Cluster group "<<i<<
":";
228 for (
size_t j = 0; j<matchedclusters[i].size(); ++j){
234 for (
int i = 0; i<nplanes; ++i){
235 for (
size_t j = 0; j<signals[i].size(); ++j){
236 delete signals[i][j];
code to link reconstructed objects back to the MC truth information
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
geo::WireID WireID() const
Initial tdc tick for hit.
Plane(const Point_t &planePos, const Vector_t &planeDir)
Constructor from reference position on the plane and direction orthogonal to the plane.
Planes which measure Z direction.
WireID_t Wire
Index of the wire within its plane.
Cluster finding and building.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
T get(std::string const &key) const
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
virtual unsigned int NumberTimeSamples() const =0
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
bool SortByLength(CluLen const &c1, CluLen const &c2)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
recob::tracking::Plane Plane
art framework interface to geometry description
virtual double GetXTicksOffset(int p, int t, int c) const =0