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: PF_PU_AssoMap.cc,v 1.8 2012/11/21 09:56:19 mgeisler Exp $
14 //
15 //
16 
18 
19 //
20 // static data member definitions
21 //
22 
23 //
24 // constructors and destructor
25 //
27 {
28 
29  //now do what ever other initialization is needed
30 
31  input_AssociationType_ = iConfig.getParameter<edm::InputTag>("AssociationType");
32 
33  input_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  edm::LogWarning("Trck2VtxAssociation") << "No correct InputTag for AssociationType!" << std::endl
48  << "Won't produce any AssociationMap!" << std::endl;
49  }
50  }
51  }
52 
53 }
54 
55 
57 {
58 
59  // do anything here that needs to be done at destruction time
60  // (e.g. close files, deallocate resources etc.)
61 
62 }
63 
64 
65 //
66 // member functions
67 //
68 
69 // ------------ method called to produce the data ------------
70 void
72 {
73 
74  using namespace edm;
75  using namespace std;
76  using namespace reco;
77 
78  //get the input track collection
79  Handle<TrackCollection> trkcollH;
80  iEvent.getByLabel(input_TrackCollection_, trkcollH);
81 
82  string asstype = input_AssociationType_.label();
83 
85 
86  if ( ( asstype == "TracksToVertex" ) || ( asstype == "Both" ) ) {
87  auto_ptr<TrackToVertexAssMap> Track2Vertex = CreateTrackToVertexMap(trkcollH, iSetup);
88  iEvent.put( SortAssociationMap( &(*Track2Vertex) ) );
89  }
90 
91  if ( ( asstype == "VertexToTracks" ) || ( asstype == "Both" ) ) {
92  auto_ptr<VertexToTrackAssMap> Vertex2Track = CreateVertexToTrackMap(trkcollH, iSetup);
93  iEvent.put( Vertex2Track );
94  }
95 
96 }
97 
98 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
99 void
101  //The following says we do not know what parameters are allowed so do no validation
102  // Please change this to state exactly what you do use, even if it is no parameters
104  desc.setUnknown();
105  descriptions.addDefault(desc);
106 }
107 
108 //define this as a plug-in
T getParameter(std::string const &) const
PF_PU_AssoMap(const edm::ParameterSet &)
#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)
edm::InputTag input_TrackCollection_
Definition: PF_PU_AssoMap.h:55
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::auto_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *)
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag input_AssociationType_
Definition: PF_PU_AssoMap.h:53
std::auto_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)