ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronMuonTopoInfo.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/**************************************************************************
6 **
7 ** File: Trigger/TrigEvent/TrigTopoEvent/ElectronMuonTopoInfo.cxx
8 **
9 ** Description: -Class for description of combined electron-muon object for
10 ** algorithms in TrigEgammaMuonCombHypo package
11 **
12 ** Author: Pavel Jez <pavel.jez@cern.ch>
13 **
14 ** Created: Apr 9, 2011
15 **
16 **
17 **************************************************************************/
18
20#include <sstream>
21#include <iostream>
22#ifdef __APPLE__
23#include "CxxUtils/sincos.h"
24#endif
26// constructors
27
37
38ElectronMuonTopoInfo::ElectronMuonTopoInfo(int roiWord, float deltaPhi, float deltaR, float invMass, bool el_valid,
39 bool oppositeCharge, unsigned short vertexState): m_roiWord(roiWord),
42 m_InvMass(invMass),
43 m_electronValid(el_valid),
44 m_oppositeCharge(oppositeCharge),
45 m_vertexState(vertexState)
46
47{}
48
49// destructor
51
52
53// set methods
60 void ElectronMuonTopoInfo::SetVertexState(unsigned short vertexState){m_vertexState = vertexState;}
61
62// text output
63 std::string str( const ElectronMuonTopoInfo& d )
64 {
65 std::stringstream ss;
66 ss << "ElectronMuonTopoInfo at address: " << &d
67 << " RoIWord: " << d.RoiWord()
68 << " Delta Phi: " << d.DeltaPhi()
69 << " Delta R: " << d.DeltaR()
70 << " Invariant mass: " << d.InvMass()
71 << " electron valid: " << d.ElecValid()
72 << " opposite charge: " << d.OppositeCharge()
73 << " vertex state: " << d.VertexState();
74 return ss.str();
75 }
76
77 MsgStream& operator<< ( MsgStream& m, const ElectronMuonTopoInfo& d )
78 {
79 return( m << str ( d ) );
80 }
81
83 {
84 return(d1.DeltaPhi()==d2.DeltaPhi() && d1.DeltaR()==d2.DeltaR() && d1.InvMass()==d2.InvMass()
85 && d1.OppositeCharge()==d2.OppositeCharge() && d1.VertexState() == d2.VertexState() );
86 }
87 // helper functions, overloaded separately for L2 and EF interface
88
89 // Vextex matching @ L2
91 const CombinedMuonFeature* muon1) {
92
93
94 double trk_e1_z0error = electron1->err_Zvtx();
95 double trk_e2_z0error = muon1->IDTrack()->param()->ez0();
96
97
98 if ( trk_e1_z0error > 0 && trk_e2_z0error > 0 ) {
99 double z0_distance = fabs(electron1->Zvtx()
100 - muon1->IDTrack()->param()->z0());
101
102 double z0_error = sqrt(trk_e1_z0error * trk_e1_z0error
103 + trk_e2_z0error * trk_e2_z0error);
104
105
106 // reject combination if distance squared between perigee of
107 // tracks is greater than sqrt(6)*error = 2.45*error: this
108 // should accept 99% of good combinations (common vertex)
109 // Note: I changed 2.45 to 3 to be conservative => efficiency is
110 // now 99.7%
111 if (z0_distance > 3*z0_error) {
112 return NotCommon;
113
114 } else {
115
116 return Common;
117 }
118 }
119
120 return Unapplicable;
121}
122
123// Vertex matching @ EF
124
126 const Trk::Perigee* perigeeMU,
127 double& pull, bool debug) {
128
129 if(debug) std::cout << "Now checking electron perigee at " << perigeeEL << " and muon perigee at " << perigeeMU << "." << std::endl;
130
131
132 double electron_z0=0.;
133 double electron_z0_error=0.;
134
135 double muon_z0=0.;
136 double muon_z0_error=0.;
137
138 if(perigeeEL!=0)
139 {
140 electron_z0 = perigeeEL->parameters()[Trk::z0];
141 electron_z0_error= Amg::error( *perigeeEL->covariance(), Trk::z0 );
142 //electron_z0_error= perigeeEL->localErrorMatrix().error(Trk::z0);
143 delete perigeeEL;
144 }
145
146 if(perigeeMU!=0)
147 {
148
149
150
151 muon_z0 = perigeeMU->parameters()[Trk::z0];
152 muon_z0_error= Amg::error( *perigeeMU->covariance(), Trk::z0 );
153
154 //muon_z0_error= perigeeMU->localErrorMatrix().error(Trk::z0);
155 delete perigeeMU;
156 }
157
158 if(debug) std::cout << "Electron z0 = " << electron_z0 << "+-" << electron_z0_error << "; muon_z0 = " << muon_z0 << "+-" << muon_z0_error << std::endl;
159
160 pull = -999.;
161
162 if ( electron_z0_error > 0 && muon_z0_error > 0 ) {
163 double z0_distance = fabs(electron_z0
164 - muon_z0);
165
166 double z0_error = sqrt(electron_z0_error * electron_z0_error
167 + muon_z0_error * muon_z0_error);
168
169 pull = z0_distance/z0_error;
170
171 if(debug) std::cout << "z-distance is " << z0_distance << "+-" << z0_error << ". And the pull is " << pull << "." << std::endl;
172
173 // reject combination if distance squared between perigee of
174 // tracks is greater than sqrt(6)*error = 2.45*error: this
175 // should accept 99% of good combinations (common vertex)
176 // Note: I changed 2.45 to 3 to be conservative => efficiency is
177 // now 99.7%
178 if (z0_distance > 3*z0_error) {
180
181 } else {
182
184 }
185 }
186
188}
189
190
191//L2
193 const CombinedMuonFeature* muon1) {
194 if ( electron1->charge() * muon1->ptq() > 0 )
195 return false;
196 return true;
197}
198
199//EF
200bool ElectronMuonTopoInfo::opositeCharge(const egamma* electron1, const Trk::Perigee* muon1){
201 if( (electron1->charge() * muon1->charge()) > 0 )
202 return false;
203 return true;
204}
205
206//L2
208 const CombinedMuonFeature* muon1) {
209 double dPhi = electron1->phi()-muon1->IDTrack()->param()->phi0();
210 if (dPhi < -M_PI) dPhi += 2*M_PI;
211 if (dPhi > M_PI) dPhi -= 2*M_PI;
212 double distEmu = fabs(dPhi);
213
214 return distEmu;
215}
216
217//L2 tau tau
219 const TrigTau* tau2) {
220 double dPhi = tau1->phi()-tau2->phi();
221 if (dPhi < -M_PI) dPhi += 2*M_PI;
222 if (dPhi > M_PI) dPhi -= 2*M_PI;
223 double distEmu = fabs(dPhi);
224
225 return distEmu;
226}
227
228//L2 tau e
230 const TrigElectron* electron1) {
231 double dPhi = tau1->phi()-electron1->phi();
232 if (dPhi < -M_PI) dPhi += 2*M_PI;
233 if (dPhi > M_PI) dPhi -= 2*M_PI;
234 double distEmu = fabs(dPhi);
235
236 return distEmu;
237}
238
239//L2 tau mu
241 const CombinedMuonFeature* muon1) {
242 double dPhi = tau1->phi()-muon1->IDTrack()->param()->phi0();
243 if (dPhi < -M_PI) dPhi += 2*M_PI;
244 if (dPhi > M_PI) dPhi -= 2*M_PI;
245 double distEmu = fabs(dPhi);
246
247 return distEmu;
248}
249
250
251
252
253//L2
255 const CombinedMuonFeature* muon1) {
256 double dPhi = electron1->phi()-muon1->IDTrack()->param()->phi0();
257 if (dPhi < -M_PI) dPhi += 2*M_PI;
258 if (dPhi > M_PI) dPhi -= 2*M_PI;
259 double dEta = electron1->eta() - muon1->IDTrack()->param()->eta();
260 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
261
262 return distEmu;
263}
264
265//L2 tautau
267 const TrigTau* tau2) {
268 double dPhi = tau1->phi()-tau2->phi();
269 if (dPhi < -M_PI) dPhi += 2*M_PI;
270 if (dPhi > M_PI) dPhi -= 2*M_PI;
271 double dEta = tau1->eta() - tau2->eta();
272 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
273
274 return distEmu;
275}
276
277//L2 tau e
279 const TrigElectron* electron1) {
280 double dPhi = tau1->phi()-electron1->phi();
281 if (dPhi < -M_PI) dPhi += 2*M_PI;
282 if (dPhi > M_PI) dPhi -= 2*M_PI;
283 double dEta = tau1->eta() - electron1->eta();
284 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
285
286 return distEmu;
287}
288
289//L2 tau mu
291 const CombinedMuonFeature* muon1) {
292 double dPhi = tau1->phi()-muon1->IDTrack()->param()->phi0();
293 if (dPhi < -M_PI) dPhi += 2*M_PI;
294 if (dPhi > M_PI) dPhi -= 2*M_PI;
295 double dEta = tau1->eta() - muon1->IDTrack()->param()->eta();
296 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
297
298 return distEmu;
299}
300
301//EF
302double ElectronMuonTopoInfo::deltaPhi(const egamma* electron1,
303 const Trk::Perigee* muon1) {
304 float mu_phi = muon1->parameters()[Trk::phi];
305
306 double dPhi = electron1->trackParticle()->phi()-mu_phi;
307 if (dPhi < -M_PI) dPhi += 2*M_PI;
308 if (dPhi > M_PI) dPhi -= 2*M_PI;
309 double distEmu = fabs(dPhi);
310
311 return distEmu;
312}
313//EF tau tau
315 const Analysis::TauJet* tau2) {
316 double dPhi = tau1->phi()-tau2->phi();
317 if (dPhi < -M_PI) dPhi += 2*M_PI;
318 if (dPhi > M_PI) dPhi -= 2*M_PI;
319 double distEmu = fabs(dPhi);
320
321 return distEmu;
322}
323
324//EF tau e
326 const egamma* electron1) {
327 double dPhi = tau1->phi()-electron1->trackParticle()->phi();
328 if (dPhi < -M_PI) dPhi += 2*M_PI;
329 if (dPhi > M_PI) dPhi -= 2*M_PI;
330 double distEmu = fabs(dPhi);
331
332 return distEmu;
333}
334
335//EF tau mu
337 const Trk::Perigee* muon1) {
338 float mu_phi = muon1->parameters()[Trk::phi];
339
340 double dPhi = tau1->phi()-mu_phi;
341 if (dPhi < -M_PI) dPhi += 2*M_PI;
342 if (dPhi > M_PI) dPhi -= 2*M_PI;
343 double distEmu = fabs(dPhi);
344
345 return distEmu;
346}
347
348
349//EF
350double ElectronMuonTopoInfo::deltaR(const egamma* electron1,
351 const Trk::Perigee* muon1) {
352 float mu_phi =muon1->parameters()[Trk::phi];
353
354 double dPhi = electron1->trackParticle()->phi()-mu_phi;
355 if (dPhi < -M_PI) dPhi += 2*M_PI;
356 if (dPhi > M_PI) dPhi -= 2*M_PI;
357 double dEta = electron1->trackParticle()->eta() - muon1->eta();
358 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
359
360 return distEmu;
361}
362
363//EF tautau
365 const Analysis::TauJet* tau2) {
366 double dPhi = tau1->phi()-tau2->phi();
367 if (dPhi < -M_PI) dPhi += 2*M_PI;
368 if (dPhi > M_PI) dPhi -= 2*M_PI;
369 double dEta = tau1->eta() - tau2->eta();
370 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
371
372 return distEmu;
373}
374
375//EF tau e
377 const egamma* electron1) {
378 double dPhi = tau1->phi()-electron1->trackParticle()->phi();
379 if (dPhi < -M_PI) dPhi += 2*M_PI;
380 if (dPhi > M_PI) dPhi -= 2*M_PI;
381 double dEta = tau1->eta() - electron1->trackParticle()->eta();
382 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
383
384 return distEmu;
385}
386
387//EF tau mu
389 const Trk::Perigee* muon1) {
390 float mu_phi =muon1->parameters()[Trk::phi];
391
392 double dPhi = tau1->phi()-mu_phi;
393 if (dPhi < -M_PI) dPhi += 2*M_PI;
394 if (dPhi > M_PI) dPhi -= 2*M_PI;
395 double dEta = tau1->eta() - muon1->eta();
396 double distEmu = sqrt(dPhi*dPhi+dEta*dEta);
397
398 return distEmu;
399}
400
401
402// L2
404 const CombinedMuonFeature* muon1) {
405 // get parameters: not electron pT no longer signed
406 double eta1 = electron1->eta();
407 double eta2 = muon1->IDTrack()->param()->eta();
408
409
410 double Pt1 = electron1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
411 double Pt2 = muon1->pt(); // it returns the cluster pT; the track pT is given by Pt()
412
413 double phi1 = electron1->phi();
414 double phi2 = muon1->IDTrack()->param()->phi0();
415
417}
418
419// L2 tautau
421 const TrigTau* tau2) {
422 // get parameters: not electron pT no longer signed
423 double eta1 = tau1->eta();
424 double eta2 = tau2->eta();
425
426
427 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
428 double Pt2 = tau2->pt(); // it returns the cluster pT; the track pT is given by Pt()
429
430 double phi1 = tau1->phi();
431 double phi2 = tau2->phi();
432
433 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::tauMassInMeV);//tau mass used
434}
435
436// L2 tau e
438 const TrigElectron* electron1) {
439 // get parameters: not electron pT no longer signed
440 double eta1 = tau1->eta();
441 double eta2 = electron1->eta();
442
443
444 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
445 double Pt2 = electron1->pt(); // it returns the cluster pT; the track pT is given by Pt()
446
447 double phi1 = tau1->phi();
448 double phi2 = electron1->phi();
449
450 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::electronMassInMeV);//tau mass used
451}
452
453// L2 tau mu
455 const CombinedMuonFeature* muon1) {
456 // get parameters: not electron pT no longer signed
457 double eta1 = tau1->eta();
458 double eta2 = muon1->IDTrack()->param()->eta();
459
460
461 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
462 double Pt2 = muon1->pt(); // it returns the cluster pT; the track pT is given by Pt()
463
464 double phi1 = tau1->phi();
465 double phi2 = muon1->IDTrack()->param()->phi0();
466
467 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::muonMassInMeV);//tau mass used
468}
469
470// EF tautau
472 const Analysis::TauJet* tau2) {
473 // get parameters: not electron pT no longer signed
474 double eta1 = tau1->eta();
475 double eta2 = tau2->eta();
476
477
478 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
479 double Pt2 = tau2->pt(); // it returns the cluster pT; the track pT is given by Pt()
480
481 double phi1 = tau1->phi();
482 double phi2 = tau2->phi();
483
484 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::tauMassInMeV);//tau mass used
485}
486
487
488// EF tautau
490 const egamma* electron1) {
491 // get parameters: not electron pT no longer signed
492 double eta1 = tau1->eta();
493 double eta2 = electron1->trackParticle()->eta();
494
495
496 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
497 double Pt2 = electron1->cluster()->e()/cosh(electron1->trackParticle()->eta()) ; //
498
499 double phi1 = tau1->phi();
500 double phi2 = electron1->trackParticle()->phi();
501
502 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::electronMassInMeV);//tau mass used
503}
504// EF tautau
506 const Trk::Perigee* muon1) {
507 // get parameters: not electron pT no longer signed
508 double eta1 = tau1->eta();
509 double eta2 = muon1->eta();
510
511
512 double Pt1 = tau1->pt() ; // IMPORTANT: pt() is the 4-momentum base class method and
513 double Pt2 = muon1->pT() ; //
514
515 double phi1 = tau1->phi();
516 double phi2 = muon1->parameters()[Trk::phi];
517
518 return invariantMass(Pt1, eta1, phi1, ParticleConstants::tauMassInMeV, Pt2, eta2, phi2, ParticleConstants::muonMassInMeV);//tau mass used
519}
520
521double ElectronMuonTopoInfo::invariantMass(double Pt1, double eta1, double phi1, double m1,
522 double Pt2, double eta2, double phi2,double m2 ) const {
523 // protection in case upstream algorithm suplies negative pt
524
525 Pt1 = fabs(Pt1);
526 Pt2 = fabs(Pt2);
527
528 double theta1 = 2*atan2((double)exp(-eta1),1.);
529 double theta2 = 2*atan2((double)exp(-eta2),1.);
530 double P1 = Pt1/sin(theta1);
531 double P2 = Pt2/sin(theta2);
532 double p1[3],p2[3];
533
534 // Replace the following by sincos which calculates the sin and cos
535 // of the same angle 40% faster (fwinkl)
536 // p1[0] = Pt1*cos(phi1);
537 // p1[1] = Pt1*sin(phi1);
538#ifndef __APPLE__
539 sincos(phi1,&p1[1],&p1[0]);
540 p1[0] *= Pt1;
541 p1[1] *= Pt1;
542#else
543 CxxUtils::sincos scphi1(phi1);
544 p1[0] = Pt1*scphi1.cs;
545 p1[1] = Pt1*scphi1.sn;
546#endif
547
548 // dito
549 // p2[0] = Pt2*cos(phi2);
550 // p2[1] = Pt2*sin(phi2);
551#ifndef __APPLE__
552 sincos(phi2,&p2[1],&p2[0]);
553 p2[0] *= Pt2;
554 p2[1] *= Pt2;
555#else
556 CxxUtils::sincos scphi2(phi2);
557 p2[0] = Pt2*scphi2.cs;
558 p2[1] = Pt2*scphi2.sn;
559#endif
560
561 p1[2] = P1*cos(theta1);
562 p2[2] = P2*cos(theta2);
563
564 // evaluate mass
565 double Ptot1 = sqrt(std::pow(p1[0],2)+std::pow(p1[1],2)+std::pow(p1[2],2));
566 double Ptot2 = sqrt(std::pow(p2[0],2)+std::pow(p2[1],2)+std::pow(p2[2],2));
567 double e1 = sqrt(Ptot1*Ptot1 + m1*m1);
568 double e2 = sqrt(Ptot2*Ptot2 + m2*m2);
569 double mass = sqrt(m1*m1+m2*m2+ 2*e1*e2 - 2*p1[0]*p2[0] - 2*p1[1]*p2[1] - 2*p1[2]*p2[2]);
570
571 return mass;
572}
573// EF
575 const Trk::Perigee* muon1) {
576
577 // get parameters: not electron pT no longer signed
578 double eta1 = electron1->trackParticle()->eta();
579 double eta2 = muon1->eta();
580
581
582 double Pt1 = electron1->cluster()->e()/cosh(electron1->trackParticle()->eta()) ; // IMPORTANT: pt() is the 4-momentum base class method and
583 double Pt2 = muon1->pT(); // it returns the cluster pT; the track pT is given by Pt()
584
585 double phi1 = electron1->trackParticle()->phi();
586 double phi2 = muon1->parameters()[Trk::phi];
587
589}
590
591
#define M_PI
bool operator==(const ElectronMuonTopoInfo &d1, const ElectronMuonTopoInfo &d2)
MsgStream & operator<<(MsgStream &m, const ElectronMuonTopoInfo &d)
static Double_t ss
const bool debug
Object for taus common for ESD and AOD.
virtual double e() const
Retrieve energy independent of signal state.
double ptq(void) const
double pt(void) const
transverse momentum
const TrigInDetTrack * IDTrack(void) const
ElectronMuonTopoInfo is a class for storing information about combuned electron-muon object.
bool opositeCharge(const TrigElectron *electron1, const CombinedMuonFeature *muon1)
Opposite charge @ L2.
float m_DeltaR
Delta R between electron and muon.
double deltaR(const TrigElectron *electron1, const CombinedMuonFeature *muon1)
Delta R @ L2.
void SetOppositeCharge(bool OppositeCharge)
unsigned short m_vertexState
3 bit description of vertex: 0=common, 1=not common, 3= not applicable
float m_DeltaPhi
Delta Phi between electron and muon.
void SetElecValid(bool ElecValid)
void SetDeltaR(float DeltaR)
int m_roiWord
Identifier of the RoI.
void SetVertexState(unsigned short vextexState)
bool m_electronValid
boolean flag showing the validity of electron
void SetInvMass(float InvMass)
double invariantMass(const TrigElectron *electron1, const CombinedMuonFeature *muon1)
Invariant mass calculation @ L2.
double deltaPhi(const TrigElectron *electron1, const CombinedMuonFeature *muon1)
Delta phi @ L2.
void SetRoiWord(int RoiWord)
set methods
int RoiWord() const
accessor methods
float m_InvMass
Invariant mass of electron and muon.
Vertex commonVertex(const TrigElectron *electron1, const CombinedMuonFeature *muon1)
checking Vertex compatibility @ L2
void SetDeltaPhi(float DeltaPhi)
bool m_oppositeCharge
True if electron and muon have opposite charged.
virtual double phi() const =0
phi in [-pi,pi[
virtual double eta() const =0
pseudo rapidity
virtual double pt() const
get pt data member
virtual double eta() const
get eta data member
virtual double phi() const
get phi data member
virtual double pt() const
transverse momentum
virtual double phi() const
phi in [-pi,pi[
virtual double eta() const
pseudo rapidity
virtual ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
int charge() const
accessor to return the track charge (sign of TrigInDetTrack pT)
void param(const TrigInDetTrackFitPar *param)
File: TrigTau.h.
Definition TrigTau.h:37
double eta() const
Access method for pseudorapidity - from momentum.
double charge() const
Returns the charge.
double pT() const
Access method for transverse momentum.
elec/gamma data class.
Definition egamma.h:58
const Rec::TrackParticle * trackParticle(unsigned int index=0) const
pointer to TrackParticle
Definition egamma.cxx:391
const CaloCluster * cluster() const
pointer to CaloCluster
Definition egamma.cxx:360
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Definition Common.h:9
constexpr double muonMassInMeV
the mass of the muon (in MeV)
constexpr double tauMassInMeV
the mass of the tau (in MeV)
constexpr double electronMassInMeV
the mass of the electron (in MeV)
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ phi
Definition ParamDefs.h:75
@ z0
Definition ParamDefs.h:64
Helper to simultaneously calculate sin and cos of the same angle.
Helper to simultaneously calculate sin and cos of the same angle.
Definition sincos.h:39