ATLAS Offline Software
Run1BStoxAODTrigger.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // Fill histograms for some of HLT xAOD containers from converted Run 1 data, to
7 // compare them with the AOD reference.
8 //
9 
10 //#include "AthenaBaseComps/AthAlgorithm.h"
11 //#include "GaudiKernel/ToolHandle.h"
12 
15 
16 // to read HLT containers
19 #include "xAODMuon/Muon.h"
20 #include "xAODMuon/MuonContainer.h"
21 #include "xAODJet/Jet.h"
22 #include "xAODJet/JetContainer.h"
25 
26 // Root headers
27 #include "TMath.h"
28 #include "TH1F.h"
29 #include "TFile.h"
30 #include <iostream>
31 
32 using namespace std;
33 using namespace Trig;
34 using namespace xAOD;
35 
36 namespace TrigAnalysisTest {
37  //
38  // Init counters and get ready to run.
39  //
40  Run1BStoxAODTrigger::Run1BStoxAODTrigger()
41  : m_passed_l1(0),
42  m_passed_hlt(0)
43  //m_first_call(true)
44  {
45  m_histFile = new TFile("hist.root", "RECREATE");
46  if (m_histFile == nullptr || !m_histFile->IsOpen()) {
47  throw std::runtime_error("unable to open file for writing, exiting");
48  }
49 
50  // bphys
51  m_HLT_EFBMuMuXFex_eta = new TH1F( "HLT_EFBMuMuXFex_eta", "HLT_EFBMuMuXFex;#eta;No. of TrigEFBphys objects", 100, -4., 4. );
52  m_HLT_EFBMuMuXFex_mass = new TH1F( "HLT_EFBMuMuXFex_mass", "HLT_EFBMuMuXFex;#M (GeV);No. of TrigEFBphys objects", 100, 0., 20. );
53  // taus
54  m_HLT_TrigTauJet = new TH1F( "HLT_TrigTauJet", "HLT_TrigTauJet;p_{T} (GeV);Jets", 100, 0., 500. );
55  // muons
56  m_HLT_MuonEF_NSegments = new TH1F( "HLT_MuonEF_NSegments", "HLT_MuonEF_NSegments;NSegments;Muons", 100, 0., 100.);
57  m_HLT_MuonEF_pt = new TH1F( "HLT_MuonEF_pt", "HLT_MuonEF_pt;p_{T} (GeV);Muons", 100, 0., 100.);
58  // MET
59  m_HLT_TrigEFMissingET = new TH1F( "HLT_TrigEFMissingET", "HLT_TrigEFMissingET;E_{T} (GeV);Entries", 100, 0., 200.);
60  m_HLT_TrigEFMissingET_FEB = new TH1F( "HLT_TrigEFMissingET_FEB", "HLT_TrigEFMissingET_FEB;E_{T} (GeV);Entries", 100, 0., 200. );
61  m_HLT_TrigEFMissingET_topocl = new TH1F( "HLT_TrigEFMissingET_topocl", "HLT_TrigEFMissingET_topocl;E_{T} (GeV);Entries", 100, 0., 200. );
62  // all trigger bits. The binning is changed in finalize() when the total number of triggers is known
63  m_all_triggers = new TH1F("all_triggers", ";Trigger;No. of events", 1, 0., 1.);
64  }
65 
66  // Actually process an event.
68 
69  // Did we pass a trigger level?
70  if (trigDecTool.isPassed("L1_.*"))
71  m_passed_l1++;
72  if (trigDecTool.isPassed("EF_.*"))
73  m_passed_hlt++;
74 
75  auto chainGroups = trigDecTool.getChainGroup(".*");
76  for(auto &trig : chainGroups->getListOfTriggers()) {
77  if(!m_trigger_counts.count(trig))
78  m_trigger_counts[trig] = 0;
79  if(trigDecTool.isPassed(trig)) {
80  m_trigger_counts[trig] += 1;
81  cout << "Trigger passed: " << trig << endl;
82  }
83  }
84 
85  //
86  //extract trigger containers and fill histograms
87  //
88 
89  // bphys
90  // HLT_EFBMuMuXFex
91  const xAOD::TrigBphysContainer* HLT_xAOD__TrigBphysContainer_EFBMuMuXFex = 0;
92  eventStore()->retrieve( HLT_xAOD__TrigBphysContainer_EFBMuMuXFex, "HLT_xAOD__TrigBphysContainer_EFBMuMuXFex" ).ignore();
93  cout << "size of HLT_xAOD__TrigBphysContainer_EFBMuMuXFex is " << HLT_xAOD__TrigBphysContainer_EFBMuMuXFex->size() << endl;
95  for(TrigBphys_iter = HLT_xAOD__TrigBphysContainer_EFBMuMuXFex->begin(); TrigBphys_iter != HLT_xAOD__TrigBphysContainer_EFBMuMuXFex->end(); ++TrigBphys_iter) {
96  cout << "eta, mass = "<< (*TrigBphys_iter)->eta() << ", "<< (*TrigBphys_iter)->mass() << endl;
97  m_HLT_EFBMuMuXFex_eta->Fill( (*TrigBphys_iter)->eta() );
98  m_HLT_EFBMuMuXFex_mass->Fill( (*TrigBphys_iter)->mass() );
99  }
100 
101  // taus
102  // HLT_TrigTauJet
103  const xAOD::JetContainer* HLT_xAOD__JetContainer_TrigTauJet = 0;
104  eventStore()->retrieve( HLT_xAOD__JetContainer_TrigTauJet, "HLT_xAOD__JetContainer_TrigTauJet" ).ignore();//weird name
105  cout << "HLT_xAOD__JetContainer_TrigTauJet successfully retrieved - size is " << HLT_xAOD__JetContainer_TrigTauJet->size() << " jets" << endl;
107  for(Jet_iter = HLT_xAOD__JetContainer_TrigTauJet->begin(); Jet_iter != HLT_xAOD__JetContainer_TrigTauJet->end(); ++Jet_iter) {
108  cout << "tau jet eta, pt: " << (*Jet_iter)->eta() << ", " << (*Jet_iter)->pt() << endl;
109  m_HLT_TrigTauJet->Fill( (*Jet_iter)->pt() / 1000. );
110  }
111 
112 
113  // muons
114  // HLT_MuonEFInfo
115  const xAOD::MuonContainer* HLT_xAOD__MuonContainer_MuonEFInfo = 0;
116  eventStore()->retrieve( HLT_xAOD__MuonContainer_MuonEFInfo, "HLT_xAOD__MuonContainer_MuonEFInfo").ignore();
117  cout << "size of HLT_xAOD__MuonContainer_MuonEFInfo is " << HLT_xAOD__MuonContainer_MuonEFInfo->size() << endl;
119  for(Muon_iter = HLT_xAOD__MuonContainer_MuonEFInfo->begin(); Muon_iter!= HLT_xAOD__MuonContainer_MuonEFInfo->end(); ++Muon_iter) {
120  cout << "muon n segments, pt: " << (*Muon_iter)->nMuonSegments() << ", " << (*Muon_iter)->pt() << endl;
121  m_HLT_MuonEF_NSegments->Fill( float((*Muon_iter)->nMuonSegments()) );
122  m_HLT_MuonEF_pt->Fill( (*Muon_iter)->pt() / 1000. );
123  }
124 
125 
126  // MET
127  // HLT_xAOD__TrigMissingETContainer_TrigEFMissingET
128  const xAOD::TrigMissingETContainer* HLT_xAOD__TrigMissingETContainer_TrigEFMissingET = 0;
129  eventStore()->retrieve( HLT_xAOD__TrigMissingETContainer_TrigEFMissingET, "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET" ).ignore();
131  cout << "Size of TrigMissingETContainer is " << HLT_xAOD__TrigMissingETContainer_TrigEFMissingET->size() << endl;
132  for(TrigMissingET_iter = HLT_xAOD__TrigMissingETContainer_TrigEFMissingET->begin(); TrigMissingET_iter != HLT_xAOD__TrigMissingETContainer_TrigEFMissingET->end(); ++TrigMissingET_iter) {
133  Double_t ex = (*TrigMissingET_iter)->ex();
134  Double_t ey = (*TrigMissingET_iter)->ey();
135  Double_t et = TMath::Sqrt(ex*ex + ey*ey);
136  cout << " missing et = " << et << endl;
137  m_HLT_TrigEFMissingET->Fill( et / 1000. );
138  }
139  // HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB
140  const xAOD::TrigMissingETContainer* HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB = 0;
141  eventStore()->retrieve( HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB, "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB" ).ignore();
142  cout << "Size of TrigMissingETContainer is " << HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB->size() << endl;
143  for(TrigMissingET_iter = HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB->begin(); TrigMissingET_iter != HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_FEB->end(); ++TrigMissingET_iter) {
144  Double_t ex = (*TrigMissingET_iter)->ex();
145  Double_t ey = (*TrigMissingET_iter)->ey();
146  Double_t et = TMath::Sqrt(ex*ex + ey*ey);
147  cout << " missing et = " << et << endl;
148  m_HLT_TrigEFMissingET_FEB->Fill( et / 1000. );
149  }
150  // HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl
151  const xAOD::TrigMissingETContainer* HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl = 0;
152  eventStore()->retrieve( HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl, "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl" ).ignore();
153  cout << "Size of TrigMissingETContainer is " << HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl->size() << endl;
154  for(TrigMissingET_iter = HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl->begin(); TrigMissingET_iter != HLT_xAOD__TrigMissingETContainer_TrigEFMissingET_topocl->end(); ++TrigMissingET_iter) {
155  Double_t ex = (*TrigMissingET_iter)->ex();
156  Double_t ey = (*TrigMissingET_iter)->ey();
157  Double_t et = TMath::Sqrt(ex*ex + ey*ey);
158  cout << " missing et = " << et << endl;
159  m_HLT_TrigEFMissingET_topocl->Fill( et / 1000. );
160  }
161 
162  cout << " --- Event processing done --- \n" << endl;
163  }
164 
165  // Dump everything and return a status.
167  {
168  //athena doesn't store m_all_triggers without this
169  m_histFile->cd();
170 
171  // Dump for debugging.
172  cout << "L1 triggers passed: " << m_passed_l1 << endl;
173  cout << "EF triggers passed: " << m_passed_hlt << endl;
174  cout << "START SUMMARY: Run1BStoxAODTrigger" << endl;
175  cout << "creating histogram with one bin per trigger, n of bins is " << m_trigger_counts.size() << endl;
176  // Set the correct binning
177  m_all_triggers->SetBins( m_trigger_counts.size(), 0.0, m_trigger_counts.size() );
178  cout << "histogram created" << endl;
179  int trigger_counter = 0;
180  for (auto it = m_trigger_counts.begin(); it!=m_trigger_counts.end(); it++) {
181  cout << (*it).first << "\t" << (*it).second <<endl;
182  trigger_counter++;
183  m_all_triggers->GetXaxis()->SetBinLabel( trigger_counter, ((*it).first).c_str() );
184  m_all_triggers->SetBinContent( trigger_counter, (*it).second );
185  }
186  cout << "END SUMMARY : Run1BStoxAODTrigger" << endl;
187 
188  m_histFile->Write();
189  m_histFile->Close();
190 
191  // our aim here is to test the conversion of variables
192  return 0;
193  }
194 
195 }
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_TrigTauJet
TH1 * m_HLT_TrigTauJet
Definition: Run1BStoxAODTrigger.h:43
TrigMissingET.h
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_MuonEF_NSegments
TH1 * m_HLT_MuonEF_NSegments
Definition: Run1BStoxAODTrigger.h:45
Jet.h
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_EFBMuMuXFex_eta
TH1 * m_HLT_EFBMuMuXFex_eta
Definition: Run1BStoxAODTrigger.h:40
et
Extra patterns decribing particle interation process.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrigAnalysisTest::Run1BStoxAODTrigger::m_passed_l1
unsigned int m_passed_l1
Definition: Run1BStoxAODTrigger.h:30
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
TrigAnalysisTest::Run1BStoxAODTrigger::m_passed_hlt
unsigned int m_passed_hlt
Definition: Run1BStoxAODTrigger.h:31
Muon.h
TrigAnalysisTest::Run1BStoxAODTrigger::m_histFile
TFile * m_histFile
Definition: Run1BStoxAODTrigger.h:35
Run1BStoxAODTrigger.h
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_TrigEFMissingET
TH1 * m_HLT_TrigEFMissingET
Definition: Run1BStoxAODTrigger.h:48
TrigAnalysisTest::Run1BStoxAODTrigger::m_trigger_counts
std::map< std::string, int > m_trigger_counts
Definition: Run1BStoxAODTrigger.h:33
TrigDecisionTool.h
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
Trig::TrigDecisionTool
Definition: TrigDecisionTool.h:65
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
TrigAnalysisTest::ITest::eventStore
EventPtr_t eventStore()
Definition: ITest.h:29
TrigAnalysisTest::Run1BStoxAODTrigger::finalize
int finalize()
Definition: Run1BStoxAODTrigger.cxx:166
TrigAnalysisTest::Run1BStoxAODTrigger::processEvent
void processEvent(Trig::TrigDecisionTool &trigDecTool)
Definition: Run1BStoxAODTrigger.cxx:67
TrigBphys.h
TrigMissingETContainer.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trig::TrigDecisionTool::isPassed
virtual bool isPassed(const std::string &chain, unsigned int condition) const
true if given chain passed
Definition: TrigDecisionTool.cxx:270
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_TrigEFMissingET_topocl
TH1 * m_HLT_TrigEFMissingET_topocl
Definition: Run1BStoxAODTrigger.h:50
TrigAnalysisTest
Definition: BasicTriggerFired.cxx:30
MuonContainer.h
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
JetContainer.h
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_MuonEF_pt
TH1 * m_HLT_MuonEF_pt
Definition: Run1BStoxAODTrigger.h:46
Trig::TrigDecisionToolCore::getChainGroup
const Trig::ChainGroup * getChainGroup(const std::vector< std::string > &patterns, TrigDefs::Group props=TrigDefs::Group::Default) const
Create/get chain group (.
Definition: ChainGroupFunctions.cxx:38
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
TrigAnalysisTest::Run1BStoxAODTrigger::m_all_triggers
TH1 * m_all_triggers
Definition: Run1BStoxAODTrigger.h:38
TrigBphysContainer.h
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_EFBMuMuXFex_mass
TH1 * m_HLT_EFBMuMuXFex_mass
Definition: Run1BStoxAODTrigger.h:41
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TrigAnalysisTest::Run1BStoxAODTrigger::m_HLT_TrigEFMissingET_FEB
TH1 * m_HLT_TrigEFMissingET_FEB
Definition: Run1BStoxAODTrigger.h:49