CMS 3D CMS Logo

TOBLayerBuilder.cc
Go to the documentation of this file.
1 #include "TOBLayerBuilder.h"
2 
4 
5 #include "TOBRodBuilder.h"
6 
7 using namespace edm;
8 using namespace std;
9 
10 TOBLayer* TOBLayerBuilder::build(const GeometricDet* aTOBLayer, const TrackerGeometry* theGeomDetGeometry) {
11  vector<const GeometricDet*> theGeometricDetRods = aTOBLayer->components();
12  vector<const GeometricDet*> negativeZrods;
13  vector<const GeometricDet*> positiveZrods;
14 
15  for (vector<const GeometricDet*>::const_iterator it = theGeometricDetRods.begin(); it != theGeometricDetRods.end();
16  it++) {
17  if ((*it)->positionBounds().z() < 0)
18  negativeZrods.push_back(*it);
19  if ((*it)->positionBounds().z() >= 0)
20  positiveZrods.push_back(*it);
21  }
22 
23  TOBRodBuilder myTOBRodBuilder;
24 
25  vector<const TOBRod*> theInnerRods;
26  vector<const TOBRod*> theOuterRods;
27 
28  //LogDebug("TkDetLayers") << "positiveZrods[0]->positionBounds().perp(): "
29  // << positiveZrods[0]->positionBounds().perp() ;
30  //LogDebug("TkDetLayers") << "positiveZrods[1]->positionBounds().perp(): "
31  // << positiveZrods[1]->positionBounds().perp() ;
32 
33  double positiveMeanR = 0;
34  if (!positiveZrods.empty()) {
35  for (unsigned int index = 0; index != positiveZrods.size(); index++) {
36  positiveMeanR += positiveZrods[index]->positionBounds().perp();
37  }
38  positiveMeanR = positiveMeanR / positiveZrods.size();
39  }
40 
41  double negativeMeanR = 0;
42  if (!negativeZrods.empty()) {
43  for (unsigned int index = 0; index != negativeZrods.size(); index++) {
44  negativeMeanR += negativeZrods[index]->positionBounds().perp();
45  }
46  negativeMeanR = negativeMeanR / negativeZrods.size();
47  }
48 
49  if (!positiveZrods.empty() && !negativeZrods.empty()) {
50  for (unsigned int index = 0; index != positiveZrods.size(); index++) {
51  if (positiveZrods[index]->positionBounds().phi() != negativeZrods[index]->positionBounds().phi()) {
52  edm::LogError("TkDetLayers") << "ERROR:rods don't have the same phi. exit!";
53  break;
54  }
55 
56  if (positiveZrods[index]->positionBounds().perp() < positiveMeanR)
57  theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index], positiveZrods[index], theGeomDetGeometry));
58  if (positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
59  theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index], positiveZrods[index], theGeomDetGeometry));
60  }
61  } else {
62  if (!positiveZrods.empty()) {
63  for (unsigned int index = 0; index != positiveZrods.size(); index++) {
64  if (positiveZrods[index]->positionBounds().perp() < positiveMeanR)
65  theInnerRods.push_back(myTOBRodBuilder.build(nullptr, positiveZrods[index], theGeomDetGeometry));
66  if (positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
67  theOuterRods.push_back(myTOBRodBuilder.build(nullptr, positiveZrods[index], theGeomDetGeometry));
68  }
69  }
70  if (!negativeZrods.empty()) {
71  for (unsigned int index = 0; index != negativeZrods.size(); index++) {
72  if (negativeZrods[index]->positionBounds().perp() < negativeMeanR)
73  theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index], nullptr, theGeomDetGeometry));
74  if (negativeZrods[index]->positionBounds().perp() >= negativeMeanR)
75  theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index], nullptr, theGeomDetGeometry));
76  }
77  }
78  }
79 
80  //LogDebug("TkDetLayers") << "theInnerRods.size(): " << theInnerRods.size() ;
81  //LogDebug("TkDetLayers") << "theOuterRods.size(): " << theOuterRods.size() ;
82 
83  return new TOBLayer(theInnerRods, theOuterRods);
84 }
TBPLayer TOBLayer
Definition: TOBLayer.h:11
TOBLayer * build(const GeometricDet *aTOBLayer, const TrackerGeometry *theGeomDetGeometry) __attribute__((cold))
TOBRod * build(const GeometricDet *negTOBRod, const GeometricDet *posTOBRod, const TrackerGeometry *theGeomDetGeometry) __attribute__((cold))
Definition: TOBRodBuilder.cc:7
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:139
T perp() const
Magnitude of transverse component.
HLT enums.