CMS 3D CMS Logo

LA_Filler_Fitter.h
Go to the documentation of this file.
1 #ifndef LA_FILLER_FITTER_H
2 #define LA_FILLER_FITTER_H
3 
4 #include <string>
5 #include <vector>
6 #include <map>
10 #include <TTree.h>
11 #include "SymmetryFit.h"
12 class TProfile;
13 
15 public:
16  //ensemble constructor
17  LA_Filler_Fitter(int methods, int M, int N, double low, double up, unsigned max, const TrackerTopology* tTopo)
18  : ensembleSize_(M),
21  ensembleUp_(up),
22  byLayer_(true),
24  localYbin_(0),
25  stripsPerBin_(0),
26  maxEvents_(max),
27  methods_(methods),
28  tTopo_(tTopo) {}
29 
30  //measurement constructor
31  LA_Filler_Fitter(int methods,
32  bool layer,
33  bool module,
34  float localybin,
35  unsigned stripbin,
36  unsigned max,
37  const TrackerTopology* tTopo)
38  : ensembleSize_(0),
39  ensembleBins_(0),
40  ensembleLow_(0),
41  ensembleUp_(0),
42  byLayer_(layer),
44  localYbin_(localybin),
45  stripsPerBin_(stripbin),
46  maxEvents_(max),
47  methods_(methods),
48  tTopo_(tTopo) {}
49 
50  enum Method {
51  WIDTH = 1 << 0,
52  FIRST_METHOD = 1 << 0,
53  PROB1 = 1 << 1,
54  AVGV2 = 1 << 2,
55  AVGV3 = 1 << 3,
56  RMSV2 = 1 << 4,
57  RMSV3 = 1 << 5,
58  LAST_METHOD = 1 << 5
59  };
60 
61  static std::string method(Method m, bool fit = true) {
62  switch (m) {
63  case WIDTH:
64  return "_width_prof";
65  case PROB1:
66  return fit ? SymmetryFit::name(method(m, false)) : "_prob_w1";
67  case AVGV2:
68  return fit ? SymmetryFit::name(method(m, false)) : "_avg_var_w2";
69  case AVGV3:
70  return fit ? SymmetryFit::name(method(m, false)) : "_avg_var_w3";
71  case RMSV2:
72  return fit ? SymmetryFit::name(method(m, false)) : "_rms_var_w2";
73  case RMSV3:
74  return fit ? SymmetryFit::name(method(m, false)) : "_rms_var_w3";
75  default:
76  return "_UNKNOWN";
77  }
78  }
79 
80  struct Result {
81  std::pair<float, float> reco, measured, calMeasured;
82  float field, chi2;
83  unsigned ndof, entries;
84  Result() : reco(1000, 0), measured(1000, 0), calMeasured(1000, 0), field(0), chi2(0), ndof(0), entries(0) {}
85  };
86 
87  struct EnsembleSummary {
88  std::pair<float, float> meanMeasured, sigmaMeasured, meanUncertainty, pull;
89  float truth;
90  unsigned samples;
92  : meanMeasured(0, 0), sigmaMeasured(0, 0), meanUncertainty(0, 0), pull(0, 0), truth(0), samples(0) {}
93  };
94 
95  //Located in src/LA_Filler.cc
96  void fill(TTree*, Book&) const;
97  void fill_one_cluster(
98  Book&, const poly<std::string>&, const unsigned, const float, const float, const float, const float) const;
99  poly<std::string> allAndOne(const unsigned width) const;
100  poly<std::string> varWidth(const unsigned width) const;
101  poly<std::string> granularity(const SiStripDetId, const float, const Long64_t, const float, const unsigned) const;
102  static std::string subdetLabel(const SiStripDetId);
103  static std::string moduleLabel(const SiStripDetId);
104  std::string layerLabel(const SiStripDetId) const;
105  static unsigned layer_index(bool TIB, bool stereo, unsigned layer) {
106  return layer + (TIB ? 0 : 6) + (stereo ? 1 : 0) + ((layer > 2) ? 1 : (layer == 1) ? -1 : 0);
107  }
108 
109  //Located in src/LA_Fitter.cc
110  static void fit(Book& book) {
111  make_and_fit_symmchi2(book);
112  fit_width_profile(book);
113  }
114  static void make_and_fit_symmchi2(Book&);
115  static void fit_width_profile(Book&);
116  static TH1* rms_profile(const std::string, const TProfile* const);
117  static TH1* subset_probability(const std::string name, const TH1* const, const TH1* const);
118  static unsigned find_rebin(const TH1* const);
119 
120  //Located in src/LA_Results.cc
121  void summarize_ensembles(Book&) const;
122  static Result result(Method, const std::string name, const Book&);
123  static std::map<std::string, Result> layer_results(const Book&, const Method);
124  static std::map<uint32_t, Result> module_results(const Book&, const Method);
125  static std::map<std::string, std::vector<Result> > ensemble_results(const Book&, const Method);
126  static std::map<std::string, std::vector<EnsembleSummary> > ensemble_summary(const Book&);
127  static std::pair<std::pair<float, float>, std::pair<float, float> > offset_slope(const std::vector<EnsembleSummary>&);
128  static float pull(const std::vector<EnsembleSummary>&);
129 
130 private:
132  const double ensembleLow_, ensembleUp_;
133  const bool byLayer_, byModule_;
134  const float localYbin_;
135  const unsigned stripsPerBin_;
136  const Long64_t maxEvents_;
137  const int methods_;
139 };
140 
141 std::ostream& operator<<(std::ostream&, const LA_Filler_Fitter::Result&);
142 std::ostream& operator<<(std::ostream&, const LA_Filler_Fitter::EnsembleSummary&);
143 
144 #endif
LA_Filler_Fitter::Method
Method
Definition: LA_Filler_Fitter.h:50
LA_Filler_Fitter::ensembleSize_
const int ensembleSize_
Definition: LA_Filler_Fitter.h:131
SectorBuilder_Tib_cff.TIB
TIB
Definition: SectorBuilder_Tib_cff.py:16
LA_Filler_Fitter::EnsembleSummary::meanMeasured
std::pair< float, float > meanMeasured
Definition: LA_Filler_Fitter.h:88
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
LA_Filler_Fitter::offset_slope
static std::pair< std::pair< float, float >, std::pair< float, float > > offset_slope(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:144
LA_Filler_Fitter::EnsembleSummary::sigmaMeasured
std::pair< float, float > sigmaMeasured
Definition: LA_Filler_Fitter.h:88
LA_Filler_Fitter::Result::Result
Result()
Definition: LA_Filler_Fitter.h:84
funct::false
false
Definition: Factorize.h:29
LA_Filler_Fitter::find_rebin
static unsigned find_rebin(const TH1 *const)
Definition: LA_Fitter.cc:104
LA_Filler_Fitter::PROB1
Definition: LA_Filler_Fitter.h:53
LA_Filler_Fitter::Result
Definition: LA_Filler_Fitter.h:80
LA_Filler_Fitter::methods_
const int methods_
Definition: LA_Filler_Fitter.h:137
LA_Filler_Fitter::Result::calMeasured
std::pair< float, float > calMeasured
Definition: LA_Filler_Fitter.h:81
LA_Filler_Fitter::Result::entries
unsigned entries
Definition: LA_Filler_Fitter.h:83
LA_Filler_Fitter::byModule_
const bool byModule_
Definition: LA_Filler_Fitter.h:133
TrackerTopology
Definition: TrackerTopology.h:16
LA_Filler_Fitter::rms_profile
static TH1 * rms_profile(const std::string, const TProfile *const)
Definition: LA_Fitter.cc:121
LA_Filler_Fitter::allAndOne
poly< std::string > allAndOne(const unsigned width) const
Definition: LA_Filler.cc:77
LA_Filler_Fitter::tTopo_
const TrackerTopology * tTopo_
Definition: LA_Filler_Fitter.h:138
SiStripDetId.h
SymmetryFit::name
static std::string name(std::string base)
Definition: SymmetryFit.h:12
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
SymmetryFit.h
Book
Definition: Book.h:16
LA_Filler_Fitter::AVGV2
Definition: LA_Filler_Fitter.h:54
LA_Filler_Fitter::Result::ndof
unsigned ndof
Definition: LA_Filler_Fitter.h:83
LA_Filler_Fitter::subdetLabel
static std::string subdetLabel(const SiStripDetId)
Definition: LA_Filler.cc:121
LA_Filler_Fitter::layerLabel
std::string layerLabel(const SiStripDetId) const
Definition: LA_Filler.cc:127
LA_Filler_Fitter::fill_one_cluster
void fill_one_cluster(Book &, const poly< std::string > &, const unsigned, const float, const float, const float, const float) const
Definition: LA_Filler.cc:59
TrackerTopology.h
LA_Filler_Fitter::RMSV3
Definition: LA_Filler_Fitter.h:57
LA_Filler_Fitter::LA_Filler_Fitter
LA_Filler_Fitter(int methods, bool layer, bool module, float localybin, unsigned stripbin, unsigned max, const TrackerTopology *tTopo)
Definition: LA_Filler_Fitter.h:31
LA_Filler_Fitter::summarize_ensembles
void summarize_ensembles(Book &) const
Definition: LA_Results.cc:89
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
LA_Filler_Fitter::byLayer_
const bool byLayer_
Definition: LA_Filler_Fitter.h:133
LA_Filler_Fitter::Result::reco
std::pair< float, float > reco
Definition: LA_Filler_Fitter.h:81
LA_Filler_Fitter::method
static std::string method(Method m, bool fit=true)
Definition: LA_Filler_Fitter.h:61
N
#define N
Definition: blowfish.cc:9
LA_Filler_Fitter::varWidth
poly< std::string > varWidth(const unsigned width) const
Definition: LA_Filler.cc:84
LA_Filler_Fitter::ensembleBins_
const int ensembleBins_
Definition: LA_Filler_Fitter.h:131
LA_Filler_Fitter::Result::field
float field
Definition: LA_Filler_Fitter.h:82
LA_Filler_Fitter::WIDTH
Definition: LA_Filler_Fitter.h:51
LA_Filler_Fitter::ensemble_results
static std::map< std::string, std::vector< Result > > ensemble_results(const Book &, const Method)
Definition: LA_Results.cc:79
LA_Filler_Fitter::moduleLabel
static std::string moduleLabel(const SiStripDetId)
Definition: LA_Filler.cc:124
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
LA_Filler_Fitter::LAST_METHOD
Definition: LA_Filler_Fitter.h:58
LA_Filler_Fitter::ensembleUp_
const double ensembleUp_
Definition: LA_Filler_Fitter.h:132
funct::true
true
Definition: Factorize.h:173
LA_Filler_Fitter::make_and_fit_symmchi2
static void make_and_fit_symmchi2(Book &)
Definition: LA_Fitter.cc:40
LA_Filler_Fitter::EnsembleSummary::EnsembleSummary
EnsembleSummary()
Definition: LA_Filler_Fitter.h:91
LA_Filler_Fitter::layer_index
static unsigned layer_index(bool TIB, bool stereo, unsigned layer)
Definition: LA_Filler_Fitter.h:105
LA_Filler_Fitter::layer_results
static std::map< std::string, Result > layer_results(const Book &, const Method)
Definition: LA_Results.cc:70
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LA_Filler_Fitter::EnsembleSummary::meanUncertainty
std::pair< float, float > meanUncertainty
Definition: LA_Filler_Fitter.h:88
Book.h
LA_Filler_Fitter::stripsPerBin_
const unsigned stripsPerBin_
Definition: LA_Filler_Fitter.h:135
LA_Filler_Fitter::Result::measured
std::pair< float, float > measured
Definition: LA_Filler_Fitter.h:81
LA_Filler_Fitter::subset_probability
static TH1 * subset_probability(const std::string name, const TH1 *const, const TH1 *const)
Definition: LA_Fitter.cc:135
LA_Filler_Fitter::EnsembleSummary::samples
unsigned samples
Definition: LA_Filler_Fitter.h:90
LA_Filler_Fitter::fit
static void fit(Book &book)
Definition: LA_Filler_Fitter.h:110
LA_Filler_Fitter::pull
static float pull(const std::vector< EnsembleSummary > &)
Definition: LA_Results.cc:168
LA_Filler_Fitter::granularity
poly< std::string > granularity(const SiStripDetId, const float, const Long64_t, const float, const unsigned) const
Definition: LA_Filler.cc:94
LA_Filler_Fitter::AVGV3
Definition: LA_Filler_Fitter.h:55
LA_Filler_Fitter::Result::chi2
float chi2
Definition: LA_Filler_Fitter.h:82
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LA_Filler_Fitter::EnsembleSummary
Definition: LA_Filler_Fitter.h:87
callgraph.module
module
Definition: callgraph.py:61
LA_Filler_Fitter::ensembleLow_
const double ensembleLow_
Definition: LA_Filler_Fitter.h:132
LA_Filler_Fitter::EnsembleSummary::truth
float truth
Definition: LA_Filler_Fitter.h:89
LA_Filler_Fitter::ensemble_summary
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
Definition: LA_Results.cc:115
poly
Definition: poly.h:11
LA_Filler_Fitter::fit_width_profile
static void fit_width_profile(Book &)
Definition: LA_Fitter.cc:8
LA_Filler_Fitter::maxEvents_
const Long64_t maxEvents_
Definition: LA_Filler_Fitter.h:136
LA_Filler_Fitter::result
static Result result(Method, const std::string name, const Book &)
Definition: LA_Results.cc:12
LA_Filler_Fitter
Definition: LA_Filler_Fitter.h:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
LA_Filler_Fitter::RMSV2
Definition: LA_Filler_Fitter.h:56
LA_Filler_Fitter::LA_Filler_Fitter
LA_Filler_Fitter(int methods, int M, int N, double low, double up, unsigned max, const TrackerTopology *tTopo)
Definition: LA_Filler_Fitter.h:17
SiStripDetId
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
LA_Filler_Fitter::module_results
static std::map< uint32_t, Result > module_results(const Book &, const Method)
Definition: LA_Results.cc:60
LA_Filler_Fitter::FIRST_METHOD
Definition: LA_Filler_Fitter.h:52
operator<<
std::ostream & operator<<(std::ostream &, const LA_Filler_Fitter::Result &)
Definition: LA_Results.cc:178
LA_Filler_Fitter::fill
void fill(TTree *, Book &) const
Definition: LA_Filler.cc:7
LA_Filler_Fitter::EnsembleSummary::pull
std::pair< float, float > pull
Definition: LA_Filler_Fitter.h:88
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
fit
Definition: CombinedChiSquaredLikelihood.h:6
up
Definition: BitonicSort.h:7
LA_Filler_Fitter::localYbin_
const float localYbin_
Definition: LA_Filler_Fitter.h:134