You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* store TGeoManager::GetPath() in MCStepLogger if track enters to
restore geometry in replay. This is necessary in particular in case of
steps on or in the vincinity of boundaries. Floating point precision
might not be enough to find a node based on spatial coordinates. In
addition, restoring from the path makes navigation and node finding
obsolete during replay
* extract TGEoVolume ID to VMC volume ID mapping. These are not the same
for Geant4_VMC hence it is necessary. Mapping is required in replay,
otheriwse, hit processing can fail.
Mapping during replay is skipped if it is the identity.
* make replay work for Geant4_VMC. This works thanks to above additions.
* add possibility to load a custom user keepStep function from a ROOT
macro
* update MCReplay/README.md
* additional small fixes
Copy file name to clipboardExpand all lines: MCReplay/README.md
+20-11Lines changed: 20 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,32 +4,36 @@ This is a pseudo-detector-simulation engine based on the [Virtual Monte Carlo (V
4
4
5
5
The main objective is to be able to provide an engine to study the impact of parameter variations with. Eventually, this can be used to optimise (full-)simulation parameters in view of enhancing their speed and efficiency.
6
6
7
-
The functionality is compiled into a separate library `libTMCReplay` which also allows to use the `libMCStepLoggerIntercept` which also allows to run the step logging against the `TMCReplay` engine.
7
+
The functionality is compiled into a separate library `libMCReplayCore`. Hence, `libMCStepLoggerIntercept` is completely independent which also allows to run the step logging against the `MCReplayEngine` engine.
8
+
9
+
The replay has been tested and is verified against [GEANT3_VMC](https://github.com/vmc-project/geant3) and [GEANT4_VMC](https://github.com/vmc-project/geant4_vmc) VMC interfaces.
8
10
9
11
## Setting parameters
10
12
11
-
The list of tunable parameters is foreseen to correspond to the possible settings implemented for [GEANT3_VMC]() and [GEANT4_VMC](https://github.com/vmc-project/geant4_vmc) and can be found [here](include/TMCReplay/Physics.h). The parameters can be set via the usual interfaces
12
-
*`TVirtualMC::SetCut` and `TVirtualMC::SetProcess` to set global cut and process values
13
-
*`TVirtualMC::Gstpar` to set parameters depending on a certain medium
13
+
The list of tunable parameters is foreseen to correspond to the possible settings implemented for GEANT3_VMC and GEANT4_VMC and can be found [here](include/MCReplay/MCReplayPhysics.h). The parameters can be set via the usual interfaces
14
+
*`TVirtualMC::SetCut` and `TVirtualMC::SetProcess` to set global cut and process values,
15
+
*`TVirtualMC::Gstpar` to set parameters depending on a certain medium.
16
+
The cut parameters act like production cuts.
14
17
15
18
**Please note** that the parameters can be set but at the moment nothing is actually applied. Therefore, the exact same steps would be reproduced regardless of the parameters. Of course, this is the next major development as it is one of the core objectives of this engine.
19
+
**On the other hand**, there is one special parameter called `CUTALLE` which is an energy production cut on **any** PDG which can also be set through the aforementioned interfaces. Note, that this parameter has no meaning to GEANT3_VMC or GEANT4_VMC.
16
20
17
21
## Testing different parameter settings
18
22
19
-
**Note that this section becomes actually meaningful when the aforementioned functionality will have been implemented.** However, in the current state it can already be verified that the `TMCReplay` engine does what it is supposed to do.
23
+
**Note that this section becomes actually meaningful when the aforementioned functionality will have been implemented.** However, in the current state it can already be verified that the `MCReplayEngine` engine does what it is supposed to do.
20
24
21
-
### Running/testing on step level only (`TMCReplayDummyApplication` and `TMCReplayDummyStack`)
25
+
### Running/testing on step level only (`MCReplayGenericApplication` and `MCReplayGenericStack`)
22
26
23
-
If only the impact on the steps is desired, all required functionality is already included here. Simply have a look at [this executable](src/replay.cxx). It makes use of the `TMCReplayDummyApplication` and `TMCReplayDummyStack` just to replay the steps. Once implemented, the impact of the parameters on the stepping can be evaluated with this tool alone. To do so, just run the `MCStepLogger`together with the replay, for instance as follows
27
+
If only the replay of steps is desired, all required functionality is already included here, completely independent of any environment the reference run was done. Simply have a look at [this code](src/replay.cxx) serving as the source for the executable `mcreplay`. It makes use of the `MCReplayGenericApplication` and `MCReplayGenericStack` just to replay the steps. Once implemented, the impact of the parameters on the stepping can be evaluated with this tool alone. To do so, just run the `MCStepLogger`followed by the replay, for instance as follows (assuming everything was setup with `aliBuild`)
That will pick up the step file `MCStepLoggerOutput.root`. If you gave that a different name (or in case also your contained tree has another name), you will find the following help message useful:
30
34
31
35
```bash
32
-
>tmcreplay --help
36
+
>mcreplay --help
33
37
Replaying a previously recorded particle transport step-by-step. Mainly meant for checking and performance measurements/optimisation of the transport:
34
38
--help show this help message and exit
35
39
--stepfilename arg (=MCStepLoggerOutput.root)
@@ -40,13 +44,18 @@ Replaying a previously recorded particle transport step-by-step. Mainly meant fo
40
44
ROOT geometry filename
41
45
--geokeyname arg (=FAIRGeom) key name inside geo file where to find
42
46
geometry tree
43
-
47
+
-n [ --nevents ] arg (=-1) number of events to replay
48
+
-e [ --energycut ] arg (=-1) energy cut to be applied [GeV]
44
49
```
45
50
46
-
As you can see the geometry is required by this executable as well since it has otherwise no idea what geometry was used for the original simulation.
51
+
As you can see the geometry is required by this executable as well since it has otherwise no idea what the geometry should look like from the `MCStepLoggerOutput.root` file alone.
47
52
48
53
### Running in another environment
49
54
50
55
In that case the geometry construction is assumed to implemented by that environment's implementation of `TVirtualMCApplication`. Also, no stack is constructed automatically and it has to be constructed and passed by the user.
51
56
52
57
Such a scenario is useful to evaluate the impact of parameter variation on hits or even digits.
58
+
59
+
## Using the engine as a full simulation engine
60
+
61
+
The `MCReplayEngine` has been tested with the [ALICE O2 framework](https://github.com/AliceO2Group/AliceO2) and also hits can be reproduced sufficiently which allows for realistic parameter tuning.
// map volume IDs assigned by the TGeoManager (replay engine) to those assigned by the engine used in the reference run
1108
+
Int_t correctGeoVolID(Int_t geoVolId) const;
1109
+
Int_t correctVMCVolID(Int_t vmcVolId) const;
1102
1110
1103
1111
// That is just a helper function to address some of the
1104
1112
// interactions with the TGeoManager
@@ -1130,7 +1138,6 @@ class MCReplayEngine : public TVirtualMC
1130
1138
{
1131
1139
auto paramIndex = physics::paramToIndex(allParamsNames, paramName);
1132
1140
if (paramIndex < 0) {
1133
-
Warning("Could not set parameter %s, unknown and therefore skipped", paramName);
1134
1141
returnfalse;
1135
1142
}
1136
1143
@@ -1151,7 +1158,6 @@ class MCReplayEngine : public TVirtualMC
1151
1158
{
1152
1159
auto paramIndex = physics::paramToIndex(allParamsNames, paramName);
1153
1160
if (paramIndex < 0) {
1154
-
Warning("Could not set parameter %s, unknown and therefore skipped", paramName);
1155
1161
returnfalse;
1156
1162
}
1157
1163
insertInto[paramIndex] = parval;
@@ -1174,6 +1180,11 @@ class MCReplayEngine : public TVirtualMC
1174
1180
std::string mStepLoggerFilename;
1175
1181
std::string mStepLoggerTreename;
1176
1182
1183
+
// mapping volume IDs correctly; a reference run might assign other volume IDs than those which would be assigned only by the TGeoManager. Hence, we need to make sure that - whatever engine was used before - we mimic the exact same volume IDs. Otherwise, the logged IDs and those assigned by this engine based on the TGeoManager are not aligned
1184
+
std::vector<int> mVolIDMap;
1185
+
std::vector<int> mVolIDMapInverse;
1186
+
boolmNeedVolIdMapping = false;
1187
+
1177
1188
// pointer to opened step file
1178
1189
TFile* mStepFile = nullptr;
1179
1190
@@ -1190,6 +1201,11 @@ class MCReplayEngine : public TVirtualMC
1190
1201
o2::StepLookups* mCurrentLookups = nullptr;
1191
1202
o2::StepInfo* mCurrentStep = nullptr;
1192
1203
1204
+
// keep track of tracks to be skipped
1205
+
std::vector<bool> mSkipTrack;
1206
+
// keep track of track ID assigned by user stack
1207
+
std::vector<int> mUserTrackId;
1208
+
1193
1209
// current event ID
1194
1210
intmCurrentEvent = 0;
1195
1211
@@ -1209,6 +1225,10 @@ class MCReplayEngine : public TVirtualMC
1209
1225
// point to the current map of cuts
1210
1226
std::vector<Double_t>* mCurrentCuts = nullptr;
1211
1227
1228
+
// a user defined cut function, return true if step should be kept, false otherwise
0 commit comments