ATLAS Offline Software
AnalysisConfig_Ntuple.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
12 #ifndef TrigInDetAnalysisExample_AnalysisConfig_Ntuple_H
13 #define TrigInDetAnalysisExample_AnalysisConfig_Ntuple_H
14 
18 
20 
23 
24 // #include "AthenaMonitoring/AthMonitorAlgorithm.h"
26 
27 #include "TTree.h"
28 #include "TFile.h"
29 
30 #define endmsg endmsg
31 
32 class AnalysisConfig_Ntuple : public T_AnalysisConfig<AthReentrantAlgorithm> {
33 
34 public:
35 
36  // Full constructor: test/reference/selection
37  // - analysisInstanceName: the name of the analysis chain being created
38  // - xxxChainName: the name of the chain to be used as test/reference/selection; must be "StoreGate" in case of direct access to SG containers
39  // - xxxType: the type of tracks to be retrieved from the test/reference/selection chain or container
40  // - xxxKey: the key for tracks to be retrieved from the test/reference/selection chain or container
41  // - all standard operations are performed in loops over 0=test 1=reference 2=selection
42 
43  AnalysisConfig_Ntuple(const std::vector<std::string>& chainNames, std::string outputFileName="TrkNtuple.root",
44  double tauEtCutOffline=0.0, int TruthPdgId = 0, bool _keepAllEvents=false, int parentTruthPdgId = 0) :
46  "", "", "",
47  "", "", "",
48  "", "", "",
49  0, 0, 0,
50  0,
51  0 ),
52  m_event(0),
53  m_File(0),
54  m_Tree(0),
55  m_doOffline(false),
56  m_doVertices(false),
57  m_doMuons(false),
58  m_doMuonsSP(false),
59  m_muonType(),
60  m_muonIsLRT(),
64  m_tauType(),
65  m_tauProngs(),
66  m_vertexType(),
67  m_doBjets(false),
68  m_hasTruthMap(false),
69  m_tauEtCutOffline(tauEtCutOffline),
70  m_TruthPdgId(TruthPdgId),
71  m_finalised(true),
72  m_printInfo(true),
73  m_ptmin(0),
74  m_parentTruthPdgId(parentTruthPdgId)
75  {
78 
79  this->keepAllEvents( _keepAllEvents );
80 
81  for ( unsigned i=0 ; i<chainNames.size() ; i++ ) {
82 
83  if ( chainNames[i].empty() ) continue;
84 
85  ChainString chain(chainNames[i]);
86 
87  std::string cs = chain.head();
88 
89  if ( cs=="Offline" ) m_doOffline = true;
90  else if ( cs=="Truth" ) m_mcTruth = true;
91  else if ( cs=="Vertex" ) {
92  m_vertexType.push_back(chain.tail());
93  m_doVertices = true;
94  }
95  else if ( cs=="MuonsSP" ) m_doMuonsSP = true;
96  else if ( cs=="Muons" ){
97  m_muonType.push_back(chain.tail());
98  if (chain.roi() == "LRT") m_muonIsLRT.push_back(true);
99  else m_muonIsLRT.push_back(false);
100  }
101  else if ( cs=="Electrons" ) {
102  m_electronType.push_back(chain.tail());
103  m_rawElectrons.push_back(chain.roi());
104 
105  if (chain.roi() == "LRT") m_electronIsLRT.push_back(true); // more abuse
106  else m_electronIsLRT.push_back(false);
107  }
108  else if ( cs=="Taus" ) {
109  m_tauType.push_back(chain.tail());
110  m_tauProngs.push_back(chain.roi());
111  }
112  else if ( cs=="Bjets" ) m_doBjets = true;
113  else {
114 
115  if ( cs!="" && cs.find("HLT")==std::string::npos ) {
117  // if ( m_provider ) m_provider->msg(MSG::WARNING) << "Unknown chain type: " << cs << endmsg;
118  // else std::cout << "Unknown chain type: " << cs << std::endl;
119  continue;
120  }
121 
122  m_chainNames.push_back( chain );
123 
124  }
125  }
126 
127  m_event = new TIDA::Event();
129 
130  }
131 
132 
133 
137  if ( !m_finalised ) finalize();
138  delete m_event;
139  }
140 
141  void set_ptmin( double d=0 ) { m_ptmin=d; }
142 
144  std::vector<TrackTrigObject>& objects, const std::string& key="" );
145 
146 protected:
147 
148  virtual void loop();
149 
150  virtual void book();
151 
152  virtual void finalize();
153 
155 
157 
158  TFile* m_File;
159  TTree* m_Tree;
160  TDirectory* m_Dir;
161 
162  std::vector<ChainString> m_chainNames;
163 
166  bool m_doMuons;
168 
169  std::vector<std::string> m_muonType;
170  std::vector<bool> m_muonIsLRT;
171 
172  std::vector<std::string> m_electronType;
173  std::vector<std::string> m_rawElectrons;
174  std::vector<bool> m_electronIsLRT;
175 
176  std::vector<std::string> m_tauType;
177  std::vector<std::string> m_tauProngs;
178 
179  std::vector<std::string> m_vertexType;
180 
181  bool m_doBjets;
184 
185  std::string m_outputFileName;
186 
188 
190 
191  // bool m_keepAllEvents; // nw in base class
192 
194 
195  double m_ptmin;
196 
198 
199 };
200 
201 
202 
203 #endif // TrigInDetAnalysisExample_AnalysisConfig_Ntuple_H
204 
AnalysisConfig_Ntuple::get_jets
size_t get_jets(Trig::FeatureContainer::combination_const_iterator citr, std::vector< TrackTrigObject > &objects, const std::string &key="")
retrieve the jets from the Roi
Definition: AnalysisConfig_Ntuple.cxx:134
AnalysisConfig_Ntuple::m_TruthPdgId
int m_TruthPdgId
Definition: AnalysisConfig_Ntuple.h:187
Trig::FeatureContainer::combination_const_iterator
std::vector< Combination >::const_iterator combination_const_iterator
Definition: FeatureContainer.h:69
AnalysisConfig_Ntuple::set_ptmin
void set_ptmin(double d=0)
Definition: AnalysisConfig_Ntuple.h:141
T_AnalysisConfig< AthReentrantAlgorithm >::m_mcTruth
bool m_mcTruth
Definition: T_AnalysisConfig.h:986
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
LArConditions2Ntuple.objects
objects
Definition: LArConditions2Ntuple.py:58
TIDAEvent.h
Basic event class to contain a vector of chains for trigger analysis
AnalysisConfig_Ntuple::m_muonIsLRT
std::vector< bool > m_muonIsLRT
Definition: AnalysisConfig_Ntuple.h:170
AnalysisConfig_Ntuple::m_parentTruthPdgId
int m_parentTruthPdgId
Definition: AnalysisConfig_Ntuple.h:197
hist_file_dump.d
d
Definition: hist_file_dump.py:137
AnalysisConfig_Ntuple::m_vertexType
std::vector< std::string > m_vertexType
Definition: AnalysisConfig_Ntuple.h:179
TIDAVertex.h
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
AnalysisConfig_Ntuple::m_useBeamCondSvc
bool m_useBeamCondSvc
Definition: AnalysisConfig_Ntuple.h:154
AnalysisConfig_Ntuple::m_chainNames
std::vector< ChainString > m_chainNames
Definition: AnalysisConfig_Ntuple.h:162
ChainString
Definition: ChainString.h:23
T_AnalysisConfig.h
TIDA::Event
Definition: TIDAEvent.h:33
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
AnalysisConfig_Ntuple::m_electronIsLRT
std::vector< bool > m_electronIsLRT
Definition: AnalysisConfig_Ntuple.h:174
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
AnalysisConfig_Ntuple::m_Dir
TDirectory * m_Dir
Definition: AnalysisConfig_Ntuple.h:160
AnalysisConfig_Ntuple::finalize
virtual void finalize()
finalise the analysis - take ratios for efficiencies etc
Definition: AnalysisConfig_Ntuple.cxx:279
AnalysisConfig_Ntuple::m_muonType
std::vector< std::string > m_muonType
Definition: AnalysisConfig_Ntuple.h:169
lumiFormat.i
int i
Definition: lumiFormat.py:85
AnalysisConfig_Ntuple::m_Tree
TTree * m_Tree
Definition: AnalysisConfig_Ntuple.h:159
AnalysisConfig_Ntuple::loop
virtual void loop()
Definition: AnalysisConfig_Ntuple.cxx:174
AnalysisConfig_Ntuple::m_rawElectrons
std::vector< std::string > m_rawElectrons
Definition: AnalysisConfig_Ntuple.h:173
AnalysisConfig_Ntuple::AnalysisConfig_Ntuple
AnalysisConfig_Ntuple(const std::vector< std::string > &chainNames, std::string outputFileName="TrkNtuple.root", double tauEtCutOffline=0.0, int TruthPdgId=0, bool _keepAllEvents=false, int parentTruthPdgId=0)
Definition: AnalysisConfig_Ntuple.h:43
AnalysisConfig_Ntuple::m_printInfo
bool m_printInfo
Definition: AnalysisConfig_Ntuple.h:193
AnalysisConfig_Ntuple::m_tauProngs
std::vector< std::string > m_tauProngs
Definition: AnalysisConfig_Ntuple.h:177
AthReentrantAlgorithm.h
AnalysisConfig_Ntuple::m_finalised
bool m_finalised
Definition: AnalysisConfig_Ntuple.h:189
AnalysisConfig_Ntuple::m_doOffline
bool m_doOffline
Definition: AnalysisConfig_Ntuple.h:164
ChainString.h
AnalysisConfig_Ntuple::m_File
TFile * m_File
Definition: AnalysisConfig_Ntuple.h:158
AnalysisConfig_Ntuple::m_doMuons
bool m_doMuons
Definition: AnalysisConfig_Ntuple.h:166
AnalysisConfig_Ntuple::m_ptmin
double m_ptmin
Definition: AnalysisConfig_Ntuple.h:195
TrackParticle.h
AnalysisConfig_Ntuple::~AnalysisConfig_Ntuple
virtual ~AnalysisConfig_Ntuple()
Definition: AnalysisConfig_Ntuple.h:134
AnalysisConfig_Ntuple::book
virtual void book()
setup the analysis the analysis, retrieve the tools etc
Definition: AnalysisConfig_Ntuple.cxx:188
AnalysisConfig_Ntuple::m_event
TIDA::Event * m_event
Definition: AnalysisConfig_Ntuple.h:156
AnalysisConfig_Ntuple::m_doVertices
bool m_doVertices
Definition: AnalysisConfig_Ntuple.h:165
AnalysisConfig_Ntuple::m_tauType
std::vector< std::string > m_tauType
Definition: AnalysisConfig_Ntuple.h:176
AnalysisConfig_Ntuple::m_doBjets
bool m_doBjets
Definition: AnalysisConfig_Ntuple.h:181
T_AnalysisConfig< AthReentrantAlgorithm >::keepAllEvents
void keepAllEvents(bool b)
Definition: T_AnalysisConfig.h:274
AnalysisConfig_Ntuple::m_hasTruthMap
bool m_hasTruthMap
Definition: AnalysisConfig_Ntuple.h:182
AthenaPoolExample_Copy.outputFileName
string outputFileName
Definition: AthenaPoolExample_Copy.py:40
AnalysisConfig_Ntuple::m_tauEtCutOffline
bool m_tauEtCutOffline
Definition: AnalysisConfig_Ntuple.h:183
AnalysisConfig_Ntuple::m_doMuonsSP
bool m_doMuonsSP
Definition: AnalysisConfig_Ntuple.h:167
AnalysisConfig_Ntuple
Definition: AnalysisConfig_Ntuple.h:32
TrackParticleContainer.h
AnalysisConfig_Ntuple::m_outputFileName
std::string m_outputFileName
Definition: AnalysisConfig_Ntuple.h:185
AnalysisConfig_Ntuple::m_electronType
std::vector< std::string > m_electronType
Definition: AnalysisConfig_Ntuple.h:172
T_AnalysisConfig
Definition: T_AnalysisConfig.h:59
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37