Skip to content

Commit be4f97a

Browse files
committed
o2-sim: Ability to focus/select a particular chunk to transport
For debugging purposes, it is sometimes of advantage to skip to a particular event chunk for debugging. This commit allows to select an event-ID + event-Part for transport. Everything else will be skipped. This is useful in situations where we know of a bug in certain event and we'd would like to study this-and-only-this event (under same seeding). The event-part selection is done via env variable `O2SIM_RESTRICT_EVENTPART=event:part`
1 parent 5fa35b2 commit be4f97a

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

run/O2SimDevice.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,28 @@ class O2SimDevice final : public fair::mq::Device
205205
reproducibleSim = false;
206206
}
207207

208+
// Mainly for debugging reasons, we allow to transport
209+
// a specific event + eventpart. This allows to reproduce and debug bugs faster, once
210+
// we know in which precise chunk they occur. The expected format for the environment variable
211+
// is "eventnum:partid".
212+
auto eventselection = getenv("O2SIM_RESTRICT_EVENTPART");
213+
int focus_on_event = -1;
214+
int focus_on_part = -1;
215+
if (eventselection) {
216+
auto splitString = [](const std::string& str) {
217+
std::pair<std::string, std::string> parts;
218+
size_t pos = str.find(':');
219+
if (pos != std::string::npos) {
220+
parts.first = str.substr(0, pos);
221+
parts.second = str.substr(pos + 1);
222+
}
223+
return parts;
224+
};
225+
auto p = splitString(eventselection);
226+
focus_on_event = std::atoi(p.first.c_str());
227+
focus_on_part = std::atoi(p.second.c_str());
228+
}
229+
208230
fair::mq::MessagePtr request(requestchannel.NewSimpleMessage(PrimaryChunkRequest{workerID, -1, counter++})); // <-- don't need content; channel means -> give primaries
209231
fair::mq::Parts reply;
210232

@@ -252,14 +274,22 @@ class O2SimDevice final : public fair::mq::Device
252274
}
253275

254276
if (goon) {
255-
mVMCApp->setPrimaries(chunk->mParticles);
256277

257278
auto info = chunk->mSubEventInfo;
258-
mVMCApp->setSubEventInfo(&info);
259-
260279
LOG(info) << workerStr() << " Processing " << chunk->mParticles.size() << " primary particles "
261280
<< "for event " << info.eventID << "/" << info.maxEvents << " "
262281
<< "part " << info.part << "/" << info.nparts;
282+
283+
if (eventselection == nullptr || (focus_on_event == info.eventID && focus_on_part == info.part)) {
284+
mVMCApp->setPrimaries(chunk->mParticles);
285+
} else {
286+
// nothing to transport here
287+
mVMCApp->setPrimaries(std::vector<TParticle>{});
288+
LOG(info) << workerStr() << " This chunk will be skipped";
289+
}
290+
291+
mVMCApp->setSubEventInfo(&info);
292+
263293
if (reproducibleSim) {
264294
LOG(info) << workerStr() << " Setting seed for this sub-event to " << chunk->mSubEventInfo.seed;
265295
gRandom->SetSeed(chunk->mSubEventInfo.seed);

0 commit comments

Comments
 (0)