25 |
|
m_logger << DEBUG << "Constructor called." << SLogger::endmsg; |
26 |
|
m_bcc = NULL; |
27 |
|
m_lumi = NULL; |
28 |
+ |
m_primlep = NULL; |
29 |
+ |
m_ttgen = NULL; |
30 |
|
} |
31 |
|
|
32 |
|
EventCalc::~EventCalc() |
49 |
|
// reset booleans |
50 |
|
b_HT = false; |
51 |
|
b_HTlep = false; |
52 |
+ |
b_Reconstruction = false; |
53 |
|
|
54 |
+ |
m_primlep = NULL; |
55 |
+ |
m_ttgen = NULL; |
56 |
|
} |
57 |
|
|
58 |
|
BaseCycleContainer* EventCalc::GetBaseCycleContainer() |
133 |
|
return m_HTlep; |
134 |
|
} |
135 |
|
|
136 |
+ |
Particle* EventCalc::GetPrimaryLepton(){ |
137 |
+ |
|
138 |
+ |
if(!m_primlep){ |
139 |
+ |
double ptmax = -999; |
140 |
+ |
for(unsigned int i=0; i<m_bcc->electrons->size(); ++i){ |
141 |
+ |
if(m_bcc->electrons->at(i).pt()>ptmax){ |
142 |
+ |
ptmax = m_bcc->electrons->at(i).pt(); |
143 |
+ |
m_primlep = &m_bcc->electrons->at(i); |
144 |
+ |
} |
145 |
+ |
} |
146 |
+ |
for(unsigned int i=0; i<m_bcc->muons->size(); ++i){ |
147 |
+ |
if(m_bcc->muons->at(i).pt()>ptmax){ |
148 |
+ |
ptmax = m_bcc->muons->at(i).pt(); |
149 |
+ |
m_primlep = &m_bcc->muons->at(i); |
150 |
+ |
} |
151 |
+ |
} |
152 |
+ |
} |
153 |
+ |
|
154 |
+ |
return m_primlep; |
155 |
+ |
} |
156 |
+ |
|
157 |
+ |
TTbarGen* EventCalc::GetTTbarGen(){ |
158 |
+ |
|
159 |
+ |
if(!m_ttgen){ |
160 |
+ |
m_ttgen = new TTbarGen(); |
161 |
+ |
} |
162 |
+ |
|
163 |
+ |
return m_ttgen; |
164 |
+ |
} |
165 |
+ |
|
166 |
+ |
|
167 |
+ |
std::vector<LorentzVector> EventCalc::NeutrinoReconstruction(const LorentzVector lepton, const LorentzVector met){ |
168 |
+ |
|
169 |
+ |
|
170 |
+ |
TVector3 lepton_pT = toVector(lepton); |
171 |
+ |
lepton_pT.SetZ(0); |
172 |
+ |
|
173 |
+ |
TVector3 neutrino_pT = toVector(met); |
174 |
+ |
neutrino_pT.SetZ(0); |
175 |
+ |
|
176 |
+ |
const float mass_w = 80.399; |
177 |
+ |
float mu = mass_w * mass_w / 2 + lepton_pT * neutrino_pT; |
178 |
+ |
|
179 |
+ |
float A = - (lepton_pT * lepton_pT); |
180 |
+ |
float B = mu * lepton.pz(); |
181 |
+ |
float C = mu * mu - lepton.e() * lepton.e() * (neutrino_pT * neutrino_pT); |
182 |
+ |
|
183 |
+ |
float discriminant = B * B - A * C; |
184 |
+ |
|
185 |
+ |
std::vector<LorentzVector> solutions; |
186 |
+ |
|
187 |
+ |
if (0 >= discriminant) |
188 |
+ |
{ |
189 |
+ |
// Take only real part of the solution |
190 |
+ |
// |
191 |
+ |
LorentzVectorXYZE solution (0,0,0,0); |
192 |
+ |
solution.SetPx(met.Px()); |
193 |
+ |
solution.SetPy(met.Py()); |
194 |
+ |
solution.SetPz(-B / A); |
195 |
+ |
solution.SetE(toVector(solution).Mag()); |
196 |
+ |
|
197 |
+ |
solutions.push_back(toPtEtaPhi(solution)); |
198 |
+ |
|
199 |
+ |
//_solutions = 0 > discriminant ? 0 : 1; |
200 |
+ |
} |
201 |
+ |
else |
202 |
+ |
{ |
203 |
+ |
discriminant = sqrt(discriminant); |
204 |
+ |
|
205 |
+ |
LorentzVectorXYZE solution (0,0,0,0); |
206 |
+ |
solution.SetPx(met.Px()); |
207 |
+ |
solution.SetPy(met.Py()); |
208 |
+ |
solution.SetPz((-B - discriminant) / A); |
209 |
+ |
solution.SetE(toVector(solution).Mag()); |
210 |
+ |
|
211 |
+ |
solutions.push_back(toPtEtaPhi(solution)); |
212 |
+ |
|
213 |
+ |
LorentzVectorXYZE solution2 (0,0,0,0); |
214 |
+ |
solution2.SetPx(met.Px()); |
215 |
+ |
solution2.SetPy(met.Py()); |
216 |
+ |
solution2.SetPz((-B + discriminant) / A); |
217 |
+ |
solution2.SetE(toVector(solution2).Mag()); |
218 |
+ |
|
219 |
+ |
solutions.push_back(toPtEtaPhi(solution2)); |
220 |
+ |
|
221 |
+ |
//_solutions = 2; |
222 |
+ |
} |
223 |
+ |
|
224 |
+ |
return solutions; |
225 |
+ |
} |
226 |
+ |
|
227 |
+ |
void EventCalc::FillHighMassTTbarHypotheses(){ |
228 |
+ |
|
229 |
+ |
if(b_Reconstruction) return; |
230 |
+ |
b_Reconstruction=true; |
231 |
+ |
|
232 |
+ |
//clear hypothesis list |
233 |
+ |
m_bcc->recoHyps->clear(); |
234 |
+ |
|
235 |
+ |
//find primary charged lepton |
236 |
+ |
Particle* lepton = GetPrimaryLepton(); |
237 |
+ |
|
238 |
+ |
//reconstruct neutrino |
239 |
+ |
std::vector<LorentzVector> neutrinos = NeutrinoReconstruction( lepton->v4(), m_bcc->met->v4()); |
240 |
+ |
|
241 |
+ |
ReconstructionHypothesis hyp; |
242 |
+ |
|
243 |
+ |
hyp.set_lepton(*lepton); |
244 |
+ |
|
245 |
+ |
//loop over neutrino solutions and jet assignments to fill hyotheses |
246 |
+ |
for(unsigned int i=0; i< neutrinos.size();++i){ |
247 |
+ |
|
248 |
+ |
hyp.set_neutrino_v4(neutrinos[i]); |
249 |
+ |
LorentzVector wlep_v4 = lepton->v4()+neutrinos[i]; |
250 |
+ |
|
251 |
+ |
unsigned int n_jets = m_bcc->jets->size(); |
252 |
+ |
unsigned int max_j = myPow(3, n_jets); |
253 |
+ |
for (unsigned int j=0; j < max_j; j++) { |
254 |
+ |
LorentzVector tophad_v4(0,0,0,0); |
255 |
+ |
LorentzVector toplep_v4 = wlep_v4; |
256 |
+ |
int hadjets=0; |
257 |
+ |
int lepjets=0; |
258 |
+ |
int num = j; |
259 |
+ |
hyp.clear_jetindices(); |
260 |
+ |
for (unsigned int k=0; k<n_jets; k++) { |
261 |
+ |
// num is the k-th digit of j if you |
262 |
+ |
// write j in a base-3 system. According |
263 |
+ |
// to the value of this digit (which takes |
264 |
+ |
// values from 0 to 2, |
265 |
+ |
// in all possible combinations with the other digits), |
266 |
+ |
// decide how to treat the jet. |
267 |
+ |
|
268 |
+ |
if(num%3==0) { |
269 |
+ |
tophad_v4 = tophad_v4 + m_bcc->jets->at(k).v4(); |
270 |
+ |
hyp.add_tophad_jet_index(k); |
271 |
+ |
hadjets++; |
272 |
+ |
} |
273 |
+ |
|
274 |
+ |
if(num%3==1) { |
275 |
+ |
toplep_v4 = toplep_v4 + m_bcc->jets->at(k).v4(); |
276 |
+ |
hyp.add_toplep_jet_index(k); |
277 |
+ |
lepjets++; |
278 |
+ |
} |
279 |
+ |
//if(num%3==2); //do not take this jet |
280 |
+ |
|
281 |
+ |
//shift the trigits of num to the right: |
282 |
+ |
num /= 3; |
283 |
+ |
} |
284 |
+ |
|
285 |
+ |
//search jet with highest pt assigned to leptonic top |
286 |
+ |
float maxpt=-999; |
287 |
+ |
int maxind=-1; |
288 |
+ |
for(unsigned int i=0; i<hyp.toplep_jets_indices().size(); ++i){ |
289 |
+ |
float pt = m_bcc->jets->at(hyp.toplep_jets_indices().at(i)).pt(); |
290 |
+ |
if(pt>maxpt){ |
291 |
+ |
maxpt=pt; |
292 |
+ |
maxind=hyp.toplep_jets_indices().at(i); |
293 |
+ |
} |
294 |
+ |
} |
295 |
+ |
hyp.set_blep_index(maxind); |
296 |
+ |
|
297 |
+ |
|
298 |
+ |
//fill only hypotheses with at least one jet assigned to each top quark |
299 |
+ |
if(hadjets>0 && lepjets>0){ |
300 |
+ |
hyp.set_tophad_v4(tophad_v4); |
301 |
+ |
hyp.set_toplep_v4(toplep_v4); |
302 |
+ |
m_bcc->recoHyps->push_back(hyp); |
303 |
+ |
} |
304 |
+ |
} |
305 |
+ |
} |
306 |
+ |
|
307 |
+ |
} |
308 |
+ |
|
309 |
+ |
|
310 |
|
void EventCalc::PrintEventContent(){ |
311 |
|
|
312 |
|
m_logger << INFO << "----------------- event content -----------------" << SLogger::endmsg; |
314 |
|
m_logger << INFO << "MET = " << m_bcc->met->pt() << " METphi = " << m_bcc->met->phi() << " HTlep = " << GetHTlep() << SLogger::endmsg; |
315 |
|
if(m_bcc->electrons){m_logger << INFO << "Electrons:" << SLogger::endmsg; |
316 |
|
for(unsigned int i=0; i<m_bcc->electrons->size(); ++i){ |
317 |
< |
m_logger << INFO << " " << i+1 << " pt = " << m_bcc->electrons->at(i).pt() <<" eta = " << m_bcc->electrons->at(i).eta() << SLogger::endmsg; |
317 |
> |
m_logger << INFO << " " << i+1 << " pt = " << m_bcc->electrons->at(i).pt() <<" eta = " << m_bcc->electrons->at(i).eta() |
318 |
> |
<< " supercluster eta = " <<m_bcc->electrons->at(i).supercluster_eta() << " IP wrt bsp = " << fabs(m_bcc->electrons->at(i).gsfTrack_dxy_vertex(m_bcc->pvs->at(0).x(), m_bcc->pvs->at(0).y())) |
319 |
> |
<< " pass conv veto = " << m_bcc->electrons->at(i).passconversionveto() << " mvaTrigV0 = " << m_bcc->electrons->at(i).mvaTrigV0() |
320 |
> |
<< " dEtaIn = " << m_bcc->electrons->at(i).dEtaIn() << " sigmaIEtaIEta = " << m_bcc->electrons->at(i).sigmaIEtaIEta() |
321 |
> |
<< " HoverE = " << m_bcc->electrons->at(i).HoverE() << " EcalEnergy = " << m_bcc->electrons->at(i).EcalEnergy() |
322 |
> |
<< " EoverPIn = " << m_bcc->electrons->at(i).EoverPIn() << " trackMomentumAtVtx = " << m_bcc->electrons->at(i).EcalEnergy()/m_bcc->electrons->at(i).EoverPIn() |
323 |
> |
<< SLogger::endmsg; |
324 |
|
} |
325 |
|
} |
326 |
|
if(m_bcc->muons){m_logger << INFO << "Muons:" << SLogger::endmsg; |
335 |
|
} |
336 |
|
if(m_bcc->jets){m_logger << INFO << "Jets:" << SLogger::endmsg; |
337 |
|
for(unsigned int i=0; i<m_bcc->jets->size(); ++i){ |
338 |
< |
m_logger << INFO << " " << i+1 << " pt = " << m_bcc->jets->at(i).pt() <<" eta = " << m_bcc->jets->at(i).eta() << SLogger::endmsg; |
338 |
> |
m_logger << INFO << " " << i+1 << " pt = " << m_bcc->jets->at(i).pt() <<" eta = " << m_bcc->jets->at(i).eta() << " genjet_pt = " << m_bcc->jets->at(i).genjet_pt() << " genjet_eta = " << m_bcc->jets->at(i).genjet_eta() <<SLogger::endmsg; |
339 |
|
} |
340 |
|
} |
341 |
|
if(m_bcc->topjets){m_logger << INFO << "TopJets:" << SLogger::endmsg; |