CMS 3D CMS Logo

LowPtGsfElectronSeedValueMapsProducer.cc
Go to the documentation of this file.
12 
14 //
16  gsfTracks_(consumes<reco::GsfTrackCollection>(conf.getParameter<edm::InputTag>("gsfTracks"))),
17  preIdsValueMap_(consumes< edm::ValueMap<reco::PreIdRef> >(conf.getParameter<edm::InputTag>("preIdsValueMap"))),
18  names_(conf.getParameter< std::vector<std::string> >("ModelNames"))
19 {
20  for ( const auto& name : names_ ) { produces< edm::ValueMap<float> >(name); }
21 }
22 
24 //
26 
28 //
30 
31  // Retrieve GsfTracks from Event
33  event.getByToken(gsfTracks_,gsfTracks);
34  if ( !gsfTracks.isValid() ) { edm::LogError("Problem with gsfTracks handle"); }
35 
36  // Retrieve PreIds from Event
38  event.getByToken(preIdsValueMap_,preIdsValueMap);
39  if ( !preIdsValueMap.isValid() ) { edm::LogError("Problem with preIdsValueMap handle"); }
40 
41  // Iterate through GsfTracks, extract BDT output, and store result in ValueMap for each model
42  std::vector< std::vector<float> > output;
43  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
44  output.push_back( std::vector<float>(gsfTracks->size(),-999.) );
45  }
46  for ( unsigned int igsf = 0; igsf < gsfTracks->size(); igsf++ ) {
47  reco::GsfTrackRef gsf(gsfTracks,igsf);
48  if ( gsf.isNonnull() &&
49  gsf->extra().isNonnull() &&
50  gsf->extra()->seedRef().isNonnull() ) {
51  reco::ElectronSeedRef seed = gsf->extra()->seedRef().castTo<reco::ElectronSeedRef>();
52  if ( seed.isNonnull() && seed->ctfTrack().isNonnull() ) {
53  const reco::PreIdRef preid = (*preIdsValueMap)[seed->ctfTrack()];
54  if ( preid.isNonnull() ) {
55  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
56  output[iname][igsf] = preid->mva(iname);
57  }
58  }
59  }
60  }
61  }
62 
63  // Create and put ValueMap in Event
64  for ( unsigned int iname = 0; iname < names_.size(); ++iname ) {
65  auto ptr = std::make_unique< edm::ValueMap<float> >( edm::ValueMap<float>() );
67  filler.insert(gsfTracks, output[iname].begin(), output[iname].end());
68  filler.fill();
69  event.put(std::move(ptr),names_[iname]);
70  }
71 
72 }
73 
75 //
77 {
79  desc.add<edm::InputTag>("gsfTracks",edm::InputTag("lowPtGsfEleGsfTracks"));
80  desc.add<edm::InputTag>("preIdsValueMap",edm::InputTag("lowPtGsfElectronSeeds"));
81  desc.add< std::vector<std::string> >("ModelNames",std::vector<std::string>());
82  descriptions.add("defaultLowPtGsfElectronSeedValueMaps",desc);
83 }
84 
86 //
const edm::EDGetTokenT< reco::GsfTrackCollection > gsfTracks_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
const edm::EDGetTokenT< edm::ValueMap< reco::PreIdRef > > preIdsValueMap_
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
#define end
Definition: vmac.h:39
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
edm::Ref< reco::PreIdCollection > PreIdRef
Definition: PreIdFwd.h:8
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &)
fixed size matrix
#define begin
Definition: vmac.h:32
HLT enums.
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1
void produce(edm::Event &, const edm::EventSetup &) override