CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TTbar_Kinematics.cc
Go to the documentation of this file.
6 
7 using namespace edm;
9  hepmcCollection_(iConfig.getParameter<edm::InputTag>("hepmcCollection"))
10  ,genEventInfoProductTag_(iConfig.getParameter<edm::InputTag>("genEventInfoProductTag"))
11 {
12 
13  hepmcCollectionToken_=consumes<HepMCProduct>(hepmcCollection_);
14  genEventInfoProductTagToken_=consumes<GenEventInfoProduct>(genEventInfoProductTag_);
15 }
16 
17 
19 
20 
21 //
22 // member functions
23 //
24 
25 // ------------ method called for each event ------------
27 {
28 
29  // --- the MC weights ---
31  iEvent.getByToken(genEventInfoProductTagToken_, evt_info);
32  if(!evt_info.isValid()) return;
33  weight = evt_info->weight() ;
34 
35 
36 
39  iEvent.getByToken(hepmcCollectionToken_, evt);
40 
41  //Get EVENT
42  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
43 
45  bool top(false), antitop(false), antibottom(false), bottom(false), Wplus(false), Wmin(false);
46  for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); iter++) {
47  if((*iter)->pdg_id()==PdtPdgMini::t || (*iter)->pdg_id()==PdtPdgMini::anti_t){
48  if( (*iter)->end_vertex()){
49  HepMC::GenVertex::particle_iterator des;
50  for(des = (*iter)->end_vertex()->particles_begin(HepMC::children);des!= (*iter)->end_vertex()->particles_end(HepMC::children);++des ){
51  if((*des)->pdg_id()==PdtPdgMini::b){
52  tlv_Bottom.SetPxPyPzE((*des)->momentum().px(),(*des)->momentum().py(),(*des)->momentum().pz(),(*des)->momentum().e());
53  bottom=true;
54  }
55  if((*des)->pdg_id()==PdtPdgMini::anti_b){
56  antibottom=true;
57  tlv_BottomBar.SetPxPyPzE((*des)->momentum().px(),(*des)->momentum().py(),(*des)->momentum().pz(),(*des)->momentum().e());
58  }
59  if((*des)->pdg_id()==PdtPdgMini::W_plus){
60  tlv_TopBar.SetPxPyPzE((*iter)->momentum().px(),(*iter)->momentum().py(),(*iter)->momentum().pz(),(*iter)->momentum().e()); antitop=true;
61  tlv_Wplus.SetPxPyPzE((*des)->momentum().px(),(*des)->momentum().py(),(*des)->momentum().pz(),(*des)->momentum().e()); Wplus=true;
62  }
63  if((*des)->pdg_id()==PdtPdgMini::W_minus){
64  tlv_Top.SetPxPyPzE((*iter)->momentum().px(),(*iter)->momentum().py(),(*iter)->momentum().pz(),(*iter)->momentum().e()); top=true;
65  tlv_Wmin.SetPxPyPzE((*des)->momentum().px(),(*des)->momentum().py(),(*des)->momentum().pz(),(*des)->momentum().e()); Wmin=true;
66  }
67  }
68  }
69  }
70  }
71 
72  tlv_TTbar = tlv_Top + tlv_TopBar ;
73 
74  //---topquarkquantities---
75  nEvt->Fill(0.5,weight);
76  if(top && antitop){
77  hTopPt->Fill(tlv_Top.Pt(),weight);
78  hTopPt->Fill(tlv_TopBar.Pt(),weight);
79 
80  hTopY->Fill(tlv_Top.Rapidity(),weight);
81  hTopY->Fill(tlv_TopBar.Rapidity(),weight);
82 
83  hTopMass->Fill(tlv_Top.M(),weight);
84  hTopMass->Fill(tlv_TopBar.M(),weight);
85 
86  //---ttbarpairquantities---
87  hTTbarPt->Fill(tlv_TTbar.Pt(),weight);
88  hTTbarY->Fill(tlv_TTbar.Rapidity(),weight);
89  hTTbarMass->Fill(tlv_TTbar.M(),weight);
90  }
91  if(bottom && antibottom){
92  hBottomPt->Fill(tlv_Bottom.Pt(),weight);
93  hBottomPt->Fill(tlv_BottomBar.Pt(),weight);
94 
95  hBottomEta->Fill(tlv_Bottom.Eta(),weight);
96  hBottomEta->Fill(tlv_BottomBar.Eta(),weight);
97 
98  //hBottomY->Fill(math::XYZTLorentzVector(bottom->momentum()).Rapidity(),weight);
99  //hBottomY->Fill(math::XYZTLorentzVector(antibottom->momentum()).Rapidity(),weight);
100 
101  hBottomY->Fill(tlv_Bottom.Rapidity(),weight);
102  hBottomY->Fill(tlv_BottomBar.Rapidity(),weight);
103 
104  hBottomPz->Fill(tlv_Bottom.Pz(),weight);
105  hBottomPz->Fill(tlv_BottomBar.Pz(),weight);
106 
107  hBottomE->Fill(tlv_Bottom.E(),weight);
108  hBottomE->Fill(tlv_BottomBar.E(),weight);
109 
110  hBottomMass->Fill(tlv_Bottom.M(),weight);
111  hBottomMass->Fill(tlv_BottomBar.M(),weight);
112 
113  hBottomPtPz->Fill(tlv_Bottom.Pt(),tlv_Bottom.Pz(),weight);
114  hBottomPtPz->Fill(tlv_BottomBar.Pt(),tlv_BottomBar.Pz(),weight);
115 
116  hBottomEtaPz->Fill(tlv_Bottom.Eta(),tlv_Bottom.Pz(),weight);
117  hBottomEtaPz->Fill(tlv_BottomBar.Eta(),tlv_BottomBar.Pz(),weight);
118 
119  hBottomEtaPt->Fill(tlv_Bottom.Eta(),tlv_Bottom.Pt(),weight);
120  hBottomEtaPt->Fill(tlv_BottomBar.Eta(),tlv_BottomBar.Pt(),weight);
121 
122  hBottomYPz->Fill(tlv_Bottom.Rapidity(),tlv_Bottom.Pz(),weight);
123  hBottomYPz->Fill(tlv_BottomBar.Rapidity(),tlv_BottomBar.Pz(),weight);
124 
125  hBottomMassPz->Fill(tlv_Bottom.M(),tlv_Bottom.Pz(),weight);
126  hBottomMassPz->Fill(tlv_BottomBar.M(),tlv_BottomBar.Pz(),weight);
127 
128  hBottomMassEta->Fill(tlv_Bottom.M(),tlv_Bottom.Eta(),weight);
129  hBottomMassEta->Fill(tlv_BottomBar.M(),tlv_BottomBar.Eta(),weight);
130 
131  hBottomMassY->Fill(tlv_Bottom.M(),tlv_Bottom.Rapidity(),weight);
132  hBottomMassY->Fill(tlv_BottomBar.M(),tlv_BottomBar.Rapidity(),weight);
133 
134  hBottomMassDeltaY->Fill(tlv_Bottom.M(),tlv_Bottom.Eta()-tlv_Bottom.Rapidity(),weight);
135  hBottomMassDeltaY->Fill(tlv_BottomBar.M(),tlv_BottomBar.Eta()-tlv_BottomBar.Rapidity(),weight);
136  }
137  if(Wplus && Wmin){
138  hWplusPz->Fill(tlv_Wplus.Pz(),weight);
139  hWminPz->Fill(tlv_Wmin.Pz(),weight);
140  }
141 }
142 
143 
144 // ------------ method called once each job just before starting event loop ------------
146  DQMHelper dqm(&i); i.setCurrentFolder("Generator/TTbar");
147 
148  nEvt = dqm.book1dHisto("nEvt", "n analyzed Events", 1, 0., 1.,"bins","Number of Events");
149 
150  hTopPt = dqm.book1dHisto("TTbar_TopPt","t quark transverse momentum",1000,0.,1000.,"P_{t}^{t quark} (GeV)","Number of Events");
151  hTopY = dqm.book1dHisto("TTbar_TopY","t quark rapidity",200,-5.,5.,"Y_{t quark}","Number of Events");
152  hTopMass = dqm.book1dHisto("TTbar_TopMass","t quark mass",500,0.,500.,"M_{t quark} (GeV)","Number of Events");
153 
154  hTTbarPt = dqm.book1dHisto("TTbar_TTbarPt","tt pair transverse momentum",1000,0.,1000.,"P_{t}^{tt pair} (GeV)","Number of Events");
155  hTTbarY = dqm.book1dHisto("TTbar_TTbarY","tt pair rapidity",200,-5.,5.,"Y_{tt pair}","Number of Events");
156  hTTbarMass = dqm.book1dHisto("TTbar_TTbarMass","tt pair mass",1000,0.,1000.,"M_{tt pair} (GeV)","Number of Events");
157 
158  hBottomPt = dqm.book1dHisto("TTbar_BottomPt","b quark transverse momentum",1000,0.,1000.,"P_{t}^{b quark} (GeV)","Number of Events");
159  hBottomEta = dqm.book1dHisto("TTbar_BottomEta","b quark pseudo-rapidity",200,-5.,5.,"#eta_{b quark} (GeV)","Number of Events");
160  hBottomY = dqm.book1dHisto("TTbar_BottomY","b quark rapidity",200,-5.,5.,"M_{b quark} (GeV)","Number of Events");
161  hBottomPz = dqm.book1dHisto("TTbar_BottomPz","b quark longitudinal momentum",200,-100.,100.,"P_{z}^{b quark} (GeV)","Number of Events");
162  hBottomE = dqm.book1dHisto("TTbar_BottomE","b quark energy",1000,0.,1000.,"E_{b quark} (GeV)","Number of Events");
163  hBottomMass = dqm.book1dHisto("TTbar_BottomMass","b quark mass",50,0.,5.,"M_{b quark} (GeV)","Number of Events");
164 
165  hBottomPtPz = dqm.book2dHisto("TTbar_BottomPtPz","b quark longitudinal vs transverse momentum",1000,0.,1000.,200,-100.,100.,"P_{z}^{b quark} (GeV)","P_{t}^{b quark} (GeV)");
166  hBottomEtaPz = dqm.book2dHisto("TTbar_BottomEtaPz","b quark longitudinal momentum vs pseudorapidity",200,-5.,5.,200,-100.,100.,"#eta_{b quark}","P_{z}^{b quark} (GeV)");
167  hBottomEtaPt = dqm.book2dHisto("TTbar_BottomEtaPt"," quark transveral momentum vs pseudorapidity",200,-5.,5.,1000,0.,1000.,"#eta_{b quark}","P_{t}^{b quark} (GeV)");
168  hBottomYPz = dqm.book2dHisto("TTbar_BottomYPz","b quark longitudinal momentum vs rapidity",200,-5.,5.,200,-100.,100.,"Y_{b quark}","P_{z}^{b quark} (GeV)");
169  hBottomMassPz = dqm.book2dHisto("TTbar_BottomMassPz","b quark longitudinal momentum vs mass",50,0.,5.,200,-100.,100.,"M_{b quark} (GeV)","P_{z}^{b quark} (GeV)");
170  hBottomMassEta = dqm.book2dHisto("TTbar_BottomMassEta","b quark pseudorapidity vs mass",50,0.,5.,200,-5.,5.,"M_{b quark} (GeV)","#eta_{b quark}");
171  hBottomMassY = dqm.book2dHisto("TTbar_BottomMassY","b quark rapidity vs mass",50,0.,5.,200,-5.,5.,"M_{b quark} (GeV)","Y_{b quark}");
172  hBottomMassDeltaY = dqm.book2dHisto("TTbar_BottomMassDeltaY","b quark pseudorapidity - rapidity vs mass",50,0.,50.,2000,-5.,5.,"M_{b quark} (GeV)","Y_{b quark}");
173 
174  hWplusPz = dqm.book1dHisto("TTbar_WplusPz","W+ boson longitudinal momentum",200,-100.,100.,"P_{z}^{W+} (GeV)","Number of Events");
175  hWminPz = dqm.book1dHisto("TTbar_WminPz","W- boson longitudinal momentum",200,-100.,100.,"P_{z}^{W-} (GeV)","Number of Events");
176 
177 }
178 
MonitorElement * book2dHisto(std::string name, std::string title, int nx, double xmin, double xmax, int ny, double ymin, double ymax, std::string xaxis, std::string yaxis)
Definition: DQMHelper.cc:27
int i
Definition: DBlmapReader.cc:9
MonitorElement * hBottomYPz
MonitorElement * nEvt
TLorentzVector tlv_Bottom
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoProductTagToken_
MonitorElement * hBottomMass
MonitorElement * hBottomPtPz
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
MonitorElement * hTTbarMass
MonitorElement * hBottomMassY
TLorentzVector tlv_Wplus
MonitorElement * book1dHisto(std::string name, std::string title, int n, double xmin, double xmax, std::string xaxis, std::string yaxis)
Definition: DQMHelper.cc:12
MonitorElement * hBottomEtaPt
void Fill(long long x)
MonitorElement * hBottomEta
TLorentzVector tlv_TopBar
int iEvent
Definition: GenABIO.cc:230
MonitorElement * hTopMass
MonitorElement * hTTbarY
TLorentzVector tlv_TTbar
MonitorElement * hWminPz
bool isValid() const
Definition: HandleBase.h:75
TLorentzVector tlv_BottomBar
MonitorElement * hBottomMassPz
MonitorElement * hBottomMassEta
edm::InputTag genEventInfoProductTag_
MonitorElement * hBottomPz
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
MonitorElement * hTopY
TLorentzVector tlv_Wmin
MonitorElement * hTTbarPt
MonitorElement * hBottomMassDeltaY
MonitorElement * hBottomPt
MonitorElement * hTopPt
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
TLorentzVector tlv_Top
MonitorElement * hBottomE
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * hWplusPz
edm::InputTag hepmcCollection_
MonitorElement * hBottomEtaPz
TTbar_Kinematics(const edm::ParameterSet &)
Definition: Run.h:43
MonitorElement * hBottomY