CMS 3D CMS Logo

CmsTrackerLayerBuilder.cc
Go to the documentation of this file.
11 
12 #include <vector>
13 #include <bitset>
14 #include <functional>
15 
17 
18  CmsTrackerStringBuilder theCmsTrackerStringBuilder ;
19  CmsTrackerRodBuilder theCmsTrackerRodBuilder;
20  CmsTrackerLadderBuilder theCmsTrackerLadderBuilder;
21 
25  theCmsTrackerStringBuilder.build(fv,subdet,s);
26  break;
27  case GeometricDet::rod:
28  theCmsTrackerRodBuilder.build(fv,subdet,s);
29  break;
31  theCmsTrackerLadderBuilder.build(fv,subdet,s);
32  break;
33  default:
34  edm::LogError("CmsTrackerLayerBuilder")<<" ERROR - I was expecting a String, Rod or Ladder, I got a "<<ExtractStringFromDDD::getString(s,&fv);
35 
36  }
37  g->addComponent(subdet);
38 
39 }
40 
42 
43  const std::function<double(const GeometricDet*)> getPhiFunc{getPhi};
44 
46 
47  // TIB
48  // SubDetector Side: 2 bits [TIB-:1 TIB+:2]
49  // Layer Part : 2 bits [internal:1 external:0]
50  // String Number : 6 bits [1,...,56 (at most)]
51  //
52  if(comp.front()->type()== GeometricDet::strng){
53  float layerRadius = (det->params()[2]+det->params()[1])/2.;
54 
61  neg.clear();
62  pos.clear();
63  extneg.clear();
64  intneg.clear();
65  extpos.clear();
66  intpos.clear();
67 
68  for(size_t i = 0; i< comp.size(); ++i) {
69  auto component = det->component(i);
70  if(component->translation().z()<0.){
71  neg.emplace_back(component);
72  }else{
73  pos.emplace_back(component);
74  }
75  }
76 
77  for(auto & i : neg){
78  double rPos = i->translation().Rho();
79  if(rPos > layerRadius ){
80  extneg.emplace_back(i);
81  }else{
82  intneg.emplace_back(i);
83  }
84  }
85 
86  for(auto & po : pos){
87  double rPos = po->translation().Rho();
88  if(rPos > layerRadius ){
89  extpos.emplace_back(po);
90  }else{
91  intpos.emplace_back(po);
92  }
93  }
94 
95  TrackerStablePhiSort(extneg.begin(), extneg.end(), getPhiFunc);
96  TrackerStablePhiSort(extpos.begin(), extpos.end(), getPhiFunc);
97  TrackerStablePhiSort(intneg.begin(), intneg.end(), getPhiFunc);
98  TrackerStablePhiSort(intpos.begin(), intpos.end(), getPhiFunc);
99 
100  for(uint32_t i=0;i<intneg.size();i++){
101  uint32_t temp=i+1;
102  temp|=(1<<8); // 1 : SubDetector Side TIB-
103  temp|=(1<<6); // 1 : Layer Part int
104  intneg[i]->setGeographicalID(DetId(temp));
105  }
106 
107  for(uint32_t i=0;i<extneg.size();i++){
108  uint32_t temp=i+1;
109  temp|=(1<<8); // 1 : SubDetector Side TIB-
110  temp|=(2<<6); // 2 : Layer Part ext
111  extneg[i]->setGeographicalID(DetId(temp));
112  }
113 
114  for(uint32_t i=0;i<intpos.size();i++){
115  uint32_t temp=i+1;
116  temp|=(2<<8); // 2 : SubDetector Side TIB+
117  temp|=(1<<6); // 1 : Layer Part int
118  intpos[i]->setGeographicalID(DetId(temp));
119  }
120 
121  for(uint32_t i=0;i<extpos.size();i++){
122  uint32_t temp=i+1;
123  temp|=(2<<8); // 2 : SubDetector Side TIB+
124  temp|=(2<<6); // 2 : Layer Part ext
125  extpos[i]->setGeographicalID(DetId(temp));
126  }
127 
128 
129  det->clearComponents();
130  det->addComponents(intneg);
131  det->addComponents(extneg);
132  det->addComponents(intpos);
133  det->addComponents(extpos);
134 
135  }else if(comp.front()->type()== GeometricDet::rod){
138  neg.clear();
139  pos.clear();
140 
141  for(size_t i=0; i<comp.size(); ++i) {
142  auto component = det->component(i);
143  if(component->translation().z()<0.){
144  neg.emplace_back(component);
145  }else{
146  pos.emplace_back(component);
147  }
148  }
149 
150  TrackerStablePhiSort(neg.begin(), neg.end(), getPhiFunc);
151  TrackerStablePhiSort(pos.begin(), pos.end(), getPhiFunc);
152 
153  for(uint32_t i=0; i<neg.size();i++){
154  uint32_t temp = i+1;
155  temp|=(1<<7);
156  neg[i]->setGeographicalID(DetId(temp));
157  }
158 
159  for(uint32_t i=0; i<pos.size();i++){
160  uint32_t temp = i+1;
161  temp|=(2<<7);
162  pos[i]->setGeographicalID(DetId(temp));
163  }
164 
165  det->clearComponents();
166  det->addComponents(neg);
167  det->addComponents(pos);
168 
169  }else if(det->components().front()->type()== GeometricDet::ladder){
170 
171  TrackerStablePhiSort(comp.begin(), comp.end(), getPhiFunc);
172 
173  for(uint32_t i=0; i<comp.size();i++){
174  det->component(i)->setGeographicalID(DetId(i+1));
175  }
176 
177  }else{
178  edm::LogError("CmsTrackerLayerBuilder")<<"ERROR - wrong SubDet to sort..... "<<det->components().front()->type();
179  }
180 
181 }
182 
static std::string getString(std::string const &, DDFilteredView *)
void buildComponent(DDFilteredView &, GeometricDet *, std::string) override
void addComponent(GeometricDet *)
void build(DDFilteredView &, GeometricDet *, std::string) override
static double getPhi(const GeometricDet *a)
void clearComponents()
Definition: GeometricDet.h:98
void setGeographicalID(DetId id)
Definition: GeometricDet.h:82
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
std::vector< double > const & params() const
Definition: GeometricDet.h:165
void sortNS(DDFilteredView &, GeometricDet *) override
void TrackerStablePhiSort(RandomAccessIterator begin, RandomAccessIterator end, const Extractor &extr)
GeometricDet * component(size_t index)
Definition: GeometricDet.h:114
std::vector< GeometricDet const * > ConstGeometricDetContainer
Definition: GeometricDet.h:36
Definition: DetId.h:18
void addComponents(GeometricDetContainer const &cont)
GeometricDet::GeometricEnumType type(std::string const &) const
CmsTrackerStringToEnum theCmsTrackerStringToEnum