-
Notifications
You must be signed in to change notification settings - Fork 4
Example 1 Generating a covariance matrix
In this example we will use the provided toy analysis root files to generate a covariance matrix via re-weighting. If you are not familiar with the basic .xml layout I suggest you read understanding the .xml config file first.
In this simplified example we will have
- 1 Mode (nu)
- 1 Detector (uboone)
- 3 Channels:
- e channel (nue) with 2 subchannels: intrinsic nue (intrinsic) and lee signal (leesignal)
- mu channel (numu) with 1 subchannel: intrinsic numu (intrinsic)
- CCpi0 sideband channel 1 subchannel: intrinsic numu (intrinsic)
This is included in the example.xml as follows:
<mode name="nu" />
<detector name="uBooNE" />
<channel name="nue" unit="MeV" >
<bins edges="100 200 300 400 500 600 700 800 900 1000 1200 1400 1600 1800 2000 2500 3000" />
<subchannel name="intrinsic" osc = "0"/>
<subchannel name="leesignal" osc = "0"/>
</channel>
<channel name="numu" unit="MeV" >
<bins edges="100 200 300 400 500 600 700 800 900 1000 1200 1400 1600 1800 2000 2500 3000"/>
<subchannel name="intrinsic" osc = "0"/>
</channel>
<channel name="ccpi0" unit="MeV" >
<bins edges="0 200 400 600 800 1000 2000" />
<subchannel name="intrinsic" osc = "0"/>
</channel>
So we have a total of 4 subchannel spectra
- nu_uboone_nue_intrinsic
- nu_uboone_nue_leesignal
- nu_uboone_numu_intrinsic
- nu_uboone_ccpi0_intrinsic
but only 3 physics channel spectra (made from adding each channels subchannels)
- nu_uboone_nue
- nu_uboone_numu
- nu_uboone_ccpi0
In addition to the layout of the modes, detectors, channels and subchannels, the .xml configuration also need to know where the data lives and what branches in those files are associated with each subchannel. For more on the format required of the files please see here. For this example we have 4 files:
ls /uboone/data/users/markross/SBNfit_example_data/
signal.root
1e1p.root
1m1p.root
ccpi0.root
We want to associate a branch in each file with a subchannel as defined in the .xml. E.g we want the branch ereco in the TTree events of file 1m1p.root to be associated to the subchannel nu_uboone_numu_intrinsic. This is included in the .xml in a relatively self explanatory way as follows:
<MultisimFile treename="events" filename="/uboone/data/users/markross/SBNfit_example_data/1e1p.root" scale = "1.0" maxevents ="10000" pot = "3.3e23" >
<friend treename = "lee_signal_weights" filename="/uboone/data/users/markross/SBNfit_example_data/lee_signal_friend_tree.root"/>
<branch
name="ereco"
type="double"
associated_subchannel="nu_uBooNE_nue_leesignal"
additional_weight="lee_signal_weights.lee_weights"
eventweight_branch_name="weights"
/>
</MultisimFile>
The pot attribute of the file is the total POT for the file, used for normalization. The scale attribute allows for an overall normalization shift the file, and the maxevents attribute useful for running over a smaller subset for quick tests. Note the branch attribute name must correspond exactly to the TTree branch name and the associated_subchannel must match one as defined in the .xml file.
The example code can be found in examples/example_1.cxx but we will step through the important lines here.
The first bit of the code is just a simple handling of command line input arguments. identify outputs. The main bit of the code is very straightforward, most of the details are in the .xml file.
std::string tag = "EXAMPLE1";
std::cout<<"Begining Covariance Calculation for tag: "<<tag<<std::endl;
//Create a SBNmultisim object initilizing with the inputted xml
//This will load all the files and weights as laid out
SBNmultisim example_multisim(xml);
//Form the covariance matrix from loaded weights and MC events
example_multisim.formCovarianceMatrix(tag);
That is all! This produces all you need to continue, however, for more human readable plots
if(print_mode){
//and make some plots of the resulting things
//Will be outputted in the form: SBNfit_covariance_plots_TAG.root
example_multisim.printMatricies(tag);
//Will be outputted in the form: SBNfit_variation_plots_TAG.root
example_multisim.printVariations(tag);
}
If compilation was successful, in /build/example there will be an executable example1 . Running this is as as straightforward as pointing to the configuration file that you wish to run on:
./example1 --xml ../../xml/example.xml --print
For this particular example (if using the example.xml exactly as is) it should take ~5-6 mins on the gpvms (if print mode is turned on with --print or -p) and 3-4 mins if the print mode is turned off (default). See ./example1 --help for more details
If successful there should be two output root files. These will be of the form EXAMPLE1.SBNcovar.root and EXAMPLE1.SBNspec.root and consist of the raw data files produced corresponding to the covariance matrices and the central value spectra respectively.
If the example was run in print mode (with --print argument) an additional three files will be created containing the same information but in more human friendly plot form SBNfit_covariance_plots_EXAMPLE1.root, SBNfit_variation_plots_EXAMPLE1.root and SBNfit_spectrum_plots_EXAMPLE1.root. We will look at these first:
This file will have a single canvas for each channel, containing a stacked histogram of all subchannels allowing for quick viewing of the spectra in all modes and detectors.
This file contains 3 plots:
- Full Covariance Matrix
- Fractional Covariance Matrix
- Correlation Matrix
An example correlation matrix and covariance matrix is shown below: Note that black horizontal lines show boundaries of channels, where as red lines show boundaries of subchannels within a given channel. Note that there are no LEE signal events above 500 MeV so the covariance matrix and entries for these bins are zero everywhere (the vertical and horizontal blue stripes).

Generated at the same time is individual covariance and correlation matrix plots in the same manner, inside the individualDir directory. They are all labeled by which eventweight variation they originate from. Note that due to low numbers of universes in some variations, as well as the fact not all variations affect all subchannels, they are coarser with more negative spaces.
This file contains a directory for every variation in the eventweight class, and for each variation plots each subchannel's central value alongside every reweighted variation. This is particularly useful to see exactly how each variation effects each and every bin of each subchannel. Note that many variations have no impact on certain reconstructed variables so some of these only show the central value prediction.
Shown below are two examples, the black crosses show the central value and each multicolored line shows a separate universe's reweighing of the central value.
