108 <<
"Attempting to cheat the track pattern recognition for real data. " 109 <<
"That will not work";
113 auto const& TPCClusters = *TPCClusterHandle;
115 std::unique_ptr< std::vector<gar::rec::Track> > trkCol(
new std::vector<gar::rec::Track>);
116 std::unique_ptr< art::Assns<gar::rec::VecHit,gar::rec::Track> > vhTrkAssns(new ::art::Assns<gar::rec::VecHit,gar::rec::Track>);
117 std::unique_ptr< art::Assns<gar::rec::TPCCluster,gar::rec::Track> > TPCClusterTrkAssns(new ::art::Assns<gar::rec::TPCCluster,gar::rec::Track>);
121 const art::FindManyP<gar::rec::Hit> HitsFromTPCClusters(TPCClusterHandle,e,
fTPCClusterLabel);
123 auto bt = gar::providerFrom<cheat::BackTracker>();
124 auto geo = gar::providerFrom<geo::GeometryGAr>();
125 TVector3 xhat(1,0,0);
126 TVector3 tpccent(geo->TPCXCent(),geo->TPCYCent(),geo->TPCZCent());
131 for (
int iside=-1; iside <= 1; iside += 2)
133 std::map<int, std::set<size_t> > trackIDclusmap;
134 for (
size_t iclus = 0; iclus<TPCClusters.size(); ++iclus)
136 TVector3 cluspos(TPCClusters.at(iclus).Position());
137 TVector3 cprel = cluspos - tpccent;
138 float rclus = (cprel.Cross(xhat)).Mag();
142 if ( rclus > geo->GetIROCInnerRadius())
144 float phi = TMath::ATan2(cprel.Z(),cprel.Y());
145 if (phi<0) phi += 2.0*TMath::Pi();
146 float phisc = phi/( TMath::Pi()/9.0 );
147 UInt_t isector = TMath::Floor(phisc);
149 float rotang = ( isector*TMath::Pi()/9.0 );
150 float crot = TMath::Cos(rotang);
151 float srot = TMath::Sin(rotang);
153 float yrot = - cprel.Z()*srot + cprel.Y()*crot;
158 std::map<int, float> chargemap;
159 auto hits = HitsFromTPCClusters.at(iclus);
160 for (
size_t ihit=0; ihit< hits.size(); ++ihit)
162 unsigned int channel = hits.at(ihit)->Channel();
164 geo->ChannelToPosition(channel,chanpos);
166 if (chanpos[0] < tpccent.X())
170 if (hitside != iside)
continue;
171 auto hitides =
bt->HitToHitIDEs(hits.at(ihit));
173 for (
size_t i=0; i<hitides.size(); ++i)
175 float charge = hitides.at(i).energyTot;
177 int trackid = TMath::Abs(hitides.at(i).trackID);
178 auto cmf = chargemap.find(trackid);
179 if (cmf == chargemap.end())
181 chargemap[trackid]=charge;
185 cmf->second += charge;
192 int ibesttrackid = 0;
193 for (
auto const&
cm : chargemap)
195 if (
cm.second > maxcharge)
197 maxcharge =
cm.second;
198 ibesttrackid =
cm.first;
201 trackIDclusmap[ibesttrackid].emplace(iclus);
208 for (
auto const& tic : trackIDclusmap)
210 std::vector<gar::rec::TPCCluster> TPCClusters_thistrack;
211 std::vector<art::Ptr<gar::rec::TPCCluster> > TPCClusterptrs;
212 for (
auto const& iclus : tic.second)
214 TPCClusters_thistrack.push_back(TPCClusters.at(iclus));
215 TPCClusterptrs.push_back(TPCClusterPtrMaker(iclus));
225 auto const trackpointer = trackPtrMaker(trkCol->size()-1);
226 for (
size_t iTPCCluster=0; iTPCCluster<TPCClusters_thistrack.size(); ++iTPCCluster)
228 TPCClusterTrkAssns->addSingle(TPCClusterptrs.at(iTPCCluster),trackpointer);
static constexpr double cm
int makepatrectrack(std::vector< gar::rec::TPCCluster > &hits, gar::rec::TrackPar &trackpar)
float fTPCClusterGapCut
in cm – skip TPC clusters within this distance of a gap
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
gar::rec::Track CreateTrack()
float fTPCClusterRCut
maximum radius from center of TPC in YZ to take a cluster
size_t fMinNumTPCClusters
minimum number of hits for a patrec track
LArSoft geometry interface.
std::string fTPCClusterLabel
cet::coded_exception< error, detail::translate > exception