CMS 3D CMS Logo

EgammaHLTPixelMatchVarProducer.cc
Go to the documentation of this file.
1 
2 
8 
13 
16 
21 
24 
28 
30 
31 namespace {
32  //first 4 bits are sub detect of each hit (0=barrel, 1 = endcap)
33  //next 8 bits are layer information (0=no hit, 1 = hit), first 4 are barrel, next 4 are endcap (theres an empty bit here
34  //next 4 bits are nr of layers info
35  int makeSeedInfo(const reco::ElectronSeed& seed) {
36  int info = 0;
37  for (size_t hitNr = 0; hitNr < seed.hitInfo().size(); hitNr++) {
38  int subDetBit = 0x1 << hitNr;
39  if (seed.subDet(hitNr) == PixelSubdetector::PixelEndcap)
40  info |= subDetBit;
41  int layerOffset = 3;
42  if (seed.subDet(hitNr) == PixelSubdetector::PixelEndcap)
43  layerOffset += 4;
44  int layerBit = 0x1 << layerOffset << seed.layerOrDiskNr(hitNr);
45  info |= layerBit;
46 
47  int nrLayersAlongTrajShifted = seed.nrLayersAlongTraj() << 12;
48  info |= nrLayersAlongTrajShifted;
49  }
50  return info;
51  }
52 
53 } // namespace
54 
55 struct PixelData {
56 public:
58  size_t hitNr,
59  float (reco::ElectronSeed::*func)(size_t) const,
61  : name_(std::move(name)), hitNr_(hitNr), func_(func), val_(std::numeric_limits<float>::max()), valInfo_(0) {
62  valMap_ = std::make_unique<reco::RecoEcalCandidateIsolationMap>(candHandle);
63  valInfoMap_ = std::make_unique<reco::RecoEcalCandidateIsolationMap>(candHandle);
64  }
65  PixelData(PixelData&& rhs) = default;
66 
67  void resetVal() {
69  valInfo_ = 0;
70  }
71  void fill(const reco::ElectronSeed& seed) {
72  if (hitNr_ < seed.hitInfo().size()) {
73  float seedVal = (seed.*func_)(hitNr_);
74  if (std::abs(seedVal) < std::abs(val_)) {
75  val_ = seedVal;
76  valInfo_ = makeSeedInfo(seed);
77  }
78  }
79  }
80  void fill(const reco::RecoEcalCandidateRef& candRef) {
81  valMap_->insert(candRef, val_);
82  valInfoMap_->insert(candRef, valInfo_);
84  valInfo_ = 0;
85  }
86 
88  event.put(std::move(valMap_), name_ + std::to_string(hitNr_ + 1));
89  event.put(std::move(valInfoMap_), name_ + std::to_string(hitNr_ + 1) + "Info");
90  }
91 
92 private:
93  std::unique_ptr<reco::RecoEcalCandidateIsolationMap> valMap_;
94  std::unique_ptr<reco::RecoEcalCandidateIsolationMap> valInfoMap_;
96  size_t hitNr_;
97  float (reco::ElectronSeed::*func_)(size_t) const;
98  float val_;
99  float valInfo_;
100 };
101 
103 public:
106 
107  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
108  void produce(edm::Event&, const edm::EventSetup&) override;
109  std::array<float, 4> calS2(const reco::ElectronSeed& seed, int charge) const;
110 
111 private:
112  // ----------member data ---------------------------
113 
116 
120 
122  size_t nrHits_;
123 };
124 
126  : recoEcalCandidateToken_(
127  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
128  pixelSeedsToken_(
129  consumes<reco::ElectronSeedCollection>(config.getParameter<edm::InputTag>("pixelSeedsProducer"))),
130  dPhi1Para_(config.getParameter<edm::ParameterSet>("dPhi1SParams")),
131  dPhi2Para_(config.getParameter<edm::ParameterSet>("dPhi2SParams")),
132  dRZ2Para_(config.getParameter<edm::ParameterSet>("dRZ2SParams")),
133  productsToWrite_(config.getParameter<int>("productsToWrite")),
134  nrHits_(4)
135 
136 {
137  //register your products
138  produces<reco::RecoEcalCandidateIsolationMap>("s2");
139  if (productsToWrite_ >= 1) {
140  produces<reco::RecoEcalCandidateIsolationMap>("dPhi1BestS2");
141  produces<reco::RecoEcalCandidateIsolationMap>("dPhi2BestS2");
142  produces<reco::RecoEcalCandidateIsolationMap>("dzBestS2");
143  }
144  if (productsToWrite_ >= 2) {
145  //note for product names we start from index 1
146  for (size_t hitNr = 1; hitNr <= nrHits_; hitNr++) {
147  produces<reco::RecoEcalCandidateIsolationMap>("dPhi" + std::to_string(hitNr));
148  produces<reco::RecoEcalCandidateIsolationMap>("dPhi" + std::to_string(hitNr) + "Info");
149  produces<reco::RecoEcalCandidateIsolationMap>("dRZ" + std::to_string(hitNr));
150  produces<reco::RecoEcalCandidateIsolationMap>("dRZ" + std::to_string(hitNr) + "Info");
151  }
152  produces<reco::RecoEcalCandidateIsolationMap>("nrClus");
153  produces<reco::RecoEcalCandidateIsolationMap>("seedClusEFrac");
154  produces<reco::RecoEcalCandidateIsolationMap>("phiWidth");
155  produces<reco::RecoEcalCandidateIsolationMap>("etaWidth");
156  }
157 }
158 
160 
163  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
164  desc.add<edm::InputTag>(("pixelSeedsProducer"), edm::InputTag("electronPixelSeeds"));
165 
166  edm::ParameterSetDescription varParamDesc;
167  edm::ParameterSetDescription binParamDesc;
168 
169  auto binDescCases = "AbsEtaClus" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
170  edm::ParameterDescription<double>("xMax", 3.0, true) and
171  edm::ParameterDescription<int>("yMin", 0, true) and
172  edm::ParameterDescription<int>("yMax", 99999, true) and
173  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
174  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true)) or
175  "AbsEtaClusPhi" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
176  edm::ParameterDescription<double>("xMax", 3.0, true) and
177  edm::ParameterDescription<int>("yMin", 0, true) and
178  edm::ParameterDescription<int>("yMax", 99999, true) and
179  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
180  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true)) or
181  "AbsEtaClusEt" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
182  edm::ParameterDescription<double>("xMax", 3.0, true) and
183  edm::ParameterDescription<int>("yMin", 0, true) and
184  edm::ParameterDescription<int>("yMax", 99999, true) and
185  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
186  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true));
187 
188  binParamDesc.ifValue(edm::ParameterDescription<std::string>("binType", "AbsEtaClus", true), std::move(binDescCases));
189 
190  varParamDesc.addVPSet("bins", binParamDesc);
191  desc.add("dPhi1SParams", varParamDesc);
192  desc.add("dPhi2SParams", varParamDesc);
193  desc.add("dRZ2SParams", varParamDesc);
194  desc.add<int>("productsToWrite", 0);
195  descriptions.add(("hltEgammaHLTPixelMatchVarProducer"), desc);
196 }
197 
199  // Get the HLT filtered objects
201  iEvent.getByToken(recoEcalCandidateToken_, recoEcalCandHandle);
202 
204  iEvent.getByToken(pixelSeedsToken_, pixelSeedsHandle);
205 
206  if (!recoEcalCandHandle.isValid())
207  return;
208  else if (!pixelSeedsHandle.isValid()) {
209  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
210  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
211  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
212  s2Map->insert(candRef, 0);
213  }
214  iEvent.put(std::move(s2Map), "s2");
215  return;
216  }
217 
218  edm::ESHandle<TrackerTopology> trackerTopoHandle;
219  iSetup.get<TrackerTopologyRcd>().get(trackerTopoHandle);
220 
221  auto dPhi1BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
222  auto dPhi2BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
223  auto dzBestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
224  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
225 
226  auto nrClusMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
227  auto seedClusEFracMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
228  auto phiWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
229  auto etaWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
230 
231  std::vector<PixelData> pixelData;
232  for (size_t hitNr = 0; hitNr < nrHits_; hitNr++) {
233  pixelData.emplace_back(PixelData("dPhi", hitNr, &reco::ElectronSeed::dPhiBest, recoEcalCandHandle));
234  pixelData.emplace_back(PixelData("dRZ", hitNr, &reco::ElectronSeed::dRZBest, recoEcalCandHandle));
235  }
236 
237  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
238  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
239  reco::SuperClusterRef candSCRef = candRef->superCluster();
240 
241  std::array<float, 4> bestS2{{std::numeric_limits<float>::max(),
245  for (auto& seed : *pixelSeedsHandle) {
246  const edm::RefToBase<reco::CaloCluster>& pixelClusterRef = seed.caloCluster();
247  reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo<reco::SuperClusterRef>();
248  if (&(*candSCRef) == &(*pixelSCRef)) {
249  std::array<float, 4> s2Data = calS2(seed, -1);
250  std::array<float, 4> s2DataPos = calS2(seed, +1);
251  if (s2Data[0] < bestS2[0])
252  bestS2 = s2Data;
253  if (s2DataPos[0] < bestS2[0])
254  bestS2 = s2DataPos;
255 
256  if (productsToWrite_ >= 2) {
257  for (auto& pixelDatum : pixelData) {
258  pixelDatum.fill(seed);
259  }
260  }
261  }
262  }
263 
264  s2Map->insert(candRef, bestS2[0]);
265  if (productsToWrite_ >= 1) {
266  dPhi1BestS2Map->insert(candRef, bestS2[1]);
267  dPhi2BestS2Map->insert(candRef, bestS2[2]);
268  dzBestS2Map->insert(candRef, bestS2[3]);
269  }
270  if (productsToWrite_ >= 2) {
271  nrClusMap->insert(candRef, candSCRef->clustersSize());
272  float seedClusEFrac = candSCRef->rawEnergy() > 0 ? candSCRef->seed()->energy() / candSCRef->rawEnergy() : 0.;
273  // std::cout <<"cand "<<candSCRef->energy()<<" E Corr "<<candSCRef->correctedEnergyUncertainty()<<" "<<candSCRef->correctedEnergy()<<" width "<<candSCRef->phiWidth()<<std::endl;
274  // float seedClusEFrac = candSCRef->phiWidth();
275  seedClusEFracMap->insert(candRef, seedClusEFrac);
276  float phiWidth = candSCRef->phiWidth();
277  float etaWidth = candSCRef->etaWidth();
278  phiWidthMap->insert(candRef, phiWidth);
279  etaWidthMap->insert(candRef, etaWidth);
280 
281  for (auto& pixelDatum : pixelData) {
282  pixelDatum.fill(candRef);
283  }
284  }
285  }
286 
287  iEvent.put(std::move(s2Map), "s2");
288  if (productsToWrite_ >= 1) {
289  iEvent.put(std::move(dPhi1BestS2Map), "dPhi1BestS2");
290  iEvent.put(std::move(dPhi2BestS2Map), "dPhi2BestS2");
291  iEvent.put(std::move(dzBestS2Map), "dzBestS2");
292  }
293  if (productsToWrite_ >= 2) {
294  for (auto& pixelDatum : pixelData) {
295  pixelDatum.putInto(iEvent);
296  }
297  iEvent.put(std::move(nrClusMap), "nrClus");
298  iEvent.put(std::move(seedClusEFracMap), "seedClusEFrac");
299  iEvent.put(std::move(phiWidthMap), "phiWidth");
300  iEvent.put(std::move(etaWidthMap), "etaWidth");
301  }
302 }
303 
304 std::array<float, 4> EgammaHLTPixelMatchVarProducer::calS2(const reco::ElectronSeed& seed, int charge) const {
305  const float dPhi1Const = dPhi1Para_(seed);
306  const float dPhi2Const = dPhi2Para_(seed);
307  const float dRZ2Const = dRZ2Para_(seed);
308 
309  float dPhi1 = (charge < 0 ? seed.dPhiNeg(0) : seed.dPhiPos(0)) / dPhi1Const;
310  float dPhi2 = (charge < 0 ? seed.dPhiNeg(1) : seed.dPhiPos(1)) / dPhi2Const;
311  float dRz2 = (charge < 0 ? seed.dRZNeg(1) : seed.dRZPos(1)) / dRZ2Const;
312 
313  float s2 = dPhi1 * dPhi1 + dPhi2 * dPhi2 + dRz2 * dRz2;
314  return std::array<float, 4>{{s2, dPhi1, dPhi2, dRz2}};
315 }
316 
RecoEcalCandidateIsolation.h
ConfigurationDescriptions.h
reco::RecoEcalCandidateCollection
std::vector< RecoEcalCandidate > RecoEcalCandidateCollection
collectin of RecoEcalCandidate objects
Definition: RecoEcalCandidateFwd.h:9
EgammaHLTPixelMatchVarProducer::pixelSeedsToken_
const edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedsToken_
Definition: EgammaHLTPixelMatchVarProducer.cc:115
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelData::valMap_
std::unique_ptr< reco::RecoEcalCandidateIsolationMap > valMap_
Definition: EgammaHLTPixelMatchVarProducer.cc:93
ESHandle.h
edm::EDGetTokenT< reco::RecoEcalCandidateCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
indexGen.s2
s2
Definition: indexGen.py:107
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
EgammaHLTPixelMatchVarProducer::productsToWrite_
int productsToWrite_
Definition: EgammaHLTPixelMatchVarProducer.cc:121
EgammaHLTPixelMatchVarProducer::nrHits_
size_t nrHits_
Definition: EgammaHLTPixelMatchVarProducer.cc:122
edm::Handle
Definition: AssociativeIterator.h:50
EgammaHLTPixelMatchVarProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EgammaHLTPixelMatchVarProducer.cc:161
ElectronSeedFwd.h
edm::Ref
Definition: AssociativeIterator.h:58
config
Definition: config.py:1
MakerMacros.h
TrackerTopology.h
reco::ElectronSeed
Definition: ElectronSeed.h:51
EgammaHLTPixelMatchVarProducer::recoEcalCandidateToken_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateToken_
Definition: EgammaHLTPixelMatchVarProducer.cc:114
TrackerTopologyRcd.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
EgammaHLTPixelMatchVarProducer
Definition: EgammaHLTPixelMatchVarProducer.cc:102
edm::ESHandle< TrackerTopology >
reco::ElectronSeedCollection
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
Definition: ElectronSeedFwd.h:10
CaloClusterFwd.h
EgammaHLTPixelMatchVarProducer::EgammaHLTPixelMatchVarProducer
EgammaHLTPixelMatchVarProducer(const edm::ParameterSet &)
Definition: EgammaHLTPixelMatchVarProducer.cc:125
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
PixelData::resetVal
void resetVal()
Definition: EgammaHLTPixelMatchVarProducer.cc:67
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
EgammaHLTPixelMatchVarProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: EgammaHLTPixelMatchVarProducer.cc:198
ParameterSet
Definition: Functions.h:16
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::ParameterSetDescription::ifValue
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
Definition: ParameterSetDescription.h:220
PixelData
Definition: EgammaHLTPixelMatchVarProducer.cc:55
egPM::Param< reco::ElectronSeed >
createfilelist.int
int
Definition: createfilelist.py:10
PixelData::putInto
void putInto(edm::Event &event)
Definition: EgammaHLTPixelMatchVarProducer.cc:87
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
EgammaHLTPixelMatchVarProducer::dPhi1Para_
egPM::Param< reco::ElectronSeed > dPhi1Para_
Definition: EgammaHLTPixelMatchVarProducer.cc:117
edm::EventSetup
Definition: EventSetup.h:57
reco::ElectronSeed::dPhiBest
float dPhiBest(size_t hitNr) const
Definition: ElectronSeed.h:105
edm::RefToBase::castTo
REF castTo() const
Definition: RefToBase.h:257
TrackCollections2monitor_cff.func
func
Definition: TrackCollections2monitor_cff.py:359
get
#define get
EgammaHLTPixelMatchVarProducer::dPhi2Para_
egPM::Param< reco::ElectronSeed > dPhi2Para_
Definition: EgammaHLTPixelMatchVarProducer.cc:118
PixelData::fill
void fill(const reco::ElectronSeed &seed)
Definition: EgammaHLTPixelMatchVarProducer.cc:71
PixelData::hitNr_
size_t hitNr_
Definition: EgammaHLTPixelMatchVarProducer.cc:96
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PixelData::valInfoMap_
std::unique_ptr< reco::RecoEcalCandidateIsolationMap > valInfoMap_
Definition: EgammaHLTPixelMatchVarProducer.cc:94
RecoEcalCandidate.h
SuperClusterFwd.h
Frameworkfwd.h
PixelData::PixelData
PixelData(std::string name, size_t hitNr, float(reco::ElectronSeed::*func)(size_t) const, const edm::Handle< reco::RecoEcalCandidateCollection > &candHandle)
Definition: EgammaHLTPixelMatchVarProducer.cc:57
SuperCluster.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::RefToBase
Definition: AssociativeIterator.h:54
EgammaHLTPixelMatchParamObjects.h
PixelData::val_
float val_
Definition: EgammaHLTPixelMatchVarProducer.cc:98
EgammaHLTPixelMatchVarProducer::calS2
std::array< float, 4 > calS2(const reco::ElectronSeed &seed, int charge) const
Definition: EgammaHLTPixelMatchVarProducer.cc:304
reco::ElectronSeed::dRZBest
float dRZBest(size_t hitNr) const
Definition: ElectronSeed.h:108
RecoEcalCandidateFwd.h
PixelData::name_
std::string name_
Definition: EgammaHLTPixelMatchVarProducer.cc:95
PixelData::valInfo_
float valInfo_
Definition: EgammaHLTPixelMatchVarProducer.cc:99
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
ParameterSet.h
EgammaHLTPixelMatchVarProducer::dRZ2Para_
egPM::Param< reco::ElectronSeed > dRZ2Para_
Definition: EgammaHLTPixelMatchVarProducer.cc:119
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::ParameterDescription
Definition: ParameterDescription.h:110
edm::InputTag
Definition: InputTag.h:15
PixelData::fill
void fill(const reco::RecoEcalCandidateRef &candRef)
Definition: EgammaHLTPixelMatchVarProducer.cc:80
EgammaHLTPixelMatchVarProducer::~EgammaHLTPixelMatchVarProducer
~EgammaHLTPixelMatchVarProducer() override
Definition: EgammaHLTPixelMatchVarProducer.cc:159
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295
ElectronSeed.h
CaloCluster.h
PixelData::func_
float(reco::ElectronSeed::* func_)(size_t) const
Definition: EgammaHLTPixelMatchVarProducer.cc:97