Telescope Simulation 
Telescope simulation is done with the Geant based simulation package 
AllPix
. See the official pages for more detail and installation instructions.
Allpix has the advantage that it comes with a converter as part of the simulation which will format the output to be read by EUTelescope. Hence, the simulated data can be run through the reconstruction chain analogously to raw data.
 Basic Features 
The code is run (once set-up) in the 
allpix/tags/AllPix_v1.0 directory. The sub-directories contain the details of simulation specification.
Execution typically is done as follow:
> cd [your allpix directory]
> source setup_allpix.sh
> allpix [your macro file]
Steering macros
Steering files are found in the 
allpix/tags/AllPix_v1.0/macros directory. Here the usual Geant parameters are specified (e.g. beam type, beam energy, # of events) as well as the detector type and positions. As many detectors as you like can be specified so long as there is no overlap. 
NB the more complicated the simulation, the longer it will take.
Sensor specification
Sensors are specified in the 
allpix/tags/AllPix_v1.0/models directory, specifically in the 
pixeldetector.xml file. There are several sensor types already made e.g. 
FeI4, 
TimePix and 
FeI3. Each has a numeric code which is referred to in the steering macro.  
 Converting to EUTelescope format 
After execution there will be a collection of (Mediipix style) output files in the directory specified in the steering macro, e.g. 
run00001/. The collection is converted as a whole so first the collection must be 
tar-ed and 
zip-ed up , e.g.
> tar -cvzf run00001.tar.gz ./run00001/*
Next, the whole collection is converted to a single lcio (i.e. EUTelescope readable file) by the 
share/TelescopeConverter.py file.
This is done in python and requires some additional libraries which are found by 
source-ing the 
share/setup_pyLCIO.sh file 
NB this has the side-effect of messing with the AllPix set-up (and vice versa) so the set up files must be re-
source-ed.
Encoding
The 
TelescopeConverter.py contains the details for encoding the AllPix data in an EUTelescope format. The processors of the reconstruction and the data format must match otherwise reconstruction will fail. This can be done either by changing the processor code after conversion, or, and more easily, by carefully setting the conversion encoding.
Before running the conversion make sure the 
TelescopeConverter.py is set-up to encode the data in the correct format i.e. that which is read by the Clustering (and other) processors of the EUTelescope code.
Usually this is 'sparsePixelType'. In addition the usual clustering processors prefer sparsePixelType = 2 (but check these things with reconstruciton code). Therefore, make sure the converter file contains a line like 
idEncoder_DUT['sparsePixelType'] = 2. For the Telescope planes (i.e. the mimosas) the equivalent line is 
idEncoder_Telescope['sparsePixelType'] = 1.
Also, make sure the event collection has the correct name e.g. 
event.addCollection( DUTDataColl, 'zsdata_apix' ).
NB The encoding settings can be checked after conversion using the 
dumpevent of EUTelescope.
Once this is done run the damn code. For example for a DUT with code 200:
> python share/TelescopeConverter.py run000001.tar.gz 200
The resulting file is in 
lcio format. This is equivalent to the 
converter step of EUTelescope. Check the DUT/mimosa plane id numbers using 
dumpevent to set the gear file correctly, the simulated data is ready to be clustered.
-- 
 
 Kenneth Wraight - 2014-05-19 
 Comments