CMS 3D CMS Logo

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

Public Member Functions

 SuperclusValueMapProducer (const edm::ParameterSet &)
 
 ~SuperclusValueMapProducer ()=default
 
- 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
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > setTokens (const std::vector< edm::InputTag > &tags)
 

Static Private Member Functions

template<typename T >
static void writeValueMap (edm::Event &iEvent, const edm::Handle< edm::View< reco::SuperCluster >> &handle, const std::vector< T > &values, const std::string &label)
 

Private Attributes

const edm::EDGetTokenT< reco::BeamSpotbsToken_
 
const std::vector< edm::InputTagcandTags_
 
const std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > candTokens_
 
std::vector< SuperclusTkIsolFromCands::PIDVetocandVetos_
 
const edm::EDGetTokenT< edm::View< reco::Vertex > > pvToken_
 
const edm::EDGetTokenT< edm::View< reco::SuperCluster > > scToken_
 
const std::string superclusTkIsoLabel_ = "superclusTkIso"
 
const SuperclusTkIsolFromCands::Configuration trkIsoCalcCfg_
 

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 18 of file SuperclusValueMapProducer.cc.

Constructor & Destructor Documentation

◆ SuperclusValueMapProducer()

SuperclusValueMapProducer::SuperclusValueMapProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 47 of file SuperclusValueMapProducer.cc.

References candTags_, candVetos_, edm::ParameterSet::getParameter(), recoMuon::in, MillePedeFileConverter_cfg::out, EleTkIsolFromCands::pidVetoFromStr(), superclusTkIsoLabel_, and HcalDetIdTransform::transform().

48  : candTags_(iConfig.getParameter<std::vector<edm::InputTag>>("cands")),
51  pvToken_(consumes<edm::View<reco::Vertex>>(iConfig.getParameter<edm::InputTag>("srcPv"))),
52  bsToken_(consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("srcBs"))),
53  trkIsoCalcCfg_(iConfig.getParameter<edm::ParameterSet>("trkIsoConfig")) {
54  auto fillVetos = [](const auto& in, auto& out) {
55  std::transform(in.begin(), in.end(), std::back_inserter(out), SuperclusTkIsolFromCands::pidVetoFromStr);
56  };
57 
58  fillVetos(iConfig.getParameter<std::vector<std::string>>("candVetos"), candVetos_);
59 
60  if (candVetos_.size() != candTags_.size())
61  throw cms::Exception("ConfigError") << "Error candVetos should be the same size as cands" << std::endl;
62 
63  produces<edm::ValueMap<float>>(superclusTkIsoLabel_);
64 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< SuperclusTkIsolFromCands::PIDVeto > candVetos_
std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > setTokens(const std::vector< edm::InputTag > &tags)
const std::vector< edm::InputTag > candTags_
const edm::EDGetTokenT< edm::View< reco::SuperCluster > > scToken_
const std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > candTokens_
const SuperclusTkIsolFromCands::Configuration trkIsoCalcCfg_
static PIDVeto pidVetoFromStr(const std::string &vetoStr)
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
const edm::EDGetTokenT< edm::View< reco::Vertex > > pvToken_
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ ~SuperclusValueMapProducer()

SuperclusValueMapProducer::~SuperclusValueMapProducer ( )
default

Member Function Documentation

◆ produce()

void SuperclusValueMapProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 66 of file SuperclusValueMapProducer.cc.

References bsToken_, candTokens_, candVetos_, heavyIonCSV_trainingSettings::idx, iEvent, edm::HandleBase::isValid(), pvToken_, scToken_, superclusTkIsoLabel_, trkIsoCalcCfg_, and writeValueMap().

66  {
68  iEvent.getByToken(scToken_, scHandle);
69 
71  iEvent.getByToken(pvToken_, pvHandle);
72 
74  iEvent.getByToken(bsToken_, bsHandle);
75 
77 
78  if (pvHandle.isValid() && !pvHandle->empty())
79  pos = pvHandle->front().position(); // first try PV
80  else
81  pos = (*bsHandle).position(); // fall back to BS
82 
83  std::vector<edm::Handle<pat::PackedCandidateCollection>> candHandles(candTokens_.size());
84  std::vector<std::unique_ptr<SuperclusTkIsolFromCands>> tkIsoCalc;
85 
86  for (unsigned idx = 0; idx < candTokens_.size(); idx++) {
87  iEvent.getByToken(candTokens_.at(idx), candHandles.at(idx));
88  tkIsoCalc.push_back(
89  std::make_unique<SuperclusTkIsolFromCands>(trkIsoCalcCfg_, *(candHandles.at(idx)), candVetos_.at(idx)));
90  }
91 
92  std::vector<float> vecTkIso;
93  vecTkIso.reserve(scHandle->size());
94 
95  for (const auto& sc : *scHandle) {
96  float tkIso = 0.;
97 
98  for (auto& calc : tkIsoCalc)
99  tkIso += (*calc)(sc, pos).ptSum;
100 
101  vecTkIso.push_back(tkIso);
102  }
103 
104  writeValueMap(iEvent, scHandle, vecTkIso, superclusTkIsoLabel_);
105 }
std::vector< SuperclusTkIsolFromCands::PIDVeto > candVetos_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< edm::View< reco::SuperCluster > > scToken_
const std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > candTokens_
static void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::SuperCluster >> &handle, const std::vector< T > &values, const std::string &label)
const SuperclusTkIsolFromCands::Configuration trkIsoCalcCfg_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< edm::View< reco::Vertex > > pvToken_

◆ setTokens()

std::vector< edm::EDGetTokenT< pat::PackedCandidateCollection > > SuperclusValueMapProducer::setTokens ( const std::vector< edm::InputTag > &  tags)
private

Definition at line 107 of file SuperclusValueMapProducer.cc.

References MillePedeFileConverter_cfg::out, makeGlobalPositionRcd_cfg::tag, and triggerMatcherToHLTDebug_cfi::tags.

108  {
109  std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection>> out;
110 
111  for (const auto& tag : tags)
112  out.push_back(consumes<pat::PackedCandidateCollection>(tag));
113 
114  return out;
115 }

◆ writeValueMap()

template<typename T >
void SuperclusValueMapProducer::writeValueMap ( edm::Event iEvent,
const edm::Handle< edm::View< reco::SuperCluster >> &  handle,
const std::vector< T > &  values,
const std::string &  label 
)
staticprivate

Definition at line 118 of file SuperclusValueMapProducer.cc.

References trigObjTnPSource_cfi::filler, patZpeak::handle, iEvent, label, eostools::move(), and contentValuesCheck::values.

Referenced by produce().

121  {
122  std::unique_ptr<edm::ValueMap<T>> valMap(new edm::ValueMap<T>());
123  typename edm::ValueMap<T>::Filler filler(*valMap);
124  filler.insert(handle, values.begin(), values.end());
125  filler.fill();
126  iEvent.put(std::move(valMap), label);
127 }
char const * label
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bsToken_

const edm::EDGetTokenT<reco::BeamSpot> SuperclusValueMapProducer::bsToken_
private

Definition at line 40 of file SuperclusValueMapProducer.cc.

Referenced by produce().

◆ candTags_

const std::vector<edm::InputTag> SuperclusValueMapProducer::candTags_
private

Definition at line 36 of file SuperclusValueMapProducer.cc.

Referenced by SuperclusValueMapProducer().

◆ candTokens_

const std::vector<edm::EDGetTokenT<pat::PackedCandidateCollection> > SuperclusValueMapProducer::candTokens_
private

Definition at line 37 of file SuperclusValueMapProducer.cc.

Referenced by produce().

◆ candVetos_

std::vector<SuperclusTkIsolFromCands::PIDVeto> SuperclusValueMapProducer::candVetos_
private

Definition at line 34 of file SuperclusValueMapProducer.cc.

Referenced by produce(), and SuperclusValueMapProducer().

◆ pvToken_

const edm::EDGetTokenT<edm::View<reco::Vertex> > SuperclusValueMapProducer::pvToken_
private

Definition at line 39 of file SuperclusValueMapProducer.cc.

Referenced by produce().

◆ scToken_

const edm::EDGetTokenT<edm::View<reco::SuperCluster> > SuperclusValueMapProducer::scToken_
private

Definition at line 38 of file SuperclusValueMapProducer.cc.

Referenced by produce().

◆ superclusTkIsoLabel_

const std::string SuperclusValueMapProducer::superclusTkIsoLabel_ = "superclusTkIso"
private

Definition at line 44 of file SuperclusValueMapProducer.cc.

Referenced by produce(), and SuperclusValueMapProducer().

◆ trkIsoCalcCfg_

const SuperclusTkIsolFromCands::Configuration SuperclusValueMapProducer::trkIsoCalcCfg_
private

Definition at line 42 of file SuperclusValueMapProducer.cc.

Referenced by produce().