6 #include <Math/Transform3D.h> 7 #include <Math/EulerAngles.h> 17 m_topology(topology), m_mergePosition(topology.getMergePositionFlag()) {
26 std::cout <<
"HcalGeometry: " <<
"HcalGeometry::init() " 42 std::unique_ptr<std::vector<DetId>> p_hbIds{
new std::vector<DetId>};
43 std::unique_ptr<std::vector<DetId>> p_heIds{
new std::vector<DetId>};
44 std::unique_ptr<std::vector<DetId>> p_hoIds{
new std::vector<DetId>};
45 std::unique_ptr<std::vector<DetId>> p_hfIds{
new std::vector<DetId>};
46 std::unique_ptr<std::vector<DetId>> p_emptyIds{
new std::vector<DetId>};
49 for (
unsigned int i ( 0 ) ;
i != baseIds.size() ; ++
i) {
52 p_hbIds->emplace_back(
id ) ;
54 p_heIds->emplace_back(
id ) ;
56 p_hoIds->emplace_back(
id ) ;
58 p_hfIds->emplace_back(
id ) ;
61 std::sort( p_hbIds->begin(), p_hbIds->end() ) ;
62 std::sort( p_heIds->begin(), p_heIds->end() ) ;
63 std::sort( p_hoIds->begin(), p_hoIds->end() ) ;
64 std::sort( p_hfIds->begin(), p_hfIds->end() ) ;
65 p_emptyIds->resize( 0 ) ;
75 const std::vector<DetId>&
91 if (!m_mergePosition) {
111 bool ignoreCorrect)
const {
115 static const double z_long=1100.0;
116 double abseta = fabs(r.
eta());
117 double absz = fabs(r.
z());
123 }
else if (absz >= z_long) {
132 int etaring =
etaRing(bc, abseta);
134 int phibin =
phiBin(bc, etaring, r.
phi());
137 int etabin = (r.
z() > 0) ? etaring : -etaring;
140 static const double z_short=1137.0;
144 HcalDetId bestId(bc,etabin,phibin,((fabs(r.
z()) - z_short >-0.1)?(2):(1)));
149 int zside = (r.
z() > 0) ? 1 : -1;
151 double pointrz(0), drz(99999.);
152 HcalDetId currentId(bc, etabin, phibin, dbin);
158 if (cell ==
nullptr) {
176 return (ignoreCorrect ? bestId :
correctId(bestId));
192 std::vector<HcalDetId>
ids;
202 std::vector<HcalDetId>
ids;
207 for (
unsigned int k=0;
k<4; ++
k) {
208 mcorners[
k] = mcf[
k];
209 mcorners[
k+4] = mcb[
k+4];
231 const double dR2 ( dR*dR ) ;
232 const double reta ( r.
eta() ) ;
233 const double rphi ( r.
phi() ) ;
234 const double lowEta ( reta - dR ) ;
235 const double highEta ( reta + dR ) ;
236 const double lowPhi ( rphi - dR ) ;
237 const double highPhi ( rphi + dR ) ;
241 if (highEta > -hfEtaHi &&
245 for (
unsigned int is ( 0 ) ; is != 4 ; ++is ) {
246 const int sign ( reta>0 ? 1 : -1 ) ;
247 const int ieta_center ( sign*
etaRing( hs[is], fabs( reta ) ) ) ;
248 const int ieta_lo ( ( 0 < lowEta*sign ? sign : -sign )*
etaRing( hs[is], fabs( lowEta ) ) ) ;
249 const int ieta_hi ( ( 0 < highEta*sign ? sign : -sign )*
etaRing( hs[is], fabs( highEta ) ) ) ;
250 const int iphi_lo (
phiBin( hs[is], ieta_center, lowPhi ) ) ;
251 const int iphi_hi (
phiBin( hs[is], ieta_center, highPhi ) ) ;
252 const int jphi_lo ( iphi_lo>iphi_hi ? iphi_lo - 72 : iphi_lo ) ;
253 const int jphi_hi ( iphi_hi ) ;
255 const int idep_lo ( 1 == is ? 4 : 1 ) ;
257 for (
int ieta ( ieta_lo ) ; ieta <= ieta_hi ; ++ieta) {
259 for (
int jphi ( jphi_lo ) ; jphi <= jphi_hi ; ++jphi) {
260 const int iphi ( 1 > jphi ? jphi+72 : jphi ) ;
261 for (
int idep ( idep_lo ) ; idep <= idep_hi ; ++idep ) {
262 const HcalDetId did ( hs[is], ieta, iphi, idep ) ;
265 if (
nullptr != cell ) {
267 const double eta (
p.eta() ) ;
268 const double phi (
p.phi() ) ;
284 unsigned int hxsize(0);
297 const int iphi ( 1 + (4*i)%72 ) ;
304 const int iphi ( 1 + (4*i)%72 ) ;
311 const int iphi ( 1 + (4*i)%72 ) ;
317 const int ring ( i/12 ) ;
318 const int ieta ( 0 == ring ? -11 :
321 3 == ring ? 5 : 11 ) ;
322 const int iphi ( 1 + ( i - ring*12 )*6 ) ;
343 const unsigned int iphi ( hid.
iphi() ) ;
344 const int ieta ( hid.
ieta() ) ;
345 const unsigned int index ( ( 0 < ieta ? nD/2 : 0 ) + ( iphi + 1 )%72/4 ) ;
346 assert( index < nD ) ;
364 const int ieta ( hid.
ieta() ) ;
365 const int iphi ( hid.
iphi() ) ;
366 const int ring ( ieta < -10 ? 0 :
369 ( ieta < 11 ? 3 : 4 ) ) ) ) ;
371 const unsigned int index ( 12*ring + ( iphi - 1 )/6 ) ;
421 const DetId& detId) {
429 std::cout <<
"HcalGeometry: " <<
" newCell subdet " 431 << detId.
rawId() <<
", hid " << hid <<
", din " 432 << din <<
", index " << std::endl;
441 const unsigned int index ( din
446 const unsigned int index ( din
460 const DetId& detId) {
465 m_dins.emplace_back( din );
472 const DetId& detId) {
477 m_dins.emplace_back( din );
499 return ((
nullptr == cell ||
nullptr == cell->
param()) ?
nullptr : cell ) ;
513 for (
float iv :
pv) {
514 dVec.emplace_back( iv ) ;
522 if (
nullptr != ptr) {
523 dinsVec.emplace_back(
i );
527 unsigned int ishape ( 9999 ) ;
529 for(
unsigned int ivv ( 0 ) ; ivv !=
parVecVec().size() ; ++ivv ) {
533 ok = ok && ( fabs( par[
k] - pv[
k] ) < 1.e-6 ) ;
540 assert( 9999 != ishape ) ;
542 const unsigned int nn ((
numberOfShapes()==1) ? (
unsigned int)1 : m_dins.size() ) ;
543 if( iVec.size() <
nn ) iVec.emplace_back( ishape ) ;
549 tr = HepGeom::Translate3D(
gp.x(),
gp.y(),
gp.z() ) ;
552 const CLHEP::Hep3Vector
tt ( tr.getTranslation() ) ;
553 tVec.emplace_back(
tt.x() ) ;
554 tVec.emplace_back(
tt.y() ) ;
555 tVec.emplace_back(
tt.z() ) ;
557 const CLHEP::HepRotation
rr ( tr.getRotation() ) ;
558 const ROOT::Math::Transform3D rtr (
rr.xx(),
rr.xy(),
rr.xz(),
tt.x(),
562 rtr.GetRotation( ea ) ;
563 tVec.emplace_back( ea.Phi() ) ;
564 tVec.emplace_back( ea.Theta() ) ;
565 tVec.emplace_back( ea.Psi() ) ;
DetId denseId2detId(unsigned int) const override
return a linear packed id
static unsigned int numberOfBarrelAlignments()
unsigned int getHFSize() const
std::set< DetId > DetIdSet
static unsigned int alignmentTransformIndexLocal(const DetId &id)
const HcalDDDRecConstants * dddConstants() const
std::vector< CCGFloat > DimVec
unsigned int getHOSize() const
CaloCellGeometry::Pt3DVec Pt3DVec
CaloSubdetectorGeometry::DetIdSet getCells(const GlobalPoint &r, double dR) const override
Get a list of all cells within a dR of the given cell.
edm::AtomicPtrCache< std::vector< DetId > > m_heIds
static unsigned int alignmentEndcapIndexLocal(const DetId &id)
HcalSubdetector subdet() const
get the subdetector
int phiBin(HcalSubdetector subdet, int etaRing, double phi) const
bool valid(const DetId &id) const override
CaloTopology const * topology(0)
unsigned int getHxSize(const int type) const
static DetId detIdFromOuterAlignmentIndex(unsigned int i)
unsigned int detId2denseId(const DetId &id) const override
return a linear packed id
virtual const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
unsigned int numberOfShapes() const override
Geom::Phi< T > phi() const
const HcalTopology & m_topology
std::vector< unsigned int > IVec
edm::AtomicPtrCache< std::vector< DetId > > m_emptyIds
const CaloCellGeometry * getGeometryBase(const DetId &id) const
bool isHE(int etabin, int depth)
std::vector< CCGFloat > TrVec
HepGeom::Transform3D Tr3D
std::vector< IdealObliquePrism > HECellVec
std::vector< Pt3D > Pt3DVec
bool isHB(int etabin, int depth)
CaloCellGeometry::CCGFloat CCGFloat
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
HcalDetId mergedDepthDetId(const HcalDetId &id) const
const CaloCellGeometry * getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.
CaloCellGeometry::Tr3D Tr3D
uint32_t rawId() const
get the raw id
void newCellFast(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
CaloCellGeometry::Pt3DVec Pt3DVec
virtual DetIdSet getCells(const GlobalPoint &r, double dR) const
Get a list of all cells within a dR of the given cell.
const CCGFloat * param() const
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
virtual void getTransform(Tr3D &tr, Pt3DVec *lptr) const
--------— only needed by specific utility; overloaded when needed -—
unsigned int numberOfParametersPerShape() const override
std::vector< DetId > m_validIds
std::vector< IdealObliquePrism > HOCellVec
static unsigned int numberOfOuterAlignments()
int maxDepth(HcalSubdetector subdet) const
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
int etaRing(HcalSubdetector subdet, double eta) const
eta and phi index from eta, phi values
DetId correctId(const DetId &id) const
int ieta() const
get the cell ieta
static DetId detIdFromForwardAlignmentIndex(unsigned int i)
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
static unsigned int alignmentBarrelIndexLocal(const DetId &id)
Abs< T >::type abs(const T &t)
static DetId detIdFromBarrelAlignmentIndex(unsigned int i)
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
CaloCellGeometry::CCGFloat CCGFloat
int phiBin(HcalSubdetector bc, int etaring, double phi) const
const CaloCellGeometry * cellGeomPtr(unsigned int index) const override
static DetId detIdFromLocalAlignmentIndex(unsigned int i)
int etaRing(HcalSubdetector bc, double abseta) const
helper methods for getClosestCell
CaloSubdetectorGeometry::IVec m_dins
HcalGeometry(const HcalTopology &topology)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
GlobalPoint getPosition(const DetId &id) const
void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
static unsigned int alignmentOuterIndexLocal(const DetId &id)
std::vector< IdealZPrism > HFCellVec
int iphi() const
get the cell iphi
~HcalGeometry() override
The HcalGeometry will delete all its cell geometries at destruction time.
bool incrementDepth(HcalDetId &id) const
static unsigned int numberOfEndcapAlignments()
CaloCellGeometry::Pt3D Pt3D
AlgebraicVector EulerAngles
void addValidID(const DetId &id)
bool set(std::unique_ptr< T > iNewValue) const
CaloCellGeometry::CornersMgr * cornersMgr()
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
CaloCellGeometry::CornersVec getCorners(const DetId &id) const
HepGeom::Point3D< CCGFloat > Pt3D
bool isHF(int etabin, int depth)
std::vector< IdealObliquePrism > HBCellVec
unsigned int getHESize() const
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
CaloCellGeometry::Tr3D Tr3D
void increaseReserve(unsigned int extra)
void getSummary(CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, CaloSubdetectorGeometry::IVec &dinsVector) const override
edm::AtomicPtrCache< std::vector< DetId > > m_hfIds
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
static unsigned int numberOfForwardAlignments()
unsigned int ncells() const override
return a count of valid cells (for dense indexing use)
static unsigned int alignmentForwardIndexLocal(const DetId &id)
GlobalPoint getBackPosition(const DetId &id) const
HcalDetId idFront(const HcalDetId &id) const
static DetId detIdFromEndcapAlignmentIndex(unsigned int i)
static unsigned int alignmentBarEndForIndexLocal(const DetId &id, unsigned int nD)
virtual unsigned int numberOfTransformParms() const
edm::AtomicPtrCache< std::vector< DetId > > m_hoIds
CaloCellGeometry::Pt3D Pt3D
bool withSpecialRBXHBHE() const
Detector det() const
get the detector field from this detid
unsigned int getHBSize() const
unsigned int newCellImpl(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
edm::AtomicPtrCache< std::vector< DetId > > m_hbIds
static unsigned int numberOfAlignments()
DetId getClosestCell(const GlobalPoint &r) const override
double etaMax(HcalSubdetector subdet) const