-
Notifications
You must be signed in to change notification settings - Fork 510
Add metadata to AOD #7501
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
Closed
Closed
Add metadata to AOD #7501
Changes from all commits
Commits
Show all changes
3 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,10 +52,13 @@ | |
| #include "SimulationDataFormat/MCEventLabel.h" | ||
| #include "SimulationDataFormat/MCTrack.h" | ||
| #include "SimulationDataFormat/MCTruthContainer.h" | ||
| #include "O2Version.h" | ||
| #include "TMath.h" | ||
| #include "MathUtils/Utils.h" | ||
| #include "Math/SMatrix.h" | ||
| #include <TMatrixD.h> | ||
| #include "TMatrixD.h" | ||
| #include "TString.h" | ||
| #include "TObjString.h" | ||
| #include <map> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
@@ -299,11 +302,6 @@ void AODProducerWorkflowDPL::fillTrackTablesPerCollision(int collisionID, | |
| } else { | ||
| auto contributorsGID = data.getSingleDetectorRefs(trackIndex); | ||
| const auto& trackPar = data.getTrackParam(trackIndex); | ||
| if (contributorsGID[GIndex::Source::ITS].isIndexSet() || contributorsGID[GIndex::Source::ITSAB].isIndexSet()) { | ||
| int nClusters = itsTracks[contributorsGID[GIndex::ITS].getIndex()].getNClusters(); | ||
| float chi2 = itsTracks[contributorsGID[GIndex::ITS].getIndex()].getChi2(); | ||
| extraInfoHolder.itsChi2NCl = nClusters != 0 ? chi2 / (float)nClusters : 0; | ||
| } | ||
| if (contributorsGID[GIndex::Source::ITS].isIndexSet()) { | ||
| extraInfoHolder.itsClusterMap = itsTracks[contributorsGID[GIndex::ITS].getIndex()].getPattern(); | ||
| } else if (contributorsGID[GIndex::Source::ITSAB].isIndexSet()) { // this is an ITS-TPC afterburner contributor | ||
|
|
@@ -658,14 +656,8 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader& | |
| } | ||
| int statusCode = 0; | ||
| uint8_t flags = 0; | ||
| if (!mcParticles[particle].isPrimary()) { | ||
| flags |= o2::aod::mcparticle::enums::ProducedByTransport; // mark as produced by transport | ||
| statusCode = mcParticles[particle].getProcess(); | ||
| } else { | ||
| statusCode = mcParticles[particle].getStatusCode(); | ||
| } | ||
| if (source == 0) { | ||
| flags |= o2::aod::mcparticle::enums::FromBackgroundEvent; // mark as particle from background event | ||
| flags |= 1 << 1; // mark as particle from background event | ||
| } | ||
| float weight = 0.f; | ||
| int mcMother0 = mcParticles[particle].getMotherTrackId(); | ||
|
|
@@ -857,6 +849,7 @@ uint8_t AODProducerWorkflowDPL::getTRDPattern(const o2::trd::TrackTRD& track) | |
| void AODProducerWorkflowDPL::init(InitContext& ic) | ||
| { | ||
| mTimer.Stop(); | ||
| mProdTags = ic.options().get<string>("prod-tags"); | ||
| mTFNumber = ic.options().get<int64_t>("aod-timeframe-id"); | ||
| mRecoOnly = ic.options().get<int>("reco-mctracks-only"); | ||
| mTruncate = ic.options().get<int>("enable-truncation"); | ||
|
|
@@ -903,6 +896,45 @@ void AODProducerWorkflowDPL::init(InitContext& ic) | |
| // Needed by MCH track extrapolation | ||
| o2::base::GeometryManager::loadGeometry(); | ||
|
|
||
| // writing metadata if it's not yet in AOD file | ||
| // note: `--aod-writer-resmode "UPDATE"` have to be used, | ||
| // so that metadata is not overwritten | ||
| mResFile += ".root"; | ||
| auto* fResFile = TFile::Open(mResFile, "UPDATE"); | ||
| if (fResFile) { | ||
| if (!fResFile->FindObjectAny("metaData")) { | ||
| std::vector<TString> vTags; | ||
| std::stringstream ss(mProdTags); | ||
| while (ss.good()) { | ||
| std::string substr; | ||
| std::getline(ss, substr, ','); | ||
| vTags.emplace_back(substr); | ||
| } | ||
| // assuming all tags passed as in `prod-tags` description | ||
| TString LPMProdTag = vTags[0]; | ||
| TString anchorPass = vTags[1]; | ||
| TString anchorProd = vTags[2]; | ||
| TString recoPass = vTags[3]; | ||
| // populating metadata map | ||
| mMetaData.Add(new TObjString("DataType"), new TObjString("MC")); | ||
| mMetaData.Add(new TObjString("Run"), new TObjString("3")); | ||
| TString converterVersion = "o2 "; | ||
| converterVersion += o2::fullVersion(); | ||
| converterVersion += " ; root "; | ||
| converterVersion += ROOT_RELEASE; | ||
| mMetaData.Add(new TObjString("Run3ConverterVersion"), new TObjString(converterVersion)); | ||
| mMetaData.Add(new TObjString("RecoPassName"), new TObjString(recoPass)); | ||
| mMetaData.Add(new TObjString("AnchorProduction"), new TObjString(anchorProd)); | ||
| mMetaData.Add(new TObjString("AnchorPassName"), new TObjString(anchorPass)); | ||
| mMetaData.Add(new TObjString("LPMProductionTag"), new TObjString(LPMProdTag)); | ||
| LOGF(info, "Metadata: writing into %s", mResFile); | ||
| fResFile->WriteObject(&mMetaData, "metaData"); | ||
| } else { | ||
| LOGF(info, "Metadata: target file not found or metadata is already written"); | ||
| } | ||
| fResFile->Close(); | ||
| } | ||
|
|
||
| mTimer.Reset(); | ||
| } | ||
|
|
||
|
|
@@ -1324,7 +1356,7 @@ void AODProducerWorkflowDPL::endOfStream(EndOfStreamContext& ec) | |
| mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1); | ||
| } | ||
|
|
||
| DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool useMC) | ||
| DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool useMC, std::string resFile) | ||
| { | ||
| std::vector<OutputSpec> outputs; | ||
| auto dataRequest = std::make_shared<DataRequest>(); | ||
|
|
@@ -1363,10 +1395,11 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool useMC) | |
| "aod-producer-workflow", | ||
| dataRequest->inputs, | ||
| outputs, | ||
| AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest)}, | ||
| AlgorithmSpec{adaptFromTask<AODProducerWorkflowDPL>(src, dataRequest, resFile)}, | ||
| Options{ | ||
| ConfigParamSpec{"aod-timeframe-id", VariantType::Int64, -1L, {"Set timeframe number"}}, | ||
| ConfigParamSpec{"enable-truncation", VariantType::Int, 1, {"Truncation parameter: 1 -- on, != 1 -- off"}}, | ||
| ConfigParamSpec{"prod-tags", VariantType::String, "LHC21Axx,pass1,LHC15o,pass1", {"Comma separated list of production tags: `LPMProductionTag,AnchorPassName,AnchorProduction,RecoPassName`"}}, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose one configSpec for each of the four strings
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, this would be better. Done in #7503 |
||
| ConfigParamSpec{"reco-mctracks-only", VariantType::Int, 0, {"Store only reconstructed MC tracks and their mothers/daughters. 0 -- off, != 0 -- on"}}}}; | ||
| } | ||
|
|
||
|
|
||
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
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.
Shouldn't this be written by using some O2 framework functions instead of doing it manually?
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.
It would be nice, but I'm not aware of a method that would allow writing an object outside of DF folder. Also, the code in this PR got mixed with some older code, so I will make another PR, where we can continue discussion :)
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.
@ktf could you comment?