CMS 3D CMS Logo

PFEcalBarrelRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFEcalBarrelRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFEcalBarrelRecHitCreator_h
3 
9 
13 
19 
27 
29 public:
31  : PFRecHitCreatorBase(iConfig, cc),
32  recHitToken_(cc.consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("src"))),
33  triggerTowerMap_(nullptr),
35  towerToken_(cc.esConsumes<edm::Transition::BeginRun>()) {
36  auto srF = iConfig.getParameter<edm::InputTag>("srFlags");
37  if (not srF.label().empty())
38  srFlagToken_ = cc.consumes<EBSrFlagCollection>(srF);
39  }
40 
41  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>& out,
42  std::unique_ptr<reco::PFRecHitCollection>& cleaned,
43  const edm::Event& iEvent,
44  const edm::EventSetup& iSetup) override {
45  beginEvent(iEvent, iSetup);
46 
48 
50 
51  bool useSrF = false;
52  if (not srFlagToken_.isUninitialized()) {
53  iEvent.getByToken(srFlagToken_, srFlagHandle_);
54  useSrF = true;
55  }
56 
57  // get the ecal geometry
59 
60  const EcalBarrelGeometry* ecalGeo = dynamic_cast<const EcalBarrelGeometry*>(gTmp);
61 
62  iEvent.getByToken(recHitToken_, recHitHandle);
63  for (const auto& erh : *recHitHandle) {
64  const DetId& detid = erh.detid();
65  auto energy = erh.energy();
66  auto time = erh.time();
67  auto flags = erh.flagsBits();
68  bool hi = (useSrF ? isHighInterest(detid) : true);
69 
70  {
71  auto thisCell = ecalGeo->getGeometry(detid);
72 
73  // find rechit geometry
74  if (!thisCell) {
75  throw cms::Exception("PFEcalBarrelRecHitCreator") << "detid " << detid.rawId() << "not found in geometry";
76  }
77 
78  out->emplace_back(std::move(thisCell), detid.rawId(), PFLayer::ECAL_BARREL, energy, flags);
79  }
80  auto& rh = out->back();
81 
82  bool rcleaned = false;
83  bool keep = true;
84 
85  //Apply Q tests
86  for (const auto& qtest : qualityTests_) {
87  if (!qtest->test(rh, erh, rcleaned, hi)) {
88  keep = false;
89  }
90  }
91 
92  if (keep) {
93  rh.setTime(time);
94  rh.setDepth(1);
95  } else {
96  if (rcleaned)
97  cleaned->push_back(std::move(out->back()));
98  out->pop_back();
99  }
100  }
101  }
102 
103  void init(const edm::EventSetup& es) override { triggerTowerMap_ = &es.getData(towerToken_); }
104 
105 protected:
106  bool isHighInterest(const EBDetId& detid) {
107  bool result = false;
108  auto srf = srFlagHandle_->find(readOutUnitOf(detid));
109  if (srf == srFlagHandle_->end())
110  return false;
111  else
112  result = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
113  return result;
114  }
115 
117 
120 
121  // ECAL trigger tower mapping
123  // selective readout flags collection
125 
126 private:
129 };
130 
131 #endif
edm::EDGetTokenT< EBSrFlagCollection > srFlagToken_
virtual CellMayOwnPtr getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > towerToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
PFEcalBarrelRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
EcalTrigTowerDetId readOutUnitOf(const EBDetId &detid) const
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
int iEvent
Definition: GenABIO.cc:224
Definition: EPCuts.h:4
static const int SRF_FULL
Definition: EcalSrFlag.h:24
Transition
Definition: Transition.h:12
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
void init(const edm::EventSetup &es) override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
Definition: DetId.h:17
edm::Handle< EBSrFlagCollection > srFlagHandle_
HLT enums.
const EcalTrigTowerConstituentsMap * triggerTowerMap_
bool isHighInterest(const EBDetId &detid)
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
def move(src, dest)
Definition: eostools.py:511