# Compare Calibrations

## CAEN

In order to compare the different results from the calibrations you an use the `Compare` program. In order to do so make sure you actually build the latest version and check out its most recent options

```bash
CompareCalib -h
Usage:
./CompareCalib [-option (arguments)]
Options:
-d [0-3] Debugging mode
-e [0-1] extended plotting
-E [1-X] histo reading options for expanded file list
-f       Force to write output if already exist
-F fff   set explicit plot extension explicitly, default is pdf 
-i uuu   Input file list
-I uuu   expanded input file list
-L [1-63]restrict max layer plotting
-o vvv   Output file name (mandatory)
-O kkk   Output directory name for plots (mandatory)
-r rrr   Name of run list file  2024 PS TB [../configs/DataTakingDB_202409_CAEN.csv] 
-R       Trending plots versus run #
-V       Trending plots versus Vop
-h       this help

Examples:
./CompareCalib (-f) -o TrendingOutput.root -i input_list.txt (-f to overwrite existing output)
./CompareCalib (-f) -o TrendingOutput.root InputName*.root InputName2.root (-f to overwrite existing output)

```

The `CompareCalib` program can be run in multiple ways in terms of inputs

1. with an auto-expanded list using `-i calibFiles*.root`
2. with a file list containing in each line the calibration files you want to use `-i calibFileList.txt` . This list has should end with `.txt` otherwise it might not be correctly detected
3. with a file list containing in each line a calibration file & the histo-output of the a specific calibration step. It can be used with `-I calibFileListExtended.txt` . This list has should end with `.txt` otherwise it might not be correctly detected.
   1. Treatment of different histogram outputs is foreseen and can be steered with `-E [1-X]` currently implemented are:
      1. `-E 1` (default if `-I` is called) format of [step 2](https://friederikebock.gitbook.io/epiclfhcaltb-ana/calibration/mip-calibration#step-2) output
      2. `-E 2` format of [step 1](https://friederikebock.gitbook.io/epiclfhcaltb-ana/calibration/mip-calibration#step-1) output

Likewise the `CompareAna` program can be run interchangably with the following inputs 3. with a file list containing in each line a calibration file & the QA output. It can be used with `-I anaFileList.txt` . This list has should end with `.txt` otherwise it might not be correctly detected.

1. Treatment of different histogram outputs is foreseen and can be steered with `-E [1-X]` currently implemented are:
   1. `-E 4` creates the deltatime overlay. This is currently the only option in the `ComparAna` function.

Similar to the other programs the options `-d` & `-e` will enabled various debugging options and more plots. In the current way two main ways of evaluating the data are implemented:

1. As a function of run number using the `-R` option
2. As a function of operational voltage using the `-V` option

Each of them is useful for different things. Below you find a few sample plots which are being created by the code. The output root file and plotsFolder have to be given after `-o` and `-O` respectively, without them the program will crash

```bash
# example for running Voltage dependence with extended output:
./CompareCalib -F png -e 1 -d 1 -f -V -i calibFileList.txt -o ../Trending/TrendingAllCalibs_Volt.root -O ../Trending/VoltDep -r -r ../configs/DataTakingDB_202409_CAEN.csv

# example for running run dependence without extended output & a file including the hist output:
./CompareCalib -F png -d 0 -e 0 -f -R -I calibFileList_45V_expanded.txt -o ../Trending/TrendingAllCalibs_Runs45V.root -O ../Trending/RunDep_45V -r ../configs/DataTakingDB_202409_CAEN.csv
```

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FXVEi7EXpw4C3iJGd3yju%2FHGPedSummary_RunOverlay.png?alt=media&#x26;token=4b5f31a5-8af1-4a2e-bab5-e70be06bf472" alt=""><figcaption><p>HG pedestal mean comparison at 45V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FKIbrjmoeJRaWyHazRhbO%2FHGPedWidthSummary_RunOverlay.png?alt=media&#x26;token=afd284cc-e664-4f4c-ac79-77cb226d3555" alt=""><figcaption><p>HG pedestal width comparison at 45V</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fol80LexAKBcJO6qTGCIo%2FLGPedSummary_RunOverlay.png?alt=media&#x26;token=dae9c31b-a32f-40bd-a3dc-d346ce632924" alt=""><figcaption><p>LG pedestal mean comparison at 45 V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FG47BupNlrf1ntDsbXwCw%2FLGPedWidthSummary_RunOverlay.png?alt=media&#x26;token=2e63394f-1603-49a2-b425-8e1904c915c2" alt=""><figcaption><p>LG pedestal width comparison at 45 V.</p></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FYuW0JNUjiyQN964DrtMl%2FHGLGCorr_RunOverlay.png?alt=media&#x26;token=de4abd46-8dca-4e3f-95ee-2e9de6835949" alt="" width="375"><figcaption><p>HG-LG slope compared for all runs at 45V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-03df1d948b349b57467a31849c32a977d58d04be%2FLGHGCorr_RunOverlay.png?alt=media" alt="" width="375"><figcaption><p>LG-HG slope compared for all runs at 45V.</p></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-e761565dd7d50790e2324317ad9c98a979ffbe5a%2FHGScaleSummary_RunOverlay.png?alt=media" alt=""><figcaption><p>HG mip equivalent values for all runs at 45V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-101cc1e904f5ffdc024c4a98882164cb80dc1634%2FHGScaleWidthSummary_RunOverlay.png?alt=media" alt=""><figcaption><p>HG mip width values for all runs at 45V.</p></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-8eb443b483cb04769a506c6189cea4a5688e078e%2FLGScaleCalcSummary_RunOverlay.png?alt=media" alt=""><figcaption><p>LG mip equivalent values, calculated based on the HG/LG-HG corr values, for all runs at 45V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FVzuaypNBEjAf12XiP5en%2FLGScaleSummary_RunOverlay.png?alt=media&#x26;token=e352b96e-bf8a-45d3-a864-4d936a48cc48" alt=""><figcaption><p>LG mip equivalent values, as determined by the fit of the LG histos, for all runs at 45V.</p></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FSHAp6z45EJPIvToRRbyd%2FLGScaleWidthSummary_RunOverlay.png?alt=media&#x26;token=23df3a60-2f59-4674-bc3b-c611792607fb" alt=""><figcaption><p>LG mip width values for all runs at 45V.</p></figcaption></figure></div>

If the extended plotting is enabled also the following individual layer plots will be produced.

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-251db858e61dfd69f6945d9e94c61942cac9bf1e%2FHGLGCorr_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-7c8dda1e23b9503640902005630c1119cb58a3d7%2FHGped_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-fad9a992289c7007a0066fe2285010762e0e79f4%2FHGScale_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-1ebb38cac20df19738a175616ab9ca13cbd8056a%2FLGHGCorr_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-6140a8c5ed64afedf5a6efda14334fb8dd05d5bb%2FLGped_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-78bbe327a5777eef2172ad11575ac67ffc9cc353%2FLGScale_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-bb3eac3d1221bf566f48fdba3b9142ed278aacb4%2FHGLGCorr_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-792d006c8474c851794a4514555c0a1f3bac30d5%2FHGped_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-d3b3e71c26e7bf6de28ca3f2fbd2536b2a590fd3%2FHGScale_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-7df9058fe6b70afd6b529c40c9295a1e9a2b8df7%2FLGHGCorr_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-9a4f5790fc813042296d52481a3ba9ac9baec5f1%2FLGped_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-8b440cde47ab95bc562aca74d997445133c138be%2FLGScale_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-b3c7d27afb56c391c4f08e36632a751ef8906f19%2FHGpedwidth_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fgit-blob-330987fc74b71eebcacc05aba69e6ec71e4f2c7b%2FLGpedwidth_Layer00.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Enabling the lowest debug option will also give you some statistics for each run, resulting in the following output in the shell for each of them:

```bash
***********************************************************************************************************************
Run Nr.: 552	 total entries: 512
	 --> LG pedestal:	 mean:	76.493		RMS:	45.517		0	 out of bounds
	 --> LG pedestal sigma:	 mean:	2.997		RMS:	0.257		0	 out of bounds
	 --> HG pedestal:	 mean:	71.639		RMS:	43.972		0	 out of bounds
	 --> HG pedestal sigma:	 mean:	11.489		RMS:	5.541		0	 out of bounds
	 --> LG scale:		 mean:	27.401		RMS:	7.381		10	 out of bounds
	 --> LG scale calc:	 mean:	27.871		RMS:	6.617		6	 out of bounds
	 --> LG scale width:	 mean:	27.449		RMS:	11.967		10	 out of bounds
	 --> HG scale:		 mean:	321.794		RMS:	75.844		5	 out of bounds
	 --> HG scale width:	 mean:	290.540		RMS:	125.518		6	 out of bounds
	 --> LG-HG corr:	 mean:	11.609		RMS:	0.476		4	 out of bounds
	 --> HG-LG corr:	 mean:	0.087		RMS:	0.008		56	 out of bounds
***********************************************************************************************************************
```

Where each of the lines represent the mean and RMS of the above shown individual run histos for the calibration values (i.e., the HG pedestal). The integer before the "out of bounds" indicates how many cells of the total entries (512 in this case) were contained in the over or under-flow bin of the respective histograms. These values for sure otherwise would have been nonsense, however, even within the histogram range some of the parameters might have reached their bounding conditions and the fits my have failed, just not in a manner which would have triggered the respective exclusion conditions defined by the various calibration routines.

Running with expanded output will produce the following plots in addition.

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FDR4QGbaKFStQNzIqjeWy%2FHG_GaussSigma_Layer00.png?alt=media&#x26;token=87f9e118-0f0f-4a41-a67e-522821393461" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FZYhXzO8LHKXiTxnuGxIX%2FHG_LandMPV_Layer00.png?alt=media&#x26;token=151141d6-52e0-4610-af68-f8381278c9d1" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FR4hJzJqFSEUtKY086Cqs%2FHG_LandSigma_Layer00.png?alt=media&#x26;token=000dccb2-541e-4dd5-974a-3bacf941e0d6" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F3TBAZWiDJFamGzuvmB1y%2FLG_GaussSigma_Layer00.png?alt=media&#x26;token=fea9a9d0-6f3f-451d-aa29-e4b38da72b33" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FC7suMwFEYUCFM1wnKAyl%2FLG_LandMPV_Layer00.png?alt=media&#x26;token=db0da310-b766-4c65-b239-6fa5f40c8a00" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F9uN4i4iZezZMZpcT5NOK%2FLG_LandSigma_Layer00.png?alt=media&#x26;token=2dd93a34-91c4-481d-b608-5b62730f2ac8" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FNojYRzsxvmv3UTIe725j%2FMuonTriggers_HGDist_Layer00.png?alt=media&#x26;token=ce4cdc93-cb7c-4bc5-a8be-684db6c09400" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F827YM6pqWWKPPTpIvccy%2FMuonTriggers_LGDist_Layer00.png?alt=media&#x26;token=52b17632-2fe2-4cb9-88e9-844445b6f570" alt=""><figcaption></figcaption></figure></div>

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FOacddWus3uoS0jiT79K1%2FMuonTriggers_Layer00.png?alt=media&#x26;token=71f5bdd2-51ca-423a-8cf4-2e863fc0e680" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fx4U3ph8ZNC6veCclj753%2FSBNoise_MuonTriggers_Layer00.png?alt=media&#x26;token=ae3e3992-2200-4e2b-a6fc-3e3a6e5bf4fe" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FdH6bL9LdjsJcB1ZRmCJe%2FSBSignal_MuonTriggers_Layer00.png?alt=media&#x26;token=d5477a5b-a722-4530-8ddd-3dc81d24a9db" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://friederikebock.gitbook.io/epiclfhcaltb-ana/comparisons/compare-calibrations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
