Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase2-hgx293 Try to resolve some issues for scintillator part of HGCal Geometry #35796

Merged
merged 4 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
*
*/

#include <string>
#include <vector>
#include "DataFormats/DetId/interface/DetId.h"
#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
#include "Geometry/HGCalCommonData/interface/HGCalGeomTools.h"
#include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
#include "Geometry/HGCalCommonData/interface/HGCalTileIndex.h"
#include "Geometry/HGCalCommonData/interface/HGCalTypes.h"
#include <CLHEP/Geometry/Point3D.h>

#include <string>
#include <vector>
#include <unordered_map>

class HGCalDDDConstants {
Expand Down Expand Up @@ -109,6 +111,12 @@ class HGCalDDDConstants {
std::pair<int, int> rowColumnWafer(const int wafer) const;
int sectors() const { return hgpar_->nSectors_; }
std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
bool tileExist(int zside, int layer, int ring, int phi) const {
int indx = HGCalTileIndex::tileIndex(layer, ring, 0);
auto itr = hgpar_->tileInfoMap_.find(indx);
bool ok = (itr == hgpar_->tileInfoMap_.end()) ? false : HGCalTileIndex::tileExist(itr->second.hex, zside, phi);
return ok;
}
int tileSiPM(int sipm) const { return ((sipm > 0) ? HGCalTypes::SiPMSmall : HGCalTypes::SiPMLarge); }
bool tileTrapezoid() const {
return ((mode_ == HGCalGeometryMode::Trapezoid) || (mode_ == HGCalGeometryMode::TrapezoidFile) ||
Expand Down Expand Up @@ -181,6 +189,21 @@ class HGCalDDDConstants {
double waferSepar(bool reco) const {
return (reco ? hgpar_->sensorSeparation_ : HGCalParameters::k_ScaleToDDD * hgpar_->sensorSeparation_);
}
GlobalPoint waferLocal2Global(
HepGeom::Point3D<float>& loc, const DetId& id, bool useWafer, bool reco, bool debug) const {
HGCSiliconDetId detid(id);
double x(0), y(0);
if (useWafer) {
auto xyw = waferPositionNoRot(detid.layer(), detid.waferU(), detid.waferV(), reco, debug);
x = xyw.first;
y = xyw.second;
}
auto xy = getXY(detid.layer(), (x + loc.x()), (y + loc.y()), false);
double zz =
(detid.zside() < 0) ? -(loc.z() + waferZ(detid.layer(), reco)) : (loc.z() + waferZ(detid.layer(), reco));
double xx = (detid.zside() < 0) ? -xy.first : xy.first;
return GlobalPoint(xx, xy.second, zz);
}
double waferSize(bool reco) const {
return (reco ? hgpar_->waferSize_ : HGCalParameters::k_ScaleToDDD * hgpar_->waferSize_);
}
Expand Down
9 changes: 6 additions & 3 deletions Geometry/HGCalGeometry/src/HGCalGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ HGCalGeometry::CornersVec HGCalGeometry::getCorners(const DetId& detid) const {
HGCalTopology::DecodedDetId id = m_topology.decode(detid);
if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
GlobalPoint v = getPosition(detid);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(id.iType, id.iSec1);
int type = std::min(id.iType, 1);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
float dr = k_half * (rr.second - rr.first);
float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
Expand Down Expand Up @@ -329,7 +330,8 @@ HGCalGeometry::CornersVec HGCalGeometry::get8Corners(const DetId& detid) const {
HGCalTopology::DecodedDetId id = m_topology.decode(detid);
if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
GlobalPoint v = getPosition(detid);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(id.iType, id.iSec1);
int type = std::min(id.iType, 1);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
float dr = k_half * (rr.second - rr.first);
float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
Expand Down Expand Up @@ -372,7 +374,8 @@ HGCalGeometry::CornersVec HGCalGeometry::getNewCorners(const DetId& detid) const
HGCalTopology::DecodedDetId id = m_topology.decode(detid);
if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
GlobalPoint v = getPosition(detid);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(id.iType, id.iSec1);
int type = std::min(id.iType, 1);
std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
float dr = k_half * (rr.second - rr.first);
float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
float dz = -id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
Expand Down
65 changes: 40 additions & 25 deletions Geometry/HGCalGeometry/src/HGCalGeometryLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ HGCalGeometry* HGCalGeometryLoader::build(const HGCalTopology& topology) {
: (int)HGCalGeometry::k_NumberOfParametersPerHex);
uint32_t numberOfShapes =
(topology.tileTrapezoid() ? HGCalGeometry::k_NumberOfShapesTrd : HGCalGeometry::k_NumberOfShapes);
HGCalGeometryMode::GeometryMode mode = topology.geomMode();
bool test = (mode == HGCalGeometryMode::TrapezoidModule);
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "Number of Cells " << numberOfCells << ":" << numberExpected << " for sub-detector "
<< topology.subDetector() << " Shapes " << numberOfShapes << ":" << parametersPerShape_
<< " mode " << topology.geomMode();
<< " mode " << mode;
#endif
geom->allocateCorners(numberOfCells);
geom->allocatePar(numberOfShapes, parametersPerShape_);
Expand Down Expand Up @@ -99,31 +101,39 @@ HGCalGeometry* HGCalGeometryLoader::build(const HGCalTopology& topology) {
id.setType(typm.first);
id.setSiPM(typm.second);
}
DetId detId = static_cast<DetId>(id);
const auto& w = topology.dddConstants().locateCellTrap(layer, ring, iphi, true);
double xx = (zside > 0) ? w.first : -w.first;
CLHEP::Hep3Vector h3v(xx, w.second, mytr.h3v.z());
const HepGeom::Transform3D ht3d(mytr.hr, h3v);
bool ok = test ? topology.dddConstants().tileExist(zside, layer, ring, iphi) : true;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader::rad:phi:type " << ring * zside << ":" << iphi << ":"
<< type << " DetId " << HGCScintillatorDetId(detId) << " " << std::hex
<< detId.rawId() << std::dec << " transf " << ht3d.getTranslation() << " R "
<< ht3d.getTranslation().perp() << " and " << ht3d.getRotation();
edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader::layer:rad:phi:type:sipm " << layer << ":"
<< ring * zside << ":" << iphi << ":" << type << ":" << typm.first << ":"
<< typm.second << " Test " << test << ":" << ok;
#endif
HGCalParameters::hgtrap vol = topology.dddConstants().getModule(md, false, true);
params[FlatTrd::k_dZ] = vol.dz;
params[FlatTrd::k_Theta] = params[FlatTrd::k_Phi] = 0;
params[FlatTrd::k_dY1] = params[FlatTrd::k_dY2] = vol.h;
params[FlatTrd::k_dX1] = params[FlatTrd::k_dX3] = vol.bl;
params[FlatTrd::k_dX2] = params[FlatTrd::k_dX4] = vol.tl;
params[FlatTrd::k_Alp1] = params[FlatTrd::k_Alp2] = 0;
params[FlatTrd::k_Cell] = topology.dddConstants().cellSizeHex(type);

buildGeom(params, ht3d, detId, geom, 1);
counter++;
if (ok) {
DetId detId = static_cast<DetId>(id);
const auto& w = topology.dddConstants().locateCellTrap(layer, ring, iphi, true);
double xx = (zside > 0) ? w.first : -w.first;
CLHEP::Hep3Vector h3v(xx, w.second, mytr.h3v.z());
const HepGeom::Transform3D ht3d(mytr.hr, h3v);
#ifdef EDM_ML_DEBUG
++kount;
edm::LogVerbatim("HGCalGeom")
<< "HGCalGeometryLoader::rad:phi:type " << ring * zside << ":" << iphi << ":" << type << " DetId "
<< HGCScintillatorDetId(detId) << " " << std::hex << detId.rawId() << std::dec << " transf "
<< ht3d.getTranslation() << " R " << ht3d.getTranslation().perp() << " and " << ht3d.getRotation();
#endif
HGCalParameters::hgtrap vol = topology.dddConstants().getModule(md, false, true);
params[FlatTrd::k_dZ] = vol.dz;
params[FlatTrd::k_Theta] = params[FlatTrd::k_Phi] = 0;
params[FlatTrd::k_dY1] = params[FlatTrd::k_dY2] = vol.h;
params[FlatTrd::k_dX1] = params[FlatTrd::k_dX3] = vol.bl;
params[FlatTrd::k_dX2] = params[FlatTrd::k_dX4] = vol.tl;
params[FlatTrd::k_Alp1] = params[FlatTrd::k_Alp2] = 0;
params[FlatTrd::k_Cell] = topology.dddConstants().cellSizeHex(type);

buildGeom(params, ht3d, detId, geom, 1);
counter++;
#ifdef EDM_ML_DEBUG
++kount;
#endif
}
}
++ring;
}
Expand Down Expand Up @@ -172,9 +182,14 @@ HGCalGeometry* HGCalGeometryLoader::build(const HGCalTopology& topology) {
geom->sortDetIds();

if (counter != numberExpected) {
edm::LogError("HGCalGeom") << "Inconsistent # of cells: expected " << numberExpected << ":" << numberOfCells
<< " , inited " << counter;
assert(counter == numberExpected);
if (test) {
edm::LogVerbatim("HGCalGeom") << "Inconsistent # of cells: expected " << numberExpected << ":" << numberOfCells
<< " , inited " << counter;
} else {
edm::LogError("HGCalGeom") << "Inconsistent # of cells: expected " << numberExpected << ":" << numberOfCells
<< " , inited " << counter;
assert(counter == numberExpected);
}
}

return geom;
Expand Down
74 changes: 56 additions & 18 deletions Geometry/HGCalGeometry/test/python/testHGCalCellDumpDDD_cfg.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
###############################################################################
# Way to use this:
# cmsRun testHGCalCellDumpDDD_cfg.py geometry=D86
#
# Options for geometry D49, D68, D77, D83, D84, D86
#
###############################################################################
import FWCore.ParameterSet.Config as cms
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11

process = cms.Process("HcalGeometryTest",Phase2C11)

process.load("Geometry.CMSCommonData.cmsExtendedGeometry2026D71XML_cfi")
process.load("Geometry.EcalCommonData.ecalSimulationParameters_cff")
process.load("Geometry.HcalCommonData.hcalDDDSimConstants_cff")
process.load("Geometry.HGCalCommonData.hgcalParametersInitialization_cfi")
process.load("Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi")
process.load("Geometry.CaloEventSetup.HGCalV9Topology_cfi")
process.load("Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi")
process.load("Geometry.CaloEventSetup.CaloTopology_cfi")
process.load("Geometry.CaloEventSetup.CaloGeometry_cff")
process.load("Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi")
process.load("Geometry.EcalMapping.EcalMapping_cfi")
process.load("Geometry.EcalMapping.EcalMappingRecord_cfi")
process.load("Geometry.HcalCommonData.hcalDDDRecConstants_cfi")
process.load("Geometry.HcalEventSetup.hcalTopologyIdeal_cfi")
import os, sys, imp, re
import FWCore.ParameterSet.VarParsing as VarParsing

####################################################################
### SETUP OPTIONS
options = VarParsing.VarParsing('standard')
options.register('geometry',
"D86",
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.string,
"geometry of operations: D49, D68, D84, D77, D83, D86")

### get and parse the command line arguments
options.parseArguments()

print(options)

####################################################################
# Use the options

if (options.geometry == "D49"):
from Configuration.Eras.Era_Phase2C9_cff import Phase2C9
process = cms.Process('PROD',Phase2C9)
process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff')
elif (options.geometry == "D68"):
from Configuration.Eras.Era_Phase2C12_cff import Phase2C12
process = cms.Process('PROD',Phase2C12)
process.load('Configuration.Geometry.GeometryExtended2026D68Reco_cff')
elif (options.geometry == "D83"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('PROD',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D83Reco_cff')
elif (options.geometry == "D84"):
from Configuration.Eras.Era_Phase2C11_cff import Phase2C11
process = cms.Process('PROD',Phase2C11)
process.load('Configuration.Geometry.GeometryExtended2026D84Reco_cff')
elif (options.geometry == "D86"):
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('PROD',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D86Reco_cff')
else:
from Configuration.Eras.Era_Phase2C11M9_cff import Phase2C11M9
process = cms.Process('PROD',Phase2C11M9)
process.load('Configuration.Geometry.GeometryExtended2026D77Reco_cff')

process.load("Geometry.HGCalGeometry.hgcalGeometryDump_cfi")
process.load('FWCore.MessageService.MessageLogger_cfi')

if hasattr(process,'MessageLogger'):
process.MessageLogger.HGCalGeom=dict()

process.source = cms.Source("EmptySource")
process.maxEvents = cms.untracked.PSet(
Expand Down