943{
945
946 SG::ReadHandle<xAOD::EventInfo> eventInfo (
m_EventInfoKey, getContext());
947 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandleRec {
m_beamSpotKey, getContext() };
948
949 if(eventInfo.isValid()) {
953 m_event_mu = eventInfo->actualInteractionsPerCrossing();
954 m_beamposX = beamSpotHandleRec->beamPos().x();
955 m_beamposY = beamSpotHandleRec->beamPos().y();
956
957 if (eventInfo->mcEventWeights().size()>0) {
959 }
960 else {
962 }
964 }
965 else {
966 ATH_MSG_DEBUG(
" IDPerfMonZmumu::execute evtStore->retrieve (eventInfo) failed .. trying another strategy.. ");
968 if (eventInfo2.isValid()) {
972 m_event_mu = eventInfo2->actualInteractionsPerCrossing();
973 if (eventInfo->mcEventWeights().size()>0) {
975 }
976 else {
978 }
980 }
981 else{
982 ATH_MSG_ERROR(
"** IDPerfMonZmumu::execute ** Could not retrieve event info.");
983 }
984 }
985
988 ATH_MSG_DEBUG(
" ** IDPerfMonZmumu::execute ** calling FourLeptonAnalysis()...");
990 if (fourLeptAnaStatus.isSuccess())
ATH_MSG_INFO (
" ** IDPerfMonZmumu::execute ** RunFourLeptonAnalysis() SUCCESS -> found a new event");
991 }
993
994
995
996 ATH_MSG_DEBUG(
" ** IDPerfMonZmumu::execute ** calling dimuon analysis m_xZmm.Reco()...");
1001 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV "
1003 << " ** SUCCESS **");
1004 }
1005 else {
1009 << " Failed dimuon reconstruction. m_xZmm.Reco() returned FALSE ");
1010 return StatusCode::SUCCESS;
1011 }
1012
1013
1014
1015
1016
1019 if (isTriggerPassed == StatusCode::SUCCESS) {
1021 }
1022 else{
1023 ATH_MSG_DEBUG(
"Trigger Failed -> reject event --> leave event");
1024 return StatusCode::SUCCESS;
1025 }
1026 }
1027
1028
1031
1034
1035
1036 StatusCode success_pos = StatusCode::FAILURE;
1037 StatusCode success_neg = StatusCode::FAILURE;
1038
1039 if (muon_pos && muon_neg) {
1041 using enum xAOD::Muon::TrackParticleType;
1043 ATH_MSG_INFO(
"** IDPerfMonZmumu::execute ** Retrieving InnerDetectorTrackParticles of the accepted muons");
1044 ppos_comb = muon_pos->
trackParticle(InnerDetectorTrackParticle);
1045 pneg_comb = muon_neg->
trackParticle(InnerDetectorTrackParticle);
1046
1047 if (!ppos_comb || !pneg_comb) {
1048 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** InnerDetectorTrackParticles are requested but they are not present. Exiting event.");
1049 return StatusCode::SUCCESS;
1050 }
1051 }
1053
1054 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Retrieving CombinedTrackParticles of the accepted muons");
1057
1058 if (!ppos_comb || !pneg_comb){
1059 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** CombinedTrackParticles are requested but they are not present. Exiting event.");
1060 return StatusCode::SUCCESS;
1061 }
1062 }
1063
1064
1065
1066 if (ppos_comb && pneg_comb) {
1068 }
1069 else {
1071 }
1072
1073
1074
1075 const EventContext& ctx = Gaudi::Hive::currentContext();
1076 SG::ReadHandle<xAOD::VertexContainer> vertices {
m_vertexKey, ctx };
1077 for (const auto V : *vertices) {
1079
1080 ppos_comb_v = V;
1081 pneg_comb_v = V;
1082 break;
1083 }
1084 }
1085
1086
1087 if (!ppos_comb_v || !pneg_comb_v){
1088 ATH_MSG_WARNING(
"Some or all of the requested particles have no vertex. Exiting event");
1089 return StatusCode::SUCCESS;
1090 }
1091 }
1092 else {
1093 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Could not find CombinedMuon pos/neg in event"
1097 return StatusCode::SUCCESS;
1098 }
1099
1100
1101
1102
1103
1104 if (
m_xZmm.AcceptEvent() ) {
1108 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ** some preliminaries are due though...");
1109
1111
1112 if ( !
m_selTool->accept(muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)) ) {
1113 ATH_MSG_DEBUG(
"Exiting because the ID segment of muon_pos do not pass the TrackSelection");
1114 return StatusCode::SUCCESS;
1115 }
1116 if ( !
m_selTool->accept(muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)) ) {
1117 ATH_MSG_DEBUG(
"Exiting because the ID segment of muon_neg do not pass the TrackSelection");
1118 return StatusCode::SUCCESS;
1119 }
1120 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Good news ** pos and neg muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle) pass the trackSelection :)");
1121 }
1122 else {
1123 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track selection is not in use ");
1124 }
1125
1127
1129
1131
1132
1135 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1136 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
charge(),
1137 ppos_comb_v);
1139 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1140 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
charge(),
1141 pneg_comb_v);
1142
1143 if (success_pos && success_neg) {
1144
1146
1147
1153 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1154 }
1158 <<
" pt: " << muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
pt()
1166 <<
" pt: " << muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)->
pt()
1171
1173
1174
1187
1196 }
1197 else {
1198 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** not filling IDTracks in combTree due to problems with muon_xxx->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle)");
1199 }
1200
1201
1202
1203
1206 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1208 ppos_comb_v);
1211 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1213 pneg_comb_v);
1215
1216 if (success_pos && success_neg) {
1222 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1223 }
1238
1240 }
1241
1254
1263 }
1264
1265
1266
1267
1271 muon_pos->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1273 ppos_comb_v);
1274
1276 muon_neg->
trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle),
1278 pneg_comb_v);
1279 if (success_pos && success_neg) {
1284 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1297
1299 }
1300 else {
1305 }
1306
1307 }
1308 }
1309
1310
1312 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Going to build TrackCollections: muonTrks, muonTrksRefit1 and muonTrksRefit2");
1316
1317 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Going to refit and store the track parameters ");
1318 Trk::Track* defaultMuonTrk1{};
1319 Trk::Track* defaultMuonTrk2{};
1320 Trk::Track* refit1MuonTrk1{};
1321 Trk::Track* refit2MuonTrk1{};
1322 Trk::Track* refit1MuonTrk2{};
1323 Trk::Track* refit2MuonTrk2{};
1324
1326
1327 const EventContext& ctx = Gaudi::Hive::currentContext();
1328 if( ppos_comb->
track() ) {
1329 defaultMuonTrk1 =
new Trk::Track(*ppos_comb->
track());
1330
1331 IegammaTrkRefitterTool::Cache fitResult{};
1333 if (fitStatus.isFailure()) {
1334 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Failed for ppos_comb->track(). Skipping Event");
1335 return StatusCode::SUCCESS;
1336 } else {
1338 muonTrksRefit1->
push_back(refit1MuonTrk1);
1339 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Success of ppos_comb->track()."
1342 }
1343
1344
1346 if (fitStatus.isFailure()) {
1347 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Failed for ppos_comb->track(). Skipping Event");
1348 return StatusCode::SUCCESS;
1349 } else {
1351 muonTrksRefit2->
push_back(refit2MuonTrk1);
1352 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Success of ppos_comb->track()."
1355 }
1356 }
1357
1358 if( pneg_comb->
track() ) {
1359 defaultMuonTrk2 =
new Trk::Track(*pneg_comb->
track());
1360
1361 IegammaTrkRefitterTool::Cache fitResult {};
1363 if (fitStatus.isFailure()) {
1364 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Failed. Skipping Event");
1365 return StatusCode::SUCCESS;
1366 } else {
1368 muonTrksRefit1->
push_back(refit1MuonTrk2);
1369 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit1 Success of pneg_comb->track()."
1372 }
1373
1374
1376 if (fitStatus.isFailure()) {
1378 return StatusCode::SUCCESS;
1379 } else {
1381 muonTrksRefit2->
push_back(refit2MuonTrk2);
1382 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** Track Refit2 Success of pneg_comb->track()."
1385 }
1386
1387 if (muonTrksRefit1->
size() != 2)
ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** WARNING ** size of muonTrksRefit1: " << muonTrksRefit1->
size());
1388 if (muonTrksRefit2->
size() != 2)
ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** WARNING ** size of muonTrksRefit2: " << muonTrksRefit2->
size());
1389 }
1390
1391
1394
1396 if (
sc.isSuccess()) {
1398 }
1399 else{
1401 }
1402
1403 if (muonTrksRefit1->
size() > 1) {
1405 if (
sc.isSuccess()) {
1407 } else {
1409 }
1410 }
1411
1412 if (muonTrksRefit2->
size() > 1) {
1414 if (
sc.isSuccess()) {
1416 } else {
1418 }
1419 }
1420
1421
1422
1423 if (muonTrksRefit1->
size()<2) {
1424 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Refit1 muon tracks are missing!");
1425 }
1426 else {
1427 ATH_MSG_DEBUG(
"** IDPerfMonZmumu::execute ** going to fill refit1tree ");
1430
1432 if (success_pos && success_neg) {
1438 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1439 }
1454 }
1455
1466
1473 }
1474 }
1475 }
1476
1477
1478 if (muonTrksRefit2->
size()<2) {
1479 ATH_MSG_WARNING(
"** IDPerfMonZmumu::execute ** Refit2 muon tracks are missing!");
1480 }
1481 else{
1485
1487 if (success_pos && success_neg) {
1493 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1494 }
1509 }
1510
1521
1528 }
1529 }
1530 }
1531
1533 }
1534 }
1535
1536 if ( !
m_xZmm.AcceptEvent() ) {
1537
1538
1540 return StatusCode::SUCCESS;
1541 }
1542
1543
1544
1545
1547 bool truthStatusIsGood = true;
1549 truthStatusIsGood = false;
1551 }
1553 truthStatusIsGood = false;
1555 }
1556 if (truthStatusIsGood) {
1561 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1574
1590
1591 }
1592 else {
1597 }
1598 }
1599
1600
1602
1603 bool dofill = false;
1609
1610 if (dofill) {
1615 <<
" Invariant mass = " <<
m_xZmm.GetInvMass() <<
" GeV ");
1617 }
1618 else {
1623 }
1624 }
1625
1627
1628
1629
1630
1631
1633 int nTracks = 0;
1635
1636
1638 if(muons){
1639 for (auto muon : *muons) {
1640 const xAOD::TrackParticle* tp =
muon->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
1641 if(!tp) {
1642 ATH_MSG_DEBUG(
" - tpb = "<< tp <<
" -> is null? " << (!tp));
1643 continue;
1644 }
1645 const Trk::Track*
t = tp->
track();
1646 if ( !t ) {
1648 continue;
1649 }
1651 if ( !tPerigee ) {
1653 continue;
1654 }
1655 IDTracks->
push_back (
new Trk::Track (*t));
1656 nTracks++;
1657 }
1658 }
1660
1662
1664 if (scid.isSuccess()) {
1666 }
1667 else{
1669 }
1670
1671
1672
1673
1674
1675 return StatusCode::SUCCESS;
1676}
#define ATH_MSG_WARNING(x)
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
ServiceHandle< StoreGateSvc > & evtStore()
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
StatusCode CheckTriggerStatusAndPrescale()
StatusCode FillTruthParameters(const xAOD::TrackParticle *track)
StatusCode RunFourLeptonAnalysis()
double m_positive_sigma_qoverp
double m_negative_sigma_qoverp
void ResetCommonNtupleVectors()
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
used for truth parameters
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexKey
StatusCode FillRecParametersSimple(const Trk::Track *track, float charge, const xAOD::Vertex *vertex)
void ExtractIDHitsInformation(const xAOD::Muon *muon_pos, const xAOD::Muon *muon_neg)
StatusCode FillRecParametersTP(const xAOD::TrackParticle *trackp, const xAOD::TrackParticle *trackp_for_unbias, double charge, const xAOD::Vertex *vertex=nullptr)
SG::ReadHandleKey< xAOD::EventInfo > m_EventInfoKey
static const T * getContainer(CONTAINERS eContainer)
double pT() const
Access method for transverse momentum.
const Perigee * perigeeParameters() const
return Perigee.
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float charge() const
Returns the charge.
::StatusCode StatusCode
StatusCode definition for legacy code.
@ OWN_ELEMENTS
this data object owns its elements
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".