ATLAS Offline Software
src/TrigMuonMatching_example.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 
10 #include <cmath>
11 
12 namespace Trig {
13 
14  TrigMuonMatching_example::TrigMuonMatching_example( const std::string& name, ISvcLocator* svcLoc )
15  : AthAlgorithm( name, svcLoc ),
16  m_matchTool("CP::TrigMuonMatching/TrigMuonMatching",this)
17  {
18  declareProperty("MuonMatchTool",m_matchTool);
19  }
20 
22  {
23 
24  ATH_CHECK(m_matchTool.retrieve());
25 
26  return StatusCode::SUCCESS;
27  }
28 
29 
31  {
32 
33  const xAOD::MuonContainer* muons = 0;
34  ATH_CHECK( evtStore()->retrieve( muons, "Muons" ) );
35  ATH_MSG_INFO( "Number of muons: " << muons->size() );
36 
39  goodMuon -> setStore(goodMuonAux);
40  CHECK( evtStore()->record(goodMuon,"GoodMuon"));
41  CHECK( evtStore()->record(goodMuonAux,"GoodMuonAux."));
42 
43  for(const auto* mu: *muons){
44  Bool_t ismu26_imedium = false;
45  Bool_t ismu50 = false;
46  Bool_t isL2SA = false;
47  Bool_t isL2CB = false;
48  Bool_t isL1 = false;
49  ismu26_imedium = m_matchTool->match(mu,"HLT_mu26_imedium");
50  ismu50 = m_matchTool->match(mu,"HLT_mu50");
51  isL2SA = m_matchTool->matchL2SA(mu, "L1_MU20", "HLT_mu26_imedium");
52  isL2CB = m_matchTool->matchL2CB(mu, "HLT_mu26_imedium");
53  isL1 = m_matchTool->matchL1(mu,"L1_MU20");
54  if(ismu26_imedium)std::cout << "HLT_mu26_imedium matched." << std::endl;
55  if(ismu50)std::cout << "HLT_mu50 matched." << std::endl;
56  if(isL2SA) std::cout << "L2 SA matched" << std::endl;
57  if(isL2CB) std::cout << "L2 CB matched" << std::endl;
58  if(isL1) std::cout << "L1_MU20 matched" << std::endl;
59 
60  Double_t dR = m_matchTool->minDelR(mu,"HLT_mu26_imedium");
61  std::cout << "DeltaR(mu26_imedium) " << dR << std::endl;
62  Double_t dRL1 = m_matchTool->minDelRL1(mu,"L1_MU20");
63  std::cout << "DeltaR(L1_MU20) " << dRL1 << std::endl;
64 
65  xAOD::Muon* newMuon = new xAOD::Muon;
66  goodMuon->push_back(newMuon);
67  *newMuon = *mu;
68  }
69 
70  const xAOD::MuonContainer* SelectedMuons = 0;
71  ATH_CHECK(evtStore()->retrieve(SelectedMuons,"GoodMuon"));
72  ATH_MSG_INFO( "Number of selected muons: " << SelectedMuons->size() );
73  if(SelectedMuons->size()==2){
74  const xAOD::Muon *mu1 = (*SelectedMuons)[0];
75  const xAOD::Muon *mu2 = (*SelectedMuons)[1];
76  if (mu1 && mu2) {
77  std::pair<Bool_t,Bool_t> result1, result2;
78  m_matchTool->matchDimuon(mu1, mu2, "HLT_2mu14", result1, result2);
79  if(result1.first && result2.first)std::cout << "HLT_2mu14 matched" << std::endl;
80  }
81  }
82 
83  return StatusCode::SUCCESS;
84  }
85 
86 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::MuonContainer
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Definition: Event/xAOD/xAODMuon/xAODMuon/MuonContainer.h:14
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trig::TrigMuonMatching_example::m_matchTool
ToolHandle< ITrigMuonMatching > m_matchTool
Definition: TrigMuonMatching_example.h:27
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MuonAuxContainer.h
Trig::TrigMuonMatching_example::execute
virtual StatusCode execute()
Definition: src/TrigMuonMatching_example.cxx:30
xAOD::MuonAuxContainer_v5
Temporary container used until we have I/O for AuxStoreInternal.
Definition: MuonAuxContainer_v5.h:31
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
Trig::TrigMuonMatching_example::TrigMuonMatching_example
TrigMuonMatching_example(const std::string &name, ISvcLocator *svcLoc)
Definition: src/TrigMuonMatching_example.cxx:14
Trig::TrigMuonMatching_example::initialize
virtual StatusCode initialize()
Definition: src/TrigMuonMatching_example.cxx:21
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
TrigMuonMatching_example.h
xAOD::Muon
Muon_v1 Muon
Reference the current persistent version:
Definition: Event/xAOD/xAODMuon/xAODMuon/Muon.h:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
MuonContainer.h
xAOD::MuonAuxContainer
MuonAuxContainer_v5 MuonAuxContainer
Definition of the current Muon auxiliary container.
Definition: MuonAuxContainer.h:19
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.