CMS 3D CMS Logo

Classes | Functions | Variables
HOCalibAnalyzer.cc File Reference
#include <memory>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/HcalCalibObjects/interface/HOCalibVariables.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "TMath.h"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TTree.h"
#include "TProfile.h"
#include "TPostScript.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TStyle.h"
#include "TMinuit.h"
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>

Go to the source code of this file.

Classes

class  HOCalibAnalyzer
 

Functions

void fcnbg (Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
 
void fcnsg (Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t flag)
 
Double_t gausX (Double_t *x, Double_t *par)
 
Double_t langaufun (Double_t *x, Double_t *par)
 
static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker< edm::ParameterSetDescriptionFiller< HOCalibAnalyzer > > s_filler__LINE__ ("HOCalibAnalyzer")
 
static const edm::MakerPluginFactory::PMaker< edm::WorkerMaker< HOCalibAnalyzer > > s_maker__LINE__ ("HOCalibAnalyzer")
 
void set_mean (double &x, bool mdigi)
 
void set_sigma (double &x, bool mdigi)
 
Double_t totalfunc (Double_t *x, Double_t *par)
 

Variables

std::vector< float > cro_ssg [netamx][nphimx+1]
 
static const int etamap [4][21]
 
int ietafit
 
int iphifit
 
static const int mapx0m [9][2] = {{17, 19}, {14, 15}, {13, 16}, {9, 11}, {0, 0}, {8, 12}, {5, 6}, {4, 7}, {1, 3}}
 
static const int mapx0p [9][2] = {{3, 1}, {7, 4}, {6, 5}, {12, 8}, {0, 0}, {11, 9}, {16, 13}, {15, 14}, {19, 17}}
 
static const int mapx1 [6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {19, 18, 17}}
 
static const int mapx2 [6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {-1, -1, -1}}
 
static const int nbgpr = 3
 
static const int netamx = 30
 
static const int nphimx = 72
 
static const int npixlebt [21] = {0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0, 11, 13, 14, 15, 0}
 
static const int npixleft [21] = {0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0, 11, 0, 13, 14, 15, 0, 17, 18, 0}
 
static const int npixleup [21] = {0, 4, 5, 6, 8, 9, 0, 11, 0, 13, 0, 15, 16, 0, 17, 18, 19, 0, 0, 0, 0}
 
static const int npixribt [21] = {0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0, 11, 12, 14, 15, 16, 0}
 
static const int npixrigh [21] = {0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0, 12, 0, 14, 15, 16, 0, 18, 19, 0, 0}
 
static const int npixriup [21] = {0, 5, 6, 7, 9, 0, 11, 12, 13, 14, 0, 16, 0, 17, 18, 19, 0, 0, 0, 0, 0}
 
static const int nsgpr = 7
 
static const int phimap [4][21]
 
std::vector< float > sig_reg [netamx][nphimx+1]
 

Function Documentation

void fcnbg ( Int_t &  npar,
Double_t *  gin,
Double_t &  f,
Double_t *  par,
Int_t  flag 
)

Definition at line 166 of file HOCalibAnalyzer.cc.

References cro_ssg, MillePedeFileConverter_cfg::e, ietafit, iphifit, cmsBatch::log, and SiStripPI::max.

Referenced by HOCalibAnalyzer::endJob().

166  {
167  double fval = -par[0];
168  for (unsigned ij = 0; ij < cro_ssg[ietafit][iphifit].size(); ij++) {
169  double xval = (double)cro_ssg[ietafit][iphifit][ij];
170  fval += std::log(std::max(1.e-30, par[0] * TMath::Gaus(xval, par[1], par[2], true)));
171  // fval +=std::log(par[0]*TMath::Gaus(xval, par[1], par[2], 1));
172  }
173  f = -fval;
174 }
std::vector< float > cro_ssg[netamx][nphimx+1]
int iphifit
double f[11][100]
int ietafit
void fcnsg ( Int_t &  npar,
Double_t *  gin,
Double_t &  f,
Double_t *  par,
Int_t  flag 
)

Definition at line 176 of file HOCalibAnalyzer.cc.

References ietafit, iphifit, cmsBatch::log, sig_reg, and totalfunc().

Referenced by HOCalibAnalyzer::endJob().

176  {
177  double xval[2];
178  double fval = -(par[0] + par[5]);
179  for (unsigned ij = 0; ij < sig_reg[ietafit][iphifit].size(); ij++) {
180  xval[0] = (double)sig_reg[ietafit][iphifit][ij];
181  fval += std::log(totalfunc(xval, par));
182  }
183  f = -fval;
184 }
Double_t totalfunc(Double_t *x, Double_t *par)
int iphifit
double f[11][100]
std::vector< float > sig_reg[netamx][nphimx+1]
int ietafit
Double_t gausX ( Double_t *  x,
Double_t *  par 
)

Definition at line 112 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::endJob(), and totalfunc().

112 { return par[0] * (TMath::Gaus(x[0], par[1], par[2], kTRUE)); }
Double_t langaufun ( Double_t *  x,
Double_t *  par 
)

Definition at line 114 of file HOCalibAnalyzer.cc.

References np, SimDataFormats::CaloAnalysis::sc, and geometryCSVtoXML::xx.

Referenced by HOCalibAnalyzer::endJob(), and totalfunc().

114  {
115  //Fit parameters:
116  //par[0]*par[1]=Width (scale) parameter of Landau density
117  //par[1]=Most Probable (MP, location) parameter of Landau density
118  //par[2]=Total area (integral -inf to inf, normalization constant)
119  //par[3]=Width (sigma) of convoluted Gaussian function
120  //
121  //In the Landau distribution (represented by the CERNLIB approximation),
122  //the maximum is located at x=-0.22278298 with the location parameter=0.
123  //This shift is corrected within this function, so that the actual
124  //maximum is identical to the MP parameter.
125  // /*
126  // Numeric constants
127  Double_t invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
128  Double_t mpshift = -0.22278298; // Landau maximum location
129 
130  // Control constants
131  Double_t np = 100.0; // number of convolution steps
132  Double_t sc = 5.0; // convolution extends to +-sc Gaussian sigmas
133 
134  // Variables
135  Double_t xx;
136  Double_t mpc;
137  Double_t fland;
138  Double_t sum = 0.0;
139  Double_t xlow, xupp;
140  Double_t step;
141 
142  // MP shift correction
143  mpc = par[1] - mpshift * par[0] * par[1];
144 
145  // Range of convolution integral
146  xlow = x[0] - sc * par[3];
147  xupp = x[0] + sc * par[3];
148 
149  step = (xupp - xlow) / np;
150 
151  // Convolution integral of Landau and Gaussian by sum
152  for (double ij = 1.0; ij <= np / 2; ij++) {
153  xx = xlow + (ij - .5) * step;
154  fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE); // / par[0];
155  sum += fland * TMath::Gaus(x[0], xx, par[3]);
156  xx = xupp - (ij - .5) * step;
157  fland = TMath::Landau(xx, mpc, par[0] * par[1], kTRUE); // / par[0];
158  sum += fland * TMath::Gaus(x[0], xx, par[3]);
159  }
160 
161  return (par[2] * step * sum * invsq2pi / par[3]);
162 }
int np
Definition: AMPTWrapper.h:33
step
Definition: StallMonitor.cc:94
static const edm::ParameterSetDescriptionFillerPluginFactory::PMaker<edm::ParameterSetDescriptionFiller< HOCalibAnalyzer > > s_filler__LINE__ ( "HOCalibAnalyzer"  )
static
static const edm::MakerPluginFactory ::PMaker< edm::WorkerMaker< HOCalibAnalyzer > > s_maker__LINE__ ( "HOCalibAnalyzer"  )
static
void set_mean ( double &  x,
bool  mdigi 
)

Definition at line 186 of file HOCalibAnalyzer.cc.

References SiStripPI::max, and min().

Referenced by HOCalibAnalyzer::endJob().

186  {
187  if (mdigi) {
188  x = std::min(x, 0.5);
189  x = std::max(x, -0.5);
190  } else {
191  x = std::min(x, 0.1);
192  x = std::max(x, -0.1);
193  }
194 }
T min(T a, T b)
Definition: MathUtil.h:58
void set_sigma ( double &  x,
bool  mdigi 
)

Definition at line 196 of file HOCalibAnalyzer.cc.

References SiStripPI::max, and min().

Referenced by HOCalibAnalyzer::endJob().

196  {
197  if (mdigi) {
198  x = std::min(x, 1.2);
199  x = std::max(x, -1.2);
200  } else {
201  x = std::min(x, 0.24);
202  x = std::max(x, 0.03);
203  }
204 }
T min(T a, T b)
Definition: MathUtil.h:58
Double_t totalfunc ( Double_t *  x,
Double_t *  par 
)

Definition at line 164 of file HOCalibAnalyzer.cc.

References gausX(), and langaufun().

Referenced by HOCalibAnalyzer::endJob(), and fcnsg().

164 { return gausX(x, par) + langaufun(x, &par[3]); }
Double_t gausX(Double_t *x, Double_t *par)
Double_t langaufun(Double_t *x, Double_t *par)

Variable Documentation

std::vector<float> cro_ssg[netamx][nphimx+1]

Definition at line 105 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze(), and fcnbg().

const int etamap[4][21]
static
Initial value:
= {{-1, 0, 3, 1, 0, 2, 3, 1, 0, 2, -1, 3, 1, 2, 4, 4, 4, -1, -1, -1, -1},
{-1, 0, 3, 1, 0, 2, 3, 1, 0, 2, -1, 3, 1, 2, 4, 4, 4, 5, 5, 5, -1},
{-1, 0, -1, 0, 1, 2, 2, 1, 3, 5, -1, 5, 3, 6, 7, 7, 6, 8, -1, 8, -1},
{-1, 8, -1, 8, 7, 6, 6, 7, 5, 3, -1, 3, 5, 2, 1, 1, 2, 0, -1, 0, -1}}

Definition at line 79 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

int ietafit

Definition at line 102 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::endJob(), fcnbg(), and fcnsg().

int iphifit

Definition at line 103 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::endJob(), fcnbg(), and fcnsg().

const int mapx0m[9][2] = {{17, 19}, {14, 15}, {13, 16}, {9, 11}, {0, 0}, {8, 12}, {5, 6}, {4, 7}, {1, 3}}
static

Definition at line 77 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int mapx0p[9][2] = {{3, 1}, {7, 4}, {6, 5}, {12, 8}, {0, 0}, {11, 9}, {16, 13}, {15, 14}, {19, 17}}
static

Definition at line 76 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int mapx1[6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {19, 18, 17}}
static

Definition at line 72 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int mapx2[6][3] = {{1, 4, 8}, {12, 7, 3}, {5, 9, 13}, {11, 6, 2}, {16, 15, 14}, {-1, -1, -1}}
static

Definition at line 74 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int nbgpr = 3
static

Definition at line 99 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::endJob().

const int netamx = 30
static
const int nphimx = 72
static
const int npixlebt[21] = {0, 0, 0, 0, 0, 1, 2, 3, 0, 4, 0, 6, 7, 8, 9, 0, 11, 13, 14, 15, 0}
static

Definition at line 92 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int npixleft[21] = {0, 0, 1, 2, 0, 4, 5, 6, 0, 8, 0, 0, 11, 0, 13, 14, 15, 0, 17, 18, 0}
static

Definition at line 90 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int npixleup[21] = {0, 4, 5, 6, 8, 9, 0, 11, 0, 13, 0, 15, 16, 0, 17, 18, 19, 0, 0, 0, 0}
static

Definition at line 94 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int npixribt[21] = {0, 0, 0, 0, 1, 2, 3, 0, 4, 5, 0, 7, 0, 9, 0, 11, 12, 14, 15, 16, 0}
static

Definition at line 93 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int npixrigh[21] = {0, 2, 3, 0, 5, 6, 7, 0, 9, 0, 0, 12, 0, 14, 15, 16, 0, 18, 19, 0, 0}
static

Definition at line 91 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int npixriup[21] = {0, 5, 6, 7, 9, 0, 11, 12, 13, 14, 0, 16, 0, 17, 18, 19, 0, 0, 0, 0, 0}
static

Definition at line 95 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

const int nsgpr = 7
static

Definition at line 100 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::endJob().

const int phimap[4][21]
static
Initial value:
= {{-1, 0, 2, 2, 1, 0, 1, 1, 2, 1, -1, 0, 0, 2, 2, 1, 0, 2, 1, 0, -1},
{-1, 0, 2, 2, 1, 0, 1, 1, 2, 1, -1, 0, 0, 2, 2, 1, 0, 2, 1, 0, -1},
{-1, 1, -1, 0, 1, 1, 0, 0, 1, 1, -1, 0, 0, 1, 1, 0, 0, 1, -1, 0, -1},
{-1, 0, -1, 1, 0, 0, 1, 1, 0, 0, -1, 1, 1, 0, 0, 1, 1, 0, -1, 1, -1}}

Definition at line 84 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze().

std::vector<float> sig_reg[netamx][nphimx+1]

Definition at line 104 of file HOCalibAnalyzer.cc.

Referenced by HOCalibAnalyzer::analyze(), HOCalibAnalyzer::endJob(), and fcnsg().