CMS 3D CMS Logo

EgammaIsoDetIdCollectionProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaIsoDetIdCollectionProducer
4 // Class: EgammaIsoDetIdCollectionProducer
5 //
33 
34 template <class T1>
36 public:
37  typedef std::vector<T1> T1Collection;
41  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
42 
43 private:
44  // ----------member data ---------------------------
51  double energyCut_;
52  double etCut_;
53  double etCandCut_;
54  double outerRadius_;
55  double innerRadius_;
57 
58  std::vector<int> severitiesexclEB_;
59  std::vector<int> severitiesexclEE_;
60  std::vector<int> flagsexclEB_;
61  std::vector<int> flagsexclEE_;
62 };
63 
64 template <class T1>
66  : recHitsToken_{consumes(iConfig.getParameter<edm::InputTag>("recHitsLabel"))},
67  emObjectToken_{consumes(iConfig.getParameter<edm::InputTag>("emObjectLabel"))},
68  caloGeometryToken_(esConsumes()),
69  sevLvToken_(esConsumes()),
70  recHitsLabel_(iConfig.getParameter<edm::InputTag>("recHitsLabel")),
71  emObjectLabel_(iConfig.getParameter<edm::InputTag>("emObjectLabel")),
72  energyCut_(iConfig.getParameter<double>("energyCut")),
73  etCut_(iConfig.getParameter<double>("etCut")),
74  etCandCut_(iConfig.getParameter<double>("etCandCut")),
75  outerRadius_(iConfig.getParameter<double>("outerRadius")),
76  innerRadius_(iConfig.getParameter<double>("innerRadius")),
77  interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")) {
78  auto const& flagnamesEB = iConfig.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
79  auto const& flagnamesEE = iConfig.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
80 
81  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
82  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
83 
84  auto const& severitynamesEB = iConfig.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEB");
85 
86  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
87 
88  auto const& severitynamesEE = iConfig.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEE");
89 
90  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
91 
92  //register your products
93  produces<DetIdCollection>(interestingDetIdCollection_);
94 }
95 
96 // ------------ method called to produce the data ------------
97 template <class T1>
100  const edm::EventSetup& iSetup) const {
101  using namespace edm;
102  using namespace std;
103 
104  auto const& emObjects = iEvent.get(emObjectToken_);
105  auto const& ecalRecHits = iEvent.get(recHitsToken_);
106 
107  edm::ESHandle<CaloGeometry> pG = iSetup.getHandle(caloGeometryToken_);
108  const CaloGeometry* caloGeom = pG.product();
109 
110  edm::ESHandle<EcalSeverityLevelAlgo> sevlv = iSetup.getHandle(sevLvToken_);
111  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
112 
113  std::unique_ptr<CaloDualConeSelector<EcalRecHit>> doubleConeSel_ = nullptr;
114  if (recHitsLabel_.instance() == "EcalRecHitsEB") {
115  doubleConeSel_ =
116  std::make_unique<CaloDualConeSelector<EcalRecHit>>(innerRadius_, outerRadius_, &*pG, DetId::Ecal, EcalBarrel);
117  } else if (recHitsLabel_.instance() == "EcalRecHitsEE") {
118  doubleConeSel_ =
119  std::make_unique<CaloDualConeSelector<EcalRecHit>>(innerRadius_, outerRadius_, &*pG, DetId::Ecal, EcalEndcap);
120  }
121 
122  //Create empty output collections
123  auto detIdCollection = std::make_unique<DetIdCollection>();
124 
125  if (doubleConeSel_) { //if cone selector was created
126  for (auto const& emObj : emObjects) { //Loop over candidates
127 
128  if (emObj.et() < etCandCut_)
129  continue; //don't calculate if object hasn't enough energy
130 
131  GlobalPoint pclu(emObj.caloPosition().x(), emObj.caloPosition().y(), emObj.caloPosition().z());
132  doubleConeSel_->selectCallback(pclu, ecalRecHits, [&](const EcalRecHit& recIt) {
133  if (recIt.energy() < energyCut_)
134  return; //dont fill if below E noise value
135 
136  double et =
137  recIt.energy() * caloGeom->getPosition(recIt.detid()).perp() / caloGeom->getPosition(recIt.detid()).mag();
138 
139  if (et < etCut_)
140  return; //dont fill if below ET noise value
141 
142  bool isBarrel = false;
143  if (fabs(caloGeom->getPosition(recIt.detid()).eta() < 1.479))
144  isBarrel = true;
145 
146  int severityFlag = sevLevel->severityLevel(recIt.detid(), ecalRecHits);
147  if (isBarrel) {
148  auto sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
149  if (sit != severitiesexclEB_.end())
150  return;
151  } else {
152  auto sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
153  if (sit != severitiesexclEE_.end())
154  return;
155  }
156 
157  if (isBarrel) {
158  // new rechit flag checks
159  if (!recIt.checkFlag(EcalRecHit::kGood)) {
160  if (recIt.checkFlags(flagsexclEB_)) {
161  return;
162  }
163  }
164  } else {
165  // new rechit flag checks
166  if (!recIt.checkFlag(EcalRecHit::kGood)) {
167  if (recIt.checkFlags(flagsexclEE_)) {
168  return;
169  }
170  }
171  }
172 
173  if (std::find(detIdCollection->begin(), detIdCollection->end(), recIt.detid()) == detIdCollection->end())
174  detIdCollection->push_back(recIt.detid());
175  }); //end rechits
176 
177  } //end candidates
178 
179  } //end if cone selector was created
180 
181  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
182 }
183 
187 
190 
EgammaIsoDetIdCollectionProducer::interestingDetIdCollection_
std::string interestingDetIdCollection_
Definition: EgammaIsoDetIdCollectionProducer.cc:56
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::StreamID
Definition: StreamID.h:30
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
EcalRecHit
Definition: EcalRecHit.h:15
EgammaIsoDetIdCollectionProducer::etCandCut_
double etCandCut_
Definition: EgammaIsoDetIdCollectionProducer.cc:53
EcalRecHit::detid
const DetId & detid() const
Definition: EcalRecHit.h:72
EgammaIsoDetIdCollectionProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: EgammaIsoDetIdCollectionProducer.cc:48
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
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
EgammaIsoDetIdCollectionProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
producer
Definition: EgammaIsoDetIdCollectionProducer.cc:98
EgammaIsoDetIdCollectionProducer::recHitsLabel_
edm::InputTag recHitsLabel_
Definition: EgammaIsoDetIdCollectionProducer.cc:49
EgammaIsoDetIdCollectionProducer::emObjectLabel_
edm::InputTag emObjectLabel_
Definition: EgammaIsoDetIdCollectionProducer.cc:50
EcalRecHit::energy
float energy() const
Definition: EcalRecHit.h:68
perp
T perp() const
Magnitude of transverse component.
Definition: Basic3DVectorLD.h:133
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
RecoCandidate.h
EgammaIsoDetIdCollectionProducer::EgammaIsoDetIdCollectionProducer
EgammaIsoDetIdCollectionProducer(const edm::ParameterSet &)
ctor
Definition: EgammaIsoDetIdCollectionProducer.cc:65
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
EgammaIsoDetIdCollectionProducer::flagsexclEE_
std::vector< int > flagsexclEE_
Definition: EgammaIsoDetIdCollectionProducer.cc:61
MakerMacros.h
Photon.h
EgammaIsoDetIdCollectionProducer::T1Collection
std::vector< T1 > T1Collection
Definition: EgammaIsoDetIdCollectionProducer.cc:37
CaloGeometry
Definition: CaloGeometry.h:21
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
EcalRecHit::checkFlag
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:187
edm::ESHandle< CaloGeometry >
EgammaIsoDetIdCollectionProducer::energyCut_
double energyCut_
Definition: EgammaIsoDetIdCollectionProducer.cc:51
StringToEnumValue.h
EcalRecHit::kGood
Definition: EcalRecHit.h:21
Point3DBase< float, GlobalTag >
GsfElectron.h
EcalSeverityLevelAlgo.h
edm::global::EDProducer
Definition: EDProducer.h:32
CaloGeometryRecord.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
EgammaIsoDetIdCollectionProducer::severitiesexclEB_
std::vector< int > severitiesexclEB_
Definition: EgammaIsoDetIdCollectionProducer.cc:58
iEvent
int iEvent
Definition: GenABIO.cc:224
EcalRecHit::checkFlags
bool checkFlags(const std::vector< int > &flagsvec) const
check if one of the flags in a set is true
Definition: EcalRecHit.h:190
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:58
EgammaIsoDetIdCollectionProducer::emObjectToken_
edm::EDGetTokenT< T1Collection > emObjectToken_
Definition: EgammaIsoDetIdCollectionProducer.cc:46
DetId::Ecal
Definition: DetId.h:27
edm::ESGetToken< CaloGeometry, CaloGeometryRecord >
EgammaIsoDetIdCollectionProducer::innerRadius_
double innerRadius_
Definition: EgammaIsoDetIdCollectionProducer.cc:55
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
EgammaIsoDetIdCollectionProducer
Definition: EgammaIsoDetIdCollectionProducer.cc:35
SuperClusterFwd.h
EgammaIsoDetIdCollectionProducer::recHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
Definition: EgammaIsoDetIdCollectionProducer.cc:45
SuperCluster.h
EgammaIsoDetIdCollectionProducer::severitiesexclEE_
std::vector< int > severitiesexclEE_
Definition: EgammaIsoDetIdCollectionProducer.cc:59
CaloGeometry.h
EgammaIsoDetIdCollectionProducer::outerRadius_
double outerRadius_
Definition: EgammaIsoDetIdCollectionProducer.cc:54
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EgammaIsoDetIdCollectionProducer::etCut_
double etCut_
Definition: EgammaIsoDetIdCollectionProducer.cc:52
EgammaIsoDetIdCollectionProducer::flagsexclEB_
std::vector< int > flagsexclEB_
Definition: EgammaIsoDetIdCollectionProducer.cc:60
CaloDualConeSelector.h
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
EDProducer.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
GlobalPoint.h
edm::InputTag
Definition: InputTag.h:15
EgammaIsoDetIdCollectionProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: EgammaIsoDetIdCollectionProducer.cc:47
DetIdCollection.h