864 std::unique_ptr<mf::LogInfo> pdump;
867 pdump = std::unique_ptr<mf::LogInfo>(
new mf::LogInfo(
"TrackAna"));
879 std::vector<std::pair<const sim::MCTrack*, int>> selected_mctracks;
883 selected_mctracks.reserve(mctrackh->size());
888 *pdump <<
"MC Tracks\n" 889 <<
" Id pdg x y z dx dy dz p\n" 890 <<
"-------------------------------------------------------------------------------------------\n";
898 imctrk != mctrackh->end(); ++imctrk) {
906 int apdg = std::abs(pdg);
921 double mctime = mctrk.
Start().
T();
930 double plen = length(mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
939 selected_mctracks.push_back(std::make_pair(&mctrk, -1));
944 double pstart = mcstartmom.Mag();
945 double pend = mcendmom.Mag();
947 << std::setw(3) << mctrk.
TrackID()
948 << std::setw(6) << mctrk.
PdgCode()
950 << std::fixed << std::setprecision(2)
951 << std::setw(10) << mcdx
953 << std::setw(3) << mctrk.
TrackID()
954 << std::setw(6) << mctrk.
PdgCode()
956 << std::fixed << std::setprecision(2)
957 << std::setw(10) << mcstart[0]
958 << std::setw(10) << mcstart[1]
959 << std::setw(10) << mcstart[2];
962 << std::fixed << std::setprecision(3)
963 << std::setw(10) << mcstartmom[0]/pstart
964 << std::setw(10) << mcstartmom[1]/pstart
965 << std::setw(10) << mcstartmom[2]/pstart;
968 *pdump << std::setw(32) <<
" ";
969 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
971 << std::setw(3) << mctrk.
TrackID()
972 << std::setw(6) << mctrk.
PdgCode()
974 << std::fixed << std::setprecision(2)
975 << std::setw(10) << mcend[0]
976 << std::setw(10) << mcend[1]
977 << std::setw(10) << mcend[2];
980 << std::fixed << std::setprecision(3)
981 << std::setw(10) << mcendmom[0]/pend
982 << std::setw(10) << mcendmom[1]/pend
983 << std::setw(10) << mcendmom[2]/pend;
986 *pdump << std::setw(32)<<
" ";
987 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend
988 <<
"\nLength: " << plen <<
"\n";
994 std::ostringstream ostr;
995 ostr <<
"MC" << (
fIgnoreSign ?
"All" : (pdg > 0 ?
"Pos" :
"Neg")) << std::abs(pdg);
1000 double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
1001 double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
1002 double mcmom = mcstartmom.Mag();
1004 double mcke = mcmom*mcmom / (std::sqrt(mcmom*mcmom + mcmass*mcmass) + mcmass);
1006 mchists.fHmcstartx->Fill(mcstart.X());
1007 mchists.fHmcstarty->Fill(mcstart.Y());
1008 mchists.fHmcstartz->Fill(mcstart.Z());
1009 mchists.fHmcendx->Fill(mcend.X());
1010 mchists.fHmcendy->Fill(mcend.Y());
1011 mchists.fHmcendz->Fill(mcend.Z());
1012 mchists.fHmctheta->Fill(mcstartmom.Theta());
1013 mchists.fHmcphi->Fill(mcstartmom.Phi());
1014 mchists.fHmctheta_xz->Fill(mctheta_xz);
1015 mchists.fHmctheta_yz->Fill(mctheta_yz);
1016 mchists.fHmcmom->Fill(mcmom);
1017 mchists.fHmcmoml->Fill(mcmom);
1018 mchists.fHmcke->Fill(mcke);
1019 mchists.fHmckel->Fill(mcke);
1020 mchists.fHmclen->Fill(plen);
1021 mchists.fHmclens->Fill(plen);
1040 std::vector<art::Ptr<recob::Hit> > allhits;
1042 allhits.reserve(hith->size());
1043 for(
unsigned int i=0; i<hith->size(); ++i) {
1044 allhits.emplace_back(hith, i);
1059 <<
"TrackAna read " << trackvh->size()
1060 <<
" vectors of Stitched PtrVectorsof tracks.";
1067 *pdump <<
"\nReconstructed Tracks\n" 1068 <<
" Id MCid x y z dx dy dz p\n" 1069 <<
"-------------------------------------------------------------------------------------------\n";
1074 int ntrack = trackh->size();
1075 for(
int i = 0; i < ntrack; ++i) {
1081 std::vector<art::Ptr<recob::Hit> > trackhits;
1082 tkhit_find.get(i, trackhits);
1095 TVector3 pos = track.
Vertex();
1097 TVector3
end = track.
End();
1101 double dpos = bdist(pos);
1102 double dend = bdist(end);
1103 double tlen = length(track);
1104 double theta_xz = std::atan2(dir.X(), dir.Z());
1105 double theta_yz = std::atan2(dir.Y(), dir.Z());
1111 rhists.fHstartx->Fill(pos.X());
1112 rhists.fHstarty->Fill(pos.Y());
1113 rhists.fHstartz->Fill(pos.Z());
1114 rhists.fHstartd->Fill(dpos);
1115 rhists.fHendx->Fill(end.X());
1116 rhists.fHendy->Fill(end.Y());
1117 rhists.fHendz->Fill(end.Z());
1118 rhists.fHendd->Fill(dend);
1119 rhists.fHtheta->Fill(dir.Theta());
1120 rhists.fHphi->Fill(dir.Phi());
1121 rhists.fHtheta_xz->Fill(theta_xz);
1122 rhists.fHtheta_yz->Fill(theta_yz);
1127 rhists.fHmom->Fill(mom);
1128 rhists.fHmoml->Fill(mom);
1129 rhists.fHlen->Fill(tlen);
1130 rhists.fHlens->Fill(tlen);
1149 int start_point = (
swap == 0 ? 0 : ntraj-1);
1155 rot(1, 0) = -rot(1, 0);
1156 rot(2, 0) = -rot(2, 0);
1157 rot(1, 1) = -rot(1, 1);
1158 rot(2, 1) = -rot(2, 1);
1159 rot(1, 2) = -rot(1, 2);
1160 rot(2, 2) = -rot(2, 2);
1170 theta_xz = std::atan2(dir.X(), dir.Z());
1171 theta_yz = std::atan2(dir.Y(), dir.Z());
1182 for(
unsigned int imc = 0; imc < selected_mctracks.size(); ++imc) {
1183 const sim::MCTrack& mctrk = *selected_mctracks[imc].first;
1188 throw cet::exception(
"TrackAna") <<
"no particle with ID=" << pdg <<
"\n";
1189 const MCHists& mchists = iMCHistMap->second;
1193 double mctime = mctrk.
Start().
T();
1201 TVector3 mcstartmom;
1203 double plen = length(mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
1207 TVector3 mcpos = mcstart - pos;
1212 TVector3 mcmoml = rot * mcstartmom;
1213 TVector3 mcposl = rot * mcpos;
1215 double colinearity = mcmoml.Z() / mcmoml.Mag();
1217 double u = mcposl.X();
1218 double v = mcposl.Y();
1219 double w = mcposl.Z();
1221 double pu = mcmoml.X();
1222 double pv = mcmoml.Y();
1223 double pw = mcmoml.Z();
1225 double dudw = pu / pw;
1226 double dvdw = pv / pw;
1228 double u0 = u - w * dudw;
1229 double v0 = v - w * dvdw;
1230 double uv0 = std::sqrt(u0*u0 + v0*v0);
1232 mchists.fHduvcosth->Fill(colinearity, uv0);
1238 mchists.fHmcdudw->Fill(dudw);
1239 mchists.fHmcdvdw->Fill(dvdw);
1240 mchists.fHdudwpull->Fill(dudw / std::sqrt(cov(2,2)));
1241 mchists.fHdvdwpull->Fill(dvdw / std::sqrt(cov(3,3)));
1243 mchists.fHcosth->Fill(colinearity);
1248 mchists.fHmcu->Fill(u0);
1249 mchists.fHmcv->Fill(v0);
1250 mchists.fHmcw->Fill(w);
1251 mchists.fHupull->Fill(u0 / std::sqrt(cov(0,0)));
1252 mchists.fHvpull->Fill(v0 / std::sqrt(cov(1,1)));
1258 double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
1259 double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
1260 double mcmom = mcstartmom.Mag();
1262 double mcke = mcmom*mcmom / (std::sqrt(mcmom*mcmom + mcmass*mcmass) + mcmass);
1264 mchists.fHstartdx->Fill(pos.X() - mcstart.X());
1265 mchists.fHstartdy->Fill(pos.Y() - mcstart.Y());
1266 mchists.fHstartdz->Fill(pos.Z() - mcstart.Z());
1267 mchists.fHenddx->Fill(end.X() - mcend.X());
1268 mchists.fHenddy->Fill(end.Y() - mcend.Y());
1269 mchists.fHenddz->Fill(end.Z() - mcend.Z());
1270 mchists.fHlvsl->Fill(plen, tlen);
1271 mchists.fHdl->Fill(tlen - plen);
1272 mchists.fHpvsp->Fill(mcmom, mom);
1273 double dp = mom - mcmom;
1274 mchists.fHdp->Fill(dp);
1275 mchists.fHppull->Fill(dp / std::sqrt(cov(4,4)));
1276 if(std::abs(dpos) >= 5. && std::abs(dend) >= 5.) {
1277 mchists.fHpvspc->Fill(mcmom, mom);
1278 mchists.fHdpc->Fill(dp);
1279 mchists.fHppullc->Fill(dp / std::sqrt(cov(4,4)));
1294 std::set<int> tkidset;
1295 tkidset.insert(mcid);
1297 bt_serv->HitCollectionEfficiency(tkidset, trackhits, allhits,
geo::k3D);
1298 double hitpurity = bt_serv->HitCollectionPurity(tkidset, trackhits);
1299 mchists.fHHitEff->Fill(hiteff);
1300 mchists.fHHitPurity->Fill(hitpurity);
1304 mchists.fHgstartx->Fill(mcstart.X());
1305 mchists.fHgstarty->Fill(mcstart.Y());
1306 mchists.fHgstartz->Fill(mcstart.Z());
1307 mchists.fHgendx->Fill(mcend.X());
1308 mchists.fHgendy->Fill(mcend.Y());
1309 mchists.fHgendz->Fill(mcend.Z());
1310 mchists.fHgtheta->Fill(mcstartmom.Theta());
1311 mchists.fHgphi->Fill(mcstartmom.Phi());
1312 mchists.fHgtheta_xz->Fill(mctheta_xz);
1313 mchists.fHgtheta_yz->Fill(mctheta_yz);
1314 mchists.fHgmom->Fill(mcmom);
1315 mchists.fHgmoml->Fill(mcmom);
1316 mchists.fHgke->Fill(mcke);
1317 mchists.fHgkel->Fill(mcke);
1318 mchists.fHglen->Fill(plen);
1319 mchists.fHglens->Fill(plen);
1322 selected_mctracks[imc].second = i;
1326 float KE = ptkl->
E() - ptkl->
Mass();
1327 std::string KEUnits =
" GeV";
1335 <<
" Match MCTkID "<<std::setw(6)<<mctrk.
TrackID()
1336 <<
" Origin "<<mctrk.
Origin()
1337 <<
" PDG"<<std::setw(5)<<mctrk.
PdgCode()
1338 <<
" KE"<<std::setw(4)<<(int)KE<<KEUnits
1339 <<
" RecoTrkID "<<track.
ID()
1340 <<
" hitEff "<<std::setprecision(2)<<hiteff<<
" hitPur "<<hitpurity;
1341 int sWire, sTick, eWire, eTick;
1343 for(
unsigned short ipl = 0; ipl < geom->
Nplanes(); ++ipl) {
1348 mf::LogVerbatim(
"TrackAna")<<
" Wire:Tick in Pln "<<ipl<<
" W:T "<<sWire<<
":"<<sTick<<
" - "<<eWire<<
":"<<eTick;
1360 TVector3 pos = track.
Vertex();
1362 TVector3 end = track.
End();
1368 *pdump <<
"\nOffset" 1369 << std::setw(3) << track.
ID()
1370 << std::setw(6) << mcid
1372 << std::fixed << std::setprecision(2)
1373 << std::setw(10) << trackdx
1375 << std::setw(3) << track.
ID()
1376 << std::setw(6) << mcid
1378 << std::fixed << std::setprecision(2)
1379 << std::setw(10) << pos[0]
1380 << std::setw(10) << pos[1]
1381 << std::setw(10) << pos[2];
1384 << std::fixed << std::setprecision(3)
1385 << std::setw(10) << dir[0]
1386 << std::setw(10) << dir[1]
1387 << std::setw(10) << dir[2];
1390 *pdump << std::setw(32) <<
" ";
1391 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
1393 << std::setw(3) << track.
ID()
1394 << std::setw(6) << mcid
1396 << std::fixed << std::setprecision(2)
1397 << std::setw(10) << end[0]
1398 << std::setw(10) << end[1]
1399 << std::setw(10) << end[2];
1402 << std::fixed << std::setprecision(3)
1403 << std::setw(10) << enddir[0]
1404 << std::setw(10) << enddir[1]
1405 << std::setw(10) << enddir[2];
1408 *pdump << std::setw(32)<<
" ";
1409 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend
1410 <<
"\nLength: " << tlen <<
"\n";
1418 for(
unsigned int imc = 0; imc < selected_mctracks.size(); ++imc) {
1419 if(selected_mctracks[imc].second >= 0)
continue;
1420 const sim::MCTrack& mctrk = *selected_mctracks[imc].first;
1422 float KE = ptkl->
E() - ptkl->
Mass();
1423 std::string KEUnits =
" GeV";
1430 TVector3 mcstart, mcend, mcstartmom, mcendmom;
1432 double plen = length(mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
1434 <<
" NoMat MCTkID "<<std::setw(6)<<mctrk.
TrackID()
1435 <<
" Origin "<<mctrk.
Origin()
1436 <<
" PDG"<<std::setw(5)<<mctrk.
PdgCode()
1437 <<
" KE"<<std::setw(4)<<(int)KE<<KEUnits
1438 <<
" Length "<<std::fixed<<std::setprecision(1)<<plen<<
" cm";
1440 int sWire, sTick, eWire, eTick;
1442 for(
unsigned short ipl = 0; ipl < geom->
Nplanes(); ++ipl) {
1448 <<
" W:T "<<sWire<<
":"<<sTick<<
" - "<<eWire<<
":"<<eTick;
double E(const int i=0) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const simb::MCParticle * TrackIdToParticle_P(int const &id)
simb::Origin_t Origin() const
double EndMomentum() const
double VertexMomentum() const
TVector3 VertexDirection() const
Covariance matrices are either set or not.
TMatrixD EndCovariance() const
Covariance matrices are either set or not.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
std::string fStitchModuleLabel
void anaStitch(const art::Event &evt)
std::map< int, MCHists > fMCHistMap
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
3-dimensional objects, potentially hits, clusters, prongs, etc.
Rotation_t GlobalToLocalRotationAtPoint(size_t p) const
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
std::string fMCTrackModuleLabel
EventNumber_t event() const
const TLorentzVector & Momentum() const
simb::Origin_t fOriginValue
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
std::map< int, RecoHists > fRecoHistMap
TVector3 Vertex() const
Covariance matrices are either set or not.
TMatrixD VertexCovariance() const
Covariance matrices are either set or not.
TVector3 EndDirection() const
Covariance matrices are either set or not.
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
const MCStep & Start() const
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::string fTrackModuleLabel
unsigned int TrackID() const
TVector3 End() const
Covariance matrices are either set or not.
std::string fHitModuleLabel
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception