CMS 3D CMS Logo

PFPSRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFPSRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFPSRecHitCreator_h
3 
8 
12 
13 
19 
26 
27 class PFPSRecHitCreator final : public PFRecHitCreatorBase {
28 
29  public:
31  PFRecHitCreatorBase(iConfig,iC)
32  {
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  beginEvent(iEvent,iSetup);
39 
42  iSetup.get<CaloGeometryRecord>().get(geoHandle);
43 
44  // get the ecal geometry
45  const CaloSubdetectorGeometry *psGeometry =
47 
48  iEvent.getByToken(recHitToken_,recHitHandle);
49  for( const auto& erh : *recHitHandle ) {
50  ESDetId detid(erh.detid());
51  auto energy = erh.energy();
52 
54 
55  switch( detid.plane() ) {
56  case 1:
57  layer = PFLayer::PS1;
58  break;
59  case 2:
60  layer = PFLayer::PS2;
61  break;
62  default:
63  throw cms::Exception("PFRecHitBadInput")
64  <<"incorrect preshower plane !! plane number "
65  <<detid.plane()<<std::endl;
66  }
67 
68 
69 
70  const CaloCellGeometry * thisCell= psGeometry->getGeometry(detid);
71 
72  // find rechit geometry
73  if(!thisCell) {
74  edm::LogError("PFPSRecHitCreator")
75  <<"warning detid "<<detid.rawId()
76  <<" not found in geometry"<<std::endl;
77  continue;
78  }
79 
80  out->emplace_back(thisCell, detid.rawId(),layer,energy);
81  auto & rh = out->back();
82  rh.setDepth(detid.plane());
83  rh.setTime(erh.time());
84 
85  bool rcleaned = false;
86  bool keep=true;
87  bool hi = true; // all ES rhs are produced, independently on the ECAL SRP decision
88 
89  //Apply Q tests
90  for( const auto& qtest : qualityTests_ ) {
91  if (!qtest->test(rh,erh,rcleaned,hi)) {
92  keep = false;
93  }
94  }
95 
96  if (rcleaned)
97  cleaned->push_back(std::move(out->back()));
98  if(!keep)
99  out->pop_back();
100  }
101  }
102 
103 
104 
105  protected:
107 
108 
109 };
110 
111 
112 #endif
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
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:460
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
const int keep
int iEvent
Definition: GenABIO.cc:230
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
Layer
layer definition
Definition: PFLayer.h:31
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
PFPSRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
def move(src, dest)
Definition: eostools.py:510