26 #include <unordered_map> 67 return std::hash<float>{}(
s.dx1 +
s.dx2 +
s.dy +
s.dz);
75 void add(
float w,
float x,
float r) {
126 bool handled =
false;
132 }
else if (
x >
i->y) {
134 }
else if (x < i->
x) {
138 }
else if (
y >
i->y) {
160 for (
auto &itvl : m_coverage) {
167 auto i = m_coverage.begin();
168 while (
i != m_coverage.end()) {
171 if (
j != m_coverage.end()) {
172 if (
j->x -
i->y >
eps) {
185 auto i = m_coverage.begin();
186 while (
i != m_coverage.end()) {
189 if (
j != m_coverage.end()) {
190 ostr <<
"(" <<
i->y <<
", " <<
j->x <<
")->" <<
j->x -
i->y;
202 float r =
gp.perp2(),
z =
gp.z();
212 bool doubleSide =
false;
229 std::array<const float, 4>
const &par =
b2->parameters();
242 printf(
"TRAP 0x%x %f %f %f %f ",
detid.rawId(), par[0], par[1], par[2], par[3]);
246 float dx =
b2->width() * 0.5;
247 float dy =
b2->length() * 0.5;
256 dz =
b2->thickness() * 0.5;
260 printf(
"RECT 0x%x %f %f %f ",
detid.rawId(),
dx,
dy,
dz);
263 throw cms::Exception(
"UnimplementedFeature") <<
"unsupported Bounds class";
274 unsigned short shape_id = 9999;
277 auto bhmi = bhm.find(ms);
278 if (bhmi == bhm.end()) {
279 bhmi = bhm.insert({ms, (
unsigned short)bhm.size()}).
first;
281 shape_id = bhmi->second;
285 printf(
" subdet=%d layer=%d side=%d is_stereo=%d is_double_side=%d --> mkflayer=%d; unique shape id=%hu\n",
297 (*lgc_map)[lay].reset_current();
299 float zbox_min = 1000, zbox_max = 0, rbox_min = 1000, rbox_max = 0;
300 for (
int i = 0;
i < 4; ++
i) {
307 findRZBox(gp1, rbox_min, rbox_max, zbox_min, zbox_max);
308 findRZBox(gp2, rbox_min, rbox_max, zbox_min, zbox_max);
310 (*lgc_map)[lay].extend_current(gp1.
perp2());
311 (*lgc_map)[lay].extend_current(gp2.
perp2());
315 (*lgc_map)[lay].add_current();
333 layer_info.register_module(
334 {{
p.x(),
p.y(),
p.z()}, {
z.x(),
z.y(),
z.z()}, {
x.x(),
x.y(),
x.z()},
detid.rawId(), shape_id});
336 layer_info.set_subdet(
detid.subdetId());
337 layer_info.set_is_pixel(
detid.subdetId() <= 2);
340 layer_info.set_has_charge(
false);
350 for (
int i = std::floor(zbox_min / iBin);
i <
std::ceil(zbox_max / iBin);
i++) {
351 for (
int j = std::floor(rbox_min / jBin);
j <
std::ceil(rbox_max / jBin);
j++) {
352 const float iF =
i * iBin;
353 const float jF =
j * jBin;
357 material_histogram(
i,
j).add(
overlap, bbxi, radL);
376 printf(
"\n*** addPixBGeometry\n\n");
385 printf(
"\n*** addPixEGeometry\n\n");
394 printf(
"\n*** addTIBGeometry\n\n");
403 printf(
"\n*** addTOBGeometry\n\n");
412 printf(
"\n*** addTIDGeometry\n\n");
421 printf(
"\n*** addTECGeometry\n\n");
429 std::ostringstream ostr;
430 ostr <<
"addTECGeometry() gap report:\n";
432 for (
auto &[
layer, gcol] : lgc_map) {
433 gcol.sqrt_elements();
434 if (gcol.find_gap(itvl, 0.5)) {
435 ostr <<
" layer: " <<
layer <<
", gap: " << itvl.
x <<
" -> " << itvl.
y <<
" width = " << itvl.
y - itvl.
x <<
"\n";
436 ostr <<
" all gaps: ";
437 gcol.print_gaps(ostr);
471 for (
int im = 0; im < trk_info.
n_layers(); ++im) {
486 for (
int j = rin;
j < rout;
j++) {
488 float distancesqmin = 100000;
490 for (
int j2 = rin; j2 < rout; j2++) {
491 if (
j == j2 &&
i ==
i2)
493 auto mydistsq = (
i -
i2) * (
i -
i2) + (
j - j2) * (
j - j2);
495 distancesqmin = mydistsq;
496 zneighbor_map(
i,
j) =
i2;
497 rneighbor_map(
i,
j) = j2;
505 for (
int j = rin;
j < rout;
j++) {
507 int iN = zneighbor_map(
i,
j);
508 int jN = rneighbor_map(
i,
j);
520 const float phase1QBins[] = {
522 2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5,
524 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5,
526 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5, 10.25, 7.5
528 const float phase2QBins[] = {
531 2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0,
533 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6,
535 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6
542 auto trackerInfo = std::make_unique<mkfit::TrackerInfo>();
547 const float *qBinDefaults =
nullptr;
551 edm::LogInfo(
"MkFitGeometryESProducer") <<
"Extracting PhaseI geometry";
552 trackerInfo->create_layers(18, 27, 27);
553 qBinDefaults = phase1QBins;
554 trackerInfo->create_material(300, 300.0
f, 120, 120.0
f);
557 edm::LogInfo(
"MkFitGeometryESProducer") <<
"Extracting PhaseII geometry";
558 #if !defined(MKFIT_PHASE2CUSTOMFLAGS) 561 using namespace mkfit;
566 trackerInfo->create_layers(16, 22, 22);
567 qBinDefaults = phase2QBins;
568 trackerInfo->create_material(300, 300.0
f, 120, 120.0
f);
570 throw cms::Exception(
"UnimplementedFeature") <<
"unsupported / unknowen geometry version";
574 for (
int i = 0;
i < trackerInfo->n_layers(); ++
i) {
575 auto &li = trackerInfo->layer_nc(
i);
578 li.reserve_modules(256);
583 MaterialHistogram material_histogram(trackerInfo->mat_nbins_z(), trackerInfo->mat_nbins_r());
595 unsigned int n_mod = 0;
596 for (
int i = 0;
i < trackerInfo->n_layers(); ++
i) {
597 auto &li = trackerInfo->layer_nc(
i);
599 li.set_propagate_to(li.is_barrel() ? li.r_mean() : li.z_mean());
600 li.set_q_bin(qBinDefaults[
i]);
601 unsigned int maxsid = li.shrink_modules();
606 assert(maxsid < 1u << 13);
611 li.resize_shapes(n_shapes);
613 li.register_shape(
shape,
id);
623 using namespace mkfit;
640 printf(
"Total number of modules %u, 14-bits fit up to %u modules\n", n_mod, 1u << 13);
643 return std::make_unique<MkFitGeometry>(iRecord.
get(
geomToken_),
const DetContainer & detsTIB() const
Log< level::Info, true > LogVerbatim
constexpr int32_t ceil(float num)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
bool tibIsDoubleSide(const DetId &id) const
void extend_limits(float r, float z)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
bool tecIsDoubleSide(const DetId &id) const
bool tidIsDoubleSide(const DetId &id) const
bool find_gap(Interval &itvl, float eps)
void addTIDGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
void set_r_hole_range(float rh1, float rh2)
layer_module_shape_vec_t layerModuleShapeVec_
void addTOBGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
const DetContainer & detsPXB() const
void addTECGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
PropagationFlags forward_fit_pflags
void fillLayers(mkfit::TrackerInfo &trk_info)
void addPixBGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
uint32_t cc[maxCellsPerHit]
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< module_shape_hmap_t > layer_module_shape_vec_t
edm::ESGetToken< GeometricSearchTracker, TrackerRecoGeometryRecord > trackerToken_
PropagationFlags backward_fit_pflags
const DetContainer & detsPXF() const
bool isStereo(const DetId &id) const
const TrackerTopology * trackerTopo_
void print_gaps(std::ostream &ostr)
unsigned int side(const DetId &id) const
void add_interval(float x, float y)
MkFitGeometryESProducer(const edm::ParameterSet &iConfig)
std::list< Interval > m_coverage
LayerInfo & layer_nc(int l)
void swap(Association< C > &lhs, Association< C > &rhs)
bool tobIsDoubleSide(const DetId &id) const
constexpr bool useMatched
unsigned int layer(const DetId &id) const
const Surface::RotationType & rotation() const
The rotation defining the local R.F.
void extend_current(float q)
PropagationFlags finding_inter_layer_pflags
Basic3DVector< T > x() const
std::unordered_map< mkfit::ModuleShape, unsigned short, ModuleShape_hash > module_shape_hmap_t
float material_radl(int binZ, int binR) const
const DetContainer & detsTOB() const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
const TrackerGeometry * trackerGeom_
bool isThere(GeomDetEnumerators::SubDetector subdet) const
int mat_bin_z(float z) const
float mat_range_z() const
Basic3DVector< T > z() const
Abs< T >::type abs(const T &t)
void considerPoint(const GlobalPoint &gp, mkfit::LayerInfo &lay_info)
PropagationFlags seed_fit_pflags
void fillShapeAndPlacement(const GeomDet *det, mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram, layer_gap_map_t *lgc_map=nullptr)
void addTIBGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
std::unordered_map< int, GapCollector > layer_gap_map_t
PropagationFlags pca_prop_pflags
bool finding_requires_propagation_to_hit_pos
DetId geographicalId() const
The label of this GeomDet.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
float mat_range_r() const
int mat_bin_r(float r) const
void add(float w, float x, float r)
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const LayerInfo & layer(int l) const
Log< level::Info, false > LogInfo
void aggregateMaterialInfo(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
const Plane & surface() const
The nominal surface of the GeomDet.
float material_bbxi(int binZ, int binR) const
void findRZBox(const GlobalPoint &gp, float &rmin, float &rmax, float &zmin, float &zmax)
const Surface::PositionType & position() const
The position (origin of the R.F.)
mkfit::LayerNumberConverter layerNrConv_
void apply_tracker_info(const TrackerInfo *ti)
std::size_t operator()(const mkfit::ModuleShape &s) const noexcept
void addPixEGeometry(mkfit::TrackerInfo &trk_info, MaterialHistogram &material_histogram)
PropagationFlags finding_intra_layer_pflags
std::unique_ptr< MkFitGeometry > produce(const TrackerRecoGeometryRecord &iRecord)
void reset(TkLayout layout)
const DetContainer & detsTEC() const
const MediumProperties & mediumProperties() const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
int convertLayerNumber(int det, int lay, bool useMatched, int isStereo, bool posZ) const
const DetContainer & detsTID() const
void round_assign(float x1, float x2, float y, float z)