ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/IPHCalignment2/analysis/EvtByEvtComparison.h
Revision: 1.3
Committed: Wed Dec 7 08:34:02 2011 UTC (13 years, 4 months ago) by cgoetzma
Content type: text/plain
Branch: MAIN
CVS Tags: TBD2011, HEAD
Changes since 1.2: +103 -10 lines
Error occurred while calculating annotation data.
Log Message:
chris mods

File Contents

# Content
1 #ifndef EvtComparison_h
2 #define EvtComparison_h
3
4 #include <TROOT.h>
5 #include <TH1F.h>
6 #include <TCanvas.h>
7 #include <TLegend.h>
8 #include <THStack.h>
9 #include <TColor.h>
10 #include <TLorentzVector.h>
11 #include <vector>
12 #include <string>
13 #include <sstream>
14 #include <math.h>
15
16
17 #include "histoAlgo.h"
18
19
20 class TreeProducer;
21 class TwoBodyDecaySpy;
22
23
24 struct histoEvt
25 {
26 TH1D* diffPT;
27 TH1D* diffP;
28 TH1D* diffPX;
29 TH1D* diffPY;
30 TH1D* diffPZ;
31 TH1D* diffE;
32 TH1D* diffEta;
33 TH1D* diffPhi;
34 TH1D* diffMz;
35
36 std::string theName;
37
38 histoEvt(std::string name)
39 {
40 std::string title=name+" : PT";
41 diffPT = new TH1D(title.c_str(),title.c_str(),100,-1.,+1.);
42 title=name+" : P";
43 diffP = new TH1D(title.c_str(),title.c_str(),100,-4,+4);
44 title=name+" : PX";
45 diffPX = new TH1D(title.c_str(),title.c_str(),100,-1,+1);
46 title=name+" : PY";
47 diffPY = new TH1D(title.c_str(),title.c_str(),100,-1,+1);
48 title=name+" : PZ";
49 diffPZ = new TH1D(title.c_str(),title.c_str(),100,-4,+4);
50 title=name+" : E";
51 diffE = new TH1D(title.c_str(),title.c_str(),100,-4,+4);
52 title=name+" : Eta";
53 diffEta = new TH1D(title.c_str(),title.c_str(),100,-0.001,+0.001);
54 title=name+" : Phi";
55 diffPhi = new TH1D(title.c_str(),title.c_str(),100,-0.001,+0.001);
56 title=name+" : MZ";
57 diffMz = new TH1D(title.c_str(),title.c_str(),100,-2,+2);
58
59 // Some change to be sure that the string could be a filename
60
61 for (unsigned int i=0;i<name.size();i++)
62 {
63 if (name[i]=='^') name[i]='_';
64 else if (name[i]=='{') name[i]='_';
65 else if (name[i]=='}') name[i]='_';
66 else if (name[i]=='(') name[i]='_';
67 else if (name[i]==')') name[i]='_';
68 else if (name[i]==' ') name[i]='_';
69 else if (name[i]=='*') name[i]='_';
70 else if (name[i]=='/') name[i]='_';
71 else if (name[i]=='\\') name[i]='_';
72 else if (name[i]=='#') name[i]='_';
73 else if (name[i]=='+') name[i]='p';
74 else if (name[i]=='-') name[i]='m';
75 }
76
77 theName=name;
78 }
79
80
81 void Draw()
82 {
83 TCanvas* theCanvas = new TCanvas("comparison_canvas","comparison_canvas");
84
85 diffPT->SetLineColor(2);
86 diffPT->GetXaxis()->SetTitle("pT difference (GeV)");
87 diffPT->GetYaxis()->SetTitle("# events");
88 diffPT->Draw();
89 theCanvas->SaveAs((theName+"_diffPT.root").c_str());
90
91 diffP->SetLineColor(2);
92 diffP->GetXaxis()->SetTitle("p difference (GeV)");
93 diffP->GetYaxis()->SetTitle("# events");
94 diffP->Draw();
95 theCanvas->SaveAs((theName+"_diffP.root").c_str());
96
97 diffPX->SetLineColor(2);
98 diffPX->GetXaxis()->SetTitle("pX difference (GeV)");
99 diffPX->GetYaxis()->SetTitle("# events");
100 diffPX->Draw();
101 theCanvas->SaveAs((theName+"_diffPX.root").c_str());
102
103 diffPY->SetLineColor(2);
104 diffPY->GetXaxis()->SetTitle("pY difference (GeV)");
105 diffPY->GetYaxis()->SetTitle("# events");
106 diffPY->Draw();
107 theCanvas->SaveAs((theName+"_diffPY.root").c_str());
108
109 diffPZ->SetLineColor(2);
110 diffPZ->GetXaxis()->SetTitle("pZ difference (GeV)");
111 diffPZ->GetYaxis()->SetTitle("# events");
112 diffPZ->Draw();
113 theCanvas->SaveAs((theName+"_diffPZ.root").c_str());
114
115 diffE->SetLineColor(2);
116 diffE->GetXaxis()->SetTitle("E difference");
117 diffE->GetYaxis()->SetTitle("# events");
118 diffE->Draw();
119 theCanvas->SaveAs((theName+"_diffE.root").c_str());
120
121 diffEta->SetLineColor(2);
122 diffEta->GetXaxis()->SetTitle("pseudo-rapidity difference");
123 diffEta->GetYaxis()->SetTitle("# events");
124 diffEta->Draw();
125 theCanvas->SaveAs((theName+"_diffEta.root").c_str());
126
127 diffPhi->SetLineColor(2);
128 diffPhi->GetXaxis()->SetTitle("azimutal angle difference (rad)");
129 diffPhi->GetYaxis()->SetTitle("# events");
130 diffPhi->Draw();
131 theCanvas->SaveAs((theName+"_diffPhi.root").c_str());
132
133 diffMz->SetLineColor(2);
134 diffMz->GetXaxis()->SetTitle("invariant mass difference (GeV)");
135 diffMz->GetYaxis()->SetTitle("# events");
136 diffMz->Draw();
137 theCanvas->SaveAs((theName+"_diffMz.root").c_str());
138 }
139
140 // function that will be use for the matching between trcks from different trees
141 double cos(double a1, double b1, double c1, double a2, double b2, double c2)
142 {
143 double n1 = sqrt(a1*a1+b1*b1+c1*c1);
144 double n2 = sqrt(a2*a2+b2*b2+c2*c2);
145 double product = a1*a2+b1*b2+c1*c2;
146 return product/(n1*n2);
147 }
148
149 };
150
151 class EvtComparison
152 {
153 public:
154 EvtComparison() {}
155 ~EvtComparison() {}
156
157 void Compare(TwoBodyDecaySpy* a, TreeProducer* b, histoEvt& histos);
158 void Compare(TreeProducer* a, TreeProducer* b, histoEvt& histos);
159 void Compare(TwoBodyDecaySpy* a, TwoBodyDecaySpy* b, histoEvt& histos);
160
161 private:
162
163 void Compare(const std::vector<TLorentzVector>& spy,
164 const std::vector<TLorentzVector>& tree,
165 histoEvt& histos);
166
167
168 };
169
170 #endif
171