コード例 #1
0
ファイル: myHist.C プロジェクト: mrelich/IceBlockAna
//------------------------------------------------------------//
// Get TProfile
//------------------------------------------------------------//
TProfile* getProfile(TFile* file, TString pname, TString xtitle,
		     TString ytitle, int color, int marker)
{
  
  TProfile* prof = (TProfile*) (file->Get(pname.Data())->Clone(Form("%s_%i",pname.Data(),color)));
  prof->GetXaxis()->SetTitle(xtitle.Data());
  prof->GetYaxis()->SetTitle(ytitle.Data());
  prof->SetMarkerStyle(marker);
  prof->SetMarkerColor(color);
  //prof->SetMarkerSize(0.5);
  prof->SetLineColor(color);
  prof->SetTitle("");
  prof->SetStats(0);
  prof->GetYaxis()->SetTitleOffset(1.5);
  
  return prof;

}
コード例 #2
0
ファイル: doPlots.C プロジェクト: magania/CMS2
TProfile* plotIsoPerformance( TFile* ftt, 
			      const char* signal,     // histogram name
			      const char* background, // histogram name
			      const char* name,       // unique name
			      bool reverse = false,   // normally signal near zero bin, reverse means signal is around max bin
			      double bkg_eff_min = 0,
			      double bkg_eff_max = 1,
			      double sig_eff_min = 0,
			      double sig_eff_max = 0
			      )
{ 
  TH1F* S = dynamic_cast<TH1F*>(ftt->Get(signal));
  if ( ! S ) {
    std::cout << "Error: histogram not found " << signal << std::endl;
    return 0;
  }
  TH1F* B = dynamic_cast<TH1F*>(ftt->Get(background));
  if ( ! B ) {
    std::cout << "Error: histogram not found " << background << std::endl;
    return 0;
  }
  char buf[1024];
  sprintf(buf,"c_%s",name);
  // TCanvas* c = new TCanvas(buf,buf,500,500);
  sprintf(buf,"p_%s",name);
  TProfile* p = new TProfile(buf,buf,50,bkg_eff_min,bkg_eff_max,sig_eff_min,sig_eff_max);
  p->SetLineColor(kBlue);
  p->SetLineWidth(2);
  p->SetMarkerStyle(20);
  p->SetMarkerSize(1);
  p->GetXaxis()->SetTitle("Background Efficiency");
  p->GetYaxis()->SetTitle("Signal Efficiency");
  p->SetStats(kFALSE);
  for( int i=0;i<=S->GetNbinsX()+1; ++i )
    if ( reverse ) 
      p->Fill(B->Integral(i,B->GetNbinsX()+1)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(i,S->GetNbinsX()+1)/S->Integral(0,S->GetNbinsX()+1));
    else
      p->Fill(B->Integral(0,i)/B->Integral(0,B->GetNbinsX()+1),
	      S->Integral(0,i)/S->Integral(0,S->GetNbinsX()+1));
  // p->Draw();
  return p;
}
コード例 #3
0
ファイル: Fake100PeVShower.C プロジェクト: mrelich/EField
void Fake100PeVShower(int opt)
{

  // opt == 0 implies save to root file
  // opt == 1 implies plot and save to canvas
  TFile* file = NULL;
  TCanvas* c  = NULL;

  if(opt == 0)
    file = new TFile("fake100PeVShower.root","recreate");
  if(opt == 1)
    c = makeCanvas("c");

  TString gaus = "1.5e7*TMath::Exp(-(pow(x-10,2)/9))";
  TString bump = "5e6*TMath::Exp(-(pow(x-17,2)/20))";
  TF1* f = new TF1("f",(gaus+"+"+bump).Data(),0,30);

  int nbins = 3000;
  float xmin  = 0;
  float xmax  = 30;
  TProfile* prof = new TProfile("prof","",nbins,xmin,xmax);
  prof->SetStats(0);
  prof->SetTitle("");
  prof->GetYaxis()->SetTitle("Charge excess / 1e7");
  prof->GetXaxis()->SetTitle("z [m]");

  float step = xmax / nbins;
  for(int i =0; i<nbins; ++i){
    float x = step * i;
    if(opt == 1 ) prof->Fill(x, f->Eval(x)/1e7);
    else          prof->Fill(x, f->Eval(x));
  }
    
  if(opt == 1){
    prof->Draw();
    c->SaveAs("JaimeCheck/FakeProfile100PeV.png");
  }
  if(opt == 0){
    file->Write();
    file->Close();
  }
}
コード例 #4
0
void makePlot(char* canv)
{
	t->SetBranchAddress("LM_PX1", &intree.LM_PX1);
	t->SetBranchAddress("LM_PX2", &intree.LM_PX2);
	t->SetBranchAddress("LM_PY1", &intree.LM_PY1);
	t->SetBranchAddress("LM_PY2", &intree.LM_PY2);
	t->SetBranchAddress("LM_P2_Integral", &intree.LM_P2_Integral);
	t->SetBranchAddress("time", &intree.timeline);
	t->Print();

	if(entries<=0)
		entries = t->GetEntries();

	char title[100]=0;
	sprintf(title,"%s runs 1100-1107",canv);
	TProfile *prof = new TProfile(title,title,24,0,entries);
	TProfile *prof1 = new TProfile(title,title,24,0,entries);
	TProfile *prof2 = new TProfile(title,title,24,0,entries);

	/**************************************
     * read entries
     **************************************
    */
	Double_t *ratio = new Double_t[entries];
	Double_t *parmean = new Double_t[entries];
	Double_t *p1 = new Double_t[entries];
	Double_t *p2 = new Double_t[entries];

	for (int j = 0; j < entries; ++j){
		gSystem->Sleep (sleep);
		t->GetEntry(j);
		ratio[j] = intree.LM_PY1/intree.LM_PY2;
		p1[j] = intree.LM_PY1;
		p2[j] = intree.LM_PY2;
		//cout<<"entry "<<j<<" peak2 "<<intree.LM_PY2<<endl;
	}

	Double_t mean = TMath::Mean(entries,ratio);
	Double_t mean1 = TMath::Mean(entries,p1);
	Double_t mean2 = TMath::Mean(entries,p2);
	for (int j = 0; j < entries; ++j){
		prof->Fill(j,(ratio[j]/mean-1)*100);
		prof1->Fill(j,(p1[j]/mean1-1)*100);
		prof2->Fill(j,(p2[j]/mean2-1)*100);
	}

	TCanvas *c1 = new TCanvas(canv,"frascatirun",900,700);
	c1->cd();

    char axisXname[100];
	sprintf(axisXname,"Time (Entries) (total: %i)",entries);
	prof->SetXTitle(axisXname);
	prof->SetYTitle("Variation (%)");
	prof->SetMaximum(1);
	prof->SetMinimum(-1);
	prof->SetMarkerColor(4);
	prof->SetMarkerSize(1);
	prof->SetMarkerStyle(8);
	prof->SetStats(kFALSE);
	prof->Draw();

	prof1->SetMarkerColor(5);
	prof1->SetMarkerSize(1);
	prof1->SetMarkerStyle(6);
	prof1->Draw("same");

	prof2->SetMarkerColor(1);
	prof2->SetMarkerSize(1);
	prof2->SetMarkerStyle(7);
	prof2->Draw("same");

/*	TLegend leg = new TLegend(0.1,0.7,0.48,0.9);
	leg->SetHeader("The Legend Title");
	leg->AddEntry(h1,"Histogram filled with random numbers","f");
	leg->AddEntry("f1","Function abs(#frac{sin(x)}{x})","l");
	leg->AddEntry("gr","Graph with error bars","lep");
	leg->Draw("same");
*/
}