Skip to content

Commit

Permalink
simple collision time setup for mctracks-to-aod
Browse files Browse the repository at this point in the history
  • Loading branch information
aalkin authored and sawenzel committed Aug 10, 2023
1 parent ac53eb8 commit e7f8ac9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions run/o2sim_mctracks_to_aod.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
#include "SimulationDataFormat/MCEventHeader.h"
#include "SimulationDataFormat/MCUtils.h"
#include "Framework/AnalysisDataModel.h"
#include "SimulationDataFormat/InteractionSampler.h"

using namespace o2::framework;

struct McTracksToAOD {
size_t bcCounter = 0;
Produces<o2::aod::McCollisions> mcollisions;
Produces<o2::aod::StoredMcParticles_001> mcparticles;
Configurable<float> IR{"interaction-rate", 100.f, "Interaction rate to simulate"};

long timeframe = 0;
uint64_t timeframe = 0;
o2::steer::InteractionSampler sampler;

void init(o2::framework::InitContext& /*ic*/) {}
void init(o2::framework::InitContext& /*ic*/)
{
sampler.setInteractionRate(IR);
sampler.setFirstIR({0, 0});
sampler.init();
}

void run(o2::framework::ProcessingContext& pc)
{
Expand All @@ -35,17 +42,20 @@ struct McTracksToAOD {
LOG(warn) << "Mismatch between number of MC headers and number of track vectors: " << Nparts << " != " << Nparts_verify << ", shipping the empty timeframe";
return;
}
// TODO: include BC simulation
auto bcCounter = 0UL;
for (auto i = 0U; i < Nparts; ++i) {
auto record = sampler.generateCollisionTime();
auto mcheader = pc.inputs().get<o2::dataformats::MCEventHeader*>("mcheader", i);
auto mctracks = pc.inputs().get<std::vector<o2::MCTrack>>("mctracks", i);

mcollisions(bcCounter++, // bc
mcollisions(bcCounter++, // bcId
0, // generatorId
mcheader->GetX(),
mcheader->GetY(),
mcheader->GetZ(),
mcheader->GetT(),
1., // weight
record.timeInBCNS * 1.e-3, // ns to ms
1., // weight
mcheader->GetB());
for (auto& mctrack : mctracks) {
std::vector<int> mothers;
Expand Down

0 comments on commit e7f8ac9

Please sign in to comment.