CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsTrackerPhase1DiskBuilder.cc
Go to the documentation of this file.
9 #include <vector>
10 #include <algorithm>
11 
12 using namespace std;
13 
14 
15 bool
17 {
18  return( Panel1->phi() < Panel2->phi());
19 }
20 
21 void
22 CmsTrackerPhase1DiskBuilder::PhiPosNegSplit_innerOuter( std::vector< GeometricDet const *>::iterator begin,
23  std::vector< GeometricDet const *>::iterator end )
24 {
25  // first sort in phi, lowest first (-pi to +pi)
26  std::sort( begin, end, PhiSort );
27 
28  // now put positive phi (in order) ahead of negative phi as in std geometry
29  std::vector<const GeometricDet*> theCompsPosNeg;
30  theCompsPosNeg.empty();
31  theCompsPosNeg.clear();
32  // also find the average radius (used to split inner and outer disk panels)
33  double theRmin = (**begin).rho();
34  double theRmax = theRmin;
35  for(vector<const GeometricDet*>::const_iterator it=begin;
36  it!=end;it++){
37  if((**it).phi() >= 0) theCompsPosNeg.push_back(*it);
38  theRmin = std::min( theRmin, (**it).rho());
39  theRmax = std::max( theRmax, (**it).rho());
40  }
41  for(vector<const GeometricDet*>::const_iterator it=begin;
42  it!=end;it++){
43  if((**it).phi() < 0) theCompsPosNeg.push_back(*it);
44  }
45 
46  // now put inner disk panels first
47  // double radius_split = 0.5 * (theRmin + theRmax);
48  // force the split radius to be 100 mm to be able to deal with disks with only outer ring
49  double radius_split = 100.;
50  std::vector<const GeometricDet*> theCompsInnerOuter;
51  theCompsInnerOuter.empty();
52  theCompsInnerOuter.clear();
53  unsigned int num_inner = 0;
54  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
55  it!=theCompsPosNeg.end();it++){
56  if((**it).rho() <= radius_split) {
57  theCompsInnerOuter.push_back(*it);
58  num_inner++;
59  }
60  }
61 
62  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
63  it!=theCompsPosNeg.end();it++){
64  if((**it).rho() > radius_split) theCompsInnerOuter.push_back(*it);
65  }
66  // std::cout << "num of inner = " << num_inner << " with radius less than " << radius_split << std::endl;
67  // now shift outer by one
68 
69  std::rotate(theCompsInnerOuter.begin()+num_inner,theCompsInnerOuter.begin()+num_inner+1,theCompsInnerOuter.end());
70  std::copy(theCompsInnerOuter.begin(), theCompsInnerOuter.end(), begin);
71 }
72 
73 void
75 {
76  CmsTrackerPanelBuilder theCmsTrackerPanelBuilder;
77  GeometricDet * subdet = new GeometricDet( &fv, theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )));
78 
79  switch( theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )))
80  {
82  theCmsTrackerPanelBuilder.build( fv, subdet, s );
83  break;
84  default:
85  edm::LogError( "CmsTrackerPhase1DiskBuilder" ) << " ERROR - I was expecting a Panel, I got a " << ExtractStringFromDDD::getString( s, &fv );
86  }
87  g->addComponent( subdet );
88 }
89 
90 void
92 {
93 
94 
96 
97  switch( det->components().front()->type())
98  {
100  PhiPosNegSplit_innerOuter( comp.begin(), comp.end());
101  break;
102  default:
103  edm::LogError( "CmsTrackerPhase1DiskBuilder" ) << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
104  }
105 
106  GeometricDet::GeometricDetContainer zminpanels; // Here z refers abs(z);
107  GeometricDet::GeometricDetContainer zmaxpanels; // So, zmin panel is always closer to ip.
108 
109  uint32_t totalblade = comp.size()/2;
110  // std::cout << "pixel_disk " << pixel_disk << endl;
111 
112  zminpanels.reserve( totalblade );
113  zmaxpanels.reserve( totalblade );
114  for( uint32_t j = 0; j < totalblade; j++ )
115  {
116  if( fabs( comp[2*j]->translation().z()) > fabs( comp[ 2*j +1 ]->translation().z()))
117  {
118  zmaxpanels.push_back( det->component(2*j) );
119  zminpanels.push_back( det->component(2*j+1) );
120 
121  }
122  else if( fabs( comp[2*j]->translation().z()) < fabs( comp[ 2*j +1 ]->translation().z()))
123  {
124  zmaxpanels.push_back( det->component(2*j+1) );
125  zminpanels.push_back( det->component(2*j) );
126  }
127  else
128  {
129  edm::LogWarning( "CmsTrackerPhase1DiskBuilder" ) << "WARNING - The Z of both panels are equal! ";
130  }
131  }
132 
133  for( uint32_t fn = 0; fn < zminpanels.size(); fn++ )
134  {
135  uint32_t blade = fn + 1;
136  uint32_t panel = 1;
137  uint32_t temp = ( blade << 2 ) | panel;
138  zminpanels[fn]->setGeographicalID( temp );
139  }
140 
141  for( uint32_t bn = 0; bn < zmaxpanels.size(); bn++)
142  {
143  uint32_t blade = bn + 1;
144  uint32_t panel = 2;
145  uint32_t temp = ( blade << 2) | panel;
146  zmaxpanels[bn]->setGeographicalID( temp );
147  }
148 
149  det->clearComponents();
150  det->addComponents( zminpanels );
151  det->addComponents( zmaxpanels );
152 
153 }
154 
static std::string getString(std::string const &, DDFilteredView *)
void addComponent(GeometricDet *)
virtual void buildComponent(DDFilteredView &, GeometricDet *, std::string)
void clearComponents()
Definition: GeometricDet.h:96
std::vector< GeometricDet * > GeometricDetContainer
Definition: GeometricDet.h:37
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:174
virtual void build(DDFilteredView &, GeometricDet *, std::string)
virtual void sortNS(DDFilteredView &, GeometricDet *)
int j
Definition: DBlmapReader.cc:9
GeometricDet * component(size_t index)
Definition: GeometricDet.h:112
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
static bool PhiSort(const GeometricDet *Panel1, const GeometricDet *Panel2)
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:36
def rotate
Definition: svgfig.py:704
double phi() const
Definition: GeometricDet.h:127
void addComponents(GeometricDetContainer const &cont)
#define begin
Definition: vmac.h:30
void PhiPosNegSplit_innerOuter(std::vector< GeometricDet const * >::iterator begin, std::vector< GeometricDet const * >::iterator end)