CMS 3D CMS Logo

Pair_Table.cc
Go to the documentation of this file.
1 //
2 //
3 // File: src/Pair_Table.cc
4 // Purpose: Helper for Fourvec_Constrainer.
5 // Created: Jul, 2000, sss, based on run 1 mass analysis code.
6 //
7 // CMSSW File : src/Pair_Table.cc
8 // Original Author : Scott Stuart Snyder <snyder@bnl.gov> for D0
9 // Imported to CMSSW by Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
10 //
11 
36 #include <ostream>
37 
38 using std::ostream;
39 using std::vector;
40 
41 namespace hitfit {
42 
43  Pair_Table::Pair_Table(const std::vector<Constraint>& cv, const Fourvec_Event& ev)
44  //
45  // Purpose: Constructor.
46  //
47  // Inputs:
48  // cv - The list of constraints for the problem.
49  // ev - The event.
50  //
51  {
52  // The number of objects in the event, including any neutrino.
53  int nobjs = ev.nobjs_all();
54 
55  // Number of constraints.
56  int nc = cv.size();
57 
58  // Loop over pairs of objects.
59  for (int i = 0; i < nobjs - 1; i++)
60  for (int j = i + 1; j < nobjs; j++) {
61  // Make an Objpair instance out of it.
62  Objpair p(i, j, nc);
63 
64  // Loop over constraints.
65  bool wanted = false;
66  for (int k = 0; k < nc; k++) {
67  int val = cv[k].has_labels(ev.obj(i).label, ev.obj(j).label);
68  if (val) {
69  // This pair is used by this constraint. Record it.
70  p.has_constraint(k, val);
71  wanted = true;
72  }
73  }
74 
75  // Was this pair used by any constraint?
76  if (wanted)
77  _pairs.push_back(p);
78  }
79  }
80 
82  //
83  // Purpose: Return the number of pairs in the table.
84  //
85  // Returns:
86  // The number of pairs in the table.
87  //
88  {
89  return _pairs.size();
90  }
91 
93  //
94  // Purpose: Return one pair from the table.
95  //
96  // Inputs:
97  // pairno - The number of the pair (0-based).
98  //
99  // Returns:
100  // Pair PAIRNO.
101  //
102  {
103  assert(pairno < _pairs.size());
104  return _pairs[pairno];
105  }
106 
115  std::ostream& operator<<(std::ostream& s, const Pair_Table& p)
116  //
117  // Purpose: Print the object to S.
118  //
119  // Inputs:
120  // s - The stream to which to write.
121  // p - The object to write.
122  //
123  // Returns:
124  // The stream S.
125  //
126  {
127  for (int i = 0; i < p.npairs(); i++)
128  s << " " << p.get_pair(i) << "\n";
129  return s;
130  }
131 
132 } // namespace hitfit
mps_fire.i
i
Definition: mps_fire.py:428
hitfit
Definition: Base_Constrainer.h:43
Fourvec_Event.h
Represent an event for kinematic fitting as a collection of four-momenta.
cuy.cv
cv
Definition: cuy.py:364
Pair_Table.h
A lookup table to speed up constraint evaluation.
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
cms::cuda::assert
assert(be >=bs)
watchdog.const
const
Definition: watchdog.py:83
hitfit::Fourvec_Event
Represent an event for kinematic fitting as a collection of four-momenta. Each object is represented ...
Definition: Fourvec_Event.h:193
hitfit::Pair_Table::get_pair
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:92
alignCSCRings.s
s
Definition: alignCSCRings.py:92
hitfit::Pair_Table::npairs
int npairs() const
Return the number of pairs in the table.
Definition: Pair_Table.cc:81
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
dqmdumpme.k
k
Definition: dqmdumpme.py:60
hitfit::operator<<
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream.
Definition: Constraint_Intermed.cc:268
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
hitfit::Objpair
Represent a pair of objects in Pair_Table.
Definition: Objpair.h:58
hitfit::Pair_Table::_pairs
std::vector< Objpair > _pairs
Definition: Pair_Table.h:131
hitfit::Pair_Table::Pair_Table
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:43
heppy_batch.val
val
Definition: heppy_batch.py:351
hitfit::Pair_Table
A lookup table to speed up constraint evaluation using Fourvec_Constrainer.
Definition: Pair_Table.h:95
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66