CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BPHDecayToV0Builder.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //-----------------------
9 // This Class' Header --
10 //-----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
19 
21 
22 //---------------
23 // C++ Headers --
24 //---------------
25 #include <cmath>
26 using namespace std;
27 
28 //-------------------
29 // Initializations --
30 //-------------------
31 
32 //----------------
33 // Constructors --
34 //----------------
36  const std::string& d1Name,
37  const std::string& d2Name,
38  const BPHRecoBuilder::BPHGenericCollection* d1Collection,
39  const BPHRecoBuilder::BPHGenericCollection* d2Collection)
41  p1Name(d1Name),
42  p2Name(d2Name),
43  p1Collection(d1Collection),
44  p2Collection(d2Collection),
45  vCollection(nullptr),
46  rCollection(nullptr),
47  sList(""),
48  ptMin(0.0),
49  etaMax(100.0) {}
50 
52  const std::string& d1Name,
53  const std::string& d2Name,
54  const std::vector<reco::VertexCompositeCandidate>* v0Collection,
55  const std::string& searchList)
57  p1Name(d1Name),
58  p2Name(d2Name),
59  p1Collection(nullptr),
60  p2Collection(nullptr),
61  vCollection(v0Collection),
62  rCollection(nullptr),
63  sList(searchList),
64  ptMin(0.0),
65  etaMax(100.0) {}
66 
68  const std::string& d1Name,
69  const std::string& d2Name,
70  const std::vector<reco::VertexCompositePtrCandidate>* vpCollection,
71  const std::string& searchList)
73  p1Name(d1Name),
74  p2Name(d2Name),
75  p1Collection(nullptr),
76  p2Collection(nullptr),
77  vCollection(nullptr),
78  rCollection(vpCollection),
79  sList(searchList),
80  ptMin(0.0),
81  etaMax(100.0) {}
82 
83 //--------------
84 // Destructor --
85 //--------------
87 
88 //--------------
89 // Operations --
90 //--------------
91 vector<BPHPlusMinusConstCandPtr> BPHDecayToV0Builder::build() {
92  if (updated)
93  return cList;
94  cList.clear();
95  v0Clear();
96 
97  if ((p1Collection != nullptr) && (p2Collection != nullptr))
99  else if (vCollection != nullptr)
101  else if (rCollection != nullptr)
103 
104  updated = true;
105  return cList;
106 }
107 
110  updated = false;
111  ptMin = pt;
112  return;
113 }
114 
116  updated = false;
117  etaMax = eta;
118  return;
119 }
120 
122 double BPHDecayToV0Builder::getPtMin() const { return ptMin; }
123 
124 double BPHDecayToV0Builder::getEtaMax() const { return etaMax; }
125 
126 template <class T>
127 void BPHDecayToV0Builder::buildFromV0(const T* v0Collection, v0Type type) {
128  int iv0;
129  int nv0 = v0Collection->size();
130  cList.reserve(nv0);
131 
132  // cycle over V0 collection
133  for (iv0 = 0; iv0 < nv0; ++iv0) {
134  const typename T::value_type& v0 = v0Collection->at(iv0);
135 
136  // every reco::VertexCompositeCandidate must have exactly two daughters
137  if (v0.numberOfDaughters() != 2)
138  continue;
139  const reco::Candidate* dr = v0.daughter(0);
140  const reco::Candidate* dl = v0.daughter(1);
141 
142  // filters
143  if (dr->p4().pt() < ptMin)
144  continue;
145  if (dl->p4().pt() < ptMin)
146  continue;
147  if (fabs(dr->p4().eta()) > etaMax)
148  continue;
149  if (fabs(dl->p4().eta()) > etaMax)
150  continue;
151 
152  BPHPlusMinusCandidatePtr cand = buildCandidate(dr, dl, &v0, type);
153  BPHPlusMinusCandidate* cptr = cand.get();
154  if (cand->daughters().size() != 2)
155  continue;
156  if (!massSel->accept(*cand))
157  continue;
158  if ((chi2Sel != nullptr) && (!chi2Sel->accept(*cand)))
159  continue;
160 
161  cList.push_back(cand);
162  V0Info* info = new V0Info;
163  info->type = type;
164  info->v0 = &v0;
165  v0Map[cptr] = info;
166  }
167 
168  return;
169 }
170 
172  map<const BPHRecoCandidate*, const V0Info*>::iterator iter = v0Map.begin();
173  map<const BPHRecoCandidate*, const V0Info*>::iterator iend = v0Map.end();
174  while (iter != iend)
175  delete iter++->second;
176  return;
177 }
BPHDecayToV0Builder(const edm::EventSetup &es, const std::string &d1Name, const std::string &d2Name, const BPHRecoBuilder::BPHGenericCollection *d1Collection, const BPHRecoBuilder::BPHGenericCollection *d2Collection)
static const TGPicture * info(bool iBackgroundIsBlack)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
std::vector< BPHPlusMinusConstCandPtr > build()
build candidates
constexpr float ptMin
bool accept(const BPHDecayVertex &cand) const override
select vertex
Definition: BPHChi2Select.h:48
virtual void buildFromBPHGenericCollection()=0
build candidates and link to V0
double getPtMin() const
get current cuts
bool accept(const BPHDecayMomentum &cand) const override
select particle
Definition: BPHMassSelect.h:48
const BPHRecoBuilder::BPHGenericCollection * p2Collection
void setEtaMax(double eta)
BPHGenericPtr< BPHPlusMinusCandidate >::type BPHPlusMinusCandidatePtr
std::map< const BPHRecoCandidate *, const V0Info * > v0Map
const BPHRecoBuilder::BPHGenericCollection * p1Collection
std::vector< BPHPlusMinusConstCandPtr > cList
const std::vector< reco::VertexCompositeCandidate > * vCollection
virtual BPHPlusMinusCandidatePtr buildCandidate(const reco::Candidate *c1, const reco::Candidate *c2, const void *v0, v0Type type)=0
void buildFromV0(const T *v0Collection, v0Type type)
const std::vector< reco::VertexCompositePtrCandidate > * rCollection
void setPtMin(double pt)
set cuts
tuple etaMax
Definition: Puppi_cff.py:46
long double T
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector