CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
pftools::CalibCompare Class Reference

#include <CalibCompare.h>

Public Member Functions

 CalibCompare (IO *options)
 
void calibrateCalibratables (TChain &sourceTree, const std::string &exercisefile)
 
void evaluateCalibrations (TTree &tree, pftools::Calibratable *calibrated, const std::vector< pftools::Calibratable > &calibVec)
 
void setTarget (CalibrationTarget t)
 
virtual ~CalibCompare ()
 

Private Member Functions

 CalibCompare (const CalibCompare &)
 
void operator= (const CalibCompare &)
 

Private Attributes

PFClusterCalibration clusterCalibration_
 
unsigned debug_
 
Erl_mlp erlCalibration_
 
double mlpOffset_
 
double mlpSlope_
 
IOoptions_
 
CalibrationTarget target_
 
bool withOffset_
 

Detailed Description

Definition at line 23 of file CalibCompare.h.

Constructor & Destructor Documentation

CalibCompare::CalibCompare ( IO options)

Definition at line 28 of file CalibCompare.cc.

References clusterCalibration_, gather_cfg::cout, debug_, reco::e1, erlCalibration_, corrVsCorr::g0, diffTwoXMLs::g1, pftools::PFClusterCalibration::getKnownSectorNames(), pftools::IO::GetOpt(), i, mlpOffset_, mlpSlope_, cscdqm::h::names, options_, pftools::PFClusterCalibration::setAllowNegativeEnergy(), pftools::PFClusterCalibration::setBarrelBoundary(), pftools::PFClusterCalibration::setCorrections(), pftools::PFClusterCalibration::setDoCorrection(), pftools::PFClusterCalibration::setDoEtaCorrection(), pftools::PFClusterCalibration::setEcalHcalEnergyCuts(), pftools::PFClusterCalibration::setEtaCorrectionParameters(), pftools::PFClusterCalibration::setEvolutionParameters(), pftools::PFClusterCalibration::setMaxEToCorrect(), pftools::Erl_mlp::setOffsetAndSlope(), AlCaHLTBitMon_QueryRunRegistry::string, and withOffset_.

28  :
29  withOffset_(false), target_(CLUSTER), options_(options), debug_(0),
30  mlpOffset_(0.0), mlpSlope_(1.0) {
31 
32  options_->GetOpt("exercises", "withOffset", withOffset_);
33  options_->GetOpt("exercises", "debug", debug_);
34 
35  /* Initialise PFClusterCalibration appropriately. */
36  double g0, g1, e0, e1;
37  options_->GetOpt("correction", "globalP0", g0);
38  options_->GetOpt("correction", "globalP1", g1);
39  options_->GetOpt("correction", "lowEP0", e0);
40  options_->GetOpt("correction", "lowEP1", e1);
41  clusterCalibration_.setCorrections(e0, e1, g0, g1);
42 
43  double ecalECut, hcalECut;
44  options_->GetOpt("evolution", "ecalECut", ecalECut);
45  options_->GetOpt("evolution", "hcalECut", hcalECut);
46  clusterCalibration_.setEcalHcalEnergyCuts(ecalECut, hcalECut);
47 
48  int allowNegative(0);
49  options_->GetOpt("correction", "allowNegativeEnergy", allowNegative);
51 
52  int doCorrection(1);
53  options_->GetOpt("correction", "doCorrection", doCorrection);
55 
56  int doEtaCorrection(0);
57  options_->GetOpt("correction", "doEtaCorrection", doEtaCorrection);
58  clusterCalibration_.setDoEtaCorrection(doEtaCorrection);
59 
60  double barrelEta;
61  options_->GetOpt("evolution", "barrelEndcapEtaDiv", barrelEta);
63 
64  double maxEToCorrect(100.0);
65  options_->GetOpt("correction", "maxEToCorrect", maxEToCorrect);
67 
68  std::vector<std::string>* names = clusterCalibration_.getKnownSectorNames();
69  for (std::vector<std::string>::iterator i = names->begin(); i
70  != names->end(); ++i) {
71  std::string sector = *i;
72  std::vector<double> params;
73  options_->GetOpt("evolution", sector.c_str(), params);
75  }
76 
77  std::vector<double> etaParams;
78  options_->GetOpt("evolution", "etaCorrection", etaParams);
80 
81  std::cout << clusterCalibration_ << "\n";
82 
83  options_->GetOpt("correction", "mlpOffset", mlpOffset_);
84  options_->GetOpt("correction", "mlpSlope", mlpSlope_);
85 
87 
88  if (debug_ > 0)
89  std::cout << __PRETTY_FUNCTION__ << ": finished.\n";
90 
91 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > * getKnownSectorNames()
static const HistoName names[]
void setBarrelBoundary(const double &eta)
void setOffsetAndSlope(const double offset, const double slope)
Definition: Erl_mlp.h:15
bool GetOpt(const char *tag, const char *key, std::vector< T > &values) const
reads a vector of T
Definition: IO.h:108
void setEcalHcalEnergyCuts(const double &ecalCut, const double &hcalCut)
void setEvolutionParameters(const std::string &sector, const std::vector< double > &params)
CalibrationTarget target_
Definition: CalibCompare.h:48
Float e1
Definition: deltaR.h:22
void setDoCorrection(const int &doCorrection)
void setCorrections(const double &lowEP0, const double &lowEP1, const double &globalP0, const double &globalP1)
void setAllowNegativeEnergy(const bool &allowIt)
tuple cout
Definition: gather_cfg.py:121
void setEtaCorrectionParameters(const std::vector< double > &params)
PFClusterCalibration clusterCalibration_
Definition: CalibCompare.h:54
void setDoEtaCorrection(const int doEtaCorrection)
tuple g0
Definition: corrVsCorr.py:108
CalibCompare::~CalibCompare ( )
virtual

Definition at line 25 of file CalibCompare.cc.

25  {
26 }
pftools::CalibCompare::CalibCompare ( const CalibCompare )
private

Member Function Documentation

void CalibCompare::calibrateCalibratables ( TChain &  sourceTree,
const std::string &  exercisefile 
)

Definition at line 93 of file CalibCompare.cc.

References gather_cfg::cout, debug_, evaluateCalibrations(), pftools::TreeUtility::getCalibratablesFromRootFile(), and diffTreeTool::tree.

94  {
95 
96  if (debug_ > 0) {
97  std::cout << "Welcome to " << __PRETTY_FUNCTION__ << "\n";
98  std::cout << "Opening TTree...\n";
99  }
100 
101  TreeUtility tu;
102  std::vector<Calibratable> calibVec;
103 
104  tu.getCalibratablesFromRootFile(sourceTree, calibVec);
105 
106  std::cout << "Moving on... " << std::endl;
107  TFile* exercises = new TFile(exercisefile.c_str(), "recreate");
108  TTree tree("CalibratedParticles", "");
109  Calibratable* calibrated = new Calibratable();
110  tree.Branch("Calibratable", "pftools::Calibratable", &calibrated, 32000, 2);
111 
112  evaluateCalibrations(tree, calibrated, calibVec);
113 
114  //save results
115  std::cout << "Writing output tree...\n";
116  tree.Write();
117  //gaussianFits(*exercises, calibVec);
118  exercises->Write();
119  exercises->Close();
120  std::cout << "Done." << std::endl;
121  delete calibrated;
122 
123 }
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
void evaluateCalibrations(TTree &tree, pftools::Calibratable *calibrated, const std::vector< pftools::Calibratable > &calibVec)
unsigned getCalibratablesFromRootFile(TChain &tree, std::vector< Calibratable > &toBeFilled)
Definition: TreeUtility.cc:21
Utility class to create particles and detector elements from a Root file.
Definition: TreeUtility.h:27
tuple cout
Definition: gather_cfg.py:121
void CalibCompare::evaluateCalibrations ( TTree &  tree,
pftools::Calibratable calibrated,
const std::vector< pftools::Calibratable > &  calibVec 
)

Definition at line 125 of file CalibCompare.cc.

References pftools::CalibrationResultWrapper::b_, pftools::BAYESIAN, pftools::CalibrationResultWrapper::c_, calib, pftools::Calibratable::calibrations_, pftools::Calibratable::cluster_energyEcal_, pftools::Calibratable::cluster_energyHcal_, pftools::Calibratable::cluster_meanEcal_, pftools::Calibratable::cluster_meanHcal_, pftools::Calibratable::cluster_numEcal_, pftools::Calibratable::cluster_numHcal_, clusterCalibration_, pftools::CalibrationResultWrapper::compute(), prof2calltree::count, pftools::CalibrationResultWrapper::ecalEnergy_, pftools::Erl_mlp::ecalFraction(), erlCalibration_, pftools::CalibratableElement::eta_, pftools::Erl_mlp::evaluate(), pftools::PFClusterCalibration::getCalibratedEcalEnergy(), pftools::PFClusterCalibration::getCalibratedEnergy(), pftools::PFClusterCalibration::getCalibratedHcalEnergy(), pftools::CalibrationResultWrapper::hcalEnergy_, pftools::LINEAR, pftools::CalibrationResultWrapper::particleEnergy_, pftools::CalibratableElement::phi_, pftools::CalibrationResultWrapper::provenance_, pftools::Calibratable::recompute(), pftools::Calibratable::reset(), pftools::Calibratable::sim_energyEvent_, pftools::Calibratable::sim_etaEcal_, pftools::Calibratable::sim_phiEcal_, target_, pftools::CalibrationResultWrapper::target_, pftools::CalibrationResultWrapper::targetFuncContrib_, pftools::CalibrationResultWrapper::truthEnergy_, and pftools::UNCALIBRATED.

Referenced by calibrateCalibratables().

126  {
127 
128  unsigned count(0);
129  for (std::vector<Calibratable>::const_iterator zit = calibVec.begin(); zit
130  != calibVec.end(); ++zit) {
131 
132  const Calibratable& calib = *zit;
133 
134  calibrated->reset();
135 
137  crwPre.ecalEnergy_ = calib.cluster_energyEcal_;
138  crwPre.hcalEnergy_ = calib.cluster_energyHcal_;
139  crwPre.particleEnergy_ = calib.cluster_energyEcal_
140  + calib.cluster_energyHcal_;
141  crwPre.truthEnergy_ = calib.sim_energyEvent_;
142  crwPre.provenance_ = UNCALIBRATED;
143  crwPre.targetFuncContrib_ = 0;
144  crwPre.target_ = target_;
145  crwPre.compute();
146  calibrated->calibrations_.push_back(crwPre);
147 
149 
151  crwPre.hcalEnergy_, calib.cluster_numEcal_,
152  calib.cluster_numHcal_, fabs(calib.cluster_meanEcal_.eta_)
153  / 2.0, crwPre.ecalEnergy_ / (crwPre.particleEnergy_),
154  (calib.cluster_meanEcal_.phi_ + 3.14) / 6.3);
155  crwErl.ecalEnergy_ = crwErl.particleEnergy_
157  crwPre.hcalEnergy_, calib.cluster_numEcal_,
158  calib.cluster_numHcal_, fabs(
159  calib.cluster_meanEcal_.eta_) / 2.0,
160  crwPre.ecalEnergy_ / (crwPre.particleEnergy_),
161  (calib.cluster_meanEcal_.phi_ + 3.14) / 6.3);
162 
163  crwErl.hcalEnergy_ = crwErl.particleEnergy_ - crwErl.ecalEnergy_;
164  crwErl.b_ = crwErl.ecalEnergy_ / crwPre.ecalEnergy_;
165  crwErl.c_ = crwErl.hcalEnergy_ / crwPre.hcalEnergy_;
166 
167  crwErl.truthEnergy_ = calib.sim_energyEvent_;
168  crwErl.provenance_ = BAYESIAN;
169  crwErl.target_ = target_;
170  crwErl.compute();
171  calibrated->calibrations_.push_back(crwErl);
172 
173  CalibrationResultWrapper crwCorr;
174 
176  crwPre.ecalEnergy_, crwPre.hcalEnergy_,
179  crwPre.ecalEnergy_, crwPre.hcalEnergy_,
182  crwPre.ecalEnergy_, crwPre.hcalEnergy_, calib.sim_etaEcal_,
183  calib.sim_phiEcal_);
184 
185  crwCorr.truthEnergy_ = calib.sim_energyEvent_;
186  crwCorr.provenance_ = LINEAR;
187  crwCorr.targetFuncContrib_ = 0;;
188  crwCorr.target_ = target_;
189  crwCorr.compute();
190  calibrated->calibrations_.push_back(crwCorr);
191 
192  calibrated->recompute();
193 
194  tree.Fill();
195 
196  ++count;
197  }
198 
199 }
Wraps essential single particle calibration data ready for export to a Root file. ...
Definition: Calibratable.h:122
CalibratableElement cluster_meanEcal_
Definition: Calibratable.h:186
std::vector< CalibrationResultWrapper > calibrations_
Definition: Calibratable.h:206
double ecalFraction(const double t1=0.0, const double t2=0.0, const double t3=0.0, const double t4=0.0, const double t5=0.0, const double t6=0.0, const double t7=0.0)
Definition: Erl_mlp.h:34
double getCalibratedEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
double getCalibratedHcalEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
double evaluate(const double t1=0.0, const double t2=0.0, const double t3=0.0, const double t4=0.0, const double t5=0.0, const double t6=0.0, const double t7=0.0)
Definition: Erl_mlp.h:20
double getCalibratedEcalEnergy(const double &ecalE, const double &hcalE, const double &eta, const double &phi) const
virtual void reset()
CalibrationTarget target_
Definition: CalibCompare.h:48
A small class designed to hold the result of a calibration of a SingleParticleWrapper.
virtual void recompute()
Definition: Calibratable.cc:45
CalibratableElement cluster_meanHcal_
Definition: Calibratable.h:186
PFClusterCalibration clusterCalibration_
Definition: CalibCompare.h:54
void pftools::CalibCompare::operator= ( const CalibCompare )
private
void pftools::CalibCompare::setTarget ( CalibrationTarget  t)
inline

Definition at line 34 of file CalibCompare.h.

References edmStreamStallGrapher::t, and target_.

34  {
35  target_ = t;
36  }
CalibrationTarget target_
Definition: CalibCompare.h:48

Member Data Documentation

PFClusterCalibration pftools::CalibCompare::clusterCalibration_
private

Definition at line 54 of file CalibCompare.h.

Referenced by CalibCompare(), and evaluateCalibrations().

unsigned pftools::CalibCompare::debug_
private

Definition at line 50 of file CalibCompare.h.

Referenced by CalibCompare(), and calibrateCalibratables().

Erl_mlp pftools::CalibCompare::erlCalibration_
private

Definition at line 55 of file CalibCompare.h.

Referenced by CalibCompare(), and evaluateCalibrations().

double pftools::CalibCompare::mlpOffset_
private

Definition at line 52 of file CalibCompare.h.

Referenced by CalibCompare().

double pftools::CalibCompare::mlpSlope_
private

Definition at line 53 of file CalibCompare.h.

Referenced by CalibCompare().

IO* pftools::CalibCompare::options_
private

Definition at line 49 of file CalibCompare.h.

Referenced by CalibCompare(), and valtools.webpage::parseArgs().

CalibrationTarget pftools::CalibCompare::target_
private

Definition at line 48 of file CalibCompare.h.

Referenced by evaluateCalibrations(), and setTarget().

bool pftools::CalibCompare::withOffset_
private

Definition at line 47 of file CalibCompare.h.

Referenced by CalibCompare().