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,DetId::Detector det,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( det != detid.det() or (subdet != 0 and subdet != detid.subdetId() ) ) {
58  throw cms::Exception("IncorrectHGCSubdetector")
59  << "det expected: " << det
60  << " det gotten: " << detid.det() << " ; "
61  << "subdet expected: " << subdet
62  << " subdet gotten: " << detid.subdetId() << std::endl;
63  }
64 
65  double energy = hgrh.energy();
66  double time = hgrh.time();
67 
68  auto thisCell = geom->getSubdetectorGeometry(det,subdet)->getGeometry(detid);
69 
70  // find rechit geometry
71  if(!thisCell) {
72  LogDebug("PFHGCalRecHitCreator")
73  <<"warning detid "<<detid.rawId()
74  <<" not found in geometry"<<std::endl;
75  ++skipped_rechits;
76  continue;
77  }
78 
79  reco::PFRecHit rh(thisCell, detid.rawId(),Layer,
80  energy);
81 
82  bool rcleaned = false;
83  bool keep=true;
84 
85  //Apply Q tests
86  for (unsigned int i=0;i<qualityTests_.size();++i) {
87  if (!qualityTests_.at(i)->test(rh,hgrh,rcleaned)) {
88  keep = false;
89  }
90  }
91 
92  if(keep) {
93  rh.setTime(time);
94  out->push_back(rh);
95  }
96  else if (rcleaned)
97  cleaned->push_back(rh);
98  }
99  edm::LogInfo("HGCalRecHitCreator")
100  << "Skipped " << skipped_rechits
101  << " out of " << rechits.size() << " rechits!" << std::endl;
102  edm::LogInfo("HGCalRecHitCreator")
103  << "Created " << out->size() << " PFRecHits!" << std::endl;
104  }
105 
106 
107 
108  protected:
111  private:
113 };
114 
119 
123 
127 
128 
129 #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:49
hgcal::RecHitTools recHitTools_
PFHGCalRecHitCreator< HGCScintillatorDetId, PFLayer::HGCAL, DetId::HGCalHSc, ForwardEmpty > PFHGCalHScRecHitCreator
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, DetId::Forward, HGCEE > PFHGCEERecHitCreator
PFHGCalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
void getEventSetup(const edm::EventSetup &)
Definition: RecHitTools.cc:73
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
const int keep
int iEvent
Definition: GenABIO.cc:224
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:32
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
PFHGCalRecHitCreator< HGCSiliconDetId,PFLayer::HGCAL, DetId::HGCalHSi, ForwardEmpty > PFHGCalHSiRecHitCreator
PFHGCalRecHitCreator< HGCSiliconDetId,PFLayer::HGCAL, DetId::HGCalEE,ForwardEmpty > PFHGCalEERecHitCreator
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.
PFHGCalRecHitCreator< HcalDetId,PFLayer::HGCAL, DetId::Hcal, HcalEndcap > PFHGCHEBRecHitCreator
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, DetId::Forward, HGCHEF > PFHGCHEFRecHitCreator
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< HGCRecHitCollection > recHitToken_