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 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
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 TVector3 boostH,boostZ1_hrest,boostZ2_hrest;
00255 TLorentzVector H,H_hrest,Z1_hrest,Z2_hrest,muon1_hrest,muon2_hrest,muon1_star,muon2_star,Z1_star,Z2_star;
00256 H = Z1+Z2;
00257 boostH = -H.BoostVector();
00258 H_hrest = H;
00259 Z1_hrest = Z1;
00260 Z2_hrest = Z2;
00261 muon1_hrest = muon1minus;
00262 muon2_hrest = muon2minus;
00263 H_hrest.Boost(boostH);
00264 Z1_hrest.Boost(boostH);
00265 Z2_hrest.Boost(boostH);
00266 muon1_hrest.Boost(boostH);
00267 muon2_hrest.Boost(boostH);
00268
00269 boostZ1_hrest = -Z1_hrest.BoostVector();
00270 boostZ2_hrest = -Z2_hrest.BoostVector();
00271
00272 Z1_star = Z1_hrest;
00273 Z2_star = Z2_hrest;
00274
00275 muon1_star = muon1_hrest;
00276 muon2_star = muon2_hrest;
00277
00278 muon1_star.Boost(boostZ1_hrest);
00279 muon2_star.Boost(boostZ2_hrest);
00280
00281 TVector3 uZ1 = Z1_hrest.Vect().Unit();
00282 TVector3 uZ2 = Z2_hrest.Vect().Unit();
00283
00284 float cosine1, cosine2;
00285 TVector3 unit_muon1_star = muon1_star.Vect().Unit();
00286 cosine1 = uZ1.Dot(unit_muon1_star);
00287
00288
00289
00290
00291 TVector3 unit_muon2_star = muon2_star.Vect().Unit();
00292 cosine2 = uZ2.Dot(unit_muon2_star);
00293
00294 Cosine1plot->Fill(cosine1);
00295 Cosine2plot->Fill(cosine2);
00296 Correlationplot->Fill(cosine1,cosine2);
00297
00298 TVector3 x1(1.0,0.0,0.0),y1(0.0,1.0,0.0);
00299 x1.RotateUz(uZ1);
00300 y1.RotateUz(uZ1);
00301
00302
00303 TVector2 muon1_star2d(x1.Dot(unit_muon1_star),y1.Dot(unit_muon1_star));
00304 Phiplot1->Fill(muon1_star2d.Phi());
00305
00306 TVector3 x2(1.0,0.0,0.0),y2(0.0,1.0,0.0);
00307 x2.RotateUz(uZ2);
00308 y2.RotateUz(uZ2);
00309
00310
00311 TVector2 muon2_star2d(x2.Dot(unit_muon2_star),y2.Dot(unit_muon2_star));
00312 Phiplot2->Fill(muon2_star2d.Phi());
00313
00314
00315 bool didImessmuonplus=false;
00316 bool didImessmuonminus=false;
00317
00318
00319 if(R.Rndm()>0.5)
00320 {
00321 TLorentzVector temp;
00322 temp=muon1plus;
00323 muon1plus=muon2plus;
00324 muon2plus=temp;
00325 didImessmuonplus=true;
00326 }
00327
00328 if(R.Rndm()>0.5)
00329 {
00330 TLorentzVector temp;
00331 temp=muon1minus;
00332 muon1minus=muon2minus;
00333 muon2minus=temp;
00334 didImessmuonminus=true;
00335 }
00336
00337 int MM=didImessmuonminus;
00338 int MP=didImessmuonplus;
00339
00340
00341 bool condition=(MM || MP) && (!MP || !MM);
00342 bool auxcond=((MP+MM)&1);
00343 if (auxcond!=condition)
00344 cout <<condition<<" "<<((MP+MM)&1)<<endl;
00345
00346
00347
00348 Hmass->Fill(muonsum.M());
00349
00350 }
00351
00352
00353
00354
00355
00356
00357
00358 char name[100];
00359
00360
00361
00362 TCanvas * c3 = new TCanvas("c3","**",800,800);
00363 c3->Divide(2,2);
00364 c3->SetFillColor(9);
00365 c3->cd(1);
00366 Cosine1plot->Draw();
00367
00368 Cosine1plot->SetTitle("Cos(#theta) of muon1 in Z1 rest frame");
00369
00370 TF1 *f2 = new TF1("f2","[0]*([1]*(3/4)*(1-x**2)+(3/8)*(1-[1])*(1+x**2))",-1,1);
00371 TF1 *f3 = new TF1("f3","[0]*( (1/(1+[1]))*(3/4)*(1-x**2) + (3/8)*([1]/(1+[1]))*(1+x**2) )",-1,1);
00372
00373 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);
00374
00375 f2->SetParNames("Normalization","alpha");
00376 f3->SetParNames("Normalization","R");
00377 f4->SetParNames("Normalization","tullyR");
00378
00379 f2->SetParameter(1,0.9);
00380 f3->SetParameter(1,0.1);
00381 f4->SetParameter(1,0.8);
00382
00383 f2->FixParameter(0,Cosine1plot->Integral("bin width"));
00384 f3->FixParameter(0,Cosine1plot->Integral("bin width"));
00385 f4->FixParameter(0,Cosine1plot->Integral("bin width"));
00386
00387 Cosine1plot->Fit("f2","L");
00388 Cosine1plot->Fit("f3","L+");
00389 Cosine1plot->Fit("f4","L+");
00390
00391
00392
00393
00394 c3->cd(2);
00395 Cosine2plot->Draw();
00396 c3->cd(3);
00397 Correlationplot->Draw();
00398
00399
00400
00401
00402
00403 TCanvas *c4 = new TCanvas("c4","**",800,800);
00404 c4->Divide(2,2);
00405 c4->SetFillColor(9);
00406 c4->cd(1);
00407 Phiplot1->Draw();
00408 c4->cd(2);
00409 Phiplot2->Draw();
00410
00411
00412 TCanvas * c5 = new TCanvas("c5","**",800,800);
00413 c5->SetFillColor(9);
00414 Hmass->Draw("e");
00415
00416 TCanvas * c6 = new TCanvas("c6","**",800,800);
00417 c6->cd();
00418 Z1plot->Draw();
00419
00420 TCanvas * c7 = new TCanvas("c6","**",800,800);
00421 c7->cd();
00422 Z2plot->Draw();
00423
00424 sprintf(name,"histograms_correct_HtoZZ_angular_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents);
00425 TFile f(name,"recreate");
00426 f.cd();
00427 int N=gROOT->GetList()->GetSize();
00428 for (int key=0; key<N ; key++)
00429 {
00430
00431 TObject * obj = gROOT->GetList()->At(key);
00432 if (obj->InheritsFrom("TH1F") || obj->InheritsFrom("TH2F"))
00433 {
00434 cout <<"write "<<obj->GetName()<<endl;
00435 obj->Write();
00436
00437 }
00438 }
00439 f.Close();
00440
00441
00442 for (int key=N-1; key>=0 ; key--)
00443 {
00444
00445 TObject * obj = gROOT->GetList()->At(key);
00446 cout <<"delete "<<obj->GetName()<<endl;
00447 if (obj) delete obj;
00448 cout <<"deleted "<<gROOT->GetList()->GetSize()<<" objects remaining"<<endl;
00449 }
00450
00451 watcher.Stop();
00452 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl;
00453
00454 return -97534;
00455
00456 }
00457