#include <PFECALSuperClusterAlgo.h>
Definition at line 47 of file PFECALSuperClusterAlgo.h.
typedef std::shared_ptr<CalibratedPFCluster> PFECALSuperClusterAlgo::CalibratedClusterPtr |
Definition at line 70 of file PFECALSuperClusterAlgo.h.
typedef std::vector<CalibratedClusterPtr> PFECALSuperClusterAlgo::CalibratedClusterPtrVector |
Definition at line 71 of file PFECALSuperClusterAlgo.h.
Definition at line 49 of file PFECALSuperClusterAlgo.h.
PFECALSuperClusterAlgo::PFECALSuperClusterAlgo | ( | ) |
void PFECALSuperClusterAlgo::buildAllSuperClusters | ( | CalibratedClusterPtrVector & | , |
double | seedthresh | ||
) | [private] |
Definition at line 259 of file PFECALSuperClusterAlgo.cc.
{ IsASeed seedable(seedthresh); // make sure only seeds appear at the front of the list of clusters std::stable_partition(clusters.begin(),clusters.end(),seedable); // 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 PFECALSuperClusterAlgo::buildSuperCluster | ( | CalibratedClusterPtr & | , |
CalibratedClusterPtrVector & | |||
) | [private] |
Definition at line 274 of file PFECALSuperClusterAlgo.cc.
References reco::SuperCluster::addCluster(), reco::CaloCluster::addHitAndFraction(), reco::SuperCluster::addPreshowerCluster(), PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, Exception, spr::find(), edm::Ptr< T >::get(), PFClusterWidthAlgo::pflowEtaWidth(), PFClusterWidthAlgo::pflowPhiWidth(), reco::SuperCluster::preshowerClustersBegin(), reco::SuperCluster::preshowerClustersEnd(), PFLayer::PS1, PFLayer::PS2, reco::SuperCluster::rawEnergy(), reco::SuperCluster::setEtaWidth(), reco::SuperCluster::setPhiWidth(), reco::SuperCluster::setPreshowerEnergy(), reco::SuperCluster::setPreshowerEnergyPlane1(), reco::SuperCluster::setPreshowerEnergyPlane2(), and reco::SuperCluster::setSeed().
{ IsClustered IsClusteredWithSeed(seed,_clustype,_useDynamicDPhi); IsLinkedByRecHit MatchesSeedByRecHit(seed,satelliteThreshold_, fractionForMajority_,0.1,0.2); 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); // satellite cluster merging // it was found that large clusters can split! if( doSatelliteClusterMerge_ ) { not_clustered = std::stable_partition(not_clustered,clusters.end(), MatchesSeedByRecHit); } 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(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); for( auto& clus : clustered ) { bare_ptrs.push_back(clus->the_ptr().get()); const double cluseraw = clus->energy_nocalib(); const math::XYZPoint& cluspos = clus->the_ptr()->position(); posX += cluseraw * cluspos.X(); posY += cluseraw * cluspos.Y(); posZ += cluseraw * cluspos.Z(); // update EE calibrated super cluster energies if( isEE ) { const auto& psclusters = _psclustersforee[clus->the_ptr()]; 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 += cluseraw; 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( const 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); } const auto& cluspsassociation = _psclustersforee[clus->the_ptr()]; // EE rechits should be uniquely matched to sets of pre-shower // clusters at this point, so we throw an exception if otherwise for( const auto& psclus : cluspsassociation ) { auto found_pscluster = std::find(new_sc.preshowerClustersBegin(), new_sc.preshowerClustersEnd(), reco::CaloClusterPtr(psclus)); if( found_pscluster == new_sc.preshowerClustersEnd() ) { const double psenergy = psclus->energy(); new_sc.addPreshowerCluster(psclus); ps1_energy += (PFLayer::PS1 == psclus->layer())*psenergy; ps2_energy += (PFLayer::PS2 == psclus->layer())*psenergy; ps_energy += psenergy; } else { throw cms::Exception("PFECALSuperClusterAlgo::buildSuperCluster") << "Found a PS cluster matched to more than one EE cluster!" << std::endl << std::hex << psclus.get() << " == " << found_pscluster->get() << std::dec << std::endl; } } } 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; } }
std::auto_ptr<reco::SuperClusterCollection> PFECALSuperClusterAlgo::getEBOutputSCCollection | ( | ) | [inline] |
Definition at line 107 of file PFECALSuperClusterAlgo.h.
References superClustersEB_.
{ return superClustersEB_; }
std::auto_ptr<reco::SuperClusterCollection> PFECALSuperClusterAlgo::getEEOutputSCCollection | ( | ) | [inline] |
Definition at line 109 of file PFECALSuperClusterAlgo.h.
References superClustersEE_.
{ return superClustersEE_; }
void PFECALSuperClusterAlgo::loadAndSortPFClusters | ( | const edm::View< reco::PFCluster > & | ecalclusters, |
const edm::View< reco::PFCluster > & | psclusters | ||
) |
Definition at line 180 of file PFECALSuperClusterAlgo.cc.
References PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, edm::Ptr< T >::isNonnull(), LogDebug, PFLayer::PS1, PFLayer::PS2, and python::multivaluedict::sort().
{ // 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()<<std::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.emplace(calib_cluster->the_ptr(), edm::PtrVector<reco::PFCluster>()); } break; default: break; } } // make the association map of ECAL clusters to preshower clusters edm::PtrVector<reco::PFCluster> clusterPtrsPS = psclusters.ptrVector(); double dist = -1.0, min_dist = -1.0; // match PS clusters to EE clusters, minimum distance to EE is ensured // since the inner loop is over the EE clusters for( const 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; } edm::Ptr<reco::PFCluster> eematch; dist = min_dist = -1.0; // reset for( const auto& eeclus : _clustersEE ) { dist = testPreshowerDistance(eeclus->the_ptr(),psclus); if( dist == -1.0 || (min_dist != -1.0 && dist > min_dist) ) continue; if( dist < min_dist || min_dist == -1.0 ) { eematch = eeclus->the_ptr(); min_dist = dist; } } // loop on EE clusters if( eematch.isNonnull() ) _psclustersforee[eematch].push_back(psclus); } // loop on PS clusters // sort full cluster collections by their calibrated energy // this will put all the seeds first by construction GreaterByEt greater; std::sort(_clustersEB.begin(), _clustersEB.end(), greater); std::sort(_clustersEE.begin(), _clustersEE.end(), greater); }
void PFECALSuperClusterAlgo::run | ( | void | ) |
Definition at line 251 of file PFECALSuperClusterAlgo.cc.
{ // clusterize the EB buildAllSuperClusters(_clustersEB, threshPFClusterSeedBarrel_); // clusterize the EE buildAllSuperClusters(_clustersEE, threshPFClusterSeedEndcap_); }
void PFECALSuperClusterAlgo::setClusteringType | ( | clustering_type | thetype | ) | [inline] |
Definition at line 79 of file PFECALSuperClusterAlgo.h.
References _clustype.
{ _clustype = thetype; }
void PFECALSuperClusterAlgo::setCrackCorrections | ( | bool | applyCrackCorrections | ) | [inline] |
Definition at line 104 of file PFECALSuperClusterAlgo.h.
References applyCrackCorrections_.
{ applyCrackCorrections_ = applyCrackCorrections;}
void PFECALSuperClusterAlgo::setEtawidthSuperClusterBarrel | ( | double | etawidth | ) | [inline] |
Definition at line 89 of file PFECALSuperClusterAlgo.h.
References etawidthSuperClusterBarrel_.
{ etawidthSuperClusterBarrel_ = etawidth;}
void PFECALSuperClusterAlgo::setEtawidthSuperClusterEndcap | ( | double | etawidth | ) | [inline] |
Definition at line 91 of file PFECALSuperClusterAlgo.h.
References etawidthSuperClusterEndcap_.
{ etawidthSuperClusterEndcap_ = etawidth;}
void PFECALSuperClusterAlgo::setMajorityFraction | ( | const double | f | ) | [inline] |
Definition at line 100 of file PFECALSuperClusterAlgo.h.
References f, and fractionForMajority_.
{ fractionForMajority_ = f; }
void PFECALSuperClusterAlgo::setPFClusterCalibration | ( | const std::shared_ptr< PFEnergyCalibration > & | calib | ) |
Definition at line 175 of file PFECALSuperClusterAlgo.cc.
References calib.
{ _pfEnergyCalibration = calib; }
void PFECALSuperClusterAlgo::setPhiwidthSuperClusterBarrel | ( | double | phiwidth | ) | [inline] |
Definition at line 88 of file PFECALSuperClusterAlgo.h.
References phiwidthSuperClusterBarrel_.
{ phiwidthSuperClusterBarrel_ = phiwidth;}
void PFECALSuperClusterAlgo::setPhiwidthSuperClusterEndcap | ( | double | phiwidth | ) | [inline] |
Definition at line 90 of file PFECALSuperClusterAlgo.h.
References phiwidthSuperClusterEndcap_.
{ phiwidthSuperClusterEndcap_ = phiwidth;}
void PFECALSuperClusterAlgo::setSatelliteMerging | ( | const bool | doit | ) | [inline] |
Definition at line 98 of file PFECALSuperClusterAlgo.h.
References doSatelliteClusterMerge_.
{ doSatelliteClusterMerge_ = doit; }
void PFECALSuperClusterAlgo::setSatelliteThreshold | ( | const double | t | ) | [inline] |
Definition at line 99 of file PFECALSuperClusterAlgo.h.
References satelliteThreshold_, and lumiQTWidget::t.
{ satelliteThreshold_ = t; }
void PFECALSuperClusterAlgo::setThreshPFClusterBarrel | ( | double | thresh | ) | [inline] |
Definition at line 84 of file PFECALSuperClusterAlgo.h.
References GOODCOLL_filter_cfg::thresh, and threshPFClusterBarrel_.
{ threshPFClusterBarrel_ = thresh;}
void PFECALSuperClusterAlgo::setThreshPFClusterEndcap | ( | double | thresh | ) | [inline] |
Definition at line 86 of file PFECALSuperClusterAlgo.h.
References GOODCOLL_filter_cfg::thresh, and threshPFClusterEndcap_.
{ threshPFClusterEndcap_ = thresh;}
void PFECALSuperClusterAlgo::setThreshPFClusterES | ( | double | thresh | ) | [inline] |
Definition at line 96 of file PFECALSuperClusterAlgo.h.
References GOODCOLL_filter_cfg::thresh, and threshPFClusterES_.
{threshPFClusterES_ = thresh;}
void PFECALSuperClusterAlgo::setThreshPFClusterSeedBarrel | ( | double | thresh | ) | [inline] |
Definition at line 83 of file PFECALSuperClusterAlgo.h.
References GOODCOLL_filter_cfg::thresh, and threshPFClusterSeedBarrel_.
void PFECALSuperClusterAlgo::setThreshPFClusterSeedEndcap | ( | double | thresh | ) | [inline] |
Definition at line 85 of file PFECALSuperClusterAlgo.h.
References GOODCOLL_filter_cfg::thresh, and threshPFClusterSeedEndcap_.
void PFECALSuperClusterAlgo::setUseDynamicDPhi | ( | bool | useit | ) | [inline] |
Definition at line 81 of file PFECALSuperClusterAlgo.h.
References _useDynamicDPhi.
{ _useDynamicDPhi = useit; }
void PFECALSuperClusterAlgo::setUsePS | ( | bool | useit | ) | [inline] |
void PFECALSuperClusterAlgo::setVerbosityLevel | ( | bool | verbose | ) | [inline] |
Definition at line 77 of file PFECALSuperClusterAlgo.h.
References validate_alignment_devdb10_cfg::verbose, and verbose_.
Definition at line 118 of file PFECALSuperClusterAlgo.h.
Definition at line 119 of file PFECALSuperClusterAlgo.h.
Definition at line 125 of file PFECALSuperClusterAlgo.h.
Referenced by setClusteringType().
std::shared_ptr<PFEnergyCalibration> PFECALSuperClusterAlgo::_pfEnergyCalibration [private] |
Definition at line 124 of file PFECALSuperClusterAlgo.h.
std::unordered_map<edm::Ptr<reco::PFCluster>, edm::PtrVector<reco::PFCluster> > PFECALSuperClusterAlgo::_psclustersforee [private] |
Definition at line 121 of file PFECALSuperClusterAlgo.h.
bool PFECALSuperClusterAlgo::_useDynamicDPhi [private] |
Definition at line 152 of file PFECALSuperClusterAlgo.h.
Referenced by setUseDynamicDPhi().
bool PFECALSuperClusterAlgo::applyCrackCorrections_ [private] |
Definition at line 154 of file PFECALSuperClusterAlgo.h.
Referenced by setCrackCorrections().
bool PFECALSuperClusterAlgo::doSatelliteClusterMerge_ [private] |
Definition at line 149 of file PFECALSuperClusterAlgo.h.
Referenced by setSatelliteMerging().
double PFECALSuperClusterAlgo::etawidthSuperCluster_ [private] |
Definition at line 135 of file PFECALSuperClusterAlgo.h.
double PFECALSuperClusterAlgo::etawidthSuperClusterBarrel_ [private] |
Definition at line 145 of file PFECALSuperClusterAlgo.h.
Referenced by setEtawidthSuperClusterBarrel().
double PFECALSuperClusterAlgo::etawidthSuperClusterEndcap_ [private] |
Definition at line 147 of file PFECALSuperClusterAlgo.h.
Referenced by setEtawidthSuperClusterEndcap().
double PFECALSuperClusterAlgo::fractionForMajority_ [private] |
Definition at line 150 of file PFECALSuperClusterAlgo.h.
Referenced by setMajorityFraction().
double PFECALSuperClusterAlgo::phiwidthSuperCluster_ [private] |
Definition at line 136 of file PFECALSuperClusterAlgo.h.
double PFECALSuperClusterAlgo::phiwidthSuperClusterBarrel_ [private] |
Definition at line 144 of file PFECALSuperClusterAlgo.h.
Referenced by setPhiwidthSuperClusterBarrel().
double PFECALSuperClusterAlgo::phiwidthSuperClusterEndcap_ [private] |
Definition at line 146 of file PFECALSuperClusterAlgo.h.
Referenced by setPhiwidthSuperClusterEndcap().
double PFECALSuperClusterAlgo::satelliteThreshold_ [private] |
Definition at line 150 of file PFECALSuperClusterAlgo.h.
Referenced by setSatelliteThreshold().
std::auto_ptr<reco::SuperClusterCollection> PFECALSuperClusterAlgo::superClustersEB_ [private] |
Definition at line 122 of file PFECALSuperClusterAlgo.h.
Referenced by getEBOutputSCCollection().
std::auto_ptr<reco::SuperClusterCollection> PFECALSuperClusterAlgo::superClustersEE_ [private] |
Definition at line 123 of file PFECALSuperClusterAlgo.h.
Referenced by getEEOutputSCCollection().
double PFECALSuperClusterAlgo::threshPFCluster_ [private] |
Definition at line 134 of file PFECALSuperClusterAlgo.h.
double PFECALSuperClusterAlgo::threshPFClusterBarrel_ [private] |
Definition at line 139 of file PFECALSuperClusterAlgo.h.
Referenced by setThreshPFClusterBarrel().
double PFECALSuperClusterAlgo::threshPFClusterEndcap_ [private] |
Definition at line 141 of file PFECALSuperClusterAlgo.h.
Referenced by setThreshPFClusterEndcap().
double PFECALSuperClusterAlgo::threshPFClusterES_ [private] |
Definition at line 142 of file PFECALSuperClusterAlgo.h.
Referenced by setThreshPFClusterES().
double PFECALSuperClusterAlgo::threshPFClusterSeed_ [private] |
Definition at line 133 of file PFECALSuperClusterAlgo.h.
double PFECALSuperClusterAlgo::threshPFClusterSeedBarrel_ [private] |
Definition at line 138 of file PFECALSuperClusterAlgo.h.
Referenced by setThreshPFClusterSeedBarrel().
double PFECALSuperClusterAlgo::threshPFClusterSeedEndcap_ [private] |
Definition at line 140 of file PFECALSuperClusterAlgo.h.
Referenced by setThreshPFClusterSeedEndcap().
bool PFECALSuperClusterAlgo::usePS [private] |
Definition at line 156 of file PFECALSuperClusterAlgo.h.
Referenced by setUsePS().
bool PFECALSuperClusterAlgo::verbose_ [private] |
Definition at line 131 of file PFECALSuperClusterAlgo.h.
Referenced by setVerbosityLevel().