20 #include "canvas/Persistency/Common/FindManyP.h" 28 #include "Geant4/G4ThreeVector.hh" 36 #include "MCCheater/BackTracker.h" 94 consumes< std::vector<gar::rec::Hit> >(hitTag);
95 consumes< std::vector<gar::rec::TPCCluster> >(TPCClusterTag);
96 consumes< art::Assns<gar::rec::TPCCluster, gar::rec::Hit> >(TPCClusterTag);
98 produces< std::vector<gar::rec::Track> >();
99 produces< art::Assns<gar::rec::TPCCluster, gar::rec::Track> >();
100 produces< art::Assns<gar::rec::VecHit, gar::rec::Track> >();
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);
253 float lengthforwards = 0;
254 std::vector<int> hlf;
255 float lengthbackwards = 0;
256 std::vector<int> hlb;
260 std::vector<float> tparbeg(6,0);
268 std::vector<float> tparend(6,0);
278 for (
size_t i=0; i<25; ++i)
static constexpr double cm
void setNTPCClusters(const size_t nTPCClusters)
tpcpatreccheat(fhicl::ParameterSet const &p)
void produce(art::Event &e) override
void setLengthForwards(const float lengthforwards)
int makepatrectrack(std::vector< gar::rec::TPCCluster > &hits, gar::rec::TrackPar &trackpar)
void setCovMatBeg(const float *covmatbeg)
EDProducer(fhicl::ParameterSet const &pset)
float fTPCClusterGapCut
in cm – skip TPC clusters within this distance of a gap
void setLengthBackwards(const float lengthbackwards)
std::string fHitLabel
label of module making hits
void setTrackParametersBegin(const float *tparbeg)
#define DEFINE_ART_MODULE(klass)
int fPrintLevel
label of module for input TPC clusters
void setXEnd(const float xend)
void setTrackParametersEnd(const float *tparend)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
void setChisqBackwards(const float chisqbackwards)
gar::rec::Track CreateTrack()
General GArSoft Utilities.
unsigned int fInitialTPNTPCClusters
number of hits to use for initial trackpar estimate, if present
void setCovMatEnd(const float *covmatend)
float fTPCClusterRCut
maximum radius from center of TPC in YZ to take a cluster
float fSortTransWeight
for use in the hit sorting algorithm – transverse distance weight factor
void sort_TPCClusters_along_track(const std::vector< gar::rec::TPCCluster > &TPCClusters, std::vector< int > &hlf, std::vector< int > &hlb, int printlevel, float &lengthforwards, float &lengthbackwards, float sorttransweight, float sortdistback)
void setXBeg(const float xbeg)
float fSortDistBack
for use in the hit sorting algorithm – how far to go back before raising the distance figure of meri...
size_t fMinNumTPCClusters
minimum number of hits for a patrec track
tpcpatreccheat & operator=(tpcpatreccheat const &)=delete
void setChisqForwards(const float chisqforwards)
LArSoft geometry interface.
art framework interface to geometry description
void setTime(const double time)
std::string fTPCClusterLabel
cet::coded_exception< error, detail::translate > exception
int initial_trackpar_estimate(const std::vector< gar::rec::TPCCluster > &TPCClusters, std::vector< int > &TPCClusterlist, float &curvature_init, float &lambda_init, float &phi_init, float &xpos, float &ypos, float &zpos, float &x_other_end, unsigned int initialtpnTPCClusters, int printlevel)