コード例 #1
0
double r_sig(const char* f_inner, const char* f_outer)
{
  TTree *TDiIn = new TTree();
  TDiIn->ReadFile(f_inner, "di/D");
  TH1D *h_din = new TH1D("h_din", "", 10000, 0, 100);
  TDiIn->Draw("di>>h_din", "", "goff");
  Double_t d_inner = h_din->GetMean(1);
  Double_t sig_inner = h_din->GetMeanError(1);
  //  cout << "Mean Inner Diameter: " << d_inner  << " +/- " << sig_inner << endl;

  //  cout<< "Reading Outer Diameters..." << f_outer <<endl;
  TTree *TDiOut = new TTree();
  TDiOut->ReadFile(f_outer, "do/D");
  TH1D *h_dout = new TH1D("h_dout", "", 10000, 0, 100);
  TDiOut->Draw("do>>h_dout", "", "goff");
  Double_t d_outer = h_dout->GetMean(1);
  Double_t sig_outer = h_dout->GetMeanError(1);
  //  cout << "Mean Outer Diameter: " << d_outer << " +/- " << sig_outer << endl;

  double Ratio = d_inner/d_outer;
  double Sigma = Ratio*sqrt( pow((sig_inner/d_inner),2) + pow((sig_outer/d_outer),2)  );
  //  cout << Sigma << endl;
  h_din->Delete();
  h_dout->Delete();

  return Sigma;
}
コード例 #2
0
ファイル: treegraph.C プロジェクト: bdorney/TurboSoftware
void treegraph(TString filename) {
   gROOT->SetStyle("Plain");
   gStyle->SetOptDate();


   Double_t x, y;
   Int_t nlines = 0;
   TFile *f = new TFile("graph.root","RECREATE");

   TCanvas *canvas_graph = new TCanvas("canvas_graph", "y vs x",467,89,400,700);

   TTree t;
   t.ReadFile(filename,"x:y");
   t.Draw("x:y","","goff");

   TGraph *g = new TGraph(t.GetSelectedRows(),t.GetV1(),t.GetV2());
   g->SetTitle(filename+": Y vs X");
   g->GetXaxis()->SetTitle("x[a.u.]");
   g->GetYaxis()->SetTitle("y[a.u.]");

   g->SetMarkerStyle(21);
   g->Draw("AP");

   f->Write();
}
コード例 #3
0
void histogram() {
	// Read data from ASCII file and create histogram/ntuple combo
	ifstream in;
 	in.open("/users/ronnie/git/Journal-Analysis/data.txt");

	Text_t month;
 	Float_t date, day, words;
	TFile *file = new TFile("histogramTest.root", "CREATE");
	TH1F *histo = new TH1F("histo", "writing distribution", 100, 0, 2);
	TTree *Tree = new TTree("ntuple", "data from file");
					
	Tree->ReadFile(Form("/users/ronnie/git/Journal-Analysis/Daily Journals/data.txt"), "month:date:day:words");
	graph = new TGraph(200, &words, &day);
	// Get the total number of words written and print out to CLI
	Tree->Print();
	Int_t numEntries = (Int_t)(Tree->GetEntries());
	TBranch *wordsBranch = Tree->GetBranch("words");
	for(Int_t i = 0; i < numEntries; i++) {
		Tree->GetEntry(i, 0);
	}
	// Draw the Tree (words vs. day) on canvas
	Tree->SetEstimate(Tree->GetEntries());
	Tree->Draw("words:day");
	// Have to loop back through drawn tree to get values and count number of words total
	Float_t numWords = 0.0;
	Double_t *array = Tree->GetV1();
	for (Int_t i = 0; i < numEntries; i++) {
		numWords += array[i];
	}
	cout << numWords << endl;
}
コード例 #4
0
void analyseFitToystudiesB0(string filename, bool justTau = false)
{
    fileprefix = "fitToyStudiesB0";
    TTree *t = new TTree;
    t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:core_frac:core_frac_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:prompt_sigma_core:prompt_sigma_core_err:prompt_sigma_tail:prompt_sigma_tail_err");

    if (!justTau)
    {
	plotPulls(t, "tau_pulls", "#tau(B^{0})", "tau", 1.529, 100, 5.0);
	plotPulls(t, "mass_pulls", "m(B^{0})", "mass_peak", 5.27950, 100, 5.0);
	plotPulls(t, "tau_bk_pulls", "#tau_{bgr}(B^{0})", "tau_bk", 0.750, 100, 5.0);
	plotPulls(t, "nsig_pulls", "n_{sig}", "n_signal", 6750, 100, 5.0);
	plotPulls(t, "npr_pulls", "n_{prompt}", "n_prompt", 3375, 100, 10);
	plotPulls(t, "nnpr_pulls", "n_{nonprompt}", "n_nonprompt", 1125, 100, 10);
    }

    plotHisto(t, "tau_histo", "#tau(B^{0})", "ps", "tau", 100, 1.30, 1.70);
    if (!justTau)
    {
	plotHisto(t, "mass_histo", "m(B^{0})", "GeV", "mass_peak", 100, 5.2785, 5.281);
	plotHisto(t, "tau_bk_histo", "#tau_{bgr}(B^{0})", "ps", "tau_bk", 100, 0.5, 0.9);
	plotHisto(t, "nsig_histo", "n_{sig}", "", "n_signal", 100, 6500, 7000);
	plotHisto(t, "npr_histo", "n_{prompt}", "", "n_prompt", 100, 2900, 3900);
	plotHisto(t, "nnpr_histo", "n_{nonprompt}", "", "n_nonprompt", 100, 950, 1450);
    }
}
コード例 #5
0
TGraphErrors* plot_point(
			     const TString infile,
			     double R,
			     double R_sig
			     )
{

  TTree *TData = new TTree();
  TData->ReadFile(infile, "t/D:x:y:z:B1:B1Range:B2:B2Range:B3:B3Range:V:T1:T2:T3:T4:T5:T6:T7:T8");

  TH1D *h = new TH1D("h", "", 10000, 0, 10000);
  TH1D *h2 = new TH1D("h2", "", 10000, 0, 10000);
  TData->Draw("TMath::Abs(B2)>>h", "", "goff");
  TData->Draw("TMath::Abs(B3)>>h2", "", "goff");

  vector<double> B_ext, B_in, Bratio, u, u_err, B_err;

  B_in.push_back(h2->GetMean(1));
  B_ext.push_back(h->GetMean(1));

  Bratio.push_back(B_in[0] / B_ext[0]);
  u.push_back( (Bratio[0]*(R**2) + Bratio[0] - 2 - 2*sqrt((Bratio[0]**2)*(R**2) - Bratio[0]*(R**2) - Bratio[0] + 1 ) ) / (Bratio[0]*(R**2) - Bratio[0]) );

  B_err.push_back( 0.00 );
  u_err.push_back( 0.00 );

  TGraphErrors *g_uvB = new TGraphErrors(u.size(), &B_ext[0], &u[0], &B_err[0], &u_err[0]);

  h->Delete();
  h2->Delete();

  return g_uvB;

}
コード例 #6
0
/*
 * The Ferromagnet_Scan function reads in
 * a data file of magentic field scans
 * from within the ferromagnet and returns
 * a graph of the magnetic permeability
 * of the ferromagnet vs the external field
 * provided by the Helmholtz coil.
 */
TGraphErrors* plot_uvB(
			 const TString scan_file,
			 TF1* calib_fit,
			 double R,
			 double R_sig
)
{

  /*Read in Data File to ROOT Tree*/
  cout<< "processing file " << scan_file <<endl;
  TTree *TData = new TTree();
  TData->ReadFile(scan_file, "t/D:I:B");
  /*Use TTree Draw command to write branches to usable arrays*/
  int n = TData->Draw("I:TMath::Abs(B):0.0:0.005", "", "goff");

  vector<double> B_ext, B_in, Bratio, u;
  for(int i = 0; i < n; i++)
    {
      B_ext.push_back( calib_fit->Eval(TData->GetV1()[i]) );
      B_in.push_back( TData->GetV2()[i] );
      Bratio.push_back( B_in[i] / B_ext[i]);
      u.push_back( (Bratio[i]*(R**2) + Bratio[i] - 2 - 2*sqrt((Bratio[i]**2)*(R**2) - Bratio[i]*(R**2) - Bratio[i] + 1 ) ) / (Bratio[i]*(R**2) - Bratio[i]) );

    }

  TGraphErrors *g_uvB = new TGraphErrors(n, &B_ext[0], &u[0], TData->GetV3(), TData->GetV4());

  /*  
  g_uvB->Fit("pol1", "", "", 10, 60);
  cout << "Permeability at 50: " << g_uvB->GetFunction("pol1")->Eval(50) << endl;
  cout << "Permeability at 40: " << g_uvB->GetFunction("pol1")->Eval(40) << endl;
  cout << "Permeability at 30: " << g_uvB->GetFunction("pol1")->Eval(30) << endl;
  */
  return g_uvB;
}
コード例 #7
0
ファイル: DrawConsistency.C プロジェクト: c-dilks/scalers11t
void DrawConsistency()
{
  TFile * cons_file = new TFile("cons_file.root","RECREATE");
  TTree * tr = new TTree();
  // cons is run number or fill number, depending on what study you're doing
  tr->ReadFile("cons_study","cons/I:tbit/I:cbit/I:spinbit/I:p0/D:p0_err/D");
  tr->Write("tr");
}
コード例 #8
0
void rads2Hist(){
  TFile * output_file = new TFile("RADS_Data.root", "RECREATE"); //Pointer to ROOT output file 
  TH1D * hist = new TH1D("hist", "Radiation Dosimetry with Altitude", 100, 0, 10000); //1D histogram of doubles
  TTree * t = new TTree("t", "RADS_Data"); //Pointer to tree to store data
  t->ReadFile("RADS_long.dat", "RAD_cpm/I"); // Add integer variable to tree called RAD_cpm
  t->Write(); //Write tree to ROOT file
  output_file->Close();
  
  
}
コード例 #9
0
ファイル: basic2.C プロジェクト: Y--/root
void basic2() {
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/");
   dir.ReplaceAll("/./","/");

   TFile *f = new TFile("basic2.root","RECREATE");
   TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
   TTree *T = new TTree("ntuple","data from ascii file");
   Long64_t nlines = T->ReadFile(Form("%sbasic.dat",dir.Data()),"x:y:z");
   printf(" found %lld points\n",nlines);
   T->Draw("x","z>2");
   T->Write();
}
コード例 #10
0
ファイル: treeFromAscii.C プロジェクト: iLCSoft/GEAR
void treeFromAscii(const char* filen) {

//  Read data from an ascii file and create a root file with a tree

  std::string rFile( filen ) ;
  rFile += ".root" ;
  TFile *f = new TFile( rFile.c_str() ,"RECREATE");

  TTree*  ntuple = new TTree("ntuple","") ;
  ntuple->ReadFile( filen ) ;
  
  f->Write() ;
  f->Close() ;
}
コード例 #11
0
int RampCorrellation_single(std::string file_name, TGraphErrors &graph, TGraphErrors &graph2, vector<double> &vec_errors)
{

	TTree *t = new TTree();
	const std::string file_path = "/home/jlab/github/MagCloak_Analysis/calibration/data-calib/DATA_MegaVIEW/";
//	std::string file_name = "DataFile_2016-12-08_06-59-11.csv";
	std::string file = file_path+file_name;

	t->ReadFile(file.c_str());
//	t->Print();

	TCanvas *c = new TCanvas();
	t->Draw("TMath::Abs(B1/B2):time");
	TGraph *gh = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double ratio_mean = gh->GetMean(2);
	double ratio_std = gh->GetRMS(2);

	t->Draw("Bnom:time");
	TGraph *gh1 = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
	double nom_mean = gh1->GetMean(2);
	double nom_std = 0;

//	cout << "At " << nom_mean << " mT, B1/B2 is: " << ratio_mean << " +/- " << ratio_std << endl;
	
	c->Close();

	int n = graph.GetN();
	graph.SetPoint(n,nom_mean,ratio_mean);
	graph.SetPointError(n,nom_std,ratio_std);

//-------------------------------------------------------------------------------

	TCanvas *c2 = new TCanvas();
	t->Draw("B3:time");
	TGraph *gh2 = (TGraph*)c2->GetListOfPrimitives()->FindObject("Graph");
	double B3_mean = -1*(gh2->GetMean(2));
	double B3_std = gh2->GetRMS(2);
	
	int n2 = graph2.GetN();
	graph2.SetPoint(n2, nom_mean, B3_mean);
	graph2.SetPointError(n2, nom_std, B3_std);
	
	c2->Close();

	if(nom_mean < 500) vec_errors.push_back(B3_std);

	return 0;
}
コード例 #12
0
plot_cluster_vs_run()
{

  TTree *tin = new TTree();
  tin->ReadFile("summaries/allruns_Run13pp510MinBias_cluster.txt","run/I:cluster/F");

  TCanvas *c1 = new TCanvas();
  tin->Draw("cluster");
  c1->Print("plots/cluster_per_event_hist.eps");
  c1->Print("plots/cluster_per_event_hist.png");

  TCanvas *c2 = new TCanvas();
  tin->Draw("cluster:Entry$");
  c2->Print("plots/cluster_per_event_graph.eps");
  c2->Print("plots/cluster_per_event_graph.png");

}
コード例 #13
0
/*
 * The Calibration function reads in the
 * calibration file and returns a graph
 * that is used to find the relation
 * between current and magentic field
 * for the Helmholtz coil.
 */
TF1* Calibrate(
		    const char* f_calib
		    )
{
  /*Read in Calibration File*/
  cout<< "processing file " << f_calib <<endl;
  TTree *TCalib = new TTree();
  TCalib->ReadFile(f_calib, "t/D:I:B");
  int n = TCalib->Draw("I:TMath::Abs(B)", "", "goff");
  TGraph *g_calib = new TGraph(n, TCalib->GetV1(), TCalib->GetV2() );
  g_calib->SetTitle("");
  // g_calib->Draw("AP");
  g_calib->Fit("pol1", "q");
  TF1* calib_fit = g_calib->GetFunction("pol1");

  return calib_fit;

}
コード例 #14
0
ファイル: getTheoXSec.C プロジェクト: RazorCMS/HggApp
TGraphErrors* getTheoXSec(TString file) {
    TTree t;

    t.ReadFile(file);

    TGraphErrors *g = new TGraphErrors(t.GetEntries());

    float m,x,e;
    t.SetBranchAddress("mass",&m);
    t.SetBranchAddress("xsec",&x);
    t.SetBranchAddress("err",&e);


    int iEntry=-1;
    while(t.GetEntry(++iEntry)) {
        g->SetPoint(iEntry,m,x);
        g->SetPointError(iEntry,0,e);
    }
    return g;
}
コード例 #15
0
ファイル: PlotFromMillepedeRes.C プロジェクト: ANSH0712/cmssw
void PlotFromMillepedeRes(TString strMillepedeRes, TString strOutdir, TString strVars, int plotType)
{
  // strPar = "u", "v", "w", "alpha", "beta", "gamma", "def1", "def2", "def3"
  TFile* f = new TFile(strOutdir+TString("fOut.root"),"recreate");
  TTree* tr = new TTree("tr","tr");
  tr->ReadFile(strMillepedeRes,strVars);

  if (plotType==PARSwithERRvsLABEL)
    PlotParValVsLabelWithErr(f, tr, strMillepedeRes, strOutdir);

  if (plotType==NHITS)
    PlotHistsNhitsPerModule(f, tr, strMillepedeRes, strOutdir);

  if (plotType==PULLS)
    PlotPullsDistr(f, tr, strMillepedeRes, strOutdir);

  if (plotType==PARS)
    PlotParsDistr(f, tr, strMillepedeRes, strOutdir);

}// end of PlotPars
コード例 #16
0
TGraphErrors* plot_ramp(
			 const TString scan_file,
			 double R,
			 double R_sig
)
{

  /*Read in Data File to ROOT Tree*/
  cout<< "processing file " << scan_file <<endl;
  TTree *TData = new TTree();
  TData->ReadFile(scan_file, "t/D:x:y:z:B1:B1Range:B2:B2Range:B3:B3Range:V:T1:T2:T3:T4:T5:T6:T7:T8");
  /*Use TTree Draw command to write branches to usable vector*/
  int n = TData->Draw("TMath::Abs(B2):TMath::Abs(B3):0.0:0.005", "", "goff");

  vector<double> B_ext, B_in, Bratio, u, u_err;
  for(int i = 0; i < n; i++)
    {
  //     if(i == 0)
  //     {
  //     	B_ext.push_back(100.00);
  //     }
  //     else{
  //     	  B_ext.push_back( TData->GetV1()[i]);
  //     }
      B_ext.push_back( TData->GetV1()[i] );
      B_in.push_back( TData->GetV2()[i]);
      // B_in.push_back( 90.53);
      // if(TMath::Abs(B_in[i]) <= TMath::Abs(B_ext[i]))
      // {
	Bratio.push_back( B_in[i] / B_ext[i]);
	u.push_back( (Bratio[i]*(R**2) + Bratio[i] - 2 - 2*sqrt((Bratio[i]**2)*(R**2) - Bratio[i]*(R**2) - Bratio[i] + 1 ) ) / (Bratio[i]*(R**2) - Bratio[i]) );
	// u_err.push_back( u[i]*( 5.5*((0.005/Bratio[i])**2.) + 10*((R_sig/R)**2.)  )**0.5 );
	u_err.push_back( 0.01 );
	// u_err.push_back( u[i]*( 5.5*((0.01/Bratio[i])**2.))  )**0.5 );
	// }
      }

  TGraphErrors *g_uvB = new TGraphErrors(n, &B_ext[0], &u[0], TData->GetV3(), &u_err[0]);

  return g_uvB;
}
コード例 #17
0
// Read data from an ascii file and create a root file with an ntuple.
void makeTree(char* txtFile) {

   char state[20];
   char car_value[20];
   float state_fips;
   float car_value_num;

   TFile *f = new TFile((TString(txtFile)+TString(".root")).Data(),"RECREATE");
   TTree *tree = new TTree("ntuple","data from ascii file");

   const char* branchDescriptor = "customer_ID/I:shopping_pt/F:record_type:day:time/C:state/C:location/F:group_size:homeowner:car_age:car_value/C:risk_factor/F:age_oldest:age_youngest:married_couple:C_previous:duration_previous:A:B:C:D:E:F:G:cost";

   Long64_t nlines = tree->ReadFile((TString(txtFile)+TString(".csv")).Data(), branchDescriptor);

   printf(" found %d points\n",nlines);


   tree->SetBranchAddress("state", state);
   tree->SetBranchAddress("car_value", car_value);
   TBranch *fips_branch = tree->Branch("state_fips", 
                                       &state_fips,"state_fips/F");
   TBranch *car_branch = tree->Branch("car_value_num", 
                                      &car_value_num,"car_value_num/F");

   Long64_t nentries = tree->GetEntries();

   for (Int_t i = 0; i < nentries; i++) {
      tree->GetEntry(i);

      state_fips = (float) GetStateFIPS(state);
      fips_branch->Fill();
      car_value_num = (float) GetCarValNum(car_value);
      car_branch->Fill();
   }


   tree->Write();
   f->Close();
}
コード例 #18
0
ファイル: plot.C プロジェクト: parkkj/BONUS_GEMC
void plot(){

  //TH2F *hframe = new TH2F("hframe","Edep_tot vs. track length p=180MeV/C",50,0,50,100,178.0,179.0);
  //TH2F *hframe = new TH2F("hframe","Edep_tot vs. track length p=120MeV/c",50,0,50,100,115.2,116.8);
  //  TH2F *hframe = new TH2F("hframe","Edep_tot vs. track length p=90MeV/c",500,0,50,100,79.5,83.0);
  TH2F *hframe = new TH2F("hframe","Edep_tot vs. track length p=72MeV/c",500,0,50,100,45.5,56.1);
  //  TH2F *hframe = new TH2F("hframe","Edep_tot vs. track length p=65MeV/c",500,0,50,100,0.5,46.1);
  TTree *MyTree = new TTree("MyTree", "MyTree");
  MyTree->ReadFile("Rout_proton72mevOnSolenoid3LIV.txt","track:edep");
  MyTree->SetMarkerStyle(kCircle);
  MyTree->SetMarkerColorAlpha(kRed, 0.35);
  hframe->Draw(); //you can set the axis att via hframe->GetXaxis()..
  MyTree->Draw("edep:track","","same");


  /*
  TTree *MyTree1 = new TTree("MyTree1", "MyTree1");
  MyTree1->ReadFile("Rout_proton120mevOnSolenoid3STD.txt","track1:edep1");
  MyTree1->SetMarkerStyle(kOpenSquare);
  MyTree1->SetMarkerColorAlpha(kBlue, 0.35);
  MyTree1->Draw("edep1:track1","","same");
  */
}
コード例 #19
0
ファイル: render.C プロジェクト: tomstroman/TelescopeArray
void render(const char* infile=NULL, const char* title=NULL) {
  gStyle->SetNumberContours(50);
  TCanvas *cam;
  if (!infile) {
    printf("generating empty camera face and exiting\n");
    cam = camFaceCanvas();
    return;
  }
  
  char *graphTitle;
  graphTitle = title?(char *)title:(char *)infile;

  TTree *rays = new TTree();
  char infile_format[64] = "cam/I:pmt:x/F:y";
  rays->ReadFile(infile, infile_format);
  TH2F *map = sqmmHeatMap();
  map->SetTitle(Form("%s;-x (m);y (m)", graphTitle));
  rays->Project("map", "y:-x");
//   rays->Draw("y:-x", "", "same");
  cam = camFaceCanvas(map, 0);
//   map->Draw("colz");
  cam->Print(Form("%s.pdf", infile));
}
コード例 #20
0
ファイル: kf_plot.C プロジェクト: parkkj/BONUS_GEMC
void kf_plot(){

  TH1F *hframe = new TH1F("hframe","momentum resolution",100,-10.,10.);
  hframe->Draw(); //you can set the axis att via hframe->GetXaxis()..
  gPad->SetLogx(0);
  hframe->GetXaxis()->SetTitle(" #Delta p_T /p_T [%]");
  hframe->GetYaxis()->SetTitle("Number of event");
  TLatex Tl; Tl.SetTextFont(43); Tl.SetTextSize(20);

  double pTresol,pXresol,pYresol;
  int nline =0;
  TTree *MyTree = new TTree("MyTree", "MyTree");
  MyTree->ReadFile("helix_out.txt","pTresol:pXresol:pYresol");
  MyTree->SetMarkerStyle(kCircle);
  MyTree->SetMarkerColorAlpha(kRed, 0.3);
  while(1){
    hframe->Fill(pTresol);
    nline++;
  }
  hframe->Draw("same");

  Tl.DrawLatex(10, 142,   "open: p_T resolution(helix)");

}
コード例 #21
0
void analyseFitToystudiesLb(string filename, bool justTau = false)
{
    fileprefix = "fitToyStudiesLb";
    TTree *t = new TTree;
    //t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:core_frac:core_frac_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:prompt_sigma_core:prompt_sigma_core_err:prompt_sigma_tail:prompt_sigma_tail_err"); // alter Fit
    //t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:core_frac:core_frac_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:prompt_sigma_core:prompt_sigma_core_err:prompt_sigma_tail:prompt_sigma_tail_err:npr_reso_sigma:npr_reso_sigma_err:sig_reso_sigma:sig_reso_sigma_err"); // Fit ohne PEE
    //t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:reso_bias:reso_bias_err:reso_sigma:reso_sigma_err"); // Fit mit PEE 1 Gauss
    t->ReadFile(filename.c_str(),"tau:tau_err:mass_peak:mass_peak_err:m_sigma1:m_sigma1_err:m_sigma2:m_sigma2_err:frac_m_gauss:frac_m_gauss_err:tau_bk:tau_bk_err:n_nonprompt:n_nonprompt_err:n_prompt:n_prompt_err:n_signal:n_signal_err:prompt_p1:prompt_p1_err:reso_bias:reso_bias_err:reso_sigma:reso_sigma_err:npr_reso_bias:npr_reso_bias_err:npr_reso_sigma:npr_reso_sigma_err:sig_reso_bias:sig_reso_bias_err:sig_reso_sigma:sig_reso_sigma_err"); // Fit mit PEE 3 Gauss
    //t.Draw("tau>>htau");
    //t->Draw("(tau-1.507)/tau_err>>htau_pulls(100,-5,5)");
    if (!justTau)
    {
	const int Nevents = 5000;
	const double bgrfrac = 0.8;
	const double nonprfrac = 0.25;
	const int Nsig = Nevents * (1-bgrfrac);
	const int Npr = Nevents * bgrfrac * ( 1-nonprfrac);
	const int Nnpr = Nevents * bgrfrac * nonprfrac;
	plotPulls(t, "tau_pulls", "#tau(#Lambda_{b})", "tau", 1.507, 100, 5.0);
	plotPulls(t, "mass_pulls", "m(#Lambda_{b})", "mass_peak", 5.6202, 100, 5.0);
	plotPulls(t, "tau_bk_pulls", "#tau_{bgr}(#Lambda_{b})", "tau_bk", 0.750, 100, 5.0);
	plotPulls(t, "nsig_pulls", "n_{sig}", "n_signal", Nsig, 100, 5.0);
	plotPulls(t, "npr_pulls", "n_{prompt}", "n_prompt", Npr, 100, 10.0);
	plotPulls(t, "nnpr_pulls", "n_{nonprompt}", "n_nonprompt", Nnpr, 100, 10.0);
    }

    plotHisto(t, "tau_histo", "#tau(#Lambda_{b})", "ps", "tau", 100, 1.30, 1.70);
    if (!justTau)
    {
	plotHisto(t, "mass_histo", "m(#Lambda_{b})", "GeV", "mass_peak", 100, 5.615, 5.625);
	plotHisto(t, "tau_bk_histo", "#tau_{bgr}(#Lambda_{b})", "ps", "tau_bk", 100, 0.5, 0.9);
	plotHisto(t, "nsig_histo", "n_{sig}", "", "n_signal", 100, .8*Nsig, 1.2*Nsig);
	plotHisto(t, "npr_histo", "n_{prompt}", "", "n_prompt", 100, .8*Npr, 1.2*Npr);
	plotHisto(t, "nnpr_histo", "n_{nonprompt}", "", "n_nonprompt", 100, 0.8*Nnpr, 1.2*Nnpr);
    }
}
コード例 #22
0
void Draw_yield_treeeff(char EBEE[20]="EB", int jetbin=0){

  int ptbin_int=0;
  float ptcut[30] = {22, 30, 36, 50, 75, 90, 105,  120, 135, 150, 165, 175, 185,
		     190, 200, 220, 250, 300, 350, 400, 500, 750, 1000, 1500, 2000, 3000, 10000}; //22 bins
  //                  13   14   15   16   17   18   19   20   21    22    23    24    25     26

  int nbin=22;

  TH1F *h_yield = new TH1F("h_yield","",nbin, ptcut);
  TH1F *h_purity = new TH1F("h_purity","",nbin, ptcut);
  TH1F *h_purity_tight = new TH1F("h_purity_tight","",nbin, ptcut);

  TH1F *h_sig_yield = new TH1F("h_sig_yield","",nbin, ptcut);
  TH1F *h_sig_yield_tight = new TH1F("h_sig_yield_tight","",nbin, ptcut);
  TH1F *h_bkg_yield = new TH1F("h_bkg_yield","",nbin, ptcut);
  TH1F *h_bkg_yield_tight = new TH1F("h_bkg_yield_tight","",nbin, ptcut);


  TH1F *h_xs = new TH1F("h_xs","",nbin,ptcut);
  double *fitted;
  float lumi = 2568.83;
  float lumi_err = lumi*0.046;
  float deta = 1.4442*2.; 
  float template_sys = TMath::Sqrt(3.2*3.2+3.*3.)*0.01;
  int ebeebin=0;
  if(strcmp(EBEE,"EE")==0) {
    deta = (2.5-1.566)*2.;
    ebeebin=1;
  }

  TTree *tt = new TTree();
  tt->ReadFile("eff.dat");
  Int_t   ptbin_;
  Int_t   ebee_;
  Int_t   jetbin_;
  Float_t trigeff;
  Float_t trigeff_err;
  Float_t recoeff;
  Float_t recoeff_err;
  Float_t preseleff;
  Float_t preseleff_err;
  Float_t SF;
  Float_t SF_err;       

  tt->SetBranchAddress("ptbin", &ptbin_);
  tt->SetBranchAddress("EBEE", &ebee_);
  tt->SetBranchAddress("jetbin", &jetbin_);
  tt->SetBranchAddress("trigeff", &trigeff);
  tt->SetBranchAddress("trigeff_err", &trigeff_err);
  tt->SetBranchAddress("recoeff", &recoeff);
  tt->SetBranchAddress("recoeff_err", &recoeff_err);
  tt->SetBranchAddress("preseleff", &preseleff);
  tt->SetBranchAddress("preseleff_err", &preseleff_err);
  tt->SetBranchAddress("SF", &SF);
  tt->SetBranchAddress("SF_err", &SF_err);

  char txt[100];
  for(int ii=13; ii<22; ii++){
    //perform fit for yield
    fitted=Ifit(ii, EBEE,1, jetbin);
    if(fitted[0]>0.) {

      h_yield->SetBinContent(ii+1, fitted[0]/h_yield->GetBinWidth(ii+1));
      h_yield->SetBinError(ii+1, fitted[1]/h_yield->GetBinWidth(ii+1));

      Long64_t jentry = ii-13 + 9*3*ebeebin + 9*jetbin;
      tt->GetEntry(jentry);
      printf("bin %d, %d, %d \n", ptbin_, ebee_, jetbin_);
    
      float djet_eta=1.5*2.;
      if(jetbin==1) djet_eta = 0.9*2.;
      if(jetbin==2) djet_eta = 1;
      printf("bin %d, ptcut %.1f,  fit %.0f , bkg %.0f , eff %.2f, %2.f, binwidth %.1f, deta %.2f \n", ii, ptcut[ii], fitted[0], fitted[2], recoeff, preseleff, h_yield->GetBinWidth(ii+1), deta );
      printf(" %f %f %f %f %f %f %f %f %f \n",  fitted[0] , lumi , trigeff, recoeff , preseleff , h_yield->GetBinWidth(ii+1) ,SF ,deta , djet_eta);
      float xs = fitted[0] / lumi / trigeff/ recoeff / preseleff / h_yield->GetBinWidth(ii+1) /SF /deta / djet_eta ; //xs per GeV
      float xs_err = (fitted[1]/fitted[0])*(fitted[1]/fitted[0]) + (lumi_err/lumi)*(lumi_err/lumi) + 
	(preseleff_err/preseleff)*(preseleff_err/preseleff) + 
	(recoeff_err/recoeff)*(recoeff_err/recoeff) + 
	(trigeff_err/trigeff)*(trigeff_err/trigeff) +
	(SF_err/SF)*(SF_err/SF) +
	(template_sys*template_sys);
      xs_err = TMath::Sqrt(xs_err)*xs;
      printf("xs %f , xs_err %f \n", xs, xs_err);
      h_xs->SetBinContent(ii+1, xs);
      h_xs->SetBinError(ii+1, xs_err);

      h_sig_yield->SetBinContent(ii+1, fitted[0]);
      h_bkg_yield->SetBinContent(ii+1, fitted[2]);

      h_sig_yield_tight->SetBinContent(ii+1, fitted[4]);
      h_bkg_yield_tight->SetBinContent(ii+1, fitted[6]);

      // //perform fit for purity in WP90 region
      // h_purity_tight->SetBinContent(ii+1, fitted[4]/(fitted[4]+fitted[6]));
      // float err = TMath::Sqrt(fitted[4]*fitted[6]/(fitted[4]+fitted[6])/(fitted[4]+fitted[6])/(fitted[4]+fitted[6]));
      // h_purity_tight->SetBinError(ii+1, err);    
      // h_purity->SetBinContent(ii+1, fitted[0]/(fitted[0]+fitted[2]));
      // err = TMath::Sqrt(fitted[0]*fitted[2]/(fitted[0]+fitted[2])/(fitted[0]+fitted[2])/(fitted[0]+fitted[2]));
      // h_purity->SetBinError(ii+1, err);    
    }
  }
  for(int ii=13; ii<nbin; ii++){
    //   printf("ptbin %d, %.2f, xs %f , xs_err %f \n", ii, ptcut[ii], h_xs->GetBinContent(ii+1), h_xs->GetBinError(ii+1));
    printf("ptbin %d, %.2f, yield, %.2f, %.2f \n", ii, ptcut[ii], h_sig_yield_tight->GetBinContent(ii+1), h_bkg_yield_tight->GetBinContent(ii+1));
  }

  TCanvas *c10 = new TCanvas("c10","",600,600);
  c10->Draw();
  gPad->SetLogy();
  h_yield->SetNdivisions(505,"XY");
  h_yield->SetXTitle("p_{T} (GeV)");
  h_yield->SetYTitle("Entries / GeV");
  h_yield->SetMarkerStyle(8);
  h_yield->GetXaxis()->SetRangeUser(150.,1000.);
  h_yield->Draw("pe");

  char pho_text[100];
  char jet_text[100];
  if(ebeebin==0) sprintf(pho_text,"|#eta_{#gamma}|<1.4442");
  else sprintf(pho_text,"1.566<|#eta_{#gamma}|<2.5");
  if(jetbin==0) sprintf(jet_text,"|#eta_{jet}|<1.5");
  else sprintf(jet_text,"1.5<|#eta_{jet}|<2.4");


  TLegend *tleg = new TLegend(0.4, 0.65, 0.85, 0.85);
  char text[50];
  sprintf(text,"CMS 13TeV, %.0f pb^{-1}",lumi);
  tleg->SetHeader(text);
  tleg->SetFillColor(0);
  tleg->SetShadowColor(0);
  tleg->SetBorderSize(0);  
  sprintf(text,"%s, %s",pho_text, jet_text);
  if(jetbin==2)   sprintf(text,"%s",pho_text);
  tleg->AddEntry(h_yield,text,"pl");
  tleg->Draw();
  

  TLatex *tlx = new TLatex();
  tlx->SetTextSize(0.04);
  tlx->DrawLatex(100, h_yield->GetMaximum()*1.3, "CMS Preliminary #sqrt{s} = 13TeV");

  // //purity plot
  // TCanvas *c11 = new TCanvas("c11","",600,600);
  // h_purity->SetNdivisions(505,"XY");
  // h_purity->SetXTitle("P_{T} (GeV)");
  // h_purity->SetYTitle("Purity");
  // h_purity->SetMarkerStyle(8);
  // h_purity->GetXaxis()->SetRangeUser(150.,1000.);
  // h_purity->GetYaxis()->SetRangeUser(0., 1.01);
  // h_purity->Draw();
  // // h_purity_tight->SetMarkerStyle(8);
  // // h_purity_tight->SetMarkerColor(4);
  // // h_purity_tight->SetLineColor(4);
  // // h_purity_tight->Draw("pe same");

  
  // TGraphAsymmErrors *tgrs = new TGraphAsymmErrors();
  // h_bkg_yield->Add(h_sig_yield);

  // tgrs->BayesDivide(h_sig_yield, h_bkg_yield);
  // tgrs->SetMarkerStyle(8);
  // tgrs->Draw("pe same");

  // TGraphAsymmErrors *tgrs_tight = new TGraphAsymmErrors();
  // h_bkg_yield_tight->Add(h_sig_yield_tight);
  // for(int ii=13; ii<nbin; ii++){
  //   //   printf("ptbin %d, %.2f, xs %f , xs_err %f \n", ii, ptcut[ii], h_xs->GetBinContent(ii+1), h_xs->GetBinError(ii+1));
  //   printf("ptbin %d, %.2f, yield, %.2f, %.2f \n", ii, ptcut[ii], h_sig_yield_tight->GetBinContent(ii+1), h_bkg_yield_tight->GetBinContent(ii+1));
  // }

  // tgrs_tight->BayesDivide(h_sig_yield_tight, h_bkg_yield_tight,"v");
  // tgrs_tight->SetMarkerStyle(8);
  // tgrs_tight->SetMarkerColor(4);
  // tgrs_tight->SetLineColor(4);
  // tgrs_tight->Draw("pe same");

  // tleg = new TLegend(0.3, 0.15, 0.85, 0.35);
  // char text[50];
  // sprintf(text,"Single Photon PD %.0f pb^{-1}", lumi);
  // tleg->SetHeader(text);
  // tleg->SetFillColor(0);
  // tleg->SetShadowColor(0);
  // tleg->SetBorderSize(0);
  // sprintf(text,"%s, %s",pho_text, jet_text);
  // tleg->AddEntry(tgrs,text,"pl");
  // sprintf(text,"%s, %s, BDT>0.37",pho_text, jet_text);
  // tleg->AddEntry(tgrs_tight,text,"pl");
  // tleg->Draw();

  // tlx->SetTextSize(0.04);
  // tlx->DrawLatex(200, 1.01, "CMS Preliminary #sqrt{s} = 13TeV");
  

  //Draw XS plot
  TCanvas *c12 = new TCanvas("c12","",600,700);  
  c12->Draw();

  TPad* pad1 = new TPad("pad1","",0.02, 0.25, 0.99, 0.99);
  TPad* pad2 = new TPad("pad1","",0.02, 0.02, 0.99, 0.25);


  // pad1->SetLeftMargin(0.02);
  pad1->SetRightMargin(0.035);
  // pad1->SetTopMargin(0.02);
  pad1->SetBottomMargin(0.0);
  pad1->SetFrameBorderMode(0);
  pad1->SetBorderMode(0);
  pad1->SetBorderSize(0);

  // pad2->SetLeftMargin(0.02);
  pad2->SetRightMargin(0.035);
  pad2->SetTopMargin(0.0);
  pad2->SetBottomMargin(0.275);
  pad2->SetFrameBorderMode(0);
  pad2->SetBorderMode(0);
  pad2->SetBorderSize(0);

  pad1->Draw();
  pad2->Draw();
  
  pad1->cd();

  gPad->SetLogy();

  TH2F *hh2 = new TH2F("hh2","",100, 150, 1000, 100, 2e-7, 1.);
  if(ebeebin==0) hh2 = new TH2F("hh2","",100, 150, 1000, 100, 2e-7, 1.);

  hh2->SetNdivisions(505,"XY");
  hh2->SetXTitle("P_{T} (GeV)");
  hh2->SetYTitle("d^{3}#sigma / d^{#gamma}p_{T}d^{#gamma}#eta d^{jet}#eta [pb/GeV]");
  if(jetbin==2)   hh2->SetYTitle("d^{2}#sigma / d^{#gamma}p_{T}d^{#gamma}#eta [pb/GeV]");
  hh2->GetXaxis()->SetLabelSize(0.035);
  hh2->GetYaxis()->SetLabelSize(0.035);
  hh2->GetYaxis()->SetTitleSize(0.04);
  hh2->GetYaxis()->SetTitleOffset(1.1);
  hh2->Draw();
  
  h_xs->SetMarkerStyle(8);
  h_xs->Draw("pel same");
  //Draw JetPhox value
  TTree *t_th = new TTree();
  t_th->ReadFile("jetphox.dat");
  t_th->Print();

  Int_t ptbin_1;
  Int_t ebee_1;
  Int_t jetbin_1;
  Double_t xs_th;
  Double_t xs_th_err;
  
  
  t_th->SetBranchAddress("ptbin", &ptbin_1);
  t_th->SetBranchAddress("EBEE", &ebee_1);
  t_th->SetBranchAddress("jetbin", &jetbin_1);
  t_th->SetBranchAddress("xs", &xs_th);
  t_th->SetBranchAddress("xs_err", &xs_th_err);
  
  
  TH1F *h_th_xs = new TH1F("h_th_xs","",nbin, ptcut);
  TH1F *h_th_xs_err = new TH1F("h_th_xs_err","",nbin, ptcut);

  for(int ii=13; ii<22; ii++){
    Long64_t jentry = ii-13 + 9*3*ebeebin + 9*jetbin;
    t_th->GetEntry(jentry);
    //printf("bin %d, %d, %d \n", ptbin_1, ebee_1, jetbin_1);
    h_th_xs->SetBinContent(ii+1, xs_th);
    h_th_xs->SetBinError(ii+1, xs_th_err);
    h_th_xs_err->SetBinContent(ii+1, xs_th_err);

    if(jetbin==2){
      if(ebeebin==0){
	h_th_xs->SetBinContent(ii+1, xs_th/deta);
	h_th_xs->SetBinError(ii+1, xs_th_err/deta);
	h_th_xs_err->SetBinContent(ii+1, xs_th_err/deta);
      }else{
	h_th_xs->SetBinContent(ii+1, xs_th/deta*2.);
	h_th_xs->SetBinError(ii+1, xs_th_err/deta*2.);
	h_th_xs_err->SetBinContent(ii+1, xs_th_err/deta*2.);
      }
    }
  }

  h_th_xs->SetMarkerStyle(25);
  h_th_xs->SetMarkerColor(2);
  h_th_xs->SetLineColor(2);
  h_th_xs->Draw("same ple");

  TLegend *tleg = new TLegend(0.4, 0.65, 0.85, 0.85);
  char text[50];
  sprintf(text,"CMS 13TeV, %.0f pb^{-1}",lumi);
  tleg->SetHeader(text);
  tleg->SetFillColor(0);
  tleg->SetShadowColor(0);
  tleg->SetBorderSize(0);  
  sprintf(text,"%s, %s",pho_text, jet_text);
  if(jetbin==2)   sprintf(text,"%s",pho_text);
  tleg->AddEntry(h_xs,text,"pl");
  tleg->AddEntry(h_th_xs,"JETPHOX","pl");
  tleg->Draw();
  
  tlx->DrawLatex(150, 1., "CMS Preliminary #sqrt{s} = 13TeV");

  
  //Draw data/th XS ratio
  // TCanvas *c15 = new TCanvas("c15","",600,600);
  // c15->Draw();
  pad2->cd();
  gPad->SetGridy();
  TH1F *h_xs_ratio = (TH1F*)h_xs->Clone();
  h_xs_ratio->Draw();


  h_xs_ratio->Divide(h_th_xs);
  // TGraphAsymmErrors *tgrs = new TGraphAsymmErrors();
  // tgrs->Divide(h_xs, h_th_xs);
  // TH1F *h_xs_ratio = new TH1F("h_xs_ratio","",nbin,ptcut);
  h_xs_ratio->SetMinimum(0.);
  h_xs_ratio->SetMaximum(2.);
  h_xs_ratio->SetNdivisions(505,"XY");
  h_xs_ratio->SetXTitle("P_{T} (GeV)");
  h_xs_ratio->SetYTitle("Data / MC");
  h_xs_ratio->GetXaxis()->SetLabelSize(0.12);
  h_xs_ratio->GetYaxis()->SetLabelSize(0.1);
  h_xs_ratio->GetXaxis()->SetTitleSize(0.12);
  h_xs_ratio->GetYaxis()->SetTitleSize(0.12);
  h_xs_ratio->GetXaxis()->SetTitleOffset(1.);
  h_xs_ratio->GetYaxis()->SetTitleOffset(0.4);

  h_xs_ratio->GetXaxis()->SetRangeUser(150,1000);
  h_xs_ratio->GetYaxis()->SetRangeUser(0.55, 1.45);
  if(ebeebin==1) h_xs_ratio->GetYaxis()->SetRangeUser(0., 2.2);
  if(jetbin==1) h_xs_ratio->GetYaxis()->SetRangeUser(0., 2.2);

  //h_xs_ratio->GetYaxis()->SetNdivisions(102,"Y");
  h_xs_ratio->Draw("pe");
  // tgrs->SetMarkerStyle(8);
  // tgrs->Draw("pe same");
  
}
コード例 #23
0
void load_simresults(TString filenameinput, int inputtype=5, double enabledistsel = 0) {
	Float_t SOURCE, L, B, TS, FLUX, FLUXERR, FLUXUL, R, EXP, SI, MINTS, FIXFLAG , CTS, CTSERR, CTSUL, TOTEXP, TOTNCOUNTS, FCN0, FCN1, EDM0, EDM1, ITER0, ITER1;
	
	Float_t GAL, ISO;
	
	double centerl = 79;
	double centerb = 0;
	
	L = B = TS = FLUX = FLUXERR = FLUXUL = R = EXP = SI = MINTS = FIXFLAG = CTS = CTSERR = CTSUL = TOTEXP = TOTNCOUNTS = FCN0 = FCN1 = EDM0 =  EDM1 = ITER0 =  ITER1 = 1;
	
	GAL=ISO=-1;
	
	Long64_t nlines;
	TTree* T;
	T = new TTree("DATA", "") ;
	
		if(inputtype == 5) {
			/*
			After R:
			double exposure = GetTotalExposure(i);
			srcout << " " << exposure*m_sources[i].GetFlux();
			srcout << " " << exposure*m_sources[i].GetFluxerr();
			srcout << " " << exposure*m_sources[i].GetFluxul();
			srcout << " " << exposure;
			srcout << " " << m_fitInfo[i].counts;

			srcout << " " << m_fitInfo[i].fcn0;
			srcout << " " << m_fitInfo[i].fcn1;
			srcout << " " << m_fitInfo[i].edm0;
			srcout << " " << m_fitInfo[i].edm1;
			srcout << " " << m_fitInfo[i].iter0;
			srcout << " " << m_fitInfo[i].iter1 << endl;
			*/
			nlines = T->ReadFile(filenameinput, "SOURCE:L:B:TS:FLUX:INDEX:FIXFLAG:MINTS:GAL:ISO:R:CTS:CTSERR:CTSUL:TOTEXP:TOTNCOUNTS:FCN0:FCN1:EDM0:EDM1:ITER0:ITER1");
			cout << "******************************************* " << endl;
			cout << "SOURCE:L:B:TS:FLUX:INDEX:FIXFLAG:MINTS:GAL:ISO:R:CTS:CTSERR:CTSUL:TOTEXP:TOTNCOUNTS:FCN0:FCN1:EDM0:EDM1:ITER0:ITER1" << endl;
			cout << "******************************************* " << endl;
		}
		cout << "N lines: " << nlines << endl;
		
		if(inputtype == 5) {
			T->SetBranchAddress("SOURCE", &SOURCE);
			T->SetBranchAddress("L", &L);
			T->SetBranchAddress("B", &B);
			T->SetBranchAddress("TS", &TS);
			T->SetBranchAddress("FLUX", &FLUX);
			T->SetBranchAddress("R", &R);
			T->SetBranchAddress("CTS", &CTS);
			T->SetBranchAddress("TOTNCOUNTS", &TOTNCOUNTS);
			T->SetBranchAddress("FCN0", &FCN0);
			T->SetBranchAddress("FCN1", &FCN1);
			T->SetBranchAddress("EDM0", &EDM0);
			T->SetBranchAddress("EDM1", &EDM1);
			T->SetBranchAddress("ITER0", &ITER0);
			T->SetBranchAddress("ITER1", &ITER1);
		
			//T->SetBranchAddress("GAL", &GAL);
			//T->SetBranchAddress("ISO", &ISO);
		}
	
		TCanvas* c1 = new TCanvas;
		c1->Divide(3,3);
		
		//FCN1 = 2 ln L1
		//FCN0 = 2 ln L0
		//TS = TS = -2(ln L0 - ln L1) = 2 ln L1 - 2 ln L0 = FCN1 - FCN0
		
		TH2D* h_tsdist = new TH2D("h_tsdist", "h_tsdist", 400, 0, 400, 100, 0, 10);
		
		TH1D* h_fcn0 = new TH1D("h_fcn0", "h_fcn0", 40000, 0, 40000);
		TH1D* h_fcn1 = new TH1D("h_fcn1", "h_fcn1", 40000, 0, 40000);
		TH1D* h_fcndiff = new TH1D("h_fcndiff", "h_fcndiff", 400, 0, 400);
		TH1D* h_ts = new TH1D("h_ts", "h_ts", 400, 0, 400);
		TH1D* h_ts_thr = new TH1D("h_ts_thr", "h_ts_thr", 400, 0, 400);
		TH1D* h_fcn0_thr = new TH1D("h_fcn0_thr", "h_fcn0_thr", 40000, 0, 40000);
		TH1D* h_fcn0_thr = new TH1D("h_fcn1_thr", "h_fcn1_thr", 40000, 0, 40000);
		TH1D* h_fcndiff_thr = new TH1D("h_fcndiff_thr", "h_fcndiff_thr", 400, 0, 400);
		TH1D* h_ts_thr = new TH1D("h_ts_thr", "h_ts_thr", 400, 0, 400);
		
		TH1D* h_edm0 = new TH1D("h_emd0", "h_edm0", 10000, 0, 100);
		TH1D* h_edm0_thr = new TH1D("h_emd0_thr", "h_edm0_thr", 10000, 0, 100);
		
		TH1D* h_edm1 = new TH1D("h_emd1", "h_edm1", 10000, 0, 0.02);
		TH1D* h_edm1_thr = new TH1D("h_emd1_thr", "h_edm1_thr", 10000, 0, 0.02);
		
		TH1D* h_iter0 = new TH1D("h_iter0", "h_iter0", 1000, 0, 1000);
		TH1D* h_iter0_thr = new TH1D("h_iter0_thr", "h_iter0_thr", 1000, 0, 1000);
		
		TH1D* h_iter1 = new TH1D("h_iter1", "h_iter1", 10000, 0, 10000);
		TH1D* h_iter1_thr = new TH1D("h_iter1_thr", "h_iter1_thr", 10000, 0, 10000);
		
		int discarded = 0;
		for(Long64_t j = 0; j<nlines; j++) {
			T->GetEntry(j);
			
			if(EDM0 != 0.5) {
				cout << "* " << SOURCE << " " << L << " " << B  << " " << (FLUX) << " " << TS << " " << EDM0 << " " << EDM1 << endl;
				discarded++;
				continue;
			}
				
			double dist = distance(L, B, centerl, centerb);

			h_tsdist->Fill(TS, dist);
			h_fcn0->Fill(FCN0);
			h_fcn1->Fill(FCN1);
			h_fcndiff->Fill(2*(FCN0-FCN1));
			h_ts->Fill(TS);
			h_edm0->Fill(EDM0);
			h_edm1->Fill(EDM1);
			h_iter0->Fill(ITER0);
			h_iter1->Fill(ITER1);
			if(dist > 1) {
				h_fcn0_thr->Fill(FCN0);
				h_fcn1_thr->Fill(FCN1);
				h_fcndiff_thr->Fill(2*(FCN0-FCN1));
				h_ts_thr->Fill(TS);
				h_edm0_thr->Fill(EDM0);
				h_edm1_thr->Fill(EDM1);
				h_iter0_thr->Fill(ITER0);
				h_iter1_thr->Fill(ITER1);
				h_ts->Fill(TS);
			}
			
		}
		
		cout << "discarded: " << discarded << endl;
		
		double scf = h_fcn0->Integral();
		h_fcn0->Scale(1.0/scf);
		h_fcn0_thr->Scale(1.0/scf);
		scf = h_fcn1->Integral();
		h_fcn1->Scale(1.0/scf);
		h_fcn1_thr->Scale(1.0/scf);
		scf = h_fcndiff->Integral();
		h_fcndiff->Scale(1.0/scf);
		h_fcndiff_thr->Scale(1.0/scf);
		scf = h_ts->Integral();
		h_ts->Scale(1.0/scf);
		h_ts_thr->Scale(1.0/scf);
		
		scf = h_edm0->Integral();
		h_edm0->Scale(1.0/scf);
		h_edm0_thr->Scale(1.0/scf);
		scf = h_edm1->Integral();
		h_edm1->Scale(1.0/scf);
		h_edm1_thr->Scale(1.0/scf);
		
		scf = h_iter0->Integral();
		h_iter0->Scale(1.0/scf);
		h_iter0_thr->Scale(1.0/scf);
		scf = h_iter1->Integral();
		h_iter1->Scale(1.0/scf);
		h_iter1_thr->Scale(1.0/scf);
		
		c1->cd(1);
		gPad->SetLogy();
		h_fcn0->Draw();
		h_fcn0_thr->SetLineColor(kRed);
		h_fcn0_thr->Draw("SAME");
		c1->cd(2);
		gPad->SetLogy();
		h_fcn1->Draw();
		h_fcn1_thr->SetLineColor(kRed);
		h_fcn1_thr->Draw("SAME");
		c1->cd(3);
		gPad->SetLogy();
		h_fcndiff->Draw();
		h_ts->SetLineColor(kRed);
		h_ts->Draw("SAME");
		c1->cd(4);
		gPad->SetLogy();
		T->Draw("EDM0");
		h_edm0->Draw();
		h_edm0_thr->SetLineColor(kRed);
		h_edm0_thr->Draw("SAME");
		
		c1->cd(5);
		gPad->SetLogy();
		T->Draw("EDM1");
		h_edm1->Draw();
		h_edm1_thr->SetLineColor(kRed);
		h_edm1_thr->Draw("SAME");
		c1->cd(6);
		gPad->SetLogy();
		h_iter0->Draw();
		h_iter0_thr->SetLineColor(kRed);
		h_iter0_thr->Draw("SAME");
		c1->cd(7);
		gPad->SetLogy();
		h_iter1->Draw();
		h_iter1_thr->SetLineColor(kRed);
		h_iter1_thr->Draw("SAME");
		c1->cd(8);
		gPad->SetLogy();
		T->Draw("FCN1", "TS>9");
		
		c1->cd(9);
		gPad->SetLogy();
		gPad->SetLogx();
		h_tsdist->Draw("BOXCOL");
		
		
}
コード例 #24
0
ファイル: make_scatterplot.c プロジェクト: bth5032/CMS
/*#include "TTree.h"
#include "TCanvas.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "TRint.h"
#include <time.h>
#include <stdio.h>

const short MaxNN = 6;
*/
void make_scatterplot(TString data_file, TString plot_name, TString header)
{
	//TApplication program = new TRInt(); 
	//pull in data
	TTree *t = new TTree(); 
	t->ReadFile(data_file);
	t->SetName("t");
	
	//TString name = "run2.png";
	TCanvas *BG = new TCanvas("c1", "Read Velocity on Local Disk for CMS3 Files", 1920, 1080);
	BG->cd();
	TPad *c = new TPad("MainPad", "My main pad", 0, 0, 1, 0.9);
	c->Draw();
	c->Divide(2,2);

	//In first slot have Time vs. Buffer for 1 Concurrent Read
	c->cd(1);
	int n1 = t->Draw("VelocityMBps:BufferSize", "ConcurrentReads==1", "goff");
	TGraph *ghist1 = new TGraph(n1, t->GetV2(), t->GetV1());
	ghist1->SetName("ghist1");
	ghist1->SetMarkerStyle(3);
	ghist1->SetMarkerColor(1);
	ghist1->SetTitle("Single File Read");
	ghist1->GetXaxis()->SetTitle("Buffer Size (Bytes)");
	ghist1->GetYaxis()->SetTitle("Read Velocity (MB/s)");
	ghist1->Draw("ap");
	
	//In second slot have Time vs. Buffer for 3 Concurrent Reads
	c->cd(2);
	int n2 = t->Draw("VelocityMBps:BufferSize", "ConcurrentReads==3", "goff");
	TGraph *ghist2 = new TGraph(n2, t->GetV2(), t->GetV1());
	Double_t DP2x[n2], DP2y[n2];
	ghist2->SetName("ghist2");
	ghist2->SetMarkerStyle(3);
	ghist2->SetMarkerColor(1);
	ghist2->SetTitle("3 Concurrent Reads");
	ghist2->GetXaxis()->SetTitle("Buffer Size (Bytes)");
	ghist2->GetYaxis()->SetTitle("Read Velocity (MB/s)");
	ghist2->Draw("ap");
	
	//In third slot have Time vs. Buffer for 3 Concurrent Reads
	c->cd(3);
	int n3 = t->Draw("VelocityMBps:BufferSize", "ConcurrentReads==6", "goff");
	TGraph *ghist3 = new TGraph(n3, t->GetV2(), t->GetV1());
	Double_t DP3x[n3], DP3y[n3];
	ghist3->SetName("ghist3");
	ghist3->SetMarkerStyle(3);
	ghist3->SetMarkerColor(1);
	ghist3->SetTitle("6 Concurrent Reads");
	ghist3->GetXaxis()->SetTitle("Buffer Size (Bytes)");
	ghist3->GetYaxis()->SetTitle("Read Velocity (MB/s)");
	ghist3->Draw("ap");
	
	//In fourth slot have Time vs. Buffer for 10 Concurrent Reads
	c->cd(4);
	int n4 = t->Draw("VelocityMBps:BufferSize", "ConcurrentReads==10", "goff");
	TGraph *ghist4 = new TGraph(n4, t->GetV2(), t->GetV1());
	ghist4->SetMarkerStyle(3);
	ghist4->SetName("ghist4");
	ghist4->SetMarkerColor(1);
	ghist4->SetTitle("10 Concurrent Reads");
	ghist4->GetXaxis()->SetTitle("Buffer Size (Bytes)");
	ghist4->GetYaxis()->SetTitle("Read Velocity (MB/s)");
	ghist4->Draw("ap");
	
	//Draw to screen
	//Initialize Canvas
	
	c->cd(0);
	c->Draw();
	
	BG->cd();
	TText *title = new TText(.5,.95, header);
	title->SetTextAlign(22);
	title->Draw();
	
	gDirectory->Add(ghist1);
	gDirectory->Add(ghist2);
	gDirectory->Add(ghist3);
	gDirectory->Add(ghist4);
	gDirectory->Add(t);
	gPad->SaveAs(plot_name);
}
コード例 #25
0
ファイル: read_tpvar.C プロジェクト: goni/HIN-15-001
void read_tpvar(const char* file, int YS, 
      const char* inputtable_pt, const char* outputtable_pt, 
      const char* inputtable_rap, const char* outputtable_rap, 
      const char* inputtable_cent="nocentrality", const char* outputtable_cent="nocentrality")
{
   // YS decides on the binning.
   // YS=1 -> fine binning
   // YS=2 -> coarse binning
   // YS=0 -> both
   // YS=4 -> both, except centrality where only fine (for 1S in pbpb)
   TFile *f = new TFile("tpvar.root","RECREATE");
   TTree *tr = new TTree("tree","tree");
   tr->ReadFile(file,"name/C:binlow/F:binhigh/F:eff/F:stat/F:syst/F");

   unsigned int NPTNS = YS==1 ? NPT1S : NPT2S;
   unsigned int NRAPNS = YS==1 ? NRAP1S : NRAP2S;
   unsigned int NCENTNS = YS==1 ? NCENT1S : NCENT2S;

   double *ptbins_NS = YS==1 ? ptbins_1S : ptbins_2S;
   double *rapbins_NS = YS==1 ? rapbins_1S : rapbins_2S;
   int *centbins_NS = YS==1 ? centbins_1S : centbins_2S;

   bool docentrality=strcmp(inputtable_cent,"nocentrality");
   ifstream intable_pt(inputtable_pt);
   ifstream intable_rap(inputtable_rap);
   ifstream intable_cent; if (docentrality) intable_cent.open(inputtable_cent);
   ofstream outtable_pt(outputtable_pt);
   ofstream outtable_rap(outputtable_rap);
   ofstream outtable_cent; if (docentrality) outtable_cent.open(outputtable_cent);
   double binmin, binmax, eff0, efferr, effmean;

   TString var("pt_SF");
   tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),ptbins_NS[0],ptbins_NS[NPTNS]),"PROFs");
   // tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),ptbins_NS[0],40.),"PROFs"); // ugly fix
   TProfile *htemp = (TProfile*) gDirectory->Get("htemp");
   binmin=ptbins_NS[0];
   binmax=ptbins_NS[NPTNS]; //40.;//(ugly fix)
   eff0=firsteff(tr,var.Data(),binmin,binmax);
   efferr=htemp->GetBinError(1);
   effmean=htemp->GetBinContent(1);
   cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
   if (dotables) print(intable_pt,outtable_pt,binmin,binmax,eff0,efferr);
   delete htemp;

   skip_lines(intable_pt,1);// \hline

   if (YS==0||YS==4)
   {
      NPTNS=NPT2S; ptbins_NS=ptbins_2S;
   }
   for (unsigned int i=0; i<NPTNS; i++)
   {
      // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),ptbins_1S[i],ptbins_1S[i+1]) << endl;
      tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),ptbins_1S[i],ptbins_1S[i+1]),"PROFs");
      htemp = (TProfile*) gDirectory->Get("htemp");
      binmin=ptbins_NS[i];
      binmax=ptbins_NS[i+1];
      eff0=firsteff(tr,var.Data(),ptbins_NS[i],ptbins_NS[i+1]);
      efferr=htemp->GetBinError(1);
      effmean=htemp->GetBinContent(1);
      cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
      if (dotables) print(intable_pt,outtable_pt,binmin,binmax,eff0,efferr);
      delete htemp;
   }

   if (YS==0||YS==4)
   {
      NPTNS=NPT1S; ptbins_NS=ptbins_1S;
      outtable_pt << "\\hline" << endl;
      skip_lines(intable_pt,1);// \hline

      for (unsigned int i=0; i<NPT1S; i++)
      {
         // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),ptbins_1S[i],ptbins_1S[i+1]) << endl;
         tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),ptbins_1S[i],ptbins_1S[i+1]),"PROFs");
         htemp = (TProfile*) gDirectory->Get("htemp");
         binmin=ptbins_NS[i];
         binmax=ptbins_NS[i+1];
         eff0=firsteff(tr,var.Data(),ptbins_NS[i],ptbins_NS[i+1]);
         efferr=htemp->GetBinError(1);
         effmean=htemp->GetBinContent(1);
         cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
         if (dotables) print(intable_pt,outtable_pt,binmin,binmax,eff0,efferr);
         delete htemp;
      }
   }

   var = TString("rapidity_SF");
   tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),rapbins_NS[0],rapbins_NS[NRAPNS]),"PROFs");
   htemp = (TProfile*) gDirectory->Get("htemp");
   binmin=rapbins_NS[0];
   binmax=rapbins_NS[NRAPNS];
   eff0=firsteff(tr,var.Data(),rapbins_NS[0],rapbins_NS[NRAPNS]);
   efferr=htemp->GetBinError(1);
   effmean=htemp->GetBinContent(1);
   cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
   delete htemp;

   if (YS==0||YS==4)
   {
      NRAPNS=NRAP2S; rapbins_NS=rapbins_2S;
   }
   for (unsigned int i=0; i<NRAPNS; i++)
   {
      // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),rapbins_NS[i],rapbins_NS[i+1]) << endl;
      tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),rapbins_NS[i],rapbins_NS[i+1]),"PROFs");
      htemp = (TProfile*) gDirectory->Get("htemp");
      binmin=rapbins_NS[i];
      binmax=rapbins_NS[i+1];
      eff0=firsteff(tr,var.Data(),rapbins_NS[i],rapbins_NS[i+1]);
      efferr=htemp->GetBinError(1);
      effmean=htemp->GetBinContent(1);
      cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
      if (dotables) print(intable_rap,outtable_rap,binmin,binmax,eff0,efferr);
      delete htemp;
   }

   if (YS==0||YS==4)
   {
      outtable_rap << "\\hline" << endl;
      skip_lines(intable_rap,1);// \hline
      NRAPNS=NRAP1S; rapbins_NS=rapbins_1S;
      for (unsigned int i=0; i<NRAPNS; i++)
      {
         // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),rapbins_NS[i],rapbins_NS[i+1]) << endl;
         tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),rapbins_NS[i],rapbins_NS[i+1]),"PROFs");
         htemp = (TProfile*) gDirectory->Get("htemp");
         binmin=rapbins_NS[i];
         binmax=rapbins_NS[i+1];
         eff0=firsteff(tr,var.Data(),rapbins_NS[i],rapbins_NS[i+1]);
         efferr=htemp->GetBinError(1);
         effmean=htemp->GetBinContent(1);
         cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
         if (dotables) print(intable_rap,outtable_rap,binmin,binmax,eff0,efferr);
         delete htemp;
      }
   }

   if (!docentrality) return;

   var = TString("centrality_SF");
   tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),centbins_NS[0]*2.5,centbins_NS[NCENTNS]*2.5),"PROFs");
   htemp = (TProfile*) gDirectory->Get("htemp");
   binmin=centbins_NS[0]*2.5;
   binmax=centbins_NS[NCENTNS]*2.5;
   eff0=firsteff(tr,var.Data(),centbins_NS[0]*2.5,centbins_NS[NCENTNS]*2.5);
   efferr=htemp->GetBinError(1);
   effmean=htemp->GetBinContent(1);
   cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
   delete htemp;

   if (YS==0)
   {
      NCENTNS=NCENT2S; centbins_NS=centbins_2S;
   }
   else if (YS==4)
   {
      NCENTNS=NCENT1S; centbins_NS=centbins_1S;
   }
   for (unsigned int i=0; i<NCENTNS; i++)
   {
      // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),centbins_NS[i],centbins_NS[i+1]) << endl;
      tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),centbins_NS[i]*2.5,centbins_NS[i+1]*2.5),"PROFs");
      htemp = (TProfile*) gDirectory->Get("htemp");
      binmin=centbins_NS[i]*2.5;
      binmax=centbins_NS[i+1]*2.5;
      eff0=firsteff(tr,var.Data(),centbins_NS[i]*2.5,centbins_NS[i+1]*2.5);
      efferr=htemp->GetBinError(1);
      effmean=htemp->GetBinContent(1);
      cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
      if (dotables) print(intable_cent,outtable_cent,binmin,binmax,eff0,efferr);
      delete htemp;
   }
   if (YS==0)
   {
      NCENTNS=NCENT1S; centbins_NS=centbins_1S;
      outtable_cent << "\\hline" << endl;
      skip_lines(intable_cent,1);// \hline
      for (unsigned int i=0; i<NCENTNS; i++)
      {
         // cout << setprecision(3)<<fixed << Form("name==\"%s\"&&binlow==%f&&binhigh==%f",var.Data(),centbins_NS[i],centbins_NS[i+1]) << endl;
         tr->Draw("eff:1>>htemp(1,0,2)",Form("name==\"%s\"&&abs(binlow-%f)<.1&&abs(binhigh-%f)<.1",var.Data(),centbins_NS[i]*2.5,centbins_NS[i+1]*2.5),"PROFs");
         htemp = (TProfile*) gDirectory->Get("htemp");
         binmin=centbins_NS[i]*2.5;
         binmax=centbins_NS[i+1]*2.5;
         eff0=firsteff(tr,var.Data(),centbins_NS[i]*2.5,centbins_NS[i+1]*2.5);
         efferr=htemp->GetBinError(1);
         effmean=htemp->GetBinContent(1);
         cout << setprecision(3)<<fixed << var << " " << binmin << " " << binmax << " " << eff0 << " " << efferr << " " << effmean << endl;
         if (dotables) print(intable_cent,outtable_cent,binmin,binmax,eff0,efferr);
         delete htemp;
      }
   }

   f->Write();
   f->Close();
}
コード例 #26
0
ファイル: mk_tree.C プロジェクト: c-dilks/scalers12
void mk_tree(const char * acc_file="datfiles/acc.dat")
{
  // read acc file into tree
  TTree * acc = new TTree("acc","counts tree from acc.dat");
  char cols[2048];
  char bbc_cols[256];
  char zdc_cols[256];
  char vpd_cols[256];
  for(Int_t i=0; i<=7; i++)
  {
    if(i==0) 
    {
      sprintf(bbc_cols,"bbc_%d/D",i);
      sprintf(zdc_cols,"zdc_%d/D",i);
      sprintf(vpd_cols,"vpd_%d/D",i);
    }
    else
    {
      sprintf(bbc_cols,"%s:bbc_%d/D",bbc_cols,i);
      sprintf(zdc_cols,"%s:zdc_%d/D",zdc_cols,i);
      sprintf(vpd_cols,"%s:vpd_%d/D",vpd_cols,i);
    };
  };
  sprintf(cols,"i/I:runnum/I:fi/I:fill/I:t/D:bx/I:%s:%s:%s:tot_bx/D:blue/I:yell/I",bbc_cols,zdc_cols,vpd_cols);
  printf("%s\n",cols);
  acc->ReadFile(acc_file,cols);

  acc->Print();

  Int_t IMAX_tmp = acc->GetMaximum("i");
  const Int_t IMAX = IMAX_tmp;

  // set branch addresses to read through acc tree
  Int_t index,runnum,fill_index,fill,bx;
  Double_t bbc[8];
  Double_t zdc[8];
  Double_t vpd[8];
  Double_t time;
  Double_t tot_bx;
  Int_t blue,yell;
  acc->SetBranchAddress("i",&index);
  acc->SetBranchAddress("runnum",&runnum);
  acc->SetBranchAddress("fi",&fill_index);
  acc->SetBranchAddress("fill",&fill);
  acc->SetBranchAddress("t",&time);
  acc->SetBranchAddress("bx",&bx);
  char str[16];
  for(Int_t i=0; i<8; i++) { sprintf(str,"bbc_%d",i); acc->SetBranchAddress(str,&bbc[i]); };
  for(Int_t i=0; i<8; i++) { sprintf(str,"zdc_%d",i); acc->SetBranchAddress(str,&zdc[i]); };
  for(Int_t i=0; i<8; i++) { sprintf(str,"vpd_%d",i); acc->SetBranchAddress(str,&vpd[i]); };
  acc->SetBranchAddress("tot_bx",&tot_bx);
  acc->SetBranchAddress("blue",&blue);
  acc->SetBranchAddress("yell",&yell);


  // build arrays for restructuring; arrays are needed so that
  // we can implement bXing shift corrections
  Double_t bbce_arr[IMAX][120];
  Double_t bbcw_arr[IMAX][120];
  Double_t bbcx_arr[IMAX][120];
  Double_t zdce_arr[IMAX][120];
  Double_t zdcw_arr[IMAX][120];
  Double_t zdcx_arr[IMAX][120];
  Double_t vpde_arr[IMAX][120];
  Double_t vpdw_arr[IMAX][120];
  Double_t vpdx_arr[IMAX][120];
  Int_t runnum_arr[IMAX];
  Int_t fi_arr[IMAX];
  Int_t fill_arr[IMAX];
  Double_t time_arr[IMAX];
  Double_t tot_bx_arr[IMAX][120];
  Int_t blue_arr[IMAX][120];
  Int_t yell_arr[IMAX][120];
  Bool_t kicked_arr[IMAX][120];


  // restructure tree into one suitable for analysis
  TTree * sca = new TTree("sca","restructured tree");
  Double_t bbce,bbcw,bbcx; // e=east, w=west, x=coincidence
  Double_t zdce,zdcw,zdcx;
  Double_t vpde,vpdw,vpdx;
  Bool_t okEntry,kicked;
  sca->Branch("i",&index,"i/I");
  sca->Branch("runnum",&runnum,"runnum/I");
  sca->Branch("fi",&fill_index,"fi/I");
  sca->Branch("fill",&fill,"fill/I");
  sca->Branch("t",&time,"t/D");
  sca->Branch("bx",&bx,"bx/I");
  sca->Branch("bbce",&bbce,"bbce/D");
  sca->Branch("bbcw",&bbcw,"bbcw/D");
  sca->Branch("bbcx",&bbcx,"bbcx/D");
  sca->Branch("zdce",&zdce,"zdce/D");
  sca->Branch("zdcw",&zdcw,"zdcw/D");
  sca->Branch("zdcx",&zdcx,"zdcx/D");
  sca->Branch("vpde",&vpde,"vpde/D");
  sca->Branch("vpdw",&vpdw,"vpdw/D");
  sca->Branch("vpdx",&vpdx,"vpdx/D");
  sca->Branch("tot_bx",&tot_bx,"tot_bx/D");
  sca->Branch("blue",&blue,"blue/I");
  sca->Branch("yell",&yell,"yell/I");
  sca->Branch("kicked",&kicked,"kicked/O");


  // read kicked bunches tree from "kicked" file
  TTree * kicked_tr = new TTree();
  kicked_tr->ReadFile("kicked","fill/I:bx/I:spinbit/I");
  Int_t kicked_fill,kicked_bx,kicked_spinbit;
  kicked_tr->SetBranchAddress("fill",&kicked_fill);
  kicked_tr->SetBranchAddress("bx",&kicked_bx);
  kicked_tr->SetBranchAddress("spinbit",&kicked_spinbit);
  
  for(Int_t q=0; q<acc->GetEntries(); q++)
  {
    acc->GetEntry(q);

    // -- see doc for bit details
    // BBC, ZDC, VPD bits: [ x w e ]
    bbce = bbc[1] + bbc[3] + bbc[5] + bbc[7]; // e + we + xe + xwe
    bbcw = bbc[2] + bbc[3] + bbc[6] + bbc[7]; // w + we + xw + xwe
    bbcx = bbc[3] + bbc[7]; // we + xwe

    zdce = zdc[1] + zdc[3] + zdc[5] + zdc[7]; // e + we + xe + xwe
    zdcw = zdc[2] + zdc[3] + zdc[6] + zdc[7]; // w + we + xw + xwe
    zdcx = zdc[3] + zdc[7]; // we + xwe
    
    vpde = vpd[1] + vpd[3] + vpd[5] + vpd[7]; // e + we + xe + xwe
    vpdw = vpd[2] + vpd[3] + vpd[6] + vpd[7]; // w + we + xw + xwe
    vpdx = vpd[3] + vpd[7]; // we + xwe


    // KICKED BUNCHES
    // manually omit empty bunches documented in pathologies.dat -- CLEAN UP PROCEDURE
    // (see 09.01.14 log entry)
    okEntry=true;
    // kicked bunches (presumably empty) 
    /*
    if(fill==17384 && (bx==29 || bx==30 || bx==117)) okEntry=false;
    if(fill==17416 && bx==79) okEntry=false;
    if(fill==17491 && bx==105) okEntry=false;
    if(fill==17519 && (bx==94 || bx==109)) okEntry=false;
    if(fill==17520 && bx==0) okEntry=false;
    if(fill==17529 && bx==97) okEntry=false;
    if(fill==17534 && bx==112) okEntry=false;
    if(fill==17553 && bx==73) okEntry=false;
    if(fill==17554 && (bx==7 || bx==14)) okEntry=false;
    if(fill==17555 && bx==61) okEntry=false;
    if(fill==17576 && bx==94) okEntry=false;
    // afterpulse-like bunches -- remove 1st 2 bunches after abort gaps 
    //if(fill==17512 && (bx>=40 && bx<=59)) okEntry=false;
    //if((fill>=17513 && fill<=17520) && ((bx>=0 && bx<=19) || (bx>=40 && bx<=59))) okEntry=false;
    */
    for(Int_t kk=0; kk<kicked_tr->GetEntries(); kk++)
    {
      kicked_tr->GetEntry(kk);
      if(fill==kicked_fill && bx==kicked_bx) okEntry=false;
    };
    
    kicked=!okEntry; // cleaned up analysis
    //kicked=0; // take all bXings
    

    // store data into arrays, implementing bXing shift corrections on scalers
    if(fill==16570 ||
       fill==16567)
    {
      bbce_arr[index-1][(bx+113)%120] = bbce; // shift down 7 bXings
      bbcw_arr[index-1][(bx+113)%120] = bbcw;
      bbcx_arr[index-1][(bx+113)%120] = bbcx;
      zdce_arr[index-1][(bx+113)%120] = zdce; // shift down 7 bXings
      zdcw_arr[index-1][(bx+113)%120] = zdcw;
      zdcx_arr[index-1][(bx+113)%120] = zdcx;
      vpde_arr[index-1][(bx+113)%120] = vpde; // shift down 7 bXings
      vpdw_arr[index-1][(bx+113)%120] = vpdw;
      vpdx_arr[index-1][(bx+113)%120] = vpdx;
    }
    else if(fill == 16582 ||
            fill == 16586 ||
            fill == 16587 || 
            fill == 16592 || 
            fill == 16593 || 
            fill == 16594 || 
            fill == 16597 || 
            fill == 16602)
    {
      bbce_arr[index-1][bx] = bbce; // no shift
      bbcw_arr[index-1][bx] = bbcw;
      bbcx_arr[index-1][bx] = bbcx;
      zdce_arr[index-1][bx] = zdce; // no shift
      zdcw_arr[index-1][bx] = zdcw;
      zdcx_arr[index-1][bx] = zdcx;
      vpde_arr[index-1][(bx+1)%120] = vpde; // shift up 1 bXings
      vpdw_arr[index-1][(bx+1)%120] = vpdw;
      vpdx_arr[index-1][(bx+1)%120] = vpdx;
    }
    else
    {
      bbce_arr[index-1][bx] = bbce;
      bbcw_arr[index-1][bx] = bbcw;
      bbcx_arr[index-1][bx] = bbcx;
      zdce_arr[index-1][bx] = zdce;
      zdcw_arr[index-1][bx] = zdcw;
      zdcx_arr[index-1][bx] = zdcx;
      vpde_arr[index-1][bx] = vpde;
      vpdw_arr[index-1][bx] = vpdw;
      vpdx_arr[index-1][bx] = vpdx;
    };

    runnum_arr[index-1] = runnum;
    fi_arr[index-1] = fill_index;
    fill_arr[index-1] = fill;
    time_arr[index-1] = time;
    tot_bx_arr[index-1][bx] = tot_bx;
    blue_arr[index-1][bx] = blue;
    yell_arr[index-1][bx] = yell;
    kicked_arr[index-1][bx] = kicked;
  };


  // fill restructured tree
  for(Int_t i=0; i<IMAX; i++)
  {
    index = i+1;
    runnum = runnum_arr[i];
    fill_index = fi_arr[i];
    fill = fill_arr[i];

    time = time_arr[i];
    for(Int_t b=0; b<120; b++)
    {
      bx = b;
      bbce = bbce_arr[i][b];
      bbcw = bbcw_arr[i][b];
      bbcx = bbcx_arr[i][b];
      zdce = zdce_arr[i][b];
      zdcw = zdcw_arr[i][b];
      zdcx = zdcx_arr[i][b];
      vpde = vpde_arr[i][b];
      vpdw = vpdw_arr[i][b];
      vpdx = vpdx_arr[i][b];
      tot_bx = tot_bx_arr[i][b];
      blue = blue_arr[i][b];
      yell = yell_arr[i][b];
      kicked = kicked_arr[i][b];
      sca->Fill();
    };
  };

  TFile * outfile = new TFile("counts.root","RECREATE");
  acc->Write("acc");
  sca->Write("sca");
  printf("counts.root written\n");
};
コード例 #27
0
ファイル: ModXSec.C プロジェクト: cfantasia/CMGWPrimeGroup
void
ModXSec(string inFile, string outFile, bool removeTaus=true, bool applyKFactors=true){
  bool doTC = inFile.find("TC") != string::npos;
  cout<<"doTC is "<<doTC<<endl;

  TTree* tLimit = new TTree("tLimit", "Limits");
  tLimit->ReadFile(inFile.c_str());

  ofstream out(outFile.c_str());

  if(doTC)  out<<"Rho/F:";
  else      out<<"Mass/F:";
  if(doTC){
    out<<"Pi/F:";
    out<<"SinX/F:";
  }
  out<<"Xsec/F:"
     <<"percentError/F"
     <<endl;

  //kfactors
  TGraph* gK = new TGraph(20);
  gK->SetPoint( 0, 200,1.347);
  gK->SetPoint( 1, 300,1.347);
  gK->SetPoint( 2, 500,1.363);
  gK->SetPoint( 3, 700,1.351);
  gK->SetPoint( 4, 900,1.347);
  gK->SetPoint( 5,1100,1.331);
  gK->SetPoint( 6,1300,1.317);
  gK->SetPoint( 7,1500,1.293);
  gK->SetPoint( 8,1700,1.257);
  gK->SetPoint( 9,1900,1.230);
  gK->SetPoint( 10,2000,1.214);

  //Signal pdf uncertainties
  TGraph* gPerErr = new TGraph(20);
  gPerErr->SetPoint(  0, 200,2.192);
  gPerErr->SetPoint(  1, 300,2.192);
  gPerErr->SetPoint(  2, 500,2.632);
  gPerErr->SetPoint(  3, 700,3.070);
  gPerErr->SetPoint(  4, 900,3.448);
  gPerErr->SetPoint(  5,1100,3.771);
  gPerErr->SetPoint(  6,1300,4.101);
  gPerErr->SetPoint(  7,1500,4.339);
  gPerErr->SetPoint(  8,1700,4.581);
  gPerErr->SetPoint(  9,1900,4.846);
  gPerErr->SetPoint( 10,2000,4.981);
  
  if(doTC) tLimit->Draw("Rho:Xsec:Pi:SinX", "SinX > 0.32 && SinX<0.34", "para goff");
  //if(doTC) tLimit->Draw("Rho:Xsec:Pi:SinX", "(280<=Rho && Rho<=300) && (150<=Pi && Pi<=160)", "para goff");
  else     tLimit->Draw("Mass:Xsec",        "", "para goff");
  float n = tLimit->GetSelectedRows(); 
  for(int isample=0; isample<n; ++isample){
    int idx=0;
    Double_t mass = tLimit->GetVal(idx++)[isample];
    Double_t xsec  = tLimit->GetVal(idx++)[isample];

    Double_t pi(-1), sinx(-1);
    if(doTC){
      pi   = tLimit->GetVal(idx++)[isample];
      sinx = tLimit->GetVal(idx++)[isample];
    }

    //cout<<"For rho: "<<rho<<" the kfactor is "<<gK->Eval(rho)<<endl; 
    
    //xsec *= 1e9; //convert from mb to pb
    if(removeTaus) xsec *= 4./9.; //convert from emt to em
    if(applyKFactors) xsec *= gK->Eval(mass);//apply k factor

    Double_t perErr  = gPerErr->Eval(mass);

    out.precision(0) ;
    out.setf ( ios::fixed, ios::floatfield);
    out  <<mass<<"\t";

    if(doTC){
      out.precision(0) ;
      out.setf ( ios::fixed, ios::floatfield);
      out  <<pi<<"\t";

      out.precision(4) ;
      out.setf ( ios::fixed, ios::floatfield);
      out  <<sinx<<"\t";
    }

    out.precision(4) ;
    out.setf ( ios::scientific, ios::floatfield);
    out  <<xsec<<"\t";
    
    out.precision(3);
    out.setf ( ios::fixed, ios::floatfield);
    out<<perErr<<"\t";
    out<<endl;

  }

}
コード例 #28
0
ファイル: csv.C プロジェクト: aatos/chep09tmva
void csv(TString input="tmva.csvoutput.txt", TString par1="par2", TString par2="par3", TString par3="", TString value="eventEffScaled_5") {
  std::cout << "Usage:" << std::endl
            << ".x scripts/csv.C    with default arguments" << std::endl
            << ".x scripts/csv.C(filename, par1, par2, value)" << std::endl
            << std::endl
            << "  Optional arguments:" << std::endl
            << "    filename        path to CSV file" << std::endl
            << "    par1            name of X-parameter branch" << std::endl
            << "    par2            name of Y-parameter branch (if empty, efficiency is drawn as a function of par1)" << std::endl
            << "    value           name of result (efficiency) branch" << std::endl
            << std::endl;

  TTree *tree = new TTree("data", "data");
  tree->ReadFile(input);

  gStyle->SetPalette(1);
  gStyle->SetPadRightMargin(0.14);

  TCanvas *canvas = new TCanvas("csvoutput", "CSV Output", 1200, 900);

  tree->SetMarkerStyle(kFullDotMedium);
  tree->SetMarkerColor(kRed);
  if(par2.Length() > 0) {
    //tree->Draw(Form("%s:%s", par2.Data(), par1.Data()));
    if(par3.Length() > 0)
      tree->Draw(Form("%s:%s:%s:%s", par1.Data(), par2.Data(), par3.Data(), value.Data()), "", "COLZ"); //, "", "Z");
    else
      tree->Draw(Form("%s:%s:%s", par2.Data(), par1.Data(), value.Data()), "", "COLZ"); //, "", "Z");

    TH1 *histo = tree->GetHistogram();
    if(!histo)
      return;

    histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
    histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
    histo->GetYaxis()->SetTitle(Form("Classifier parameter %s", par2.Data()));
    if(par3.Length() > 0)
      histo->GetZaxis()->SetTitle(Form("Classifier parameter %s", par3.Data()));
    else
      histo->GetZaxis()->SetTitle("");

    if(par3.Length() == 0) {
      float x = 0;
      float y = 0;
      float val = 0;
      double maxVal = tree->GetMaximum(value);
      double minVal = tree->GetMinimum(value);

      tree->SetBranchAddress(par1, &x);
      tree->SetBranchAddress(par2, &y);
      tree->SetBranchAddress(value, &val);
      TLatex l;
      l.SetTextSize(0.03);
    
      Long64_t nentries = tree->GetEntries();
      for(Long64_t entry=0; entry < nentries; ++entry) {
        tree->GetEntry(entry);
    
        l.SetTextColor(textColor(val, maxVal, minVal));
        l.DrawLatex(x, y, Form("%.3f", val*100));
      }
    }
  }
  else {
    tree->Draw(Form("%s:%s", value.Data(), par1.Data()));
    TH1 *histo = tree->GetHistogram();
    if(!histo) 
      return;
    histo->SetTitle(Form("%s with different classifier parameters", value.Data()));
    histo->GetXaxis()->SetTitle(Form("Classifier parameter %s", par1.Data()));
    histo->GetYaxis()->SetTitle(value);
  }
}
コード例 #29
0
plot_stability_mean(){

  gStyle->SetOptStat(0);

  TTree *tfit = new TTree();
  tfit->ReadFile("pi0peak_fit_Run13pp510ERT_reformat.txt","run_index/F:run_number:nevents:sector:mean:dmean:sigma:dsigma:chisquare");

  TTree *tfit_raw = new TTree();
  tfit_raw->ReadFile("pi0peak_fit_raw_Run13pp510ERT_reformat.txt","run_index/F:run_number:nevents:sector:mean:dmean:sigma:dsigma:chisquare");

  TLine *lpi0 = new TLine( 0, 0.137, tfit->GetEntries("sector==0"), 0.137 );
  lpi0->SetLineColor(kRed);

  // frame
  TH1F* hframe = new TH1F("hframe","",875,0,875);
  hframe->GetYaxis()->SetRangeUser(0.12,0.16);
  hframe->GetXaxis()->SetTitle("run");
  hframe->GetYaxis()->SetTitle("mean [GeV]");
  hframe->SetLineColor(kWhite);

  // sectors PbSc-West
  tfit->Draw("mean:run_index:dmean","sector==0");
  TGraphErrors *g_mean_PbScW = new TGraphErrors( tfit->GetEntries("sector==0"), tfit->GetV2(), tfit->GetV1(), 0, tfit->GetV3());

  tfit_raw->Draw("mean:run_index:dmean","sector==0");
  TGraphErrors *g_mean_PbScW_raw = new TGraphErrors( tfit_raw->GetEntries("sector==0"), tfit_raw->GetV2(), tfit_raw->GetV1(), 0, tfit_raw->GetV3());

  // sectors PbSc-East
  tfit->Draw("mean:run_index:dmean","sector==1");
  TGraphErrors *g_mean_PbScE = new TGraphErrors( tfit->GetEntries("sector==1"), tfit->GetV2(), tfit->GetV1(), 0, tfit->GetV3());

  tfit_raw->Draw("mean:run_index:dmean","sector==1");
  TGraphErrors *g_mean_PbScE_raw = new TGraphErrors( tfit_raw->GetEntries("sector==1"), tfit_raw->GetV2(), tfit_raw->GetV1(), 0, tfit_raw->GetV3());

  // sectors PbGl-East
  tfit->Draw("mean:run_index:dmean","sector==2");
  TGraphErrors *g_mean_PbGlE = new TGraphErrors( tfit->GetEntries("sector==2"), tfit->GetV2(), tfit->GetV1(), 0, tfit->GetV3());

  tfit_raw->Draw("mean:run_index:dmean","sector==2");
  TGraphErrors *g_mean_PbGlE_raw = new TGraphErrors( tfit_raw->GetEntries("sector==2"), tfit_raw->GetV2(), tfit_raw->GetV1(), 0, tfit_raw->GetV3());


  // Plotting
  TCanvas *c_PbScW = new TCanvas();
  hframe->Draw();
  g_mean_PbScW->Draw("Psame");
  lpi0->Draw("same");
  c_PbScW->Print("plots-escale-check/mpi0_mean_PbScW.png");

  TCanvas *c_PbScW_raw = new TCanvas();
  hframe->Draw();
  g_mean_PbScW_raw->Draw("Psame");
  lpi0->Draw("same");
  c_PbScW_raw->Print("plots-escale-check/mpi0_mean_PbScW_raw.png");

  TCanvas *c_PbScE = new TCanvas();
  hframe->Draw();
  g_mean_PbScE->Draw("Psame");
  lpi0->Draw("same");
  c_PbScE->Print("plots-escale-check/mpi0_mean_PbScE.png");

  TCanvas *c_PbScE_raw = new TCanvas();
  hframe->Draw();
  g_mean_PbScE_raw->Draw("Psame");
  lpi0->Draw("same");
  c_PbScE_raw->Print("plots-escale-check/mpi0_mean_PbScE_raw.png");

  TCanvas *c_PbGlE = new TCanvas();
  hframe->Draw();
  g_mean_PbGlE->Draw("Psame");
  lpi0->Draw("same");
  c_PbGlE->Print("plots-escale-check/mpi0_mean_PbGlE.png");

  TCanvas *c_PbGlE_raw = new TCanvas();
  hframe->Draw();
  g_mean_PbGlE_raw->Draw("Psame");
  lpi0->Draw("same");
  c_PbGlE_raw->Print("plots-escale-check/mpi0_mean_PbGlE_raw.png");

}
コード例 #30
0
ファイル: CalcLimit.C プロジェクト: cfantasia/CMGWPrimeGroup
void
CalcLimit(bool useCLs=true, string inName="nEvents.txt", string outName="nLimit.txt"){
  gErrorIgnoreLevel = kWarning;
  gSystem->SetIncludePath( "-I$ROOFITSYS/include" );
  gSystem->Load("libRooFit");
//  gSystem->SetIncludePath( "-I/afs/hep.wisc.edu/cern/.root/root_v5.30.00.Linux-slc5_amd64-gcc4.3/include/RooStats" );
  gROOT->ProcessLine(".L ../../../StatisticalTools/RooStatsRoutines/root/roostats_cl95.C+");
  
  string outfile(outName.c_str());
  ofstream out(outfile.c_str());
  if(!out) { 
    cout << "Cannot open file " << outfile << endl; 
    abort();
  } 
  
  out  << setiosflags(ios::fixed) << setprecision(4) << setiosflags(ios::left);
    
  out<<"SignalCode/F:"
     <<"Mass/F:"
     <<"Lumi/F:"
     <<"sLumi/F:"
     <<"Eff/F:"
     <<"sEff/F:"
     <<"DataEvts/F:"
     <<"BkgEvts/F:"
     <<"sBkgEvts/F:"
     <<"ObsLimit/F:"
     <<"ExpLimit/F:"
     <<"ExpLimitP1/F:"
     <<"ExpLimitM1/F:"
     <<"ExpLimitP2/F:"
     <<"ExpLimitM2/F"
     <<endl;

  TTree* tree = new TTree("tree", "Number of Events");
  tree->ReadFile(inName.c_str());
  tree->Draw("SignalCode:Mass:Lumi:DataEvts:BkgEvts:sBkgEvts:Eff:sEff", 
             "", "para goff");
  float n = tree->GetSelectedRows(); 
  for(int isample=0; isample<n; ++isample){
    const Double_t SignalCode = tree->GetVal(0)[isample];
    const Double_t  mass = tree->GetVal(1)[isample];
    const Double_t  lumi = tree->GetVal(2)[isample];
    const Double_t  DataEvts = tree->GetVal(3)[isample];
    const Double_t    BkgEvts = tree->GetVal(4)[isample];
    const Double_t   sBkgEvts = tree->GetVal(5)[isample];
    const Double_t       Eff = tree->GetVal(6)[isample];
    const Double_t      sEff = tree->GetVal(7)[isample];
    
    cout<<"Calculating limit for mass: "<<mass<<" and lumi: "<<lumi<<endl;
        
    float sLumi = sLumiFrac*lumi;
    
    Double_t obs_limit, exp_limit;
    Double_t exp_up, exp_down, exp_2up, exp_2down;
    
    if(useCLs){////CLs Limits
      //Does not work for bayesian, only works with cls    
      LimitResult limit = roostats_limit(lumi, sLumi, Eff, sEff, BkgEvts, sBkgEvts, DataEvts, false, 0, "cls", "", 12345);
      cout<<"\nCompleted Limit Calc\n";
      obs_limit = limit.GetObservedLimit();
      exp_limit = limit.GetExpectedLimit();
      exp_up    = limit.GetOneSigmaHighRange();
      exp_down  = limit.GetOneSigmaLowRange();
      exp_2up   = limit.GetTwoSigmaHighRange();
      exp_2down = limit.GetTwoSigmaLowRange();        
    }else{
      ////Bayesian Limits
      LimitResult limit  = roostats_clm (lumi, sLumi, Eff, sEff, BkgEvts, sBkgEvts);
      //obs_limit = limit.GetObservedLimit();
      obs_limit = roostats_cl95(lumi, sLumi, Eff, sEff, BkgEvts, sBkgEvts, DataEvts, false, 0, "bayesian", "");
      
      exp_limit = limit.GetExpectedLimit();
      exp_up    = limit.GetOneSigmaHighRange();
      exp_down  = limit.GetOneSigmaLowRange();
      exp_2up   = limit.GetTwoSigmaHighRange();
      exp_2down = limit.GetTwoSigmaLowRange();        
    }
  
    out<<setprecision(1)
       <<SignalCode<<"\t"
       <<setprecision(0)
       <<mass<<"\t"
       <<lumi<<"\t"
       <<sLumi<<"\t"
       <<setprecision(4)
       <<Eff<<"\t"
       <<sEff<<"\t"
       <<setprecision(0)
       <<DataEvts<<"\t"
       <<setprecision(4)
       <<BkgEvts<<"\t"
       <<sBkgEvts<<"\t";
//    out<<Value(obs_limit,-4)<<"\t"
//       <<Value(exp_limit,-4)<<"\t"
//       <<Value(exp_up,-4)<<"\t"
//       <<Value(exp_down,-4)<<"\t"
//       <<Value(exp_2up,-4)<<"\t"
//       <<Value(exp_2down,-4)
//       <<endl;
    out<<setprecision(8)
       <<obs_limit<<"\t"
       <<exp_limit<<"\t"
       <<exp_up<<"\t"
       <<exp_down<<"\t"
       <<exp_2up<<"\t"
       <<exp_2down
       <<endl;
  }
  
  out.close(); 
  cout<<"Done\n";
  return;
}