00001 #include "AtlfastUtils/HepMC_helper/HepMC_helper.h"
00002 #include "AtlfastEvent/ParticleCodes.h"
00003 #include "HepMC/GenParticle.h"
00004 namespace HepMC_helper {
00005 using std::vector;
00006 using std::abs;
00007
00008
00009
00010 bool All::operator()( const Particle* const) const {
00011 return true;
00012 }
00013 bool All::operator() ( const Particle& p ) const {
00014 return this->operator()(&p);
00015 }
00016 IMCselector* All::create() const {return new All();}
00017
00018
00019
00020 IsFinalState::IsFinalState() {}
00021
00022
00023 bool IsFinalState::operator()( const Particle* const p ) const {
00024
00025
00026
00027 return ( p->barcode() < 100000 && ( p->status()==1 || p->status()>100) ) ? true:false;
00028 }
00029
00030 bool IsFinalState::operator() ( const Particle& p ) const {
00031 return this->operator()(&p);
00032 }
00033 IMCselector* IsFinalState::create() const {return new IsFinalState(*this);}
00034
00035
00036
00037 bool IsStatusxx::operator()( const Particle* const p ) const {
00038 return ( p->status()%100 == m_stat)? true:false;}
00039 bool IsStatusxx::operator() ( const Particle& p ) const {
00040 return this->operator()(&p);
00041 }
00042 IMCselector* IsStatusxx::create() const {return new IsStatusxx(*this);}
00043
00044
00045
00046 bool NCutter::operator()( const Particle* const p ) const {
00047 for (vector<IMCselector*>::const_iterator i = m_selectors.begin();
00048 i != m_selectors.end(); i++) {
00049 if ( !(*i)->operator()(p) ) return false;
00050 }
00051 return true;
00052 }
00053 bool NCutter::operator() ( const Particle& p ) const {
00054 return this->operator()(&p);
00055 }
00056 IMCselector* NCutter::create() const {return new NCutter(*this);}
00057
00058
00059
00060 SelectType::SelectType(vector<int> types):m_requiredTypes(types){}
00061 SelectType::SelectType(int type){m_requiredTypes.push_back(type);}
00062 SelectType::SelectType(const SelectType& rhs):
00063 IMCselector(),
00064 m_requiredTypes(rhs.m_requiredTypes){}
00065
00066 bool SelectType::operator() ( const Particle* const p ) const {
00067 vector<int>::const_iterator itype = m_requiredTypes.begin();
00068 for(; itype < m_requiredTypes.end(); ++itype ){
00069 if( abs(p->pdg_id()) == (*itype) ) return true ;
00070 }
00071 return false ;
00072 }
00073 bool SelectType::operator() ( const Particle& p ) const {
00074 return this->operator()(&p);
00075 }
00076 IMCselector* SelectType::create() const {return new SelectType(*this);}
00077
00078
00079
00080
00081
00082 RejectType::RejectType(int type): m_selectType(type){}
00083 RejectType::RejectType(vector<int> types): m_selectType(types){}
00084 RejectType::RejectType(const RejectType& rhs):
00085 IMCselector(),
00086 m_selectType(rhs.m_selectType){}
00087
00088 bool RejectType::operator() ( const Particle* const p ) const{
00089 return !m_selectType(p);}
00090 bool RejectType::operator()( const Particle& p ) const {
00091 return this->operator()(&p);}
00092 IMCselector* RejectType::create() const {return new RejectType(*this);}
00093
00094
00095
00096
00097
00098 bool IsCharged::operator() ( const Particle* const p )const{
00099
00100 double charge = m_chargeService(p);
00101 if(charge==0) return false;
00102 return true ;
00103 }
00104
00105 bool IsCharged::operator() ( const Particle& p ) const {
00106 return this->operator()(&p);
00107 }
00108 IMCselector* IsCharged::create() const {return new IsCharged(*this);}
00109
00110
00111
00112
00113 MCCuts::MCCuts(double ptMin, double etaMax):
00114 m_ptMin(ptMin),m_etaMax(etaMax){}
00115 bool MCCuts::operator() ( const Particle* const p )const {
00116 if (p->momentum().perp() < m_ptMin) return false;
00117 if (abs(p->momentum().pseudoRapidity()) > m_etaMax) return false;
00118 return true;
00119 }
00120
00121 bool MCCuts::operator() ( const Particle& p ) const {
00122 return this->operator()(&p);
00123 }
00124 IMCselector* MCCuts::create() const {return new MCCuts(*this);}
00125
00126
00127
00128
00129
00130 Unseen::Unseen( vector<int> requiredTypes,
00131 double muonPtMax,
00132 double muonEtaMax):
00133 m_seltype( SelectType(requiredTypes) ),
00134 m_muonPtMax( muonPtMax ),
00135 m_muonEtaMax( muonEtaMax ){
00136 }
00137
00138 Unseen::Unseen(const Unseen& src ):
00139 IMCselector(),
00140 m_seltype( src.m_seltype ),
00141 m_muonPtMax( src.m_muonPtMax ),
00142 m_muonEtaMax( src.m_muonEtaMax ){
00143 }
00144 bool Unseen::operator() ( const Particle* const p )const{
00145 if(m_seltype(p)) return true;
00146 if( abs(p->pdg_id()) == 13){
00147 if(!m_ifs(p)) return false;
00148 if(abs(p->momentum().pseudoRapidity()) > m_muonEtaMax) return true;
00149 if( p->momentum().perp() < m_muonPtMax ) return true;
00150 }
00151 return false ;
00152 }
00153 IMCselector* Unseen::create() const {return new Unseen(*this);}
00154
00155 bool Unseen::operator() ( const Particle& p ) const {
00156 return this->operator()(&p);
00157 }
00158
00159
00160
00161
00162 SelectJetTag::SelectJetTag(int id, double pt, double eta):
00163 m_id(abs(id)), m_ptMin(pt), m_etaMax(eta){
00164 }
00165 bool SelectJetTag::operator() ( const Particle* const p ) const{
00166
00167 if( abs(p->pdg_id()) != m_id) return false ;
00168 if( p->momentum().perp() < m_ptMin) return false ;
00169 if((abs(p->momentum().pseudoRapidity())) > m_etaMax) return false ;
00170 if(p->end_vertex()){
00171
00172 HepMC::GenVertex::particle_iterator firstChild =
00173 p->end_vertex()->particles_begin(HepMC::children);
00174
00175 HepMC::GenVertex::particle_iterator endChild =
00176 p->end_vertex()->particles_end(HepMC::children);
00177
00178 HepMC::GenVertex::particle_iterator thisChild = firstChild;
00179
00180
00181
00182
00183 for(; thisChild!=endChild; ++thisChild){
00184 if(abs((*thisChild)->pdg_id()) == m_id) return false;
00185 }
00186 }
00187 return true ;
00188 }
00189 IMCselector* SelectJetTag::create() const {return new SelectJetTag(*this);}
00190 bool SelectJetTag::operator() ( const Particle& p ) const {
00191 return this->operator()(&p);
00192 }
00193
00194
00195
00196
00197
00198
00199 SelectTauTag::SelectTauTag(double pt, double eta):
00200 m_jetTagSelector(ParticleCodes::TAU, pt, eta){
00201 }
00202 bool SelectTauTag::operator() ( const Particle* const p ) const{
00203 if(p->end_vertex()){
00204
00205 HepMC::GenVertex::particle_iterator firstChild =
00206 p->end_vertex()->particles_begin(HepMC::children);
00207
00208 HepMC::GenVertex::particle_iterator endChild =
00209 p->end_vertex()->particles_end(HepMC::children);
00210
00211 HepMC::GenVertex::particle_iterator thisChild = firstChild;
00212
00213
00214 for(; thisChild!=endChild; ++thisChild){
00215 if(abs((*thisChild)->pdg_id()) == 11 ||
00216 abs((*thisChild)->pdg_id()) == 13 ||
00217 abs((*thisChild)->pdg_id()) == 15 ) return false;
00218 }
00219 }
00220 return m_jetTagSelector(p);
00221 }
00222
00223 IMCselector* SelectTauTag::create() const {return new SelectTauTag(*this);}
00224
00225 bool SelectTauTag::operator() ( const Particle& p ) const {
00226 return this->operator()(&p);
00227 }
00228
00229
00230
00231
00232
00233 bool SelectZ0::operator() ( const Particle* const p ) const{
00234 if(!m_z0Type(p)) return false;
00235 if(!m_kineCuts(p)) return false;
00236 return true;
00237 }
00238 IMCselector* SelectZ0::create() const {return new SelectZ0(*this);}
00239 bool SelectZ0::operator() ( const Particle& p ) const {
00240 return this->operator()(&p);
00241 }
00242
00243
00244
00245
00246
00247 bool BFieldCutter::operator()(const Particle* const a) const {
00248 if(m_chargeService(a) == 0.) return true;
00249 return (a->momentum().perp()<m_ptCut) ? false:true;
00250 }
00251
00252 IMCselector* BFieldCutter::create() const {return new BFieldCutter(*this);}
00253 bool BFieldCutter::operator()( const Particle& p ) const {
00254 return this->operator()(&p);
00255 }
00256
00257
00258
00259
00260
00261 bool AscendingEta::operator() ( const Particle* const a,
00262 const Particle* const b ) const{
00263 return( a->momentum().pseudoRapidity() <
00264 b->momentum().pseudoRapidity() ); }
00265 bool AscendingEta::operator() ( const Particle& a,
00266 const Particle& b ) const{
00267 return( a.momentum().pseudoRapidity() <
00268 b.momentum().pseudoRapidity() );
00269 }
00270
00271 }
00272
00273
00274
00275
00276
00277
00278
00279