当前位置: 首页>>代码示例>>C++>>正文


C++ TLatex::DrawLatexNDC方法代码示例

本文整理汇总了C++中TLatex::DrawLatexNDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TLatex::DrawLatexNDC方法的具体用法?C++ TLatex::DrawLatexNDC怎么用?C++ TLatex::DrawLatexNDC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TLatex的用法示例。


在下文中一共展示了TLatex::DrawLatexNDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawLogbook

/*!
 * ### Example usage:
\code
    .L $AliRoot_SRC/STAT/Macros/aliExternalInfo.C+
    drawLogbook("LHC15o","pass1","QA.TPC.meanTPCncl>0","runDuration:totalEventsPhysics:totalNumberOfFilesMigrated:MonALISA.RCT.tpc_value");
    drawLogbook("LHC10h","pass2","totalEventsPhysics>1000&&totalNumberOfFilesMigrated>20","runDuration:totalEventsPhysics:totalNumberOfFilesMigrated:MonALISA.RCT.tpc_value");
    drawLogbook("LHC11h","pass2","totalEventsPhysics>1000&&totalNumberOfFilesMigrated>20","runDuration:totalEventsPhysics:totalNumberOfFilesMigrated:MonALISA.RCT.tpc_value");
\endcode
*/
void drawLogbook(TString period, TString pass,TString runSelection="", TString varSelection="runDuration:totalEventsPhysics:totalNumberOfFilesMigrated"){
  TTree * treeLogbook = info.GetTree("Logbook",period,pass,"QA.TPC;QA.TRD;QA.ITS;MonALISA.RCT");
  TObjArray *varList=0;
  if (varSelection[0]=='['){ //variable list using class selection
    // Use class selection to select variables
    varList=AliTreePlayer::selectMetadata(treeLogbook,varSelection,0);
    Int_t nvars=varList->GetEntries();
    for (Int_t i=0; i<nvars;i++){
      TString vname=varList->At(i)->GetName();
      vname.ReplaceAll(".class","");
    }
    // varList=AliTreePlayer::selectMetadata(treeLogbook, "[class==\"Logbook&&Time\"]",0);
  }else{
    varList=varSelection.Tokenize(":");
  }
  Int_t nvars=varList->GetEntries();
  TCanvas * canvas = new TCanvas("drawLogbook","drawLogbook",1200,1000);
  canvas->Divide(1,nvars);
  for (Int_t i=0; i<nvars; i++){
    canvas->cd(i+1);
    TString var=TString::Format("%s:run",varList->At(i)->GetName());
    TStatToolkit::MakeGraphSparse(treeLogbook,var,runSelection,25,1,1)->Draw("ap");
    Double_t mean = TMath::Mean(treeLogbook->GetSelectedRows(),treeLogbook->GetV1());
    Double_t sum  = treeLogbook->GetSelectedRows()*mean;
    latex.DrawLatexNDC(0.15,0.8,TString::Format("Mean=%0.0f",mean));
    latex.DrawLatexNDC(0.15,0.7,TString::Format("Sum=%0.0f",sum));
  }
  canvas->SaveAs(TString::Format("%s_%s.png",pass.Data(),period.Data()).Data());
}
开发者ID:alisw,项目名称:AliRoot,代码行数:38,代码来源:aliExternalInfo.C

示例2: PlotPoints

void PlotPoints(){
	GetAllMasses();
  TCanvas *c1 = new TCanvas("c1","MassPlot",200,10,700,500);
  c1 -> DrawFrame(0, 0, 850, 600);
	TGraph *MassPlot = new TGraph(StopMass.size(), (float*) &StopMass[0], (float*) &NeutralinoMass[0]);
  MassPlot->SetMarkerStyle(20);
  MassPlot->SetMarkerSize(1.1);
  MassPlot->SetMarkerColor(2);
  MassPlot->Draw("P");
  TLatex Title = TLatex(); Title.DrawLatexNDC(.40, .94, "Mass Points");
  TLatex Xaxis = TLatex(); Xaxis.DrawLatexNDC(0.65, 0.03, "Stop Mass [GeV]");
  TLatex Yaxis = TLatex(); Yaxis.SetTextAngle(90); Yaxis.DrawLatexNDC(0.03, 0.31, "Neutralino Mass [GeV]");
  c1 -> Print(outputdir + "MassPoints.pdf", "pdf");
  c1 -> Print(outputdir + "MassPoints.png", "png");
}
开发者ID:GonzalezFJR,项目名称:TOP13TeV,代码行数:15,代码来源:getT2ttInfo.C

示例3: plotMttResolution

void plotMttResolution() {

  setTDRStyle();

  TCanvas *c = new TCanvas("c", "c", 800, 800);

  TH1F *mtt = (TH1F*) _file0->Get("mtt_resolution_mva");
  mtt->SetTitle("");
  mtt->SetName("m_{t#bar{t}}");
  mtt->GetXaxis()->SetTitle("m_{t#bar{t}} - m_{t#bar{t}}^{gen} (GeV)");
  mtt->SetLineColor(TColor::GetColor("#542437"));
  mtt->SetLineColor(TColor::GetColor("#8A9B0F"));
  mtt->SetLineColor(TColor::GetColor("#C02942"));
  mtt->SetFillColor(mtt->GetLineColor());
  mtt->SetFillStyle(3004);
  mtt->GetXaxis()->SetTitleOffset(1.2);

  TF1 *voigt = new TF1("voigt", "gaus", -100, 100);
	voigt->SetParName(0, "amp");
	voigt->SetParName(2, "mean");
	voigt->SetParName(1, "sigma");

  voigt->SetParameter(0, mtt->GetMaximum());
	voigt->SetParameter(2, 0);
	voigt->SetParameter(1, 100);

  mtt->Fit(voigt, "RVN");

  voigt->SetLineColor(TColor::GetColor("#8A9B0F"));
  voigt->SetLineWidth(2);

  mtt->Draw();
  voigt->Draw("same");

  TLatex* latex = new TLatex();
  latex->SetTextFont(42);
  latex->SetTextSize(0.033);
  latex->DrawLatexNDC(0.25, 0.84, TString::Format("mean = %.2f", voigt->GetParameter(1)));
  latex->DrawLatexNDC(0.25, 0.8, TString::Format("#sigma = %.2f", voigt->GetParameter(2)));

  gPad->Modified();
  gPad->Update();

  c->Print("mtt_resolution.pdf");
}
开发者ID:IPNL-CMS,项目名称:MttTools,代码行数:45,代码来源:plotMttResolution.C

示例4: derivefromprofile

void derivefromprofile()
{

  auto file = config.getfile_djt("mcPbqcd");
  auto nt = (TTree *)file->Get("nt");

  for (unsigned i=1;i<binbounds.size();i++) {
    int b1 = binbounds[i-1];
    int b2 = binbounds[i];
    auto p = new TProfile(Form("p%d%d",b1,b2),Form("prof"),100,0,200);

    nt->Project(p->GetName(),"(subid2 == 0 && refpt2 > 20):jtptSignal2",Form("weight*(jtpt1>100&&bin>=%d && bin<%d)",b1,b2));
    profs.push_back(p);

    auto f = new TF1(Form("f%d%d",b1,b2),"exp(-[0]*exp(-[1]*x))");
    f->SetParameters(100,0.1);
    p->Fit(f);
    fs.push_back(f);

    float median = -1/f->GetParameter(1)*log(-1/f->GetParameter(0)*log(0.5));

    auto c = getc();
      TLatex *Tl = new TLatex();
    p->SetMinimum(0);p->SetMaximum(1);
    p->Draw();
    f->Draw("same");
    Tl->DrawLatexNDC(0.6,0.4,Form("PbPb bin %d-%d",b1,b2));
    Tl->DrawLatexNDC(0.6,0.35,Form("median = %.2f",median));

    TLine *l1 = new TLine(median,0,median, f->Eval(median));
    l1->Draw();
    TLine *l2 = new TLine(0,0.5,median, f->Eval(median));
    l2->Draw();

    SavePlot(c,Form("fit%d%d",b1,b2));
  }

}
开发者ID:bjet2015,项目名称:dibjets,代码行数:38,代码来源:eclipsederive.C

示例5: countZs

void countZs(const char* filename, int run1=1, int run2=0, float lumi=0, bool add=false) {
   TFile *file = new TFile(filename);
   if (!file) return;
   
   TCanvas *c1 = new TCanvas();
   c1->cd();

   TH1F *h = (TH1F*) file->Get("Run summary/DiMuonHistograms/GlbGlbMuon_HM");
   h->GetYaxis()->SetRangeUser(0,200);
   h->Draw();

   TF1 *f = new TF1("f","gaus(0)+pol2(3)",70,110);
   f->SetParName(0,"norm");
   f->SetParName(1,"mass");
   f->SetParName(2,"width");
   f->SetParameters(1.16028e+02,9.07785e+01,2.11556e+00,-2.17600e+01,9.67443e-01,-6.98382e-03);
   f->SetParLimits(0,0,1e6);
   f->SetParLimits(1,85,95);
   f->SetParLimits(2,1.5,5);
   h->Fit(f,"","",70,110);
   h->GetYaxis()->SetRangeUser(0,200);
   c1->Update();

   TF1 *f2 = new TF1("f2","gaus(0)",70,110);
   f2->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2));
   int integral = (int) (f2->Integral(70,110) / h->GetBinWidth(2));

   TLatex *tl = new TLatex();
   tl->DrawLatexNDC(0.1,0.95,Form("pPb 8TeV [%i-%i, %.1f nb^{-1}]",run1,run2,lumi));
   tl->DrawLatexNDC(0.18,0.75,Form("%i Z bosons",integral));
   tl->DrawLatexNDC(0.18,0.7,Form("(#sigma = %.1f nb)",integral/lumi));

   if (!add) c1->SaveAs(Form("plotZ_%i_%i.pdf",run1,run2));
   else c1->SaveAs("plotZ.gif+100");

   file->Close();
}
开发者ID:CMS-HIN-dilepton,项目名称:RunPreparation,代码行数:37,代码来源:countZs.C

示例6: CompHist

void CompHist(TH1 *h1, TH1 *href, int run1, int runref) {
   if (!h1 || !href || h1->Integral()==0 || href->Integral()==0) return;
   // first check if both histograms are compatible
   Stat_t s[TH1F::kNstat];
   h1->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights
   Double_t sumBinContent1 = s[0];
   Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
   href->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights
   Double_t sumBinContent2 = s[0];
   Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0);
   float pval_chi2=1, pval_ks=1,pval_ad=1;
   bool iswt = (sumBinContent1==0 || effEntries1==0 || sumBinContent2==0 || effEntries2==0 || TMath::Abs(sumBinContent1 - effEntries1) != 0 || TMath::Abs(sumBinContent2 - effEntries2) != 0);
   if (iswt) {
      // weighted histograms
      pval_chi2 = h1->Chi2Test(href,"WW");
      // pval_ks = h1->KolmogorovTest(href);
   } else {
      // unweighted histograms
      pval_ks = h1->KolmogorovTest(href);
      pval_ad = h1->AndersonDarlingTest(href);
      // double int1 = h1->Integral();
      // double intref = href->Integral(); 
      // if (int1==0 || intref==0) return;
      // h1->Scale(1./int1);
      // href->Scale(1./intref);
      // pval_chi2 = h1->Chi2Test(href,"NORM UU");
   }

   if (pval_chi2>minpval && pval_ks>minpval) return;

   // looks like we have a discrepancy! let's plot the histograms and print the output
   cout << h1->GetTitle() << ": p-val(chi2) = " << pval_chi2 << ", p-val(KS) = " << pval_ks << ", pval_ad = " << pval_ad << endl;

   TCanvas *c1 = new TCanvas();
   href->SetLineColor(kRed);
   href->SetMarkerColor(kRed);
   if (!iswt) href->DrawNormalized();
   else href->Draw();
   c1->Update();
   // Retrieve the stat box
   TPaveStats *ps = (TPaveStats*)c1->GetPrimitive("stats");
   ps->SetName("statsref");
   ps->SetTextColor(kRed);
   ps->SetX1NDC(0.8);
   ps->SetX2NDC(1.);
   ps->SetY1NDC(0.6);
   ps->SetY2NDC(0.8);

   h1->SetLineColor(kBlack);
   h1->SetMarkerColor(kBlack);
   if (!iswt) h1->DrawNormalized("sames");
   else h1->Draw("sames");
   c1->Update();
   TPaveStats *psref = (TPaveStats*)c1->GetPrimitive("stats");
   psref->SetName("stats1");
   psref->SetX1NDC(0.8);
   psref->SetX2NDC(1.);
   psref->SetY1NDC(0.8);
   psref->SetY2NDC(1.);
   c1->Modified();
   c1->Update();

   TLatex *txt = new TLatex();
   if (!iswt) txt->DrawLatexNDC(0.02,0.02,Form("p(KS) = %f, p(AD) = %f",pval_ks,pval_ad));
   else txt->DrawLatexNDC(0.02,0.02,Form("p(#chi^{2}) = %f",pval_chi2));

   c1->SaveAs(Form("%s_%i_%i.png",h1->GetName(),run1,runref));
   delete c1;
}
开发者ID:CMS-HIN-dilepton,项目名称:RunPreparation,代码行数:69,代码来源:compare.C

示例7: drawSpectra2D


//.........这里部分代码省略.........
        else if (nDrawOptions == nHistosInput) drawOption = drawOptions.at(i%nDrawOptions).c_str();

        h_draw[i]->Draw(drawOption.c_str());

        if (nLegendEntryLabels == nHistosInput) {
            std::string label = legendEntryLabels.at(i%nLegendEntryLabels).c_str();
            std::string legendOption = "lpf";
            if (drawOption.find("hist") != std::string::npos)  legendOption = "lf";
            if (label.compare(CONFIGPARSER::nullInput) != 0)  leg->AddEntry(h_draw[i], label.c_str(), legendOption.c_str());
        }

        if (legendTextSize != 0)  leg->SetTextSize(legendTextSize);
        leg->SetBorderSize(legendBorderSize);
        double height = calcTLegendHeight(leg);
        double width = calcTLegendWidth(leg);
        if (legendHeight != 0)  height = legendHeight;
        if (legendWidth != 0)  width = legendWidth;
        if (legendPosition.size() > 0) {    // draw the legend if really a position is provided.
            setLegendPosition(leg, legendPosition, c, height, width, legendOffsetX, legendOffsetY);
            leg->Draw();
        }

        // add Text
        TLatex* latex = 0;
        if (nTextLines > 0) {
            latex = new TLatex();
            latex->SetTextFont(textFont);
            latex->SetTextSize(textSize);
            setTextAlignment(latex, textPosition);
            std::vector<std::pair<float,float>> textCoordinates = calcTextCoordinates(textLines, textPosition, c, textOffsetX, textOffsetY);
            for (int i = 0; i<nTextLines; ++i) {
                float x = textCoordinates.at(i).first;
                float y = textCoordinates.at(i).second;
                latex->DrawLatexNDC(x, y, textLines.at(i).c_str());
            }
        }

        // add Text above the pad
        TLatex* latexOverPad = 0;
        if (nTextsOverPad > 0) {
            latexOverPad = new TLatex();
            latexOverPad->SetTextFont(textAbovePadFont);
            latexOverPad->SetTextSize(textAbovePadSize);
            for (int i = 0; i < nTextsOverPad; ++i) {
                int textOverPadAlignment = GRAPHICS::textAlign;
                if (nTextsOverPadAlignments == 1) textOverPadAlignment = GraphicsConfigurationParser::ParseTextAlign(textsOverPadAlignments.at(0));
                else if (nTextsOverPadAlignments == nTextsOverPad) textOverPadAlignment = GraphicsConfigurationParser::ParseTextAlign(textsOverPadAlignments.at(i));

                latexOverPad->SetTextAlign(textOverPadAlignment);
                setTextAbovePad(latexOverPad, c, textAbovePadOffsetX, textAbovePadOffsetY);

                latexOverPad->DrawLatexNDC(latexOverPad->GetX(), latexOverPad->GetY(), textsOverPad.at(i).c_str());
            }
        }

        // add TLine
        TLine* line_horizontal[nTLines_horizontal];
        for (int iLine = 0; iLine<nTLines_horizontal; ++iLine) {
            // draw horizontal line
            double xmin = h[i]->GetXaxis()->GetBinLowEdge(h[i]->GetXaxis()->GetFirst());
            double xmax = h[i]->GetXaxis()->GetBinLowEdge(h[i]->GetXaxis()->GetLast()+1);

            int lineStyle_horizontal = GRAPHICS::lineStyle_horizontal;
            if (nLineStyles_horizontal == 1)
                lineStyle_horizontal = GraphicsConfigurationParser::ParseLineStyle(lineStyles_horizontal.at(0));
            else if (nLineStyles_horizontal == nTLines_horizontal)
开发者ID:CmsHI,项目名称:ElectroWeak-Jet-Track-Analyses,代码行数:67,代码来源:drawSpectra2D.C

示例8: plotResoVsIC

int plotResoVsIC(){

  SetTdrStyle();


  const unsigned nIC = 10;
  const unsigned ICval[nIC] = {0,1,2,3,4,5,10,15,20,50};


  std::ostringstream label;
  TFile *fcalib[nIC];
  
  TGraphErrors *constant = new TGraphErrors();
  constant->SetName("constant");
  constant->SetTitle(";intercalib. smearing");
  constant->SetMarkerStyle(20);
  constant->SetMarkerColor(1);
  constant->SetLineColor(1);
  TGraphErrors *constantSR7 =  new TGraphErrors();
  constantSR7->SetName("constantSR7");
  constantSR7->SetTitle(";intercalib. smearing");
  constantSR7->SetMarkerStyle(23);
  constantSR7->SetMarkerColor(2);
  constantSR7->SetLineColor(2);

  TGraphErrors *noise = (TGraphErrors *) constant->Clone("noise");
  TGraphErrors *sampling = (TGraphErrors *) constant->Clone("sampling");
  TGraphErrors *samplingSR7 = (TGraphErrors *) constantSR7->Clone("samplingSR7");

  TCanvas *mycReso = new TCanvas("mycReso","mycReso",1500,1000);
  mycReso->Divide(2,5);
  TCanvas *mycR = new TCanvas("mycR","Sampling",1500,1000);
  TCanvas *mycC = new TCanvas("mycC","Constant",1500,1000);
  TCanvas *mycN = new TCanvas("mycN","Noise",1500,1000);

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);

  gStyle->SetStatW(0.2);
  gStyle->SetStatH(0.5);

  TLatex lat;
  char buf[500];

  TGraphErrors *gr[nIC][2];
  double x0,y0;
  double x0_7,y0_7;

  for (unsigned ic(0);ic<nIC;++ic){//loop on intercalib
    label.str("");
    label << "PLOTS/CalibReso";
    label << "_vsE";
    label << "_IC" << ICval[ic];
    label << ".root";
    fcalib[ic] = TFile::Open(label.str().c_str());
    if (!fcalib[ic]) {
      std::cout << " -- failed to open file: " << label.str() << std::endl;
      continue;
    }
    else {
      std::cout << " -- file " << label.str() << " successfully opened." << std::endl;
    }
    fcalib[ic]->cd("SR2");
    gr[ic][0] = (TGraphErrors *)gDirectory->Get("resoRecoFit2eta21pu1");
    fcalib[ic]->cd("SR7");
    gr[ic][1] = (TGraphErrors *)gDirectory->Get("resoRecoFit7eta21pu1");


    TF1 *fit = gr[ic][0]->GetFunction("reso");
    TF1 *fit7 = gr[ic][1]->GetFunction("reso");
    mycReso->cd(ic+1);
    gr[ic][0]->Draw("APE");
    fit->SetLineColor(6);
    fit->Draw("same");
    lat.SetTextSize(0.1);
    sprintf(buf,"Single #gamma, #eta=2.1, 3#times3 cm^{2}");
    lat.DrawLatexNDC(0.2,0.8,buf);
    sprintf(buf,"ICsmear = %d %%",ICval[ic]);
    lat.DrawLatexNDC(0.2,0.7,buf);

    double cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2));
    constant->SetPoint(ic,ICval[ic]/100.,cval);
    constant->SetPointError(ic,0,fit->GetParameter(1)*fit->GetParError(1)/cval);
    noise->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(2));
    noise->SetPointError(ic,0,fit->GetParError(2));
    sampling->SetPoint(ic,ICval[ic]/100.,fit->GetParameter(0));
    sampling->SetPointError(ic,0,fit->GetParError(0));
    cval = sqrt(pow(fit7->GetParameter(1),2)-pow(y0_7,2));
    constantSR7->SetPoint(ic,ICval[ic]/100.,cval);
    constantSR7->SetPointError(ic,0,fit7->GetParameter(1)*fit7->GetParError(1)/cval);    
    //constantSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(1));
    //constantSR7->SetPointError(ic,0,fit7->GetParError(1));
    samplingSR7->SetPoint(ic,ICval[ic]/100.,fit7->GetParameter(0));
    samplingSR7->SetPointError(ic,0,fit7->GetParError(0));

    if (ic==0) {
      constant->GetPoint(0,x0,y0);
      constantSR7->GetPoint(0,x0_7,y0_7);
      cval = sqrt(pow(fit->GetParameter(1),2)-pow(y0,2));
      constant->SetPoint(ic,ICval[ic]/100.,cval);
//.........这里部分代码省略.........
开发者ID:J-C-Wright,项目名称:PFCal,代码行数:101,代码来源:plotResoVsIC.C

示例9: fitTime

void fitTime(float deltaT1,float deltaT2, float MIPcalib, float MIPcut, TString tag, TString title)
{
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(1111111);
  TCanvas* c1=new TCanvas("c1","c1",900,700);
  TChain *c=new TChain("H4treeReco");
  // c->Add("root://eoscms///eos/cms/store/caf/user/meridian/test/RECO_3353.root");
  // c->Add("root://eoscms///eos/cms/store/caf/user/meridian/test/RECO_3354.root");
  // c->Add("root://eoscms///eos/cms/store/caf/user/meridian/test/RECO_3355.root");
  // c->Add("root://eoscms///eos/cms/store/caf/user/meridian/test/RECO_3356.root");
  c->Add("root://eoscms///eos/cms/store/caf/user/meridian/test/RECO_3367.root");

  c->Draw(Form("(t_max_frac50[2]-t_max_frac50[1]+%4.3f)>>h1(100,-0.2,0.2)",deltaT1),Form("wave_max[1]>200 && wave_fit_smallw_ampl[2]>%3.1f*%3.1f",MIPcalib,MIPcut));
  c->Draw(Form("(t_max_frac50[3]-t_max_frac50[1]+%4.3f)>>h2(100,-0.2,0.2)",deltaT2),Form("wave_max[1]>200 && wave_fit_smallw_ampl[3]>%3.1f*%3.1f",MIPcalib,MIPcut));
  // c->Draw("(t_max_frac50[3]-t_max_frac50[1]+5.41)>>h2(100,-0.2,0.2)","wave_max[1]>200 && wave_fit_smallw_ampl[3]>41*20");
  // c->Draw("(t_max_frac50[2]-t_max_frac50[3]+0.155)>>h3(100,-0.2,0.2)","wave_fit_smallw_ampl[2]>41*20 && wave_fit_smallw_ampl[3]>41*20");
  c->Draw(Form("(t_max_frac50[2]-t_max_frac50[3]+%4.3f)>>h3(100,-0.2,0.2)",deltaT1-deltaT2),Form("wave_max[1]>200 && wave_fit_smallw_ampl[3]>%3.1f*%3.1f && wave_fit_smallw_ampl[2]>%3.1f*%3.1f",MIPcalib,MIPcut,MIPcalib,MIPcut));

  TLatex t;
  t.SetTextSize(0.04);
  TH1F* h1=(TH1F*)gROOT->FindObject("h1");
  h1->Sumw2();
  h1->SetMarkerStyle(20);
  h1->SetMarkerSize(0.3);
  h1->SetMarkerColor(kMagenta);
  h1->SetLineColor(kBlack);  
  h1->Fit("gaus");
  h1->GetXaxis()->SetTitle("#Delta_{t} Si_{1} - MCP (ns)");
  t.DrawLatexNDC(0.07,0.92,title);
  t.DrawLatexNDC(0.16,0.8,Form("Amplitude > %2.0f MIP",MIPcut));
  c1->SaveAs(Form("DeltaT_ch%d_MCP_%s.png",2,tag.Data()));

  TH1F* h2=(TH1F*)gROOT->FindObject("h2");
  h2->Sumw2();
  h2->SetMarkerStyle(20);
  h2->SetMarkerSize(0.3);
  h2->SetMarkerColor(kMagenta);
  h2->GetXaxis()->SetTitle("#Delta_{t} Si_{2} - MCP (ns)");
  h2->SetLineColor(kBlack);  
  h2->Fit("gaus");
  t.DrawLatexNDC(0.07,0.92,title);
  t.DrawLatexNDC(0.16,0.8,Form("Amplitude > %2.0f MIP",MIPcut));
  c1->SaveAs(Form("DeltaT_ch%d_MCP_%s.png",3,tag.Data()));

  TH1F* h3=(TH1F*)gROOT->FindObject("h3");
  h3->Sumw2();
  h3->SetMarkerStyle(20);
  h3->SetMarkerSize(0.3);
  h3->SetMarkerColor(kMagenta);
  h3->GetXaxis()->SetTitle("#Delta_{t} Si_{1} - Si_{2} (ns)");
  h3->SetLineColor(kBlack);  
  h3->Fit("gaus");
  t.DrawLatexNDC(0.07,0.92,"e- 50 GeV Si 320#mum p-type. 4 X_{0} lead");
  t.DrawLatexNDC(0.16,0.8,"Amplitude > 20 MIP");
  t.DrawLatexNDC(0.07,0.92,title);
  t.DrawLatexNDC(0.16,0.8,Form("Amplitude > %2.0f MIP",MIPcut));
  c1->SaveAs(Form("DeltaT_ch%d_ch%d_%s.png",2,3,tag.Data()));

  TF1* fRes=new TF1("fRes","TMath::Sqrt(([0]*[0])/(x*x)+([1]*[1]))",1,100);
  fRes->SetLineWidth(2);
  
  // c->Draw("(t_max_frac50[2]-t_max_frac50[1]+5.57):wave_fit_smallw_ampl[2]/41.>>h1_2(30,1,41,50,-0.2,0.2)","wave_max[1]>200 && wave_fit_smallw_ampl[2]>20");
  c->Draw(Form("(t_max_frac50[2]-t_max_frac50[1]+%4.3f):wave_fit_smallw_ampl[2]/%3.1f>>h1_2(30,1,41,50,-0.2,0.2)",deltaT1,MIPcalib),"wave_max[1]>200 && wave_fit_smallw_ampl[2]>20");
  TH2F* h1_2=(TH2F*)gROOT->FindObject("h1_2");
  h1_2->FitSlicesY();
  TH1F* h1_2_2=(TH1F*)gROOT->FindObject("h1_2_2");
  TH1F* h1_2_2_corr=(TH1F*)h1_2_2->Clone(h1_2_2->GetName()+TString("_corr"));
  for (int i=1;i<=h1_2_2_corr->GetNbinsX();++i)
    {
      if (h1_2_2->GetBinContent(i)>0.0221)
	{
	  h1_2_2_corr->SetBinContent(i,TMath::Sqrt(h1_2_2->GetBinContent(i)*h1_2_2->GetBinContent(i)-0.0221*0.0221));
	  h1_2_2_corr->SetBinError(i,TMath::Sqrt(h1_2_2->GetBinError(i)*h1_2_2->GetBinError(i)+0.003*0.003)); 
	}
      else
	{
	  h1_2_2_corr->SetBinContent(i,0.);
	  h1_2_2_corr->SetBinError(i,0.008);
	}
      //     std::cout << i << "," << h1_2_2_corr->GetBinContent(i) << "," << h1_2_2_corr->GetBinError(i) << std::endl;
    }
  h1_2_2_corr->Draw();
  h1_2_2_corr->Fit("fRes","R");
  h1_2_2_corr->SetMinimum(0.);
  h1_2_2_corr->SetMaximum(0.3);
  h1_2_2_corr->GetXaxis()->SetTitle("Signal amplitude (# MIP)");
  h1_2_2_corr->GetYaxis()->SetTitle("#sigma_{t} (ns)");
  h1_2_2_corr->SetMarkerStyle(20);
  h1_2_2_corr->SetMarkerSize(1.2);
  h1_2_2_corr->SetMarkerColor(kBlue);
  h1_2_2_corr->SetLineColor(kBlack);
  t.DrawLatexNDC(0.12,0.92,title);
  t.DrawLatexNDC(0.12,0.82,"#sigma_{MCP}=22.1ps subtracted");
  c1->SaveAs(Form("DeltaT_vs_Ampl_ch%d_MCP_%s.png",2,tag.Data()));


  c->Draw(Form("(t_max_frac50[3]-t_max_frac50[1]+%4.3f):wave_fit_smallw_ampl[3]/%3.1f>>h2_2(30,1,41,50,-0.2,0.2)",deltaT2,MIPcalib),"wave_max[1]>200 && wave_fit_smallw_ampl[3]>20");
  TH2F* h2_2=(TH2F*)gROOT->FindObject("h2_2");
  h2_2->FitSlicesY();
//.........这里部分代码省略.........
开发者ID:PFCal-dev,项目名称:FastTimeTestBeamAnalysis,代码行数:101,代码来源:fitTime.C

示例10: logWeightingScanAll


//.........这里部分代码省略.........
	      double y = 0;//10*(wy[2][iS]-wy[0][iS])/wy[3][iS];
	      if (wy[5][iS]!=0) {
		if (iL>22) y = 10*(2*wy[4][iS]+wy[3][iS]-wy[1][iS]-2*wy[0][iS])/wy[5][iS];
		else y = 10*(wy[2][iS]-wy[0][iS])/wy[5][iS];
	      }

	      //if (fabs(y-yt)>5) std::cout << " --- iL=" << iL << " iS=" << iS 
	      //<< " x=" << x << " xt=" << xt 
	      //<< " y=" << y << " yt=" << yt 
	      //<< std::endl;
	      p_posx[ipu][iL][iS]->Fill(x-xt);
	      p_posy[ipu][iL][iS]->Fill(y-yt);
	    }

	  }//loop on layers
	  if (savePoint) p_intercalibSigmaSquare[ipu]->Fill(Etotsq);
	}//loop on entries
    
      }//loop on pt

      //fill first point with linear weighting
      TLatex lat;
      char buf[500];

      for (unsigned iL(0);iL<nLayers;++iL){
	mycFit->cd();
	TH1D *projy = p_deltavsreco_x[ipu][iL]->ProjectionY();
	projy->Draw();
	projy->Fit("gaus","0+Q");
	TF1 *fitx = projy->GetFunction("gaus");
	fitx->SetLineColor(6);
	fitx->Draw("same");
	sprintf(buf,"Layer %d, linear weighting, pu=%d",iL,pu[ipu]);
	lat.DrawLatexNDC(0.1,0.96,buf);
	
	grX[ipu][iL]->SetPoint(0,0.5,fitx->GetParameter(2));
	grX[ipu][iL]->SetPointError(0,0,fitx->GetParError(2));
	grXrms[ipu][iL]->SetPoint(0,0.5,projy->GetRMS());
	grXrms[ipu][iL]->SetPointError(0,0,projy->GetRMSError());
	mycFit->Update();
	if (savePoint) mycFit->Print("PLOTS/fits_x.pdf");
	
	mycFit->cd();
	projy = p_deltavsreco_y[ipu][iL]->ProjectionY();
	projy->Draw();
	projy->Fit("gaus","0+Q");
	TF1 *fity = projy->GetFunction("gaus");
	fitx->SetLineColor(6);
	fitx->Draw("same");
	sprintf(buf,"Layer %d, linear weighting, pu=%d",iL,pu[ipu]);
	lat.DrawLatexNDC(0.1,0.96,buf);
	
	grY[ipu][iL]->SetPoint(0,0.5,fity->GetParameter(2));
	grY[ipu][iL]->SetPointError(0,0,fity->GetParError(2));
	grYrms[ipu][iL]->SetPoint(0,0.5,projy->GetRMS());
	grYrms[ipu][iL]->SetPointError(0,0,projy->GetRMSError());
	mycFit->Update();
	if (savePoint) mycFit->Print("PLOTS/fits_y.pdf");
      }

      //fit vs w0, get w0min
      for (unsigned iL(0);iL<nLayers;++iL){
	for (unsigned iS(0); iS<nScans;++iS){
	  mycFit->cd();
	  p_posx[ipu][iL][iS]->Draw();
	  double w0 = wStart+iS*wStep;
开发者ID:J-C-Wright,项目名称:PFCal,代码行数:67,代码来源:logWeightingScanAll.C

示例11: EvtDisplay


//.........这里部分代码省略.........
      //p_slice[iS]->SetLineColor(iS+1);
      //p_slice[iS]->SetFillColor(iS+1);
      //p_slice[iS]->SetMarkerStyle(7);
      p_slice[iS]->GetXaxis()->SetRangeUser(minZ,maxZ);
      p_slice[iS]->GetYaxis()->SetRangeUser(minX[ievt],maxX[ievt]);
      p_slice[iS]->GetZaxis()->SetRangeUser(minY[ievt],maxY[ievt]);
    
      p_slice[iS]->GetXaxis()->SetLabelSize(0.05);
      p_slice[iS]->GetYaxis()->SetLabelSize(0.05);
      p_slice[iS]->GetZaxis()->SetLabelSize(0.05);
      p_slice[iS]->GetXaxis()->SetTitleSize(0.05);
      p_slice[iS]->GetYaxis()->SetTitleSize(0.05);
      p_slice[iS]->GetZaxis()->SetTitleSize(0.05);
      p_slice[iS]->SetTitle(ltitle.str().c_str());

      //val[iS]= exp(iS*log(p_xyz->GetMaximum())/nSlices);
    }

    //val[nSlices] = p_xyz->GetMaximum();

    double lmin = 10;
    double lmax = p_xyz->GetBinContent(1,1,1);

    for (int xb(1); xb<p_xyz->GetNbinsX()+1;++xb){
      //std::cout << "--- xb=" << xb << "" << std::endl;
      for (int yb(1); yb<p_xyz->GetNbinsY()+1;++yb){
	double xTmp = p_xyz->GetYaxis()->GetBinCenter(yb);
	for (int zb(1); zb<p_xyz->GetNbinsZ()+1;++zb){
	  double yTmp = p_xyz->GetZaxis()->GetBinCenter(zb);
	  double radius = sqrt(yTmp*yTmp+xTmp*xTmp);
	  if (radius < minRadius){
	    p_xyz->SetBinContent(xb,yb,zb,0);
	    continue;
	  }
	  double ltmp = p_xyz->GetBinContent(xb,yb,zb);
	  if (ltmp<lmin && ltmp>0) lmin=ltmp;
	  if (ltmp>lmax) lmax=ltmp;

	  if (ltmp<1) continue;
	  //std::cout << xb << " " << yb << " " << zb << " " << p_xyz->GetBinContent(xb,yb,zb) << std::endl;
	  if (ltmp < mipThresh) {
		  p_xyz->SetBinContent(xb,yb,zb,0);
	  }
	  else {
	    p_xyz->SetBinContent(xb,yb,zb,ltmp);
	    for (unsigned iS(0); iS<nSlices; ++iS){
	      if (ltmp<=val[iS+1] && ltmp>val[iS])
		p_slice[iS]->SetBinContent(xb,yb,zb,ltmp);
	    }
	  }
	}
      }
    }

    std::cout << " --min and max by hand = " 
	      << lmin << " " 
	      << lmax 
	      << std::endl;

    gStyle->SetOptStat(0);

    myc[ievt]->cd();
    //TPad *pad1 = new TPad("pad1","This is pad1",0.01,0.01,0.83,0.99);
    //pad1->Draw();
    //pad1->cd();    
    //myc[ievt]->cd(1);
    for (unsigned iS(0); iS<nSlices; ++iS){
      std::cout << " -- slice " << iS << std::endl;
      //set artificially the boundaries: min and max in dummy bins
      //p_slice[iS]->SetBinContent(1,1,1,1);
      //p_slice[iS]->SetBinContent(2,1,1,lmax);
      p_slice[iS]->Draw(iS==0? "" : "same");
    }
    //myc[ievt]->cd(2);
    //TPad *pad2 = new TPad("pad2","This is pad2",0.85,0.01,0.99,0.99);
    //pad2->Draw();
    //pad2->cd();
    TLatex lat;
    lat.SetTextAlign(31);
    //lat.SetTextSize(0.2);
    for (unsigned iS(0); iS<nSlices; iS++){
      //std::cout << iS << std::endl;
      char buf[500];
      sprintf(buf,"%3.1f < Mips < %3.1f",val[iS],val[iS+1]);
      lat.SetTextColor(lColor[iS]);
      lat.DrawLatexNDC(1.,(iS*1.0/nSlices)/2.+0.5,buf);
    }

    myc[ievt]->Update();
    saveName.str("");
    saveName << plotDir << "/evtDisplay_evt" << event[ievt] << "_mipThresh" << mipThresh;
    myc[ievt]->Print((saveName.str()+".png").c_str());
    myc[ievt]->Print((saveName.str()+".pdf").c_str());
    
  }//loop on events

  return 0;
  
  
}//main
开发者ID:xu0724,项目名称:PFCal,代码行数:101,代码来源:EvtDisplay.C

示例12: plotEmissed


//.........这里部分代码省略.........
	      err = sqrt(err);*/
	      maxNhit[iH]->SetBinContent(bin,integral/inttot);
	      maxNhit[iH]->SetBinError(bin,err/inttot);
	    }
	  }
	}

      mycL->cd();
      TLegend *leg = new TLegend(0.66,0.66,0.89,0.89);
      leg->SetFillColor(10);
      for (unsigned iH(0); iH<nHists;++iH){
	gStyle->SetOptStat(0);
	myc->cd();
	gPad->SetLogy(1);
	gStyle->SetStatX(0.89);
	gStyle->SetStatY(0.89);
	gStyle->SetStatH(0.5);
	gStyle->SetStatW(0.3);
	//maxNhit[iH]->Rebin(genEn[iE]>500? 20*iE : (iE>0?2*iE:1));
	maxNhit[iH]->GetXaxis()->SetRange(maxNhit[iH]->FindFirstBinAbove(0),maxNhit[iH]->FindLastBinAbove(0));
	//maxNhit[iH]->SetTitle(";#hits with E_{hit} > E^{avg}_{max};Events");
	//maxNhit[iH]->SetTitle(";#hits with E_{hit} > E^{avg}_{max};Events");
	maxNhit[iH]->SetLineColor(iH+1);
	maxNhit[iH]->SetMarkerColor(iH+1);
	maxNhit[iH]->SetMarkerStyle(iH+21);

	//maxNhit[iH]->Rebin(2);
	maxNhit[iH]->Draw();
	
	//sprintf(buf,"Maximum = %3.0f MIPs",maxNhit[iH]->GetXaxis()->GetBinCenter(maxNhit[iH]->FindLastBinAbove(0)));
	lat.SetTextSize(0.05);
	//lat.DrawLatexNDC(0.12,0.85,buf);
	sprintf(buf,"%s #mu m Si",pSuffix.c_str());
	lat.DrawLatexNDC(0.12,0.75,buf);
	//sprintf(buf,"Geant4 Standalone, e-, pad size = %s",label[iH].c_str());
	//if (nGenEn==1) 
	sprintf(buf,"Geant4 Standalone, e- %d GeV, pad size = %s",genEn[iE], label[iH].c_str());
	lat.DrawLatexNDC(0.1,0.92,buf);
	
	std::ostringstream lsave;
	lsave << plotDir << pSuffix << "um/" << basename << label[iH];
	//if (nGenEn==1) 
	lsave << "e" << genEn[iE];
	if (integrate) lsave << "_int";
	lsave << ".pdf";
	myc->Print(lsave.str().c_str());

	mycL->cd(iE+1);
	gPad->SetLogy(1);
	gPad->SetGridx();
	gPad->SetGridy();
	maxNhit[iH]->GetYaxis()->SetTitle("Event fraction");
	maxNhit[iH]->GetXaxis()->SetTitle("#frac{E_{missed}}{E_{tot}}");
	//maxNhit[iH]->DrawNormalized(iH==0?"PE":"PEsame");
	maxNhit[iH]->Sumw2();
	if (!integrate && maxNhit[iH]->GetEntries()>0) maxNhit[iH]->Scale(1./maxNhit[iH]->GetEntries());
	maxNhit[iH]->SetMaximum(1);
	maxNhit[iH]->SetMinimum(0.0001);
	maxNhit[iH]->GetXaxis()->SetRangeUser(0,0.6);
	maxNhit[iH]->Draw(iH==0?"PE":"PEsame");
	leg->AddEntry(maxNhit[iH],label[iH].c_str(),"P");
	lat.SetTextSize(0.05);
	//sprintf(buf,"Maximum = %3.0f MIPs",maxNhit[iH]->GetXaxis()->GetBinCenter(maxNhit[iH]->FindLastBinAbove(0)));
	//lat.DrawLatexNDC(0.2,0.8,buf);
	if (iH==0){
	  //sprintf(buf,"%s #mu m Si",pSuffix.c_str());
开发者ID:J-C-Wright,项目名称:PFCal,代码行数:67,代码来源:plotEmissed.C

示例13: plotHist

void plotHist() {

  gROOT->ProcessLine(".L tdrstyle.C");
  setTDRStyle();

  // names and such
  string inDir, inFile01, inFile02, inFile03, inFile04, outFile, numHist, denHist, proc;

  inDir = "/home/ieeya/Downloads/HLT_Val/Part2_OpenHLT/OpenHLT/logs/run02/ttbar_skim/e_740/turnOn_phys14/drawVar_v1/";

  // specify input and output files, 01 is numerator, 02 is denominator
  // same for 03, 04 etc

  proc = "dye";

  inFile01 = inDir + "dye_tID.root";
  inFile02 = inDir + "dye_eID.root";

  inFile03 = inDir + "wev_tID.root";
  inFile04 = inDir + "wev_eID.root";

  numHist = "drawHist/ptElectron_match";
  denHist = "drawHist/ptElectron_gsf";

  TFile *inPut01 = new TFile(inFile01.c_str());
  TFile *inPut02 = new TFile(inFile02.c_str());

  TFile *inPut03 = new TFile(inFile03.c_str());
  TFile *inPut04 = new TFile(inFile04.c_str());

  const Int_t nBin = 25; //25
  //Double_t ptBins[nBin + 1] = {0., 5., 10., 15., 20., 25., 30., 32., 34., 36., 38., 40., 42., 44., 46., 48., 50., 55., 60., 70., 80., 90., 110., 130., 150., 200.};
  Double_t ptBins[nBin + 1] = {0., 5., 10., 15., 20., 25., 30., 32., 34., 36., 38., 40., 42., 44., 46., 48., 50., 55., 60., 70., 80., 90., 110., 130., 150., 200.};
  //Double_t ptBins[nBin + 1] = {20., 25., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 52., 54., 56., 58., 60., 62., 64., 66., 68., 70., 75., 80., 85., 90., 95., 100., 110., 120., 130., 140., 150., 175., 200.};

  // create the histograms
  TH1::SetDefaultSumw2(true);

  TH1D *inNum01 = dynamic_cast<TH1D *>(inPut01->Get(numHist.c_str()));
  //TH1D *reNum01 = (TH1D*) inNum01->Rebin(nBin, "reNum01", ptBins);

  TH1D *inDen01 = dynamic_cast<TH1D *>(inPut02->Get(denHist.c_str()));
  //TH1D *reDen01 = (TH1D*) inDen01->Rebin(nBin, "reDen01", ptBins);

  TH1D *inNum02 = dynamic_cast<TH1D *>(inPut03->Get(numHist.c_str()));
  //TH1D *reNum02 = (TH1D*) inNum02->Rebin(nBin, "reNum02", ptBins);

  TH1D *inDen02 = dynamic_cast<TH1D *>(inPut04->Get(denHist.c_str()));
  //TH1D *reDen02 = (TH1D*) inDen01->Rebin(nBin, "reDen02", ptBins);

  Double_t yMin = 0., yMax = 1.13;

  // bins etc is still manual
  TH1D *outEff01 = new TH1D("effElectron01", "Single Electron Turn On for 32 GeV Online Cut", nBin, ptBins);
  outEff01->SetXTitle("Electron p_{T} (GeV/c)");
  outEff01->SetYTitle("Efficiency");
  outEff01->SetLineColor(kAzure - 1);
  outEff01->SetLineWidth(3);

  outEff01->Divide(inNum01, inDen01, 1., 1., "B");
  outEff01->SetMinimum(yMin);
  outEff01->SetMaximum(yMax);

  TH1D *outEff02 = new TH1D("effElectron02", "720p8 WP75 Electron eff vs p_{T}", nBin, ptBins);
  outEff02->SetXTitle("Electron p_{T} (GeV/c)");
  outEff02->SetYTitle("Efficiency");
  outEff02->SetLineColor(kRed + 1);
  outEff02->SetLineWidth(3);

  //outEff02->Divide(reNum02, reDen02, 1., 1., "B");
  outEff02->SetMinimum(yMin);
  outEff02->SetMaximum(yMax);

  TCanvas *c01 = new TCanvas("c01", "c01", 200, 10, 1000, 1000);
  c01->cd();
  c01->SetGrid();

  outEff01->Draw("CL");
  //outEff02->Draw("same");

  TLatex txt;
  txt.SetTextSize(0.03);
  txt.SetTextAlign(13);
  txt.DrawLatexNDC(0.1, 0.87, "#bf{CMS}");
  txt.DrawLatexNDC(0.1, 0.84, "#it{Simulation Preliminary}");
  txt.DrawLatexNDC(0.808, 0.927, "2015, 13 TeV");

  TLegend *leg01 = new TLegend(.76, .75, .94, .93);
  leg01->SetHeader("L1 Seed");
  leg01->AddEntry(outEff01, "L1_SingleIsoEG30er");
  leg01->AddEntry(outEff02, "L1_SingleEG30");
  //leg01->Draw();

  c01->SaveAs((inDir + proc + "_turnOn.pdf").c_str());
  c01->Close();

}
开发者ID:nurnuha,项目名称:hltStuff,代码行数:97,代码来源:plotHist.cpp

示例14: derivefromNS

void derivefromNS(bool data = false)
{
  // float shift = mode == 2 ? -2 : mode*2; //mode = 0,1,2 shift = 0,2,-2
  // cout<<"shift = "<<shift<<endl;

  auto file = config.getfile_djt(data ? "dtPbjcl" : "mcPbqcd");
  auto nt = (TTree *)file->Get("nt");

  for (unsigned i=1;i<binbounds.size();i++) {
    int b1 = binbounds[i-1];
    int b2 = binbounds[i];
    seth(71,38,180); //71,38
    auto h = geth(Form("h%d%d",b1,b2)); //allowing one more bin for overflow
    seth(b2-b1,b1,b2);
    auto hb = geth(Form("hb%d%d",b1,b2));

   
    TString mcappendix = data ? "" : "&& pthat>50";//"&& subid2!=0 && pthat>50"; //"&& pthat>50";//"&& !(subid2==0 && refpt2>20) && pthat>50"; //"&& pthat>80";//
   
    //Form("jtpt2+%f",shift)
    nt->Project(h->GetName(),"jtpt2", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data()));
    nt->Project(hb->GetName(),"bin", Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphi21<1.05 %s)",b1,b2,mcappendix.Data()));

    ScaleVisibleBins(h,NSfrac[i-1]);

    h->SetBinContent(1,h->GetBinContent(0)+h->GetBinContent(1));

    // auto p = new TProfile(Form("p%d%d",b1,b2),Form("prof"),71,38,180);
    // nt->Project(p->GetName(),"(subid2 == 0 && refpt2 > 20):jtptSignal2",Form("weight*(jtpt1>100&&bin>=%d && bin<%d && dphiSignal21<1.05 && !(subid2==0 && refpt2>20) && pthat>80)",b1,b2));


    auto g = getCDFgraph(h);
    g->GetXaxis()->SetTitle("p_{T,2} threshold [GeV]");
    g->GetYaxis()->SetTitle("found fraction");

    auto gtemp = getCDFgraph(h);
    meanb.push_back(hb->GetMean());
    prob.push_back(gtemp->Eval(pt));

    float c0=g->Eval(50);
    cout<<"prob at 50: "<<c0<<endl;

    auto gf = new TFile("graph.root","recreate");
    gtemp->Write();
    gf->Close();

    // auto f = new TF1(Form("f%d%d",b1,b2),"1-[0]*exp(-[1]*(x-40))",40,180);
    // f->SetParameters(0.1,0.1);
    // // f->FixParameter(1,0.08);

    // auto f = new TF1(Form("f%d%d",b1,b2),"TMath::Erf((x-[0])/[1])",40,180);
    // f->SetParameters(40,10);
    // f->FixParameter(1,25);

    auto f = new TF1(Form("f%d%d",b1,b2),"exp(-[0]*exp(-[1]*x))",40,180);
    f->SetParameters(100,0.1);
    // f->FixParameter(1,0.11); //!!!!!!!!!!

    f->SetLineColor(kRed);
    f->SetLineWidth(2);
    g->Fit(f,"RM");
    fs.push_back(f);
    binmean.push_back(hb->GetMean());

    float median = -1/f->GetParameter(1)*log(-1/f->GetParameter(0)*log(0.5));

    Draw({h});

    // h->Rebin(2);
    auto gcoarse = getCDFgraph(h);

    auto c = getc();
          TLatex *Tl = new TLatex();
    gcoarse->SetMinimum(0);g->SetMaximum(1);
    gcoarse->Draw("AP");
    f->Draw("same");
    Tl->DrawLatexNDC(0.6,0.55,"y=e^{-a e^{-b x} }");
    Tl->DrawLatexNDC(0.6,0.50,Form("a = %.1f",f->GetParameter(0)));
    Tl->DrawLatexNDC(0.6,0.45,Form("b = %.2f",f->GetParameter(1)));
    Tl->DrawLatexNDC(0.6,0.4,Form("PbPb bin %d-%d",b1,b2));
    Tl->DrawLatexNDC(0.6,0.35,Form("median = %.2f",median));

    TLine *l1 = new TLine(median,0,median, f->Eval(median));
    l1->Draw();
    TLine *l2 = new TLine(0,0.5,median, f->Eval(median));
    l2->Draw();

    // p->SetMarkerColor(kRed);
    // p->SetMarkerSize(1);
    // p->Draw("same");
    SavePlot(c,Form("fit%d%d",b1,b2));//return;
  }

}
开发者ID:bjet2015,项目名称:dibjets,代码行数:94,代码来源:eclipsederive.C

示例15: findtruthpp

void findtruthpp()
{
  seth(10,0,1);
  auto hmcppxJTrue = geth("hmcppxJTrue","true;x_{J};Event fractions");
  auto hmcppxJTrueTag = geth("hmcppxJTrueTag","true tagged;x_{J};Event fractions");
  auto hmcppxJTrueTagCorr = geth("hmcppxJTrueTagCorr","true tagged corrected;x_{J};Event fractions");

  TFile *fmcpp = new TFile(config.getFileName_djt("mcppbfa"));
  Fill(fmcpp,[&] (dict &m) {
    if (m["pthat"]<pthatcut) return;
    if (m[pairCodeSB1]!=0) return;
    // if (m["pthat"]<80) return;
    
    // if (m["bProdCode"]!=1) return;
    float w = m["weight"]*processweight((int)m["bProdCode"]);

    // float w = m["weight"];
    // if (m["bProdCode"]==2) return;

    float corr = tageffcorrectionpp(m["jtpt1"],m["jteta1"],m[jtptSB],m[jtetaSB]);
    float wb = w*corr;

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23)
      hmcppxJTrue->Fill(m[jtptSB]/m["jtpt1"],w);

    if (m["jtpt1"]>pt1cut && m["refpt1"]>50 && abs(m["refparton_flavorForB1"])==5 && m[jtptSB]>pt2cut && m[dphiSB1]>PI23
        && m["discr_csvV1_1"]>0.9 && m[discr_csvV1_SB]>0.9) {
      hmcppxJTrueTag->Fill(m[jtptSB]/m["jtpt1"],w);
      hmcppxJTrueTagCorr->Fill(m[jtptSB]/m["jtpt1"],wb);
    }


  });

  NormalizeAllHists();
  plotputmean = true;
  plotytitle = "Event fractions";
  plotdivide = false;
  // aktstring += "R=0.4 |#eta|<2.0";
  // plotsecondline = Form("p_{T,1}>%d GeV, p_{T,2}>%d GeV", (int)pt1cut, (int)pt2cut);
  // plotthirdline = "#Delta#phi>2/3#pi";
  plottextposy = 0.8;
  plottextposx = 0.2;

  plotmeanposy = 0.43;
  plotymax = 0.2;
  plotymin = 0;
  plotlegendpos = BottomRight;//TopLeft;
  
  aktstring = "pp";
  SetMC({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});
  SetData({hmcppxJTrue});
  Draw({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  hmcppxJTrue->SetMinimum(0);
  hmcppxJTrue->SetMaximum(0.3);
  hmcppxJTrue->SetLineWidth(2);
  hmcppxJTrue->SetMarkerStyle(kNone);
  hmcppxJTrue->SetFillStyle(0);

  hmcppxJTrueTag->SetMarkerStyle(kOpenCircle);
  hmcppxJTrueTagCorr->SetMarkerStyle(kOpenSquare);


  plotymax = 0.3;

  SetB({hmcppxJTrue,hmcppxJTrueTag,hmcppxJTrueTagCorr});


  float xjtrue = hmcppxJTrue->GetMean();
  float xjtruetag = hmcppxJTrueTag->GetMean();
  float xjtruetagcorr = hmcppxJTrueTagCorr->GetMean();

  float exjtrue = hmcppxJTrue->GetMeanError();
  float exjtruetag = hmcppxJTrueTag->GetMeanError();
  float exjtruetagcorr = hmcppxJTrueTagCorr->GetMeanError();

  auto c = getc();
  hmcppxJTrue->Draw("hist");
  hmcppxJTrueTag->Draw("E1,same");
  hmcppxJTrueTagCorr->Draw("E1,same");

  plotlegendpos = TopLeft;
  auto l = getLegend();
  l->AddEntry(hmcppxJTrue,Form("b-dijets, #LTx_{J}#GT=%.3f#pm%.3f",xjtrue,exjtrue),"L");
  l->AddEntry(hmcppxJTrueTag,Form("uncorrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetag,exjtruetag),"P");
  l->AddEntry(hmcppxJTrueTagCorr,Form("corrected, #LTx_{J}#GT=%.3f#pm%.3f",xjtruetagcorr,exjtruetagcorr),"P");
  l->Draw();
  TLatex *Tl = new TLatex();
  Tl->DrawLatexNDC(0.2, 0.8, aktstring);
  SavePlot(c,"closurepp");
}
开发者ID:bjet2015,项目名称:dibjets,代码行数:93,代码来源:tageffcorr.C


注:本文中的TLatex::DrawLatexNDC方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。