-
Notifications
You must be signed in to change notification settings - Fork 661
PWGCF: JCorran: dedicated weights loader #6256
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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,121 @@ | ||
| // 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. | ||
| /// \author Jasper Parkkila (jparkkil@cern.ch) | ||
| /// \since May 2024 | ||
|
|
||
| #include <TFile.h> | ||
| #include <THn.h> | ||
|
|
||
| #include "Framework/AnalysisTask.h" | ||
| #include "Framework/ASoAHelpers.h" | ||
| #include "Framework/RunningWorkflowInfo.h" | ||
| #include "Framework/HistogramRegistry.h" | ||
|
|
||
| #include "Common/DataModel/EventSelection.h" | ||
| #include "Common/Core/TrackSelection.h" | ||
| #include "Common/DataModel/TrackSelectionTables.h" | ||
| #include "Common/DataModel/Centrality.h" | ||
| #include "ReconstructionDataFormats/V0.h" | ||
|
|
||
| // #include "CCDB/BasicCCDBManager.h" | ||
|
|
||
| #include "PWGCF/JCorran/DataModel/JCatalyst.h" | ||
| #include "PWGCF/DataModel/CorrelationsDerived.h" | ||
| #include "Framework/runDataProcessing.h" | ||
|
|
||
| using namespace o2; | ||
| using namespace o2::framework; | ||
| using namespace o2::framework::expressions; | ||
|
|
||
| #define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP}; | ||
|
|
||
| // The standalone jfluc code expects the entire list of tracks for an event. At the same time, it expects weights together with other track attributes. | ||
| // This workflow creates a table of weights that can be joined with track tables. | ||
| struct jflucWeightsLoader { | ||
| O2_DEFINE_CONFIGURABLE(pathPhiWeights, std::string, "", "Local (local://) or CCDB path for the phi acceptance correction histogram"); | ||
|
|
||
| THnF* ph = 0; | ||
| TFile* pf = 0; | ||
| int runNumber = 0; | ||
|
|
||
| ~jflucWeightsLoader() | ||
| { | ||
| if (ph) | ||
| delete ph; | ||
| if (pf) { | ||
| pf->Close(); | ||
| delete pf; | ||
| } | ||
| } | ||
|
|
||
| Produces<aod::JWeights> output; | ||
| void init(InitContext const&) | ||
| { | ||
| if (!doprocessLoadWeights && !doprocessLoadWeightsCF) | ||
| return; | ||
| if (doprocessLoadWeights && doprocessLoadWeightsCF) | ||
| LOGF(fatal, "Only one weights loader process switch can be enabled at a time."); | ||
| if (pathPhiWeights.value.substr(0, 8) == "local://") { | ||
| pf = new TFile(pathPhiWeights.value.substr(8).c_str(), "read"); | ||
| if (!pf->IsOpen()) { | ||
| delete pf; | ||
| pf = 0; | ||
| LOGF(fatal, "NUA correction weights file not found: %s", pathPhiWeights.value.substr(8).c_str()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| template <class CollisionT, class TrackT> | ||
| void loadWeights(CollisionT const& collision, TrackT const& tracks) | ||
| { | ||
| if (!pf) | ||
| LOGF(fatal, "NUA correction weights file has not been opened."); | ||
| if (collision.runNumber() != runNumber) { | ||
| if (ph) | ||
| delete ph; | ||
| if (!(ph = static_cast<THnF*>(pf->Get(Form("NUAWeights_%d", collision.runNumber()))))) | ||
| LOGF(warning, "NUA correction histogram not found for run %d.", collision.runNumber()); | ||
| else | ||
| LOGF(info, "Loaded NUA correction histogram for run %d.", collision.runNumber()); | ||
| runNumber = collision.runNumber(); | ||
| } | ||
| for (auto& track : tracks) { | ||
| float phiWeight, effWeight; | ||
| if (ph) { | ||
| const Double_t coords[] = {collision.multiplicity(), track.phi(), track.eta(), collision.posZ()}; | ||
| phiWeight = ph->GetBinContent(ph->GetBin(coords)); | ||
| } else { | ||
| phiWeight = 1.0f; | ||
| } | ||
|
|
||
| effWeight = 1.0f; //<--- todo | ||
|
|
||
| output(phiWeight, effWeight); | ||
| } | ||
| } | ||
|
|
||
| void processLoadWeights(aod::JCollision const& collision, aod::JTracks const& tracks) | ||
| { | ||
| loadWeights(collision, tracks); | ||
| } | ||
| PROCESS_SWITCH(jflucWeightsLoader, processLoadWeights, "Load weights histograms for derived data table", false); | ||
|
|
||
| void processLoadWeightsCF(aod::CFCollision const& collision, aod::CFTracks const& tracks) | ||
| { | ||
| loadWeights(collision, tracks); | ||
| } | ||
| PROCESS_SWITCH(jflucWeightsLoader, processLoadWeightsCF, "Load weights histograms for CF derived data table", true); | ||
| }; | ||
|
|
||
| WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) | ||
| { | ||
| return WorkflowSpec{adaptAnalysisTask<jflucWeightsLoader>(cfgc)}; | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful on how you will use this table
The tracks table has tracks that are not associated to collisions and that means they will not be in this output which in its turn means you will not be able to join this table to the tracks table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the point, will be careful with this.