12#include "TLorentzVector.h"
22#include "GaudiKernel/IInterface.h"
48 ISvcLocator* pSvcLocator):
57 m_selTool(
"InDet::InDetTrackSelectionTool/TrackSelectionTool"),
182 return StatusCode::FAILURE;
191 return StatusCode::FAILURE;
199 return StatusCode::FAILURE;
210 return StatusCode::FAILURE;
233 ATH_MSG_INFO(
" -- IDPerfMonZmumu::initialize() -- init m_beamSpotKey ");
260 m_4mu.setDebugMode(
true);
271 return StatusCode::FAILURE;
279 return StatusCode::FAILURE;
287 return StatusCode::FAILURE;
294 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::Initialize ** Completed **");
295 return StatusCode::SUCCESS;
303 m_h_cutflow =
new TH1F(
"h_cutflow",
"cut flow histogram",11, -0.5, 9.5);
425 bool isTreeNone =
false;
426 if (
m_IDTreeName.find(
"none") != std::string::npos) isTreeNone =
true;
592 if (
m_combTreeName.find(
"none") != std::string::npos) isTreeNone =
true;
648 if (
m_MSTreeName.find(
"none") != std::string::npos) isTreeNone =
true;
650 ATH_MSG_INFO(
"initialize() ** defining IDPerfMon MSTree ");
813 ATH_MSG_INFO(
"initialize() Going to register the mu+mu- trees");
815 if (tHistSvc.retrieve().isFailure()){
816 ATH_MSG_ERROR(
"initialize() Could not find Hist Service -> Switching ValidationMode Off !");
822 ATH_MSG_INFO(
"initialize() commonTree succesfully registered!");
825 ATH_MSG_ERROR(
"initialize() Could not register the validation commonTree -> Switching ValidationMode Off !");
833 ATH_MSG_INFO(
"initialize() IDTree succesfully registered!");
836 ATH_MSG_ERROR(
"initialize() Could not register the validation IDTree -> Switching ValidationMode Off !");
849 ATH_MSG_INFO(
"initialize() CBTree succesfully registered!");
852 ATH_MSG_ERROR(
"initialize() Could not register the validation CBTree -> Switching ValidationMode Off !");
866 ATH_MSG_INFO(
"initialize() MSTree succesfully registered!");
869 ATH_MSG_ERROR(
"initialize() Could not register the validation MSTree -> Switching ValidationMode Off !");
879 ATH_MSG_INFO(
"initialize() Refit1 Tree succesfully registered!");
882 ATH_MSG_ERROR(
"initialize() Could not register the validation Tree -> Switching ValidationMode Off !");
890 ATH_MSG_INFO(
"initialize() Refit2 Tree succesfully registered!");
893 ATH_MSG_ERROR(
"initialize() Could not register the validation Tree -> Switching ValidationMode Off !");
902 ATH_MSG_INFO(
"initialize() truthTree Tree succesfully registered!");
905 ATH_MSG_ERROR(
"initialize() Could not register the validation truth Tree -> Switching ValidationMode Off !");
913 ATH_MSG_INFO(
"initialize() FourMu Tree succesfully registered!");
916 ATH_MSG_ERROR(
"initialize() Could not register the validation FourMu Tree -> Switching ValidationMode Off !");
922 return StatusCode::SUCCESS;
945 m_event_mu = eventInfo->actualInteractionsPerCrossing();
946 m_beamposX = beamSpotHandleRec->beamPos().x();
947 m_beamposY = beamSpotHandleRec->beamPos().y();
949 if (eventInfo->mcEventWeights().size()>0) {
958 ATH_MSG_DEBUG(
" IDPerfMonZmumu::execute evtStore->retrieve (eventInfo) failed .. trying another strategy.. ");
964 m_event_mu = eventInfo2->actualInteractionsPerCrossing();
965 if (eventInfo->mcEventWeights().size()>0) {
974 ATH_MSG_ERROR(
"** IDPerfMonZmumu::execute ** Could not retrieve event info.");
980 ATH_MSG_DEBUG(
" ** IDPerfMonZmumu::execute ** calling FourLeptonAnalysis()...");
982 if (fourLeptAnaStatus.isSuccess())
ATH_MSG_INFO (
" ** IDPerfMonZmumu::execute ** RunFourLeptonAnalysis() SUCCESS -> found a new event");
988 ATH_MSG_DEBUG(
" ** IDPerfMonZmumu::execute ** calling dimuon analysis m_xZmm.Reco()...");
993 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV "
995 <<
" ** SUCCESS **");
1001 <<
" Failed dimuon reconstruction. m_xZmm.Reco() returned FALSE ");
1002 return StatusCode::SUCCESS;
1011 if (isTriggerPassed == StatusCode::SUCCESS) {
1015 ATH_MSG_DEBUG(
"Trigger Failed -> reject event --> leave event");
1016 return StatusCode::SUCCESS;
1028 StatusCode success_pos = StatusCode::FAILURE;
1029 StatusCode success_neg = StatusCode::FAILURE;
1031 if (muon_pos && muon_neg) {
1033 using enum xAOD::Muon::TrackParticleType;
1035 ATH_MSG_INFO(
"** IDPerfMonZmumu::execute ** Retrieving InnerDetectorTrackParticles of the accepted muons");
1036 ppos_comb = muon_pos->
trackParticle(InnerDetectorTrackParticle);
1037 pneg_comb = muon_neg->
trackParticle(InnerDetectorTrackParticle);
1039 if (!ppos_comb || !pneg_comb) {
1040 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** InnerDetectorTrackParticles are requested but they are not present. Exiting event.");
1041 return StatusCode::SUCCESS;
1046 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Retrieving CombinedTrackParticles of the accepted muons");
1050 if (!ppos_comb || !pneg_comb){
1051 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** CombinedTrackParticles are requested but they are not present. Exiting event.");
1052 return StatusCode::SUCCESS;
1058 if (ppos_comb && pneg_comb) {
1068 for (
const auto V : *vertices) {
1078 if (!ppos_comb_v || !pneg_comb_v){
1079 ATH_MSG_WARNING(
"Some or all of the requested particles have no vertex. Exiting event");
1080 return StatusCode::SUCCESS;
1084 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Could not find CombinedMuon pos/neg in event"
1088 return StatusCode::SUCCESS;
1095 if (
m_xZmm.AcceptEvent() ) {
1099 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ** some preliminaries are due though...");
1103 if ( !
m_selTool->accept(muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)) ) {
1104 ATH_MSG_DEBUG(
"Exiting because the ID segment of muon_pos do not pass the TrackSelection");
1105 return StatusCode::SUCCESS;
1107 if ( !
m_selTool->accept(muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)) ) {
1108 ATH_MSG_DEBUG(
"Exiting because the ID segment of muon_neg do not pass the TrackSelection");
1109 return StatusCode::SUCCESS;
1111 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Good news ** pos and neg muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) pass the trackSelection :)");
1114 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track selection is not in use ");
1126 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1127 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
charge(),
1130 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1131 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
charge(),
1134 if (success_pos && success_neg) {
1144 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1149 <<
" pt: " << muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
pt()
1157 <<
" pt: " << muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
pt()
1189 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** not filling IDTracks in combTree due to problems with muon_xxx->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)");
1197 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1202 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1207 if (success_pos && success_neg) {
1213 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1262 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1267 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1270 if (success_pos && success_neg) {
1275 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1303 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Going to build TrackCollections: muonTrks, muonTrksRefit1 and muonTrksRefit2");
1308 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Going to refit and store the track parameters ");
1309 std::unique_ptr<Trk::Track> defaultMuonTrk1;
1310 std::unique_ptr<Trk::Track> defaultMuonTrk2;
1316 StatusCode fitStatus;
1318 if( ppos_comb->
track() ) {
1319 defaultMuonTrk1 = std::make_unique<Trk::Track>(*ppos_comb->
track());
1322 if (fitStatus.isFailure()) {
1323 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Failed for ppos_comb->track(). Skipping Event");
1324 return StatusCode::SUCCESS;
1327 muonTrksRefit1->push_back(refit1MuonTrk1);
1328 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Success of ppos_comb->track()."
1333 if (fitStatus.isFailure()) {
1334 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Failed for ppos_comb->track(). Skipping Event");
1335 return StatusCode::SUCCESS;
1338 muonTrksRefit2->push_back(refit2MuonTrk1);
1339 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Success of ppos_comb->track()."
1345 if( pneg_comb->
track() ) {
1346 defaultMuonTrk2 = std::make_unique<Trk::Track>(*pneg_comb->
track());
1350 if (fitStatus.isFailure()) {
1351 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Failed. Skipping Event");
1352 return StatusCode::SUCCESS;
1355 muonTrksRefit1->push_back(refit1MuonTrk2);
1356 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Success of pneg_comb->track()."
1363 if (fitStatus.isFailure()) {
1365 return StatusCode::SUCCESS;
1368 muonTrksRefit2->push_back(refit2MuonTrk2);
1369 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Success of pneg_comb->track()."
1373 if (muonTrksRefit1->size() != 2)
ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** WARNING ** size of muonTrksRefit1: " << muonTrksRefit1->size());
1374 if (muonTrksRefit2->size() != 2)
ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** WARNING ** size of muonTrksRefit2: " << muonTrksRefit2->size());
1378 muonTrks->push_back(defaultMuonTrk1.release());
1379 muonTrks->push_back(defaultMuonTrk2.release());
1380 auto nMuonTracks = muonTrks->size();
1382 if (
sc.isSuccess()) {
1387 auto nMuonTracks1 = muonTrksRefit1->size();
1388 if (nMuonTracks1 > 1) {
1390 if (
sc.isSuccess()) {
1396 auto nMuonTracks2 = muonTrksRefit2->size();
1397 if (nMuonTracks2 > 1) {
1399 if (
sc.isSuccess()) {
1407 if (nMuonTracks1<2) {
1408 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Refit1 muon tracks are missing!");
1410 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** going to fill refit1tree ");
1415 if (success_pos && success_neg) {
1421 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1461 if (muonTrksRefit2->size()<2) {
1462 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Refit2 muon tracks are missing!");
1469 if (success_pos && success_neg) {
1475 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1518 if ( !
m_xZmm.AcceptEvent() ) {
1522 return StatusCode::SUCCESS;
1529 bool truthStatusIsGood =
true;
1531 truthStatusIsGood =
false;
1535 truthStatusIsGood =
false;
1538 if (truthStatusIsGood) {
1543 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1585 bool dofill =
false;
1597 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1621 for (
auto muon : *muons) {
1622 const xAOD::TrackParticle* tp = muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
1624 ATH_MSG_DEBUG(
" - tpb = "<< tp <<
" -> is null? " << (!tp));
1632 const Trk::Perigee* tPerigee = t->perigeeParameters() ;
1645 StatusCode scid =
evtStore()->record(IDTracks,
"IDTracks");
1646 if (scid.isSuccess()) {
1657 return StatusCode::SUCCESS;
1665 const EventContext& ctx)
1669 return StatusCode::FAILURE;
1673 return StatusCode::FAILURE;
1690 double sigma_pt = 0;
1692 double sigma_qOverP = 1.;
1695 px = trackp->
p4().Px();
1696 py = trackp->
p4().Py();
1697 pt = trackp->
p4().Pt();
1698 pz = trackp->
p4().Pz();
1699 phi= trackp->
p4().Phi();
1700 eta= trackp->
p4().Eta();
1703 qoverp = trackp->
qOverP();
1712 double sigma_pt_term1 = (sin(trackp->
theta()) / pow(qoverp,2)) * sigma_qOverP;
1713 double sigma_pt_term2 = (1./qoverp) * cos(trackp->
theta()) * sigma_theta;
1714 double sigma_pt_term3 = (cos(trackp->
theta()) / pow(qoverp,2)) * sigma_theta * sigma_qOverP;
1718 if (vertex ==
nullptr) {
1720 return StatusCode::FAILURE;
1723 ATH_MSG_WARNING(
"in FillRecParametersTP. WARNING: m_trackToVertexIPEstimator is NULL");
1724 return StatusCode::FAILURE;
1728 std::unique_ptr<Trk::ImpactParametersAndSigma> iPandSigma(
nullptr);
1734 ATH_MSG_DEBUG(
"return from the trackToVertexIPEstimator->estimate()");
1737 ATH_MSG_WARNING (
"FillRecParametersTP::trackToVertexIPEstimator failed !");
1738 return StatusCode::FAILURE;
1741 ATH_MSG_DEBUG(
"FillRecParametersTP::trackToVertexIPEstimator success !");
1742 PVd0 = iPandSigma->IPd0;
1743 PVd0res = iPandSigma->PVsigmad0;
1744 d0res = iPandSigma->sigmad0;
1745 PVz0 = iPandSigma->IPz0;
1746 PVz0res = iPandSigma->PVsigmaz0;
1747 z0res = iPandSigma->sigmaz0;
1771 ATH_MSG_DEBUG(
"(Filled charge == 1 ) (reco)-> px : "<< px <<
" py: "<<py <<
" pt: "<<pt <<
" pz: "<<pz
1772 <<
" d0: "<<
m_positive_d0 <<
" d0res : "<< d0res <<
" PVd0res : "<< PVd0res <<
" z0: "<<
m_positive_z0 <<
" z0res : " << z0res <<
" PVz0res : "<< PVz0res );
1774 }
else if (
charge == -1) {
1794 ATH_MSG_DEBUG(
"(Filled charge == -1 ) (reco)-> px : "<< px <<
" py: "<< py <<
" pt: " << pt <<
" pz: "<<pz
1795 <<
" d0: "<<
m_negative_d0 <<
" d0res : "<< d0res <<
" PVd0res : "<< PVd0res <<
" z0: "<<
m_negative_z0 <<
" z0res : " << z0res <<
" PVz0res : "<< PVz0res );
1798 return StatusCode::SUCCESS;
1806 ATH_MSG_DEBUG(
"* FillRecParameters * Empty Track: track. Skipping.");
1807 return StatusCode::FAILURE;
1811 ATH_MSG_DEBUG(
"* FillRecParameters * Empty Track: trackp_for_unbias. Skipping.");
1812 return StatusCode::FAILURE;
1815 const Trk::Perigee* trkPerigee = track->perigeeParameters();
1828 double d0_err = 999.;
1829 double z0_err = 999.;
1837 if (trkPerigee !=
nullptr){
1838 double qOverP = trkPerigee->parameters()[
Trk::qOverP];
1842 pt = std::abs(trkPerigee->
pT());
1846 d0 = trkPerigee->parameters()[
Trk::d0];
1847 z0 = trkPerigee->parameters()[
Trk::z0];
1865 pt = std::abs(atBL->
pT());
1869 d0 = atBL->parameters()[
Trk::d0];
1870 z0 = atBL->parameters()[
Trk::z0];
1875 ATH_MSG_WARNING(
"FillRecParameters::Failed extrapolation to the BeamLine");
1880 TLorentzVector vtrack = TLorentzVector (trkPerigee->
momentum().x(),
1886 std::unique_ptr<Trk::ImpactParametersAndSigma> iPandSigma(
nullptr);
1889 if( iPandSigma==0 ){
1890 ATH_MSG_WARNING (
"FillRecParameters::trackToVertexIPEstimator failed !");
1891 return StatusCode::FAILURE;
1894 ATH_MSG_DEBUG(
"FillRecParameters::trackToVertexIPEstimator success !");
1895 PVd0 = iPandSigma->IPd0;
1896 PVd0res = iPandSigma->PVsigmad0;
1898 PVz0 = iPandSigma->IPz0;
1899 PVz0res = iPandSigma->PVsigmaz0;
1903 ATH_MSG_INFO(
" FillRecParameters::trackToVertexIPEstimator vertex does exist ");
1930 ATH_MSG_DEBUG(
"(Filled charge == 1 ) (reco)-> px : "<< px <<
" py: "<<py <<
" pz: "<<pz <<
" d0: "<<d0<<
" z0: "<< z0);
1949 ATH_MSG_DEBUG(
"(Filled charge == -1 ) (reco)-> px : "<< px <<
" py: "<<py <<
" pz: "<<pz <<
" d0: "<<d0<<
" z0: "<<z0 );
1952 return StatusCode::SUCCESS;
1958 ATH_MSG_DEBUG(
"* FillRecParametersSimple * Empty Track: track. Skipping.");
1959 return StatusCode::FAILURE;
1962 const Trk::Perigee* trkPerigee = track->perigeeParameters();
1963 if (not trkPerigee) {
1964 ATH_MSG_ERROR(
"trkPerigee pointer is null in IDPerfMonZmumu::FillRecParametersSimple");
1965 return StatusCode::FAILURE;
1976 double d0_err = 999.;
1977 double z0_err = 999.;
1980 double qOverP = trkPerigee->parameters()[
Trk::qOverP];
1984 pt = std::abs(trkPerigee->
pT());
1988 d0 = trkPerigee->parameters()[
Trk::d0];
1989 z0 = trkPerigee->parameters()[
Trk::z0];
1996 Amg::Vector3D position (eventInfo->beamPosX(), eventInfo->beamPosY(), eventInfo->beamPosZ());
1997 TLorentzVector vtrack = TLorentzVector (trkPerigee->
momentum().x(),
2016 pt = std::abs(atBL->
pT());
2020 d0 = atBL->parameters()[
Trk::d0];
2021 z0 = atBL->parameters()[
Trk::z0] - vertex->z();
2025 <<
" ** trackToVertexTool->trackAtBeamline ** "
2026 <<
"( " << beamSpotHandleRec->beamPos().x()
2027 <<
", " << beamSpotHandleRec->beamPos().y()
2028 <<
", " << beamSpotHandleRec->beamPos().z()
2034 ATH_MSG_WARNING(
"FillRecParametersSimple::Failed extrapolation to the BeamLine --> extrapolate using line approximation");
2035 float trkd0 = trkPerigee->parameters()[
Trk::d0];
2036 float trkz0 = trkPerigee->parameters()[
Trk::z0];
2037 float bsX = beamSpotHandleRec->beamPos().x();
2038 float bsY = beamSpotHandleRec->beamPos().y();
2039 float bsZ = beamSpotHandleRec->beamPos().z();
2040 float btiltX = beamSpotHandleRec->beamTilt(0);
2041 float btiltY = beamSpotHandleRec->beamTilt(1);
2043 float beamX = bsX + std::tan(btiltX) * (trkz0-bsZ);
2044 float beamY = bsY + std::tan(btiltY) * (trkz0-bsZ);
2045 float beamD0 = ( -std::sin(vtrack.Phi())*beamX + std::cos(vtrack.Phi())*beamY );
2048 d0 = trkd0 - beamD0;
2049 z0 = trkz0 - bsZ - vertex->z();
2054 <<
"( " << beamSpotHandleRec->beamPos().x()
2055 <<
", " << beamSpotHandleRec->beamPos().y()
2056 <<
", " << beamSpotHandleRec->beamPos().z()
2088 ATH_MSG_DEBUG(
"* FillRecParametersSimple * completed * charge " <<
charge <<
" pt: " << pt <<
" d0: " << d0 <<
" z0: " << z0);
2089 return StatusCode::SUCCESS;
2096 if (!trackParticle ){
2097 ATH_MSG_WARNING(
"-- FillTruthParameters -- Empty Trackparticle. Skipping.");
2098 return StatusCode::FAILURE;
2104 ATH_MSG_DEBUG(
" -- FillTruthParameters -- Failure while retrieving the truth particle. Returning FAILURE.");
2105 return StatusCode::FAILURE;
2108 if ( particle->pdgId() == 13)
charge = -1.;
2109 if ( particle->pdgId() == -13)
charge = 1.;
2110 if ( particle->isNeutral() ) {
2111 ATH_MSG_DEBUG(
" -- FillTruthParameters -- reco muon associated to a truth neutral!! Returning FAILURE.");
2112 return StatusCode::FAILURE;
2115 ATH_MSG_DEBUG(
" -- FillTruthParameters -- reco muon associated to a non true muon!! Returning FAILURE.");
2116 return StatusCode::FAILURE;
2119 const Amg::Vector3D momentum(particle->px(), particle->py(), particle->pz());
2121 ptruthVertex=particle->prodVtx();
2123 ATH_MSG_DEBUG(
"A production vertex pointer was retrieved, but it is NULL");
2124 return StatusCode::FAILURE;
2128 if (particle->parent(0) !=
nullptr) {
2132 ATH_MSG_DEBUG(
" -- FillTruthParameters -- truth particle is good. pdg: " << particle->pdgId()
2133 <<
" type: " << particle->type()
2134 <<
" nparents " << particle->nParents()
2135 <<
" parent->pdg: " << particle->parent(0)->pdgId()
2136 <<
" truthType: " << truthTypeAcc(*particle)
2137 <<
" truthOrigin: " << truthOriginAcc(*particle)
2142 ATH_MSG_DEBUG(
" -- FillTruthParameters -- truth particle is good. pdg: " << particle->pdgId()
2143 <<
" type: " << particle->type()
2144 <<
" nparents " << particle->nParents()
2145 <<
" parent->pdg: " << particle->parent(0)->pdgId()
2146 <<
" truthType & truthOrigin: " <<
" NOT AVAILABLE "
2151 const auto xPos=ptruthVertex->
x();
2152 const auto yPos=ptruthVertex->
y();
2153 const auto z_truth=ptruthVertex->
z();
2181 ATH_MSG_DEBUG(
"reco IPs (pos): > d0 : "<<d0recoPos <<
" z0: " << z0recoPos <<
" trackp z0 : " << trackParticle->
z0() <<
" trackp d0 : " << trackParticle->
d0());
2182 ATH_MSG_DEBUG(
"reco IPs (neg): > d0 : "<<d0recoNeg <<
" z0: " << z0recoNeg <<
" trackp z0 : " << trackParticle->
z0() <<
" trackp d0 : " << trackParticle->
d0() );
2184 double qOverP_truth = 0.;
2189 px = tP->momentum().x();
2190 py = tP->momentum().y();
2192 pz = tP->momentum().z();
2195 d0 = tP->parameters()[
Trk::d0];
2196 z0 = tP->parameters()[
Trk::z0];
2198 ATH_MSG_DEBUG(
"cand perig HEP particle (truth) px : "<< tP->momentum().x());
2199 ATH_MSG_DEBUG(
"cand perig HEP particle (truth) py : "<< tP->momentum().y());
2200 ATH_MSG_DEBUG(
"cand perig HEP particle (truth) pz : "<< tP->momentum().z());
2223 bool parentfound =
false;
2224 if (particle->nParents()>0) {
2225 if (particle->parent(0) !=
nullptr) {
2240 }
else if (
charge == -1) {
2255 bool parentfound =
false;
2256 if (particle->nParents()>0) {
2257 if (particle->parent(0) !=
nullptr) {
2272 return StatusCode::SUCCESS;
2283 if( ! acc.isAvailable( p ) ) {
2287 const Link_t& link = acc( p );
2289 if( ! link.isValid() ) {
2300 return StatusCode::SUCCESS;
2311 return StatusCode::FAILURE;
2317 float thisEventTriggerPrescale = 999999.9;
2318 float thisHLTTriggerPrescale = 999999.9;
2319 bool thisHLTIsPassed =
false;
2320 std::string thisHLTTriggerName;
2321 std::string thisEventTriggerName;
2324 const std::vector<std::string> myHLTtriglist =
m_triggerDecision->getChainGroup(
"HLT_mu.*, HLT_2mu.*")->getListOfTriggers();
2325 for (
int i=0; i < (int) myHLTtriglist.size(); i++) {
2327 ATH_MSG_DEBUG(
"HLT trigger = " << i <<
" out of " << myHLTtriglist.size() <<
" --> " << myHLTtriglist.at(i) <<
" isPassed? " <<
m_triggerDecision->isPassed(myHLTtriglist.at(i)) <<
" prescale: " <<
m_triggerDecision->getChainGroup(myHLTtriglist.at(i))->getPrescale() );
2330 thisHLTIsPassed =
true;
2331 float thisprescale =
m_triggerDecision->getChainGroup(myHLTtriglist.at(i))->getPrescale();
2332 if (thisprescale < thisHLTTriggerPrescale) {
2333 thisHLTTriggerPrescale = thisprescale;
2334 thisHLTTriggerName = myHLTtriglist.at(i);
2338 if (thisHLTTriggerPrescale < 1) thisHLTTriggerPrescale = 1;
2339 ATH_MSG_DEBUG(
"Event HLT trigger prescale = " << thisHLTTriggerPrescale);
2342 if (thisHLTIsPassed) {
2347 return StatusCode::FAILURE;
2351 thisEventTriggerPrescale = std::move(thisHLTTriggerPrescale);
2352 thisEventTriggerName = thisHLTTriggerName;
2353 ATH_MSG_DEBUG(
"CheckTriggerStatusAndPrescale -- Event trigger prescale = " << thisEventTriggerPrescale);
2354 ATH_MSG_DEBUG(
"CheckTriggerStatusAndPrescale -- Event trigger name = " << thisEventTriggerName);
2360 return StatusCode::SUCCESS;
2374 for (
int ivtx=0; ivtx< (int) vxContainer->
size();ivtx++) {
2375 myVtx = (*vxContainer)[ivtx];
2543 StatusCode thisStatus = StatusCode::SUCCESS;
2564 if( electronTruth) {
2565 ATH_MSG_DEBUG (
"retrieving electron Truth container with key: \"egammaTruthParticles\" SUCCESS ");
2567 if( electronTruth->hasStore() ) {
2569 auto tr_itr = electronTruth->
begin();
2570 auto tr_end = electronTruth->
end();
2571 int electronCount = 0;
2572 for(
int i = 0; tr_itr != tr_end; ++tr_itr, ++i ) {
2573 ATH_MSG_DEBUG(
"Truth : Investigating truth electron #" << i <<
" pdgID= " << ( *tr_itr )->pdgId());
2574 if (fabs(( *tr_itr )->pdgId()) == 11) {
2575 if (( *tr_itr )->pt() > 10000 && fabs(( *tr_itr )->eta()) < 2.47) {
2576 ATH_MSG_INFO(
" central electron found --> pt: " << ( *tr_itr )->charge()*( *tr_itr )->pt() <<
" eta " <<( *tr_itr )->eta() );
2581 ATH_MSG_INFO(
"#central electrons: " << electronCount );
2584 ATH_MSG_WARNING (
"electronTruth container has no Store !!! FAILURE");
2588 ATH_MSG_WARNING (
"retrieve electron Truth container with key: \"egammaTruthParticles\" FAILURE");
2592 if (
m_doDebug) std::cout <<
" ** RunFourLeptonAnalysis ** calling m_4mu.Reco() .... " << std::endl;
2593 bool statusOf4LeptReco =
m_4mu.Reco();
2596 if(statusOf4LeptReco) {
2597 thisStatus = StatusCode::SUCCESS;
2598 ATH_MSG_INFO (
"4-lepton reconstruction SUCCESS. # accepted events " <<
m_4mu.getAcceptedEvents() <<
" Invariant mass = " <<
m_4mu.GetInvMass() <<
" GeV ");
2599 if (
m_doDebug) std::cout <<
" ** RunFourLeptonAnalysis ** 4-lepton reconstruction SUCCESS. # accepted events " <<
m_4mu.getAcceptedEvents() <<
" Invariant mass = " <<
m_4mu.GetInvMass() <<
" GeV " << std::endl;
2602 thisStatus = StatusCode::FAILURE;
2603 ATH_MSG_DEBUG (
"4-lepton reconstruction FAILURE. m_4mu.Reco() returned FALSE --> event failed selection");
2604 if (
m_doDebug) std::cout <<
" ** RunFourLeptonAnalysis ** 4-lepton reconstruction FAILURE. m_4mu.Reco() returned FALSE --> event failed selection" << std::endl;
2607 if(statusOf4LeptReco) {
2608 if (
m_4mu.EventPassed() ) {
2715 std::string metName =
"MET_Reference_AntiKt4LCTopo";
2716 std::string metRefFinalName =
"FinalClus";
2723 ATH_MSG_WARNING (
"No Collection with name " << metName <<
" found in StoreGate");
2727 StatusCode
sc =
evtStore()->retrieve(final_met, metName);
2728 if (
sc.isFailure()) {
2729 ATH_MSG_DEBUG (
"Could not retrieve Collection " << metName <<
" from StoreGate");
2734 if (final_met)
met = (*final_met)[metRefFinalName];
2741 ATH_MSG_INFO (
" -- IDPerfMonZmumu::execute -- Accepted event " <<
m_4mu.getAcceptedEvents() <<
" with m_4mu.GetInvMass= " <<
m_4mu_minv);
2746 <<
" Invariant mass = " <<
m_4mu_minv <<
" GeV ");
2747 if (muon1_pos !=
nullptr)
ATH_MSG_DEBUG(
"mu1+ --> pxyz " << muon1_pos->
p4().Px()
2748 <<
", " << muon1_pos->
p4().Py()
2749 <<
", " << muon1_pos->
p4().Pz()
2750 <<
" pt: " << muon1_pos->
pt()
2751 <<
" d0: " << muon1_pos->
d0()
2752 <<
" z0: " << muon1_pos->
z0()
2755 if (muon1_neg !=
nullptr)
ATH_MSG_DEBUG(
"mu1- --> pxyz " << muon1_neg->
p4().Px()
2756 <<
", " << muon1_neg->
p4().Py()
2757 <<
", " << muon1_neg->
p4().Pz()
2758 <<
" pt: " << muon1_neg->
pt()
2759 <<
" d0: " << muon1_neg->
d0()
2760 <<
" z0: " << muon1_neg->
z0()
2763 if (elec1_pos !=
nullptr)
ATH_MSG_DEBUG(
"el1+ --> pxyz " << elec1_pos->
p4().Px()
2764 <<
", " << elec1_pos->
p4().Py()
2765 <<
", " << elec1_pos->
p4().Pz()
2766 <<
" pt: " << elec1_pos->
pt()
2767 <<
" d0: " << elec1_pos->
d0()
2768 <<
" z0: " << elec1_pos->
z0()
2789 int nBLhits, nhitsPIX, nhitsSCT, nhitsTRT, nContribPixLayers;
2790 int nPIXholes, nSCTholes;
2791 if (IDTrkMuPos && IDTrkMuNeg) {
2809 <<
" nBLhits: " << nBLhits
2810 <<
" nhitsPIX: " << nhitsPIX
2811 <<
" nPIXLayers: " << nContribPixLayers
2812 <<
" nhitsSCT: " << nhitsSCT
2813 <<
" Silicon holes: " << nPIXholes + nSCTholes
2814 <<
" nhitsTRT: " << nhitsTRT);
2830 <<
" nBLhits: " << nBLhits
2831 <<
" nhitsPIX: " << nhitsPIX
2832 <<
" nPIXLayers: " << nContribPixLayers
2833 <<
" nhitsSCT: " << nhitsSCT
2834 <<
" Silicon holes: " << nPIXholes + nSCTholes
2835 <<
" nhitsTRT: " << nhitsTRT);
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Helper class to provide constant type-safe access to aux data.
ElementLink< xAOD::TruthParticleContainer > Link_t
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
double m_el_negative1_z0_err
ToolHandle< Trig::TrigDecisionTool > m_triggerDecision
std::vector< float > m_Refit1_qoverp
StatusCode CheckTriggerStatusAndPrescale()
virtual StatusCode finalize()
StatusCode RunFourLeptonAnalysis()
bool m_useCustomMuonSelector
std::vector< float > m_Refit1_sigma_qoverp
double m_el_positive1_d0_err
double m_el_positive2_z0_err
double m_positive_d0_PVerr
std::string m_truthTreeFolder
double m_negative_2_z0_err
double m_positive_sigma_qoverp
double m_negative_sigma_qoverp
const xAOD::Vertex * GetDiMuonVertex(const xAOD::TrackParticle *, const xAOD::TrackParticle *)
double m_positive_2_d0_err
void ResetCommonNtupleVectors()
std::vector< float > m_Refit2_sigma_d0
std::vector< float > m_CBTrack_sigma_z0
TH1F * m_h_cutflow
link vector to map HepMC onto xAOD truth
ToolHandle< Reco::ITrackToVertex > m_trackToVertexTool
tool to extrapolate tracks to BL
std::vector< float > m_Refit1_sigma_d0
std::vector< float > m_CBTrack_d0
std::string m_refit1TreeFolder
std::string m_ValidationTreeDescription
< validation tree description - second argument in TTree
std::vector< float > m_Refit2_qoverp
std::string m_outputTracksName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainerName
IDTtacks.
std::vector< float > m_Refit1_eta
ToolHandle< Trig::IMatchingTool > m_triggerMatching
std::vector< float > m_CBTrack_sigma_d0
unsigned int m_lumi_block
std::vector< float > m_IDTrack_d0
std::string m_MSTreeFolder
std::string m_trackParticleName
Track(Particle)TruthCollection input name.
std::string m_combTreeFolder
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter1
The track refitter.
StatusCode FillRecParametersSimple(const Trk::Track *track, float charge, const xAOD::Vertex *vertex, const EventContext &ctx)
double m_negative_2_d0_err
double m_positive_z0_PVerr
std::vector< float > m_Truth_phi
StatusCode FillRecParametersTP(const xAOD::TrackParticle *trackp, const xAOD::TrackParticle *trackp_for_unbias, double charge, const xAOD::Vertex *vertex, const EventContext &ctx)
std::vector< float > m_Truth_pt
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator
Needed for IP resolution studies.
std::vector< float > m_Refit2_d0
std::string m_MuonQualityName
double m_el_positive1_z0_err
ToolHandle< Trk::IExtrapolator > m_extrapolator
bool m_validationMode
< boolean to switch to validation mode
std::vector< float > m_Refit1_phi
std::vector< float > m_Refit2_eta
bool m_useTrackSelectionTool
std::string m_FourMuTreeFolder
Root Validation Tree.
std::vector< float > m_IDTrack_pt
std::vector< float > m_CBTrack_sigma_pt
std::vector< float > m_Truth_z0
double m_negative_z0_PVerr
ToolHandle< IegammaTrkRefitterTool > m_TrackRefitter2
The track refitter.
std::vector< float > m_IDTrack_sigma_d0
std::vector< float > m_Refit2_pt
double m_positive_sigma_pt
std::string m_truthTreeName
StatusCode FillTruthParameters(const xAOD::TrackParticle *track, const EventContext &ctx)
std::string m_refit1TreeName
double m_el_negative2_z0_err
std::vector< float > m_CBTrack_z0
std::string m_FourMuTreeName
std::vector< float > m_CBTrack_pt
std::vector< float > m_Refit1_sigma_pt
std::string m_triggerName
std::string m_refit2TreeName
virtual StatusCode initialize()
std::vector< float > m_Refit1_d0
std::vector< float > m_Truth_eta
ToolHandle< CP::ITrackVertexAssociationTool > m_Trk2VtxAssociationTool
std::string m_defaultTreeName
double m_negative_d0_PVerr
double m_positive_2_z0_err
std::vector< float > m_CBTrack_sigma_qoverp
std::vector< int > m_nSCThits
std::vector< int > m_nTRThits
std::vector< float > m_IDTrack_qoverp
std::vector< float > m_Refit2_z0
std::string m_truthLinkVecName
TrackParticle input name.
std::vector< float > m_Truth_d0
std::vector< int > m_nBLhits
std::vector< float > m_Refit1_pt
double m_LeadingMuonPtCut
std::string m_defaultTreeFolder
std::string m_IDTreeFolder
double m_el_positive2_d0_err
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
used for truth parameters
std::vector< float > m_IDTrack_phi
virtual StatusCode execute(const EventContext &ctx)
Execute method.
std::vector< float > m_Refit2_sigma_pt
std::string m_sTriggerChainName
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
std::string m_commonTreeFolder
std::vector< float > m_IDTrack_sigma_z0
double m_negative_sigma_pt
std::string m_combTreeName
void ExtractIDHitsInformation(const xAOD::Muon *muon_pos, const xAOD::Muon *muon_neg)
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
ToolHandle< CP::IMuonSelectionTool > m_muonSelector
used to pass a custom muon selector
std::vector< float > m_Refit2_sigma_qoverp
std::string m_commonTreeName
std::vector< float > m_Refit1_z0
std::vector< float > m_Truth_qoverp
std::vector< float > m_IDTrack_z0
StatusCode FillRecParameters(const Trk::Track *track, const xAOD::TrackParticle *trackp_for_unbias, double charge, const xAOD::Vertex *vertex, const EventContext &ctx)
std::vector< float > m_Refit2_phi
double m_el_negative2_d0_err
std::vector< int > m_nPIXhits
std::vector< float > m_IDTrack_sigma_pt
std::vector< float > m_CBTrack_eta
void RegisterHistograms()
std::string m_refit2TreeFolder
std::vector< int > m_Truth_parent
std::vector< float > m_IDTrack_sigma_qoverp
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
ToolHandle< InDet::IInDetTrackSelectionTool > m_selTool
The track selection Tool.
std::vector< float > m_Refit1_sigma_z0
std::vector< float > m_CBTrack_qoverp
double m_el_negative1_d0_err
std::vector< float > m_Refit2_sigma_z0
std::vector< float > m_IDTrack_eta
std::vector< float > m_CBTrack_phi
void Clear4MuNtupleVariables()
IDPerfMonZmumu(const std::string &name, ISvcLocator *pSvcLocator)
needed for IP resolution studies
static const T * getContainer(CONTAINERS eContainer)
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & momentum() const
Access method for the momentum.
double pT() const
Access method for transverse momentum.
Class describing the Line to which the Perigee refers to.
const Perigee * perigeeParameters() const
return Perigee.
Class providing the definition of the 4-vector interface.
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be a nullptr) to the TrackParticle used in identification of this muon.
float z0() const
Returns the parameter.
float theta() const
Returns the parameter, which has range 0 to .
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
const ParametersCovMatrix_t definingParametersCovMatrix() const
Returns the 5x5 symmetric matrix containing the defining parameters covariance matrix.
float d0() const
Returns the parameter.
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
float qOverP() const
Returns the parameter.
std::vector< float > definingParametersCovMatrixVec() const
Returns the length 6 vector containing the elements of defining parameters covariance matrix.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float charge() const
Returns the charge.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
VxType::VertexType vertexType() const
The type of the vertex.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Matrix< double, 3, 1 > Vector3D
@ OWN_ELEMENTS
this data object owns its elements
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< TrackParametersDim, Charged, StraightLineSurface > AtaStraightLine
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
MissingET_v1 MissingET
Version control by type defintion.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
MissingETContainer_v1 MissingETContainer
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfContribPixelLayers
number of contributing layers of the pixel detector [unit8_t].
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfBLayerHits
these are the hits in the first pixel layer, i.e.
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.