CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CmsTrackerDiskBuilder.cc
Go to the documentation of this file.
9 #include <vector>
10 #include <algorithm>
11 
12 using namespace std;
13 
15  : m_totalBlade( totalBlade )
16 {}
17 
18 bool
19 PhiSort( const GeometricDet* Panel1, const GeometricDet* Panel2 )
20 {
21  return( Panel1->phi() < Panel2->phi());
22 }
23 
24 void
25 CmsTrackerDiskBuilder::PhiPosNegSplit_innerOuter( GeometricDet::ConstGeometricDetContainer::iterator begin,
26  GeometricDet::ConstGeometricDetContainer::iterator end )
27 {
28  // first sort in phi, lowest first (-pi to +pi)
29  std::sort( begin, end, PhiSort );
30 
31  // now put positive phi (in order) ahead of negative phi as in std geometry
33  theCompsPosNeg.empty();
34  theCompsPosNeg.clear();
35  // also find the average radius (used to split inner and outer disk panels)
36  double theRmin = (**begin).rho();
37  double theRmax = theRmin;
38  for(GeometricDet::ConstGeometricDetContainer::const_iterator it=begin;
39  it!=end;it++){
40  if((**it).phi() >= 0) theCompsPosNeg.push_back(*it);
41  theRmin = std::min( theRmin, (**it).rho());
42  theRmax = std::max( theRmax, (**it).rho());
43  }
44  for(GeometricDet::ConstGeometricDetContainer::const_iterator it=begin;
45  it!=end;it++){
46  if((**it).phi() < 0) theCompsPosNeg.push_back(*it);
47  }
48 
49  // now put inner disk panels first
50  double radius_split = 0.5 * (theRmin + theRmax);
52  theCompsInnerOuter.empty();
53  theCompsInnerOuter.clear();
54  //unsigned int num_inner = 0;
55  for(GeometricDet::ConstGeometricDetContainer::const_iterator it=theCompsPosNeg.begin();
56  it!=theCompsPosNeg.end();it++){
57  if((**it).rho() <= radius_split) {
58  theCompsInnerOuter.push_back(*it);
59  //num_inner++;
60  }
61  }
62  for(GeometricDet::ConstGeometricDetContainer::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  std::copy(theCompsInnerOuter.begin(), theCompsInnerOuter.end(), begin);
68 }
69 
70 void
72 {
73  CmsTrackerPanelBuilder theCmsTrackerPanelBuilder;
75 
77  {
79  theCmsTrackerPanelBuilder.build( fv, subdet, s );
80  break;
81  default:
82  edm::LogError( "CmsTrackerDiskBuilder" ) << " ERROR - I was expecting a Panel, I got a " << ExtractStringFromDDD::getString( s, &fv );
83  }
84  g->addComponent( subdet );
85 }
86 
87 void
89 {
91 
92  switch( det->components().front()->type())
93  {
95  if( m_totalBlade == 24 )
96  TrackerStablePhiSort( comp.begin(), comp.end(), ExtractPhi());
97  else
98  PhiPosNegSplit_innerOuter( comp.begin(), comp.end());
99  break;
100  default:
101  edm::LogError( "CmsTrackerDiskBuilder" ) << "ERROR - wrong SubDet to sort..... " << det->components().front()->type();
102  }
103 
104  GeometricDet::GeometricDetContainer zminpanels; // Here z refers abs(z);
105  GeometricDet::GeometricDetContainer zmaxpanels; // So, zmin panel is always closer to ip.
106 
107  uint32_t totalblade = comp.size()/2;
108  if( totalblade != m_totalBlade )
109  edm::LogError( "CmsTrackerDiskBuilder" ) << "ERROR, The Total Number of Blade in one disk is " << totalblade << "; configured " << m_totalBlade;
110 
111  zminpanels.reserve( totalblade );
112  zmaxpanels.reserve( totalblade );
113  for( uint32_t j = 0; j < totalblade; j++ )
114  {
115  if( fabs( comp[2*j]->translation().z()) > fabs( comp[ 2*j +1 ]->translation().z()))
116  {
117  zmaxpanels.push_back( det->component(2*j) );
118  zminpanels.push_back( det->component(2*j+1) );
119 
120  }
121  else if( fabs( comp[2*j]->translation().z()) < fabs( comp[ 2*j +1 ]->translation().z()))
122  {
123  zmaxpanels.push_back( det->component(2*j+1) );
124  zminpanels.push_back( det->component(2*j) );
125  }
126  else
127  {
128  edm::LogWarning( "CmsTrackerDiskBuilder" ) << "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 }
static std::string getString(std::string const &, DDFilteredView *)
virtual void sortNS(DDFilteredView &, GeometricDet *)
void addComponent(GeometricDet *)
bool PhiSort(const GeometricDet *Panel1, const GeometricDet *Panel2)
void clearComponents()
Definition: GeometricDet.h:91
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
float float float z
ConstGeometricDetContainer & components()
Definition: GeometricDet.h:169
virtual void build(DDFilteredView &, GeometricDet *, std::string)
void TrackerStablePhiSort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
virtual void buildComponent(DDFilteredView &, GeometricDet *, std::string)
int j
Definition: DBlmapReader.cc:9
GeometricDet * component(size_t index)
Definition: GeometricDet.h:107
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
CmsTrackerDiskBuilder(unsigned int totalBlade)
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:36
double phi() const
Definition: GeometricDet.h:122
void addComponents(GeometricDetContainer const &cont)
#define begin
Definition: vmac.h:30
void PhiPosNegSplit_innerOuter(GeometricDet::ConstGeometricDetContainer::iterator begin, GeometricDet::ConstGeometricDetContainer::iterator end)
GeometricDet::GeometricEnumType type(std::string const &) const
CmsTrackerStringToEnum theCmsTrackerStringToEnum