CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes | Private Attributes
PFHGCalRecHitCreator< DET, Layer, subdet > Class Template Reference

#include <PFHGCalRecHitCreator.h>

Inheritance diagram for PFHGCalRecHitCreator< DET, Layer, subdet >:
PFRecHitCreatorBase

Public Member Functions

void importRecHits (std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 PFHGCalRecHitCreator (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from PFRecHitCreatorBase
virtual void init (const edm::EventSetup &es)
 
 PFRecHitCreatorBase ()
 
 PFRecHitCreatorBase (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
virtual ~PFRecHitCreatorBase ()=default
 

Protected Attributes

std::string geometryInstance_
 
edm::EDGetTokenT< HGCRecHitCollectionrecHitToken_
 
- Protected Attributes inherited from PFRecHitCreatorBase
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
 

Private Attributes

std::vector< const CaloCellGeometryHGCALAdapter * > caloCells_
 
hgcal::RecHitTools recHitTools_
 

Additional Inherited Members

- Protected Member Functions inherited from PFRecHitCreatorBase
void beginEvent (const edm::Event &event, const edm::EventSetup &setup)
 

Detailed Description

template<typename DET, PFLayer::Layer Layer, unsigned subdet>
class PFHGCalRecHitCreator< DET, Layer, subdet >

Definition at line 27 of file PFHGCalRecHitCreator.h.

Constructor & Destructor Documentation

template<typename DET , PFLayer::Layer Layer, unsigned subdet>
PFHGCalRecHitCreator< DET, Layer, subdet >::PFHGCalRecHitCreator ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)
inline

Member Function Documentation

template<typename DET , PFLayer::Layer Layer, unsigned subdet>
void PFHGCalRecHitCreator< DET, Layer, subdet >::importRecHits ( std::unique_ptr< reco::PFRecHitCollection > &  out,
std::unique_ptr< reco::PFRecHitCollection > &  cleaned,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverridevirtual

Implements PFRecHitCreatorBase.

Definition at line 37 of file PFHGCalRecHitCreator.h.

References EnergyCorrector::c, PFHGCalRecHitCreator< DET, Layer, subdet >::caloCells_, Exception, relativeConstraints::geom, edm::EventSetup::get(), edm::Event::getByToken(), hgcal::RecHitTools::getEventSetup(), ecaldqm::getGeometry(), hgcal::RecHitTools::getPosition(), CaloGeometry::getSubdetectorGeometry(), DetId::Hcal, mps_fire::i, keep, LogDebug, edm::ESHandle< T >::product(), PFRecHitCreatorBase::qualityTests_, TrackInfoProducer_cfi::rechits, PFHGCalRecHitCreator< DET, Layer, subdet >::recHitToken_, PFHGCalRecHitCreator< DET, Layer, subdet >::recHitTools_, edm::SortedCollection< T, SORT >::size(), and ntuplemaker::time.

37  {
38 
39  // Setup RecHitTools to properly compute the position of the HGCAL Cells vie their DetIds
41 
42  for (unsigned int i=0;i<qualityTests_.size();++i) {
43  qualityTests_.at(i)->beginEvent(iEvent,iSetup);
44  }
45 
47  iEvent.getByToken(recHitToken_,recHitHandle);
48  const HGCRecHitCollection& rechits = *recHitHandle;
49 
51  iSetup.get<CaloGeometryRecord>().get(geoHandle);
52  const CaloGeometry* geom = geoHandle.product();
53 
54  // Get rid of the content of the previous event
55  for (auto c : caloCells_)
56  delete c;
57 
58  caloCells_.clear();
59  caloCells_.reserve(rechits.size());
60 
61  unsigned skipped_rechits = 0;
62  for (const auto & hgrh : rechits) {
63  const DET detid(hgrh.detid());
64 
65  if( subdet != detid.subdetId() ) {
66  throw cms::Exception("IncorrectHGCSubdetector")
67  << "subdet expected: " << subdet
68  << " subdet gotten: " << detid.subdetId() << std::endl;
69  }
70 
71  double energy = hgrh.energy();
72  double time = hgrh.time();
73 
74  const CaloCellGeometry *thisCell;
75  if( detid.det() == DetId::Hcal ) {
76  thisCell = geom->getSubdetectorGeometry(detid.det(),detid.subdetId())->getGeometry(detid);
77  } else {
78  const auto* hg = static_cast<const HGCalGeometry*>(geom->getSubdetectorGeometry(detid.det(),detid.subdetId()));
79  caloCells_.push_back(new CaloCellGeometryHGCALAdapter(static_cast<const FlatTrd*>(hg->getGeometry(detid)),
80  recHitTools_.getPosition(detid)));
81  thisCell = caloCells_.back();
82  }
83 
84  // find rechit geometry
85  if(!thisCell) {
86  LogDebug("PFHGCalRecHitCreator")
87  <<"warning detid "<<detid.rawId()
88  <<" not found in geometry"<<std::endl;
89  ++skipped_rechits;
90  continue;
91  }
92 
93 
94  reco::PFRecHit rh(thisCell, detid.rawId(),Layer,
95  energy);
96  // rh.setOriginalRecHit(edm::Ref<HGCRecHitCollection>(recHitHandle,i));
97 
98 
99  bool rcleaned = false;
100  bool keep=true;
101 
102  //Apply Q tests
103  for (unsigned int i=0;i<qualityTests_.size();++i) {
104  if (!qualityTests_.at(i)->test(rh,hgrh,rcleaned)) {
105  keep = false;
106  }
107  }
108 
109  if(keep) {
110  rh.setTime(time);
111  out->push_back(rh);
112  }
113  else if (rcleaned)
114  cleaned->push_back(rh);
115  }
116  edm::LogInfo("HGCalRecHitCreator")
117  << "Skipped " << skipped_rechits
118  << " out of " << rechits.size() << " rechits!" << std::endl;
119  edm::LogInfo("HGCalRecHitCreator")
120  << "Created " << out->size() << " PFRecHits!" << std::endl;
121  }
#define LogDebug(id)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
CaloGeometry const * getGeometry()
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:61
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
const int keep
hgcal::RecHitTools recHitTools_
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
edm::EDGetTokenT< HGCRecHitCollection > recHitToken_
const T & get() const
Definition: EventSetup.h:55
GlobalPoint getPosition(const DetId &id) const
Definition: RecHitTools.cc:77
std::vector< const CaloCellGeometryHGCALAdapter * > caloCells_
size_type size() const
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

template<typename DET , PFLayer::Layer Layer, unsigned subdet>
std::vector<const CaloCellGeometryHGCALAdapter*> PFHGCalRecHitCreator< DET, Layer, subdet >::caloCells_
private
template<typename DET , PFLayer::Layer Layer, unsigned subdet>
std::string PFHGCalRecHitCreator< DET, Layer, subdet >::geometryInstance_
protected
template<typename DET , PFLayer::Layer Layer, unsigned subdet>
edm::EDGetTokenT<HGCRecHitCollection> PFHGCalRecHitCreator< DET, Layer, subdet >::recHitToken_
protected
template<typename DET , PFLayer::Layer Layer, unsigned subdet>
hgcal::RecHitTools PFHGCalRecHitCreator< DET, Layer, subdet >::recHitTools_
private