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 
23 template <typename DET,PFLayer::Layer Layer,unsigned subdet>
25 
26  public:
28  PFRecHitCreatorBase(iConfig,iC)
29  {
31  geometryInstance_ = iConfig.getParameter<std::string>("geometryInstance");
32  }
33 
34  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>&out,std::unique_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) {
35 
36  for (unsigned int i=0;i<qualityTests_.size();++i) {
37  qualityTests_.at(i)->beginEvent(iEvent,iSetup);
38  }
39 
41  iEvent.getByToken(recHitToken_,recHitHandle);
42  const HGCRecHitCollection& rechits = *recHitHandle;
43 
45  iSetup.get<CaloGeometryRecord>().get(geoHandle);
46  const CaloGeometry* geom = geoHandle.product();
47 
48  unsigned skipped_rechits = 0;
49  for (unsigned int i=0;i<rechits.size();++i) {
50  const HGCRecHit& hgrh = rechits[i];
51  const DET detid(hgrh.detid());
52 
53  if( subdet != detid.subdetId() ) {
54  throw cms::Exception("IncorrectHGCSubdetector")
55  << "subdet expected: " << subdet
56  << " subdet gotten: " << detid.subdetId() << std::endl;
57  }
58 
59  double energy = hgrh.energy();
60  double time = hgrh.time();
61 
62  const CaloCellGeometry *thisCell = geom->getSubdetectorGeometry(detid.det(),detid.subdetId())->getGeometry(detid);
63 
64  // find rechit geometry
65  if(!thisCell) {
66  LogDebug("PFHGCalRecHitCreator")
67  <<"warning detid "<<detid.rawId()
68  <<" not found in geometry"<<std::endl;
69  ++skipped_rechits;
70  continue;
71  }
72 
73 
74  reco::PFRecHit rh(thisCell, detid.rawId(),Layer,
75  energy);
76 
77  // rh.setOriginalRecHit(edm::Ref<HGCRecHitCollection>(recHitHandle,i));
78 
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 
110 };
111 
114 
118 
119 
120 #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:45
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, HGCHEF > PFHGCHEFRecHitCreator
int i
Definition: DBlmapReader.cc:9
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
PFHGCalRecHitCreator< HcalDetId,PFLayer::HGCAL, HcalEndcap > PFHGCHEBRecHitCreator
const DetId & detid() const
Definition: CaloRecHit.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
PFHGCalRecHitCreator< HGCalDetId, PFLayer::HGCAL, HGCEE > PFHGCEERecHitCreator
PFHGCalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
float time() const
Definition: CaloRecHit.h:19
CaloGeometry const * getGeometry()
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
const int keep
int iEvent
Definition: GenABIO.cc:230
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
float energy() const
Definition: CaloRecHit.h:17
edm::EDGetTokenT< HGCRecHitCollection > recHitToken_
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)
const T & get() const
Definition: EventSetup.h:56
size_type size() const
T const * product() const
Definition: ESHandle.h:86