23 #include "CLHEP/Random/RandFlat.h"
67 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Init * START *" <<
endmsg;
69 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Init * initializing muon selector *" <<
endmsg;
71 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Init * initializing electron selector *" <<
endmsg;
74 if (
m_workAsFourMuons) {(*m_msgStream) << MSG::INFO <<
" * FourMuonEvent::Init * working mode: 4 muons" <<
endmsg; }
79 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Init * Completed * " <<
endmsg;
100 if (pxMuonContainer !=
nullptr) {
102 <<
" track list has "<< pxMuonContainer->
size()
110 while ( xMuonItr != xMuonItrE ){
116 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Reco ** muon " << theCount <<
" is accepted " <<
endmsg;
124 if (!pxMuonContainer) {
125 std::cout <<
" * FourMuonEvent::Reco * Can't retrieve combined muon collection (container: " <<
m_container <<
") " << std::endl;
140 if (pxElecContainer !=
nullptr) {
141 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Reco * retrieving xAOD::ElectronContainer SUCCESS. "
143 <<
" size: " << pxElecContainer->
size()
145 if (pxElecContainer->
size() > 0 ){
152 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Reco * retrieving xAOD::ElectronContainer -- FAILED -- eventcount: " <<
m_eventCount <<
endmsg;
171 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" is a GOOD 4-muon event " << std::endl;
174 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" FAILS the 4-muon event selection " << std::endl;
180 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * applying 4 electron selection " << std::endl;
189 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" is a GOOD 4-electrom event " << std::endl;
192 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" FAILS the 4-electron event selection " << std::endl;
196 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" is not a 4-electron event " << std::endl;
202 if (
m_doDebug) std::cout <<
" * FourMuonEvent::Reco * applying 4 lepton selection " << std::endl;
205 bool enoughleptons =
false;
210 if ( enoughleptons) {
212 std::cout <<
" * FourMuonEvent::Reco * Global statistics: Total number of accepted muons so far: " <<
m_acceptedMuonCount
228 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::Reco * === Event " <<
m_eventCount <<
" -- FAILS -- the 4-lepton event selection " <<
endmsg;
267 bool eventisgood =
true;
268 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent::EventSelection( type= " << eType <<
") ** started ** " << std::endl
279 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Failing number of good muons == 4 :( "
288 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Failing number of good electrons == 4 :( "
295 bool thisselection =
false;
299 if (!thisselection) {
300 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Failing number of good muons >= 2 && electrons >= 2 :( "
305 eventisgood = thisselection;
311 unsigned int npassleadingpt = 0;
312 unsigned int npasssecondpt = 0;
318 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * using muon " <<
i <<
" with pt: " <<
m_pxIDTrack[
i]->
pt() << std::endl;}
322 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * #muons with pt > leading pt: " <<
m_LeadingMuonPtCut*
CLHEP::GeV <<
" = " << npassleadingpt << std::endl;}
323 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * #muons with pt > second pt: " <<
m_SecondMuonPtCut*
CLHEP::GeV <<
" = " << npasssecondpt << std::endl;}
324 if (npassleadingpt == 0) {
342 if (
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * using electron " <<
i <<
" with pt: " <<
m_pxELTrack[
i]->
pt() << std::endl;}
346 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * #elecs with pt > leading pt: " <<
m_LeadingMuonPtCut*
CLHEP::GeV <<
" = " << npassleadingpt << std::endl;}
347 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * #elecs with pt > second pt: " <<
m_SecondMuonPtCut*
CLHEP::GeV <<
" = " << npasssecondpt << std::endl;}
348 if (npassleadingpt == 0) {
363 std::cout <<
" * FourMuonEvent::EventSelection * Failing mass window low cut: reco m= " <<
m_fInvariantMass[eType] <<
" > " <<
m_MassWindowLow << std::endl;
369 std::cout <<
" * FourMuonEvent::EventSelection * Failing mass window high cut: reco m= " <<
m_fInvariantMass[eType] <<
" > " <<
m_MassWindowHigh << std::endl;
377 bool vertexstatus =
false;
379 std::vector <float> vtxListX;
380 std::vector <float> vtxListY;
381 std::vector <float> vtxListZ;
382 std::vector <int> vtxNpart;
384 int noVertexCountMuon = 0;
385 int noVertexCountElec = 0;
388 for (
unsigned int imu = 0; imu <
NUM_MUONS; imu++) {
426 for (
unsigned int iel = 0; iel <
NUM_MUONS; iel++) {
473 if (vtxListX.size()>0) vertexstatus =
true;
477 if (noVertexCountMuon > 0) vertexstatus =
false;
479 std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * vertices ID of the muons = " << std::endl
490 if (vtxListX.size()>0) vertexstatus =
true;
494 if (noVertexCountElec > 0) vertexstatus =
false;
496 std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * vertices ID of the electrons = " << std::endl
507 if (vtxListX.size()>0) vertexstatus =
true;
512 std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * vertices in event = " << vtxListX.size() << std::endl;
513 for (
size_t imu=0; imu <
NUM_MUONS; imu++) {
516 for (
size_t iel=0; iel <
NUM_MUONS; iel++) {
525 std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Number of vertex found = " << vtxListX.size()
526 <<
" and mu without vertex: " << noVertexCountMuon
527 <<
" and elec without vertex: " << noVertexCountElec << std::endl;
528 for (
unsigned int ivtx=0; ivtx < vtxListX.size(); ivtx++) {
529 std::cout <<
" vtx[" << ivtx <<
"]= "
530 <<
"( " << vtxListX.at(ivtx)
531 <<
", " << vtxListY.at(ivtx)
532 <<
", " << vtxListZ.at(ivtx)
533 <<
") nparticles: " << vtxNpart.at(ivtx)
539 std::cout <<
" * FourMuonEvent::EventSelection * FAILED * number of vertex found = " << vtxListX.size()
540 <<
" mu without vertex: " << noVertexCountMuon
541 <<
" elec without vertex: " << noVertexCountElec << std::endl;
544 eventisgood = vertexstatus;
548 if(
m_doDebug){ std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") ** completed ** result= " << eventisgood << std::endl;}
557 if(
m_doDebug){ std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") ** started ** " << std::endl
566 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Failing number of good muons and electrons == 4 :( "
573 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Too many muons !! Failing number of good muons == 4 :( "
579 if(
m_doDebug) {std::cout <<
" * FourMuonEvent::EventSelection(" << eType <<
") * Too many electrons !! Failing number of good electrons == 4 :( "
585 double leadingMuonPt = -1., secondMuonPt=-1., thirdMuonPt=-1, fourthMuonPt=-1.;
629 double theLeadingPt = leadingMuonPt;
630 if (secondMuonPt > theLeadingPt) { theLeadingPt = secondMuonPt;}
631 if (thirdMuonPt > theLeadingPt) { theLeadingPt = thirdMuonPt;}
632 if (fourthMuonPt > theLeadingPt) { theLeadingPt = fourthMuonPt;}
634 double theTrailingPt = leadingMuonPt;
635 if (secondMuonPt < theTrailingPt && secondMuonPt > 0) { theTrailingPt = secondMuonPt;}
636 if (thirdMuonPt < theTrailingPt && thirdMuonPt > 0) { theTrailingPt = thirdMuonPt;}
637 if (fourthMuonPt < theTrailingPt && fourthMuonPt > 0) { theTrailingPt = fourthMuonPt;}
642 std::cout <<
" Pt of muons in this event 1: " << leadingMuonPt << std::endl
643 <<
" 2: " << secondMuonPt << std::endl
644 <<
" 3: " << thirdMuonPt << std::endl
645 <<
" 4: " << fourthMuonPt << std::endl
646 <<
" leading Pt: " << theLeadingPt << std::endl
647 <<
" trailing Pt: " << theTrailingPt << std::endl;
653 std::cout <<
" * FourMuonEvent::EventSelection * Failing pt cut * Reco Pt: leading " << theLeadingPt <<
" --> trailing " << theTrailingPt << std::endl;
658 std::cout <<
" * FourMuonEvent::EventSelection * Event passed the pt cuts: leading muon pt: " << leadingMuonPt << std::endl;
659 std::cout <<
" trailing muon pt: " << theTrailingPt << std::endl;
666 std::cout <<
" * FourMuonEvent::EventSelection * Failing mass window low cut: reco m= " <<
m_fInvariantMass[eType] <<
" > " <<
m_MassWindowLow << std::endl;
677 std::cout <<
" * FourMuonEvent::EventSelection * Event passed the mass window: " <<
m_fInvariantMass[eType] << std::endl;
866 std::cout <<
" * FourMuonEvent::EventSelection( type= " << eType <<
")* Good 4-muon set: pt range from " << leadingMuonPt/1000
867 <<
" to " << secondMuonPt/1000
868 <<
" GeV 4-muon invariant mass = " <<
m_fInvariantMass[eType] <<
" GeV " << std::endl;
869 std::cout <<
" * FourMuonEvent::EventSelection( type= " << eType <<
")* completed * " << std::endl;
925 bool thisdebug =
false;
929 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * RecordMuon * bad pxMuon --> EXIT "<< std::endl;}
944 if (
m_doDebug){ std::cout <<
" * FourMuonEvent * RecordMuon * bad pxMSmuon --> EXIT "<< std::endl;}
957 if (
m_doDebug){ std::cout <<
" * FourMuonEvent * RecordMuon * bad pxIDTrack for this muon--> EXIT "<< std::endl;}
978 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics * -- start -- " << std::endl; }
979 bool kinematicscomputed =
false;
984 bool goodidentifiers =
true;
990 if (goodidentifiers) {
992 bool goodtracks =
true;
1010 kinematicscomputed =
true;
1013 std::cout <<
" * FourMuonEvent * ReconstructKinematics4Elec * -- Muon ID Tracks -- new -- " << std::endl
1026 if (!kinematicscomputed) {
1027 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics * -- FAILED -- " << std::endl; }
1030 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics * -- completed -- status: " << kinematicscomputed << std::endl; }
1031 return kinematicscomputed;
1037 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics4Elec * -- start -- " << std::endl; }
1038 bool kinematicscomputed =
false;
1043 bool goodtracks =
true;
1048 if (
m_pxELTrack[0] ==
nullptr) goodtracks =
false;
1049 if (
m_pxELTrack[1] ==
nullptr) goodtracks =
false;
1050 if (
m_pxELTrack[2] ==
nullptr) goodtracks =
false;
1051 if (
m_pxELTrack[3] ==
nullptr) goodtracks =
false;
1060 kinematicscomputed =
true;
1063 std::cout <<
" * FourMuonEvent * ReconstructKinematics4Elec * -- Electron Tracks -- " << std::endl
1074 if (!kinematicscomputed) {
1075 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics4Elec * -- FAILED -- " << std::endl; }
1078 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematics4Elec * -- completed -- status: " << kinematicscomputed << std::endl; }
1079 return kinematicscomputed;
1085 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent * ReconstructKinematicsNew * -- START -- " <<
endmsg;
1087 bool kinematicscomputed =
false;
1111 bool goodtracks =
true;
1112 if (
m_pxMUTrack[0] ==
nullptr) goodtracks =
false;
1113 if (
m_pxMUTrack[1] ==
nullptr) goodtracks =
false;
1114 if (
m_pxMUTrack[2] ==
nullptr) goodtracks =
false;
1115 if (
m_pxMUTrack[3] ==
nullptr) goodtracks =
false;
1123 kinematicscomputed =
true;
1128 std::cout <<
" * FourMuonEvent * ReconstructKinematicsNew * -- Muon ID Tracks -- new -- " << std::endl;
1133 if (kinematicscomputed) std::cout <<
" invariant mass (4mu) = " <<
m_fInvariantMass[
ID] << std::endl;
1136 double invmass_test = -1.;
1139 bool goodtracks =
true;
1140 if (
m_pxELTrack[0] ==
nullptr) goodtracks =
false;
1141 if (
m_pxELTrack[1] ==
nullptr) goodtracks =
false;
1142 if (
m_pxELTrack[2] ==
nullptr) goodtracks =
false;
1143 if (
m_pxELTrack[3] ==
nullptr) goodtracks =
false;
1145 if (goodtracks && !kinematicscomputed) {
1153 kinematicscomputed =
true;
1157 std::cout <<
" * FourMuonEvent * ReconstructKinematicsNew * -- Electron Tracks -- " << std::endl;
1162 std::cout <<
" invariant mass (4e) = " << invmass_test << std::endl;
1167 bool goodtracks =
true;
1168 if (
m_pxMUTrack[0] ==
nullptr) goodtracks =
false;
1169 if (
m_pxMUTrack[2] ==
nullptr) goodtracks =
false;
1170 if (
m_pxELTrack[0] ==
nullptr) goodtracks =
false;
1171 if (
m_pxELTrack[2] ==
nullptr) goodtracks =
false;
1173 if (goodtracks && !kinematicscomputed) {
1181 kinematicscomputed =
true;
1185 std::cout <<
" * FourMuonEvent * ReconstructKinematicsNew * -- Muon and Electron Tracks -- " << std::endl;
1195 std::cout <<
" invariant mass test = " << invmass_test << std::endl;
1198 if (!kinematicscomputed) {
1199 if(
m_doDebug){ std::cout <<
" * FourMuonEvent * ReconstructKinematicsNew * -- FAILED -- " << std::endl; }
1202 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonEvent * ReconstructKinematicsNew * -- COMPLETED -- status " << kinematicscomputed <<
endmsg;
1203 return kinematicscomputed;
1291 if ( pxTrackContainer )
1295 while ( xTrkItr != xTrkItrE )
1298 if ( !pxTrack )
continue;
1300 if(!pxTrkTrack)
continue;
1302 if ( !pxPerigee )
continue;
1303 const float fTrkPhi = pxPerigee->parameters()[
Trk::phi];
1304 const float fTrkEta = pxPerigee->eta();
1308 float fDR = sqrt( fDPhi*fDPhi + fDEta*fDEta );
1335 std::cout <<
" * FourMuonEvent * SetLeadingMuonPtCut * new Pt cuts: " <<
m_LeadingMuonPtCut <<
" & "
1357 std::cout <<
" * FourMuonEvent * SetSecondMuonPtCut * new Pt cuts: " <<
m_LeadingMuonPtCut
1369 bool thisdebug =
false;
1371 if (
m_doDebug || thisdebug) {std::cout <<
" * FourMuonEvent::OrderMuonList * -- start -- " << std::endl
1376 int muMinus1Id = -9;
1377 int muMinus2Id = -9;
1378 double muPlus1Pt = 0.;
1379 double muPlus2Pt = 0.;
1380 double muMinus1Pt = 0.;
1381 double muMinus2Pt = 0.;
1389 if (nMuonsAtEntry >= 2) {
1390 for (
int imuon=0; imuon < (
int) nMuonsAtEntry; imuon++) {
1391 if(
m_doDebug &&
false ){ std::cout <<
" * FourMuonEvent::OrderMuonList * testing imuon= " << imuon
1402 muPlus2Pt = muPlus1Pt;
1403 muPlus2Id = muPlus1Id;
1419 muMinus2Pt = muMinus1Pt;
1420 muMinus2Id = muMinus1Id;
1434 if (nMuonsAtEntry >= 2 && (muposcount == 0 || munegcount == 0)) {
1435 if (
m_doDebug) std::cout <<
" -- FourMuonEvent::OrderMuonList -- No opposite charge muons in the " << nMuonsAtEntry <<
" input muons"
1436 <<
" #mu+ " << muposcount
1437 <<
" #mu- " << munegcount
1438 <<
" --> DISCARD ALL MUONS -- " << std::endl;
1456 std::cout <<
" * FourMuonEvent::OrderMuonList * taking " <<
m_numberOfFullPassMuons <<
" muons from the input list of " << nMuonsAtEntry <<
" muons: " << std::endl;
1457 if (muMinus1Id >= 0) std::cout <<
" leading mu-: " << muMinus1Id <<
" Pt = " << muMinus1Pt << std::endl;
1458 if (muMinus2Id >= 0) std::cout <<
" second mu-: " << muMinus2Id <<
" Pt = " << muMinus2Pt << std::endl;
1459 if (muPlus1Id >= 0) std::cout <<
" leading mu+: " << muPlus1Id <<
" Pt = " << muPlus1Pt << std::endl;
1460 if (muPlus2Id >= 0) std::cout <<
" second mu+: " << muPlus2Id <<
" Pt = " << muPlus2Pt << std::endl;
1463 if (
m_doDebug) std::cout <<
" * FourMuonEvent::OrderMuonList * This event has less than 2 muons :(" << std::endl;
1466 if (
m_doDebug || thisdebug) std::cout <<
" * FourMuonEvent::OrderMuonList * completed * m_numberOfFullPassMuons= " <<
m_numberOfFullPassMuons << std::endl;
1473 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonsEvents::CheckMuonVertices * -- START --" <<
endmsg;
1475 bool goodvertices =
false;
1476 goodvertices =
true;
1477 int nverticesfound = 0;
1481 for (
unsigned int imuneg = 0; imuneg <= 1; imuneg++) {
1517 if (nverticesfound >= 1) goodvertices =
true;
1519 if (nverticesfound == 0)
if (
m_doDebug) std::cout <<
" -- FourMuonEvent::CheckMuonVertices -- WARNING -- MUONS DO NOT COME FROM SAME VERTEX " << std::endl;
1521 (*m_msgStream) <<
MSG::DEBUG <<
" * FourMuonsEvents::CheckMuonVertices * -- COMPLETED -- status: " << goodvertices <<
endmsg;
1522 return goodvertices;