CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions
DetGroupMerger Class Reference

#include <DetGroupMerger.h>

Static Public Member Functions

static void addSameLevel (std::vector< DetGroup > &&gvec, std::vector< DetGroup > &result)
 
static void doubleIndexSize (std::vector< DetGroup > &vec)
 
static void incrementAndDoubleSize (std::vector< DetGroup > &vec)
 
static void mergeTwoLevels (std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result)
 
static void orderAndMergeTwoLevels (std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result, int firstIndex, int firstCrossed)
 

Detailed Description

Definition at line 7 of file DetGroupMerger.h.

Member Function Documentation

void DetGroupMerger::addSameLevel ( std::vector< DetGroup > &&  gvec,
std::vector< DetGroup > &  result 
)
static

Definition at line 52 of file DetGroupMerger.cc.

References newFWLiteAna::found, cmsHarvester::index, ires, and LogDebug.

Referenced by CompatibleDetToGroupAdder::add(), and Phase2OTECRingedLayer::groupedCompatibleDetsV().

52  {
53  for (auto && ig : gvec) {
54  int gSize = ig.indexSize();
55  int index = ig.index(); // at which level it should be inserted
56  bool found = false;
57  for (vector<DetGroup>::iterator ires=result.begin(); ires!=result.end(); ires++) {
58  int resSize = ires->indexSize();
59  if (gSize != resSize) {
60  LogDebug("TkDetLayers") << "DetGroupMerger::addSameLevel called with groups of different index sizes";
61  // throw something appropriate...or handle it properly (may happen in petals?)
62  }
63 
64  int resIndex = ires->index();
65  if (index == resIndex) {
66  ires->insert(ires->end(), ig.begin(), ig.end()); // insert in group with same index
67  found = true;
68  break;
69  }
70  else if (index < resIndex) {
71  // result has no group at index level yet
72  result.insert( ires, ig); // insert a new group, invalidates the iterator ires
73  found = true;
74  break;
75  }
76  } // end of loop over result groups
77  if (!found) result.insert( result.end(), ig); // in case the ig index is bigger than any in result
78  }
79 }
#define LogDebug(id)
int ires[2]
tuple result
Definition: query.py:137
void DetGroupMerger::doubleIndexSize ( std::vector< DetGroup > &  vec)
static

Definition at line 82 of file DetGroupMerger.cc.

References i.

82  {
83  int indSize = vec.front().indexSize();
84  for (vector<DetGroup>::iterator i=vec.begin(); i!=vec.end(); i++) {
85  i->setIndexSize( 2*indSize);
86  }
87 }
int i
Definition: DBlmapReader.cc:9
void DetGroupMerger::incrementAndDoubleSize ( std::vector< DetGroup > &  vec)
static

Definition at line 90 of file DetGroupMerger.cc.

References i.

90  {
91  int indSize = vec.front().indexSize();
92  for (vector<DetGroup>::iterator i=vec.begin(); i!=vec.end(); i++) {
93  i->incrementIndex( indSize);
94  }
95 }
int i
Definition: DBlmapReader.cc:9
void DetGroupMerger::mergeTwoLevels ( std::vector< DetGroup > &&  one,
std::vector< DetGroup > &&  two,
std::vector< DetGroup > &  result 
)
static

Definition at line 34 of file DetGroupMerger.cc.

References eostools::move().

34  {
35 
36  result.reserve( one.size() + two.size());
37 
38  int indSize1 = one.front().indexSize();
39  int indSize2 = two.front().indexSize();
40 
41  for (auto && dg : one) {
42  result.push_back(std::move(dg));
43  result.back().setIndexSize(indSize1+indSize2);
44  }
45  for (auto && dg : two) {
46  result.push_back(std::move(dg));
47  result.back().incrementIndex(indSize1);
48  }
49 }
tuple result
Definition: query.py:137
def move
Definition: eostools.py:508
void DetGroupMerger::orderAndMergeTwoLevels ( std::vector< DetGroup > &&  one,
std::vector< DetGroup > &&  two,
std::vector< DetGroup > &  result,
int  firstIndex,
int  firstCrossed 
)
static

Definition at line 8 of file DetGroupMerger.cc.

References eostools::move().

Referenced by PixelForwardLayer::groupedCompatibleDetsV(), PixelForwardLayerPhase1::groupedCompatibleDetsV(), TECLayer::groupedCompatibleDetsV(), CompositeTECWedge::groupedCompatibleDetsV(), Phase2OTECRingedLayer::groupedCompatibleDetsV(), TIDRing::groupedCompatibleDetsV(), TIBRing::groupedCompatibleDetsV(), TBLayer::groupedCompatibleDetsV(), Phase2OTECRing::groupedCompatibleDetsV(), PixelBlade::groupedCompatibleDetsV(), TOBRod::groupedCompatibleDetsV(), Phase1PixelBlade::groupedCompatibleDetsV(), Phase2OTBarrelRod::groupedCompatibleDetsV(), and CompositeTECPetal::groupedCompatibleDetsV().

12  {
13  if (one.empty() && two.empty()) return;
14 
15 
16  if (one.empty()) {
17  result = std::move(two);
18  if (firstIndex == firstCrossed) incrementAndDoubleSize(result);
19  else doubleIndexSize(result);
20  }
21  else if (two.empty()) {
22  result = std::move(one);
23  if (firstIndex == firstCrossed) doubleIndexSize(result);
25  }
26  else { // both are not empty
27  if (firstIndex == firstCrossed) mergeTwoLevels( std::move(one), std::move(two), result);
28  else mergeTwoLevels( std::move(two), std::move(one), result);
29  }
30 }
static void incrementAndDoubleSize(std::vector< DetGroup > &vec)
static void mergeTwoLevels(std::vector< DetGroup > &&one, std::vector< DetGroup > &&two, std::vector< DetGroup > &result)
static void doubleIndexSize(std::vector< DetGroup > &vec)
tuple result
Definition: query.py:137
def move
Definition: eostools.py:508