ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ElectronSelector Class Reference

#include <ElectronSelector.h>

Inheritance diagram for ElectronSelector:
Collaboration diagram for ElectronSelector:

Public Member Functions

 ElectronSelector ()
 
 ~ElectronSelector ()
 
 ElectronSelector (const ElectronSelector &)=delete
 
ElectronSelectoroperator= (const ElectronSelector &)=delete
 
void setDebug (bool debug)
 
const xAOD::TrackParticleGetElecNegTrackParticle (size_t i)
 
const xAOD::TrackParticleGetElecPosTrackParticle (size_t i)
 
unsigned int GetElectronCollectionSize ()
 
void Init ()
 
void PrepareElectronList (const xAOD::ElectronContainer *pxElecContainer)
 
bool RecordElectron (const xAOD::Electron *)
 
void SetPtCut (float newpt)
 

Static Public Member Functions

template<class T >
static CLHEP::Hep3Vector calculateMomentum (const T *pP)
 
template<class T >
static float EvalInvMass (const T *pxP1, const T *pxP2, float fMass1, float fMass2=invalidAnswer)
 
template<class T >
static float EvalInvMass (const T *pxP1, const T *pxP2, const T *pxp3, const T *pxP4, float fMass1, float fMass2=-999.9, float fMass3=-999.9, float fMass4=invalidAnswer)
 
template<class T >
static float EvalDiMuInvMass (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalFourMuInvMass (const T *pxP1, const T *pxP2, const T *pxP3, const T *pxP4)
 
template<class T >
static float EvaluateAngle (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalPtDiff (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalPhiDiff (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalEtaDiff (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalPt (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalPhi (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalEta (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalCharge (const T *pxP1, const T *pxP2)
 
template<class T >
static float EvalTransverseMass (const T *pxP1, float fMETx, float fMETy, float fMass1, float fMass2=invalidAnswer)
 
template<class T >
static float EvalTransverseMass (const T *pxP1, float fMETx, float fMETy)
 
template<class T >
static float EvalTransverseMass (const T *pxP1, const T *pxP2, float fMETx, float fMETy, float fMass1, float fMass2=invalidAnswer)
 
template<class T >
static float EvalTransverseMass (const T *pxP1, const T *pxP2, float fMETx, float fMETy)
 

Static Public Attributes

static constexpr float invalidAnswer {-999.9f}
 

Protected Member Functions

virtual void BookHistograms ()
 

Protected Attributes

unsigned int m_uPassedEvents
 
std::map< unsigned int, TH1F * > m_x1DHistograms
 
std::map< unsigned int, TH2F * > m_x2DHistograms
 
std::map< unsigned int, TProfile * > m_x1DProfHistograms
 
std::map< unsigned int, TProfile2D * > m_x2DProfHistograms
 
std::string m_xSampleName
 

Private Types

typedef EventAnalysis PARENT
 

Private Member Functions

void Clear ()
 
bool OrderElectronList ()
 
bool RetrieveVertices ()
 
void Register ()
 

Private Attributes

MsgStream * m_msgStream
 
const xAOD::Muonm_pxElectron
 
std::vector< const xAOD::TrackParticle * > m_pxElTrackList
 
std::vector< const xAOD::TrackParticle * > m_goodElecNegTrackParticleList
 
std::vector< const xAOD::TrackParticle * > m_goodElecPosTrackParticleList
 
bool m_doDebug
 
float m_ptCut
 
float m_etaCut
 
AsgElectronLikelihoodToolm_LHTool2015 = nullptr
 
int m_elecneg1 = 0
 
int m_elecneg2 = 0
 
int m_elecpos1 = 0
 
int m_elecpos2 = 0
 
const float m_CGeV = 1.0e-3
 

Static Private Attributes

static std::atomic< unsigned int > s_uNumInstances
 

Detailed Description

Definition at line 30 of file ElectronSelector.h.

Member Typedef Documentation

◆ PARENT

Definition at line 54 of file ElectronSelector.h.

Constructor & Destructor Documentation

◆ ElectronSelector() [1/2]

ElectronSelector::ElectronSelector ( )

Definition at line 32 of file ElectronSelector.cxx.

32  :
33  m_doDebug ( false ),
34  m_ptCut ( 10. ),
35  m_etaCut ( 2.47 ) // 2.47 is the official acceptance for central electrons. Forward electrons is another story...
36 {
38 
39  std::stringstream xTmp; xTmp << s_uNumInstances;
40  m_xSampleName = "ElectronSelector_" + xTmp.str();
41 
42  m_pxElectron = nullptr;
43 
44  m_msgStream = new MsgStream(PerfMonServices::getMessagingService(), "InDetPerformanceMonitoring" );
45 }

◆ ~ElectronSelector()

ElectronSelector::~ElectronSelector ( )

Definition at line 48 of file ElectronSelector.cxx.

49 {
51  delete m_msgStream;
52 }

◆ ElectronSelector() [2/2]

ElectronSelector::ElectronSelector ( const ElectronSelector )
delete

Member Function Documentation

◆ BookHistograms()

void EventAnalysis::BookHistograms ( )
protectedvirtualinherited

Reimplemented in FourMuonEvent, ZmumuEvent, and MuonSelector.

Definition at line 56 of file EventAnalysis.cxx.

57 {
58  // This must be overriden by an inheriting class.
59 }

◆ calculateMomentum()

template<class T >
CLHEP::Hep3Vector EventAnalysis::calculateMomentum ( const T *  pP)
staticinherited

Definition at line 91 of file EventAnalysis.h.

91  {
92  const auto & p4(pP->p4());
93  return CLHEP::Hep3Vector(p4.Px() * EAna::CGeV , p4.Py() * EAna::CGeV, p4.Pz() * EAna::CGeV);
94 }

◆ Clear()

void ElectronSelector::Clear ( )
private

Definition at line 210 of file ElectronSelector.cxx.

211 {
212  m_pxElTrackList.clear();
215 
216  // -1 means not assigned
217  m_elecneg1 = -1;
218  m_elecneg2 = -1;
219  m_elecpos1 = -1;
220  m_elecpos2 = -1;
221 
222  return;
223 }

◆ EvalCharge()

template<class T >
float EventAnalysis::EvalCharge ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 238 of file EventAnalysis.h.

239 {
240  // Check integrity of inputs.
241  if ( !pxP1 || !pxP2 ) return invalidAnswer;
242  return static_cast<float>( pxP1->charge() + pxP2->charge() );
243 }

◆ EvalDiMuInvMass()

template<class T >
float EventAnalysis::EvalDiMuInvMass ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 97 of file EventAnalysis.h.

98 {
99  // Check integrity of inputs.
100  if ( !pxP1 || !pxP2 ) return invalidAnswer;
101 
102  // Evaluate Di-mu invariant mass.
103  return EvalInvMass( pxP1, pxP2, EAna::g_fMuonMass );
104 }

◆ EvalEta()

template<class T >
float EventAnalysis::EvalEta ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 229 of file EventAnalysis.h.

230 {
231  // Check integrity of inputs.
232  if ( !pxP1 || !pxP2 ) return invalidAnswer;
233  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
234  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
235  return static_cast<float>( (xTmp1 + xTmp2).pseudoRapidity() );
236 }

◆ EvalEtaDiff()

template<class T >
float EventAnalysis::EvalEtaDiff ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 201 of file EventAnalysis.h.

202 {
203  // Check integrity of inputs.
204  if ( !pxP1 || !pxP2 ) return invalidAnswer;
205  // Evaluate the angle.
206  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
207  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
208  return static_cast<float>( xTmp1.polarAngle(xTmp2) );
209 }

◆ EvalFourMuInvMass()

template<class T >
float EventAnalysis::EvalFourMuInvMass ( const T *  pxP1,
const T *  pxP2,
const T *  pxP3,
const T *  pxP4 
)
staticinherited

Definition at line 123 of file EventAnalysis.h.

124 {
125  // Check integrity of inputs.
126  if ( !pxP1 || !pxP2 || !pxP3 || !pxP4) return invalidAnswer;
127 
128  // Evaluate invariant mass.
129  return EvalInvMass( pxP1, pxP2, pxP3, pxP4, EAna::g_fMuonMass );
130 }

◆ EvalInvMass() [1/2]

template<class T >
float EventAnalysis::EvalInvMass ( const T *  pxP1,
const T *  pxP2,
const T *  pxp3,
const T *  pxP4,
float  fMass1,
float  fMass2 = -999.9,
float  fMass3 = -999.9,
float  fMass4 = invalidAnswer 
)
staticinherited

Definition at line 132 of file EventAnalysis.h.

134 {
135  // Check integrity of inputs.No tachyons.
136  if ( fMass1 < 0.0f ) return invalidAnswer;
137  if ( !pxP1 || !pxP2 || !pxP3 || !pxP4) return invalidAnswer;
138 
139  // Set masses equal if required by user
140  fMass2 = ( fMass2 < 0.0f ) ? fMass1 : fMass2;
141  fMass3 = ( fMass3 < 0.0f ) ? fMass1 : fMass3;
142  fMass4 = ( fMass4 < 0.0f ) ? fMass1 : fMass4;
143 
144  // Evaluate invariant mass.
145  CLHEP::Hep3Vector xTmp1 = CLHEP::Hep3Vector( pxP1->p4().Px() * EAna::CGeV, pxP1->p4().Py() * EAna::CGeV, pxP1->p4().Pz() * EAna::CGeV );
146  CLHEP::Hep3Vector xTmp2 = CLHEP::Hep3Vector( pxP2->p4().Px() * EAna::CGeV, pxP2->p4().Py() * EAna::CGeV, pxP2->p4().Pz() * EAna::CGeV );
147  CLHEP::Hep3Vector xTmp3 = CLHEP::Hep3Vector( pxP3->p4().Px() * EAna::CGeV, pxP3->p4().Py() * EAna::CGeV, pxP3->p4().Pz() * EAna::CGeV );
148  CLHEP::Hep3Vector xTmp4 = CLHEP::Hep3Vector( pxP4->p4().Px() * EAna::CGeV, pxP4->p4().Py() * EAna::CGeV, pxP4->p4().Pz() * EAna::CGeV );
149 
150  CLHEP::HepLorentzVector xLVec; xLVec.setVectM ( xTmp1, fMass1 );
151  CLHEP::HepLorentzVector xLVec2; xLVec2.setVectM( xTmp2, fMass2 );
152  CLHEP::HepLorentzVector xLVec3; xLVec3.setVectM( xTmp3, fMass3 );
153  CLHEP::HepLorentzVector xLVec4; xLVec4.setVectM( xTmp4, fMass4 );
154 
155  xLVec += xLVec2;
156  xLVec += xLVec3;
157  xLVec += xLVec4;
158 
159  return static_cast<float>( xLVec.m() );
160 }

◆ EvalInvMass() [2/2]

template<class T >
float EventAnalysis::EvalInvMass ( const T *  pxP1,
const T *  pxP2,
float  fMass1,
float  fMass2 = invalidAnswer 
)
staticinherited

Definition at line 106 of file EventAnalysis.h.

108 {
109  // Check integrity of inputs.No tachyons.
110  if ( fMass1 < 0.0f ) return invalidAnswer;
111  if ( !pxP1 || !pxP2 ) return invalidAnswer;
112  // Set masses equal if required by user
113  fMass2 = ( fMass2 < 0.0f ) ? fMass1 : fMass2;
114  // Evaluate invariant mass.
115  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
116  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
117  CLHEP::HepLorentzVector xLVec1; xLVec1.setVectM( xTmp1, fMass1 );
118  CLHEP::HepLorentzVector xLVec2; xLVec2.setVectM( xTmp2, fMass2 );
119  return static_cast<float>( xLVec1.invariantMass( xLVec2 ) );
120 }

◆ EvalPhi()

template<class T >
float EventAnalysis::EvalPhi ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 220 of file EventAnalysis.h.

221 {
222  // Check integrity of inputs.
223  if ( !pxP1 || !pxP2 ) return invalidAnswer;
224  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
225  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
226  return static_cast<float>( (xTmp1 + xTmp2).phi() );
227 }

◆ EvalPhiDiff()

template<class T >
float EventAnalysis::EvalPhiDiff ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 190 of file EventAnalysis.h.

191 {
192  // Check integrity of inputs.
193  if ( !pxP1 || !pxP2 ) return invalidAnswer;
194  // Evaluate the angle.
195  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
196  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
197  return static_cast<float>( xTmp1.deltaPhi(xTmp2) );
198 }

◆ EvalPt()

template<class T >
float EventAnalysis::EvalPt ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 211 of file EventAnalysis.h.

212 {
213  // Check integrity of inputs.
214  if ( !pxP1 || !pxP2 ) return invalidAnswer;
215  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
216  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
217  return static_cast<float>( (xTmp1 + xTmp2).perp() );
218 }

◆ EvalPtDiff()

template<class T >
float EventAnalysis::EvalPtDiff ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 173 of file EventAnalysis.h.

174 {
175  // Check integrity of inputs.
176  if ( !pxP1 || !pxP2 ) return invalidAnswer;
177  // Evaluate the difference between the momenta. Signed using positive - negative if appropriate.
178  if ( pxP1->charge() > 0.5f )
179  {
180  return static_cast<float>( pxP1->pt() * EAna::CGeV - pxP2->pt() * EAna::CGeV );
181  }
182  else
183  {
184  return static_cast<float>( pxP2->pt() * EAna::CGeV - pxP1->pt() * EAna::CGeV );
185  }
186 }

◆ EvalTransverseMass() [1/4]

template<class T >
float EventAnalysis::EvalTransverseMass ( const T *  pxP1,
const T *  pxP2,
float  fMETx,
float  fMETy 
)
staticinherited

Definition at line 271 of file EventAnalysis.h.

272 {
273  // Check integrity of inputs.
274  if ( !pxP1 || !pxP2 ) return invalidAnswer;
275  // Evaluate Di-mu invariant mass.
276  return EvalTransverseMass( pxP1, pxP2, fMETx, fMETy, EAna::g_fMuonMass );
277 }

◆ EvalTransverseMass() [2/4]

template<class T >
float EventAnalysis::EvalTransverseMass ( const T *  pxP1,
const T *  pxP2,
float  fMETx,
float  fMETy,
float  fMass1,
float  fMass2 = invalidAnswer 
)
staticinherited

Definition at line 279 of file EventAnalysis.h.

281 {
282  // Check integrity of inputs.No tachyons.
283  if ( fMass1 < 0.0f ) return invalidAnswer;
284  if ( !pxP1 || !pxP2 ) return invalidAnswer;
285  // Set masses equal if required by user.
286  fMass2 = ( fMass2 < 0.0f ) ? fMass1 : fMass2;
287  // Evaluate invariant mass.
288  CLHEP::Hep3Vector xTmp1 = CLHEP::Hep3Vector( pxP1->p4().Px() * EAna::CGeV, pxP1->p4().Py() * EAna::CGeV, 0.0f );
289  CLHEP::Hep3Vector xTmp2 = CLHEP::Hep3Vector( pxP2->p4().Px() * EAna::CGeV, pxP2->p4().Py() * EAna::CGeV, 0.0f );
290  CLHEP::Hep3Vector xTmp12 = xTmp1 + xTmp2;
291  CLHEP::Hep3Vector xTmp3 = CLHEP::Hep3Vector( fMETx, fMETy, 0.0f );
292  CLHEP::HepLorentzVector xLVec1; xLVec1.setVectM( xTmp12, fMass1 );
293  CLHEP::HepLorentzVector xLVec2; xLVec2.setVectM( xTmp3, 0.0f );
294  return static_cast<float>( xLVec1.invariantMass( xLVec2 ) );
295 }

◆ EvalTransverseMass() [3/4]

template<class T >
float EventAnalysis::EvalTransverseMass ( const T *  pxP1,
float  fMETx,
float  fMETy 
)
staticinherited

Definition at line 246 of file EventAnalysis.h.

247 {
248  // Check integrity of inputs.
249  if ( !pxP1 ) return invalidAnswer;
250  // Evaluate Di-mu invariant mass.
251  return EvalInvMass( pxP1, fMETx, fMETy, EAna::g_fMuonMass );
252 }

◆ EvalTransverseMass() [4/4]

template<class T >
float EventAnalysis::EvalTransverseMass ( const T *  pxP1,
float  fMETx,
float  fMETy,
float  fMass1,
float  fMass2 = invalidAnswer 
)
staticinherited

Definition at line 254 of file EventAnalysis.h.

256 {
257  // Check integrity of inputs.No tachyons.
258  if ( fMass1 < 0.0f ) return invalidAnswer;
259  if ( !pxP1 ) return invalidAnswer;
260  // Set masses equal if required by user.
261  fMass2 = ( fMass2 < 0.0f ) ? fMass1 : fMass2;
262  // Evaluate invariant mass.
263  CLHEP::Hep3Vector xTmp1 = CLHEP::Hep3Vector( pxP1->p4().Px() * EAna::CGeV, pxP1->p4().Py() * EAna::CGeV, 0.0f );
264  CLHEP::Hep3Vector xTmp2 = CLHEP::Hep3Vector( fMETx, fMETy, 0.0f );
265  CLHEP::HepLorentzVector xLVec1; xLVec1.setVectM( xTmp1, fMass1 );
266  CLHEP::HepLorentzVector xLVec2; xLVec2.setVectM( xTmp2, 0.0f );
267  return static_cast<float>( xLVec1.invariantMass( xLVec2 ) );
268 }

◆ EvaluateAngle()

template<class T >
float EventAnalysis::EvaluateAngle ( const T *  pxP1,
const T *  pxP2 
)
staticinherited

Definition at line 163 of file EventAnalysis.h.

164 {
165  // Check integrity of inputs.
166  if ( !pxP1 || !pxP2 ) return invalidAnswer;
167  // Evaluate the angle.
168  CLHEP::Hep3Vector xTmp1 = calculateMomentum(pxP1);
169  CLHEP::Hep3Vector xTmp2 = calculateMomentum(pxP2);
170  return static_cast<float>( xTmp1.angle(xTmp2) );
171 }

◆ GetElecNegTrackParticle()

const xAOD::TrackParticle * ElectronSelector::GetElecNegTrackParticle ( size_t  i)

Definition at line 359 of file ElectronSelector.cxx.

360 {
361  if (i >= m_goodElecNegTrackParticleList.size()) { // requesting out of range electron
362  return nullptr;
363  }
365 }

◆ GetElecPosTrackParticle()

const xAOD::TrackParticle * ElectronSelector::GetElecPosTrackParticle ( size_t  i)

Definition at line 368 of file ElectronSelector.cxx.

369 {
370  if (i >= m_goodElecPosTrackParticleList.size()) { // requesting out of range electron
371  return nullptr;
372  }
374 }

◆ GetElectronCollectionSize()

unsigned int ElectronSelector::GetElectronCollectionSize ( )
inline

Definition at line 43 of file ElectronSelector.h.

◆ Init()

void ElectronSelector::Init ( )
virtual

Reimplemented from EventAnalysis.

Definition at line 55 of file ElectronSelector.cxx.

56 {
57  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::Init -- START -- " << endmsg;
58  ISvcLocator* serviceLocator = Gaudi::svcLocator();
59  IToolSvc* toolSvc;
60  StatusCode sc = serviceLocator->service("ToolSvc", toolSvc, true);
61 
62  if ( sc.isFailure() || toolSvc == nullptr ) {
63  (*m_msgStream) << MSG::ERROR << " * ElectronSelector::Init * Unable to retrieve ToolSvc " << endmsg;
64  return;
65  }
66 
67  // PARENT::Init();
68 
69  //---Electron Likelihood tool---
70  // m_doIDCuts = true;
71  (*m_msgStream) << MSG::INFO << "ElectronSelector::Init -- Setting up electron LH tool." << endmsg;
72  m_LHTool2015 = new AsgElectronLikelihoodTool ("m_LHTool2015");
73 
74  const std::string elecWorkingPoint = "LooseLHElectron"; // "MediumLHElectron" "TightLHElectron"
75 
76  if((m_LHTool2015->setProperty("WorkingPoint",elecWorkingPoint.c_str())).isFailure()) {
77  (*m_msgStream) << MSG::WARNING << "Failure loading ConfigFile for electron likelihood tool with working point: " << elecWorkingPoint.c_str() << endmsg;
78  }
79  else {
80  (*m_msgStream) << MSG::INFO << "Loading ConfigFile for electron likelihood tool with working point: " << elecWorkingPoint << ". SUCCESS " << endmsg;
81  }
82 
83  // check config files at: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/EGammaIdentificationRun2
84  std::string confDir = "ElectronPhotonSelectorTools/offline/mc20_20210514/ElectronLikelihoodVeryLooseOfflineConfig2017_Smooth.conf";
85  if ( (m_LHTool2015->setProperty("ConfigFile", confDir)).isSuccess()) {
86  (*m_msgStream) << MSG::INFO << "Electron likelihood config ("<< confDir.c_str() << ") setting SUCCESS!" << endmsg;
87  }
88  else {
89  (*m_msgStream) << MSG::WARNING << "Electron likelihood config ("<< confDir.c_str() << ") setting FAILURE" << endmsg;
90  }
91 
92  if (m_LHTool2015->initialize().isSuccess()) {
93  (*m_msgStream) << MSG::INFO << "Electron likelihood tool initialize() SUCCESS!" << endmsg;
94  }
95  else {
96  (*m_msgStream) << MSG::WARNING << "Electron likelihood tool initialize() FAILURE!" << endmsg;
97  }
98 
99  (*m_msgStream) << MSG::DEBUG << " --ElectronSelector::Init -- COMPLETED -- " << endmsg;
100  return;
101 }

◆ operator=()

ElectronSelector& ElectronSelector::operator= ( const ElectronSelector )
delete

◆ OrderElectronList()

bool ElectronSelector::OrderElectronList ( )
private

Definition at line 226 of file ElectronSelector.cxx.

227 {
228  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::OrderElectronList -- START -- list size: " << m_pxElTrackList.size( ) << endmsg;
229 
230  bool goodlist = true;
231 
232  if (m_pxElTrackList.size() >= 2) { // we need at least 2 electrons
233  double ptMinus1 = 0.;
234  double ptMinus2 = 0.;
235  double ptPlus1 = 0.;
236  double ptPlus2 = 0.;
237 
238  int elecnegcount = 0;
239  int elecposcount = 0;
240 
241  for (int ielec=0; ielec < (int) m_pxElTrackList.size(); ielec++) {
242  // negative electrons
243  if (m_pxElTrackList.at(ielec)->charge()== -1) { // positive electron
244  elecnegcount++;
245  if (m_pxElTrackList.at(ielec)->pt()> ptMinus1) {
246  // store 1st in 2nd
247  ptMinus2 = ptMinus1;
249  // now store the new one in 1st place
250  ptMinus1 = m_pxElTrackList.at(ielec)->pt();
251  m_elecneg1 = ielec;
252  }
253  else if (m_pxElTrackList.at(ielec)->pt()> ptMinus2) {
254  // store the new one in 2nd place
255  ptMinus2 = m_pxElTrackList.at(ielec)->pt();
256  m_elecneg2 = ielec;
257  }
258  }
259  // positive electrons
260  if (m_pxElTrackList.at(ielec)->charge()== 1) { // positive electron
261  elecposcount++;
262  if (m_pxElTrackList.at(ielec)->pt()> ptPlus1) {
263  // store 1st in 2nd
264  ptPlus2 = ptPlus1;
266  // now store the new one in 1st place
267  ptPlus1 = m_pxElTrackList.at(ielec)->pt();
268  m_elecpos1 = ielec;
269  }
270  else if (m_pxElTrackList.at(ielec)->pt()> ptPlus2) {
271  // store the new one in 2nd place
272  ptPlus2 = m_pxElTrackList.at(ielec)->pt();
273  m_elecpos2 = ielec;
274  }
275  }
276  }
277 
278  if (elecposcount == 0 || elecnegcount == 0) {
279  // We need at least one e- and one e+
280  if (m_doDebug) std::cout << " -- ElectronSelector::OrderElectronList -- No opposite charge electrons --> DISCARD ALL ELECTRONS -- " << std::endl;
281  elecposcount = 0;
282  elecnegcount = 0;
283  this->Clear();
284  goodlist = false;
285  }
286 
287  if (m_doDebug && elecposcount + elecnegcount >= 2 ){
288  std::cout << " -- ElectronSelector::OrderElectronList -- electron summary list taking " << elecposcount + elecnegcount
289  << " electrons from the input list of " << m_pxElTrackList.size() << " electrons: " << std::endl;
290  if (m_elecneg1 >= 0) std::cout << " leading e-: " << m_elecneg1 << " Pt = " << ptMinus1 << std::endl;
291  if (m_elecneg2 >= 0) std::cout << " second e-: " << m_elecneg2 << " Pt = " << ptMinus2 << std::endl;
292  if (m_elecpos1 >= 0) std::cout << " leading e+: " << m_elecpos1 << " Pt = " << ptPlus1 << std::endl;
293  if (m_elecpos2 >= 0) std::cout << " second e+: " << m_elecpos2 << " Pt = " << ptPlus2 << std::endl;
294  }
295 
296  if (elecposcount + elecnegcount >= 2){ // fill the final list of electrons
301  }
302  }
303 
304  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::OrderElectronList -- COMPLETED -- status: "<< goodlist << std::endl;
305  return goodlist;
306 }

◆ PrepareElectronList()

void ElectronSelector::PrepareElectronList ( const xAOD::ElectronContainer pxElecContainer)

Definition at line 104 of file ElectronSelector.cxx.

105 {
106  (*m_msgStream) << MSG::DEBUG << " --ElectronSelector::PrepareElectronList -- START -- " << endmsg;
107  Clear(); // clear current list records
108 
109  using electron_iterator = xAOD::ElectronContainer::const_iterator;
110  electron_iterator iter = pxElecContainer->begin();
111  electron_iterator iterEnd = pxElecContainer->end();
112 
113  // Loop over the Electrons
114  int electroncount = 0;
115  for(; iter != iterEnd ; ++iter) {
116  electroncount++;
117  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
118  << " has author " << (*iter)->author(xAOD::EgammaParameters::AuthorElectron)
119  << endmsg;
120  const xAOD::Electron * ELE = (*iter);
121  if ( RecordElectron(ELE) ) {
122  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
123  << " is good "
124  << endmsg;
125  }
126  }
127  bool progressingwell = true;
128 
129  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- finished recording electrons. "
130  << " recorded electrons: " << m_pxElTrackList.size()
131  << " out of tested electron candidates:" << electroncount << endmsg;
132  if (m_pxElTrackList.size() < 2) progressingwell = false;
133  if (progressingwell) progressingwell = OrderElectronList ();
134  if (progressingwell) progressingwell = RetrieveVertices ();
135 
136  if (!progressingwell) {
137  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- FAILED -- this event has not even a good e+e- pair " << endmsg;
138  this->Clear(); // reset the content as it is not going to be used
139  }
140 
141  (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- COMPLETED -- electroncount -- m_pxElTrackList.size() / all = "
142  << m_pxElTrackList.size() << " / " << electroncount
143  << endmsg;
144  return;
145 }

◆ RecordElectron()

bool ElectronSelector::RecordElectron ( const xAOD::Electron thisElec)

Definition at line 148 of file ElectronSelector.cxx.

149 {
150  // start assuming electron candidate is good
151  bool electronisgood = true;
152 
153  // check the electron satisfies the working point
154  if (!m_LHTool2015->accept(thisElec) ) {
155  electronisgood = false;
156  (*m_msgStream) << MSG::DEBUG << " -- electron fails workingpoint selection -- " << endmsg;
157  }
158 
159  //Get the track particle
160  const xAOD::TrackParticle* theTrackParticle = thisElec->trackParticle();
161 
162  if (!theTrackParticle) {
163  electronisgood = false;
164  (*m_msgStream) << MSG::DEBUG << " -- electron fails trackparticle -- " << endmsg;
165  }
166 
167  if (electronisgood && thisElec->author(xAOD::EgammaParameters::AuthorElectron) != 1) {
168  electronisgood = false;
169  (*m_msgStream) << MSG::DEBUG << " -- electron fails author -- " << thisElec->author(xAOD::EgammaParameters::AuthorElectron) << endmsg;
170  }
171 
172  if (electronisgood && theTrackParticle->pt() * m_CGeV < m_ptCut ) { // pt cut given in GeV
173  electronisgood = false;
174  (*m_msgStream) << MSG::DEBUG << " -- electron fails pt cut -- pt= " << theTrackParticle->pt()
175  << " < " << m_ptCut << " (cut value) "
176  << endmsg;
177  }
178 
179  const xAOD::CaloCluster* cluster = thisElec->caloCluster();
180  if(!cluster) {
181  electronisgood = false;
182  (*m_msgStream) << MSG::DEBUG << " -- electron candidate has no CaloCluster " << endmsg;
183  }
184 
185  if (electronisgood && (cluster->e() * sin(theTrackParticle->theta())) * m_CGeV < m_ptCut) { // cut on et of the cluster
186  electronisgood = false;
187  (*m_msgStream) << MSG::DEBUG << " -- electron fails cluster Et cut -- Et= " << (cluster->e() * cos(theTrackParticle->theta()))* m_CGeV
188  << " < " << m_ptCut << " (cut value) "
189  << endmsg;
190  }
191 
192  if (electronisgood && (std::abs(cluster->eta())> m_etaCut || std::abs(theTrackParticle->eta())> m_etaCut) ) { // cut in eta for the cluster and the track
193  electronisgood = false;
194  (*m_msgStream) << MSG::DEBUG << " -- electron fails eta cut -- cluster_eta= " << cluster->eta() << endmsg;
195  }
196 
197  if (electronisgood) {
198  // store this electron
199  m_pxElTrackList.push_back(theTrackParticle);
200 
201  (*m_msgStream) << MSG::DEBUG << " * RecordElectron * good electron found -> store this electron with pt " << theTrackParticle->pt()
202  << " --> current m_pxElTrackList.size(): " << m_pxElTrackList.size()
203  << std::endl;
204  }
205 
206  return electronisgood;
207 }

◆ Register()

void EventAnalysis::Register ( )
privateinherited

Definition at line 64 of file EventAnalysis.cxx.

65 {
66  ServiceHandle<ITHistSvc> histSvc ("THistSvc", "EventAnalysis");
67 
68  // Register histograms in monitoring tool
69  registerHistogramType(*histSvc, m_x1DHistograms, m_xSampleName, "/1dhisto_");
70  registerHistogramType(*histSvc, m_x2DHistograms, m_xSampleName, "/2dhisto_");
71 
72  registerHistogramType(*histSvc, m_x1DProfHistograms, m_xSampleName, "/1dprof_");
73  registerHistogramType(*histSvc, m_x2DProfHistograms, m_xSampleName, "/2dprof_");
74 }

◆ RetrieveVertices()

bool ElectronSelector::RetrieveVertices ( )
private

Definition at line 309 of file ElectronSelector.cxx.

310 {
311  if (m_doDebug) std::cout << " -- ElectronSelector::RetrieveVertices -- START -- list size: "
313  << std::endl;
314  bool goodvertices = false;
315  int nverticesfound = 1; // WARNING default must be 0 --> set to 1 for R22 --> needs to be fixed
316 
317  if (m_goodElecNegTrackParticleList.size() >= 1 && m_goodElecPosTrackParticleList.size() >= 1) { // we need at least 1 e- and 1 e+
318  // then, check the distances between the e- and e+ vertices, and make sure at least 1 pair comes from same vertex
319  for (size_t ielec = 0; ielec < m_goodElecNegTrackParticleList.size(); ielec++) {
320  // loop on e-
321  // R21 -> R22 SALVA // TrkParticles have no vertex in R22 --> THIS NEEDS A FIX
322  /*
323  if (m_goodElecNegTrackParticleList.at(ielec)->vertex()) {
324  if (m_doDebug) std::cout << " e-(" << ielec <<")->vertex()->v= (" << m_goodElecNegTrackParticleList.at(ielec)->vertex()->x()
325  << ", " << m_goodElecNegTrackParticleList.at(ielec)->vertex()->y()
326  << ", " << m_goodElecNegTrackParticleList.at(ielec)->vertex()->z()
327  << ") " << std::endl;
328 
329  // for (unsigned int iposi = 0; iposi < m_goodElecPosTrackParticleList.size(); iposi++) {
330  for (size_t iposi = 0; iposi < m_goodElecPosTrackParticleList.size(); iposi++) {
331  if (m_goodElecPosTrackParticleList.at(iposi)->vertex()) {
332  if (m_doDebug) std::cout << " e+(" << iposi <<")->vertex()->v= (" << m_goodElecPosTrackParticleList.at(iposi)->vertex()->x()
333  << ", " << m_goodElecPosTrackParticleList.at(iposi)->vertex()->y()
334  << ", " << m_goodElecPosTrackParticleList.at(iposi)->vertex()->z()
335  << ") " << std::endl;
336  float delta_x = std::abs( m_goodElecNegTrackParticleList.at(ielec)->vertex()->x()-m_goodElecPosTrackParticleList.at(iposi)->vertex()->x() );
337  float delta_y = std::abs( m_goodElecNegTrackParticleList.at(ielec)->vertex()->y()-m_goodElecPosTrackParticleList.at(iposi)->vertex()->y() );
338  float delta_z = std::abs( m_goodElecNegTrackParticleList.at(ielec)->vertex()->z()-m_goodElecPosTrackParticleList.at(iposi)->vertex()->z() );
339 
340  if (delta_x < m_deltaXYcut && delta_y < m_deltaXYcut && delta_z < m_deltaZcut) {
341  nverticesfound++;
342  if (m_doDebug) std::cout << " ELEC-BINGO !!! e+e- pair in same vertex !!! e-[" << ielec
343  << "] e+[" << iposi<< "] count: " << nverticesfound << std::endl;
344  } // vertex is the same
345  } // positron has vertex
346  } // loop on positrons
347  } // electron has vertex
348  */
349  } // loop on electrons (e-)
350  } // at least one e+e- pair
351 
352  if (nverticesfound >= 1) goodvertices = true;
353 
354  if (m_doDebug) std::cout << " -- ElectronSelector::RetrieveVertices -- COMPLETED -- status: " << goodvertices << std::endl;
355  return goodvertices;
356 }

◆ setDebug()

void ElectronSelector::setDebug ( bool  debug)
inline

Definition at line 39 of file ElectronSelector.h.

39 {m_doDebug = debug;}

◆ SetPtCut()

void ElectronSelector::SetPtCut ( float  newpt)
inline

Definition at line 48 of file ElectronSelector.h.

48 {m_ptCut = newpt;}

Member Data Documentation

◆ invalidAnswer

constexpr float EventAnalysis::invalidAnswer {-999.9f}
staticconstexprinherited

Definition at line 39 of file EventAnalysis.h.

◆ m_CGeV

const float ElectronSelector::m_CGeV = 1.0e-3
private

Definition at line 88 of file ElectronSelector.h.

◆ m_doDebug

bool ElectronSelector::m_doDebug
private

Definition at line 73 of file ElectronSelector.h.

◆ m_elecneg1

int ElectronSelector::m_elecneg1 = 0
private

Definition at line 82 of file ElectronSelector.h.

◆ m_elecneg2

int ElectronSelector::m_elecneg2 = 0
private

Definition at line 83 of file ElectronSelector.h.

◆ m_elecpos1

int ElectronSelector::m_elecpos1 = 0
private

Definition at line 84 of file ElectronSelector.h.

◆ m_elecpos2

int ElectronSelector::m_elecpos2 = 0
private

Definition at line 85 of file ElectronSelector.h.

◆ m_etaCut

float ElectronSelector::m_etaCut
private

Definition at line 76 of file ElectronSelector.h.

◆ m_goodElecNegTrackParticleList

std::vector<const xAOD::TrackParticle*> ElectronSelector::m_goodElecNegTrackParticleList
private

Definition at line 69 of file ElectronSelector.h.

◆ m_goodElecPosTrackParticleList

std::vector<const xAOD::TrackParticle*> ElectronSelector::m_goodElecPosTrackParticleList
private

Definition at line 70 of file ElectronSelector.h.

◆ m_LHTool2015

AsgElectronLikelihoodTool* ElectronSelector::m_LHTool2015 = nullptr
private

Definition at line 79 of file ElectronSelector.h.

◆ m_msgStream

MsgStream* ElectronSelector::m_msgStream
private

Definition at line 64 of file ElectronSelector.h.

◆ m_ptCut

float ElectronSelector::m_ptCut
private

Definition at line 75 of file ElectronSelector.h.

◆ m_pxElectron

const xAOD::Muon* ElectronSelector::m_pxElectron
private

Definition at line 67 of file ElectronSelector.h.

◆ m_pxElTrackList

std::vector<const xAOD::TrackParticle*> ElectronSelector::m_pxElTrackList
private

Definition at line 68 of file ElectronSelector.h.

◆ m_uPassedEvents

unsigned int EventAnalysis::m_uPassedEvents
protectedinherited

Definition at line 74 of file EventAnalysis.h.

◆ m_x1DHistograms

std::map<unsigned int, TH1F*> EventAnalysis::m_x1DHistograms
protectedinherited

Definition at line 75 of file EventAnalysis.h.

◆ m_x1DProfHistograms

std::map<unsigned int, TProfile*> EventAnalysis::m_x1DProfHistograms
protectedinherited

Definition at line 77 of file EventAnalysis.h.

◆ m_x2DHistograms

std::map<unsigned int, TH2F*> EventAnalysis::m_x2DHistograms
protectedinherited

Definition at line 76 of file EventAnalysis.h.

◆ m_x2DProfHistograms

std::map<unsigned int, TProfile2D*> EventAnalysis::m_x2DProfHistograms
protectedinherited

Definition at line 78 of file EventAnalysis.h.

◆ m_xSampleName

std::string EventAnalysis::m_xSampleName
protectedinherited

Definition at line 80 of file EventAnalysis.h.

◆ s_uNumInstances

std::atomic< unsigned int > ElectronSelector::s_uNumInstances
staticprivate

Definition at line 56 of file ElectronSelector.h.


The documentation for this class was generated from the following files:
EventAnalysis::EvalInvMass
static float EvalInvMass(const T *pxP1, const T *pxP2, float fMass1, float fMass2=invalidAnswer)
Definition: EventAnalysis.h:106
ElectronSelector::m_etaCut
float m_etaCut
Definition: ElectronSelector.h:76
ElectronSelector::m_pxElTrackList
std::vector< const xAOD::TrackParticle * > m_pxElTrackList
Definition: ElectronSelector.h:68
xAOD::TrackParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TrackParticle_v1.cxx:73
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
PerfMonServices::getMessagingService
static IMessageSvc * getMessagingService()
Definition: PerfMonServices.h:36
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ElectronSelector::m_goodElecPosTrackParticleList
std::vector< const xAOD::TrackParticle * > m_goodElecPosTrackParticleList
Definition: ElectronSelector.h:70
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
DataVector::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition: DataVector.h:837
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:35
ElectronSelector::m_doDebug
bool m_doDebug
Definition: ElectronSelector.h:73
xAOD::TrackParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TrackParticle_v1.cxx:77
ElectronSelector::s_uNumInstances
static std::atomic< unsigned int > s_uNumInstances
Definition: ElectronSelector.h:56
xAOD::Egamma_v1::author
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
Definition: Egamma_v1.cxx:166
AsgElectronLikelihoodTool::accept
virtual asg::AcceptData accept(const xAOD::IParticle *part) const override final
The main accept method: using the generic interface.
Definition: AsgElectronLikelihoodTool.cxx:868
xAOD::Electron_v1::trackParticle
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
Definition: Electron_v1.cxx:55
ElectronSelector::OrderElectronList
bool OrderElectronList()
Definition: ElectronSelector.cxx:226
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
AsgElectronLikelihoodTool
Electron selector tool to select objects in Athena using an underlying pure ROOT tool.
Definition: AsgElectronLikelihoodTool.h:30
EventAnalysis::m_x1DHistograms
std::map< unsigned int, TH1F * > m_x1DHistograms
Definition: EventAnalysis.h:75
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ElectronSelector::m_elecpos2
int m_elecpos2
Definition: ElectronSelector.h:85
ElectronSelector::m_msgStream
MsgStream * m_msgStream
Definition: ElectronSelector.h:64
ElectronSelector::m_goodElecNegTrackParticleList
std::vector< const xAOD::TrackParticle * > m_goodElecNegTrackParticleList
Definition: ElectronSelector.h:69
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
EventAnalysis::m_x2DHistograms
std::map< unsigned int, TH2F * > m_x2DHistograms
Definition: EventAnalysis.h:76
EventAnalysis::EvalTransverseMass
static float EvalTransverseMass(const T *pxP1, float fMETx, float fMETy, float fMass1, float fMass2=invalidAnswer)
Definition: EventAnalysis.h:254
EventAnalysis::calculateMomentum
static CLHEP::Hep3Vector calculateMomentum(const T *pP)
Definition: EventAnalysis.h:91
xAOD::CaloCluster_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: CaloCluster_v1.cxx:251
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ElectronSelector::RecordElectron
bool RecordElectron(const xAOD::Electron *)
Definition: ElectronSelector.cxx:148
ElectronSelector::m_pxElectron
const xAOD::Muon * m_pxElectron
Definition: ElectronSelector.h:67
xAOD::Egamma_v1::caloCluster
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
Definition: Egamma_v1.cxx:388
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
EventAnalysis::m_x1DProfHistograms
std::map< unsigned int, TProfile * > m_x1DProfHistograms
Definition: EventAnalysis.h:77
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
ElectronSelector::m_LHTool2015
AsgElectronLikelihoodTool * m_LHTool2015
Definition: ElectronSelector.h:79
xAOD::Electron_v1
Definition: Electron_v1.h:34
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
ElectronSelector::m_CGeV
const float m_CGeV
Definition: ElectronSelector.h:88
EventAnalysis::m_x2DProfHistograms
std::map< unsigned int, TProfile2D * > m_x2DProfHistograms
Definition: EventAnalysis.h:78
ElectronSelector::RetrieveVertices
bool RetrieveVertices()
Definition: ElectronSelector.cxx:309
EAna::g_fMuonMass
const float g_fMuonMass
Definition: EventAnalysis.h:26
DEBUG
#define DEBUG
Definition: page_access.h:11
ElectronSelector::Clear
void Clear()
Definition: ElectronSelector.cxx:210
ElectronSelector::m_elecneg1
int m_elecneg1
Definition: ElectronSelector.h:82
AsgElectronLikelihoodTool::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations.
Definition: AsgElectronLikelihoodTool.cxx:80
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
ElectronSelector::m_ptCut
float m_ptCut
Definition: ElectronSelector.h:75
EventAnalysis::m_xSampleName
std::string m_xSampleName
Definition: EventAnalysis.h:80
ElectronSelector::m_elecpos1
int m_elecpos1
Definition: ElectronSelector.h:84
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
EAna::CGeV
const float CGeV
Definition: EventAnalysis.h:28
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
EventAnalysis::invalidAnswer
static constexpr float invalidAnswer
Definition: EventAnalysis.h:39
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::EgammaParameters::AuthorElectron
const uint16_t AuthorElectron
Object Reconstructed by standard cluster-based algorithm.
Definition: EgammaDefs.h:24
ServiceHandle< ITHistSvc >
ElectronSelector::m_elecneg2
int m_elecneg2
Definition: ElectronSelector.h:83