CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFPSRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFPSRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFPSRecHitCreator_h
3 
8 
12 
18 
25 
26 class PFPSRecHitCreator final : public PFRecHitCreatorBase {
27 public:
29  : PFRecHitCreatorBase(iConfig, cc),
30  recHitToken_(cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("src"))),
31  geomToken_(cc.esConsumes()) {}
32 
33  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>& out,
34  std::unique_ptr<reco::PFRecHitCollection>& cleaned,
35  const edm::Event& iEvent,
36  const edm::EventSetup& iSetup) override {
37  beginEvent(iEvent, iSetup);
38 
41 
42  // get the ecal geometry
43  const CaloSubdetectorGeometry* psGeometry = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
44 
45  iEvent.getByToken(recHitToken_, recHitHandle);
46  for (const auto& erh : *recHitHandle) {
47  ESDetId detid(erh.detid());
48  auto energy = erh.energy();
49 
51 
52  switch (detid.plane()) {
53  case 1:
54  layer = PFLayer::PS1;
55  break;
56  case 2:
57  layer = PFLayer::PS2;
58  break;
59  default:
60  throw cms::Exception("PFRecHitBadInput")
61  << "incorrect preshower plane !! plane number " << detid.plane() << std::endl;
62  }
63 
64  auto thisCell = psGeometry->getGeometry(detid);
65 
66  // find rechit geometry
67  if (!thisCell) {
68  edm::LogError("PFPSRecHitCreator")
69  << "warning detid " << detid.rawId() << " not found in geometry" << std::endl;
70  continue;
71  }
72 
73  out->emplace_back(thisCell, detid.rawId(), layer, energy);
74  auto& rh = out->back();
75  rh.setDepth(detid.plane());
76  rh.setTime(erh.time());
77 
78  bool rcleaned = false;
79  bool keep = true;
80  bool hi = true; // all ES rhs are produced, independently on the ECAL SRP decision
81 
82  //Apply Q tests
83  for (const auto& qtest : qualityTests_) {
84  if (!qtest->test(rh, erh, rcleaned, hi)) {
85  keep = false;
86  }
87  }
88 
89  if (rcleaned)
90  cleaned->push_back(std::move(out->back()));
91  if (!keep)
92  out->pop_back();
93  }
94  }
95 
96 protected:
98 
99 private:
101 };
102 
103 #endif
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Log< level::Error, false > LogError
PFPSRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
constexpr std::array< uint8_t, layerIndexSize > layer
const int keep
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
Layer
layer definition
Definition: PFLayer.h:29
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.
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283