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