CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
GamIsoDetIdCollectionProducer Class Reference

#include <GamIsoDetIdCollectionProducer.h>

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

Public Member Functions

void beginJob ()
 
 GamIsoDetIdCollectionProducer (const edm::ParameterSet &)
 ctor More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 producer More...
 
 ~GamIsoDetIdCollectionProducer () override
 
- 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::InputTag emObjectLabel_
 
edm::EDGetTokenT< reco::PhotonCollectionemObjectToken_
 
double energyCut_
 
double etCandCut_
 
double etCut_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
double innerRadius_
 
std::string interestingDetIdCollection_
 
double outerRadius_
 
edm::InputTag recHitsLabel_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitsToken_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 

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: Matthew LeBourgeois PH/CMG Modified from : RecoEcal/EgammaClusterProducers/{src,interface}/InterestingDetIdCollectionProducer.{h,cc} by Paolo Meridiani PH/CMG

Implementation: <Notes on="" implementation>="">

Definition at line 37 of file GamIsoDetIdCollectionProducer.h.

Constructor & Destructor Documentation

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

ctor

Definition at line 31 of file GamIsoDetIdCollectionProducer.cc.

References flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), interestingDetIdCollection_, severitiesexclEB_, and severitiesexclEE_.

32  : recHitsToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"))),
33  emObjectToken_(consumes<reco::PhotonCollection>(iConfig.getParameter<edm::InputTag>("emObjectLabel"))),
34  //the labels are still used to decide if its endcap or barrel...
35  recHitsLabel_(iConfig.getParameter<edm::InputTag>("recHitsLabel")),
36  emObjectLabel_(iConfig.getParameter<edm::InputTag>("emObjectLabel")),
37  energyCut_(iConfig.getParameter<double>("energyCut")),
38  etCut_(iConfig.getParameter<double>("etCut")),
39  etCandCut_(iConfig.getParameter<double>("etCandCut")),
40  outerRadius_(iConfig.getParameter<double>("outerRadius")),
41  innerRadius_(iConfig.getParameter<double>("innerRadius")),
42  interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")) {
43  const std::vector<std::string> flagnamesEB =
44  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
45 
46  const std::vector<std::string> flagnamesEE =
47  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
48 
49  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
50 
51  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
52 
53  const std::vector<std::string> severitynamesEB =
54  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
55 
56  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
57 
58  const std::vector<std::string> severitynamesEE =
59  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
60 
61  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
62 
63  //register your products
64  produces<DetIdCollection>(interestingDetIdCollection_);
65 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
edm::EDGetTokenT< reco::PhotonCollection > emObjectToken_
GamIsoDetIdCollectionProducer::~GamIsoDetIdCollectionProducer ( )
override

Definition at line 67 of file GamIsoDetIdCollectionProducer.cc.

67 {}

Member Function Documentation

void GamIsoDetIdCollectionProducer::beginJob ( void  )

Definition at line 69 of file GamIsoDetIdCollectionProducer.cc.

69 {}
void GamIsoDetIdCollectionProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

producer

Definition at line 72 of file GamIsoDetIdCollectionProducer.cc.

References EcalRecHit::checkFlag(), EcalRecHit::checkFlags(), EcalRecHit::detid(), DetId::Ecal, EcalBarrel, EcalEndcap, emObjectToken_, EcalRecHit::energy(), energyCut_, EgHLTOffHistBins_cfi::et, PVValHelper::eta, etCandCut_, etCut_, spr::find(), flagsexclEB_, flagsexclEE_, edm::EventSetup::get(), edm::Event::getByToken(), CaloGeometry::getPosition(), innerRadius_, edm::InputTag::instance(), interestingDetIdCollection_, PixelPluginsPhase0_cfi::isBarrel, EcalRecHit::kGood, mag(), eostools::move(), outerRadius_, perp(), edm::ESHandle< T >::product(), edm::Event::put(), recHitsLabel_, recHitsToken_, CaloDualConeSelector< T >::selectCallback(), severitiesexclEB_, severitiesexclEE_, and EcalSeverityLevelAlgo::severityLevel().

72  {
73  using namespace edm;
74  using namespace std;
75 
76  //Get EM Object
78  iEvent.getByToken(emObjectToken_, emObjectH);
79 
80  // take EcalRecHits
82  iEvent.getByToken(recHitsToken_, recHitsH);
83 
85  iSetup.get<CaloGeometryRecord>().get(pG);
86  const CaloGeometry* caloGeom = pG.product();
87 
89  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
90  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
91 
92  CaloDualConeSelector<EcalRecHit>* doubleConeSel_ = nullptr;
93  if (recHitsLabel_.instance() == "EcalRecHitsEB")
95  else if (recHitsLabel_.instance() == "EcalRecHitsEE")
97 
98  //Create empty output collections
99  auto detIdCollection = std::make_unique<DetIdCollection>();
100 
101  reco::PhotonCollection::const_iterator emObj;
102  if (doubleConeSel_) { //if cone selector was created
103  for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) { //Loop over candidates
104 
105  if (emObj->et() < etCandCut_)
106  continue;
107 
108  GlobalPoint pclu(emObj->caloPosition().x(), emObj->caloPosition().y(), emObj->caloPosition().z());
109  doubleConeSel_->selectCallback(pclu, *recHitsH, [&](const EcalRecHit& recHitRef) {
110  const EcalRecHit* recIt = &recHitRef;
111 
112  if ((recIt->energy()) < energyCut_)
113  return; //dont fill if below E noise value
114 
115  double et = recIt->energy() * caloGeom->getPosition(recIt->detid()).perp() /
116  caloGeom->getPosition(recIt->detid()).mag();
117 
118  if (et < etCut_)
119  return; //dont fill if below ET noise value
120 
121  bool isBarrel = false;
122  if (fabs(caloGeom->getPosition(recIt->detid()).eta() < 1.479))
123  isBarrel = true;
124 
125  int severityFlag = sevLevel->severityLevel(recIt->detid(), *recHitsH);
126  std::vector<int>::const_iterator sit;
127  if (isBarrel) {
128  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
129  if (sit != severitiesexclEB_.end())
130  return;
131  } else {
132  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
133  if (sit != severitiesexclEE_.end())
134  return;
135  }
136 
137  if (isBarrel) {
138  // new rechit flag checks
139  if (!recIt->checkFlag(EcalRecHit::kGood)) {
140  if (recIt->checkFlags(flagsexclEB_)) {
141  return;
142  }
143  }
144  } else {
145  // new rechit flag checks
146  if (!recIt->checkFlag(EcalRecHit::kGood)) {
147  if (recIt->checkFlags(flagsexclEE_)) {
148  return;
149  }
150  }
151  }
152 
153  if (std::find(detIdCollection->begin(), detIdCollection->end(), recIt->detid()) == detIdCollection->end())
154  detIdCollection->push_back(recIt->detid());
155  }); //end rechits
156 
157  } //end candidates
158 
159  delete doubleConeSel_;
160  } //end if cone selector was created
161 
162  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
163 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
bool checkFlags(const std::vector< int > &flagsvec) const
check if one of the flags in a set is true
Definition: EcalRecHit.h:190
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const DetId & detid() const
Definition: EcalRecHit.h:72
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:187
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
float energy() const
Definition: EcalRecHit.h:68
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
T perp() const
Magnitude of transverse component.
HLT enums.
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< reco::PhotonCollection > emObjectToken_
T const * product() const
Definition: ESHandle.h:86
std::string const & instance() const
Definition: InputTag.h:37
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::InputTag GamIsoDetIdCollectionProducer::emObjectLabel_
private

Definition at line 51 of file GamIsoDetIdCollectionProducer.h.

edm::EDGetTokenT<reco::PhotonCollection> GamIsoDetIdCollectionProducer::emObjectToken_
private

Definition at line 49 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

double GamIsoDetIdCollectionProducer::energyCut_
private

Definition at line 52 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

double GamIsoDetIdCollectionProducer::etCandCut_
private

Definition at line 54 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

double GamIsoDetIdCollectionProducer::etCut_
private

Definition at line 53 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

std::vector<int> GamIsoDetIdCollectionProducer::flagsexclEB_
private

Definition at line 61 of file GamIsoDetIdCollectionProducer.h.

Referenced by GamIsoDetIdCollectionProducer(), and produce().

std::vector<int> GamIsoDetIdCollectionProducer::flagsexclEE_
private

Definition at line 62 of file GamIsoDetIdCollectionProducer.h.

Referenced by GamIsoDetIdCollectionProducer(), and produce().

double GamIsoDetIdCollectionProducer::innerRadius_
private

Definition at line 56 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

std::string GamIsoDetIdCollectionProducer::interestingDetIdCollection_
private

Definition at line 57 of file GamIsoDetIdCollectionProducer.h.

Referenced by GamIsoDetIdCollectionProducer(), and produce().

double GamIsoDetIdCollectionProducer::outerRadius_
private

Definition at line 55 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

edm::InputTag GamIsoDetIdCollectionProducer::recHitsLabel_
private

Definition at line 50 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

edm::EDGetTokenT<EcalRecHitCollection> GamIsoDetIdCollectionProducer::recHitsToken_
private

Definition at line 48 of file GamIsoDetIdCollectionProducer.h.

Referenced by produce().

std::vector<int> GamIsoDetIdCollectionProducer::severitiesexclEB_
private

Definition at line 59 of file GamIsoDetIdCollectionProducer.h.

Referenced by GamIsoDetIdCollectionProducer(), and produce().

std::vector<int> GamIsoDetIdCollectionProducer::severitiesexclEE_
private

Definition at line 60 of file GamIsoDetIdCollectionProducer.h.

Referenced by GamIsoDetIdCollectionProducer(), and produce().