CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
GenericSimClusterMapper Class Reference

#include <GenericSimClusterMapper.h>

Inheritance diagram for GenericSimClusterMapper:
InitialClusteringStepBase

Public Member Functions

void buildClusters (const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
 
 GenericSimClusterMapper (const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
 
 GenericSimClusterMapper (const B2DGT &)=delete
 
B2DGToperator= (const B2DGT &)=delete
 
void updateEvent (const edm::Event &) final
 
 ~GenericSimClusterMapper () override=default
 
- Public Member Functions inherited from InitialClusteringStepBase
 InitialClusteringStepBase (const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
 
 InitialClusteringStepBase (const ICSB &)=delete
 
std::ostream & operator<< (std::ostream &o) const
 
ICSBoperator= (const ICSB &)=delete
 
void reset ()
 
virtual void update (const edm::EventSetup &)
 
virtual ~InitialClusteringStepBase ()=default
 

Private Types

typedef GenericSimClusterMapper B2DGT
 

Private Attributes

edm::Handle< SimClusterCollection_simClusterH
 
edm::EDGetTokenT< SimClusterCollection_simClusterToken
 

Additional Inherited Members

- Protected Types inherited from InitialClusteringStepBase
typedef std::tuple< std::vector< int >,std::vector< double >, std::vector< double > > I3tuple
 
- Protected Member Functions inherited from InitialClusteringStepBase
reco::PFRecHitRef makeRefhit (const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
 
- Protected Attributes inherited from InitialClusteringStepBase
const std::unordered_map< std::string, int > _layerMap
 
unsigned _nClustersFound
 
unsigned _nSeeds
 
std::unordered_map< int, I3tuple_thresholds
 

Detailed Description

Definition at line 9 of file GenericSimClusterMapper.h.

Member Typedef Documentation

Definition at line 10 of file GenericSimClusterMapper.h.

Constructor & Destructor Documentation

GenericSimClusterMapper::GenericSimClusterMapper ( const edm::ParameterSet conf,
edm::ConsumesCollector sumes 
)
inline

Definition at line 12 of file GenericSimClusterMapper.h.

References _simClusterToken, buildClusters(), edm::ConsumesCollector::consumes(), edm::ParameterSet::getParameter(), operator=(), updateEvent(), and ~GenericSimClusterMapper().

13  :
14  InitialClusteringStepBase(conf,sumes) {
16  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< SimClusterCollection > _simClusterToken
InitialClusteringStepBase(const edm::ParameterSet &conf, edm::ConsumesCollector &sumes)
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
GenericSimClusterMapper::~GenericSimClusterMapper ( )
overridedefault

Referenced by GenericSimClusterMapper().

GenericSimClusterMapper::GenericSimClusterMapper ( const B2DGT )
delete

Member Function Documentation

void GenericSimClusterMapper::buildClusters ( const edm::Handle< reco::PFRecHitCollection > &  input,
const std::vector< bool > &  rechitMask,
const std::vector< bool > &  seedable,
reco::PFClusterCollection output 
)
overridevirtual

Implements InitialClusteringStepBase.

Definition at line 27 of file GenericSimClusterMapper.cc.

References _simClusterH, reco::PFCluster::addRecHitFraction(), f, hfClusterShapes_cfi::hits, SimCluster::hits_and_fractions(), reco::CaloCluster::hitsAndFractions(), mps_fire::i, input, InitialClusteringStepBase::makeRefhit(), SimDataFormats::CaloAnalysis::sc, SurveyInfoScenario_cff::seed, reco::CaloCluster::setCorrectedEnergy(), reco::CaloCluster::setEnergy(), and reco::CaloCluster::setSeed().

Referenced by GenericSimClusterMapper(), and updateEvent().

30  {
31  const SimClusterCollection& simClusters = *_simClusterH;
32  auto const& hits = *input;
33 
34  // for quick indexing back to hit energy
35  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
36  for( uint32_t i = 0; i < hits.size(); ++i ) {
37  detIdToIndex[hits[i].detId()] = i;
38  auto ref = makeRefhit(input,i);
39  }
40 
41  for( const auto& sc : simClusters ) {
42  output.emplace_back();
43  reco::PFCluster& back = output.back();
45  double energy = 0.0, highest_energy = 0.0;
46  auto hitsAndFractions = sc.hits_and_fractions() ;
47  for( const auto& hAndF : hitsAndFractions ) {
48  auto itr = detIdToIndex.find(hAndF.first);
49  if( itr == detIdToIndex.end() ) continue; // hit wasn't saved in reco
50  auto ref = makeRefhit(input,itr->second);
51  const double hit_energy = hAndF.second * ref->energy();
52  energy += hit_energy;
53  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
54  if( hit_energy > highest_energy || highest_energy == 0.0) {
55  highest_energy = hit_energy;
56  seed = ref;
57  }
58  }
59  if( !back.hitsAndFractions().empty() ) {
60  back.setSeed(seed->detId());
61  back.setEnergy(energy);
62  back.setCorrectedEnergy(energy);
63  } else {
64  back.setSeed(-1);
65  back.setEnergy(0.f);
66  }
67  }
68 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
std::vector< std::pair< uint32_t, float > > hits_and_fractions() const
Returns list of rechit IDs and fractions for this SimCluster.
Definition: SimCluster.h:210
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
void setEnergy(double energy)
Definition: CaloCluster.h:113
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
static std::string const input
Definition: EdmProvDump.cc:45
void setSeed(const DetId &id)
Definition: CaloCluster.h:123
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
edm::Handle< SimClusterCollection > _simClusterH
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:114
double f[11][100]
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:91
std::vector< SimCluster > SimClusterCollection
Definition: SimClusterFwd.h:8
B2DGT& GenericSimClusterMapper::operator= ( const B2DGT )
delete

Referenced by GenericSimClusterMapper().

void GenericSimClusterMapper::updateEvent ( const edm::Event ev)
finalvirtual

Reimplemented from InitialClusteringStepBase.

Definition at line 22 of file GenericSimClusterMapper.cc.

References _simClusterH, _simClusterToken, buildClusters(), and edm::Event::getByToken().

Referenced by GenericSimClusterMapper().

22  {
24 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::Handle< SimClusterCollection > _simClusterH
edm::EDGetTokenT< SimClusterCollection > _simClusterToken

Member Data Documentation

edm::Handle<SimClusterCollection> GenericSimClusterMapper::_simClusterH
private

Definition at line 30 of file GenericSimClusterMapper.h.

Referenced by buildClusters(), and updateEvent().

edm::EDGetTokenT<SimClusterCollection> GenericSimClusterMapper::_simClusterToken
private

Definition at line 29 of file GenericSimClusterMapper.h.

Referenced by GenericSimClusterMapper(), and updateEvent().