Skip to content

Commit

Permalink
Clear unrequired headers of boost lexical_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Purva-Chaudhari committed Sep 9, 2021
1 parent fd2a236 commit 63cbeb4
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 90 deletions.
2 changes: 0 additions & 2 deletions GeneratorInterface/AMPTInterface/src/AMPTHadronizer.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <iostream>
#include <cmath>

#include "boost/lexical_cast.hpp"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
Expand Down
2 changes: 0 additions & 2 deletions GeneratorInterface/HijingInterface/src/HijingHadronizer.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include <iostream>
#include <cmath>

#include "boost/lexical_cast.hpp"

#include "FWCore/Concurrency/interface/SharedResourceNames.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include <iostream>
#include <fstream>
#include <cmath>
#include "boost/lexical_cast.hpp"

#include "FWCore/Concurrency/interface/SharedResourceNames.h"
#include "FWCore/Framework/interface/Event.h"
Expand Down
2 changes: 0 additions & 2 deletions GeneratorInterface/HydjetInterface/src/HydjetHadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <iostream>
#include <cmath>

#include "boost/lexical_cast.hpp"

#include "FWCore/Concurrency/interface/SharedResourceNames.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
Expand Down
1 change: 0 additions & 1 deletion Geometry/CommonTopologies/test/ValidateRadial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/TrackerGeometryBuilder/interface/ProxyStripTopology.h"
#include "Geometry/CommonTopologies/interface/TkRadialStripTopology.h"
#include "boost/lexical_cast.hpp"
#include "TFile.h"
#include "TProfile.h"

Expand Down
1 change: 0 additions & 1 deletion HLTriggerOffline/Egamma/interface/EmDQM.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "HepMC/GenParticle.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>

#include "TDirectory.h"
Expand Down
2 changes: 1 addition & 1 deletion HLTriggerOffline/Egamma/src/EmDQM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ double EmDQM::getPrimaryEtCut(const std::string &path) {

boost::smatch what;
if (boost::regex_match(path, what, reg, boost::match_extra)) {
minEt = boost::lexical_cast<double>(what[2]);
minEt = std::stod(what[2]);
}

return minEt;
Expand Down
139 changes: 61 additions & 78 deletions MuonAnalysis/MomentumScaleCalibration/test/Macros/CompareRecoGenPt.C
Original file line number Diff line number Diff line change
Expand Up @@ -19,103 +19,89 @@
#include <iostream>
#include <iomanip>

// #include "boost/lexical_cast.hpp"

/// Helper function getting the histogram from file.
TProfile * getHistogram( const TString & fileName )
{
TFile * file = new TFile(fileName, "READ");
if( file == 0 ) {
TProfile *getHistogram(const TString &fileName) {
TFile *file = new TFile(fileName, "READ");
if (file == 0) {
std::cout << "Wrong file: " << fileName << std::endl;
exit(1);
}
TDirectory * dir = (TDirectory*) file->Get("hPtRecoVsPtGen");
if( dir == 0 ) {
TDirectory *dir = (TDirectory *)file->Get("hPtRecoVsPtGen");
if (dir == 0) {
std::cout << "Wrong directory for file: " << fileName << std::endl;
exit(1);
}
TProfile * profile = (TProfile*) dir->Get("hPtRecoVsPtGenProf");
if( profile == 0 ) {
TProfile *profile = (TProfile *)dir->Get("hPtRecoVsPtGenProf");
if (profile == 0) {
std::cout << "Wrong histogram for file: " << fileName << std::endl;
exit(1);
}
return profile;
}

/// Helper function building the histogram from the TProfile settings.
TH1F * makeHistogram( const TProfile * profile, const TString & name )
{
return new TH1F(TString(profile->GetName())+name, TString(profile->GetTitle())+" "+name, profile->GetNbinsX(), profile->GetXaxis()->GetXmin(), profile->GetXaxis()->GetXmax());
TH1F *makeHistogram(const TProfile *profile, const TString &name) {
return new TH1F(TString(profile->GetName()) + name,
TString(profile->GetTitle()) + " " + name,
profile->GetNbinsX(),
profile->GetXaxis()->GetXmin(),
profile->GetXaxis()->GetXmax());
}

/// Helper function to write the histograms to file.
void saveHistograms( TH1 * histo1, TH1 * histo2 )
{
void saveHistograms(TH1 *histo1, TH1 *histo2) {
histo1->Draw();
histo2->SetLineColor(kRed);
histo2->Draw("Same");
TLegend *leg = new TLegend(0.65,0.85,1,1);
TLegend *leg = new TLegend(0.65, 0.85, 1, 1);
leg->SetFillColor(0);
leg->AddEntry(histo1,"before calibration","L");
leg->AddEntry(histo2,"after calibration","L");
leg->AddEntry(histo1, "before calibration", "L");
leg->AddEntry(histo2, "after calibration", "L");
leg->Draw("same");
}

#include "TPaveText.h"
/// Helper class holding a TPaveText for better formatting and predefined options
class PaveText
{
public:
PaveText(const double & textX = 0.7, const double & textY = 0.4 )
{
paveText_ = new TPaveText(textX, textY, textX+0.2, textY+0.17, "NDC");
}
void AddText(const TString & text)
{
paveText_->AddText(text);
class PaveText {
public:
PaveText(const double &textX = 0.7, const double &textY = 0.4) {
paveText_ = new TPaveText(textX, textY, textX + 0.2, textY + 0.17, "NDC");
}
void Draw(const TString & option)
{
paveText_->SetFillColor(0); // text is black on white
void AddText(const TString &text) { paveText_->AddText(text); }
void Draw(const TString &option) {
paveText_->SetFillColor(0); // text is black on white
paveText_->SetTextSize(0.03);
paveText_->SetBorderSize(0);
paveText_->SetTextAlign(12);
paveText_->Draw(option);
}
void SetTextColor(const int color)
{
paveText_->SetTextColor(color);
}
protected:
TPaveText * paveText_;
void SetTextColor(const int color) { paveText_->SetTextColor(color); }

protected:
TPaveText *paveText_;
};

/**
* Compute the precision to give to the stream operator so that the passed number
* will be printed with two significant figures.
*/
int precision( const double & value )
{
int precision(const double &value) {
// Counter gives the precision
int precision = 1;
int k=1;
while( int(value*k) == 0 ) {
k*=10;
int k = 1;
while (int(value * k) == 0) {
k *= 10;
++precision;
}
return precision;
}

/// Helper function to extract and format the text for the fitted parameters
void getParameters( const TF1 * func, TString & fit1, TString & fit2, TString & fit3 )
{


void getParameters(const TF1 *func, TString &fit1, TString &fit2, TString &fit3) {
std::stringstream a;

double error = func->GetParError(0);
a << std::setprecision(precision(error)) << std::fixed << func->GetParameter(0);
// fit1 += boost::lexical_cast<string>(1);
fit1 += a.str() + "+-";
a.str("");
a << error;
Expand All @@ -137,18 +123,16 @@ void getParameters( const TF1 * func, TString & fit1, TString & fit2, TString &
fit3 += a.str();
}

void CompareRecoGenPt( const TString & fileNum1 = "0",
const TString & fileNum2 = "1" )
{
TFile * outputFile = new TFile("CompareRecoGenPt.root", "RECREATE");
void CompareRecoGenPt(const TString &fileNum1 = "0", const TString &fileNum2 = "1") {
TFile *outputFile = new TFile("CompareRecoGenPt.root", "RECREATE");

TProfile * profile1 = getHistogram( fileNum1+"_MuScleFit.root" );
TProfile *profile1 = getHistogram(fileNum1 + "_MuScleFit.root");
profile1->SetXTitle("gen muon Pt (GeV)");
profile1->SetYTitle("reco muon Pt (GeV)");
TProfile * profile2 = getHistogram( fileNum2+"_MuScleFit.root" );
TProfile *profile2 = getHistogram(fileNum2 + "_MuScleFit.root");

int xBins = profile1->GetNbinsX();
if( xBins != profile2->GetNbinsX() ) {
if (xBins != profile2->GetNbinsX()) {
std::cout << "Wrong number of bins" << std::endl;
exit(1);
}
Expand All @@ -158,40 +142,40 @@ void CompareRecoGenPt( const TString & fileNum1 = "0",

outputFile->cd();

TH1F * meanHisto1 = makeHistogram(profile1, "mean");
TH1F * meanHisto2 = makeHistogram(profile2, "mean");
TH1F * rmsHisto1 = makeHistogram(profile1, "rms");
TH1F * rmsHisto2 = makeHistogram(profile2, "rms");
for( int iBin = 1; iBin <= xBins; ++iBin ) {
// if( profile1->GetBinError(iBin) != 0 ) {
meanHisto1->SetBinContent( iBin, profile1->GetBinContent(iBin) );
meanHisto1->SetBinError( iBin, profile1->GetBinError(iBin) );
// }
// if( profile2->GetBinError(iBin) ) {
meanHisto2->SetBinContent( iBin, profile2->GetBinContent(iBin) );
meanHisto2->SetBinError( iBin, profile2->GetBinError(iBin) );
// }
rmsHisto1->SetBinContent( iBin, profile1->GetBinError(iBin) );
rmsHisto2->SetBinContent( iBin, profile2->GetBinError(iBin) );
TH1F *meanHisto1 = makeHistogram(profile1, "mean");
TH1F *meanHisto2 = makeHistogram(profile2, "mean");
TH1F *rmsHisto1 = makeHistogram(profile1, "rms");
TH1F *rmsHisto2 = makeHistogram(profile2, "rms");
for (int iBin = 1; iBin <= xBins; ++iBin) {
// if( profile1->GetBinError(iBin) != 0 ) {
meanHisto1->SetBinContent(iBin, profile1->GetBinContent(iBin));
meanHisto1->SetBinError(iBin, profile1->GetBinError(iBin));
// }
// if( profile2->GetBinError(iBin) ) {
meanHisto2->SetBinContent(iBin, profile2->GetBinContent(iBin));
meanHisto2->SetBinError(iBin, profile2->GetBinError(iBin));
// }
rmsHisto1->SetBinContent(iBin, profile1->GetBinError(iBin));
rmsHisto2->SetBinContent(iBin, profile2->GetBinError(iBin));
}

// Setting all weigths to 1 ("W" option) because of Profile errors for low statistics bins biasing the fit

// meanHisto1->Fit("pol1", "W", "", 2, 1000);
profile1->Fit("pol1", "W", "", 0, 1000);
TF1 * func1 = profile1->GetFunction("pol1");
TF1 *func1 = profile1->GetFunction("pol1");
// TF1 * func1 = meanHisto1->GetFunction("pol1");
func1->SetLineWidth(1);
func1->SetLineColor(kBlack);

profile2->Fit("pol1", "W", "", 0, 1000);
// meanHisto2->Fit("pol1", "W", "", 2, 1000);
TF1 * func2 = profile2->GetFunction("pol1");
TF1 *func2 = profile2->GetFunction("pol1");
// TF1 * func2 = meanHisto2->GetFunction("pol1");
func2->SetLineWidth(1);
func2->SetLineColor(kRed);

TCanvas * canvas = new TCanvas("before", "before corrections", 1000, 800);
TCanvas *canvas = new TCanvas("before", "before corrections", 1000, 800);
// canvas->Divide(2);
canvas->cd();
// canvas->cd(1);
Expand Down Expand Up @@ -231,10 +215,9 @@ void CompareRecoGenPt( const TString & fileNum1 = "0",
outputFile->Write();
outputFile->Close();

// TLegend *leg = new TLegend(0.2,0.4,0.4,0.6);
// leg->SetFillColor(0);
// leg->AddEntry(func1,"fit of before","L");
// leg->AddEntry(func2,"fit of after","L");
// leg->Draw("same");
// TLegend *leg = new TLegend(0.2,0.4,0.4,0.6);
// leg->SetFillColor(0);
// leg->AddEntry(func1,"fit of before","L");
// leg->AddEntry(func2,"fit of after","L");
// leg->Draw("same");
}

2 changes: 0 additions & 2 deletions PhysicsTools/SelectorUtils/bin/testSelection_wplusjets.C
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <iostream>
#include <cmath> //necessary for absolute function fabs()

#include <boost/lexical_cast.hpp>

//Root includes
#include "TROOT.h"
#include "TFile.h"
Expand Down

0 comments on commit 63cbeb4

Please sign in to comment.