Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Generators/include/Generators/GeneratorFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ class GeneratorFromEventPool : public o2::eventgen::Generator

void updateHeader(o2::dataformats::MCEventHeader* eventHeader) override
{
// Copy current vertex position from the event header
const double xyz[3] = {eventHeader->GetX(), eventHeader->GetY(), eventHeader->GetZ()};
mO2KineGenerator->updateHeader(eventHeader);
// Event pool uses vertex position from current simulation, only extKinO2 takes the one from the file instead
eventHeader->SetVertex(xyz[0], xyz[1], xyz[2]);
}

// determine the collection of available files
Expand Down
1 change: 1 addition & 0 deletions Generators/include/Generators/GeneratorHybrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class GeneratorHybrid : public Generator
bool mIsInitialized = false;

o2::dataformats::MCEventHeader mMCEventHeader; // to capture event headers
int mHeaderGeneratorIndex = -1; // index of the generator that updated the header in current event

enum class GenMode {
kSeq,
Expand Down
12 changes: 11 additions & 1 deletion Generators/src/GeneratorHybrid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ bool GeneratorHybrid::importParticles()

// Clear particles and event header
mParticles.clear();
mMCEventHeader.clearInfo();
// event header of underlying generator must be fully reset
// this is important when using extKinO2 or event pools where the full header information is forwarded from the generator
// otherwise some events might have mixed header information from different generators
mMCEventHeader.Reset();
if (mCocktailMode) {
// in cocktail mode we need to merge the particles from the different generators
bool baseGen = true; // first generator of the cocktail is used as reference to update the event header information
Expand Down Expand Up @@ -445,6 +448,7 @@ bool GeneratorHybrid::importParticles()
if (baseGen) {
gens[subIndex]->updateHeader(&mMCEventHeader);
baseGen = false;
mHeaderGeneratorIndex = subIndex; // store index of generator updating the header
}
mInputTaskQueue.push(subIndex);
mTasksStarted++;
Expand All @@ -467,6 +471,7 @@ bool GeneratorHybrid::importParticles()

// fetch the event Header information from the underlying generator
gens[genIndex]->updateHeader(&mMCEventHeader);
mHeaderGeneratorIndex = genIndex; // store index of generator updating the header
mInputTaskQueue.push(genIndex);
mTasksStarted++;
}
Expand All @@ -484,6 +489,11 @@ bool GeneratorHybrid::importParticles()
void GeneratorHybrid::updateHeader(o2::dataformats::MCEventHeader* eventHeader)
{
if (eventHeader) {
// Overwrite current vertex position only if extkinO2 is not used as underlying generator
if (mGens[mHeaderGeneratorIndex] != "extkinO2") {
mMCEventHeader.SetVertex(eventHeader->GetX(), eventHeader->GetY(), eventHeader->GetZ());
}
mHeaderGeneratorIndex = -1; // reset header generator index for next event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it here be simply possible to delegate to mGens[mHeaderGeneratorIndex]->updateHeader() to do whatever it has to do? The if looks a bit awkward.

// Forward the base class fields from FairMCEventHeader
static_cast<FairMCEventHeader&>(*eventHeader) = static_cast<FairMCEventHeader&>(mMCEventHeader);
// Copy the key-value store info
Expand Down
Loading