ATLAS Offline Software
Functions | Variables
util/TrigTauMatching_example.cxx File Reference
#include "TrigConfxAOD/xAODConfigTool.h"
#include "TrigDecisionTool/TrigDecisionTool.h"
#include "xAODTau/TauJetContainer.h"
#include "xAODTau/TauJetAuxContainer.h"
#include "TrigTauMatching/TrigTauMatching.h"
#include "TChain.h"
#include "TError.h"
#include "TFile.h"
#include "TH1F.h"
#include "TLorentzVector.h"
#include <iostream>
#include <memory>

Go to the source code of this file.

Functions

std::unique_ptr< TChain > getFilesFromCommandLine (int argc, char *argv[])
 
int main (int argc, char *argv[])
 

Variables

const char * APP_NAME = "TrigTauMatching_example"
 
const std::string prescaledTauTrigger = "L1_TAU12IM"
 
const std::string tauTrigger = "HLT_tau125_medium1_tracktwo"
 
const std::string diTauTrigger = "HLT_tau35_medium1_tracktwo_tau25_medium1_tracktwo"
 

Function Documentation

◆ getFilesFromCommandLine()

std::unique_ptr< TChain > getFilesFromCommandLine ( int  argc,
char *  argv[] 
)

Definition at line 188 of file util/TrigTauMatching_example.cxx.

189 {
190  if (argc < 2) {
191  ::Error(APP_NAME, "Usage: %s <xAOD file> [xAOD file2]...", APP_NAME);
192  return nullptr;
193  }
194 
195  std::unique_ptr< TChain > chain( new TChain( "CollectionTree" ) );
196  for (int i = 1; i < argc; i++) {
197  chain->Add(argv[i]);
198  }
199 
200  return chain;
201 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 42 of file util/TrigTauMatching_example.cxx.

42  {
43 
44  // Initialize (as done for all xAOD standalone programs!)
46 
48  if( ! chain ) {
49  return 1;
50  }
51 
52  // The TEvent object
55 
56  // The TStore object
58  store.setActive();
59 
60  // The configuration tool.
61  TrigConf::xAODConfigTool configTool("xAODConfigTool");
62  ToolHandle<TrigConf::ITrigConfigTool> configHandle(&configTool);
63  ASG_CHECK_SA(APP_NAME,configHandle->initialize());
64 
65  // The decision tool
66  Trig::TrigDecisionTool trigDecTool("TrigDecTool");
67  ASG_CHECK_SA(APP_NAME, trigDecTool.setProperty("ConfigTool", configHandle));
68  ASG_CHECK_SA(APP_NAME, trigDecTool.setProperty("TrigDecisionKey", "xTrigDecision"));
69  ASG_CHECK_SA(APP_NAME, trigDecTool.initialize());
70  ToolHandle<Trig::TrigDecisionTool> decisionToolHandle(&trigDecTool);
71 
72  Trig::TrigTauMatchingTool matchTool("TrigTauMatching");
73  ASG_CHECK_SA(APP_NAME, matchTool.setProperty("TrigDecisionTool", decisionToolHandle));
74  ASG_CHECK_SA(APP_NAME, matchTool.initialize());
75 
76  Trig::TrigTauMatchingTool resurrectedMatchTool("TrigTauMatchingWithResurrection");
77  ASG_CHECK_SA(APP_NAME, resurrectedMatchTool.setProperty("TrigDecisionTool", decisionToolHandle));
78  ASG_CHECK_SA(APP_NAME, resurrectedMatchTool.setProperty("AllowResurrectedDecision", true));
79  ASG_CHECK_SA(APP_NAME, resurrectedMatchTool.initialize());
80 
81  // Run the files
82  std::pair<int, int> prescaledTauEvents(0, 0);
83  std::pair<int, int> resurrectedTauEvents(0, 0);
84  std::pair<int, int> tauEvents(0, 0);
85  std::pair<int, int> diTauEvents(0, 0);
86  for (Long64_t entry = 0; entry < chain->GetEntries(); entry++)
87  {
88  bool prescaledTauTriggered = false;
89  bool resurrectedTauTriggered = false;
90  bool tauTriggered = false;
91  bool diTauTriggered = false;
92  int prescaledTauMatches = 0;
93  int resurrectedTauMatches = 0;
94  int tauMatches = 0;
95  int diTauMatches = 0;
96 
97 
98  event.getEntry(entry);
99 
100  const xAOD::TauJetContainer *taus;
101  RETURN_CHECK(APP_NAME, event.retrieve(taus, "TauJets"));
102  const xAOD::EmTauRoIContainer *emTauRoIs;
103  RETURN_CHECK(APP_NAME, event.retrieve(emTauRoIs, "LVL1EmTauRoIs"));
104 
105  prescaledTauTriggered = trigDecTool.isPassed(prescaledTauTrigger);
106  resurrectedTauTriggered = trigDecTool.isPassed(
108  TrigDefs::Physics | TrigDefs::allowResurrectedDecision);
109  tauTriggered = trigDecTool.isPassed(tauTrigger);
110  diTauTriggered = trigDecTool.isPassed(diTauTrigger);
111 
112  for (auto it: *taus)
113  {
114  // Cut on tau pT >= 25 GeV, |eta| <= 2.5, and medium ID
115  if ( it->pt() < 25000
116  || std::abs(it->eta()) > 2.5
118  {
119  continue;
120  }
121 
122  if (matchTool.matchL1(it, prescaledTauTrigger, emTauRoIs))
123  {
124  prescaledTauMatches++;
125  }
126 
127  if (resurrectedMatchTool.matchL1(it, prescaledTauTrigger, emTauRoIs))
128  {
129  resurrectedTauMatches++;
130  }
131 
132  if (matchTool.match(it, tauTrigger))
133  {
134  tauMatches++;
135  }
136 
137  if (matchTool.match(it, diTauTrigger))
138  {
139  diTauMatches++;
140  }
141  }
142 
143  if (prescaledTauTriggered)
144  {
145  prescaledTauEvents.first++;
146  prescaledTauEvents.second += (prescaledTauMatches > 0);
147  std::cout << "[" << entry << "] " << prescaledTauMatches
148  << " taus matched with "
149  << prescaledTauTrigger << std::endl;
150  }
151 
152  if (resurrectedTauTriggered)
153  {
154  resurrectedTauEvents.first++;
155  resurrectedTauEvents.second += (resurrectedTauMatches > 0);
156  std::cout << "[" << entry << "] " << resurrectedTauMatches
157  << " taus matched with (resurrected) "
158  << prescaledTauTrigger << std::endl;
159  }
160 
161  if (tauTriggered)
162  {
163  tauEvents.first++;
164  tauEvents.second += (tauMatches > 0);
165  std::cout << "[" << entry << "] " << tauMatches << " taus matched with "
166  << tauTrigger << std::endl;
167  }
168 
169  if (diTauTriggered)
170  {
171  diTauEvents.first++;
172  diTauEvents.second += (diTauMatches > 1);
173  std::cout << "[" << entry << "] " << diTauMatches << " taus matched with "
174  << diTauTrigger << std::endl;
175  }
176  }
177 
178  std::cout << prescaledTauEvents.second << "/" << prescaledTauEvents.first
179  << " events for " << prescaledTauTrigger << std::endl;
180  std::cout << resurrectedTauEvents.second << "/" << resurrectedTauEvents.first
181  << " resurrected events for " << prescaledTauTrigger << std::endl;
182  std::cout << tauEvents.second << "/" << tauEvents.first << " events for "
183  << tauTrigger << std::endl;
184  std::cout << diTauEvents.second << "/" << diTauEvents.first << " events for "
185  << diTauTrigger << std::endl;
186 }

Variable Documentation

◆ APP_NAME

const char* APP_NAME = "TrigTauMatching_example"

Definition at line 32 of file util/TrigTauMatching_example.cxx.

◆ diTauTrigger

const std::string diTauTrigger = "HLT_tau35_medium1_tracktwo_tau25_medium1_tracktwo"

Definition at line 37 of file util/TrigTauMatching_example.cxx.

◆ prescaledTauTrigger

const std::string prescaledTauTrigger = "L1_TAU12IM"

Definition at line 35 of file util/TrigTauMatching_example.cxx.

◆ tauTrigger

const std::string tauTrigger = "HLT_tau125_medium1_tracktwo"

Definition at line 36 of file util/TrigTauMatching_example.cxx.

store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
RETURN_CHECK
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Definition: ReturnCheck.h:26
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
Trig::TrigTauMatchingTool
Definition: TrigTauMatching.h:21
skel.it
it
Definition: skel.GENtoEVGEN.py:423
xAOD::TauJetParameters::JetBDTSigMedium
@ JetBDTSigMedium
Definition: TauDefs.h:137
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:97
Trig::TrigDecisionTool
Definition: TrigDecisionTool.h:65
POOL::TEvent::readFrom
StatusCode readFrom(TFile *file)
Definition: PhysicsAnalysis/POOLRootAccess/src/TEvent.cxx:132
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
prescaledTauTrigger
const std::string prescaledTauTrigger
Definition: util/TrigTauMatching_example.cxx:35
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
getFilesFromCommandLine
std::unique_ptr< TChain > getFilesFromCommandLine(int argc, char *argv[])
Definition: util/TrigTauMatching_example.cxx:188
POOL::TEvent::retrieve
StatusCode retrieve(const T *&obj)
Definition: PhysicsAnalysis/POOLRootAccess/POOLRootAccess/TEvent.h:73
ASG_CHECK_SA
#define ASG_CHECK_SA(SOURCE, EXP)
Helper macro for checking the status code of a call outside of an ASG tool.
Definition: Check.h:69
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
diTauTrigger
const std::string diTauTrigger
Definition: util/TrigTauMatching_example.cxx:37
tauTrigger
const std::string tauTrigger
Definition: util/TrigTauMatching_example.cxx:36
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:81
APP_NAME
const char * APP_NAME
Definition: util/TrigTauMatching_example.cxx:32
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31
TrigConf::xAODConfigTool
Trigger configuration metadata tool for xAOD analysis.
Definition: xAODConfigTool.h:55