Skip to content

Commit

Permalink
Merge pull request #22001 from kpedro88/Phase1-HECollapse3-101X
Browse files Browse the repository at this point in the history
Fix collapsed status in HCAL topology
  • Loading branch information
cmsbuild committed Feb 3, 2018
2 parents f244918 + dc4b421 commit d1b6abe
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 52 deletions.
Expand Up @@ -128,12 +128,16 @@
}
upgradeSteps['heCollapse'] = {
'steps' : [
'GenSimFull',
'DigiFull',
'RecoFull',
'RecoFullGlobal',
'HARVESTFull',
'ALCAFull',
],
'PU' : [
'DigiFull',
'RecoFull',
'RecoFullGlobal',
'HARVESTFull',
],
'suffix' : '_heCollapse',
'offset' : 0.6,
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/Hcal/src/HcalRecHitsAnalyzer.cc
Expand Up @@ -1126,7 +1126,7 @@ double HcalRecHitsAnalyzer::dPhiWsign(double phi1, double phi2) {
int HcalRecHitsAnalyzer::hcalSevLvl(const CaloRecHit* hit){

HcalDetId id = hit->detid();
if (theHcalTopology->withSpecialRBXHBHE() && id.subdet() == HcalEndcap) {
if (theHcalTopology->getMergePositionFlag() && id.subdet() == HcalEndcap) {
id = theHcalTopology->idFront(id);
}

Expand Down
4 changes: 2 additions & 2 deletions Geometry/CaloTopology/src/CaloTowerConstituentsMap.cc
Expand Up @@ -97,7 +97,7 @@ std::vector<DetId> CaloTowerConstituentsMap::constituentsOf(const CaloTowerDetId
if (id.ietaAbs()<=m_cttopo->lastHBRing()) {
m_hcaltopo->depthBinInformation(HcalBarrel,hcal_ieta,id.iphi(),id.zside(),nd,sd);
for (int i=0; i<nd; i++) {
if (m_hcaltopo->withSpecialRBXHBHE()) {
if (m_hcaltopo->getMergePositionFlag()) {
HcalDetId hid = m_hcaltopo->mergedDepthDetId(HcalDetId(HcalBarrel,hcal_ieta*id.zside(),id.iphi(),i+sd));
if (std::find(items.begin(),items.end(),hid) == items.end()) {
items.emplace_back(hid);
Expand Down Expand Up @@ -131,7 +131,7 @@ std::vector<DetId> CaloTowerConstituentsMap::constituentsOf(const CaloTowerDetId
if (id.ietaAbs()>=m_cttopo->firstHERing() && id.ietaAbs()<=m_cttopo->lastHERing()) {
m_hcaltopo->depthBinInformation(HcalEndcap,hcal_ieta,id.iphi(),id.zside(),nd,sd);
for (int i=0; i<nd; i++) {
if (m_hcaltopo->withSpecialRBXHBHE()) {
if (m_hcaltopo->getMergePositionFlag()) {
HcalDetId hid = m_hcaltopo->mergedDepthDetId(HcalDetId(HcalEndcap,hcal_ieta*id.zside(),id.iphi(),i+sd));
if (std::find(items.begin(),items.end(),hid) == items.end()) {
items.emplace_back(hid);
Expand Down
13 changes: 13 additions & 0 deletions Geometry/HcalEventSetup/python/hcalTopologyIdeal_cfi.py
@@ -0,0 +1,13 @@
import FWCore.ParameterSet.Config as cms

from Geometry.HcalEventSetup.hcalTopologyIdealBase_cfi import hcalTopologyIdealBase as hcalTopologyIdeal

from Configuration.Eras.Modifier_run2_HEPlan1_2017_cff import run2_HEPlan1_2017
run2_HEPlan1_2017.toModify(hcalTopologyIdeal,
MergePosition = cms.untracked.bool(True)
)

from Configuration.ProcessModifiers.run2_HECollapse_2018_cff import run2_HECollapse_2018
run2_HECollapse_2018.toModify(hcalTopologyIdeal,
MergePosition = cms.untracked.bool(True)
)
4 changes: 2 additions & 2 deletions Geometry/HcalEventSetup/src/HcalTopologyIdealEP.cc
Expand Up @@ -59,8 +59,8 @@ void HcalTopologyIdealEP::fillDescriptions( edm::ConfigurationDescriptions & des

edm::ParameterSetDescription desc;
desc.addUntracked<std::string>( "Exclude", "" );
desc.addUntracked<bool>("MergePosition", true);
descriptions.add( "hcalTopologyIdeal", desc );
desc.addUntracked<bool>("MergePosition", false);
descriptions.add( "hcalTopologyIdealBase", desc );
}

//
Expand Down
2 changes: 1 addition & 1 deletion Geometry/HcalTowerAlgo/src/HcalGeometry.cc
Expand Up @@ -21,7 +21,7 @@ HcalGeometry::HcalGeometry(const HcalTopology& topology) :
HcalGeometry::~HcalGeometry() {}

void HcalGeometry::init() {
if (!m_topology.withSpecialRBXHBHE()) m_mergePosition = false;
if (!m_topology.getMergePositionFlag()) m_mergePosition = false;
#ifdef EDM_ML_DEBUG
std::cout << "HcalGeometry: " << "HcalGeometry::init() "
<< " HBSize " << m_topology.getHBSize()
Expand Down
11 changes: 11 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Expand Up @@ -32,6 +32,15 @@ def customiseFor21821(process):

return process

def customiseFor22001(process):
for producer in producers_by_type(process, "CaloTowersCreator"):
if hasattr(producer,'HcalCollapsed'):
del producer.HcalCollapsed
if hasattr(process,'HcalTopologyIdealEP'):
# should only be true for "collapsed" cases (2017, 2018)
process.HcalTopologyIdealEP.MergePosition = cms.untracked.bool(True)
return process

def customiseFor21664_forMahiOn(process):
for producer in producers_by_type(process, "HBHEPhase1Reconstructor"):
producer.algorithm.useMahi = cms.bool(True)
Expand Down Expand Up @@ -84,4 +93,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"):

process = customiseFor21821(process)

process = customiseFor22001(process)

return process
Expand Up @@ -75,8 +75,7 @@ class CaloTowersCreationAlgo {
double momHEDepth,
double momEBDepth,
double momEEDepth,
int hcalPhase=0,
bool hcalCollapsed=false
int hcalPhase=0
);

CaloTowersCreationAlgo(double EBthreshold, double EEthreshold,
Expand Down Expand Up @@ -109,8 +108,7 @@ class CaloTowersCreationAlgo {
double momHEDepth,
double momEBDepth,
double momEEDepth,
int hcalPhase=0,
bool hcalCollapsed=false
int hcalPhase=0
);

void setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, const HcalTopology* htopo, const CaloGeometry* geo);
Expand Down Expand Up @@ -249,9 +247,6 @@ class CaloTowersCreationAlgo {
/// helper method to look up the appropriate threshold & weight
void getThresholdAndWeight(const DetId & detId, double & threshold, double & weight) const;

// wrapper for HcalTopology method
bool mergedDepth29(HcalDetId id) const;

double theEBthreshold, theEEthreshold;
bool theUseEtEBTresholdFlag, theUseEtEETresholdFlag;
bool theUseSymEBTresholdFlag,theUseSymEETresholdFlag;
Expand Down Expand Up @@ -364,7 +359,6 @@ class CaloTowersCreationAlgo {
edm::Handle<EcalRecHitCollection> theEeHandle;

int theHcalPhase;
bool isHcalCollapsed;

std::vector<HcalDetId> ids_;
};
Expand Down
7 changes: 2 additions & 5 deletions RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py
Expand Up @@ -141,9 +141,7 @@
AllowMissingInputs = cms.bool(False),

# specify hcal upgrade phase - 0, 1, 2
HcalPhase = cms.int32(0),

HcalCollapsed = cms.bool(False),
HcalPhase = cms.int32(0)

)

Expand All @@ -156,11 +154,10 @@
HEDThreshold = cms.double(0.2)
)

# needed to handle inner/outer and 28/29 splitting w/ collapsed rechits
# needed to handle inner/outer assignment
from Configuration.ProcessModifiers.run2_HECollapse_2018_cff import run2_HECollapse_2018
run2_HECollapse_2018.toModify(calotowermaker,
HcalPhase = cms.int32(0),
HcalCollapsed = cms.bool(True),
HESThreshold1 = cms.double(0.8),
HESThreshold = cms.double(0.8),
HEDThreshold1 = cms.double(0.8),
Expand Down
29 changes: 9 additions & 20 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc
Expand Up @@ -86,8 +86,7 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo()
theMomHEDepth(0.),
theMomEBDepth(0.),
theMomEEDepth(0.),
theHcalPhase(0),
isHcalCollapsed(false)
theHcalPhase(0)
{
}

Expand Down Expand Up @@ -116,8 +115,7 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthre
double momHEDepth,
double momEBDepth,
double momEEDepth,
int hcalPhase,
bool hcalCollapsed)
int hcalPhase)

: theEBthreshold(EBthreshold),
theEEthreshold(EEthreshold),
Expand Down Expand Up @@ -192,8 +190,7 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthre
theMomHEDepth(momHEDepth),
theMomEBDepth(momEBDepth),
theMomEEDepth(momEEDepth),
theHcalPhase(hcalPhase),
isHcalCollapsed(hcalCollapsed)
theHcalPhase(hcalPhase)
{
}

Expand Down Expand Up @@ -229,8 +226,7 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthre
double momHEDepth,
double momEBDepth,
double momEEDepth,
int hcalPhase,
bool hcalCollapsed)
int hcalPhase)

: theEBthreshold(EBthreshold),
theEEthreshold(EEthreshold),
Expand Down Expand Up @@ -305,8 +301,7 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, double EEthre
theMomHEDepth(momHEDepth),
theMomEBDepth(momEBDepth),
theMomEEDepth(momEEDepth),
theHcalPhase(hcalPhase),
isHcalCollapsed(hcalCollapsed)
theHcalPhase(hcalPhase)
{
// static int N = 0;
// std::cout << "VI Algo " << ++N << std::endl;
Expand Down Expand Up @@ -499,7 +494,7 @@ void CaloTowersCreationAlgo::rescaleTowers(const CaloTowerCollection& ctc, CaloT
void CaloTowersCreationAlgo::assignHitHcal(const CaloRecHit * recHit) {
DetId detId = recHit->detid();
DetId detIdF(detId);
if (detId.det() == DetId::Hcal && theHcalTopology->withSpecialRBXHBHE()) {
if (detId.det() == DetId::Hcal && theHcalTopology->getMergePositionFlag()) {
detIdF = theHcalTopology->idFront(HcalDetId(detId));
#ifdef EDM_ML_DEBUG
std::cout << "AssignHitHcal DetId " << HcalDetId(detId) << " Front "
Expand All @@ -526,7 +521,7 @@ void CaloTowersCreationAlgo::assignHitHcal(const CaloRecHit * recHit) {
(theHcalPhase==0 || theHcalPhase==1) &&
//HcalDetId(detId).depth()==3 &&
HcalDetId(detIdF).ietaAbs()==theHcalTopology->lastHERing()-1) {
merge = mergedDepth29(HcalDetId(detIdF));
merge = theHcalTopology->mergedDepth29(HcalDetId(detIdF));
#ifdef EDM_ML_DEBUG
std::cout << "Merge " << HcalDetId(detIdF) << ":" << merge << std::endl;
#endif
Expand Down Expand Up @@ -1304,12 +1299,6 @@ void CaloTowersCreationAlgo::getThresholdAndWeight(const DetId & detId, double &
}
}

bool CaloTowersCreationAlgo::mergedDepth29(HcalDetId id) const {
//hack for collapsed case (topology only knows about real depths)
if(isHcalCollapsed) return id.depth()==3;
return theHcalTopology->mergedDepth29(id);
}

void CaloTowersCreationAlgo::setEBEScale(double scale){
if (scale>0.00001) *&theEBEScale = scale;
else *&theEBEScale = 50.;
Expand Down Expand Up @@ -1491,7 +1480,7 @@ GlobalPoint CaloTowersCreationAlgo::hadShwPosFromCells(DetId frontCellId, DetId
// to determine the axis. point set by the predefined depth.

HcalDetId hid1(frontCellId), hid2(backCellId);
if (theHcalTopology->withSpecialRBXHBHE()) {
if (theHcalTopology->getMergePositionFlag()) {
hid1 = theHcalTopology->idFront(frontCellId);
#ifdef EDM_ML_DEBUG
std::cout << "Front " << HcalDetId(frontCellId) << " " << hid1 << "\n";
Expand Down Expand Up @@ -1631,7 +1620,7 @@ void CaloTowersCreationAlgo::makeHcalDropChMap() {
if (hid.subdet()==HcalEndcap &&
(theHcalPhase==0 || theHcalPhase==1) &&
hid.ietaAbs()==theHcalTopology->lastHERing()-1) {
bool merge = mergedDepth29(hid);
bool merge = theHcalTopology->mergedDepth29(hid);
if (merge) {
CaloTowerDetId twrId29(twrId.ieta()+twrId.zside(), twrId.iphi());
hcalDropChMap[twrId29] +=1;
Expand Down
4 changes: 1 addition & 3 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc
Expand Up @@ -66,8 +66,7 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) :
conf.getParameter<double>("MomHEDepth"),
conf.getParameter<double>("MomEBDepth"),
conf.getParameter<double>("MomEEDepth"),
conf.getParameter<int>("HcalPhase"),
conf.getParameter<bool>("HcalCollapsed")
conf.getParameter<int>("HcalPhase")
),

ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
Expand Down Expand Up @@ -365,7 +364,6 @@ void CaloTowersCreator::fillDescriptions(edm::ConfigurationDescriptions& descrip
desc.add<unsigned int>("HcalAcceptSeverityLevelForRejectedHit", 9999);
desc.add<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers", {});
desc.add<int>("HcalPhase", 0);
desc.add<bool>("HcalCollapsed", 0);

descriptions.addDefault(desc);
}
4 changes: 1 addition & 3 deletions RecoLocalCalo/CaloTowersCreator/src/CaloTowersReCreator.cc
Expand Up @@ -37,8 +37,7 @@ CaloTowersReCreator::CaloTowersReCreator(const edm::ParameterSet& conf) :
conf.getParameter<double>("MomHEDepth"),
conf.getParameter<double>("MomEBDepth"),
conf.getParameter<double>("MomEEDepth"),
conf.getParameter<int>("HcalPhase"),
conf.getParameter<bool>("HcalCollapsed")
conf.getParameter<int>("HcalPhase")
),
allowMissingInputs_(false)
{
Expand Down Expand Up @@ -143,7 +142,6 @@ void CaloTowersReCreator::fillDescriptions(edm::ConfigurationDescriptions& descr
desc.add<edm::InputTag>("caloLabel", edm::InputTag("calotowermaker"));
desc.add<int>("MomConstrMethod", 1);
desc.add<int>("HcalPhase", 0);
desc.add<bool>("HcalCollapsed", 0);

descriptions.addDefault(desc);
}
2 changes: 1 addition & 1 deletion RecoLocalCalo/HcalRecProducers/src/HBHEPlan1Combiner.cc
Expand Up @@ -104,7 +104,7 @@ HBHEPlan1Combiner::produce(edm::Event& iEvent, const edm::EventSetup& eventSetup

// Are we using "Plan 1" geometry?
const bool plan1Mode = ignorePlan1Topology_ ? usePlan1Mode_
: htopo->withSpecialRBXHBHE();
: htopo->getMergePositionFlag();

// Find the input rechit collection
Handle<HBHERecHitCollection> inputRechits;
Expand Down
2 changes: 1 addition & 1 deletion RecoLocalCalo/HcalRecProducers/src/HcalHitSelection.cc
Expand Up @@ -82,7 +82,7 @@ template <class CollectionType> void HcalHitSelection::skim( const edm::Handle<C
for (;hit!=end;++hit){
// edm::LogError("HcalHitSelection")<<"the hit pointer is"<<&(*hit);
HcalDetId id = hit->detid();
if (theHcalTopology_->withSpecialRBXHBHE() && id.subdet() == HcalEndcap) {
if (theHcalTopology_->getMergePositionFlag() && id.subdet() == HcalEndcap) {
id = theHcalTopology_->idFront(id);
}
const uint32_t & recHitFlag = hit->flags();
Expand Down
Expand Up @@ -55,7 +55,7 @@ template <typename Digi, typename Geometry,PFLayer::Layer Layer,int Detector>
if (esd !=Detector && Detector != HcalOther )
continue;

if (theHcalTopology->withSpecialRBXHBHE() && esd == HcalEndcap) {
if (theHcalTopology->getMergePositionFlag() && esd == HcalEndcap) {
detid = theHcalTopology->idFront(detid);
}

Expand Down
Expand Up @@ -147,7 +147,7 @@ class PFRecHitQTestHCALChannel : public PFRecHitQTestBase {

bool test(unsigned aDETID, double energy, int flags, bool& clean){
HcalDetId detid = (HcalDetId)aDETID;
if (theHcalTopology_->withSpecialRBXHBHE() and detid.subdet() == HcalEndcap){
if (theHcalTopology_->getMergePositionFlag() and detid.subdet() == HcalEndcap){
detid = theHcalTopology_->idFront(detid);
}

Expand Down
Expand Up @@ -187,7 +187,7 @@ void PFCTRecHitProducer::produce(edm::Event& iEvent,
if(hit.det()==DetId::Hcal) {
foundHCALConstituent = true;
detid = hit;
if (theHcalTopology->withSpecialRBXHBHE() &&
if (theHcalTopology->getMergePositionFlag() &&
detid.subdet() == HcalEndcap) {
detid = theHcalTopology->idFront(detid);
}
Expand Down

0 comments on commit d1b6abe

Please sign in to comment.