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 119 of file EgammaHLTPixelMatchVarProducer.cc.

Constructor & Destructor Documentation

◆ EgammaHLTPixelMatchVarProducer()

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

Definition at line 142 of file EgammaHLTPixelMatchVarProducer.cc.

References nrHits_, productsToWrite_, and to_string().

144  consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"))),
146  consumes<reco::ElectronSeedCollection>(config.getParameter<edm::InputTag>("pixelSeedsProducer"))),
147  dPhi1Para_(config.getParameter<edm::ParameterSet>("dPhi1SParams")),
148  dPhi2Para_(config.getParameter<edm::ParameterSet>("dPhi2SParams")),
149  dRZ2Para_(config.getParameter<edm::ParameterSet>("dRZ2SParams")),
150  productsToWrite_(config.getParameter<int>("productsToWrite")),
151  nrHits_(4)
152 
153 {
154  //register your products
155  produces<reco::RecoEcalCandidateIsolationMap>("s2");
156  if (productsToWrite_ >= 1) {
157  produces<reco::RecoEcalCandidateIsolationMap>("dPhi1BestS2");
158  produces<reco::RecoEcalCandidateIsolationMap>("dPhi2BestS2");
159  produces<reco::RecoEcalCandidateIsolationMap>("dzBestS2");
160  }
161  if (productsToWrite_ >= 2) {
162  //note for product names we start from index 1
163  for (size_t hitNr = 1; hitNr <= nrHits_; hitNr++) {
164  produces<reco::RecoEcalCandidateIsolationMap>("dPhi" + std::to_string(hitNr));
165  produces<reco::RecoEcalCandidateIsolationMap>("dPhi" + std::to_string(hitNr) + "Info");
166  produces<reco::RecoEcalCandidateIsolationMap>("dRZ" + std::to_string(hitNr));
167  produces<reco::RecoEcalCandidateIsolationMap>("dRZ" + std::to_string(hitNr) + "Info");
168  }
169  produces<reco::RecoEcalCandidateIsolationMap>("nrClus");
170  produces<reco::RecoEcalCandidateIsolationMap>("seedClusEFrac");
171  produces<reco::RecoEcalCandidateIsolationMap>("phiWidth");
172  produces<reco::RecoEcalCandidateIsolationMap>("etaWidth");
173  }
174 }
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 176 of file EgammaHLTPixelMatchVarProducer.cc.

176 {}

Member Function Documentation

◆ calS2()

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

Definition at line 316 of file EgammaHLTPixelMatchVarProducer.cc.

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

Referenced by produce().

316  {
317  const float dPhi1Const = dPhi1Para_(seed);
318  const float dPhi2Const = dPhi2Para_(seed);
319  const float dRZ2Const = dRZ2Para_(seed);
320 
321  float dPhi1 = (charge < 0 ? seed.dPhiNeg(0) : seed.dPhiPos(0)) / dPhi1Const;
322  float dPhi2 = (charge < 0 ? seed.dPhiNeg(1) : seed.dPhiPos(1)) / dPhi2Const;
323  float dRz2 = (charge < 0 ? seed.dRZNeg(1) : seed.dRZPos(1)) / dRZ2Const;
324 
325  float s2 = dPhi1 * dPhi1 + dPhi2 * dPhi2 + dRz2 * dRz2;
326  return std::array<float, 4>{{s2, dPhi1, dPhi2, dRz2}};
327 }
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 178 of file EgammaHLTPixelMatchVarProducer.cc.

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

178  {
180  desc.add<edm::InputTag>(("recoEcalCandidateProducer"), edm::InputTag("hltL1SeededRecoEcalCandidate"));
181  desc.add<edm::InputTag>(("pixelSeedsProducer"), edm::InputTag("electronPixelSeeds"));
182 
183  edm::ParameterSetDescription varParamDesc;
184  edm::ParameterSetDescription binParamDesc;
185 
186  auto binDescCases = "AbsEtaClus" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
187  edm::ParameterDescription<double>("xMax", 3.0, true) and
188  edm::ParameterDescription<int>("yMin", 0, true) and
189  edm::ParameterDescription<int>("yMax", 99999, true) and
190  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
191  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true)) or
192  "AbsEtaClusPhi" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
193  edm::ParameterDescription<double>("xMax", 3.0, true) and
194  edm::ParameterDescription<int>("yMin", 0, true) and
195  edm::ParameterDescription<int>("yMax", 99999, true) and
196  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
197  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true)) or
198  "AbsEtaClusEt" >> (edm::ParameterDescription<double>("xMin", 0.0, true) and
199  edm::ParameterDescription<double>("xMax", 3.0, true) and
200  edm::ParameterDescription<int>("yMin", 0, true) and
201  edm::ParameterDescription<int>("yMax", 99999, true) and
202  edm::ParameterDescription<std::string>("funcType", "pol0", true) and
203  edm::ParameterDescription<std::vector<double>>("funcParams", {0.}, true));
204 
205  binParamDesc.ifValue(edm::ParameterDescription<std::string>("binType", "AbsEtaClus", true), std::move(binDescCases));
206 
207  varParamDesc.addVPSet("bins", binParamDesc);
208  desc.add("dPhi1SParams", varParamDesc);
209  desc.add("dPhi2SParams", varParamDesc);
210  desc.add("dRZ2SParams", varParamDesc);
211  desc.add<int>("productsToWrite", 0);
212  descriptions.add(("hltEgammaHLTPixelMatchVarProducer"), desc);
213 }
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 215 of file EgammaHLTPixelMatchVarProducer.cc.

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

215  {
216  // Get the HLT filtered objects
217  auto recoEcalCandHandle = iEvent.getHandle(recoEcalCandidateToken_);
218 
219  auto pixelSeedsHandle = iEvent.getHandle(pixelSeedsToken_);
220 
221  if (!recoEcalCandHandle.isValid())
222  return;
223  else if (!pixelSeedsHandle.isValid()) {
224  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
225  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
226  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
227  s2Map->insert(candRef, 0);
228  }
229  iEvent.put(std::move(s2Map), "s2");
230  return;
231  }
232 
233  auto dPhi1BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
234  auto dPhi2BestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
235  auto dzBestS2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
236  auto s2Map = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
237 
238  auto nrClusMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
239  auto seedClusEFracMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
240  auto phiWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
241  auto etaWidthMap = std::make_unique<reco::RecoEcalCandidateIsolationMap>(recoEcalCandHandle);
242 
243  std::vector<PixelData> pixelData;
244  for (size_t hitNr = 0; hitNr < nrHits_; hitNr++) {
245  pixelData.emplace_back(PixelData("dPhi", hitNr, &reco::ElectronSeed::dPhiBest, recoEcalCandHandle));
246  pixelData.emplace_back(PixelData("dRZ", hitNr, &reco::ElectronSeed::dRZBest, recoEcalCandHandle));
247  }
248 
249  for (unsigned int candNr = 0; candNr < recoEcalCandHandle->size(); candNr++) {
250  reco::RecoEcalCandidateRef candRef(recoEcalCandHandle, candNr);
251  reco::SuperClusterRef candSCRef = candRef->superCluster();
252 
253  std::array<float, 4> bestS2{{std::numeric_limits<float>::max(),
257  for (auto& seed : *pixelSeedsHandle) {
258  const edm::RefToBase<reco::CaloCluster>& pixelClusterRef = seed.caloCluster();
259  reco::SuperClusterRef pixelSCRef = pixelClusterRef.castTo<reco::SuperClusterRef>();
260  if (&(*candSCRef) == &(*pixelSCRef)) {
261  std::array<float, 4> s2Data = calS2(seed, -1);
262  std::array<float, 4> s2DataPos = calS2(seed, +1);
263  if (s2Data[0] < bestS2[0])
264  bestS2 = s2Data;
265  if (s2DataPos[0] < bestS2[0])
266  bestS2 = s2DataPos;
267 
268  if (productsToWrite_ >= 2) {
269  for (auto& pixelDatum : pixelData) {
270  pixelDatum.fill(seed);
271  }
272  }
273  }
274  }
275 
276  s2Map->insert(candRef, bestS2[0]);
277  if (productsToWrite_ >= 1) {
278  dPhi1BestS2Map->insert(candRef, bestS2[1]);
279  dPhi2BestS2Map->insert(candRef, bestS2[2]);
280  dzBestS2Map->insert(candRef, bestS2[3]);
281  }
282  if (productsToWrite_ >= 2) {
283  nrClusMap->insert(candRef, candSCRef->clustersSize());
284  float seedClusEFrac = candSCRef->rawEnergy() > 0 ? candSCRef->seed()->energy() / candSCRef->rawEnergy() : 0.;
285  // std::cout <<"cand "<<candSCRef->energy()<<" E Corr "<<candSCRef->correctedEnergyUncertainty()<<" "<<candSCRef->correctedEnergy()<<" width "<<candSCRef->phiWidth()<<std::endl;
286  // float seedClusEFrac = candSCRef->phiWidth();
287  seedClusEFracMap->insert(candRef, seedClusEFrac);
288  float phiWidth = candSCRef->phiWidth();
289  float etaWidth = candSCRef->etaWidth();
290  phiWidthMap->insert(candRef, phiWidth);
291  etaWidthMap->insert(candRef, etaWidth);
292 
293  for (auto& pixelDatum : pixelData) {
294  pixelDatum.fill(candRef);
295  }
296  }
297  }
298 
299  iEvent.put(std::move(s2Map), "s2");
300  if (productsToWrite_ >= 1) {
301  iEvent.put(std::move(dPhi1BestS2Map), "dPhi1BestS2");
302  iEvent.put(std::move(dPhi2BestS2Map), "dPhi2BestS2");
303  iEvent.put(std::move(dzBestS2Map), "dzBestS2");
304  }
305  if (productsToWrite_ >= 2) {
306  for (auto& pixelDatum : pixelData) {
307  pixelDatum.putInto(iEvent);
308  }
309  iEvent.put(std::move(nrClusMap), "nrClus");
310  iEvent.put(std::move(seedClusEFracMap), "seedClusEFrac");
311  iEvent.put(std::move(phiWidthMap), "phiWidth");
312  iEvent.put(std::move(etaWidthMap), "etaWidth");
313  }
314 }
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 134 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ dPhi2Para_

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

Definition at line 135 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ dRZ2Para_

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

Definition at line 136 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by calS2().

◆ nrHits_

size_t EgammaHLTPixelMatchVarProducer::nrHits_
private

Definition at line 139 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by EgammaHLTPixelMatchVarProducer(), and produce().

◆ pixelSeedsToken_

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

Definition at line 132 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by produce().

◆ productsToWrite_

int EgammaHLTPixelMatchVarProducer::productsToWrite_
private

Definition at line 138 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by EgammaHLTPixelMatchVarProducer(), and produce().

◆ recoEcalCandidateToken_

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

Definition at line 131 of file EgammaHLTPixelMatchVarProducer.cc.

Referenced by produce().