CMS 3D CMS Logo

LowPtGsfElectronSeedValueMapsProducer.cc
Go to the documentation of this file.
17 
18 #include <vector>
19 #include <string>
20 
22 public:
24 
25  void produce(edm::Event&, const edm::EventSetup&) override;
26 
28 
29 private:
32  const std::vector<std::string> names_;
33 };
34 
36 //
38  : gsfTracks_(consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("gsfTracks"))),
39  preIdsValueMap_(consumes<edm::ValueMap<reco::PreIdRef> >(conf.getParameter<edm::InputTag>("preIdsValueMap"))),
40  names_(conf.getParameter<std::vector<std::string> >("ModelNames")) {
41  for (const auto& name : names_) {
42  produces<edm::ValueMap<float> >(name);
43  }
44 }
45 
47 //
49  // Retrieve GsfTracks from Event
51  event.getByToken(gsfTracks_, gsfTracks);
52  if (!gsfTracks.isValid()) {
53  edm::LogError("Problem with gsfTracks handle");
54  }
55 
56  // Retrieve PreIds from Event
58  event.getByToken(preIdsValueMap_, preIdsValueMap);
59  if (!preIdsValueMap.isValid()) {
60  edm::LogError("Problem with preIdsValueMap handle");
61  }
62 
63  // Iterate through GsfTracks, extract BDT output, and store result in ValueMap for each model
64  std::vector<std::vector<float> > output;
65  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
66  output.push_back(std::vector<float>(gsfTracks->size(), -999.));
67  }
68  for (unsigned int igsf = 0; igsf < gsfTracks->size(); igsf++) {
70  if (gsf.isNonnull() && gsf->extra().isNonnull() && gsf->extra()->seedRef().isNonnull()) {
71  reco::ElectronSeedRef seed = gsf->extra()->seedRef().castTo<reco::ElectronSeedRef>();
72  if (seed.isNonnull() && seed->ctfTrack().isNonnull()) {
73  const reco::PreIdRef preid = (*preIdsValueMap)[seed->ctfTrack()];
74  if (preid.isNonnull()) {
75  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
76  output[iname][igsf] = preid->mva(iname);
77  }
78  }
79  }
80  }
81  }
82 
83  // Create and put ValueMap in Event
84  for (unsigned int iname = 0; iname < names_.size(); ++iname) {
85  auto ptr = std::make_unique<edm::ValueMap<float> >(edm::ValueMap<float>());
87  filler.insert(gsfTracks, output[iname].begin(), output[iname].end());
88  filler.fill();
89  event.put(std::move(ptr), names_[iname]);
90  }
91 }
92 
94 //
97  desc.add<edm::InputTag>("gsfTracks", edm::InputTag("lowPtGsfEleGsfTracks"));
98  desc.add<edm::InputTag>("preIdsValueMap", edm::InputTag("lowPtGsfElectronSeeds"));
99  desc.add<std::vector<std::string> >("ModelNames", {"unbiased", "ptbiased"});
100  descriptions.add("lowPtGsfElectronSeedValueMaps", desc);
101 }
102 
104 //
ConfigurationDescriptions.h
LowPtGsfElectronSeedValueMapsProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:48
Handle.h
GsfTrackExtra.h
MessageLogger.h
LowPtGsfElectronSeedValueMapsProducer::preIdsValueMap_
const edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:31
ESHandle.h
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< reco::GsfTrackCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
LowPtGsfElectronSeedValueMapsProducer::LowPtGsfElectronSeedValueMapsProducer
LowPtGsfElectronSeedValueMapsProducer(const edm::ParameterSet &)
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:37
LowPtGsfElectronSeedValueMapsProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:95
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::GsfTrackCollection >
ElectronSeedFwd.h
edm::Ref< GsfTrackCollection >
PreId.h
fileCollector.seed
seed
Definition: fileCollector.py:127
MakerMacros.h
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
mps_fire.end
end
Definition: mps_fire.py:242
ecalDrivenGsfElectronCoresFromMultiCl_cff.gsfTracks
gsfTracks
Definition: ecalDrivenGsfElectronCoresFromMultiCl_cff.py:4
ParameterSetDescription.h
LowPtGsfElectronSeedValueMapsProducer::names_
const std::vector< std::string > names_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
LowPtGsfElectronSeedValueMapsProducer::gsfTracks_
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:30
reco::PreIdRef
edm::Ref< reco::PreIdCollection > PreIdRef
Definition: PreIdFwd.h:8
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
GsfTrack.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:38
ntupleEnum.gsf
gsf
Definition: ntupleEnum.py:48
edm::EventSetup
Definition: EventSetup.h:57
PreIdFwd.h
LowPtGsfElectronSeedValueMapsProducer
Definition: LowPtGsfElectronSeedValueMapsProducer.cc:21
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
InputTag.h
ValueMap.h
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
GsfTrackFwd.h
edm::ValueMap< float >
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
ElectronSeed.h