StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trighistcombiner.C
1 #include <fstream>
2 #include <map>
3 using namespace std;
4 
5 void trighistcombiner(const char* filelistname="trigevent.list")
6 {
7  map<int,int> trigmap;
8  const int nTriggers = 12;
9  int triggers[nTriggers] = {117001,137221,137222,137822,117300,137571,137575,137585,137586,137611,137501,137622};
10  gROOT->Macro("LoadLogger.C");
11  gROOT->Macro("loadMuDst.C");
12  gSystem->Load("StDaqLib");//for decoder
13  gSystem->Load("StDetectorDbMaker");
14  gSystem->Load("St_db_Maker");
15  gSystem->Load("StEmcRawMaker");
16  gSystem->Load("StEmcADCtoEMaker");
17  gSystem->Load("StTriggerUtilities");
18  gSystem->Load("StTriggerStudyMaker");
19 
20  TFile outfile("trighists.root","RECREATE");
21 
22  const char* dbTime = "2006-03-14 15:09:26";
23  StBemcTablesWriter* bemctables = new StBemcTablesWriter;
24  bemctables->loadTables(dbTime,"ofl");
25  StEmcGeom* mEmcGeom = StEmcGeom::instance("bemc");
26  StEmcDecoder* mDecoder = new StEmcDecoder();
27 
28  ifstream filelist(filelistname);
29  TH1F* dumhist;
30  TH1F* zvertall;
31  TH1F* bbctall;
32  TH1F* zverttrig[nTriggers];
33  TH1F* bbcttrig[nTriggers];
34  TH1F* jp1et;
35  TH1F* jp2et;
36  TH1F* jp2eff;
37  TH1F* jp1eff;
38  TH1F* jp1et0;
39  TH1F* jp0et0;
40  int nFiles = 0;
41  while(1){
42  char file[100];
43  filelist>>file;
44  if(!filelist.good())break;
45  TFile inputfile(file,"READ");
46  if(!inputfile.IsOpen())continue;
47  if(nFiles == 0){
48  zvertall = (TH1F*)inputfile.Get("zvertall");
49  bbctall = (TH1F*)inputfile.Get("bbctall");
50  jp1et = (TH1F*)inputfile.Get("jp1et");
51  jp2et = (TH1F*)inputfile.Get("jp2et");
52  jp1et0 = (TH1F*)inputfile.Get("jp1et0");
53  jp0et0 = (TH1F*)inputfile.Get("jp0et0");
54  jp1eff = (TH1F*)jp0et0->Clone("jp1eff");
55  jp2eff = (TH1F*)jp1et->Clone("jp2eff");
56  jp1eff->Reset();
57  jp2eff->Reset();
58  for(int i = 0; i < nTriggers; i++){
59  trigmap[triggers[i]] = i;;
60  char namez[100];
61  sprintf(namez,"zvert%i",triggers[i]);
62  zverttrig[i] = (TH1F*)inputfile.Get(namez);
63  char nameb[100];
64  sprintf(nameb,"bbct%i",triggers[i]);
65  bbcttrig[i] = (TH1F*)inputfile.Get(nameb);
66  }
67 
68  }else{
69  dumhist = (TH1F*)inputfile.Get("zvertall");
70  zvertall->Add(dumhist);
71  dumhist->Clear();
72  dumhist = (TH1F*)inputfile.Get("bbctall");
73  bbctall->Add(dumhist);
74  dumhist->Clear();
75  dumhist = (TH1F*)inputfile.Get("jp1et");
76  jp1et->Add(dumhist);
77  dumhist->Clear();
78  dumhist = (TH1F*)inputfile.Get("jp2et");
79  jp2et->Add(dumhist);
80  dumhist->Clear();
81  dumhist = (TH1F*)inputfile.Get("jp0et0");
82  jp0et0->Add(dumhist);
83  dumhist->Clear();
84  dumhist = (TH1F*)inputfile.Get("jp1et0");
85  jp1et0->Add(dumhist);
86  dumhist->Clear();
87  for(int i = 0; i < nTriggers; i++){
88  char namez[100];
89  sprintf(namez,"zvert%i",triggers[i]);
90  dumhist = (TH1F*)inputfile.Get(namez);
91  zverttrig[i]->Add(dumhist);
92  dumhist->Clear();
93  char nameb[100];
94  sprintf(nameb,"bbct%i",triggers[i]);
95  dumhist = (TH1F*)inputfile.Get(nameb);
96  bbcttrig[i]->Add(dumhist);
97  dumhist->Clear();
98  }
99  }
100  inputfile.Clear();
101  nFiles++;
102  }
103 
104  for(int i = 1; i <= jp1eff->GetNbinsX(); i++){
105  float jp1et0c = jp1et0->GetBinContent(i);
106  float jp0et0c = jp0et0->GetBinContent(i);
107  float jp1etc = jp1et->GetBinContent(i);
108  float jp2etc = jp2et->GetBinContent(i);
109  float jp1efferr = TMath::Sqrt(jp1et0c/(jp0et0c*jp0et0c) + (jp1et0c*jp1et0c)/(jp0et0c*jp0et0c*jp0et0c));
110  float jp2efferr = TMath::Sqrt(jp2etc/(jp1etc*jp1etc) + (jp2etc*jp2etc)/(jp1etc*jp1etc*jp1etc));
111  jp1eff->SetBinContent(i,jp1et0c/jp0et0c);
112  jp1eff->SetBinError(i,jp1efferr);
113  jp2eff->SetBinContent(i,jp2etc/jp1etc);
114  jp2eff->SetBinError(i,jp2efferr);
115  }
116 
117  jp1eff->SetTitle("JP1 Efficiency");
118  jp2eff->SetTitle("JP2 Efficiency");
119  jp1eff->GetYaxis()->SetRangeUser(0,1.2);
120  jp2eff->GetYaxis()->SetRangeUser(0,1.2);
121 
122  outfile.cd();
123  zvertall->Write();
124  bbctall->Write();
125  jp1et->Write();
126  jp2et->Write();
127  jp1et0->Write();
128  jp0et0->Write();
129  jp1eff->Write();
130  jp2eff->Write();
131  for(int i = 0; i < nTriggers; i++){
132  zverttrig[i]->Write();
133  bbcttrig[i]->Write();
134  }
135 
136  outfile.Write();
137  outfile.Close();
138 
139 }
void loadTables(const char *sqlTime, const char *flavor="ofl")
load directly from DB, no Maker needed