Muon Monitor Simulations

ACNET Variables

Instructions for Plotting Muon Monitor Data

This is a living document originally intended for personal use, so there may be some rough edges and room for improvement, but hopefully this will help anyone interested in this work skip past my original obstacles. -- Tyler Rehak, August 2018

Utilizing MINOS Data Files

Since some files are accessible via ifdb for 30 days, the preferred method for plotting data is to utilize the data files stored by MINOS. Instructions for using ifdb instead are listed at the bottom.

My working directory is /minerva/app/users/trehak/ifdb/

First steps:

source $MINOS_SETUP_DIR_GRID/ -r R3.11

cd muoninfo
srt_setup -a

If the minos setup does not work for you, make sure you have not run any other commands before running these, including in your .bash_profile, .profile and .bash_login scripts.

Edit /MuonMonInfo/MuonInfoDump.cxx as follows:
 Line 59, set output directory and file name
 Line 61, set the header line listing all devices. Replace with commented line 62 to use a list of all devices plus all muon monitor pixels.
 Line 233, set the list of desired devices
 Lines 260-313, if you want to include looping over all the pixel data

make all

Multiple files can be used on the command line, but don't try to use all the files for a single year. Note that the output can easily be several GB, but it will be greatly reduced once it's processed with the rest of the steps included in here and then you can delete the original output csv if you need the space.

loon -b -q  dump_muonmon.C /minos/app/BEAMDATA_CF/MBEAM/2015/B150512_000000.mbeam.root

Example command for a full day of data:

nohup loon -b -q dump_muonmon.C /minos/app/BEAMDATA_CF/MBEAM/B180225_000000.mbeam.root
                                /minos/app/BEAMDATA_CF/MBEAM/B180225_200000.mbeam.root >> out.log &

Note the format of the input minos files: /minos/app/BEAMDATA_CF/MBEAM/year/Byymmdd_hh0000.mbeam.root and each file is a 4 hour block.

You should ls /minos/app/BEAMDATA_CF/MBEAM/year/ just to be sure there were no changes in that convention in the year you are looking for. For example, last time I checked, 2018 root files were in /minos/app/BEAMDATA_CF/MBEAM/

I recommend using some python scripts to generate the loon arguments if you want data from more than a few files.

Example for 1 file from each day for several months:

s="loon -b -q dump_muonmon.C " 
for i in range(17,32):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2015/B15100"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2015/B1510"+str(i)+"_000000.mbeam.root " 

for i in range(15,31):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2016/B16110"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2016/B1611"+str(i)+"_000000.mbeam.root " 

for i in range(1,32):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2016/B16120"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2016/B1612"+str(i)+"_000000.mbeam.root " 

for i in range(1,32):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B17010"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B1701"+str(i)+"_000000.mbeam.root " 

for i in range(1,29):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B17020"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B1702"+str(i)+"_000000.mbeam.root " 

for i in range(1,32):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B17030"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B1703"+str(i)+"_000000.mbeam.root " 

for i in range(1,31):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B17040"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2017/B1704"+str(i)+"_000000.mbeam.root " 

for i in range(1,32):
    if (i<10):
        s+="/minos/app/BEAMDATA_CF/MBEAM/2015/B15050"+str(i)+"_000000.mbeam.root " 
        s+="/minos/app/BEAMDATA_CF/MBEAM/2015/B1505"+str(i)+"_000000.mbeam.root " 

Get back into the /ifdb/muoninfo directory
Generate a ntuple from the csv using minosntuple.c. This also adds columns for a proper Unix timestamp and corrected monitor signals. Be sure to change the input/output files as needed, especially so the output doesn't overwrite an existing file.

.x minosntuple

Edit allerrors.c as follows:
 Input and output files
 Line 97, set x seconds for (time>t0+x). x determines how much data to include in each error bar. If running lots of days, each with a single 4 hour file, I like to just do the full 14400 seconds.

Note that errors.c was the first attempt at computing error bars, and then it grew to encompass most all values. You may want to use errors.c if you only grabbed the muon monitor signals and not the other devices.

Backup existing allerrors.c output (allerrors.root) if desired

.x allerrors.c

Now use allerrors.root to plot as desired.
Several graphing macros I worked on are in /ifdb/muoninfo. The most comprehensive is graphall.c
Note that my graphing macros were built for root v6, and I know there were some errors when using them with root v5. I usually downloaded allerrors.root (usually a small file) and ran the graphing macros locally.
At this point, you can delete the original out.csv and work solely with allerrors.root and minos.root.

Utilizing Data from ifdb

Note that there is a 30 day restriction on this data, so the above method with MINOS data is preferred and more recently supported.



Edit getifdata.cpp as follows:
 Line 15 and 16, set start and end times according to Unix epoch
 Line 18, set any devices names you want recorded
 Line 32, set the interval to grab data. Over long periods, suggest using every few hours or so. Note that it is possible to simply provide a list of discrete times (see line 83 for example)
 Line 43, set the header string of the csv. You can generate it with python:

s=""#var string from line 18
for i,c in enumerate(s):
    if c!=',':


make getifdata

Backup existing out.csv if desired


Check out.csv, especially the header. For example using: head -5 out.csv

Use on out.csv to remove extraneous data points (this can be fixed in getifdata if you care)

Backup existing ifdb.root if desired

Generate root file:

.x ifntuple.c

Open ifdb.root and plot away