Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "RecoMET/METProducers/interface/METProducer.h"
00023
00024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00025 #include "FWCore/Framework/interface/Event.h"
00026 #include "FWCore/Framework/interface/EventSetup.h"
00027
00028 #include "DataFormats/Math/interface/LorentzVector.h"
00029 #include "DataFormats/Math/interface/Point3D.h"
00030 #include "DataFormats/Common/interface/Handle.h"
00031 #include "DataFormats/Common/interface/View.h"
00032 #include "DataFormats/Candidate/interface/Candidate.h"
00033 #include "DataFormats/METReco/interface/METFwd.h"
00034 #include "DataFormats/METReco/interface/CaloMETFwd.h"
00035 #include "DataFormats/METReco/interface/CaloMET.h"
00036 #include "DataFormats/METReco/interface/GenMETFwd.h"
00037 #include "DataFormats/METReco/interface/PFMETFwd.h"
00038 #include "DataFormats/METReco/interface/PFClusterMETFwd.h"
00039 #include "DataFormats/METReco/interface/CommonMETData.h"
00040
00041 #include "RecoMET/METAlgorithms/interface/METAlgo.h"
00042 #include "RecoMET/METAlgorithms/interface/TCMETAlgo.h"
00043 #include "RecoMET/METAlgorithms/interface/SignAlgoResolutions.h"
00044 #include "RecoMET/METAlgorithms/interface/PFSpecificAlgo.h"
00045 #include "RecoMET/METAlgorithms/interface/PFClusterSpecificAlgo.h"
00046 #include "RecoMET/METAlgorithms/interface/GenSpecificAlgo.h"
00047 #include "RecoMET/METAlgorithms/interface/CaloSpecificAlgo.h"
00048 #include "RecoMET/METAlgorithms/interface/SignCaloSpecificAlgo.h"
00049
00050 #include <memory>
00051
00052
00053 namespace cms
00054 {
00055 METProducer::METProducer(const edm::ParameterSet& iConfig)
00056 : inputLabel(iConfig.getParameter<edm::InputTag>("src"))
00057 , inputType(iConfig.getParameter<std::string>("InputType"))
00058 , METtype(iConfig.getParameter<std::string>("METType"))
00059 , alias(iConfig.getParameter<std::string>("alias"))
00060 , calculateSignificance_(false)
00061 , resolutions_(0)
00062 , globalThreshold(iConfig.getParameter<double>("globalThreshold"))
00063 {
00064 if( METtype == "CaloMET" )
00065 {
00066 noHF = iConfig.getParameter<bool>("noHF");
00067 produces<reco::CaloMETCollection>().setBranchAlias(alias.c_str());
00068 calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
00069 }
00070 else if( METtype == "GenMET" )
00071 {
00072 onlyFiducial = iConfig.getParameter<bool>("onlyFiducialParticles");
00073 usePt = iConfig.getUntrackedParameter<bool>("usePt", false);
00074 produces<reco::GenMETCollection>().setBranchAlias(alias.c_str());
00075 }
00076 else if( METtype == "PFMET" )
00077 {
00078 produces<reco::PFMETCollection>().setBranchAlias(alias.c_str());
00079
00080 calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
00081
00082 if(calculateSignificance_)
00083 {
00084 jetsLabel_ = iConfig.getParameter<edm::InputTag>("jets");
00085 }
00086
00087 }
00088 else if( METtype == "PFClusterMET" )
00089 {
00090 produces<reco::PFClusterMETCollection>().setBranchAlias(alias.c_str());
00091 }
00092 else if (METtype == "TCMET" )
00093 {
00094 produces<reco::METCollection>().setBranchAlias(alias.c_str());
00095
00096 int rfType_ = iConfig.getParameter<int>("rf_type");
00097 bool correctShowerTracks_ = iConfig.getParameter<bool>("correctShowerTracks");
00098
00099 int responseFunctionType = 0;
00100 if(! correctShowerTracks_)
00101 {
00102 if( rfType_ == 1 ) responseFunctionType = 1;
00103 else if( rfType_ == 2 ) responseFunctionType = 2;
00104 else { }
00105 }
00106 tcMetAlgo_.configure(iConfig, responseFunctionType );
00107 }
00108 else
00109 produces<reco::METCollection>().setBranchAlias(alias.c_str());
00110
00111 if (calculateSignificance_ && ( METtype == "CaloMET" || METtype == "PFMET")){
00112 resolutions_ = new metsig::SignAlgoResolutions(iConfig);
00113
00114 }
00115 }
00116
00117
00118 void METProducer::produce(edm::Event& event, const edm::EventSetup& setup)
00119 {
00120 if( METtype == "CaloMET" )
00121 {
00122 produce_CaloMET(event);
00123 return;
00124 }
00125
00126 if( METtype == "TCMET" )
00127 {
00128 produce_TCMET(event, setup);
00129 return;
00130 }
00131
00132 if( METtype == "PFMET" )
00133 {
00134 produce_PFMET(event);
00135 return;
00136 }
00137
00138 if( METtype == "PFClusterMET" )
00139 {
00140 produce_PFClusterMET(event);
00141 return;
00142 }
00143
00144 if( METtype == "GenMET" )
00145 {
00146 produce_GenMET(event);
00147 return;
00148 }
00149
00150 produce_else(event);
00151 }
00152
00153 void METProducer::produce_CaloMET(edm::Event& event)
00154 {
00155 edm::Handle<edm::View<reco::Candidate> > input;
00156 event.getByLabel(inputLabel, input);
00157
00158 METAlgo algo;
00159 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00160
00161 CaloSpecificAlgo calospecalgo;
00162 reco::CaloMET calomet = calospecalgo.addInfo(input, commonMETdata, noHF, globalThreshold);
00163
00164 if( calculateSignificance_ )
00165 {
00166 SignCaloSpecificAlgo signcalospecalgo;
00167 signcalospecalgo.calculateBaseCaloMET(input, commonMETdata, *resolutions_, noHF, globalThreshold);
00168 calomet.SetMetSignificance(signcalospecalgo.getSignificance() );
00169 calomet.setSignificanceMatrix(signcalospecalgo.getSignificanceMatrix());
00170 }
00171
00172 std::auto_ptr<reco::CaloMETCollection> calometcoll;
00173 calometcoll.reset(new reco::CaloMETCollection);
00174 calometcoll->push_back( calomet ) ;
00175 event.put( calometcoll );
00176 }
00177
00178 void METProducer::produce_TCMET(edm::Event& event, const edm::EventSetup& setup)
00179 {
00180 std::auto_ptr<reco::METCollection> tcmetcoll;
00181 tcmetcoll.reset(new reco::METCollection);
00182 tcmetcoll->push_back( tcMetAlgo_.CalculateTCMET(event, setup ) ) ;
00183 event.put( tcmetcoll );
00184 }
00185
00186 void METProducer::produce_PFMET(edm::Event& event)
00187 {
00188 edm::Handle<edm::View<reco::Candidate> > input;
00189 event.getByLabel(inputLabel, input);
00190
00191 METAlgo algo;
00192 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00193
00194 PFSpecificAlgo pf;
00195
00196 if( calculateSignificance_ )
00197 {
00198 edm::Handle<edm::View<reco::PFJet> > jets;
00199 event.getByLabel(jetsLabel_, jets);
00200 pf.runSignificance(*resolutions_, jets);
00201 }
00202
00203 std::auto_ptr<reco::PFMETCollection> pfmetcoll;
00204 pfmetcoll.reset(new reco::PFMETCollection);
00205 pfmetcoll->push_back( pf.addInfo(input, commonMETdata) );
00206 event.put( pfmetcoll );
00207 }
00208
00209 void METProducer::produce_PFClusterMET(edm::Event& event)
00210 {
00211 edm::Handle<edm::View<reco::Candidate> > input;
00212 event.getByLabel(inputLabel, input);
00213
00214 METAlgo algo;
00215 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00216
00217 PFClusterSpecificAlgo pfcluster;
00218 std::auto_ptr<reco::PFClusterMETCollection> pfclustermetcoll;
00219 pfclustermetcoll.reset (new reco::PFClusterMETCollection);
00220
00221 pfclustermetcoll->push_back( pfcluster.addInfo(input, commonMETdata) );
00222 event.put( pfclustermetcoll );
00223 }
00224
00225 void METProducer::produce_GenMET(edm::Event& event)
00226 {
00227 edm::Handle<edm::View<reco::Candidate> > input;
00228 event.getByLabel(inputLabel, input);
00229
00230 CommonMETData commonMETdata;
00231
00232 GenSpecificAlgo gen;
00233 std::auto_ptr<reco::GenMETCollection> genmetcoll;
00234 genmetcoll.reset (new reco::GenMETCollection);
00235 genmetcoll->push_back( gen.addInfo(input, &commonMETdata, globalThreshold, onlyFiducial, usePt) );
00236 event.put( genmetcoll );
00237 }
00238
00239 void METProducer::produce_else(edm::Event& event)
00240 {
00241 edm::Handle<edm::View<reco::Candidate> > input;
00242 event.getByLabel(inputLabel, input);
00243
00244 CommonMETData commonMETdata;
00245
00246 METAlgo algo;
00247 algo.run(input, &commonMETdata, globalThreshold);
00248
00249 math::XYZTLorentzVector p4( commonMETdata.mex, commonMETdata.mey, 0.0, commonMETdata.met);
00250 math::XYZPoint vtx(0,0,0);
00251 reco::MET met( commonMETdata.sumet, p4, vtx );
00252 std::auto_ptr<reco::METCollection> metcoll;
00253 metcoll.reset(new reco::METCollection);
00254 metcoll->push_back( met );
00255 event.put( metcoll );
00256 }
00257
00258 }