585 std::unique_ptr<mf::LogInfo> pdump;
588 pdump = std::unique_ptr<mf::LogInfo>(
new mf::LogInfo(
"TrackAna"));
602 std::map<const recob::Seed*, int> seedmap;
614 *pdump <<
"MC Tracks\n" 615 <<
" Id pdg x y z dx dy dz " 617 <<
"--------------------------------------------------------------------------------" 627 imctrk != mctrackh->end();
647 double mctime = mctrk.
Start().
T();
648 double mcdx = mctime * 1.e-3 * detProp.DriftVelocity();
656 double plen = length(detProp, mctrk, mcdx, mcstart, mcend, mcstartmom, mcendmom);
666 double pstart = mcstartmom.Mag();
667 double pend = mcendmom.Mag();
673 << mcstart[1] <<
std::setw(10) << mcstart[2];
676 << mcstartmom[0] / pstart <<
std::setw(10) << mcstartmom[1] / pstart
677 <<
std::setw(10) << mcstartmom[2] / pstart;
688 << mcendmom[0] / pend <<
std::setw(10) << mcendmom[1] / pend
699 std::ostringstream ostr;
705 double mctheta_xz = std::atan2(mcstartmom.X(), mcstartmom.Z());
706 double mctheta_yz = std::atan2(mcstartmom.Y(), mcstartmom.Z());
708 mchists.fHmcstartx->Fill(mcstart.X());
709 mchists.fHmcstarty->Fill(mcstart.Y());
710 mchists.fHmcstartz->Fill(mcstart.Z());
711 mchists.fHmcendx->Fill(mcend.X());
712 mchists.fHmcendy->Fill(mcend.Y());
713 mchists.fHmcendz->Fill(mcend.Z());
714 mchists.fHmctheta->Fill(mcstartmom.Theta());
715 mchists.fHmcphi->Fill(mcstartmom.Phi());
716 mchists.fHmctheta_xz->Fill(mctheta_xz);
717 mchists.fHmctheta_yz->Fill(mctheta_yz);
718 mchists.fHmcmom->Fill(mcstartmom.Mag());
719 mchists.fHmclen->Fill(plen);
728 int nseed = seedh->size();
729 for (
int i = 0; i < nseed; ++i) {
732 if (seedmap.count(&seed) == 0) seedmap[&seed] = -1;
746 double dirmag = dir.Mag();
747 double diryz = std::sqrt(dir.Y() * dir.Y() + dir.Z() * dir.Z());
749 double sinth = dir.X() / dirmag;
750 double costh = diryz / dirmag;
754 sinphi = -dir.Y() / diryz;
755 cosphi = dir.Z() / diryz;
760 rot(0, 1) = sinth * sinphi;
762 rot(2, 1) = -costh * sinphi;
763 rot(0, 2) = -sinth * cosphi;
765 rot(2, 2) = costh * cosphi;
769 int itraj = mcmatch(detProp, mctrk, seed);
774 TVector3 mcpos = mctrk[itraj].Position().Vect() -
pos;
775 TVector3 mcmom = mctrk[itraj].Momentum().Vect();
781 TVector3 mcmoml = rot * mcmom;
782 TVector3 mcposl = rot * mcpos;
784 if (mcmoml.Z() < 0.) mcmoml = -mcmoml;
785 double costh = mcmoml.Z() / mcmoml.Mag();
787 double u = mcposl.X();
788 double v = mcposl.Y();
789 double w = mcposl.Z();
791 double pu = mcmoml.X();
792 double pv = mcmoml.Y();
793 double pw = mcmoml.Z();
795 double dudw = pu / pw;
796 double dvdw = pv / pw;
798 double u0 = u - w * dudw;
799 double v0 = v - w * dvdw;
800 double uv0 = std::sqrt(u0 * u0 + v0 * v0);
804 mchists.fHduvcosth->Fill(costh, uv0);
809 mchists.fHmcdudw->Fill(dudw);
810 mchists.fHmcdvdw->Fill(dvdw);
812 mchists.fHcosth->Fill(costh);
817 mchists.fHmcu->Fill(u0);
818 mchists.fHmcv->Fill(v0);
819 mchists.fHmcw->Fill(w);
827 seedmap[&seed] = mctrk.
TrackID();
831 mchists.fHmstartx->Fill(mcstart.X());
832 mchists.fHmstarty->Fill(mcstart.Y());
833 mchists.fHmstartz->Fill(mcstart.Z());
834 mchists.fHmendx->Fill(mcend.X());
835 mchists.fHmendy->Fill(mcend.Y());
836 mchists.fHmendz->Fill(mcend.Z());
837 mchists.fHmtheta->Fill(mcstartmom.Theta());
838 mchists.fHmphi->Fill(mcstartmom.Phi());
839 mchists.fHmtheta_xz->Fill(mctheta_xz);
840 mchists.fHmtheta_yz->Fill(mctheta_yz);
841 mchists.fHmmom->Fill(mcstartmom.Mag());
842 mchists.fHmlen->Fill(plen);
852 mchists.fHgstartx->Fill(mcstart.X());
853 mchists.fHgstarty->Fill(mcstart.Y());
854 mchists.fHgstartz->Fill(mcstart.Z());
855 mchists.fHgendx->Fill(mcend.X());
856 mchists.fHgendy->Fill(mcend.Y());
857 mchists.fHgendz->Fill(mcend.Z());
858 mchists.fHgtheta->Fill(mcstartmom.Theta());
859 mchists.fHgphi->Fill(mcstartmom.Phi());
860 mchists.fHgtheta_xz->Fill(mctheta_xz);
861 mchists.fHgtheta_yz->Fill(mctheta_yz);
862 mchists.fHgmom->Fill(mcstartmom.Mag());
863 mchists.fHglen->Fill(plen);
878 int nseed = seedh->size();
880 if (nseed > 0 && pdump != 0) {
881 *pdump <<
"\nReconstructed Seeds\n" 882 <<
" MCid x y z dx dy dz " 884 <<
"--------------------------------------------------------------------------------" 888 for (
int i = 0; i < nseed; ++i) {
899 double mdir = dir.Mag();
900 if (mdir != 0.) { dir *= (1. / mdir); }
902 double dpos = bdist(pos);
903 double theta_xz = std::atan2(dir.X(), dir.Z());
904 double theta_yz = std::atan2(dir.Y(), dir.Z());
909 int mcid = seedmap[&seed];
921 rhists.fHx->Fill(pos.X());
922 rhists.fHy->Fill(pos.Y());
923 rhists.fHz->Fill(pos.Z());
924 rhists.fHdist->Fill(dpos);
925 rhists.fHtheta->Fill(dir.Theta());
926 rhists.fHphi->Fill(dir.Phi());
927 rhists.fHtheta_xz->Fill(theta_xz);
928 rhists.fHtheta_yz->Fill(theta_yz);
std::string fMCTrackModuleLabel
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void GetPoint(double *Pt, double *Err) const
std::string fSeedModuleLabel
Q_EXPORT QTSManip setprecision(int p)
bool isValid() const noexcept
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::map< int, RecoHists > fRecoHistMap
void err(const char *fmt,...)
const TLorentzVector & Momentum() const
Q_EXPORT QTSManip setw(int w)
std::map< int, MCHists > fMCHistMap
const MCStep & Start() const
unsigned int TrackID() const
void GetDirection(double *Dir, double *Err) const