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();
173 bool matchview =
false;
177 clusterlist[Cls[i][
c1]]->View()){
182 matchedclusters[imatch][ii] = Cls[i][
c1];
183 matched[Cls[i][
c1]] = 1;
189 matched[Cls[i][
c1]] = 1;
193 bool matchview =
false;
196 clusterlist[Cls[j][
c2]]->View()){
199 if (fm.at(Cls[j][c2]).size()>fm.at(
matchedclusters[imatch][jj]).size()){
201 matchedclusters[imatch][jj] = Cls[j][
c2];
202 matched[Cls[j][
c2]] = 1;
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]);
217 matched[Cls[i][
c1]]=1;
218 matched[Cls[j][
c2]]=1;
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
Planes which measure Z direction.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< std::vector< unsigned int > > matchedclusters
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
virtual double GetXTicksOffset(int p, int t, int c) const =0