Skip to content

Commit cf85a4c

Browse files
committed
PrimaryGen: More consistent vertex configuration
* do not apply a vertex when the mode is kNoVertex (this was buggy) * introduce a new vertex mode kCollContext to indicate the the vertex is to be taken from a collision context
1 parent 513970b commit cf85a4c

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ enum class SimFieldMode {
3737
enum class VertexMode {
3838
kNoVertex = 0, // no vertexing should be applied in the generator
3939
kDiamondParam = 1, // Diamond param will influence vertexing
40-
kCCDB = 2 // vertex should be taken from CCDB (Calib/MeanVertex object)
40+
kCCDB = 2, // vertex should be taken from CCDB (Calib/MeanVertex object)
41+
kCollCxt = 3 // vertex should be taken from collision context
4142
};
4243

4344
enum class TimeStampMode {

Common/SimConfig/src/SimConfig.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,11 @@ bool SimConfig::parseVertexModeString(std::string const& vertexstring, VertexMod
391391
} else if (vertexstring == "kCCDB") {
392392
mode = VertexMode::kCCDB;
393393
return true;
394+
} else if (vertexstring == "kCollContext") {
395+
mode = VertexMode::kCollCxt;
396+
return true;
394397
}
395-
LOG(error) << "Vertex mode must be one of kNoVertex, kDiamondParam, kCCDB";
398+
LOG(error) << "Vertex mode must be one of kNoVertex, kDiamondParam, kCCDB, kCollContext";
396399
return false;
397400
}
398401

Generators/src/PrimaryGenerator.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ void PrimaryGenerator::setVertexMode(o2::conf::VertexMode const& mode, o2::dataf
270270
LOG(info) << "The mean vertex is set to :";
271271
mMeanVertex->print();
272272
}
273+
if (mVertexMode == o2::conf::VertexMode::kNoVertex) {
274+
setApplyVertex(false);
275+
LOG(info) << "Disabling vertexing";
276+
mMeanVertex = std::move(std::unique_ptr<o2::dataformats::MeanVertexObject>(new o2::dataformats::MeanVertexObject(0, 0, 0, 0, 0, 0, 0, 0)));
277+
LOG(info) << "The mean vertex is set to :";
278+
mMeanVertex->print();
279+
}
273280
}
274281

275282
/*****************************************************************/
@@ -298,7 +305,7 @@ void PrimaryGenerator::fixInteractionVertex()
298305
SmearGausVertexZ(false);
299306

300307
// we use the mMeanVertexObject if initialized (initialize first)
301-
if (!mMeanVertex) {
308+
if (mMeanVertex.get() == nullptr) {
302309
if (mVertexMode == o2::conf::VertexMode::kDiamondParam) {
303310
auto const& param = InteractionDiamondParam::Instance();
304311
const auto& xyz = param.position;

run/O2PrimaryServerDevice.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class O2PrimaryServerDevice final : public fair::mq::Device
127127
} else if (vtxMode == VertexMode::kCCDB) {
128128
// we need to fetch the CCDB object
129129
mPrimGen->setVertexMode(vtxMode, ccdbmgr.getForTimeStamp<o2::dataformats::MeanVertexObject>("GLO/Calib/MeanVertex", conf.getTimestamp()));
130+
} else if (vtxMode == VertexMode::kCollCxt) {
131+
// The vertex will be injected from the outside via setExternalVertex
130132
} else {
131133
LOG(fatal) << "Unsupported vertex mode";
132134
}
@@ -186,13 +188,14 @@ class O2PrimaryServerDevice final : public fair::mq::Device
186188
const int MAX_RETRY = 100;
187189
do {
188190
mStack->Reset();
191+
const auto& conf = mSimConfig;
189192
// see if we the vertex comes from the collision context
190-
if (mCollissionContext) {
193+
if (mCollissionContext && conf.getVertexMode() == o2::conf::VertexMode::kCollCxt) {
191194
const auto& vertices = mCollissionContext->getInteractionVertices();
192195
if (vertices.size() > 0) {
193196
auto collisionindex = mEventID_to_CollID.at(mEventCounter);
194197
auto& vertex = vertices.at(collisionindex);
195-
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix();
198+
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix() << " from CollContext";
196199
mPrimGen->setExternalVertexForNextEvent(vertex.X(), vertex.Y(), vertex.Z());
197200
}
198201
}

0 commit comments

Comments
 (0)