CMS 3D CMS Logo

ParticleTreeDrawer Class Reference

Inheritance diagram for ParticleTreeDrawer:

edm::EDAnalyzer

List of all members.

Public Member Functions

 ParticleTreeDrawer (const edm::ParameterSet &)

Private Types

typedef std::vector< intvint
 accepted status codes

Private Member Functions

bool accept (const reco::Candidate &) const
 accept candidate
void analyze (const edm::Event &, const edm::EventSetup &)
std::string getParticleName (int id) const
bool hasValidDaughters (const reco::Candidate &) const
 has valid daughters in the chain
void printDecay (const reco::Candidate &, const std::string &pre) const
void printInfo (const reco::Candidate &) const
 print 4 momenta

Private Attributes

std::vector< const
reco::Candidate * > 
cands_
 pointer to collection
edm::ESHandle< ParticleDataTablepdt_
bool printIndex_
bool printP4_
 print parameters
bool printPtEtaPhi_
bool printStatus_
bool printVertex_
edm::InputTag src_
vint status_


Detailed Description

Definition at line 13 of file ParticleTreeDrawer.cc.


Member Typedef Documentation

typedef std::vector<int> ParticleTreeDrawer::vint [private]

accepted status codes

Definition at line 25 of file ParticleTreeDrawer.cc.


Constructor & Destructor Documentation

ParticleTreeDrawer::ParticleTreeDrawer ( const edm::ParameterSet cfg  ) 

Definition at line 49 of file ParticleTreeDrawer.cc.

00049                                                                  :
00050   src_( cfg.getParameter<InputTag>( "src" ) ),
00051   printP4_( cfg.getUntrackedParameter<bool>( "printP4", false ) ),
00052   printPtEtaPhi_( cfg.getUntrackedParameter<bool>( "printPtEtaPhi", false ) ),
00053   printVertex_( cfg.getUntrackedParameter<bool>( "printVertex", false ) ),
00054   printStatus_( cfg.getUntrackedParameter<bool>( "printStatus", false ) ),
00055   printIndex_( cfg.getUntrackedParameter<bool>( "printIndex", false ) ),
00056   status_( cfg.getUntrackedParameter<vint>( "status", vint() ) ) {
00057 }


Member Function Documentation

bool ParticleTreeDrawer::accept ( const reco::Candidate c  )  const [private]

accept candidate

Definition at line 59 of file ParticleTreeDrawer.cc.

References find(), reco::Particle::status(), and status_.

Referenced by analyze(), and hasValidDaughters().

00059                                                                {
00060   if ( status_.size() == 0 ) return true;
00061   return find( status_.begin(), status_.end(), c.status() ) != status_.end();
00062 }

void ParticleTreeDrawer::analyze ( const edm::Event event,
const edm::EventSetup es 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 83 of file ParticleTreeDrawer.cc.

References accept(), cands_, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), edm::EventSetup::getData(), p, pdt_, printDecay(), and src_.

00083                                                                              {  
00084   es.getData( pdt_ );
00085   Handle<View<Candidate> > particles;
00086   event.getByLabel( src_, particles );
00087   cands_.clear();
00088   for( View<Candidate>::const_iterator p = particles->begin();
00089        p != particles->end(); ++ p ) {
00090     cands_.push_back( & * p );
00091   }
00092   for( View<Candidate>::const_iterator p = particles->begin();
00093        p != particles->end(); ++ p ) {
00094     if ( accept( * p ) ) {
00095       if ( p->mother() == 0 ) {
00096         cout << "-- decay tree: --" << endl;
00097         printDecay( * p, "" );
00098       }
00099     }
00100   }
00101 }

std::string ParticleTreeDrawer::getParticleName ( int  id  )  const [private]

Definition at line 72 of file ParticleTreeDrawer.cc.

References pdt_, and ss.

00073 {
00074   const ParticleData * pd = pdt_->particle( id );
00075   if (!pd) {
00076     std::ostringstream ss;
00077     ss << "P" << id;
00078     return ss.str();
00079   } else
00080     return pd->name();
00081 }

bool ParticleTreeDrawer::hasValidDaughters ( const reco::Candidate c  )  const [private]

has valid daughters in the chain

Definition at line 64 of file ParticleTreeDrawer.cc.

References accept(), reco::Candidate::daughter(), i, and reco::Candidate::numberOfDaughters().

00064                                                                           {
00065   size_t ndau = c.numberOfDaughters();
00066   for( size_t i = 0; i < ndau; ++ i )
00067     if ( accept( * c.daughter( i ) ) )
00068       return true;
00069   return false;
00070 }

void ParticleTreeDrawer::printDecay ( const reco::Candidate ,
const std::string &  pre 
) const [private]

Referenced by analyze().

void ParticleTreeDrawer::printInfo ( const reco::Candidate c  )  const [private]

print 4 momenta

Definition at line 103 of file ParticleTreeDrawer.cc.

References cands_, GenMuonPlsPt100GeV_cfg::cout, reco::Particle::energy(), reco::Particle::eta(), find(), reco::Particle::phi(), printIndex_, printP4_, printPtEtaPhi_, printStatus_, printVertex_, reco::Particle::pt(), reco::Particle::px(), reco::Particle::py(), reco::Particle::pz(), reco::Particle::status(), reco::Particle::vx(), reco::Particle::vy(), and reco::Particle::vz().

00103                                                               {
00104   if ( printP4_ ) cout << " (" << c.px() << ", " << c.py() << ", " << c.pz() << "; " << c.energy() << ")"; 
00105   if ( printPtEtaPhi_ ) cout << " [" << c.pt() << ": " << c.eta() << ", " << c.phi() << "]";
00106   if ( printVertex_ ) cout << " {" << c.vx() << ", " << c.vy() << ", " << c.vz() << "}";
00107   if ( printStatus_ ) cout << "{status: " << c.status() << "}";
00108   if ( printIndex_ ) {
00109     int idx = -1;
00110     vector<const Candidate *>::const_iterator found = find( cands_.begin(), cands_.end(), & c );
00111     if ( found != cands_.end() ) {
00112       idx = found - cands_.begin();
00113       cout << " <idx: " << idx << ">";
00114     }
00115   }
00116 }


Member Data Documentation

std::vector<const reco::Candidate *> ParticleTreeDrawer::cands_ [private]

pointer to collection

Definition at line 34 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and printInfo().

edm::ESHandle<ParticleDataTable> ParticleTreeDrawer::pdt_ [private]

Definition at line 21 of file ParticleTreeDrawer.cc.

Referenced by analyze(), and getParticleName().

bool ParticleTreeDrawer::printIndex_ [private]

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printP4_ [private]

print parameters

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printPtEtaPhi_ [private]

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printStatus_ [private]

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

bool ParticleTreeDrawer::printVertex_ [private]

Definition at line 23 of file ParticleTreeDrawer.cc.

Referenced by printInfo().

edm::InputTag ParticleTreeDrawer::src_ [private]

Definition at line 19 of file ParticleTreeDrawer.cc.

Referenced by analyze().

vint ParticleTreeDrawer::status_ [private]

Definition at line 26 of file ParticleTreeDrawer.cc.

Referenced by accept().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:29:27 2009 for CMSSW by  doxygen 1.5.4