CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
InterestingDetIdCollectionProducer Class Reference

#include <InterestingDetIdCollectionProducer.h>

Inheritance diagram for InterestingDetIdCollectionProducer:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &, const edm::EventSetup &) final
 
 InterestingDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< reco::BasicClusterCollectionbasicClustersToken_
 
const CaloTopologycaloTopology_
 
std::string interestingDetIdCollection_
 
bool keepNextToBoundary_
 
bool keepNextToDead_
 
int minimalEtaSize_
 
int minimalPhiSize_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
const EcalSeverityLevelAlgoseverity_
 
int severityLevel_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Original author: Paolo Meridiani PH/CMG

Make a collection of detids to be kept tipically in a AOD rechit collection

The following classes of "interesting id" are considered

1.in a region around  the seed of the cluster collection specified
  by paramter basicClusters. The size of the region is specified by
  minimalEtaSize_, minimalPhiSize_

2. if the severity of the hit is >= severityLevel_
   If severityLevel=0 this class is ignored

3. Channels next to dead ones,  keepNextToDead_ is true
4. Channels next to the EB/EE transition if keepNextToBoundary_ is true

Definition at line 45 of file InterestingDetIdCollectionProducer.h.

Constructor & Destructor Documentation

InterestingDetIdCollectionProducer::InterestingDetIdCollectionProducer ( const edm::ParameterSet iConfig)
explicit

ctor

Definition at line 21 of file InterestingDetIdCollectionProducer.cc.

References basicClustersToken_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, keepNextToBoundary_, keepNextToDead_, minimalEtaSize_, minimalPhiSize_, recHitsToken_, severityLevel_, and AlCaHLTBitMon_QueryRunRegistry::string.

21  {
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 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_

Member Function Documentation

void InterestingDetIdCollectionProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup iSetup 
)
final

Definition at line 41 of file InterestingDetIdCollectionProducer.cc.

References caloTopology_, edm::EventSetup::get(), edm::ESHandle< T >::product(), and severity_.

41  {
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 }
T get() const
Definition: EventSetup.h:73
T const * product() const
Definition: ESHandle.h:86
void InterestingDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

producer

Definition at line 52 of file InterestingDetIdCollectionProducer.cc.

References funct::abs(), basicClustersToken_, edm::SortedCollection< T, SORT >::begin(), caloTopology_, DetId::det(), EcalBarrel, EcalEndcap, cosmicPhotonAnalyzer_cfi::eMax, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), edm::Event::getByToken(), CaloTopology::getSubdetectorTopology(), CaloSubdetectorTopology::getWindow(), interestingDetIdCollection_, EcalTools::isNextToDead(), EEDetId::isNextToRingBoundary(), keepNextToBoundary_, keepNextToDead_, EcalRecHit::kTPSaturated, minimalEtaSize_, minimalPhiSize_, DetId::null(), edm::Event::put(), recHitsToken_, severity_, EcalSeverityLevelAlgo::severityLevel(), severityLevel_, DetId::subdetId(), ecaldqm::topology(), and tier0::unique().

52  {
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 
98  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(eMaxId.det(), eMaxId.subdetId());
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
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
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< EcalRecHit >::const_iterator const_iterator
def unique(seq, keepstr=True)
Definition: tier0.py:24
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:284
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
const_iterator end() const
Definition: DetId.h:17
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
iterator find(key_type k)
HLT enums.
const_iterator begin() const
edm::EDGetTokenT< reco::BasicClusterCollection > basicClustersToken_

Member Data Documentation

edm::EDGetTokenT<reco::BasicClusterCollection> InterestingDetIdCollectionProducer::basicClustersToken_
private
const CaloTopology* InterestingDetIdCollectionProducer::caloTopology_
private

Definition at line 60 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().

std::string InterestingDetIdCollectionProducer::interestingDetIdCollection_
private
bool InterestingDetIdCollectionProducer::keepNextToBoundary_
private
bool InterestingDetIdCollectionProducer::keepNextToDead_
private
int InterestingDetIdCollectionProducer::minimalEtaSize_
private
int InterestingDetIdCollectionProducer::minimalPhiSize_
private
edm::EDGetTokenT<EcalRecHitCollection> InterestingDetIdCollectionProducer::recHitsToken_
private
const EcalSeverityLevelAlgo* InterestingDetIdCollectionProducer::severity_
private

Definition at line 63 of file InterestingDetIdCollectionProducer.h.

Referenced by beginRun(), and produce().

int InterestingDetIdCollectionProducer::severityLevel_
private