585 std::unique_ptr<mf::LogInfo> pdump;
588 pdump = std::unique_ptr<mf::LogInfo>(
new mf::LogInfo(
"TrackAna"));
593 bool mc = !
evt.isRealData();
597 art::Handle<std::vector<recob::Seed>> seedh;
602 std::map<const recob::Seed*, int> seedmap;
608 art::Handle<std::vector<sim::MCTrack>> mctrackh;
614 *pdump <<
"MC Tracks\n"
615 <<
" Id pdg x y z dx dy dz "
617 <<
"--------------------------------------------------------------------------------"
624 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt);
626 for (std::vector<sim::MCTrack>::const_iterator imctrk = mctrackh->begin();
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();
668 *pdump <<
"\nOffset" << std::setw(3) << mctrk.
TrackID() << std::setw(6)
669 << mctrk.
PdgCode() <<
" " << std::fixed << std::setprecision(2)
670 << std::setw(10) << mcdx <<
"\nStart " << std::setw(3) << mctrk.
TrackID()
671 << std::setw(6) << mctrk.
PdgCode() <<
" " << std::fixed
672 << std::setprecision(2) << std::setw(10) << mcstart[0] << std::setw(10)
673 << mcstart[1] << std::setw(10) << mcstart[2];
675 *pdump <<
" " << std::fixed << std::setprecision(3) << std::setw(10)
676 << mcstartmom[0] / pstart << std::setw(10) << mcstartmom[1] / pstart
677 << std::setw(10) << mcstartmom[2] / pstart;
680 *pdump << std::setw(32) <<
" ";
681 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pstart;
682 *pdump <<
"\nEnd " << std::setw(3) << mctrk.
TrackID() << std::setw(6)
683 << mctrk.
PdgCode() <<
" " << std::fixed << std::setprecision(2)
684 << std::setw(10) << mcend[0] << std::setw(10) << mcend[1] << std::setw(10)
687 *pdump <<
" " << std::fixed << std::setprecision(3) << std::setw(10)
688 << mcendmom[0] / pend << std::setw(10) << mcendmom[1] / pend
689 << std::setw(10) << mcendmom[2] / pend;
692 *pdump << std::setw(32) <<
" ";
693 *pdump << std::setw(12) << std::fixed << std::setprecision(3) << pend <<
"\n";
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);
724 if (seedh.isValid()) {
728 int nseed = seedh->size();
729 for (
int i = 0; i < nseed; ++i) {
730 art::Ptr<recob::Seed> pseed(seedh, 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);
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);
874 if (seedh.isValid()) {
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) {
889 art::Ptr<recob::Seed> pseed(seedh, 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];
910 *pdump << std::setw(15) << mcid <<
" " << std::fixed << std::setprecision(2)
911 << std::setw(10) << pos[0] << std::setw(10) << pos[1] << std::setw(10) << pos[2]
912 <<
" " << std::fixed << std::setprecision(3) << std::setw(10) << dir[0]
913 << std::setw(10) << dir[1] << std::setw(10) << dir[2] <<
"\n";
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
EResult err(const char *call)
void GetPoint(double *Pt, double *Err) const
std::string fSeedModuleLabel
std::map< int, RecoHists > fRecoHistMap
const TLorentzVector & Momentum() const
std::map< int, MCHists > fMCHistMap
const MCStep & Start() const
unsigned int TrackID() const
void GetDirection(double *Dir, double *Err) const