Automating Allpix-Squared

Hi all,

A bit of an open ended question, but what are my options if I wanted to try and automate how I run allpix?

A bit of context: my current simulations are focused on calculating the charge collection efficiency (as well as other variables) from the movement of charges placed in a sensor using [DepositionPointCharge]. In particular, I’m interested in how the CCE changes depending on how deep in the sensor I place the charges. Right now, I place the charges using the “standard” method:

source_type = "point"
model = "fixed"
position = 0um 151um 0um
number_of_charges = 1000
output_plots = 1

where the position is done using the positon key in the [DepositionPointCharge] module. I don’t think this works very well if I wanted to simulate depositing the charges at 100 different depths. I’ve seen other posts in the forums have commands that look something like:

allpix -c config.conf -o ModuleName.module_variable=value

but I don’t think that would work very well for position since it requires 3 inputs? If there was an easy way to change the z-position on its own, it would make my job much easier, since I could automate the process with a bash script or a python program. Without it, I might have to resort to automatically making a set of 100 config files, which then will be used one-by-one.


Dear @damir ,

as a matter of fact, the input of vectors is possible also from the command line. For this you have to know that 0um 151um 0um is equivalent to 0um,151um,0um. With this, it should be straight forward to write a script. Here’s e.g. a script that I’ve used in the past:

while [ "$pos" -le 50 ]; do 
    cmd="allpix -c main.conf -o DepositionPointCharge.position=0mm,0mm,${pos}um -o root_file=histo_${pos}um.root -o ROOTObjectWriter.file_name=data_${pos}um.root"
    echo $cmd

I hope this helps!


Hi @damir

The user manual has your back :wink:

If there is whitespace in the key/value pair this should be properly enclosed in quotation marks to ensure the argument is parsed correctly.

Just do this:


# Scanning along z in steps of 10um
for i in {-100..100..10}
  allpix -c config.conf -o DepositionPointCharge.position="0um 151um ${i}um"