HardEventHypothesis is a pure virtual base class to implement a "hard" event hypothesis class. More...
#include <DataFormats/PatCandidates/interface/HardEventHypothesis.h>
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::Candidate & | getCandidate (std::string name, int irole=-1)=0 |
Protected Attributes | |
float | quality_ |
Friends | |
class | StarterKit |
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.
|
protectedpure virtual |
Implemented in pat::__class__.
Referenced by getQuality().
|
pure virtual |
Implemented in pat::__class__.
Referenced by getQuality().
|
pure virtual |
Implemented in pat::__class__.
Referenced by getQuality().
|
inline |
Definition at line 120 of file HardEventHypothesis.h.
References getCandidate(), getCandidateRole(), getIsVector(), mps_fire::i, dataset::name, quality_, and AlCaHLTBitMon_QueryRunRegistry::string.
|
inline |
|
friend |
Definition at line 114 of file HardEventHypothesis.h.
|
protected |
Definition at line 136 of file HardEventHypothesis.h.
Referenced by getQuality(), and setQuality().