#include <PFClusterCalibration.h>
Public Member Functions | |
void | calibrate (Calibratable &c) |
void | calibrateTree (TTree *tree) |
double | getCalibratedEcalEnergy (const double &ecalE, const double &hcalE, const double &eta, const double &phi) const |
double | getCalibratedEnergy (const double &ecalE, const double &hcalE, const double &eta, const double &phi) const |
void | getCalibratedEnergyEmbedAInHcal (double &ecalE, double &hcalE, const double &eta, const double &phi) const |
double | getCalibratedHcalEnergy (const double &ecalE, const double &hcalE, const double &eta, const double &phi) const |
void | getCalibrationResultWrapper (const Calibratable &c, CalibrationResultWrapper &crw) |
std::vector< std::string > * | getKnownSectorNames () |
PFClusterCalibration () | |
void | setAllowNegativeEnergy (const bool &allowIt) |
void | setBarrelBoundary (const double &eta) |
void | setCorrections (const double &lowEP0, const double &lowEP1, const double &globalP0, const double &globalP1) |
void | setDoCorrection (const int &doCorrection) |
void | setDoEtaCorrection (const int doEtaCorrection) |
void | setEcalHcalEnergyCuts (const double &ecalCut, const double &hcalCut) |
void | setEtaCorrectionParameters (std::vector< double > params) |
void | setEvolutionParameters (const std::string §or, std::vector< double > params) |
void | setMaxEToCorrect (double maxE) |
virtual | ~PFClusterCalibration () |
Private Member Functions | |
void | init () |
Private Attributes | |
int | allowNegativeEnergy_ |
double | barrelEndcapEtaDiv_ |
TF1 * | correction_ |
double | correctionLowLimit_ |
int | doCorrection_ |
int | doEtaCorrection_ |
double | ecalOnlyDiv_ |
TF1 * | etaCorrection_ |
double | globalP0_ |
double | globalP1_ |
double | hcalOnlyDiv_ |
double | lowEP0_ |
double | lowEP1_ |
double | maxEToCorrect_ |
std::vector< std::string > | names_ |
std::map< std::string, TF1 > | namesAndFunctions_ |
Friends | |
std::ostream & | pftools::operator<< (std::ostream &s, const PFClusterCalibration &cc) |
Definition at line 40 of file PFClusterCalibration.h.
PFClusterCalibration::PFClusterCalibration | ( | ) |
Definition at line 104 of file PFClusterCalibration.cc.
References init().
: barrelEndcapEtaDiv_(1.0), ecalOnlyDiv_(0.3), hcalOnlyDiv_(0.5), doCorrection_(1), allowNegativeEnergy_(0), doEtaCorrection_(1), maxEToCorrect_(-1.0), correctionLowLimit_(0.), globalP0_(0.0), globalP1_(1.0), lowEP0_(0.0), lowEP1_(1.0) { // std::cout << __PRETTY_FUNCTION__ << std::endl; init(); // std::cout // << "WARNING! PFClusterCalibration evolution functions have not yet been initialised - ensure this is done.\n"; // std::cout << "PFClusterCalibration construction complete."<< std::endl; }
PFClusterCalibration::~PFClusterCalibration | ( | ) | [virtual] |
Definition at line 117 of file PFClusterCalibration.cc.
References correction_, and etaCorrection_.
{ delete correction_; delete etaCorrection_; }
void PFClusterCalibration::calibrate | ( | Calibratable & | c | ) |
Definition at line 263 of file PFClusterCalibration.cc.
References pftools::Calibratable::calibrations_, and getCalibrationResultWrapper().
Referenced by calibrateTree().
{ CalibrationResultWrapper crw; getCalibrationResultWrapper(c, crw); c.calibrations_.push_back(crw); }
void PFClusterCalibration::calibrateTree | ( | TTree * | tree | ) |
Definition at line 292 of file PFClusterCalibration.cc.
References calibrate(), gather_cfg::cout, and python::tagInventory::entries.
{ std::cout << __PRETTY_FUNCTION__ << ": WARNING! This isn't working properly yet!\n"; TBranch* calibBr = input->GetBranch("Calibratable"); Calibratable* calib_ptr = new Calibratable(); calibBr->SetAddress(&calib_ptr); // TBranch* newBranch = input->Branch("NewCalibratable", // "pftools::Calibratable", &calib_ptr, 32000, 2); std::cout << "Looping over tree's "<< input->GetEntries() << " entries...\n"; for (unsigned entries(0); entries < 20000; entries++) { if (entries % 10000== 0) std::cout << "\tProcessing entry "<< entries << "\n"; input->GetEntry(entries); calibrate(*calib_ptr); input->Fill(); } //input.Write("",TObject::kOverwrite); }
double PFClusterCalibration::getCalibratedEcalEnergy | ( | const double & | ecalE, |
const double & | hcalE, | ||
const double & | eta, | ||
const double & | phi | ||
) | const |
Definition at line 178 of file PFClusterCalibration.cc.
References barrelEndcapEtaDiv_, and namesAndFunctions_.
Referenced by pftools::CalibCompare::evaluateCalibrations(), pftools::Exercises3::evaluateCalibrator(), getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), and getCalibrationResultWrapper().
{ const TF1* theFunction(0); if (fabs(eta) < barrelEndcapEtaDiv_) { //barrel theFunction = &(namesAndFunctions_.find("ecalHcalEcalBarrel")->second); } else { //endcap theFunction = &(namesAndFunctions_.find("ecalHcalEcalEndcap")->second); } assert(theFunction != 0); double totalE(ecalE + hcalE); double bCoeff = theFunction->Eval(totalE); return ecalE * bCoeff; }
double PFClusterCalibration::getCalibratedEnergy | ( | const double & | ecalE, |
const double & | hcalE, | ||
const double & | eta, | ||
const double & | phi | ||
) | const |
Definition at line 214 of file PFClusterCalibration.cc.
References allowNegativeEnergy_, submit::answer, correction_, doCorrection_, doEtaCorrection_, etaCorrection_, getCalibratedEcalEnergy(), getCalibratedHcalEnergy(), and maxEToCorrect_.
Referenced by pftools::CalibCompare::evaluateCalibrations(), pftools::Exercises3::evaluateCalibrator(), and getCalibrationResultWrapper().
{ double totalE(ecalE + hcalE); double answer(totalE); answer = getCalibratedEcalEnergy(ecalE, hcalE, eta, phi) + getCalibratedHcalEnergy(ecalE, hcalE, eta, phi); if (doEtaCorrection_) answer = answer/etaCorrection_->Eval(eta); if (maxEToCorrect_> 0 && answer < maxEToCorrect_) return correction_->Eval(answer); if (doCorrection_) { if (maxEToCorrect_> 0 && answer < maxEToCorrect_) answer = correction_->Eval(answer); else if (maxEToCorrect_ < 0) { answer = correction_->Eval(answer); } } if (!allowNegativeEnergy_ && answer < 0) return 0; return answer; }
void PFClusterCalibration::getCalibratedEnergyEmbedAInHcal | ( | double & | ecalE, |
double & | hcalE, | ||
const double & | eta, | ||
const double & | phi | ||
) | const |
Definition at line 239 of file PFClusterCalibration.cc.
References a, allowNegativeEnergy_, correction_, doCorrection_, doEtaCorrection_, etaCorrection_, getCalibratedEcalEnergy(), and getCalibratedHcalEnergy().
{ double ecalEOld(ecalE); double hcalEOld(hcalE); ecalE = getCalibratedEcalEnergy(ecalEOld, hcalEOld, eta, phi); hcalE = getCalibratedHcalEnergy(ecalEOld, hcalEOld, eta, phi); double preCorrection(ecalE + hcalE); if (doEtaCorrection_) preCorrection = preCorrection/etaCorrection_->Eval(eta); if (doCorrection_) { double corrE = correction_->Eval(preCorrection); //a term = difference double a = corrE - preCorrection; hcalE += a; } if (hcalE < 0 && !allowNegativeEnergy_) hcalE = 0; }
double PFClusterCalibration::getCalibratedHcalEnergy | ( | const double & | ecalE, |
const double & | hcalE, | ||
const double & | eta, | ||
const double & | phi | ||
) | const |
Definition at line 196 of file PFClusterCalibration.cc.
References barrelEndcapEtaDiv_, and namesAndFunctions_.
Referenced by pftools::CalibCompare::evaluateCalibrations(), pftools::Exercises3::evaluateCalibrator(), getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), and getCalibrationResultWrapper().
{ const TF1* theFunction(0); if (fabs(eta) < barrelEndcapEtaDiv_) { //barrel theFunction = &(namesAndFunctions_.find("ecalHcalHcalBarrel")->second); } else { //endcap theFunction = &(namesAndFunctions_.find("ecalHcalHcalEndcap")->second); } double totalE(ecalE + hcalE); assert(theFunction != 0); double cCoeff = theFunction->Eval(totalE); return hcalE * cCoeff; }
void PFClusterCalibration::getCalibrationResultWrapper | ( | const Calibratable & | c, |
CalibrationResultWrapper & | crw | ||
) |
Definition at line 270 of file PFClusterCalibration.cc.
References pftools::CalibrationResultWrapper::b_, pftools::CalibrationResultWrapper::c_, pftools::Calibratable::cluster_energyEcal_, pftools::Calibratable::cluster_energyHcal_, pftools::Calibratable::cluster_meanEcal_, pftools::CalibrationResultWrapper::ecalEnergy_, pftools::CalibratableElement::eta_, getCalibratedEcalEnergy(), getCalibratedEnergy(), getCalibratedHcalEnergy(), pftools::CalibrationResultWrapper::hcalEnergy_, pftools::LINEARCORR, pftools::CalibrationResultWrapper::particleEnergy_, pftools::CalibratableElement::phi_, pftools::CalibrationResultWrapper::provenance_, pftools::Calibratable::sim_energyEvent_, and pftools::CalibrationResultWrapper::truthEnergy_.
Referenced by calibrate().
{ crw.ecalEnergy_ = getCalibratedEcalEnergy(c.cluster_energyEcal_, c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), fabs(c.cluster_meanEcal_.phi_)); crw.hcalEnergy_ = getCalibratedHcalEnergy(c.cluster_energyEcal_, c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), fabs(c.cluster_meanEcal_.phi_)); crw.particleEnergy_ = getCalibratedEnergy(c.cluster_energyEcal_, c.cluster_energyHcal_, fabs(c.cluster_meanEcal_.eta_), fabs(c.cluster_meanEcal_.phi_)); crw.provenance_ = LINEARCORR; crw.b_ = crw.ecalEnergy_ / c.cluster_energyEcal_; crw.c_ = crw.hcalEnergy_ / c.cluster_energyHcal_; crw.truthEnergy_ = c.sim_energyEvent_; }
std::vector<std::string>* pftools::PFClusterCalibration::getKnownSectorNames | ( | ) | [inline] |
Definition at line 127 of file PFClusterCalibration.h.
References names_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ return &names_; }
void PFClusterCalibration::init | ( | void | ) | [private] |
Definition at line 13 of file PFClusterCalibration.cc.
References correction_, correctionLowLimit_, etaCorrection_, globalP0_, globalP1_, lowEP0_, lowEP1_, mergeVDriftHistosByStation::name, names_, namesAndFunctions_, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by PFClusterCalibration().
{ //std::cout << __PRETTY_FUNCTION__ << std::endl; correction_ = new TF1("correction", "((x-[0])/[1])*(x>[4])+((x-[2])/[3])*(x<[4])"); etaCorrection_ = new TF1( "etaCorrection", "(1-[0]*x-[1]*x*x)*(x<[2])+([3]+[4]*x)*(x>[2]&&x<[5])+(1-[6]*x-[7]*x*x)*(x>[5])"); correction_->FixParameter(0, globalP0_); correction_->FixParameter(1, globalP1_); correction_->FixParameter(2, lowEP0_); correction_->FixParameter(3, lowEP1_); correction_->FixParameter(4, correctionLowLimit_); /* These are the types of calibration I know about: * ecalOnly_elementName * etc. Sorry, it's not very nice, but well, neither is ROOT... */ std::string eheb("ecalHcalEcalBarrel"); names_.push_back(eheb); std::string ehee("ecalHcalEcalEndcap"); names_.push_back(ehee); std::string ehhb("ecalHcalHcalBarrel"); names_.push_back(ehhb); std::string ehhe("ecalHcalHcalEndcap"); names_.push_back(ehhe); /* char * funcString("([0]*[5]*x*([1]-[5]*x)/pow(([2]+[5]*x),3)+[3]*pow([5]*x, 0.1))*([5]*x<[8] && [5]*x>[7])+[4]*([5]*x>[8])+([6]*[5]*x)*([5]*x<[7])"); */ const char* funcString("([0]*[5]*x)*([5]*x<=[1])+([2]+[3]*exp([4]*[5]*x))*([5]*x>[1])"); //Create functions for each sector for (std::vector<std::string>::const_iterator cit = names_.begin(); cit != names_.end(); ++cit) { std::string name = *cit; TF1 func(name.c_str(), funcString); //some sensible defaults func.FixParameter(0, 1); func.FixParameter(1, 0); func.FixParameter(2, 1); func.FixParameter(3, 0); func.FixParameter(4, 0); func.FixParameter(5, 1); func.SetMinimum(0); //Store in map namesAndFunctions_[name] = func; } }
void pftools::PFClusterCalibration::setAllowNegativeEnergy | ( | const bool & | allowIt | ) | [inline] |
Definition at line 87 of file PFClusterCalibration.h.
References allowNegativeEnergy_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ allowNegativeEnergy_ = allowIt; }
void pftools::PFClusterCalibration::setBarrelBoundary | ( | const double & | eta | ) | [inline] |
Definition at line 109 of file PFClusterCalibration.h.
References barrelEndcapEtaDiv_, and eta().
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ barrelEndcapEtaDiv_ = eta; }
void PFClusterCalibration::setCorrections | ( | const double & | lowEP0, |
const double & | lowEP1, | ||
const double & | globalP0, | ||
const double & | globalP1 | ||
) |
Definition at line 157 of file PFClusterCalibration.cc.
References correction_, correctionLowLimit_, globalP0_, globalP1_, lowEP0_, and lowEP1_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ //'a' term is -globalP0/globalP1 globalP0_ = globalP0; globalP1_ = globalP1; //Specifically for low energies... lowEP0_ = lowEP0; lowEP1_ = lowEP1; //Intersection of two straight lines => matching at... correctionLowLimit_ = (lowEP0_ - globalP0_)/(globalP1_ - lowEP1_); correction_->FixParameter(0, globalP0_); correction_->FixParameter(1, globalP1_); correction_->FixParameter(2, lowEP0_); correction_->FixParameter(3, lowEP1_); correction_->FixParameter(4, correctionLowLimit_); // std::cout << __PRETTY_FUNCTION__ << ": setting correctionLowLimit_ = " // << correctionLowLimit_ << "\n"; }
void pftools::PFClusterCalibration::setDoCorrection | ( | const int & | doCorrection | ) | [inline] |
Definition at line 93 of file PFClusterCalibration.h.
References doCorrection_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ doCorrection_ = doCorrection; }
void pftools::PFClusterCalibration::setDoEtaCorrection | ( | const int | doEtaCorrection | ) | [inline] |
Definition at line 97 of file PFClusterCalibration.h.
References doEtaCorrection_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ doEtaCorrection_ = doEtaCorrection; }
void pftools::PFClusterCalibration::setEcalHcalEnergyCuts | ( | const double & | ecalCut, |
const double & | hcalCut | ||
) | [inline] |
Definition at line 102 of file PFClusterCalibration.h.
References ecalOnlyDiv_, and hcalOnlyDiv_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ //std::cout << __PRETTY_FUNCTION__ << "WARNING! These will be ignored.\n"; ecalOnlyDiv_ = ecalCut; hcalOnlyDiv_ = hcalCut; }
void PFClusterCalibration::setEtaCorrectionParameters | ( | std::vector< double > | params | ) |
Definition at line 122 of file PFClusterCalibration.cc.
References prof2calltree::count, gather_cfg::cout, and etaCorrection_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ if (params.size() != 6) { std::cout << __PRETTY_FUNCTION__ << ": params is of the wrong length." << std::endl; return; } // std::cout << "Fixing eta correction:\n\t"; unsigned count(0); for (std::vector<double>::const_iterator dit = params.begin(); dit != params.end(); ++dit) { //std::cout << *dit << "\t"; etaCorrection_->FixParameter(count, *dit); ++count; } // std::cout << std::endl; /*for(double eta(0); eta < 2.5; eta += 0.05) { std::cout << "Eta = " << eta << ",\tcorr = " << etaCorrection_->Eval(eta) << "\n"; }*/ }
void PFClusterCalibration::setEvolutionParameters | ( | const std::string & | sector, |
std::vector< double > | params | ||
) |
Definition at line 142 of file PFClusterCalibration.cc.
References prof2calltree::count, and namesAndFunctions_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ TF1* func = &(namesAndFunctions_.find(sector)->second); unsigned count(0); //std::cout << "Fixing for "<< sector << "\n"; for (std::vector<double>::const_iterator dit = params.begin(); dit != params.end(); ++dit) { func->FixParameter(count, *dit); //std::cout << "\t"<< count << ": "<< *dit; ++count; } // std::cout << std::endl; func->SetMinimum(0); }
void pftools::PFClusterCalibration::setMaxEToCorrect | ( | double | maxE | ) | [inline] |
Definition at line 113 of file PFClusterCalibration.h.
References maxEToCorrect_.
Referenced by pftools::CalibCompare::CalibCompare(), and pftools::Exercises3::Exercises3().
{ maxEToCorrect_ = maxE; }
std::ostream& pftools::operator<< | ( | std::ostream & | s, |
const PFClusterCalibration & | cc | ||
) | [friend] |
int pftools::PFClusterCalibration::allowNegativeEnergy_ [private] |
Definition at line 147 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), pftools::operator<<(), and setAllowNegativeEnergy().
double pftools::PFClusterCalibration::barrelEndcapEtaDiv_ [private] |
Definition at line 140 of file PFClusterCalibration.h.
Referenced by getCalibratedEcalEnergy(), getCalibratedHcalEnergy(), pftools::operator<<(), and setBarrelBoundary().
TF1* pftools::PFClusterCalibration::correction_ [private] |
Definition at line 158 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), init(), setCorrections(), and ~PFClusterCalibration().
double pftools::PFClusterCalibration::correctionLowLimit_ [private] |
Definition at line 151 of file PFClusterCalibration.h.
Referenced by init(), pftools::operator<<(), and setCorrections().
int pftools::PFClusterCalibration::doCorrection_ [private] |
Definition at line 146 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), pftools::operator<<(), and setDoCorrection().
int pftools::PFClusterCalibration::doEtaCorrection_ [private] |
Definition at line 148 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), pftools::operator<<(), and setDoEtaCorrection().
double pftools::PFClusterCalibration::ecalOnlyDiv_ [private] |
Definition at line 143 of file PFClusterCalibration.h.
Referenced by pftools::operator<<(), and setEcalHcalEnergyCuts().
TF1* pftools::PFClusterCalibration::etaCorrection_ [private] |
Definition at line 160 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), getCalibratedEnergyEmbedAInHcal(), init(), setEtaCorrectionParameters(), and ~PFClusterCalibration().
double pftools::PFClusterCalibration::globalP0_ [private] |
Definition at line 152 of file PFClusterCalibration.h.
Referenced by init(), pftools::operator<<(), and setCorrections().
double pftools::PFClusterCalibration::globalP1_ [private] |
Definition at line 153 of file PFClusterCalibration.h.
Referenced by init(), pftools::operator<<(), and setCorrections().
double pftools::PFClusterCalibration::hcalOnlyDiv_ [private] |
Definition at line 144 of file PFClusterCalibration.h.
Referenced by pftools::operator<<(), and setEcalHcalEnergyCuts().
double pftools::PFClusterCalibration::lowEP0_ [private] |
Definition at line 154 of file PFClusterCalibration.h.
Referenced by init(), pftools::operator<<(), and setCorrections().
double pftools::PFClusterCalibration::lowEP1_ [private] |
Definition at line 155 of file PFClusterCalibration.h.
Referenced by init(), pftools::operator<<(), and setCorrections().
double pftools::PFClusterCalibration::maxEToCorrect_ [private] |
Definition at line 149 of file PFClusterCalibration.h.
Referenced by getCalibratedEnergy(), and setMaxEToCorrect().
std::vector<std::string> pftools::PFClusterCalibration::names_ [private] |
Definition at line 163 of file PFClusterCalibration.h.
Referenced by getKnownSectorNames(), and init().
std::map<std::string, TF1> pftools::PFClusterCalibration::namesAndFunctions_ [private] |
Definition at line 162 of file PFClusterCalibration.h.
Referenced by getCalibratedEcalEnergy(), getCalibratedHcalEnergy(), init(), and setEvolutionParameters().