void KgpgApp::slotVerifyFile(KURL url) { /////////////////////////////////// check file signature TQString sigfile=TQString(); if (!url.isEmpty()) { ////////////////////////////////////// try to find detached signature. if (!url.fileName().endsWith(".sig")) { sigfile=url.path()+".sig"; TQFile fsig(sigfile); if (!fsig.exists()) { sigfile=url.path()+".asc"; TQFile fsig(sigfile); ////////////// if no .asc or .sig signature file included, assume the file is internally signed if (!fsig.exists()) sigfile=TQString(); } } ///////////////////////// pipe gpg command KgpgInterface *verifyFileProcess=new KgpgInterface(); verifyFileProcess->KgpgVerifyFile(url,KURL(sigfile)); connect (verifyFileProcess,TQT_SIGNAL(verifyquerykey(TQString)),this,TQT_SLOT(importSignatureKey(TQString))); } }
int main( int argc, char** argv ) { CCP4program prog( "cecalc", "0.1", "$Date: 2004/07/01" ); // defaults clipper::String ipfile = "NONE"; clipper::String ipcolfo = "NONE"; clipper::String opfile = "ecalc.mtz"; clipper::String opcol = "ecalc"; const int nprm = 12; // command input CommandInput args( argc, argv, true ); int arg = 0; while ( ++arg < args.size() ) { if ( args[arg] == "-mtzin" ) { if ( ++arg < args.size() ) ipfile = args[arg]; } else if ( args[arg] == "-mtzout" ) { if ( ++arg < args.size() ) opfile = args[arg]; } else if ( args[arg] == "-colin-fo" ) { if ( ++arg < args.size() ) ipcolfo = args[arg]; } else if ( args[arg] == "-colout" ) { if ( ++arg < args.size() ) opcol = args[arg]; } else { std::cout << "Unrecognized:\t" << args[arg] << "\n"; args.clear(); } } if ( args.size() <= 1 ) { std::cout << "Usage: cecalc\n\t-mtzin <filename>\n\t-mtzout <filename>\n\t-colin-fo <colpath>\n\t-colout <colpath>\nCalculate E's from F's\n"; exit(1); } // make data objects clipper::CCP4MTZfile mtzin, mtzout; clipper::HKL_info hkls; typedef clipper::HKL_data_base::HKL_reference_index HRI; // open file mtzin.open_read( ipfile ); mtzin.import_hkl_info( hkls ); clipper::HKL_data<clipper::data32::F_sigF> fsig( hkls ); mtzin.import_hkl_data( fsig, ipcolfo ); if ( opcol[0] != '/' ) opcol = mtzin.assigned_paths()[0].notail()+"/"+opcol; mtzin.close_read(); // create initial E clipper::HKL_data<clipper::data32::E_sigE> esig( hkls ); esig.compute( fsig, clipper::data32::Compute_EsigE_from_FsigF() ); // calc E-scaling std::vector<double> params_init( nprm, 1.0 ); clipper::BasisFn_spline basis_fo( esig, nprm, 2.0 ); clipper::TargetFn_scaleEsq<clipper::data32::E_sigE> target_fo( esig ); clipper::ResolutionFn escale( hkls, basis_fo, target_fo, params_init ); // apply E-scaling for ( HRI ih = esig.first(); !ih.last(); ih.next() ) if ( !esig[ih].missing() ) esig[ih].scale( sqrt( escale.f(ih) ) ); // output data mtzout.open_append( ipfile, opfile ); mtzout.export_hkl_data( esig, opcol ); mtzout.close_append(); }
void nuint09_qel4(int isample) { cout << " ***** running: QEL.4" << endl; if(isample<0 || isample >= kNSamples) return; const char * label = kLabel[isample]; int A = kA[isample]; int Z = kZ[isample]; int N = A-Z; // get cross section graphs TFile fsig("../sig/splines.root","read"); TDirectory * sig_dir = (TDirectory *) fsig.Get(label); TGraph * sig_graph_qelcc = (TGraph*) sig_dir->Get("qel_cc_n"); // range & spacing const int nKEp = 60; const double KEpmin = 0.01; const double KEpmax = 1.50; const int ncosth = 30; const double costhmin = -1; const double costhmax = +1; // create output stream ostringstream out_filename; out_filename << label << ".qel_4.d2sig_dKEpdOmega.data"; ofstream out_stream(out_filename.str().c_str(), ios::out); // write out txt file out_stream << "# [" << label << "]" << endl; out_stream << "# " << endl; out_stream << "# [QEL.4]:" << endl; out_stream << "# dSigma / dOmega_p dKE_p at E_nu = 0.5 and 1.0 GeV" << endl; out_stream << "# " << endl; out_stream << "# Note:" << endl; out_stream << "# - proton energies are _kinetic_ energies " << endl; out_stream << "# - proton kinetic energy KE in GeV, between KEmin = " << KEpmin << " GeV, KEmax = " << KEpmax << " GeV " << endl; out_stream << "# - cross sections in 1E-38 cm^2 /GeV /sterad" << endl; out_stream << "# - quoted cross section is nuclear cross section per nucleon contributing in the scattering (eg only neutrons for nu_mu QELCC)" << endl; out_stream << "# Columns:" << endl; out_stream << "# | KE(p) | cos(theta_p) | sig(QELCC; Ev=0.5GeV) | sig(QELCC; Ev=1.0GeV) | " << endl; out_stream << setiosflags(ios::fixed) << setprecision(6); // // load event data // TChain * chain = new TChain("gst"); // loop over CC/NC cases for(int iwkcur=0; iwkcur<kNWCur; iwkcur++) { // loop over energies for(int ie=0; ie<kNEnergies; ie++) { // loop over runs for current case for(int ir=0; ir<kNRunsPerCase; ir++) { // build filename ostringstream filename; int run_number = kRunNu[isample][iwkcur][ie][ir]; filename << "../gst/gntp." << run_number << ".gst.root"; // add to chain cout << "Adding " << filename.str() << " to event chain" << endl; chain->Add(filename.str().c_str()); } } } // // get QELCC cross sections at given energies for normalization purposes // double sig_qelcc_0500MeV = sig_graph_qelcc->Eval(0.5) / N; double sig_qelcc_1000MeV = sig_graph_qelcc->Eval(1.0) / N; // // book histograms // TH2D * hst_d2sig_dKEpdOmg_qelcc_0500MeV = new TH2D("hst_d2sig_dKEpdOmg_qelcc_0500MeV", "dsig/d2KEpdOmega, nu_mu QEL CC, Enu=0.5 GeV", nKEp, KEpmin, KEpmax, ncosth, costhmin, costhmax); TH2D * hst_d2sig_dKEpdOmg_qelcc_1000MeV = new TH2D("hst_d2sig_dKEpdOmg_qelcc_1000MeV", "dsig/d2KEpdOmega, nu_mu QEL CC, Enu=1.0 GeV", nKEp, KEpmin, KEpmax, ncosth, costhmin, costhmax); // // fill histograms // chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.938272)>>hst_d2sig_dKEpdOmg_qelcc_0500MeV","qel&&cc&&Ev>0.49&&Ev<0.51&&pdgi==2212","GOFF"); chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.938272)>>hst_d2sig_dKEpdOmg_qelcc_1000MeV","qel&&cc&&Ev>0.99&&Ev<1.01&&pdgi==2212","GOFF"); // // normalize // double norm_qelcc_0500MeV = hst_d2sig_dKEpdOmg_qelcc_0500MeV -> Integral("width") * 2*TMath::Pi() / sig_qelcc_0500MeV; double norm_qelcc_1000MeV = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> Integral("width") * 2*TMath::Pi() / sig_qelcc_1000MeV; if (norm_qelcc_0500MeV > 0) hst_d2sig_dKEpdOmg_qelcc_0500MeV -> Scale(1./norm_qelcc_0500MeV); if (norm_qelcc_1000MeV > 0) hst_d2sig_dKEpdOmg_qelcc_1000MeV -> Scale(1./norm_qelcc_1000MeV); for(int i = 1; i <= hst_d2sig_dKEpdOmg_qelcc_1000MeV->GetNbinsX(); i++) { for(int j = 1; j <= hst_d2sig_dKEpdOmg_qelcc_1000MeV->GetNbinsY(); j++) { double KEp = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetXaxis() -> GetBinCenter(i); double costhp = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetYaxis() -> GetBinCenter(j); double d2sig_dKEpdOmg_qelcc_0500MeV = hst_d2sig_dKEpdOmg_qelcc_0500MeV -> GetBinContent(i,j); double d2sig_dKEpdOmg_qelcc_1000MeV = hst_d2sig_dKEpdOmg_qelcc_1000MeV -> GetBinContent(i,j); d2sig_dKEpdOmg_qelcc_0500MeV = TMath::Max(0., d2sig_dKEpdOmg_qelcc_0500MeV); d2sig_dKEpdOmg_qelcc_1000MeV = TMath::Max(0., d2sig_dKEpdOmg_qelcc_1000MeV); out_stream << setw(15) << KEp << setw(15) << costhp << setw(15) << d2sig_dKEpdOmg_qelcc_0500MeV << setw(15) << d2sig_dKEpdOmg_qelcc_1000MeV << endl; }//costh }//E out_stream.close(); delete chain; }
void fitTF1(TCanvas *canvas, TH1F h, double XMIN_, double XMAX_, double dX_, double params[], Color_t LC_=kBlack) { //double& FWHM_, double& x0_, double& x1_, double& x2_, double& y0_, double& y1_, double& INT_, double& YIELD_) { //TCanvas* fitTF1(TH1F h, double HSCALE_, double XMIN_, double XMAX_) { //TF1* fitTF1(TH1F h, double HSCALE_, double XMIN_, double XMAX_) { gROOT->ForceStyle(); RooMsgService::instance().setSilentMode(kTRUE); for(int i=0;i<2;i++) RooMsgService::instance().setStreamStatus(i,kFALSE); //TCanvas *canvas = new TCanvas(TString::Format("canvas_%s",h.GetName()),TString::Format("canvas_%s",h.GetName()),1800,1200); RooDataHist *RooHistFit = 0; RooAddPdf *model = 0; RooWorkspace w = RooWorkspace("w","workspace"); RooRealVar x("mbbReg","mbbReg",XMIN_,XMAX_); RooRealVar kJES("CMS_scale_j","CMS_scale_j",1,0.9,1.1); RooRealVar kJER("CMS_res_j","CMS_res_j",1,0.8,1.2); kJES.setConstant(kTRUE); kJER.setConstant(kTRUE); TString hname = h.GetName(); RooHistFit = new RooDataHist("fit_"+hname,"fit_"+hname,x,&h); RooRealVar YieldVBF = RooRealVar("yield_"+hname,"yield_"+hname,h.Integral()); RooRealVar m("mean_"+hname,"mean_"+hname,125,100,150); RooRealVar s("sigma_"+hname,"sigma_"+hname,12,3,30); RooFormulaVar mShift("mShift_"+hname,"@0*@1",RooArgList(m,kJES)); RooFormulaVar sShift("sShift_"+hname,"@0*@1",RooArgList(m,kJER)); RooRealVar a("alpha_"+hname,"alpha_"+hname,1,-10,10); RooRealVar n("exp_"+hname,"exp_"+hname,1,0,100); RooRealVar b0("b0_"+hname,"b0_"+hname,0.5,0.,1.); RooRealVar b1("b1_"+hname,"b1_"+hname,0.5,0.,1.); RooRealVar b2("b2_"+hname,"b2_"+hname,0.5,0.,1.); RooRealVar b3("b3_"+hname,"b3_"+hname,0.5,0.,1.); RooBernstein bkg("signal_bkg_"+hname,"signal_bkg_"+hname,x,RooArgSet(b0,b1,b2)); RooRealVar fsig("fsig_"+hname,"fsig_"+hname,0.7,0.0,1.0); RooCBShape sig("signal_gauss_"+hname,"signal_gauss_"+hname,x,mShift,sShift,a,n); model = new RooAddPdf("signal_model_"+hname,"signal_model_"+hname,RooArgList(sig,bkg),fsig); //RooFitResult *res = model->fitTo(*RooHistFit,RooFit::Save(),RooFit::SumW2Error(kFALSE),"q"); model->fitTo(*RooHistFit,RooFit::Save(),RooFit::SumW2Error(kFALSE),"q"); //res->Print(); //model->Print(); canvas->cd(); canvas->SetTopMargin(0.1); RooPlot *frame = x.frame(); // no scale RooHistFit->plotOn(frame); model->plotOn(frame,RooFit::LineColor(LC_),RooFit::LineWidth(2));//,RooFit::LineStyle(kDotted)); model->plotOn(frame,RooFit::Components(bkg),RooFit::LineColor(LC_),RooFit::LineWidth(2),RooFit::LineStyle(kDashed)); // with scale // RooHistFit->plotOn(frame,RooFit::Normalization(HSCALE_,RooAbsReal::NumEvent)); // model->plotOn(frame,RooFit::Normalization(HSCALE_,RooAbsReal::NumEvent),RooFit::LineWidth(1)); // model->plotOn(frame,RooFit::Components(bkg),RooFit::LineColor(kBlue),RooFit::LineWidth(1),RooFit::LineStyle(kDashed),RooFit::Normalization(HSCALE_,RooAbsReal::NumEvent)); frame->GetXaxis()->SetLimits(50,200); frame->GetXaxis()->SetNdivisions(505); frame->GetXaxis()->SetTitle("M_{b#bar{b}} (GeV)"); frame->GetYaxis()->SetTitle("Events"); frame->Draw(); h.SetFillColor(kGray); h.Draw("hist,same"); frame->Draw("same"); gPad->RedrawAxis(); TF1 *tmp = model->asTF(x,fsig,x); //tmp->Print(); double y0_ = tmp->GetMaximum(); double x0_ = tmp->GetMaximumX(); double x1_ = tmp->GetX(y0_/2.,XMIN_,x0_); double x2_ = tmp->GetX(y0_/2.,x0_,XMAX_); double FWHM_ = x2_-x1_; double INT_ = tmp->Integral(XMIN_,XMAX_); double YIELD_= YieldVBF.getVal(); double y1_ = dX_*0.5*y0_*(YieldVBF.getVal()/tmp->Integral(XMIN_,XMAX_)); params[0] = x0_; params[1] = x1_; params[2] = x2_; params[3] = y0_; params[4] = y1_; params[5] = FWHM_; params[6] = INT_; params[7] = YIELD_; //cout<<"Int = "<<tmp->Integral(XMIN_,XMAX_)<<", Yield = "<<YieldVBF.getVal()<<", y0 = "<<y0_<<", y1 = "<<y1_ <<", x0 = "<< x0_ << ", x1 = "<<x1_<<", x2 = "<<x2_<<", FWHM = "<<FWHM_<<endl; TLine ln = TLine(x1_,y1_,x2_,y1_); ln.SetLineColor(kMagenta+3); ln.SetLineStyle(7); ln.SetLineWidth(2); ln.Draw(); canvas->Update(); canvas->SaveAs("testC.png"); // tmp->Delete(); // frame->Delete(); // res->Delete(); // TF1 *f1 = model->asTF(x,fsig,x); // return f1; ////tmp->Delete(); ////ln->Delete(); ////model->Delete(); ////RooHistFit->Delete(); ////w->Delete(); ////YieldVBF->Delete(); ////frame->Delete(); ////res->Delete(); //delete tmp; //delete ln; //delete model; //delete RooHistFit; //delete w; //delete YieldVBF; //delete frame; //delete res; // return canvas; }
void nuint09_qel2(int isample, int include_fsi=0) { cout << " ***** running: QEL.2" << endl; if(include_fsi==0) { cout << "-FSI" << endl; } else if(include_fsi==1) { cout << "+FSI" << endl; } else return; if(isample<0 || isample >= kNSamples) return; const char * label = kLabel[isample]; int A = kA[isample]; int Z = kZ[isample]; int N = A-Z; // get cross section graphs TFile fsig("../sig/splines.root","read"); TDirectory * sig_dir = (TDirectory *) fsig.Get(label); TGraph * sig_graph_qelcc = (TGraph*) sig_dir->Get("qel_cc_n"); // range & spacing const int nKEp = 60; const double KEpmin = 0.01; const double KEpmax = 1.50; // create output stream ostringstream out_filename; if(include_fsi==0) { out_filename << label << ".qel_2.dsig_dKEp.data"; } else { out_filename << label << ".qel_2.dsig_dKEp_withFSI.data"; } ofstream out_stream(out_filename.str().c_str(), ios::out); // write out txt file out_stream << "# [" << label << "]" << endl; out_stream << "# " << endl; out_stream << "# [QEL.2]:" << endl; out_stream << "# Cross section as a function of f/s proton kinetic energy at E_nu= 0.5, 1.0 GeV." << endl; out_stream << "# " << endl; out_stream << "# Note:" << endl; if(include_fsi==1) { out_stream << "# - INCLUDING FSI " << endl; } out_stream << "# - proton energies are _kinetic_ energies " << endl; out_stream << "# - proton kinetic energy KE in GeV, between KEmin = " << KEpmin << " GeV, KEmax = " << KEpmax << " GeV " << endl; out_stream << "# - cross sections in 1E-38 cm^2 / GeV" << endl; out_stream << "# - quoted cross section is nuclear cross section per nucleon contributing in the scattering (eg only neutrons for nu_mu QELCC)" << endl; out_stream << "# Columns:" << endl; out_stream << "# | KE(p) | sig(QELCC; Ev=0.5GeV) | sig(QELCC; Ev=1.0GeV) | " << endl; out_stream << setiosflags(ios::fixed) << setprecision(6); // // load event data // TChain * chain = new TChain("gst"); // loop over CC/NC cases for(int iwkcur=0; iwkcur<kNWCur; iwkcur++) { // loop over energies for(int ie=0; ie<kNEnergies; ie++) { // loop over runs for current case for(int ir=0; ir<kNRunsPerCase; ir++) { // build filename ostringstream filename; int run_number = kRunNu[isample][iwkcur][ie][ir]; filename << "../gst/gntp." << run_number << ".gst.root"; // add to chain cout << "Adding " << filename.str() << " to event chain" << endl; chain->Add(filename.str().c_str()); } } } // // get QELCC cross sections at given energies for normalization purposes // double sig_qelcc_0500MeV = sig_graph_qelcc->Eval(0.5) / N; double sig_qelcc_1000MeV = sig_graph_qelcc->Eval(1.0) / N; // // book histograms // TH1D * hst_dsig_dKEp_qelcc_0500MeV = new TH1D("hst_dsig_dKEp_qelcc_0500MeV","dsig/dKEp, nu_mu QEL CC, Enu=0.5 GeV", nKEp, KEpmin, KEpmax); TH1D * hst_dsig_dKEp_qelcc_1000MeV = new TH1D("hst_dsig_dKEp_qelcc_1000MeV","dsig/dKEp, nu_mu QEL CC, Enu=1.0 GeV", nKEp, KEpmin, KEpmax); // // fill histograms // if(include_fsi==0) { chain->Draw("(Ei-0.938)>>hst_dsig_dKEp_qelcc_0500MeV","qel&&cc&&Ev>0.49&&Ev<0.51&&pdgi==2212","GOFF"); chain->Draw("(Ei-0.938)>>hst_dsig_dKEp_qelcc_1000MeV","qel&&cc&&Ev>0.99&&Ev<1.01&&pdgi==2212","GOFF"); } else { chain->Draw("(Ef-0.938)>>hst_dsig_dKEp_qelcc_0500MeV","qel&&cc&&Ev>0.49&&Ev<0.51&&pdgf==2212","GOFF"); chain->Draw("(Ef-0.938)>>hst_dsig_dKEp_qelcc_1000MeV","qel&&cc&&Ev>0.99&&Ev<1.01&&pdgf==2212","GOFF"); } // // normalize // double norm_qelcc_0500MeV = hst_dsig_dKEp_qelcc_0500MeV -> Integral("width") / sig_qelcc_0500MeV; double norm_qelcc_1000MeV = hst_dsig_dKEp_qelcc_1000MeV -> Integral("width") / sig_qelcc_1000MeV; if (norm_qelcc_0500MeV > 0) hst_dsig_dKEp_qelcc_0500MeV -> Scale(1./norm_qelcc_0500MeV); if (norm_qelcc_1000MeV > 0) hst_dsig_dKEp_qelcc_1000MeV -> Scale(1./norm_qelcc_1000MeV); for(int i = 1; i <= hst_dsig_dKEp_qelcc_1000MeV->GetNbinsX(); i++) { double KEp = hst_dsig_dKEp_qelcc_1000MeV->GetBinCenter(i); double dsig_dKEp_qelcc_0500MeV = hst_dsig_dKEp_qelcc_0500MeV -> GetBinContent(i); double dsig_dKEp_qelcc_1000MeV = hst_dsig_dKEp_qelcc_1000MeV -> GetBinContent(i); dsig_dKEp_qelcc_0500MeV = TMath::Max(0., dsig_dKEp_qelcc_0500MeV); dsig_dKEp_qelcc_1000MeV = TMath::Max(0., dsig_dKEp_qelcc_1000MeV); out_stream << setw(15) << KEp << setw(15) << dsig_dKEp_qelcc_0500MeV << setw(15) << dsig_dKEp_qelcc_1000MeV << endl; } out_stream.close(); delete chain; }
void nuint09_1pi1(int isample, int single_pion_sources=0, int stage=1) { cout << " ***** running: 1PI.1" << endl; if(isample<0 || isample >= kNSamples) return; if(single_pion_sources<0 || single_pion_sources>2) return; const char * label = kLabel[isample]; int A = kA[isample]; // get cross section graphs TFile fsig("../sig/splines.root","read"); TDirectory * sig_dir = (TDirectory *) fsig.Get(label); TGraph * sig_graph_totcc = (TGraph*) sig_dir->Get("tot_cc"); // range & spacing const int nEnu = 60; const double Enumin = 0.05; const double Enumax = 30.00; // create output stream ostringstream out_filename; out_filename << label; if (single_pion_sources==0) out_filename << ".1pi_1a."; else if (single_pion_sources==1) out_filename << ".1pi_1b."; else if (single_pion_sources==2) out_filename << ".1pi_1c."; if(stage==0) out_filename << "no_FSI."; out_filename << "sig1pi_vs_Enu.data"; ofstream out_stream(out_filename.str().c_str(), ios::out); // write out txt file out_stream << "# [" << label << "]" << endl; out_stream << "# " << endl; out_stream << "# [1PI.1]:" << endl; out_stream << "# Total cross section for 1 pion (pi+ only) production as a function of energy" << endl; if(stage==0) { out_stream << "# ***** NO FSI: The {X pi+} state is a primary hadronic state" << endl; } if(single_pion_sources==0) { out_stream << "# 1pi sources: All" << endl; } else if(single_pion_sources==1) { out_stream << "# 1pi sources: P33(1232) resonance only" << endl; } else if(single_pion_sources==2) { out_stream << "# 1pi sources: All resonances only" << endl; } out_stream << "# " << endl; out_stream << "# Note:" << endl; out_stream << "# - neutrino energy E in GeV, linear spacing between Emin = " << Enumin << " GeV, Emax = " << Enumax << " GeV " << endl; out_stream << "# - cross sections in 1E-38 cm^2 " << endl; out_stream << "# - quoted cross section is nuclear cross section divided with number of nucleons A" << endl; out_stream << "# Columns:" << endl; out_stream << "# | Energy | sig(nu_mu + A -> mu- 1pi+ X) | " << endl; out_stream << setiosflags(ios::fixed) << setprecision(6); // // load event data // TChain * chain = new TChain("gst"); // loop over CC/NC cases for(int iwkcur=0; iwkcur<kNWCur; iwkcur++) { // loop over runs for current case for(int ir=0; ir<kNRunsPerCase; ir++) { // build filename ostringstream filename; int run_number = kRunNu1PI1[isample][iwkcur][ir]; cout << "isample = " << isample << ", iwkcur = " << iwkcur << ", ir = " << ir << ", run = " << run_number << endl; filename << "../gst/gntp." << run_number << ".gst.root"; // add to chain cout << "Adding " << filename.str() << " to event chain" << endl; chain->Add(filename.str().c_str()); } } // // book histograms // TH1D * hst_cc1pip = new TH1D("hst_cc1pip","CC1pi+ events, Enu spectrum", nEnu, Enumin, Enumax); TH1D * hst_allcc = new TH1D("hst_allcc", "all CC events, Enu spectrum", nEnu, Enumin, Enumax); // // fill histograms // chain->Draw("Ev>>hst_allcc", "cc","GOFF"); if(stage==1) { if(single_pion_sources==0) { //all sources chain->Draw("Ev>>hst_cc1pip","cc&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } else if(single_pion_sources==1) { //P33(1232) only chain->Draw("Ev>>hst_cc1pip","cc&&resid==0&&res&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } else if(single_pion_sources==2) { //all resonances only chain->Draw("Ev>>hst_cc1pip","cc&&res&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } } else if(stage==0) { if(single_pion_sources==0) { //all sources chain->Draw("Ev>>hst_cc1pip","cc&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } else if(single_pion_sources==1) { //P33(1232) only chain->Draw("Ev>>hst_cc1pip","cc&&resid==0&&res&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } else if(single_pion_sources==2) { //all resonances only chain->Draw("Ev>>hst_cc1pip","cc&&res&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } } cout << "CC1pi+ nevents: " << hst_cc1pip->GetEntries() << endl; cout << "ALLCC nevents: " << hst_allcc->GetEntries() << endl; // // compute sig(CC1pi+) and write out in txt file expected by NuINT organizers // Also write out root graph in temp file to be re-used at later benchmarking calc // double e[nEnu], sig[nEnu]; for(int i=1; i <= hst_cc1pip->GetNbinsX(); i++) { double Enu = hst_cc1pip->GetBinCenter(i); double Ncc1pip = hst_cc1pip -> GetBinContent(i); double Nallcc = hst_allcc -> GetBinContent(i); double sig_cc1pip=0; if(Nallcc>0) { sig_cc1pip = (Ncc1pip/Nallcc) * sig_graph_totcc->Eval(Enu) / A; } out_stream << setw(15) << Enu << setw(15) << sig_cc1pip << endl; e [i-1] = Enu; sig[i-1] = sig_cc1pip; } out_stream.close(); TFile ftmp("./cc1pip_tmp.root","recreate"); TGraph * grCC1pip = new TGraph(nEnu,e,sig); grCC1pip->Write("CC1pip"); hst_allcc->Write(); hst_cc1pip->Write(); // visual inspection TCanvas * c1 = new TCanvas("c1","",20,20,500,500); grCC1pip->Draw("alp"); c1->Update(); ftmp.Close(); delete chain; }
void templatesSig(double XMIN,double XMAX,double dX,TString cutstring) { gROOT->ForceStyle(); RooMsgService::instance().setSilentMode(kTRUE); for(int i=0;i<2;i++) RooMsgService::instance().setStreamStatus(i,kFALSE); const int NMASS(1); char name[1000]; TFile *fVBF[NMASS];//,*fGF[NMASS]; TH1F *hVBF[NMASS][5],*hPassVBF; int H_MASS[1] = {125}; TString SELECTION[1] = {"jetPt[0]>80 && jetPt[1]>70"}; int NCAT[1] = {4}; int LUMI[1] = {19281}; int XSEC_VBF[1] = {0.911}; // TH1F *hGF[NMASS][5],*hVBF[NMASS][5],*hTOT[NMASS][5],*hPassGF,*hPassVBF; RooDataHist *RooHistFit[NMASS][5],*RooHistScaled[NMASS][5]; RooAddPdf *model[NMASS][5]; TCanvas *can[NMASS]; TString PATH("rootfiles/"); RooWorkspace *w = new RooWorkspace("w","workspace"); int NBINS = (XMAX-XMIN)/dX; RooRealVar x("mbbReg","mbbReg",XMIN,XMAX); RooRealVar kJES("CMS_scale_j","CMS_scale_j",1,0.9,1.1); RooRealVar kJER("CMS_res_j","CMS_res_j",1,0.8,1.2); kJES.setConstant(kTRUE); kJER.setConstant(kTRUE); TString TRIG_WT[2] = {"trigWtNOM[1]","trigWtVBF"}; for(int iMass=0;iMass<NMASS;iMass++) { cout<<"Mass = "<<H_MASS[iMass]<<" GeV"<<endl; int counter(0); for(int iSEL=0;iSEL<2;iSEL++) { // sprintf(name,"Fit_VBFPowheg%d_sel%s.root",H_MASS[iMass],SELECTION[iSEL].Data()); sprintf(name,"vbfHbb_uncertainties_JEx.root"); cout << name << endl; fVBF[iMass] = TFile::Open(PATH+TString(name)); // hPassVBF = (TH1F*)fVBF[iMass]->Get("TriggerPass"); // sprintf(name,"Fit_GFPowheg%d_sel%s.root",H_MASS[iMass],SELECTION[iSEL].Data()); // fGF[iMass] = TFile::Open(PATH+TString(name)); // hPassGF = (TH1F*)fGF[iMass]->Get("TriggerPass"); sprintf(name,"HMassTemplate_%d_sel%s",H_MASS[iMass],SELECTION[iSEL].Data()); can[iMass] = new TCanvas(name,name,1200,800); can[iMass]->Divide(2,2); for(int icat=0;icat<NCAT[iSEL];icat++) { sprintf(name,"Hbb%d/events",icat); // trVBF = (TTree*)fVBF[iMass]->Get(name); // trGF = (TTree*)fGF[iMass]->Get(name); can[iMass]->cd(icat+1); sprintf(name,"mass_VBF%d_sel%s_CAT%d",H_MASS[iMass],SELECTION[iSEL].Data(),icat); hVBF[iMass][icat] = (TH1F*)fVBF[iMass]->Get("histos/VBF125/h_NOM_VBF125_Hbb_mbbReg1;1");//new TH1F(name,name,NBINS,XMIN,XMAX); // hVBF[iMass][icat]->Sumw2(); // TCut cut("puWt[0]*"+TRIG_WT[iSEL]+"*(mva"+SELECTION[iSEL]+">-1)"); // TCut cut(cutstring.Data()); // trVBF->Draw(MASS_VAR[iSEL]+">>"+TString(name),cut); // sprintf(name,"mass_GF%d_sel%s_CAT%d",H_MASS[iMass],SELECTION[iSEL].Data(),icat); // hGF[iMass][icat] = new TH1F(name,name,NBINS,XMIN,XMAX); // hGF[iMass][icat]->Sumw2(); // trGF->Draw(MASS_VAR[iSEL]+">>"+TString(name),cut); // // delete trVBF; // delete trGF; sprintf(name,"roohist_fit_mass%d_sel%s_CAT%d",H_MASS[iMass],SELECTION[iSEL].Data(),icat); RooHistFit[iMass][icat] = new RooDataHist(name,name,x,hVBF[iMass][icat]); // hGF[iMass][icat]->Scale(LUMI[iSEL]*XSEC_GF[iMass]/hPassGF->GetBinContent(1)); hVBF[iMass][icat]->Scale(LUMI[iSEL]*XSEC_VBF[iMass]/4794398.);//hPassVBF->GetBinContent(1)); // sprintf(name,"mass_Total%d_sel%s_CAT%d",H_MASS[iMass],SELECTION[iSEL].Data(),icat); hTOT[iMass][icat] = (TH1F*)hVBF[iMass][icat]->Clone(name); // hTOT[iMass][icat]->Add(hGF[iMass][icat]); sprintf(name,"yield_signalVBF_mass%d_CAT%d",H_MASS[iMass],counter); RooRealVar *YieldVBF = new RooRealVar(name,name,hVBF[iMass][icat]->Integral()); sprintf(name,"roohist_demo_mass%d_sel%s_CAT%d",H_MASS[iMass],SELECTION[iSEL].Data(),icat); RooHistScaled[iMass][icat] = new RooDataHist(name,name,x,hTOT[iMass][icat]); sprintf(name,"mean_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar m(name,name,125,100,150); sprintf(name,"sigma_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar s(name,name,12,3,30); sprintf(name,"mean_shifted_m%d_CAT%d",H_MASS[iMass],counter); RooFormulaVar mShift(name,"@0*@1",RooArgList(m,kJES)); sprintf(name,"sigma_shifted_m%d_CAT%d",H_MASS[iMass],counter); RooFormulaVar sShift(name,"@0*@1",RooArgList(s,kJER)); sprintf(name,"alpha_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar a(name,name,1,-10,10); sprintf(name,"exp_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar n(name,name,1,0,100); sprintf(name,"b0_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar b0(name,name,0.5,0.,1.); sprintf(name,"b1_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar b1(name,name,0.5,0.,1.); sprintf(name,"b2_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar b2(name,name,0.5,0.,1.); sprintf(name,"b3_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar b3(name,name,0.5,0.,1.); sprintf(name,"signal_bkg_m%d_CAT%d",H_MASS[iMass],counter); RooBernstein bkg(name,name,x,RooArgSet(b0,b1,b2)); sprintf(name,"fsig_m%d_CAT%d",H_MASS[iMass],counter); RooRealVar fsig(name,name,0.7,0.,1.); sprintf(name,"signal_gauss_m%d_CAT%d",H_MASS[iMass],counter); RooCBShape sig(name,name,x,mShift,sShift,a,n); // model(x) = fsig*sig(x) + (1-fsig)*bkg(x) sprintf(name,"signal_model_m%d_CAT%d",H_MASS[iMass],counter); model[iMass][icat] = new RooAddPdf(name,name,RooArgList(sig,bkg),fsig); RooFitResult *res = model[iMass][icat]->fitTo(*RooHistFit[iMass][icat],RooFit::Save(),RooFit::SumW2Error(kFALSE),"q"); //res->Print(); RooPlot* frame = x.frame(); RooHistScaled[iMass][icat]->plotOn(frame); //model[iMass][icat]->plotOn(frame,RooFit::VisualizeError(*res,1,kFALSE),RooFit::FillColor(kGray)); //RooHist[iMass][icat]->plotOn(frame); model[iMass][icat]->plotOn(frame); double chi2 = frame->chiSquare(); //model[iMass][icat]->plotOn(frame,RooFit::LineWidth(2)); model[iMass][icat]->plotOn(frame,RooFit::Components(bkg),RooFit::LineColor(kBlue),RooFit::LineWidth(2),RooFit::LineStyle(kDashed)); frame->GetXaxis()->SetNdivisions(505); frame->GetXaxis()->SetTitle("M_{bb} (GeV)"); frame->GetYaxis()->SetTitle("Events"); frame->Draw(); // hGF[iMass][icat]->SetFillColor(kGreen-8); hVBF[iMass][icat]->SetFillColor(kRed-10); THStack *hs = new THStack("hs","hs"); // hs->Add(hGF[iMass][icat]); hs->Add(hVBF[iMass][icat]); hs->Draw("same hist"); frame->Draw("same"); gPad->RedrawAxis(); TF1 *tmp_func = model[iMass][icat]->asTF(x,fsig,x); double y0 = tmp_func->GetMaximum(); double x0 = tmp_func->GetMaximumX(); double x1 = tmp_func->GetX(y0/2,XMIN,x0); double x2 = tmp_func->GetX(y0/2,x0,XMAX); double FWHM = x2-x1; //cout<<"Int = "<<tmp_func->Integral(XMIN,XMAX)<<", Yield = "<<Yield->getVal()<<", y0 = "<<y0<<", x0 = "<<x0<<", x1 = "<<x1<<", x2 = "<<x2<<", FWHM = "<<FWHM<<endl; //delete tmp_func; double y1 = dX*0.5*y0*(YieldVBF->getVal()+YieldGF->getVal())/tmp_func->Integral(XMIN,XMAX); TLine *ln = new TLine(x1,y1,x2,y1); ln->SetLineColor(kMagenta+3); ln->SetLineStyle(7); ln->SetLineWidth(2); ln->Draw(); TLegend *leg = new TLegend(0.65,0.35,0.9,0.45); leg->AddEntry(hVBF[iMass][icat],"VBF","F"); // leg->AddEntry(hGF[iMass][icat],"GF","F"); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.05); leg->Draw("same"); TPaveText *pave = new TPaveText(0.65,0.55,0.9,0.92,"NDC"); sprintf(name,"M_{H} = %d GeV",H_MASS[iMass]); TLegend *leg = new TLegend(0.65,0.35,0.9,0.45); leg->AddEntry(hVBF[iMass][icat],"VBF","F"); // leg->AddEntry(hGF[iMass][icat],"GF","F"); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.05); leg->Draw("same"); TPaveText *pave = new TPaveText(0.65,0.55,0.9,0.92,"NDC"); sprintf(name,"M_{H} = %d GeV",H_MASS[iMass]); pave->AddText(name); sprintf(name,"%s selection",SELECTION[iSEL].Data()); pave->AddText(name); sprintf(name,"CAT%d",icat); pave->AddText(name); sprintf(name,"m = %1.1f #pm %1.1f",m.getVal(),m.getError()); pave->AddText(name); sprintf(name,"#sigma = %1.1f #pm %1.1f",s.getVal(),s.getError()); pave->AddText(name); sprintf(name,"FWHM = %1.2f",FWHM); pave->AddText(name); /* sprintf(name,"a = %1.2f #pm %1.2f",a.getVal(),a.getError()); pave->AddText(name); sprintf(name,"n = %1.2f #pm %1.2f",n.getVal(),n.getError()); pave->AddText(name); sprintf(name,"f = %1.2f #pm %1.2f",fsig.getVal(),fsig.getError()); pave->AddText(name); */ pave->SetFillColor(0); pave->SetBorderSize(0); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->Draw(); b0.setConstant(kTRUE); b1.setConstant(kTRUE); b2.setConstant(kTRUE); b3.setConstant(kTRUE); //m2.setConstant(kTRUE); //s2.setConstant(kTRUE); m.setConstant(kTRUE); s.setConstant(kTRUE); a.setConstant(kTRUE); n.setConstant(kTRUE); fsig.setConstant(kTRUE); w->import(*model[iMass][icat]); w->import(*RooHistScaled[iMass][icat]); w->import(*res); w->import(*YieldVBF); w->import(*YieldGF); counter++; }// categories loop }// selection loop }// mass loop w->Print(); //x.Print(); TString selName = "_"; selName += XMIN; selName += "-"; selName += XMAX; w->writeToFile("signal_shapes_workspace"+selName+".root"); }
void nuint09_1pi3(int isample, int single_pion_sources=0, int stage=1) { cout << " ***** running: 1PI.3" << endl; if(isample<0 || isample >= kNSamples) return; if(single_pion_sources<0 || single_pion_sources>2) return; const char * label = kLabel[isample]; // get cross section graphs TFile fsig("./cc1pip_tmp.root","read"); // generated at [1PI.1] TGraph * sig_graph_cc1pip = (TGraph*) fsig.Get("CC1pip"); // range & spacing const int nKEpip = 60; const double KEpipmin = 0.00; const double KEpipmax = 1.50; const int ncosth = 30; const double costhmin = -1; const double costhmax = +1; // create output stream ostringstream out_filename; out_filename << label; if (single_pion_sources==0) out_filename << ".1pi_3a."; else if (single_pion_sources==1) out_filename << ".1pi_3b."; else if (single_pion_sources==2) out_filename << ".1pi_3c."; if(stage==0) out_filename << "no_FSI."; out_filename << label << "d2sig1pi_dKEpidOmega.data"; ofstream out_stream(out_filename.str().c_str(), ios::out); // write out txt file out_stream << "# [" << label << "]" << endl; out_stream << "# " << endl; out_stream << "# [1PI.3]:" << endl; out_stream << "# d^Sigma / dOmega_pi+ dKE_pi+ at E_nu= 1.0 and 1.5 GeV" << endl; if(stage==0) { out_stream << "# ***** NO FSI: The {X pi+} state is a primary hadronic state" << endl; } if(single_pion_sources==0) { out_stream << "# 1pi sources: All" << endl; } else if(single_pion_sources==1) { out_stream << "# 1pi sources: P33(1232) resonance only" << endl; } else if(single_pion_sources==2) { out_stream << "# 1pi sources: All resonances only" << endl; } out_stream << "# " << endl; out_stream << "# Note:" << endl; out_stream << "# - pi+ kinetic energy KE in GeV, linear spacing between KEmin = " << KEpipmin << " GeV, KEmax = " << KEpipmax << " GeV " << endl; out_stream << "# - cross sections in 1E-38 cm^2 /GeV /sr" << endl; out_stream << "# - quoted cross section is nuclear cross section divided with number of nucleons A" << endl; out_stream << "# Columns:" << endl; out_stream << "# | KE(pi+) | cos(theta_pi+) | dsig(numu A -> mu- 1pi+ X; Enu = 1.0 GeV) | dsig(numu A -> mu- 1pi+ X; Enu = 1.5 GeV) | " << endl; out_stream << setiosflags(ios::fixed) << setprecision(6); // // load event data // TChain * chain = new TChain("gst"); // loop over CC/NC cases for(int iwkcur=0; iwkcur<kNWCur; iwkcur++) { // loop over energies for(int ie=0; ie<kNEnergies; ie++) { // loop over runs for current case for(int ir=0; ir<kNRunsPerCase; ir++) { // build filename ostringstream filename; int run_number = kRunNu1PI3[isample][iwkcur][ie][ir]; filename << "../gst/gntp." << run_number << ".gst.root"; // add to chain cout << "Adding " << filename.str() << " to event chain" << endl; chain->Add(filename.str().c_str()); } } } // // get CC1pi+ cross sections at given energies for normalization purposes // double sig_cc1pip_1000MeV = sig_graph_cc1pip -> Eval (1.0); double sig_cc1pip_1500MeV = sig_graph_cc1pip -> Eval (1.5); // // book histograms // TH2D * hst_d2sig_dKEpipdOmg_1000MeV = new TH2D("hst_d2sig_dKEpipdOmg_1000MeV", "d2sig / dKEpi+ dOmega, numu A -> mu- 1pi+ X, Enu=1.0 GeV", nKEpip, KEpipmin, KEpipmax, ncosth, costhmin, costhmax); TH2D * hst_d2sig_dKEpipdOmg_1500MeV = new TH2D("hst_d2sig_dKEpipdOmg_1500MeV", "d2sig / dKEpi+ dOmega, numu A -> mu- 1pi+ X, Enu=1.5 GeV", nKEpip, KEpipmin, KEpipmax, ncosth, costhmin, costhmax); // // fill histograms // if(stage==1) { if(single_pion_sources==0) { // all sources chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&Ev>0.99&&Ev<1.01&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&Ev>1.49&&Ev<1.51&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } else if(single_pion_sources==1) { // P33(1232) only chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&resid==0&&res&&Ev>0.99&&Ev<1.01&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&resid==0&&res&&Ev>1.49&&Ev<1.51&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } else if(single_pion_sources==2) { // all resonances only chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&res&&Ev>0.99&&Ev<1.01&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); chain->Draw("pzf/sqrt(pzf*pzf+pyf*pyf+pxf*pxf):(Ef-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&res&&Ev>1.49&&Ev<1.51&&pdgf==211&&nfpip==1&&nfpim==0&&nfpi0==0","GOFF"); } } else if(stage==0) { if(single_pion_sources==0) { // all sources chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&Ev>0.99&&Ev<1.01&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&Ev>1.49&&Ev<1.51&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } else if(single_pion_sources==1) { // P33(1232) only chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&resid==0&&res&&Ev>0.99&&Ev<1.01&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&resid==0&&res&&Ev>1.49&&Ev<1.51&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } else if(single_pion_sources==2) { // all resonances only chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1000MeV","cc&&res&&Ev>0.99&&Ev<1.01&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); chain->Draw("pzi/sqrt(pzi*pzi+pyi*pyi+pxi*pxi):(Ei-0.139)>>hst_d2sig_dKEpipdOmg_1500MeV","cc&&res&&Ev>1.49&&Ev<1.51&&pdgi==211&&nipip==1&&nipim==0&&nipi0==0","GOFF"); } } // // normalize // double norm_cc1pip_1000MeV = hst_d2sig_dKEpipdOmg_1000MeV -> Integral("width") * 2*TMath::Pi() / sig_cc1pip_1000MeV; double norm_cc1pip_1500MeV = hst_d2sig_dKEpipdOmg_1500MeV -> Integral("width") * 2*TMath::Pi() / sig_cc1pip_1500MeV; if (norm_cc1pip_1000MeV > 0) hst_d2sig_dKEpipdOmg_1000MeV -> Scale(1./norm_cc1pip_1000MeV); if (norm_cc1pip_1500MeV > 0) hst_d2sig_dKEpipdOmg_1500MeV -> Scale(1./norm_cc1pip_1500MeV); for(int i = 1; i <= hst_d2sig_dKEpipdOmg_1500MeV->GetNbinsX(); i++) { for(int j = 1; j <= hst_d2sig_dKEpipdOmg_1500MeV->GetNbinsY(); j++) { double KEpip = hst_d2sig_dKEpipdOmg_1500MeV -> GetXaxis() -> GetBinCenter(i); double costhpip = hst_d2sig_dKEpipdOmg_1500MeV -> GetYaxis() -> GetBinCenter(j); double d2sig_dKEpipdOmg_1000MeV = hst_d2sig_dKEpipdOmg_1000MeV -> GetBinContent(i,j); double d2sig_dKEpipdOmg_1500MeV = hst_d2sig_dKEpipdOmg_1500MeV -> GetBinContent(i,j); d2sig_dKEpipdOmg_1000MeV = TMath::Max(0., d2sig_dKEpipdOmg_1000MeV); d2sig_dKEpipdOmg_1500MeV = TMath::Max(0., d2sig_dKEpipdOmg_1500MeV); out_stream << setw(15) << KEpip << setw(15) << costhpip << setw(15) << d2sig_dKEpipdOmg_1000MeV << setw(15) << d2sig_dKEpipdOmg_1500MeV << endl; } } out_stream.close(); // visual inspection //TCanvas * c1 = new TCanvas("c1","",20,20,500,500); //... //c1->Update(); fsig.Close(); delete chain; }