DESY Hbb Analysis Framework
Collection.h
Go to the documentation of this file.
1 #ifndef Analysis_Tools_Collection_h
2 #define Analysis_Tools_Collection_h 1
3 
4 // -*- C++ -*-
5 //
6 // Package: Analysis/Tools
7 // Class: Collection
8 //
16 //
17 // Original Author: Roberval Walsh Bastos Rangel
18 // Created: Mon, 20 Oct 2014 14:24:08 GMT
19 //
20 //
21 
22 // system include files
23 #include <memory>
24 #include <vector>
25 //
26 // user include files
32 
33 //
34 // class declaration
35 //
36 
37 namespace analysis {
38  namespace tools {
39 
40  template <class Object>
41  class Collection {
42 
43  typedef std::vector<Object> Objects;
44 
45  public:
46  Collection();
47  Collection(const Objects & objects, const std::string & name_ = "");
48  ~Collection();
49 
50  int size();
51  void setSize(const int & size);
52  Object & at(const int & index);
53  void add(const Object & object);
54 
55  void matchTo( const std::vector<Candidate>* vectorcandidates, const std::string & name , const float & deltaR = 0.5 );
56  void matchTo( const Collection<Candidate> & collection, const float & delta_pT, const float & deltaR);
57  void matchTo( const Collection<Jet> & collection, const float & delta_pT, const float & deltaR);
58  void matchTo( const Collection<Candidate> & collection, const float & deltaR = 0.5 );
59  void matchTo( const Collection<TriggerObject> & collection, const float & deltaR = 0.5 );
60  void matchTo( const std::shared_ptr<Collection<TriggerObject> > collection, const float & deltaR = 0.5 );
61 
62  void smearTo( const Collection<Jet> & collection, const double & n_sigma = 0 );
63 
64  std::vector< std::shared_ptr<Object> > vector();
65  std::vector<Candidate>* vectorCandidates() const;
66 
67  std::string name() const;
68 
69  void associatePartons(const std::shared_ptr<Collection<GenParticle> > & , const float & deltaR = 0.4, const float & ptMin = 1., const bool & pythia8 = true);
70  void addGenJets(const std::shared_ptr<Collection<GenJet> > &);
71  void btagAlgo(const std::string &);
72  // ----------member data ---------------------------
73  protected:
74 
75  private:
76  Objects objects_;
77  mutable std::vector<Candidate> candidates_; // maybe not the best idea but need to make code work
78  int size_;
79  std::string name_;
80 
81  };
82  // ===============================================
83  // INLINE IMPLEMENTATIONS
84 
85 
86  // Gets
87  template <class Object> inline int Collection<Object>::size() { return size_; }
88  template <class Object> inline Object & Collection<Object>::at(const int & index) { return objects_.at(index); }
89  template <class Object> inline std::string Collection<Object>::name() const { return name_; }
90 
91  // Sets
92  template <class Object> inline void Collection<Object>::add(const Object & object) { objects_.push_back(object); ++size_; }
93  template <class Object> inline void Collection<Object>::setSize(const int & size) { size_ = size; }
94 
95  }
96 }
97 
98 #endif // Analysis_Tools_Tree_h
std::vector< Candidate > * vectorCandidates() const
Definition: Collection.cc:286
void setSize(const int &size)
Definition: Collection.h:93
void btagAlgo(const std::string &)
Definition: Collection.cc:103
std::vector< Candidate > candidates_
Definition: Collection.h:77
std::string name() const
Definition: Collection.h:89
void add(const Object &object)
Definition: Collection.h:92
void associatePartons(const std::shared_ptr< Collection< GenParticle > > &, const float &deltaR=0.4, const float &ptMin=1., const bool &pythia8=true)
Definition: Collection.cc:131
Object & at(const int &index)
Definition: Collection.h:88
void matchTo(const std::vector< Candidate > *vectorcandidates, const std::string &name, const float &deltaR=0.5)
Definition: Collection.cc:195
void addGenJets(const std::shared_ptr< Collection< GenJet > > &)
Definition: Collection.cc:115
std::vector< Object > Objects
Definition: Collection.h:43
void smearTo(const Collection< Jet > &collection, const double &n_sigma=0)
std::vector< std::shared_ptr< Object > > vector()
Definition: Collection.cc:92