# 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
# make Compare program
make Compare

/Compare -h
Usage:
./Compare [-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:
./Compare (-f) -o TrendingOutput.root -i input_list.txt (-f to overwrite existing output)
./Compare (-f) -o TrendingOutput.root InputName*.root InputName2.root (-f to overwrite existing output)

```

This program can be run in multiple ways in terms of inputs&#x20;

1. with an auto-expanded list using `-i calibFiles*.root`&#x20;
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.&#x20;
   1. Treatment of different histogram outputs is foreseen and can be steered with `-E [1-X]` currently implemented are:&#x20;
      1. `-E 1` (default if `-I` is called) format of [step 2](../../calibration/mip-calibration#step-2) output
      2. `-E 2` format of [step 1](../../calibration/mip-calibration#step-1) output

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:
./Compare -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:
./Compare -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%2FsgxLvZ555IvVRBzR87hk%2FLGHGCorr_RunOverlay.png?alt=media&#x26;token=b449d941-b37d-4f7e-909d-74898d045b3f" 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%2FddA4kPAvvc5twfGO2Jqg%2FHGScaleSummary_RunOverlay.png?alt=media&#x26;token=455cecbd-d056-405d-aecb-2dc8ffa68c66" 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%2FJ1KazuWUwxc10TTWHvXY%2FHGScaleWidthSummary_RunOverlay.png?alt=media&#x26;token=3b02ed00-37d5-4674-8515-df7b13048924" 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%2F4MELXFwIlA9KO6bE7AnJ%2FLGScaleCalcSummary_RunOverlay.png?alt=media&#x26;token=0e04b053-f87f-4496-ad85-8de968c10154" 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.&#x20;

<div><figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FM27AgBJc1fQJVE3s8TBa%2FHGLGCorr_Layer00.png?alt=media&#x26;token=f86489a7-1ad0-4726-85b7-66799a47ddb6" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FkLFgFPSipsrogIOyWyOP%2FHGped_Layer00.png?alt=media&#x26;token=8d0360c4-cbd1-405c-a5c5-ac7af8c77c4a" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FPmMwbDYCewvUi4uquLJX%2FHGScale_Layer00.png?alt=media&#x26;token=c8a0b72f-ccfa-4545-b07e-f399ad06861f" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FVZPwX4Gbld2T9OWVkadt%2FLGHGCorr_Layer00.png?alt=media&#x26;token=a799aedd-784f-4cb1-9699-75786cd0de36" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F7o3KTvPZTZA4nsQLrQth%2FLGped_Layer00.png?alt=media&#x26;token=083f9829-ff6d-4864-8af0-9d81b9049368" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fk4svOZ7R5nwUo9Iq022M%2FLGScale_Layer00.png?alt=media&#x26;token=c86420bd-c40a-4d76-8390-fcff25332b80" 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%2FUm8tXMuPoJQh8yQgBgqM%2FHGLGCorr_Layer00.png?alt=media&#x26;token=da71691a-17fc-49a6-a072-f8bae42e7e5f" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FlNX3n3fYDg7WpVbX5Ky8%2FHGped_Layer00.png?alt=media&#x26;token=e4864e66-3aba-4921-9901-683e113eb102" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2Fn2zD0t2hPTU5wGtlhVq1%2FHGScale_Layer00.png?alt=media&#x26;token=c5832692-21ba-4803-a892-cc0b0c448f83" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F0pyx9x9sVZZxLivtb3eX%2FLGHGCorr_Layer00.png?alt=media&#x26;token=8ea0457e-a75c-48a5-933b-9bb36dbddd0d" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2F77xGKsOodGkg9T4z7hU3%2FLGped_Layer00.png?alt=media&#x26;token=402e7fe2-e05c-4620-8bda-4778e5de0cee" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FMuftrFNfyv6OraLjyrO6%2FLGScale_Layer00.png?alt=media&#x26;token=205f3a66-d1a0-4823-b5fe-5ec9ea246bd4" 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%2Fejees4H8iJJtntNfI3Wz%2FHGpedwidth_Layer00.png?alt=media&#x26;token=f4c58a0c-de44-4886-bae1-320c84e53d7a" alt=""><figcaption></figcaption></figure> <figure><img src="https://790592996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs5C8zkGYS3GkZpbQrPK0%2Fuploads%2FqRJgTWs0fq3I6AxIwvK4%2FLGpedwidth_Layer00.png?alt=media&#x26;token=528f4610-db88-4245-8c77-c62b990233b6" 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.&#x20;

Running with expanded output will produce the following plots in addition.&#x20;

<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>
