22 #ifndef SELECTORBASE_H
23 #define SELECTORBASE_H
27 #include "GaudiKernel/MsgStream.h"
28 #include "GaudiKernel/AlgTool.h"
29 #include "GaudiKernel/ToolHandle.h"
31 #include "CLHEP/Units/SystemOfUnits.h"
35 template<
class Derived>
77 template<
class Derived>
83 declareProperty(
"InputKey", m_inputKey =
"NONE");
84 declareProperty(
"InSelectedParticlesKey", m_inselectedKey =
"NONE");
85 declareProperty(
"OutSelectedParticlesKey", m_selectedKey =
"NONE");
86 declareProperty(
"InParticleLinksKey", m_inlinksKey =
"NONE");
87 declareProperty(
"OutParticleLinksKey", m_linksKey =
"NONE");
88 declareProperty(
"PtMin",m_ptmin = 15.0*
CLHEP::GeV);
89 declareProperty(
"PtMax",m_ptmax = 10000.0*
CLHEP::GeV);
90 declareProperty(
"EtaMax",m_etamax = 2.5);
91 declareProperty(
"EtaMin",m_etamin = -2.5);
92 declareProperty(
"AbsEtaMax",m_absetamax = 2.5);
93 declareProperty(
"AbsEtaMin",m_absetamin =0);
94 declareProperty(
"SelectAll",m_all =
false);
99 template<
class Derived>
105 if(m_inputKey==std::string(
"NONE")) m_nogood=
true;
106 if(m_selectedKey==std::string(
"NONE")) m_gensel=
false;
107 if(m_inselectedKey!=std::string(
"NONE")) m_inSel=
true;
108 if(m_linksKey==std::string(
"NONE") ) m_genlink=
false;
109 if(m_inlinksKey!=std::string(
"NONE")) m_inLink=
true;
111 ATH_MSG_INFO(
"InputKey="<<m_inputKey.c_str()<<
", OutSelectedParticlesKey="<<m_selectedKey.c_str()
112 <<
", InSelectedParticlesKey="<<m_inselectedKey.c_str()
113 <<
", InParticlesLinksKey="<<m_inlinksKey.c_str()
114 <<
", OutParticleLinksKey="<<m_linksKey.c_str() );
116 << MSG::INFO<<
", PtMax="<<m_ptmax
117 << MSG::INFO<<
", EtaMin="<<m_etamin
118 << MSG::INFO<<
", EtaMax="<<m_etamax
119 << MSG::INFO<<
", AbsEtaMin="<<m_absetamin
120 << MSG::INFO<<
", AbsEtaMax="<<m_absetamax
121 << MSG::INFO<<
", SelectAll="<<m_all );
124 m_nogood=m_nogood && (!m_genlink && !m_gensel);
126 ATH_MSG_FATAL(
"Must supply names for InputKey, OutSelectedParticlesKey and/or OutParticleLinksKey" );
128 m_nogood=m_inSel && m_inLink;
130 ATH_MSG_FATAL(
"Cannot have both InSelectedParticlesKey and InParticlesLinksKey, must chose one" );
134 return StatusCode::SUCCESS;
137 template<
class Derived>
140 typedef typename Derived::Container
Container;
142 typedef typename Derived::Links Links;
149 const Links* inlinks=0;
159 ATH_MSG_DEBUG(
" >>>> got Container, no. of particles="<<npart );
166 ATH_CHECK(evtStore()->record(selparts,m_selectedKey) );
167 typename Container::const_iterator ipItr =
particles->begin();
168 typename Container::const_iterator ipEnd =
particles->end();
173 if(m_inSel)
ATH_MSG_DEBUG(
" using InSelectedParticles("<<m_inselectedKey
174 <<
"), no. particles="<<inselparts->
numGood()
177 for(; ipItr != ipEnd; ++ipItr) {
178 if(m_inSel && !inselparts->
isGood(ipart)){
183 if( m_all ||
static_cast<Derived*
>(
this)->
accept(*ipItr)){
191 typename Links::const_iterator ilItr = inlinks->begin();
192 typename Links::const_iterator ilEnd = inlinks->end();
193 ATH_MSG_DEBUG(
" using input ParticleLinks ("<<m_inlinksKey<<
"), no. of particles="
194 <<inlinks->size()<<
" <<<<<" );
196 for(; ilItr != ilEnd; ++ilItr) {
197 ipart=(*ilItr).index();
200 if( m_all ||
static_cast<Derived*
>(
this)->
accept(*ilItr) ){
212 Links*
links=
new Links();
217 typename Container::const_iterator ipItr =
particles->begin();
218 typename Container::const_iterator ipEnd =
particles->end();
220 for(; ipItr != ipEnd; ++ipItr) {
221 if(selparts->
isGood(ipart)){
227 return StatusCode::SUCCESS;
230 typename Links::const_iterator ilItr = inlinks->begin();
231 typename Links::const_iterator ilEnd = inlinks->end();
232 ATH_MSG_DEBUG(
" using input ParticleLinks ("<<m_inlinksKey<<
"), no. of particles="
233 <<inlinks->size()<<
" <<<<<" );
235 for(; ilItr != ilEnd; ++ilItr) {
236 ipart=(*ilItr).index();
239 if( m_all ||
static_cast<Derived*
>(
this)->
accept(*ilItr) ){
240 links->push_back(*ilItr);
245 if(m_inSel)
ATH_MSG_DEBUG(
" using InSelectedParticles("<<m_inselectedKey
246 <<
"), no. particles="<<inselparts->
numGood()
249 typename Container::const_iterator ipItr =
particles->begin();
250 typename Container::const_iterator ipEnd =
particles->end();
252 for(; ipItr != ipEnd; ++ipItr) {
253 if(m_inSel && !inselparts->
isGood(ipart)){
258 if( m_all ||
static_cast<Derived*
>(
this)->
accept(*ipItr) ){
267 return StatusCode::SUCCESS;
270 template<
class Derived>
275 return StatusCode::SUCCESS;
278 template<
class Derived>
280 if(
pt<m_ptmin)
return false;
281 if(
pt>m_ptmax)
return false;
282 if(fabs(
eta)>m_absetamax)
return false;
283 if(fabs(
eta)<m_absetamin)
return false;
284 if(
eta>m_etamax)
return false;
285 if(
eta<m_etamin)
return false;