|
| 1 | +// Copyright 2019-2024 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 taskFwdTrackPid.cxx |
| 13 | +/// \brief Task for the analysis of forward PID with MFT |
| 14 | +/// \author Luca Micheletti <luca.micheletti@to.infn.it>, INFN |
| 15 | + |
| 16 | +#include <iostream> |
| 17 | +#include <vector> |
| 18 | +#include <algorithm> |
| 19 | +#include <TH1F.h> |
| 20 | +#include <TH3F.h> |
| 21 | +#include <THashList.h> |
| 22 | +#include <TList.h> |
| 23 | +#include <TString.h> |
| 24 | +#include "CCDB/BasicCCDBManager.h" |
| 25 | +#include "DataFormatsParameters/GRPObject.h" |
| 26 | +#include "Framework/runDataProcessing.h" |
| 27 | +#include "Framework/AnalysisTask.h" |
| 28 | +#include "Framework/AnalysisDataModel.h" |
| 29 | +#include "Framework/ASoAHelpers.h" |
| 30 | +#include "PWGDQ/DataModel/ReducedInfoTables.h" |
| 31 | +#include "PWGDQ/Core/VarManager.h" |
| 32 | +#include "PWGDQ/Core/HistogramManager.h" |
| 33 | +#include "PWGDQ/Core/MixingHandler.h" |
| 34 | +#include "PWGDQ/Core/AnalysisCut.h" |
| 35 | +#include "PWGDQ/Core/AnalysisCompositeCut.h" |
| 36 | +#include "PWGDQ/Core/HistogramsLibrary.h" |
| 37 | +#include "PWGDQ/Core/CutsLibrary.h" |
| 38 | +#include "PWGDQ/Core/MixingLibrary.h" |
| 39 | +#include "DataFormatsParameters/GRPMagField.h" |
| 40 | +#include "Field/MagneticField.h" |
| 41 | +#include "TGeoGlobalMagField.h" |
| 42 | +#include "DetectorsBase/Propagator.h" |
| 43 | +#include "DetectorsBase/GeometryManager.h" |
| 44 | +#include "ITSMFTBase/DPLAlpideParam.h" |
| 45 | +#include "Common/CCDB/EventSelectionParams.h" |
| 46 | + |
| 47 | +using namespace o2; |
| 48 | +using namespace o2::framework; |
| 49 | +using namespace o2::framework::expressions; |
| 50 | + |
| 51 | +// Some definitions |
| 52 | +namespace o2::aod |
| 53 | +{ |
| 54 | + |
| 55 | +namespace dqanalysisflags |
| 56 | +{ |
| 57 | +// TODO: the barrel amd muon selection columns are bit maps so unsigned types should be used, however, for now this is not supported in Filter expressions |
| 58 | +// TODO: For now in the tasks we just statically convert from unsigned int to int, which should be fine as long as we do |
| 59 | +// not use a large number of bits (>=30) |
| 60 | +// Bcandidate columns for ML analysis of B->Jpsi+K |
| 61 | +DECLARE_SOA_COLUMN(MixingHash, mixingHash, int); |
| 62 | +DECLARE_SOA_COLUMN(IsEventSelected, isEventSelected, int); |
| 63 | +DECLARE_SOA_COLUMN(IsBarrelSelected, isBarrelSelected, int); |
| 64 | +DECLARE_SOA_COLUMN(IsMuonSelected, isMuonSelected, int); |
| 65 | +DECLARE_SOA_COLUMN(IsBarrelSelectedPrefilter, isBarrelSelectedPrefilter, int); |
| 66 | +DECLARE_SOA_COLUMN(IsPrefilterVetoed, isPrefilterVetoed, int); |
| 67 | +DECLARE_SOA_COLUMN(massBcandidate, MBcandidate, float); |
| 68 | +DECLARE_SOA_COLUMN(pTBcandidate, PtBcandidate, float); |
| 69 | +DECLARE_SOA_COLUMN(LxyBcandidate, lxyBcandidate, float); |
| 70 | +DECLARE_SOA_COLUMN(LxyzBcandidate, lxyzBcandidate, float); |
| 71 | +DECLARE_SOA_COLUMN(LzBcandidate, lzBcandidate, float); |
| 72 | +DECLARE_SOA_COLUMN(TauxyBcandidate, tauxyBcandidate, float); |
| 73 | +DECLARE_SOA_COLUMN(TauzBcandidate, tauzBcandidate, float); |
| 74 | +DECLARE_SOA_COLUMN(CosPBcandidate, cosPBcandidate, float); |
| 75 | +DECLARE_SOA_COLUMN(Chi2Bcandidate, chi2Bcandidate, float); |
| 76 | + |
| 77 | +// Xcandidate columns |
| 78 | +DECLARE_SOA_COLUMN(massXcandidate, MXcandidate, float); |
| 79 | +DECLARE_SOA_COLUMN(pTXcandidate, PtXcandidate, float); |
| 80 | +DECLARE_SOA_COLUMN(rapidityXcandidate, YXcandidate, float); |
| 81 | +DECLARE_SOA_COLUMN(etaXcandidate, EtaXcandidate, float); |
| 82 | +DECLARE_SOA_COLUMN(massJpsicandidate, MJpsicandidate, float); |
| 83 | +DECLARE_SOA_COLUMN(massDipioncandidate, MDipioncandidate, float); |
| 84 | +DECLARE_SOA_COLUMN(pTJpsicandidate, PtJpsicandidate, float); |
| 85 | +DECLARE_SOA_COLUMN(pTDipioncandidate, PtDipioncandidate, float); |
| 86 | +DECLARE_SOA_COLUMN(massDiff, Q, float); |
| 87 | +DECLARE_SOA_COLUMN(angDistPion1, DeltaR1, float); |
| 88 | +DECLARE_SOA_COLUMN(angDistPion2, DeltaR2, float); |
| 89 | +DECLARE_SOA_COLUMN(cosDileptonDipion, CosDileptonDipion, float); |
| 90 | +DECLARE_SOA_COLUMN(dcaxyPion1, DcaXYPion1, float); |
| 91 | +DECLARE_SOA_COLUMN(dcazPion1, DcaZPion1, float); |
| 92 | +DECLARE_SOA_COLUMN(dcaxyPion2, DcaXYPion2, float); |
| 93 | +DECLARE_SOA_COLUMN(dcazPion2, DcaZPion2, float); |
| 94 | +DECLARE_SOA_COLUMN(pTPion1, PtPion1, float); |
| 95 | +DECLARE_SOA_COLUMN(pTPion2, PtPion2, float); |
| 96 | +DECLARE_SOA_COLUMN(dileptonSign, DileptonSign, int); |
| 97 | +DECLARE_SOA_COLUMN(ditrackSign, DitrackSign, int); |
| 98 | + |
| 99 | +} // namespace dqanalysisflags |
| 100 | + |
| 101 | +DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTS", dqanalysisflags::IsEventSelected); |
| 102 | +DECLARE_SOA_TABLE(MixingHashes, "AOD", "DQANAMIXHASH", dqanalysisflags::MixingHash); |
| 103 | +DECLARE_SOA_TABLE(BarrelTrackCuts, "AOD", "DQANATRKCUTS", dqanalysisflags::IsBarrelSelected, dqanalysisflags::IsBarrelSelectedPrefilter); |
| 104 | +DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTS", dqanalysisflags::IsMuonSelected); |
| 105 | +DECLARE_SOA_TABLE(Prefilter, "AOD", "DQPREFILTER", dqanalysisflags::IsPrefilterVetoed); |
| 106 | +DECLARE_SOA_TABLE(BmesonCandidates, "AOD", "DQBMESONS", dqanalysisflags::massBcandidate, dqanalysisflags::pTBcandidate, dqanalysisflags::LxyBcandidate, dqanalysisflags::LxyzBcandidate, dqanalysisflags::LzBcandidate, dqanalysisflags::TauxyBcandidate, dqanalysisflags::TauzBcandidate, dqanalysisflags::CosPBcandidate, dqanalysisflags::Chi2Bcandidate); |
| 107 | +DECLARE_SOA_TABLE(XCandidates, "AOD", "DQX3872", dqanalysisflags::massXcandidate, dqanalysisflags::pTXcandidate, dqanalysisflags::rapidityXcandidate, dqanalysisflags::etaXcandidate, dqanalysisflags::massJpsicandidate, dqanalysisflags::massDipioncandidate, dqanalysisflags::pTJpsicandidate, dqanalysisflags::pTDipioncandidate, dqanalysisflags::massDiff, dqanalysisflags::angDistPion1, dqanalysisflags::angDistPion2, dqanalysisflags::cosDileptonDipion, dqanalysisflags::dcaxyPion1, dqanalysisflags::dcazPion1, dqanalysisflags::dcaxyPion2, dqanalysisflags::dcazPion2, dqanalysisflags::pTPion1, dqanalysisflags::pTPion2, dqanalysisflags::dileptonSign, dqanalysisflags::ditrackSign); |
| 108 | +} // namespace o2::aod |
| 109 | + |
| 110 | +using MyEvents = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended>; |
| 111 | +using MyEventsSelected = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended, aod::EventCuts>; |
| 112 | + |
| 113 | +using MyMuonTracks = soa::Join<aod::ReducedMuons, aod::ReducedMuonsExtra>; |
| 114 | +using MyMftTracks = soa::Join<aod::ReducedMFTs, aod::ReducedMFTsExtra>; |
| 115 | + |
| 116 | +// bit maps used for the Fill functions of the VarManager |
| 117 | +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended; |
| 118 | +constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra; |
| 119 | + |
| 120 | +struct taskFwdTrackPid { |
| 121 | + Produces<aod::FwdPidsAll> fwdPidAllList; |
| 122 | + |
| 123 | + Configurable<float> fConfigMaxDCA{"cfgMaxDCA", 0.5f, "Manually set maximum DCA of the track"}; |
| 124 | + |
| 125 | + void init(o2::framework::InitContext& context) |
| 126 | + { |
| 127 | + if (context.mOptions.get<bool>("processDummy")) { |
| 128 | + return; |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + // Template function to pair mft tracks and muon tracks |
| 133 | + template <bool TMatchedOnly, uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvent, typename Muons, typename MftTracks> |
| 134 | + void runFwdTrackPid(TEvent const& event, Muons const& muons, MftTracks const& mftTracks) |
| 135 | + { |
| 136 | + fwdPidAllList.reserve(1); |
| 137 | + for (const auto& muon : muons) { |
| 138 | + if (muon.has_matchMFTTrack() && muon.trackType() == 0 && TMath::Abs(muon.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(muon.fwdDcaY()) < fConfigMaxDCA) { |
| 139 | + auto mftTrack = muon.template matchMFTTrack_as<MyMftTracks>(); |
| 140 | + fwdPidAllList(muon.trackType(), event.posX(), event.posY(), event.posZ(), event.numContrib(), muon.pt(), muon.eta(), muon.phi(), muon.sign(), mftTrack.mftClusterSizesAndTrackFlags(), muon.fwdDcaX(), muon.fwdDcaY(), muon.chi2MatchMCHMID(), muon.chi2MatchMCHMFT()); |
| 141 | + } |
| 142 | + } |
| 143 | + if constexpr (TMatchedOnly == false) { |
| 144 | + for (const auto& mftTrack : mftTracks) { |
| 145 | + if (TMath::Abs(mftTrack.fwdDcaX()) < fConfigMaxDCA && TMath::Abs(mftTrack.fwdDcaY()) < fConfigMaxDCA) { |
| 146 | + fwdPidAllList(4, event.posX(), event.posY(), event.posZ(), event.numContrib(), mftTrack.pt(), mftTrack.eta(), mftTrack.phi(), mftTrack.sign(), mftTrack.mftClusterSizesAndTrackFlags(), mftTrack.fwdDcaX(), mftTrack.fwdDcaY(), -999, -999); |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | + } |
| 151 | + |
| 152 | + void processFwdPidMatched(MyEvents::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) |
| 153 | + { |
| 154 | + if (muons.size() > 0 && mftTracks.size() > 0) { |
| 155 | + runFwdTrackPid<false, gkEventFillMap, gkMuonFillMap>(event, muons, mftTracks); |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + void processFwdPidMatchedOnly(MyEvents::iterator const& event, MyMuonTracks const& muons, MyMftTracks const& mftTracks) |
| 160 | + { |
| 161 | + if (muons.size() > 0) { |
| 162 | + runFwdTrackPid<true, gkEventFillMap, gkMuonFillMap>(event, muons, mftTracks); |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + void processDummy(MyEvents&) |
| 167 | + { |
| 168 | + // do nothing |
| 169 | + } |
| 170 | + |
| 171 | + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatched, "Run MFT - muon track pairing filling tree with MFT and global tracks", false); |
| 172 | + PROCESS_SWITCH(taskFwdTrackPid, processFwdPidMatchedOnly, "Run MFT - muon track pairing filling tree with global tracks only", false); |
| 173 | + PROCESS_SWITCH(taskFwdTrackPid, processDummy, "Dummy function", false); |
| 174 | +}; // End of struct taskFwdTrackPid |
| 175 | + |
| 176 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 177 | +{ |
| 178 | + return WorkflowSpec{ |
| 179 | + adaptAnalysisTask<taskFwdTrackPid>(cfgc)}; |
| 180 | +} |
0 commit comments