CMS 3D CMS Logo

List of all members | Public Member Functions
Phase2EndcapRingBuilder Class Reference

#include <Phase2EndcapRingBuilder.h>

Public Member Functions

Phase2EndcapRingbuild (const GeometricDet *aPhase2EndcapRing, const TrackerGeometry *theGeomDetGeometry, const bool useBrothers=true) __attribute__((cold))
 
 Phase2EndcapRingBuilder ()
 

Detailed Description

A concrete builder for Phase2EndcapRing

Definition at line 14 of file Phase2EndcapRingBuilder.h.

Constructor & Destructor Documentation

Phase2EndcapRingBuilder::Phase2EndcapRingBuilder ( )
inline

Definition at line 16 of file Phase2EndcapRingBuilder.h.

References build().

16 {};

Member Function Documentation

Phase2EndcapRing * Phase2EndcapRingBuilder::build ( const GeometricDet aPhase2EndcapRing,
const TrackerGeometry theGeomDetGeometry,
const bool  useBrothers = true 
)

Definition at line 7 of file Phase2EndcapRingBuilder.cc.

References GeometricDet::components(), TrackerGeometry::idToDet(), LogDebug, and LogTrace.

Referenced by Phase2EndcapLayerBuilder::build(), Phase2OTBarrelLayerBuilder::build(), and Phase2EndcapRingBuilder().

9  {
10  vector<const GeometricDet*> allGeometricDets = aPhase2EndcapRing->components();
11  vector<const GeometricDet*> compGeometricDets;
12  LogDebug("TkDetLayers") << "Phase2EndcapRingBuilder with #Modules: " << allGeometricDets.size() << std::endl;
13 
14  vector<const GeomDet*> frontGeomDets;
15  vector<const GeomDet*> backGeomDets;
16  double meanZ = 0;
17 
18  if (!useBrothers) {
19  //---- to evaluate meanZ
20  for (vector<const GeometricDet*>::const_iterator compGeometricDets = allGeometricDets.begin();
21  compGeometricDets != allGeometricDets.end();
22  compGeometricDets++) {
23  LogTrace("TkDetLayers") << " compGeometricDets->positionBounds().perp() "
24  << (*compGeometricDets)->positionBounds().z() << std::endl;
25  meanZ = meanZ + (*compGeometricDets)->positionBounds().z();
26  }
27  meanZ = meanZ / allGeometricDets.size();
28  LogDebug("TkDetLayers") << " meanZ " << meanZ << std::endl;
29 
30  for (vector<const GeometricDet*>::const_iterator compGeometricDets = allGeometricDets.begin();
31  compGeometricDets != allGeometricDets.end();
32  compGeometricDets++) {
33  const GeomDet* theGeomDet = theGeomDetGeometry->idToDet((*compGeometricDets)->geographicalID());
34 
35  if (fabs((*compGeometricDets)->positionBounds().z()) < fabs(meanZ))
36  frontGeomDets.push_back(theGeomDet);
37 
38  if (fabs((*compGeometricDets)->positionBounds().z()) > fabs(meanZ))
39  backGeomDets.push_back(theGeomDet);
40 
41  if (fabs((*compGeometricDets)->positionBounds().z()) == fabs(meanZ))
42  throw DetLayerException("Not possible to assiciate this GeometricDet in front or back");
43  }
44 
45  LogDebug("TkDetLayers") << "frontGeomDets.size(): " << frontGeomDets.size();
46  LogDebug("TkDetLayers") << "backGeomDets.size(): " << backGeomDets.size();
47 
48  return new Phase2EndcapRing(frontGeomDets, backGeomDets);
49 
50  } else {
51  vector<const GeomDet*> frontGeomDetBrothers;
52  vector<const GeomDet*> backGeomDetBrothers;
53  vector<const GeometricDet*> compGeometricDets;
54 
55  //---- to evaluate meanZ
56  double meanZ = 0;
57  double meanZBrothers = 0;
58  for (vector<const GeometricDet*>::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end();
59  it++) {
60  compGeometricDets = (*it)->components();
61  if (compGeometricDets.size() != 2) {
62  throw DetLayerException("Phase2OTEndcapRing is considered as a stack but does not have two components");
63  } else {
64  LogTrace("TkDetLayers") << " compGeometricDets[0]->positionBounds().perp() "
65  << compGeometricDets[0]->positionBounds().z() << std::endl;
66  LogTrace("TkDetLayers") << " compGeometricDets[1]->positionBounds().perp() "
67  << compGeometricDets[1]->positionBounds().z() << std::endl;
68  meanZ = meanZ + compGeometricDets[0]->positionBounds().z();
69  meanZBrothers = meanZBrothers + compGeometricDets[1]->positionBounds().z();
70  }
71  }
72  meanZ = meanZ / allGeometricDets.size();
73  meanZBrothers = meanZBrothers / allGeometricDets.size();
74  LogDebug("TkDetLayers") << " meanZ Lower " << meanZ << std::endl;
75  LogDebug("TkDetLayers") << " meanZ Upper " << meanZBrothers << std::endl;
76 
77  for (vector<const GeometricDet*>::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end();
78  it++) {
79  compGeometricDets = (*it)->components();
80  const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalID());
81 
82  if (fabs(compGeometricDets[0]->positionBounds().z()) < fabs(meanZ))
83  frontGeomDets.push_back(theGeomDet);
84 
85  if (fabs(compGeometricDets[0]->positionBounds().z()) > fabs(meanZ))
86  backGeomDets.push_back(theGeomDet);
87 
88  const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalID());
89 
90  if (fabs(compGeometricDets[1]->positionBounds().z()) < fabs(meanZBrothers))
91  frontGeomDetBrothers.push_back(theGeomDetBrother);
92 
93  if (fabs(compGeometricDets[1]->positionBounds().z()) > fabs(meanZBrothers))
94  backGeomDetBrothers.push_back(theGeomDetBrother);
95 
96  if (fabs(compGeometricDets[0]->positionBounds().z()) == fabs(meanZ) ||
97  fabs(compGeometricDets[1]->positionBounds().z()) == fabs(meanZBrothers))
98  throw DetLayerException("Not possible to assiciate components of this GeometricDet in front or back");
99  }
100 
101  LogDebug("TkDetLayers") << "frontGeomDets.size(): " << frontGeomDets.size();
102  LogDebug("TkDetLayers") << "backGeomDets.size(): " << backGeomDets.size();
103  LogDebug("TkDetLayers") << "frontGeomDetsBro.size(): " << frontGeomDetBrothers.size();
104  LogDebug("TkDetLayers") << "backGeomDetsBro.size(): " << backGeomDetBrothers.size();
105 
106  return new Phase2EndcapRing(frontGeomDets, backGeomDets, frontGeomDetBrothers, backGeomDetBrothers);
107  }
108  return new Phase2EndcapRing(frontGeomDets, backGeomDets);
109 }
#define LogDebug(id)
Common base class.
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:139
#define LogTrace(id)
const TrackerGeomDet * idToDet(DetId) const override