diff --git a/PWGMM/Lumi/Tasks/lumiStability.cxx b/PWGMM/Lumi/Tasks/lumiStability.cxx index edfb91ef6c3..0beb05681d0 100644 --- a/PWGMM/Lumi/Tasks/lumiStability.cxx +++ b/PWGMM/Lumi/Tasks/lumiStability.cxx @@ -16,6 +16,7 @@ #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include "Common/DataModel/EventSelection.h" #include "Common/DataModel/TrackSelectionTables.h" #include "Framework/ASoAHelpers.h" #include "DataFormatsFDD/Digit.h" @@ -23,7 +24,10 @@ using namespace o2; using namespace o2::framework; +using namespace o2::aod::evsel; + using BCsWithTimestamps = soa::Join; +using BCsRun3 = soa::Join; int nBCsPerOrbit = 3564; @@ -33,39 +37,42 @@ struct lumiStabilityTask { void init(InitContext const&) { - const AxisSpec axisFDDTriggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; - const AxisSpec axisFT0Triggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; - const AxisSpec axisFV0Triggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; + const AxisSpec axisTriggger{nBCsPerOrbit, -0.5f, nBCsPerOrbit - 0.5f}; // histo about triggers - histos.add("FDD/bcVertexTrigger", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcVertexTriggerCoincidence", "vertex trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcSCentralTrigger", "scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcSCentralTriggerCoincidence", "scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcVSCTrigger", "vertex and scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcVSCTriggerCoincidence", "vertex and scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcCentralTrigger", "central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcCentralTriggerCoincidence", "central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcVCTrigger", "vertex and central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisFDDTriggger}); - histos.add("FDD/bcVCTriggerCoincidence", "vertex and central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisFDDTriggger}); - - histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - histos.add("FT0/bcSCentralTrigger", "Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - histos.add("FT0/bcVSCTrigger", "vertex and Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - histos.add("FT0/bcCentralTrigger", "central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - histos.add("FT0/bcVCTrigger", "vertex and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - histos.add("FT0/bcSCentralCentralTrigger", "Scentral and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisFT0Triggger}); - - histos.add("FV0/bcOutTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisFV0Triggger}); - histos.add("FV0/bcInTrigger", "In trigger per BC (FV0);BC in V0; counts", kTH1F, {axisFV0Triggger}); - histos.add("FV0/bcSCenTrigger", "SCen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisFV0Triggger}); - histos.add("FV0/bcCenTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisFV0Triggger}); - histos.add("FV0/bcSCenCenTrigger", "SCen and Cen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisFV0Triggger}); + histos.add("FDD/bcVertexTrigger", "vertex trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcVertexTriggerCoincidence", "vertex trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcSCentralTrigger", "scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcSCentralTriggerCoincidence", "scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcVSCTrigger", "vertex and scentral trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcVSCTriggerCoincidence", "vertex and scentral trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcCentralTrigger", "central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcCentralTriggerCoincidence", "central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcVCTrigger", "vertex and central trigger per BC (FDD);BC in FDD; counts", kTH1F, {axisTriggger}); + histos.add("FDD/bcVCTriggerCoincidence", "vertex and central trigger per BC (FDD) with coincidences;BC in FDD; counts", kTH1F, {axisTriggger}); + + histos.add("FT0/bcVertexTrigger", "vertex trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + histos.add("FT0/bcSCentralTrigger", "Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + histos.add("FT0/bcVSCTrigger", "vertex and Scentral trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + histos.add("FT0/bcCentralTrigger", "central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + histos.add("FT0/bcVCTrigger", "vertex and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + histos.add("FT0/bcSCentralCentralTrigger", "Scentral and central trigger per BC (FT0);BC in FT0; counts", kTH1F, {axisTriggger}); + + histos.add("FV0/bcOutTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); + histos.add("FV0/bcInTrigger", "In trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); + histos.add("FV0/bcSCenTrigger", "SCen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); + histos.add("FV0/bcCenTrigger", "Out trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); + histos.add("FV0/bcSCenCenTrigger", "SCen and Cen trigger per BC (FV0);BC in V0; counts", kTH1F, {axisTriggger}); } bool checkAnyCoincidence(const std::vector& channels) { - std::map channelPairs = {{0, 4}, {1, 5}, {2, 6}, {4, 7}}; + constexpr std::pair pair0 = {0, 4}; + constexpr std::pair pair1 = {1, 5}; + constexpr std::pair pair2 = {2, 6}; + constexpr std::pair pair3 = {3, 7}; + constexpr std::array, 4> channelPairs = {pair0, pair1, pair2, pair3}; + // std::map channelPairs = {{0, 4}, {1, 5}, {2, 6}, {3, 7}}; for (const auto& pair : channelPairs) { if (std::find(channels.begin(), channels.end(), pair.first) != channels.end() && std::find(channels.begin(), channels.end(), pair.second) != channels.end()) { @@ -75,17 +82,59 @@ struct lumiStabilityTask { return false; } - void processFDDFT0(aod::FT0s const& ft0s, aod::FDDs const& fdds, aod::BCsWithTimestamps const&) + void processMain(aod::FT0s const& ft0s, aod::FDDs const& fdds, aod::FV0As const& fv0s, BCsRun3 const& bcs) { + int CountNormal(0), CountPastProtec(0); for (auto const& fdd : fdds) { - auto bc = fdd.bc_as(); - if (bc.timestamp() == false) { + auto bc = fdd.bc_as(); + if (bc.timestamp() == 0) { continue; } Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + int deltaIndex = 0; // backward move counts + int deltaBC = 0; // current difference wrt globalBC + int maxDeltaBC = 5; // maximum difference + bool pastActivityFDD = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() - deltaIndex < 0) { + break; + } + const auto& bc_past = bcs.iteratorAt(bc.globalIndex() - deltaIndex); + deltaBC = globalBC - bc_past.globalBC(); + if (deltaBC < maxDeltaBC) { + pastActivityFDD |= bc_past.has_fdd(); + } + } + deltaIndex = 0; + deltaBC = 0; + + bool futureActivityFDD = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() + deltaIndex >= bcs.size()) { + break; + } + const auto& bc_future = bcs.iteratorAt(bc.globalIndex() + deltaIndex); + deltaBC = bc_future.globalBC() - globalBC; + if (deltaBC < maxDeltaBC) { + futureActivityFDD |= bc_future.has_fdd(); + } + } + + CountNormal++; + if (pastActivityFDD == true || futureActivityFDD == true) { + CountPastProtec++; + continue; + } + /*if (pastActivityFDD == true) { + CountPastProtec++; + continue; + }*/ + std::bitset<8> fddTriggers = fdd.triggerMask(); bool vertex = fddTriggers[o2::fdd::Triggers::bitVertex]; bool scentral = fddTriggers[o2::fdd::Triggers::bitSCen]; @@ -144,14 +193,52 @@ struct lumiStabilityTask { } // loop over FDD events for (auto const& ft0 : ft0s) { - auto bc = ft0.bc_as(); - if (bc.timestamp() == false) { + auto bc = ft0.bc_as(); + if (bc.timestamp() == 0) { continue; } Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + int deltaIndex = 0; // backward move counts + int deltaBC = 0; // current difference wrt globalBC + int maxDeltaBC = 5; // maximum difference + bool pastActivityFT0 = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() - deltaIndex < 0) { + break; + } + const auto& bc_past = bcs.iteratorAt(bc.globalIndex() - deltaIndex); + deltaBC = globalBC - bc_past.globalBC(); + if (deltaBC < maxDeltaBC) { + pastActivityFT0 |= bc_past.has_ft0(); + } + } + deltaIndex = 0; + deltaBC = 0; + + bool futureActivityFT0 = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() + deltaIndex >= bcs.size()) { + break; + } + const auto& bc_future = bcs.iteratorAt(bc.globalIndex() + deltaIndex); + deltaBC = bc_future.globalBC() - globalBC; + if (deltaBC < maxDeltaBC) { + futureActivityFT0 |= bc_future.has_ft0(); + } + } + + if (pastActivityFT0 == true || futureActivityFT0 == true) { + continue; + } + /*if (pastActivityFT0 == true) { + continue; + }*/ + std::bitset<8> fT0Triggers = ft0.triggerMask(); bool vertex = fT0Triggers[o2::fdd::Triggers::bitVertex]; @@ -179,21 +266,55 @@ struct lumiStabilityTask { } } } // loop over FT0 events - } // end processFDDFT0 - - PROCESS_SWITCH(lumiStabilityTask, processFDDFT0, "Process FDD and FT0 to lumi stability analysis", true); - void processV0(aod::FV0As const& fv0s, aod::BCsWithTimestamps const&) - { for (auto const& fv0 : fv0s) { - auto bc = fv0.bc_as(); - if (bc.timestamp() == false) { + auto bc = fv0.bc_as(); + if (bc.timestamp() == 0) { continue; } Long64_t globalBC = bc.globalBC(); int localBC = globalBC % nBCsPerOrbit; + int deltaIndex = 0; // backward move counts + int deltaBC = 0; // current difference wrt globalBC + int maxDeltaBC = 5; // maximum difference + bool pastActivityV0A = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() - deltaIndex < 0) { + break; + } + const auto& bc_past = bcs.iteratorAt(bc.globalIndex() - deltaIndex); + deltaBC = globalBC - bc_past.globalBC(); + if (deltaBC < maxDeltaBC) { + pastActivityV0A |= bc_past.has_fv0a(); + } + } + deltaIndex = 0; + deltaBC = 0; + + bool futureActivityV0A = false; + while (deltaBC < maxDeltaBC) { + deltaIndex++; + if (bc.globalIndex() + deltaIndex >= bcs.size()) { + break; + } + const auto& bc_future = bcs.iteratorAt(bc.globalIndex() + deltaIndex); + deltaBC = bc_future.globalBC() - globalBC; + if (deltaBC < maxDeltaBC) { + futureActivityV0A |= bc_future.has_fv0a(); + } + } + + if (pastActivityV0A == true || futureActivityV0A == true) { + continue; + } + + /*if (pastActivityV0A == true) { + continue; + }*/ + std::bitset<8> fv0Triggers = fv0.triggerMask(); bool aOut = fv0Triggers[o2::fdd::Triggers::bitAOut]; bool aIn = fv0Triggers[o2::fdd::Triggers::bitAIn]; @@ -219,9 +340,12 @@ struct lumiStabilityTask { } } } // loop over V0 events - } // end processV0 + std::cout << "************ >>>>>>>>>>>>>> " + << "Whithout Past Protection: " << CountNormal << " " + << "Avoided Whith Past Protection: " << CountPastProtec << "<<<<<<<<<<<< ********************" << std::endl; + } // end processMain - PROCESS_SWITCH(lumiStabilityTask, processV0, "Process V0 to lumi stability analysis", true); + PROCESS_SWITCH(lumiStabilityTask, processMain, "Process FDD and FT0 to lumi stability analysis", true); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) diff --git a/PWGMM/Mult/DataModel/ReducedTables.h b/PWGMM/Mult/DataModel/ReducedTables.h index ed740b2fb91..8b9cdb45ba7 100644 --- a/PWGMM/Mult/DataModel/ReducedTables.h +++ b/PWGMM/Mult/DataModel/ReducedTables.h @@ -11,6 +11,8 @@ #ifndef PWGMM_MULT_DATAMODEL_REDUCEDTABLES_H_ #define PWGMM_MULT_DATAMODEL_REDUCEDTABLES_H_ +#include + #include "Framework/AnalysisDataModel.h" #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/Centrality.h" @@ -34,7 +36,7 @@ namespace rcol { DECLARE_SOA_INDEX_COLUMN(RBC, rbc); DECLARE_SOA_COLUMN(MapEtaPhi, mapetaphi, std::vector); -} +} // namespace rcol #define Ccols o2::soa::Index<>, \ rcol::RBCId, \ diff --git a/PWGUD/Tasks/CMakeLists.txt b/PWGUD/Tasks/CMakeLists.txt index 2280bf4741a..ab028384214 100644 --- a/PWGUD/Tasks/CMakeLists.txt +++ b/PWGUD/Tasks/CMakeLists.txt @@ -92,3 +92,8 @@ o2physics_add_dpl_workflow(polarisation-rho SOURCES PolarisationRho.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2Physics::DGPIDSelector COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(upc-photonuclear-jmg + SOURCES upcPhotonuclearAnalysisJMG.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::ReconstructionDataFormats O2::DetectorsBase O2::DetectorsCommonDataFormats + COMPONENT_NAME Analysis) diff --git a/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx b/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx new file mode 100644 index 00000000000..bbec3c1dcda --- /dev/null +++ b/PWGUD/Tasks/upcPhotonuclearAnalysisJMG.cxx @@ -0,0 +1,357 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. +/// +/// \brief +/// \author Josué Martínez García, josuem@cern.ch + +#include "Framework/AnalysisDataModel.h" +#include "Framework/AnalysisTask.h" +#include "Framework/runDataProcessing.h" + +#include "Common/CCDB/EventSelectionParams.h" +#include "Common/Core/TrackSelection.h" +#include "Common/Core/TrackSelectionDefaults.h" +#include "Common/Core/trackUtilities.h" +#include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "PWGUD/DataModel/UDTables.h" +#include "PWGUD/Core/UPCTauCentralBarrelHelperRL.h" + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct upcPhotonuclearAnalysisJMG { + + HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + // Declare configurables on events/collisions + Configurable cutMyPosZMin{"cutMyPosZMin", -10., {"My collision cut"}}; + Configurable cutMyPosZMax{"cutMyPosZMax", 10., {"My collision cut"}}; + Configurable cutMyTimeZNA{"cutMyTimeZNA", 2., {"My collision cut"}}; + Configurable cutMyTimeZNC{"cutMyTimeZNC", 2., {"My collision cut"}}; + // Declare configurables on side A gap + Configurable cutAGapMyEnergyZNA{"cutAGapMyEnergyZNA", 4., {"My collision cut. A Gap"}}; + Configurable cutAGapMyEnergyZNC{"cutAGapMyEnergyZNC", 4., {"My collision cut. A Gap"}}; + // Declare configurables on side C gap + Configurable cutCGapMyEnergyZNA{"cutCGapMyEnergyZNA", 4., {"My collision cut. C Gap"}}; + Configurable cutCGapMyEnergyZNC{"cutCGapMyEnergyZNC", 4., {"My collision cut. C Gap"}}; + // Declare configurables on both side gap + Configurable cutBothGapMyEnergyZNA{"cutBothGapMyEnergyZNA", 4., {"My collision cut. Both Gap"}}; + Configurable cutBothGapMyEnergyZNC{"cutBothGapMyEnergyZNC", 4., {"My collision cut. Both Gap"}}; + // Declare configurables on tracks + Configurable cutMyptMin{"cutMyptMin", 0.15, {"My Track cut"}}; + Configurable cutMyptMax{"cutMyptMax", 10., {"My Track cut"}}; + Configurable cutMyetaMin{"cutMyetaMin", -0.9, {"My Track cut"}}; + Configurable cutMyetaMax{"cutMyetaMax", 0.9, {"My Track cut"}}; + Configurable cutMydcaZmax{"cutMydcaZmax", 2.f, {"My Track cut"}}; + Configurable cutMydcaXYmax{"cutMydcaXYmax", 1e0f, {"My Track cut"}}; + Configurable cutMydcaXYusePt{"cutMydcaXYusePt", false, {"My Track cut"}}; + Configurable cutMyHasITS{"cutMyHasITS", true, {"My Track cut"}}; + Configurable cutMyITSNClsMin{"cutMyITSNClsMin", 1, {"My Track cut"}}; + Configurable cutMyITSChi2NClMax{"cutMyITSChi2NClMax", 36.f, {"My Track cut"}}; + Configurable cutMyHasTPC{"cutMyHasTPC", true, {"MyGlobalTrack cut"}}; + Configurable cutMyTPCNClsMin{"cutMyTPCNClsMin", 0, {"My Track cut"}}; + Configurable cutMyTPCNClsCrossedRowsMin{"cutMyTPCNClsCrossedRowsMin", 50, {"My Track cut"}}; + Configurable cutMyTPCNClsCrossedRowsOverNClsMin{"cutMyTPCNClsCrossedRowsOverNClsMin", 1.f, {"My Track cut"}}; + Configurable cutMyTPCChi2NclMax{"cutMyTPCChi2NclMax", 4.f, {"My Track cut"}}; + + using FullSGUDCollision = soa::Join::iterator; + using FullUDTracks = soa::Join; + + void init(InitContext const&) + { + const AxisSpec axisCollision{4, -0.5, 3.5}; + const AxisSpec axisZvtx{40, -20., 20.}; + const AxisSpec axisPt{402, -0.05, 20.05}; + const AxisSpec axisTPCSignal{402, -0.05, 200.05}; + const AxisSpec axisPhi{64, -2 * o2::constants::math::PI, 2 * o2::constants::math::PI}; + const AxisSpec axisEta{50, -1.2, 1.2}; + const AxisSpec axisRapidity{40, -10, 10}; + const AxisSpec axisNch{101, -0.5, 100.5}; + const AxisSpec axisZNEnergy{1002, -0.5, 500.5}; + const AxisSpec axisZNTime{21, -10.5, 10.5}; + const AxisSpec axisNCls{201, -0.5, 200.5}; + const AxisSpec axisChi2NCls{100, 0, 50}; + const AxisSpec axisTPCNClsCrossedRowsMin{100, -0.05, 2.05}; + + histos.add("Events/hCountCollisions", "0 total - 1 side A - 2 side C - 3 both side; Number of analysed collision; counts", kTH1F, {axisCollision}); + + // histos to selection gap in side A + histos.add("Tracks/SGsideA/hTrackPt", "#it{p_{T}} distribution; #it{p_{T}}; counts", kTH1F, {axisPt}); + histos.add("Tracks/SGsideA/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); + histos.add("Tracks/SGsideA/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); + histos.add("Tracks/SGsideA/hTrackRapidity", "#it{y} distribution; #it{y}; counts", kTH1F, {axisRapidity}); + histos.add("Tracks/SGsideA/hTrackITSNCls", "#it{N Clusters ITS} distribution; #it{N Clusters ITS}; counts", kTH1F, {axisNCls}); + histos.add("Tracks/SGsideA/hTrackITSChi2NCls", "#it{N Clusters Chi2 ITS} distribution; #it{N Clusters Chi2 ITS}; counts", kTH1F, {axisChi2NCls}); + histos.add("Tracks/SGsideA/hTrackTPCNCls", "#it{N Clusters TPC} distribution; #it{N Clusters TPC}; counts", kTH1F, {axisTPCNClsCrossedRowsMin}); + histos.add("Tracks/SGsideA/hTrackTPCNClsCrossedRows", "#it{Number of crossed TPC Rows} distribution; #it{Number of crossed TPC Rows}; counts", kTH1F, {axisNCls}); + histos.add("Tracks/SGsideA/hTrackTPCNClsFindable", "#it{Findable TPC clusters for this track} distribution; #it{Findable TPC clusters for this track}; counts", kTH1F, {axisNCls}); + histos.add("Tracks/SGsideA/hTrackTPCChi2NCls", "#it{N Clusters Chi2 TPC} distribution; #it{N Clusters Chi2 TPC}; counts", kTH1F, {axisChi2NCls}); + histos.add("Tracks/SGsideA/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); + histos.add("Tracks/SGsideA/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{TPC dE/dx}; #it{p}", kTH2F, {axisPt, axisTPCSignal}); + + histos.add("Events/SGsideA/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); + histos.add("Events/SGsideA/hNch", "#it{N_{ch}} distribution; #it{N_{ch}}; counts", kTH1F, {axisNch}); + histos.add("Events/SGsideA/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{N_{ch}}; #it{N_{ch}}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); + histos.add("Events/SGsideA/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideA/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideA/hEnergyRelationSides", "Energy in side A vs energy in side C; Energy in side A; Energy in side C", kTH2F, {axisZNEnergy, axisZNEnergy}); + histos.add("Events/SGsideA/hTimeZNA", "Time in side A distribution; Time in side A; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideA/hTimeZNC", "Time in side C distribution; Time in side C; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideA/hTimeRelationSides", "Time in side A vs time in side C; Time in side A; Time in side C", kTH2F, {axisZNTime, axisZNTime}); + + // histos to selection gap in side C + histos.add("Tracks/SGsideC/hTrackPt", "#it{p_{T}} distribution; #it{p_{T}}; counts", kTH1F, {axisPt}); + histos.add("Tracks/SGsideC/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); + histos.add("Tracks/SGsideC/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); + histos.add("Tracks/SGsideC/hTrackRapidity", "#it{y} distribution; #it{y}; counts", kTH1F, {axisRapidity}); + histos.add("Tracks/SGsideC/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); + histos.add("Tracks/SGsideC/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{TPC dE/dx}; #it{p}", kTH2F, {axisPt, axisTPCSignal}); + + histos.add("Events/SGsideC/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); + histos.add("Events/SGsideC/hNch", "#it{N_{ch}} distribution; #it{N_{ch}}; counts", kTH1F, {axisNch}); + histos.add("Events/SGsideC/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{N_{ch}}; #it{N_{ch}}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); + histos.add("Events/SGsideC/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideC/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideC/hEnergyRelationSides", "Energy in side A vs energy in side C; Energy in side A; Energy in side C", kTH2F, {axisZNEnergy, axisZNEnergy}); + histos.add("Events/SGsideC/hTimeZNA", "Time in side A distribution; Time in side A; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideC/hTimeZNC", "Time in side C distribution; Time in side C; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideC/hTimeRelationSides", "Time in side A vs time in side C; Time in side A; Time in side C", kTH2F, {axisZNTime, axisZNTime}); + + // histos to selection gap in both sides + histos.add("Tracks/SGsideBoth/hTrackPt", "#it{p_{T}} distribution; #it{p_{T}}; counts", kTH1F, {axisPt}); + histos.add("Tracks/SGsideBoth/hTrackPhi", "#it{#phi} distribution; #it{#phi}; counts", kTH1F, {axisPhi}); + histos.add("Tracks/SGsideBoth/hTrackEta", "#it{#eta} distribution; #it{#eta}; counts", kTH1F, {axisEta}); + histos.add("Tracks/SGsideBoth/hTrackRapidity", "#it{y} distribution; #it{y}; counts", kTH1F, {axisRapidity}); + histos.add("Tracks/SGsideBoth/hTrackITSNClsTPCCls", "#it{ITS Clusters vs TPC Clusters}; #it{TPC Clusters}; #it{ITS Clusters}", kTH2F, {axisNCls, axisNCls}); + histos.add("Tracks/SGsideBoth/hTrackTPCSignnalP", "#it{TPC dE/dx vs p}; #it{TPC dE/dx}; #it{p}", kTH2F, {axisPt, axisTPCSignal}); + + histos.add("Events/SGsideBoth/hTrackZVtx", "vertex in z; z (cm); counts", kTH1F, {axisZvtx}); + histos.add("Events/SGsideBoth/hNch", "#it{N_{ch}} distribution; #it{N_{ch}}; counts", kTH1F, {axisNch}); + histos.add("Events/SGsideBoth/hPtVSNch", "#it{ #LT p_{T} #GT } vs #it{N_{ch}}; #it{N_{ch}}; #it{ #LT p_{T} #GT }", kTH2F, {axisNch, axisPt}); + histos.add("Events/SGsideBoth/hEnergyZNA", "Energy in side A distribution; Energy in side A; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideBoth/hEnergyZNC", "Energy in side C distribution; Energy in side C; counts", kTH1F, {axisZNEnergy}); + histos.add("Events/SGsideBoth/hEnergyRelationSides", "Energy in side A vs energy in side C; Energy in side A; Energy in side C", kTH2F, {axisZNEnergy, axisZNEnergy}); + histos.add("Events/SGsideBoth/hTimeZNA", "Time in side A distribution; Time in side A; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideBoth/hTimeZNC", "Time in side C distribution; Time in side C; counts", kTH1F, {axisZNTime}); + histos.add("Events/SGsideBoth/hTimeRelationSides", "Time in side A vs time in side C; Time in side A; Time in side C", kTH2F, {axisZNTime, axisZNTime}); + } + + template + bool isGlobalCollisionCut(C const& collision) + { + if (collision.posZ() < cutMyPosZMin || cutMyPosZMax < collision.posZ()) { + return false; + } + if ((std::abs(collision.timeZNA()) < cutMyTimeZNA && std::abs(collision.timeZNC()) < cutMyTimeZNC) == false) { + return false; + } + return true; + } + + template + bool isCollisionCutSG(CSG const& collision, int SideGap) + { + switch (SideGap) { + case 0: // Gap in A side + if ((collision.energyCommonZNA() < cutAGapMyEnergyZNA && collision.energyCommonZNC() > cutAGapMyEnergyZNC) == false) { // 0n - A side && Xn - C Side + return false; + } + break; + case 1: // Gap in C side + if ((collision.energyCommonZNA() > cutCGapMyEnergyZNA && collision.energyCommonZNC() < cutCGapMyEnergyZNC) == false) { // Xn - A side && 0n - C Side + return false; + } + break; + case 2: // Gap in Both Sides + if ((collision.energyCommonZNA() < cutBothGapMyEnergyZNA && collision.energyCommonZNC() < cutBothGapMyEnergyZNC) == false) { // 0n - A side && 0n - C Side + return false; + } + break; + } + return true; + } + + template + bool isTrackCut(T const& track) + { + if (track.pt() < cutMyptMin || track.pt() > cutMyptMax) { + return false; + } + if (eta(track.px(), track.py(), track.pz()) < cutMyetaMin || eta(track.px(), track.py(), track.pz()) > cutMyetaMax) { + return false; + } + if (std::abs(track.dcaZ()) > cutMydcaZmax) { + return false; + } + if (cutMydcaXYusePt) { + float maxDCA = 0.0105f + 0.0350f / std::pow(track.pt(), 1.1f); + if (std::abs(track.dcaXY()) > maxDCA) { + return false; + } + } else { + if (std::abs(track.dcaXY()) > cutMydcaXYmax) { + return false; + } + } + // Quality Track + // ITS + if (cutMyHasITS && !track.hasITS()) { + return false; // ITS refit + } + if (track.itsNCls() < cutMyITSNClsMin) { + return false; + } + if (track.itsChi2NCl() > cutMyITSChi2NClMax) { + return false; + } + // TPC + if (cutMyHasTPC && !track.hasTPC()) { + return false; // TPC refit + } + if (track.tpcNClsCrossedRows() < cutMyTPCNClsCrossedRowsMin) { + return false; + } + if ((static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable())) < cutMyTPCNClsMin) { + return false; // tpcNClsFound() + } + if (track.tpcChi2NCl() > cutMyTPCChi2NclMax) { + return false; // TPC chi2 + } + return true; + } + + void processSG(FullSGUDCollision const& reconstructedCollision, FullUDTracks const& reconstructedTracks) + { + histos.fill(HIST("Events/hCountCollisions"), 0); + int SGside = reconstructedCollision.gapSide(); + int nTracksCharged = 0; + float sumPt = 0; + + if (isGlobalCollisionCut(reconstructedCollision) == false) { + return; + } + + switch (SGside) { + case 0: // for side A + if (isCollisionCutSG(reconstructedCollision, 0) == false) { + return; + } + histos.fill(HIST("Events/hCountCollisions"), 1); + histos.fill(HIST("Events/SGsideA/hEnergyZNA"), reconstructedCollision.energyCommonZNA()); + histos.fill(HIST("Events/SGsideA/hEnergyZNC"), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideA/hEnergyRelationSides"), reconstructedCollision.energyCommonZNA(), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideA/hTimeZNA"), reconstructedCollision.timeZNA()); + histos.fill(HIST("Events/SGsideA/hTimeZNC"), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideA/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideA/hTrackZVtx"), reconstructedCollision.posZ()); + for (auto& track : reconstructedTracks) { + if (track.sign() == 1 || track.sign() == -1) { + if (isTrackCut(track) == false) { + continue; + } + nTracksCharged++; + sumPt += track.pt(); + histos.fill(HIST("Tracks/SGsideA/hTrackPt"), track.pt()); + histos.fill(HIST("Tracks/SGsideA/hTrackPhi"), phi(track.px(), track.py())); + histos.fill(HIST("Tracks/SGsideA/hTrackEta"), eta(track.px(), track.py(), track.pz())); + histos.fill(HIST("Tracks/SGsideA/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()), track.tpcSignal()); + // histos.fill(HIST("Tracks/SGsideA/hTrackRapidity"), track.rapidity()); + + histos.fill(HIST("Tracks/SGsideA/hTrackITSNCls"), track.itsNCls()); + histos.fill(HIST("Tracks/SGsideA/hTrackITSChi2NCls"), track.itsChi2NCl()); + histos.fill(HIST("Tracks/SGsideA/hTrackTPCNCls"), (static_cast(track.tpcNClsCrossedRows()) / static_cast(track.tpcNClsFindable()))); + histos.fill(HIST("Tracks/SGsideA/hTrackTPCNClsCrossedRows"), track.tpcNClsCrossedRows()); + histos.fill(HIST("Tracks/SGsideA/hTrackTPCNClsFindable"), track.tpcNClsFindable()); + histos.fill(HIST("Tracks/SGsideA/hTrackTPCChi2NCls"), track.tpcChi2NCl()); + histos.fill(HIST("Tracks/SGsideA/hTrackITSNClsTPCCls"), track.tpcNClsFindable(), track.itsNCls()); + } + } + histos.fill(HIST("Events/SGsideA/hNch"), nTracksCharged); + histos.fill(HIST("Events/SGsideA/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); + nTracksCharged = sumPt = 0; + break; + case 1: // for side C + if (isCollisionCutSG(reconstructedCollision, 1) == false) { + return; + } + histos.fill(HIST("Events/hCountCollisions"), 2); + histos.fill(HIST("Events/SGsideC/hEnergyZNA"), reconstructedCollision.energyCommonZNA()); + histos.fill(HIST("Events/SGsideC/hEnergyZNC"), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideC/hEnergyRelationSides"), reconstructedCollision.energyCommonZNA(), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideC/hTimeZNA"), reconstructedCollision.timeZNA()); + histos.fill(HIST("Events/SGsideC/hTimeZNC"), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideC/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideC/hTrackZVtx"), reconstructedCollision.posZ()); + for (auto& track : reconstructedTracks) { + if (track.sign() == 1 || track.sign() == -1) { + if (isTrackCut(track) == false) { + continue; + } + nTracksCharged++; + sumPt += track.pt(); + histos.fill(HIST("Tracks/SGsideC/hTrackPt"), track.pt()); + histos.fill(HIST("Tracks/SGsideC/hTrackPhi"), phi(track.px(), track.py())); + histos.fill(HIST("Tracks/SGsideC/hTrackEta"), eta(track.px(), track.py(), track.pz())); + // histos.fill(HIST("Tracks/SGsideC/hTrackRapidity"), track.rapidity()); + histos.fill(HIST("Tracks/SGsideC/hTrackITSNClsTPCCls"), track.tpcNClsFindable(), track.itsNCls()); + histos.fill(HIST("Tracks/SGsideC/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()), track.tpcSignal()); + } + } + histos.fill(HIST("Events/SGsideC/hNch"), nTracksCharged); + histos.fill(HIST("Events/SGsideC/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); + nTracksCharged = sumPt = 0; + break; + case 2: // for both sides + if (isCollisionCutSG(reconstructedCollision, 2) == false) { + return; + } + histos.fill(HIST("Events/hCountCollisions"), 3); + histos.fill(HIST("Events/SGsideBoth/hEnergyZNA"), reconstructedCollision.energyCommonZNA()); + histos.fill(HIST("Events/SGsideBoth/hEnergyZNC"), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideBoth/hEnergyRelationSides"), reconstructedCollision.energyCommonZNA(), reconstructedCollision.energyCommonZNC()); + histos.fill(HIST("Events/SGsideBoth/hTimeZNA"), reconstructedCollision.timeZNA()); + histos.fill(HIST("Events/SGsideBoth/hTimeZNC"), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideBoth/hTimeRelationSides"), reconstructedCollision.timeZNA(), reconstructedCollision.timeZNC()); + histos.fill(HIST("Events/SGsideBoth/hTrackZVtx"), reconstructedCollision.posZ()); + for (auto& track : reconstructedTracks) { + if (track.sign() == 1 || track.sign() == -1) { + if (isTrackCut(track) == false) { + continue; + } + nTracksCharged++; + sumPt += track.pt(); + histos.fill(HIST("Tracks/SGsideBoth/hTrackPt"), track.pt()); + histos.fill(HIST("Tracks/SGsideBoth/hTrackPhi"), phi(track.px(), track.py())); + histos.fill(HIST("Tracks/SGsideBoth/hTrackEta"), eta(track.px(), track.py(), track.pz())); + // histos.fill(HIST("Tracks/SGsideBoth/hTrackRapidity"), track.rapidity()); + histos.fill(HIST("Tracks/SGsideBoth/hTrackITSNClsTPCCls"), track.tpcNClsFindable(), track.itsNCls()); + histos.fill(HIST("Tracks/SGsideBoth/hTrackTPCSignnalP"), momentum(track.px(), track.py(), track.pz()), track.tpcSignal()); + } + } + histos.fill(HIST("Events/SGsideBoth/hNch"), nTracksCharged); + histos.fill(HIST("Events/SGsideBoth/hPtVSNch"), nTracksCharged, (sumPt / nTracksCharged)); + nTracksCharged = sumPt = 0; + break; + default: + return; + break; + } + } + PROCESS_SWITCH(upcPhotonuclearAnalysisJMG, processSG, "Process in UD tables", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"upcphotonuclear"})}; +}