StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plLumi.C
1 #include <iostream>
2 #include <fstream>
3 
4 // This macro is used to determine the integrated luminosity for
5 // the Run 9 st_W triggered dataset from the *.wana.hist.root files
6 // produced from the St2009WlumiMaker.
7 
8 int plLumi(){
9  gStyle->SetPalette(1);
10  string line; int nRuns; float nTot;
11  //input/output files
12  ifstream infile("runList584.lis");
13  //ifstream infile("zdcRateHigh.csv");
14  ofstream outfile("lumi_sl11b.csv");
15  outfile<<"runNumber,nSBB,nBHT3,fDet,Lumi"<<endl;
16 
17  TString iPath="/star/data01/pwg/stevens4/wAnalysis/xSecPaper/sl11b/7.14.11/data/R";
18  float lumiTot=0; float lumiTotErr=0;
19  int BHT3prescale=50;
20  float BHT3xs=434000; // for HT sum
21 
22  int BTH3coinBin=5;
23 
24  //loop ovr 584 good data runs in analysis
25  while(infile.good()){
26  getline (infile,line);
27  if(line == ""){ //blank last line ie. end of file
28  cout<<"lumiTot="<<lumiTot<<" +/- "<<sqrt(lumiTotErr)<<endl;
29  return 0;
30  }
31 
32  string run = line.substr(0,8);
33  int runNum = atoi(run.data());
34 
35  //if(runNum>10094000) {
36  //continue;
37  //cout<<"lumiTot="<<lumiTot<<endl;
38  //return 0;
39  //}
40 
41  TString fullInpName=iPath; fullInpName+=run;
42  fullInpName+=".wana.hist.root";
43  fd=new TFile(fullInpName);
44 
45  tmp=(TH1F*)fd->Get(Form("lumi_AbortGap1_coinBin%d",BTH3coinBin));
46  int nAbortGap1=tmp->Integral();
47  tmp=(TH1F*)fd->Get(Form("lumi_AbortGap2_coinBin%d",BTH3coinBin));
48  int nAbortGap2=tmp->Integral();
49  float nSBB=nAbortGap1*120/11+nAbortGap2*120/9;
50  tmp=(TH1F*)fd->Get(Form("lumi_nBTH3coin_coinBin%d",BTH3coinBin));
51  float nBHT3=tmp->Integral();
52  tmp=(TH1F*)fd->Get("lumi_GoodvsT");
53  float fDet=tmp->Integral();
54 
55  //compute scaled number of BHT3+coin triggers
56  float nTrig=(nBHT3-nAbortGap1*110.0/8.0-nAbortGap2*110.0/8.0)*BHT3prescale/fDet;
57  float lumi=nTrig/BHT3xs;
58  lumiTot+=lumi;
59  float lumiErr=0;
60  if(nBHT3>0.) lumiErr=lumi/sqrt(nBHT3);
61  else cout<<runNum<<","<<nBHT3<<endl;
62  lumiTotErr+=lumiErr*lumiErr;
63 
64  outfile<<runNum<<","<<nSBB<<","<<nBHT3<<","<<fDet<<","<<lumi<<","<<lumiErr<<endl;
65 
66  }
67 
68  return 0;
69 
70 }
71