-
Notifications
You must be signed in to change notification settings - Fork 640
[PWGJE,Infrastructure] Create qg tree creator #15555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Physicistdana
wants to merge
29
commits into
AliceO2Group:master
Choose a base branch
from
Physicistdana:createqgTreeCreator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+216
−0
Draft
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a750f5f
Update CMakeLists.txt
Physicistdana bf392dd
Update CMakeLists.txt
Physicistdana d4b81eb
Create qgTreeCreator.cxx
Physicistdana da5612f
Delete PWGJE/qgTreeCreator.cxx
Physicistdana 8cc4971
Create qgTreeCreator.cxx
Physicistdana 332def0
Merge branch 'AliceO2Group:master' into createqgTreeCreator
Physicistdana 65d1d22
Update qgTreeCreator.cxx
Physicistdana 874b775
Update CMakeLists.txt
Physicistdana 7f83f26
Update CMakeLists.txt
Physicistdana c9665a1
Merge branch 'AliceO2Group:master' into createqgTreeCreator
Physicistdana f23ad14
Merge branch 'AliceO2Group:master' into createqgTreeCreator
Physicistdana 9bbf97f
Update CMakeLists.txt
Physicistdana 6747b9b
Update qgTreeCreator.cxx
Physicistdana 391e1c7
Update qgTreeCreator.cxx
Physicistdana 836aba4
Update CMakeLists.txt
Physicistdana 9420cc2
Update CMakeLists.txt
Physicistdana 9e50c17
Merge branch 'AliceO2Group:master' into createqgTreeCreator
Physicistdana 6f9c472
Update o2-linter.yml
Physicistdana b6545de
Update qgTreeCreator.cxx
Physicistdana 10f4842
Update o2-linter.yml
Physicistdana 5226b16
Update qgTreeCreator.cxx
Physicistdana 040af13
Update CMakeLists.txt
Physicistdana 6d008b9
Update qgTreeCreator.cxx
Physicistdana 60aeffb
Update qgTreeCreator.cxx
Physicistdana c4ef955
Update qgTreeCreator.cxx
Physicistdana 6db5360
Update qgTreeCreator.cxx
Physicistdana 5ae5f73
Update qgTreeCreator.cxx
Physicistdana c415b12
Merge branch 'AliceO2Group:master' into createqgTreeCreator
Physicistdana 47a8656
Update qgTreeCreator.cxx
Physicistdana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,210 @@ | ||
| // Copyright 2019-2026 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. | ||
|
|
||
| #include "Framework/runDataProcessing.h" | ||
| #include "Framework/AnalysisTask.h" | ||
| #include "Framework/HistogramRegistry.h" | ||
| #include "Framework/Configurable.h" | ||
|
|
||
| #include "PWGJE/DataModel/Jet.h" | ||
| #include "PWGJE/DataModel/JetMatching.h" | ||
| #include "Common/DataModel/TrackSelectionTables.h" | ||
| #include "Common/DataModel/MCTruthContainer.h" | ||
|
|
||
| #include <cmath> | ||
|
|
||
| using namespace o2; | ||
| using namespace o2::framework; | ||
|
|
||
| namespace o2::aod | ||
| { | ||
| DECLARE_SOA_COLUMN(JetPt, jetPt, float); | ||
| DECLARE_SOA_COLUMN(JetEta, jetEta, float); | ||
| DECLARE_SOA_COLUMN(JetPhi, jetPhi, float); | ||
| DECLARE_SOA_COLUMN(NConst, nConst, int); | ||
| DECLARE_SOA_COLUMN(Girth, girth, float); | ||
| DECLARE_SOA_COLUMN(PTD, pTD, float); | ||
| DECLARE_SOA_COLUMN(MatchDeltaR, matchDeltaR, float); | ||
| DECLARE_SOA_COLUMN(PtResponse, ptResponse, float); | ||
| DECLARE_SOA_COLUMN(QGLabel, qgLabel, int); | ||
|
|
||
| DECLARE_SOA_TABLE(QGJetTable, "AOD", "QGJET", | ||
| JetPt, | ||
| JetEta, | ||
| JetPhi, | ||
| NConst, | ||
| Girth, | ||
| PTD, | ||
| MatchDeltaR, | ||
| PtResponse, | ||
| QGLabel); | ||
| } | ||
|
|
||
| //------------------------------------------------ | ||
| // helper functions | ||
| //------------------------------------------------ | ||
| float deltaPhi(float phi1, float phi2) | ||
| { | ||
| return std::remainder(phi1 - phi2, 2.f * static_cast<float>(M_PI)); | ||
| } | ||
|
|
||
| float deltaR(float eta1, float phi1, float eta2, float phi2) | ||
|
||
| { | ||
| float deta = eta1 - eta2; | ||
| float dphi = deltaPhi(phi1, phi2); | ||
| return std::sqrt(deta * deta + dphi * dphi); | ||
| } | ||
|
|
||
| //------------------------------------------------ | ||
| // find initiating parton by ancestry | ||
| //------------------------------------------------ | ||
| int getInitiatingParton(auto const& particle, | ||
| aod::McParticles const& mcParticles) | ||
| { | ||
| auto p = particle; | ||
| int pdg = p.pdgCode(); | ||
|
|
||
| while (p.has_mothers()) { | ||
| auto mothers = p.mothers_as<aod::McParticles>(); | ||
| if (mothers.size() == 0) { | ||
| break; | ||
| } | ||
|
|
||
| auto mom = mothers.iteratorAt(0); | ||
| int mpdg = mom.pdgCode(); | ||
|
|
||
| // stop at quark or gluon | ||
| if (std::abs(mpdg) == 21 || (std::abs(mpdg) >= 1 && std::abs(mpdg) <= 6)) { | ||
vkucera marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| pdg = mpdg; | ||
| } | ||
|
|
||
| p = mom; | ||
| } | ||
|
|
||
| return pdg; | ||
| } | ||
|
|
||
| //------------------------------------------------ | ||
| // main task | ||
| //------------------------------------------------ | ||
| struct QGTreeCreator { | ||
|
|
||
| Configurable<float> jetPtMin{"jetPtMin",10.f}; | ||
| Configurable<float> maxMatchDeltaR{"maxMatchDeltaR",0.3f}; | ||
|
|
||
| Produces<aod::QGJetTable> qgjets; | ||
|
|
||
| void process(aod::ChargedMCDetectorLevelJets const& recoJets, | ||
| aod::ChargedMCParticleLevelJets const& truthJets, | ||
| aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets const& matches, | ||
| aod::McParticles const& mcParticles) | ||
| { | ||
| for (auto const& jet : recoJets) { | ||
|
|
||
| if (jet.pt() < jetPtMin) | ||
| continue; | ||
|
|
||
| //---------------------------------- | ||
| // compute jet observables | ||
| //---------------------------------- | ||
| int nconst = 0; | ||
| float sumPt = 0; | ||
| float sumPt2 = 0; | ||
| float sumPtDr = 0; | ||
|
|
||
| for (auto const& c : jet.tracks_as<aod::ChargedMCDetectorLevelJetConstituent>()) { | ||
| float pt = c.pt(); | ||
| float dr = deltaR(c.eta(), c.phi(), jet.eta(), jet.phi()); | ||
|
|
||
| nconst++; | ||
| sumPt += pt; | ||
| sumPt2 += pt*pt; | ||
| sumPtDr += pt*dr; | ||
| } | ||
|
|
||
| float girth = sumPt>0 ? sumPtDr/sumPt : -1; | ||
| float ptd = sumPt>0 ? std::sqrt(sumPt2)/sumPt : -1; | ||
|
|
||
| //---------------------------------- | ||
| // matching block | ||
| //---------------------------------- | ||
| float matchDr = -1; | ||
| float ptResp = -1; | ||
| int qg = -1; | ||
|
|
||
| for (auto const& match : matches) { | ||
|
|
||
| if (match.chargedMCDetectorLevelJetId() != jet.globalIndex()) | ||
| continue; | ||
|
|
||
| auto truthJet = truthJets.iteratorAt( | ||
| match.chargedMCParticleLevelJetId()); | ||
|
|
||
| matchDr = deltaR(jet.eta(), jet.phi(), | ||
| truthJet.eta(), truthJet.phi()); | ||
|
|
||
| if (matchDr > maxMatchDeltaR) | ||
| continue; | ||
|
|
||
| ptResp = jet.pt() / truthJet.pt(); | ||
|
|
||
| //---------------------------------- | ||
| // find initiating parton | ||
| //---------------------------------- | ||
| float maxPt = -1; | ||
| int pdg = 0; | ||
|
|
||
| for (auto const& tc : | ||
| truthJet.tracks_as<aod::ChargedMCParticleLevelJetConstituent>()) | ||
| { | ||
| if (!tc.has_mcParticle()) | ||
| continue; | ||
|
|
||
| auto mc = tc.mcParticle(); | ||
|
|
||
| if (tc.pt() > maxPt) { | ||
| maxPt = tc.pt(); | ||
| pdg = getInitiatingParton(mc, mcParticles); | ||
| } | ||
| } | ||
|
|
||
| //---------------------------------- | ||
| // assign q/g label | ||
| //---------------------------------- | ||
| if (std::abs(pdg) == 21) | ||
| qg = 1; // gluon | ||
| else if (std::abs(pdg) >= 1 && std::abs(pdg) <= 6) | ||
| qg = 0; // quark | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| //---------------------------------- | ||
| // store | ||
| //---------------------------------- | ||
| qgjets(jet.pt(), | ||
| jet.eta(), | ||
| jet.phi(), | ||
| nconst, | ||
| girth, | ||
| ptd, | ||
| matchDr, | ||
| ptResp, | ||
| qg); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) | ||
| { | ||
| return WorkflowSpec{ | ||
| adaptAnalysisTask<QGTreeCreator>(cfgc, TaskName{"qg-tree-creator"})}; | ||
vkucera marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.