|
| 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 kstarInOO.cxx |
| 13 | +/// \author Jimun Lee <jimun.lee@cern.ch> |
| 14 | + |
| 15 | +#include "PWGLF/DataModel/LFResonanceTables.h" |
| 16 | + |
| 17 | +#include "Common/Core/RecoDecay.h" |
| 18 | +#include "Common/Core/TrackSelection.h" |
| 19 | +#include "Common/Core/TrackSelectionDefaults.h" |
| 20 | +#include "Common/Core/trackUtilities.h" |
| 21 | +#include "Common/DataModel/EventSelection.h" |
| 22 | +#include "Common/DataModel/Multiplicity.h" |
| 23 | +#include "Common/DataModel/PIDResponse.h" |
| 24 | +#include "Common/DataModel/TrackSelectionTables.h" |
| 25 | + |
| 26 | +#include "CommonConstants/PhysicsConstants.h" |
| 27 | +#include "DataFormatsParameters/GRPObject.h" |
| 28 | +#include "Framework/ASoA.h" |
| 29 | +#include "Framework/ASoAHelpers.h" |
| 30 | +#include "Framework/AnalysisDataModel.h" |
| 31 | +#include "Framework/AnalysisTask.h" |
| 32 | +#include "Framework/HistogramRegistry.h" |
| 33 | +#include "Framework/runDataProcessing.h" |
| 34 | +#include "ReconstructionDataFormats/Track.h" |
| 35 | + |
| 36 | +#include "TF1.h" |
| 37 | +#include <TLorentzVector.h> |
| 38 | +#include <TVector2.h> |
| 39 | + |
| 40 | +#include <algorithm> |
| 41 | +#include <iostream> |
| 42 | +#include <string> |
| 43 | +#include <vector> |
| 44 | + |
| 45 | +using namespace o2; |
| 46 | +using namespace o2::framework; |
| 47 | +using namespace o2::framework::expressions; |
| 48 | + |
| 49 | +struct kstarInOO { |
| 50 | + SliceCache cache; |
| 51 | + HistogramRegistry OOhistos{"OOhistos", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 52 | + |
| 53 | + Configurable<std::string> cfgeventSelections{"cfgeventSelections", "sel8", "choose event selection"}; |
| 54 | + Configurable<std::string> cfgtrackSelections{"cfgtrackSelections", "globalTracks", "set track selections"}; |
| 55 | + |
| 56 | + Configurable<double> cfgtrkMinPt{"cfgtrkMinPt", 0.15, "set track min pT"}; |
| 57 | + Configurable<double> cfgtrkMaxEta{"cfgtrkMaxEta", 0.9, "set track max Eta"}; |
| 58 | + Configurable<double> cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; |
| 59 | + Configurable<double> cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; |
| 60 | + Configurable<bool> cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz |
| 61 | + Configurable<bool> cfgConnectedToPV{"cfgConnectedToPV", true, "PV contributor track selection"}; // PV Contriuibutor |
| 62 | + Configurable<bool> cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange) |
| 63 | + Configurable<double> cfgnFindableTPCClusters{"cfgnFindableTPCClusters", 50, "nFindable TPC Clusters"}; |
| 64 | + Configurable<double> cfgnTPCCrossedRows{"cfgnTPCCrossedRows", 70, "nCrossed TPC Rows"}; |
| 65 | + Configurable<double> cfgnRowsOverFindable{"cfgnRowsOverFindable", 1.2, "nRowsOverFindable TPC CLusters"}; |
| 66 | + Configurable<double> cfgnTPCChi2{"cfgnTPChi2", 4.0, "nTPC Chi2 per Cluster"}; |
| 67 | + Configurable<double> cfgnITSChi2{"cfgnITShi2", 36.0, "nITS Chi2 per Cluster"}; |
| 68 | + Configurable<int> cfgnTPCPID{"cfgnTPCPID", 4, "nTPC PID"}; |
| 69 | + Configurable<int> cfgnTOFPID{"cfgnTOFPID", 4, "nTOF PID"}; |
| 70 | + Configurable<float> cfgVtxCut{"cfgVtxCut", 10.0, "V_z cut selection"}; |
| 71 | + Configurable<int> cDebugLevel{"cDebugLevel", 0, "Resolution of Debug"}; |
| 72 | + |
| 73 | + void init(o2::framework::InitContext&) |
| 74 | + { |
| 75 | + // HISTOGRAMS |
| 76 | + const AxisSpec axisEta{30, -1.5, +1.5, "#eta"}; |
| 77 | + const AxisSpec axisPhi{200, -1, +7, "#phi"}; |
| 78 | + const AxisSpec PtAxis = {200, 0, 20.0}; |
| 79 | + const AxisSpec PIDAxis = {120, -6, 6}; |
| 80 | + |
| 81 | + OOhistos.add("nEvents", "nEvents", kTH1F, {{4, 0.0, 4.0}}); |
| 82 | + OOhistos.add("h_rawpT", "h_rawpT", kTH1F, {{1000, 0.0, 10.0}}); |
| 83 | + OOhistos.add("h_rawpT_Kaon", "h_rawpT_Kaon", kTH1F, {{1000, 0.0, 10.0}}); |
| 84 | + OOhistos.add("h_eta", "h_eta", kTH1F, {axisEta}); |
| 85 | + OOhistos.add("h_phi", "h_phi", kTH1F, {axisPhi}); |
| 86 | + |
| 87 | + OOhistos.add("QA_nSigma_pion_TPC", "QA_nSigma_pion_TPC", {HistType::kTH2F, {PtAxis, PIDAxis}}); |
| 88 | + OOhistos.add("QA_nSigma_pion_TOF", "QA_nSigma_pion_TOF", {HistType::kTH2F, {PtAxis, PIDAxis}}); |
| 89 | + OOhistos.add("QA_pion_TPC_TOF", "QA_pion_TPC_TOF", {HistType::kTH2F, {PIDAxis, PIDAxis}}); |
| 90 | + OOhistos.add("QA_nSigma_kaon_TPC", "QA_nSigma_kaon_TPC", {HistType::kTH2F, {PtAxis, PIDAxis}}); |
| 91 | + OOhistos.add("QA_nSigma_kaon_TOF", "QA_nSigma_kaon_TOF", {HistType::kTH2F, {PtAxis, PIDAxis}}); |
| 92 | + OOhistos.add("QA_kaon_TPC_TOF", "QA_kaon_TPC_TOF", {HistType::kTH2F, {PIDAxis, PIDAxis}}); |
| 93 | + |
| 94 | + } // end of init |
| 95 | + |
| 96 | + double massKa = o2::constants::physics::MassKPlus; |
| 97 | + double massPi = o2::constants::physics::MassPiMinus; |
| 98 | + |
| 99 | + using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::MultZeqs>; // , aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs |
| 100 | + using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, |
| 101 | + aod::pidTPCKa, aod::pidTOFKa, aod::pidTPCPi, aod::pidTOFPi>; |
| 102 | + |
| 103 | + //================================== |
| 104 | + // 0. Track quality cuts |
| 105 | + //================================== |
| 106 | + // for PID QA TrackType |
| 107 | + template <typename TrackType> |
| 108 | + bool trackSelection(const TrackType track) |
| 109 | + { |
| 110 | + |
| 111 | + if (track.pt() < cfgtrkMinPt) |
| 112 | + return false; |
| 113 | + |
| 114 | + if (std::abs(track.eta()) > cfgtrkMaxEta) |
| 115 | + return false; |
| 116 | + |
| 117 | + if (std::abs(track.dcaXY()) > cfgMaxDCArToPVcut) |
| 118 | + return false; |
| 119 | + |
| 120 | + if (std::abs(track.dcaZ()) > cfgMaxDCAzToPVcut) |
| 121 | + return false; |
| 122 | + |
| 123 | + if (cfgPrimaryTrack && !track.isPrimaryTrack()) |
| 124 | + return false; |
| 125 | + |
| 126 | + if (track.tpcNClsFindable() < cfgnFindableTPCClusters) |
| 127 | + return false; |
| 128 | + |
| 129 | + if (track.tpcNClsCrossedRows() < cfgnTPCCrossedRows) |
| 130 | + return false; |
| 131 | + |
| 132 | + if (track.tpcCrossedRowsOverFindableCls() > cfgnRowsOverFindable) |
| 133 | + return false; |
| 134 | + |
| 135 | + if (track.tpcChi2NCl() > cfgnTPCChi2) |
| 136 | + return false; |
| 137 | + |
| 138 | + if (track.itsChi2NCl() > cfgnITSChi2) |
| 139 | + return false; |
| 140 | + |
| 141 | + if (cfgConnectedToPV && !track.isPVContributor()) |
| 142 | + return false; |
| 143 | + |
| 144 | + return true; |
| 145 | + }; |
| 146 | + |
| 147 | + //--------------------------------------- |
| 148 | + // 1-2. Check whether it passes tpc&tof |
| 149 | + //--------------------------------------- |
| 150 | + // Kaon |
| 151 | + template <typename T> |
| 152 | + bool trackPIDKaon(const T& candidate, bool QA = false) |
| 153 | + { |
| 154 | + bool tpcPIDPassed{false}, tofPIDPassed{false}; |
| 155 | + // TPC |
| 156 | + if (QA) { |
| 157 | + OOhistos.fill(HIST("QA_nSigma_kaon_TPC"), candidate.pt(), candidate.tpcNSigmaKa()); |
| 158 | + OOhistos.fill(HIST("QA_nSigma_kaon_TOF"), candidate.pt(), candidate.tofNSigmaKa()); |
| 159 | + } |
| 160 | + if (std::abs(candidate.tpcNSigmaKa()) < cfgnTPCPID) |
| 161 | + tpcPIDPassed = true; |
| 162 | + |
| 163 | + // TOF |
| 164 | + if (candidate.hasTOF()) { |
| 165 | + if (std::abs(candidate.tofNSigmaKa()) < cfgnTOFPID) |
| 166 | + tofPIDPassed = true; |
| 167 | + else |
| 168 | + tofPIDPassed = true; |
| 169 | + } |
| 170 | + |
| 171 | + // TPC & TOF |
| 172 | + if (tpcPIDPassed && tofPIDPassed) |
| 173 | + return true; |
| 174 | + |
| 175 | + return false; |
| 176 | + } |
| 177 | + |
| 178 | + // Pion |
| 179 | + template <typename T> |
| 180 | + bool trackPIDPion(const T& candidate) |
| 181 | + { |
| 182 | + bool tpcPIDPassed{false}, tofPIDPassed{false}; |
| 183 | + if (std::abs(candidate.tpcNSigmaPi()) < cfgnTPCPID) |
| 184 | + tpcPIDPassed = true; |
| 185 | + |
| 186 | + if (candidate.hasTOF()) { |
| 187 | + if (std::abs(candidate.tofNSigmaPi()) < cfgnTOFPID) |
| 188 | + tofPIDPassed = true; |
| 189 | + else |
| 190 | + tofPIDPassed = true; |
| 191 | + } |
| 192 | + |
| 193 | + if (tpcPIDPassed && tofPIDPassed) |
| 194 | + return true; |
| 195 | + |
| 196 | + return false; |
| 197 | + } |
| 198 | + |
| 199 | + //================================ |
| 200 | + // 3. Basic PID QA (Pion, Kaon) |
| 201 | + //================================ |
| 202 | + // template <typename TrackType> |
| 203 | + // void fillHistograms(TrackType const& dTracks1, TrackType const& dTracks2) |
| 204 | + // { |
| 205 | + // for (auto& [trk1, trk2] : combinations(CombinationsFullIndexPolicy(dTracks1, dTracks2))) |
| 206 | + // { |
| 207 | + // // Full index policy is needed to consider all possible combinations |
| 208 | + // if (trk1.index() == trk2.index()) |
| 209 | + // continue; // We need to run (0,1), (1,0) pairs as well. but same id pairs are not needed. |
| 210 | + |
| 211 | + // //// Initialize variables |
| 212 | + // // trk1: Pion, trk2: Kaon |
| 213 | + // // apply the track cut |
| 214 | + // if (!trackSelection(trk1) || !trackSelection(trk2)) |
| 215 | + // continue; |
| 216 | + |
| 217 | + // auto isTrk1hasTOF = trk1.hasTOF(); |
| 218 | + // auto isTrk2hasTOF = trk2.hasTOF(); |
| 219 | + // auto trk1ptPi = trk1.pt(); |
| 220 | + // auto trk1NSigmaPiTPC = trk1.tpcNSigmaPi(); |
| 221 | + // auto trk1NSigmaPiTOF = (isTrk1hasTOF) ? trk1.tofNSigmaPi() : -999.; |
| 222 | + // auto trk2ptKa = trk2.pt(); |
| 223 | + // auto trk2NSigmaKaTPC = trk2.tpcNSigmaKa(); |
| 224 | + // auto trk2NSigmaKaTOF = (isTrk2hasTOF) ? trk2.tofNSigmaKa() : -999.; |
| 225 | + |
| 226 | + // if (!trackPIDPion(trk1) || !trackPIDKaon(trk2)) |
| 227 | + // continue; |
| 228 | + |
| 229 | + // // PID QA Pion |
| 230 | + // OOhistos.fill(HIST("QA_nSigma_pion_TPC"), trk1ptPi, trk1NSigmaPiTPC); |
| 231 | + // OOhistos.fill(HIST("QA_nSigma_pion_TOF"), trk1ptPi, trk1NSigmaPiTOF); |
| 232 | + // OOhistos.fill(HIST("QA_pion_TPC_TOF"), trk1NSigmaPiTOF, trk1NSigmaPiTPC); |
| 233 | + |
| 234 | + // // PID QA Kaon |
| 235 | + // OOhistos.fill(HIST("QA_nSigma_kaon_TPC"), trk2ptKa, trk2NSigmaKaTPC); |
| 236 | + // OOhistos.fill(HIST("QA_nSigma_kaon_TOF"), trk2ptKa, trk2NSigmaKaTOF); |
| 237 | + // OOhistos.fill(HIST("QA_kaon_TPC_TOF"), trk2NSigmaKaTOF, trk2NSigmaKaTPC); |
| 238 | + // } |
| 239 | + // } |
| 240 | + |
| 241 | + //================================= |
| 242 | + // 1. nEvents Selection |
| 243 | + //================================= |
| 244 | + int nprocessEvents = 0; |
| 245 | + void processEvents(EventCandidates::iterator const& collision, TrackCandidates const& tracks) |
| 246 | + { |
| 247 | + // 1. All events |
| 248 | + if (cDebugLevel > 0) { |
| 249 | + nprocessEvents++; |
| 250 | + if ((nprocessEvents + 1) % 10000 == 0) { |
| 251 | + std::cout << "Processed Events: " << nprocessEvents << std::endl; |
| 252 | + } |
| 253 | + } |
| 254 | + OOhistos.fill(HIST("nEvents"), 0.5); |
| 255 | + if (std::fabs(collision.posZ()) > cfgVtxCut) |
| 256 | + return; |
| 257 | + |
| 258 | + // 2. The events passed a condition |
| 259 | + bool INELgt0 = false; |
| 260 | + for (const auto& track : tracks) { |
| 261 | + if (std::fabs(track.eta()) < cfgtrkMaxEta) { |
| 262 | + INELgt0 = true; |
| 263 | + break; |
| 264 | + } |
| 265 | + } |
| 266 | + if (!INELgt0) // not INEL |
| 267 | + return; |
| 268 | + |
| 269 | + OOhistos.fill(HIST("nEvents"), 1.5); |
| 270 | + |
| 271 | + //===================================== |
| 272 | + // 2. Basic track QA ( pt, phi, eta ) |
| 273 | + //===================================== |
| 274 | + for (auto& track : tracks) { |
| 275 | + // auto originalTrack = track_as<TrackCandidates>(); |
| 276 | + |
| 277 | + if (!trackSelection(track)) |
| 278 | + continue; |
| 279 | + |
| 280 | + OOhistos.fill(HIST("h_rawpT"), track.pt()); |
| 281 | + OOhistos.fill(HIST("h_eta"), track.eta()); |
| 282 | + OOhistos.fill(HIST("h_phi"), track.phi()); |
| 283 | + |
| 284 | + if (!trackPIDKaon(track, true)) // Once it sets the value is true, but later, should be change to false |
| 285 | + continue; |
| 286 | + |
| 287 | + OOhistos.fill(HIST("h_rawpT_Kaon"), track.pt()); |
| 288 | + } |
| 289 | + } |
| 290 | + PROCESS_SWITCH(kstarInOO, processEvents, "Jimun Code Go!", true); |
| 291 | + |
| 292 | + void processEventsDummy(EventCandidates::iterator const&, TrackCandidates const&) |
| 293 | + { |
| 294 | + return; |
| 295 | + } |
| 296 | + PROCESS_SWITCH(kstarInOO, processEventsDummy, "dummy", false); |
| 297 | + |
| 298 | +}; // kstarInOO |
| 299 | + |
| 300 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 301 | +{ |
| 302 | + return WorkflowSpec{adaptAnalysisTask<kstarInOO>(cfgc)}; |
| 303 | +}; |
0 commit comments