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