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 = 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
00112
00113 TH2F *Correlationplot_theta1_phi = new TH2F("Correlationplot_theta1_phi","Phi angle versus theta angle muon 1",NbinIVplot,-1,1,NbinIVplot,0,2*TMath::Pi());
00114 TH2F *Correlationplot_theta2_phi = new TH2F("Correlationplot_theta2_phi","Phi angle versus theta angle muon 2",NbinIVplot,-1,1,NbinIVplot,0,2*TMath::Pi());
00115
00116 Int_t KF_muon =13;
00117
00118
00119
00120 TRandom2 R;
00121
00122
00123 for (Int_t ievt = 0; ievt < nEvents; ievt++)
00124 {
00125
00126 if (ievt % 100 == 0)
00127 cout << "Event # " << ievt << endl;
00128
00129
00130 pythia->GenerateEvent();
00131
00132
00133
00134
00135 TLorentzVector muonsum;
00136 TLorentzVector muon1plus, muon2plus, muon1minus , muon2minus;
00137
00138 int Nmuonplus=0;
00139 int Nmuonminus=0;
00140
00141 int Nz=0;
00142
00143
00144
00145 Int_t N = pythia->GetN();
00146
00147
00148
00149
00150
00151 Int_t N_muons =0;
00152 for (Int_t itk =1; itk<=N; itk++)
00153 {
00154
00155 Int_t KS = pythia->GetK(itk,1);
00156
00157 if ( KS!=21) continue;
00158
00159 Int_t KF = pythia->GetK(itk,2);
00160
00161
00162
00163 if ((abs(KF)== KF_muon))
00164 {
00165 TLorentzVector lvMuon = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4));
00166
00167
00168
00169 if(KS==21)
00170 {
00171 N_muons++;
00172
00173 muonsum+=lvMuon;
00174
00175
00176 if (KF<0)
00177 {
00178 if (Nmuonplus==1)
00179 {
00180 muon2plus = lvMuon;
00181 }
00182 if (Nmuonplus==0)
00183 {
00184 muon1plus = lvMuon;
00185 Nmuonplus=1;
00186 }
00187 }
00188 else
00189 {
00190 if (Nmuonminus==1)
00191 {
00192 muon2minus = lvMuon;
00193 }
00194 if (Nmuonminus==0)
00195 {
00196 muon1minus = lvMuon;
00197 Nmuonminus=1;
00198 }
00199 }
00200 }
00201 else
00202 {
00203
00204 }
00205 }
00206
00207
00208 }
00209
00210
00211
00212
00213
00214
00215
00216 TLorentzVector Z1,Z2;
00217 Z1 = muon1plus + muon1minus;
00218 Z2 = muon2plus + muon2minus;
00219 Z1plot->Fill(Z1.M());
00220 Z2plot->Fill(Z2.M());
00221
00222
00223
00224 TVector3 boostH,boostZ1_hrest,boostZ2_hrest;
00225 TLorentzVector H,H_hrest,Z1_hrest,Z2_hrest,muon1_hrest,muon2_hrest,muon1_star,muon2_star,Z1_star,Z2_star;
00226 H = Z1+Z2;
00227 boostH = -H.BoostVector();
00228 H_hrest = H;
00229 Z1_hrest = Z1;
00230 Z2_hrest = Z2;
00231 muon1_hrest = muon1minus;
00232 muon2_hrest = muon2minus;
00233 H_hrest.Boost(boostH);
00234 Z1_hrest.Boost(boostH);
00235 Z2_hrest.Boost(boostH);
00236 muon1_hrest.Boost(boostH);
00237 muon2_hrest.Boost(boostH);
00238
00239 boostZ1_hrest = -Z1_hrest.BoostVector();
00240 boostZ2_hrest = -Z2_hrest.BoostVector();
00241
00242 Z1_star = Z1_hrest;
00243 Z2_star = Z2_hrest;
00244
00245 muon1_star = muon1_hrest;
00246 muon2_star = muon2_hrest;
00247
00248 muon1_star.Boost(boostZ1_hrest);
00249 muon2_star.Boost(boostZ2_hrest);
00250
00251 TVector3 uZ1 = Z1_hrest.Vect().Unit();
00252 TVector3 uZ2 = Z2_hrest.Vect().Unit();
00253
00254 float cosine1, cosine2;
00255 TVector3 unit_muon1_star = muon1_star.Vect().Unit();
00256 cosine1 = uZ1.Dot(unit_muon1_star);
00257 cout<<"The angle cosine1 is: "<<cosine1<<endl;
00258
00259 TVector3 unit_muon2_star = muon2_star.Vect().Unit();
00260 cosine2 = uZ2.Dot(unit_muon2_star);
00261 cout<<"The angle cosine2 is "<<cosine2<<endl;
00262
00263 Cosine1plot->Fill(cosine1);
00264 Cosine2plot->Fill(cosine2);
00265 Correlationplot->Fill(cosine1,cosine2);
00266
00267
00268
00269 double projection_z_1, projection_z_2;
00270 TVector3 muon1_hrest_vector3, muon1_x1;
00271 TVector3 muon2_hrest_vector3, muon2_T;
00272
00273 muon1_hrest_vector3 = muon1_hrest.Vect();
00274 projection_z_1 = -uZ1.Dot(muon1_hrest_vector3);
00275 muon1_x1 = muon1_hrest_vector3 + projection_z_1*uZ1;
00276 double check_1 = muon1_x1.Dot(uZ1);
00277
00278
00279 muon2_hrest_vector3 = muon2_hrest.Vect();
00280 projection_z_2 = uZ1.Dot(muon2_hrest_vector3);
00281 muon2_T = muon2_hrest_vector3 - projection_z_2*uZ1;
00282 double check_2 = muon2_T.Dot(uZ2);
00283
00284
00285 double phi, phi_0_2pi;
00286
00287 TVector3 y_axis_1, muon1_x1_unit;
00288 muon1_x1_unit = muon1_x1.Unit();
00289 y_axis_1 = muon1_x1.Dot(uZ1);
00290
00291
00292 double dot_y_mu2;
00293 double sign;
00294 dot_y_mu2 = y_axis_1.Dot(muon2_T);
00295 if(dot_y_mu2 > 0)
00296 {sign = +1;
00297 }
00298 else
00299 {sign = -1;}
00300
00301 phi = sign*(muon2_T.Angle(muon1_x1));
00302 if(phi<0)
00303 {phi_0_2pi = 2*TMath::Pi()+phi;
00304 }
00305 else
00306 {phi_0_2pi = phi;
00307 }
00308 Phiplot1->Fill(phi_0_2pi);
00309 Correlationplot_theta1_phi->Fill(cosine1,phi_0_2pi);
00310 Correlationplot_theta2_phi->Fill(cosine2,phi_0_2pi);
00311
00312 bool didImessmuonplus=false;
00313 bool didImessmuonminus=false;
00314
00315
00316 if(R.Rndm()>0.5)
00317 {
00318 TLorentzVector temp;
00319 temp=muon1plus;
00320 muon1plus=muon2plus;
00321 muon2plus=temp;
00322 didImessmuonplus=true;
00323 }
00324
00325 if(R.Rndm()>0.5)
00326 {
00327 TLorentzVector temp;
00328 temp=muon1minus;
00329 muon1minus=muon2minus;
00330 muon2minus=temp;
00331 didImessmuonminus=true;
00332 }
00333
00334 int MM=didImessmuonminus;
00335 int MP=didImessmuonplus;
00336
00337
00338 bool condition=(MM || MP) && (!MP || !MM);
00339 bool auxcond=((MP+MM)&1);
00340 if (auxcond!=condition)
00341 cout <<condition<<" "<<((MP+MM)&1)<<endl;
00342
00343
00344
00345 Hmass->Fill(muonsum.M());
00346
00347 }
00348
00349
00350
00351
00352
00353
00354
00355 char name[100];
00356
00357
00358
00359 TCanvas * c3 = new TCanvas("c3","**",800,800);
00360 c3->Divide(3,2);
00361 c3->SetFillColor(9);
00362 c3->cd(1);
00363 Cosine1plot->Draw();
00364
00365 Cosine1plot->SetTitle("Cos(#theta) of muon1 in Z1 rest frame");
00366
00367 TF1 *f2 = new TF1("f2","[0]*([1]*(3/4)*(1-x**2)+(3/8)*(1-[1])*(1+x**2))",-1,1);
00368 TF1 *f3 = new TF1("f3","[0]*( (1/(1+[1]))*(3/4)*(1-x**2) + (3/8)*([1]/(1+[1]))*(1+x**2) )",-1,1);
00369
00370 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);
00371
00372 f2->SetParNames("Normalization","alpha");
00373 f3->SetParNames("Normalization","R");
00374 f4->SetParNames("Normalization","tullyR");
00375
00376 f2->SetParameter(1,0.9);
00377 f3->SetParameter(1,0.1);
00378 f4->SetParameter(1,0.8);
00379
00380 f2->FixParameter(0,Cosine1plot->Integral("bin width"));
00381 f3->FixParameter(0,Cosine1plot->Integral("bin width"));
00382 f4->FixParameter(0,Cosine1plot->Integral("bin width"));
00383
00384 Cosine1plot->Fit("f2","L");
00385 Cosine1plot->Fit("f3","L+");
00386 Cosine1plot->Fit("f4","L+");
00387
00388
00389
00390
00391 c3->cd(2);
00392 Cosine2plot->Draw();
00393 Cosine2plot->SetTitle("Cos(#theta) of muon2 in Z2 rest frame");
00394 c3->cd(3);
00395 Correlationplot->Draw();
00396 Correlationplot->SetTitle("Cos(#theta) of muon2 in Z2 rest frame vs. muon1 in Z1 rest frame");
00397 c3->cd(4);
00398 Correlationplot_theta1_phi->Draw();
00399 Correlationplot_theta1_phi->SetTitle("Phi vs. muon1 in Z1 rest frame");
00400 c3->cd(5);
00401 Correlationplot_theta2_phi->Draw();
00402 Correlationplot_theta2_phi->SetTitle("Phi vs. muon2 in Z2 rest frame");
00403
00404
00405
00406
00407 TCanvas *c4 = new TCanvas("c4","**",800,800);
00408 c4->Divide(2,2);
00409 c4->SetFillColor(9);
00410 c4->cd(1);
00411 Phiplot1->Draw();
00412
00413
00414
00415
00416
00417 TCanvas * c5 = new TCanvas("c5","**",800,800);
00418 c5->SetFillColor(9);
00419 Hmass->Draw("e");
00420
00421 TCanvas * c6 = new TCanvas("c6","**",800,800);
00422 c6->cd();
00423 Z1plot->Draw();
00424
00425 TCanvas * c7 = new TCanvas("c7","**",800,800);
00426 c7->cd();
00427 Z2plot->Draw();
00428
00429 TCanvas * c8 = new TCanvas("c8","**",800,800);
00430 c8->cd();
00431 Phiplot1->Draw();
00432
00433 TF1 *f7 = new TF1("f7","[0]*(1+[1]*[2]*cos(x)+[2]*cos(2*x))",0,2*TMath::Pi());
00434
00435 f7->SetParNames("Normalization","a1","a2");
00436
00437
00438
00439
00440
00441 f7->FixParameter(0,(Phiplot1->Integral("bin width"))/(2*TMath::Pi()));
00442
00443 Phiplot1->Fit("f7","L");
00444
00445
00446
00447
00448 sprintf(name,"histograms_correct_HtoZZ_angular_wphi_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents);
00449 TFile f(name,"recreate");
00450 f.cd();
00451 int N=gROOT->GetList()->GetSize();
00452 for (int key=0; key<N ; key++)
00453 {
00454
00455 TObject * obj = gROOT->GetList()->At(key);
00456 if (obj->InheritsFrom("TH1F") || obj->InheritsFrom("TH2F"))
00457 {
00458 cout <<"write "<<obj->GetName()<<endl;
00459 obj->Write();
00460
00461 }
00462 }
00463 f.Close();
00464
00465
00466 for (int key=N-1; key>=0 ; key--)
00467 {
00468
00469 TObject * obj = gROOT->GetList()->At(key);
00470 cout <<"delete "<<obj->GetName()<<endl;
00471 if (obj) delete obj;
00472 cout <<"deleted "<<gROOT->GetList()->GetSize()<<" objects remaining"<<endl;
00473 }
00474
00475 watcher.Stop();
00476 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl;
00477
00478 return -97534;
00479
00480 }
00481