-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimpleAnalysis.cxx
149 lines (133 loc) · 5.48 KB
/
simpleAnalysis.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/HistogramRegistry.h"
#include <TH1F.h>
#include <TParameter.h>
#include <cmath>
using namespace o2;
using namespace o2::framework;
struct SimpleHistogramTaskWithRuntimeDefinition {
HistogramRegistry registry{"registry", {}};
void init(InitContext&)
{
std::vector<double> ptBinning = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0,
1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 5.0, 10.0, 20.0, 50.0};
AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/c)"};
registry.add("pt", "pt", kTH1F, {ptAxis});
}
// aod::Track is an iterator over tracks table
// HIST() is a macro to parse the string and find appropriate histogram at compile time
void process(aod::Track const& track)
{
registry.get<TH1>(HIST("pt"))->Fill(track.pt());
}
};
struct SimpleHistogramTask {
HistogramRegistry registry{
"registry",
{
// name, title, hist type, vector of axes
// here each axis is defined as: {nBins, min, max, optional title, optional name}
// alternatively, for variable binning: {{binEdge1, binEdge2, ...}, optional title, optional name}
{"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, //
{"phi", "#varphi", {HistType::kTH1F, {{100, 0., 2. * M_PI}}}}, //
{"pt", "pt", {HistType::kTH1F, {{100, -0.01, 10.01, "#it{p}_{T} (GeV/c)"}}}}, //
{"ptVariableBinning", "pt", {HistType::kTH1F, {{ //
{0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, //
1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 5.0, 10.0, 20.0, 50.0},
"#it{p}_{T} (GeV/c)"}}}} //
} //
};
// aod::Track is an iterator over tracks table
void process(aod::Track const& track)
{
registry.get<TH1>(HIST("eta"))->Fill(track.eta());
registry.get<TH1>(HIST("phi"))->Fill(track.phi());
registry.get<TH1>(HIST("pt"))->Fill(track.pt());
registry.get<TH1>(HIST("ptVariableBinning"))->Fill(track.pt());
}
};
struct HistogramsWithFilters {
HistogramRegistry registry{
"registry",
{
{"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, //
{"ptToPt", "ptToPt", {HistType::kTH2F, {{100, -0.01, 10.01}, {100, -0.01, 10.01}}}} //
} //
};
// If we fill histograms with filters, we need to provide full tables
// aod::Tracks instead of aod::Track
void process(aod::Tracks const& tracks)
{
registry.fill<aod::track::Eta>(HIST("eta"), tracks, aod::track::eta > 0.0f);
registry.fill<aod::track::Pt, aod::track::Pt>(HIST("ptToPt"), tracks, aod::track::pt < 5.0f);
}
};
//start TPCvsPT ZCH
struct HistogramsWithTPC {
HistogramRegistry registry{
"registry",
{
{"TPCSignal", "TPC signal", {HistType::kTH2F, {{500, 0, 10, "pt"}, {1000, 0, 600, "tpc"}}}}//
} //
};
// If we fill histograms with filters, we need to provide full tables
// aod::Tracks instead of aod::Track
void process(aod::FullTrack const& track)
{
registry.fill(HIST("TPCSignal"), track.pt(), track.tpcSignal());
}
};
//end TPCvsPT ZCH
//start TOFvsPT ZCH
struct HistogramsWithTof {
HistogramRegistry registry{
"registry",
{
{"TOFSignal", "TOF signal", {HistType::kTH2F, {{500, 0, 10, "pt"}, {50000, 0, 50000, "tof"}}}}//
} //
};
// If we fill histograms with filters, we need to provide full tables
// aod::Tracks instead of aod::Track
void process(aod::FullTrack const& track)
{
registry.fill(HIST("TOFSignal"), track.pt(), track.tofSignal());
}
};
//end TOFvsPT ZCH
//start ETAvsPHI
struct HistogramEtaVsPhi{
HistogramRegistry registry{
"registry",
{
{"EtaVsPhi", "EtaVsPhi", {HistType::kTH2F, {{100, 0, 2*TMath::Pi(), "phi"}, {100, -1.2, 1.2, "eta"}}}}//
} //
};
// If we fill histograms with filters, we need to provide full tables
// aod::Tracks instead of aod::Track
void process(aod::FullTrack const& track)
{
registry.fill(HIST("EtaVsPhi"), track.phi(), track.eta());
}
};
//end EtavsPhi ZCH
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<SimpleHistogramTaskWithRuntimeDefinition>(cfgc),
adaptAnalysisTask<SimpleHistogramTask>(cfgc),
adaptAnalysisTask<HistogramsWithTPC>(cfgc),
adaptAnalysisTask<HistogramsWithTof>(cfgc),
adaptAnalysisTask<HistogramEtaVsPhi>(cfgc),
adaptAnalysisTask<HistogramsWithFilters>(cfgc)};
}