CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pair_Table.cc
Go to the documentation of this file.
1 //
2 // $Id: Pair_Table.cc,v 1.1 2011/05/26 09:47:00 mseidel Exp $
3 //
4 // File: src/Pair_Table.cc
5 // Purpose: Helper for Fourvec_Constrainer.
6 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
7 //
8 // CMSSW File : src/Pair_Table.cc
9 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
10 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
11 //
12 
13 
39 #include <ostream>
40 
41 
42 using std::vector;
43 using std::ostream;
44 
45 
46 namespace hitfit {
47 
48 
49 Pair_Table::Pair_Table (const std::vector<Constraint>& cv,
50  const Fourvec_Event& ev)
51 //
52 // Purpose: Constructor.
53 //
54 // Inputs:
55 // cv - The list of constraints for the problem.
56 // ev - The event.
57 //
58 {
59  // The number of objects in the event, including any neutrino.
60  int nobjs = ev.nobjs_all();
61 
62  // Number of constraints.
63  int nc = cv.size();
64 
65  // Loop over pairs of objects.
66  for (int i=0; i < nobjs-1; i++)
67  for (int j=i+1; j < nobjs; j++) {
68  // Make an Objpair instance out of it.
69  Objpair p (i, j, nc);
70 
71  // Loop over constraints.
72  bool wanted = false;
73  for (int k=0; k < nc; k++) {
74  int val = cv[k].has_labels (ev.obj (i).label, ev.obj (j).label);
75  if (val) {
76  // This pair is used by this constraint. Record it.
77  p.has_constraint (k, val);
78  wanted = true;
79  }
80  }
81 
82  // Was this pair used by any constraint?
83  if (wanted)
84  _pairs.push_back (p);
85  }
86 }
87 
88 
90 //
91 // Purpose: Return the number of pairs in the table.
92 //
93 // Returns:
94 // The number of pairs in the table.
95 //
96 {
97  return _pairs.size();
98 }
99 
100 
102 //
103 // Purpose: Return one pair from the table.
104 //
105 // Inputs:
106 // pairno - The number of the pair (0-based).
107 //
108 // Returns:
109 // Pair PAIRNO.
110 //
111 {
112  assert (pairno < _pairs.size());
113  return _pairs[pairno];
114 }
115 
124 std::ostream& operator<< (std::ostream& s, const Pair_Table& p)
125 //
126 // Purpose: Print the object to S.
127 //
128 // Inputs:
129 // s - The stream to which to write.
130 // p - The object to write.
131 //
132 // Returns:
133 // The stream S.
134 //
135 {
136  for (int i=0; i < p.npairs(); i++)
137  s << " " << p.get_pair (i) << "\n";
138  return s;
139 }
140 
141 
142 } // namespace hitfit
const Objpair & get_pair(std::vector< Objpair >::size_type pairno) const
Get one of the pairs from the table, index starts from 0.
Definition: Pair_Table.cc:101
int i
Definition: DBlmapReader.cc:9
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
int npairs() const
Return the number of pairs in the table.
Definition: Pair_Table.cc:89
const FE_Obj & obj(std::vector< FE_Obj >::size_type i) const
Access object at index i, with the convention that the index starts at 0.
uint16_t size_type
void has_constraint(std::vector< signed char >::size_type k, int val)
Set the value for a constraint to a value.
Definition: Objpair.cc:64
int j
Definition: DBlmapReader.cc:9
std::vector< Objpair > _pairs
Definition: Pair_Table.h:138
int nobjs_all() const
Return the number of objects in the event including any neutrinos.
dictionary cv
Definition: cuy.py:362
int k[5][pyjets_maxn]
A lookup table to speed up constraint evaluation using Fourvec_Constrainer.
Definition: Pair_Table.h:100
string const
Definition: compareJSON.py:14
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream...
Pair_Table(const std::vector< Constraint > &cv, const Fourvec_Event &ev)
Constructor, give it the event and the list of constraints.
Definition: Pair_Table.cc:49
A lookup table to speed up constraint evaluation.
Represent a pair of objects in Pair_Table.
Definition: Objpair.h:63
Represent an event for kinematic fitting as a collection of four-momenta.