ATLAS Offline Software
Loading...
Searching...
No Matches
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
12namespace 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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
TrigMuonMatching_example(const std::string &name, ISvcLocator *svcLoc)
ToolHandle< ITrigMuonMatching > m_matchTool
The common trigger namespace for trigger analysis tools.
Muon_v1 Muon
Reference the current persistent version:
MuonAuxContainer_v5 MuonAuxContainer
Definition of the current Muon auxiliary container.
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".