Back to home page

EIC code displayed by LXR

 
 

    


Warning, /pfRICH/README.md is written in an unsupported language. File is not indexed.

0001 pfRICH
0002 ======
0003 
0004 Standalone ePIC pfRICH GEANT4 simulation codes
0005 
0006  Content:
0007 
0008  * [Introduction](#introduction)
0009  * [Prerequisites and basic installation](#prerequisites-and-basic-installation)
0010  * [Pre-installed example](#pre-installed-example)
0011  * [Full installation](#full-installation)
0012  * [Example scripts](#example-scripts)
0013  * [Environment customization](#environment-customization)
0014 
0015 Introduction
0016 ------------
0017 
0018   These codes were originally written for the ATHENA EIC detector proposal proximity focusing
0019 Ring Imaging CHerenkov detector (pfRICH) in Fall 
0020 2021. Later on they were adapted for a standalone simulation of ePIC pfRICH, as well as 
0021 interfaced to the latest (2.0) version if [IRT libraries](https://github.com/eic/irt). 
0022 
0023   The codes contain a complete ePIC pfRICH detector geometry description, including its IRT-style
0024 optics representation as a sequence of refractive and reflective boundaries between photon 
0025 emisson and detection points. A custom [GEANT stepping function](g4irt/source/CherenkovSteppingAction.cc)
0026 allows one to fully record history of Cherenkov photon creation and propagation through
0027 the optical media, as well as keeps track of the daughter-parent relashionships between 
0028 charged particles and produced optical photons, association between emission vertices and 
0029 particular Cherenkov light radiators, etc.
0030 
0031   As of February 2024, the source code is split into four partss: one related to a 
0032 [complete ePIC pfRICH detector](epic) simulation, one for a 
0033 [pfRICH mockup](ftbf) simulation for the 2024 Fermilab beam test, one for a BNL HRPPD 
0034 [test stand](tstand), and a part which is [common](share) for all three different geometries.
0035 
0036   As of March 2026, a [pfRICH mockup](cern) simulation for the 2026 CERN beam test was added.
0037 
0038 <br/>
0039 
0040 Prerequisites and basic installation
0041 ------------------------------------
0042 
0043   It is assumed that a user is familiar with ROOT and GEANT, as well as with the basic
0044 concepts of Monte-Carlo simulations, Cherenkov ring imaging detector design and event 
0045 reconstruction goals, as well as the basic principles of Ring Imaging CHerenkov (RICH) 
0046 particle identification (PID) techniques.
0047 
0048   It is assumed that ROOT and GEANT are installed on a host PC, where the codes are supposed to be 
0049 installed, as well as that *thisroot.sh* and *geant4.sh* were sourced already. GEANT is 
0050 not needed to just import already produced ROOT trees.
0051 
0052   In the following the installation under /tmp/sandbox is assumed. Define SANDBOX 
0053 environment variable accordingly if installing in a different directory. 
0054 
0055   Make sure 'cmake' is version 3.0 or higher. 
0056 
0057   The following combination is known to work: SL7, gcc 4.8.5, cmake 3.22.1, ROOT 6.18.04, 
0058 GEANT 4.10.05.p01 . 
0059 
0060 
0061 ```
0062 #
0063 # Define installation area
0064 #
0065 export SANDBOX=/tmp/sandbox
0066 export LD_LIBRARY_PATH=${SANDBOX}/lib:${SANDBOX}/lib64:${LD_LIBRARY_PATH}
0067 ```
0068 
0069 ```
0070 #
0071 # Install IRT library
0072 #
0073 cd ${SANDBOX}
0074 
0075 git clone -b pfrich https://github.com/eic/irt.git
0076 cd irt && mkdir build && cd build
0077 cmake -DCMAKE_INSTALL_PREFIX=${SANDBOX} -Wno-dev ..
0078 make -j8 install
0079 ```
0080 
0081 ```
0082 #
0083 # Download pfRICH repository
0084 #
0085 cd ${SANDBOX}
0086 
0087 git clone https://github.com/eic/pfRICH.git
0088 ```
0089 
0090 This is sufficient to import and analyze ROOT trees already produced after pfRICH 
0091 GEANT simulation pass elsewhere (as long as there were no drastic changes to the 
0092 C++ class variable description):
0093 
0094 <br/>
0095 
0096 Pre-installed example 
0097 ---------------------
0098 
0099 ```
0100 #  TODO: NEED TO UPLOAD NEW ONES
0101 #cd ${SANDBOX}/pfRICH
0102 # A pre-uploaded file with 500 events;
0103 #root -l './examples/pfrich.C("examples/pfrich.root")'
0104 #root -l './examples/multi-eval.C("examples/pfrich.root")'
0105 ```
0106 
0107 <br/>
0108 
0109 Full installation
0110 -----------------
0111 
0112 Installation of the actual GEANT simulation environment requires few more steps (make sure 
0113 *geant.sh* was sourced!):
0114 
0115 
0116 ```
0117 #
0118 # Install Xerces; YES, DO THIS EVEN IF YOU HAVE A SYSTEM ONE INSTALLED ALREADY
0119 #
0120 cd ${SANDBOX} 
0121 
0122 # Copy over xerces-c-3.2.4.tar.gz (or a similar version) from the Web, unpack;
0123 cd xerces-c-3.2.4 && mkdir build && cd build
0124 cmake -DCMAKE_INSTALL_PREFIX=${SANDBOX} -Wno-dev ..
0125 make -j8 install
0126 ```
0127 
0128 
0129 ```
0130 #
0131 # Install BeastMagneticField (optional, only needed for a full ePIC pfRICH simulation);
0132 #
0133 cd ${SANDBOX} 
0134 
0135 git clone https://github.com/eic/BeastMagneticField.git
0136 cd BeastMagneticField && mkdir build && cd build
0137 cmake -DCMAKE_INSTALL_PREFIX=${SANDBOX} -Wno-dev ..
0138 make -j8 install
0139 ```
0140 
0141 
0142 ```
0143 #
0144 # Install HepMC3 (optional, only needed for a full ePIC pfRICH simulation);
0145 #
0146 cd ${SANDBOX}
0147 
0148 git clone https://gitlab.cern.ch/hepmc/HepMC3.git
0149 cd HepMC3 && mkdir build && cd build
0150 cmake -DCMAKE_INSTALL_PREFIX=${SANDBOX} -DHEPMC3_ENABLE_ROOTIO=ON -DHEPMC3_ENABLE_PYTHON=OFF ..
0151 make -j8 install
0152 ```
0153 
0154 
0155 ```
0156 #
0157 # Install pfRICH simulation codes themselves
0158 #
0159 cd ${SANDBOX}/pfRICH
0160 
0161 # Create links to the default header files; 
0162 pushd share/include  && ln -s hrppd.default.h  hrppd.h && ln -s share.default.h share.h && popd
0163 pushd epic/include   && ln -s epic.default.h   epic.h && popd
0164 pushd ftbf/include   && ln -s ftbf.default.h   ftbf.h && popd
0165 pushd cern/include   && ln -s cern.default.h   cern.h && popd
0166 pushd tstand/include && ln -s tstand.default.h tstand.h && popd
0167 
0168 mkdir build && cd build
0169 # 'BMF' and 'HepMC3' are optional;
0170 cmake -DCMAKE_INSTALL_PREFIX=${SANDBOX} -DIRT=${SANDBOX} -DBMF=${SANDBOX} -DHEPMC3=${SANDBOX} -DXERCES=${SANDBOX} -Wno-dev ..
0171 
0172 make -j8 install
0173 ```
0174 
0175 Example scripts 
0176 ---------------
0177 
0178 ```
0179 #
0180 # A full ePIC pfRICH detector
0181 #
0182 cd ${SANDBOX}/pfRICH
0183 # FIXME: may need to click on "Useful tips", then on "viewer-0" in a Qt display;
0184 ./build/pfrich-epic -m macro/vis-epic.mac
0185 ```
0186 
0187 A GEANT Qt display will appear with a picture similar to the image below. Use a green button 
0188 in the Qt display controls to generate more events.  
0189  
0190 ![](pics/epic-geant-qt.png)
0191 
0192 
0193 ```
0194 # Generate a file *pfrich-epic.root* with 1000 7 GeV/c pions at eta = -2.5
0195 ./build/pfrich-epic -o pfrich-epic.root -s 1000
0196 
0197 # See a hit map in the sensor plane;
0198 root -l 'scripts/hit-map-epic.C("pfrich-epic.root")'
0199 ```
0200 
0201 ![](pics/epic-hit-map.png)
0202 
0203 Consider to uncomment *#define PRIMARY_PARTICLE_PHI* in [epic/include/epic.default.h](epic/include/epic.default.h), 
0204 recompile and rerun both commands, in order to see a clear ring. 
0205 
0206 ```
0207 # Run IRT reconstruction; 
0208 root -l 'scripts/reco-epic.C("pfrich-epic.root")'
0209 ```
0210 
0211 ![](pics/epic-reco.png)
0212 
0213 Top row of plots: reconstructed single photon Cherenkov angle distribution, its equivalent representation as a 
0214 cumulative chi^2 distribution with one degree of freedom, track-level cumulative chi^2 distribution with N degrees 
0215 of freedom (over N photons associated with a given track), event-level cumulative chi^2 distribution which is of 
0216 course identical to the track-level one because there was only one track per events generated. *Cumulative chi^2
0217 distributions are expected to be reasonably uniform, otherwise something must be fundamentally wrong with the 
0218 reconstruction procedure*.
0219 
0220 Middle row of plots: Cherenkov photon hit count associated with a given track (should look like a 
0221 Poissonian distribution), pion/kaon (mis)identification rate, the same plot, Cherenkov photon timing resolution 
0222 (ignore).
0223 
0224 Bottom row of plots: Track-level reconstructed Cherenkov angle distribution, wavelength distribution of detected
0225 photons (a convolution of several effects), empty panel, truth refractive index in aerogel for the detected photons.
0226 
0227 
0228 ```
0229 #
0230 # A Fermilab mockup of a pfRICH detector
0231 #
0232 ./build/pfrich-ftbf -m macro/vis-ftbf.mac
0233 
0234 # Will take quite some time because of the optical photon tracing in the lens radiator;
0235 ./build/pfrich-ftbf -o pfrich-ftbf.root -s 1000
0236 
0237 root -l 'scripts/hit-map-ftbf-1x1.C("pfrich-ftbf.root")'
0238 root -l 'scripts/hit-map-ftbf-2x2.C("pfrich-ftbf.root")'
0239 
0240 # This one is also time consuming; comment "#define _ZCOORD_ASPHERIC_LENS_" in ftbf.default.h", 
0241 # recompile and re-run ./build/pfrich-ftbf if the lens is of no interest;
0242 root -l 'scripts/reco-ftbf.C("pfrich-ftbf.root")'
0243 ```
0244 
0245 ```
0246 #
0247 # A CERN 2026 mockup of a pfRICH detector
0248 #
0249 ${SANDBOX}/bin/pfrich-cern-geant -m macro/pfrich-cern-vis.mac
0250 
0251 # Generate 1000 events;
0252 ${SANDBOX}/bin/pfrich-cern-geant -o pfrich-cern-events.root -s 1000
0253 
0254 # See a hit map;
0255 #root -l 'scripts/pfrich-hit-map-cern-1x1.C("pfrich-cern-events.root")'
0256 root -l 'scripts/pfrich-cern-hit-map-2x2.C("pfrich-cern-events.root")'
0257 
0258 # Runs calibration (optional; once);
0259 root -l './scripts/pfrich-cern-calibration.C("pfrich-cern-events.root", "calibration/pfrich-cern-calibration.json")'
0260 
0261 # Run reconstruction;
0262 root -l 'scripts/pfrich-cern-reco.C("pfrich-cern-events.root")'
0263 ```
0264 
0265 Environment customization
0266 -------------------------
0267 
0268 The code should be started in a *${SANDBOX}/pfRICH* directory, or otherwise in any other one, 
0269 where exists a link to a *database* subdirectory, which contains MARCO solenoid field map (may be 
0270 obsolete!), some of the media refractive index tables, etc. 
0271 
0272 Per design, there are no other configuration files, either ASCII or XML ones, in this package.
0273 All of the configuration changes are made through editing C++ header files and recompiling the 
0274 executable codes. The rationale behind this paradigm is to have as transparent environment as
0275 possible, where there is no convoluted path from e.g. changing the detector geometry and propagating 
0276 this change to the actual simulation pass. Besides this, the optical description of a setup is 
0277 saved in the output ROOT tree with the charged particle, optical photon information and hits, to simplify 
0278 book-keeping (there is no way a reconstruction code can pick up an optical configuration which is
0279 inconsistent with the GEANT geometry used in this simulation pass). All in all, it is a *development*
0280 style package, limited in its functionality, and designed just to do the job of implementing and 
0281 trying out changes in the detector geometry *by you* in as simple and efficient way as possible 
0282 (on a time scale 
0283 of minutes for a full edit-compile-run-reconstruct sequence for O(10k) events), rather than a 
0284 versatile solid framework with a detector configuration being changed *by somebody else for you* 
0285 on a time scale of weeks and months. 
0286 
0287 One downside of this approach is a necessity to keep track of *your own changes* and do not let them 
0288 interfere (after a *pull* request) with other changes occasionally happening in the repository. There are 
0289 presently six "default" C++ header files in the repository: one with an 
0290 [HRPPD description](share/include/hrppd.default.h), one with [shared parameters](share/include/share.default.h), 
0291 and one for each of the [epic](epic/include/epic.default.h), [Fermilab](ftbf/include/ftbf.default.h),
0292 [CERN](cern/include/cern.default.h) and BNL [QA station](tstand/include/tstand.default.h) configurations.
0293 
0294 
0295 ```
0296 # Consider creating your local copies of the repository header files, which you may want to change,
0297 # and pointing links like share.h to them, like (for a person 'xx'):
0298 cd ${SANDBOX}/pfRICH
0299 
0300 pushd epic/include && rm epic.h && cp epic.default.h epic.xx.h && ln -s epic.xx.h epic.h && popd
0301 
0302 # Then you can edit epic.xx.h locally without being affected by possible changes in epic.default.h
0303 # which would overwrite your local changes after next pull
0304 ```
0305 
0306 Feel free to store your private header files in the repository (ask for a write access if you do not have one),
0307 and push them to the repository often enough. One can of course just create a git branch where one can modify 
0308 the default header files directly.
0309 
0310 It may make sense to look through the above mentioned default header files, line by line. They have a certain 
0311 amount of 
0312 comments, which allow one to understand what is what. It makes sense to periodically check whether anything 
0313 was changed in the default configuration header files as compared to your local custom copies.
0314 
0315 ```
0316 #Automation
0317 #----------
0318 #
0319 #
0320 # TODO: UPDATE THIS SECTION
0321 #Inside pfRICH directory run
0322 #`bash ./scripts/cc/AutomatedSimulationChain.sh`
0323 #It will display all the features with an example.
0324 #
0325 ```