|
| 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 | + |
| 11 | +// O2 includes |
| 12 | +#include "ReconstructionDataFormats/Track.h" |
| 13 | +#include "Framework/AnalysisTask.h" |
| 14 | +#include "Framework/AnalysisDataModel.h" |
| 15 | +#include "Framework/ASoAHelpers.h" |
| 16 | +#include "AnalysisDataModel/PID/PIDResponse.h" |
| 17 | +#include "AnalysisDataModel/TrackSelectionTables.h" |
| 18 | + |
| 19 | +using namespace o2; |
| 20 | +using namespace o2::framework; |
| 21 | +using namespace o2::framework::expressions; |
| 22 | + |
| 23 | +void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions) |
| 24 | +{ |
| 25 | + std::vector<ConfigParamSpec> options{ |
| 26 | + {"add-tof-histos", VariantType::Int, 0, {"Generate TPC with TOF histograms"}}}; |
| 27 | + std::swap(workflowOptions, options); |
| 28 | +} |
| 29 | + |
| 30 | +#include "Framework/runDataProcessing.h" |
| 31 | + |
| 32 | +// FIXME: we should put this function in some common header so it has to be defined only once |
| 33 | +template <typename T> |
| 34 | +void makelogaxis(T h) |
| 35 | +{ |
| 36 | + const int nbins = h->GetNbinsX(); |
| 37 | + double binp[nbins + 1]; |
| 38 | + double max = h->GetXaxis()->GetBinUpEdge(nbins); |
| 39 | + double min = h->GetXaxis()->GetBinLowEdge(1); |
| 40 | + if (min <= 0) { |
| 41 | + min = 0.00001; |
| 42 | + } |
| 43 | + double lmin = TMath::Log10(min); |
| 44 | + double ldelta = (TMath::Log10(max) - lmin) / ((double)nbins); |
| 45 | + for (int i = 0; i < nbins; i++) { |
| 46 | + binp[i] = TMath::Exp(TMath::Log(10) * (lmin + i * ldelta)); |
| 47 | + } |
| 48 | + binp[nbins] = max + 1; |
| 49 | + h->GetXaxis()->Set(nbins, binp); |
| 50 | +} |
| 51 | + |
| 52 | +constexpr int Np = 9; |
| 53 | +struct TPCSpectraReferenceTask { |
| 54 | + static constexpr const char* pT[Np] = {"e", "#mu", "#pi", "K", "p", "d", "t", "^{3}He", "#alpha"}; |
| 55 | + static constexpr std::string_view hp[Np] = {"p/El", "p/Mu", "p/Pi", "p/Ka", "p/Pr", "p/De", "p/Tr", "p/He", "p/Al"}; |
| 56 | + static constexpr std::string_view hpt[Np] = {"pt/El", "pt/Mu", "pt/Pi", "pt/Ka", "pt/Pr", "pt/De", "pt/Tr", "pt/He", "pt/Al"}; |
| 57 | + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 58 | + |
| 59 | + void init(o2::framework::InitContext&) |
| 60 | + { |
| 61 | + histos.add("p/Unselected", "Unselected;#it{p} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); |
| 62 | + histos.add("pt/Unselected", "Unselected;#it{p}_{T} (GeV/#it{c})", kTH1F, {{100, 0, 20}}); |
| 63 | + for (int i = 0; i < Np; i++) { |
| 64 | + histos.add(hp[i].data(), Form("%s;#it{p} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); |
| 65 | + histos.add(hpt[i].data(), Form("%s;#it{p}_{T} (GeV/#it{c})", pT[i]), kTH1F, {{100, 0, 20}}); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + //Defining filters and input |
| 70 | + Configurable<float> cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; |
| 71 | + Configurable<float> cfgCutEta{"cfgCutEta", 0.8f, "Eta range for tracks"}; |
| 72 | + Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; |
| 73 | + Filter trackFilter = (nabs(aod::track::eta) < cfgCutEta) && (aod::track::isGlobalTrack == (uint8_t) true); |
| 74 | + |
| 75 | + Configurable<float> nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; |
| 76 | + |
| 77 | + template <std::size_t i, typename T> |
| 78 | + void fillParticleHistos(const T& track, const float nsigma[]) |
| 79 | + { |
| 80 | + if (abs(nsigma[i]) > nsigmacut.value) { |
| 81 | + return; |
| 82 | + } |
| 83 | + histos.fill(HIST(hp[i]), track.p()); |
| 84 | + histos.fill(HIST(hpt[i]), track.pt()); |
| 85 | + } |
| 86 | + |
| 87 | + using TrackCandidates = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::pidRespTPC, aod::TrackSelection>>; |
| 88 | + void process(TrackCandidates::iterator const& track) |
| 89 | + { |
| 90 | + const float nsigma[Np] = {track.tpcNSigmaEl(), track.tpcNSigmaMu(), track.tpcNSigmaPi(), |
| 91 | + track.tpcNSigmaKa(), track.tpcNSigmaPr(), track.tpcNSigmaDe(), |
| 92 | + track.tpcNSigmaTr(), track.tpcNSigmaHe(), track.tpcNSigmaAl()}; |
| 93 | + histos.fill(HIST("p/Unselected"), track.p()); |
| 94 | + histos.fill(HIST("pt/Unselected"), track.pt()); |
| 95 | + |
| 96 | + fillParticleHistos<0>(track, nsigma); |
| 97 | + fillParticleHistos<1>(track, nsigma); |
| 98 | + fillParticleHistos<2>(track, nsigma); |
| 99 | + fillParticleHistos<3>(track, nsigma); |
| 100 | + fillParticleHistos<4>(track, nsigma); |
| 101 | + fillParticleHistos<5>(track, nsigma); |
| 102 | + fillParticleHistos<6>(track, nsigma); |
| 103 | + fillParticleHistos<7>(track, nsigma); |
| 104 | + fillParticleHistos<8>(track, nsigma); |
| 105 | + } |
| 106 | +}; |
| 107 | + |
| 108 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 109 | +{ |
| 110 | + WorkflowSpec workflow{adaptAnalysisTask<TPCSpectraReferenceTask>("tpcspectra-task-skim-reference")}; |
| 111 | + return workflow; |
| 112 | +} |
0 commit comments