Skip to content

Commit bccd760

Browse files
committed
More flexibel use of event setup from collisioncontext
can now give --fromCollContext file[:prefix] on the command line to specify prefix to use (previously less flexible).
1 parent 4be913d commit bccd760

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class SimConfig
180180
SimConfigData mConfigData; //!
181181

182182
// adjust/overwrite some option settings when collision context is used
183-
void adjustFromCollContext();
183+
void adjustFromCollContext(std::string const& collcontextfile, std::string const& prefix);
184184

185185
ClassDefNV(SimConfig, 1);
186186
};

Common/SimConfig/src/SimConfig.cxx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,17 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
256256
mConfigData.mFilterNoHitEvents = true;
257257
}
258258
mConfigData.mFromCollisionContext = vm["fromCollContext"].as<std::string>();
259-
adjustFromCollContext();
259+
// we decompose the argument to fetch
260+
// (a) collision contextfilename
261+
// (b) sim prefix to use from the context
262+
auto pos = mConfigData.mFromCollisionContext.find(':');
263+
std::string collcontextfile{mConfigData.mFromCollisionContext};
264+
std::string simprefix{mConfigData.mOutputPrefix};
265+
if (pos != std::string::npos) {
266+
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
267+
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
268+
}
269+
adjustFromCollContext(collcontextfile, simprefix);
260270

261271
// analyse vertex options
262272
if (!parseVertexModeString(vm["vertexMode"].as<std::string>(), mConfigData.mVertexMode)) {
@@ -323,28 +333,28 @@ bool SimConfig::parseFieldString(std::string const& fieldstring, int& fieldvalue
323333
return true;
324334
}
325335

326-
void SimConfig::adjustFromCollContext()
336+
void SimConfig::adjustFromCollContext(std::string const& collcontextfile, std::string const& prefix)
327337
{
328338
// When we use pregenerated collision contexts, some options
329339
// need to be auto-adjusted. Do so and inform about this in the logs.
330-
if (mConfigData.mFromCollisionContext == "") {
340+
if (collcontextfile == "") {
331341
return;
332342
}
333343

334-
auto context = o2::steer::DigitizationContext::loadFromFile(mConfigData.mFromCollisionContext);
344+
auto context = o2::steer::DigitizationContext::loadFromFile(collcontextfile);
335345
if (context) {
336346
// find the events belonging to a source that corresponds to a sim prefix
337-
LOG(info) << "Looking up simprefixes " << mConfigData.mOutputPrefix;
338-
int sourceid = context->findSimPrefix(mConfigData.mOutputPrefix);
347+
LOG(info) << "Looking up simprefixes " << prefix;
348+
int sourceid = context->findSimPrefix(prefix);
339349
if (sourceid == -1) {
340-
LOG(error) << "Could not find collisions with sim prefix " << mConfigData.mOutputPrefix << " in the collision context. The collision contet specifies the following prefixes:";
341-
for (auto& prefix : context->getSimPrefixes()) {
342-
LOG(info) << prefix;
350+
LOG(error) << "Could not find collisions with sim prefix " << prefix << " in the collision context. The collision context specifies the following prefixes:";
351+
for (auto& sp : context->getSimPrefixes()) {
352+
LOG(info) << sp;
343353
}
344354
LOG(fatal) << "Aborting due to prefix error";
345355
} else {
346356
auto collisionmap = context->getCollisionIndicesForSource(sourceid);
347-
LOG(info) << "Found " << collisionmap.size() << " events in the collisioncontext for prefix " << mConfigData.mOutputPrefix;
357+
LOG(info) << "Found " << collisionmap.size() << " events in the collisioncontext for prefix " << prefix;
348358

349359
// check if collisionmap is dense (otherwise it will get screwed up with order/indexing in ROOT output)
350360
bool good = true;
@@ -368,7 +378,7 @@ void SimConfig::adjustFromCollContext()
368378
LOG(info) << "Setting number of events to simulate to " << mConfigData.mNEvents;
369379
}
370380
} else {
371-
LOG(fatal) << "Could not open collision context file " << mConfigData.mFromCollisionContext;
381+
LOG(fatal) << "Could not open collision context file " << collcontextfile;
372382
}
373383
}
374384

0 commit comments

Comments
 (0)