ATLAS Offline Software
TrigMuonEFInvMassHypoTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "GaudiKernel/SystemOfUnits.h"
9 
10 TrigMuonEFInvMassHypoTool::TrigMuonEFInvMassHypoTool(const std::string & type, const std::string & name, const IInterface* parent):
12 { }
13 
15 }
16 
18 if(m_acceptAll) {
19  ATH_MSG_DEBUG("Accepting all the events!");
20  } else {
21  if(m_invMassLow<0 && m_invMassHigh<0){
22  ATH_MSG_ERROR("Both mass cuts are <0. This is probably a configuration mistake.");
23  return StatusCode::FAILURE;
24  }
25  }
26  if ( not m_monTool.name().empty() ) {
27  ATH_CHECK( m_monTool.retrieve() );
28  ATH_MSG_DEBUG("MonTool name: " << m_monTool);
29  }
30  ATH_MSG_DEBUG("Initialization completed successfully");
31  return StatusCode::SUCCESS;
32 }
33 
34 bool TrigMuonEFInvMassHypoTool::executeAlg(const std::vector<Combo::LegDecision>& combination) const{
35 
36  //Monitored Variables
37  std::vector<float> fexInvMass, fexInvMassSel;
38  auto muonMassMon = Monitored::Collection("Mass", fexInvMass);
39  auto muonMassSelMon = Monitored::Collection("Mass_sel", fexInvMassSel);
40  auto monitorIt = Monitored::Group(m_monTool, muonMassMon, muonMassSelMon);
41 
42  bool result = false;
43 
44  //for pass through mode
45  if(m_acceptAll) {
46  result = true;
47  ATH_MSG_DEBUG("Accept property is set: taking all the events");
48  return result;
49  }
50 
51  std::vector<const xAOD::Muon*> selected_muons;
52  for(auto el: combination){
53  auto EL= el.second;
54  auto dec= (*EL);
55  auto muonLinks = TrigCompositeUtils::findLinks<xAOD::MuonContainer>( dec, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
56  for(size_t i=0; i<muonLinks.size(); i++){
57  if(muonLinks.at(i).isValid()){
58  const xAOD::Muon *mu = *(muonLinks.at(i).link);
59  if(mu->primaryTrackParticle()) selected_muons.push_back(mu);
60  }
61  }
62  }
63 
64 
65  // decision making
66  // Loop over muons passing previous hypo
67  for(size_t i=0; i<selected_muons.size(); i++){
68  const xAOD::Muon* muon1 = selected_muons[i];
69 
70  for(size_t j=i+1; j<selected_muons.size(); j++){
71  const xAOD::Muon* muon2 = selected_muons[j];
72 
73  //We always get muons from previous decision that have combined track particles
74  const xAOD::TrackParticle* tr1 = muon1->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle);
75  const xAOD::TrackParticle* tr2 = muon2->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle);
76  if (!tr1 || !tr2) {
77  ATH_MSG_DEBUG("No CombinedTrackParticle found.");
78  } else {
79  ATH_MSG_DEBUG("Retrieved CombinedTrack tracks with abs pt "<< (*tr1).pt()/Gaudi::Units::GeV << " GeV and "<< (*tr2).pt()/Gaudi::Units::GeV << " GeV ");
80 
81  float diMuMass = (tr1->p4()+tr2->p4()).M()/Gaudi::Units::GeV;
82 
83  //fill monitored variables
84  fexInvMass.push_back(diMuMass);
85 
86  ATH_MSG_DEBUG(" REGTEST diMuon mass is " << diMuMass << " GeV "
87  << " and lowMassCut cut is " << m_invMassLow << " GeV"
88  << " and highMassCut cut is " << m_invMassHigh << " GeV");
89 
90  //Apply hypo cuts. If any mass combination is true, then the overall result should be true.
91  if(m_invMassLow>0 && diMuMass>m_invMassLow && m_invMassHigh>0 && diMuMass<m_invMassHigh){
92  if(m_selOS){
93  if(muon1->charge()*muon2->charge()<0){
94  result=true;
95  }
96  } else {
97  result = true;
98  }
99  //fill monitored variables
100  fexInvMassSel.push_back(diMuMass);
101  }
102  }
103  }
104  }
105 
106  ATH_MSG_DEBUG("Overall result is: "<<(result?"true":"false"));
107  return result;
108 }
109 
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
get_generator_info.result
result
Definition: get_generator_info.py:21
xAOD::Muon_v1::trackParticle
const TrackParticle * trackParticle(TrackParticleType type) const
Returns a pointer (which can be NULL) to the TrackParticle used in identification of this muon.
Definition: Muon_v1.cxx:504
TrigMuonEFInvMassHypoTool::initialize
virtual StatusCode initialize() override
Definition: TrigMuonEFInvMassHypoTool.cxx:17
TrigMuonEFInvMassHypoTool::executeAlg
bool executeAlg(const std::vector< Combo::LegDecision > &combinaiton) const override
Only a dummy implementation exists in ComboHypoToolBase.
Definition: TrigMuonEFInvMassHypoTool.cxx:34
TrigMuonEFInvMassHypoTool::TrigMuonEFInvMassHypoTool
TrigMuonEFInvMassHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigMuonEFInvMassHypoTool.cxx:10
ComboHypoToolBase
Base class for tools which cut on properties of multi-object or multi-leg chains. User should derive ...
Definition: ComboHypoToolBase.h:26
TrigMuonEFInvMassHypoTool.h
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
xAOD::Muon_v1::charge
float charge() const
xAOD::TrackParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TrackParticle_v1.cxx:129
TrigMuonEFInvMassHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigMuonEFInvMassHypoTool.h:37
TrigMuonEFInvMassHypoTool::m_invMassHigh
Gaudi::Property< double > m_invMassHigh
Definition: TrigMuonEFInvMassHypoTool.h:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
TrigMuonEFInvMassHypoTool::m_invMassLow
Gaudi::Property< double > m_invMassLow
Definition: TrigMuonEFInvMassHypoTool.h:27
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigMuonEFInvMassHypoTool::~TrigMuonEFInvMassHypoTool
virtual ~TrigMuonEFInvMassHypoTool()
Definition: TrigMuonEFInvMassHypoTool.cxx:14
MuonContainer.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigMuonEFInvMassHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: TrigMuonEFInvMassHypoTool.h:31
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigMuonEFInvMassHypoTool::m_selOS
Gaudi::Property< bool > m_selOS
Definition: TrigMuonEFInvMassHypoTool.h:33
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30