CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DRNCorrectionProducerT< T > Class Template Reference
Inheritance diagram for DRNCorrectionProducerT< T >:
TritonEDProducerT< G, Capabilities > SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... > SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > > edm::stream::EDProducer< edm::ExternalWork, Capabilities... >

Public Member Functions

void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, Input &input) override
 
 DRNCorrectionProducerT (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup, Output const &iOutput) override
 
- Public Member Functions inherited from TritonEDProducerT< G, Capabilities >
void endStream () final
 
 TritonEDProducerT (edm::ParameterSet const &cfg)
 
virtual void tritonEndStream ()
 
- Public Member Functions inherited from SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... >
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup) final
 
virtual void produce (edm::Event &iEvent, edm::EventSetup const &iSetup, Output const &iOutput)=0
 
 SonicEDProducer (edm::ParameterSet const &cfg)
 
 ~SonicEDProducer () override=default
 
- Public Member Functions inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder holder) final
 
virtual void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, Input &iInput)=0
 
void beginStream (edm::StreamID) override
 
 SonicAcquirer (edm::ParameterSet const &cfg)
 
 ~SonicAcquirer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork, Capabilities... >
 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)
 
- Static Public Member Functions inherited from TritonEDProducerT< G, Capabilities >
static void globalEndJob (G *)
 
static std::unique_ptr< G > initializeGlobalCache (edm::ParameterSet const &pset)
 

Private Member Functions

bool isEB (const T &part)
 
bool isEE (const T &part)
 
bool skip (const T &part)
 

Private Attributes

edm::EDGetTokenT< EcalRecHitCollectionEBRecHitsToken_
 
edm::EDGetTokenT< EcalRecHitCollectionEERecHitsToken_
 
edm::EDGetTokenT< EcalRecHitCollectionESRecHitsToken_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordgeomToken_
 
size_t nPart_
 
size_t nValidPart_
 
edm::EDGetTokenT< edm::View< T > > particleToken_
 
edm::ESGetToken< EcalPedestals, EcalPedestalsRcdpedToken_
 
edm::EDGetTokenT< double > rhoToken_
 

Additional Inherited Members

- Public Types inherited from SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... >
typedef TritonClient ::Output Output
 
- Public Types inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
typedef TritonClient ::Input Input
 
- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork, Capabilities... >
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
 
- Protected Member Functions inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
void makeClient ()
 
- Protected Attributes inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
std::unique_ptr< TritonClientclient_
 
edm::ParameterSet clientPset_
 
std::string debugName_
 
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
 
bool verbose_
 

Detailed Description

template<typename T>
class DRNCorrectionProducerT< T >

Definition at line 96 of file DRNCorrectionProducerT.cc.

Constructor & Destructor Documentation

◆ DRNCorrectionProducerT()

template<typename T >
DRNCorrectionProducerT< T >::DRNCorrectionProducerT ( const edm::ParameterSet iConfig)
explicit

Definition at line 123 of file DRNCorrectionProducerT.cc.

124  : TritonEDProducer<>(iConfig),
125  particleToken_(consumes(iConfig.getParameter<edm::InputTag>("particleSource"))),
126  rhoToken_(consumes(iConfig.getParameter<edm::InputTag>("rhoName"))),
127  EBRecHitsToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEcalRecHitsEB"))),
128  EERecHitsToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEcalRecHitsEE"))),
129  ESRecHitsToken_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("reducedEcalRecHitsES"))),
132  produces<edm::ValueMap<std::pair<float, float>>>();
133 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
edm::EDGetTokenT< EcalRecHitCollection > EBRecHitsToken_
edm::EDGetTokenT< double > rhoToken_
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedToken_
edm::EDGetTokenT< EcalRecHitCollection > EERecHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > ESRecHitsToken_
edm::EDGetTokenT< edm::View< T > > particleToken_

Member Function Documentation

◆ acquire()

template<typename T >
void DRNCorrectionProducerT< T >::acquire ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
Input input 
)
override

Definition at line 156 of file DRNCorrectionProducerT.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, relativeConstraints::geom, edm::EventSetup::getData(), CaloSubdetectorGeometry::getGeometry(), iEvent, electrons_cff::isEB, EcalRecHit::kESGood, EcalRecHit::kGood, EcalRecHit::kHasSwitchToGain1, EcalRecHit::kHasSwitchToGain6, EcalRecHit::kOutOfTime, EcalRecHit::kPoorCalib, sistrip::NOISE_MIN, QIE10Task_cfi::ped, DetId::rawId(), EcalDeadCellBoundaryEnergyFilter_cfi::recHitsEB, HLTValidation_cff::recHitsEE, IsoPhotonEBSkim_cff::rho, optionsL1T::skip, and Z_RANGE.

156  {
157  /*
158  * Get products from event and event setup
159  */
160  const auto& particles_ = iEvent.getHandle(particleToken_);
161  float rho = iEvent.get(rhoToken_);
162 
163  const auto& ped = &iSetup.getData(pedToken_);
164  const auto& geo = &iSetup.getData(geomToken_);
165 
166  const CaloSubdetectorGeometry* ecalEBGeom =
167  static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalBarrel));
168  const CaloSubdetectorGeometry* ecalEEGeom =
169  static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalEndcap));
170  const CaloSubdetectorGeometry* ecalESGeom =
171  static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalPreshower));
172 
173  const auto& recHitsEB = iEvent.get(EBRecHitsToken_);
174  const auto& recHitsEE = iEvent.get(EERecHitsToken_);
175  const auto& recHitsES = iEvent.get(ESRecHitsToken_);
176 
177  nPart_ = particles_->size();
178 
179  if (nPart_ == 0) {
180  client_->setBatchSize(0);
181  return;
182  } else {
183  client_->setBatchSize(1);
184  }
185 
186  /*
187  * Determine how many particles, how many RecHits there are in each subdetector
188  */
189  unsigned nHitsECAL = 0, nHitsES = 0;
190  nValidPart_ = 0;
191  for (auto& part : *particles_) {
192  const reco::SuperClusterRef& sc = part.superCluster();
193 
194  if (skip(part))
195  continue;
196 
197  nHitsECAL += sc->hitsAndFractions().size();
198 
199  for (auto iES = sc->preshowerClustersBegin(); iES != sc->preshowerClustersEnd(); ++iES) {
200  nHitsES += (*iES)->hitsAndFractions().size();
201  }
202 
203  ++nValidPart_;
204  }
205 
206  /*
207  * Allocate DRN inputs ({SB} is one of ECAL, ES):
208  * x{SB}: (x, y, z, energy, [noise]) continuous-valued inputs per RecHit
209  * f{SB}: (flagVal) integer denoting RecHit flag values
210  * gainECAL: (gain) integer in (0, 1, 2) denoting gain value
211  * gx: (rho, H/E) additional high-level features.
212  * batch{SB}: graph models require explicitely passing the particle index for each vertex
213  */
214  auto& inputxECAL = iInput.at("xECAL__0");
215  inputxECAL.setShape(0, nHitsECAL);
216  auto dataxECAL = inputxECAL.allocate<float>();
217  auto& vdataxECAL = (*dataxECAL)[0];
218 
219  auto& inputfECAL = iInput.at("fECAL__1");
220  inputfECAL.setShape(0, nHitsECAL);
221  auto datafECAL = inputfECAL.allocate<int64_t>();
222  auto& vdatafECAL = (*datafECAL)[0];
223 
224  auto& inputGainECAL = iInput.at("gain__2");
225  inputGainECAL.setShape(0, nHitsECAL);
226  auto dataGainECAL = inputGainECAL.allocate<int64_t>();
227  auto& vdataGainECAL = (*dataGainECAL)[0];
228 
229  auto& inputGx = iInput.at("graph_x__5");
230  inputGx.setShape(0, nValidPart_);
231  auto dataGx = inputGx.allocate<float>();
232  auto& vdataGx = (*dataGx)[0];
233 
234  auto& inputBatchECAL = iInput.at("xECAL_batch__6");
235  inputBatchECAL.setShape(0, nHitsECAL);
236  auto dataBatchECAL = inputBatchECAL.allocate<int64_t>();
237  auto& vdataBatchECAL = (*dataBatchECAL)[0];
238 
239  auto& inputxES = iInput.at("xES__3");
240  inputxES.setShape(0, nHitsES);
241  auto dataxES = inputxES.allocate<float>();
242  auto& vdataxES = (*dataxES)[0];
243 
244  auto& inputfES = iInput.at("fES__4");
245  inputfES.setShape(0, nHitsES);
246  auto datafES = inputfES.allocate<int64_t>();
247  auto& vdatafES = (*datafES)[0];
248 
249  auto& inputBatchES = iInput.at("xES_batch__7");
250  inputBatchES.setShape(0, nHitsES);
251  auto dataBatchES = inputBatchES.allocate<int64_t>();
252  auto& vdataBatchES = (*dataBatchES)[0];
253 
254  /*
255  * Fill input tensors by iterating over particles...
256  */
257  int64_t partNum = 0;
259  for (auto& part : *particles_) {
260  const reco::SuperClusterRef& sc = part.superCluster();
261 
262  if (skip(part))
263  continue;
264 
265  std::vector<std::pair<DetId, float>> hitsAndFractions = sc->hitsAndFractions();
267 
268  //iterate over ECAL hits...
269  for (const auto& detitr : hitsAndFractions) {
270  DetId id = detitr.first.rawId();
271  if (isEB(part)) {
272  geom = ecalEBGeom->getGeometry(id);
273  hit = recHitsEB.find(detitr.first);
274  } else {
275  geom = ecalEEGeom->getGeometry(id);
276  hit = recHitsEE.find(detitr.first);
277  }
278 
279  //fill xECAL
280  auto pos = geom->getPosition();
281  vdataxECAL.push_back(rescale(pos.x(), XY_MIN, XY_RANGE));
282  vdataxECAL.push_back(rescale(pos.y(), XY_MIN, XY_RANGE));
283  vdataxECAL.push_back(rescale(pos.z(), Z_MIN, Z_RANGE));
284  vdataxECAL.push_back(rescale(hit->energy() * detitr.second, ECAL_MIN, ECAL_RANGE));
285  vdataxECAL.push_back(rescale(ped->find(detitr.first)->rms(1), NOISE_MIN, NOISE_RANGE));
286 
287  //fill fECAL
288  int64_t flagVal = 0;
289  if (hit->checkFlag(EcalRecHit::kGood))
290  flagVal += 1;
291  if (hit->checkFlag(EcalRecHit::kOutOfTime))
292  flagVal += 2;
293  if (hit->checkFlag(EcalRecHit::kPoorCalib))
294  flagVal += 4;
295 
296  vdatafECAL.push_back(flagVal);
297 
298  //fill gain
299  int64_t gainVal = 0;
300  if (hit->checkFlag(EcalRecHit::kHasSwitchToGain6))
301  gainVal = 1;
302  else if (hit->checkFlag(EcalRecHit::kHasSwitchToGain1))
303  gainVal = 0;
304  else
305  gainVal = 2;
306 
307  vdataGainECAL.push_back(gainVal);
308 
309  //fill batch number
310  vdataBatchECAL.push_back(partNum);
311  } //end iterate over ECAL hits
312 
313  //iterate over ES clusters...
314  for (auto iES = sc->preshowerClustersBegin(); iES != sc->preshowerClustersEnd(); ++iES) {
315  for (const auto& ESitr : (*iES)->hitsAndFractions()) { //iterate over ES hits
316  hit = recHitsES.find(ESitr.first);
317  geom = ecalESGeom->getGeometry(ESitr.first);
318  auto& pos = geom->getPosition();
319 
320  //fill xES
321  vdataxES.push_back(rescale(pos.x(), XY_MIN, XY_RANGE));
322  vdataxES.push_back(rescale(pos.y(), XY_MIN, XY_RANGE));
323  vdataxES.push_back(rescale(pos.z(), Z_MIN, Z_RANGE));
324  vdataxES.push_back(rescale(hit->energy(), ES_MIN, ES_RANGE));
325 
326  //fill fES
327  int64_t flagVal = 0;
328  if (hit->checkFlag(EcalRecHit::kESGood))
329  flagVal += 1;
330 
331  vdatafES.push_back(flagVal);
332 
333  //fill batchES
334  vdataBatchES.push_back(partNum);
335  } //end iterate over ES hits
336  } //end iterate over ES clusters
337 
338  //fill gx
339  vdataGx.push_back(rescale(rho, RHO_MIN, RHO_RANGE));
340  vdataGx.push_back(rescale(part.hadronicOverEm(), HOE_MIN, HOE_RANGE));
341 
342  //increment particle number
343  ++partNum;
344  } // end iterate over particles
345 
346  /*
347  * Convert input tensors to server data format
348  */
349 
350  inputxECAL.toServer(dataxECAL);
351  inputfECAL.toServer(datafECAL);
352  inputGainECAL.toServer(dataGainECAL);
353  inputBatchECAL.toServer(dataBatchECAL);
354 
355  inputGx.toServer(dataGx);
356 
357  inputxES.toServer(dataxES);
358  inputfES.toServer(datafES);
359  inputBatchES.toServer(dataBatchES);
360 }
virtual CellMayOwnPtr getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
std::vector< EcalRecHit >::const_iterator const_iterator
edm::EDGetTokenT< EcalRecHitCollection > EBRecHitsToken_
edm::EDGetTokenT< double > rhoToken_
int iEvent
Definition: GenABIO.cc:224
static const float Z_RANGE
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
part
Definition: HCALResponse.h:20
edm::ESGetToken< EcalPedestals, EcalPedestalsRcd > pedToken_
edm::EDGetTokenT< EcalRecHitCollection > EERecHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > ESRecHitsToken_
edm::EDGetTokenT< edm::View< T > > particleToken_

◆ fillDescriptions()

template<typename T >
void DRNCorrectionProducerT< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 403 of file DRNCorrectionProducerT.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, TritonClient::fillPSetDescription(), and ProducerED_cfi::InputTag.

403  {
406  desc.add<edm::InputTag>("particleSource");
407  desc.add<edm::InputTag>("rhoName");
408  desc.add<edm::InputTag>("reducedEcalRecHitsEB", edm::InputTag("reducedEcalRecHitsEB"));
409  desc.add<edm::InputTag>("reducedEcalRecHitsEE", edm::InputTag("reducedEcalRecHitsEE"));
410  desc.add<edm::InputTag>("reducedEcalRecHitsES", edm::InputTag("reducedEcalRecHitsES"));
411  descriptions.addWithDefaultLabel(desc);
412 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)

◆ isEB()

template<typename T >
bool DRNCorrectionProducerT< T >::isEB ( const T part)
private

Definition at line 136 of file DRNCorrectionProducerT.cc.

References EcalBarrel.

Referenced by Electron.Electron::absIsoWithFSR().

136  {
137  return part.superCluster()->seed()->hitsAndFractions().at(0).first.subdetId() == EcalBarrel;
138 }
part
Definition: HCALResponse.h:20

◆ isEE()

template<typename T >
bool DRNCorrectionProducerT< T >::isEE ( const T part)
private

Definition at line 141 of file DRNCorrectionProducerT.cc.

References EcalEndcap.

141  {
142  return part.superCluster()->seed()->hitsAndFractions().at(0).first.subdetId() == EcalEndcap;
143 }
part
Definition: HCALResponse.h:20

◆ produce()

template<typename T >
void DRNCorrectionProducerT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup,
Output const &  iOutput 
)
override

Definition at line 363 of file DRNCorrectionProducerT.cc.

References pfMETCorrectionType0_cfi::correction, f, trigObjTnPSource_cfi::filler, mps_fire::i, iEvent, eostools::move(), amptDefaultParameters_cff::mu, MillePedeFileConverter_cfg::out, dtDQMClient_cfg::resolution, and optionsL1T::skip.

363  {
364  const auto& particles_ = iEvent.getHandle(particleToken_);
365 
366  std::vector<std::pair<float, float>> corrections;
367  corrections.reserve(nPart_);
368 
369  //if there are no particles, the fromServer() call will fail
370  //but we can just put() an empty valueMap
371  if (nPart_) {
372  const auto& out = iOutput.at("combined_output__0").fromServer<float>();
373 
374  unsigned i = 0;
375  float mu, sigma, Epred, sigmaPred, rawE;
376  for (unsigned iPart = 0; iPart < nPart_; ++iPart) {
377  const auto& part = particles_->at(iPart);
378  if (!skip(part)) {
379  mu = correction(out[0][0 + 11 * i]);
380  sigma = resolution(out[0][6 + 11 * i]);
381  ++i;
382 
383  rawE = part.superCluster()->rawEnergy();
384  Epred = mu * rawE;
385  sigmaPred = sigma * rawE;
386  corrections.emplace_back(Epred, sigmaPred);
387  } else {
388  corrections.emplace_back(-1.0f, -1.0f);
389  }
390  }
391  }
392 
393  //fill
394  auto out = std::make_unique<edm::ValueMap<std::pair<float, float>>>();
396  filler.insert(particles_, corrections.begin(), corrections.end());
397  filler.fill();
398 
399  iEvent.put(std::move(out));
400 }
int iEvent
Definition: GenABIO.cc:224
double f[11][100]
part
Definition: HCALResponse.h:20
edm::EDGetTokenT< edm::View< T > > particleToken_
def move(src, dest)
Definition: eostools.py:511

◆ skip()

template<typename T >
bool DRNCorrectionProducerT< T >::skip ( const T part)
private

Definition at line 146 of file DRNCorrectionProducerT.cc.

References electrons_cff::isEB.

146  {
147  /*
148  * Separated out from acquire() and produce() to ensure that skipping check is identical in both
149  * N.B. in MiniAOD there are sometimes particles with no RecHits
150  * We can not apply our regression to these, so we skip them
151  */
152  return (!isEB(part) && !isEE(part)) || part.superCluster()->hitsAndFractions().empty();
153 }
part
Definition: HCALResponse.h:20

Member Data Documentation

◆ EBRecHitsToken_

template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> DRNCorrectionProducerT< T >::EBRecHitsToken_
private

Definition at line 110 of file DRNCorrectionProducerT.cc.

◆ EERecHitsToken_

template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> DRNCorrectionProducerT< T >::EERecHitsToken_
private

Definition at line 110 of file DRNCorrectionProducerT.cc.

◆ ESRecHitsToken_

template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> DRNCorrectionProducerT< T >::ESRecHitsToken_
private

Definition at line 110 of file DRNCorrectionProducerT.cc.

◆ geomToken_

template<typename T >
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> DRNCorrectionProducerT< T >::geomToken_
private

Definition at line 113 of file DRNCorrectionProducerT.cc.

◆ nPart_

template<typename T >
size_t DRNCorrectionProducerT< T >::nPart_
private

Definition at line 115 of file DRNCorrectionProducerT.cc.

◆ nValidPart_

template<typename T >
size_t DRNCorrectionProducerT< T >::nValidPart_
private

Definition at line 115 of file DRNCorrectionProducerT.cc.

◆ particleToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > DRNCorrectionProducerT< T >::particleToken_
private

Definition at line 106 of file DRNCorrectionProducerT.cc.

◆ pedToken_

template<typename T >
edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> DRNCorrectionProducerT< T >::pedToken_
private

Definition at line 112 of file DRNCorrectionProducerT.cc.

◆ rhoToken_

template<typename T >
edm::EDGetTokenT<double> DRNCorrectionProducerT< T >::rhoToken_
private

Definition at line 108 of file DRNCorrectionProducerT.cc.