CMS 3D CMS Logo

CmsTrackerPhase2TPDiskBuilder.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 CmsTrackerPhase2TPDiskBuilder::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  theCompsPosNeg.empty();
30  theCompsPosNeg.clear();
31  // also find the average radius (used to split inner and outer disk panels)
32  double theRmin = (**begin).rho();
33  double theRmax = theRmin;
34  for(vector<const GeometricDet*>::const_iterator it=begin;
35  it!=end;it++){
36  if((**it).phi() >= 0) theCompsPosNeg.emplace_back(*it);
37  theRmin = std::min( theRmin, (**it).rho());
38  theRmax = std::max( theRmax, (**it).rho());
39  }
40  for(vector<const GeometricDet*>::const_iterator it=begin;
41  it!=end;it++){
42  if((**it).phi() < 0) theCompsPosNeg.emplace_back(*it);
43  }
44 
45  // now put inner disk panels first
46  // double radius_split = 0.5 * (theRmin + theRmax);
47  // force the split radius to be 100 mm to be able to deal with disks with only outer ring
48  double radius_split = 100.;
49  std::vector<const GeometricDet*> theCompsInnerOuter;
50  theCompsInnerOuter.empty();
51  theCompsInnerOuter.clear();
52  unsigned int num_inner = 0;
53  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
54  it!=theCompsPosNeg.end();it++){
55  if((**it).rho() <= radius_split) {
56  theCompsInnerOuter.emplace_back(*it);
57  num_inner++;
58  }
59  }
60 
61  for(vector<const GeometricDet*>::const_iterator it=theCompsPosNeg.begin();
62  it!=theCompsPosNeg.end();it++){
63  if((**it).rho() > radius_split) theCompsInnerOuter.emplace_back(*it);
64  }
65  // std::cout << "num of inner = " << num_inner << " with radius less than " << radius_split << std::endl;
66  // now shift outer by one
67 
68  std::rotate(theCompsInnerOuter.begin()+num_inner,theCompsInnerOuter.begin()+num_inner+1,theCompsInnerOuter.end());
69  std::copy(theCompsInnerOuter.begin(), theCompsInnerOuter.end(), begin);
70 }
71 
72 void
74 {
75  CmsTrackerPanelBuilder theCmsTrackerPanelBuilder;
76  GeometricDet * subdet = new GeometricDet( &fv, theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )));
77 
78  switch( theCmsTrackerStringToEnum.type( ExtractStringFromDDD::getString( s, &fv )))
79  {
81  theCmsTrackerPanelBuilder.build( fv, subdet, s );
82  break;
83  default:
84  edm::LogError( "CmsTrackerPhase2TPDiskBuilder" ) << " ERROR - I was expecting a Panel, I got a " << ExtractStringFromDDD::getString( s, &fv );
85  }
86  g->addComponent( subdet );
87 }
88 
89 void
91 {
92 
93 
95 
96  switch( det->components().front()->type())
97  {
99  PhiPosNegSplit_innerOuter( comp.begin(), comp.end());
100  break;
101  default:
102  edm::LogError( "CmsTrackerPhase2TPDiskBuilder" ) << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
103  }
104 
105  GeometricDet::GeometricDetContainer zminpanels; // Here z refers abs(z);
106  GeometricDet::GeometricDetContainer zmaxpanels; // So, zmin panel is always closer to ip.
107 
108  uint32_t totalblade = comp.size()/2;
109  // std::cout << "pixel_disk " << pixel_disk << endl;
110 
111  zminpanels.reserve( totalblade );
112  zmaxpanels.reserve( totalblade );
113  for( uint32_t j = 0; j < totalblade; j++ )
114  {
115  if( std::abs( comp[2*j]->translation().z()) > std::abs( comp[ 2*j +1 ]->translation().z()))
116  {
117  zmaxpanels.emplace_back( det->component(2*j) );
118  zminpanels.emplace_back( det->component(2*j+1) );
119 
120  }
121  else if( std::abs( comp[2*j]->translation().z()) < std::abs( comp[ 2*j +1 ]->translation().z()))
122  {
123  zmaxpanels.emplace_back( det->component(2*j+1) );
124  zminpanels.emplace_back( det->component(2*j) );
125  }
126  else
127  {
128  edm::LogWarning( "CmsTrackerPhase2TPDiskBuilder" ) << "WARNING - The Z of both panels are equal! ";
129  }
130  }
131 
132  for( uint32_t fn = 0; fn < zminpanels.size(); fn++ )
133  {
134  uint32_t blade = fn + 1;
135  uint32_t panel = 1;
136  uint32_t temp = ( blade << 2 ) | panel;
137  zminpanels[fn]->setGeographicalID( temp );
138  }
139 
140  for( uint32_t bn = 0; bn < zmaxpanels.size(); bn++)
141  {
142  uint32_t blade = bn + 1;
143  uint32_t panel = 2;
144  uint32_t temp = ( blade << 2) | panel;
145  zmaxpanels[bn]->setGeographicalID( temp );
146  }
147 
148  det->clearComponents();
149  det->addComponents( zminpanels );
150  det->addComponents( zmaxpanels );
151 
152 }
static std::string getString(std::string const &, DDFilteredView *)
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
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:176
void PhiPosNegSplit_innerOuter(std::vector< GeometricDet const * >::iterator begin, std::vector< GeometricDet const * >::iterator end)
void sortNS(DDFilteredView &, GeometricDet *) override
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
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
void buildComponent(DDFilteredView &, GeometricDet *, std::string) override
def rotate(angle, cx=0, cy=0)
Definition: svgfig.py:704