CMS 3D CMS Logo

InterestingDetIdFromSuperClusterProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: InterestingDetIdFromSuperClusterProducer
4 // Class: InterestingDetIdFromSuperClusterProducer
5 //
46 
47 #include <memory>
48 
50 public:
53  void beginRun(edm::Run const&, const edm::EventSetup&) final;
55  void produce(edm::Event&, const edm::EventSetup&) override;
56 
57 private:
58  // ----------member data ---------------------------
68 
73 };
74 
77 
79  recHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
81  consumes<reco::SuperClusterCollection>(iConfig.getParameter<edm::InputTag>("superClustersLabel"));
82  caloTopologyToken_ = esConsumes<CaloTopology, CaloTopologyRecord, edm::Transition::BeginRun>();
83  severityLevelToken_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd, edm::Transition::BeginRun>();
84  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
85 
86  minimalEtaSize_ = iConfig.getParameter<int>("etaSize");
87  minimalPhiSize_ = iConfig.getParameter<int>("phiSize");
88  if (minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
89  edm::LogError("InterestingDetIdFromSuperClusterProducerError") << "Size of eta/phi should be odd numbers";
90 
91  //register your products
92  produces<DetIdCollection>(interestingDetIdCollection_);
93 
94  severityLevel_ = iConfig.getParameter<int>("severityLevel");
95  keepNextToDead_ = iConfig.getParameter<bool>("keepNextToDead");
96  keepNextToBoundary_ = iConfig.getParameter<bool>("keepNextToBoundary");
97  if (keepNextToDead_) {
98  nextToDeadToken_ = esConsumes<EcalNextToDeadChannel, EcalNextToDeadChannelRcd>();
99  }
100 }
101 
103  edm::ESHandle<CaloTopology> theCaloTopology = iSetup.getHandle(caloTopologyToken_);
104  caloTopology_ = &(*theCaloTopology);
105 
107  severity_ = sevLv.product();
108 }
109 
110 // ------------ method called to produce the data ------------
112  using namespace edm;
113  using namespace std;
114 
115  // take BasicClusters
117  iEvent.getByToken(superClustersToken_, pClusters);
118 
119  // take EcalRecHits
120  Handle<EcalRecHitCollection> recHitsHandle;
121  iEvent.getByToken(recHitsToken_, recHitsHandle);
122 
123  //Create empty output collections
124  std::vector<DetId> indexToStore;
125  indexToStore.reserve(1000);
126 
127  reco::SuperClusterCollection::const_iterator sclusIt;
128 
129  std::vector<DetId> xtalsToStore;
130  xtalsToStore.reserve(50);
131 
132  //loop over superclusters
133  for (sclusIt = pClusters->begin(); sclusIt != pClusters->end(); sclusIt++) {
134  //loop over subclusters
135  for (reco::CaloCluster_iterator clusIt = sclusIt->clustersBegin(); clusIt != sclusIt->clustersEnd(); ++clusIt) {
136  //PG barrel
137 
138  float eMax = 0.;
139  DetId eMaxId(0);
140 
141  std::vector<std::pair<DetId, float> > clusterDetIds = (*clusIt)->hitsAndFractions();
142  std::vector<std::pair<DetId, float> >::iterator posCurrent;
143 
144  EcalRecHit testEcalRecHit;
145 
146  for (posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++) {
147  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
148  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax)) {
149  eMax = (*itt).energy();
150  eMaxId = (*itt).id();
151  }
152  }
153 
154  if (eMaxId.null())
155  continue;
156 
157  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(), eMaxId.subdetId());
158 
159  xtalsToStore = topology->getWindow(eMaxId, minimalEtaSize_, minimalPhiSize_);
160  std::vector<std::pair<DetId, float> > xtalsInClus = (*clusIt)->hitsAndFractions();
161 
162  for (unsigned int ii = 0; ii < xtalsInClus.size(); ii++) {
163  xtalsToStore.push_back(xtalsInClus[ii].first);
164  }
165 
166  indexToStore.insert(indexToStore.end(), xtalsToStore.begin(), xtalsToStore.end());
167  }
168  }
169 
170  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
171  // also add recHits of dead TT if the corresponding TP is saturated
172  if (it->checkFlag(EcalRecHit::kTPSaturated)) {
173  indexToStore.push_back(it->id());
174  }
175  // add hits for severities above a threshold
176  if (severityLevel_ >= 0 && severity_->severityLevel(*it) >= severityLevel_) {
177  indexToStore.push_back(it->id());
178  }
179  if (keepNextToDead_) {
181  // also keep channels next to dead ones
182  if (EcalTools::isNextToDead(it->id(), *dch)) {
183  indexToStore.push_back(it->id());
184  }
185  }
186 
187  if (keepNextToBoundary_) {
188  // keep channels around EB/EE boundary
189  if (it->id().subdetId() == EcalBarrel) {
190  EBDetId ebid(it->id());
191  if (abs(ebid.ieta()) == 85)
192  indexToStore.push_back(it->id());
193  } else {
194  if (EEDetId::isNextToRingBoundary(it->id()))
195  indexToStore.push_back(it->id());
196  }
197  }
198  }
199 
200  //unify the vector
201  std::sort(indexToStore.begin(), indexToStore.end());
202  std::unique(indexToStore.begin(), indexToStore.end());
203 
204  auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
205 
206  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
207 }
InterestingDetIdFromSuperClusterProducer::keepNextToDead_
bool keepNextToDead_
Definition: InterestingDetIdFromSuperClusterProducer.cc:71
InterestingDetIdFromSuperClusterProducer::caloTopology_
const CaloTopology * caloTopology_
Definition: InterestingDetIdFromSuperClusterProducer.cc:67
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
InterestingDetIdFromSuperClusterProducer::nextToDeadToken_
edm::ESGetToken< EcalNextToDeadChannel, EcalNextToDeadChannelRcd > nextToDeadToken_
Definition: InterestingDetIdFromSuperClusterProducer.cc:63
InterestingDetIdFromSuperClusterProducer
Definition: InterestingDetIdFromSuperClusterProducer.cc:49
EcalRecHit
Definition: EcalRecHit.h:15
EcalRecHit::kTPSaturated
Definition: EcalRecHit.h:33
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
InterestingDetIdFromSuperClusterProducer::superClustersToken_
edm::EDGetTokenT< reco::SuperClusterCollection > superClustersToken_
Definition: InterestingDetIdFromSuperClusterProducer.cc:60
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
ESHandle.h
EcalSeverityLevelAlgoRcd.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
InterestingDetIdFromSuperClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
producer
Definition: InterestingDetIdFromSuperClusterProducer.cc:111
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
EBDetId.h
EEDetId.h
edm::PtrVectorItr
Definition: PtrVector.h:51
EDProducer.h
InterestingDetIdFromSuperClusterProducer::interestingDetIdCollection_
std::string interestingDetIdCollection_
Definition: InterestingDetIdFromSuperClusterProducer.cc:64
DetId::null
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
InterestingDetIdFromSuperClusterProducer::minimalEtaSize_
int minimalEtaSize_
Definition: InterestingDetIdFromSuperClusterProducer.cc:65
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
CaloTopology
Definition: CaloTopology.h:19
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
InterestingDetIdFromSuperClusterProducer::keepNextToBoundary_
bool keepNextToBoundary_
Definition: InterestingDetIdFromSuperClusterProducer.cc:72
InterestingDetIdFromSuperClusterProducer::InterestingDetIdFromSuperClusterProducer
InterestingDetIdFromSuperClusterProducer(const edm::ParameterSet &)
ctor
Definition: InterestingDetIdFromSuperClusterProducer.cc:78
InterestingDetIdFromSuperClusterProducer::severityLevelToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > severityLevelToken_
Definition: InterestingDetIdFromSuperClusterProducer.cc:62
DetId
Definition: DetId.h:17
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EcalTools::isNextToDead
static bool isNextToDead(const DetId &id, const EcalNextToDeadChannel &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:54
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
edm::ESHandle< CaloTopology >
InterestingDetIdFromSuperClusterProducer::severityLevel_
int severityLevel_
Definition: InterestingDetIdFromSuperClusterProducer.cc:69
EcalSeverityLevelAlgo.h
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
InterestingDetIdFromSuperClusterProducer::caloTopologyToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
Definition: InterestingDetIdFromSuperClusterProducer.cc:61
EEDetId::isNextToRingBoundary
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:284
cosmicPhotonAnalyzer_cfi.eMax
eMax
Definition: cosmicPhotonAnalyzer_cfi.py:10
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
CaloTopology::getSubdetectorTopology
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
EcalNextToDeadChannelRcd.h
InterestingDetIdFromSuperClusterProducer::beginRun
void beginRun(edm::Run const &, const edm::EventSetup &) final
Definition: InterestingDetIdFromSuperClusterProducer.cc:102
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
EcalTools.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< CaloTopology, CaloTopologyRecord >
InterestingDetIdFromSuperClusterProducer::severity_
const EcalSeverityLevelAlgo * severity_
Definition: InterestingDetIdFromSuperClusterProducer.cc:70
InputTag.h
CaloTopology.h
CaloSubdetectorTopology::getWindow
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Definition: CaloSubdetectorTopology.cc:4
CaloSubdetectorTopology.h
CaloTopologyRecord.h
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
SuperClusterFwd.h
InterestingDetIdFromSuperClusterProducer::recHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
Definition: InterestingDetIdFromSuperClusterProducer.cc:59
SuperCluster.h
InterestingDetIdFromSuperClusterProducer::minimalPhiSize_
int minimalPhiSize_
Definition: InterestingDetIdFromSuperClusterProducer.cc:66
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
cuy.ii
ii
Definition: cuy.py:589
edm::InputTag
Definition: InputTag.h:15
DetIdCollection.h