CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ZIterativeAlgorithmWithFit Class Reference

#include <ZIterativeAlgorithmWithFit.h>

Classes

struct  ZIterativeAlgorithmWithFitPlots
 

Public Member Functions

bool addEvent (calib::CalibElectron *, calib::CalibElectron *, float)
 
const std::vector< float > & getEpsilonSum () const
 
const ZIterativeAlgorithmWithFitPlotsgetHistos () const
 
int getNumberOfChannels () const
 
int getNumberOfIterations () const
 
const std::vector< float > & getOptimizedChiSquare () const
 
const std::vector< float > & getOptimizedCoefficients () const
 
const std::vector< float > & getOptimizedCoefficientsError () const
 
const std::vector< int > & getOptimizedIterations () const
 
const std::vector< float > & getWeightSum () const
 
bool iterate ()
 
ZIterativeAlgorithmWithFitoperator= (const ZIterativeAlgorithmWithFit &r)
 Assignment operator. More...
 
bool resetIteration ()
 
 ZIterativeAlgorithmWithFit ()
 Default constructor. More...
 
 ZIterativeAlgorithmWithFit (const edm::ParameterSet &ps)
 Constructor with explicit iterations & exponent. More...
 
virtual ~ZIterativeAlgorithmWithFit ()
 Destructor. More...
 

Static Public Member Functions

static float cosTheta12 (float Eta1, float Phi1, float Eta2, float Phi2)
 
static void gausfit (TH1F *histoou, double *par, double *errpar, float nsigmalow, float nsigmaup, double *mychi2, int *iterations)
 
static float invMassCalc (float Energy1, float Eta1, float Phi1, float Energy2, float Eta2, float Phi2)
 

Private Member Functions

void addWeightsCorrections (unsigned int event_id)
 
void bookHistograms ()
 
float getEventWeight (unsigned int event_id)
 
void getStatWeights (const std::string &file)
 
void getWeight (unsigned int evid, calib::CalibElectron *ele, float)
 
void getWeight (unsigned int evid, std::pair< calib::CalibElectron *, calib::CalibElectron * >, float)
 
void recalculateMasses ()
 
void recalculateWeightsEnergies ()
 
void recalculateWeightsEnergies (calib::CalibElectron *electron)
 

Private Attributes

std::vector< float > calib_fac_
 
TString calibType_
 
unsigned int channels_
 
unsigned int currentEvent_
 
unsigned int currentIteration_
 
std::vector< std::pair< calib::CalibElectron *, calib::CalibElectron * > > electrons_
 
std::vector< float > Event_Weight_
 
std::string massMethod
 
std::vector< float > massReco_
 
int nCrystalCut_
 
unsigned int numberOfIterations_
 
std::vector< float > optimizedChiSquare_
 
std::vector< float > optimizedCoefficients_
 
std::vector< float > optimizedCoefficientsError_
 
std::vector< int > optimizedIterations_
 
std::vector< float > StatWeights_
 
ZIterativeAlgorithmWithFitPlotsthePlots_
 
unsigned int totalEvents_
 
bool UseStatWeights_
 
std::vector< float > weight_sum_
 
std::string WeightFileName_
 

Static Private Attributes

static const double M_Z_ = 91.187
 

Detailed Description

Class that implements an iterative in situ calibration algorithm using Z events

Author: paolo.nosp@m..mer.nosp@m.idian.nosp@m.i@ro.nosp@m.ma1.i.nosp@m.nfn..nosp@m.it

Definition at line 28 of file ZIterativeAlgorithmWithFit.h.

Constructor & Destructor Documentation

◆ ZIterativeAlgorithmWithFit() [1/2]

ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFit ( )

Default constructor.

Definition at line 46 of file ZIterativeAlgorithmWithFit.cc.

46  {
47  // std::cout<< "ZIterativeAlgorithmWithFit::Called Construnctor" << std::endl;
49  channels_ = 1;
50  totalEvents_ = 0;
51  currentEvent_ = 0;
57  calib_fac_.resize(channels_);
58  weight_sum_.resize(channels_);
59  electrons_.resize(1);
60  massReco_.resize(1);
61 }

References calib_fac_, channels_, currentEvent_, currentIteration_, electrons_, massReco_, numberOfIterations_, optimizedChiSquare_, optimizedCoefficients_, optimizedCoefficientsError_, optimizedIterations_, totalEvents_, and weight_sum_.

◆ ZIterativeAlgorithmWithFit() [2/2]

ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFit ( const edm::ParameterSet ps)

Constructor with explicit iterations & exponent.

Definition at line 63 of file ZIterativeAlgorithmWithFit.cc.

65 {
66  //std::cout<< "ZIterativeAlgorithmWithFit::Called Constructor" << std::endl;
67  numberOfIterations_ = ps.getUntrackedParameter<unsigned int>("maxLoops", 0);
68  massMethod = ps.getUntrackedParameter<std::string>("ZCalib_InvMass", "SCMass");
69  calibType_ = ps.getUntrackedParameter<std::string>("ZCalib_CalibType", "RING");
70 
71  if (calibType_ == "RING")
73  else if (calibType_ == "MODULE")
74 
76  else if (calibType_ == "ABS_SCALE")
77  channels_ = 1;
78  else if (calibType_ == "ETA_ET_MODE")
80 
81  std::cout << "[ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFit] channels_ = " << channels_ << std::endl;
82 
83  nCrystalCut_ = ps.getUntrackedParameter<int>("ZCalib_nCrystalCut", -1);
84 
85  //Resetting currentEvent & iteration
86  currentEvent_ = 0;
88  totalEvents_ = 0;
89 
94  calib_fac_.resize(channels_);
95  weight_sum_.resize(channels_);
96 
97  //Creating and booking histograms
98  thePlots_ = new ZIterativeAlgorithmWithFitPlots;
100 
101  //Setting up rescaling if needed
102  UseStatWeights_ = ps.getUntrackedParameter<bool>("ZCalib_UseStatWeights", false);
103  if (UseStatWeights_) {
104  WeightFileName_ = "weights.txt";
105  StatWeights_.resize(channels_);
107  // Event_Weight_.resize(events);
108  }
109 }

References bookHistograms(), calib_fac_, calibType_, channels_, gather_cfg::cout, currentEvent_, currentIteration_, EcalIndexingTools::getInstance(), EcalIndexingTools::getNumberOfChannels(), getStatWeights(), edm::ParameterSet::getUntrackedParameter(), massMethod, EcalRingCalibrationTools::N_MODULES_BARREL, EcalRingCalibrationTools::N_RING_TOTAL, nCrystalCut_, numberOfIterations_, optimizedChiSquare_, optimizedCoefficients_, optimizedCoefficientsError_, optimizedIterations_, StatWeights_, AlCaHLTBitMon_QueryRunRegistry::string, thePlots_, totalEvents_, UseStatWeights_, weight_sum_, and WeightFileName_.

◆ ~ZIterativeAlgorithmWithFit()

ZIterativeAlgorithmWithFit::~ZIterativeAlgorithmWithFit ( )
virtual

Destructor.

Definition at line 353 of file ZIterativeAlgorithmWithFit.cc.

353 {}

Member Function Documentation

◆ addEvent()

bool ZIterativeAlgorithmWithFit::addEvent ( calib::CalibElectron ele1,
calib::CalibElectron ele2,
float  invMassRescFactor 
)

Definition at line 250 of file ZIterativeAlgorithmWithFit.cc.

252  {
253  totalEvents_++;
254  std::pair<calib::CalibElectron*, calib::CalibElectron*> Electrons(ele1, ele2);
255 #ifdef DEBUG
256  std::cout << "In addEvent ";
257  std::cout << ele1->getRecoElectron()->superCluster()->rawEnergy() << " ";
258  std::cout << ele1->getRecoElectron()->superCluster()->position().eta() << " ";
259  std::cout << ele2->getRecoElectron()->superCluster()->rawEnergy() << " ";
260  std::cout << ele2->getRecoElectron()->superCluster()->position().eta() << " ";
261  std::cout << std::endl;
262 #endif
263 
264  if (massMethod == "SCTRMass") {
265  massReco_.push_back(invMassCalc(ele1->getRecoElectron()->superCluster()->energy(),
266  ele1->getRecoElectron()->eta(),
267  ele1->getRecoElectron()->phi(),
268  ele2->getRecoElectron()->superCluster()->energy(),
269  ele2->getRecoElectron()->eta(),
270  ele2->getRecoElectron()->phi()));
271  }
272 
273  else if (massMethod == "SCMass") {
274  massReco_.push_back(invMassCalc(ele1->getRecoElectron()->superCluster()->energy(),
275  ele1->getRecoElectron()->superCluster()->position().eta(),
276  ele1->getRecoElectron()->superCluster()->position().phi(),
277  ele2->getRecoElectron()->superCluster()->energy(),
278  ele2->getRecoElectron()->superCluster()->position().eta(),
279  ele2->getRecoElectron()->superCluster()->position().phi()));
280  }
281 
282 #ifdef DEBUG
283  std::cout << "Mass calculated " << massReco_[currentEvent_] << std::endl;
284 #endif
285 
286  if ((ele2->getRecoElectron()->superCluster()->position().eta() > -10.) &&
287  (ele2->getRecoElectron()->superCluster()->position().eta() < 10.) &&
288  (ele2->getRecoElectron()->superCluster()->position().phi() > -10.) &&
289  (ele2->getRecoElectron()->superCluster()->position().phi() < 10.)) {
290  getWeight(currentEvent_, Electrons, invMassRescFactor);
291  }
292 
293  currentEvent_++;
294  return kTRUE;
295 }

References gather_cfg::cout, currentEvent_, HLTTauDQMOffline_cfi::Electrons, reco::LeafCandidate::eta(), calib::CalibElectron::getRecoElectron(), getWeight(), invMassCalc(), massMethod, massReco_, reco::LeafCandidate::phi(), reco::GsfElectron::superCluster(), and totalEvents_.

Referenced by ZeeCalibration::duringLoop().

◆ addWeightsCorrections()

void ZIterativeAlgorithmWithFit::addWeightsCorrections ( unsigned int  event_id)
private

◆ bookHistograms()

void ZIterativeAlgorithmWithFit::bookHistograms ( )
private

Definition at line 111 of file ZIterativeAlgorithmWithFit.cc.

111  {
112  if (!thePlots_)
113  return;
114 
115  for (unsigned int i2 = 0; i2 < numberOfIterations_; i2++) {
116  for (unsigned int i1 = 0; i1 < channels_; i1++) {
117  char histoName[200];
118  char histoTitle[200];
119 
120  //WeightedRescaling factor
121  sprintf(histoName, "WeightedRescaleFactor_channel_%d_Iteration_%d", i1, i2);
122  sprintf(histoTitle, "WeightedRescaleFactor Channel_%d Iteration %d", i1, i2);
123  if (i1 > 15 && i1 < 155)
125  new TH1F(histoName, histoTitle, NBINS_LOWETA, MIN_RESCALE, MAX_RESCALE);
126  else
128  new TH1F(histoName, histoTitle, NBINS_HIGHETA, MIN_RESCALE, MAX_RESCALE);
129  thePlots_->weightedRescaleFactor[i2][i1]->GetXaxis()->SetTitle("Rescale factor");
130  thePlots_->weightedRescaleFactor[i2][i1]->GetYaxis()->SetTitle("a.u.");
131 
132  //UnweightedRescaling factor
133  sprintf(histoName, "UnweightedRescaleFactor_channel_%d_Iteration_%d", i1, i2);
134  sprintf(histoTitle, "UnweightedRescaleFactor Channel_%d Iteration %d", i1, i2);
135  if (i1 > 15 && i1 < 155)
137  new TH1F(histoName, histoTitle, NBINS_LOWETA, MIN_RESCALE, MAX_RESCALE);
138  else
140  new TH1F(histoName, histoTitle, NBINS_HIGHETA, MIN_RESCALE, MAX_RESCALE);
141  thePlots_->unweightedRescaleFactor[i2][i1]->GetXaxis()->SetTitle("Rescale factor");
142  thePlots_->unweightedRescaleFactor[i2][i1]->GetYaxis()->SetTitle("a.u.");
143 
144  //Weights
145  sprintf(histoName, "Weight_channel_%d_Iteration_%d", i1, i2);
146  sprintf(histoTitle, "Weight Channel_%d Iteration %d", i1, i2);
147  thePlots_->weight[i2][i1] = new TH1F(histoName, histoTitle, 100, 0., 1.);
148  thePlots_->weight[i2][i1]->GetXaxis()->SetTitle("Weight");
149  thePlots_->weight[i2][i1]->GetYaxis()->SetTitle("a.u.");
150  }
151  }
152 }

References channels_, HltBtagPostValidation_cff::histoName, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, MAX_RESCALE, MIN_RESCALE, NBINS_HIGHETA, NBINS_LOWETA, numberOfIterations_, thePlots_, ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::unweightedRescaleFactor, ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weight, and ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weightedRescaleFactor.

Referenced by ZIterativeAlgorithmWithFit().

◆ cosTheta12()

static float ZIterativeAlgorithmWithFit::cosTheta12 ( float  Eta1,
float  Phi1,
float  Eta2,
float  Phi2 
)
inlinestatic

Definition at line 79 of file ZIterativeAlgorithmWithFit.h.

79  {
80  return ((cos(Phi1 - Phi2) + sinh(Eta1) * sinh(Eta2)) / (cosh(Eta1) * cosh(Eta2)));
81  }

References funct::cos().

Referenced by invMassCalc().

◆ gausfit()

void ZIterativeAlgorithmWithFit::gausfit ( TH1F *  histoou,
double *  par,
double *  errpar,
float  nsigmalow,
float  nsigmaup,
double *  mychi2,
int *  iterations 
)
static

Definition at line 355 of file ZIterativeAlgorithmWithFit.cc.

356  {
357  auto gausa = std::make_unique<TF1>(
358  "gausa", "gaus", histoou->GetMean() - 3 * histoou->GetRMS(), histoou->GetMean() + 3 * histoou->GetRMS());
359 
360  gausa->SetParameters(histoou->GetMaximum(), histoou->GetMean(), histoou->GetRMS());
361 
362  histoou->Fit(gausa.get(), "qR0N");
363 
364  double p1 = gausa->GetParameter(1);
365  double sigma = gausa->GetParameter(2);
366  double nor = gausa->GetParameter(0);
367 
368  double xmi, xma, xmin_fit, xmax_fit;
369  double chi2 = 100;
370  int iter = 0;
371 
372  while ((chi2 > 1. && iter < 5) || iter < 2) {
373  xmin_fit = p1 - nsigmalow * sigma;
374  xmax_fit = p1 + nsigmaup * sigma;
375  xmi = p1 - 5 * sigma;
376  xma = p1 + 5 * sigma;
377 
378  char suffix[20];
379  sprintf(suffix, "_iter_%d", iter);
380  auto fitFunc = std::make_unique<TF1>("FitFunc" + TString(suffix), "gaus", xmin_fit, xmax_fit);
381  fitFunc->SetParameters(nor, p1, sigma);
382  fitFunc->SetLineColor((int)(iter + 1));
383  fitFunc->SetLineWidth(1);
384  //histoou->Fit("FitFunc","lR+","");
385  histoou->Fit(fitFunc.get(), "qR0+", "");
386 
387  histoou->GetXaxis()->SetRangeUser(xmi, xma);
388  histoou->GetXaxis()->SetLabelSize(0.055);
389 
390  // std::cout << fitFunc->GetParameters() << "," << par << std::endl;
391  par[0] = (fitFunc->GetParameters())[0];
392  par[1] = (fitFunc->GetParameters())[1];
393  par[2] = (fitFunc->GetParameters())[2];
394  errpar[0] = (fitFunc->GetParErrors())[0];
395  errpar[1] = (fitFunc->GetParErrors())[1];
396  errpar[2] = (fitFunc->GetParErrors())[2];
397  if (fitFunc->GetNDF() != 0) {
398  chi2 = fitFunc->GetChisquare() / (fitFunc->GetNDF());
399  *myChi2 = chi2;
400 
401  } else {
402  chi2 = 100.;
403  // par[0]=-99;
404  // par[1]=-99;
405  // par[2]=-99;
406  std::cout << "WARNING: Not enough NDF" << std::endl;
407  // return 0;
408  }
409 
410  // Non visualizzare
411  // histoou->Draw();
412  // c1->Update();
413 
414  // std::cout << "iter " << iter << " chi2 " << chi2 << std::endl;
415  nor = par[0];
416  p1 = par[1];
417  sigma = par[2];
418  iter++;
419  *iterations = iter;
420  }
421  return;
422 }

References hltPixelTracks_cff::chi2, gather_cfg::cout, p1, and createPayload::suffix.

Referenced by ZeeCalibration::endOfLoop(), and iterate().

◆ getEpsilonSum()

const std::vector<float>& ZIterativeAlgorithmWithFit::getEpsilonSum ( ) const
inline

Definition at line 71 of file ZIterativeAlgorithmWithFit.h.

71 { return calib_fac_; }

References calib_fac_.

◆ getEventWeight()

float ZIterativeAlgorithmWithFit::getEventWeight ( unsigned int  event_id)
private

Definition at line 304 of file ZIterativeAlgorithmWithFit.cc.

304 { return 1.; }

◆ getHistos()

const ZIterativeAlgorithmWithFitPlots* ZIterativeAlgorithmWithFit::getHistos ( ) const
inline

Definition at line 55 of file ZIterativeAlgorithmWithFit.h.

55 { return thePlots_; }

References thePlots_.

Referenced by ZeeCalibration::endOfJob(), and ZeeRescaleFactorPlots::writeHistograms().

◆ getNumberOfChannels()

int ZIterativeAlgorithmWithFit::getNumberOfChannels ( ) const
inline

◆ getNumberOfIterations()

int ZIterativeAlgorithmWithFit::getNumberOfIterations ( ) const
inline

◆ getOptimizedChiSquare()

const std::vector<float>& ZIterativeAlgorithmWithFit::getOptimizedChiSquare ( ) const
inline

Definition at line 65 of file ZIterativeAlgorithmWithFit.h.

65 { return optimizedChiSquare_; }

References optimizedChiSquare_.

Referenced by ZeeCalibration::endOfLoop().

◆ getOptimizedCoefficients()

const std::vector<float>& ZIterativeAlgorithmWithFit::getOptimizedCoefficients ( ) const
inline

Definition at line 61 of file ZIterativeAlgorithmWithFit.h.

61 { return optimizedCoefficients_; }

References optimizedCoefficients_.

Referenced by ZeeCalibration::endOfLoop().

◆ getOptimizedCoefficientsError()

const std::vector<float>& ZIterativeAlgorithmWithFit::getOptimizedCoefficientsError ( ) const
inline

Definition at line 63 of file ZIterativeAlgorithmWithFit.h.

References optimizedCoefficientsError_.

Referenced by ZeeCalibration::endOfLoop().

◆ getOptimizedIterations()

const std::vector<int>& ZIterativeAlgorithmWithFit::getOptimizedIterations ( ) const
inline

Definition at line 67 of file ZIterativeAlgorithmWithFit.h.

67 { return optimizedIterations_; }

References optimizedIterations_.

Referenced by ZeeCalibration::endOfLoop().

◆ getStatWeights()

void ZIterativeAlgorithmWithFit::getStatWeights ( const std::string &  file)
private

Definition at line 154 of file ZIterativeAlgorithmWithFit.cc.

154  {
155  std::ifstream statfile;
156  statfile.open(file.c_str());
157  if (!statfile) {
158  std::cout << "ZIterativeAlgorithmWithFit::FATAL: stat weight file " << file << " not found" << std::endl;
159  exit(-1);
160  }
161  for (unsigned int i = 0; i < channels_; i++) {
162  int imod;
163  statfile >> imod >> StatWeights_[i];
164  //std::cout << "Read Stat Weight for module " << imod << ": " << StatWeights_[i] << std::endl;
165  }
166 }

References channels_, gather_cfg::cout, beamvalidation::exit(), geometryDiff::file, mps_fire::i, and StatWeights_.

Referenced by ZIterativeAlgorithmWithFit().

◆ getWeight() [1/2]

void ZIterativeAlgorithmWithFit::getWeight ( unsigned int  evid,
calib::CalibElectron ele,
float  evweight 
)
private

Definition at line 306 of file ZIterativeAlgorithmWithFit.cc.

306  {
307  // std::cout<< "getting weight for module " << module << " in electron " << ele << std::endl;
308 
309  std::vector<std::pair<int, float> > modules = (*ele).getCalibModulesWeights(calibType_);
310 
311  for (int imod = 0; imod < (int)modules.size(); imod++) {
312  int mod = (int)modules[imod].first;
313 
314  if (mod < (int)channels_ && mod >= 0) {
315  if (modules[imod].second >= 0.12 && modules[imod].second < 10000.) {
316  if ((nCrystalCut_ == -1) ||
317  ((!(mod <= nCrystalCut_ - 1)) && !((mod > (19 - nCrystalCut_)) && (mod <= (19 + nCrystalCut_))) &&
318  !((mod > (39 - nCrystalCut_)) && (mod <= (39 + nCrystalCut_))) &&
319  !((mod > (59 - nCrystalCut_)) && (mod <= (59 + nCrystalCut_))) &&
320  !((mod > (84 - nCrystalCut_)) && (mod <= (84 + nCrystalCut_))) &&
321  !((mod > (109 - nCrystalCut_)) && (mod <= (109 + nCrystalCut_))) &&
322  !((mod > (129 - nCrystalCut_)) && (mod <= (129 + nCrystalCut_))) &&
323  !((mod > (149 - nCrystalCut_)) && (mod <= (149 + nCrystalCut_))) && !(mod > (169 - nCrystalCut_)))) {
324  float weight2 = modules[imod].second / ele->getRecoElectron()->superCluster()->rawEnergy();
325 #ifdef DEBUG
326  std::cout << "w2 " << weight2 << std::endl;
327 #endif
328  if (weight2 >= 0. && weight2 <= 1.) {
329  float rescale = (TMath::Power((massReco_[event_id] / evweight), 2.) - 1) / 2.;
330 #ifdef DEBUG
331  std::cout << "rescale " << rescale << std::endl;
332 #endif
333  if (rescale >= MIN_RESCALE && rescale <= MAX_RESCALE) {
334  calib_fac_[mod] += weight2 * rescale;
335  weight_sum_[mod] += weight2;
336 
339  thePlots_->weight[currentIteration_][mod]->Fill(weight2, 1.);
340  } else {
341  std::cout << "[ZIterativeAlgorithmWithFit]::[getWeight]::rescale out " << rescale << std::endl;
342  }
343  }
344  }
345  }
346  } else {
347  std::cout << "ZIterativeAlgorithmWithFit::FATAL:found a wrong module_id " << mod << " channels " << channels_
348  << std::endl;
349  }
350  }
351 }

References calib_fac_, calibType_, channels_, gather_cfg::cout, currentIteration_, first, calib::CalibElectron::getRecoElectron(), createfilelist::int, massReco_, MAX_RESCALE, MIN_RESCALE, mod(), nCrystalCut_, MuonErrorMatrixAdjuster_cfi::rescale, edm::second(), reco::GsfElectron::superCluster(), thePlots_, ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::unweightedRescaleFactor, ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weight, weight_sum_, and ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weightedRescaleFactor.

◆ getWeight() [2/2]

void ZIterativeAlgorithmWithFit::getWeight ( unsigned int  evid,
std::pair< calib::CalibElectron *, calib::CalibElectron * >  elepair,
float  invMassRescFactor 
)
private

Definition at line 297 of file ZIterativeAlgorithmWithFit.cc.

299  {
300  getWeight(event_id, elepair.first, invMassRescFactor);
301  getWeight(event_id, elepair.second, invMassRescFactor);
302 }

Referenced by addEvent().

◆ getWeightSum()

const std::vector<float>& ZIterativeAlgorithmWithFit::getWeightSum ( ) const
inline

Definition at line 69 of file ZIterativeAlgorithmWithFit.h.

69 { return weight_sum_; }

References weight_sum_.

◆ invMassCalc()

static float ZIterativeAlgorithmWithFit::invMassCalc ( float  Energy1,
float  Eta1,
float  Phi1,
float  Energy2,
float  Eta2,
float  Phi2 
)
inlinestatic

◆ iterate()

bool ZIterativeAlgorithmWithFit::iterate ( )

Definition at line 182 of file ZIterativeAlgorithmWithFit.cc.

182  {
183  //Found optimized coefficients
184  for (int i = 0; i < (int)channels_; i++) {
185  //RP if (weight_sum_[i]!=0. && calib_fac_[i]!=0.) {
186  if ((nCrystalCut_ == -1) ||
187  ((!(i <= nCrystalCut_ - 1)) && !((i > (19 - nCrystalCut_)) && (i <= (19 + nCrystalCut_))) &&
188  !((i > (39 - nCrystalCut_)) && (i <= (39 + nCrystalCut_))) &&
189  !((i > (59 - nCrystalCut_)) && (i <= (59 + nCrystalCut_))) &&
190  !((i > (84 - nCrystalCut_)) && (i <= (84 + nCrystalCut_))) &&
191  !((i > (109 - nCrystalCut_)) && (i <= (109 + nCrystalCut_))) &&
192  !((i > (129 - nCrystalCut_)) && (i <= (129 + nCrystalCut_))) &&
193  !((i > (149 - nCrystalCut_)) && (i <= (149 + nCrystalCut_))) && !(i > (169 - nCrystalCut_)))) {
194  if (weight_sum_[i] != 0.) {
195  //optimizedCoefficients_[i] = calib_fac_[i]/weight_sum_[i];
196 
197  double gausFitParameters[3], gausFitParameterErrors[3], gausFitChi2;
198  int gausFitIterations;
199 
201  gausFitParameters,
202  gausFitParameterErrors,
203  2.5,
204  2.5,
205  &gausFitChi2,
206  &gausFitIterations);
207 
208  float peak = gausFitParameters[1];
209  float peakError = gausFitParameterErrors[1];
210  float chi2 = gausFitChi2;
211 
212  int iters = gausFitIterations;
213 
214  optimizedCoefficientsError_[i] = peakError;
216  optimizedIterations_[i] = iters;
217 
218  if (peak >= MIN_RESCALE && peak <= MAX_RESCALE)
219  optimizedCoefficients_[i] = 1 / (1 + peak);
220  else
222 
223  } else {
226  optimizedChiSquare_[i] = -1.;
227  optimizedIterations_[i] = 0;
228  }
229 
230  }
231 
232  else {
235  optimizedChiSquare_[i] = -1.;
236  optimizedIterations_[i] = 0;
237  // EcalCalibMap::getMap()->setRingCalib(i, optimizedCoefficients_[i]);
238  // // initialCoefficients_[i] *= optimizedCoefficients_[i];
239  }
240 
241  std::cout << "ZIterativeAlgorithmWithFit::run():Energy Rescaling Coefficient for region " << i << " is "
242  << optimizedCoefficients_[i] << ", with error " << optimizedCoefficientsError_[i]
243  << " - number of events: " << weight_sum_[i] << std::endl;
244  }
245 
247  return kTRUE;
248 }

References calib_fac_, channels_, hltPixelTracks_cff::chi2, gather_cfg::cout, currentIteration_, gausfit(), mps_fire::i, createfilelist::int, MAX_RESCALE, MIN_RESCALE, nCrystalCut_, optimizedChiSquare_, optimizedCoefficients_, optimizedCoefficientsError_, optimizedIterations_, thePlots_, weight_sum_, and ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weightedRescaleFactor.

Referenced by ZeeCalibration::endOfLoop().

◆ operator=()

ZIterativeAlgorithmWithFit& ZIterativeAlgorithmWithFit::operator= ( const ZIterativeAlgorithmWithFit r)
inline

Assignment operator.

Definition at line 44 of file ZIterativeAlgorithmWithFit.h.

44 { return *this; }

◆ recalculateMasses()

void ZIterativeAlgorithmWithFit::recalculateMasses ( )
private

◆ recalculateWeightsEnergies() [1/2]

void ZIterativeAlgorithmWithFit::recalculateWeightsEnergies ( )
private

◆ recalculateWeightsEnergies() [2/2]

void ZIterativeAlgorithmWithFit::recalculateWeightsEnergies ( calib::CalibElectron electron)
private

◆ resetIteration()

bool ZIterativeAlgorithmWithFit::resetIteration ( )

Definition at line 168 of file ZIterativeAlgorithmWithFit.cc.

168  {
169  totalEvents_ = 0;
170  currentEvent_ = 0;
171 
172  //Reset correction
173  massReco_.clear();
174  for (unsigned int i = 0; i < channels_; i++)
175  calib_fac_[i] = 0.;
176  for (unsigned int i = 0; i < channels_; i++)
177  weight_sum_[i] = 0.;
178 
179  return kTRUE;
180 }

References calib_fac_, channels_, currentEvent_, mps_fire::i, massReco_, totalEvents_, and weight_sum_.

Referenced by ZeeCalibration::startingNewLoop().

Member Data Documentation

◆ calib_fac_

std::vector<float> ZIterativeAlgorithmWithFit::calib_fac_
private

◆ calibType_

TString ZIterativeAlgorithmWithFit::calibType_
private

Definition at line 140 of file ZIterativeAlgorithmWithFit.h.

Referenced by getWeight(), and ZIterativeAlgorithmWithFit().

◆ channels_

unsigned int ZIterativeAlgorithmWithFit::channels_
private

◆ currentEvent_

unsigned int ZIterativeAlgorithmWithFit::currentEvent_
private

◆ currentIteration_

unsigned int ZIterativeAlgorithmWithFit::currentIteration_
private

Definition at line 120 of file ZIterativeAlgorithmWithFit.h.

Referenced by getWeight(), iterate(), and ZIterativeAlgorithmWithFit().

◆ electrons_

std::vector<std::pair<calib::CalibElectron*, calib::CalibElectron*> > ZIterativeAlgorithmWithFit::electrons_
private

Definition at line 122 of file ZIterativeAlgorithmWithFit.h.

Referenced by ZIterativeAlgorithmWithFit().

◆ Event_Weight_

std::vector<float> ZIterativeAlgorithmWithFit::Event_Weight_
private

Definition at line 138 of file ZIterativeAlgorithmWithFit.h.

◆ M_Z_

const double ZIterativeAlgorithmWithFit::M_Z_ = 91.187
staticprivate

Definition at line 142 of file ZIterativeAlgorithmWithFit.h.

◆ massMethod

std::string ZIterativeAlgorithmWithFit::massMethod
private

Definition at line 132 of file ZIterativeAlgorithmWithFit.h.

Referenced by addEvent(), and ZIterativeAlgorithmWithFit().

◆ massReco_

std::vector<float> ZIterativeAlgorithmWithFit::massReco_
private

◆ nCrystalCut_

int ZIterativeAlgorithmWithFit::nCrystalCut_
private

Definition at line 113 of file ZIterativeAlgorithmWithFit.h.

Referenced by getWeight(), iterate(), and ZIterativeAlgorithmWithFit().

◆ numberOfIterations_

unsigned int ZIterativeAlgorithmWithFit::numberOfIterations_
private

◆ optimizedChiSquare_

std::vector<float> ZIterativeAlgorithmWithFit::optimizedChiSquare_
private

◆ optimizedCoefficients_

std::vector<float> ZIterativeAlgorithmWithFit::optimizedCoefficients_
private

◆ optimizedCoefficientsError_

std::vector<float> ZIterativeAlgorithmWithFit::optimizedCoefficientsError_
private

◆ optimizedIterations_

std::vector<int> ZIterativeAlgorithmWithFit::optimizedIterations_
private

◆ StatWeights_

std::vector<float> ZIterativeAlgorithmWithFit::StatWeights_
private

Definition at line 137 of file ZIterativeAlgorithmWithFit.h.

Referenced by getStatWeights(), and ZIterativeAlgorithmWithFit().

◆ thePlots_

ZIterativeAlgorithmWithFitPlots* ZIterativeAlgorithmWithFit::thePlots_
private

◆ totalEvents_

unsigned int ZIterativeAlgorithmWithFit::totalEvents_
private

◆ UseStatWeights_

bool ZIterativeAlgorithmWithFit::UseStatWeights_
private

Definition at line 134 of file ZIterativeAlgorithmWithFit.h.

Referenced by ZIterativeAlgorithmWithFit().

◆ weight_sum_

std::vector<float> ZIterativeAlgorithmWithFit::weight_sum_
private

◆ WeightFileName_

std::string ZIterativeAlgorithmWithFit::WeightFileName_
private

Definition at line 135 of file ZIterativeAlgorithmWithFit.h.

Referenced by ZIterativeAlgorithmWithFit().

ZIterativeAlgorithmWithFit::totalEvents_
unsigned int totalEvents_
Definition: ZIterativeAlgorithmWithFit.h:116
ZIterativeAlgorithmWithFit::optimizedIterations_
std::vector< int > optimizedIterations_
Definition: ZIterativeAlgorithmWithFit.h:130
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
ZIterativeAlgorithmWithFit::calib_fac_
std::vector< float > calib_fac_
Definition: ZIterativeAlgorithmWithFit.h:126
mps_fire.i
i
Definition: mps_fire.py:428
ZIterativeAlgorithmWithFit::getStatWeights
void getStatWeights(const std::string &file)
Definition: ZIterativeAlgorithmWithFit.cc:154
ZIterativeAlgorithmWithFit::currentEvent_
unsigned int currentEvent_
Definition: ZIterativeAlgorithmWithFit.h:119
modules
Definition: MuonCleanerBySegments.cc:35
ZIterativeAlgorithmWithFit::thePlots_
ZIterativeAlgorithmWithFitPlots * thePlots_
Definition: ZIterativeAlgorithmWithFit.h:111
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
gather_cfg.cout
cout
Definition: gather_cfg.py:144
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ZIterativeAlgorithmWithFit::optimizedChiSquare_
std::vector< float > optimizedChiSquare_
Definition: ZIterativeAlgorithmWithFit.h:129
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
NBINS_LOWETA
#define NBINS_LOWETA
Definition: ZIterativeAlgorithmWithFit.cc:37
ZIterativeAlgorithmWithFit::currentIteration_
unsigned int currentIteration_
Definition: ZIterativeAlgorithmWithFit.h:120
createPayload.suffix
suffix
Definition: createPayload.py:281
ZIterativeAlgorithmWithFit::massMethod
std::string massMethod
Definition: ZIterativeAlgorithmWithFit.h:132
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ZIterativeAlgorithmWithFit::numberOfIterations_
unsigned int numberOfIterations_
Definition: ZIterativeAlgorithmWithFit.h:117
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
MuonErrorMatrixAdjuster_cfi.rescale
rescale
Definition: MuonErrorMatrixAdjuster_cfi.py:8
MIN_RESCALE
#define MIN_RESCALE
Definition: ZIterativeAlgorithmWithFit.cc:35
ZIterativeAlgorithmWithFit::massReco_
std::vector< float > massReco_
Definition: ZIterativeAlgorithmWithFit.h:128
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
EcalRingCalibrationTools::N_RING_TOTAL
static constexpr short N_RING_TOTAL
Definition: EcalRingCalibrationTools.h:37
geometryDiff.file
file
Definition: geometryDiff.py:13
ZIterativeAlgorithmWithFit::UseStatWeights_
bool UseStatWeights_
Definition: ZIterativeAlgorithmWithFit.h:134
ZIterativeAlgorithmWithFit::nCrystalCut_
int nCrystalCut_
Definition: ZIterativeAlgorithmWithFit.h:113
EcalIndexingTools::getInstance
static EcalIndexingTools * getInstance()
Definition: EcalIndexingTools.h:23
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
ZIterativeAlgorithmWithFit::optimizedCoefficients_
std::vector< float > optimizedCoefficients_
Definition: ZIterativeAlgorithmWithFit.h:124
createfilelist.int
int
Definition: createfilelist.py:10
ZIterativeAlgorithmWithFit::getWeight
void getWeight(unsigned int evid, std::pair< calib::CalibElectron *, calib::CalibElectron * >, float)
Definition: ZIterativeAlgorithmWithFit.cc:297
p1
double p1[4]
Definition: TauolaWrapper.h:89
ZIterativeAlgorithmWithFit::channels_
unsigned int channels_
Definition: ZIterativeAlgorithmWithFit.h:115
ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weightedRescaleFactor
TH1 * weightedRescaleFactor[50][250]
Definition: ZIterativeAlgorithmWithFit.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ZIterativeAlgorithmWithFit::gausfit
static void gausfit(TH1F *histoou, double *par, double *errpar, float nsigmalow, float nsigmaup, double *mychi2, int *iterations)
Definition: ZIterativeAlgorithmWithFit.cc:355
ZIterativeAlgorithmWithFit::cosTheta12
static float cosTheta12(float Eta1, float Phi1, float Eta2, float Phi2)
Definition: ZIterativeAlgorithmWithFit.h:79
ZIterativeAlgorithmWithFit::WeightFileName_
std::string WeightFileName_
Definition: ZIterativeAlgorithmWithFit.h:135
ZIterativeAlgorithmWithFit::StatWeights_
std::vector< float > StatWeights_
Definition: ZIterativeAlgorithmWithFit.h:137
NBINS_HIGHETA
#define NBINS_HIGHETA
Definition: ZIterativeAlgorithmWithFit.cc:38
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::weight
TH1 * weight[50][250]
Definition: ZIterativeAlgorithmWithFit.h:33
ZIterativeAlgorithmWithFit::invMassCalc
static float invMassCalc(float Energy1, float Eta1, float Phi1, float Energy2, float Eta2, float Phi2)
Definition: ZIterativeAlgorithmWithFit.h:75
calib::CalibElectron::getRecoElectron
const reco::GsfElectron * getRecoElectron()
Definition: CalibElectron.h:24
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
ZIterativeAlgorithmWithFit::bookHistograms
void bookHistograms()
Definition: ZIterativeAlgorithmWithFit.cc:111
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
ZIterativeAlgorithmWithFit::electrons_
std::vector< std::pair< calib::CalibElectron *, calib::CalibElectron * > > electrons_
Definition: ZIterativeAlgorithmWithFit.h:122
ZIterativeAlgorithmWithFit::calibType_
TString calibType_
Definition: ZIterativeAlgorithmWithFit.h:140
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:52
EcalRingCalibrationTools::N_MODULES_BARREL
static constexpr short N_MODULES_BARREL
Definition: EcalRingCalibrationTools.h:41
ZIterativeAlgorithmWithFit::ZIterativeAlgorithmWithFitPlots::unweightedRescaleFactor
TH1 * unweightedRescaleFactor[50][250]
Definition: ZIterativeAlgorithmWithFit.h:32
HLTTauDQMOffline_cfi.Electrons
Electrons
Definition: HLTTauDQMOffline_cfi.py:25
ZIterativeAlgorithmWithFit::optimizedCoefficientsError_
std::vector< float > optimizedCoefficientsError_
Definition: ZIterativeAlgorithmWithFit.h:125
EcalIndexingTools::getNumberOfChannels
int getNumberOfChannels()
Definition: EcalIndexingTools.h:32
MAX_RESCALE
#define MAX_RESCALE
Definition: ZIterativeAlgorithmWithFit.cc:36
ZIterativeAlgorithmWithFit::weight_sum_
std::vector< float > weight_sum_
Definition: ZIterativeAlgorithmWithFit.h:127