|
| 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 | +/// @author Kaare Endrup Iversen |
| 12 | +// Contact: iarsene@cern.ch, i.c.arsene@fys.uio.no |
| 13 | +// |
| 14 | +#include "PWGDQ/Core/AnalysisCompositeCut.h" |
| 15 | +#include "PWGDQ/Core/AnalysisCut.h" |
| 16 | +#include "PWGDQ/Core/VarManager.h" |
| 17 | +#include "PWGDQ/DataModel/ReducedInfoTables.h" |
| 18 | + |
| 19 | +#include <CCDB/BasicCCDBManager.h> |
| 20 | +#include <CommonConstants/MathConstants.h> |
| 21 | +#include <Framework/AnalysisDataModel.h> |
| 22 | +#include <Framework/AnalysisHelpers.h> |
| 23 | +#include <Framework/AnalysisTask.h> |
| 24 | +#include <Framework/BinningPolicy.h> |
| 25 | +#include <Framework/Configurable.h> |
| 26 | +#include <Framework/HistogramRegistry.h> |
| 27 | +#include <Framework/HistogramSpec.h> |
| 28 | +#include <Framework/InitContext.h> |
| 29 | +#include <Framework/StringHelpers.h> |
| 30 | +#include <Framework/runDataProcessing.h> |
| 31 | + |
| 32 | +#include <sys/types.h> |
| 33 | + |
| 34 | +#include <RtypesCore.h> |
| 35 | + |
| 36 | +#include <chrono> |
| 37 | +#include <cmath> |
| 38 | +#include <cstdint> |
| 39 | +#include <memory> |
| 40 | +#include <string> |
| 41 | +#include <vector> |
| 42 | + |
| 43 | +using std::string; |
| 44 | + |
| 45 | +using namespace o2; |
| 46 | +using namespace o2::framework; |
| 47 | +using namespace o2::framework::expressions; |
| 48 | +using namespace o2::aod; |
| 49 | + |
| 50 | +// Some definitions |
| 51 | +namespace o2::aod |
| 52 | +{ |
| 53 | + |
| 54 | +namespace dqanalysisflags |
| 55 | +{ |
| 56 | +// DECLARE_SOA_COLUMN(IsEventSelected, isEventSelected, int); |
| 57 | +DECLARE_SOA_BITMAP_COLUMN(IsEventSelected, isEventSelected, 8); //! Event decision |
| 58 | +// DECLARE_SOA_COLUMN(IsMuonSelected, isMuonSelected, int); |
| 59 | +DECLARE_SOA_BITMAP_COLUMN(IsMuonSelected, isMuonSelected, 32); //! Muon track decisions (joinable to ReducedMuonsAssoc) |
| 60 | +} |
| 61 | + |
| 62 | +DECLARE_SOA_TABLE(EventCuts, "AOD", "DQANAEVCUTSA", dqanalysisflags::IsEventSelected); //! joinable to ReducedEvents |
| 63 | +DECLARE_SOA_TABLE(MuonTrackCuts, "AOD", "DQANAMUONCUTSA", dqanalysisflags::IsMuonSelected); //! joinable to ReducedMuonsAssoc |
| 64 | +} |
| 65 | + |
| 66 | +// Declarations of various short names |
| 67 | +using MyEvents = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended>; |
| 68 | +using MyEventsSelected = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended, aod::EventCuts>; |
| 69 | +using MyEventsVtxCov = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended, aod::ReducedEventsVtxCov>; |
| 70 | +using MyEventsVtxCovSelected = soa::Join<aod::ReducedEvents, aod::ReducedEventsExtended, aod::ReducedEventsVtxCov, aod::EventCuts>; |
| 71 | + |
| 72 | +using MyPairCandidatesSelected = soa::Join<aod::Dimuons, aod::DimuonsExtra>; |
| 73 | +using MyMuonTracks = soa::Join<aod::ReducedMuons, aod::ReducedMuonsExtra>; |
| 74 | +using MyMuonTracksSelected = soa::Join<aod::ReducedMuons, aod::ReducedMuonsExtra, aod::MuonTrackCuts>; |
| 75 | +using MyMuonTracksWithCov = soa::Join<aod::ReducedMuons, aod::ReducedMuonsExtra, aod::ReducedMuonsCov>; |
| 76 | +using MyMuonTracksSelectedWithCov = soa::Join<aod::ReducedMuons, aod::ReducedMuonsExtra, aod::ReducedMuonsCov, aod::MuonTrackCuts>; |
| 77 | + |
| 78 | +// bit maps used for the Fill functions of the VarManager |
| 79 | +constexpr static uint32_t gkEventFillMap = VarManager::ObjTypes::ReducedEvent | VarManager::ObjTypes::ReducedEventExtended; |
| 80 | +constexpr static uint32_t gkMuonFillMap = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::ReducedMuonExtra; |
| 81 | + |
| 82 | +struct DqJPsiMuonCorrelations { |
| 83 | + |
| 84 | + // Configurables for the dilepton and dilepton cuts |
| 85 | + Configurable<float> fConfigDileptonLowMass{"cfgDileptonLowMass", 2., "Low mass cut for the dileptons used in analysis"}; |
| 86 | + Configurable<float> fConfigDileptonHighMass{"cfgDileptonHighMass", 4., "High mass cut for the dileptons used in analysis"}; |
| 87 | + |
| 88 | + // Connect to ccdb |
| 89 | + Service<ccdb::BasicCCDBManager> ccdb; |
| 90 | + Configurable<int64_t> nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"}; |
| 91 | + Configurable<std::string> url{"ccdb-url", "http://ccdb-test.cern.ch:8080", "url of the ccdb repository"}; |
| 92 | + |
| 93 | + // Define the filter for events |
| 94 | + Filter eventFilter = aod::dqanalysisflags::isEventSelected == 1; |
| 95 | + |
| 96 | + // Define the filter for the dileptons |
| 97 | + Filter dileptonFilter = aod::reducedpair::sign == 0; |
| 98 | + |
| 99 | + constexpr static uint32_t fgDimuonsFillMap = VarManager::ObjTypes::ReducedMuon | VarManager::ObjTypes::Pair; // fill map |
| 100 | + |
| 101 | + // use two values array to avoid mixing up the quantities |
| 102 | + float* fValuesDilepton; |
| 103 | + float* fValuesMuon; |
| 104 | + |
| 105 | + HistogramRegistry registry{"registry"}; |
| 106 | + |
| 107 | + void init(o2::framework::InitContext&) |
| 108 | + { |
| 109 | + ccdb->setURL(url.value); |
| 110 | + ccdb->setCaching(true); |
| 111 | + ccdb->setCreatedNotAfter(nolaterthan.value); |
| 112 | + |
| 113 | + fValuesDilepton = new float[VarManager::kNVars]; |
| 114 | + fValuesMuon = new float[VarManager::kNVars]; |
| 115 | + VarManager::SetDefaultVarNames(); |
| 116 | + |
| 117 | + LOG(info) << "Initialized DqJPsiMuonCorrelations task" << std::endl; |
| 118 | + } |
| 119 | + |
| 120 | + // Template function to run pair - muon combinations |
| 121 | + template <int TCandidateType, uint32_t TEventFillMap, uint32_t TMuonFillMap, typename TEvent, typename TMuons, typename TDileptons> |
| 122 | + void runDileptonMuon(TEvent const& event, TMuons const& muons, TDileptons const& dileptons) |
| 123 | + { |
| 124 | + // VarManager::ResetValues(0, VarManager::kNVars, fValuesHadron); |
| 125 | + VarManager::ResetValues(0, VarManager::kNVars, fValuesMuon); |
| 126 | + VarManager::ResetValues(0, VarManager::kNVars, fValuesDilepton); |
| 127 | + VarManager::FillEvent<TEventFillMap>(event, fValuesMuon); |
| 128 | + VarManager::FillEvent<TEventFillMap>(event, fValuesDilepton); |
| 129 | + |
| 130 | + if (dileptons.size() > 0) { |
| 131 | + LOG(info) << "Dileptons in event: " << dileptons.size() << std::endl; |
| 132 | + } else { |
| 133 | + LOG(info) << "No dileptons in event" << std::endl; |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + void processSkimmedDimuon(MyEventsSelected::iterator const& event, MyMuonTracksSelected const& muons, soa::Filtered<MyPairCandidatesSelected> const& dileptons) |
| 138 | + { |
| 139 | + LOG(info) << "Processing event " << event.globalIndex() << " with " << muons.size() << " muons and " << dileptons.size() << " dileptons" << std::endl; |
| 140 | + runDileptonMuon<VarManager::kDecayToMuMu, gkEventFillMap, gkMuonFillMap>(event, muons, dileptons); |
| 141 | + } |
| 142 | + void processDummy(MyEvents&) |
| 143 | + { |
| 144 | + } |
| 145 | + |
| 146 | + PROCESS_SWITCH(DqJPsiMuonCorrelations, processSkimmedDimuon, "Run dilepton-muon pairing, using skimmed data", false); |
| 147 | + PROCESS_SWITCH(DqJPsiMuonCorrelations, processDummy, "Dummy function", false); |
| 148 | +}; |
| 149 | + |
| 150 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 151 | +{ |
| 152 | + return WorkflowSpec{ |
| 153 | + adaptAnalysisTask<DqJPsiMuonCorrelations>(cfgc)}; |
| 154 | +} |
0 commit comments