All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Covariance.h
Go to the documentation of this file.
1 #ifndef __sbnanalysis_ana_SBNOsc_Covariance__
2 #define __sbnanalysis_ana_SBNOsc_Covariance__
3 
4 /**
5  * \file Covariance.h
6  */
7 
8 #include "fhiclcpp/ParameterSet.h"
10 
11 #include <string>
12 #include <vector>
13 #include <map>
14 #include <string>
15 #include <iostream>
16 #include <cassert>
17 
18 #include <TFile.h>
19 #include <TTree.h>
20 #include <TH1D.h>
21 #include <TH2D.h>
22 #include <TH3D.h>
23 #include <TMatrixDSym.h>
24 
25 class TTree;
26 
27 namespace ana {
28 namespace SBNOsc {
29 
31  public:
32  // Constructor
34 
35  // implementing PostProcessor
36  void FileCleanup(TTree *eventTree);
37  void Initialize(fhicl::ParameterSet *config);
38  void ProcessEvent(const event::Event *event);
39  void ProcessSubRun(const SubRun *subrun);
40  void Finalize() { Scale(); GetCovs(); Write(); }
41 
42  // API Functions
43  void GetCovs();
44  void Write();
45  void Scale();
46 
47  // build the covariance matrix
48  TMatrixDSym CovarianceMatrix();
49 
50  // Output
51  std::vector<TH2D> cov; //!< Covariance Matrix per variation
52  std::vector<TH2D> fcov; //!< Fractional Covariance Matrix per variation
53  std::vector<TH2D> corr; //!< Correlation Matrix per variation
54 
55  private:
56  class EventSample {
57  public:
58 
59  /** Constructors. */
60  EventSample(const fhicl::ParameterSet &config, unsigned nUniverses, unsigned nVariations);
61 
62  double fScaleCC;
63  double fScaleNC;
64  double fScaleEnergy;
65  double fPOT;
66  double fScalePOT; //!< Factor for POT (etc.) scaling
67  std::vector <double> fBins; //!< Energy bin limits
68  TH1D *fCentralValue; //!< central value histogram
69  std::vector<std::vector<TH1D *>> fUniverses; //!< List of histogram per systematic universe.
70  // List has index per covariance matrix to be generated.
71  std::string fName; //!< Name for the sample
72  std::vector<double> fEnergyBinScale;
73  };
74  void GetCovPerVariation(unsigned variation);
75 
76  // config
77  std::vector<std::vector<std::string>> fWeightKeys;
78  std::vector<std::vector<std::string>> fWeightKeysCC;
79  std::vector<std::vector<std::string>> fWeightKeysNC;
82  std::string fEnergyType;
83 
84 
85  unsigned fNVariations;
86 
89  std::string fOutputFile;
90 
93 
94 
95  double fWeightMax;
96 
97  // file counter
98  unsigned fSampleIndex;
99 
100  // Stored Event Samples
101  std::vector<EventSample> fEventSamples;
102 };
103 
104 } // namespace SBNOsc
105 } // namespace ana
106 
107 #endif// __sbnanalysis_ana_SBNOsc_Covariance__
std::vector< TH2D > cov
Covariance Matrix per variation.
Definition: Covariance.h:51
double fScalePOT
Factor for POT (etc.) scaling.
Definition: Covariance.h:66
TH1D * fCentralValue
central value histogram
Definition: Covariance.h:68
std::string fName
Name for the sample.
Definition: Covariance.h:71
std::vector< std::vector< std::string > > fWeightKeysNC
Definition: Covariance.h:79
TMatrixDSym CovarianceMatrix()
Definition: Covariance.cxx:407
std::string fOutputFile
Definition: Covariance.h:89
void Initialize(fhicl::ParameterSet *config)
Definition: Covariance.cxx:76
std::vector< TH2D > fcov
Fractional Covariance Matrix per variation.
Definition: Covariance.h:52
std::vector< std::vector< std::string > > fWeightKeysCC
Definition: Covariance.h:78
process_name opflashCryoW ana
std::vector< std::vector< std::string > > fWeightKeys
Definition: Covariance.h:77
std::vector< double > fEnergyBinScale
Definition: Covariance.h:72
std::vector< std::vector< TH1D * > > fUniverses
List of histogram per systematic universe.
Definition: Covariance.h:69
std::vector< TH2D > corr
Correlation Matrix per variation.
Definition: Covariance.h:53
std::string fEnergyType
Definition: Covariance.h:82
The standard subrun data definition.
Definition: SubRun.hh:23
void GetCovPerVariation(unsigned variation)
Definition: Covariance.cxx:266
void ProcessSubRun(const SubRun *subrun)
Definition: Covariance.cxx:147
The standard event data definition.
Definition: Event.hh:228
EventSample(const fhicl::ParameterSet &config, unsigned nUniverses, unsigned nVariations)
Definition: Covariance.cxx:28
std::vector< EventSample > fEventSamples
Definition: Covariance.h:101
void FileCleanup(TTree *eventTree)
Definition: Covariance.cxx:257
A generic tree-reading event-by-event processor.
void ProcessEvent(const event::Event *event)
Definition: Covariance.cxx:151
std::vector< double > fBins
Energy bin limits.
Definition: Covariance.h:67