CMS 3D CMS Logo

EleIsoDetIdCollectionProducer.cc
Go to the documentation of this file.
2 
7 
9 
18 
21 
23 
26 
28  : recHitsToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"))),
29  emObjectToken_(consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("emObjectLabel"))),
30  caloGeometryToken_(esConsumes()),
31  sevLvToken_(esConsumes()),
32  recHitsLabel_(iConfig.getParameter<edm::InputTag>("recHitsLabel")),
33  emObjectLabel_(iConfig.getParameter<edm::InputTag>("emObjectLabel")),
34  energyCut_(iConfig.getParameter<double>("energyCut")),
35  etCut_(iConfig.getParameter<double>("etCut")),
36  etCandCut_(iConfig.getParameter<double>("etCandCut")),
37  outerRadius_(iConfig.getParameter<double>("outerRadius")),
38  innerRadius_(iConfig.getParameter<double>("innerRadius")),
39  interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")) {
40  const std::vector<std::string> flagnamesEB =
41  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
42 
43  const std::vector<std::string> flagnamesEE =
44  iConfig.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
45 
46  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
47 
48  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
49 
50  const std::vector<std::string> severitynamesEB =
51  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
52 
53  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
54 
55  const std::vector<std::string> severitynamesEE =
56  iConfig.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
57 
58  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
59 
60  //register your products
61  produces<DetIdCollection>(interestingDetIdCollection_);
62 }
63 
65 
67 
68 // ------------ method called to produce the data ------------
70  using namespace edm;
71  using namespace std;
72 
73  //Get EM Object
75  iEvent.getByToken(emObjectToken_, emObjectH);
76 
77  // take EcalRecHits
79  iEvent.getByToken(recHitsToken_, recHitsH);
80 
82  const CaloGeometry* caloGeom = pG.product();
83 
84  //Get the channel status from the db
85  //edm::ESHandle<EcalChannelStatus> chStatus;
86  //iSetup.get<EcalChannelStatusRcd>().get(chStatus);
87 
89  const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
90 
91  CaloDualConeSelector<EcalRecHit>* doubleConeSel_ = nullptr;
92  if (recHitsLabel_.instance() == "EcalRecHitsEB")
94  else if (recHitsLabel_.instance() == "EcalRecHitsEE")
96 
97  //Create empty output collections
98  auto detIdCollection = std::make_unique<DetIdCollection>();
99 
100  reco::GsfElectronCollection::const_iterator emObj;
101  if (doubleConeSel_) { //if cone selector was created
102  for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) { //Loop over candidates
103 
104  if (emObj->et() < etCandCut_)
105  continue; //don't calculate if object hasn't enough energy
106 
107  GlobalPoint pclu(emObj->caloPosition().x(), emObj->caloPosition().y(), emObj->caloPosition().z());
108  doubleConeSel_->selectCallback(pclu, *recHitsH, [&](const EcalRecHit& recIt) {
109  if (recIt.energy() < energyCut_)
110  return; //dont fill if below E noise value
111 
112  double et =
113  recIt.energy() * caloGeom->getPosition(recIt.detid()).perp() / caloGeom->getPosition(recIt.detid()).mag();
114 
115  bool isBarrel = false;
116  if (fabs(caloGeom->getPosition(recIt.detid()).eta() < 1.479))
117  isBarrel = true;
118 
119  if (et < etCut_)
120  return; //dont fill if below ET noise value
121 
122  std::vector<int>::const_iterator sit;
123  int severityFlag = sevLevel->severityLevel(recIt.detid(), *recHitsH);
124  if (isBarrel) {
125  sit = std::find(severitiesexclEB_.begin(), severitiesexclEB_.end(), severityFlag);
126  if (sit != severitiesexclEB_.end())
127  return;
128  } else {
129  sit = std::find(severitiesexclEE_.begin(), severitiesexclEE_.end(), severityFlag);
130  if (sit != severitiesexclEE_.end())
131  return;
132  }
133 
134  if (isBarrel) {
135  // new rechit flag checks
136  if (!(recIt.checkFlag(EcalRecHit::kGood))) {
137  if (recIt.checkFlags(flagsexclEB_)) {
138  return;
139  }
140  }
141  } else {
142  // new rechit flag checks
143  if (!(recIt.checkFlag(EcalRecHit::kGood))) {
144  if (recIt.checkFlags(flagsexclEE_)) {
145  return;
146  }
147  }
148  }
149 
150  if (std::find(detIdCollection->begin(), detIdCollection->end(), recIt.detid()) == detIdCollection->end())
151  detIdCollection->push_back(recIt.detid());
152  }); //end rechits
153 
154  } //end candidates
155 
156  delete doubleConeSel_;
157  } //end if cone selector was created
158 
159  iEvent.put(std::move(detIdCollection), interestingDetIdCollection_);
160 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalSeverityLevelAlgo
Definition: EcalSeverityLevelAlgo.h:33
EcalRecHit
Definition: EcalRecHit.h:15
EleIsoDetIdCollectionProducer::recHitsLabel_
edm::InputTag recHitsLabel_
Definition: EleIsoDetIdCollectionProducer.h:53
MessageLogger.h
EcalRecHit::detid
const DetId & detid() const
Definition: EcalRecHit.h:72
EcalSeverityLevelAlgo::severityLevel
EcalSeverityLevel::SeverityLevel severityLevel(const DetId &id) const
Evaluate status from id use channelStatus from DB.
Definition: EcalSeverityLevelAlgo.cc:85
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
ESHandle.h
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
EleIsoDetIdCollectionProducer::sevLvToken_
edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > sevLvToken_
Definition: EleIsoDetIdCollectionProducer.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDetId.h
EEDetId.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
EleIsoDetIdCollectionProducer::EleIsoDetIdCollectionProducer
EleIsoDetIdCollectionProducer(const edm::ParameterSet &)
ctor
Definition: EleIsoDetIdCollectionProducer.cc:27
edm::SortedCollection< EcalRecHit >
reco::GsfElectronCollection
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
Definition: GsfElectronFwd.h:14
EcalRecHit::energy
float energy() const
Definition: EcalRecHit.h:68
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
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
EleIsoDetIdCollectionProducer::innerRadius_
double innerRadius_
Definition: EleIsoDetIdCollectionProducer.h:59
edm::Handle< reco::GsfElectronCollection >
RecoCandidate.h
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
EleIsoDetIdCollectionProducer::outerRadius_
double outerRadius_
Definition: EleIsoDetIdCollectionProducer.h:58
EleIsoDetIdCollectionProducer::etCandCut_
double etCandCut_
Definition: EleIsoDetIdCollectionProducer.h:57
EleIsoDetIdCollectionProducer::flagsexclEE_
std::vector< int > flagsexclEE_
Definition: EleIsoDetIdCollectionProducer.h:65
EleIsoDetIdCollectionProducer.h
CaloGeometry
Definition: CaloGeometry.h:21
PVValHelper::eta
Definition: PVValidationHelpers.h:69
EcalRecHit::checkFlag
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:187
EleIsoDetIdCollectionProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
producer
Definition: EleIsoDetIdCollectionProducer.cc:69
edm::ESHandle< CaloGeometry >
StringToEnumValue.h
EcalRecHit::kGood
Definition: EcalRecHit.h:21
EleIsoDetIdCollectionProducer::~EleIsoDetIdCollectionProducer
~EleIsoDetIdCollectionProducer() override
Definition: EleIsoDetIdCollectionProducer.cc:64
CaloDualConeSelector::selectCallback
void selectCallback(double eta, double phi, const edm::SortedCollection< T > &inputCollection, std::function< void(const T &)> callback)
Definition: CaloDualConeSelector.h:22
Point3DBase< float, GlobalTag >
GsfElectron.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
EleIsoDetIdCollectionProducer::severitiesexclEE_
std::vector< int > severitiesexclEE_
Definition: EleIsoDetIdCollectionProducer.h:63
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
EleIsoDetIdCollectionProducer::beginJob
void beginJob()
Definition: EleIsoDetIdCollectionProducer.cc:66
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:148
EleIsoDetIdCollectionProducer::energyCut_
double energyCut_
Definition: EleIsoDetIdCollectionProducer.h:55
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:57
CaloDualConeSelector
Definition: CaloDualConeSelector.h:14
DetId::Ecal
Definition: DetId.h:27
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
EleIsoDetIdCollectionProducer::recHitsToken_
edm::EDGetToken recHitsToken_
Definition: EleIsoDetIdCollectionProducer.h:49
SuperClusterFwd.h
SuperCluster.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EleIsoDetIdCollectionProducer::emObjectToken_
edm::EDGetToken emObjectToken_
Definition: EleIsoDetIdCollectionProducer.h:50
EleIsoDetIdCollectionProducer::interestingDetIdCollection_
std::string interestingDetIdCollection_
Definition: EleIsoDetIdCollectionProducer.h:60
EleIsoDetIdCollectionProducer::flagsexclEB_
std::vector< int > flagsexclEB_
Definition: EleIsoDetIdCollectionProducer.h:64
CaloDualConeSelector.h
EleIsoDetIdCollectionProducer::severitiesexclEB_
std::vector< int > severitiesexclEB_
Definition: EleIsoDetIdCollectionProducer.h:62
edm::Event
Definition: Event.h:73
EleIsoDetIdCollectionProducer::etCut_
double etCut_
Definition: EleIsoDetIdCollectionProducer.h:56
EcalChannelStatus.h
GlobalPoint.h
EleIsoDetIdCollectionProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: EleIsoDetIdCollectionProducer.h:51
DetIdCollection.h
EcalChannelStatusRcd.h