-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 #8003 from lgray/topic_fix_pandora_pointers
Remove static pointer holding Pandora
- Loading branch information
Showing
6 changed files
with
206 additions
and
46 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
RecoParticleFlow/PandoraTranslator/interface/CMSGlobalHadronCompensationPlugin.h
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,46 @@ | ||
/** | ||
* @file RecoParticleFlow/PandoraTranslator/interface/CMSGlobalHadronCompensationPlugin.h" | ||
* | ||
* @brief Header file for hit-based shower compensation | ||
* | ||
* $Log: $ | ||
*/ | ||
#ifndef CMS_GLOBAL_HADRON_COMPENSATION_PLUGINS_H | ||
#define CMS_GLOBAL_HADRON_COMPENSATION_PLUGINS_H 1 | ||
|
||
#include "Plugins/EnergyCorrectionsPlugin.h" | ||
|
||
namespace cms_content | ||
{ | ||
|
||
/** | ||
* @brief GlobalHadronCompensation class. Correct cluster energy by looking at number of hits above 10 MIPs compared to the average energy density in HEF in MIPs | ||
*/ | ||
class GlobalHadronCompensation : public pandora::EnergyCorrectionPlugin | ||
{ | ||
public: | ||
/** | ||
* @brief Default constructor | ||
*/ | ||
GlobalHadronCompensation(); | ||
|
||
pandora::StatusCode MakeEnergyCorrections(const pandora::Cluster *const pCluster, float &correctedEnergy) const; | ||
|
||
private: | ||
/** | ||
* @brief Get the sum of the hadronic energies of all calo hits in a specified layer of an ordered calo hit list | ||
* | ||
* @param orderedCaloHitList the ordered calo hit list | ||
* @param pseudoLayer the specified pseudolayer | ||
*/ | ||
float GetHadronicEnergyInLayer(const pandora::OrderedCaloHitList &orderedCaloHitList, const unsigned int pseudoLayer) const; | ||
|
||
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle); | ||
|
||
float m_nMIPsCut; ///< Min calo energy in MIPs to consider a hit for correction the | ||
|
||
}; | ||
|
||
} //cms_content | ||
|
||
#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
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
117 changes: 117 additions & 0 deletions
117
RecoParticleFlow/PandoraTranslator/src/CMSGlobalHadronCompensationPlugin.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,117 @@ | ||
/** | ||
* @file RecoParticleFlow/PandoraTranslator/src/CMSGlobalHadronCompensationPlugin.cc | ||
* | ||
* @brief Implementation of the Global Hadronic Energy Compensation strategy | ||
* | ||
* $Log: $ | ||
*/ | ||
|
||
#include "Pandora/AlgorithmHeaders.h" | ||
|
||
#include "LCHelpers/ReclusterHelper.h" | ||
|
||
#include "RecoParticleFlow/PandoraTranslator/interface/CMSGlobalHadronCompensationPlugin.h" | ||
|
||
#include <DataFormats/ForwardDetId/interface/ForwardSubdetector.h> | ||
#include <DataFormats/ParticleFlowReco/interface/PFRecHit.h> | ||
|
||
using namespace pandora; | ||
using namespace cms_content; | ||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------ | ||
|
||
GlobalHadronCompensation::GlobalHadronCompensation() : | ||
m_nMIPsCut(10.0f) | ||
{ | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------ | ||
|
||
StatusCode GlobalHadronCompensation::MakeEnergyCorrections(const Cluster *const pCluster, float &correctedHadronicEnergy) const | ||
{ | ||
|
||
//const unsigned int firstPseudoLayer(this->GetPandora().GetPlugins()->GetPseudoLayerPlugin()->GetPseudoLayerAtIp()); | ||
|
||
const OrderedCaloHitList& orderedCaloHitList = pCluster->GetOrderedCaloHitList(); | ||
|
||
OrderedCaloHitList::const_iterator layer = orderedCaloHitList.begin(); | ||
OrderedCaloHitList::const_iterator hits_end = orderedCaloHitList.end(); | ||
|
||
float en_avg(0.f), nHits(0.f); | ||
|
||
for( ; layer != hits_end; ++ layer ) { | ||
const CaloHitList& hits_in_layer = *(layer->second); | ||
for( const auto& hit : hits_in_layer ) { | ||
// hack so that we can know if we are in the HEF or not (go back to cmssw det id) | ||
const void* void_hit_ptr = hit->GetParentCaloHitAddress(); | ||
const reco::PFRecHit* original_hit_ptr = static_cast<const reco::PFRecHit*>(void_hit_ptr); | ||
const uint32_t rawid = original_hit_ptr->detId(); | ||
const int subDetId = (rawid>>25)&0x7; | ||
if( subDetId != ForwardSubdetector::HGCHEF ) continue; | ||
|
||
const float en_mip = hit->GetMipEquivalentEnergy(); | ||
en_avg += en_mip; | ||
nHits += 1.f; | ||
} | ||
} | ||
|
||
if( nHits == 0.f ) { | ||
correctedHadronicEnergy *= 1.f; | ||
return STATUS_CODE_SUCCESS; | ||
} | ||
|
||
en_avg /= nHits; | ||
|
||
float nHits_avg(0.f), nHits_elim(0.f); | ||
for( ; layer != hits_end; ++ layer ) { | ||
const CaloHitList& hits_in_layer = *(layer->second); | ||
for( const auto& hit : hits_in_layer ) { | ||
// hack so that we can know if we are in the HEF or not (go back to cmssw det id) | ||
const void* void_hit_ptr = hit->GetParentCaloHitAddress(); | ||
const reco::PFRecHit* original_hit_ptr = static_cast<const reco::PFRecHit*>(void_hit_ptr); | ||
const uint32_t rawid = original_hit_ptr->detId(); | ||
const int subDetId = (rawid>>25)&0x7; | ||
if( subDetId != ForwardSubdetector::HGCHEF ) continue; | ||
|
||
const float en_mip = hit->GetMipEquivalentEnergy(); | ||
if( en_mip > en_avg ) { | ||
nHits_avg += 1.f; | ||
} else { | ||
nHits_elim += 1.f; | ||
} | ||
} | ||
} | ||
|
||
correctedHadronicEnergy *= (nHits-nHits_elim)/(nHits-nHits_avg); | ||
|
||
return STATUS_CODE_SUCCESS; | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------ | ||
|
||
float GlobalHadronCompensation::GetHadronicEnergyInLayer(const OrderedCaloHitList &orderedCaloHitList, const unsigned int pseudoLayer) const | ||
{ | ||
OrderedCaloHitList::const_iterator iter = orderedCaloHitList.find(pseudoLayer); | ||
|
||
float hadronicEnergy(0.f); | ||
|
||
if (iter != orderedCaloHitList.end()) | ||
{ | ||
for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter) | ||
{ | ||
hadronicEnergy += (*hitIter)->GetHadronicEnergy(); | ||
} | ||
} | ||
|
||
return hadronicEnergy; | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------------------------------------------------ | ||
|
||
StatusCode GlobalHadronCompensation::ReadSettings(const TiXmlHandle xmlHandle) | ||
{ | ||
PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, | ||
"MipEnergyThreshold", m_nMIPsCut)); | ||
|
||
return STATUS_CODE_SUCCESS; | ||
} |
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