CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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),
34  geomToken_(cc.esConsumes()),
35  towerToken_(cc.esConsumes<edm::Transition::BeginLuminosityBlock>()) {
36  auto srF = iConfig.getParameter<edm::InputTag>("srFlags");
37  if (not srF.label().empty())
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()) {
54  useSrF = true;
55  }
56 
57  // get the ecal geometry
58  const CaloSubdetectorGeometry* gTmp = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
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  const auto thisCell = ecalGeo->getGeometry(detid);
71 
72  // find rechit geometry
73  if (!thisCell) {
74  throw cms::Exception("PFEcalBarrelRecHitCreator") << "detid " << detid.rawId() << "not found in geometry";
75  }
76 
77  out->emplace_back(thisCell, detid.rawId(), PFLayer::ECAL_BARREL, energy, flags);
78 
79  auto& rh = out->back();
80 
81  bool rcleaned = false;
82  bool keep = true;
83 
84  //Apply Q tests
85  for (const auto& qtest : qualityTests_) {
86  if (!qtest->test(rh, erh, rcleaned, hi)) {
87  keep = false;
88  }
89  }
90 
91  if (keep) {
92  rh.setTime(time);
93  rh.setDepth(1);
94  } else {
95  if (rcleaned)
96  cleaned->push_back(std::move(out->back()));
97  out->pop_back();
98  }
99  }
100  }
101 
102  void init(const edm::EventSetup& es) override { triggerTowerMap_ = &es.getData(towerToken_); }
103 
104 protected:
105  bool isHighInterest(const EBDetId& detid) {
106  bool result = false;
107  auto srf = srFlagHandle_->find(readOutUnitOf(detid));
108  if (srf == srFlagHandle_->end())
109  return false;
110  else
111  result = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
112  return result;
113  }
114 
115  EcalTrigTowerDetId readOutUnitOf(const EBDetId& detid) const { return triggerTowerMap_->towerOf(detid); }
116 
119 
120  // ECAL trigger tower mapping
122  // selective readout flags collection
124 
125 private:
128 };
129 
130 #endif
edm::EDGetTokenT< EBSrFlagCollection > srFlagToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > towerToken_
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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 towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
tuple result
Definition: mps_fire.py:311
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
const int keep
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
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
Definition: DetId.h:17
edm::Handle< EBSrFlagCollection > srFlagHandle_
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.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EcalTrigTowerDetId readOutUnitOf(const EBDetId &detid) const
const EcalTrigTowerConstituentsMap * triggerTowerMap_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
bool isHighInterest(const EBDetId &detid)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283