---
# System prepended metadata

title: Rivet Work

---

# Rivet Work
### Discussion
1. Try to run Christian's code & make a brief annotation( [ALEPH_2019_I1737859.diff](https://gist.github.com/janice-cat/ea1843b8895fcd55984907484912b75b/revisions), [ALEPH_2019_I1737859.cc](https://gist.github.com/janice-cat/ea1843b8895fcd55984907484912b75b) )
    > Can make a coworking Git repo, which we can correct on and communicate over. (If you think is useful, I can create one)
    
    **All are about lab frame analysis**
    1. we project TPC (to get 1D dN/dΔɸ) after doing Eq. (3)
    2. original the deltaphi() function return from 0-pi, which creates a discontinuity at edge, so for B(0,0) 
    3. bZeroZero does not corresponds to the 0-th bin content in background function
    4. Symmetrizing the results for TPC
    5. haven't multiplied $1/N_{\rm evt}$ for background function
    6. for each event, we calculate the associated yield per track, but not doing the average of nCh after accumulation
    7. [Better check] if scaling of bin width automatically handled? (to get differential function:  $\frac{d^2N}{d \Delta \eta d \Delta \phi}$ or $\frac{dN}{d \Delta \phi}$)
    8. [Better check] multiplicity class:
    It seems that all the events having nCh=30
    
    **Thrust axis analysis needs an extra mix correction. We think it's better suspend this part until lab frame results are validated.**

2. For detailed validation
    1. Convert his sample (ee-z.hepmc) to our TPCNtuple 
        I think we can modify the pythia script in MCFragments/Pythia8 to achieve this
    2. Use ridge_check.exe to compare w/ rivet analysis output
    3. Will need to convert rivet output (histogram: .dat) to ROOT format, so that a careful comparison can be made
3. [long-term] Think of how to convert ALEPH open data / MC.

---
### Useful link
+ hepmc & pythia8:
http://home.thep.lu.se/~torbjorn/pythia82html/RIVETusage.html
+ rivet analysis:
    https://alice-doc.github.io/alice-analysis-tutorial/rivet/implementing-rivet-analysis.html
+ [EventMixingBase](https://gitlab.com/hepcedar/rivet/-/blob/release-3-1-x/include/Rivet/Projections/EventMixingFinalState.hh)

### Rivet on Grendel 
#### Environment setting
```bash
source /data/belle2work/rivet/rivetenv.sh
### gcc-8.2.0
PATH=/data/belle2work/gcc/bin/:$PATH
LD_LIBRARY_PATH=/data/belle2work/gcc/lib64/:$LD_LIBRARY_PATH
```

#### Circumventing the version issue: 
> I can only install rivet-3.1.1 successfully, but the script is built using 3.1.2 (or developing version) )

Replacing: 
```cpp
declare(EventMixingALEPH(cfs, cfs, 5, nRange, defaultWeightIndex()), "EVM");
```
with (syntax in old version)
```cpp
const size_t defaultWeightIndex = _globalDefaultWeightIndex();
declare(EventMixingALEPH(cfs, cfs, 5, nRange, defaultWeightIndex), "EVM");
```
- About `defaultWeightIndex()`: https://rivet.hepforge.org/code/dev/classRivet_1_1AnalysisHandler.html
- This seems not affecting for now: https://gitlab.com/hepcedar/rivet/-/blob/release-3-1-x/include/Rivet/Projections/EventMixingFinalState.hh, but I think we probably can discuss w/ Christian to find out the proper way to handle this (or how to build developing version)

#### Run rivet script
```bash
# generate pythia8 events -> hepmc
/data/belle2work/Herwig/src/pythia8240/examples/main42 ee-z.cmnd ee-z.hepmc 
# run rivet script
rivet-build RivetALEPH_2019_I1737859.so ALEPH_2019_I1737859.cc 
rivet --pwd -a ALEPH_2019_I1737859 ee-z.hepmc
rivet-mkhtml Rivet.yoda:ee-z.hepmc 
# results are stored in rivet-plots/
```