|
| 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 | +#include "Framework/runDataProcessing.h" |
| 13 | +#include "Framework/AnalysisTask.h" |
| 14 | +#include "Framework/HistogramRegistry.h" |
| 15 | +#include "Framework/ASoA.h" |
| 16 | +#include "Framework/Expressions.h" |
| 17 | +#include <CCDB/BasicCCDBManager.h> |
| 18 | + |
| 19 | +using namespace o2::framework; |
| 20 | +using namespace o2::framework::expressions; |
| 21 | +using namespace o2; |
| 22 | + |
| 23 | +// Output-table definition |
| 24 | +namespace o2::aod |
| 25 | +{ |
| 26 | +namespace trd::col |
| 27 | +{ |
| 28 | +DECLARE_SOA_COLUMN(Q00, q00, float); |
| 29 | +DECLARE_SOA_COLUMN(Q01, q01, float); |
| 30 | +DECLARE_SOA_COLUMN(Q02, q02, float); |
| 31 | +DECLARE_SOA_COLUMN(Q03, q03, float); |
| 32 | +DECLARE_SOA_COLUMN(Q04, q04, float); |
| 33 | +DECLARE_SOA_COLUMN(Q05, q05, float); |
| 34 | +DECLARE_SOA_COLUMN(Q10, q10, float); |
| 35 | +DECLARE_SOA_COLUMN(Q11, q11, float); |
| 36 | +DECLARE_SOA_COLUMN(Q12, q12, float); |
| 37 | +DECLARE_SOA_COLUMN(Q13, q13, float); |
| 38 | +DECLARE_SOA_COLUMN(Q14, q14, float); |
| 39 | +DECLARE_SOA_COLUMN(Q15, q15, float); |
| 40 | +DECLARE_SOA_COLUMN(Q20, q20, float); |
| 41 | +DECLARE_SOA_COLUMN(Q21, q21, float); |
| 42 | +DECLARE_SOA_COLUMN(Q22, q22, float); |
| 43 | +DECLARE_SOA_COLUMN(Q23, q23, float); |
| 44 | +DECLARE_SOA_COLUMN(Q24, q24, float); |
| 45 | +DECLARE_SOA_COLUMN(Q25, q25, float); |
| 46 | +DECLARE_SOA_COLUMN(Pt, pt, float); |
| 47 | +} // namespace trd::col |
| 48 | +DECLARE_SOA_TABLE(TRDPID, "AOD", "TRDPID", o2::soa::Index<>, |
| 49 | + trd::col::Q00, trd::col::Q01, trd::col::Q02, trd::col::Q03, trd::col::Q04, trd::col::Q05, |
| 50 | + trd::col::Q10, trd::col::Q11, trd::col::Q12, trd::col::Q13, trd::col::Q14, trd::col::Q15, |
| 51 | + trd::col::Q20, trd::col::Q21, trd::col::Q22, trd::col::Q23, trd::col::Q24, trd::col::Q25, |
| 52 | + trd::col::Pt); |
| 53 | +} // namespace o2::aod |
| 54 | + |
| 55 | +struct TRDPIDStudy { |
| 56 | + Produces<aod::TRDPID> pidTable; |
| 57 | + HistogramRegistry mRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 58 | + |
| 59 | + // Config |
| 60 | + Configurable<bool> mFilterNeighbors{"filterNeighbors", true, "Filter tracklets with neighbors"}; |
| 61 | + Configurable<bool> mFilterCrossings{"filterCrossings", true, "Filter tracklets crossing pads"}; |
| 62 | + Configurable<size_t> mMinTracklets{"minTracklets", 4, "Minimum number of tracklets"}; |
| 63 | + Configurable<float> mMinPt{"minPt", 0.1, "Minimum track-pt required"}; |
| 64 | + Configurable<float> mMaxPt{"maxPt", 20, "Maximum track-pt allowed"}; |
| 65 | + |
| 66 | + using Tracks = soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksCovIU>; |
| 67 | + |
| 68 | + void init(InitContext& /*ctx*/) |
| 69 | + { |
| 70 | + mRegistry.add("Q0", "Q0", HistType::kTH1F, {{127, 0, 127}}); |
| 71 | + mRegistry.add("Q1", "Q1", HistType::kTH1F, {{127, 0, 127}}); |
| 72 | + mRegistry.add("Q2", "Q2", HistType::kTH1F, {{127, 0, 127}}); |
| 73 | + mRegistry.add("QTot", "QTot", HistType::kTH1F, {{300, 0, 300}}); |
| 74 | + mRegistry.add("Q0Cor", "Q0Cor", HistType::kTH1F, {{127, 0, 127}}); |
| 75 | + mRegistry.add("Q1Cor", "Q1Cor", HistType::kTH1F, {{127, 0, 127}}); |
| 76 | + mRegistry.add("Q2Cor", "Q2Cor", HistType::kTH1F, {{127, 0, 127}}); |
| 77 | + mRegistry.add("QTotCor", "QTotCor", HistType::kTH1F, {{300, 0, 300}}); |
| 78 | + } |
| 79 | + |
| 80 | + void process(Tracks const& tracks, aod::TRDsExtra const& trdExtra) |
| 81 | + { |
| 82 | + for (const auto& trd : trdExtra) { |
| 83 | + const auto& track = tracks.rawIteratorAt(trd.trackId()); |
| 84 | + std::bitset<6> good; |
| 85 | + if (!filterTrack(track, trd, good)) { |
| 86 | + continue; |
| 87 | + } |
| 88 | + |
| 89 | + const auto& q0s = trd.trdQ0s(); |
| 90 | + const auto& q1s = trd.trdQ1s(); |
| 91 | + const auto& q2s = trd.trdQ2s(); |
| 92 | + const auto& q0sCor = trd.trdQ0sCorrected(); |
| 93 | + const auto& q1sCor = trd.trdQ1sCorrected(); |
| 94 | + const auto& q2sCor = trd.trdQ2sCorrected(); |
| 95 | + |
| 96 | + for (int i{0}; i < 6; ++i) { |
| 97 | + if (!good[i]) { |
| 98 | + continue; |
| 99 | + } |
| 100 | + |
| 101 | + mRegistry.fill(HIST("Q0"), q0s[i]); |
| 102 | + mRegistry.fill(HIST("Q1"), q1s[i]); |
| 103 | + mRegistry.fill(HIST("Q2"), q2s[i]); |
| 104 | + mRegistry.fill(HIST("QTot"), q0s[i] + q1s[i] + q2s[i]); |
| 105 | + mRegistry.fill(HIST("Q0Cor"), q0sCor[i]); |
| 106 | + mRegistry.fill(HIST("Q1Cor"), q1sCor[i]); |
| 107 | + mRegistry.fill(HIST("Q2Cor"), q2sCor[i]); |
| 108 | + mRegistry.fill(HIST("QTotCor"), q0sCor[i] + q1sCor[i] + q2sCor[i]); |
| 109 | + } |
| 110 | + |
| 111 | + pidTable( |
| 112 | + q0sCor[0], q0sCor[1], q0sCor[2], q0sCor[3], q0sCor[4], q0sCor[5], |
| 113 | + q1sCor[0], q1sCor[1], q1sCor[2], q1sCor[3], q1sCor[4], q1sCor[5], |
| 114 | + q2sCor[0], q2sCor[1], q2sCor[2], q2sCor[3], q2sCor[4], q2sCor[5], |
| 115 | + track.pt()); |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + template <typename Track, typename TRD> |
| 120 | + bool filterTrack(Track const& trk, TRD const& trd, std::bitset<6>& good) |
| 121 | + { |
| 122 | + if (trk.trdNTracklets() < mMinTracklets) { |
| 123 | + return false; |
| 124 | + } |
| 125 | + if (trk.trdHasNeighbor()) { |
| 126 | + return false; |
| 127 | + } |
| 128 | + if (trk.trdHasCrossing()) { |
| 129 | + return false; |
| 130 | + } |
| 131 | + const auto& q0s = trd.trdQ0s(); |
| 132 | + const auto& q1s = trd.trdQ0s(); |
| 133 | + const auto& q2s = trd.trdQ0s(); |
| 134 | + for (int i{0}; i < 6; ++i) { |
| 135 | + if ((trk.trdPattern() & (1 << i)) == 0) { |
| 136 | + continue; |
| 137 | + } |
| 138 | + if (q2s[i] >= 62 || q2s[i] < 6) { |
| 139 | + continue; |
| 140 | + } |
| 141 | + if (q1s[i] >= 127 || q1s[i] < 6) { |
| 142 | + continue; |
| 143 | + } |
| 144 | + if (q0s[0] >= 127 || q0s[0] < 6) { |
| 145 | + continue; |
| 146 | + } |
| 147 | + good.set(i); |
| 148 | + } |
| 149 | + |
| 150 | + return good.count() >= mMinTracklets; |
| 151 | + } |
| 152 | +}; |
| 153 | + |
| 154 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 155 | +{ |
| 156 | + return WorkflowSpec{ |
| 157 | + adaptAnalysisTask<TRDPIDStudy>(cfgc), |
| 158 | + }; |
| 159 | +} |
0 commit comments