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
00037 TPythia6* pythia = new TPythia6;
00038
00039
00040
00041
00042 pythia->SetMSEL(0);
00043 pythia->SetMSUB(102,1);
00044 pythia->SetPMAS(25,1,Higgsmass);
00045 pythia->SetMSTP(61,0);
00046
00047
00048
00049
00050
00051
00052 int KF = 25;
00053 int idcmin = pythia->GetMDCY(KF,2);
00054 int idcmax = idcmin + pythia->GetMDCY(KF,3);
00055 cout<<"MyOutput: Higgs idcmin="<<idcmin<<" idcmax="<<idcmax<<endl;
00056
00057 for (int idc = idcmin; idc < idcmax; idc++)
00058 {
00059 pythia->SetMDME(idc,1,0);
00060 }
00061 pythia->SetMDME(223,1,1);
00062
00063
00064 pythia->Initialize("cms", "p", "p", ECM);
00065
00066
00067
00068 float higgswidth = pythia->GetPMAS(25,2);
00069 float higgs_generated_mass = 0;
00070 cout<<"The higgs width from Pythia is "<<higgswidth<<endl;
00071
00072
00073 TStopwatch watcher;
00074 watcher.Reset();
00075 watcher.Start();
00076
00077
00078 float Higgsmass_max = 3000;
00079 float Higgsmaxplot = 3000;
00080 float Higgsminplot = 0.0;
00081
00082 int Nbins = 500;
00083 if (Higgsmass<191)
00084 {
00085 Nbins = 500;
00086 Higgsmaxplot = Higgsmass + 5 * higgswidth;
00087 Higgsminplot = Higgsmass - 5 * higgswidth;
00088 }
00089
00090
00091 TH1F *Hmass = new TH1F("Hmass","Higgs Mass",Nbins,Higgsminplot,Higgsmaxplot);
00092 TH1F *Hpt = new TH1F("Hpt","Higgs Tranverse Momentum",500,0.,500.0);
00093 TH1F *Hgeneratedmass = new TH1F("Hgeneratedmass","Higgs Generated Mass",Nbins,Higgsminplot,Higgsmaxplot);
00094
00095
00096
00097 int Num = 0;
00098
00099 for (Int_t ievt = 0; ievt < nEvents; ievt++)
00100 {
00101
00102 if (ievt % 100 == 0)
00103 cout << "Event # " << ievt << endl;
00104
00105
00106
00107
00108 pythia->GenerateEvent();
00109
00110
00111
00112 if(Num<1)
00113 {pythia->Pylist(1);
00114 }
00115
00116 Num++;
00117
00118
00119
00120 Int_t N = pythia->GetN();
00121
00122
00123
00124 TLorentzVector gammasum;
00125
00126 int N_gammas = 0;
00127
00128 for (Int_t itk =1; itk<=N; itk++)
00129 {
00130
00131 Int_t KS = pythia->GetK(itk,1);
00132
00133 if(KS!=21) continue;
00134
00135 Int_t KF = pythia->GetK(itk,2);
00136
00137 if ( KF == 25)
00138
00139 {
00140 TLorentzVector higgs = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4));
00141 Hgeneratedmass->Fill(higgs.M());
00142 }
00143
00144 if( KF == 22)
00145 {
00146
00147 TLorentzVector lvGamma = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4));
00148
00149
00150
00151
00152 if(KS==21)
00153 {
00154 N_gammas++;
00155 gammasum+=lvGamma;
00156
00157
00158
00159
00160 }
00161 }
00162
00163 }
00164
00165
00166
00167
00168
00169
00170
00171 Hmass->Fill(gammasum.M());
00172 Hpt->Fill(gammasum.Pt());
00173 }
00174
00175
00176
00177
00178
00179 char name[100];
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 TCanvas * c5 = new TCanvas("c5","**",800,800);
00191 c5->SetFillColor(9);
00192 Hmass->Draw("e");
00193 TF1 *f_fit = new TF1("f_fit","[0]*TMath::BreitWigner(x,[1],[2])",0,500);
00194 TF1 *f_theory = new TF1("f_theory","[0]*TMath::BreitWigner(x,[1],[2])",0,500);
00195 f_fit->SetParNames("Constant","Mass","Width");
00196 f_theory->SetParNames("Constant","Mass","Width");
00197
00198 if (Higgsmass>180)
00199 {
00200 f_fit->SetParameters(Hmass->GetEntries(),Higgsmass,higgswidth);
00201 f_fit->SetParLimits(2, higgswidth - higgswidth/2, higgswidth + higgswidth/2);
00202 f_fit->SetParLimits(0,0,100*Hmass->GetEntries());
00203 f_fit->SetParLimits(1,Higgsmass - Higgsmass/2,Higgsmass + Higgsmass/2);
00204 }
00205 else
00206 {
00207 f_fit->SetParameters(Hmass->GetEntries(),Higgsmass,higgswidth);
00208 f_fit->SetParLimits(2, higgswidth - higgswidth/5, higgswidth + higgswidth/5);
00209 f_fit->SetParLimits(0,0,100*Hmass->GetEntries());
00210 f_fit->SetParLimits(1,Higgsmass - 2*higgswidth,Higgsmass + 2*higgswidth);
00211 }
00212 for(int number = 0;number<3;number++)
00213 {
00214 Hmass->Fit("f_fit","L","",Higgsminplot,Higgsmaxplot);
00215
00216 }
00217 float fit_higgswidth = f_fit->GetParameter(2);
00218 float fit_higgsmass = f_fit->GetParameter(1);
00219
00220 f_theory->SetParameter(0,Hmass->GetEntries());
00221 f_theory->FixParameter(1,Higgsmass);
00222 f_theory->FixParameter(2,higgswidth);
00223 f_theory->SetParLimits(0,0,10000);
00224
00225 Hmass->Fit("f_theory","L+","",Higgsminplot,Higgsmaxplot);
00226
00227 cout<<"Fitted Higgs mass: "<<fit_higgsmass<<", Fitted Higgs width: "<<fit_higgswidth<<endl;
00228 cout<<"Theory Higgs mass: "<<Higgsmass<<", Theory Higgs width: "<<higgswidth<<endl;
00229
00230 sprintf(name,"histograms_Htogammagamma_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents);
00231 TFile f(name,"recreate");
00232 f.cd();
00233 int N=gROOT->GetList()->GetSize();
00234 for (int key=0; key<N ; key++)
00235 {
00236 gROOT->GetList()->At(key)->Write();
00237
00238 }
00239 f.Close();
00240
00241 watcher.Stop();
00242 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl;
00243
00244 return -97534;
00245 */
00246 }
00247