Skip to content

Commit 4e6f70e

Browse files
jokonigjokonig
andauthored
[PWGEM] PhotonMeson: Add task for event normalization on derived data (#17875)
Co-authored-by: jokonig <jokonig@cern.ch>
1 parent 4620cb3 commit 4e6f70e

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

PWGEM/PhotonMeson/Tasks/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,8 @@ o2physics_add_dpl_workflow(emcal-mc-task
195195
SOURCES emcalMcTask.cxx
196196
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::PWGEMPhotonMesonCore
197197
COMPONENT_NAME Analysis)
198+
199+
o2physics_add_dpl_workflow(event-normalization-task
200+
SOURCES eventNormalizationTask.cxx
201+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
202+
COMPONENT_NAME Analysis)
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file eventNormalizationTask.cxx
13+
/// \brief task to produce histogram with event counter information
14+
/// \author Joshua Konig, joshua.konig@cern.ch
15+
16+
#include "PWGEM/PhotonMeson/DataModel/EventTables.h"
17+
18+
#include <Framework/AnalysisDataModel.h>
19+
#include <Framework/AnalysisTask.h>
20+
#include <Framework/Configurable.h>
21+
#include <Framework/HistogramRegistry.h>
22+
#include <Framework/HistogramSpec.h>
23+
#include <Framework/InitContext.h>
24+
#include <Framework/OutputObjHeader.h>
25+
#include <Framework/runDataProcessing.h>
26+
27+
#include <TH1.h>
28+
29+
#include <cstddef>
30+
#include <string>
31+
#include <vector>
32+
33+
using namespace o2;
34+
using namespace o2::aod;
35+
using namespace o2::framework;
36+
using namespace o2::framework::expressions;
37+
using namespace o2::soa;
38+
39+
struct EventNormalizationTask {
40+
41+
HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false};
42+
43+
void init(InitContext& /*context*/)
44+
{
45+
// Names derived from EventAcceptance bits in EventTables.h
46+
std::vector<std::string> vecLabelNames = {
47+
"all",
48+
"has MC coll",
49+
"good zVtx",
50+
"is FT0AND",
51+
"No TFB",
52+
"ITS ROFB",
53+
"Same bunch Pileup",
54+
"ZVtxFT0PV",
55+
"No coll in time range",
56+
"good track occi",
57+
"Good FT0 occupancy",
58+
"kTVXinEMC",
59+
"Good centrality",
60+
"Good RCT",
61+
"Good Sel8"};
62+
fRegistry.add("EventNormalization/hEventCounter", "Event Counter;category;#it{N}_{evt}", kTH1D, {{static_cast<int>(vecLabelNames.size()), -0.5, -0.5 + static_cast<int>(vecLabelNames.size())}}, false);
63+
for (size_t i = 0; i < vecLabelNames.size(); ++i) {
64+
fRegistry.get<TH1>(HIST("EventNormalization/hEventCounter"))->GetXaxis()->SetBinLabel(i + 1, vecLabelNames[i].c_str());
65+
}
66+
}
67+
68+
// Process function only takes the entries and fills them into the histogram. This is done per DF and not per collision
69+
void processNorm(o2::aod::PMEvSelBit const& evSelBit)
70+
{
71+
72+
auto vecEvSelBits = evSelBit.eventSelectionBit();
73+
for (size_t i = 0; i < vecEvSelBits.size(); ++i) {
74+
fRegistry.fill(HIST("EventNormalization/hEventCounter"), i, vecEvSelBits[i]);
75+
}
76+
}
77+
78+
PROCESS_SWITCH(EventNormalizationTask, processNorm, "run event normalization task", true);
79+
};
80+
81+
WorkflowSpec defineDataProcessing(ConfigContext const& context)
82+
{
83+
return WorkflowSpec{
84+
adaptAnalysisTask<EventNormalizationTask>(context, TaskName{"event-normalization-task"})};
85+
}

0 commit comments

Comments
 (0)