Skip to content

Commit 73044db

Browse files
sawenzelalcaliva
authored andcommitted
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 (cherry picked from commit cf85a4c)
1 parent bc24847 commit 73044db

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
@@ -122,6 +122,8 @@ class O2PrimaryServerDevice final : public fair::mq::Device
122122
} else if (vtxMode == VertexMode::kCCDB) {
123123
// we need to fetch the CCDB object
124124
mPrimGen->setVertexMode(vtxMode, ccdbmgr.getForTimeStamp<o2::dataformats::MeanVertexObject>("GLO/Calib/MeanVertex", conf.getTimestamp()));
125+
} else if (vtxMode == VertexMode::kCollCxt) {
126+
// The vertex will be injected from the outside via setExternalVertex
125127
} else {
126128
LOG(fatal) << "Unsupported vertex mode";
127129
}
@@ -181,13 +183,14 @@ class O2PrimaryServerDevice final : public fair::mq::Device
181183
const int MAX_RETRY = 100;
182184
do {
183185
mStack->Reset();
186+
const auto& conf = mSimConfig;
184187
// see if we the vertex comes from the collision context
185-
if (mCollissionContext) {
188+
if (mCollissionContext && conf.getVertexMode() == o2::conf::VertexMode::kCollCxt) {
186189
const auto& vertices = mCollissionContext->getInteractionVertices();
187190
if (vertices.size() > 0) {
188191
auto collisionindex = mEventID_to_CollID.at(mEventCounter);
189192
auto& vertex = vertices.at(collisionindex);
190-
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix();
193+
LOG(info) << "Setting vertex " << vertex << " for event " << mEventCounter << " for prefix " << mSimConfig.getOutPrefix() << " from CollContext";
191194
mPrimGen->setExternalVertexForNextEvent(vertex.X(), vertex.Y(), vertex.Z());
192195
}
193196
}

0 commit comments

Comments
 (0)