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
46 
47  iEvent.getByToken(recHitToken_,recHitHandle);
48  for( const auto& erh : *recHitHandle ) {
49  ESDetId detid(erh.detid());
50  auto energy = erh.energy();
51 
53 
54  switch( detid.plane() ) {
55  case 1:
56  layer = PFLayer::PS1;
57  break;
58  case 2:
59  layer = PFLayer::PS2;
60  break;
61  default:
62  throw cms::Exception("PFRecHitBadInput")
63  <<"incorrect preshower plane !! plane number "
64  <<detid.plane()<<std::endl;
65  }
66 
67 
68 
69  auto thisCell= psGeometry->getGeometry(detid);
70 
71  // find rechit geometry
72  if(!thisCell) {
73  edm::LogError("PFPSRecHitCreator")
74  <<"warning detid "<<detid.rawId()
75  <<" not found in geometry"<<std::endl;
76  continue;
77  }
78 
79  out->emplace_back(thisCell, detid.rawId(),layer,energy);
80  auto & rh = out->back();
81  rh.setDepth(detid.plane());
82  rh.setTime(erh.time());
83 
84  bool rcleaned = false;
85  bool keep=true;
86  bool hi = true; // all ES rhs are produced, independently on the ECAL SRP decision
87 
88  //Apply Q tests
89  for( const auto& qtest : qualityTests_ ) {
90  if (!qtest->test(rh,erh,rcleaned,hi)) {
91  keep = false;
92  }
93  }
94 
95  if (rcleaned)
96  cleaned->push_back(std::move(out->back()));
97  if(!keep)
98  out->pop_back();
99  }
100  }
101 
102 
103 
104  protected:
106 
107 
108 };
109 
110 
111 #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:49
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:579
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
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_
PFPSRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
T get() const
Definition: EventSetup.h:63
def move(src, dest)
Definition: eostools.py:510