CMS 3D CMS Logo

CandCombiner.h

Go to the documentation of this file.
00001 #ifndef CandUtils_CandCombiner_h
00002 #define CandUtils_CandCombiner_h
00003 
00008 #include "PhysicsTools/CandUtils/interface/CandCombinerBase.h"
00009 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h"
00010 #include "PhysicsTools/CandUtils/interface/CandSelector.h"
00011 #include "PhysicsTools/UtilAlgos/interface/AnyPairSelector.h"
00012 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00013 #include "DataFormats/Candidate/interface/NamedCompositeCandidate.h"
00014 #include "DataFormats/Candidate/interface/ShallowCloneCandidate.h"
00015 #include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h"
00016 
00017 namespace combiner {
00018   namespace helpers {
00019     struct NormalClone {
00020       typedef reco::CandidateBaseRef CandPtr;
00021       template<typename Ref>
00022       static void addDaughter(reco::CompositeCandidate & cmp, const Ref & c, const std::string name = "") {
00023         cmp.addDaughter(*c, name);
00024       }
00025     };
00026      
00027     struct ShallowClone {
00028       typedef reco::CandidateBaseRef CandPtr;
00029       static void addDaughter(reco::CompositeCandidate & cmp, const reco::CandidateBaseRef & c, const std::string name = "") {
00030         if(c->numberOfDaughters()==0)
00031           cmp.addDaughter(reco::ShallowCloneCandidate(c), name);
00032         else
00033           cmp.addDaughter(*c, name);
00034       }
00035     };
00036     struct ShallowClonePtr {
00037       typedef reco::CandidatePtr CandPtr;
00038       static void addDaughter(reco::CompositeCandidate & cmp, const reco::CandidatePtr & c, const std::string name = "") {
00039         if(c->numberOfDaughters()==0)
00040           cmp.addDaughter(reco::ShallowClonePtrCandidate(c), name);
00041         else
00042           cmp.addDaughter(*c, name);
00043       }
00044     };
00045  }
00046 }
00047 
00048 template<typename Selector, 
00049          typename PairSelector = AnyPairSelector,
00050          typename Cloner = combiner::helpers::NormalClone, 
00051          typename OutputCollection = reco::CompositeCandidateCollection,
00052          typename Setup = AddFourMomenta>
00053 class CandCombiner : public CandCombinerBase<OutputCollection, typename Cloner::CandPtr> {
00054 public:
00055   typedef typename Cloner::CandPtr CandPtr;
00056   typedef CandCombinerBase<OutputCollection, CandPtr> base;
00058   CandCombiner() :
00059   base(), 
00060     select_(), selectPair_(), setup_() { }
00062   CandCombiner(int q1, int q2) :
00063     base(q1, q2), 
00064     select_(), selectPair_(), setup_() { }
00066   CandCombiner( int q1, int q2, int q3 ) :
00067     base(q1, q2, q3), 
00068     select_(), selectPair_(), setup_() { }
00070   CandCombiner(int q1, int q2, int q3, int q4) :
00071     base(q1, q2, q3, q4), 
00072     select_(), selectPair_(), setup_() { }
00074   CandCombiner(const Selector & select) :
00075     base( ), 
00076     select_(select), selectPair_(), setup_() { }
00078   CandCombiner( const Selector & select, int q1, int q2 ) :
00079     base(q1, q2), 
00080     select_(select), selectPair_(), setup_() { }
00082   CandCombiner( const Selector & select, int q1, int q2, int q3 ) :
00083     base(q1, q2, q3), 
00084     select_(select), selectPair_(), setup_() { }
00086   CandCombiner( const Selector & select, int q1, int q2, int q3, int q4 ) :
00087     base(q1, q2, q3, q4), 
00088     select_(select), selectPair_(), setup_() { }
00090   CandCombiner(const Selector & select, const PairSelector & selectPair) :
00091     base( ), 
00092     select_(select), selectPair_(selectPair), setup_() { }
00094   CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2) :
00095     base(q1, q2), 
00096     select_(select), selectPair_(selectPair), setup_() { }
00098   CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3) :
00099     base(q1, q2, q3), 
00100     select_(select), selectPair_(selectPair), setup_() { }
00102   CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3, int q4) :
00103     base(q1, q2, q3, q4), 
00104     select_(select), selectPair_(selectPair), setup_() { }
00105   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup) :
00106     base(), 
00107     select_(select), selectPair_(selectPair), setup_(setup) { }
00109   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2) :
00110     base(q1, q2), 
00111     select_(select), selectPair_(selectPair), setup_(setup) { }
00113   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3) :
00114     base(q1, q2, q3), 
00115     select_(select), selectPair_(selectPair), setup_(setup) { }
00117   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3, int q4) :
00118     base(q1, q2, q3, q4), 
00119     select_(select), selectPair_(selectPair), setup_(setup) { }
00121   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup,const std::vector <int> & dauCharge) : 
00122     base(true, dauCharge), select_(select), selectPair_(selectPair), setup_(setup) { }
00124   CandCombiner( const Selector & select, const PairSelector & selectPair, const std::vector <int> & dauCharge ) : 
00125     base(true, dauCharge), select_(select), selectPair_(selectPair), setup_() { }
00127   CandCombiner(const std::vector <int> & dauCharge) : 
00128     base(true, dauCharge), select_(), selectPair_(), setup_() { }
00130   CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup,
00131                bool checkCharge, const std::vector <int> & dauCharge) : 
00132     base(checkCharge, dauCharge), 
00133     select_(select), selectPair_(selectPair), setup_(setup) { }
00135   Setup & setup() { return setup_; }
00136 
00137 private:
00139   virtual bool select(const reco::Candidate & c) const {
00140     return select_(c);
00141   } 
00143   virtual bool selectPair(const reco::Candidate & c1, const reco::Candidate & c2) const {
00144     return selectPair_(c1, c2);
00145   } 
00147   virtual void setup(typename OutputCollection::value_type & c) const {
00148     setup_.set(c);
00149   }
00151   virtual void addDaughter(typename OutputCollection::value_type & cmp, const CandPtr & c, const std::string name = "") const {
00152     Cloner::addDaughter(cmp, c, name);
00153   }
00155   Selector select_; 
00157   PairSelector selectPair_; 
00159   Setup setup_;
00160 };
00161 
00162 #endif

Generated on Tue Jun 9 17:40:56 2009 for CMSSW by  doxygen 1.5.4