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 
30  public:
32  PFRecHitCreatorBase(iConfig,iC)
33  {
36  triggerTowerMap_ = nullptr;
37  }
38 
39  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>&out,std::unique_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) override {
40 
41  beginEvent(iEvent,iSetup);
42 
44 
46  iSetup.get<CaloGeometryRecord>().get(geoHandle);
47 
49 
50  // get the ecal geometry
51  const CaloSubdetectorGeometry *gTmp =
53 
54  const EcalBarrelGeometry *ecalGeo =dynamic_cast< const EcalBarrelGeometry* > (gTmp);
55 
56  iEvent.getByToken(recHitToken_,recHitHandle);
57  for(const auto& erh : *recHitHandle ) {
58  const DetId& detid = erh.detid();
59  auto energy = erh.energy();
60  auto time = erh.time();
61  bool hi = isHighInterest(detid);
62 
63  const CaloCellGeometry * thisCell= ecalGeo->getGeometry(detid);
64 
65  // find rechit geometry
66  if(!thisCell) {
67  throw cms::Exception("PFEcalBarrelRecHitCreator")
68  << "detid " << detid.rawId() << "not found in geometry";
69  }
70 
71  out->emplace_back(thisCell, detid.rawId(), PFLayer::ECAL_BARREL, energy);
72 
73  auto & rh = out->back();
74 
75  bool rcleaned = false;
76  bool keep=true;
77 
78  //Apply Q tests
79  for( const auto& qtest : qualityTests_ ) {
80  if (!qtest->test(rh,erh,rcleaned,hi)) {
81  keep = false;
82  }
83  }
84 
85  if(keep) {
86  rh.setTime(time);
87  rh.setDepth(1);
88  }
89  else {
90  if (rcleaned)
91  cleaned->push_back(std::move(out->back()));
92  out->pop_back();
93  }
94  }
95  }
96 
97  void init(const edm::EventSetup &es) override {
98 
100  es.get<IdealGeometryRecord>().get(hTriggerTowerMap);
101  triggerTowerMap_ = hTriggerTowerMap.product();
102 
103  }
104 
105 
106  protected:
107 
108  bool isHighInterest(const EBDetId& detid) {
109  bool result=false;
110  auto srf = srFlagHandle_->find(readOutUnitOf(detid));
111  if(srf==srFlagHandle_->end()) return false;
112  else result = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
113  return result;
114  }
115 
117  return triggerTowerMap_->towerOf(detid);
118  }
119 
122 
123  // ECAL trigger tower mapping
125  // selective readout flags collection
127 
128 };
129 
130 #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:45
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
const int keep
int iEvent
Definition: GenABIO.cc:230
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:18
edm::Handle< EBSrFlagCollection > srFlagHandle_
const T & get() const
Definition: EventSetup.h:56
EcalTrigTowerDetId readOutUnitOf(const EBDetId &detid) const
const EcalTrigTowerConstituentsMap * triggerTowerMap_
bool isHighInterest(const EBDetId &detid)
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510