Skip to content
Merged
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
3 changes: 2 additions & 1 deletion Common/SimConfig/include/SimConfig/SimConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ enum class SimFieldMode {
enum class VertexMode {
kNoVertex = 0, // no vertexing should be applied in the generator
kDiamondParam = 1, // Diamond param will influence vertexing
kCCDB = 2 // vertex should be taken from CCDB (Calib/MeanVertex object)
kCCDB = 2, // vertex should be taken from CCDB (Calib/MeanVertex object)
kCollCxt = 3 // vertex should be taken from collision context
};

enum class TimeStampMode {
Expand Down
5 changes: 4 additions & 1 deletion Common/SimConfig/src/SimConfig.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,11 @@ bool SimConfig::parseVertexModeString(std::string const& vertexstring, VertexMod
} else if (vertexstring == "kCCDB") {
mode = VertexMode::kCCDB;
return true;
} else if (vertexstring == "kCollContext") {
mode = VertexMode::kCollCxt;
return true;
}
LOG(error) << "Vertex mode must be one of kNoVertex, kDiamondParam, kCCDB";
LOG(error) << "Vertex mode must be one of kNoVertex, kDiamondParam, kCCDB, kCollContext";
return false;
}

Expand Down
9 changes: 8 additions & 1 deletion Generators/src/PrimaryGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ void PrimaryGenerator::setVertexMode(o2::conf::VertexMode const& mode, o2::dataf
LOG(info) << "The mean vertex is set to :";
mMeanVertex->print();
}
if (mVertexMode == o2::conf::VertexMode::kNoVertex) {
setApplyVertex(false);
LOG(info) << "Disabling vertexing";
mMeanVertex = std::move(std::unique_ptr<o2::dataformats::MeanVertexObject>(new o2::dataformats::MeanVertexObject(0, 0, 0, 0, 0, 0, 0, 0)));
LOG(info) << "The mean vertex is set to :";
mMeanVertex->print();
}
}

/*****************************************************************/
Expand Down Expand Up @@ -298,7 +305,7 @@ void PrimaryGenerator::fixInteractionVertex()
SmearGausVertexZ(false);

// we use the mMeanVertexObject if initialized (initialize first)
if (!mMeanVertex) {
if (mMeanVertex.get() == nullptr) {
if (mVertexMode == o2::conf::VertexMode::kDiamondParam) {
auto const& param = InteractionDiamondParam::Instance();
const auto& xyz = param.position;
Expand Down
7 changes: 5 additions & 2 deletions run/O2PrimaryServerDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class O2PrimaryServerDevice final : public fair::mq::Device
} else if (vtxMode == VertexMode::kCCDB) {
// we need to fetch the CCDB object
mPrimGen->setVertexMode(vtxMode, ccdbmgr.getForTimeStamp<o2::dataformats::MeanVertexObject>("GLO/Calib/MeanVertex", conf.getTimestamp()));
} else if (vtxMode == VertexMode::kCollCxt) {
// The vertex will be injected from the outside via setExternalVertex
} else {
LOG(fatal) << "Unsupported vertex mode";
}
Expand Down Expand Up @@ -186,13 +188,14 @@ class O2PrimaryServerDevice final : public fair::mq::Device
const int MAX_RETRY = 100;
do {
mStack->Reset();
const auto& conf = mSimConfig;
// see if we the vertex comes from the collision context
if (mCollissionContext) {
if (mCollissionContext && conf.getVertexMode() == o2::conf::VertexMode::kCollCxt) {
const auto& vertices = mCollissionContext->getInteractionVertices();
if (vertices.size() > 0) {
auto collisionindex = mEventID_to_CollID.at(mEventCounter);
auto& vertex = vertices.at(collisionindex);
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix();
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix() << " from CollContext";
mPrimGen->setExternalVertexForNextEvent(vertex.X(), vertex.Y(), vertex.Z());
}
}
Expand Down