@@ -165,18 +165,17 @@ mll_vars["lp4_up"]->Draw("same");
165
165
166
166
@section example-phys DAOD_PHYS
167
167
168
- - Note the manipulation of non-trivial data types (` xAOD::EventInfo ` , ` ConstDataVector< xAOD::MuonContainer> ` ) as columns!
168
+ - Note the manipulation of non-trivial data types (` xAOD::EventInfo ` , ` xAOD::MuonContainer ` ) as columns!
169
169
170
170
@cpp
171
- #include "AnalysisPlugins /Event.h"
172
- #include "AnalysisPlugins /Hist.h"
171
+ #include "qhep /Event.h"
172
+ #include "qhep /Hist.h"
173
173
174
174
#include <xAODEventInfo/EventInfo.h>
175
- #include <xAODMuon/MuonContainer .h>
175
+ #include <xAODEgamma/ElectronContainer .h>
176
176
177
177
using VecF = ROOT::RVec<float >;
178
178
using VecD = ROOT::RVec<double >;
179
- using TLV = TLorentzVector;
180
179
181
180
#include "queryosity/queryosity.h"
182
181
@@ -187,83 +186,108 @@ namespace column = queryosity::column;
187
186
namespace query = queryosity::query;
188
187
namespace systematic = queryosity::systematic;
189
188
190
- #include "TFile.h"
191
189
#include "TH1F.h"
192
- #include "TLorentzVector.h"
193
190
#include "TPad.h"
194
- #include "TTreeReader.h"
195
- #include "TTreeReaderValue.h"
196
- #include "TVector2.h"
191
+ #include "TCanvas.h"
197
192
#include <ROOT/RVec.hxx>
198
193
199
194
#include <chrono >
200
195
#include <iostream >
201
196
#include <memory >
202
197
#include <sstream >
203
198
204
- class MuonSelection
205
- : public column::definition<ConstDataVector< xAOD::MuonContainer > (
206
- xAOD::MuonContainer)> {
199
+ std::vector< std::string > daodFiles{
200
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000001.pool.root.1",
201
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000002.pool.root.1",
202
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000003.pool.root.1",
203
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000004.pool.root.1",
204
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000005.pool.root.1",
205
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000006.pool.root.1",
206
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000007.pool.root.1",
207
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000008.pool.root.1",
208
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000009.pool.root.1",
209
+ "/project/6001378/thpark/public/mc23_13p6TeV.601189.PhPy8EG_AZNLO_Zee.deriv.DAOD_PHYS.e8514_s4162_r14622_p5855/DAOD_PHYS.35010014._ 000010.pool.root.1"
210
+ };
211
+ std::string treeName = "CollectionTree";
212
+
213
+ float EventWeight(const xAOD::EventInfo &eventInfo) {
214
+ return eventInfo.mcEventWeight();
215
+ }
216
+
217
+ class ElectronSelection
218
+ : public column::definition<ConstDataVector< xAOD::ElectronContainer > (
219
+ xAOD::ElectronContainer)> {
207
220
public:
208
- MuonSelection(double etaMax) : m_etaMax(etaMax) {}
209
- virtual ~ MuonSelection() = default;
210
- virtual ConstDataVector< xAOD::MuonContainer >
211
- evaluate(column::observable< xAOD::MuonContainer > muons) const override {
212
- ConstDataVector< xAOD::MuonContainer > selMuons(SG::VIEW_ELEMENTS);
213
- for (const xAOD::Muon * mu : * muons) {
214
- if (TMath::Abs(mu->eta()) < 1.5) {
215
- selMuons.push_back(mu);
216
- }
221
+ ElectronSelection(double pT_min, double eta_max)
222
+ : m_pT_min(pT_min), m_eta_max(eta_max) {}
223
+ virtual ~ ElectronSelection() = default;
224
+ virtual ConstDataVector< xAOD::ElectronContainer > evaluate(
225
+ column::observable< xAOD::ElectronContainer > els) const override {
226
+ ConstDataVector< xAOD::ElectronContainer > els_sel(
227
+ SG::VIEW_ELEMENTS);
228
+ for (const xAOD::Electron * el : * els) {
229
+ if (el->pt() < m_pT_min)
230
+ continue;
231
+ if (TMath::Abs(el->eta()) > m_eta_max)
232
+ continue;
233
+ els_sel.push_back(el);
217
234
}
218
- return selMuons ;
235
+ return els_sel ;
219
236
}
220
237
221
238
protected:
222
- double m_etaMax;
239
+ double m_pT_min;
240
+ double m_eta_max;
223
241
};
224
242
225
- int main() {
243
+ bool AtLeastTwoElectrons(ConstDataVector< xAOD::ElectronContainer > const &els) {
244
+ return els.size() >= 2;
245
+ }
226
246
227
- dataflow df;
247
+ float DiElectronsMass(ConstDataVector< xAOD::ElectronContainer > const &els) {
248
+ return (els[ 0] ->p4() + els[ 1] ->p4()).M();
249
+ };
228
250
229
- std::vector< std::string > evnt_files{
230
- "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/ASG/DAOD_PHYS/p5169/"
231
- "mc20_13TeV.410470.PhPy8EG_A14_ttbar_hdamp258p75_nonallhad.deriv.DAOD_ "
232
- "PHYS.e6337_s3681_r13167_p5169/DAOD_PHYS.29445530._ 000001.pool.root.1"};
233
- auto ds = df.load(dataset::input<Event >(evnt_files, "CollectionTree"));
251
+ void analyze(unsigned int n) {
252
+ dataflow df(multithread::enable(n));
234
253
254
+ auto ds = df.load(dataset::input<Event >(daodFiles, treeName));
235
255
auto eventInfo = ds.read(dataset::column< xAOD::EventInfo > ("EventInfo"));
236
- auto allMuons = ds.read(dataset::column< xAOD::MuonContainer > ("Muons"));
237
- auto selMuons = df.define(column::definition<MuonSelection >(1.5),allMuons);
238
-
239
- auto getPts = [ ] (ConstDataVector< xAOD::MuonContainer > const &muons) {
240
- VecD pts; pts.reserve(muons.size());
241
- for (const xAOD::Muon * mu : muons) {
242
- pts.push_back(mu->pt());
243
- }
244
- return pts;
245
- };
246
- auto selMuonsPtMeV =
247
- df.define(column::expression(getPts),selMuons);
248
-
249
- auto toGeV = df.define(column::constant(1.0/1000.0));
250
- auto selMuonsPt = selMuonsPtMeV * toGeV;
251
-
252
- auto mcEventWeight = df.define(
253
- column::expression([ ] (const xAOD::EventInfo &eventInfo) {
254
- return eventInfo.mcEventWeight();
255
- }),eventInfo
256
- );
257
- auto mcEventWeighted = df.weight(mcEventWeight);
258
-
259
- auto selMuonsPtHist = df.make(query::plan<Hist<1, VecF>>("muons_pt", 100, 0, 100))
260
- .fill(selMuonsPt)
261
- .book(mcEventWeighted);
256
+ auto allElectrons =
257
+ ds.read(dataset::column< xAOD::ElectronContainer > ("Electrons"));
258
+
259
+ auto selectedElectrons =
260
+ df.define(column::definition<ElectronSelection >(10.0,1.5), allElectrons);
261
+ auto diElectronsMassMeV =
262
+ df.define(column::expression(DiElectronsMass), selectedElectrons);
263
+ auto toGeV = df.define(column::constant(1.0 / 1000.0));
264
+ auto diElectronsMassGeV = diElectronsMassMeV * toGeV;
265
+
266
+ auto eventWeight = df.define(column::expression(EventWeight), eventInfo);
267
+ auto atLeastTwoSelectedElectrons =
268
+ df.weight(eventWeight)
269
+ .filter(column::expression(AtLeastTwoElectrons), selectedElectrons);
270
+
271
+ auto selectedElectronsPtHist =
272
+ df.make(query::plan<Hist<1,float>>("diElectronMass", 100, 0, 500))
273
+ .fill(diElectronsMassGeV)
274
+ .book(atLeastTwoSelectedElectrons);
275
+
276
+ selectedElectronsPtHist->Draw();
277
+ gPad->SetLogy();
278
+ gPad->Print("el_pts.pdf");
279
+ }
262
280
263
- selMuonsPtHist->Draw();
264
- gPad->Print("muons_pt.pdf");
281
+ int main(int argc, char * argv[ ] ) {
282
+ int nthreads = 0;
283
+ if (argc==2) { nthreads=strtol(argv[ 1] , nullptr, 0); }
265
284
266
- return 0;
285
+ auto tic = std::chrono::steady_clock::now();
286
+ analyze(nthreads);
287
+ auto toc = std::chrono::steady_clock::now();
288
+ std::chrono::duration<double > elapsed_seconds = toc-tic;
289
+ std::cout << "elapsed time (" << nthreads << " threads) = " << elapsed_seconds.count() << "s"
290
+ << std::endl;
267
291
}
268
292
@endcpp
269
293
0 commit comments