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::Phase2EndcapRingBuilder ( )
inline

Definition at line 16 of file Phase2EndcapRingBuilder.h.

16 {};

Member Function Documentation

◆ build()

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

Definition at line 8 of file Phase2EndcapRingBuilder.cc.

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

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

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