CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonMET.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MuonMET
4 // Class: MuonMET
5 //
13 //
14 // Created: Wed Aug 29 2007
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 
22 #include <string.h>
23 
24 // user include files
26 
34 
36 
38 
39 //using namespace std;
40 
41 namespace cms
42 {
43  // PRODUCER CONSTRUCTORS ------------------------------------------
44  MuonMET::MuonMET( const edm::ParameterSet& iConfig ) : alg_()
45  {
46  metTypeInputTag_ = iConfig.getParameter<edm::InputTag>("metTypeInputTag");
47  uncorMETInputTag_ = iConfig.getParameter<edm::InputTag>("uncorMETInputTag");
48  muonsInputTag_ = iConfig.getParameter<edm::InputTag>("muonsInputTag");
49  muonDepValueMap_ = iConfig.getParameter<edm::InputTag>("muonMETDepositValueMapInputTag");
50 
51 
52  inputMuonToken_ = consumes<edm::View<reco::Muon> >(muonsInputTag_);
53  inputValueMapMuonMetCorrToken_ = consumes<edm::ValueMap<reco::MuonMETCorrectionData> >(muonDepValueMap_);
54 
55  if( metTypeInputTag_.label() == "CaloMET" ) {
56  inputCaloMETToken_ = consumes<edm::View<reco::CaloMET> >(uncorMETInputTag_);
57  produces<reco::CaloMETCollection>();
58  } else
59  inputMETToken_ = consumes<edm::View<reco::MET> >(uncorMETInputTag_);
60  produces<reco::METCollection>();
61 
62  }
63  MuonMET::MuonMET() : alg_() {}
64  // PRODUCER DESTRUCTORS -------------------------------------------
66 
67  // PRODUCER METHODS -----------------------------------------------
69  {
70  using namespace edm;
71 
72  //get the muons
73  Handle<View<reco::Muon> > inputMuons;
74  iEvent.getByToken(inputMuonToken_, inputMuons );
75 
77 
78  iEvent.getByToken(inputValueMapMuonMetCorrToken_, vm_muCorrData_h);
79 
80  if( metTypeInputTag_.label() == "CaloMET")
81  {
82  Handle<View<reco::CaloMET> > inputUncorMet;
83  iEvent.getByToken(inputCaloMETToken_, inputUncorMet); //Get Inputs
84  std::auto_ptr<reco::CaloMETCollection> output( new reco::CaloMETCollection() ); //Create empty output
85 
86  alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()),
87  *(inputUncorMet.product()), &*output);
88 
89  iEvent.put(output); //Put output into Event
90  }
91  else
92  {
93  Handle<View<reco::MET> > inputUncorMet; //Define Inputs
94  iEvent.getByToken(inputMETToken_, inputUncorMet); //Get Inputs
95  std::auto_ptr<reco::METCollection> output( new reco::METCollection() ); //Create empty output
96 
97 
98  alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()),*(inputUncorMet.product()), &*output);
99  iEvent.put(output); //Put output into Event
100  }
101  }
102 }//end namespace cms
103 
104 
105 
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::MET > > inputMETToken_
Definition: MuonMET.h:57
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< edm::View< reco::Muon > > inputMuonToken_
Definition: MuonMET.h:54
MuonMETAlgo alg_
Definition: MuonMET.h:48
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
edm::InputTag metTypeInputTag_
Definition: MuonMET.h:49
edm::InputTag muonDepValueMap_
Definition: MuonMET.h:52
int iEvent
Definition: GenABIO.cc:243
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > inputValueMapMuonMetCorrToken_
Definition: MuonMET.h:55
virtual ~MuonMET()
Definition: MuonMET.cc:65
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
T const * product() const
Definition: Handle.h:81
std::string const & label() const
Definition: InputTag.h:42
edm::InputTag muonsInputTag_
Definition: MuonMET.h:51
edm::InputTag uncorMETInputTag_
Definition: MuonMET.h:50
virtual void run(const edm::View< reco::Muon > &inputMuons, const edm::ValueMap< reco::MuonMETCorrectionData > &vm_muCorrData, const edm::View< reco::MET > &uncorMET, reco::METCollection *corMET)
edm::EDGetTokenT< edm::View< reco::CaloMET > > inputCaloMETToken_
Definition: MuonMET.h:56
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: MuonMET.cc:68