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