Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16562 from bsunanda/Phase2-ft09
bsunanda:Phase2-ft09 Add Reco geometry for Fast Timing
- Loading branch information
Showing
27 changed files
with
1,318 additions
and
35 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
Geometry/CaloEventSetup/plugins/FastTimeTopologyBuilder.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// -*- C++ -*- | ||
// | ||
// Package: CaloEventSetup | ||
// Class: FastTimeTopologyBuilder | ||
// | ||
/**\class FastTimeTopologyBuilder FastTimeTopologyBuilder.h | ||
Description: <one line class summary> | ||
Implementation: | ||
<Notes on implementation> | ||
*/ | ||
// | ||
// Original Author: Sunanda Banerjee | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
|
||
// user include files | ||
#include <FWCore/Framework/interface/ModuleFactory.h> | ||
#include "FWCore/Framework/interface/ESProducer.h" | ||
|
||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "Geometry/CaloTopology/interface/FastTimeTopology.h" | ||
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" | ||
#include "Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h" | ||
#include "Geometry/Records/interface/IdealGeometryRecord.h" | ||
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" | ||
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" | ||
|
||
//#define EDM_ML_DEBUG | ||
|
||
// | ||
// class decleration | ||
// | ||
|
||
class FastTimeTopologyBuilder : public edm::ESProducer { | ||
|
||
public: | ||
FastTimeTopologyBuilder( const edm::ParameterSet& iP ); | ||
~FastTimeTopologyBuilder() ; | ||
|
||
typedef std::shared_ptr< FastTimeTopology > ReturnType; | ||
|
||
ReturnType produce(const IdealGeometryRecord&); | ||
|
||
private: | ||
// ----------member data --------------------------- | ||
std::string name_; | ||
int type_; | ||
ForwardSubdetector subdet_; | ||
}; | ||
|
||
|
||
FastTimeTopologyBuilder::FastTimeTopologyBuilder(const edm::ParameterSet& iConfig) { | ||
|
||
name_ = iConfig.getUntrackedParameter<std::string>("Name"); | ||
type_ = iConfig.getUntrackedParameter<int>("Type"); | ||
subdet_ = FastTime; | ||
#ifdef EDM_ML_DEBUG | ||
std::cout <<"constructing FastTimeTopology for " << name_ << " Type " | ||
<< type_ << std::endl; | ||
#endif | ||
setWhatProduced(this, name_); | ||
} | ||
|
||
|
||
FastTimeTopologyBuilder::~FastTimeTopologyBuilder() { } | ||
|
||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
FastTimeTopologyBuilder::ReturnType | ||
FastTimeTopologyBuilder::produce(const IdealGeometryRecord& iRecord ) { | ||
|
||
edm::ESHandle<FastTimeDDDConstants> pHGDC; | ||
iRecord.get(pHGDC) ; | ||
const FastTimeDDDConstants & hgdc = (*pHGDC); | ||
|
||
ReturnType ct ( new FastTimeTopology(hgdc, subdet_, type_) ) ; | ||
#ifdef EDM_ML_DEBUG | ||
std::cout << "Create FastTimeTopology(hgdc,subdet,type)" << std::endl; | ||
#endif | ||
return ct ; | ||
} | ||
|
||
DEFINE_FWK_EVENTSETUP_MODULE(FastTimeTopologyBuilder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
# | ||
# This cfi should be included to build the FastTime Topologies | ||
# | ||
FastTimeBarrelTopologyBuilder = cms.ESProducer("FastTimeTopologyBuilder", | ||
Name = cms.untracked.string("FastTimeBarrel"), | ||
Type = cms.untracked.int32(1) | ||
) | ||
|
||
|
||
FastTimeEndcapTopologyBuilder = cms.ESProducer("FastTimeTopologyBuilder", | ||
Name = cms.untracked.string("SFBX"), | ||
Type = cms.untracked.int32(2) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#ifndef Geometry_CaloTopology_FastTimeTopology_h | ||
#define Geometry_CaloTopology_FastTimeTopology_h 1 | ||
|
||
#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" | ||
#include "DataFormats/ForwardDetId/interface/HGCEEDetId.h" | ||
#include "DataFormats/ForwardDetId/interface/HGCHEDetId.h" | ||
#include "DataFormats/ForwardDetId/interface/FastTimeDetId.h" | ||
#include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" | ||
#include "Geometry/HGCalCommonData/interface/FastTimeDDDConstants.h" | ||
#include <vector> | ||
#include <iostream> | ||
|
||
class FastTimeTopology : public CaloSubdetectorTopology { | ||
|
||
public: | ||
/// create a new Topology | ||
FastTimeTopology(const FastTimeDDDConstants& hdcons, | ||
ForwardSubdetector subdet, int type); | ||
|
||
/// virtual destructor | ||
virtual ~FastTimeTopology() { } | ||
|
||
/// move the Topology north (increment iy) | ||
virtual DetId goNorth(const DetId& id) const { | ||
return offsetBy(id,0,+1); | ||
} | ||
virtual std::vector<DetId> north(const DetId& id) const { | ||
DetId nextId= goNorth(id); | ||
std::vector<DetId> vNeighborsDetId; | ||
if (! (nextId==DetId(0))) | ||
vNeighborsDetId.push_back(DetId(nextId.rawId())); | ||
return vNeighborsDetId; | ||
} | ||
|
||
/// move the Topology south (decrement iy) | ||
virtual DetId goSouth(const DetId& id) const { | ||
return offsetBy(id,0,-1); | ||
} | ||
virtual std::vector<DetId> south(const DetId& id) const { | ||
DetId nextId= goSouth(id); | ||
std::vector<DetId> vNeighborsDetId; | ||
if (! (nextId==DetId(0))) | ||
vNeighborsDetId.push_back(DetId(nextId.rawId())); | ||
return vNeighborsDetId; | ||
} | ||
|
||
/// move the Topology east (positive ix) | ||
virtual DetId goEast(const DetId& id) const { | ||
return offsetBy(id,+1,0); | ||
} | ||
virtual std::vector<DetId> east(const DetId& id) const { | ||
DetId nextId=goEast(id); | ||
std::vector<DetId> vNeighborsDetId; | ||
if (! (nextId==DetId(0))) | ||
vNeighborsDetId.push_back(DetId(nextId.rawId())); | ||
return vNeighborsDetId; | ||
} | ||
|
||
/// move the Topology west (negative ix) | ||
virtual DetId goWest(const DetId& id) const { | ||
return offsetBy(id,-1,0); | ||
} | ||
virtual std::vector<DetId> west(const DetId& id) const { | ||
DetId nextId=goWest(id); | ||
std::vector<DetId> vNeighborsDetId; | ||
if (! (nextId==DetId(0))) | ||
vNeighborsDetId.push_back(DetId(nextId.rawId())); | ||
return vNeighborsDetId; | ||
} | ||
|
||
virtual std::vector<DetId> up(const DetId& id) const { | ||
std::vector<DetId> vNeighborsDetId; | ||
return vNeighborsDetId; | ||
} | ||
|
||
virtual std::vector<DetId> down(const DetId& id) const { | ||
std::vector<DetId> vNeighborsDetId; | ||
return vNeighborsDetId; | ||
} | ||
|
||
///Dense indexing | ||
virtual uint32_t detId2denseId(const DetId& id) const; | ||
virtual DetId denseId2detId(uint32_t denseId) const; | ||
virtual uint32_t detId2denseGeomId(const DetId& id) const; | ||
|
||
///Is this a valid cell id | ||
virtual bool valid(const DetId& id) const; | ||
bool validHashIndex(uint32_t ix) const {return (ix < kSizeForDenseIndexing);} | ||
|
||
unsigned int totalModules() const {return kSizeForDenseIndexing;} | ||
unsigned int totalGeomModules() const {return (unsigned int)(2*kHGeomHalf_);} | ||
int numberCells() const {return kHGeomHalf_;} | ||
|
||
const FastTimeDDDConstants& dddConstants () const {return hdcons_;} | ||
|
||
DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY ) const; | ||
DetId switchZSide(const DetId startId) const; | ||
|
||
struct DecodedDetId { | ||
DecodedDetId() : iPhi(0), iEtaZ(0), zside(0), iType(0), subdet(0) {} | ||
int iPhi, iEtaZ, zside, iType, subdet; | ||
}; | ||
|
||
DecodedDetId geomDenseId2decId(const uint32_t& hi) const; | ||
DecodedDetId decode(const DetId& id) const ; | ||
DetId encode(const DecodedDetId& id_) const ; | ||
|
||
ForwardSubdetector subDetector() const { return subdet_;} | ||
int detectorType() const { return type_;} | ||
private: | ||
|
||
/// move the nagivator along x, y | ||
DetId changeXY(const DetId& id, int nrStepsX, int nrStepsY) const ; | ||
|
||
const FastTimeDDDConstants& hdcons_; | ||
ForwardSubdetector subdet_; | ||
int type_, nEtaZ_, nPhi_, kHGhalf_, kHGeomHalf_; | ||
unsigned int kSizeForDenseIndexing; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include "Geometry/CaloTopology/interface/FastTimeTopology.h" | ||
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" | ||
|
||
#define EDM_ML_DEBUG | ||
|
||
FastTimeTopology::FastTimeTopology(const FastTimeDDDConstants& hdcons, | ||
ForwardSubdetector sub, | ||
int type) : hdcons_(hdcons), subdet_(sub), | ||
type_(type) { | ||
nEtaZ_ = hdcons_.numberEtaZ(type_); | ||
nPhi_ = hdcons_.numberPhi(type_); | ||
kHGhalf_ = nEtaZ_*nPhi_; | ||
kHGeomHalf_ = 1; | ||
kSizeForDenseIndexing = (unsigned int)(2*kHGhalf_); | ||
#ifdef EDM_ML_DEBUG | ||
std::cout << "FastTimeTopology initialized for subDetetcor " << subdet_ | ||
<< " Type " << type_ << " with " << nEtaZ_ | ||
<< " cells along Z|Eta and " << nPhi_ | ||
<< " cells along phi: total channels " << kSizeForDenseIndexing | ||
<< ":" << (2*kHGeomHalf_) << std::endl; | ||
#endif | ||
} | ||
|
||
uint32_t FastTimeTopology::detId2denseId(const DetId& id) const { | ||
|
||
FastTimeTopology::DecodedDetId id_ = decode(id); | ||
uint32_t idx = (uint32_t)(((id_.zside > 0) ? kHGhalf_ : 0) + | ||
((id_.iEtaZ-1)*nPhi_+id_.iPhi-1)); | ||
return idx; | ||
} | ||
|
||
DetId FastTimeTopology::denseId2detId(uint32_t hi) const { | ||
|
||
if (validHashIndex(hi)) { | ||
FastTimeTopology::DecodedDetId id_; | ||
id_.iType = type_; | ||
id_.zside = ((int)(hi)<kHGhalf_ ? -1 : 1); | ||
int di = ((int)(hi)%kHGhalf_); | ||
int iPhi = (di%nPhi_); | ||
id_.iPhi = iPhi+1; | ||
id_.iEtaZ = (((di-iPhi)/nPhi_)+1); | ||
return encode(id_); | ||
} else { | ||
return DetId(0); | ||
} | ||
} | ||
|
||
uint32_t FastTimeTopology::detId2denseGeomId(const DetId& id) const { | ||
|
||
FastTimeTopology::DecodedDetId id_ = decode(id); | ||
uint32_t idx = (uint32_t)((id_.zside > 0) ? kHGeomHalf_ : 0); | ||
return idx; | ||
} | ||
|
||
bool FastTimeTopology::valid(const DetId& id) const { | ||
|
||
FastTimeTopology::DecodedDetId id_ = decode(id); | ||
bool flag = hdcons_.isValidXY(id_.iType,id_.iEtaZ,id_.iPhi); | ||
return flag; | ||
} | ||
|
||
DetId FastTimeTopology::offsetBy(const DetId startId, int nrStepsX, | ||
int nrStepsY ) const { | ||
|
||
if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)){ | ||
DetId id = changeXY(startId,nrStepsX,nrStepsY); | ||
if (valid(id)) return id; | ||
} | ||
return DetId(0); | ||
} | ||
|
||
DetId FastTimeTopology::switchZSide(const DetId startId) const { | ||
|
||
if (startId.det() == DetId::Forward && startId.subdetId() == (int)(subdet_)){ | ||
FastTimeTopology::DecodedDetId id_ = decode(startId); | ||
id_.zside =-id_.zside; | ||
DetId id = encode(id_); | ||
if (valid(id)) return id; | ||
} | ||
return DetId(0); | ||
} | ||
|
||
FastTimeTopology::DecodedDetId FastTimeTopology::geomDenseId2decId(const uint32_t& hi) const { | ||
|
||
FastTimeTopology::DecodedDetId id_; | ||
if (hi < totalGeomModules()) { | ||
id_.zside = ((int)(hi)<kHGeomHalf_ ? -1 : 1); | ||
} | ||
return id_; | ||
} | ||
|
||
FastTimeTopology::DecodedDetId FastTimeTopology::decode(const DetId& startId) const { | ||
|
||
FastTimeTopology::DecodedDetId id_; | ||
FastTimeDetId id(startId); | ||
id_.iPhi = id.iphi(); | ||
id_.iEtaZ = id.ieta(); | ||
id_.iType = id.type(); | ||
id_.zside = id.zside(); | ||
id_.subdet = id.subdetId(); | ||
return id_; | ||
} | ||
|
||
DetId FastTimeTopology::encode(const FastTimeTopology::DecodedDetId& id_) const { | ||
|
||
DetId id = FastTimeDetId(id_.iType,id_.iEtaZ,id_.iPhi,id_.zside); | ||
return id; | ||
} | ||
|
||
DetId FastTimeTopology::changeXY(const DetId& id, int nrStepsX, | ||
int nrStepsY ) const { | ||
|
||
FastTimeTopology::DecodedDetId id_ = decode(id); | ||
int iEtaZ = id_.iEtaZ + nrStepsX; | ||
int iPhi = id_.iPhi + nrStepsY; | ||
if (iPhi < 1) iPhi += nPhi_; | ||
else if (iPhi > nPhi_) iPhi -= nPhi_; | ||
if (id_.iType == 1 && iEtaZ < 0) { | ||
iEtaZ = -iEtaZ; | ||
id_.zside = -id_.zside; | ||
} | ||
id_.iPhi = iPhi; | ||
id_.iEtaZ = iEtaZ; | ||
DetId nextPoint = encode(id_); | ||
if (valid(nextPoint)) return nextPoint; | ||
else return DetId(0); | ||
} | ||
|
||
#include "FWCore/Utilities/interface/typelookup.h" | ||
|
||
TYPELOOKUP_DATA_REG(FastTimeTopology); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.