-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 123258 b: refs/heads/vhbbHeppy74X c: 911c0e9 h: refs/heads/vhbbHeppy74X
- Loading branch information
Lindsey Gray
committed
Apr 29, 2013
1 parent
b95083f
commit 47ac9ec
Showing
7 changed files
with
812 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/vhbbHeppy74X: 3a296552423cf6cb5ec0a31dc5dd9e658588a200 | ||
refs/heads/vhbbHeppy74X: 911c0e9e55dff017172f3592154b0b696d1e6ddd |
146 changes: 146 additions & 0 deletions
146
trunk/RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgoNew.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,146 @@ | ||
#ifndef RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgoNew_h | ||
#define RecoEcal_EgammaClusterAlgos_PFECALSuperClusterAlgoNew_h | ||
|
||
|
||
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFLayer.h" | ||
#include "DataFormats/Common/interface/OrphanHandle.h" | ||
|
||
#include "DataFormats/EgammaReco/interface/SuperCluster.h" | ||
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" | ||
#include "DataFormats/EgammaReco/interface/BasicCluster.h" | ||
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h" | ||
|
||
#include "RecoParticleFlow/PFClusterTools/interface/PFEnergyCalibration.h" | ||
|
||
#include "TVector2.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
//#include <unordered_map> | ||
#include <set> | ||
|
||
#include <memory> | ||
|
||
class TFile; | ||
class TH2F; | ||
|
||
/// \ Algorithm for box particle flow super clustering in the ECAL | ||
/*! | ||
Original Author: Nicolas Chanon | ||
Additional Authors (Mustache): Y. Gershtein, R. Patel, L. Gray | ||
\date July 2012 | ||
*/ | ||
|
||
class PFECALSuperClusterAlgoNew { | ||
public: | ||
enum clustering_type{kBOX=1, kMustache=2}; | ||
|
||
// simple class for associating calibrated energies | ||
class CalibratedPFCluster { | ||
public: | ||
CalibratedPFCluster(const edm::Ptr<reco::PFCluster>& p, | ||
const double ce) : cluptr(p), calib_e(ce) {} | ||
|
||
double energy() const { return calib_e; } | ||
double energy_nocalib() const { return cluptr->energy(); } | ||
double eta() const { return cluptr->eta(); } | ||
double phi() const { return cluptr->phi(); } | ||
|
||
void resetCalibratedEnergy(const double ce) { calib_e = ce; } | ||
|
||
edm::Ptr<reco::PFCluster> the_ptr() const { return cluptr; } | ||
|
||
private: | ||
edm::Ptr<reco::PFCluster> cluptr; | ||
double calib_e; | ||
}; | ||
typedef std::shared_ptr<CalibratedPFCluster> CalibratedClusterPtr; | ||
typedef std::vector<CalibratedClusterPtr> CalibratedClusterPtrVector; | ||
|
||
|
||
/// constructor | ||
PFECALSuperClusterAlgoNew(); | ||
|
||
void setVerbosityLevel(bool verbose){ verbose_ = verbose;} | ||
|
||
void setClusteringType(clustering_type thetype) { _clustype = thetype; } | ||
|
||
void setThreshPFClusterSeedBarrel(double thresh){ threshPFClusterSeedBarrel_ = thresh;} | ||
void setThreshPFClusterBarrel(double thresh){ threshPFClusterBarrel_ = thresh;} | ||
void setThreshPFClusterSeedEndcap(double thresh){ threshPFClusterSeedEndcap_ = thresh;} | ||
void setThreshPFClusterEndcap(double thresh){ threshPFClusterEndcap_ = thresh;} | ||
|
||
void setPhiwidthSuperClusterBarrel( double phiwidth ){ phiwidthSuperClusterBarrel_ = phiwidth;} | ||
void setEtawidthSuperClusterBarrel( double etawidth ){ etawidthSuperClusterBarrel_ = etawidth;} | ||
void setPhiwidthSuperClusterEndcap( double phiwidth ){ phiwidthSuperClusterEndcap_ = phiwidth;} | ||
void setEtawidthSuperClusterEndcap( double etawidth ){ etawidthSuperClusterEndcap_ = etawidth;} | ||
void setUsePS( bool useit ){ usePS = useit; } | ||
|
||
void setPFClusterCalibration(const std::shared_ptr<PFEnergyCalibration>&); | ||
|
||
void setThreshPFClusterES(double thresh){threshPFClusterES_ = thresh;} | ||
|
||
void setMustacheCut( bool doMustacheCut ) { doMustacheCut_ = doMustacheCut;} | ||
//void setThreshPFClusterMustacheOutBarrel(double thresh){ threshPFClusterMustacheOutBarrel_ = thresh;} | ||
//void setThreshPFClusterMustacheOutEndcap(double thresh){ threshPFClusterMustacheOutEndcap_ = thresh;} | ||
|
||
void setCrackCorrections( bool applyCrackCorrections) { applyCrackCorrections_ = applyCrackCorrections;} | ||
|
||
std::auto_ptr<reco::SuperClusterCollection> | ||
getEBOutputSCCollection() { return superClustersEB_; } | ||
std::auto_ptr<reco::SuperClusterCollection> | ||
getEEOutputSCCollection() { return superClustersEE_; } | ||
|
||
void loadAndSortPFClusters(const edm::View<reco::PFCluster>& ecalclusters, | ||
const edm::View<reco::PFCluster>& psclusters); | ||
|
||
void run(); | ||
|
||
private: | ||
|
||
CalibratedClusterPtrVector _clustersEB; | ||
CalibratedClusterPtrVector _clustersEE; | ||
std::map<edm::Ptr<reco::PFCluster>, edm::PtrVector<reco::PFCluster> > | ||
_psclustersforee; | ||
std::auto_ptr<reco::SuperClusterCollection> superClustersEB_; | ||
std::auto_ptr<reco::SuperClusterCollection> superClustersEE_; | ||
std::shared_ptr<PFEnergyCalibration> _pfEnergyCalibration; | ||
clustering_type _clustype; | ||
void buildAllSuperClusters(CalibratedClusterPtrVector&, | ||
double seedthresh); | ||
void buildSuperCluster(CalibratedClusterPtr&, | ||
CalibratedClusterPtrVector&); | ||
|
||
bool verbose_; | ||
|
||
double threshPFClusterSeed_; | ||
double threshPFCluster_; | ||
double etawidthSuperCluster_; | ||
double phiwidthSuperCluster_; | ||
|
||
double threshPFClusterSeedBarrel_; | ||
double threshPFClusterBarrel_; | ||
double threshPFClusterSeedEndcap_; | ||
double threshPFClusterEndcap_; | ||
double threshPFClusterES_; | ||
|
||
double phiwidthSuperClusterBarrel_; | ||
double etawidthSuperClusterBarrel_; | ||
double phiwidthSuperClusterEndcap_; | ||
double etawidthSuperClusterEndcap_; | ||
|
||
bool doMustacheCut_; | ||
|
||
bool applyCrackCorrections_; | ||
|
||
bool usePS; | ||
|
||
}; | ||
|
||
#endif |
350 changes: 350 additions & 0 deletions
350
trunk/RecoEcal/EgammaClusterAlgos/src/PFECALSuperClusterAlgoNew.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,350 @@ | ||
#include "RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgoNew.h" | ||
#include "RecoParticleFlow/PFClusterTools/interface/PFClusterWidthAlgo.h" | ||
#include "RecoParticleFlow/PFClusterTools/interface/LinkByRecHit.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFLayer.h" | ||
#include "DataFormats/HcalDetId/interface/HcalDetId.h" | ||
#include "RecoEcal/EgammaCoreTools/interface/Mustache.h" | ||
#include "Math/GenVector/VectorUtil.h" | ||
#include "TFile.h" | ||
#include "TH2F.h" | ||
#include "TROOT.h" | ||
#include "TMath.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include <stdexcept> | ||
#include <string> | ||
#include <sstream> | ||
|
||
using namespace std; | ||
|
||
namespace { | ||
typedef edm::View<reco::PFCluster> PFClusterView; | ||
typedef edm::Ptr<reco::PFCluster> PFClusterPtr; | ||
typedef edm::PtrVector<reco::PFCluster> PFClusterPtrVector; | ||
typedef PFECALSuperClusterAlgoNew::CalibratedClusterPtr CalibClusterPtr; | ||
typedef PFECALSuperClusterAlgoNew::CalibratedClusterPtrVector CalibClusterPtrVector; | ||
|
||
typedef std::binary_function<const CalibClusterPtr&, | ||
const CalibClusterPtr&, | ||
bool> ClusBinaryFunction; | ||
|
||
typedef std::unary_function<const CalibClusterPtr&, | ||
bool> ClusUnaryFunction; | ||
|
||
struct SumPSEnergy : public std::binary_function<double, | ||
const PFClusterPtr&, | ||
double> { | ||
PFLayer::Layer _thelayer; | ||
SumPSEnergy(PFLayer::Layer layer) : _thelayer(layer) {} | ||
double operator()(double a, | ||
const PFClusterPtr& b) { | ||
return a + (_thelayer == b->layer())*b->energy(); | ||
} | ||
}; | ||
|
||
struct GreaterByE : public ClusBinaryFunction { | ||
bool operator()(const CalibClusterPtr& x, | ||
const CalibClusterPtr& y) { | ||
return x->energy_nocalib() > y->energy_nocalib() ; | ||
} | ||
}; | ||
|
||
struct IsASeed : public ClusUnaryFunction { | ||
double threshold; | ||
IsASeed(double thresh) : threshold(thresh) {} | ||
bool operator()(const CalibClusterPtr& x) { | ||
return x->energy() > threshold; | ||
} | ||
}; | ||
|
||
struct IsClustered : public ClusUnaryFunction { | ||
const CalibClusterPtr the_seed; | ||
PFECALSuperClusterAlgoNew::clustering_type _type; | ||
double etawidthSuperCluster_, phiwidthSuperCluster_; | ||
IsClustered(const CalibClusterPtr s, | ||
PFECALSuperClusterAlgoNew::clustering_type ct) : | ||
the_seed(s), _type(ct) {} | ||
bool operator()(const CalibClusterPtr& x) { | ||
double dphi = | ||
std::abs(TVector2::Phi_mpi_pi(the_seed->phi() - x->phi())); | ||
|
||
switch( _type ) { | ||
case PFECALSuperClusterAlgoNew::kBOX: | ||
return ( std::abs(the_seed->eta()-x->eta())<etawidthSuperCluster_ && | ||
dphi < phiwidthSuperCluster_ ); | ||
break; | ||
case PFECALSuperClusterAlgoNew::kMustache: | ||
return ( dphi < phiwidthSuperCluster_ && | ||
reco::MustacheKernel::inMustache(the_seed->eta(), | ||
the_seed->phi(), | ||
x->energy_nocalib(), | ||
x->eta(), | ||
x->phi() )); | ||
break; | ||
default: | ||
return false; | ||
} | ||
return false; | ||
} | ||
}; | ||
} | ||
|
||
PFECALSuperClusterAlgoNew::PFECALSuperClusterAlgoNew() { | ||
} | ||
|
||
void PFECALSuperClusterAlgoNew:: | ||
setPFClusterCalibration(const std::shared_ptr<PFEnergyCalibration>& calib) { | ||
_pfEnergyCalibration = calib; | ||
} | ||
|
||
void PFECALSuperClusterAlgoNew:: | ||
loadAndSortPFClusters(const PFClusterView& clusters, | ||
const PFClusterView& psclusters) { | ||
// reset the system for running | ||
superClustersEB_.reset(new reco::SuperClusterCollection); | ||
_clustersEB.clear(); | ||
superClustersEE_.reset(new reco::SuperClusterCollection); | ||
_clustersEE.clear(); | ||
_psclustersforee.clear(); | ||
|
||
auto clusterPtrs = clusters.ptrVector(); | ||
//Select PF clusters available for the clustering | ||
for ( auto cluster : clusterPtrs ){ | ||
LogDebug("PFClustering") | ||
<< "Loading PFCluster i="<<cluster.key() | ||
<<" energy="<<cluster->energy()<<endl; | ||
|
||
double Ecorr = _pfEnergyCalibration->energyEm(*cluster, | ||
0.0,0.0, | ||
applyCrackCorrections_); | ||
CalibratedClusterPtr calib_cluster(new CalibratedPFCluster(cluster, | ||
Ecorr)); | ||
switch( cluster->layer() ) { | ||
case PFLayer::ECAL_BARREL: | ||
if( calib_cluster->energy() > threshPFClusterBarrel_ ) { | ||
_clustersEB.push_back(calib_cluster); | ||
} | ||
break; | ||
case PFLayer::ECAL_ENDCAP: | ||
if( calib_cluster->energy() > threshPFClusterEndcap_ ) { | ||
_clustersEE.push_back(calib_cluster); | ||
_psclustersforee.insert(std::make_pair(calib_cluster->the_ptr(), | ||
PFClusterPtrVector())); } | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
// make the association map of ECAL clusters to preshower clusters | ||
auto clusterPtrsPS = psclusters.ptrVector(); | ||
double dist = -1.0, min_dist = -1.0; | ||
// match PS clusters to clusters from the EE (many to one relation) | ||
for( auto psclus : clusterPtrsPS ) { | ||
if( psclus->energy() < threshPFClusterES_ ) continue; | ||
switch( psclus->layer() ) { // just in case this isn't the ES... | ||
case PFLayer::PS1: | ||
case PFLayer::PS2: | ||
break; | ||
default: | ||
continue; | ||
} | ||
// now match the PS cluster to the closest EE cluster | ||
edm::Ptr<reco::PFCluster> eematch; | ||
min_dist = -1.0; | ||
for( auto eeclus : _clustersEE ) { | ||
// lazy continue based on geometry | ||
double prod = eeclus->eta()*psclus->eta(); | ||
double deta= std::abs(eeclus->eta() - psclus->eta()); | ||
double dphi= std::abs(TVector2::Phi_mpi_pi(eeclus->phi() - | ||
psclus->phi())); | ||
if( prod < 0 || deta > 0.3 || dphi > 0.6 ) continue; | ||
// now we actually do the matching | ||
dist = LinkByRecHit::testECALAndPSByRecHit( *(eeclus->the_ptr()), | ||
*psclus, | ||
false); | ||
if( dist == -1.0 ) continue; | ||
if( dist < min_dist || min_dist == -1.0 ) eematch = eeclus->the_ptr(); | ||
} | ||
if( eematch.isNull() ) continue; // lazy continue if no match found | ||
_psclustersforee[eematch].push_back(psclus); | ||
} | ||
|
||
// sort full cluster collections by their calibrated energy | ||
// this will put all the seeds first by construction | ||
GreaterByE greaterByE; | ||
std::sort(_clustersEB.begin(), _clustersEB.end(), greaterByE); | ||
std::sort(_clustersEE.begin(), _clustersEE.end(), greaterByE); | ||
} | ||
|
||
void PFECALSuperClusterAlgoNew::run() { | ||
// clusterize the EB | ||
buildAllSuperClusters(_clustersEB, threshPFClusterSeedBarrel_); | ||
// clusterize the EE | ||
buildAllSuperClusters(_clustersEE, threshPFClusterSeedEndcap_); | ||
} | ||
|
||
void PFECALSuperClusterAlgoNew:: | ||
buildAllSuperClusters(CalibClusterPtrVector& clusters, | ||
double seedthresh) { | ||
IsASeed seedable(seedthresh); | ||
// in each iteration we are working on a list that is already sorted | ||
// in the cluster energy and remains so through each iteration | ||
// NB: since clusters is sorted in loadClusters any_of has O(1) | ||
// timing until you run out of seeds! | ||
while( std::any_of(clusters.cbegin(), | ||
clusters.cend(), | ||
seedable ) ) { | ||
buildSuperCluster(clusters.front(),clusters); | ||
} | ||
} | ||
|
||
void PFECALSuperClusterAlgoNew:: | ||
buildSuperCluster(CalibClusterPtr& seed, | ||
CalibClusterPtrVector& clusters) { | ||
IsClustered IsClusteredWithSeed(seed,_clustype); | ||
bool isEE = false; | ||
SumPSEnergy sumps1(PFLayer::PS1), sumps2(PFLayer::PS2); | ||
switch( seed->the_ptr()->layer() ) { | ||
case PFLayer::ECAL_BARREL: | ||
IsClusteredWithSeed.phiwidthSuperCluster_ = phiwidthSuperClusterBarrel_; | ||
IsClusteredWithSeed.etawidthSuperCluster_ = etawidthSuperClusterBarrel_; | ||
edm::LogInfo("PFClustering") << "Building SC number " | ||
<< superClustersEB_->size() + 1 | ||
<< " in the ECAL barrel!"; | ||
break; | ||
case PFLayer::ECAL_ENDCAP: | ||
IsClusteredWithSeed.phiwidthSuperCluster_ = phiwidthSuperClusterEndcap_; | ||
IsClusteredWithSeed.etawidthSuperCluster_ = etawidthSuperClusterEndcap_; | ||
edm::LogInfo("PFClustering") << "Building SC number " | ||
<< superClustersEE_->size() + 1 | ||
<< " in the ECAL endcap!" << std::endl; | ||
isEE = true; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
// this function shuffles the list of clusters into a list | ||
// where all clustered sub-clusters are at the front | ||
// and returns a pointer to the first unclustered cluster. | ||
// The relative ordering of clusters is preserved | ||
// (i.e. both resulting sub-lists are sorted by energy). | ||
auto not_clustered = std::stable_partition(clusters.begin(), | ||
clusters.end(), | ||
IsClusteredWithSeed); | ||
if(verbose_) { | ||
edm::LogInfo("PFClustering") << "Dumping cluster detail"; | ||
edm::LogVerbatim("PFClustering") | ||
<< "\tPassed seed: e = " << seed->energy_nocalib() | ||
<< " eta = " << seed->eta() | ||
<< " phi = " << seed->phi() <<std::endl; | ||
for( auto clus = clusters.cbegin(); clus != not_clustered; ++clus ) { | ||
edm::LogVerbatim("PFClustering") | ||
<< "\t\tClustered cluster: e = " | ||
<< (*clus)->energy_nocalib() | ||
<< " eta = " << (*clus)->eta() | ||
<< " phi = " << (*clus)->phi() << std::endl; | ||
} | ||
for( auto clus = not_clustered; clus != clusters.end(); ++clus ) { | ||
edm::LogVerbatim("PFClustering") | ||
<< "\tNon-Clustered cluster: e = " | ||
<< (*clus)->energy_nocalib() | ||
<< " eta = " << (*clus)->eta() | ||
<< " phi = " << (*clus)->phi() << std::endl; | ||
} | ||
} | ||
// move the clustered clusters out of available cluster list | ||
// and into a temporary vector for building the SC | ||
CalibratedClusterPtrVector clustered; | ||
clustered.reserve(not_clustered - clusters.begin()); | ||
clustered.insert(clustered.begin(),clusters.begin(),not_clustered); | ||
clusters.erase(clusters.begin(),not_clustered); | ||
// need the vector of raw pointers for a PF width class | ||
std::vector<const reco::PFCluster*> bare_ptrs; | ||
// calculate necessary parameters and build the SC | ||
double posX(0), posY(0), posZ(0), | ||
rawSCEnergy(0), corrSCEnergy(0), clusterCorrEE(0), | ||
PS1_clus_sum(0), PS2_clus_sum(0); | ||
edm::PtrVector<reco::PFCluster> psclusters; | ||
for( auto clus : clustered ) { | ||
bare_ptrs.push_back(clus->the_ptr().get()); | ||
|
||
posX += clus->energy_nocalib() * clus->the_ptr()->position().X(); | ||
posY += clus->energy_nocalib() * clus->the_ptr()->position().Y(); | ||
posZ += clus->energy_nocalib() * clus->the_ptr()->position().Z(); | ||
// update EE calibrated super cluster energies | ||
if( isEE ) { | ||
psclusters = _psclustersforee.find(clus->the_ptr())->second; | ||
PS1_clus_sum = std::accumulate(psclusters.begin(), | ||
psclusters.end(), | ||
0.0,sumps1); | ||
PS2_clus_sum = std::accumulate(psclusters.begin(), | ||
psclusters.end(), | ||
0.0,sumps2); | ||
clusterCorrEE = | ||
_pfEnergyCalibration->energyEm(*(clus->the_ptr()), | ||
PS1_clus_sum, | ||
PS2_clus_sum, | ||
applyCrackCorrections_); | ||
clus->resetCalibratedEnergy(clusterCorrEE); | ||
} | ||
|
||
rawSCEnergy += clus->energy_nocalib(); | ||
corrSCEnergy += clus->energy(); | ||
} | ||
posX /= rawSCEnergy; | ||
posY /= rawSCEnergy; | ||
posZ /= rawSCEnergy; | ||
|
||
// now build the supercluster | ||
reco::SuperCluster new_sc(corrSCEnergy,math::XYZPoint(posX,posY,posZ)); | ||
double ps1_energy(0.0), ps2_energy(0.0), ps_energy(0.0); | ||
new_sc.setSeed(clustered.front()->the_ptr()); | ||
for( auto clus : clustered ) { | ||
new_sc.addCluster(clus->the_ptr()); | ||
auto hits_and_fractions = clus->the_ptr()->hitsAndFractions(); | ||
for( auto hit_and_fraction : hits_and_fractions ) { | ||
new_sc.addHitAndFraction(hit_and_fraction.first,hit_and_fraction.second); | ||
} | ||
auto cluspsassociation = _psclustersforee.find(clus->the_ptr()); | ||
if( cluspsassociation != _psclustersforee.end() ) { | ||
// since EE rechits can share PS rechits, we have to make | ||
// sure the PS rechit hasn't already been added | ||
for( auto psclus : cluspsassociation->second ) { | ||
auto found_pscluster = std::find(new_sc.preshowerClustersBegin(), | ||
new_sc.preshowerClustersEnd(), | ||
reco::CaloClusterPtr(psclus)); | ||
if( found_pscluster == new_sc.preshowerClustersEnd() ) { | ||
ps1_energy += (PFLayer::PS1 == psclus->layer())*psclus->energy(); | ||
ps2_energy += (PFLayer::PS2 == psclus->layer())*psclus->energy(); | ||
ps_energy += psclus->energy(); | ||
new_sc.addPreshowerCluster(psclus); | ||
} | ||
} | ||
} | ||
} | ||
new_sc.setPreshowerEnergy(ps_energy); | ||
new_sc.setPreshowerEnergyPlane1(ps1_energy); | ||
new_sc.setPreshowerEnergyPlane2(ps2_energy); | ||
|
||
// calculate linearly weighted cluster widths | ||
PFClusterWidthAlgo pfwidth(bare_ptrs); | ||
new_sc.setEtaWidth(pfwidth.pflowEtaWidth()); | ||
new_sc.setPhiWidth(pfwidth.pflowPhiWidth()); | ||
|
||
// cache the value of the raw energy | ||
new_sc.rawEnergy(); | ||
|
||
// save the super cluster to the appropriate list | ||
switch( seed->the_ptr()->layer() ) { | ||
case PFLayer::ECAL_BARREL: | ||
superClustersEB_->push_back(new_sc); | ||
break; | ||
case PFLayer::ECAL_ENDCAP: | ||
superClustersEE_->push_back(new_sc); | ||
break; | ||
default: | ||
break; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
trunk/RecoEcal/EgammaClusterProducers/interface/PFECALSuperClusterProducerNew.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,68 @@ | ||
#ifndef RecoEcal_EgammaClusterProducers_PFECALSuperClusterProducerNew_h_ | ||
#define RecoEcal_EgammaClusterProducers_PFECALSuperClusterProducerNew_h_ | ||
|
||
// system include files | ||
#include <memory> | ||
#include <vector> | ||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/EDProducer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" | ||
|
||
#include "RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgoNew.h" | ||
|
||
/**\class PFECALSuperClusterProducerNew | ||
\author Nicolas Chanon | ||
Additional authors for Mustache: Y. Gershtein, R. Patel, L. Gray | ||
\date July 2012 | ||
*/ | ||
|
||
class CaloSubdetectorTopology; | ||
class CaloSubdetectorGeometry; | ||
class DetId; | ||
|
||
|
||
class PFECALSuperClusterProducerNew : public edm::EDProducer { | ||
public: | ||
explicit PFECALSuperClusterProducerNew(const edm::ParameterSet&); | ||
~PFECALSuperClusterProducerNew(); | ||
|
||
|
||
virtual void produce(edm::Event&, const edm::EventSetup&); | ||
|
||
|
||
private: | ||
|
||
// ----------member data --------------------------- | ||
|
||
/// clustering algorithm | ||
PFECALSuperClusterAlgoNew superClusterAlgo_; | ||
PFECALSuperClusterAlgoNew::clustering_type _theclusteringtype; | ||
|
||
std::shared_ptr<PFEnergyCalibration> thePFEnergyCalibration_; | ||
|
||
/// verbose ? | ||
bool verbose_; | ||
|
||
edm::InputTag inputTagPFClusters_; | ||
edm::InputTag inputTagPFClustersES_; | ||
|
||
std::string PFBasicClusterCollectionBarrel_; | ||
std::string PFSuperClusterCollectionBarrel_; | ||
std::string PFBasicClusterCollectionEndcap_; | ||
std::string PFSuperClusterCollectionEndcap_; | ||
std::string PFBasicClusterCollectionPreshower_; | ||
std::string PFSuperClusterCollectionEndcapWithPreshower_; | ||
|
||
}; | ||
|
||
#endif |
98 changes: 98 additions & 0 deletions
98
trunk/RecoEcal/EgammaClusterProducers/python/particleFlowSuperClusterECALNew_cfi.py
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,98 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
particleFlowSuperClusterECALNew = cms.EDProducer( | ||
"PFECALSuperClusterProducerNew", | ||
# verbosity | ||
verbose = cms.untracked.bool(False), | ||
#clustering type: "Box" or "Mustache" | ||
ClusteringType = cms.string("Box"), | ||
|
||
#PFClusters collection | ||
PFClusters = cms.InputTag("particleFlowClusterECAL"), | ||
PFClustersES = cms.InputTag("particleFlowClusterPS"), | ||
|
||
PFBasicClusterCollectionBarrel = cms.string("particleFlowBasicClusterECALBarrel"), | ||
PFSuperClusterCollectionBarrel = cms.string("particleFlowSuperClusterECALBarrel"), | ||
PFBasicClusterCollectionEndcap = cms.string("particleFlowBasicClusterECALEndcap"), | ||
PFSuperClusterCollectionEndcap = cms.string("particleFlowSuperClusterECALEndcap"), | ||
PFBasicClusterCollectionPreshower = cms.string("particleFlowSuperClusterECALPreshower"), | ||
PFSuperClusterCollectionEndcapWithPreshower = cms.string("particleFlowSuperClusterECALEndcapWithPreshower"), | ||
|
||
#use preshower ? | ||
use_preshower = cms.bool(True), | ||
|
||
# threshold in ECAL | ||
thresh_PFClusterSeedBarrel = cms.double(3.0), | ||
thresh_PFClusterBarrel = cms.double(0.5), | ||
|
||
thresh_PFClusterSeedEndcap = cms.double(3.0), | ||
thresh_PFClusterEndcap = cms.double(0.5), | ||
|
||
# window width in ECAL | ||
phiwidth_SuperClusterBarrel = cms.double(0.28), | ||
etawidth_SuperClusterBarrel = cms.double(0.04), | ||
|
||
phiwidth_SuperClusterEndcap = cms.double(0.28), | ||
etawidth_SuperClusterEndcap = cms.double(0.04), | ||
|
||
# threshold in preshower | ||
thresh_PFClusterES = cms.double(0.), | ||
|
||
# threshold for clusters outside mustache area | ||
doMustachePUcleaning = cms.bool(False), | ||
#thresh_PFClusterMustacheOutBarrel = cms.double(0.), | ||
#thresh_PFClusterMustacheOutEndcap = cms.double(0.), | ||
|
||
#corrections | ||
applyCrackCorrections = cms.bool(False) | ||
|
||
) | ||
|
||
particleFlowSuperClusterECALMustacheNew = cms.EDProducer( | ||
"PFECALSuperClusterProducerNew", | ||
# verbosity | ||
verbose = cms.untracked.bool(False), | ||
#clustering type: "Box" or "Mustache" | ||
ClusteringType = cms.string("Mustache"), | ||
|
||
#PFClusters collection | ||
PFClusters = cms.InputTag("particleFlowClusterECAL"), | ||
PFClustersES = cms.InputTag("particleFlowClusterPS"), | ||
|
||
PFBasicClusterCollectionBarrel = cms.string("particleFlowBasicClusterECALBarrel"), | ||
PFSuperClusterCollectionBarrel = cms.string("particleFlowSuperClusterECALBarrel"), | ||
PFBasicClusterCollectionEndcap = cms.string("particleFlowBasicClusterECALEndcap"), | ||
PFSuperClusterCollectionEndcap = cms.string("particleFlowSuperClusterECALEndcap"), | ||
PFBasicClusterCollectionPreshower = cms.string("particleFlowSuperClusterECALPreshower"), | ||
PFSuperClusterCollectionEndcapWithPreshower = cms.string("particleFlowSuperClusterECALEndcapWithPreshower"), | ||
|
||
#use preshower ? | ||
use_preshower = cms.bool(True), | ||
|
||
# threshold in ECAL | ||
thresh_PFClusterSeedBarrel = cms.double(3.0), | ||
thresh_PFClusterBarrel = cms.double(0.0), | ||
|
||
thresh_PFClusterSeedEndcap = cms.double(3.0), | ||
thresh_PFClusterEndcap = cms.double(0.0), | ||
|
||
# window width in ECAL | ||
phiwidth_SuperClusterBarrel = cms.double(0.6), | ||
etawidth_SuperClusterBarrel = cms.double(0.04), | ||
|
||
phiwidth_SuperClusterEndcap = cms.double(0.6), | ||
etawidth_SuperClusterEndcap = cms.double(0.04), | ||
|
||
# threshold in preshower | ||
thresh_PFClusterES = cms.double(0.), | ||
|
||
# threshold for clusters outside mustache area | ||
doMustachePUcleaning = cms.bool(False), | ||
#thresh_PFClusterMustacheOutBarrel = cms.double(0.), | ||
#thresh_PFClusterMustacheOutEndcap = cms.double(0.), | ||
|
||
#corrections | ||
applyCrackCorrections = cms.bool(False) | ||
|
||
) | ||
|
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
145 changes: 145 additions & 0 deletions
145
trunk/RecoEcal/EgammaClusterProducers/src/PFECALSuperClusterProducerNew.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,145 @@ | ||
#include "RecoEcal/EgammaClusterProducers/interface/PFECALSuperClusterProducerNew.h" | ||
|
||
#include <memory> | ||
|
||
#include "RecoEcal/EgammaClusterAlgos/interface/PFECALSuperClusterAlgoNew.h" | ||
|
||
#include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h" | ||
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" | ||
|
||
#include "DataFormats/EgammaReco/interface/SuperCluster.h" | ||
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
|
||
using namespace std; | ||
using namespace edm; | ||
|
||
namespace { | ||
const std::string ClusterType__BOX("Box"); | ||
const std::string ClusterType__Mustache("Mustache"); | ||
} | ||
|
||
PFECALSuperClusterProducerNew::PFECALSuperClusterProducerNew(const edm::ParameterSet& iConfig) | ||
{ | ||
|
||
verbose_ = | ||
iConfig.getUntrackedParameter<bool>("verbose",false); | ||
|
||
std::string _typename = iConfig.getParameter<std::string>("ClusteringType"); | ||
if( _typename == ClusterType__BOX ) { | ||
_theclusteringtype = PFECALSuperClusterAlgoNew::kBOX; | ||
} else if ( _typename == ClusterType__Mustache ) { | ||
_theclusteringtype = PFECALSuperClusterAlgoNew::kMustache; | ||
} else { | ||
throw cms::Exception("InvalidClusteringType") | ||
<< "You have not chosen a valid clustering type," | ||
<< " please choose from \"Box\" or \"Mustache\"!"; | ||
} | ||
|
||
|
||
// parameters for clustering | ||
|
||
double threshPFClusterSeedBarrel = iConfig.getParameter<double>("thresh_PFClusterSeedBarrel"); | ||
double threshPFClusterBarrel = iConfig.getParameter<double>("thresh_PFClusterBarrel"); | ||
|
||
double threshPFClusterSeedEndcap = iConfig.getParameter<double>("thresh_PFClusterSeedEndcap"); | ||
double threshPFClusterEndcap = iConfig.getParameter<double>("thresh_PFClusterEndcap"); | ||
|
||
double phiwidthSuperClusterBarrel = iConfig.getParameter<double>("phiwidth_SuperClusterBarrel"); | ||
double etawidthSuperClusterBarrel = iConfig.getParameter<double>("etawidth_SuperClusterBarrel"); | ||
|
||
double phiwidthSuperClusterEndcap = iConfig.getParameter<double>("phiwidth_SuperClusterEndcap"); | ||
double etawidthSuperClusterEndcap = iConfig.getParameter<double>("etawidth_SuperClusterEndcap"); | ||
|
||
double threshPFClusterES = iConfig.getParameter<double>("thresh_PFClusterES"); | ||
|
||
//double threshPFClusterMustacheOutBarrel = iConfig.getParameter<double>("thresh_PFClusterMustacheOutBarrel"); | ||
//double threshPFClusterMustacheOutEndcap = iConfig.getParameter<double>("thresh_PFClusterMustacheOutEndcap"); | ||
|
||
double doMustacheCut = iConfig.getParameter<bool>("doMustachePUcleaning"); | ||
|
||
superClusterAlgo_.setVerbosityLevel(verbose_); | ||
superClusterAlgo_.setClusteringType(_theclusteringtype); | ||
|
||
superClusterAlgo_.setThreshPFClusterSeedBarrel( threshPFClusterSeedBarrel ); | ||
superClusterAlgo_.setThreshPFClusterBarrel( threshPFClusterBarrel ); | ||
|
||
superClusterAlgo_.setThreshPFClusterSeedEndcap( threshPFClusterSeedEndcap ); | ||
superClusterAlgo_.setThreshPFClusterEndcap( threshPFClusterEndcap ); | ||
|
||
superClusterAlgo_.setPhiwidthSuperClusterBarrel( phiwidthSuperClusterBarrel ); | ||
superClusterAlgo_.setEtawidthSuperClusterBarrel( etawidthSuperClusterBarrel ); | ||
|
||
superClusterAlgo_.setPhiwidthSuperClusterEndcap( phiwidthSuperClusterEndcap ); | ||
superClusterAlgo_.setEtawidthSuperClusterEndcap( etawidthSuperClusterEndcap ); | ||
|
||
superClusterAlgo_.setThreshPFClusterES( threshPFClusterES ); | ||
|
||
superClusterAlgo_.setMustacheCut( doMustacheCut ); | ||
//superClusterAlgo_.setThreshPFClusterMustacheOutBarrel( threshPFClusterMustacheOutBarrel ); | ||
//superClusterAlgo_.setThreshPFClusterMustacheOutEndcap( threshPFClusterMustacheOutEndcap ); | ||
|
||
//Load the ECAL energy calibration | ||
thePFEnergyCalibration_ = | ||
std::shared_ptr<PFEnergyCalibration>(new PFEnergyCalibration()); | ||
superClusterAlgo_.setPFClusterCalibration(thePFEnergyCalibration_); | ||
superClusterAlgo_.setUsePS(iConfig.getParameter<bool>("use_preshower")); | ||
|
||
bool applyCrackCorrections_ = iConfig.getParameter<bool>("applyCrackCorrections"); | ||
superClusterAlgo_.setCrackCorrections(applyCrackCorrections_); | ||
|
||
|
||
|
||
inputTagPFClusters_ = iConfig.getParameter<InputTag>("PFClusters"); | ||
inputTagPFClustersES_ = iConfig.getParameter<InputTag>("PFClustersES"); | ||
|
||
PFBasicClusterCollectionBarrel_ = iConfig.getParameter<string>("PFBasicClusterCollectionBarrel"); | ||
PFSuperClusterCollectionBarrel_ = iConfig.getParameter<string>("PFSuperClusterCollectionBarrel"); | ||
|
||
PFBasicClusterCollectionEndcap_ = iConfig.getParameter<string>("PFBasicClusterCollectionEndcap"); | ||
PFSuperClusterCollectionEndcap_ = iConfig.getParameter<string>("PFSuperClusterCollectionEndcap"); | ||
|
||
PFBasicClusterCollectionPreshower_ = iConfig.getParameter<string>("PFBasicClusterCollectionPreshower"); | ||
PFSuperClusterCollectionEndcapWithPreshower_ = iConfig.getParameter<string>("PFSuperClusterCollectionEndcapWithPreshower"); | ||
|
||
produces<reco::SuperClusterCollection>(PFSuperClusterCollectionBarrel_); | ||
produces<reco::SuperClusterCollection>(PFSuperClusterCollectionEndcap_); | ||
} | ||
|
||
|
||
|
||
PFECALSuperClusterProducerNew::~PFECALSuperClusterProducerNew() {} | ||
|
||
|
||
|
||
|
||
void PFECALSuperClusterProducerNew::produce(edm::Event& iEvent, | ||
const edm::EventSetup& iSetup) { | ||
|
||
|
||
//Load the pfcluster collections | ||
edm::Handle<edm::View<reco::PFCluster> > pfclustersHandle; | ||
iEvent.getByLabel( inputTagPFClusters_, pfclustersHandle ); | ||
|
||
edm::Handle<edm::View<reco::PFCluster> > preshowerpfclustersHandle; | ||
iEvent.getByLabel( inputTagPFClustersES_, preshowerpfclustersHandle); | ||
|
||
|
||
// do clustering | ||
superClusterAlgo_.loadAndSortPFClusters(*pfclustersHandle, | ||
*preshowerpfclustersHandle); | ||
superClusterAlgo_.run(); | ||
|
||
//store in the event | ||
iEvent.put(superClusterAlgo_.getEBOutputSCCollection(), | ||
PFSuperClusterCollectionBarrel_); | ||
iEvent.put(superClusterAlgo_.getEEOutputSCCollection(), | ||
PFSuperClusterCollectionEndcap_); | ||
} | ||
|
||
|
||
|