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


C++ TF1::Eval方法代码示例

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


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

示例1: vncent_sys_ratio


//.........这里部分代码省略.........
      leg2->AddEntry(ge,"eff.(-2%)/Default","pl");
    }
    for (int im=0;im<1;im++)
    { 
      int j=im*5+iw;
      int col=4;
      //if (ndp[j]==0) continue;
      geB=new TGraphErrors(10,&nBRxa[j][0],&nBRya[j][0],&nBRxe[j][0],&nBRye[j][0]);
      ///drawSysBoxValue(ge,16,1.6, ye5sys[j]);
      //drawSysBox(ge,16,2., sysXYZ[j]);
      geB->SetTitle("");
      geB->SetMarkerStyle(25);
      //      ge->SetMarkerStyle(msty[im]);
      geB->SetMarkerSize(msiz[im]);
      geB->SetMarkerColor(col);
      geB->SetLineWidth(1.2);
      geB->SetLineColor(col);
      //ge->Draw("pe");
      leg2->AddEntry(geB,"eff.(+2%)/Default","pl");
    }
    ge->Draw("pe");
    geB->Draw("pe");
    if (iw==2) leg2->Draw();

    TLine *lines = new TLine(0,1,60,1);
    lines->SetLineStyle(2);
    lines->SetLineWidth(1); 
    lines->Draw();

if(iw==0||iw==1){
    TF1 *fitFun = new TF1("fitFun","pol2", 0, 60);
    fitFun->SetLineColor(4);
    geB->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(2.5)<<",  "<<fitFun->Eval(7.5)<<",  "<<fitFun->Eval(45)<<",  "<<fitFun->Eval(55)<<endl;
}
else {
    TF1 *fitFun = new TF1("fitFun","pol0", 0, 60);
    fitFun->SetLineColor(4);
    geB->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(2.5)<<",  "<<fitFun->Eval(7.5)<<",  "<<fitFun->Eval(45)<<",  "<<fitFun->Eval(55)<<endl;
}

    double chi2 = fitFun->GetChisquare();
    double ndf = fitFun->GetNDF();
   TLatex *tex = new TLatex(10.06,0.6,Form("#chi^{2}/ndf = %2.1f", chi2/ndf));
   //tex->SetNDC();
   //tex->SetTextFont(42);
   tex->SetTextColor(4);
   tex->SetTextSize(16);
   //tex->SetLineWidth(2);
   tex->Draw("same");

   //TLatex *text = new TLatex();
   //text->DrawTextNDC(10.12, 1.14, "D0 Preliminary");

/*
    double p0 = fitFun->GetParameter(0);
    double p0Err = fitFun->GetParError(0);
    TLine *linesErrP = new TLine(0,p0+p0Err,60,p0+p0Err);
    linesErrP->SetLineStyle(2);
    linesErrP->SetLineWidth(1);
    linesErrP->SetLineColor(2);
    linesErrP->Draw();
    TLine *linesErrM = new TLine(0,p0-p0Err,60,p0-p0Err);
    linesErrM->SetLineStyle(2);
    linesErrM->SetLineWidth(1);
    linesErrM->SetLineColor(2);
    linesErrM->Draw();
*/
  }
//end new

   can->cd();
   TLatex *   tex = new TLatex(0.06,0.97,"CMS");
   tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.034);
   tex->SetLineWidth(2);
   tex->Draw();
   TLatex *   tex = new TLatex(0.108,0.97,"Preliminary");
   tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.044);
   tex->SetLineWidth(2);
   //tex->Draw();
   TLatex *   tex = new TLatex(0.24,0.970,"0.3<p_{T}<3.0 GeV/c         |#eta|<0.8");
   tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.044);
   tex->SetLineWidth(2);
   tex->Draw();

  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/plot_vncent_esSys_ratio.png");
  can->Print("./figures/plot_vncent_esSys_ratio.pdf");

}
开发者ID:tuos,项目名称:FlowAndCorrelations,代码行数:101,代码来源:vncent_sys_ratio.C

示例2: softrad


//.........这里部分代码省略.........
	  tex->DrawLatex(0.55,0.27-0.045*isample,
			 Form("#chi^{2}/NDF = %1.1f / %d",
			      fk->GetChisquare(), fk->GetNDF()));
	  tex->SetTextColor(kBlack);

	  // Error band
	  const int n = fk->GetNpar();
	  TMatrixD emat(n,n);
	  gMinuit->mnemat(emat.GetMatrixArray(), n);
	  TF1 *fke = new TF1(Form("fk_%s_%s_%s",ct,cm,cs),
			     sr_fitError, 30, 1300, 1);
	  _sr_fitError_func = fk;
	  _sr_fitError_emat = &emat;

	  fke->SetLineStyle(kSolid);
	  fke->SetLineColor(fk->GetLineColor()-10);
	  fke->SetParameter(0,-1);
	  fke->DrawClone("SAME");
	  fke->SetParameter(0,+1);
	  fke->DrawClone("SAME");

	  fk->DrawClone("SAME");
	  gk->DrawClone("SAME Pz");

	  // Store soft radiation corrections in fsr subdirectory
	  assert(fin->cd(ct));
	  assert(gDirectory->cd(bin));
	  if (!gDirectory->FindObject("fsr")) gDirectory->mkdir("fsr");
	  assert(gDirectory->cd("fsr"));

	  TH1D *hk = (TH1D*)(isample==0 ? hpt2->Clone() : hpt1->Clone());
	  hk->SetName(Form("hkfsr_%s_%s",cm,cs));
	  TProfile *ppt = (isample==0 ? ppt2 : ppt1);
	  if (isample==3) { ppt = ppt4; } // pas-v6
	  for (int i = 1; i != hk->GetNbinsX()+1; ++i) {
	    double pt = ppt->GetBinContent(i);
	    if (pt>30 && pt<1300) {
	      hk->SetBinContent(i, fk->Eval(pt));
	      hk->SetBinError(i, fabs(fke->Eval(pt)-fk->Eval(pt)));
	    }
	    else {
	      hk->SetBinContent(i, 0);
	      hk->SetBinError(i, 0);
	    }
	  }
	  
	  hk->Write(hk->GetName(), TObject::kOverwrite);

	  // Factorize error matrix into eigenvectors
	  // Remember: A = Q*Lambda*Q^-1, where
	  // A is emat, Q is eigmat, and Lambda is a diagonal matrix with
	  // eigenvalues from eigvec on the diagonal. For eigenmatrix
	  // Q^-1 = Q^T, i.e. inverse matrix is the original transposed
	  TVectorD eigvec(n);
	  TMatrixD eigmat = emat.EigenVectors(eigvec);

	  // Eigenvectors are the columns and sum of eigenvectors squared
	  // equals original uncertainty. Calculate histograms from the
	  // eigenvectors and store them
	  TF1 *fkeig = (TF1*)fk->Clone(Form("%s_eig",fk->GetName()));
	  fkeig->SetLineStyle(kDotted);
	  for (int ieig = 0; ieig != n; ++ieig) {

	    // Eigenvector functions
	    for (int i = 0; i != n; ++i) {
	      fkeig->SetParameter(i, fk->GetParameter(i)
				  + eigmat[i][ieig] * sqrt(eigvec[ieig]));
	    }
	    fkeig->DrawClone("SAMEL");

	    // Eigenvector histograms evaluated at bin mean pT
	    TH1D *hke = (TH1D*)hk->Clone(Form("%s_eig%d",hk->GetName(),ieig));
	    hke->Reset();

	    for (int i = 0; i != gk->GetN(); ++i) {

	      double pt = gk->GetX()[i];
	      int ipt = hke->FindBin(pt);
	      // Need to store central value as well, because
	      // uncertainty sources are signed
	      hke->SetBinContent(ipt, fkeig->Eval(pt)-fk->Eval(pt));
	      hke->SetBinError(ipt, fabs(fkeig->Eval(pt)-fk->Eval(pt)));
	    }
	    hke->Write(hke->GetName(), TObject::kOverwrite);
	  }

	  cout << "." << flush;
	} // if tree
      } // for isample
    } // for imethod
  } // for itype
  
  c3->cd(0);
  //cmsPrel(_lumi, true);
  CMS_lumi(c3, 2, 33);
  c3->SaveAs("pdf/softrad_2x6_kfsr.pdf");

  fin->Close();
  curdir->cd();
} // softrad
开发者ID:cihar29,项目名称:jecsys,代码行数:101,代码来源:softrad.C

示例3: makeTrees_MuTau


//.........这里部分代码省略.........
    ptVeto  = (veto>=0) ? (*jets)[veto].Pt() : -99;
    etaVeto = (veto>=0) ? (*jets)[veto].Eta(): -99;
    phiVeto = (veto>=0) ? (*jets)[veto].Phi(): -99;
 
    isVetoInJets = 0;
    for(int l = 0 ; l < indexes.size() ; l++){
      if(lead>=0 && trail>=0 && (l!= lead && l!= trail) &&
	 (*jets)[indexes[l]].Pt()>PtVETO && ((*jets)[indexes[l]].Eta() - eta1)*((*jets)[indexes[l]].Eta() - eta2)<=0 )
	isVetoInJets = 1;
    }

    diTauSVFitMass = (*diTauSVfitP4)[0].M();
    diTauVisMass   = (*diTauVisP4)[0].M();
    diTauVisPt     = (*diTauVisP4)[0].Pt();
    diTauVisEta    = (*diTauVisP4)[0].Eta();
    diTauVisPhi    = (*diTauVisP4)[0].Phi();
    
    ptL1     = (*diTauLegsP4)[0].Pt();
    ptL2     = (*diTauLegsP4)[1].Pt();
    etaL1    = (*diTauLegsP4)[0].Eta();
    etaL2    = (*diTauLegsP4)[1].Eta();
    phiL1    = (*diTauLegsP4)[0].Phi();
    phiL2    = (*diTauLegsP4)[1].Phi();
    dPhiL1L2 =  abs((*diTauLegsP4)[0].Phi()-(*diTauLegsP4)[1].Phi()) > TMath::Pi() ? 
      -abs( (*diTauLegsP4)[0].Phi()-(*diTauLegsP4)[1].Phi() ) + 2*TMath::Pi()  :
      abs( (*diTauLegsP4)[0].Phi()-(*diTauLegsP4)[1].Phi() ) ;

    diTauCharge_    = diTauCharge;
    
    

    ////////////////////////////////////////////////////////////////////

    float scalarSumPt     = ( *diTauLegsP4)[0].Pt() + (*METP4)[0].Pt();
    float vectorSumPt     = ((*diTauLegsP4)[0] +      (*METP4)[0]).Pt() ;

    MtLeg1_     = TMath::Sqrt( scalarSumPt*scalarSumPt - vectorSumPt*vectorSumPt ) ;
    MEt     = (*METP4)[0].Et();
    combRelIsoLeg1DBeta    = (chIsoLeg1+ std::max( nhIsoLeg1+phIsoLeg1-0.5*(nhIsoPULeg1),double(0.0)))/(*diTauLegsP4)[0].Pt();

    tightestHPSDBWP_ = tightestHPSDBWP;
    visibleTauMass_  = visibleTauMass;
    decayMode_       = decayMode;
    numPV_           = numPV;
    sampleWeight     = scaleFactor; 
    puWeight         = (std::string(sample.Data())).find("Data")!=string::npos ? 1.0 : pileupWeight(nPUVertices);   

    HqTWeight = histo!=0 ? histo->GetBinContent( histo->FindBin( (*genVP4)[0].Pt() ) ) : 1.0;

    if((std::string(sample.Data())).find("Data")!=string::npos){
      
      HLTx =  float((*triggerBits)[0]);  //HLT_IsoMu15_LooseIsoPFTau15_v8
      bool isTriggMatched = (*tauXTriggers)[0] && (*tauXTriggers)[1] ; //hltSingleMuIsoL3IsoFiltered15 && hltOverlapFilterIsoMu15IsoPFTau15
      HLTmatch = isTriggMatched ? 1.0 : 0.0;
      HLTweightTau = 1.0;
      HLTweightMu  = 1.0;
      SFTau        = 1.0;
      SFMu         = 1.0;
      
    } 
    else{

      HLTx  =  float((*triggerBits)[0]); //HLT_IsoMu15_LooseIsoPFTau15_v9
      bool isTriggMatched = (*tauXTriggers)[0] && (*tauXTriggers)[1] ; //hltSingleMuIsoL3IsoFiltered15 && hltOverlapFilterIsoMu15IsoPFTau15
      HLTmatch = isTriggMatched ? 1.0 : 0.0;

      HLTweightTau  = TMath::Abs((*diTauLegsP4)[1].Eta())<1.5 ?  
	ratioTauHLTBL->Eval( (*diTauLegsP4)[1].Pt() ) : ratioTauHLTEC->Eval( (*diTauLegsP4)[1].Pt() );
      HLTweightMu  = TMath::Abs((*diTauLegsP4)[0].Eta())<1.5 ?  
	ratioMuHLTBL->Eval( (*diTauLegsP4)[0].Pt() ) : ratioMuHLTEC->Eval( (*diTauLegsP4)[0].Pt() );
      SFTau  = 1.0;
      SFMu   =  TMath::Abs((*diTauLegsP4)[0].Eta())<1.5 ?
	ratioMuIDIsoBL->Eval( (*diTauLegsP4)[0].Pt() ): 
	ratioMuIDIsoEC->Eval( (*diTauLegsP4)[0].Pt() );
      
    }
   
    muFlag_          = muFlag;
    genDecay_        = genDecay ;
    event_           = event;
    run_             = run;
    lumi_            = lumi;
    
    outTreePtOrd->Fill();
  }


  file->Close();
  
  if(SAVE) outFile->Write();
  outFile->Close();

  delete jets; delete diTauLegsP4; delete diTauVisP4; delete diTauSVfitP4; delete genDiTauLegsP4;
  delete tauXTriggers; delete triggerBits;
  delete METP4; delete genVP4; delete genMETP4;
  delete HqT;
  
  return;

}
开发者ID:bianchini,项目名称:usercode,代码行数:101,代码来源:treeSkimmer.C

示例4: main

int main(int argc, char** argv){
 
 
 ///===============================================================================
 gROOT->Reset();
 gROOT->SetStyle("Plain");
 gStyle->SetPalette(1);
 gStyle->SetOptStat(1111);
 gStyle->SetOptFit(111);

 const Int_t __NRGBs = 5;
 const Int_t __NCont = 76;
 Double_t __stops[__NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
 Double_t __red[__NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
 Double_t __green[__NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
 Double_t __blue[__NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };

 TColor::CreateGradientColorTable(__NRGBs, __stops, __red, __green, __blue, __NCont);
 gStyle->SetNumberContours(__NCont);
 ///===============================================================================
 
 
 
 
 if(argc != 2)
 {
  std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ;
  return 1;
 }
 
 // Parse the config file 
 parseConfigFile (argv[1]) ;
 
 std::string inputFile = gConfigParser -> readStringOption("Input::inputFile"); 
 std::cout << ">>>>> Input::inputFile " << inputFile  << std::endl;  
 TFile *_file0 = TFile::Open(inputFile.c_str());
 
 double minReco = gConfigParser -> readDoubleOption("Options::minReco"); 
 std::cout << ">>>>> Options::minReco " << minReco  << std::endl;  
 TString Selection = Form("xRECO>%f",minReco);
 std::cout << ">>>>> Selection =  " << Selection.Data()  << std::endl;  
 
 double maxTrue = gConfigParser -> readDoubleOption("Options::maxTrue"); 
 std::cout << ">>>>> Options::maxTrue " << maxTrue  << std::endl;  
 
 double maxReco = gConfigParser -> readDoubleOption("Options::maxReco"); 
 std::cout << ">>>>> Options::maxReco " << maxReco  << std::endl;  
 
 int binTrue = gConfigParser -> readIntOption("Options::binTrue"); 
 std::cout << ">>>>> Options::binTrue " << binTrue  << std::endl;  
 
 int binReco = gConfigParser -> readIntOption("Options::binReco"); 
 std::cout << ">>>>> Options::binReco " << binReco  << std::endl;  
 
 
 TTree* tree = (TTree*) _file0->Get("InputTree"); 
 
 TCanvas cResult("cResult","cResult",800,400);
 cResult.Divide(2,1);
 TH2F h2("h2","h2",binReco,0,maxReco,binTrue,0,maxTrue);
 TH1F h1RECO("h1RECO","h1RECO",binReco,0,maxReco);
 TH1F h1MC("h1MC","h1MC",binTrue,0,maxTrue);
 
 cResult.cd(1);
 tree->Draw("xMC:xRECO >> h2",Selection.Data(),"colz");
 h2.Draw("colz");
 h2.GetXaxis()->SetTitle("RECO");
 h2.GetYaxis()->SetTitle("TRUE"); 
 
 h2.FitSlicesX();
 TH1F* h2_1_X = (TH1F*) gDirectory->Get("h2_1");
 h2_1_X->SetName("h2_1_X");
 h2_1_X->SetLineWidth(2);
 
 double x[1000];
 double y[1000];
 for (int iBin=0; iBin < h2_1_X->GetNbinsX(); iBin++){
  y[iBin] = h2_1_X->GetBinCenter(iBin+1);
  x[iBin] = h2_1_X->GetBinContent(iBin+1);
 }
 
 TGraph gr(h2_1_X->GetNbinsX(),x,y);
 gr.SetMarkerSize(1);
 gr.SetMarkerStyle(22);
 gr.SetMarkerColor(kRed);
 gr.Draw("Psame");
 gPad->SetGrid();
 
 
 double xMC[1000];
 double yMC[1000];
 TF1 *kFunction = new TF1("kFunction","1.3 + 0.001 * x - exp(-x/100)",0,2000);
 for (int iBin=0; iBin < 1000; iBin++){
  yMC[iBin] = (maxTrue) / 1000. * iBin;
  xMC[iBin] = kFunction->Eval(yMC[iBin]) * yMC[iBin];
 }
 
 TGraph grMC(1000,xMC,yMC);
 grMC.SetMarkerSize(0.5);
 grMC.SetMarkerStyle(20);
//.........这里部分代码省略.........
开发者ID:amassiro,项目名称:usercode,代码行数:101,代码来源:PlotCaVa.cpp

示例5: line_width

void line_width() {

  TCanvas *c1 = MakeCanvas("c1", "c1", 800, 600);


    TF1 *fitPeak = new TF1("fitPeak", "[0]-[1]*([3]/2)^2/((x-[2])^2+([3]/2)^2)-[4]*([6]/2)^2/((x-[5])^2+([6]/2)^2)-[7]*([9]/2)^2/((x-[8])^2+([9]/2)^2)-[10]*([12]/2)^2/((x-[11])^2+([12]/2)^2)-[13]*([15]/2)^2/((x-[14])^2+([15]/2)^2)-[16]*([18]/2)^2/((x-[17])^2+([18]/2)^2)-[19]*(x-[20])**2",200, 2040);

  char outfile[50];

  vector<Double_t> linewidths;
  vector<Double_t> linewidthsunc;
  vector<Double_t> err1;
  vector<Double_t> err2;
  for (Int_t i=21; i<27; i++) {

    TH1D *fecn = new TH1D("fecn", "fecn", 2048, 0, 2048);
    TH1D *cal = new TH1D("cal", "cal", 2048, 0, 2048);

    confParse("data_list.txt", i, fecn);
    if ((i==21)||(i==26)) confParse("data_list.txt", 4, cal);
    else confParse("data_list.txt", 30, cal);

    fitPeak->SetParameter(0, 120);

    fitPeak->SetParameter(1, 20);
    fitPeak->SetParameter(2, 500);
    fitPeak->SetParameter(3, 15);

    fitPeak->SetParameter(4, 20);
    fitPeak->SetParameter(5, 700);
    fitPeak->SetParameter(6, 15);

    fitPeak->SetParameter(7, 200);
    fitPeak->SetParameter(8, 1000);
    fitPeak->SetParameter(9, 15);

    fitPeak->SetParameter(10, 20);
    fitPeak->SetParameter(11, 1100);
    fitPeak->SetParameter(12, 15);

    fitPeak->SetParameter(13, 20);
    fitPeak->SetParameter(14, 1400);
    fitPeak->SetParameter(15, 15);

    fitPeak->SetParameter(16, 20);
    fitPeak->SetParameter(17, 1600);
    fitPeak->SetParameter(18, 15);

    cal->SetTitle("");
    cal->GetXaxis()->SetTitle("MCA Channel");
    cal->GetYaxis()->SetTitle("Counts");
    cal->GetXaxis()->SetNdivisions(8,5,0);
    cal->SetLineColor(kRed);

    cal->Fit("fitPeak", "R");
    sprintf(outfile, "linewidthcal%i.png", i);

    c1->SaveAs(outfile);

    vector<Double_t> peakPos;
    vector<Double_t> peakPosUnc;

    peakPos.push_back(fitPeak->GetParameter(2));  peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(3))));
    peakPos.push_back(fitPeak->GetParameter(5));  peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(6))));
    peakPos.push_back(fitPeak->GetParameter(8));  peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(9))));
    peakPos.push_back(fitPeak->GetParameter(11)); peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(12))));
    peakPos.push_back(fitPeak->GetParameter(14)); peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(15))));
    peakPos.push_back(fitPeak->GetParameter(17)); peakPosUnc.push_back(TMath::Sqrt(fabs(fitPeak->GetParameter(18))));

    TF1 *velCurve = new TF1("velCurve", "[0]*x+[1]*x^2+[2]", 200, 2040);
    getVel(peakPos, peakPosUnc, velCurve);

    //TF1 *fitPeak2 = new TF1("fitPeak2", "[0]-[1]*([3]/2)^2/((x-[2])^2+([3]/2)^2)", 800, 1300);
    TF1 *fitPeak2 = new TF1("fitPeak2", "[0]-[1]*([3]/2)^2/((x-[2])^2+([3]/2)^2)", 900, 1200);
    //TF1 *fitPeak2 = new TF1("fitPeak2", "[0]-[1]*([3]/2)^2/((x-[2])^2+([3]/2)^2)-[4]*(x-[5])", 200, 2000);
    
    fitPeak2->SetParameter(0, 21500);
    fitPeak2->SetParameter(1, 2000);
    fitPeak2->SetParameter(2, 1040);
    fitPeak2->SetParameter(3, 50);

    fecn->SetTitle("");
    fecn->GetXaxis()->SetRangeUser(800, 1300);
    fecn->GetXaxis()->SetTitle("MCA Channel");
    fecn->GetYaxis()->SetTitle("Counts");
    fecn->GetXaxis()->SetNdivisions(8,5,0);
    fecn->SetLineColor(kRed);

    fecn->Draw();
    
    fecn->Fit("fitPeak2", "RN");
    fitPeak2->Draw("same");

    sprintf(outfile, "linewidth%i.png", i);

    c1->SaveAs(outfile);

    Double_t blah = fabs(velCurve->Eval(fitPeak2->GetParameter(2)+fitPeak2->GetParameter(3)/2)-velCurve->Eval(fitPeak2->GetParameter(2)-fitPeak2->GetParameter(3)/2));
    linewidths.push_back(fabs(velCurve->Eval(fitPeak2->GetParameter(2)+fitPeak2->GetParameter(3)/2)-velCurve->Eval(fitPeak2->GetParameter(2)-fitPeak2->GetParameter(3)/2)));
    Double_t temp1=fabs(velCurve->Eval(fitPeak2->GetParameter(2)+fitPeak2->GetParameter(3)/2-fitPeak2->GetParError(3)/2)-velCurve->Eval(fitPeak2->GetParameter(2)-fitPeak2->GetParameter(3)/2+fitPeak2->GetParError(3)/2));
//.........这里部分代码省略.........
开发者ID:jaylawhorn,项目名称:junior-lab,代码行数:101,代码来源:line_width.C

示例6: plot

void plot()
{
  TGraph * gr1 = new TGraph();
  gr1->SetMarkerStyle(21);
  int nPoints1 = 0;

  TGraph * gr2 = new TGraph();
  gr2->SetMarkerStyle(21);
  int nPoints2 = 0;

  TGraph * gr3 = new TGraph();
  gr3->SetMarkerStyle(21);
  int nPoints3 = 0;

  TGraph * gr4 = new TGraph();
  gr4->SetMarkerStyle(21);
  int nPoints4 = 0;

  TGraph * gr5 = new TGraph();
  gr5->SetMarkerStyle(21);
  int nPoints5 = 0;

  while (M1[nPoints1].bath!=-999.0) {
    gr1->SetPoint(nPoints1, M1[nPoints1].ambient, M1[nPoints1].slope);
    nPoints1++;

    gr2->SetPoint(nPoints2, M1[nPoints2].bath, M1[nPoints2].ambient);
    nPoints2++;

    gr3->SetPoint(nPoints3, M1[nPoints3].bottom, M1[nPoints3].ambient);
    nPoints3++;

    gr4->SetPoint(nPoints4, M1[nPoints4].top, M1[nPoints4].ambient);
    nPoints4++;

    gr5->SetPoint(nPoints5, M1[nPoints5].top, M1[nPoints5].slope);
    nPoints5++;
  }

  TF1 * fit = new TF1("fit", myfunction, 5, 35, 2);
  fit->SetLineColor(2);

  gr3->Draw("AP");
  gr3->Fit(fit, "NR");
  fit->Draw("same");

  double Tbottom = fit->GetParameter(0) / (1.0 - fit->GetParameter(1));
  cout << Tbottom << endl;

  gr4->Draw("AP");
  gr4->Fit(fit, "NR");
  fit->Draw("same");

  double Ttop = fit->GetParameter(0) / (1.0 - fit->GetParameter(1));
  cout << Ttop << endl;

  gr5->Draw("AP");

  gr5->Fit(fit, "NR");
  fit->Draw("same");

  cout << fit->Eval(Tbottom) << endl;
  cout << fit->Eval(Ttop) << endl;
  cout << fit->Eval(Ttop + (Ttop-Tbottom)) << endl;
}
开发者ID:Negusbuk,项目名称:Analysis,代码行数:65,代码来源:plot.C

示例7: massBias


//.........这里部分代码省略.........
    hist_sig[j] = (TH1*)(workspace->Get("th1f_nominal_sig_"+boost_str[j]+"_ggh_140.0_cat0"))->Clone();
    hist_data[8][j]->Add(hist_sig[j],sig_sf);

    hist_bkg[0][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_3low_"+boost_str[j]+"_"+basemass_str[0]+"_cat0"))->Clone();
    hist_bkg[1][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_2low_"+boost_str[j]+"_"+basemass_str[0]+"_cat0"))->Clone();
    hist_bkg[2][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_1low_"+boost_str[j]+"_"+basemass_str[0]+"_cat0"))->Clone();
    hist_bkg[3][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_3low_"+boost_str[j]+"_"+basemass_str[1]+"_cat0"))->Clone();
    hist_bkg[4][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_2low_"+boost_str[j]+"_"+basemass_str[1]+"_cat0"))->Clone();
    hist_bkg[5][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_1low_"+boost_str[j]+"_"+basemass_str[1]+"_cat0"))->Clone();
    hist_bkg[6][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_1high_"+boost_str[j]+"_"+basemass_str[2]+"_cat0"))->Clone();
    hist_bkg[7][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_2high_"+boost_str[j]+"_"+basemass_str[2]+"_cat0"))->Clone();
    hist_bkg[8][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_3high_"+boost_str[j]+"_"+basemass_str[2]+"_cat0"))->Clone();
    hist_bkg[9][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_1high_"+boost_str[j]+"_"+basemass_str[3]+"_cat0"))->Clone();
    hist_bkg[10][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_2high_"+boost_str[j]+"_"+basemass_str[3]+"_cat0"))->Clone();
    hist_bkg[11][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_3high_"+boost_str[j]+"_"+basemass_str[3]+"_cat0"))->Clone();
    hist_bkg[12][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_1high_"+boost_str[j]+"_"+basemass_str[4]+"_cat0"))->Clone();
    hist_bkg[13][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_2high_"+boost_str[j]+"_"+basemass_str[4]+"_cat0"))->Clone();
    hist_bkg[14][j] = (TH1*)(workspace_mc->Get("th1f_nominal_bkg_mc_3high_"+boost_str[j]+"_"+basemass_str[4]+"_cat0"))->Clone();
    hist_bkg[8][j]->Add(hist_sig[j],sig_sf);

  }

  if (correctShape) {

    TString fastsim_str="";
    if (fastsim) fastsim_str = "_fastsim";
    TFile *f_bias = TFile::Open("/afs/cern.ch/user/f/futyand/scratch1/mva_ucsd/newBkgBias/BkgBias_mit_2var_07_01_12_v2"+fastsim_str+".root");
    float slope_data_in[100][2];
    float slope_mc_in[100][2];
    for (int j=0; j<2; j++) {
      for (int ibin=1; ibin<hist_data[0][j]->GetNbinsX()+1; ibin++) {
	graph_data = (TGraphErrors*)(f_bias->Get("tgraph_biasslopes_data_"+boost_str[j]+"_"+mass_str))->Clone();
	graph_mc = (TGraphErrors*)(f_bias->Get("tgraph_biasslopes_mc_"+boost_str[j]+"_"+mass_str))->Clone();
	slope_data_in[ibin][j] = graph_data->Eval(float(ibin)-0.5);
	slope_mc_in[ibin][j] = graph_mc->Eval(float(ibin)-0.5);
      }
    }

    for (int j=0; j<2; j++) {
      for(int isb=0; isb<15; isb++) {
	hist_data_corrected[isb][j] = (TH1*)hist_data[isb][j]->Clone();
	hist_bkg_corrected[isb][j] = (TH1*)hist_bkg[isb][j]->Clone();
	for (int ibin=1; ibin<hist_data[isb][j]->GetNbinsX()+1; ibin++) {
	  float deltam = mass[isb]-float(mass_in);
	  float corrfac_data = 1./(1.+(slope_data_in[ibin][j]*deltam));
	  float corrfac_mc = 1./(1.+(slope_mc_in[ibin][j]*deltam));
	  if (ibin==6) cout << j << " " << isb << " "  << deltam << " " << ibin << " " << hist_data[isb][j]->GetBinContent(ibin) << " " << slope_data_in[ibin][j] << " " << corrfac_data << endl; 
	  hist_data_corrected[isb][j]->SetBinContent(ibin,hist_data[isb][j]->GetBinContent(ibin)*corrfac_data);
	  hist_bkg_corrected[isb][j]->SetBinContent(ibin,hist_bkg[isb][j]->GetBinContent(ibin)*corrfac_mc);
	}
	hist_data_corrected[isb][j]->Scale(hist_data[isb][j]->Integral()/hist_data_corrected[isb][j]->Integral());
	hist_bkg_corrected[isb][j]->Scale(hist_bkg[isb][j]->Integral()/hist_bkg_corrected[isb][j]->Integral());
	hist_data[isb][j] = hist_data_corrected[isb][j];
	hist_bkg[isb][j] = hist_bkg_corrected[isb][j];
      }
    }

  }

  TGraphErrors *G_bdtout_data[10][2];
  TGraphErrors *G_bdtout_mc[10][2];
  TGraphErrors *G_slope_data[2];
  TGraphErrors *G_slope_mc[2];
  TGraphErrors *G_chi2pol1_data[2];
  TGraphErrors *G_chi2pol1_mc[2];
  TGraphErrors *G_chi2pol2_data[2];
开发者ID:kreczko,项目名称:HiggsAnalysisExample,代码行数:67,代码来源:massBias.C

示例8: main


//.........这里部分代码省略.........
      //cout << endl;   
      
     
      float slewRate = A[ihit][imax-1];
      hSlewRate -> Fill(slewRate); 

      // graphs
      gsample = new TGraphErrors();
      sprintf(gtitle,"shape_Run%d_Evt%d",runId,eventId);
      sprintf(gname,"shape_%d",ievt);
      gsample->SetName(gname);
      gsample->SetTitle(gtitle);
      gsample->GetXaxis()->SetTitle("Time (ns)");
      gsample->GetYaxis()->SetTitle("ADC counts");
      
      for (int isample = 0; isample < 10 ; isample++)
      	{
      	  gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);      
      	  gsample->SetPointError(isample,0.,0.9);      
      	}



      
      // fit function            
      TF1 *fpulseShape = new TF1("fpulseShape", pulseShape,0.,240.,3);
      fpulseShape->SetLineColor(kBlue);
      fpulseShape->SetParName(0,"Ped");
      fpulseShape->SetParName(1,"A");
      fpulseShape->SetParName(2,"T0");
      fpulseShape->FixParameter(0,0); // ped
      fpulseShape->SetParameter(1,A[ihit][imax]); // ampl
      fpulseShape->SetParameter(2,imax*25.); // T0
      gsample->RemovePoint(imax-1);
      gsample->Fit("fpulseShape","QSR+") ;
      //re-set dei punti, altrimenti root non li plotta!
      for (int isample = 0; isample < 10 ; isample++)
      	{
      	  gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);      
      	  gsample->SetPointError(isample,0.,0.9);      
      	}
      ievt++;
      

      float measuredAmpl = A[ihit][imax-1] ;
      float expectedAmpl = A[ihit][imax] * fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.);
                  
      hAmplitude  -> Fill(expectedAmpl,measuredAmpl);
      hAmplitude2 -> Fill( A[ihit][imax] * 0.774,measuredAmpl);
 

      float t0 = fpulseShape->GetParameter(2);
      
      hAmpl_vs_Time -> Fill(t0-125.,expectedAmpl);
      hRatio_vs_Time -> Fill(t0-125., fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
      
      if (expectedAmpl > 3000) {
	hr2->Fill( fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
	hTfit2->Fill(t0-125.);
	hAmax2->Fill(A[ihit][imax]);
      }
      else {
	hr1->Fill( fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
	hTfit1->Fill(t0-125.);
	hAmax1->Fill(A[ihit][imax]);
      }

      if ( expectedAmpl < 3000 )
	//if (ievt<10)
	gsample->Write();

    } // end loop over recHits
    
  }//end loop over events
 
 
  chain->Delete();

  saving.cd () ;

  hGainSwitch ->Write();
  hSlewRate   -> Write();
  hAmplitude  ->Write();
  hAmplitude2 ->Write();
  hAmpl_vs_Time ->Write();
  hRatio_vs_Time ->Write();
  hTfit1->Write();
  hTfit2->Write();
  hAmax1->Write();
  hAmax2->Write();

  hr1->Write();
  hr2->Write();

  saving.Close () ;
  
  return 0;
  
  
}
开发者ID:Bicocca,项目名称:UserCode,代码行数:101,代码来源:SlewRateAnalysis.cpp

示例9: TLatex

//---------------------------------------------------------------
double *treat(TString fileData, double lumi, TString decay, vector<double> mtop, vector<double> xlim, int binned, TString date, TString version) 
//---------------------------------------------------------------
{
  //TString indir = date+"/v"+version+"/";
  TString indir = date+"/"+version+"/";
  TString outdir = indir;
  TString channel = " + Jets channel";
  if (fileData.Contains("ElectronHad")) {
    outdir += "CalibEl/";
    indir += "MyAnaEl/";
    if (decay.Contains("semi", TString::kIgnoreCase))
      channel = "e"+channel;
    if (decay.Contains("di", TString::kIgnoreCase))
      channel = "ee/e#mu"+channel;
    if (decay.Contains("all", TString::kIgnoreCase))
      channel = "e/ee/e#mu"+channel;
  }
  if (fileData.Contains("MuHad")) {
    outdir += "CalibMu/";
    indir += "MyAnaMu/";
    if (decay.Contains("semi", TString::kIgnoreCase))
      channel = "#mu"+channel;
    if (decay.Contains("di", TString::kIgnoreCase))
      channel = "#mu#mu/#mue"+channel;
    if (decay.Contains("all", TString::kIgnoreCase))
      channel = "#mu/#mu#mu/#mue"+channel;
  }
  if (fileData.Contains("Run2012")) {
    outdir += "CalibAll/";
    indir += "MyAnaAll/";
    if (decay.Contains("semi", TString::kIgnoreCase))
      channel = "e/#mu"+channel;
    if (decay.Contains("di", TString::kIgnoreCase))
      channel = "ee/#mu#mu/e#mu"+channel;
    if (decay.Contains("all", TString::kIgnoreCase))
      channel = "e/#mu/ee/#mu#mu/e#mu"+channel;
  }
  gROOT->ProcessLine(".! mkdir "+outdir);
  TLatex* channel_tex = new TLatex(0.22, 0.9, channel);
  channel_tex->SetNDC(true);
  channel_tex->SetTextFont(43);
  channel_tex->SetTextSize(TITLE_FONTSIZE - 6);

  const unsigned int numberOfPoints = mtop.size(); 
  double x[numberOfPoints], ex[numberOfPoints];
  double y[numberOfPoints], ey[numberOfPoints];

  for (unsigned int itop = 0; itop < numberOfPoints; itop++) {
    TString fileMC = TString::Format("All_%d_5.root", (int)mtop[itop]);
    //TString fileMC = TString::Format("TTJets_MSDecays_JpsiFilter_%d_5.root", (int)mtop[itop]);
    double *mean_err = new double[2];
    if (binned < 2)
      mean_err = unbinnedFit(indir+fileMC, xlim, mtop[itop], channel_tex, outdir, lumi);
    if (binned == 2)
      mean_err = binnedFit(indir+fileMC, xlim, mtop[itop], channel_tex, outdir, lumi);
    y[itop] = mean_err[0];
    ey[itop] = mean_err[1];
    x[itop] = mtop[itop]+0.5;
    ex[itop] = 0.;
  }

  TGraphErrors *gr = new TGraphErrors(numberOfPoints, x, y, ex, ey);

  TFitResultPtr fitptr = gr->Fit("pol1", "FSQ", "");
  TF1 *fit = gr->GetFunction("pol1");
  double yinte = fitptr->Parameter(0);
  double errYinte = fitptr->ParError(0);
  double slope = fitptr->Parameter(1);
  double errSlope = fitptr->ParError(1);
  double chi2 = fitptr->Chi2();
  double ndf = fitptr->Ndf();

  double err_up[numberOfPoints];
  double err_down[numberOfPoints];
  double err_val[numberOfPoints];
  fitptr->GetConfidenceIntervals(numberOfPoints, 1, 1, x, err_val, 0.68);
  for(unsigned int itop = 0; itop < numberOfPoints; itop++) {
    double error = err_val[itop];
    err_up[itop] = fit->Eval(x[itop]) + error;
    err_down[itop] = fit->Eval(x[itop]) - error;
  }

  TGraph *gr_up = new TGraph(numberOfPoints,x,err_up);
  gr_up->Fit("pol2","FQ","");
  TF1 *fit_up = gr_up->GetFunction("pol2");
  TGraph *gr_down = new TGraph(numberOfPoints,x,err_down);
  gr_down->Fit("pol2","FQ","");
  TF1 *fit_down = gr_down->GetFunction("pol2");  

  TLegend *leg_calib = new TLegend(0.2,0.75,0.65,0.83,NULL,"brNDC");
  leg_calib->SetTextSize(0.04);
  leg_calib->AddEntry(gr,TString::Format("Slope of %.2f #pm %.2f", slope, errSlope),"lp");
  leg_calib->SetHeader("Calibration curve");

  // Blinded analysis 
  
  TCanvas *cn_calib = new TCanvas("cn_calib", "cn_calib", 800, 800);
  cn_calib->cd();
  grapherrors_myStyle(gr,"gr",2,30,1,30,1001,-1111,-1111,510,510,21,36,1.,"M_{t} (GeV)","M_{J/#psi+l} (GeV)");
//.........这里部分代码省略.........
开发者ID:ebouvier,项目名称:UserCode,代码行数:101,代码来源:calib.C

示例10: drawAvsB


//.........这里部分代码省略.........
  fjes->SetLineWidth(2);
  fjes->SetRange(10.,3500.);
  fjes->Draw("SAME");
  
  //TF1 *ft = new TF1("ft","1-[0]-[1]*pow(x,[2]) + ([3]+[4]*log(x))/x",30,2200);
  //ft->SetParameters(0,0.05,-0.5,1,0.1);
  //ft->FixParameter(3,0);

  // Logarithmic sigmoid
  //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-log(abs([1])))"
  //	       "/(log(abs([2])+abs([1]))-log(abs([1])))))", 30,2200);
  //ft->SetParameters(0.98, 150, 50);
  TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))",30,2200);
  //ft->SetParameters(0.98,log(145),log(190)-log(145));
  //ft->SetParameters(0.982,4.967,0.271);
  //ft->SetParameters(0.976,5.040,0.370); // ENDCAP
  //ft->SetParameters(0.985,5.0,0.3);
  ft->SetParameters(0.985,5.025,0.3);
  //ft->FixParameter(1,5.03); // semi-weighted average of BCD and EF
  //ft->FixParameter(2,0.395); // combined fit to BCD+EF / G+H 

  // ( 12.9*5.055+6.8*5.000)/(12.9+6.8)
  ft->FixParameter(1,5.036); // semi-weighted average of BCD/GH and EF/GH
  // ( 12.9*0.344 + 6.8*0.455)/(12.9+6.8)
  ft->FixParameter(2,0.391); // combined fit to BCD+EF / GH 

  // Log-sigmoid + powerlaw
  //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))"
  //	       "*(1-[3]*pow(x,[4]))",30,2200);
  //ft->SetParameters(0.982,4.967,0.271,0.1,-0.2);
  // Double powerlaw
  //TF1 *ft = new TF1("ft","[4]-[0]*pow(x,[1])-[2]*pow(x,[3])",30,2200);
  //ft->SetParameters(0.05,-0.15,0.01,-0.3,1);
  

  mg->Fit(ft,"RN");
  ft->SetLineColor(kBlue);
  ft->SetLineWidth(2);
  ft->SetRange(10.,3500.);
  ft->Draw("SAME");

  // Map multijet with response ratio
  if (gmpf) { // we have multijet available
    TGraphErrors *gmpf2 = (TGraphErrors*)gmpf->Clone("gmpf2");
    gmpf2->SetMarkerColor(kBlack);//kGray+1);
    gmpf2->SetLineColor(kBlack);//kGray+1);
    for (int i = 0; i != gmpf->GetN(); ++i) {
      if (mjvsjes) {
	gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i],
			fjes->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]);
	gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i],
			     gmpf->GetEY()[i]);
      }
      else {
	gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i],
			ft->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]);
	gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i],
			     gmpf->GetEY()[i]);
      }
    }
    gmpf2->Draw("SAMEPz");
  } // multijet

  tex->SetTextColor(kBlue);
  tex->DrawLatex(0.50,0.85,Form("#chi^{2} / NDF = %1.1f / %d",
				ft->GetChisquare(),
				ft->GetNDF()));
  tex->SetTextColor(kBlack);
  tex->SetTextSize(0.040);
  tex->DrawLatex(0.50,0.80,Form("(#chi^{2} / NDF = %1.1f / %d)",
				fjes->GetChisquare(),
				fjes->GetNDF()));


  tex->SetTextColor(kBlue-9);
  tex->SetTextSize(0.030);
  tex->DrawLatex(0.20,0.25,ft->GetExpFormula());
  tex->DrawLatex(0.20,0.20,
		 Form("p_{0}=%1.3f#pm%1.3f"
		      ", p_{1}=%1.3f#pm%1.3f"
		      ", p_{2}=%1.3f#pm%1.3f",
		      ft->GetParameter(0),ft->GetParError(0),
		      ft->GetParameter(1),ft->GetParError(1),
		      ft->GetParameter(2),ft->GetParError(2)));
  if (ft->GetNpar()>3)
    tex->DrawLatex(0.20,0.17,
		   Form("p_{3}=%1.3f#pm%1.3f"
			", p_{4}=%1.3f#pm%1.3f",
			ft->GetParameter(3),ft->GetParError(3),
			ft->GetParameter(4),ft->GetParError(4)));

  c1->SaveAs(Form("pdf/%s.pdf",s.c_str()));

  for (int i = 0; i != ft->GetNpar(); ++i) {
    cout << Form("%s%1.4g",i==0 ? "{" : ", ",ft->GetParameter(i));
  }
  cout << "}" << endl;
    

}
开发者ID:miquork,项目名称:jecsys,代码行数:101,代码来源:drawAvsB.C

示例11: ratioPlots_Zxx


//.........这里部分代码省略.........
   TH1D *histp0 = new TH1D("p0","p0",100,-0.2,0.3);
   TH1D *histp1 = new TH1D("p1","p1",100,0.0,0.01);
   TH1D *histp2 = new TH1D("p2","p2",100,-0.00001,0);
   TH1D *histp3 = new TH1D("p3","p3",100,0,0.000000002);



   for (Int_t i = 0; i< 500; i++){
     NewP(0) = r.Gaus(PNb(0),sqrt(eigenVal(0,0)));
     NewP(1) = r.Gaus(PNb(1),sqrt(eigenVal(1,1)));
     NewP(2) = r.Gaus(PNb(2),sqrt(eigenVal(2,2)));
     NewP(3) = r.Gaus(PNb(3),sqrt(eigenVal(3,3)));
     //NewP.Print();

     //FittedParam.Print();

     const TVectorD NewP2 = Vt*NewP;
     //NewP2.Print();

     histp0->Fill(NewP2(0));
     histp1->Fill(NewP2(1));
     histp2->Fill(NewP2(2));
     histp3->Fill(NewP2(3));



     TF1 *newFit=new TF1("test","[0]+x*[1]+[2]*pow(x,2)+[3]*pow(x,3)",0,1400);
     newFit->SetParameters(NewP2(0),NewP2(1),NewP2(2),NewP2(3));
     newFit->SetLineColor(kBlue);

     Double_t area=0;
     for(Int_t it=1; it < 16; it++){
       //cout << "bin : " << it << " " << h1c2->GetBinContent(it) << endl;
       area += h1c2->GetBinContent(it)*newFit->Eval(100*it+50);
       }
   
     //newFit->Draw("same");
     //cout <<"val: " << newFit->Eval(200) << endl;
     hist100->Fill(newFit->Eval(100)/area);
     hist200->Fill(newFit->Eval(200)/area);
     hist400->Fill(newFit->Eval(400)/area);
     hist600->Fill(newFit->Eval(600)/area);
     hist800->Fill(newFit->Eval(800)/area);
     hist1000->Fill(newFit->Eval(1000)/area);
     }

   c1->cd();
   TCanvas *c2 = new TCanvas("c2","c2",1000,1000);
   c2->cd();
   c2->Divide(3,2);
   c2->cd(1);
   hist100->Draw();
   c2->cd(2);
   hist200->Draw();
   c2->cd(3);
   hist400->Draw();
   c2->cd(4);
   hist600->Draw();
   c2->cd(5);
   hist800->Draw();
   c2->cd(6);
   hist1000->Draw();



Double_t m_100,m_200,m_400,m_600,m_800,m_1000;
开发者ID:AlexandreMertens,项目名称:ZAPlotters,代码行数:67,代码来源:ratioPlots_Zxx.C

示例12: ana_Run11_eff


//.........这里部分代码省略.........

  TH1F *hRcPtNoWeight = (TH1F*)hMcPtVsRcNoWeight->ProjectionX("hRcPtNoWeight");
  hRcPtNoWeight->SetMarkerStyle(21);
  hRcPtNoWeight->SetMarkerColor(2);
  hRcPtNoWeight->SetLineColor(2);
  hRcPtNoWeight->Draw("sames P");

  TH1F *hRatioNoWeight = (TH1F*)hRcPtNoWeight->Clone("hRatioNoWeight");
  hRatioNoWeight->Divide(hMcPtNoWeight);
  cEff->cd();
  hRatioNoWeight->SetMarkerColor(4);
  hRatioNoWeight->Draw("samesP");

  // weight with input histogram
  TH1F *hMcPtWeight = (TH1F*)hMcPtNoWeight->Clone("hMcPtWeight");
  TH2F *hMcPtVsRcWeight = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcWeight");
  for(int ibin=1; ibin<=hMcPtVsRcNoWeight->GetNbinsX(); ibin++)
    {
      double scale = hMcPt->GetBinContent(ibin);
      hMcPtWeight->SetBinContent(ibin,hMcPtWeight->GetBinContent(ibin)*scale);
      hMcPtWeight->SetBinError(ibin,hMcPtWeight->GetBinError(ibin)*scale);
      for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++)
	{
	  hMcPtVsRcWeight->SetBinContent(ibin,jbin,hMcPtVsRcWeight->GetBinContent(ibin,jbin)*scale);
	  hMcPtVsRcWeight->SetBinError(ibin,jbin,hMcPtVsRcWeight->GetBinError(ibin,jbin)*scale);
	}
    }
  TH1F *hRcPtWeight = (TH1F*)hMcPtVsRcWeight->ProjectionY("hRcPtWeight");
  hRcPtWeight->SetMarkerStyle(21);
  hRcPtWeight->SetMarkerColor(2);
  hRcPtWeight->SetLineColor(2);

  draw2D(hMcPtVsRcWeight);
  draw1D(hMcPtWeight,"",kTRUE);
  hRcPtWeight->Draw("sames P");
  
  TH1F *hRatioWeight = (TH1F*)hRcPtWeight->Clone("hRatioWeight");
  hRatioWeight->Divide(hMcPtWeight);
  cEff->cd();
  hRatioWeight->SetMarkerColor(6);
  hRatioWeight->Draw("samesP");

  TH1F *hCheck = (TH1F*)hRatioWeight->Clone("check");
  hCheck->Divide(hRatio);
  draw1D(hCheck);

  // weight with fitted function
  TCanvas *c = new TCanvas("Fit","Fit",800,600);
  SetPadMargin(gPad,0.15,0.15);
  gPad->SetLogy();
  TH1F *h = new TH1F("histogram",";;;",7,0,30);
  h->GetYaxis()->SetRangeUser(1e-7,100);
  h->Draw();

  TFile *fdata = TFile::Open("Rootfiles/Spectrum_in_bin.root","read");
  TGraphErrors	*gr = (TGraphErrors*)fdata->Get("gall");
  gr->SetMarkerColor(1);
  gr->SetLineColor(1);
  gr->GetXaxis()->SetRangeUser(0,30);
  gr->Draw("sames PE");
  TF1 *func = new TF1("func",InvPt,0,30,4);
  func->SetParameters(0.4,-0.4796,4.229,-7.54);
  gr->Fit(func,"RL");

  TH1F *hMcPtFunc = (TH1F*)hMcPtNoWeight->Clone("hMcPtFunc");
  TH2F *hMcPtVsRcFunc = (TH2F*)hMcPtVsRcNoWeight->Clone("hMcPtVsRcFunc");
  for(int ibin=1; ibin<=hMcPtVsRcFunc->GetNbinsX(); ibin++)
    {
      double scale = func->Eval(hMcPtFunc->GetBinCenter(ibin));
      hMcPtFunc->SetBinContent(ibin,hMcPtFunc->GetBinContent(ibin)*scale);
      hMcPtFunc->SetBinError(ibin,hMcPtFunc->GetBinError(ibin)*scale);
      for(int jbin=1; jbin<=hMcPtVsRcNoWeight->GetNbinsY(); jbin++)
	{
	  hMcPtVsRcFunc->SetBinContent(ibin,jbin,hMcPtVsRcFunc->GetBinContent(ibin,jbin)*scale);
	  hMcPtVsRcFunc->SetBinError(ibin,jbin,hMcPtVsRcFunc->GetBinError(ibin,jbin)*scale);
	}
    }
  TH1F *hRcPtFunc = (TH1F*)hMcPtVsRcFunc->ProjectionY("hRcPtFunc");
  hRcPtFunc->SetMarkerStyle(21);
  hRcPtFunc->SetMarkerColor(2);
  hRcPtFunc->SetLineColor(2);
  hMcPtVsRcFunc->GetZaxis()->SetRangeUser(1e-4,1e2);
  draw2D(hMcPtVsRcFunc);
  hMcPtFunc->GetYaxis()->SetRangeUser(1e-4,5e4);
  draw1D(hMcPtFunc,"",kTRUE);
  hRcPtFunc->Draw("sames P");

  TH1F *hRatioFunc = (TH1F*)hRcPtFunc->Clone("hRatioFunc");
  hRatioFunc->Rebin(100);
  hMcPtFunc->Rebin(100);
  hRatioFunc->Divide(hMcPtFunc);
  cEff->cd();
  hRatioFunc->SetMarkerColor(5);
  hRatioFunc->Draw("samesP");
  
  TH1F *hCheck2 = (TH1F*)hRatioFunc->Clone("check2");
  hCheck2->Divide(hRatio);
  draw1D(hCheck2);

}
开发者ID:marrbnl,项目名称:STAR,代码行数:101,代码来源:ana_Run11_eff.C

示例13: anaAsyJetTrig


//.........这里部分代码省略.........
        if(my_hists->IsMC!=kTRUE){
          //  if(noise_evt==0) continue ;
            if(!noise_evt) continue ;
             int jetTr2 ;
              if(coll=="HI"|| coll=="PbPb")
               jetTr2 = trigSel->HLT_HIJet80_v1 ;
                else if (coll=="PP2011")
                 jetTr2 = trigSel->HLT_Jet60_v1 ;
               else {
               //  jetTr2 = trigSel->HLT_PAJet80_NoJetID_v1 ;
                if(TrigName=="Jet20") jetTr2 = trigSel->HLT_PAJet20_NoJetID_v1  ;
                else  if(TrigName=="Jet40") jetTr2 = trigSel->HLT_PAJet40_NoJetID_v1  ;
                else  if(TrigName=="Jet60") jetTr2 = trigSel->HLT_PAJet60_NoJetID_v1  ;
                else  if(TrigName=="Jet80") jetTr2 = trigSel->HLT_PAJet80_NoJetID_v1  ;
                else  if(TrigName=="Jet100") jetTr2 = trigSel->HLT_PAJet100_NoJetID_v1  ;
                else  jetTr2 = trigSel->HLT_PAZeroBiasPixel_SingleTrack_v1 ;
               }
            if(!jetTr2) continue ;
            int run=offSel->run ;
             if( !(my_skim->phfPosFilter1 && my_skim->phfNegFilter1 && my_skim->pBeamScrapingFilter && my_skim->pprimaryvertexFilter)) continue ;
            if(coll=="PPb"){
            // if( my_skim->phfPosFilter1==0 || my_skim->phfNegFilter1==0 ||my_skim->pBeamScrapingFilter==0 || my_skim->pprimaryvertexFilter==0) continue ;
             if(!pileup_Gplus) continue ;
             if(run>211256) continue ;
             if(run<210676) continue ;  //remove the runs with old alignment
            }
           if(coll=="PbP"){
             if(pileup_Gplus==0) continue ;
            if(run<=211256) continue ;
           }
        }

        if(TMath::Abs(vz)>15.) continue ;
        if(my_hists->IsMC==kTRUE) weight*=fVz->Eval(vz);
     //run selection
    if(my_hists->IsMC!=kTRUE && coll=="PPb") {
       if(offSel->run<210676 ||offSel->run>211256) //211256: last pPb run (Pb goes to +eta)
         continue;
     }
      bool event_accepted = true;
/*      if(!(my_skim->pPAcollisionEventSelectionPA && my_skim->phfPosFilter1 && my_skim->phfNegFilter1
          && my_skim->pBeamScrapingFilter
          && my_skim->pprimaryvertexFilter
          && my_skim->pVertexFilterCutGplus
          && TMath::Abs(offSel->vz)<15.
          )
        ) event_accepted = false;
*/
      if(event_accepted == false)
         continue;

                
    /*    //if there is no jets or no PF candidates, skip the event
        if(my_ct->nref==0) continue ;
   */     //put the higher pthat cut
        if(my_hists->IsMC==kTRUE && my_ct->pthat>ptmax ) continue ;
        if(my_hists->IsMC==kTRUE && my_ct->pthat<pthat) continue ;
         if(my_ct->pthat>ptmax) cout <<"pthat =" <<my_ct->pthat <<endl ;
       if(coll=="HI"|| coll=="PP2011") 
        my_hists->CenBin->Fill(hiBin*2.5);
      else my_hists->CenBin->Fill(hiBin);

        my_hists->Vertex->Fill(vz);

        //   cout <<"vz =" <<vz <<endl ;
        
开发者ID:XuQiao,项目名称:HI,代码行数:66,代码来源:anaAsyJetTrig_YX.C

示例14: computeAccSelZeeBinned_PileupSys


//.........这里部分代码省略.........

      nEvtsv[ifile]+=weight;        

      // trigger requirement               
      if (!isEleTrigger(triggerMenu, info->triggerBits, kFALSE)) continue;
      
      // good vertex requirement
      if(!(info->hasGoodPV)) continue;
      
      electronArr->Clear();
      electronBr->GetEntry(ientry);

      for(Int_t i1=0; i1<electronArr->GetEntriesFast(); i1++) {
  	const baconhep::TElectron *ele1 = (baconhep::TElectron*)((*electronArr)[i1]);

	TLorentzVector vEle1(0,0,0,0);
	vEle1.SetPtEtaPhiM(ele1->pt, ele1->eta, ele1->phi, ELE_MASS);
	
	// check ECAL gap
//	if(fabs(ele1->scEta)>=ETA_BARREL && fabs(ele1->scEta)<=ETA_ENDCAP) continue;
	if(fabs(vEle1.Eta())>=ETA_BARREL && fabs(vEle1.Eta())<=ETA_ENDCAP) continue;

        if(doScaleCorr && (ele1->r9 < 1.)){
            // set up variable and apply smear correction to ele1 
            float ele1Smear = 0.;
	    float ele1Error = 0.;

            float ele1AbsEta   = fabs(vEle1.Eta());
            float ele1Et       = vEle1.E() / cosh(ele1AbsEta);
            bool  ele1isBarrel = ele1AbsEta < 1.4442;

              float ele1R9Prime = ele1->r9; // r9 corrections MC only
              if(ele1isBarrel){
                        ele1R9Prime = gR9EB->Eval(ele1->r9);}
              else {
                        ele1R9Prime = gR9EE->Eval(ele1->r9);
              }

	      double ele1Random = gRandom->Gaus(0,1);

              ele1Smear = eleCorr.getSmearingSigma(info->runNum, ele1isBarrel, ele1R9Prime, ele1AbsEta, ele1Et, 0., 0.);
              float ele1SmearEP = eleCorr.getSmearingSigma(info->runNum, ele1isBarrel, ele1R9Prime, ele1AbsEta, ele1Et, 1., 0.);
              float ele1SmearEM = eleCorr.getSmearingSigma(info->runNum, ele1isBarrel, ele1R9Prime, ele1AbsEta, ele1Et, -1., 0.);

              if(sigma==0){
                (vEle1) *= 1. + ele1Smear * ele1Random;
              }else if(sigma==1){
                (vEle1) *= 1. + ele1SmearEP * ele1Random;
              }else if(sigma==-1){
                (vEle1) *= 1. + ele1SmearEM * ele1Random;
              }
        }

	
	//double ele1_pt = gRandom->Gaus(ele1->pt*getEleScaleCorr(ele1->scEta,0), getEleResCorr(ele1->scEta,0));

//  	if(ele1->pt	     < PT_CUT && ele1->scEt < PT_CUT)	  continue;  // lepton pT cut
//        if(fabs(ele1->scEta) > ETA_CUT && fabs(ele1->eta) > ETA_CUT)	  continue;  // lepton |eta| cut
//        if(!passEleID(ele1,info->rhoIso)) continue;  // lepton selection
        if(vEle1.Pt()           < PT_CUT)     continue;  // lepton pT cut
        if(fabs(vEle1.Eta())    > ETA_CUT)    continue;  // lepton |eta| cut
        if(!passEleID(ele1, vEle1, info->rhoIso))     continue;  // lepton selection


	//if(!isEleTriggerObj(triggerMenu, ele1->hltMatchBits, kFALSE, kFALSE)) continue;
开发者ID:MiT-HEP,项目名称:MitEwk13TeV,代码行数:66,代码来源:computeAccSelZeeBinned_PileupSys.C

示例15: TriggerEfficienciesSF


//.........这里部分代码省略.........

   file = new TFile(mcfile);

   Ref = (TH1D*) file->Get("Trigger"+ref+variable)->Clone();
   Trigger = (TH1D*) file->Get("Trigger"+id+variable)->Clone();

   Ref->Rebin(ngroup);
   Trigger->Rebin(ngroup);

   TEfficiency * EffMC = new TEfficiency();
   EffMC->SetTotalHistogram(*Ref, "f");
   EffMC->SetPassedHistogram(*Trigger, "f");
   EffMC->SetMarkerStyle(kFullSquare);
   EffMC->SetMarkerColor(kRed);
   EffMC->SetLineColor(kRed);

   All->Draw("axis");
   EffMC->Draw("samep");
   
   TF1 * mcfit = new TF1("mcfit","[0] + [1]*(x-100)^2", 100, 800);

   mcfit->SetLineColor(kRed);   
   mcfit->SetParameter(0,1.0);
   mcfit->SetParameter(1,0.0);
   if (linear) mcfit->FixParameter(1,0.0);

   TBinomialEfficiencyFitter * mcfitter = new TBinomialEfficiencyFitter(Trigger,Ref);
   mcfitter->Fit(mcfit);
   mcfit->Draw("same");

   Double_t * mcmatrix = mcfitter->GetFitter()->GetCovarianceMatrix(); 
   
   Double_t mcparam[7];
   mcparam[1] = mcfit->GetParameter(0);
   mcparam[2] = mcfit->GetParameter(1);
   for (Int_t i = 0; i < 4; ++i)
   {
   	   if (linear && i)
           mcparam[i+3] = 0;
   	   else 
           mcparam[i+3] = mcmatrix[i];
   }

   mcparam[0] = 1.0;
   TF1 * mcplus = new TF1("dataplus", fitSigma, 100.0, 1000, 7);
   mcplus->SetParameters(mcparam);   
   mcplus->SetLineStyle(kDashed);
   mcplus->SetLineColor(kRed);    
   mcplus->SetLineWidth(1); 
   mcplus->Draw("same");
     
   mcparam[0] = -1.0;
   TF1 * mcminus = new TF1("dataminus", fitSigma, 100.0, 1000, 7);
   mcminus->SetParameters(mcparam);  
   mcminus->SetLineStyle(kDashed);
   mcminus->SetLineColor(kRed);
   mcminus->SetLineWidth(1);
   mcminus->Draw("same");

   canvas->SaveAs(id+variable+"r"+ref+"-mc.png");
   
   Double_t sfparam[13];
   sfparam[1] = dataparam[1];
   sfparam[2] = dataparam[2];
   sfparam[3] = mcparam[1];
   sfparam[4] = mcparam[2];   
   for (Int_t i = 0; i < 4; ++i) sfparam[i+5] = dataparam[i+3];
   for (Int_t i = 0; i < 4; ++i) sfparam[i+9] = mcparam[i+3];

   for (Int_t i = 0; i < 13; ++i) 
     cout << sfparam[i] << " ";
   cout << endl;
 
   sfparam[0] = 0.0;
   TF1 * sf = new TF1("sf", sffit, 100.0, 1000, 13);
   sf->SetParameters(sfparam);   

   All->GetYaxis()->SetTitle("Trigger scale factor");
   All->GetYaxis()->SetRangeUser(0.0,1.1);
   All->Draw("axis");
   sf->Draw("same");

   sfparam[0] = 1.0;
   TF1 * sfplus = new TF1("sfplus", sffit, 100.0, 1000, 13);
   sfplus->SetParameters(sfparam);   
   sfplus->SetLineStyle(kDashed);
   sfplus->SetLineWidth(1); 
   sfplus->Draw("same");

   sfparam[0] = -1.0;
   TF1 * sfminus = new TF1("sfminus", sffit, 100.0, 1000, 13);
   sfminus->SetParameters(sfparam);   
   sfminus->SetLineStyle(kDashed);
   sfminus->SetLineWidth(1); 
   sfminus->Draw("same");

   if (linear) cout << "Linear fit for sf: " << sf->Eval(100) << " +- " << (sfplus->Eval(100)-sf->Eval(100)) << endl; 
      
   canvas->SaveAs(id+variable+"r"+ref+"-sf.png");   
}
开发者ID:PerilousApricot,项目名称:bsm_analyze,代码行数:101,代码来源:TriggerEfficienciesSF.C


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