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

bsunanda:Run2-hcx60 Provide hexgonal geometry for HGCal #12845

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions CondFormats/GeometryObjects/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<use name="DataFormats/DetId"/>
<use name="CondFormats/Serialization"/>
<use name="boost_serialization"/>
<use name="clhep"/>

<export>
<lib name="1"/>
Expand Down
104 changes: 104 additions & 0 deletions CondFormats/GeometryObjects/interface/HGCalParameters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#ifndef CondFormats_GeometryObjects_HGCalParameters_h
#define CondFormats_GeometryObjects_HGCalParameters_h

#include "CondFormats/Serialization/interface/Serializable.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include<string>
#include<vector>
#include<iostream>
#include<stdint.h>
#include<CLHEP/Geometry/Transform3D.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsunanda - please, add a space in the lines above. I think, using clhep here is not a good idea.


class HGCalParameters {

public:

struct hgtrap {
int lay;
float bl, tl, h, dz, alpha, cellSize;
};

struct hgtrform {
int zp, lay, sec, subsec;
CLHEP::Hep3Vector h3v;
CLHEP::HepRotation hr;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsunanda - this object should define what is stored to/retrieved from DB. I think, using vectors of doubles is better.


HGCalParameters(const std::string& nam);
~HGCalParameters( void );
void fillModule(const hgtrap& mytr, bool reco);
hgtrap getModule(unsigned int k, bool reco) const;
void fillTrForm(const hgtrform& mytr);
hgtrform getTrForm(unsigned int k) const;
void addTrForm(const CLHEP::Hep3Vector& h3v);
void scaleTrForm(double);

static const int kMaskZside = 0x1;
static const int kMaskLayer = 0x7F;
static const int kMaskSector = 0x3FF;
static const int kMaskSubSec = 0x1;
static const int kShiftZside = 19;
static const int kShiftLayer = 12;
static const int kShiftSector = 1;
static const int kShiftSubSec = 0;

std::string name_;
int nCells_;
int nSectors_;
std::vector<double> cellSize_;
std::vector<int> moduleLayS_;
std::vector<double> moduleBlS_;
std::vector<double> moduleTlS_;
std::vector<double> moduleHS_;
std::vector<double> moduleDzS_;
std::vector<double> moduleAlphaS_;
std::vector<double> moduleCellS_;
std::vector<int> moduleLayR_;
std::vector<double> moduleBlR_;
std::vector<double> moduleTlR_;
std::vector<double> moduleHR_;
std::vector<double> moduleDzR_;
std::vector<double> moduleAlphaR_;
std::vector<double> moduleCellR_;
std::vector<uint32_t> trformIndex_;
std::vector<double> trformTranX_;
std::vector<double> trformTranY_;
std::vector<double> trformTranZ_;
std::vector<double> trformRotXX_;
std::vector<double> trformRotYX_;
std::vector<double> trformRotZX_;
std::vector<double> trformRotXY_;
std::vector<double> trformRotYY_;
std::vector<double> trformRotZY_;
std::vector<double> trformRotXZ_;
std::vector<double> trformRotYZ_;
std::vector<double> trformRotZZ_;
std::vector<int> layer_;
std::vector<int> layerIndex_;
std::vector<int> layerGroup_;
std::vector<int> cellFactor_;
std::vector<int> depth_;
std::vector<int> depthIndex_;
std::vector<int> depthLayerF_;
std::vector<double> zLayerHex_;
std::vector<double> rMinLayHex_;
std::vector<double> rMaxLayHex_;
std::vector<int> waferCopy_;
std::vector<int> waferTypeL_;
std::vector<int> waferTypeT_;
std::vector<double> waferPosX_;
std::vector<double> waferPosY_;
std::vector<double> cellFineX_;
std::vector<double> cellFineY_;
std::vector<double> cellCoarseX_;
std::vector<double> cellCoarseY_;
std::vector<int> layerGroupM_;
std::vector<int> layerGroupO_;
std::vector<double> boundR_;
double waferR_;
int mode_;

COND_SERIALIZABLE;
};

#endif
146 changes: 146 additions & 0 deletions CondFormats/GeometryObjects/src/HGCalParameters.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include "CondFormats/GeometryObjects/interface/HGCalParameters.h"
//#define DebugLog

HGCalParameters::HGCalParameters(const std::string& nam): name_(nam) { }

HGCalParameters::~HGCalParameters() { }

void HGCalParameters::fillModule(const HGCalParameters::hgtrap& mytr,
bool reco) {

if (reco) {
moduleLayR_.push_back(mytr.lay);
moduleBlR_.push_back(mytr.bl);
moduleTlR_.push_back(mytr.tl);
moduleHR_.push_back(mytr.h);
moduleDzR_.push_back(mytr.dz);
moduleAlphaR_.push_back(mytr.alpha);
moduleCellR_.push_back(mytr.cellSize);
} else {
moduleLayS_.push_back(mytr.lay);
moduleBlS_.push_back(mytr.bl);
moduleTlS_.push_back(mytr.tl);
moduleHS_.push_back(mytr.h);
moduleDzS_.push_back(mytr.dz);
moduleAlphaS_.push_back(mytr.alpha);
moduleCellS_.push_back(mytr.cellSize);
}
}

HGCalParameters::hgtrap HGCalParameters::getModule(unsigned int k,
bool reco) const {
HGCalParameters::hgtrap mytr;
if (reco) {
if (k < moduleLayR_.size()) {
mytr.lay = moduleLayR_[k];
mytr.bl = moduleBlR_[k];
mytr.tl = moduleTlR_[k];
mytr.h = moduleHR_[k];
mytr.dz = moduleDzR_[k];
mytr.alpha = moduleAlphaR_[k];
mytr.cellSize = moduleCellR_[k];
} else {
mytr.lay = -1;
mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0;
}
} else {
if (k < moduleLayS_.size()) {
mytr.lay = moduleLayS_[k];
mytr.bl = moduleBlS_[k];
mytr.tl = moduleTlS_[k];
mytr.h = moduleHS_[k];
mytr.dz = moduleDzS_[k];
mytr.alpha = moduleAlphaS_[k];
mytr.cellSize = moduleCellS_[k];
} else {
mytr.lay = -1;
mytr.bl = mytr.tl = mytr.h = mytr.dz = mytr.alpha = mytr.cellSize = 0;
}
}
return mytr;
}

void HGCalParameters::fillTrForm(const HGCalParameters::hgtrform& mytr) {

int zp = (mytr.zp == 1) ? 1 : 0;
uint32_t indx = ((zp & kMaskZside) << kShiftZside);
indx |= ((mytr.lay & kMaskLayer) << kShiftLayer);
indx |= ((mytr.sec & kMaskSector) << kShiftSector);
indx |= ((mytr.subsec & kMaskSubSec) << kShiftSubSec);
// std::cout << "ZP " << zp << ":" << kMaskZside << ":" << kShiftZside << ((zp & kMaskZside) << kShiftZside) << " Lay " << mytr.lay << ":" << kMaskLayer << ":" << kShiftLayer << ":" << ((mytr.lay & kMaskLayer) << kShiftLayer) << " Sector " << mytr.sec << ":" << kMaskSector << ":" << kShiftSector << ":" << ((mytr.sec & kMaskSector) << kShiftSector) << " SubSec " << mytr.subsec << ":" << kMaskSubSec << ":" << kShiftSubSec << ":" << ((mytr.subsec & kMaskSubSec) << kShiftSubSec) << " Index " << std::hex << indx << std::dec << std::endl;

trformIndex_.push_back(indx);
trformTranX_.push_back(mytr.h3v.x());
trformTranY_.push_back(mytr.h3v.y());
trformTranZ_.push_back(mytr.h3v.z());
trformRotXX_.push_back(mytr.hr.xx());
trformRotYX_.push_back(mytr.hr.yx());
trformRotZX_.push_back(mytr.hr.zx());
trformRotXY_.push_back(mytr.hr.xy());
trformRotYY_.push_back(mytr.hr.yy());
trformRotZY_.push_back(mytr.hr.zy());
trformRotXZ_.push_back(mytr.hr.xz());
trformRotYZ_.push_back(mytr.hr.yz());
trformRotZZ_.push_back(mytr.hr.zz());
#ifdef DebugLog
unsigned int k = trformIndex_.size() - 1;
std::cout << "HGCalParameters[" << k << "] Index " << std::hex
<< trformIndex_[k] << std::dec << " (" << mytr.zp << ", "<< mytr.lay
<< ", " << mytr.sec << ", " << mytr.subsec << ") Translation ("
<< trformTranX_[k] << ", " << trformTranY_[k] << ", "
<< trformTranZ_[k] << ") Rotation (" << trformRotXX_[k] << ", "
<< trformRotYX_[k] << ", " << trformRotZX_[k] << ", "
<< trformRotXY_[k] << ", " << trformRotYY_[k] << ", "
<< trformRotZY_[k] << ", " << trformRotXZ_[k] << ", "
<< trformRotYZ_[k] << ", " << trformRotZZ_[k] << std::endl;
#endif
}

HGCalParameters::hgtrform HGCalParameters::getTrForm(unsigned int k) const {

HGCalParameters::hgtrform mytr;
if (k < trformIndex_.size()) {
int zp = ((trformIndex_[k] >> kShiftZside) & kMaskZside);
mytr.zp = (zp == 1) ? 1 : -1;
mytr.lay = ((trformIndex_[k] >> kShiftLayer) & kMaskLayer);
mytr.sec = ((trformIndex_[k] >> kShiftSector) & kMaskSector);
mytr.subsec= ((trformIndex_[k] >> kShiftSubSec) & kMaskSubSec);
mytr.h3v = CLHEP::Hep3Vector(trformTranX_[k],trformTranY_[k],trformTranZ_[k]);
const CLHEP::HepRep3x3 rotation(trformRotXX_[k],trformRotXY_[k],trformRotXZ_[k],
trformRotYX_[k],trformRotYY_[k],trformRotYZ_[k],
trformRotZX_[k],trformRotZY_[k],trformRotZZ_[k]);
mytr.hr = CLHEP::HepRotation(rotation);
} else {
mytr.zp = mytr.lay = mytr.sec = mytr.subsec = 0;
}
#ifdef DebugLog
std::cout << "HGCalParameters[" << k << "] Index " << std::hex
<< trformIndex_[k] << std::dec << " (" << mytr.zp << ", "<< mytr.lay
<< ", " << mytr.sec << ", " << mytr.subsec << ") Translation ("
<< mytr.h3v.x() << ", " << mytr.h3v.y() << ", " << mytr.h3v.z()
<< ") Rotation (" << mytr.hr.xx() << ", " << mytr.hr.yx() << ", "
<< mytr.hr.zx() << ", " << mytr.hr.xy() << ", " << mytr.hr.yy()
<< ", " << mytr.hr.zy() << ", " << mytr.hr.xz() << ", "
<< mytr.hr.yz() << ", " << mytr.hr.zz() << std::endl;
#endif
return mytr;
}

void HGCalParameters::addTrForm(const CLHEP::Hep3Vector& h3v) {

unsigned int k = trformTranX_.size();
if (k > 0) {
trformTranX_[k-1] += h3v.x();
trformTranY_[k-1] += h3v.y();
trformTranZ_[k-1] += h3v.z();
}
}

void HGCalParameters::scaleTrForm(double scale) {
unsigned int k = trformTranX_.size();
if (k > 0) {
trformTranX_[k-1] *= scale;
trformTranY_[k-1] *= scale;
trformTranZ_[k-1] *= scale;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "CondFormats/GeometryObjects/interface/HGCalParameters.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(HGCalParameters);
1 change: 1 addition & 0 deletions CondFormats/GeometryObjects/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h"
#include "CondFormats/GeometryObjects/interface/HcalParameters.h"
#include "CondFormats/GeometryObjects/interface/PHcalParameters.h"
#include "CondFormats/GeometryObjects/interface/HGCalParameters.h"

61 changes: 61 additions & 0 deletions CondFormats/GeometryObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,67 @@
<class name="HcalParameters::LayerItem"/>
<class name="std::vector<HcalParameters::LayerItem>"/>


<class name="HGCalParameters" class_version="0">
<field name="name_" mapping="blob"/>
<field name="nCells_" mapping="blob"/>
<field name="nSectors_" mapping="blob"/>
<field name="cellSize_" mapping="blob"/>
<field name="layer_" mapping="blob"/>
<field name="layerIndex_" mapping="blob"/>
<field name="layerGroup_" mapping="blob"/>
<field name="cellFactor_" mapping="blob"/>
<field name="depth_" mapping="blob"/>
<field name="depthIndex_" mapping="blob"/>
<field name="depthLayerF_" mapping="blob"/>
<field name="zLayerHex_" mapping="blob"/>
<field name="rMinLayHex_" mapping="blob"/>
<field name="rMaxLayHex_" mapping="blob"/>
<field name="waferCopy_" mapping="blob"/>
<field name="waferTypeL_" mapping="blob"/>
<field name="waferTypeT_" mapping="blob"/>
<field name="moduleLayS_" mapping="blob"/>
<field name="moduleBlS_" mapping="blob"/>
<field name="moduleTlS_" mapping="blob"/>
<field name="moduleHS_" mapping="blob"/>
<field name="moduleDzS_" mapping="blob"/>
<field name="moduleAlphaS_" mapping="blob"/>
<field name="moduleCellS_" mapping="blob"/>
<field name="moduleLayR_" mapping="blob"/>
<field name="moduleBlR_" mapping="blob"/>
<field name="moduleTlR_" mapping="blob"/>
<field name="moduleHR_" mapping="blob"/>
<field name="moduleDzR_" mapping="blob"/>
<field name="moduleAlphaR_" mapping="blob"/>
<field name="moduleCellR_" mapping="blob"/>
<field name="modules_" mapping="blob"/>
<field name="moduler_" mapping="blob"/>
<field name="trformIndex_" mapping="blob"/>
<field name="trformTranX_" mapping="blob"/>
<field name="trformTranY_" mapping="blob"/>
<field name="trformTranZ_" mapping="blob"/>
<field name="trformRotXX_" mapping="blob"/>
<field name="trformRotYX_" mapping="blob"/>
<field name="trformRotZX_" mapping="blob"/>
<field name="trformRotXY_" mapping="blob"/>
<field name="trformRotYY_" mapping="blob"/>
<field name="trformRotZY_" mapping="blob"/>
<field name="trformRotXZ_" mapping="blob"/>
<field name="trformRotYZ_" mapping="blob"/>
<field name="trformRotZZ_" mapping="blob"/>
<field name="waferPosX_" mapping="blob"/>
<field name="waferPosY_" mapping="blob"/>
<field name="cellFineX_" mapping="blob"/>
<field name="cellFineY_" mapping="blob"/>
<field name="cellCoarseX_" mapping="blob"/>
<field name="cellCoarseY_" mapping="blob"/>
<field name="layerGroupM_" mapping="blob"/>
<field name="layerGroupO_" mapping="blob"/>
<field name="boundR_" mapping="blob"/>
<field name="waferR_" mapping="blob"/>
<field name="mode_" mapping="blob"/>
</class>

<class name="PHcalParameters" class_version="0">
<field name="phioff" mapping="blob"/>
<field name="etaTable" mapping="blob"/>
Expand Down
2 changes: 2 additions & 0 deletions Configuration/Geometry/python/GeometryExtended2023Dev_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *
from Geometry.HcalCommonData.hcalParameters_cfi import *
from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import *
from Geometry.HGCalCommonData.hgcalParametersInitialization_cfi import *
from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import *
25 changes: 22 additions & 3 deletions Configuration/Geometry/python/GeometryExtended2023Reco_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from Geometry.MuonNumbering.muonNumberingInitialization_cfi import *
from RecoMuon.DetLayers.muonDetLayerGeometry_cfi import *
from Geometry.GEMGeometryBuilder.gemGeometry_cfi import *
from Geometry.GEMGeometryBuilder.me0Geometry_cfi import *

# Alignment
from Geometry.TrackerGeometryBuilder.idealForDigiTrackerGeometry_cff import *
Expand All @@ -25,10 +26,28 @@
trackerGeometry.applyAlignment = cms.bool(False)

# Calorimeters
from Geometry.CaloEventSetup.HGCalTopology_cfi import *
from Geometry.HGCalGeometry.HGCalGeometryESProducer_cfi import *
from Geometry.CaloEventSetup.CaloTopology_cfi import *
from Geometry.CaloEventSetup.CaloGeometry_cff import *
from Geometry.CaloEventSetup.CaloGeometryBuilder_cfi import *

CaloGeometryBuilder = cms.ESProducer("CaloGeometryBuilder",
SelectedCalos = cms.vstring('HCAL' ,
'ZDC' ,
'CASTOR' ,
'EcalBarrel' ,
'TOWER' )
)

from Geometry.EcalAlgo.EcalBarrelGeometry_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 *
from Geometry.HcalCommonData.hcalDDDRecConstants_cfi import *
from Geometry.HcalEventSetup.hcalTopologyIdeal_cfi import *

1 change: 1 addition & 0 deletions Configuration/Geometry/python/GeometryExtended2023_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *
from Geometry.HcalCommonData.hcalParameters_cfi import *
from Geometry.HcalCommonData.hcalDDDSimConstants_cfi import *
from Geometry.HGCalCommonData.hgcalParametersInitialization_cfi import *
from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import *
from Geometry.CaloEventSetup.HGCalTopology_cfi import *
Loading