CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
11  const TrackerGeometry* theGeomDetGeometry){
12 
13  vector<const GeometricDet*> theGeometricDetRods = aTOBLayer->components();
14  vector<const GeometricDet*> negativeZrods;
15  vector<const GeometricDet*> positiveZrods;
16 
17  for(vector<const GeometricDet*>::const_iterator it=theGeometricDetRods.begin();
18  it!=theGeometricDetRods.end(); it++){
19  if( (*it)->positionBounds().z() < 0) negativeZrods.push_back(*it);
20  if( (*it)->positionBounds().z() >= 0) 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.size()>0){
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 
42  double negativeMeanR = 0;
43  if(negativeZrods.size()>0){
44  for(unsigned int index=0; index!=negativeZrods.size(); index++){
45  negativeMeanR += negativeZrods[index]->positionBounds().perp();
46  }
47  negativeMeanR = negativeMeanR/negativeZrods.size();
48  }
49 
50  if(positiveZrods.size()>0 && negativeZrods.size()>0){
51  for(unsigned int index=0; index!=positiveZrods.size(); index++){
52  if( positiveZrods[index]->positionBounds().phi() != negativeZrods[index]->positionBounds().phi()){
53  edm::LogError("TkDetLayers") << "ERROR:rods don't have the same phi. exit!";
54  break;
55  }
56 
57  if(positiveZrods[index]->positionBounds().perp() < positiveMeanR)
58  theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
59  positiveZrods[index],
60  theGeomDetGeometry) );
61  if(positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
62  theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
63  positiveZrods[index],
64  theGeomDetGeometry) );
65  }
66  } else{
67  if(positiveZrods.size()>0){
68  for(unsigned int index=0; index!=positiveZrods.size(); index++){
69  if(positiveZrods[index]->positionBounds().perp() < positiveMeanR)
70  theInnerRods.push_back(myTOBRodBuilder.build(0,
71  positiveZrods[index],
72  theGeomDetGeometry) );
73  if(positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
74  theOuterRods.push_back(myTOBRodBuilder.build(0,
75  positiveZrods[index],
76  theGeomDetGeometry) );
77  }
78  }
79  if(negativeZrods.size()>0){
80  for(unsigned int index=0; index!=negativeZrods.size(); index++){
81  if(negativeZrods[index]->positionBounds().perp() < negativeMeanR)
82  theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
83  0,
84  theGeomDetGeometry) );
85  if(negativeZrods[index]->positionBounds().perp() >= negativeMeanR)
86  theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
87  0,
88  theGeomDetGeometry) );
89  }
90  }
91  }
92 
93  //LogDebug("TkDetLayers") << "theInnerRods.size(): " << theInnerRods.size() ;
94  //LogDebug("TkDetLayers") << "theOuterRods.size(): " << theOuterRods.size() ;
95 
96 
97  return new TOBLayer(theInnerRods,theOuterRods);
98 }
TOBLayer * build(const GeometricDet *aTOBLayer, const TrackerGeometry *theGeomDetGeometry)
GeometricDetContainer & components()
Definition: GeometricDet.h:163
T perp() const
Magnitude of transverse component.
TOBRod * build(const GeometricDet *negTOBRod, const GeometricDet *posTOBRod, const TrackerGeometry *theGeomDetGeometry)
Definition: TOBRodBuilder.cc:7