CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 15 of file Phase2EndcapRingBuilder.h.

Constructor & Destructor Documentation

Phase2EndcapRingBuilder::Phase2EndcapRingBuilder ( )
inline

Definition at line 17 of file Phase2EndcapRingBuilder.h.

17 {};

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