ATLAS Offline Software
Loading...
Searching...
No Matches
CalibrationDataEigenVariations.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// CalibrationDataEigenVariations.h, (c) ATLAS Detector software
8
9#ifndef ANALYSISCALIBRATIONDATAINTERFACEEVVARIATIONS_H
10#define ANALYSISCALIBRATIONDATAINTERFACEEVVARIATIONS_H
11
12#include <string>
13#include <vector>
14#include <map>
15#include <set>
16#include <utility>
17#include "TMatrixD.h"
18#include "TMatrixDSym.h"
20
21class TH1;
22
23namespace Analysis
24{
26
28 public:
29 typedef std::set<size_t> IndexSet;
30 typedef std::set<IndexSet> IndexSuperSet;
31
33 CalibrationDataEigenVariations(const std::string& cdipath, const std::string& tagger, const std::string& wp, const std::string& jetcollection, CalibrationDataHistogramContainer* cnt, bool excludeRecommendedUncertaintySet = false, bool base = true);
35
37 void excludeNamedUncertainty(const std::string& name, CalibrationDataContainer* cnt);
40 virtual void initialize(double min_variance = 1.0E-20); // <------ this default value for min_variance can be tuned - some combinations of CDI file and systematic strategy can use a higher threshold
41
43 void removeVariations(const IndexSet &set);
46
48 void mergeVariationsFrom(const size_t& index);
49
51 void mergeVariations(const IndexSet &set);
53 void mergeVariations(const IndexSuperSet &set);
54
56 unsigned int getNumberOfNamedVariations() const;
58 std::vector<std::string> listNamedVariations() const;
62 unsigned int getNamedVariationIndex(const std::string& name) const;
63
65 unsigned int getNumberOfEigenVariations();
66
69 bool getEigenvectorVariation(unsigned int variation, TH1*& up, TH1*& down);
70
74 bool getNamedVariation(const std::string& name, TH1*& up, TH1*& down);
79 bool getNamedVariation(unsigned int nameIndex, TH1*& up, TH1*& down);
81 bool isExtrapolationVariation(unsigned int nameIndex) const;
82
85 virtual TMatrixDSym getEigenCovarianceMatrix();
91
93 bool EigenVectorRecomposition(const std::string& label,
94 std::map<std::string, std::map<std::string, float>> &coefficientMap);
95
96 void setVerbose(bool);
97
98 private:
101
102 protected:
103
106 bool m_validate; // <------ flag that says you want to validate the systematic strategies, and the merging schemes
107
109 std::map<std::string, unsigned int> m_namedIndices;
110 std::vector<std::pair<TH1*, TH1*> > m_named; // <---- In the CalibrationDataGlobalEigenVariations, this will store regular variations as well
111
114
116 std::vector<std::pair<TH1*, TH1*> > m_eigen; // <----- In the CalibrationDataGlobalEigenVariations, this will store the **combined** variations FOR PRUNING ONLY ("reporting" is done differently)
117
120
121 // /** @ data members needed for eigenvector method **/
122 // /** the map stores the int which is needed to access the other vector<> objects **/
123 // mutable std::map<std::string, unsigned int> m_eigenvectorMethod_index;
124 // std::vector<TMatrixT<double> > m_eigenvectorMethod_matrix;
125 // std::vector<std::vector<TObject*> > m_eigenvectorMethod_uncUpProvider;
126 // std::vector<std::vector<TObject*> > m_eigenvectorMethod_uncDownProvider;
127 // std::vector<std::vector<TObject*> > m_eigenvectorMethod_uncProvider;
128
129 std::string m_cdipath;
130 std::string m_taggername;
131 std::string m_wp;
132 std::string m_jetauthor;
133 // The reduction scheme can be said to "capture" X % of the variance by computing m_capturedvariance/m_totalvariance
134 // total variance is the sum of all the eigenvalues found through eigenvector decomposition
135 // the "captured" variance is the sum of the eigenvalue of the retained eigenvectors (after pruning)
138
140
141 };
142
143
144
146 public:
147 CalibrationDataGlobalEigenVariations(const std::string& cdipath, const std::string& tagger, const std::string& wp, const std::string& jetcollection, const std::vector<std::string>& flavours, CalibrationDataHistogramContainer* cnt, bool excludeRecommendedUncertaintySet = false) ;
149
151 TMatrixDSym getEigenCovarianceMatrix();
152
153 void initialize(double min_variance = 1.0E-6) ; // <------ this min_variance threshold value holds generally for the global eigenvariations strategy - but not necessarily set in stone, can depend on CDI file as well
154
155 TMatrixD getJacobianReductionMatrix(TMatrixDSym& cov);
156
157 void excludeNamedUncertainty(const std::string& name, const std::string& flavour);
158
159 std::vector<std::string> listNamedVariations(const std::string& flavour) const;
160 unsigned int getNamedVariationIndex(const std::string& name, const std::string& flavour) const;
161 bool getNamedVariation(const std::string& flavour, const std::string& name, TH1*& up, TH1*& down); // <--- Get the named variation index by flavour and variation name
162 bool getNamedVariation(unsigned int nameIndex, const std::string& flavour, TH1*& up, TH1*& down); // <--- This does the actual retrieval, just also enforces that initialization was done first
163
164 bool getEigenvectorVariation(const std::string& flavour, unsigned int variation, TH1*& up, TH1*& down);
165 unsigned int getNumberOfEigenVariations(const std::string& flavour);
166 bool isExtrapolationVariation(unsigned int nameIndex, const std::string& flavour) const;
167
168 void mergeVariationsFrom(const size_t& index, std::string& flav);
169
170 void mergeVariations(const IndexSet &set, std::string& flav);
171 void mergeVariations(const IndexSuperSet &set, std::string& flav);
172
173 void removeVariations(const IndexSet &set, std::string& flav);
174 void removeVariations(const IndexSuperSet &set, std::string& flav);
175
176 private:
177
178 int m_blockmatrixsize; // store the concatenated length of all binned flavour calibrations, i.e. dim(B) + dim(C) + dim(Light) + dim(T)
179
180 std::map<std::string, Analysis::CalibrationDataHistogramContainer*> m_histcontainers; // map of flavour to container, useful for when you need to actually quote a variation! (correct binning here per flavour)
181 std::set<std::string> m_all_shared_systematics;
182 std::set<std::string> m_only_shared_systematics;
183 std::map<std::string, std::vector<int>> m_flavour_combinations;
184
185
186 std::map<std::string, std::map<std::string, unsigned int>> m_flav_namedIndices; // replace the m_namedIndices, still can use m_named to store? Yes.
187 std::map<std::string, std::vector<std::pair<TH1*,TH1*>>> m_flav_named; // On second second thought, this is needed to keep indices consistent between flavours...
188 std::map<std::string, int> m_flav_namedExtrapolation; // store the index of the flavour container's extrapolation named uncertainty index - replaces m_namedExtrapolation
189 std::map<std::string, std::vector<std::pair<TH1*, TH1*>>> m_flav_eigen; // replace m_eigen when it comes to RETURNING VARIATIONS with proper binning (i.e. the "reporting" of up/down variations per flavour)
190 std::vector<std::string> m_flavours;
191
192 };
193
194}
195
196#endif // ANALYSISCALIBRATIONDATAINTERFACEEVVARIATIONS_H
Define macros for attributes used to control the static checker.
This is the interface for the objects to be stored in the calibration ROOT file.
CalibrationDataHistogramContainer * m_cnt
container object containing the basic information
bool m_initialized
flag whether the initialization has been carried out
unsigned int getNumberOfNamedVariations() const
retrieve the number of named variations
void removeVariations(const IndexSet &set)
remove all variations in the given set
std::map< std::string, unsigned int > m_namedIndices
named variations
std::vector< std::pair< TH1 *, TH1 * > > m_eigen
eigenvector variations
TMatrixD getJacobianReductionMatrix()
matrix to remove unecessary rows and columns from covariance
bool getEigenvectorVariation(unsigned int variation, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the given eigenvector number.
int m_namedExtrapolation
named variation index for the special case of extrapolation uncertainties
void mergeVariationsFrom(const size_t &index)
merge all variations starting from the given index
TMatrixDSym getEigenCovarianceMatrixFromVariations()
covariance matrix corresponding to eigenvector variations constructed from the eigen-variation
bool isExtrapolationVariation(unsigned int nameIndex) const
flag whether the given index corresponds to an extrapolation variation
unsigned int getNumberOfEigenVariations()
retrieve the number of eigenvector variations
void excludeNamedUncertainty(const std::string &name, CalibrationDataContainer *cnt)
exclude the source of uncertainty indicated by name from eigenvector calculations
bool m_statVariations
indicate whether statistical uncertainties are stored as variations
bool getNamedVariation(const std::string &name, TH1 *&up, TH1 *&down)
obtain the "up" and "down" variations for the named uncertainty.
virtual TMatrixDSym getEigenCovarianceMatrix()
also provide (some) access to the underlying information: covariance matrix corresponding to eigenvec...
std::string m_cdipath
@ data members needed for eigenvector method
unsigned int getNamedVariationIndex(const std::string &name) const
retrieve the integer index corresponding to the named variation.
std::vector< std::pair< TH1 *, TH1 * > > m_named
void mergeVariations(const IndexSet &set)
merge all variations in the given set
std::vector< std::string > listNamedVariations() const
list the named variations
CalibrationDataEigenVariations(const std::string &cdipath, const std::string &tagger, const std::string &wp, const std::string &jetcollection, CalibrationDataHistogramContainer *cnt, bool excludeRecommendedUncertaintySet=false, bool base=true)
normal constructor.
bool EigenVectorRecomposition(const std::string &label, std::map< std::string, std::map< std::string, float > > &coefficientMap)
Eigenvector recomposition method.
std::map< std::string, std::vector< std::pair< TH1 *, TH1 * > > > m_flav_named
void removeVariations(const IndexSet &set, std::string &flav)
void excludeNamedUncertainty(const std::string &name, const std::string &flavour)
bool getEigenvectorVariation(const std::string &flavour, unsigned int variation, TH1 *&up, TH1 *&down)
std::map< std::string, Analysis::CalibrationDataHistogramContainer * > m_histcontainers
CalibrationDataGlobalEigenVariations(const std::string &cdipath, const std::string &tagger, const std::string &wp, const std::string &jetcollection, const std::vector< std::string > &flavours, CalibrationDataHistogramContainer *cnt, bool excludeRecommendedUncertaintySet=false)
TMatrixDSym getEigenCovarianceMatrix()
also provide (some) access to the underlying information: covariance matrix corresponding to eigenvec...
std::map< std::string, std::map< std::string, unsigned int > > m_flav_namedIndices
unsigned int getNamedVariationIndex(const std::string &name, const std::string &flavour) const
bool isExtrapolationVariation(unsigned int nameIndex, const std::string &flavour) const
std::map< std::string, std::vector< std::pair< TH1 *, TH1 * > > > m_flav_eigen
std::map< std::string, std::vector< int > > m_flavour_combinations
void mergeVariations(const IndexSet &set, std::string &flav)
void mergeVariationsFrom(const size_t &index, std::string &flav)
bool getNamedVariation(const std::string &flavour, const std::string &name, TH1 *&up, TH1 *&down)
This is the class holding information for histogram-based calibration results.
STL class.
std::string base
Definition hcg.cxx:81
std::string label(const std::string &format, int i)
Definition label.h:19
The namespace of all packages in PhysicsAnalysis/JetTagging.
Definition index.py:1
void initialize()