CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
pat::HardEventHypothesis Class Referenceabstract

HardEventHypothesis is a pure virtual base class to implement a "hard" event hypothesis class. More...

#include <DataFormats/PatCandidates/interface/HardEventHypothesis.h>

Inheritance diagram for pat::HardEventHypothesis:
pat::__class__

Public Member Functions

virtual const char * getCandidateRole (int i=0) const =0
 
virtual bool getIsVector (int i=0) const =0
 
float getQuality () const
 
void setQuality (float q)
 

Protected Member Functions

virtual reco::CandidategetCandidate (std::string name, int irole=-1)=0
 

Protected Attributes

float quality_
 

Friends

class StarterKit
 

Detailed Description

HardEventHypothesis is a pure virtual base class to implement a "hard" event hypothesis class.

The idea of HardEventHypothesis is to act as the definition of the interface of a user-defined event hypothesis class. This class is what generic plotting utilities like the StarterKit will be using to interface with all of the plethora of derived classes that are forseen to exist inheriting from this class.

Ultimately the interface to the StarterKit is defined by the two virtual functions

virtual Candidate * getCandidate (std::string name) = 0; virtual std::vector<Candidate *> & getCandidateVector (std::string name) = 0;

The specific implementation of the concrete derived class must overload these operators with logic that gives the right role<—>candidate mapping.

As a concrete example, examine

class ZPlusJetsHypothesis : public UserEventHypothesis { public: pat::Muon & getMuon1(); pat::Muon & getMuon2(); std::vector<pat::Jet> & getJets();

void setMuon1( const pat::Muon & muon1, std::string sMuon1); void setMuon2( const pat::Muon & muon2, std::string sMuon2); void setJets ( const std::vector<pat::Jet> & jets, std::string sJets);

virtual Candidate * getCandidate (std::string name); virtual std::vector<Candidate*> & getCandidateVector (std::string name);

protected: pat::Muon muon1_; pat::Muon muon2_; std::vector<pat::Jet> jets_;

};

The user must overload getCandidate and getCandidateVector as:

Candidate * getCandidate( std::string name ) { if ( name == "muon1" ) return muon1_; else if ( name == "muon2" ) return muon2_; else return 0; }

vector<Candidate*> & getCandidateVector( std::string name ) { if ( name == "jets" ) return jets_; else return 0; }

The StarterKit and it's derived classes will then be implementing decision logic based on dynamic type casting. This will be hidden from the user.

The user code will have a skeleton generated by a perl script which will create "specific" get functions that the users should be using to access internal information.

For example,

 Muon &        getMuon1() { return *(dynamic_cast<Muon *>( & getCandidate("muon1") )); }
 Muon &        getMuon2() { return *(dynamic_cast<Muon *>( & getCandidate("muon2") )); }
 Jet &         getJet  (int i = 0)  { return *(dynamic_cast<Jet *> (& getCandidateVector("jets").at(i))); }

This obviates the need for users to deal with dynamic type casting while retaining full capability for polymorphism in the friend classes derived from StarterKit. Ideally, the user will be implementing a "Kit" to go along with their hypothesis formation that will rely on the public "hypothesis-specific" methods, while only the actual StarterKit will be using the generic interface from the base class.

Definition at line 110 of file HardEventHypothesis.h.

Member Function Documentation

virtual reco::Candidate& pat::HardEventHypothesis::getCandidate ( std::string  name,
int  irole = -1 
)
protectedpure virtual

Implemented in pat::__class__.

Referenced by getQuality().

virtual const char* pat::HardEventHypothesis::getCandidateRole ( int  i = 0) const
pure virtual

Implemented in pat::__class__.

Referenced by getQuality().

virtual bool pat::HardEventHypothesis::getIsVector ( int  i = 0) const
pure virtual

Implemented in pat::__class__.

Referenced by getQuality().

float pat::HardEventHypothesis::getQuality ( ) const
inline
void pat::HardEventHypothesis::setQuality ( float  q)
inline

Friends And Related Function Documentation

friend class StarterKit
friend

Definition at line 114 of file HardEventHypothesis.h.

Member Data Documentation

float pat::HardEventHypothesis::quality_
protected

Definition at line 136 of file HardEventHypothesis.h.

Referenced by getQuality(), and setQuality().