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.getParameter<bool>("usePt");
00074 applyFiducialThresholdForFractions = iConfig.getParameter<bool>("applyFiducialThresholdForFractions");
00075 produces<reco::GenMETCollection>().setBranchAlias(alias.c_str());
00076 }
00077 else if( METtype == "PFMET" )
00078 {
00079 produces<reco::PFMETCollection>().setBranchAlias(alias.c_str());
00080
00081 calculateSignificance_ = iConfig.getParameter<bool>("calculateSignificance");
00082
00083 if(calculateSignificance_)
00084 {
00085 jetsLabel_ = iConfig.getParameter<edm::InputTag>("jets");
00086 }
00087
00088 }
00089 else if( METtype == "PFClusterMET" )
00090 {
00091 produces<reco::PFClusterMETCollection>().setBranchAlias(alias.c_str());
00092 }
00093 else if (METtype == "TCMET" )
00094 {
00095 produces<reco::METCollection>().setBranchAlias(alias.c_str());
00096
00097 int rfType_ = iConfig.getParameter<int>("rf_type");
00098 bool correctShowerTracks_ = iConfig.getParameter<bool>("correctShowerTracks");
00099
00100 int responseFunctionType = 0;
00101 if(! correctShowerTracks_)
00102 {
00103 if( rfType_ == 1 ) responseFunctionType = 1;
00104 else if( rfType_ == 2 ) responseFunctionType = 2;
00105 else { }
00106 }
00107 tcMetAlgo_.configure(iConfig, responseFunctionType );
00108 }
00109 else
00110 produces<reco::METCollection>().setBranchAlias(alias.c_str());
00111
00112 if (calculateSignificance_ && ( METtype == "CaloMET" || METtype == "PFMET")){
00113 resolutions_ = new metsig::SignAlgoResolutions(iConfig);
00114
00115 }
00116 }
00117
00118
00119 void METProducer::produce(edm::Event& event, const edm::EventSetup& setup)
00120 {
00121 if( METtype == "CaloMET" )
00122 {
00123 produce_CaloMET(event);
00124 return;
00125 }
00126
00127 if( METtype == "TCMET" )
00128 {
00129 produce_TCMET(event, setup);
00130 return;
00131 }
00132
00133 if( METtype == "PFMET" )
00134 {
00135 produce_PFMET(event);
00136 return;
00137 }
00138
00139 if( METtype == "PFClusterMET" )
00140 {
00141 produce_PFClusterMET(event);
00142 return;
00143 }
00144
00145 if( METtype == "GenMET" )
00146 {
00147 produce_GenMET(event);
00148 return;
00149 }
00150
00151 produce_else(event);
00152 }
00153
00154 void METProducer::produce_CaloMET(edm::Event& event)
00155 {
00156 edm::Handle<edm::View<reco::Candidate> > input;
00157 event.getByLabel(inputLabel, input);
00158
00159 METAlgo algo;
00160 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00161
00162 CaloSpecificAlgo calospecalgo;
00163 reco::CaloMET calomet = calospecalgo.addInfo(input, commonMETdata, noHF, globalThreshold);
00164
00165 if( calculateSignificance_ )
00166 {
00167 SignCaloSpecificAlgo signcalospecalgo;
00168 signcalospecalgo.calculateBaseCaloMET(input, commonMETdata, *resolutions_, noHF, globalThreshold);
00169 calomet.SetMetSignificance(signcalospecalgo.getSignificance() );
00170 calomet.setSignificanceMatrix(signcalospecalgo.getSignificanceMatrix());
00171 }
00172
00173 std::auto_ptr<reco::CaloMETCollection> calometcoll;
00174 calometcoll.reset(new reco::CaloMETCollection);
00175 calometcoll->push_back( calomet ) ;
00176 event.put( calometcoll );
00177 }
00178
00179 void METProducer::produce_TCMET(edm::Event& event, const edm::EventSetup& setup)
00180 {
00181 std::auto_ptr<reco::METCollection> tcmetcoll;
00182 tcmetcoll.reset(new reco::METCollection);
00183 tcmetcoll->push_back( tcMetAlgo_.CalculateTCMET(event, setup ) ) ;
00184 event.put( tcmetcoll );
00185 }
00186
00187 void METProducer::produce_PFMET(edm::Event& event)
00188 {
00189 edm::Handle<edm::View<reco::Candidate> > input;
00190 event.getByLabel(inputLabel, input);
00191
00192 METAlgo algo;
00193 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00194
00195 PFSpecificAlgo pf;
00196
00197 if( calculateSignificance_ )
00198 {
00199 edm::Handle<edm::View<reco::PFJet> > jets;
00200 event.getByLabel(jetsLabel_, jets);
00201 pf.runSignificance(*resolutions_, jets);
00202 }
00203
00204 std::auto_ptr<reco::PFMETCollection> pfmetcoll;
00205 pfmetcoll.reset(new reco::PFMETCollection);
00206 pfmetcoll->push_back( pf.addInfo(input, commonMETdata) );
00207 event.put( pfmetcoll );
00208 }
00209
00210 void METProducer::produce_PFClusterMET(edm::Event& event)
00211 {
00212 edm::Handle<edm::View<reco::Candidate> > input;
00213 event.getByLabel(inputLabel, input);
00214
00215 METAlgo algo;
00216 CommonMETData commonMETdata = algo.run(input, globalThreshold);
00217
00218 PFClusterSpecificAlgo pfcluster;
00219 std::auto_ptr<reco::PFClusterMETCollection> pfclustermetcoll;
00220 pfclustermetcoll.reset (new reco::PFClusterMETCollection);
00221
00222 pfclustermetcoll->push_back( pfcluster.addInfo(input, commonMETdata) );
00223 event.put( pfclustermetcoll );
00224 }
00225
00226 void METProducer::produce_GenMET(edm::Event& event)
00227 {
00228 edm::Handle<edm::View<reco::Candidate> > input;
00229 event.getByLabel(inputLabel, input);
00230
00231 CommonMETData commonMETdata;
00232
00233 GenSpecificAlgo gen;
00234 std::auto_ptr<reco::GenMETCollection> genmetcoll;
00235 genmetcoll.reset (new reco::GenMETCollection);
00236 genmetcoll->push_back( gen.addInfo(input, &commonMETdata, globalThreshold, onlyFiducial,applyFiducialThresholdForFractions, usePt) );
00237 event.put( genmetcoll );
00238 }
00239
00240 void METProducer::produce_else(edm::Event& event)
00241 {
00242 edm::Handle<edm::View<reco::Candidate> > input;
00243 event.getByLabel(inputLabel, input);
00244
00245 CommonMETData commonMETdata;
00246
00247 METAlgo algo;
00248 algo.run(input, &commonMETdata, globalThreshold);
00249
00250 math::XYZTLorentzVector p4( commonMETdata.mex, commonMETdata.mey, 0.0, commonMETdata.met);
00251 math::XYZPoint vtx(0,0,0);
00252 reco::MET met( commonMETdata.sumet, p4, vtx );
00253 std::auto_ptr<reco::METCollection> metcoll;
00254 metcoll.reset(new reco::METCollection);
00255 metcoll->push_back( met );
00256 event.put( metcoll );
00257 }
00258
00259 }