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 makePyEvts(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 = 100;
00091
00092 if (Higgsmass < 131)
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",800,Higgsminplot,400);
00102
00103 TH1F *Z1mass = new TH1F("Z1mass","Z1mass",800,0,400);
00104 TH1F *Z2mass = new TH1F("Z2mass","Z2mass",800,0,400);
00105 TH1F *Z_Pt = new TH1F("Z_Pt","Z_Pt",Nbins,0,150);
00106 TH1F *Z_phi = new TH1F("Z_phi","Z_phi",NbinIVplot,0,2*TMath::Pi());
00107 TH1F *Z_rapidity = new TH1F("Z_rapidity","Z_rapidity",NbinIVplot,-2.5,2.5);
00108
00109 TH1F *Higgs_Pt = new TH1F("Higgs_Pt","Higgs_Pt",Nbins,0,150);
00110 TH1F *Higgs_phi = new TH1F("Higgs_phi","Higgs_phi",NbinIVplot,0,2*TMath::Pi());
00111 TH1F *Higgs_rapidity = new TH1F("Higgs_rapidity","Higgs_rapidity",NbinIVplot,-2.5,2.5);
00112
00113 TH1F *Cosine1plot = new TH1F("Cosine1graph","Cos(#theta) angle of muon1 in Z1 rest frame",NbinIVplot,-1,1);
00114 TH1F *Cosine2plot = new TH1F("Cosine2graph","Cos(#theta) angle of muon2 in Z2 rest frame",NbinIVplot,-1,1);
00115 TH2F *Correlationplot = new TH2F("Correlationplot","Cos(#Theta) angle muon 1 versus Cos(#theta) angle muon 2",NbinIVplot,-1,1,NbinIVplot,-1,1);
00116
00117 TH1F *Muon1_phi = new TH1F("Muon1_phi","Muon1_phi",NbinIVplot,0,2*TMath::Pi());
00118 TH1F *Muon1_Pt = new TH1F("Muon1_Pt","Muon1_Pt",Nbins,0,150);
00119 TH1F *Muon1_rapidity = new TH1F("Muon1_rapidity","Muon2_rapidity",NbinIVplot,-2.5,2.5);
00120
00121 TH1F *Muons_Pt = new TH1F("Muons_Pt","Muons_Pt",Nbins,0,150);
00122 TH1F *Muons_rapidity = new TH1F("Muons_rapidity","Muons_rapidity",NbinIVplot,-2.5,2.5);
00123 TH1F *Muons_phi = new TH1F("Muons_phi","Muons_phi",NbinIVplot,0,2*TMath::Pi());
00124
00125 TH1F *Phiplot1 = new TH1F("Phiplot1","Phi angle of muon 1 in Z1 rest frame",NbinIVplot,0,2*TMath::Pi());
00126 TH1F *Phiplot2 = new TH1F("Phiplot2","Phi angle of muon 2 in Z2 rest frame",NbinIVplot,0,2*TMath::Pi());
00127
00128
00129 Int_t KF_muon =13;
00130
00131
00132
00133 TRandom2 R;
00134
00135
00136 for (Int_t ievt = 0; ievt < nEvents; ievt++)
00137 {
00138
00139 if (ievt % 100 == 0)
00140 cout << "Event # " << ievt << endl;
00141
00142
00143 pythia->GenerateEvent();
00144
00145
00146
00147
00148 TLorentzVector muonsum;
00149 TLorentzVector muon1plus, muon2plus, muon1minus , muon2minus;
00150
00151 int Nmuonplus=0;
00152 int Nmuonminus=0;
00153
00154 int Nz=0;
00155
00156
00157
00158 Int_t N = pythia->GetN();
00159
00160
00161
00162
00163
00164 Int_t N_muons =0;
00165 for (Int_t itk =1; itk<=N; itk++)
00166 {
00167
00168 Int_t KS = pythia->GetK(itk,1);
00169
00170 if ( KS!=21) continue;
00171
00172 Int_t KF = pythia->GetK(itk,2);
00173
00174
00175
00176 if ((abs(KF)== KF_muon))
00177 {
00178 TLorentzVector lvMuon = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4));
00179
00180
00181
00182 if(KS==21)
00183 { Muons_Pt->Fill(lvMuon.Pt());
00184 Muons_phi->Fill(lvMuon.Phi());
00185 Muons_rapidity->Fill(lvMuon.Rapidity());
00186 N_muons++;
00187
00188 muonsum+=lvMuon;
00189
00190
00191 if (KF<0)
00192 {
00193 if (Nmuonplus==1)
00194 {
00195 muon2plus = lvMuon;
00196 }
00197 if (Nmuonplus==0)
00198 {
00199 muon1plus = lvMuon;
00200 Nmuonplus=1;
00201 }
00202 }
00203 else
00204 {
00205 if (Nmuonminus==1)
00206 {
00207 muon2minus = lvMuon;
00208 }
00209 if (Nmuonminus==0)
00210 {
00211 muon1minus = lvMuon;
00212 Nmuonminus=1;
00213 Muon1_Pt->Fill(lvMuon.Pt());
00214 Muon1_rapidity->Fill(lvMuon.Rapidity());
00215 Muon1_phi->Fill(lvMuon.Phi());
00216 }
00217 }
00218 }
00219 else
00220 {
00221
00222 }
00223 }
00224
00225
00226 }
00227
00228
00229
00230
00231
00232
00233
00234 TLorentzVector Z1,Z2;
00235 Z1 = muon1plus + muon1minus;
00236 Z_Pt->Fill(Z1.Pt());
00237 Z_rapidity->Fill(Z1.Rapidity());
00238 Z_phi->Fill(Z1.Phi());
00239
00240 Z2 = muon2plus + muon2minus;
00241 Z_Pt->Fill(Z2.Pt());
00242 Z_rapidity->Fill(Z2.Rapidity());
00243 Z_phi->Fill(Z2.Phi());
00244
00245 Z1mass->Fill(Z1.M());
00246 Z2mass->Fill(Z2.M());
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 TVector3 boostH,boostZ1_hrest,boostZ2_hrest;
00283 TLorentzVector H,H_hrest,Z1_hrest,Z2_hrest,muon1_hrest,muon2_hrest,muon1_star,muon2_star,Z1_star,Z2_star,antimuon1_hrest,antimuon1_star;
00284 H = Z1+Z2;
00285 boostH = -H.BoostVector();
00286 H_hrest = H;
00287 Z1_hrest = Z1;
00288 Z2_hrest = Z2;
00289 muon1_hrest = muon1minus;
00290 muon2_hrest = muon2minus;
00291 antimuon1_hrest = muon1plus;
00292
00293 H_hrest.Boost(boostH);
00294
00295
00296
00297 Z1_hrest.Boost(boostH);
00298 Z2_hrest.Boost(boostH);
00299
00300
00301 muon1_hrest.Boost(boostH);
00302 muon2_hrest.Boost(boostH);
00303 antimuon1_hrest.Boost(boostH);
00304
00305 boostZ1_hrest = -Z1_hrest.BoostVector();
00306 boostZ2_hrest = -Z2_hrest.BoostVector();
00307
00308 Z1_star = Z1_hrest;
00309 Z2_star = Z2_hrest;
00310
00311 muon1_star = muon1_hrest;
00312 muon2_star = muon2_hrest;
00313 antimuon1_star = antimuon1_hrest;
00314
00315 Z1_star.Boost(boostZ1_hrest);
00316 Z2_star.Boost(boostZ2_hrest);
00317
00318
00319
00320 muon1_star.Boost(boostZ1_hrest);
00321 muon2_star.Boost(boostZ2_hrest);
00322 antimuon1_star.Boost(boostZ1_hrest);
00323
00324 TVector3 uZ1 = Z1_hrest.Vect().Unit();
00325 TVector3 uZ2 = Z2_hrest.Vect().Unit();
00326
00327 float cosine1, cosine2, antimuon_cosine1;
00328 TVector3 unit_muon1_star = muon1_star.Vect().Unit();
00329 cosine1 = uZ1.Dot(unit_muon1_star);
00330
00331
00332
00333
00334
00335 TVector3 unit_antimuon2_star = antimuon1_star.Vect().Unit();
00336 antimuon_cosine1 = uZ1.Dot(unit_antimuon2_star);
00337
00338
00339
00340 TVector3 unit_muon2_star = muon2_star.Vect().Unit();
00341 cosine2 = uZ2.Dot(unit_muon2_star);
00342
00343
00344 Cosine1plot->Fill(cosine1);
00345 Cosine2plot->Fill(cosine2);
00346 Correlationplot->Fill(cosine1,cosine2);
00347
00348 TVector3 x1(1.0,0.0,0.0),y1(0.0,1.0,0.0);
00349 x1.RotateUz(uZ1);
00350 y1.RotateUz(uZ1);
00351
00352
00353 TVector2 muon1_star2d(x1.Dot(unit_muon1_star),y1.Dot(unit_muon1_star));
00354 Phiplot1->Fill(muon1_star2d.Phi());
00355
00356 TVector3 x2(1.0,0.0,0.0),y2(0.0,1.0,0.0);
00357 x2.RotateUz(uZ2);
00358 y2.RotateUz(uZ2);
00359
00360
00361 TVector2 muon2_star2d(x2.Dot(unit_muon2_star),y2.Dot(unit_muon2_star));
00362 Phiplot2->Fill(muon2_star2d.Phi());
00363
00364
00365 bool didImessmuonplus=false;
00366 bool didImessmuonminus=false;
00367
00368
00369 if(R.Rndm()>0.5)
00370 {
00371 TLorentzVector temp;
00372 temp=muon1plus;
00373 muon1plus=muon2plus;
00374 muon2plus=temp;
00375 didImessmuonplus=true;
00376 }
00377
00378 if(R.Rndm()>0.5)
00379 {
00380 TLorentzVector temp;
00381 temp=muon1minus;
00382 muon1minus=muon2minus;
00383 muon2minus=temp;
00384 didImessmuonminus=true;
00385 }
00386
00387 int MM=didImessmuonminus;
00388 int MP=didImessmuonplus;
00389
00390
00391 bool condition=(MM || MP) && (!MP || !MM);
00392 bool auxcond=((MP+MM)&1);
00393 if (auxcond!=condition)
00394 cout <<condition<<" "<<((MP+MM)&1)<<endl;
00395
00396
00397
00398 Hmass->Fill(muonsum.M());
00399 Higgs_Pt->Fill(muonsum.Pt());
00400 Higgs_phi->Fill(muonsum.Phi());
00401 Higgs_rapidity->Fill(muonsum.Rapidity());
00402
00403 }
00404
00405
00406
00407
00408
00409
00410
00411 char name[100];
00412
00413
00414
00415 TCanvas * c3 = new TCanvas("c3","**",800,800);
00416 c3->Divide(2,2);
00417 c3->SetFillColor(9);
00418 c3->cd(1);
00419 Cosine1plot->Draw();
00420
00421 Cosine1plot->SetTitle("Cos(#theta) of muon1 in Z1 rest frame");
00422
00423 TF1 *f2 = new TF1("f2","[0]*([1]*(3/4)*(1-x**2)+(3/8)*(1-[1])*(1+x**2))",-1,1);
00424 TF1 *f3 = new TF1("f3","[0]*( (1/(1+[1]))*(3/4)*(1-x**2) + (3/8)*([1]/(1+[1]))*(1+x**2) )",-1,1);
00425 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);
00426
00427 f2->SetParNames("Normalization","alpha");
00428 f3->SetParNames("Normalization","R");
00429 f4->SetParNames("Normalization","tullyR");
00430
00431 f2->SetParameter(1,0.9);
00432 f3->SetParameter(1,0.1);
00433 f4->SetParameter(1,0.8);
00434
00435 f2->FixParameter(0,Cosine1plot->Integral("bin width"));
00436 f3->FixParameter(0,Cosine1plot->Integral("bin width"));
00437 f4->FixParameter(0,Cosine1plot->Integral("bin width"));
00438
00439 Cosine1plot->Fit("f2","L");
00440 Cosine1plot->Fit("f3","L+");
00441 Cosine1plot->Fit("f4","L+");
00442
00443
00444
00445
00446 c3->cd(2);
00447 Cosine2plot->Draw();
00448 c3->cd(3);
00449 Correlationplot->Draw();
00450
00451
00452
00453
00454
00455 TCanvas *c4 = new TCanvas("c4","**",800,800);
00456 c4->Divide(2,2);
00457 c4->SetFillColor(9);
00458 c4->cd(1);
00459 Phiplot1->Draw();
00460 c4->cd(2);
00461 Phiplot2->Draw();
00462
00463
00464 TCanvas * c5 = new TCanvas("c5","**",800,800);
00465 c5->SetFillColor(9);
00466 Hmass->Draw("e");
00467
00468 TCanvas * c6 = new TCanvas("c6","**",800,800);
00469 c6->cd();
00470 Z1mass->Draw();
00471
00472 TCanvas * c7 = new TCanvas("c7","**",800,800);
00473 c7->cd();
00474 Z2mass->Draw();
00475
00476 TCanvas * c8 = new TCanvas("c8","**",800,800);
00477 c8->cd();
00478 Higgs_Pt->Draw();
00479
00480
00481 TCanvas * c9 = new TCanvas("c9","**",800,800);
00482 c9->cd();
00483 Z_Pt->Draw();
00484
00485 TCanvas * c10 = new TCanvas("c10","**",800,800);
00486 c10->cd();
00487 Higgs_phi->Draw();
00488
00489 TCanvas * c11 = new TCanvas("c11","**",800,800);
00490 c11->cd();
00491 Higgs_rapidity->Draw();
00492
00493 TCanvas * c12 = new TCanvas("c12","**",800,800);
00494 c12->cd();
00495 Z_rapidity->Draw();
00496
00497 TCanvas * c13 = new TCanvas("c13","**",800,800);
00498 c13->cd();
00499 Z_phi->Draw();
00500
00501 TCanvas * c14 = new TCanvas("c14","**",800,800);
00502 c14->cd();
00503 Muon1_phi->Draw();
00504
00505 TCanvas * c15 = new TCanvas("c15","**",800,800);
00506 c15->cd();
00507 Muon1_Pt->Draw();
00508
00509 TCanvas * c16 = new TCanvas("c16","**",800,800);
00510 c16->cd();
00511 Muon1_rapidity->Draw();
00512
00513 TCanvas * c17 = new TCanvas("c17","**",800,800);
00514 c17->cd();
00515 Muons_Pt->Draw();
00516
00517 TCanvas * c18 = new TCanvas("c18","**",800,800);
00518 c18->cd();
00519 Muons_rapidity->Draw();
00520
00521 TCanvas * c19 = new TCanvas("c19","**",800,800);
00522 c19->cd();
00523 Muons_phi->Draw();
00524
00525
00526 sprintf(name,"histograms_correct_HtoZZ_angular_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents);
00527 TFile f(name,"recreate");
00528 f.cd();
00529 int N=gROOT->GetList()->GetSize();
00530 for (int key=0; key<N ; key++)
00531 {
00532
00533 TObject * obj = gROOT->GetList()->At(key);
00534 if (obj->InheritsFrom("TH1F") || obj->InheritsFrom("TH2F"))
00535 {
00536 cout <<"write "<<obj->GetName()<<endl;
00537 obj->Write();
00538
00539 }
00540 }
00541 f.Close();
00542
00543
00544 for (int key=N-1; key>=0 ; key--)
00545 {
00546
00547 TObject * obj = gROOT->GetList()->At(key);
00548 cout <<"delete "<<obj->GetName()<<endl;
00549 if (obj) delete obj;
00550 cout <<"deleted "<<gROOT->GetList()->GetSize()<<" objects remaining"<<endl;
00551 }
00552
00553 watcher.Stop();
00554 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl;
00555
00556 return -97534;
00557
00558 }
00559