00001 // Program to use Pythia to generate H->ZZ; Z->mu+mu- from within ROOT. 00002 // To make an event sample (of size 100) do 00003 // 00004 // shell> root 00005 // root [0] .L makePyEvts.C 00006 // root [1] makePyEvts(100) 00007 // 00008 // 00009 #define ECM 14000 00010 // using namespace TMath; 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 //double higgswidth; 00030 00031 // nEvents is how many events we want. 00032 int makePyEvts(int nEvents,float Higgsmass = 1000 ) 00033 { 00034 00035 // Create an instance of the Pythia event generator ... 00036 TPythia6* pythia = new TPythia6; 00037 00038 // Initialise it to run p+p at ECM GeV in CMS 00039 00040 pythia->SetMSEL(0); //Full user control 00041 pythia->SetMSUB(102,1); //Select gg->Higgs 00042 pythia->SetPMAS(25,1,Higgsmass); //Set Higgs mass 00043 pythia->SetMSTP(61,0); //Turn off initial-state radiation 00044 pythia->SetMSTP(71,0); //Turn off final state radiation 00045 00046 // Turn off all Z decay modes; then turn on correct mode 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 // Turn off all Higgs (h0) decay modes; then turn on correct mode 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 //Set collision 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 // #define FILENAME "pythia.root" 00075 // #define TREENAME "tree" 00076 // #define BRANCHNAME "particles" 00077 00078 // Open an output file 00079 // TFile* file = TFile::Open(FILENAME, "RECREATE"); 00080 // if (!file || !file->IsOpen()) { 00081 // Error("makeEventSample", "Couldn;t open file %s", FILENAME); 00082 // return 1; 00083 // } 00084 00085 00086 // Make a tree in that file ... 00087 // TTree* tree = new TTree(TREENAME, "Pythia 6 tree"); 00088 00089 // Register a the cache of pythia on a branch (It's a 00090 // TClonesArray of TMCParticle objects. ) 00091 // TClonesArray* particles = (TClonesArray*)pythia->GetListOfParticles(); 00092 // tree->Branch(BRANCHNAME, &particles); 00093 00094 00095 TStopwatch watcher; 00096 watcher.Reset(); 00097 watcher.Start(); 00098 00099 00100 float Higgsmass_max = 3000; 00101 00102 // if (Higgsmass > Higgsmass_max) 00103 // {cout<<"I am not happy !"<<endl; return;} 00104 00105 int NbinIVplot = 3000; 00106 00107 00108 float Higgsmaxplot = 3000; 00109 float Higgsminplot = 0.0; 00110 int Nbins = 300; 00111 00112 if (Higgsmass < 191) 00113 { 00114 Nbins = 500; 00115 Higgsminplot = Higgsmass - 5*higgswidth; 00116 Higgsmaxplot = Higgsmass + 5*higgswidth; 00117 } 00118 00119 00120 00121 TH1F *Hmass = new TH1F("Hmass","Higgs Mass",Nbins,Higgsminplot,Higgsmaxplot); 00122 TH1F *Hpt = new TH1F("Hpt","Higgs Tranverse Momentum",500,0.,500.0); 00123 /* 00124 TH1F *hmuonpt_initial = new TH1F("hmuonpt_initial","Muon Pt in initial state",200,0.,200.0); 00125 TH1F *hmuonpt_final = new TH1F("hmuonpt_final","Muon Pt in final state",200,0.,200.0); 00126 00127 TH1F *hgamma = new TH1F("hgamma","Gamma Pt",200,0.,200.0); 00128 00129 TH1F * mcZ1mass = new TH1F("mcZ1mass","generated Z mass",NbinIVplot,0,Higgsmass_max); 00130 TH1F * mcZ2mass = new TH1F("mcZ2mass","generated Z mass",NbinIVplot,0,Higgsmass_max); 00131 00132 TH1F * mu1p_pt = new TH1F("mu1p_pt","#mu^{+}_{1} p_{T} [GeV]",NbinIVplot,0,Higgsmass_max); 00133 TH1F * mu2p_pt = new TH1F("mu2p_pt","#mu^{+}_{2} p_{T} [GeV]",NbinIVplot,0,Higgsmass_max); 00134 TH1F * mu1m_pt = new TH1F("mu1m_pt","#mu^{-}_{1} p_{T} [GeV]",NbinIVplot,0,Higgsmass_max); 00135 TH1F * mu2m_pt = new TH1F("mu2m_pt","#mu^{-}_{2} p_{T} [GeV]",NbinIVplot,0,Higgsmass_max); 00136 00137 TH1F *Cosine1plot = new TH1F("Cosine1graph","Theta angle of muon1 in Z1 rest frame",NbinIVplot,-1,1); 00138 TH1F *Cosine2plot = new TH1F("Cosine2graph","Theta angle of muon2 in Z2 rest frame",NbinIVplot,-1,1); 00139 TH2F *Correlationplot = new TH2F("Correlationplot","Theta angle muon 1 versus theta angle muon 2",NbinIVplot,-1,1,NbinIVplot,-1,1); 00140 00141 TH1F *Phiplot1 = new TH1F("Phiplot1","Phi angle of muon 1 in Z1 rest frame",NbinIVplot,0,2*TMath::Pi()); 00142 TH1F *Phiplot2 = new TH1F("Phiplot2","Phi angle of muon 2 in Z2 rest frame",NbinIVplot,0,2*TMath::Pi()); 00143 00144 TH1F *IV1 = new TH1F("IV1","Invariant mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00145 TH1F *IV1wc = new TH1F("IV1wc","wrong invariant mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00146 TH1F *IV1rc = new TH1F("IV1rc","right invariant mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00147 IV1wc->SetLineColor(2); 00148 IV1rc->SetLineColor(4); 00149 00150 TH1F *IV2 = new TH1F("IV2","Invariant mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00151 TH1F *IV2wc = new TH1F("IV2wc","wrong Invariant mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00152 TH1F *IV2rc = new TH1F("IV2rc","right Invariant mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00153 IV2wc->SetLineColor(2); 00154 IV2rc->SetLineColor(4); 00155 00156 TH1F *IV3 = new TH1F("IV3","Invariant mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00157 TH1F *IV3wc = new TH1F("IV3wc","Invariant mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00158 TH1F *IV3rc = new TH1F("IV3rc","Invariant mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max); 00159 IV3wc->SetLineColor(6); 00160 IV3rc->SetLineColor(3); 00161 00162 TH1F *IV4 = new TH1F("IV4","Invariant mass #mu^{+}_{2} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00163 TH1F *IV4wc = new TH1F("IV4wc","Invariant mass #mu^{+}_{2} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00164 TH1F *IV4rc = new TH1F("IV4rc","Invariant mass #mu^{+}_{2} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max); 00165 00166 IV4wc->SetLineColor(6); 00167 IV4rc->SetLineColor(3); 00168 00169 IV1->SetXTitle("IV1 = Invariant mass of (#mu_{1}^{+},#mu_{1}^{-})"); 00170 IV2->SetXTitle("IV2 = Invariant mass of (#mu_{2}^{+},#mu_{2}^{-})"); 00171 IV3->SetXTitle("IV3 = Invariant mass of (#mu_{1}^{+},#mu_{2}^{-})"); 00172 IV4->SetXTitle("IV4 = Invariant mass of (#mu_{2}^{+},#mu_{1}^{-})"); 00173 00174 TH2F *IV21 = new TH2F("IV21","mass #mu^{+}_{2} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00175 TH2F *IV2w1w = new TH2F("IV2w1w","mass #mu^{+}_{2} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00176 TH2F *IV2r1r = new TH2F("IV2r1r","mass #mu^{+}_{2} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00177 IV2w1w->SetMarkerStyle(5); 00178 IV2w1w->SetMarkerColor(2);//red 00179 // IV2w1w->SetMarkerSize(0.5); 00180 IV2r1r->SetMarkerStyle(2); 00181 IV2r1r->SetMarkerColor(4); 00182 // IV2r1r->SetMarkerSize(0.5); 00183 00184 TH2F *IV43 = new TH2F("IV43","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00185 TH2F *IV4w3w = new TH2F("IV4w3w","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00186 TH2F *IV4r3r = new TH2F("IV4r3r","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{1} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00187 IV4w3w->SetMarkerStyle(5); 00188 IV4w3w->SetMarkerColor(6);//pink 00189 // IV4w3w->SetMarkerSize(0.5); 00190 IV4r3r->SetMarkerStyle(2); 00191 IV4r3r->SetMarkerColor(5);//green 00192 // IV4r3r->SetMarkerSize(0.5); 00193 00194 00195 TH2F *IV31 = new TH2F("IV31","mass #mu^{+}_{1} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00196 TH2F *IV3r1w = new TH2F("IV3r1w","mass #mu^{+}_{1} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00197 TH2F *IV3w1r = new TH2F("IV3w1r","mass #mu^{+}_{1} #mu_{2}^{-} versus mass #mu^{+}_{1} #mu_{1}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00198 // IV3r1w->SetMarkerSize(0.5); 00199 // IV3w1r->SetMarkerSize(0.5); 00200 00201 00202 TH2F *IV42 = new TH2F("IV42","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00203 TH2F *IV4r2w = new TH2F("IV4r2w","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00204 TH2F *IV4w2r = new TH2F("IV4w2r","mass #mu^{+}_{2} #mu_{1}^{-} versus mass #mu^{+}_{2} #mu_{2}^{-}",NbinIVplot,0,Higgsmass_max,NbinIVplot,0,Higgsmass_max); 00205 // IV4r2w->SetMarkerSize(0.5); 00206 // IV4w2r->SetMarkerSize(0.5); 00207 00208 IV21->SetXTitle("IV2 = Invariant mass of (#mu_{2}^{+},#mu_{2}^{-})"); 00209 IV21->SetYTitle("IV1 = Invariant mass of (#mu_{1}^{+},#mu_{1}^{-})"); 00210 00211 IV43->SetXTitle("IV4 = Invariant mass of (#mu_{2}^{+},#mu_{1}^{-})"); 00212 IV43->SetYTitle("IV3 = Invariant mass of (#mu_{1}^{+},#mu_{2}^{-})"); 00213 00214 IV31->SetXTitle("IV3 = Invariant mass of (#mu_{1}^{+},#mu_{2}^{-})"); 00215 IV31->SetYTitle("IV1 = Invariant mass of (#mu_{1}^{+},#mu_{1}^{-})"); 00216 00217 IV42->SetXTitle("IV4 = Invariant mass of (#mu_{2}^{+},#mu_{1}^{-})"); 00218 IV42->SetYTitle("IV2 = Invariant mass of (#mu_{2}^{+},#mu_{2}^{-})"); 00219 00220 */ 00221 Int_t KF_muon =13; 00222 00223 00224 00225 // Now generate events 00226 00227 TRandom2 R; 00228 int counting_num = 0; 00229 //loop over the events 00230 for (Int_t ievt = 0; ievt < nEvents; ievt++) 00231 { 00232 // Show how far we got every 100'th event. 00233 if (ievt % 100 == 0) 00234 cout << "Event # " << ievt << endl; 00235 00236 00237 00238 // Make one event. 00239 pythia->GenerateEvent(); 00240 // Now we're ready to fill the tree, and the event is over. 00241 // tree->Fill(); 00242 // 00243 00244 TLorentzVector muonsum; 00245 TLorentzVector muon1plus, muon2plus, muon1minus , muon2minus; 00246 00247 int Nmuonplus=0; 00248 int Nmuonminus=0; 00249 00250 int Nz=0; 00251 00252 //Get some event information! 00253 //Total number of Pythia tracks 00254 Int_t N = pythia->GetN(); 00255 //cout << "MyOutput: Number of Pythia tracks ="<<N<<endl; 00256 //Loop over all tracks 00257 00258 00259 if(counting_num<1) 00260 {pythia->Pylist(1); 00261 } 00262 counting_num++; 00263 Int_t N_muons =0; // initialize number muons 00264 for (Int_t itk =1; itk<=N; itk++) //loop over the particles in one event 00265 { 00266 00267 00268 00269 Int_t KS = pythia->GetK(itk,1); //KS code 00270 00271 if ( KS!=21) continue; 00272 00273 Int_t KF = pythia->GetK(itk,2); //KF code 00274 00275 00276 /* if ( (KF==23) && (KS==21)) //Z boson 00277 { 00278 TLorentzVector lvZ = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4)); 00279 if (Nz==0) 00280 { mcZ1mass->Fill(lvZ.M()); Nz=1;} 00281 else 00282 mcZ2mass->Fill(lvZ.M()); 00283 } 00284 00285 if((abs(KF) == 22) &&(KS!=21)) //photon 00286 { 00287 00288 TLorentzVector lvGamma = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4)); 00289 if(lvGamma.Pt() >= 10.) 00290 hgamma->Fill(lvGamma.Pt()); 00291 } 00292 */ 00293 00294 00295 if ((abs(KF)== KF_muon)) 00296 { 00297 TLorentzVector lvMuon = TLorentzVector(pythia->GetP(itk,1), pythia->GetP(itk,2), pythia->GetP(itk,3), pythia->GetP(itk,4)); 00298 00299 cout<<"Hello"<<endl; 00300 00301 if(KS==21) 00302 { 00303 N_muons++; 00304 // hmuonpt_initial->Fill(lvMuon.Pt()); 00305 muonsum+=lvMuon; 00306 00307 00308 if (KF<0) //anti-muon 00309 { 00310 if (Nmuonplus==1) 00311 { 00312 muon2plus = lvMuon; 00313 } 00314 if (Nmuonplus==0) 00315 { 00316 muon1plus = lvMuon; 00317 Nmuonplus=1; 00318 } 00319 } 00320 else //muon 00321 { 00322 if (Nmuonminus==1) 00323 { 00324 muon2minus = lvMuon; 00325 } 00326 if (Nmuonminus==0) 00327 { 00328 muon1minus = lvMuon; 00329 Nmuonminus=1; 00330 } 00331 } 00332 } 00333 else 00334 { 00335 // hmuonpt_final->Fill(lvMuon.Pt()); 00336 } 00337 } 00338 00339 00340 }//itk //end of the loop over particles in one event 00341 //cout << "MyOutput: Number of muons =" << N_muons<<endl; 00342 00343 00344 00345 00346 //Want to take the four vector of the muon and anti-muon and add them to get the four vectors of the Z 00347 /* TVector3 boostZ1,boostZ2; 00348 TLorentzVector Z1,Z2; 00349 Z1 = muon1plus + muon1minus; 00350 Z2 = muon2plus + muon2minus; 00351 //get the opposite of the 3-vector of the Zs 00352 boostZ1 = - Z1.BoostVector(); 00353 boostZ2 = - Z2.BoostVector(); 00354 00355 // boostZ1.Print(); 00356 // boostZ2.Print(); 00357 00358 //boost muon, anti-muon and Z1 to the Z1 rest frame 00359 TLorentzVector Z1_star,muon1_star,antimuon1_star; 00360 Z1_star = Z1; 00361 muon1_star = muon1minus; 00362 antimuon1_star = muon1plus; 00363 00364 Z1_star.Boost(boostZ1); 00365 muon1_star.Boost(boostZ1); 00366 antimuon1_star.Boost(boostZ1); 00367 // Z1_star.Vect().Print(); 00368 00369 //boost muon, anti-muon and Z2 to the Z2 rest frame 00370 TLorentzVector Z2_star,muon2_star,antimuon2_star; 00371 Z2_star = Z2; 00372 muon2_star = muon2minus; 00373 antimuon2_star = muon2plus; 00374 00375 Z2_star.Boost(boostZ2); 00376 muon2_star.Boost(boostZ2); 00377 antimuon2_star.Boost(boostZ2); 00378 // Z2_star.Vect().Print(); 00379 00380 TVector3 uZ1=-boostZ1.Unit(); 00381 TVector3 uZ2=-boostZ2.Unit(); 00382 00383 float cosine1, cosine2; 00384 TVector3 unit_muon1_star = muon1_star.Vect().Unit(); 00385 cosine1 = uZ1.Dot(unit_muon1_star); 00386 // cout <<cosine1<<endl; 00387 // cout <<" radian or degree "<<uZ1.Angle(unit_muon1_star)<<endl; 00388 // cout <<cos( uZ1.Angle(unit_muon1_star) )<<endl; 00389 00390 TVector3 unit_muon2_star = muon2_star.Vect().Unit(); 00391 cosine2 = uZ2.Dot(unit_muon2_star); 00392 00393 Cosine1plot->Fill(cosine1); 00394 Cosine2plot->Fill(cosine2); 00395 Correlationplot->Fill(cosine1,cosine2); 00396 00397 TVector3 x1(1.0,0.0,0.0),y1(0.0,1.0,0.0); 00398 x1.RotateUz(uZ1); 00399 y1.RotateUz(uZ1); 00400 //(x1,y1,uZ1) is the rest frame of the Z, with z axis along the Z boson. 00401 00402 TVector2 muon1_star2d(x1.Dot(unit_muon1_star),y1.Dot(unit_muon1_star)); 00403 Phiplot1->Fill(muon1_star2d.Phi()); 00404 00405 TVector3 x2(1.0,0.0,0.0),y2(0.0,1.0,0.0); 00406 x2.RotateUz(uZ2); 00407 y2.RotateUz(uZ2); 00408 //(x2,y2,uZ2) is the rest frame of the Z, with z axis along the Z boson. 00409 00410 TVector2 muon2_star2d(x2.Dot(unit_muon2_star),y2.Dot(unit_muon2_star)); 00411 Phiplot2->Fill(muon2_star2d.Phi()); 00412 */ 00413 00414 bool didImessmuonplus=false; 00415 bool didImessmuonminus=false; 00416 00417 //randomizing the anti-muons order 00418 if(R.Rndm()>0.5) 00419 { 00420 TLorentzVector temp; 00421 temp=muon1plus; 00422 muon1plus=muon2plus; 00423 muon2plus=temp; 00424 didImessmuonplus=true; 00425 } 00426 //randomizing the muons order 00427 if(R.Rndm()>0.5) 00428 { 00429 TLorentzVector temp; 00430 temp=muon1minus; 00431 muon1minus=muon2minus; 00432 muon2minus=temp; 00433 didImessmuonminus=true; 00434 } 00435 00436 float IV_1=0,IV_2=0,IV_3=0,IV_4=0; 00437 00438 /* IV_1 = (muon1plus+muon1minus).M(); 00439 IV_2 = (muon2plus+muon2minus).M(); 00440 IV_3 = (muon1plus+muon2minus).M(); 00441 IV_4 = (muon2plus+muon1minus).M(); 00442 00443 00444 mu1p_pt->Fill(muon1plus.Pt()); 00445 mu2p_pt->Fill(muon2plus.Pt()); 00446 mu1m_pt->Fill(muon1minus.Pt()); 00447 mu2m_pt->Fill(muon2minus.Pt()); 00448 00449 IV1->Fill(IV_1); 00450 IV2->Fill(IV_2); 00451 IV3->Fill(IV_3); 00452 IV4->Fill(IV_4); 00453 */ 00454 00455 int MM=didImessmuonminus; 00456 int MP=didImessmuonplus; 00457 00458 00459 bool condition=(MM || MP) && (!MP || !MM); 00460 bool auxcond=((MP+MM)&1); 00461 if (auxcond!=condition) 00462 cout <<condition<<" "<<((MP+MM)&1)<<endl; 00463 00464 /* if (condition) 00465 { 00466 //blue 00467 IV1wc->Fill(IV_1); 00468 IV2wc->Fill(IV_2); 00469 IV3rc->Fill(IV_3); 00470 IV4rc->Fill(IV_4); 00471 IV2w1w->Fill(IV_2,IV_1); 00472 IV4r3r->Fill(IV_4,IV_3); 00473 IV3r1w->Fill(IV_3,IV_1); 00474 IV4r2w->Fill(IV_4,IV_2); 00475 } 00476 else 00477 { 00478 //black 00479 IV1rc->Fill(IV_1); 00480 IV2rc->Fill(IV_2); 00481 IV3wc->Fill(IV_3); 00482 IV4wc->Fill(IV_4); 00483 IV2r1r->Fill(IV_2,IV_1); 00484 IV4w3w->Fill(IV_4,IV_3); 00485 IV3w1r->Fill(IV_3,IV_1); 00486 IV4w2r->Fill(IV_4,IV_2); 00487 } 00488 00489 IV21->Fill(IV_2,IV_1); 00490 IV43->Fill(IV_4,IV_3); 00491 IV31->Fill(IV_3,IV_1); 00492 IV42->Fill(IV_4,IV_2); 00493 */ 00494 00495 Hmass->Fill(muonsum.M()); 00496 Hpt->Fill(muonsum.Pt()); 00497 }//ievt /end of loop over the events 00498 00499 00500 00501 00502 00503 00504 /* TCanvas *c1 = new TCanvas("c1","**",800,800); 00505 c1->Divide(2,2); 00506 c1->SetFillColor(9); 00507 c1->cd(1); 00508 IV1->Draw(); 00509 IV1wc->Draw("same"); 00510 IV1rc->Draw("same"); 00511 00512 (c1->cd(2))->SetLogy(); 00513 IV2->Draw(); 00514 IV2wc->Draw("same"); 00515 IV2rc->Draw("same"); 00516 00517 c1->cd(3); 00518 IV3->Draw(); 00519 IV3wc->Draw("same"); 00520 IV3rc->Draw("same"); 00521 00522 c1->cd(4)->SetLogy(); 00523 IV4->Draw(); 00524 IV4wc->Draw("same"); 00525 IV4rc->Draw("same"); 00526 */ 00527 char name[100]; 00528 // sprintf(name,"IVplots_Hm%5.2f_Nevt%d.eps",Higgsmass,nEvents); 00529 // c1->Print(name); 00530 00531 /* TCanvas * c3 = new TCanvas("c3","**",800,800); 00532 c3->Divide(2,2); 00533 c3->SetFillColor(9); 00534 c3->cd(1); 00535 Cosine1plot->Draw(); 00536 c3->cd(2); 00537 Cosine2plot->Draw(); 00538 c3->cd(3); 00539 Correlationplot->Draw(); 00540 00541 // sprintf(name,"AnglePlots_Hm%5.2f_Nevt%d.eps",Higgsmass,nEvents); 00542 // c3->Print(name); 00543 00544 00545 TCanvas *c4 = new TCanvas("c4","**",800,800); 00546 c4->Divide(2,2); 00547 c4->SetFillColor(9); 00548 c4->cd(1); 00549 Phiplot1->Draw(); 00550 c4->cd(2); 00551 Phiplot2->Draw(); 00552 00553 TCanvas *c2=new TCanvas("c2","**",800,800); 00554 c2->Divide(2,2); 00555 c2->SetFillColor(8); 00556 c2->cd(1); 00557 IV21->Draw(); 00558 IV2r1r->Draw("same"); 00559 IV2w1w->Draw("same"); 00560 00561 c2->cd(2); 00562 IV43->Draw(); 00563 IV4r3r->Draw("same"); 00564 IV4w3w->Draw("same"); 00565 00566 c2->cd(3); 00567 TH2F * IV3w1r_c = new TH2F(*IV3w1r); 00568 IV3w1r->SetMarkerStyle(2); 00569 IV3w1r_c->SetMarkerStyle(5); 00570 IV3w1r->SetMarkerColor(4); //blue 00571 IV3w1r_c->SetMarkerColor(6);//yellow 00572 00573 TH2F * IV3r1w_c = new TH2F(*IV3r1w); 00574 IV3r1w->SetMarkerStyle(2); 00575 IV3r1w_c->SetMarkerStyle(5); 00576 IV3r1w->SetMarkerColor(2); //red 00577 IV3r1w_c->SetMarkerColor(3); //green 00578 00579 IV3w1r->Draw(); 00580 IV3r1w->Draw("same"); 00581 IV3w1r_c->Draw("same"); 00582 IV3r1w_c->Draw("same"); 00583 IV31->Draw("same"); 00584 00585 c2->cd(4); 00586 TH2F * IV4w2r_c = new TH2F(*IV4w2r); 00587 IV4w2r->SetMarkerStyle(2); 00588 IV4w2r_c->SetMarkerStyle(5); 00589 IV4w2r->SetMarkerColor(4); //blue 00590 IV4w2r_c->SetMarkerColor(6); //yellow 00591 00592 TH2F * IV4r2w_c = new TH2F(*IV4r2w); 00593 IV4r2w->SetMarkerStyle(2); 00594 IV4r2w_c->SetMarkerStyle(5); 00595 IV4r2w->SetMarkerColor(2); //red 00596 IV4r2w_c->SetMarkerColor(3); //green 00597 00598 00599 IV4w2r->Draw(""); 00600 IV4r2w->Draw("same"); 00601 IV4w2r_c->Draw("same"); 00602 IV4r2w_c->Draw("same"); 00603 IV42->Draw("same"); 00604 */ 00605 TCanvas * c5 = new TCanvas("c5","**",800,800); 00606 c5->SetFillColor(9); 00607 Hmass->Draw("e"); 00608 TF1 *f_fit = new TF1("f_fit","[0]*TMath::BreitWigner(x,[1],[2])",0,500); 00609 TF1 *f_theory = new TF1("f_theory","[0]*TMath::BreitWigner(x,[1],[2])",0,500); 00610 f_fit->SetParNames("Constant","Mass","Width"); 00611 f_theory->SetParNames("Constant","Mass","Width"); 00612 00613 f_fit->SetParameters(Hmass->GetEntries(),Higgsmass,10); 00614 00615 Hmass->Fit("f_fit","L","",Higgsminplot,Higgsmaxplot); 00616 00617 float fit_higgswidth = f_fit->GetParameter(2); 00618 float fit_higgsmass = f_fit->GetParameter(1); 00619 00620 f_theory->SetParameter(0,Hmass->GetEntries()); 00621 f_theory->FixParameter(1,Higgsmass); 00622 f_theory->FixParameter(2,higgswidth); 00623 00624 Hmass->Fit("f_theory","L+","",Higgsminplot,Higgsmaxplot); 00625 00626 // higgswidth = 3.5; 00627 00628 // sprintf(name,"scatterplots_Hm%5.2f_Nevt%d.eps",Higgsmass,nEvents); 00629 // c2->Print(name); 00630 00631 sprintf(name,"histograms_HtoZZ_Hm%5.2f_Nevt%d.root",Higgsmass,nEvents); 00632 TFile f(name,"recreate"); 00633 f.cd(); 00634 int N=gROOT->GetList()->GetSize(); 00635 for (int key=0; key<N-1 ; key++) 00636 { 00637 00638 TObject * obj = gROOT->GetList()->At(key); 00639 if (obj->InheritsFrom("TH1F") || obj->InheritsFrom("TH2F")) 00640 { 00641 cout <<"write "<<obj->GetName()<<endl; 00642 obj->Write(); 00643 00644 } 00645 } 00646 f.Close(); 00647 00648 00649 for (int key=N-1; key>=0 ; key--) 00650 { 00651 00652 TObject * obj = gROOT->GetList()->At(key); 00653 cout <<"delete "<<obj->GetName()<<endl; 00654 if (obj) delete obj; 00655 cout <<"deleted "<<gROOT->GetList()->GetSize()<<" objects remaining"<<endl; 00656 } 00657 00658 watcher.Stop(); 00659 cout <<"Time spent for "<<nEvents<<" events :"<< watcher.RealTime()<<" [s]"<<endl; 00660 00661 return -97534; 00662 00663 }//makePyEvts 00664