00001
00002
00003
00004
00005
00006
00007
00008
00009 #define ECM 14000
00010
00011
00012 #include <iostream>
00013 using namespace std;
00014
00015 #include "TStopwatch.h"
00016 #include "TH1F.h"
00017 #include "TH2F.h"
00018 #include "TF1.h"
00019 #include "TPythia6.h"
00020 #include "TCanvas.h"
00021 #include "TMath.h"
00022 #include "TRandom2.h"
00023 #include "TLorentzVector.h"
00024 #include "TVector3.h"
00025 #include "TVector2.h"
00026 #include "TFile.h"
00027 #include "TROOT.h"
00028
00029
00030
00031
00032 int makePyEvts1(int nEvents,float Higgsmass = 300 )
00033 {
00034
00035
00036 TPythia6* pythia = new TPythia6;
00037
00038
00039
00040 pythia->SetMSEL(0);
00041 pythia->SetMSUB(102,1);
00042 pythia->SetPMAS(25,1,Higgsmass);
00043 pythia->SetMSTP(61,0);
00044
00045
00046
00047 int KF = 23;
00048 int idcmin = pythia->GetMDCY(KF,2);
00049 int idcmax = idcmin + pythia->GetMDCY(KF,3);
00050 cout<<"MyOutput: Z idcmin="<<idcmin<<" idcmax="<<idcmax<<endl;
00051 for (int idc = idcmin; idc < idcmax; idc++)
00052 {
00053 pythia->SetMDME(idc,1,0);
00054 }
00055 pythia->SetMDME(184,1,1);
00056
00057
00058 KF = 25;
00059 idcmin = pythia->GetMDCY(KF,2);
00060 idcmax = idcmin + pythia->GetMDCY(KF,3);
00061 cout<<"MyOutput: Higgs idcmin="<<idcmin<<" idcmax="<<idcmax<<endl;
00062 for (Int_t idc = idcmin; idc < idcmax; idc++)
00063 {
00064 pythia->SetMDME(idc,1,0);
00065 }
00066 pythia->SetMDME(225,1,1);
00067
00068
00069 pythia->Initialize("cms", "p", "p", ECM);
00070
00071 float higgswidth = pythia->GetPMAS(25,2);
00072 cout<<"The higgs width from Pythia is "<<higgswidth<<endl;
00073
00074
00075 TStopwatch watcher;
00076 watcher.Reset();
00077 watcher.Start();
00078
00079
00080 float Higgsmass_max = 3000;
00081
00082
00083
00084
00085 int NbinIVplot = 100;
00086
00087
00088 float Higgsmaxplot = 3000;
00089 float Higgsminplot = 0.0;
00090 int Nbins = 300;
00091
00092 if (Higgsmass < 191)
00093 {
00094 Nbins = 500;
00095 Higgsminplot = Higgsmass - 5*higgswidth;
00096 Higgsmaxplot = Higgsmass + 5*higgswidth;
00097 }
00098
00099
00100
00101 TH1F *Hmass = new TH1F("Hmass","Higgs Mass",Nbins,Higgsminplot,Higgsmaxplot);
00102
00103 TH1F *Z1plot = new TH1F("Z1mass","Z1mass",Nbins,0,150);
00104 TH1F *Z2plot = new TH1F("Z2mass","Z2mass",Nbins,0,150);
00105
00106 TH1F *Cosine1plot = new TH1F("Cosine1graph","Cos(#theta) angle of muon1 in Z1 rest frame",NbinIVplot,-1,1);
00107 TH1F *Cosine2plot = new TH1F("Cosine2graph","Cos(#theta) angle of muon2 in Z2 rest frame",NbinIVplot,-1,1);
00108 TH2F *Correlationplot = new TH2F("Correlationplot","Theta angle muon 1 versus theta angle muon 2",NbinIVplot,-1,1,NbinIVplot,-1,1);
00109
00110 TH1F *Phiplot1 = new TH1F("Phiplot1","Phi angle of muon 1 in Z1 rest frame",NbinIVplot,0,2*TMath::Pi());
00111 TH1F *Phiplot2 = new TH1F("Phiplot2","Phi angle of muon 2 in Z2 rest frame",NbinIVplot,0,2*TMath::Pi());
00112
00113
00114 Int_t KF_muon =13;
00115
00116
00117
00118 TRandom2 R;
00119
00120
00121 for (Int_t ievt = 0; ievt < nEvents; ievt++)
00122 {
00123
00124 if (ievt % 100 == 0)
00125 cout << "Event # " << ievt << endl;
00126
00127
00128 pythia->GenerateEvent();
00129
00130
00131
00132
00133 TLorentzVector muonsum;
00134 TLorentzVector muon1plus, muon2plus, muon1minus , muon2minus;
00135
00136 int Nmuonplus=0;
00137 int Nmuonminus=0;
00138
00139 int Nz=0;
00140
00141
00142
00143 Int_t N = pythia->GetN();
00144
00145
00146
00147
00148
00149 Int_t N_muons =0;
00150 for (Int_t itk =1; itk<=N; itk++)
00151 {
00152
00153 Int_t KS = pythia->GetK(itk,1);
00154
00155 if ( KS!=21) continue;
00156
00157 Int_t KF = pythia->GetK(itk,2);
00158
00159
00160
00161 if ((abs(KF)== KF_muon))
00162 {
00163 TLorentzVector lvMuon = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4));
00164
00165
00166
00167 if(KS==21)
00168 {
00169 N_muons++;
00170
00171 muonsum+=lvMuon;
00172
00173
00174 if (KF<0)
00175 {
00176 if (Nmuonplus==1)
00177 {
00178 muon2plus = lvMuon;
00179 }
00180 if (Nmuonplus==0)
00181 {
00182 muon1plus = lvMuon;
00183 Nmuonplus=1;
00184 }
00185 }
00186 else
00187 {
00188 if (Nmuonminus==1)
00189 {
00190 muon2minus = lvMuon;
00191 }
00192 if (Nmuonminus==0)
00193 {
00194 muon1minus = lvMuon;
00195 Nmuonminus=1;
00196 }
00197 }
00198 }
00199 else
00200 {
00201
00202 }
00203 }
00204
00205
00206 }
00207
00208
00209
00210
00211
00212
00213
00214 TLorentzVector Z1,Z2;
00215 Z1 = muon1plus + muon1minus;
00216 Z2 = muon2plus + muon2minus;
00217 Z1plot->Fill(Z1.M());
00218 Z2plot->Fill(Z2.M());
00219
00220
00221
00222
00223
00224 TVector3 boostZ1,boostZ2;
00225
00226
00227
00228
00229 boostZ1 = - Z1.BoostVector();
00230 boostZ2 = - Z2.BoostVector();
00231
00232
00233
00234
00235
00236 TLorentzVector muon1_star,antimuon1_star;
00237
00238 muon1_star = muon1minus;
00239 antimuon1_star = muon1plus;
00240
00241
00242 muon1_star.Boost(boostZ1);
00243 antimuon1_star.Boost(boostZ1);
00244
00245
00246
00247 TLorentzVector Z2_star,muon2_star,antimuon2_star;
00248
00249 muon2_star = muon2minus;
00250 antimuon2_star = muon2plus;
00251 muon2_star.Boost(boostZ2);
00252 antimuon2_star.Boost(boostZ2);
00253
00254
00255
00256 TVector3 boostH;
00257 TLorentzVector H,H_hrest,Z1_hrest,Z2_hrest;
00258 H = Z1+Z2;
00259 boostH = -H.BoostVector();
00260 H_hrest = H;
00261 Z1_hrest = Z1;
00262 Z2_hrest = Z2;
00263 H_hrest.Boost(boostH);
00264 Z1_hrest.Boost(boostH);
00265 Z2_hrest.Boost(boostH);
00266
00267
00268
00269 TVector3 uZ1=Z1_hrest.Vect().Unit();
00270 TVector3 uZ2=Z2_hrest.Vect().Unit();
00271
00272 float cosine1, cosine2;
00273 TVector3 unit_muon1_star = muon1_star.Vect().Unit();
00274 cosine1 = uZ1.Dot(unit_muon1_star);
00275
00276
00277
00278
00279 TVector3 unit_muon2_star = muon2_star.Vect().Unit();
00280 cosine2 = uZ2.Dot(unit_muon2_star);
00281
00282 Cosine1plot->Fill(cosine1);
00283 Cosine2plot->Fill(cosine2);
00284 Correlationplot->Fill(cosine1,cosine2);
00285
00286 TVector3 x1(1.0,0.0,0.0),y1(0.0,1.0,0.0);
00287 x1.RotateUz(uZ1);
00288 y1.RotateUz(uZ1);
00289
00290
00291 TVector2 muon1_star2d(x1.Dot(unit_muon1_star),y1.Dot(unit_muon1_star));
00292 Phiplot1->Fill(muon1_star2d.Phi());
00293
00294 TVector3 x2(1.0,0.0,0.0),y2(0.0,1.0,0.0);
00295 x2.RotateUz(uZ2);
00296 y2.RotateUz(uZ2);
00297
00298
00299 TVector2 muon2_star2d(x2.Dot(unit_muon2_star),y2.Dot(unit_muon2_star));
00300 Phiplot2->Fill(muon2_star2d.Phi());
00301
00302
00303
00304 Hmass->Fill(muonsum.M());
00305
00306 }
00307
00308
00309
00310
00311
00312
00313
00314 char name[100];
00315
00316
00317
00318 TCanvas * c3 = new TCanvas("c3","**",800,800);
00319 c3->Divide(2,2);
00320 c3->SetFillColor(9);
00321 c3->cd(1);
00322 Cosine1plot->Draw();
00323
00324 Cosine1plot->SetTitle("Cos(#theta) of muon1 in Z1 rest frame");
00325
00326 TF1 *f2 = new TF1("f2","[0]*([1]*(3/4)*(1-x**2)+(3/8)*(1-[1])*(1+x**2))",-1,1);
00327 TF1 *f3 = new TF1("f3","[0]*( (1/(1+[1]))*(3/4)*(1-x**2) + (3/8)*([1]/(1+[1]))*(1+x**2) )",-1,1);
00328 TF1 *f4 = new TF1("f4","[0]*( ((-1-[1])/([1]-3)) * (3/4)*(1-x**2) + (3/8)*((2*[1]-2)/([1]-3))*(1+x**2) )",-1,1);
00329
00330 f2->SetParNames("Normalization","alpha");
00331 f3->SetParNames("Normalization","R");
00332 f4->SetParNames("Normalization","tullyR");
00333
00334 f2->SetParameter(1,0.9);
00335 f3->SetParameter(1,0.1);
00336 f4->SetParameter(1,0.8);
00337
00338 f2->FixParameter(0,Cosine1plot->Integral("bin width"));
00339 f3->FixParameter(0,Cosine1plot->Integral("bin width"));
00340 f4->FixParameter(0,Cosine1plot->Integral("bin width"));
00341
00342 Cosine1plot->Fit("f2","L");
00343 Cosine1plot->Fit("f3","L+");
00344 Cosine1plot->Fit("f4","L+");
00345
00346
00347
00348
00349 c3->cd(2);
00350 Cosine2plot->Draw();
00351 c3->cd(3);
00352 Correlationplot->Draw();
00353
00354
00355
00356
00357
00358 TCanvas *c4 = new TCanvas("c4","**",800,800);
00359 c4->Divide(2,2);
00360 c4->SetFillColor(9);
00361 c4->cd(1);
00362 Phiplot1->Draw();
00363 c4->cd(2);
00364 Phiplot2->Draw();
00365
00366
00367 TCanvas * c5 = new TCanvas("c5","**",800,800);
00368 c5->SetFillColor(9);
00369 Hmass->Draw("e");
00370
00371 TCanvas * c6 = new TCanvas("c6","**",800,800);
00372 c6->cd();
00373 Z1plot->Draw();
00374
00375 TCanvas * c7 = new TCanvas("c6","**",800,800);
00376 c7->cd();
00377 Z2plot->Draw();
00378
00379 sprintf(name,"histograms_correct_HtoZZ_angular__incorrectboost_1_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents);
00380 TFile f(name,"recreate");
00381 f.cd();
00382 int N=gROOT->GetList()->GetSize();
00383 for (int key=0; key<N ; key++)
00384 {
00385
00386 TObject * obj = gROOT->GetList()->At(key);
00387 if (obj->InheritsFrom("TH1F") || obj->InheritsFrom("TH2F"))
00388 {
00389 cout <<"write "<<obj->GetName()<<endl;
00390 obj->Write();
00391
00392 }
00393 }
00394 f.Close();
00395
00396
00397 for (int key=N-1; key>=0 ; key--)
00398 {
00399
00400 TObject * obj = gROOT->GetList()->At(key);
00401 cout <<"delete "<<obj->GetName()<<endl;
00402 if (obj) delete obj;
00403 cout <<"deleted "<<gROOT->GetList()->GetSize()<<" objects remaining"<<endl;
00404 }
00405
00406 watcher.Stop();
00407 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl;
00408
00409 return -97534;
00410
00411 }
00412