CMS 3D CMS Logo

PFEcalEndcapRecHitCreator.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFEcalEndcapRecHitCreator_h
2 #define RecoParticleFlow_PFClusterProducer_PFEcalEndcapRecHitCreator_h
3 
9 
13 
19 
29 
31 
32  public:
34  PFRecHitCreatorBase(iConfig,iC)
35  {
38  elecMap_ = nullptr;
39  }
40 
41  void importRecHits(std::unique_ptr<reco::PFRecHitCollection>&out,std::unique_ptr<reco::PFRecHitCollection>& cleaned ,const edm::Event& iEvent,const edm::EventSetup& iSetup) override {
42 
43  beginEvent(iEvent,iSetup);
44 
46 
48  iSetup.get<CaloGeometryRecord>().get(geoHandle);
49 
51 
52  // get the ecal geometry
53  const CaloSubdetectorGeometry *gTmp =
55 
56  const EcalEndcapGeometry *ecalGeo =dynamic_cast< const EcalEndcapGeometry* > (gTmp);
57 
58  iEvent.getByToken(recHitToken_,recHitHandle);
59  for(const auto& erh : *recHitHandle ) {
60  const DetId& detid = erh.detid();
61  auto energy = erh.energy();
62  auto time = erh.time();
63 
64  bool hi = isHighInterest(detid);
65 
66  const CaloCellGeometry * thisCell= ecalGeo->getGeometry(detid);
67 
68  // find rechit geometry
69  if(!thisCell) {
70  throw cms::Exception("PFEcalEndcapRecHitCreator")
71  << "detid "<< detid.rawId() << "not found in geometry";
72  }
73 
74  out->emplace_back(thisCell, detid.rawId(), PFLayer::ECAL_ENDCAP, energy);
75 
76  auto & rh = out->back();
77 
78  bool rcleaned = false;
79  bool keep=true;
80 
81  //Apply Q tests
82  for( const auto& qtest : qualityTests_ ) {
83  if (!qtest->test(rh,erh,rcleaned,hi)) {
84  keep = false;
85  }
86  }
87 
88  if(keep) {
89  rh.setTime(time);
90  rh.setDepth(1);
91  }
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 {
101 
103  es.get< EcalMappingRcd >().get(ecalmapping);
104  elecMap_ = ecalmapping.product();
105 
106  }
107 
108  protected:
109 
110 
111  bool isHighInterest(const EEDetId& detid) {
112  bool result=false;
113  auto srf = srFlagHandle_->find(readOutUnitOf(detid));
114  if(srf==srFlagHandle_->end()) return false;
115  else result = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK) == EcalSrFlag::SRF_FULL);
116  return result;
117  }
118 
119  EcalScDetId readOutUnitOf(const EEDetId& detid) const{
120  const EcalElectronicsId& EcalElecId = elecMap_->getElectronicsId(detid);
121  int iDCC= EcalElecId.dccId();
122  int iDccChan = EcalElecId.towerId();
123  const bool ignoreSingle = true;
124  const std::vector<EcalScDetId> id = elecMap_->getEcalScDetId(iDCC, iDccChan, ignoreSingle);
125  return id.size()>0?id[0]:EcalScDetId();
126  }
127 
128 
131 
133 
134  // Ecal electronics/geometrical mapping
136  // selective readout flags collection
138 
139 };
140 
141 #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:45
std::vector< std::unique_ptr< PFRecHitQTestBase > > qualityTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
edm::EDGetTokenT< EcalRecHitCollection > recHitToken_
int towerId() const
get the tower id
bool isHighInterest(const EEDetId &detid)
void init(const edm::EventSetup &es) override
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
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
const int keep
int iEvent
Definition: GenABIO.cc:230
PFEcalEndcapRecHitCreator(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
static const int SRF_FULL
Definition: EcalSrFlag.h:24
void beginEvent(const edm::Event &event, const edm::EventSetup &setup)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
Definition: DetId.h:18
void importRecHits(std::unique_ptr< reco::PFRecHitCollection > &out, std::unique_ptr< reco::PFRecHitCollection > &cleaned, const edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::Handle< EESrFlagCollection > srFlagHandle_
EcalScDetId readOutUnitOf(const EEDetId &detid) const
const T & get() const
Definition: EventSetup.h:56
edm::EDGetTokenT< EESrFlagCollection > srFlagToken_
const EcalTrigTowerConstituentsMap * eTTmap_
const EcalElectronicsMapping * elecMap_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510