CMS 3D CMS Logo

PF_PU_AssoMap.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PF_PU_AssoMap
4 // Class: PF_PU_AssoMap
5 //
11 //
12 // Original Author: Matthias Geisler,32 4-B20,+41227676487,
13 // $Id$
14 //
15 //
16 
18 
19 //
20 // static data member definitions
21 //
22 
23 //
24 // constructors and destructor
25 //
26 PF_PU_AssoMap::PF_PU_AssoMap(const edm::ParameterSet& iConfig) : PF_PU_AssoMapAlgos(iConfig, consumesCollector()) {
27  //now do what ever other initialization is needed
28 
29  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
30 
31  token_TrackCollection_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TrackCollection"));
32 
33  //register your products
34 
35  if (input_AssociationType_.label() == "TracksToVertex") {
36  produces<TrackToVertexAssMap>();
37  } else {
38  if (input_AssociationType_.label() == "VertexToTracks") {
39  produces<VertexToTrackAssMap>();
40  } else {
41  if (input_AssociationType_.label() == "Both") {
42  produces<TrackToVertexAssMap>();
43  produces<VertexToTrackAssMap>();
44  } else {
45  std::cout << "No correct InputTag for AssociationType!" << std::endl;
46  std::cout << "Won't produce any AssociationMap!" << std::endl;
47  }
48  }
49  }
50 }
51 
53  // do anything here that needs to be done at destruction time
54  // (e.g. close files, deallocate resources etc.)
55 }
56 
57 //
58 // member functions
59 //
60 
61 // ------------ method called to produce the data ------------
63  using namespace edm;
64  using namespace std;
65  using namespace reco;
66 
67  //get the input track collection
68  Handle<TrackCollection> trkcollH;
69  iEvent.getByToken(token_TrackCollection_, trkcollH);
70 
71  string asstype = input_AssociationType_.label();
72 
74 
75  if (asstype == "TracksToVertex" || asstype == "VertexToTracks" || asstype == "Both") {
76  auto mappings = createMappings(trkcollH, iSetup);
77  if (asstype == "TracksToVertex" || asstype == "Both") {
78  iEvent.put(SortAssociationMap(&(*mappings.first), trkcollH));
79  }
80  if (asstype == "VertexToTracks" || asstype == "Both") {
81  iEvent.put(std::move(mappings.second));
82  }
83  }
84 }
85 
86 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
88  //The following says we do not know what parameters are allowed so do no validation
89  // Please change this to state exactly what you do use, even if it is no parameters
91  desc.setUnknown();
92  descriptions.addDefault(desc);
93 }
94 
95 //define this as a plug-in
PF_PU_AssoMapAlgos
Definition: PF_PU_AssoMapAlgos.h:83
edm
HLT enums.
Definition: AlignableModifier.h:19
PF_PU_AssoMapAlgos::GetInputCollections
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
Definition: PF_PU_AssoMapAlgos.cc:59
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PF_PU_AssoMapAlgos::createMappings
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH, const edm::EventSetup &iSetup)
Definition: PF_PU_AssoMapAlgos.cc:102
PF_PU_AssoMap::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PF_PU_AssoMap.cc:87
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
PF_PU_AssoMap.h
PF_PU_AssoMap::token_TrackCollection_
edm::EDGetTokenT< reco::TrackCollection > token_TrackCollection_
Definition: PF_PU_AssoMap.h:54
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PF_PU_AssoMap::~PF_PU_AssoMap
~PF_PU_AssoMap() override
Definition: PF_PU_AssoMap.cc:52
PF_PU_AssoMap::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PF_PU_AssoMap.cc:62
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:36
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSetDescription::setUnknown
void setUnknown()
Definition: ParameterSetDescription.cc:39
edm::EventSetup
Definition: EventSetup.h:57
PF_PU_AssoMapAlgos::SortAssociationMap
std::unique_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *, edm::Handle< reco::TrackCollection >)
Definition: PF_PU_AssoMapAlgos.cc:170
PF_PU_AssoMap::PF_PU_AssoMap
PF_PU_AssoMap(const edm::ParameterSet &)
Definition: PF_PU_AssoMap.cc:26
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PF_PU_AssoMap
Definition: PF_PU_AssoMap.h:40
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::InputTag
Definition: InputTag.h:15
PF_PU_AssoMap::input_AssociationType_
edm::InputTag input_AssociationType_
Definition: PF_PU_AssoMap.h:52