CMS 3D CMS Logo

InterestingDetIdCollectionProducer.cc
Go to the documentation of this file.
2 
6 
9 
12 
16 
20 
22  recHitsToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
24  consumes<reco::BasicClusterCollection>(iConfig.getParameter<edm::InputTag>("basicClustersLabel"));
25 
26  interestingDetIdCollection_ = iConfig.getParameter<std::string>("interestingDetIdCollection");
27 
28  minimalEtaSize_ = iConfig.getParameter<int>("etaSize");
29  minimalPhiSize_ = iConfig.getParameter<int>("phiSize");
30  if (minimalPhiSize_ % 2 == 0 || minimalEtaSize_ % 2 == 0)
31  edm::LogError("InterestingDetIdCollectionProducerError") << "Size of eta/phi should be odd numbers";
32 
33  //register your products
34  produces<DetIdCollection>(interestingDetIdCollection_);
35 
36  severityLevel_ = iConfig.getParameter<int>("severityLevel");
37  keepNextToDead_ = iConfig.getParameter<bool>("keepNextToDead");
38  keepNextToBoundary_ = iConfig.getParameter<bool>("keepNextToBoundary");
39 }
40 
42  edm::ESHandle<CaloTopology> theCaloTopology;
43  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
44  caloTopology_ = &(*theCaloTopology);
45 
47  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
48  severity_ = sevLv.product();
49 }
50 
51 // ------------ method called to produce the data ------------
53  using namespace edm;
54  using namespace std;
55 
56  // take BasicClusters
58  iEvent.getByToken(basicClustersToken_, pClusters);
59 
60  // take EcalRecHits
61  Handle<EcalRecHitCollection> recHitsHandle;
62  iEvent.getByToken(recHitsToken_, recHitsHandle);
63 
64  //Create empty output collections
65  std::vector<DetId> indexToStore;
66  indexToStore.reserve(1000);
67 
68  reco::BasicClusterCollection::const_iterator clusIt;
69 
70  std::vector<DetId> xtalsToStore;
71  xtalsToStore.reserve(50);
72  for (clusIt = pClusters->begin(); clusIt != pClusters->end(); clusIt++) {
73  const std::vector<std::pair<DetId, float> >& clusterDetIds = clusIt->hitsAndFractions();
74  for (const auto& detidpair : clusterDetIds) {
75  indexToStore.push_back(detidpair.first);
76  }
77 
78  //below checks and additional code are only relevant for EB/EE, not for ES
79  if (clusterDetIds.front().first.subdetId() == EcalBarrel || clusterDetIds.front().first.subdetId() == EcalEndcap) {
80  std::vector<std::pair<DetId, float> >::const_iterator posCurrent;
81 
82  float eMax = 0.;
83  DetId eMaxId(0);
84 
85  EcalRecHit testEcalRecHit;
86 
87  for (posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++) {
88  EcalRecHitCollection::const_iterator itt = recHitsHandle->find((*posCurrent).first);
89  if ((!((*posCurrent).first.null())) && (itt != recHitsHandle->end()) && ((*itt).energy() > eMax)) {
90  eMax = (*itt).energy();
91  eMaxId = (*itt).id();
92  }
93  }
94 
95  if (eMaxId.null())
96  continue;
97 
99 
100  xtalsToStore = topology->getWindow(eMaxId, minimalEtaSize_, minimalPhiSize_);
101 
102  for (const auto& detid : xtalsToStore) {
103  indexToStore.push_back(detid);
104  }
105  }
106  }
107 
109  for (EcalRecHitCollection::const_iterator it = recHitsHandle->begin(); it != recHitsHandle->end(); ++it) {
110  // also add recHits of dead TT if the corresponding TP is saturated
111  if (it->checkFlag(EcalRecHit::kTPSaturated)) {
112  indexToStore.push_back(it->id());
113  }
114  // add hits for severities above a threshold
115  if (severityLevel_ >= 0 && severity_->severityLevel(*it) >= severityLevel_) {
116  indexToStore.push_back(it->id());
117  }
118  if (keepNextToDead_) {
119  // also keep channels next to dead ones
120  if (EcalTools::isNextToDead(it->id(), iSetup)) {
121  indexToStore.push_back(it->id());
122  }
123  }
124 
125  if (keepNextToBoundary_) {
126  // keep channels around EB/EE boundary
127  if (it->id().subdetId() == EcalBarrel) {
128  EBDetId ebid(it->id());
129  if (abs(ebid.ieta()) == 85)
130  indexToStore.push_back(it->id());
131  } else {
132  if (EEDetId::isNextToRingBoundary(it->id()))
133  indexToStore.push_back(it->id());
134  }
135  }
136  }
137  }
138 
139  //unify the vector
140  std::sort(indexToStore.begin(), indexToStore.end());
141  std::unique(indexToStore.begin(), indexToStore.end());
142 
143  iEvent.put(std::make_unique<DetIdCollection>(indexToStore), interestingDetIdCollection_);
144 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
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
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
ESHandle.h
InterestingDetIdCollectionProducer::caloTopology_
const CaloTopology * caloTopology_
Definition: InterestingDetIdCollectionProducer.h:60
EcalSeverityLevelAlgoRcd.h
edm::Run
Definition: Run.h:45
BasicCluster.h
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
CaloTopology::getWindow
std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Get the neighbors of the given cell in a window of given size.
Definition: CaloTopology.cc:64
EBDetId.h
EEDetId.h
InterestingDetIdCollectionProducer::beginRun
void beginRun(edm::Run const &, const edm::EventSetup &) final
Definition: InterestingDetIdCollectionProducer.cc:41
DetId::null
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
InterestingDetIdCollectionProducer::severityLevel_
int severityLevel_
Definition: InterestingDetIdCollectionProducer.h:62
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
InterestingDetIdCollectionProducer::recHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
Definition: InterestingDetIdCollectionProducer.h:55
edm::Handle
Definition: AssociativeIterator.h:50
InterestingDetIdCollectionProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
producer
Definition: InterestingDetIdCollectionProducer.cc:52
EcalBarrel
Definition: EcalSubdetector.h:10
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ecaldqm::topology
const CaloTopology * topology(nullptr)
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
edm::ESHandle< CaloTopology >
EcalSeverityLevelAlgoRcd
Definition: EcalSeverityLevelAlgoRcd.h:12
EcalSeverityLevelAlgo.h
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
EEDetId::isNextToRingBoundary
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:284
cosmicPhotonAnalyzer_cfi.eMax
eMax
Definition: cosmicPhotonAnalyzer_cfi.py:10
InterestingDetIdCollectionProducer::keepNextToBoundary_
bool keepNextToBoundary_
Definition: InterestingDetIdCollectionProducer.h:65
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
CaloTopology::getSubdetectorTopology
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
CaloTopologyRecord.h
InterestingDetIdCollectionProducer::interestingDetIdCollection_
std::string interestingDetIdCollection_
Definition: InterestingDetIdCollectionProducer.h:57
iEvent
int iEvent
Definition: GenABIO.cc:224
InterestingDetIdCollectionProducer::basicClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_
Definition: InterestingDetIdCollectionProducer.h:56
edm::EventSetup
Definition: EventSetup.h:57
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
get
#define get
EcalTools.h
CaloTopology.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CaloSubdetectorTopology.h
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
tier0.unique
def unique(seq, keepstr=True)
Definition: tier0.py:24
InterestingDetIdCollectionProducer::InterestingDetIdCollectionProducer
InterestingDetIdCollectionProducer(const edm::ParameterSet &)
ctor
Definition: InterestingDetIdCollectionProducer.cc:21
InterestingDetIdCollectionProducer::minimalPhiSize_
int minimalPhiSize_
Definition: InterestingDetIdCollectionProducer.h:59
EventSetup.h
InterestingDetIdCollectionProducer::minimalEtaSize_
int minimalEtaSize_
Definition: InterestingDetIdCollectionProducer.h:58
EcalTools::isNextToDead
static bool isNextToDead(const DetId &id, const edm::EventSetup &es)
true if the channel is near a dead one (in the 3x3)
Definition: EcalTools.cc:56
InterestingDetIdCollectionProducer.h
InterestingDetIdCollectionProducer::keepNextToDead_
bool keepNextToDead_
Definition: InterestingDetIdCollectionProducer.h:64
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
DetIdCollection.h
InterestingDetIdCollectionProducer::severity_
const EcalSeverityLevelAlgo * severity_
Definition: InterestingDetIdCollectionProducer.h:63