Skip to content

Commit

Permalink
delection of obsolete table subscription, map improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fjonasALICE committed Sep 6, 2024
1 parent c5c45e7 commit 23d6db8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
12 changes: 10 additions & 2 deletions PWGJE/Core/JetUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ std::tuple<std::vector<std::vector<int>>, std::vector<std::vector<int>>> MatchCl
template <typename T, typename U>
float deltaR(T const& A, U const& B)
{
float dPhi = RecoDecay::constrainAngle(A.phi() - B.phi(), -M_PI);
float dPhi = RecoDecay::constrainAngle(RecoDecay::constrainAngle(A.phi() , -M_PI)- RecoDecay::constrainAngle(B.phi() , -M_PI), -M_PI);
float dEta = A.eta() - B.eta();

return TMath::Sqrt(dEta * dEta + dPhi * dPhi);
return std::sqrt(dEta * dEta + dPhi * dPhi);
}
// same as deltaR but explicit specification of the eta and phi components
template <typename T, typename U, typename V, typename W>
float deltaR(T const& eta1, U const& phi1, V const& eta2, W const& phi2)
{
float dPhi = RecoDecay::constrainAngle(RecoDecay::constrainAngle(phi1 , -M_PI)- RecoDecay::constrainAngle(phi2 , -M_PI), -M_PI);
float dEta = eta1 - eta2;

return std::sqrt(dEta * dEta + dPhi * dPhi);
}
}; // namespace jetutilities

#endif // PWGJE_CORE_JETUTILITIES_H_
1 change: 0 additions & 1 deletion PWGJE/Tasks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ if(FastJet_FOUND)
o2physics_add_dpl_workflow(gamma-jet-tree-producer
SOURCES gammajettreeproducer.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::EMCALBase O2::EMCALCalib O2Physics::PWGJECore O2Physics::AnalysisCore
O2Physics::EventFilteringUtils
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(bjet-tagging-ml
SOURCES bjetTaggingML.cxx
Expand Down
45 changes: 19 additions & 26 deletions PWGJE/Tasks/gammajettreeproducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "PWGJE/Core/FastJetUtilities.h"
#include "PWGJE/Core/JetDerivedDataUtilities.h"
#include "PWGJE/Core/JetUtilities.h"
#include "PWGJE/DataModel/Jet.h"
#include "PWGJE/DataModel/GammaJetAnalysisTree.h"

Expand All @@ -45,7 +46,6 @@
using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using bcEvSelIt = o2::soa::Join<o2::aod::BCs, o2::aod::BcSels>::iterator;
using selectedClusters = o2::soa::Filtered<o2::aod::JClusters>;

#include "Framework/runDataProcessing.h"
Expand Down Expand Up @@ -83,7 +83,7 @@ struct GammaJetTreeProducer {
int eventSelection = -1;
int trackSelection = -1;

std::map<int32_t, int32_t> collisionMapping;
std::unordered_map<int32_t, int32_t> collisionMapping;
std::vector<int> triggerMaskBits;

void init(InitContext const&)
Expand Down Expand Up @@ -111,19 +111,6 @@ struct GammaJetTreeProducer {
// ---------------------
// Helper functions
// ---------------------
template <typename T>
double deltaR(T const& eta1, T const& phi1, T const& eta2, T const& phi2)
{
// make sure both phi1 and phi2 are 0 to 2pi

double dPhi = TVector2::Phi_0_2pi(phi1) - TVector2::Phi_0_2pi(phi2);
if (abs(dPhi) > M_PI) {
dPhi = 2 * M_PI - abs(dPhi);
}
double dEta = eta1 - eta2;
return std::sqrt(dPhi * dPhi + dEta * dEta);
}

bool isTrackSelected(const auto& track)
{
if (!jetderiveddatautilities::selectTrack(track, trackSelection)) {
Expand All @@ -142,7 +129,10 @@ struct GammaJetTreeProducer {
if (collision.posZ() > mVertexCut) {
return false;
}
if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || !jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)) {
if (!jetderiveddatautilities::selectCollision(collision, eventSelection)) {
return false;
}
if(!jetderiveddatautilities::selectTrigger(collision, triggerMaskBits)){
return false;
}
if (!jetderiveddatautilities::eventEMCAL(collision)) {
Expand All @@ -159,7 +149,7 @@ struct GammaJetTreeProducer {
continue;
}
// make dR function live somwhere else
double dR = deltaR(cluster.eta(), cluster.phi(), track.eta(), track.phi());
float dR = jetutilities::deltaR(cluster, track);
if (dR < radius) {
iso += track.pt();
}
Expand All @@ -183,8 +173,8 @@ struct GammaJetTreeProducer {
if (!isTrackSelected(track)) {
continue;
}
dRLeft = deltaR(cluster.eta(), cPhiLeft, track.eta(), track.phi());
dRRight = deltaR(cluster.eta(), cPhiRight, track.eta(), track.phi());
dRLeft = jetutilities::deltaR(cluster.eta(), cPhiLeft, track.eta(), track.phi());
dRRight = jetutilities::deltaR(cluster.eta(), cPhiRight, track.eta(), track.phi());

if (dRLeft < radius) {
ptSumLeft += track.pt();
Expand Down Expand Up @@ -212,14 +202,14 @@ struct GammaJetTreeProducer {
// an integer instead
Filter clusterDefinitionSelection = (o2::aod::jcluster::definition == mClusterDefinition);
// Process clusters
void processClusters(soa::Join<JetCollisions,aod::BkgChargedRhos, aod::JCollisionBCs>::iterator const& collision, aod::JBCs const&, selectedClusters const& clusters, JetTracks const& tracks)
void processClusters(soa::Join<JetCollisions,aod::BkgChargedRhos, aod::JCollisionBCs>::iterator const& collision, selectedClusters const& clusters, JetTracks const& tracks)
{
if (!isEventAccepted(collision)) {
return;
}

eventsTable(collision.multiplicity(), collision.centrality(), collision.rho(), collision.eventSel(), collision.alias_raw());
collisionMapping.insert(std::make_pair(collision.globalIndex(), eventsTable.lastIndex()));
collisionMapping[collision.globalIndex()] = eventsTable.lastIndex();

// loop over clusters
for (auto cluster : clusters) {
Expand Down Expand Up @@ -257,7 +247,7 @@ struct GammaJetTreeProducer {
// dEta = 0;
// }

gammasTable(collisionMapping[collision.globalIndex()], cluster.energy(), cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), cluster.nlm(), isoraw, perpconerho, dPhi, dEta, p);
gammasTable(eventsTable.lastIndex(), cluster.energy(), cluster.eta(), cluster.phi(), cluster.m02(), cluster.m20(), cluster.nCells(), cluster.time(), cluster.isExotic(), cluster.distanceToBadChannel(), cluster.nlm(), isoraw, perpconerho, dPhi, dEta, p);
}

// dummy loop over tracks
Expand All @@ -269,7 +259,7 @@ struct GammaJetTreeProducer {

Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f);
// Process charged jets
void processChargedJets(soa::Join<JetCollisions, aod::BkgChargedRhos, aod::JCollisionBCs>::iterator const& collision, aod::JBCs const&, soa::Filtered<soa::Join<aod::ChargedJets, aod::ChargedJetConstituents>> const& chargedJets, JetTracks const&)
void processChargedJets(soa::Join<JetCollisions, aod::BkgChargedRhos, aod::JCollisionBCs>::iterator const& collision,soa::Filtered<soa::Join<aod::ChargedJets, aod::ChargedJetConstituents>> const& chargedJets, JetTracks const&)
{
// event selection
if (!isEventAccepted(collision)) {
Expand All @@ -286,8 +276,11 @@ struct GammaJetTreeProducer {
mHistograms.fill(HIST("chjetpt_vs_constpt"), jet.pt(), constituent.pt());
nconst++;
}

chargedJetsTable(collisionMapping[collision.globalIndex()], jet.pt(), jet.eta(), jet.phi(), jet.energy(), jet.mass(), jet.area(), nconst);
int32_t storedColIndex = -1;
if (auto foundCol = collisionMapping.find(collision.globalIndex()); foundCol != collisionMapping.end()) {
storedColIndex = foundCol->second;
}
chargedJetsTable(storedColIndex, jet.pt(), jet.eta(), jet.phi(), jet.energy(), jet.mass(), jet.area(), nconst);
// fill histograms
mHistograms.fill(HIST("chjetPt"), jet.pt());
}
Expand All @@ -297,6 +290,6 @@ struct GammaJetTreeProducer {
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
WorkflowSpec workflow{
adaptAnalysisTask<GammaJetTreeProducer>(cfgc, TaskName{"gamma-jet-tree-producer"}, SetDefaultProcesses{{{"processClearMaps",true},{"processClusters", true}, {"processChargedJets", true}}})};
adaptAnalysisTask<GammaJetTreeProducer>(cfgc, TaskName{"gamma-jet-tree-producer"})};
return workflow;
}

0 comments on commit 23d6db8

Please sign in to comment.