Atlfast::ChargeService Class Reference

#include <ChargeService.h>

List of all members.

Public Member Functions

 ChargeService ()
 ChargeService (const ChargeService &other)
double operator() (const HepMC::GenParticle *p) const
double operator() (const ReconstructedParticle *p) const

Private Attributes

HepPDT::ParticleDataTable * m_particleDataTable


Detailed Description

Service providing the charge of HepMC::GenParticle / ReconstructedParticle.

Definition at line 22 of file ChargeService.h.


Constructor & Destructor Documentation

Atlfast::ChargeService::ChargeService (  ) 

Default Constructor

Definition at line 17 of file ChargeService.cxx.

00017                               {
00018 
00019     IPartPropSvc* p_PartPropSvc;
00020     static const bool CREATEIFNOTTHERE(true);
00021     ISvcLocator* svcLoc = Gaudi::svcLocator( );
00022     StatusCode PartPropStatus = svcLoc->service("PartPropSvc", 
00023                                                 p_PartPropSvc, 
00024                                                 CREATEIFNOTTHERE
00025                                                 );
00026     if (!PartPropStatus.isSuccess() || 0 == p_PartPropSvc) {
00027       std::cerr<<"ChargeService: could not find PartPropService"<<std::endl;
00028       std::string errMsg = "ChargeService: could not find PartPropService";
00029       throw errMsg;
00030     }      
00031     m_particleDataTable = (HepPDT::ParticleDataTable*)p_PartPropSvc->PDT();
00032     if(m_particleDataTable == 0){
00033       std::cerr<< "ChargeService: PDG table not found"<<std::endl;
00034       std::string errMsg = "ChargeService: PDG table not found";
00035       throw errMsg;
00036     }
00037 
00038 
00039     //make a test read of the table
00040     HepPDT::ParticleData* ap = 
00041       m_particleDataTable->particle( 211 );
00042     
00043     if(!ap){ 
00044       std::cerr<< "ChargeService: Test read of PDG table failed"<<std::endl;
00045       std::string errMsg = "ChargeService: Test read of PDG table failed";
00046       throw errMsg;
00047     }
00048     
00049 
00050   }

Atlfast::ChargeService::ChargeService ( const ChargeService other  ) 

Copy Constructor

Definition at line 51 of file ChargeService.cxx.

00051                                                          :
00052     m_particleDataTable(other.m_particleDataTable){}
  


Member Function Documentation

double Atlfast::ChargeService::operator() ( const HepMC::GenParticle *  p  )  const

returns charge of HepMC::GenParticle

Definition at line 54 of file ChargeService.cxx.

00054                                                                  {
00055     
00056     //does particle exist in table only positive ids for neutrals !?
00057     HepPDT::ParticleData* ap = 
00058       m_particleDataTable->particle( abs( p->pdg_id() ) );
00059     
00060     if(!ap){ 
00061       std::cout << "Atlfast::ChargeService: PDGID " << p->pdg_id()
00062                 << " is not in ParticleDataTable!!!" << std::endl;
00063       return -999.;
00064     }
00065     
00066     //if in table, and the charge is 0, return 0. 
00067     double c = ap->charge();
00068     if(c==0){ return 0.;}
00069     return (p->pdg_id() > 0)? c:-c;
00070     
00071   }

double Atlfast::ChargeService::operator() ( const ReconstructedParticle p  )  const

returns charge of ReconstructedParticle

Definition at line 73 of file ChargeService.cxx.

00073                                                                       {
00074     return (*this)(p->truth());
00075   }


Member Data Documentation

HepPDT::ParticleDataTable* Atlfast::ChargeService::m_particleDataTable [private]

Definition at line 34 of file ChargeService.h.


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 13:00:20 2007 for AtlfastEvent by  doxygen 1.5.1