Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:35

0001 #include "TFile.h"
0002 #include "TString.h"
0003 #include "TCanvas.h"
0004 #include "RooPlot.h"
0005 #include "RooHist.h"
0006 #include "RooCurve.h"
0007 #include "TPaveText.h"
0008 #include "FitMass.cc"
0009 
0010 void CompareMass()
0011 {
0012   // TString fileName1("../FSRmodel/MassFit_3.root");
0013   TString fileNum1 = "0";
0014   TString fileNum2 = "2";
0015 
0016   TString fitType1("voigtian");
0017   TString fitType2("voigtian");
0018   TString backgroundType("exponential");
0019 
0020   FitMass fitMass1;
0021   fitMass1.fitter()->initMean(91., 80., 100.);
0022   fitMass1.fitter()->initSigma(2.5, 0., 10.);
0023   fitMass1.fit(80., 100., fileNum1, fitType1, backgroundType);
0024   FitMass fitMass2;
0025   fitMass2.fitter()->initMean(91., 80., 100.);
0026   fitMass2.fitter()->initSigma(2.5, 0., 10.);
0027   fitMass2.fit(80., 100., fileNum2, fitType2, backgroundType);
0028 
0029   TString fileName1("MassFit_"+fileNum1+".root");
0030   TString fileName2("MassFit_"+fileNum2+".root");  
0031 
0032   TFile * file1 = new TFile(fileName1, "READ");
0033   RooPlot * rooPlot1 = (RooPlot*)file1->Get("hRecBestRes_Mass_frame");
0034 
0035   TFile * file2 = new TFile(fileName2, "READ");
0036   RooPlot * rooPlot2 = (RooPlot*)file2->Get("hRecBestRes_Mass_frame");
0037 
0038   TFile * outputFile = new TFile("CompareMass.root", "RECREATE");
0039   outputFile->cd();
0040   TCanvas * canvas = new TCanvas("canvas", "canvas", 1000, 800);
0041   canvas->Draw();
0042   rooPlot1->Draw();
0043   rooPlot2->Draw("same");
0044   rooPlot2->getHist("h_dh")->SetLineColor(kRed);
0045   rooPlot2->getHist("h_dh")->SetMarkerColor(kRed);
0046   RooCurve * curve = 0;
0047   TPaveText * paveText = 0;
0048   if( backgroundType != "" ) {
0049     curve = (RooCurve*)rooPlot2->findObject("model_Norm[x]");
0050     paveText = (TPaveText*)rooPlot2->findObject("model_paramBox");
0051   }
0052   else if( fitType2 == "gaussian" ) {
0053     curve = (RooCurve*)rooPlot2->findObject("gaussian_Norm[x]");
0054     paveText = (TPaveText*)rooPlot2->findObject("gaussian_paramBox");
0055   }
0056   else if( fitType2 == "doubleGaussian" ) {
0057     curve = (RooCurve*)rooPlot2->findObject("doubleGaussian_Norm[x]");
0058     paveText = (TPaveText*)rooPlot2->findObject("doubleGaussian_paramBox");
0059   }
0060   else if( fitType2 == "voigtian" ) {
0061     paveText = (TPaveText*)rooPlot2->findObject("voigt_paramBox");
0062     curve = (RooCurve*)rooPlot2->findObject("voigt_Norm[x]");
0063   }
0064   if( curve != 0 ) curve->SetLineColor(kRed);
0065   if( paveText != 0 ) paveText->SetTextColor(kRed);
0066   canvas->Write();
0067   outputFile->Write();
0068   outputFile->Close();
0069 }