Skip to content

Commit

Permalink
Bckport #45511 #46033fo the changes t zDC geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunanda committed Oct 4, 2024
1 parent 4783bf1 commit 9352017
Show file tree
Hide file tree
Showing 34 changed files with 1,851 additions and 239 deletions.
455 changes: 312 additions & 143 deletions CalibCalorimetry/HcalPlugins/src/HcalHardcodeCalibrations.cc

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion CalibCalorimetry/HcalPlugins/src/HcalHardcodeCalibrations.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
#include "CondFormats/HcalObjects/interface/AllObjects.h"
#include "CalibCalorimetry/HcalAlgos/interface/HBHERecalibration.h"
#include "CondFormats/DataRecord/interface/HcalTPParametersRcd.h"
Expand Down Expand Up @@ -68,9 +69,13 @@ class HcalHardcodeCalibrations : public edm::ESProducer, public edm::EventSetupR

std::unique_ptr<HcalPedestals> producePedestals_(const HcalPedestalsRcd& rcd,
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>&,
const edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord>&,
bool eff);
std::unique_ptr<HcalPedestalWidths> producePedestalWidths_(
const HcalPedestalWidthsRcd& rcd, const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>&, bool eff);
const HcalPedestalWidthsRcd& rcd,
const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>&,
const edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord>&,
bool eff);
std::unique_ptr<HcalPedestals> producePedestals(const HcalPedestalsRcd& rcd);
std::unique_ptr<HcalPedestalWidths> producePedestalWidths(const HcalPedestalWidthsRcd& rcd);
std::unique_ptr<HcalPedestals> produceEffectivePedestals(const HcalPedestalsRcd& rcd);
Expand Down Expand Up @@ -147,6 +152,7 @@ class HcalHardcodeCalibrations : public edm::ESProducer, public edm::EventSetupR
std::unique_ptr<HBHERecalibration> he_recalibration;
std::unique_ptr<HFRecalibration> hf_recalibration;
std::unordered_map<int, edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>> topoTokens_;
std::unordered_map<int, edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord>> zdcTopoTokens_;
edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> heDarkeningToken_;
edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> hbDarkeningToken_;
bool switchGainWidthsForTrigPrims;
Expand Down
2 changes: 2 additions & 0 deletions CondFormats/HcalObjects/interface/HcalCondObjectContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class HcalCondObjectContainerBase {
HcalCondObjectContainerBase& operator=(HcalCondObjectContainerBase const& o) {
topo_ = o.topo();
packedIndexVersion_ = o.packedIndexVersion_;
kSizeForDenseIndexing_ = o.kSizeForDenseIndexing_;
return *this;
}
#ifndef __GCCXML__
Expand All @@ -47,6 +48,7 @@ class HcalCondObjectContainerBase {

private:
const HcalTopology* topo_ COND_TRANSIENT;
uint32_t kSizeForDenseIndexing_ COND_TRANSIENT;

COND_SERIALIZABLE;
};
Expand Down
27 changes: 20 additions & 7 deletions CondFormats/HcalObjects/src/HcalCondObjectContainerBase.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Geometry/CaloTopology/interface/HcalTopology.h"
#include "Geometry/HcalCommonData/interface/HcalTopologyMode.h"
#include "CondFormats/HcalObjects/interface/HcalCondObjectContainer.h"
#include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
#include "DataFormats/HcalDetId/interface/HcalCalibDetId.h"
Expand All @@ -9,16 +10,28 @@
#include "FWCore/Utilities/interface/Exception.h"

HcalCondObjectContainerBase::HcalCondObjectContainerBase(const HcalTopology* topo)
: packedIndexVersion_(0), topo_(topo) {
if (topo)
: packedIndexVersion_(0), topo_(topo), kSizeForDenseIndexing_(HcalZDCDetId::kSizeForDenseIndexingRun1) {
if (topo) {
packedIndexVersion_ = topo->topoVersion();
HcalTopologyMode::Mode mode = topo->mode();
kSizeForDenseIndexing_ = (((mode == HcalTopologyMode::Run3) || (mode == HcalTopologyMode::Run4))
? HcalZDCDetId::kSizeForDenseIndexingRun3
: HcalZDCDetId::kSizeForDenseIndexingRun1);
}
}

void HcalCondObjectContainerBase::setTopo(const HcalTopology* topo) {
if ((topo) && (packedIndexVersion_ != 0) && (!topo->denseIdConsistent(packedIndexVersion_)))
edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (") << topo->topoVersion()
<< ") and calibration object (" << packedIndexVersion_ << ")";
topo_ = topo;
if (topo) {
if ((packedIndexVersion_ != 0) && (!topo->denseIdConsistent(packedIndexVersion_)))
edm::LogError("HCAL") << std::string("Inconsistent dense packing between current topology (")
<< topo->topoVersion() << ") and calibration object (" << packedIndexVersion_ << ")";
topo_ = topo;
packedIndexVersion_ = topo->topoVersion();
kSizeForDenseIndexing_ = ((packedIndexVersion_ >= 10) ? HcalZDCDetId::kSizeForDenseIndexingRun3
: HcalZDCDetId::kSizeForDenseIndexingRun1);
} else {
edm::LogError("HCAL") << "Illegal call to HcalCondObjectContainerBase with a null pointer";
}
}

unsigned int HcalCondObjectContainerBase::indexFor(DetId fId) const {
Expand Down Expand Up @@ -114,7 +127,7 @@ unsigned int HcalCondObjectContainerBase::sizeFor(DetId fId) const {
if (fId.subdetId() == HcalCastorDetId::SubdetectorId) {
retval = HcalCastorDetId::kSizeForDenseIndexing;
} else if (fId.subdetId() == HcalZDCDetId::SubdetectorId) {
retval = HcalZDCDetId::kSizeForDenseIndexing;
retval = kSizeForDenseIndexing_;
}
}
return retval;
Expand Down
110 changes: 110 additions & 0 deletions CondTools/Geometry/plugins/calowriters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Geometry/HcalTowerAlgo/interface/CaloGeometryDBHcal.h"
#include "Geometry/HcalTowerAlgo/interface/CaloGeometryDBCaloTower.h"
#include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
#include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
#include "Geometry/ForwardGeometry/interface/CaloGeometryDBZdc.h"
#include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
#include "Geometry/Records/interface/HcalRecNumberingRecord.h"
#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
Expand Down Expand Up @@ -322,6 +324,114 @@ CaloGeometryDBEP<HGCalGeometry, CaloGeometryDBWriter>::produceAligned(
return ptr;
}

template <>
CaloGeometryDBEP<ZdcGeometry, CaloGeometryDBWriter>::PtrType
CaloGeometryDBEP<ZdcGeometry, CaloGeometryDBWriter>::produceAligned(const typename ZdcGeometry::AlignedRecord& iRecord) {
const auto [alignPtr, globalPtr] = getAlignGlobal(iRecord);

TrVec tvec;
DimVec dvec;
IVec ivec;
IVec dins;

const auto& pG = iRecord.get(geometryToken_);

pG.getSummary(tvec, ivec, dvec, dins);

CaloGeometryDBWriter::writeIndexed(tvec, dvec, ivec, dins, ZdcGeometry::dbString());
//*********************************************************************************************

const auto& zdcTopology = iRecord.get(additionalTokens_.topology);

// We know that the numer of shapes chanes with changing depth
// so, this check is temporary disabled. We need to implement
// a way either to store or calculate the number of shapes or be able
// to deal with only max numer of shapes.
assert(dvec.size() <= ZdcGeometry::k_NumberOfShapes * ZdcGeometry::k_NumberOfParametersPerShape);
ZdcGeometry* zdcGeometry = new ZdcGeometry(&zdcTopology);
PtrType ptr(zdcGeometry);

const unsigned int nTrParm(tvec.size() / zdcTopology.kSizeForDenseIndexing());

ptr->fillDefaultNamedParameters();
ptr->allocateCorners(zdcTopology.kSizeForDenseIndexing());
ptr->allocatePar(zdcGeometry->numberOfShapes(), ZdcGeometry::k_NumberOfParametersPerShape);

for (unsigned int i(0); i < dins.size(); ++i) {
const unsigned int nPerShape(ZdcGeometry::k_NumberOfParametersPerShape);
DimVec dims;
dims.reserve(nPerShape);

const unsigned int indx(ivec.size() == 1 ? 0 : i);

DimVec::const_iterator dsrc(dvec.begin() + ivec[indx] * nPerShape);

for (unsigned int j(0); j != nPerShape; ++j) {
dims.push_back(*dsrc);
++dsrc;
}

const CCGFloat* myParm(CaloCellGeometry::getParmPtr(dims, ptr->parMgr(), ptr->parVecVec()));

const DetId id(zdcTopology.denseId2detId(dins[i]));

const unsigned int iGlob(nullptr == globalPtr ? 0 : ZdcGeometry::alignmentTransformIndexGlobal(id));

assert(nullptr == globalPtr || iGlob < globalPtr->m_align.size());

const AlignTransform* gt(nullptr == globalPtr ? nullptr : &globalPtr->m_align[iGlob]);

assert(nullptr == gt || iGlob == ZdcGeometry::alignmentTransformIndexGlobal(DetId(gt->rawId())));

const unsigned int iLoc(nullptr == alignPtr ? 0 : ZdcGeometry::alignmentTransformIndexLocal(id));

assert(nullptr == alignPtr || iLoc < alignPtr->m_align.size());

const AlignTransform* at(nullptr == alignPtr ? nullptr : &alignPtr->m_align[iLoc]);

assert(nullptr == at || (ZdcGeometry::alignmentTransformIndexLocal(DetId(at->rawId())) == iLoc));

Pt3D lRef;
Pt3DVec lc(8, Pt3D(0, 0, 0));
zdcGeometry->localCorners(lc, &dims.front(), dins[i], lRef);

const Pt3D lBck(0.25 * (lc[4] + lc[5] + lc[6] + lc[7])); // ctr rear face in local
const Pt3D lCor(lc[0]);

//----------------------------------- create transform from 6 numbers ---
const unsigned int jj(i * nTrParm);
Tr3D tr;
const ROOT::Math::Translation3D tl(tvec[jj], tvec[jj + 1], tvec[jj + 2]);
const ROOT::Math::EulerAngles ea(6 == nTrParm ? ROOT::Math::EulerAngles(tvec[jj + 3], tvec[jj + 4], tvec[jj + 5])
: ROOT::Math::EulerAngles());
const ROOT::Math::Transform3D rt(ea, tl);
double xx, xy, xz, dx;
double yx, yy, yz, dy;
double zx, zy, zz, dz;
rt.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
tr = Tr3D(CLHEP::HepRep3x3(xx, xy, xz, yx, yy, yz, zx, zy, zz), CLHEP::Hep3Vector(dx, dy, dz));

// now prepend alignment(s) for final transform
const Tr3D atr(nullptr == at ? tr
: (nullptr == gt ? at->transform() * tr : at->transform() * gt->transform() * tr));
//--------------------------------- done making transform ---------------

const Pt3D gRef(atr * lRef);
const GlobalPoint fCtr(gRef.x(), gRef.y(), gRef.z());
const Pt3D gBck(atr * lBck);
const GlobalPoint fBck(gBck.x(), gBck.y(), gBck.z());
const Pt3D gCor(atr * lCor);
const GlobalPoint fCor(gCor.x(), gCor.y(), gCor.z());

assert(zdcTopology.detId2denseId(id) == dins[i]);
ptr->newCell(fCtr, fBck, fCor, myParm, id);
}

ptr->initializeParms(); // initializations; must happen after cells filled

return ptr;
}

template class CaloGeometryDBEP<EcalBarrelGeometry, CaloGeometryDBWriter>;
template class CaloGeometryDBEP<EcalEndcapGeometry, CaloGeometryDBWriter>;
template class CaloGeometryDBEP<EcalPreshowerGeometry, CaloGeometryDBWriter>;
Expand Down
1 change: 1 addition & 0 deletions Configuration/Geometry/python/GeometryRecoDB_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from Geometry.EcalMapping.EcalMappingRecord_cfi import *
from Geometry.HcalCommonData.hcalDBConstants_cff import *
from Geometry.HcalEventSetup.hcalTopologyIdeal_cfi import *
from Geometry.ForwardGeometry.zdcTopologyEP_cfi import *

# Alignment
from Geometry.TrackerGeometryBuilder.idealForDigiTrackerGeometryDB_cff import *
Expand Down
88 changes: 78 additions & 10 deletions Configuration/Geometry/python/dict2021Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@
caloDict = {
"abbrev" : "C",
"name" : "calo",
"default" : 1,
"default" : 2,
"C1" : {
1 : [
'Geometry/EcalCommonData/data/ebcon/2021/v1/ebcon.xml',
Expand Down Expand Up @@ -1382,7 +1382,75 @@
'from Geometry.EcalMapping.EcalMappingRecord_cfi import *',
],
"era" : "run3_HB",
}
},
"C2" : {
1 : [
'Geometry/EcalCommonData/data/ebcon/2021/v1/ebcon.xml',
'Geometry/EcalCommonData/data/eecon.xml',
'Geometry/EcalCommonData/data/escon.xml',
'Geometry/EcalCommonData/data/eregalgo/2017/v1/eregalgo.xml',
'Geometry/EcalCommonData/data/ebalgo.xml',
'Geometry/EcalCommonData/data/ebrot.xml',
'Geometry/EcalCommonData/data/eefixed/2021/v1/eefixed.xml',
'Geometry/EcalCommonData/data/eehier.xml',
'Geometry/EcalCommonData/data/eealgo.xml',
'Geometry/EcalCommonData/data/esalgo.xml',
'Geometry/EcalCommonData/data/eeF.xml',
'Geometry/EcalCommonData/data/eeB.xml',
'Geometry/EcalCommonData/data/ectkcable.xml',
'Geometry/HcalCommonData/data/hcalrotations.xml',
'Geometry/HcalCommonData/data/hcal/PhaseI/hcalalgo.xml',
'Geometry/HcalCommonData/data/hcalcablealgo.xml',
'Geometry/HcalCommonData/data/hcalbarrelalgo.xml',
'Geometry/HcalCommonData/data/hcalendcap/PhaseI/hcalendcapalgo.xml',
'Geometry/HcalCommonData/data/hcalouteralgo/v1/hcalouteralgo.xml',
'Geometry/HcalCommonData/data/hcalforwardalgo.xml',
'Geometry/HcalCommonData/data/average/hcalforwardmaterial.xml',
'Geometry/HcalCommonData/data/hcalSimNumbering/2021/v1/hcalSimNumbering.xml',
'Geometry/HcalCommonData/data/hcalRecNumbering/2021/v2/hcalRecNumbering.xml',
],
3 : [
'Geometry/EcalSimData/data/ecalsens.xml',
'Geometry/HcalCommonData/data/hcalsens/2021/v2/hcalsenspmf.xml',
'Geometry/HcalSimData/data/hf.xml',
'Geometry/HcalSimData/data/hfpmt.xml',
'Geometry/HcalSimData/data/hffibrebundle.xml',
'Geometry/HcalSimData/data/CaloUtil/2021/v1/CaloUtil.xml',
],
4 : [
'Geometry/HcalSimData/data/HcalProdCuts/2021/v2/HcalProdCuts.xml',
'Geometry/EcalSimData/data/EcalProdCuts.xml',
'Geometry/EcalSimData/data/ESProdCuts.xml',
],
"sim" : [
'from Geometry.EcalCommonData.ecalSimulationParameters_cff import *',
'from Geometry.HcalCommonData.hcalDDDSimConstants_cff import *',
],
"reco" : [
'from Geometry.CaloEventSetup.CaloTopology_cfi import *',
'from Geometry.CaloEventSetup.CaloGeometryBuilder_cfi import *',
'CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder",',
' SelectedCalos = cms.vstring("HCAL",',
' "ZDC",',
' "EcalBarrel",',
' "EcalEndcap",',
' "EcalPreshower",',
' "TOWER",',
' )',
')',
'from Geometry.EcalAlgo.EcalGeometry_cfi import *',
'from Geometry.HcalEventSetup.HcalGeometry_cfi import *',
'from Geometry.HcalEventSetup.CaloTowerGeometry_cfi import *',
'from Geometry.HcalEventSetup.CaloTowerTopology_cfi import *',
'from Geometry.HcalCommonData.hcalDDDRecConstants_cfi import *',
'from Geometry.HcalEventSetup.hcalTopologyIdeal_cfi import *',
'from Geometry.ForwardGeometry.ForwardGeometry_cfi import *',
'from Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi import *',
'from Geometry.EcalMapping.EcalMapping_cfi import *',
'from Geometry.EcalMapping.EcalMappingRecord_cfi import *',
],
"era" : "run3_HB",
},
}

muonDict = {
Expand Down Expand Up @@ -1497,7 +1565,7 @@
'Geometry/MuonCommonData/data/mfshield/2017/v2/mfshield.xml',
],
2 : [
'Geometry/MuonCommonData/data/muonNumbering/2021/v5/muonNumbering.xml',
'Geometry/MuonCommonData/data/muonNumbering/2024/v1/muonNumbering.xml',
],
3 : [
'Geometry/MuonSimData/data/muonSens/2021/v4/muonSens.xml',
Expand Down Expand Up @@ -1655,7 +1723,7 @@
'Geometry/ForwardCommonData/data/zdcrotations.xml',
'Geometry/ForwardCommonData/data/lumirotations.xml',
'Geometry/ForwardCommonData/data/zdc/2021/v3/zdc.xml',
'Geometry/ForwardCommonData/data/rpd/2021/v1/rpd.xml',
'Geometry/ForwardCommonData/data/rpd/2021/v2/rpd.xml',
'Geometry/ForwardCommonData/data/cmszdc.xml',
],
3 : [
Expand Down Expand Up @@ -1795,12 +1863,12 @@
("O5","T6","C1","M2","F2","P7") : "2023FlatMinus10Percent",
("O5","T7","C1","M2","F2","P7") : "2023FlatPlus05Percent",
("O5","T8","C1","M2","F2","P7") : "2023FlatPlus10Percent",
("O6","T3","C1","M4","F3","P7") : "2024",
("O4","T4","C1","M4","F2","P7") : "2024ZeroMaterial",
("O5","T5","C1","M4","F2","P7") : "2024FlatMinus05Percent",
("O5","T6","C1","M4","F2","P7") : "2024FlatMinus10Percent",
("O5","T7","C1","M4","F2","P7") : "2024FlatPlus05Percent",
("O5","T8","C1","M4","F2","P7") : "2024FlatPlus10Percent",
("O6","T3","C2","M4","F3","P7") : "2024",
("O4","T4","C2","M4","F2","P7") : "2024ZeroMaterial",
("O5","T5","C2","M4","F2","P7") : "2024FlatMinus05Percent",
("O5","T6","C2","M4","F2","P7") : "2024FlatMinus10Percent",
("O5","T7","C2","M4","F2","P7") : "2024FlatPlus05Percent",
("O5","T8","C2","M4","F2","P7") : "2024FlatPlus10Percent",
}

deprecatedSubdets = set([ "T1", "T2", "O1", "O2", "O3", "P1", "P2", "P3",
Expand Down
4 changes: 0 additions & 4 deletions Geometry/CaloGeometry/src/CaloGenericDetId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ bool CaloGenericDetId::validDetId() const {
} else if (isHcal()) {
edm::LogError("CaloGenericDetIdError") << "No support for HB/HE/HO/HF in CaloGenericDetId";
throw cms::Exception("No support");

returnValue = false;
} else if (isZDC()) {
const HcalZDCDetId zdid(rawId());
returnValue = HcalZDCDetId::validDetId(zdid.section(), zdid.channel());
} else if (isCastor()) {
const HcalCastorDetId zdid(rawId());
returnValue = HcalCastorDetId::validDetId(zdid.section(), zdid.zside() > 0, zdid.sector(), zdid.module());
Expand Down
Loading

0 comments on commit 9352017

Please sign in to comment.