Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62199
b: refs/heads/l1tmuon-upgrade-dev
c: ee657f3
h: refs/heads/l1tmuon-upgrade-dev
i:
  62197: f0793ef
  62195: d83063c
  62191: 873aa03
  • Loading branch information
Marco De Mattia committed Mar 17, 2009
1 parent 45749f6 commit 65cbe7d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/l1tmuon-upgrade-dev: 197cc2d93e72313a705db9facd7f10c274925da3
refs/heads/l1tmuon-upgrade-dev: ee657f3726bd57bb03d2ee866c852e3229ede321
12 changes: 7 additions & 5 deletions trunk/MuonAnalysis/MomentumScaleCalibration/test/Macros/Run.C
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
gROOT->ProcessLine(".L fit2DProj.C+");
// macroPlot parameters are: histogram name, input file 1 name, input file 2 name, output histogram title, resonance type,
// rebinX, rebinY, fitType (1:gaussian; 2:lorentzian, ...)
// rebinX, rebinY, fitType (1:gaussian; 2:lorentzian, ...), output file name (default "filegraph.root")

// Y: gaussian fit
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPt\", \"0_MuScleFit_Y.root\", \"1_MuScleFit_Y.root\", \"Resonance mass vs pt\", \"Y\", 4, 4, 1)" );
gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSEta\", \"0_MuScleFit_Y.root\", \"1_MuScleFit_Y.root\", \"Resonance mass vs #eta\", \"Y\", 4, 4, 1)" );
gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPt\", \"0_MuScleFit.root\", \"2_MuScleFit.root\", \"Resonance mass vs pt\", \"Y\", 4, 4, 1, \"filegraph_pt.root\")" );
gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSEta\", \"0_MuScleFit.root\", \"2_MuScleFit.root\", \"Resonance mass vs #eta\", \"Y\", 2, 2, 1, \"filegraph_eta.root\")" );
gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPhiPlus\", \"0_MuScleFit.root\", \"2_MuScleFit.root\", \"Resonance mass vs #phi\", \"Y\", 2, 2, 1, \"filegraph_phi.root\")" );

// Z: lorentzian fit
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPt\", \"0_MuScleFit_Y.root\", \"1_MuScleFit_Y.root\", \"Resonance mass vs pt\", \"Z\", 4, 4, 2)" );
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSEta\", \"0_MuScleFit_Y.root\", \"1_MuScleFit_Y.root\", \"Resonance mass vs #eta\", \"Z\", 4, 4, 2)" );
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPt\", \"0_MuScleFit.root\", \"1_MuScleFit.root\", \"Resonance mass vs pt\", \"Z\", 4, 4, 2)" );
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSEta\", \"0_MuScleFit.root\", \"1_MuScleFit.root\", \"Resonance mass vs #eta\", \"Z\", 4, 4, 2)" );
// gROOT->ProcessLine( "macroPlot(\"hRecBestResVSMu_MassVSPhiPlus\", \"0_MuScleFit.root\", \"1_MuScleFit.root\", \"Resonance mass vs #phi\", \"Z\", 4, 4, 2)" );

// gROOT->Reset();
}
60 changes: 44 additions & 16 deletions trunk/MuonAnalysis/MomentumScaleCalibration/test/Macros/fit2DProj.C
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ TGraphErrors* fit2DProj(TString name, TString path, int minEntries, int rebinX,
histoY->SetName(title);

if (histoY->GetEntries() > minEntries) {

//Make the dirty work!
TF1 *fit;
if(fitType == 1){
Expand All @@ -154,6 +155,11 @@ TGraphErrors* fit2DProj(TString name, TString path, int minEntries, int rebinX,
double *par = fit->GetParameters();
double *err = fit->GetParErrors();

// Check the histogram alone
TCanvas *canvas = new TCanvas(nameY+"alone", nameY+" alone");
histoY->Draw();
canvas->Write();

// Only for check
TCanvas *c = new TCanvas(nameY, nameY);

Expand All @@ -162,20 +168,37 @@ TGraphErrors* fit2DProj(TString name, TString path, int minEntries, int rebinX,
fileOut->cd();
c->Write();

//Store the fit results
Ftop.push_back(par[0]);
Fwidth.push_back(fabs(par[1]));//sometimes the gaussian has negative width (checked with Rene Brun)
Fmass.push_back(par[2]);
Etop.push_back(err[0]);
Ewidth.push_back(err[1]);
Emass.push_back(err[2]);

Fchi2.push_back(fit->GetChisquare()/fit->GetNDF());

double xx= histo->GetXaxis()->GetBinCenter(i);
Xcenter.push_back(xx);
double ex = 0;
Ex.push_back(ex);
// Skip nan
if( par[0] == par[0] ) {
//Store the fit results
Ftop.push_back(par[0]);
Fwidth.push_back(fabs(par[1]));//sometimes the gaussian has negative width (checked with Rene Brun)
Fmass.push_back(par[2]);
Etop.push_back(err[0]);
Ewidth.push_back(err[1]);
Emass.push_back(err[2]);

Fchi2.push_back(fit->GetChisquare()/fit->GetNDF());

double xx= histo->GetXaxis()->GetBinCenter(i);
Xcenter.push_back(xx);
double ex = 0;
Ex.push_back(ex);
}
else {
//Store the fit results
Ftop.push_back(0);
Fwidth.push_back(0);//sometimes the gaussian has negative width (checked with Rene Brun)
Fmass.push_back(0);
Etop.push_back(1);
Ewidth.push_back(1);
Emass.push_back(1);

Fchi2.push_back(100000);

Xcenter.push_back(0);
Ex.push_back(1);
}
}
}

Expand Down Expand Up @@ -323,12 +346,13 @@ TF1* linLorentzianFit(TH1* histoY){

/****************************************************************************************/
void macroPlot( TString name, const TString & nameFile1, const TString & nameFile2, const TString & title,
const TString & resonanceType, const int rebinX, const int rebinY, const int fitType ) {
const TString & resonanceType, const int rebinX, const int rebinY, const int fitType,
const TString & outputFileName) {

gROOT->SetBatch(true);

//Save the graphs in a file
TFile *outputFile = new TFile("filegraph.root","RECREATE");
TFile *outputFile = new TFile(outputFileName,"RECREATE");

setTDRStyle();

Expand All @@ -352,6 +376,10 @@ void macroPlot( TString name, const TString & nameFile1, const TString & nameFil
x[0]=-3; x[1]=3; //<------useful for reso VS eta
xAxisTitle = "#eta";
}
else if ( name.Contains("PhiPlus") ){
x[0] = -3.2; x[1] = 3.2;
xAxisTitle = "phi(rad)";
}
else {
x[0] = 0.; x[1] = 200;
xAxisTitle = "pt(GeV)";
Expand Down

0 comments on commit 65cbe7d

Please sign in to comment.