22#include "CLHEP/Random/RandFlat.h"
56 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::Init -- START -- " <<
endmsg;
62 (*m_msgStream) << MSG::INFO <<
"ElectronSelector::Init -- Setting up electron LH tool." <<
endmsg;
65 const std::string elecWorkingPoint =
"LooseLHElectron";
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;
71 (*m_msgStream) << MSG::INFO <<
"Loading ConfigFile for electron likelihood tool with working point: " << elecWorkingPoint <<
". SUCCESS " <<
endmsg;
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;
80 (*m_msgStream) << MSG::WARNING <<
"Electron likelihood config ("<< confDir.c_str() <<
") setting FAILURE" <<
endmsg;
84 (*m_msgStream) << MSG::INFO <<
"Electron likelihood tool initialize() SUCCESS!" <<
endmsg;
87 (*m_msgStream) << MSG::WARNING <<
"Electron likelihood tool initialize() FAILURE!" <<
endmsg;
90 (*m_msgStream) << MSG::DEBUG <<
" --ElectronSelector::Init -- COMPLETED -- " <<
endmsg;
97 (*m_msgStream) << MSG::DEBUG <<
" --ElectronSelector::PrepareElectronList -- START -- " <<
endmsg;
101 electron_iterator iter = pxElecContainer->
begin();
102 electron_iterator iterEnd = pxElecContainer->
end();
105 int electroncount = 0;
106 for(; iter != iterEnd ; ++iter) {
108 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
113 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::PrepareElectronList -- candiate electron " << electroncount
118 bool progressingwell =
true;
120 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::PrepareElectronList -- finished recording electrons. "
122 <<
" out of tested electron candidates:" << electroncount <<
endmsg;
127 if (!progressingwell) {
128 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::PrepareElectronList -- FAILED -- this event has not even a good e+e- pair " <<
endmsg;
132 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::PrepareElectronList -- COMPLETED -- electroncount -- m_pxElTrackList.size() / all = "
142 bool electronisgood =
true;
146 electronisgood =
false;
147 (*m_msgStream) << MSG::DEBUG <<
" -- electron fails workingpoint selection -- " <<
endmsg;
153 if (!theTrackParticle) {
154 electronisgood =
false;
155 (*m_msgStream) << MSG::DEBUG <<
" -- electron fails trackparticle -- " <<
endmsg;
159 electronisgood =
false;
164 electronisgood =
false;
165 (*m_msgStream) << MSG::DEBUG <<
" -- electron fails pt cut -- pt= " << theTrackParticle->
pt()
166 <<
" < " <<
m_ptCut <<
" (cut value) "
172 electronisgood =
false;
173 (*m_msgStream) << MSG::DEBUG <<
" -- electron candidate has no CaloCluster " <<
endmsg;
176 if (electronisgood && (cluster->
e() * sin(theTrackParticle->
theta())) *
m_CGeV <
m_ptCut) {
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) "
183 if (electronisgood && (std::abs(cluster->
eta())>
m_etaCut || std::abs(theTrackParticle->
eta())>
m_etaCut) ) {
184 electronisgood =
false;
185 (*m_msgStream) << MSG::DEBUG <<
" -- electron fails eta cut -- cluster_eta= " << cluster->
eta() <<
endmsg;
188 if (electronisgood) {
192 (*m_msgStream) << MSG::DEBUG <<
" * RecordElectron * good electron found -> store this electron with pt " << theTrackParticle->
pt()
197 return electronisgood;
219 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::OrderElectronList -- START -- list size: " <<
m_pxElTrackList.size( ) <<
endmsg;
223 struct LeadingElectrons {
225 double subleadingPt{};
226 int leadingIndex{-1};
227 int subleadingIndex{-1};
231 LeadingElectrons negative;
232 LeadingElectrons positive;
233 const auto updateLeading = [](LeadingElectrons& electrons,
double pt,
int index) {
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;
248 if (electron->charge() < 0.) {
249 updateLeading(negative, electron->pt(),
static_cast<int>(
index));
250 }
else if (electron->charge() > 0.) {
251 updateLeading(positive, electron->pt(),
static_cast<int>(
index));
255 if (negative.count == 0 || positive.count == 0) {
257 std::cout <<
" -- ElectronSelector::OrderElectronList -- "
258 "No opposite-charge electrons --> DISCARD ALL ELECTRONS --\n";
269 std::cout <<
" -- ElectronSelector::OrderElectronList -- electron summary list taking "
270 << negative.count + positive.count <<
" electrons from the input list of "
275 <<
" Pt = " << negative.leadingPt <<
'\n';
280 <<
" Pt = " << negative.subleadingPt <<
'\n';
285 <<
" Pt = " << positive.leadingPt <<
'\n';
290 <<
" Pt = " << positive.subleadingPt <<
'\n';
293 const auto addElectron = [
this](
auto& output,
int index) {
303 (*m_msgStream) << MSG::DEBUG <<
" -- ElectronSelector::OrderElectronList -- COMPLETED -- status: true\n";
310 if (
m_doDebug) std::cout <<
" -- ElectronSelector::RetrieveVertices -- START -- list size: "
313 bool goodvertices =
false;
314 const int nverticesfound = 1;
315 if (nverticesfound >= 1) goodvertices =
true;
316 if (
m_doDebug) std::cout <<
" -- ElectronSelector::RetrieveVertices -- COMPLETED -- status: " << goodvertices << std::endl;
DataModel_detail::const_iterator< DataVector > const_iterator
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.
AsgElectronLikelihoodTool * m_LHTool2015
const xAOD::TrackParticle * GetElecPosTrackParticle(size_t i)
std::vector< const xAOD::TrackParticle * > m_pxElTrackList
const xAOD::Muon * m_pxElectron
static std::atomic< unsigned int > s_uNumInstances
bool RecordElectron(const xAOD::Electron *)
const xAOD::TrackParticle * GetElecNegTrackParticle(size_t i)
std::vector< const xAOD::TrackParticle * > m_goodElecPosTrackParticleList
std::vector< const xAOD::TrackParticle * > m_goodElecNegTrackParticleList
void PrepareElectronList(const xAOD::ElectronContainer *pxElecContainer)
std::string m_xSampleName
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.
singleton-like access to IMessageSvc via open function and helper
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
IMessageSvc * getMessageSvc(bool quiet=false)
const uint16_t AuthorElectron
Object Reconstructed by standard cluster-based algorithm.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Electron_v1 Electron
Definition of the current "egamma version".