ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/dasu/UltraFastSim/ZHAnalysis.cc
(Generate patch)

Comparing UserCode/dasu/UltraFastSim/ZHAnalysis.cc (file contents):
Revision 1.1 by dasu, Fri Feb 18 05:06:02 2011 UTC vs.
Revision 1.2 by dasu, Thu Feb 24 07:34:29 2011 UTC

# Line 1 | Line 1
1   #include "ZHAnalysis.h"
2  
3 #include <iostream>
4 #include <vector>
5 #include <string>
3   using namespace std;
4  
5 < #include "Pythia.h"
6 < using namespace Pythia8;
7 <
8 < #include "UltraFastSim.h"
12 <
13 < #include "TFile.h"
14 < #include "TH1F.h"
15 <
16 < double CorrectPhi(double phi, double x, double y)
17 < {
18 <  if(phi>0 && x<0 && y<0)phi+=M_PI;
19 <  if(phi<0 && x>0 && y<0)phi=(2*M_PI-fabs(phi));
20 <  if(phi<0 && x<0 && y>0)phi=(M_PI-fabs(phi));
21 <  //if(y<0)phi-=(2*M_PI);//without this you have 0<phi<2pi, but with this
22 <  return phi;//you get -pi<phi<pi
5 > void ZHAnalysis::BookTree() {
6 >  myevent_ = new myevent;
7 >  t=new TTree("t","tree");
8 >  t->Branch("myevent","myevent",&myevent_,256000,1);
9   }
10  
25 ZHAnalysis::ZHAnalysis(TFile *o, Pythia *p, UltraFastSim *u, bool v) : outFile(o), pythia(p), ufs(u), verbose_(v),
26                                                                       AnalyzedEvents(0),
27                                                                       LeptonPairPreSelection(0),LeptonPairSelection(0),
28                                                                       BJetPairPreSelection(0),BJetPairSelection(0),
29                                                                       ZptSelection(0),HptSelection(0),
30                                                                       DphiSelection(0),InvMassSelection(0)
31 {
32  outFile->cd();
33
34  hptmuons = new TH1F("Muons Pt","Muons Pt",300,0.,300.);
35  hetamuons = new TH1F("Muons Eta","Muons Eta",100,-5.,5.);
36  hphimuons = new TH1F("Muons Phi","Muons Phi",100,-7.,7.);
37
38  hetbjets = new TH1F("B-jets Et","B-jets Et",300,0.,300.);
39  hetabjets = new TH1F("B-jets Eta","B-jets Eta",100,-5.,5.);
40  hphibjets = new TH1F("B-jets Phi","B-jets Phi",100,-7.,7.);
41
42  hptz     = new TH1F("Z Pt","Z Pt",300,0.,300.);
43  hzinvmass= new TH1F("Z invmass","Z invmass",300,0.,300.);
44
45  hpth     = new TH1F("H Pt","H Pt",300,0.,300.);
46  hhinvmass= new TH1F("H invmass preselection","H invmass preselection",300,0.,300.);
47  hhinvmass2= new TH1F("H invmass","H invmass",300,0.,300.);
48
49  hphiz= new TH1F("Z Phi","Z Phi",100,-7.,7.);
50  hphih= new TH1F("H Phi","H Phi",100,-7.,7.);
11  
12 <  hdphiZH= new TH1F("Dphi(Z,H)","Dphi(Z,H)",100,-7.,7.);
53 <
54 <
55 < }
12 > bool ZHAnalysis::Run(UltraFastSim * ufs){
13  
14 +  vector<TParticle>          GenTaus_ = ufs->genTauList();
15 +  vector<TParticle>          BQuarks_ = ufs->bQuarkList();
16 +  vector<TParticle>          CQuarks_ = ufs->cQuarkList();
17 +  vector<TParticle>          Photons_ = ufs->photonList();
18 +  vector<TParticle>          Electrons_ = ufs->electronList();
19 +  vector<TParticle>          Muons_ = ufs->muonList();
20 +  vector<TParticle>          Taus_ = ufs->tauList();
21 +  vector<TParticle>          ChargedHadrons_ = ufs->chargedHadronList();
22 +  vector<TParticle>          NeutralHadrons_ = ufs->neutralHadronList();
23 +  vector<fastjet::PseudoJet> Jets_ = ufs->jetList();
24 +  vector<fastjet::PseudoJet> BJets_ = ufs->bJetList();
25 +  vector<fastjet::PseudoJet> BJetsStdGeom_ = ufs->bJetListStdGeom();
26 +
27 +  myevent_->clear();
28 +
29 +  for(vector<TParticle>::const_iterator it=GenTaus_.begin();it!=GenTaus_.end();it++){
30 +    myobject obj;
31 +    obj.px=it->Px();
32 +    obj.py=it->Py();
33 +    obj.pz=it->Pz();
34 +    obj.E=it->Energy();
35 +    obj.pt=it->Pt();
36 +    obj.eta=it->Eta();
37 +    obj.phi=it->Phi();
38 +    (myevent_->GenTaus).push_back(obj);
39 +  }
40 +  for(vector<TParticle>::const_iterator it=BQuarks_.begin();it!=BQuarks_.end();it++){
41 +    myobject obj;
42 +    obj.px=it->Px();
43 +    obj.py=it->Py();
44 +    obj.pz=it->Pz();
45 +    obj.E=it->Energy();
46 +    obj.pt=it->Pt();
47 +    obj.eta=it->Eta();
48 +    obj.phi=it->Phi();
49 +    (myevent_->BQuarks).push_back(obj);
50 +  }
51 +  for(vector<TParticle>::const_iterator it=CQuarks_.begin();it!=CQuarks_.end();it++){
52 +    myobject obj;
53 +    obj.px=it->Px();
54 +    obj.py=it->Py();
55 +    obj.pz=it->Pz();
56 +    obj.E=it->Energy();
57 +    obj.pt=it->Pt();
58 +    obj.eta=it->Eta();
59 +    obj.phi=it->Phi();
60 +    (myevent_->CQuarks).push_back(obj);
61 +  }
62 +  for(vector<TParticle>::const_iterator it=Photons_.begin();it!=Photons_.end();it++){
63 +    myobject obj;
64 +    obj.px=it->Px();
65 +    obj.py=it->Py();
66 +    obj.pz=it->Pz();
67 +    obj.E=it->Energy();
68 +    obj.pt=it->Pt();
69 +    obj.eta=it->Eta();
70 +    obj.phi=it->Phi();
71 +    (myevent_->Photons).push_back(obj);
72 +  }
73 +  for(vector<TParticle>::const_iterator it=Electrons_.begin();it!=Electrons_.end();it++){
74 +    myobject obj;
75 +    obj.px=it->Px();
76 +    obj.py=it->Py();
77 +    obj.pz=it->Pz();
78 +    obj.E=it->Energy();
79 +    obj.pt=it->Pt();
80 +    obj.eta=it->Eta();
81 +    obj.phi=it->Phi();
82 +    (myevent_->Electrons).push_back(obj);
83 +  }
84 +  for(vector<TParticle>::const_iterator it=Muons_.begin();it!=Muons_.end();it++){
85 +    myobject obj;
86 +    obj.px=it->Px();
87 +    obj.py=it->Py();
88 +    obj.pz=it->Pz();
89 +    obj.E=it->Energy();
90 +    obj.pt=it->Pt();
91 +    obj.eta=it->Eta();
92 +    obj.phi=it->Phi();
93 +    (myevent_->Muons).push_back(obj);
94 +  }
95 +  for(vector<TParticle>::const_iterator it=Taus_.begin();it!=Taus_.end();it++){
96 +    myobject obj;
97 +    obj.px=it->Px();
98 +    obj.py=it->Py();
99 +    obj.pz=it->Pz();
100 +    obj.E=it->Energy();
101 +    obj.pt=it->Pt();
102 +    obj.eta=it->Eta();
103 +    obj.phi=it->Phi();
104 +    (myevent_->Taus).push_back(obj);
105 +  }
106 +  for(vector<TParticle>::const_iterator it=ChargedHadrons_.begin();it!=ChargedHadrons_.end();it++){
107 +    myobject obj;
108 +    obj.px=it->Px();
109 +    obj.py=it->Py();
110 +    obj.pz=it->Pz();
111 +    obj.E=it->Energy();
112 +    obj.pt=it->Pt();
113 +    obj.eta=it->Eta();
114 +    obj.phi=it->Phi();
115 +    (myevent_->ChargedHadrons).push_back(obj);
116 +  }
117 +  for(vector<TParticle>::const_iterator it=NeutralHadrons_.begin();it!=NeutralHadrons_.end();it++){
118 +    myobject obj;
119 +    obj.px=it->Px();
120 +    obj.py=it->Py();
121 +    obj.pz=it->Pz();
122 +    obj.E=it->Energy();
123 +    obj.pt=it->Pt();
124 +    obj.eta=it->Eta();
125 +    obj.phi=it->Phi();
126 +    (myevent_->NeutralHadrons).push_back(obj);
127 +  }
128 +  for(vector<fastjet::PseudoJet>::const_iterator it=Jets_.begin();it!=Jets_.end();it++){
129 +    myobject obj;
130 +    obj.px=it->px();
131 +    obj.py=it->py();
132 +    obj.pz=it->pz();
133 +    obj.E=it->E();
134 +    obj.pt=it->perp();
135 +    obj.eta=it->eta();
136 +    obj.phi=it->phi();
137 +    (myevent_->Jets).push_back(obj);
138 +  }
139 +  for(vector<fastjet::PseudoJet>::const_iterator it=BJets_.begin();it!=BJets_.end();it++){
140 +    myobject obj;
141 +    obj.px=it->px();
142 +    obj.py=it->py();
143 +    obj.pz=it->pz();
144 +    obj.E=it->E();
145 +    obj.pt=it->perp();
146 +    obj.eta=it->eta();
147 +    obj.phi=it->phi();
148 +    (myevent_->BJets).push_back(obj);
149 +  }
150 +  for(vector<fastjet::PseudoJet>::const_iterator it=BJetsStdGeom_.begin();it!=BJetsStdGeom_.end();it++){
151 +    myobject obj;
152 +    obj.px=it->px();
153 +    obj.py=it->py();
154 +    obj.pz=it->pz();
155 +    obj.E=it->E();
156 +    obj.pt=it->perp();
157 +    obj.eta=it->eta();
158 +    obj.phi=it->phi();
159 +    (myevent_->BJetsStdGeom).push_back(obj);
160 +  }
161  
162 < bool ZHAnalysis::run() {
59 <
60 <  vector<TParticle> MyMuons = ufs->muonList();
61 <  vector<fastjet::PseudoJet> MyBJets = ufs->bJetList();
62 <
63 <  for(vector<TParticle>::const_iterator itm=MyMuons.begin();itm!=MyMuons.end();itm++){
64 <    hptmuons->Fill(itm->Pt());
65 <    hetamuons->Fill(itm->Eta());
66 <    hphimuons->Fill(itm->Phi());
67 <  }
68 <
69 <  for(vector<fastjet::PseudoJet>::const_iterator itb=MyBJets.begin();itb!=MyBJets.end();itb++){
70 <    hetbjets->Fill(itb->perp());
71 <    hetabjets->Fill(itb->eta());
72 <    hphibjets->Fill(itb->phi());
73 <  }
74 <  
75 <  //Event selection
76 <
77 <  double Zinvmass=0;
78 <  double Zpt=0;
79 <  double Hinvmass=0;
80 <  double Hpt=0;
81 <  double Hphi=0;
82 <  double Zphi=0;
83 <  double DphiZH=0;
84 <
85 <  AnalyzedEvents++;
86 <
87 <  if(MyMuons.size()==2){
88 <    
89 <    LeptonPairPreSelection++;
90 <    
91 <    if(MyMuons[0].Pt()>20. && MyMuons[1].Pt()>20.){
92 <      
93 <      LeptonPairSelection++;
94 <      
95 <      Zinvmass=(pow((MyMuons[0].Energy()+MyMuons[1].Energy()),2)-
96 <                pow((MyMuons[0].Px()+MyMuons[1].Px()),2)-
97 <                pow((MyMuons[0].Py()+MyMuons[1].Py()),2)-
98 <                pow((MyMuons[0].Pz()+MyMuons[1].Pz()),2));
99 <      if(Zinvmass>0)Zinvmass=sqrt(Zinvmass);
100 <      else Zinvmass=0;
101 <      Zpt=sqrt(pow((MyMuons[0].Px()+MyMuons[1].Px()),2)+pow((MyMuons[0].Py()+MyMuons[1].Py()),2));
102 <
103 <      double Zpx=0;
104 <      double Zpy=0;
105 <      Zpx=MyMuons[0].Px()+MyMuons[1].Px();
106 <      Zpy=MyMuons[0].Py()+MyMuons[1].Py();
107 <      Zphi=atan(Zpy/Zpx);
108 <      Zphi=CorrectPhi(Zphi,Zpx,Zpy);
109 <
110 <      hzinvmass->Fill(Zinvmass);
111 <      hptz->Fill(Zpt);
112 <      hphiz->Fill(Zphi);      
113 <  
114 <      if(MyBJets.size()==2){
115 <
116 <        BJetPairPreSelection++;
117 <
118 <        if(MyBJets[0].perp()>30. && MyBJets[1].perp()>30.){
119 <
120 <          BJetPairSelection++;
121 <          
122 <          Hinvmass=(pow((MyBJets[0].E()+MyBJets[1].E()),2)-
123 <                    pow((MyBJets[0].px()+MyBJets[1].px()),2)-
124 <                    pow((MyBJets[0].py()+MyBJets[1].py()),2)-
125 <                    pow((MyBJets[0].pz()+MyBJets[1].pz()),2));
126 <          if(Hinvmass>0)Hinvmass=sqrt(Hinvmass);
127 <          else Hinvmass=0;
128 <
129 <          Hpt=sqrt(pow((MyBJets[0].px()+MyBJets[1].px()),2)+pow((MyBJets[0].py()+MyBJets[1].py()),2));
130 <
131 <          double Hpx=0;
132 <          double Hpy=0;
133 <          Hpx=MyBJets[0].px()+MyBJets[1].px();
134 <          Hpy=MyBJets[0].py()+MyBJets[1].py();
135 <          Hphi=atan(Hpy/Hpx);
136 <          Hphi=CorrectPhi(Hphi,Hpx,Hpy);
137 <
138 <          hhinvmass->Fill(Hinvmass);
139 <          hpth->Fill(Hpt);
140 <          hphih->Fill(Hphi);
141 <
142 <          DphiZH=fabs(Hphi-Zphi);
143 <          if(DphiZH>M_PI)DphiZH = (2.*M_PI-DphiZH);
144 <          hdphiZH->Fill(DphiZH);
145 <
146 <          if(Zpt>150.){
147 <            
148 <            ZptSelection++;
149 <
150 <            if(Hpt>150.){
151 <              
152 <              HptSelection++;
153 <
154 <                hhinvmass2->Fill(Hinvmass);
155 <                if(Hinvmass<140. && Hinvmass>100){
156 <
157 <                  InvMassSelection++;
158 <                  
159 <                  if(DphiZH>2.5){
160 <                    
161 <                    DphiSelection++;
162 <                    
163 <                  }//dphi cut
164 <                }//inv mass cut
165 <            }//h pt cut
166 <          }//z pt cut
167 <        }//bjet et > 30 GeV
168 <      }//bjet pair
169 <    }//muon pt>20 GeV
170 <  }//muon.size==2
162 >  t->Fill();
163  
164    return true;
165  
166   }//Run
175
176 bool ZHAnalysis::end() {
177  outFile->cd();
178  return true;
179 }
180
181 ZHAnalysis::~ZHAnalysis() {
182  cout<<" ====================================== " <<endl;
183  cout<<" Analyzed Events               : "<<AnalyzedEvents<<endl;
184  cout<<" Lepton pair preselection eff.(%) : "<<100.*double(LeptonPairPreSelection)/AnalyzedEvents<<endl;
185  cout<<" Lepton pair    selection eff.(%) : "<<100.*double(LeptonPairSelection)/LeptonPairPreSelection<<endl;
186  cout<<" B-jet  pair preselection eff.(%) : "<<100.*double(BJetPairPreSelection)/LeptonPairSelection<<endl;
187  cout<<" B-jet  pair    selection eff.(%) : "<<100.*double(BJetPairSelection)/BJetPairPreSelection<<endl;
188  cout<<" Z pt                     eff.(%) : "<<100.*double(ZptSelection)/BJetPairSelection<<endl;
189  cout<<" H pt                     eff.(%) : "<<100.*double(HptSelection)/ZptSelection<<endl;
190  cout<<" H inv. mass              eff.(%) : "<<100.*double(InvMassSelection)/HptSelection<<endl;
191  cout<<" Dphi(H,Z)                eff.(%) : "<<100.*double(DphiSelection)/InvMassSelection<<endl;
192  cout<<" Total selection          eff.(%) : "<<100.*double(DphiSelection)/AnalyzedEvents<<endl;
193  cout<<" ====================================== " <<endl;
194 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines