test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
28 
29  //now do what ever other initialization is needed
30 
31  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
32 
33  token_TrackCollection_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("TrackCollection"));
34 
35  //register your products
36 
37  if ( input_AssociationType_.label() == "TracksToVertex" ) {
38  produces<TrackToVertexAssMap>();
39  } else {
40  if ( input_AssociationType_.label() == "VertexToTracks" ) {
41  produces<VertexToTrackAssMap>();
42  } else {
43  if ( input_AssociationType_.label() == "Both" ) {
44  produces<TrackToVertexAssMap>();
45  produces<VertexToTrackAssMap>();
46  } else {
47  std::cout << "No correct InputTag for AssociationType!" << std::endl;
48  std::cout << "Won't produce any AssociationMap!" << std::endl;
49  }
50  }
51  }
52 
53 
54 }
55 
56 
58 {
59 
60  // do anything here that needs to be done at destruction time
61  // (e.g. close files, deallocate resources etc.)
62 
63 }
64 
65 
66 //
67 // member functions
68 //
69 
70 // ------------ method called to produce the data ------------
71 void
73 {
74 
75  using namespace edm;
76  using namespace std;
77  using namespace reco;
78 
79 
80  //get the input track collection
81  Handle<TrackCollection> trkcollH;
82  iEvent.getByToken(token_TrackCollection_, trkcollH);
83 
84  string asstype = input_AssociationType_.label();
85 
87 
88  if ( ( asstype == "TracksToVertex" ) || ( asstype == "Both" ) ) {
89  auto_ptr<TrackToVertexAssMap> Track2Vertex = CreateTrackToVertexMap(trkcollH, iSetup);
90  iEvent.put( SortAssociationMap( &(*Track2Vertex) ) );
91  }
92 
93  if ( ( asstype == "VertexToTracks" ) || ( asstype == "Both" ) ) {
94  auto_ptr<VertexToTrackAssMap> Vertex2Track = CreateVertexToTrackMap(trkcollH, iSetup);
95  iEvent.put( Vertex2Track );
96  }
97 
98 }
99 
100 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
101 void
103  //The following says we do not know what parameters are allowed so do no validation
104  // Please change this to state exactly what you do use, even if it is no parameters
106  desc.setUnknown();
107  descriptions.addDefault(desc);
108 }
109 
110 //define this as a plug-in
T getParameter(std::string const &) const
PF_PU_AssoMap(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::auto_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
std::auto_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *)
edm::EDGetTokenT< reco::TrackCollection > token_TrackCollection_
Definition: PF_PU_AssoMap.h:55
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag input_AssociationType_
Definition: PF_PU_AssoMap.h:53
tuple cout
Definition: gather_cfg.py:145
std::auto_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)