ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/ResultLibraryClass.C
Revision: 1.2
Committed: Mon Mar 26 09:29:01 2012 UTC (13 years, 1 month ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.1: +6 -6 lines
Log Message:
Double out (dout) instead of cout to save results table to log as well

File Contents

# Content
1 #include <iostream>
2 #include "YieldClass.C"
3 #define ResultLibraryClassLoaded
4
5 using namespace std;
6
7 string ampersand=" & \t";
8
9 class tripple
10 {
11 public:
12 string name;
13 float first;
14 float second;
15 };
16
17 class LeptonResult
18 {
19 public:
20 float eemm;
21 float ee;
22 float mm;
23 float em;
24 };
25
26 std::ostream &operator<<(std::ostream &ostr, LeptonResult l)
27 {
28 return ostr << l.eemm << " (" << l.ee << " , " << l.mm << ")";
29 }
30
31 class LibraryForOneCut {
32 public:
33 Yield Zbkg; // Filled in ResultModule
34 Yield Flavorsym; // Filled in ResultModule
35 Yield total; // Filled in ResultModule
36 LeptonResult observed; // Filled in ResultModule
37 vector<tripple> SignalYield;
38 float UpperLimit;//Filled in ResultModule
39 float jzbcut; // Filled in ResultModule
40 void Print();
41 };
42
43 void LibraryForOneCut::Print() {
44 dout << "Library for jzb cut at " << this->jzbcut << " : " << endl;
45 dout << "Z prediction : " << Zbkg.value << " +/- " << Zbkg.syserror << " (sys) +/- " << Zbkg.staterror << " (stat)" << endl;
46 dout << "Flavorsym prediction : " << Flavorsym.value << " +/- " << Flavorsym.syserror << " (sys) +/- " << Flavorsym.staterror << " (stat)" << endl;
47 dout << "Total prediction: " << total.value << " +/- " << total.syserror << " (sys) +/- " << total.staterror << " (stat)" << endl;
48 dout << "Observed : " << observed.eemm << " (" << observed.ee << " , " << observed.mm << ")" << endl;
49 dout << "Upper Limits: " << UpperLimit << endl;
50
51 }
52
53 class ResultLibrary {
54 public:
55 vector<LibraryForOneCut> predictions;
56 void Add(LibraryForOneCut);
57 int Find(float);
58 void Print();
59 };
60
61 void ResultLibrary::Add(LibraryForOneCut alpha) {
62 this->predictions.push_back(alpha);
63 }
64
65 int ResultLibrary::Find(float jzbcut) {
66 for(int i=0;i<this->predictions.size();i++) if(this->predictions[i].jzbcut==jzbcut) return i;
67 // if cut wasn't found, create this library and return the new index!
68 LibraryForOneCut additional;
69 additional.jzbcut=jzbcut;
70 this->Add(additional);
71 cout << "A library for cut " << jzbcut << " was added " << endl;
72 return (this->predictions).size()-1;
73 }
74
75 void ResultLibrary::Print() {
76 cout << " \\hline" << endl;
77 cout << " " << ampersand << " ";
78 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " JZB > " << predictions[i].jzbcut << " GeV " << " ";
79 cout << " \\\\ \\hline" << endl;
80 cout << " " << ampersand << " Z bkgd ";
81 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " " << predictions[i].Zbkg;
82 cout << " \\\\" << endl;
83 cout << " " << ampersand << " flavor-symmetric ";
84 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " " << predictions[i].Flavorsym;
85 cout << " \\\\" << endl;
86 cout << " " << ampersand << " Total ";
87 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " " << predictions[i].total;
88 cout << " \\\\ \\hline" << endl;
89 cout << " " << ampersand << " Observed ";
90 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " " << predictions[i].observed;
91 cout << " \\\\ \\hline" << endl;
92 cout << " " << ampersand << " Upper Limit";
93 for(int i=0;i<this->predictions.size();i++) cout << ampersand << " " << predictions[i].UpperLimit;
94 cout << " \\\\ \\hline";
95 for(int isignal=0;isignal<this->predictions[0].SignalYield.size();isignal++) {
96 cout << endl;
97 cout << " " << ampersand << " " << predictions[0].SignalYield[isignal].name;
98 for(int i=0;i<this->predictions.size();i++) {
99 if(predictions[i].SignalYield.size()<=isignal) cout << "X";
100 else cout << ampersand << " " << predictions[i].SignalYield[isignal].first << " +/- " << predictions[i].SignalYield[isignal].second << " \\\\";
101 }
102 }
103 cout << " \\hline " << endl;
104
105 }
106
107 /*
108 int main() {
109 LibraryForOneCut tester;
110 LeptonResult observed;
111 observed.ee=2;
112 observed.mm=3;
113 observed.eemm=5;
114 Yield Zbkg;Zbkg.value=3;Zbkg.staterror=2;Zbkg.syserror=1;
115 Yield Flavorsym;Flavorsym.value=6;Flavorsym.staterror=5;Flavorsym.syserror=4;
116 Yield total;total.value=9;total.staterror=8;total.syserror=7;
117 float UpperLimit=15;
118 tester.observed=observed;
119 tester.jzbcut=11;
120 tester.Zbkg=Zbkg;
121 tester.Flavorsym=Flavorsym;
122 tester.total=total;
123 tester.UpperLimit=UpperLimit;
124 ResultLibrary hello;
125 vector<tripple> signals;
126 tripple signal;
127 signal.name="LM4";
128 signal.first=2;
129 signal.second=3;
130 (tester.SignalYield).push_back(signal);
131 signal.name="LM8";
132 signal.first=4;
133 signal.second=5;
134 tester.SignalYield.push_back(signal);
135
136
137 hello.Add(tester);
138 tester.SignalYield.push_back(signal);
139
140 tester.observed.ee=12;
141 tester.observed.mm=13;
142 tester.observed.eemm=25;
143 tester.jzbcut=50;
144 hello.Add(tester);
145 tester.jzbcut=150;
146 hello.Add(tester);
147 tester.Print();
148 hello.Print();
149 }
150 */