111 std::unique_ptr< std::vector<gar::rec::VecHit> > vhCol(
new std::vector<gar::rec::VecHit>);
112 std::unique_ptr< art::Assns<gar::rec::TPCCluster,gar::rec::VecHit> > TPCClusterVHAssns(new ::art::Assns<gar::rec::TPCCluster,gar::rec::VecHit>);
115 auto const& TPCClusters = *TPCClusterHandle;
121 double xtpccent = geo->TPCXCent();
122 double ytpccent = geo->TPCYCent();
123 double ztpccent = geo->TPCZCent();
124 TVector3 tpccent(xtpccent,ytpccent,ztpccent);
125 TVector3 xhat(1,0,0);
128 std::vector<float> TPCClusterx;
129 for (
size_t i=0; i<TPCClusters.size(); ++i)
131 TPCClusterx.push_back(TPCClusters[i].Position()[0]);
133 std::vector<int> hsi(TPCClusterx.size());
134 TMath::Sort((
int) TPCClusterx.size(),TPCClusterx.data(),hsi.data());
136 std::vector<vechit_t> vechits;
137 std::vector<vechit_t> vhtmp;
141 for (
size_t ipass=0; ipass<
fNPasses; ++ipass)
143 for (
size_t iTPCClusterxs=0; iTPCClusterxs<hsi.size(); ++iTPCClusterxs)
145 int iTPCCluster = hsi[iTPCClusterxs];
146 const float *hpos = TPCClusters[iTPCCluster].Position();
147 TVector3 hpvec(hpos);
148 TVector3 cprel = hpvec - tpccent;
149 float rclus = (cprel.Cross(xhat)).Mag();
157 if ( rclus > geo->GetIROCInnerRadius())
159 float phi = TMath::ATan2(cprel.Z(),cprel.Y());
160 if (phi<0) phi += 2.0*TMath::Pi();
161 float phisc = phi/( TMath::Pi()/9.0 );
162 UInt_t isector = TMath::Floor(phisc);
164 float rotang = ( isector*TMath::Pi()/9.0 );
165 float crot = TMath::Cos(rotang);
166 float srot = TMath::Sin(rotang);
168 float yrot = - cprel.Z()*srot + cprel.Y()*crot;
174 vechit_t bestproposedvh;
175 size_t ibestmatch = 0;
177 for (
size_t ivh=0; ivh<vhtmp.size(); ++ivh)
180 if (
vh_TPCClusmatch(iTPCCluster, vhtmp[ivh], TPCClusters, proposedvh, ipass ))
182 if (!matched || proposedvh.c2ndf < bestproposedvh.c2ndf )
186 bestproposedvh = proposedvh;
193 vh.pos.SetXYZ(hpos[0],hpos[1],hpos[2]);
194 vh.dir.SetXYZ(0,0,0);
197 vh.TPCClusterindex.push_back(iTPCCluster);
203 vhtmp[ibestmatch] = bestproposedvh;
211 if (fNPasses > 1 && ipass < fNPasses-1)
214 std::vector<vechit_t> vhtmp2;
215 for (
size_t ivh=0; ivh<vhtmp.size(); ++ivh)
219 std::cout <<
"about to push vh: " << ivh <<
" " << vhtmp[ivh].c2ndf <<
" " << vhtmp[ivh].TPCClusterindex.size() <<
std::endl;
223 vhtmp2.push_back(vhtmp[ivh]);
227 for (
size_t iTPCCluster=0; iTPCCluster<vhtmp[ivh].TPCClusterindex.size(); ++iTPCCluster)
229 hsi.push_back(vhtmp[ivh].TPCClusterindex[iTPCCluster]);
236 std::cout <<
"left with " << vhtmp.size() <<
" vec hits and " << hsi.size() <<
" TPCClusters to reassociate " <<
std::endl;
243 for (
size_t ivh=0; ivh<vhtmp.size(); ++ivh)
245 vechits.push_back(vhtmp[ivh]);
246 vechit_t vh = vechits[ivh];
247 float pos[3] = {0,0,0};
248 float dir[3] = {0,0,0};
251 vhCol->emplace_back(pos,dir,vh.length);
252 auto const vhpointer = vhPtrMaker(ivh);
253 for (
size_t iTPCCluster=0; iTPCCluster<vh.TPCClusterindex.size(); ++iTPCCluster)
255 auto const TPCClusterpointer = TPCClusterPtrMaker(vh.TPCClusterindex[iTPCCluster]);
256 TPCClusterVHAssns->addSingle(TPCClusterpointer,vhpointer);
std::vector< float > fTPCClusterRCut
only take TPCClusters within rcut of the center of the detector
std::string fTPCClusterLabel
label of module to get the TPCClusters from
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::vector< unsigned int > fVecHitMinTPCClusters
minimum number of TPCClusters on a vector hit for it to be considered
bool vh_TPCClusmatch(int iTPCCluster, vechit_t &vechit, const std::vector< gar::rec::TPCCluster > &TPCClusters, vechit_t &proposedvh, size_t ipass)
std::vector< float > fTPCClusterGapCut
in cm – skip TPC clusters within this distance of a gap
std::vector< float > fC2Cut
"chisquared" per ndof cut to reassign TPCClusters
size_t fNPasses
number of passes to reassign TPCClusters from vector hits with poor chisquareds
int fPrintLevel
debug printout: 0: none, 1: selected, 2: all
LArSoft geometry interface.
QTextStream & endl(QTextStream &s)