10 vector<const GeometricDet*> allGeometricDets = aPhase2EndcapRing->
components();
11 vector<const GeometricDet*> compGeometricDets;
12 LogDebug(
"TkDetLayers") <<
"Phase2EndcapRingBuilder with #Modules: " << allGeometricDets.size() << std::endl;
14 vector<const GeomDet*> frontGeomDets;
15 vector<const GeomDet*> backGeomDets;
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();
27 meanZ = meanZ / allGeometricDets.size();
28 LogDebug(
"TkDetLayers") <<
" meanZ " << meanZ << std::endl;
30 for (vector<const GeometricDet*>::const_iterator compGeometricDets = allGeometricDets.begin();
31 compGeometricDets != allGeometricDets.end();
32 compGeometricDets++) {
33 const GeomDet* theGeomDet = theGeomDetGeometry->
idToDet((*compGeometricDets)->geographicalID());
35 if (fabs((*compGeometricDets)->positionBounds().z()) < fabs(meanZ))
36 frontGeomDets.push_back(theGeomDet);
38 if (fabs((*compGeometricDets)->positionBounds().z()) > fabs(meanZ))
39 backGeomDets.push_back(theGeomDet);
41 if (fabs((*compGeometricDets)->positionBounds().z()) == fabs(meanZ))
42 throw DetLayerException(
"Not possible to assiciate this GeometricDet in front or back");
45 LogDebug(
"TkDetLayers") <<
"frontGeomDets.size(): " << frontGeomDets.size();
46 LogDebug(
"TkDetLayers") <<
"backGeomDets.size(): " << backGeomDets.size();
51 vector<const GeomDet*> frontGeomDetBrothers;
52 vector<const GeomDet*> backGeomDetBrothers;
53 vector<const GeometricDet*> compGeometricDets;
57 double meanZBrothers = 0;
58 for (vector<const GeometricDet*>::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end();
60 compGeometricDets = (*it)->components();
61 if (compGeometricDets.size() != 2) {
62 throw DetLayerException(
"Phase2OTEndcapRing is considered as a stack but does not have two components");
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();
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;
77 for (vector<const GeometricDet*>::const_iterator it = allGeometricDets.begin(); it != allGeometricDets.end();
79 compGeometricDets = (*it)->components();
80 const GeomDet* theGeomDet = theGeomDetGeometry->
idToDet(compGeometricDets[0]->geographicalID());
82 if (fabs(compGeometricDets[0]->positionBounds().
z()) < fabs(meanZ))
83 frontGeomDets.push_back(theGeomDet);
85 if (fabs(compGeometricDets[0]->positionBounds().
z()) > fabs(meanZ))
86 backGeomDets.push_back(theGeomDet);
88 const GeomDet* theGeomDetBrother = theGeomDetGeometry->
idToDet(compGeometricDets[1]->geographicalID());
90 if (fabs(compGeometricDets[1]->positionBounds().
z()) < fabs(meanZBrothers))
91 frontGeomDetBrothers.push_back(theGeomDetBrother);
93 if (fabs(compGeometricDets[1]->positionBounds().
z()) > fabs(meanZBrothers))
94 backGeomDetBrothers.push_back(theGeomDetBrother);
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");
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();
106 return new Phase2EndcapRing(frontGeomDets, backGeomDets, frontGeomDetBrothers, backGeomDetBrothers);