580 std::unique_ptr<mf::LogInfo> pdump;
583 pdump = std::unique_ptr<mf::LogInfo>(
new mf::LogInfo(
"TrackAna"));
597 std::map<const recob::Seed*, int> seedmap;
609 *pdump <<
"MC Tracks\n" 610 <<
" Id pdg x y z dx dy dz " 612 <<
"--------------------------------------------------------------------------------" 622 imctrk != mctrackh->end();
642 double mctime = mctrk.
Start().
T();
643 double mcdx = mctime * 1.e-3 * detProp.DriftVelocity();
651 double plen = length(detProp, mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
661 double pstart = mcstartmom.Mag();
662 double pend = mcendmom.Mag();
663 *pdump <<
"\nOffset" << std::setw(3) << mctrk.
TrackID() << std::setw(6)
664 << mctrk.
PdgCode() <<
" " << std::fixed << std::setprecision(2)
665 << std::setw(10) << mcdx <<
"\nStart " << std::setw(3) << mctrk.
TrackID()
666 << std::setw(6) << mctrk.
PdgCode() <<
" " << std::fixed
667 << std::setprecision(2) << std::setw(10) << mcstart[0] << std::setw(10)
668 << mcstart[1] << std::setw(10) << mcstart[2];
670 *pdump <<
" " << std::fixed << std::setprecision(3) << std::setw(10)
671 << mcstartmom[0] / pstart << std::setw(10) << mcstartmom[1] / pstart
672 << std::setw(10) << mcstartmom[2] / pstart;
675 *pdump << std::setw(32) <<
" ";
676 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
677 *pdump <<
"\nEnd " << std::setw(3) << mctrk.
TrackID() << std::setw(6)
678 << mctrk.
PdgCode() <<
" " << std::fixed << std::setprecision(2)
679 << std::setw(10) << mcend[0] << std::setw(10) << mcend[1] << std::setw(10)
682 *pdump <<
" " << std::fixed << std::setprecision(3) << std::setw(10)
683 << mcendmom[0] / pend << std::setw(10) << mcendmom[1] / pend
684 << std::setw(10) << mcendmom[2] / pend;
687 *pdump << std::setw(32) <<
" ";
688 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend <<
"\n";
694 std::ostringstream ostr;
700 double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
701 double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
703 mchists.fHmcstartx->Fill(mcstart.X());
704 mchists.fHmcstarty->Fill(mcstart.Y());
705 mchists.fHmcstartz->Fill(mcstart.Z());
706 mchists.fHmcendx->Fill(mcend.X());
707 mchists.fHmcendy->Fill(mcend.Y());
708 mchists.fHmcendz->Fill(mcend.Z());
709 mchists.fHmctheta->Fill(mcstartmom.Theta());
710 mchists.fHmcphi->Fill(mcstartmom.Phi());
711 mchists.fHmctheta_xz->Fill(mctheta_xz);
712 mchists.fHmctheta_yz->Fill(mctheta_yz);
713 mchists.fHmcmom->Fill(mcstartmom.Mag());
714 mchists.fHmclen->Fill(plen);
723 int nseed = seedh->size();
724 for (
int i = 0; i < nseed; ++i) {
727 if (seedmap.count(&seed) == 0) seedmap[&seed] = -1;
741 double dirmag = dir.Mag();
742 double diryz = std::sqrt(dir.Y() * dir.Y() + dir.Z() * dir.Z());
744 double sinth = dir.X() / dirmag;
745 double costh = diryz / dirmag;
749 sinphi = -dir.Y() / diryz;
750 cosphi = dir.Z() / diryz;
755 rot(0, 1) = sinth * sinphi;
757 rot(2, 1) = -costh * sinphi;
758 rot(0, 2) = -sinth * cosphi;
760 rot(2, 2) = costh * cosphi;
764 int itraj = mcmatch(detProp, mctrk, seed);
769 TVector3 mcpos = mctrk[itraj].Position().Vect() - pos;
770 TVector3 mcmom = mctrk[itraj].Momentum().Vect();
776 TVector3 mcmoml = rot * mcmom;
777 TVector3 mcposl = rot * mcpos;
779 if (mcmoml.Z() < 0.) mcmoml = -mcmoml;
780 double costh = mcmoml.Z() / mcmoml.Mag();
782 double u = mcposl.X();
783 double v = mcposl.Y();
784 double w = mcposl.Z();
786 double pu = mcmoml.X();
787 double pv = mcmoml.Y();
788 double pw = mcmoml.Z();
790 double dudw = pu / pw;
791 double dvdw = pv / pw;
793 double u0 = u - w * dudw;
794 double v0 = v - w * dvdw;
795 double uv0 = std::sqrt(u0 * u0 + v0 * v0);
799 mchists.fHduvcosth->Fill(costh, uv0);
804 mchists.fHmcdudw->Fill(dudw);
805 mchists.fHmcdvdw->Fill(dvdw);
807 mchists.fHcosth->Fill(costh);
812 mchists.fHmcu->Fill(u0);
813 mchists.fHmcv->Fill(v0);
814 mchists.fHmcw->Fill(w);
826 mchists.fHmstartx->Fill(mcstart.X());
827 mchists.fHmstarty->Fill(mcstart.Y());
828 mchists.fHmstartz->Fill(mcstart.Z());
829 mchists.fHmendx->Fill(mcend.X());
830 mchists.fHmendy->Fill(mcend.Y());
831 mchists.fHmendz->Fill(mcend.Z());
832 mchists.fHmtheta->Fill(mcstartmom.Theta());
833 mchists.fHmphi->Fill(mcstartmom.Phi());
834 mchists.fHmtheta_xz->Fill(mctheta_xz);
835 mchists.fHmtheta_yz->Fill(mctheta_yz);
836 mchists.fHmmom->Fill(mcstartmom.Mag());
837 mchists.fHmlen->Fill(plen);
847 mchists.fHgstartx->Fill(mcstart.X());
848 mchists.fHgstarty->Fill(mcstart.Y());
849 mchists.fHgstartz->Fill(mcstart.Z());
850 mchists.fHgendx->Fill(mcend.X());
851 mchists.fHgendy->Fill(mcend.Y());
852 mchists.fHgendz->Fill(mcend.Z());
853 mchists.fHgtheta->Fill(mcstartmom.Theta());
854 mchists.fHgphi->Fill(mcstartmom.Phi());
855 mchists.fHgtheta_xz->Fill(mctheta_xz);
856 mchists.fHgtheta_yz->Fill(mctheta_yz);
857 mchists.fHgmom->Fill(mcstartmom.Mag());
858 mchists.fHglen->Fill(plen);
873 int nseed = seedh->size();
875 if (nseed > 0 && pdump != 0) {
876 *pdump <<
"\nReconstructed Seeds\n" 877 <<
" MCid x y z dx dy dz " 879 <<
"--------------------------------------------------------------------------------" 883 for (
int i = 0; i < nseed; ++i) {
894 double mdir = dir.Mag();
895 if (mdir != 0.) { dir *= (1. / mdir); }
897 double dpos = bdist(pos);
898 double theta_xz = std::atan2(dir.X(), dir.Z());
899 double theta_yz = std::atan2(dir.Y(), dir.Z());
904 int mcid = seedmap[&
seed];
905 *pdump << std::setw(15) << mcid <<
" " << std::fixed << std::setprecision(2)
906 << std::setw(10) << pos[0] << std::setw(10) << pos[1] << std::setw(10) << pos[2]
907 <<
" " << std::fixed << std::setprecision(3) << std::setw(10) << dir[0]
908 << std::setw(10) << dir[1] << std::setw(10) << dir[2] <<
"\n";
916 rhists.fHx->Fill(pos.X());
917 rhists.fHy->Fill(pos.Y());
918 rhists.fHz->Fill(pos.Z());
919 rhists.fHdist->Fill(dpos);
920 rhists.fHtheta->Fill(dir.Theta());
921 rhists.fHphi->Fill(dir.Phi());
922 rhists.fHtheta_xz->Fill(theta_xz);
923 rhists.fHtheta_yz->Fill(theta_yz);
std::string fMCTrackModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void GetPoint(double *Pt, double *Err) const
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::string fSeedModuleLabel
bool isValid() const noexcept
std::map< int, RecoHists > fRecoHistMap
const TLorentzVector & Momentum() const
std::map< int, MCHists > fMCHistMap
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
const MCStep & Start() const
unsigned int TrackID() const
void GetDirection(double *Dir, double *Err) const