Example #1
0
/*============================================================================*/
void gaus1peakfit(Char_t *s, Float_t x1, Float_t x2, Float_t x3, Float_t x4)
{
  Double_t par[5],epar[5],x[4],y[4];
  TH1 *hist;
  hist = (TH1 *) gROOT->FindObject(s);
  setcanvas(1);
  TCanvas *c1=(TCanvas*) gROOT->FindObject("c1");
  if(c1==NULL)setcanvas(1);
  c1->Clear();
  hist->SetAxisRange(x1-30,x4+30);
  hist->Draw();

  //--**-- Linear background estimation --**--//
  x[0] = x1;
  x[1] = x2;
  x[2] = x3;
  x[3] = x4;
  Int_t bin1 = hist->FindBin(x1);
  y[0] = hist->GetBinContent(bin1);
  Int_t bin2 = hist->FindBin(x2);
  y[1] = hist->GetBinContent(bin2);
  Int_t bin3 = hist->FindBin(x3);
  y[2] = hist->GetBinContent(bin3);
  Int_t bin4 = hist->FindBin(x4);
  y[3] = hist->GetBinContent(bin4);
  TGraph *g = new TGraph(4,x,y);
  TF1 *fpol1 = new TF1("POL1","pol1",x1,x4);
  g->Fit(fpol1,"RQN");
  par[3]=fpol1->GetParameter(0);
  par[4]=fpol1->GetParameter(1);

  //--**-- Gaussian Peak estimation without background --**--//
  TF1 *fgaus = new TF1("GAUS","gaus",x2,x3);
  hist->Fit(fgaus,"RQN");
  fgaus->GetParameters(&par[0]);

  //--**-- Final Peak Fit with Background --**--//
  TF1 *func = new TF1("FGAUS","gaus(0)+pol1(3)",x1,x4);
  func->SetParameters(par);
  hist->Fit(func,"R+QN");
  func->GetParameters(par);
  epar[0]=func->GetParError(0);
  epar[1]=func->GetParError(1);
  epar[2]=func->GetParError(2);
  Double_t fwhm = par[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t efwhm = epar[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t N0 = par[0]*(TMath::Sqrt(TMath::TwoPi())*par[2]);
  Double_t r0 = epar[0]/par[0];
  Double_t r2 = epar[2]/par[2];
  Double_t eN0= N0*TMath::Sqrt(r0*r0+r2*r2);
  printf("Peak = %f +- %f; FFHM = %f +- %f; Area = %f +- %f\n",
          par[1],epar[1],fwhm,efwhm,N0,eN0);
  //printf("%11.4f %11.4f %11.0f %11.0f\n",
  //        par[1],epar[1],N0,eN0);
  func->SetLineWidth(0.5);
  func->SetLineStyle(1);
  func->SetLineColor(4);
  func->SetFillColor(4);
  func->Draw("same");
}
Example #2
0
/*=========================================================*/
void d2d(Char_t *matn)
{
  TH2F *hist;
  Axis_t axmax=axmin+numchx;
  Axis_t aymax=aymin+numchy;

  setcanvas(1);
  gStyle->SetPalette(1);
  gPad->SetLogz(1);
  hist=(TH2F*)f1->Get(matn);
  hist->SetAxisRange(axmin,axmax,"X");
  hist->SetAxisRange(aymin,aymax,"Y");
  hist->Draw("COLZ");
  return;
}
Example #3
0
/*=========================================================*/
Float_t AGY(Char_t *matn,Float_t peak,Float_t width=0.0)
{
  Axis_t axmax=axmin+numchx;
  setcanvas(2);
  TH1D *hist;
  hist=(TH1D*)gROOT->FindObject("xtemp");
  if(hist!=NULL)hist->Delete();
  hist=new TH1D("xtemp","xtemp",NCHX,0,DIMX);
  hist->Add(histx,1.0);
  Float_t a=GY(matn,peak,width);
  histx->Add(hist,1.0);
  c1->cd(2);
  histx->SetAxisRange(axmin,axmax);
  histx->SetLineColor(3);
  histx->Draw();
  return a;
}
Example #4
0
/*=========================================================*/
Float_t AGX(Char_t *matn,Float_t peak,Float_t width=0.0)
{
  Axis_t aymax=aymin+numchy;
  setcanvas(2);
  TH1D *hist;
  hist=(TH1D*)gROOT->FindObject("ytemp");
  if(hist!=NULL)hist->Delete();
  hist=new TH1D("ytemp","ytemp",NCHY,0,DIMY);
  hist->Add(histy,1.0);
  Float_t a=GX(matn,peak,width);
  histy->Add(hist,1.0);
  c1->cd(2);
  histy->SetAxisRange(aymin,aymax);
  histy->SetLineColor(3);
  histy->Draw();
  return a;
}
void plotdjr(const TString & infile, const TString & outfile) {
 
  gSystem->Load("libFWCoreFWLite.so");  
  AutoLibraryLoader::enable();  
  TH1::SetDefaultSumw2();
  
  TChain *tree = new TChain("Events");
  tree->Add(infile);
  
  tree->SetAlias("GenEvent","GenEventInfoProduct_generator__GEN.obj");
  tree->SetAlias("LHEEvent","LHEEventProduct_externalLHEProducer__LHE.obj");
 
  TCut weight = "GenEvent.weight()";
  int nbins = 50.;
  double djrmin = -0.5;
  double djrmax = 3.;
  //typeMC sets the kind of sample we are looking at: 
  //0 is for NLO with FXFX merging; 
  //1 is for LO with MLM; 
  //2 is for LO with MLM (plotting partons after excluding non-matched partons in wbb/vbf type processes)
  int typeMC = 2;
  
  TCanvas *c1 = new TCanvas("c1", "c1", 800, 600);
  TPad *pad[5];
  setcanvas(c1,pad);

  pad[0]->cd();
  makeplot("djr0",tree,weight,"log10(GenEvent.DJRValues_[0])","DJR 0->1",nbins,djrmin,djrmax,typeMC);
  pad[1]->cd();
  makeplot("djr1",tree,weight,"log10(GenEvent.DJRValues_[1])","DJR 1->2",nbins,djrmin,djrmax,typeMC);
  pad[2]->cd();
  makeplot("djr2",tree,weight,"log10(GenEvent.DJRValues_[2])","DJR 2->3",nbins,djrmin,djrmax,typeMC);
  pad[3]->cd();
  makeplot("djr3",tree,weight,"log10(GenEvent.DJRValues_[3])","DJR 3->4",nbins,djrmin,djrmax,typeMC);
  pad[4]->cd();
  makeplot("djr4",tree,weight,"log10(GenEvent.DJRValues_[4])","DJR 4->5",nbins,djrmin,djrmax,typeMC);


  c1->Print(outfile);
  return;  
}
Example #6
0
/*=========================================================*/
void dy(Char_t *matn)
{
  TH1D *hist[3];
  Axis_t aymax=aymin+numchy;
  Char_t str[255];

  setcanvas(1);
  sprintf(str,"%sy",matn);
  hist[2]=(TH1D*)gROOT->FindObject(str);
  if(hist[2]==NULL){
    hist[2]=new TH1D(str,str,NCHY,0,DIMY);
    pjy(matn);
    sprintf(str,"%s_py",matn);
    hist[0]=(TH1D*)gROOT->FindObject(str);
    sprintf(str,"%s_bgy",matn);
    hist[1]=(TH1D*)gROOT->FindObject(str);
    hist[2]->Add(hist[0],hist[1],1.0,-1.0);
    hist[2]->SetLineColor(2);
  }
  hist[2]->SetAxisRange(aymin,aymax);
  hist[2]->Draw();
  return;
}
Example #7
0
/*=========================================================*/
void dx(Char_t *matn)
{
  TH1D *hist[3];
  Axis_t axmax=axmin+numchx;
  Char_t str[255];

  setcanvas(1);
  sprintf(str,"%sx",matn);
  hist[2]=(TH1D*)gROOT->FindObject(str); 
  if(hist[2]==NULL){
    hist[2]=new TH1D(str,str,NCHX,0,DIMX);
    pjx(matn);
    sprintf(str,"%s_px",matn);
    hist[0]=(TH1D*)gROOT->FindObject(str); 
    sprintf(str,"%s_bgx",matn);
    hist[1]=(TH1D*)gROOT->FindObject(str); 
    hist[2]->Add(hist[0],hist[1],1.0,-1.0);
    hist[2]->SetLineColor(2);
  }
  hist[2]->SetAxisRange(axmin,axmax);
  hist[2]->Draw();
  return;
}
Example #8
0
/*============================================================================*/
void gaus2peakfit(Char_t *s, Float_t x1, Float_t x2, Float_t x3, Float_t x4)
{
  Double_t par[8],epar[8],x[2],y[2];
  TH1 *hist;
  hist = (TH1 *) gROOT->FindObject(s);
  TCanvas *c1=(TCanvas*) gROOT->FindObject("c1");
  if(c1==NULL)setcanvas(1);
  c1->Clear();
  hist->SetAxisRange(x1-30,x4+30);
  hist->Draw();

  //--**-- Linear background estimation --**--//
  x[0] = x1;
  x[1] = x4;
  Int_t bin1 = hist->FindBin(x1);
  y[0] = hist->GetBinContent(bin1);
  Int_t bin2 = hist->FindBin(x4);
  y[1] = hist->GetBinContent(bin2);
  TGraph *g = new TGraph(2,x,y);
  TF1 *fpol1 = new TF1("POL1","pol1",x1,x4);
  g->Fit(fpol1,"RQN");
  par[6]=fpol1->GetParameter(0);
  par[7]=fpol1->GetParameter(1);

  //--**-- Two Gaussian Peak estimation without background --**--//
  fgaus1 = new TF1("m1","gaus",x1,x2);
  fgaus2 = new TF1("m2","gaus",x3,x4);
  hist->Fit(fgaus1,"R+QN");
  hist->Fit(fgaus2,"R+QN");
  fgaus1->GetParameters(&par[0]);
  fgaus2->GetParameters(&par[3]);

  //--**-- Final Peak Fit with Background --**--//
  func = new TF1("m","gaus(0)+gaus(3)+pol1(6)",x1,x4);
  func->SetParameters(par);

  
  hist->Fit(func,"R+QN");
  func->SetLineWidth(0.5);
  func->SetLineStyle(1);
  func->SetLineColor(4);
  func->SetFillColor(4);
  func->Draw("same");
  func->GetParameters(par);
  epar[0]=func->GetParError(0);
  epar[1]=func->GetParError(1);
  epar[2]=func->GetParError(2);
  epar[3]=func->GetParError(3);
  epar[4]=func->GetParError(4);
  epar[5]=func->GetParError(5);
 
  Double_t fwhm1 = par[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t efwhm1 = epar[2]*TMath::Sqrt(8*TMath::Log(2));
  Double_t N10 = par[0]*(TMath::Sqrt(TMath::TwoPi())*par[2]);
  Double_t r10 = epar[0]/par[0];
  Double_t r12 = epar[2]/par[2];
  Double_t eN10= N10*TMath::Sqrt(r10*r10+r12*r12);

  Double_t fwhm2 = par[5]*TMath::Sqrt(8*TMath::Log(2));
  Double_t efwhm2 = epar[5]*TMath::Sqrt(8*TMath::Log(2));
  Double_t N20 = par[3]*(TMath::Sqrt(TMath::TwoPi())*par[5]);
  Double_t r20 = epar[3]/par[3];
  Double_t r22 = epar[5]/par[5];
  Double_t eN20= N20*TMath::Sqrt(r20*r20+r22*r22);

  //printf("Peak = %f +- %f; FFHM = %f +- %f; Area = %f +- %f\n",
  //        par[1],epar[1],fwhm1,efwhm1,N10,eN10);
  //printf("Peak = %f +- %f; FFHM = %f +- %f; Area = %f +- %f\n",
  //        par[4],epar[4],fwhm2,efwhm2,N20,eN20);
  printf("%11.4f %11.4f %11.0f %11.0f\n",
          par[1],epar[1],N10,eN10);
  printf("%11.4f %11.4f %11.0f %11.0f\n",
          par[4],epar[4],N20,eN20);
}
Example #9
0
/*=========================================================*/
Float_t GX(Char_t *matn,Float_t peak,Float_t width=0.0,Int_t cy=0)
{
  TH2 *hist2;
  TH1 *hist[5];
  Char_t str[255];
  Int_t nxmin,nxmax;
  Float_t ratio,a,b;
  Float_t xmin,xmax;
  Axis_t aymax=aymin+numchy;
  s1=new TSpectrum();

  hist2 = (TH2*)f1->Get(matn);
  if(hist2==NULL){
    printf("Couldn't find %s\n",matn);
    return -1.0;
  }
  hist2->SetAxisRange(0,DIMX,"X");
  hist2->SetAxisRange(0,DIMY,"Y");

  sprintf(str,"%s_px",matn);
  hist[0]=(TH1*)gROOT->FindObject(str);
  if(hist[0]==NULL){
    pjx(matn);
    hist[0]=(TH1*)gROOT->FindObject(str);
  }
  hist[0]->SetAxisRange(0,DIMX);

  sprintf(str,"%s_py",matn);
  hist[1]=(TH1*)gROOT->FindObject(str);
  if(hist[1]==NULL){
    pjy(matn);
    hist[1]=(TH1*)gROOT->FindObject(str);
  }
  hist[1]->SetAxisRange(0,DIMY);

  sprintf(str,"%s_bgx",matn);
  hist[2]=(TH1*)gROOT->FindObject(str);
  hist[2]->SetAxisRange(0,DIMX);

  if(width==0.0){
    width = (Float_t)f2x->Eval(peak/1000.);
    width=sqrt(width);
  }
  printf("width=%f\n",width);
  xmin=peak-width;
  xmax=peak+width;
  nxmin=hist[0]->FindBin(xmin);
  nxmax=hist[0]->FindBin(xmax);
  a=hist[2]->Integral(nxmin,nxmax);
  b=hist[0]->Integral();

  sprintf(str,"%sg%4.4iy",matn,(Int_t)peak);
  hist[3]=(TH1*)gROOT->FindObject(str);
  if(hist[3]!=NULL)hist[3]->Delete();
  hist[3]=hist2->ProjectionY(str, nxmin, nxmax);
  ratio=a/b;
  hist[3]->Add(hist[1],-ratio);
  hist[4]=s1->Background(hist[3],30);
  hist[3]->Add(hist[4],-1);
  hist[3]->SetLineColor(2);
  hist[3]->SetAxisRange(aymin,aymax);
  histy->Add(histy,hist[3],0.0,1.0);
  if(cy>=1){
    c1=(TCanvas *)gROOT->FindObject("c1");
    if(c1==NULL)setcanvas(cy);
    c1->cd(cy);
    c1->SetCrosshair(1);
    hist[3]->Draw();
  }
  return ratio;
}