See mu3e software on merlin for detailed instructions how to build the software and all required dependencies.
Production and reconstruction of simulated data samples
Generic simulated data sample
To produce and reconstruct generic simulated data sample, proceed as follows
-
mu3eSim
runs the generator and GEANT4 detector simulation. The primary output of at this stage is the "mu3e" tree. See wiki for information on the resulting tree format. -
mu3eSort
changes the "mu3e" tree to put the data into the correct time ordering. -
mu3eTriRec
runs the triplet reconstruction and dumps the results into the "frames" and "segs" trees. See wiki for a first information on the resulting tree format. -
mu3eAnaVertexfit
runs vertex fitting
There is documentation on the executables on bitbucket.
So the recipe is (because the default run number in run1.mac is 779), once you cd'ed into ../run and created data:
../_build/mu3eSim/mu3eSim --script run1.mac ../_build/mu3eSim/sort/mu3eSort 779 ../_build/mu3eTrirec/mu3eTrirec data/mu3e_sorted_000779.root data/mu3e_trirec_000779.rootIntegration run simulated data samples
There is a special branch for the integration run with the modified detector configuration:
git clone git@bitbucket.org:mu3e/mu3e mu3e-integration_run cd mu3e-integration_run git checkout -b integration_run --track remotes/origin/integration_run git submodule update --init --recursive mkdir _build && cd _build # if on merlin6, replace the following line with the box below! cmake -DMU3E_TRIREC_DISPLAY=yes .. make VERBOSE=1 -j24 >& make.log &On merlin, you need the following:
patch ../mu3eTrirec/CMakeLists.txt /data/experiment/mu3e/code/patches/210706-mu3eTrirec-CMakeLists.patch cmake -DMU3E_TRIREC_DISPLAY=yes -DGTKMM_LOCALDIR=/psi/home/langenegger/data/misc/lib ..After compilation/linking, run the jobs (maybe consider changing the number of events in run1.mac), noticing that the runnumber in this branch is 123:
cd ../run && mkdir data ../_build/mu3eSim/mu3eSim --script run1.mac ../_build/mu3eSim/sort/mu3eSort 123 ../_build/mu3eTrirec/mu3eTrirec --twolayer \ --conf ../mu3eTrirec/trirec.conf \ --input data/mu3e_sorted_000123.root \ --output data/mu3e_trirec_000123.rootLook at events with the trirec event display:
../_build/mu3eTrirec/mu3eTrirec -d --twolayer \ --conf ../mu3eTrirec/trirec.conf \ --input data/mu3e_sorted_000123.rootmu3eSim
The configuration of mu3eSim is provided mostly in run/digi.conf. In addition, a (GEANT4) mac file can be fiven as argument.
...
Concepts
Perusing the mu3e (offline) code base the following points are noticeable. Knowledge of C++ will not be sufficient for an understanding of the code, you must be proficient in at least C++-11. There are no naming conventions discernible. Often class data members are public. Curly braces are voluntary; leaving them out is compensated by consecutive statements on the same line. Type casts can be in C-style. Implementation code is distributed between header and source files. Classes and elaborate structs are sometimes collected into single files. Structs, also with private data members, often are used in place of classes; consequently(?) preprocessor macros are (often) used in structs. Modern iterators are abundant, but printf
overwhelms cout
. Only primitive built-in types are stored in ROOT trees; as a consequence I/O is exceedingly fast. Cf. the C++ style advice here.
Trying to understand the code constructs, CppCoreGuidelines was very helpful.
Frames
A Frame
holds the data of an 'event'. It has shared pointers to the detectors (Si, Fb, Tl), lists of shared pointers to all kind of segments, a map of indices and MCTracks. It also contains runId
and eventId
.
It is constructed with the (shared) pointers to the detectors and an rvalue reference (or here) to the MCTrack map. In trirec.cpp this happens to be based on the MC trajectories.
Frame
organizes the reconstruction of the event data with its main method Frame::rec()
, invoking MCTrack::makeTracks()
resulting in MCTracks based on MC hits (no surpise). See below for more details of the MCTrack
code description. The track reconstruction works also without first invoking the MCTrack building.
After filling hits into the appropriate detector hit vectors, makeSegs() is invoked.
Segment
analyzer
The analyzer package allows the analysis of the recorded midas files. To date, the translation into trirec input files seem not yet existent.
Building
The analyzer has a dependency on midas, which must be installed first:
cd ~/mu3e git clone https://bitbucket.org/tmidas/midas --recursive cd midas mkdir _build && cd _build cmake -DCMAKE_CXX_STANDARD=17 .. make -j18 install setenv MIDASSYS ~/mu3e/midas cd ~/mu3e git clone git@bitbucket.org:mu3e/analyzer cd analyzer/ git submodule update --init --recursive mkdir _build cd _build cmake -DCMAKE_CXX_STANDARD=17 .. make VERBOSE=1 -j18Normally, the main branch should be used, but merge in the cleanup branch when having problems with the main branch.
Running
../_build/analyzer/analyzer_mu3e ~/scratch/mu3e/midas/run00198.mid >& /dev/null
Frequently asked questions
General
There is no output file
If you do not specify the output file you will not get one. E.g.
mu3eTrirec --twolayer --input data/mu3e_run_000123.root --conf ../mu3eTrirec/trirec.conf --output data/mu3e_trirec_000123.rootEvent display
How to run the event display?
mu3eTrirec -d data/mu3e_run_000001.rootDo not run mu3eDisplay, it is deprecated.
There is an error when running the event display:
../_build/mu3eTrirec/mu3eTrirec -d --input data/mu3e_run_000001.root libc++abi.dylib: terminating with uncaught exception of type boost::wrapexcept<boost::program_options::unknown_option>: unrecognised option '-d' Abort(On Linux the error looks a bit different, but the important part [no -d option] should be similar.)
The configuration was done without the event display. Therefore, rerun cmake with
If you are on merlin6, see above for how to get the gtkmm libraries compatible with the mu3e-required C++ compiler version.
Nothing is displayed and no error is printed
This is most likely due to no hits. Try to rerun the simulation with more events.