CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Namespaces | Functions | Variables
HardwareSortingMethods.cc File Reference
#include <iostream>
#include "L1Trigger/L1TCalorimeter/interface/HardwareSortingMethods.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Namespaces

 l1t
 map containing the conditions
 

Functions

std::vector< l1t::Jetarray_from_row_sorted_matrix (std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int n_keep)
 
std::vector< std::vector
< l1t::Jet > > 
extract_sub_jet_energy_position_matrix (std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int row_i, unsigned int row_f, unsigned int col_i, unsigned int col_f)
 
std::vector< std::vector
< l1t::Jet > > 
presort (std::vector< std::vector< l1t::Jet > > energies, int rows, int cols)
 
void print2DVector (std::vector< std::vector< l1t::Jet > > myVector)
 
std::vector< l1t::Jetsort_array (std::vector< l1t::Jet > inputArray)
 
std::vector< std::vector
< l1t::Jet > > 
sort_by_row_in_groups (std::vector< std::vector< l1t::Jet > > input_matrix, int group_size)
 
std::vector< std::vector
< l1t::Jet > > 
sort_matrix_rows (std::vector< std::vector< l1t::Jet > > input_matrix)
 
void l1t::SortJets (std::vector< l1t::Jet > *input, std::vector< l1t::Jet > *output)
 
std::vector< std::vector
< l1t::Jet > > 
super_sort_matrix_rows (std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int group_size, unsigned int n_keep)
 

Variables

int fw_to_gt_phi_map [] = {4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5}
 
int gt_to_fw_phi_map [] = {4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5}
 
const bool verbose = false
 

Function Documentation

std::vector<l1t::Jet> array_from_row_sorted_matrix ( std::vector< std::vector< l1t::Jet > >  input_matrix,
unsigned int  n_keep 
)

Definition at line 133 of file HardwareSortingMethods.cc.

References i, j, gen::k, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), and findQualityFiles::size.

Referenced by super_sort_matrix_rows().

133  {
134  std::vector<l1t::Jet> output_array (n_keep*(n_keep+1)/2);
135  unsigned int max_row = n_keep-1;
136  unsigned int max_col = n_keep-1;
137 
138  //compute size
139  if(input_matrix.size() < n_keep) max_row = input_matrix.size()-1;
140  if(input_matrix[0].size() < n_keep) max_col = input_matrix[0].size()-1;
141 
142  unsigned int array_position = 0;
143  for(unsigned int i=0; i<=max_row; i++){
144  for(unsigned int j=0; j<=max_col-i; j++){
145  //cout << input_matrix[i][j].hwPt() << endl;
146  output_array[array_position] = input_matrix[i][j];
147  array_position++;
148  }//j
149  }//i
150 
151  //fill rest with zeros
152  l1t::Jet dummyJet;
153  dummyJet.setHwPt(0);
154  dummyJet.setHwPhi(99);
155  dummyJet.setHwEta(99);
156  for(unsigned int k=array_position; k<output_array.size(); k++){
157  output_array[k]=dummyJet;
158  }
159 
160  //printVector(output_array);
161  return output_array;
162 }
int i
Definition: DBlmapReader.cc:9
Definition: Jet.h:13
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
void setHwPt(int pt)
Definition: L1Candidate.cc:44
void setHwEta(int eta)
Definition: L1Candidate.cc:49
tuple size
Write out results.
std::vector<std::vector<l1t::Jet> > extract_sub_jet_energy_position_matrix ( std::vector< std::vector< l1t::Jet > >  input_matrix,
unsigned int  row_i,
unsigned int  row_f,
unsigned int  col_i,
unsigned int  col_f 
)

Definition at line 86 of file HardwareSortingMethods.cc.

References i, j, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), and l1t::L1Candidate::setHwPt().

Referenced by sort_by_row_in_groups(), and super_sort_matrix_rows().

86  {
87  std::vector<std::vector<l1t::Jet> > output_matrix(row_f-row_i+1,std::vector<l1t::Jet>(col_f-col_i+1));
88  l1t::Jet dummyJet;
89  dummyJet.setHwPt(0);
90  dummyJet.setHwPhi(99);
91  dummyJet.setHwEta(99);
92 
93  for(unsigned int i=0; i<row_f-row_i+1; i++){
94  for(unsigned int j=0; j<col_f-col_i+1; j++){
95  if(row_i+i > input_matrix.size()-1) output_matrix[i][j] = dummyJet;
96  else output_matrix[i][j] = input_matrix[row_i+i][col_i+j];
97  }//j
98  }//i
99  return output_matrix;
100 }
int i
Definition: DBlmapReader.cc:9
Definition: Jet.h:13
int j
Definition: DBlmapReader.cc:9
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
void setHwPt(int pt)
Definition: L1Candidate.cc:44
void setHwEta(int eta)
Definition: L1Candidate.cc:49
std::vector<std::vector<l1t::Jet> > presort ( std::vector< std::vector< l1t::Jet > >  energies,
int  rows,
int  cols 
)

Definition at line 45 of file HardwareSortingMethods.cc.

References trackerHits::c, cuy::col, print2DVector(), alignCSCRings::r, tablePrinter::rows, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), l1t::L1Candidate::setHwPt(), and sort_array().

Referenced by l1t::SortJets().

45  {
46 
47  int row_block_length = energies.size() / cols;
48  if(energies.size() % cols != 0) row_block_length++;
49 
50  l1t::Jet dummyJet;
51  dummyJet.setHwPt(0);
52  dummyJet.setHwPhi(99);
53  dummyJet.setHwEta(99);
54  std::vector<std::vector<l1t::Jet> > sorted_energies (rows, std::vector<l1t::Jet>(cols, dummyJet));
55  if(verbose) print2DVector( sorted_energies );
56 
57  unsigned int row=0, col=0;
58  std::vector<l1t::Jet> energy_feeder (cols, dummyJet);
59  std::vector<l1t::Jet> energy_result (cols, dummyJet);
60  for(int r=0; r<rows; r++){
61  for(int c=0; c<cols; c++){
62 
63  row = (r % row_block_length)*cols+c;//row goes up to 19 and we pad with zeros
64 
65  if(row < energies.size()){
66  energy_feeder[c] = energies[row][col];
67  }
68  else{
69  energy_feeder[c] = dummyJet;
70  }
71 
72  }//c
73 
74  energy_result = sort_array(energy_feeder);//sort!
75 
76  sorted_energies[r] = energy_result;
77 
78  if(r % row_block_length == row_block_length - 1) col++;
79 
80  }//r
81  if(verbose) print2DVector( sorted_energies );
82 
83  return sorted_energies;
84 }
Definition: Jet.h:13
void print2DVector(std::vector< std::vector< l1t::Jet > > myVector)
std::vector< l1t::Jet > sort_array(std::vector< l1t::Jet > inputArray)
void setHwPhi(int phi)
Definition: L1Candidate.cc:54
void setHwPt(int pt)
Definition: L1Candidate.cc:44
void setHwEta(int eta)
Definition: L1Candidate.cc:49
int col
Definition: cuy.py:1008
void print2DVector ( std::vector< std::vector< l1t::Jet > >  myVector)

Definition at line 18 of file HardwareSortingMethods.cc.

References trackerHits::c, gather_cfg::cout, and alignCSCRings::r.

Referenced by presort(), sort_by_row_in_groups(), and super_sort_matrix_rows().

18  {
19  int nrows = myVector.size();
20  int ncols = myVector[0].size();
21  std::cout << std::endl;
22  std::cout << "rows: " << nrows << std::endl;
23  std::cout << "cols: " << ncols << std::endl;
24 
25  for(int r=0; r<nrows; r++){
26  for(int c=0; c<ncols; c++){
27  std::cout << std::setw(5) << myVector[r][c].hwPt() << ' ';
28  }
29  std::cout << std::endl;
30  }
31 }
tuple cout
Definition: gather_cfg.py:121
std::vector<l1t::Jet> sort_array ( std::vector< l1t::Jet inputArray)

Definition at line 33 of file HardwareSortingMethods.cc.

References i, and j.

Referenced by presort(), and super_sort_matrix_rows().

33  {
34  std::vector<l1t::Jet> outputArray(inputArray.size());
35  for(unsigned int i=0; i<inputArray.size(); i++){
36  int rank=0;
37  for(unsigned int j=0; j<inputArray.size(); j++){
38  if( (inputArray[i].hwPt() > inputArray[j].hwPt()) || ( (inputArray[i].hwPt() == inputArray[j].hwPt()) && i<j) ) rank++;
39  }//j
40  outputArray[outputArray.size()-1-rank] = inputArray[i];
41  }//i
42  return outputArray;
43 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector<std::vector<l1t::Jet> > sort_by_row_in_groups ( std::vector< std::vector< l1t::Jet > >  input_matrix,
int  group_size 
)

Definition at line 116 of file HardwareSortingMethods.cc.

References extract_sub_jet_energy_position_matrix(), g, i, print2DVector(), findQualityFiles::size, and sort_matrix_rows().

Referenced by l1t::SortJets().

116  {
117  int n_groups = input_matrix.size()/group_size + (1 - input_matrix.size()/group_size*group_size/input_matrix.size()); //constants must make this an integer
118  std::vector<std::vector<l1t::Jet> > output_matrix(input_matrix.size()+(input_matrix.size() % group_size), std::vector<l1t::Jet> (input_matrix[0].size()));
119 
120  for(int g=0; g<n_groups; g++){
121  std::vector<std::vector<l1t::Jet> > small_output_matrix = extract_sub_jet_energy_position_matrix(input_matrix, g*group_size, (g+1)*group_size-1, 0, input_matrix[0].size()-1 );
122  small_output_matrix = sort_matrix_rows(small_output_matrix);
123 
124  for(unsigned int i=0; i<small_output_matrix.size(); i++){
125  output_matrix[g*group_size+i]=small_output_matrix[i];
126  }
127  }
128 
129  if(verbose) print2DVector( output_matrix );
130  return output_matrix;
131 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< l1t::Jet > > extract_sub_jet_energy_position_matrix(std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int row_i, unsigned int row_f, unsigned int col_i, unsigned int col_f)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void print2DVector(std::vector< std::vector< l1t::Jet > > myVector)
std::vector< std::vector< l1t::Jet > > sort_matrix_rows(std::vector< std::vector< l1t::Jet > > input_matrix)
tuple size
Write out results.
std::vector<std::vector<l1t::Jet> > sort_matrix_rows ( std::vector< std::vector< l1t::Jet > >  input_matrix)

Definition at line 102 of file HardwareSortingMethods.cc.

References i, and j.

Referenced by sort_by_row_in_groups().

102  {
103  std::vector<std::vector<l1t::Jet> > output_matrix( input_matrix.size(), std::vector<l1t::Jet> (input_matrix[0].size()));
104 
105  for(unsigned int i=0; i<input_matrix.size(); i++){
106  int rank=0;
107  for (unsigned int j=0; j<input_matrix.size(); j++){
108  if( (input_matrix[i][0].hwPt() > input_matrix[j][0].hwPt()) || ((input_matrix[i][0].hwPt() == input_matrix[j][0].hwPt()) && i<j)) rank++;
109  }//j
110  output_matrix[input_matrix.size()-1-rank] = input_matrix[i];
111  }//i
112 
113  return output_matrix;
114 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
std::vector<std::vector<l1t::Jet> > super_sort_matrix_rows ( std::vector< std::vector< l1t::Jet > >  input_matrix,
unsigned int  group_size,
unsigned int  n_keep 
)

Definition at line 164 of file HardwareSortingMethods.cc.

References array_from_row_sorted_matrix(), extract_sub_jet_energy_position_matrix(), g, i, print2DVector(), findQualityFiles::size, and sort_array().

Referenced by l1t::SortJets().

164  {
165  unsigned int n_groups = input_matrix.size()/group_size + (1 - input_matrix.size()/group_size*group_size/input_matrix.size()); //constants must make this an integer
166  std::vector<std::vector<l1t::Jet> > output_matrix(n_groups, std::vector<l1t::Jet>(n_keep));
167 
168  for(unsigned int g=0; g<n_groups; g++){
169  std::vector<std::vector<l1t::Jet> > small_output_matrix = extract_sub_jet_energy_position_matrix(input_matrix, g*group_size, (g+1)*group_size-1, 0, input_matrix[0].size()-1 );
170  std::vector<l1t::Jet> unsorted_array = array_from_row_sorted_matrix(small_output_matrix, n_keep);
171  std::vector<l1t::Jet> unsorted_array_without_largest (unsorted_array.size()-1);//we know first element is the biggest
172  for(unsigned int i=0; i<unsorted_array.size()-1; i++){
173  unsorted_array_without_largest[i] = unsorted_array[1+i];
174  }
175  std::vector<l1t::Jet> sorted_array_without_largest = sort_array(unsorted_array_without_largest);
176 
177  std::vector<l1t::Jet> sorted_array (n_keep);
178  sorted_array[0] = unsorted_array[0];
179  for(unsigned int i=0; i<n_keep-1; i++){
180  sorted_array[1+i]=sorted_array_without_largest[i];
181  }
182 
183  output_matrix[g] = sorted_array;
184  }//g
185 
186  if(verbose) print2DVector(output_matrix);
187  return output_matrix;
188 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< l1t::Jet > > extract_sub_jet_energy_position_matrix(std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int row_i, unsigned int row_f, unsigned int col_i, unsigned int col_f)
std::vector< l1t::Jet > array_from_row_sorted_matrix(std::vector< std::vector< l1t::Jet > > input_matrix, unsigned int n_keep)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void print2DVector(std::vector< std::vector< l1t::Jet > > myVector)
std::vector< l1t::Jet > sort_array(std::vector< l1t::Jet > inputArray)
tuple size
Write out results.

Variable Documentation

int fw_to_gt_phi_map[] = {4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5}

Definition at line 15 of file HardwareSortingMethods.cc.

Referenced by l1t::SortJets().

int gt_to_fw_phi_map[] = {4, 3, 2, 1, 0, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5}

Definition at line 16 of file HardwareSortingMethods.cc.

Referenced by l1t::SortJets().

const bool verbose = false

Definition at line 13 of file HardwareSortingMethods.cc.