CMS 3D CMS Logo

CmsTrackerPhase1DiskBuilder.cc
Go to the documentation of this file.
8 #include <vector>
9 #include <algorithm>
10 
11 using namespace std;
12 
13 
14 bool
16 {
17  return( Panel1->phi() < Panel2->phi());
18 }
19 
20 void
21 CmsTrackerPhase1DiskBuilder::PhiPosNegSplit_innerOuter( std::vector< GeometricDet const *>::iterator begin,
22  std::vector< GeometricDet const *>::iterator end )
23 {
24  // first sort in phi, lowest first (-pi to +pi)
25  std::sort( begin, end, PhiSort );
26 
27  // now put positive phi (in order) ahead of negative phi as in std geometry
28  std::vector<const GeometricDet*> theCompsPosNeg;
29  // also find the average radius (used to split inner and outer disk panels)
30  double theRmin = (**begin).rho();
31  double theRmax = theRmin;
32  for(vector<const GeometricDet*>::const_iterator it=begin;
33  it!=end;it++){
34  if((**it).phi() >= 0) theCompsPosNeg.emplace_back(*it);
35  theRmin = std::min( theRmin, (**it).rho());
36  theRmax = std::max( theRmax, (**it).rho());
37  }
38  for(vector<const GeometricDet*>::const_iterator it=begin;
39  it!=end;it++){
40  if((**it).phi() < 0) theCompsPosNeg.emplace_back(*it);
41  }
42 
43  // now put inner disk panels first
44  // double radius_split = 0.5 * (theRmin + theRmax);
45  // force the split radius to be 100 mm to be able to deal with disks with only outer ring
46  double radius_split = 100.;
47  std::vector<const GeometricDet*> theCompsInnerOuter;
48  unsigned int num_inner = 0;
49  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
50  it!=theCompsPosNeg.end();it++){
51  if((**it).rho() <= radius_split) {
52  theCompsInnerOuter.emplace_back(*it);
53  num_inner++;
54  }
55  }
56 
57  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
58  it!=theCompsPosNeg.end();it++){
59  if((**it).rho() > radius_split) theCompsInnerOuter.emplace_back(*it);
60  }
61  // std::cout << "num of inner = " << num_inner << " with radius less than " << radius_split << std::endl;
62  // now shift outer by one
63 
64  std::rotate(theCompsInnerOuter.begin()+num_inner,theCompsInnerOuter.end()-1,theCompsInnerOuter.end());
65  std::rotate(theCompsInnerOuter.begin(),theCompsInnerOuter.begin()+num_inner-1,theCompsInnerOuter.begin()+num_inner);
66  std::copy(theCompsInnerOuter.begin(), theCompsInnerOuter.end(), begin);
67 }
68 
69 void
71 {
72  CmsTrackerPanelBuilder theCmsTrackerPanelBuilder;
73  GeometricDet * subdet = new GeometricDet( &fv, theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )));
74 
75  switch( theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )))
76  {
78  theCmsTrackerPanelBuilder.build( fv, subdet, s );
79  break;
80  default:
81  edm::LogError( "CmsTrackerPhase1DiskBuilder" ) << " ERROR - I was expecting a Panel, I got a " << ExtractStringFromDDD::getString( s, &fv );
82  }
83  g->addComponent( subdet );
84 }
85 
86 void
88 {
89 
90 
92 
93  switch( det->components().front()->type())
94  {
96  PhiPosNegSplit_innerOuter( comp.begin(), comp.end());
97  break;
98  default:
99  edm::LogError( "CmsTrackerPhase1DiskBuilder" ) << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
100  }
101 
102  GeometricDet::GeometricDetContainer zminpanels; // Here z refers abs(z);
103  GeometricDet::GeometricDetContainer zmaxpanels; // So, zmin panel is always closer to ip.
104 
105  uint32_t totalblade = comp.size()/2;
106  // std::cout << "pixel_disk " << pixel_disk << endl;
107 
108  zminpanels.reserve( totalblade );
109  zmaxpanels.reserve( totalblade );
110  for( uint32_t j = 0; j < totalblade; j++ )
111  {
112  if( std::abs( comp[2*j]->translation().z()) > std::abs( comp[ 2*j +1 ]->translation().z()))
113  {
114  zmaxpanels.emplace_back( det->component(2*j) );
115  zminpanels.emplace_back( det->component(2*j+1) );
116 
117  }
118  else if( std::abs( comp[2*j]->translation().z()) < std::abs( comp[ 2*j +1 ]->translation().z()))
119  {
120  zmaxpanels.emplace_back( det->component(2*j+1) );
121  zminpanels.emplace_back( det->component(2*j) );
122  }
123  else
124  {
125  edm::LogWarning( "CmsTrackerPhase1DiskBuilder" ) << "WARNING - The Z of both panels are equal! ";
126  }
127  }
128 
129  for( uint32_t fn = 0; fn < zminpanels.size(); fn++ )
130  {
131  uint32_t blade = fn + 1;
132  uint32_t panel = 2; // though being zmin, it is actually the one facing away the ip
133  uint32_t temp = ( blade << 2 ) | panel;
134  zminpanels[fn]->setGeographicalID( temp );
135  }
136 
137  for( uint32_t bn = 0; bn < zmaxpanels.size(); bn++)
138  {
139  uint32_t blade = bn + 1;
140  uint32_t panel = 1; // though being zmax, it is the one facing the ip
141  uint32_t temp = ( blade << 2) | panel;
142  zmaxpanels[bn]->setGeographicalID( temp );
143  }
144 
145  det->clearComponents();
146  det->addComponents( zminpanels );
147  det->addComponents( zmaxpanels );
148 
149 }
150 
def copy(args, dbName)
void addComponent(GeometricDet *)
void build(DDFilteredView &, GeometricDet *, std::string) override
void clearComponents()
Definition: GeometricDet.h:98
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
void buildComponent(DDFilteredView &, GeometricDet *, std::string) override
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:176
static std::string getString(std::string const &, DDFilteredView *)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GeometricDet * component(size_t index)
Definition: GeometricDet.h:114
#define end
Definition: vmac.h:39
T min(T a, T b)
Definition: MathUtil.h:58
void sortNS(DDFilteredView &, GeometricDet *) override
static bool PhiSort(const GeometricDet *Panel1, const GeometricDet *Panel2)
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:36
double phi() const
Definition: GeometricDet.h:129
void addComponents(GeometricDetContainer const &cont)
#define begin
Definition: vmac.h:32
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:705
void PhiPosNegSplit_innerOuter(std::vector< GeometricDet const * >::iterator begin, std::vector< GeometricDet const * >::iterator end)