Skip to content

Commit 7a1dd9e

Browse files
committed
Add possibility to apply signal filtering for MC with embedding
1 parent f72e1a2 commit 7a1dd9e

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class AODProducerWorkflowDPL : public Task
256256

257257
int mNThreads = 1;
258258
bool mUseMC = true;
259+
bool mUseSigFiltMC = false; // enable signal filtering for MC with embedding
259260
bool mEnableSV = true; // enable secondary vertices
260261
bool mEnableFITextra = false;
261262
bool mFieldON = false;

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,13 +947,17 @@ void clearMCKeepStore(std::vector<std::vector<std::unordered_map<int, int>>>& st
947947
}
948948

949949
// helper function to add a particle/track to the MC keep store
950-
void keepMCParticle(std::vector<std::vector<std::unordered_map<int, int>>>& store, int source, int event, int track, int value = 1)
950+
void keepMCParticle(std::vector<std::vector<std::unordered_map<int, int>>>& store, int source, int event, int track, int value = 1, bool useSigFilt = false)
951951
{
952952
if (track < 0) {
953953
LOG(warn) << "trackID is smaller than 0. Neglecting";
954954
return;
955955
}
956-
store[source][event][track] = value;
956+
if (useSigFilt && source == 0) {
957+
store[source][event][track] = -1;
958+
} else {
959+
store[source][event][track] = value;
960+
}
957961
}
958962

959963
void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader& mcReader,
@@ -982,7 +986,7 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
982986
if (!mcLabel.isValid()) {
983987
return;
984988
}
985-
keepMCParticle(mToStore, mcLabel.getSourceID(), mcLabel.getEventID(), mcLabel.getTrackID());
989+
keepMCParticle(mToStore, mcLabel.getSourceID(), mcLabel.getEventID(), mcLabel.getTrackID(), 1, mUseSigFiltMC);
986990
};
987991

988992
// mark reconstructed MC particles to store them into the table
@@ -997,7 +1001,7 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
9971001
if (!mcTruth.isValid()) {
9981002
continue;
9991003
}
1000-
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID());
1004+
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID(), 1, mUseSigFiltMC);
10011005
// treating contributors of global tracks
10021006
auto contributorsGID = data.getSingleDetectorRefs(trackIndex);
10031007
if (contributorsGID[GIndex::Source::TPC].isIndexSet()) {
@@ -1012,7 +1016,7 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
10121016
if (!mcLabel.isValid()) {
10131017
continue;
10141018
}
1015-
keepMCParticle(mToStore, mcLabel.getSourceID(), mcLabel.getEventID(), mcLabel.getTrackID());
1019+
keepMCParticle(mToStore, mcLabel.getSourceID(), mcLabel.getEventID(), mcLabel.getTrackID(), 1, mUseSigFiltMC);
10161020
}
10171021
}
10181022
}
@@ -1026,7 +1030,7 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
10261030
if (!mcTruth.isValid()) {
10271031
continue;
10281032
}
1029-
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID());
1033+
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID(), 1, mUseSigFiltMC);
10301034
}
10311035
}
10321036
if (mInputSources[GIndex::PHS]) {
@@ -1035,7 +1039,7 @@ void AODProducerWorkflowDPL::fillMCParticlesTable(o2::steer::MCKinematicsReader&
10351039
if (!mcTruth.isValid()) {
10361040
continue;
10371041
}
1038-
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID());
1042+
keepMCParticle(mToStore, mcTruth.getSourceID(), mcTruth.getEventID(), mcTruth.getTrackID(), 1, mUseSigFiltMC);
10391043
}
10401044
}
10411045
using namespace aodmchelpers;
@@ -1728,6 +1732,8 @@ void AODProducerWorkflowDPL::init(InitContext& ic)
17281732
LOG(info) << "The Run number will be obtained from DPL headers";
17291733
}
17301734

1735+
mUseSigFiltMC = ic.options().get<bool>("mc-signal-filt");
1736+
17311737
// set no truncation if selected by user
17321738
if (mTruncate != 1) {
17331739
LOG(info) << "Truncation is not used!";
@@ -2083,7 +2089,9 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
20832089
0,
20842090
sourceID);
20852091
}
2086-
mcColToEvSrc.emplace_back(std::vector<int>{iCol, sourceID, eventID}); // point background and injected signal events to one collision
2092+
if (sourceID != 0 || !mUseSigFiltMC) {
2093+
mcColToEvSrc.emplace_back(std::vector<int>{iCol, sourceID, eventID}); // point background and injected signal events to one collision
2094+
}
20872095
}
20882096
}
20892097
}
@@ -3311,6 +3319,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo
33113319
ConfigParamSpec{"trackqc-tpc-pt", VariantType::Float, 0.2f, {"Keep TPC standalone track with this pt"}},
33123320
ConfigParamSpec{"with-streamers", VariantType::String, "", {"Bit-mask to steer writing of intermediate streamer files"}},
33133321
ConfigParamSpec{"seed", VariantType::Int, 0, {"Set seed for random generator used for sampling (0 (default) means using a random_device)"}},
3322+
ConfigParamSpec{"mc-signal-filt", VariantType::Bool, false, {"Enable usage of signal filtering (only for MC with embedding)"}}
33143323
}};
33153324
}
33163325

0 commit comments

Comments
 (0)