-
Notifications
You must be signed in to change notification settings - Fork 0
/
etadiff.cc
executable file
·236 lines (216 loc) · 4.79 KB
/
etadiff.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* to find the number of gammajets that fall in all ranges of eta vs a specific range*/
#include "Pythia8/Pythia.h"
using namespace Pythia8;
using namespace std;
#include "TFile.h"
#include "TTree.h"
#include "TRandom3.h"
#include "TMath.h"
#include "Utils.C"
float deltaPhi(Photon p, Jet j);
float deltaR(Parton,Jet);
class DiJet
{
public:
DiJet(Jet j1, Jet j2){
leading = bigger(j1,j2);
subleading=smaller(j1,j2);
}
DiJet(double pt1, double phi1, double pt2,double phi2){
if (pt1>pt2)
{
leading=Jet(pt1,phi1,0,0);
subleading=Jet(pt2,phi2,0,0);
}
else{
subleading=Jet(pt1,phi1,0,0);
leading=Jet(pt2,phi2,0,0);
}
makeXjPhi();
}
DiJet(){}
~DiJet(){}
Jet getleading(){
return leading;
}
Jet getsubleading(){
return subleading;
}
private:
void makeXjPhi(){
xjphi=XjPhi(leading,subleading);
}
Jet leading;
Jet subleading;
XjPhi xjphi;
};
class PhotonJet
{
public:
PhotonJet(){}
PhotonJet(Photon p, Jet j){
photon = p;
jet = j;
makeXjPhi();
}
PhotonJet(bool f){ //place holder for NULL events
xjphi= XjPhi(0,2*TMath::Pi());
}
PhotonJet(Photon p, DiJet d){
//get the Jet with the bigger difference in phi
if (deltaPhi(p,d.getleading())>deltaPhi(p,d.getsubleading()))
{
jet = d.getleading();
}
else{
jet = d.getsubleading();
}
photon=p;
makeXjPhi();
}
PhotonJet(Photon p, Jet j1, Jet j2){
photon=p;
if (deltaPhi(p,j1)>deltaPhi(p,j2))
{
jet=j1;
}
else{
jet=j2;
}
makeXjPhi();
}
PhotonJet(Photon p){//for events with no paired jet
photon=p;
xjphi=XjPhi(0,0);
}
~PhotonJet(){}
Scalar getXj(){
return xjphi.getXj();
}
Scalar getphi(){
return xjphi.getphi();
}
Photon getPhoton(){
return photon;
}
Jet getJet(){
return jet;
}
bool isDirect(){
return photon.isDirect();
}
void matchPartons(Parton p1, Parton p2){
if (deltaR(p1,jet)<deltaR(p2,jet))
{
jet.setParton(p1);
photon.setParton(p2);
}
else{
jet.setParton(p2);
photon.setParton(p1);
}
}
bool isJetQuark(){
return jet.isJetQuark();
}
friend ostream& operator<<(ostream& os, PhotonJet const & tc) {
return os << tc.xjphi;
}
private:
void makeXjPhi(){
xjphi = XjPhi(photon,jet);
}
Photon photon;
Jet jet;
XjPhi xjphi;
};
template<class T>
T positivePhi(T in){
if (in<0)
{
in = in+2*TMath::Pi();
}
return in;
}
inline bool quickPhotonCheck(Particle p){
return p.id()==22&&p.isFinal()&&p.pT()>10;
}
queue<myParticle> EventToQueue(Event e){
myParticle temp;
queue<myParticle> r;
for (int i = 0; i < e.size(); ++i)
{
temp = myParticle(e[i].id(),e[i].pT(),e[i].phi(),e[i].y());
r.push(temp);
}
return r;
}
void makeData(std::string filename, int nEvents){
/*TFile* f = new TFile(filename.c_str(),"RECREATE");
TTree* directTree=new TTree("tree100","direct");*/
Pythia pythiaengine;
pythiaengine.readString("Beams:eCM = 200.");
pythiaengine.readString("promptphoton:all = on");
pythiaengine.readString("HardQCD:all = on");
pythiaengine.readString("PhaseSpace:pTHatMin = 10.");
pythiaengine.readString("Random::setSeed = on");
pythiaengine.readString("Random::seed =0");
pythiaengine.init();
SlowJet *antikT = new SlowJet(-1,.4,10,4,2,1);
int total=0;
int etaCut=0;
int eTCut=0;
int seperated=0;
PhotonJet tempXj;
for (int iEvent = 0; iEvent < nEvents; ++iEvent)
{
if (!pythiaengine.next()){
cout<<"pythia.next() failed"<<"\n";
iEvent--;
continue;
}
for (int i = 0; i < pythiaengine.event.size(); ++i)
{
if (quickPhotonCheck(pythiaengine.event[i]))
{
total++;
if (TMath::Abs(pythiaengine.event[i].eta())<1.1)
{
etaCut++;
}
Photon myPhoton = Photon(pythiaengine.event[i].pT(),positivePhi(pythiaengine.event[i].phi()),pythiaengine.event[i].eta(),EventToQueue(pythiaengine.event));
antikT->analyze(pythiaengine.event);
if(antikT->sizeJet()>1){
tempXj=PhotonJet(myPhoton,Jet(antikT->pT(1),positivePhi(antikT->phi(1)),positivePhi(antikT->y(1))),Jet(antikT->pT(0),positivePhi(antikT->phi(0)),positivePhi(antikT->y(0))));
if (myPhoton.getIsoEt()<3)
{
eTCut++;
}
if (tempXj.getphi()>7*TMath::Pi()/8)
{
seperated++;
}
}
}
}
}
cout<<"Total:"<<total<<" eta:"<<etaCut<<"et:"<<eTCut<<" Seperated:"<<seperated<<endl;
}
int main(int argc, char const *argv[] )
{
string fileOut = string(argv[1]);
int nEvents = 1000000;
makeData(fileOut,nEvents);
return 0;
}
float deltaPhi(Photon p, Jet j){
Scalar r= Scalar(TMath::Abs((p.getphi()-j.getphi()).value));
if (r>TMath::Pi())
{
r= r*(-1)+2*TMath::Pi();
}
return r.value;
}
inline float deltaR(Parton p, Jet j){
return TMath::Power(TMath::Power(TMath::Abs(p.getphi()-j.getphi().value),2)+TMath::Power(TMath::Abs(p.gety()-j.gety().value),2),.5);
}