Skip to content

Commit d7863b5

Browse files
authored
Update DetectorSimulation.md
1 parent b442a31 commit d7863b5

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

doc/DetectorSimulation.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ for (auto& label : labels_for_digit) {
416416
```
417417

418418

419-
## Accessing Monte Carlo kinematics after the digitization phase <a name="MCReader"></a>
419+
## Accessing Monte Carlo kinematics<a name="MCReader"></a>
420420

421421
After digitization is done, one can use the `MCKinematicsReader` class to load and access the Monte Carlo tracks.
422422
The MCKinematicsReader needs the digitization context file, generated during digitization. Once initialized it can return the tracks associated to a Monte Carlo label.
@@ -442,7 +442,20 @@ for (int pos = 0; pos < alldigits.size(); ++pos) {
442442
}
443443
```
444444
Note, that one can also access kinematics directly after the transport simulation.
445-
In this case, one needs to initialize the MCKinematicsReader in a different mode.
445+
In this case, one needs to initialize the MCKinematicsReader in a different mode:
446+
```c++
447+
// init the reader from the transport kinematics file (assuming here prefix o2sim)
448+
o2::steer::MCKinematicsReader reader("o2sim", o2::steer::MCKinematicsReader::Mode::kMCKine);
449+
450+
// loop over all events in the file
451+
for (int event = 0; event < reader.getNEvents(0); ++event) {
452+
// get all Monte Carlo tracks for this event
453+
std::vector<MCTrack> const& tracks = reader.getTracks(event);
454+
455+
// analyse tracks
456+
}
457+
```
458+
446459

447460
# Simulation tutorials/examples <a name="Examples"></a>
448461

0 commit comments

Comments
 (0)