We use the
fwmugen generator on
GeneratorFactory.cxx to evaluate the MFT. However, to make changes on the event parameters we need to compile O2. This approach is cumbersome and prevents automations. I wonder if there is a better way of configuring the generators to change multiplicity, rapidity and pT ranges, vertex position, and so on without recompiling O2?
Thanks in advance,
I am not an expert but what I did to have a variable multiplicity was to simply add it as an option in the
SimConfig class. You can then get the information from the SimConfig object in the
GeneratorFactory.cxx. The option can be passed to the simulation when you start it making automation easy.
This should work for all the properties you want.
Maybe its not the best way but for me it worked.
I hope this helps.
Thanks for pointing to
SimConfig. The boxgen generator can be configured for 10 events with 100 forward muons with the following command:
o2-sim-serial -m MFT -e TGeant3 -g boxgen -n 10 --configKeyValues 'BoxGun.pdg=13 ; BoxGun.eta=-3.6 ; BoxGun.eta=-2.45; BoxGun.number=100'
Correct. You could make a parameter in a similar way done for BoxGun and fetch the values in the GeneratorFactory.
Hi Sandro, all,
this proposal (thanks Thomas!) solves all but one issue. How do we add a realistic vertex distribution to the generation of the events? As far as I see, now all events are generated at the nominal zero.
I changed the GeneratorFactory and BoxGunParameter to provide the option to set the vertex position and the vertex range. It is implemented in the boxgunvertex branch of my fork and can be used as.
o2-sim -m MFT -e TGeant3 -g boxgen -n 10 --configKeyValues 'BoxGun.pdg=13 ; BoxGun.eta=-3.9 ; BoxGun.eta=-2.1; BoxGun.prange=0.1 ; BoxGun.prange=5 ; BoxGun.vertexXYZ=-15 ; BoxGun.number=20'
For vertex ranges, this branch has a new generator named
boxgenvrange that can be used as
o2-sim -m MFT -e TGeant3 -g boxgenvrange -n 10 --configKeyValues 'BoxGun.pdg=13 ; BoxGun.eta=-3.9 ; BoxGun.eta=-2.1; BoxGun.prange=0.1 ; BoxGun.prange=5 ; BoxGun.vertexRange=-.1 ; BoxGun.vertexRange=-.1 ; BoxGun.vertexRange=+.1 ; BoxGun.vertexRange=+.1 ; BoxGun.number=20'
However, strange enough, the FairBoxGenerator, on which the O2 generator factory is based, allows ranges only for the x and y positions of the vertex, not the z. Thus, setting BoxGun.vertexRange sets the z vertex position.
The workaround I have in mind is to scan the z vertex position with external scripts. It is a strange limitation, though.
@swenzel, should I create a merge request for this?
Hi Guillermo, Rafael,
you can easily implement a variable z vertex position in the FairBoxGenerator. However, having FairRoot as a development package is sometimes a little painful since (afaik) O2 does not always work with the latest commit of FairRoot so you have to check which commit is working.
Vertex position can already be configured using the “InteractionDiamond” key. This is independent on the generator and should be provided on the framework level. Please make a JIRA ticket if features are missing.
@pezzi: I’d be happy if you could contribute generalizations to the vertexing in a PR. But please do it on the InteractionDiamond level. If something cannot be done in the FairRoot system we would either need
to generalize their classes or decouple completely.
if you need some custom generator, I think you can easily use an external one.
For example, I created the macro
myfwmugen.C (see below for the content) which I launch with the command:
o2-sim -m MID -g extgen --extGenFile=myfwmugen.C --extGenFunc='myfwmugen(2)' -n 10000
This example is a bit overshooting, since I see from this mail thread that I could simply use the boxgen with the proper configKeyValues, but still, it can come at hand for the future.
FairGenerator* myfwmugen(int nMuons = 1, double pMin = 2., double pMax = 100., bool isMuPlus = false)
// instance and configure an external TGenerator
int pdgCode = ( isMuPlus ) ? -13 : 13;
std::cout << "Simulate " << nMuons << " particles with pdg code " << pdgCode << " per event" << std::endl;
auto gen = new FairBoxGenerator(pdgCode, nMuons);
Hi Sandro, I missed this edit. Sorry for the late answer. Thanks for pointing that the interaction diamond method implements vertexes distributions for all axes. It present Gaussian distributions and in this particular case flat distributions are prefered. FairBoxGenerator is able to generate particles with vertexes ranges in X, Y, but not Z. This limitation is evident on the implementation of FairBoxGenerator::SetBoxXYZ.
In my opinion O2 should be able to use what is available at FairRoot, thus I implemented a version of boxgun with vertexing control. Se PR#2685 .
I would like to have a flat/box vertex distribution in O2 for the Z axis as well. It would be straight forward to generalize FairBoxGenerator class to support ranges in Z, or add several generators along the Z axis as done here (not included in the pull request #2685).