CMS 3D CMS Logo

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

◆ addSameLevel()

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

Definition at line 47 of file DetGroupMerger.cc.

References newFWLiteAna::found, LogDebug, and mps_fire::result.

Referenced by CompatibleDetToGroupAdder::add(), Phase2EndcapLayerDoubleDisk::groupedCompatibleDetsV(), Phase2EndcapSingleRing::groupedCompatibleDetsV(), and tkDetUtil::groupedCompatibleDetsV().

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

◆ doubleIndexSize()

void DetGroupMerger::doubleIndexSize ( std::vector< DetGroup > &  vec)
static

Definition at line 76 of file DetGroupMerger.cc.

References mps_fire::i.

76  {
77  int indSize = vec.front().indexSize();
78  for (vector<DetGroup>::iterator i = vec.begin(); i != vec.end(); i++) {
79  i->setIndexSize(2 * indSize);
80  }
81 }

◆ incrementAndDoubleSize()

void DetGroupMerger::incrementAndDoubleSize ( std::vector< DetGroup > &  vec)
static

Definition at line 83 of file DetGroupMerger.cc.

References mps_fire::i.

83  {
84  int indSize = vec.front().indexSize();
85  for (vector<DetGroup>::iterator i = vec.begin(); i != vec.end(); i++) {
86  i->incrementIndex(indSize);
87  }
88 }

◆ mergeTwoLevels()

void DetGroupMerger::mergeTwoLevels ( std::vector< DetGroup > &&  one,
std::vector< DetGroup > &&  two,
std::vector< DetGroup > &  result 
)
static

Definition at line 31 of file DetGroupMerger.cc.

References eostools::move(), mps_fire::result, and SiPixelPI::two.

31  {
32  result.reserve(one.size() + two.size());
33 
34  int indSize1 = one.front().indexSize();
35  int indSize2 = two.front().indexSize();
36 
37  for (auto&& dg : one) {
38  result.push_back(std::move(dg));
39  result.back().setIndexSize(indSize1 + indSize2);
40  }
41  for (auto&& dg : two) {
42  result.push_back(std::move(dg));
43  result.back().incrementIndex(indSize1);
44  }
45 }
def move(src, dest)
Definition: eostools.py:511

◆ orderAndMergeTwoLevels()

void DetGroupMerger::orderAndMergeTwoLevels ( std::vector< DetGroup > &&  one,
std::vector< DetGroup > &&  two,
std::vector< DetGroup > &  result,
int  firstIndex,
int  firstCrossed 
)
static

Definition at line 6 of file DetGroupMerger.cc.

References JetHT_cfg::firstIndex, eostools::move(), mps_fire::result, and SiPixelPI::two.

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

7  {
8  if (one.empty() && two.empty())
9  return;
10 
11  if (one.empty()) {
12  result = std::move(two);
13  if (firstIndex == firstCrossed)
15  else
17  } else if (two.empty()) {
18  result = std::move(one);
19  if (firstIndex == firstCrossed)
21  else
23  } else { // both are not empty
24  if (firstIndex == firstCrossed)
26  else
28  }
29 }
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)
dictionary firstIndex
Definition: JetHT_cfg.py:140
def move(src, dest)
Definition: eostools.py:511