CMS 3D CMS Logo

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,unsigned subdet>
27 
28  public:
30  PFRecHitCreatorBase(iConfig,iC)
31  {
33  geometryInstance_ = iConfig.getParameter<std::string>("geometryInstance");
34  }
35 
36  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>&out,std::unique_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) override {
37 
38  // Setup RecHitTools to properly compute the position of the HGCAL Cells vie their DetIds
40 
41  for (unsigned int i=0;i<qualityTests_.size();++i) {
42  qualityTests_.at(i)->beginEvent(iEvent,iSetup);
43  }
44 
46  iEvent.getByToken(recHitToken_,recHitHandle);
47  const HGCRecHitCollection& rechits = *recHitHandle;
48 
50  iSetup.get<CaloGeometryRecord>().get(geoHandle);
51  const CaloGeometry* geom = geoHandle.product();
52 
53  unsigned skipped_rechits = 0;
54  for (const auto & hgrh : rechits) {
55  const DET detid(hgrh.detid());
56 
57  if( subdet != detid.subdetId() ) {
58  throw cms::Exception("IncorrectHGCSubdetector")
59  << "subdet expected: " << subdet
60  << " subdet gotten: " << detid.subdetId() << std::endl;
61  }
62 
63  double energy = hgrh.energy();
64  double time = hgrh.time();
65 
66  auto thisCell = geom->getSubdetectorGeometry(detid.det(),detid.subdetId())->getGeometry(detid);
67 
68  // find rechit geometry
69  if(!thisCell) {
70  LogDebug("PFHGCalRecHitCreator")
71  <<"warning detid "<<detid.rawId()
72  <<" not found in geometry"<<std::endl;
73  ++skipped_rechits;
74  continue;
75  }
76 
77  reco::PFRecHit rh(thisCell, detid.rawId(),Layer,
78  energy);
79 
80  bool rcleaned = false;
81  bool keep=true;
82 
83  //Apply Q tests
84  for (unsigned int i=0;i<qualityTests_.size();++i) {
85  if (!qualityTests_.at(i)->test(rh,hgrh,rcleaned)) {
86  keep = false;
87  }
88  }
89 
90  if(keep) {
91  rh.setTime(time);
92  out->push_back(rh);
93  }
94  else if (rcleaned)
95  cleaned->push_back(rh);
96  }
97  edm::LogInfo("HGCalRecHitCreator")
98  << "Skipped " << skipped_rechits
99  << " out of " << rechits.size() << " rechits!" << std::endl;
100  edm::LogInfo("HGCalRecHitCreator")
101  << "Created " << out->size() << " PFRecHits!" << std::endl;
102  }
103 
104 
105 
106  protected:
109  private:
111 };
112 
115 
119 
120 
121 #endif
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:44
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, HGCHEF > PFHGCHEFRecHitCreator
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
PFHGCalRecHitCreator< HcalDetId,PFLayer::HGCAL, HcalEndcap > PFHGCHEBRecHitCreator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, HGCEE > PFHGCEERecHitCreator
PFHGCalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
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_
int iEvent
Definition: GenABIO.cc:230
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:32
edm::EDGetTokenT< HGCRecHitCollection > recHitToken_
const T & get() const
Definition: EventSetup.h:58
T const * product() const
Definition: ESHandle.h:86