CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFHGCalRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFHGCalRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFHGCalRecHitCreator_h
3 
5 
8 
14 
21 
22 template <typename DET,PFLayer::Layer Layer,ForwardSubdetector subdet>
24 
25  public:
27  PFRecHitCreatorBase(iConfig,iC)
28  {
30  geometryInstance_ = iConfig.getParameter<std::string>("geometryInstance");
31  }
32 
33  void importRecHits(std::auto_ptr<reco::PFRecHitCollection>&out,std::auto_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) {
34 
35  for (unsigned int i=0;i<qualityTests_.size();++i) {
36  qualityTests_.at(i)->beginEvent(iEvent,iSetup);
37  }
38 
40  iEvent.getByToken(recHitToken_,recHitHandle);
41  const HGCRecHitCollection& rechits = *recHitHandle;
42 
44  iSetup.get<IdealGeometryRecord>().get(geometryInstance_,geoHandle);
45  const HGCalGeometry& hgcGeo = *geoHandle;
46 
47  unsigned skipped_rechits = 0;
48  for (unsigned int i=0;i<rechits.size();++i) {
49  const HGCRecHit& hgrh = rechits[i];
50  const DET detid(hgrh.detid());
51 
52  if( subdet != detid.subdet() ) {
53  throw cms::Exception("IncorrectHGCSubdetector")
54  << "subdet expected: " << subdet
55  << " subdet gotten: " << detid.subdet() << std::endl;
56  }
57 
58  double energy = hgrh.energy();
59  double time = hgrh.time();
60 
61  const FlatTrd *thisCell =
62  static_cast<const FlatTrd*>(hgcGeo.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
int i
Definition: DBlmapReader.cc:9
A base class to handle the particular shape of HGCal volumes.
Definition: FlatTrd.h:19
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
const DetId & detid() const
Definition: CaloRecHit.h:20
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
PFHGCalRecHitCreator< HGCEEDetId, PFLayer::HGCAL, HGCEE > PFHGCEERecHitCreator
PFHGCalRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
float time() const
Definition: CaloRecHit.h:19
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
PFHGCalRecHitCreator< HGCHEDetId, PFLayer::HGCAL, HGCHEB > PFHGCHEBRecHitCreator
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::auto_ptr< reco::PFRecHitCollection > &out, std::auto_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup)
const T & get() const
Definition: EventSetup.h:56
size_type size() const
PFHGCalRecHitCreator< HGCHEDetId, PFLayer::HGCAL, HGCHEF > PFHGCHEFRecHitCreator
virtual const CaloCellGeometry * getGeometry(const DetId &id) const override
Get the cell geometry of a given detector id. Should return false if not found.