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, iC) {
33  auto srF = iConfig.getParameter<edm::InputTag>("srFlags");
34  if (not srF.label().empty())
36  triggerTowerMap_ = nullptr;
37  }
38 
39  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>& out,
40  std::unique_ptr<reco::PFRecHitCollection>& cleaned,
41  const edm::Event& iEvent,
42  const edm::EventSetup& iSetup) override {
43  beginEvent(iEvent, iSetup);
44 
46 
48  iSetup.get<CaloGeometryRecord>().get(geoHandle);
49 
50  bool useSrF = false;
51  if (not srFlagToken_.isUninitialized()) {
53  useSrF = true;
54  }
55 
56  // get the ecal geometry
58 
59  const EcalBarrelGeometry* ecalGeo = dynamic_cast<const EcalBarrelGeometry*>(gTmp);
60 
61  iEvent.getByToken(recHitToken_, recHitHandle);
62  for (const auto& erh : *recHitHandle) {
63  const DetId& detid = erh.detid();
64  auto energy = erh.energy();
65  auto time = erh.time();
66  bool hi = (useSrF ? isHighInterest(detid) : true);
67 
68  const auto thisCell = ecalGeo->getGeometry(detid);
69 
70  // find rechit geometry
71  if (!thisCell) {
72  throw cms::Exception("PFEcalBarrelRecHitCreator") << "detid " << detid.rawId() << "not found in geometry";
73  }
74 
75  out->emplace_back(thisCell, detid.rawId(), PFLayer::ECAL_BARREL, energy);
76 
77  auto& rh = out->back();
78 
79  bool rcleaned = false;
80  bool keep = true;
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 (keep) {
90  rh.setTime(time);
91  rh.setDepth(1);
92  } else {
93  if (rcleaned)
94  cleaned->push_back(std::move(out->back()));
95  out->pop_back();
96  }
97  }
98  }
99 
100  void init(const edm::EventSetup& es) override {
102  es.get<IdealGeometryRecord>().get(hTriggerTowerMap);
103  triggerTowerMap_ = hTriggerTowerMap.product();
104  }
105 
106 protected:
107  bool isHighInterest(const EBDetId& detid) {
108  bool result = false;
109  auto srf = srFlagHandle_->find(readOutUnitOf(detid));
110  if (srf == srFlagHandle_->end())
111  return false;
112  else
113  result = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
114  return result;
115  }
116 
117  EcalTrigTowerDetId readOutUnitOf(const EBDetId& detid) const { return triggerTowerMap_->towerOf(detid); }
118 
121 
122  // ECAL trigger tower mapping
124  // selective readout flags collection
126 };
127 
128 #endif
edm::EDGetTokenT< EBSrFlagCollection > srFlagToken_
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:34
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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
PFEcalBarrelRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
const int keep
int iEvent
Definition: GenABIO.cc:224
static const int SRF_FULL
Definition: EcalSrFlag.h:24
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.
EcalTrigTowerDetId readOutUnitOf(const EBDetId &detid) const
const EcalTrigTowerConstituentsMap * triggerTowerMap_
T get() const
Definition: EventSetup.h:73
bool isHighInterest(const EBDetId &detid)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511