CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFHGCalRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFHGCalRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFHGCalRecHitCreator_h
3 
5 
9 
15 
22 
24 
25 template <typename DET, PFLayer::Layer Layer, DetId::Detector det, unsigned subdet>
27 public:
29  : PFRecHitCreatorBase(iConfig, cc),
30  recHitToken_(cc.consumes<HGCRecHitCollection>(iConfig.getParameter<edm::InputTag>("src"))),
31  geometryInstance_(iConfig.getParameter<std::string>("geometryInstance")),
32  geomToken_(cc.esConsumes()) {}
33 
34  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>& out,
35  std::unique_ptr<reco::PFRecHitCollection>& cleaned,
36  const edm::Event& iEvent,
37  const edm::EventSetup& iSetup) override {
38  // Setup RecHitTools to properly compute the position of the HGCAL Cells vie their DetIds
40  recHitTools_.setGeometry(*geoHandle);
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 
50  const CaloGeometry* geom = geoHandle.product();
51 
52  unsigned skipped_rechits = 0;
53  for (const auto& hgrh : rechits) {
54  const DET detid(hgrh.detid());
55 
56  if (det != detid.det() or (subdet != 0 and subdet != detid.subdetId())) {
57  throw cms::Exception("IncorrectHGCSubdetector")
58  << "det expected: " << det << " det gotten: " << detid.det() << " ; "
59  << "subdet expected: " << subdet << " subdet gotten: " << detid.subdetId() << std::endl;
60  }
61 
62  double energy = hgrh.energy();
63  double time = hgrh.time();
64 
65  auto thisCell = geom->getSubdetectorGeometry(det, subdet)->getGeometry(detid);
66 
67  // find rechit geometry
68  if (!thisCell) {
69  LogDebug("PFHGCalRecHitCreator") << "warning detid " << detid.rawId() << " not found in geometry" << std::endl;
70  ++skipped_rechits;
71  continue;
72  }
73 
74  reco::PFRecHit rh(thisCell, detid.rawId(), Layer, energy);
75 
76  bool rcleaned = false;
77  bool keep = true;
78 
79  //Apply Q tests
80  for (unsigned int i = 0; i < qualityTests_.size(); ++i) {
81  if (!qualityTests_.at(i)->test(rh, hgrh, rcleaned)) {
82  keep = false;
83  }
84  }
85 
86  if (keep) {
87  rh.setTime(time);
88  out->push_back(rh);
89  } else if (rcleaned)
90  cleaned->push_back(rh);
91  }
92  edm::LogInfo("HGCalRecHitCreator") << "Skipped " << skipped_rechits << " out of " << rechits.size() << " rechits!"
93  << std::endl;
94  edm::LogInfo("HGCalRecHitCreator") << "Created " << out->size() << " PFRecHits!" << std::endl;
95  }
96 
97 protected:
100 
101 private:
104 };
105 
110 
114 
119 
120 #endif
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
hgcal::RecHitTools recHitTools_
PFHGCalRecHitCreator< HGCSiliconDetId, PFLayer::HGCAL, DetId::HGCalEE, ForwardEmpty > PFHGCalEERecHitCreator
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, DetId::Forward, HGCEE > PFHGCEERecHitCreator
const int keep
int iEvent
Definition: GenABIO.cc:224
PFHGCalRecHitCreator< HGCScintillatorDetId, PFLayer::HGCAL, DetId::HGCalHSc, ForwardEmpty > PFHGCalHScRecHitCreator
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, DetId::Forward, HGCHEF > PFHGCHEFRecHitCreator
Log< level::Info, false > LogInfo
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T const * product() const
Definition: ESHandle.h:86
void setGeometry(CaloGeometry const &)
Definition: RecHitTools.cc:68
PFHGCalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
PFHGCalRecHitCreator< HcalDetId, PFLayer::HGCAL, DetId::Hcal, HcalEndcap > PFHGCHEBRecHitCreator
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
PFHGCalRecHitCreator< HGCSiliconDetId, PFLayer::HGCAL, DetId::HGCalHSi, ForwardEmpty > PFHGCalHSiRecHitCreator
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< HGCRecHitCollection > recHitToken_
#define LogDebug(id)