From 0370c181e8125250e36a661add8cbd22bddcba42 Mon Sep 17 00:00:00 2001 From: Florian Jonas Date: Tue, 31 May 2022 09:16:17 +0200 Subject: [PATCH] [EMCAL-734] fixed cluster definition and added ambiguous clusters [EMCAL-734] merge conflicts [EMCAL-734] merge conflicts 2 [EMCAL-734] fixed conflicts part 3 --- PWGJE/DataModel/EMCALClusters.h | 12 ++-- PWGJE/TableProducer/emcalCorrectionTask.cxx | 8 ++- PWGJE/Tasks/emcclustermonitor.cxx | 68 ++++++++++++++------- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/PWGJE/DataModel/EMCALClusters.h b/PWGJE/DataModel/EMCALClusters.h index 42e119c63a5..1969258ece2 100644 --- a/PWGJE/DataModel/EMCALClusters.h +++ b/PWGJE/DataModel/EMCALClusters.h @@ -27,12 +27,12 @@ namespace emcalcluster // define global cluster definitions // the V1 algorithm is not yet implemented, but the V3 algorithm is // New definitions should be added here! -const EMCALClusterDefinition kV1Default(ClusterAlgorithm_t::kV1, 0, 1, "kV1Default", 0.1, 0.5, -10000, 10000, 0.03); -const EMCALClusterDefinition kV1Variation1(ClusterAlgorithm_t::kV3, 1, 1, "kV1Variation1", 0.1, 0.3, -10000, 10000, 0.03); -const EMCALClusterDefinition kV1Variation2(ClusterAlgorithm_t::kV3, 2, 1, "kV1Variation2", 0.1, 0.2, -10000, 10000, 0.03); -const EMCALClusterDefinition kV3Default(ClusterAlgorithm_t::kV3, 10, 1, "kV3Default", 0.1, 0.5, -10000, 10000, 0.03); -const EMCALClusterDefinition kV3Variation1(ClusterAlgorithm_t::kV3, 11, 1, "kV3Variation1", 0.1, 0.3, -10000, 10000, 0.03); -const EMCALClusterDefinition kV3Variation2(ClusterAlgorithm_t::kV3, 12, 1, "kV3Variation2", 0.1, 0.2, -10000, 10000, 0.03); +const EMCALClusterDefinition kV1Default(ClusterAlgorithm_t::kV1, 0, 1, "kV1Default", 0.5, 0.1, -10000, 10000, 0.03); +const EMCALClusterDefinition kV1Variation1(ClusterAlgorithm_t::kV3, 1, 1, "kV1Variation1", 0.3, 0.1, -10000, 10000, 0.03); +const EMCALClusterDefinition kV1Variation2(ClusterAlgorithm_t::kV3, 2, 1, "kV1Variation2", 0.2, 0.1, -10000, 10000, 0.03); +const EMCALClusterDefinition kV3Default(ClusterAlgorithm_t::kV3, 10, 1, "kV3Default", 0.5, 0.1, -10000, 10000, 0.03); +const EMCALClusterDefinition kV3Variation1(ClusterAlgorithm_t::kV3, 11, 1, "kV3Variation1", 0.3, 0.1, -10000, 10000, 0.03); +const EMCALClusterDefinition kV3Variation2(ClusterAlgorithm_t::kV3, 12, 1, "kV3Variation2", 0.2, 0.1, -10000, 10000, 0.03); /// \brief function returns EMCALClusterDefinition for the given name /// \param name name of the cluster definition diff --git a/PWGJE/TableProducer/emcalCorrectionTask.cxx b/PWGJE/TableProducer/emcalCorrectionTask.cxx index c73f2e2ddf9..adb9515eddc 100644 --- a/PWGJE/TableProducer/emcalCorrectionTask.cxx +++ b/PWGJE/TableProducer/emcalCorrectionTask.cxx @@ -103,6 +103,11 @@ struct EmcalCorrectionTask { mClusterizers.emplace_back(std::make_unique>(1, clusterDefinition.timeMin, clusterDefinition.timeMax, clusterDefinition.gradientCut, true, clusterDefinition.seedEnergy, clusterDefinition.minCellEnergy)); mClusterFactories.emplace_back(std::make_unique>()); LOG(info) << "Cluster definition initialized: " << clusterDefinition.toString(); + LOG(info) << "timeMin: " << clusterDefinition.timeMin; + LOG(info) << "timeMax: " << clusterDefinition.timeMax; + LOG(info) << "gradientCut: " << clusterDefinition.gradientCut; + LOG(info) << "seedEnergy: " << clusterDefinition.seedEnergy; + LOG(info) << "minCellEnergy: " << clusterDefinition.minCellEnergy; } for (auto& clusterizer : mClusterizers) { clusterizer->setGeometry(geometry); @@ -142,7 +147,6 @@ struct EmcalCorrectionTask { } // LOG(debug) << "Cell E: " << cell.getEnergy(); // LOG(debug) << "Cell E: " << cell; - mEmcalCells.emplace_back(o2::emcal::Cell( cell.cellNumber(), cell.amplitude(), @@ -187,8 +191,8 @@ struct EmcalCorrectionTask { mClusterFactories.at(i)->setClustersContainer(*emcalClusters); mClusterFactories.at(i)->setCellsContainer(mEmcalCells); mClusterFactories.at(i)->setCellsIndicesContainer(*emcalClustersInputIndices); - LOG(debug) << "Cluster factory set up."; + LOG(debug) << "Cluster factory set up."; // Convert to analysis clusters. for (int icl = 0; icl < mClusterFactories.at(i)->getNumberOfClusters(); icl++) { auto analysisCluster = mClusterFactories.at(i)->buildCluster(icl); diff --git a/PWGJE/Tasks/emcclustermonitor.cxx b/PWGJE/Tasks/emcclustermonitor.cxx index 145cc2aa439..d7381b2df8c 100644 --- a/PWGJE/Tasks/emcclustermonitor.cxx +++ b/PWGJE/Tasks/emcclustermonitor.cxx @@ -54,6 +54,7 @@ using namespace o2::framework; using namespace o2::framework::expressions; using collisionEvSelIt = o2::soa::Join::iterator; using selectedClusters = o2::soa::Filtered; +using selectedAmbiguousClusters = o2::soa::Filtered; struct ClusterMonitor { HistogramRegistry mHistManager{"ClusterMonitorHistograms"}; o2::emcal::Geometry* mGeometry = nullptr; @@ -102,7 +103,7 @@ struct ClusterMonitor { mHistManager.add("eventVertexZAll", "z-vertex of event (all events)", o2HistType::kTH1F, {{200, -20, 20}}); mHistManager.add("eventVertexZSelected", "z-vertex of event (selected events)", o2HistType::kTH1F, {{200, -20, 20}}); - // cluster properties + // cluster properties (matched clusters) mHistManager.add("clusterE", "Energy of cluster", o2HistType::kTH1F, {energyAxis}); mHistManager.add("clusterE_SimpleBinning", "Energy of cluster", o2HistType::kTH1F, {{400, 0, 100}}); mHistManager.add("clusterEtaPhi", "Eta and phi of cluster", o2HistType::kTH2F, {{100, -1, 1}, {100, 0, 2 * TMath::Pi()}}); @@ -135,7 +136,7 @@ struct ClusterMonitor { } } /// \brief Process EMCAL clusters that are matched to a collisions - void process(collisionEvSelIt const& theCollision, selectedClusters const& clusters, o2::aod::BCs const& bcs) + void processCollisions(collisionEvSelIt const& theCollision, selectedClusters const& clusters, o2::aod::BCs const& bcs) { mHistManager.fill(HIST("eventsAll"), 1); @@ -151,26 +152,14 @@ struct ClusterMonitor { LOG(debug) << "Event not selected because of z-vertex cut z= " << theCollision.posZ() << " > " << mVertexCut << " cm, skipping"; return; } + mHistManager.fill(HIST("eventVertexZAll"), theCollision.posZ()); + if (mVertexCut > 0 && TMath::Abs(theCollision.posZ()) > mVertexCut) { + LOG(debug) << "Event not selected because of z-vertex cut z= " << theCollision.posZ() << " > " << mVertexCut << " cm, skipping"; + return; + } mHistManager.fill(HIST("eventsSelected"), 1); mHistManager.fill(HIST("eventVertexZSelected"), theCollision.posZ()); - // loop over bc , if requested (mVetoBCID >= 0), reject everything from a certain BC - // this can be used as alternative to event selection (e.g. for pilot beam data) - // TODO: remove this loop and put it in separate process function that only takes care of ambiguous clusters - for (const auto& bc : bcs) { - o2::InteractionRecord eventIR; - eventIR.setFromLong(bc.globalBC()); - mHistManager.fill(HIST("eventBCAll"), eventIR.bc); - if (std::find(mVetoBCIDs.begin(), mVetoBCIDs.end(), eventIR.bc) != mVetoBCIDs.end()) { - LOG(info) << "Event rejected because of veto BCID " << eventIR.bc; - continue; - } - if (mSelectBCIDs.size() && (std::find(mSelectBCIDs.begin(), mSelectBCIDs.end(), eventIR.bc) == mSelectBCIDs.end())) { - continue; - } - mHistManager.fill(HIST("eventBCSelected"), eventIR.bc); - } - // loop over all clusters from accepted collision // auto eventClusters = clusters.select(o2::aod::emcalcluster::bcId == theCollision.bc().globalBC()); for (const auto& cluster : clusters) { @@ -193,6 +182,41 @@ struct ClusterMonitor { mHistManager.fill(HIST("clusterDistanceToBadChannel"), cluster.distanceToBadChannel()); } } + PROCESS_SWITCH(ClusterMonitor, processCollisions, "Process clusters from collision", false); + + /// \brief Process EMCAL clusters that are not matched to a collision + /// This is not needed for most users + + void processAmbiguous(o2::aod::BC const bc, selectedAmbiguousClusters const& clusters) + { + // loop over bc , if requested (mVetoBCID >= 0), reject everything from a certain BC + // this can be used as alternative to event selection (e.g. for pilot beam data) + // TODO: remove this loop and put it in separate process function that only takes care of ambiguous clusters + o2::InteractionRecord eventIR; + eventIR.setFromLong(bc.globalBC()); + mHistManager.fill(HIST("eventBCAll"), eventIR.bc); + if (std::find(mVetoBCIDs.begin(), mVetoBCIDs.end(), eventIR.bc) != mVetoBCIDs.end()) { + LOG(info) << "Event rejected because of veto BCID " << eventIR.bc; + return; + } + if (mSelectBCIDs.size() && (std::find(mSelectBCIDs.begin(), mSelectBCIDs.end(), eventIR.bc) == mSelectBCIDs.end())) { + return; + } + mHistManager.fill(HIST("eventBCSelected"), eventIR.bc); + // loop over ambiguous clusters + for (const auto& cluster : clusters) { + mHistManager.fill(HIST("clusterE"), cluster.energy()); + mHistManager.fill(HIST("clusterE_SimpleBinning"), cluster.energy()); + mHistManager.fill(HIST("clusterEtaPhi"), cluster.eta(), cluster.phi()); + mHistManager.fill(HIST("clusterM02"), cluster.m02()); + mHistManager.fill(HIST("clusterM20"), cluster.m20()); + mHistManager.fill(HIST("clusterTimeVsE"), cluster.time(), cluster.energy()); + mHistManager.fill(HIST("clusterNLM"), cluster.nlm()); + mHistManager.fill(HIST("clusterNCells"), cluster.nCells()); + mHistManager.fill(HIST("clusterDistanceToBadChannel"), cluster.distanceToBadChannel()); + } + } + PROCESS_SWITCH(ClusterMonitor, processAmbiguous, "Process Ambiguous clusters", false); /// \brief Create binning for cluster energy axis (variable bin size) /// \return vector with bin limits @@ -250,6 +274,8 @@ struct ClusterMonitor { WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{ - adaptAnalysisTask(cfgc)}; + WorkflowSpec workflow{ + adaptAnalysisTask(cfgc, TaskName{"EMCClusterMonitorTask"}, SetDefaultProcesses{{{"processCollisions", true}, {"processAmbiguous", false}}}), + adaptAnalysisTask(cfgc, TaskName{"EMCClusterMonitorTaskAmbiguous"}, SetDefaultProcesses{{{"processCollisions", false}, {"processAmbiguous", true}}})}; + return workflow; } \ No newline at end of file