CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
EgammaHLTPixelMatchVarProducer Class Reference
Inheritance diagram for EgammaHLTPixelMatchVarProducer:
edm::stream::EDProducer<>

Public Member Functions

std::array< float, 4 > calS2 (const reco::ElectronSeed &seed, int charge) const
 
 EgammaHLTPixelMatchVarProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EgammaHLTPixelMatchVarProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

egPM::Param< reco::ElectronSeeddPhi1Para_
 
egPM::Param< reco::ElectronSeeddPhi2Para_
 
egPM::Param< reco::ElectronSeeddRZ2Para_
 
size_t nrHits_
 
const edm::EDGetTokenT< reco::ElectronSeedCollectionpixelSeedsToken_
 
int productsToWrite_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateCollectionrecoEcalCandidateToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 102 of file EgammaHLTPixelMatchVarProducer.cc.

Constructor & Destructor Documentation

◆ EgammaHLTPixelMatchVarProducer()

EgammaHLTPixelMatchVarProducer::EgammaHLTPixelMatchVarProducer ( const edm::ParameterSet config)
explicit

Definition at line 125 of file EgammaHLTPixelMatchVarProducer.cc.

References nrHits_, productsToWrite_, and to_string().

127  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
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 }
egPM::Param< reco::ElectronSeed > dPhi2Para_
egPM::Param< reco::ElectronSeed > dPhi1Para_
Definition: config.py:1
static std::string to_string(const XMLCh *ch)
egPM::Param< reco::ElectronSeed > dRZ2Para_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateToken_
const edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedsToken_

◆ ~EgammaHLTPixelMatchVarProducer()

EgammaHLTPixelMatchVarProducer::~EgammaHLTPixelMatchVarProducer ( )
override

Definition at line 159 of file EgammaHLTPixelMatchVarProducer.cc.

159 {}

Member Function Documentation

◆ calS2()

std::array< float, 4 > EgammaHLTPixelMatchVarProducer::calS2 ( const reco::ElectronSeed seed,
int  charge 
) const

Definition at line 299 of file EgammaHLTPixelMatchVarProducer.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, dPhi1Para_, dPhi2Para_, dRZ2Para_, and fileCollector::seed.

Referenced by produce().

299  {
300  const float dPhi1Const = dPhi1Para_(seed);
301  const float dPhi2Const = dPhi2Para_(seed);
302  const float dRZ2Const = dRZ2Para_(seed);
303 
304  float dPhi1 = (charge < 0 ? seed.dPhiNeg(0) : seed.dPhiPos(0)) / dPhi1Const;
305  float dPhi2 = (charge < 0 ? seed.dPhiNeg(1) : seed.dPhiPos(1)) / dPhi2Const;
306  float dRz2 = (charge < 0 ? seed.dRZNeg(1) : seed.dRZPos(1)) / dRZ2Const;
307 
308  float s2 = dPhi1 * dPhi1 + dPhi2 * dPhi2 + dRz2 * dRz2;
309  return std::array<float, 4>{{s2, dPhi1, dPhi2, dRz2}};
310 }
egPM::Param< reco::ElectronSeed > dPhi2Para_
egPM::Param< reco::ElectronSeed > dPhi1Para_
egPM::Param< reco::ElectronSeed > dRZ2Para_

◆ fillDescriptions()

void EgammaHLTPixelMatchVarProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 161 of file EgammaHLTPixelMatchVarProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, edm::ParameterSetDescription::ifValue(), eostools::move(), and or.

161  {
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 }
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
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
def move(src, dest)
Definition: eostools.py:511

◆ produce()

void EgammaHLTPixelMatchVarProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
override

Definition at line 198 of file EgammaHLTPixelMatchVarProducer.cc.

References calS2(), edm::RefToBase< T >::castTo(), reco::ElectronSeed::dPhiBest(), reco::ElectronSeed::dRZBest(), electrons_cff::etaWidth, iEvent, WZElectronSkims53X_cff::max, eostools::move(), nrHits_, electrons_cff::phiWidth, pixelSeedsToken_, productsToWrite_, recoEcalCandidateToken_, and fileCollector::seed.

198  {
199  // Get the HLT filtered objects
200  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandidateToken_);
201 
202  auto pixelSeedsHandle = iEvent.getHandle(pixelSeedsToken_);
203 
204  if (!recoEcalCandHandle.isValid())
205  return;
206  else if (!pixelSeedsHandle.isValid()) {
207  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
208  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
209  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
210  s2Map->insert(candRef, 0);
211  }
212  iEvent.put(std::move(s2Map), "s2");
213  return;
214  }
215 
216  auto dPhi1BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
217  auto dPhi2BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
218  auto dzBestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
219  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
220 
221  auto nrClusMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
222  auto seedClusEFracMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
223  auto phiWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
224  auto etaWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
225 
226  std::vector<PixelData> pixelData;
227  for (size_t hitNr = 0; hitNr < nrHits_; hitNr++) {
228  pixelData.emplace_back(PixelData("dPhi", hitNr, &reco::ElectronSeed::dPhiBest, recoEcalCandHandle));
229  pixelData.emplace_back(PixelData("dRZ", hitNr, &reco::ElectronSeed::dRZBest, recoEcalCandHandle));
230  }
231 
232  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
233  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
234  reco::SuperClusterRef candSCRef = candRef->superCluster();
235 
236  std::array<float, 4> bestS2{{std::numeric_limits<float>::max(),
240  for (auto& seed : *pixelSeedsHandle) {
241  const edm::RefToBase<reco::CaloCluster>& pixelClusterRef = seed.caloCluster();
242  reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo<reco::SuperClusterRef>();
243  if (&(*candSCRef) == &(*pixelSCRef)) {
244  std::array<float, 4> s2Data = calS2(seed, -1);
245  std::array<float, 4> s2DataPos = calS2(seed, +1);
246  if (s2Data[0] < bestS2[0])
247  bestS2 = s2Data;
248  if (s2DataPos[0] < bestS2[0])
249  bestS2 = s2DataPos;
250 
251  if (productsToWrite_ >= 2) {
252  for (auto& pixelDatum : pixelData) {
253  pixelDatum.fill(seed);
254  }
255  }
256  }
257  }
258 
259  s2Map->insert(candRef, bestS2[0]);
260  if (productsToWrite_ >= 1) {
261  dPhi1BestS2Map->insert(candRef, bestS2[1]);
262  dPhi2BestS2Map->insert(candRef, bestS2[2]);
263  dzBestS2Map->insert(candRef, bestS2[3]);
264  }
265  if (productsToWrite_ >= 2) {
266  nrClusMap->insert(candRef, candSCRef->clustersSize());
267  float seedClusEFrac = candSCRef->rawEnergy() > 0 ? candSCRef->seed()->energy() / candSCRef->rawEnergy() : 0.;
268  // std::cout <<"cand "<<candSCRef->energy()<<" E Corr "<<candSCRef->correctedEnergyUncertainty()<<" "<<candSCRef->correctedEnergy()<<" width "<<candSCRef->phiWidth()<<std::endl;
269  // float seedClusEFrac = candSCRef->phiWidth();
270  seedClusEFracMap->insert(candRef, seedClusEFrac);
271  float phiWidth = candSCRef->phiWidth();
272  float etaWidth = candSCRef->etaWidth();
273  phiWidthMap->insert(candRef, phiWidth);
274  etaWidthMap->insert(candRef, etaWidth);
275 
276  for (auto& pixelDatum : pixelData) {
277  pixelDatum.fill(candRef);
278  }
279  }
280  }
281 
282  iEvent.put(std::move(s2Map), "s2");
283  if (productsToWrite_ >= 1) {
284  iEvent.put(std::move(dPhi1BestS2Map), "dPhi1BestS2");
285  iEvent.put(std::move(dPhi2BestS2Map), "dPhi2BestS2");
286  iEvent.put(std::move(dzBestS2Map), "dzBestS2");
287  }
288  if (productsToWrite_ >= 2) {
289  for (auto& pixelDatum : pixelData) {
290  pixelDatum.putInto(iEvent);
291  }
292  iEvent.put(std::move(nrClusMap), "nrClus");
293  iEvent.put(std::move(seedClusEFracMap), "seedClusEFrac");
294  iEvent.put(std::move(phiWidthMap), "phiWidth");
295  iEvent.put(std::move(etaWidthMap), "etaWidth");
296  }
297 }
REF castTo() const
Definition: RefToBase.h:243
std::array< float, 4 > calS2(const reco::ElectronSeed &seed, int charge) const
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateToken_
float dPhiBest(size_t hitNr) const
Definition: ElectronSeed.h:104
const edm::EDGetTokenT< reco::ElectronSeedCollection > pixelSeedsToken_
float dRZBest(size_t hitNr) const
Definition: ElectronSeed.h:107
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ dPhi1Para_

egPM::Param<reco::ElectronSeed> EgammaHLTPixelMatchVarProducer::dPhi1Para_
private

Definition at line 117 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ dPhi2Para_

egPM::Param<reco::ElectronSeed> EgammaHLTPixelMatchVarProducer::dPhi2Para_
private

Definition at line 118 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ dRZ2Para_

egPM::Param<reco::ElectronSeed> EgammaHLTPixelMatchVarProducer::dRZ2Para_
private

Definition at line 119 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ nrHits_

size_t EgammaHLTPixelMatchVarProducer::nrHits_
private

Definition at line 122 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by EgammaHLTPixelMatchVarProducer(), and produce().

◆ pixelSeedsToken_

const edm::EDGetTokenT<reco::ElectronSeedCollection> EgammaHLTPixelMatchVarProducer::pixelSeedsToken_
private

Definition at line 115 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by produce().

◆ productsToWrite_

int EgammaHLTPixelMatchVarProducer::productsToWrite_
private

Definition at line 121 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by EgammaHLTPixelMatchVarProducer(), and produce().

◆ recoEcalCandidateToken_

const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> EgammaHLTPixelMatchVarProducer::recoEcalCandidateToken_
private

Definition at line 114 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by produce().