ATLAS Offline Software
Loading...
Searching...
No Matches
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 31 of file ElectronSelector.cxx.

31 :
32 m_doDebug ( false ),
33 m_ptCut ( 10. ),
34 m_etaCut ( 2.47 ) // 2.47 is the official acceptance for central electrons. Forward electrons is another story...
35{
37
38 std::stringstream xTmp; xTmp << s_uNumInstances;
39 m_xSampleName = "ElectronSelector_" + xTmp.str();
40
41 m_pxElectron = nullptr;
42
43 m_msgStream = new MsgStream(Athena::getMessageSvc(), "InDetPerformanceMonitoring" );
44}
MsgStream * m_msgStream
const xAOD::Muon * m_pxElectron
static std::atomic< unsigned int > s_uNumInstances
std::string m_xSampleName
IMessageSvc * getMessageSvc(bool quiet=false)

◆ ~ElectronSelector()

ElectronSelector::~ElectronSelector ( )

Definition at line 47 of file ElectronSelector.cxx.

48{
50 delete m_msgStream;
51}

◆ ElectronSelector() [2/2]

ElectronSelector::ElectronSelector ( const ElectronSelector & )
delete

Member Function Documentation

◆ BookHistograms()

void EventAnalysis::BookHistograms ( )
protectedvirtualinherited

Reimplemented in FourMuonEvent, MuonSelector, and ZmumuEvent.

Definition at line 55 of file EventAnalysis.cxx.

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

◆ calculateMomentum()

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

Definition at line 92 of file EventAnalysis.h.

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

◆ Clear()

void ElectronSelector::Clear ( )
private

Definition at line 201 of file ElectronSelector.cxx.

202{
203 m_pxElTrackList.clear();
206
207 // -1 means not assigned
208 m_elecneg1 = -1;
209 m_elecneg2 = -1;
210 m_elecpos1 = -1;
211 m_elecpos2 = -1;
212
213 return;
214}
std::vector< const xAOD::TrackParticle * > m_pxElTrackList
std::vector< const xAOD::TrackParticle * > m_goodElecPosTrackParticleList
std::vector< const xAOD::TrackParticle * > m_goodElecNegTrackParticleList

◆ EvalCharge()

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

Definition at line 239 of file EventAnalysis.h.

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

◆ EvalDiMuInvMass()

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

Definition at line 98 of file EventAnalysis.h.

99{
100 // Check integrity of inputs.
101 if ( !pxP1 || !pxP2 ) return invalidAnswer;
102
103 // Evaluate Di-mu invariant mass.
104 return EvalInvMass( pxP1, pxP2, EAna::g_fMuonMass );
105}
static float EvalInvMass(const T *pxP1, const T *pxP2, float fMass1, float fMass2=invalidAnswer)
const float g_fMuonMass

◆ EvalEta()

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

Definition at line 230 of file EventAnalysis.h.

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

◆ EvalEtaDiff()

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

Definition at line 202 of file EventAnalysis.h.

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

◆ EvalFourMuInvMass()

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

Definition at line 124 of file EventAnalysis.h.

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

◆ 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 133 of file EventAnalysis.h.

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

◆ EvalInvMass() [2/2]

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

Definition at line 107 of file EventAnalysis.h.

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

◆ EvalPhi()

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

Definition at line 221 of file EventAnalysis.h.

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

◆ EvalPhiDiff()

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

Definition at line 191 of file EventAnalysis.h.

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

◆ EvalPt()

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

Definition at line 212 of file EventAnalysis.h.

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

◆ EvalPtDiff()

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

Definition at line 174 of file EventAnalysis.h.

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

◆ EvalTransverseMass() [1/4]

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

Definition at line 272 of file EventAnalysis.h.

273{
274 // Check integrity of inputs.
275 if ( !pxP1 || !pxP2 ) return invalidAnswer;
276 // Evaluate Di-mu invariant mass.
277 return EvalTransverseMass( pxP1, pxP2, fMETx, fMETy, EAna::g_fMuonMass );
278}
static float EvalTransverseMass(const T *pxP1, float fMETx, float fMETy, float fMass1, float fMass2=invalidAnswer)

◆ 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 280 of file EventAnalysis.h.

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

◆ EvalTransverseMass() [3/4]

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

Definition at line 247 of file EventAnalysis.h.

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

◆ 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 255 of file EventAnalysis.h.

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

◆ EvaluateAngle()

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

Definition at line 164 of file EventAnalysis.h.

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

◆ GetElecNegTrackParticle()

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

Definition at line 321 of file ElectronSelector.cxx.

322{
323 if (i >= m_goodElecNegTrackParticleList.size()) { // requesting out of range electron
324 return nullptr;
325 }
327}

◆ GetElecPosTrackParticle()

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

Definition at line 330 of file ElectronSelector.cxx.

331{
332 if (i >= m_goodElecPosTrackParticleList.size()) { // requesting out of range electron
333 return nullptr;
334 }
336}

◆ 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 54 of file ElectronSelector.cxx.

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

◆ operator=()

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

◆ OrderElectronList()

bool ElectronSelector::OrderElectronList ( )
private

Definition at line 217 of file ElectronSelector.cxx.

218{
219 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::OrderElectronList -- START -- list size: " << m_pxElTrackList.size( ) << endmsg;
220 if (m_pxElTrackList.size() < 2) {
221 return false;
222 }
223 struct LeadingElectrons {
224 double leadingPt{};
225 double subleadingPt{};
226 int leadingIndex{-1};
227 int subleadingIndex{-1};
228 std::size_t count{};
229 };
230 //
231 LeadingElectrons negative;
232 LeadingElectrons positive;
233 const auto updateLeading = [](LeadingElectrons& electrons, double pt, int index) {
234 ++electrons.count;
235 if (pt > electrons.leadingPt) {
236 electrons.subleadingPt = electrons.leadingPt;
237 electrons.subleadingIndex = electrons.leadingIndex;
238 electrons.leadingPt = pt;
239 electrons.leadingIndex = index;
240 } else if (pt > electrons.subleadingPt) {
241 electrons.subleadingPt = pt;
242 electrons.subleadingIndex = index;
243 }
244 };
245
246 for (std::size_t index = 0; index < m_pxElTrackList.size(); ++index){
248 if (electron->charge() < 0.) { // negative electrons
249 updateLeading(negative, electron->pt(), static_cast<int>(index));
250 } else if (electron->charge() > 0.) { // positive electrons
251 updateLeading(positive, electron->pt(), static_cast<int>(index));
252 }
253 }
254
255 if (negative.count == 0 || positive.count == 0) {
256 if (m_doDebug) {
257 std::cout << " -- ElectronSelector::OrderElectronList -- "
258 "No opposite-charge electrons --> DISCARD ALL ELECTRONS --\n";
259 }
260 Clear();
261 return false;
262 }
263 m_elecneg1 = negative.leadingIndex;
264 m_elecneg2 = negative.subleadingIndex;
265 m_elecpos1 = positive.leadingIndex;
266 m_elecpos2 = positive.subleadingIndex;
267 //
268 if (m_doDebug) {
269 std::cout << " -- ElectronSelector::OrderElectronList -- electron summary list taking "
270 << negative.count + positive.count << " electrons from the input list of "
271 << m_pxElTrackList.size() << " electrons:\n";
272 //
273 if (m_elecneg1 >= 0) {
274 std::cout << " leading e-: " << m_elecneg1
275 << " Pt = " << negative.leadingPt << '\n';
276 }
277 //
278 if (m_elecneg2 >= 0) {
279 std::cout << " second e-: "<< m_elecneg2
280 << " Pt = " << negative.subleadingPt << '\n';
281 }
282 //
283 if (m_elecpos1 >= 0) {
284 std::cout << " leading e+: " << m_elecpos1
285 << " Pt = " << positive.leadingPt << '\n';
286 }
287 //
288 if (m_elecpos2 >= 0) {
289 std::cout << " second e+: " << m_elecpos2
290 << " Pt = " << positive.subleadingPt << '\n';
291 }
292 }
293 const auto addElectron = [this](auto& output, int index) {
294 if (index >= 0) {
295 output.push_back(m_pxElTrackList[static_cast<std::size_t>(index)]);
296 }
297 };
302 //
303 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::OrderElectronList -- COMPLETED -- status: true\n";
304 return true;
305}
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
str index
Definition DeMoScan.py:362
output
Definition merge.py:16
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ PrepareElectronList()

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

Definition at line 95 of file ElectronSelector.cxx.

96{
97 (*m_msgStream) << MSG::DEBUG << " --ElectronSelector::PrepareElectronList -- START -- " << endmsg;
98 Clear(); // clear current list records
99
100 using electron_iterator = xAOD::ElectronContainer::const_iterator;
101 electron_iterator iter = pxElecContainer->begin();
102 electron_iterator iterEnd = pxElecContainer->end();
103
104 // Loop over the Electrons
105 int electroncount = 0;
106 for(; iter != iterEnd ; ++iter) {
107 electroncount++;
108 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
109 << " has author " << (*iter)->author(xAOD::EgammaParameters::AuthorElectron)
110 << endmsg;
111 const xAOD::Electron * ELE = (*iter);
112 if ( RecordElectron(ELE) ) {
113 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
114 << " is good "
115 << endmsg;
116 }
117 }
118 bool progressingwell = true;
119
120 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- finished recording electrons. "
121 << " recorded electrons: " << m_pxElTrackList.size()
122 << " out of tested electron candidates:" << electroncount << endmsg;
123 if (m_pxElTrackList.size() < 2) progressingwell = false;
124 if (progressingwell) progressingwell = OrderElectronList ();
125 if (progressingwell) progressingwell = RetrieveVertices ();
126
127 if (!progressingwell) {
128 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- FAILED -- this event has not even a good e+e- pair " << endmsg;
129 this->Clear(); // reset the content as it is not going to be used
130 }
131
132 (*m_msgStream) << MSG::DEBUG << " -- ElectronSelector::PrepareElectronList -- COMPLETED -- electroncount -- m_pxElTrackList.size() / all = "
133 << m_pxElTrackList.size() << " / " << electroncount
134 << endmsg;
135 return;
136}
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool RecordElectron(const xAOD::Electron *)
const uint16_t AuthorElectron
Object Reconstructed by standard cluster-based algorithm.
Definition EgammaDefs.h:24
Electron_v1 Electron
Definition of the current "egamma version".

◆ RecordElectron()

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

Definition at line 139 of file ElectronSelector.cxx.

140{
141 // start assuming electron candidate is good
142 bool electronisgood = true;
143
144 // check the electron satisfies the working point
145 if (!m_LHTool2015->accept(thisElec) ) {
146 electronisgood = false;
147 (*m_msgStream) << MSG::DEBUG << " -- electron fails workingpoint selection -- " << endmsg;
148 }
149
150 //Get the track particle
151 const xAOD::TrackParticle* theTrackParticle = thisElec->trackParticle();
152
153 if (!theTrackParticle) {
154 electronisgood = false;
155 (*m_msgStream) << MSG::DEBUG << " -- electron fails trackparticle -- " << endmsg;
156 }
157
158 if (electronisgood && thisElec->author(xAOD::EgammaParameters::AuthorElectron) != 1) {
159 electronisgood = false;
160 (*m_msgStream) << MSG::DEBUG << " -- electron fails author -- " << thisElec->author(xAOD::EgammaParameters::AuthorElectron) << endmsg;
161 }
162
163 if (electronisgood && theTrackParticle->pt() * m_CGeV < m_ptCut ) { // pt cut given in GeV
164 electronisgood = false;
165 (*m_msgStream) << MSG::DEBUG << " -- electron fails pt cut -- pt= " << theTrackParticle->pt()
166 << " < " << m_ptCut << " (cut value) "
167 << endmsg;
168 }
169
170 const xAOD::CaloCluster* cluster = thisElec->caloCluster();
171 if(!cluster) {
172 electronisgood = false;
173 (*m_msgStream) << MSG::DEBUG << " -- electron candidate has no CaloCluster " << endmsg;
174 }
175
176 if (electronisgood && (cluster->e() * sin(theTrackParticle->theta())) * m_CGeV < m_ptCut) { // cut on et of the cluster
177 electronisgood = false;
178 (*m_msgStream) << MSG::DEBUG << " -- electron fails cluster Et cut -- Et= " << (cluster->e() * cos(theTrackParticle->theta()))* m_CGeV
179 << " < " << m_ptCut << " (cut value) "
180 << endmsg;
181 }
182
183 if (electronisgood && (std::abs(cluster->eta())> m_etaCut || std::abs(theTrackParticle->eta())> m_etaCut) ) { // cut in eta for the cluster and the track
184 electronisgood = false;
185 (*m_msgStream) << MSG::DEBUG << " -- electron fails eta cut -- cluster_eta= " << cluster->eta() << endmsg;
186 }
187
188 if (electronisgood) {
189 // store this electron
190 m_pxElTrackList.push_back(theTrackParticle);
191
192 (*m_msgStream) << MSG::DEBUG << " * RecordElectron * good electron found -> store this electron with pt " << theTrackParticle->pt()
193 << " --> current m_pxElTrackList.size(): " << m_pxElTrackList.size()
194 << std::endl;
195 }
196
197 return electronisgood;
198}
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
float theta() const
Returns the parameter, which has range 0 to .
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ Register()

void EventAnalysis::Register ( )
privateinherited

Definition at line 63 of file EventAnalysis.cxx.

64{
65 ServiceHandle<ITHistSvc> histSvc ("THistSvc", "EventAnalysis");
66
67 // Register histograms in monitoring tool
68 registerHistogramType(*histSvc, m_x1DHistograms, m_xSampleName, "/1dhisto_");
69 registerHistogramType(*histSvc, m_x2DHistograms, m_xSampleName, "/2dhisto_");
70
71 registerHistogramType(*histSvc, m_x1DProfHistograms, m_xSampleName, "/1dprof_");
72 registerHistogramType(*histSvc, m_x2DProfHistograms, m_xSampleName, "/2dprof_");
73}
std::map< unsigned int, TProfile2D * > m_x2DProfHistograms
std::map< unsigned int, TH2F * > m_x2DHistograms
std::map< unsigned int, TH1F * > m_x1DHistograms
std::map< unsigned int, TProfile * > m_x1DProfHistograms

◆ RetrieveVertices()

bool ElectronSelector::RetrieveVertices ( )
private

Definition at line 308 of file ElectronSelector.cxx.

309{
310 if (m_doDebug) std::cout << " -- ElectronSelector::RetrieveVertices -- START -- list size: "
312 << "\n";
313 bool goodvertices = false;
314 const int nverticesfound = 1; // WARNING default must be 0 --> set to 1 for R22 --> needs to be fixed
315 if (nverticesfound >= 1) goodvertices = true;
316 if (m_doDebug) std::cout << " -- ElectronSelector::RetrieveVertices -- COMPLETED -- status: " << goodvertices << std::endl;
317 return goodvertices;
318}

◆ setDebug()

void ElectronSelector::setDebug ( bool debug)
inline

Definition at line 39 of file ElectronSelector.h.

const bool debug

◆ SetPtCut()

void ElectronSelector::SetPtCut ( float newpt)
inline

Definition at line 48 of file ElectronSelector.h.

48{m_ptCut = newpt;}

Member Data Documentation

◆ invalidAnswer

float EventAnalysis::invalidAnswer {-999.9f}
staticconstexprinherited

Definition at line 40 of file EventAnalysis.h.

40{-999.9f};

◆ 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.

73{};

◆ 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.

76{};

◆ 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.

75{};

◆ m_pxElectron

const xAOD::Muon* ElectronSelector::m_pxElectron {}
private

Definition at line 67 of file ElectronSelector.h.

67{};

◆ 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 75 of file EventAnalysis.h.

◆ m_x1DHistograms

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

Definition at line 76 of file EventAnalysis.h.

◆ m_x1DProfHistograms

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

Definition at line 78 of file EventAnalysis.h.

◆ m_x2DHistograms

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

Definition at line 77 of file EventAnalysis.h.

◆ m_x2DProfHistograms

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

Definition at line 79 of file EventAnalysis.h.

◆ m_xSampleName

std::string EventAnalysis::m_xSampleName
protectedinherited

Definition at line 81 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: