1121 const sim::ParticleList& plist = pi_serv->
ParticleList();
1125 particle = ipar->second;
1127 if (particle->
Mother() ==
1129 const TLorentzVector& positionStart = particle->
Position(0);
1130 positionStart.GetXYZT(
1135 MCTruthMuonParticle = particle;
1143 (180.0 / 3.14159) * atan(particle->
Momentum().Px() / particle->
Momentum().Pz());
1145 else if (particle->
Momentum().Pz() < 0 && particle->
Momentum().Px() >= 0) {
1147 180.0 + (180.0 / 3.14159) * atan(particle->
Momentum().Px() / particle->
Momentum().Pz());
1151 180.0 + (180.0 / 3.14159) * atan(particle->
Momentum().Px() / particle->
Momentum().Pz());
1153 else if (particle->
Momentum().Pz() >= 0 && particle->
Momentum().Px() < 0) {
1155 360.0 + (180.0 / 3.14159) * atan(particle->
Momentum().Px() / particle->
Momentum().Pz());
1162 double MCTruthLengthMuon =
truthLength(MCTruthMuonParticle);
1169 if (!isFiducial)
return;
1172 if (MCTruthMuonParticle) {
1178 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1186 int NMuonTracks = 0;
1190 std::vector<art::Ptr<recob::Track>>
TrackList;
1192 int NRecoTracks = TrackList.size();
1194 if (NRecoTracks == 0) {
1195 MF_LOG_DEBUG(
"MuonTrackingEff") <<
"There are no reco tracks... bye";
1196 std::cout <<
"There are no reco tracks! MCTruthMuonThetaXZ: " <<
std::endl;
1201 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1203 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1209 MF_LOG_DEBUG(
"MuonTrackingEff") <<
"Found this many reco tracks " << NRecoTracks;
1213 double PurityLeadingMuon = 0.;
1214 double CompletenessLeadingMuon = 0.;
1215 double RecoLengthLeadingMuon = 0.;
1218 double RecoLengthSecondMuon = 0.;
1219 double CompletenessSecondMuon = 0.;
1220 double PuritySecondMuon = 0.;
1223 double TrackLengthMuonSum = 0.;
1224 double tmpTotalRecoEnergy = 0.;
1226 double MaxLengthNoRecoMuon = 0;
1227 int PDGCodeMaxLengthNoRecoMuon = 0;
1231 std::vector<art::Ptr<recob::Hit>> tmp_TrackHits = track_hits.at(0);
1232 std::vector<art::Ptr<recob::Hit>> AllHits;
1236 auto const clockData =
1240 for (
int i = 0; i < NRecoTracks; i++) {
1242 std::vector<art::Ptr<recob::Hit>> TrackHits = track_hits.at(i);
1243 double tmpPurity = 0.;
1244 double tmpCompleteness = 0.;
1248 clockData, AllHits, TrackHits, particle, tmpPurity, tmpCompleteness, tmpTotalRecoEnergy);
1251 std::cout <<
"ERROR: Truth matcher didn't find a particle!" <<
std::endl;
1257 MaxLengthNoRecoMuon = track->
Length();
1258 PDGCodeMaxLengthNoRecoMuon = particle->
PdgCode();
1262 tmpCompleteness > 0 && tmpPurity > 0) {
1265 TrackLengthMuonSum += track->
Length();
1267 if (NMuonTracks == 1) {
1268 CompletenessLeadingMuon = tmpCompleteness;
1269 PurityLeadingMuon = tmpPurity;
1270 RecoLengthLeadingMuon = track->
Length();
1271 TrackLeadingMuon = track;
1273 RecoMuonParticle = particle;
1276 if (NMuonTracks >= 2 && tmpCompleteness > CompletenessLeadingMuon) {
1278 CompletenessSecondMuon = CompletenessLeadingMuon;
1279 PuritySecondMuon = PurityLeadingMuon;
1280 RecoLengthSecondMuon = RecoLengthLeadingMuon;
1281 TrackSecondMuon = TrackLeadingMuon;
1283 CompletenessLeadingMuon = tmpCompleteness;
1284 PurityLeadingMuon = tmpPurity;
1285 RecoLengthLeadingMuon = track->
Length();
1286 TrackLeadingMuon = track;
1288 RecoMuonParticle = particle;
1291 else if (NMuonTracks >= 2 && tmpCompleteness < CompletenessLeadingMuon &&
1292 tmpCompleteness > CompletenessSecondMuon) {
1293 CompletenessSecondMuon = tmpCompleteness;
1294 PuritySecondMuon = tmpPurity;
1295 RecoLengthSecondMuon = track->
Length();
1296 TrackSecondMuon = track;
1306 if (RecoMuonParticle && MCTruthMuonParticle) {
1310 h_TrackRes->Fill(RecoLengthLeadingMuon / MCTruthLengthMuon);
1312 std::cout <<
"TrackLeadingMuon->Vertex().X(): " << TrackLeadingMuon->
Vertex().X()
1314 std::cout <<
"MCTruthMuonParticle->Vz(): " << MCTruthMuonParticle->
Vz() <<
std::endl;
1317 double DistanceBetweenTruthAndRecoTrack;
1318 double AngleBetweenTruthAndRecoTrack;
1321 DistanceBetweenTruthAndRecoTrack,
1322 AngleBetweenTruthAndRecoTrack);
1324 h_VertexRes->Fill(DistanceBetweenTruthAndRecoTrack);
1328 CompletenessLeadingMuon);
1329 if (NMuonTracks >= 2) {
1330 double DistanceBetweenTracks;
1331 double AngleBetweenTracks;
1332 double CriteriaTwoTracks;
1336 DistanceBetweenTracks,
1341 RecoLengthLeadingMuon / MCTruthLengthMuon, RecoLengthSecondMuon / MCTruthLengthMuon);
1344 RecoLengthSecondMuon / MCTruthLengthMuon, AngleBetweenTracks);
1346 AngleBetweenTracks);
1351 if (CompletenessLeadingMuon < 0.5) {
1355 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1360 if (PurityLeadingMuon < 0.5) {
1364 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1369 if (RecoLengthLeadingMuon / MCTruthLengthMuon < 0.75) {
1373 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1378 if (RecoLengthLeadingMuon / MCTruthLengthMuon > 1.25) {
1382 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1406 if (CompletenessLeadingMuon < 0.5 || PurityLeadingMuon < 0.5 ||
1407 RecoLengthLeadingMuon / MCTruthLengthMuon < 0.75 ||
1408 RecoLengthLeadingMuon / MCTruthLengthMuon > 1.25) {
1412 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1414 RecoLengthLeadingMuon / MCTruthLengthMuon, CompletenessLeadingMuon);
1421 if (NMuonTracks >= 2) {
1422 double AngleBetweenTracks;
1423 double DistanceBetweenTracks;
1424 double CriteriaTwoTracks;
1427 DistanceBetweenTracks,
1431 if (AngleBetweenTracks > 160.) {
1433 std::cout <<
"Angle b/w tracks: " << AngleBetweenTracks <<
std::endl;
1434 std::cout <<
"CriteriaTwoTracks: " << CriteriaTwoTracks <<
std::endl;
1435 std::cout <<
"CompletenessLeadingMuon: " << CompletenessLeadingMuon <<
std::endl;
1436 std::cout <<
"CompletenessSecondMuon: " << CompletenessSecondMuon <<
std::endl;
1437 std::cout <<
"PurityLeadingMuon: " << PurityLeadingMuon <<
std::endl;
1438 std::cout <<
"PuritySecondMuon: " << PuritySecondMuon <<
std::endl;
1439 std::cout <<
"TrackLeadingMuon: " << RecoLengthLeadingMuon / MCTruthLengthMuon
1441 std::cout <<
"TrackResSecondMuon: " << RecoLengthSecondMuon / MCTruthLengthMuon
1443 std::cout <<
"TrackID leading: " << TrackLeadingMuon->
ID() <<
std::endl;
1444 std::cout <<
"TrackID second: " << TrackSecondMuon->
ID() <<
std::endl;
1448 AngleBetweenTracks);
1450 RecoLengthLeadingMuon / MCTruthLengthMuon, RecoLengthSecondMuon / MCTruthLengthMuon);
1452 CompletenessLeadingMuon, CompletenessSecondMuon);
1454 RecoLengthSecondMuon / MCTruthLengthMuon, AngleBetweenTracks);
1456 CompletenessSecondMuon, AngleBetweenTracks);
1458 AngleBetweenTracks);
1459 if ((CompletenessLeadingMuon + CompletenessSecondMuon) >= 0.5 &&
1460 PurityLeadingMuon >= 0.5 && PuritySecondMuon >= 0.5 &&
1461 (RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon >= 0.75 &&
1462 (RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon <= 1.25) {
1469 RecoLengthLeadingMuon / MCTruthLengthMuon, CompletenessLeadingMuon);
1471 ->Fill(RecoLengthLeadingMuon / MCTruthLengthMuon,
1472 RecoLengthSecondMuon / MCTruthLengthMuon);
1474 DistanceBetweenTracks, AngleBetweenTracks);
1476 if ((CompletenessLeadingMuon + CompletenessSecondMuon) < 0.5 || PurityLeadingMuon < 0.5 ||
1477 PuritySecondMuon < 0.5 ||
1478 (RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon < 0.75 ||
1479 (RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon > 1.25) {
1483 RecoLengthLeadingMuon / MCTruthLengthMuon, CompletenessLeadingMuon);
1485 ->Fill(RecoLengthLeadingMuon / MCTruthLengthMuon,
1486 RecoLengthSecondMuon / MCTruthLengthMuon);
1488 DistanceBetweenTracks, AngleBetweenTracks);
1490 if ((CompletenessLeadingMuon + CompletenessSecondMuon) < 0.5) {
1493 if (PurityLeadingMuon < 0.5 || PuritySecondMuon < 0.5) {
1496 if ((RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon < 0.75) {
1499 if ((RecoLengthLeadingMuon + RecoLengthSecondMuon) / MCTruthLengthMuon > 1.25) {
1503 else if (NMuonTracks == 1) {
1505 if (CompletenessLeadingMuon < 0.5) {
1509 if (RecoLengthLeadingMuon / MCTruthLengthMuon < 0.75) {
1512 if (RecoLengthLeadingMuon / MCTruthLengthMuon > 1.25) {
1518 if (CompletenessLeadingMuon >= 0.5 && PurityLeadingMuon >= 0.5 &&
1519 RecoLengthLeadingMuon / MCTruthLengthMuon >= 0.75 &&
1520 RecoLengthLeadingMuon / MCTruthLengthMuon <= 1.25) {
1528 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1533 RecoLengthLeadingMuon / MCTruthLengthMuon, CompletenessLeadingMuon);
1540 if (NMuonTracks >= 2) {
1542 RecoLengthLeadingMuon / MCTruthLengthMuon, RecoLengthSecondMuon / MCTruthLengthMuon);
1544 double AngleBetweenTracks;
1545 double DistanceBetweenTracks;
1546 double CriteriaTwoTracks;
1549 DistanceBetweenTracks,
1553 AngleBetweenTracks);
1555 AngleBetweenTracks);
1560 if (!RecoMuonParticle && MCTruthMuonParticle) {
1565 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1568 sin((3.14159 / 180.) * MCTruthMuonThetaYZ));
1572 static_cast<double>(PDGCodeMaxLengthNoRecoMuon));
TH2D * h_MuonTrackStitching_TrackRes_Completeness
TH2D * h_NoRecoTrackAtAll_ThetaXZ_SinThetaYZ
TH2D * h_NoMuonTrack_ThetaXZ_SinThetaYZ
TH2D * h_Completeness_ThetaXZ_SinThetaYZ
int CountBadLeadingMuonTrackAndOnlyOneMuonTrackPurity
int CountBadLeadingMuonTrackButLeadingPlusSecondGood
const TLorentzVector & Position(const int i=0) const
int BadEvents4OrMoreMuonTrack
TH2D * h_TrackTooLong_ThetaXZ_SinThetaYZ
void FuncDistanceAndAngleBetweenTruthAndRecoTrack(const simb::MCParticle *&MCparticle, art::Ptr< recob::Track > Track, double &TempDistanceBetweenTruthAndRecoTrack, double &TempAngleBeetweenTruthAndRecoTrack)
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity
int GoodEvents4OrMoreMuonTrack
TH2D * h_TrackTooShort_ThetaXZ_SinThetaYZ
TH2D * h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk
int CountTrackLengthTooShort
TH2D * h_MuonTrackStitching_Distance_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle
TH2D * h_NoMuonTrack_MaxTrackLength_PDGCode
TH2D * h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond
TH2D * h_Criteria_NRecoTrack_num
TH2D * h_MuonTrackStitching_FailedCriteria_Distance_Angle
std::set< const gar::rec::Track * > TrackList
TH2D * h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness
void truthMatcher(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> AllHits, std::vector< art::Ptr< recob::Hit >> track_hits, const simb::MCParticle *&MCparticle, double &Purity, double &Completeness, double &TotalRecoEnergy)
int CountBadLeadingMuonTrackAndOnlyOneMuonTrack
TH2D * h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk
TH2D * h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond
bool insideFV(double vertex[4])
TH2D * h_FailedReconstruction_ThetaXZ_SinThetaYZ
TH2D * h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness
TH2D * h_MuonTrackStitching_TrackResLeading_TrackResSecond
double Length(size_t p=0) const
Access to various track properties.
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond
double MCTruthMuonVertex[4]
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness
Point_t const & Vertex() const
int CountBadLeadingMuonTrack
int CountGoodLeadingMuonTrack
int CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooLong
void FuncDistanceAndAngleBetweenTracks(art::Ptr< recob::Track > Track1, art::Ptr< recob::Track > Track2, double &TempDistanceBetweenTracks, double &TempAngleBetweenTracks, double &TempCriteriaTwoTracks)
TH2D * h_ThetaXZ_SinThetaYZ_den
TH2D * h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle
const sim::ParticleList & ParticleList() const
double MCTruthMuonThetaYZ
int CountBadLeadingMuonTrackAndLeadingPlusSecondBad
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong
TH2D * h_Purity_ThetaXZ_SinThetaYZ
TH2D * h_ThetaXZ_ThetaYZ_num
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle
int CountTrackLengthTooLong
TH2D * h_ThetaXZ_ThetaYZ_den
const TLorentzVector & Momentum(const int i=0) const
TH2D * h_MuonTrackStitching_CompletenessSecondMuon_Angle
double Vz(const int i=0) const
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness
TH2D * h_FailedReconstruction_ThetaXZ_ThetaYZ
double truthLength(const simb::MCParticle *MCparticle)
TH2D * h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
int CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooShort
TH2D * h_MuonTrackStitching_CriteriaTwoTracks_Angle
double MCTruthMuonThetaXZ
TH2D * h_Criteria_NMuonTrack_num
TH2D * h_MuonTrackStitching_TrackResSecondMuon_Angle
int CountBadLeadingMuonTrackAndOnlyOneMuonTrackCompleteness
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness
double MCTruthMuonMomentum
TH2D * h_ThetaXZ_SinThetaYZ_num
TH2D * h_MuonTrackStitching_MatchedCriteria_Distance_Angle
QTextStream & endl(QTextStream &s)
Event finding and building.
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle
std::string fTrackModuleLabel