0. NameOfShortExercise : twiki url 0. NameOfShortExercise :
[[twiki url]]
0. NameOfShortExercise : [[twiki url]]

source /cvmfs/cms.cern.ch/cmsset_default.(c)sh

You will find various METs :

vector<pat::MET>                      "slimmedMETs"               ""                "PAT"     
vector<pat::MET>                      "slimmedMETsEGClean"        ""                "PAT"     
vector<pat::MET>                      "slimmedMETsMuEGClean"      ""                "PAT"     
vector<pat::MET>                      "slimmedMETsNoHF"           ""                "PAT"     
vector<pat::MET>                      "slimmedMETsPuppi"          ""                "PAT"     
vector<pat::MET>                      "slimmedMETsUncorrected"    ""                "PAT"     

run 278874 lumi 9 event 17273331 pt 67.0655 px -28.6796 py -60.624 phi -2.01267
run 278874 lumi 9 event 18359743 pt 89.0266 px 88.8648 py -5.36489 phi -0.0602982
run 278874 lumi 9 event 17841758 pt 165.658 px -25.6357 py 163.663 phi 1.72617
run 278874 lumi 9 event 17433190 pt 133.75 px 132.665 py -17.002 phi -0.127463
run 278874 lumi 9 event 19107519 pt 85.0301 px -34.7823 py -77.5907 phi -1.99222
run 278874 lumi 9 event 17735097 pt 125.61 px 76.4499 py 99.6658 phi 0.916464
run 278874 lumi 9 event 19022152 pt 72.6863 px 46.4467 py -55.9107 phi -0.877596
run 278874 lumi 9 event 17790656 pt 66.2335 px -5.23666 py 66.0262 phi 1.64994
run 278874 lumi 9 event 17233435 pt 58.6413 px 54.363 py -21.9878 phi -0.384347
run 278874 lumi 9 event 18563781 pt 27.6717 px -12.6039 py -24.6347 phi -2.04371

  • run, lumi, event are the run number, the luminosity section, and the event id.
  • met.pt is the magnitude of MET. MET is, in principle, a vector on the px-py plane. However, we often casually call its magnitude MET as well.
  • met.px, met.py are the x and y components of MET respectively.
  • met.phi is the azimuth of MET.

// system include files
#include <memory>
#include <iostream>
#include <vector>
#include <TROOT.h>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/PatCandidates/interface/MET.h"
#include "TLorentzVector.h"
#include "Math/GenVector/LorentzVector.h"

// class declaration
class METAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources>  {
public:
  explicit METAnalyzer(const edm::ParameterSet&);
  ~METAnalyzer();
  
  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
    
private:
  virtual void beginJob() override;
  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
  virtual void endJob() override;
  
  // ----------member data ---------------------------
  edm::InputTag metSrcTag_;
  edm::EDGetTokenT<edm::View<pat::MET>>            metSrcToken_;
  int nEvent;
};

METAnalyzer::METAnalyzer(const edm::ParameterSet& iConfig)
{
  metSrcTag_ = iConfig.getUntrackedParameter<edm::InputTag>("metSrc");
  metSrcToken_ = consumes<edm::View<pat::MET> >(metSrcTag_);

  nEvent=0;
  usesResource("TFileService");
}

METAnalyzer::~METAnalyzer()
{
 
}

// ------------ method called for each event  ------------
void
METAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  using namespace edm;

  edm::Handle<edm::View<pat::MET> > meth;
  iEvent.getByToken(metSrcToken_,meth);
  const pat::MET &met = meth->front();

  // Print event information
  std::cout << "run " << iEvent.id().run()
       << " lumi " << iEvent.id().luminosityBlock()
       << " event " << iEvent.id().event();
  // Print corr MET (default out-of-box)
  std::cout << " pt " <<  met.pt() 
       << " px " <<  met.px() 
       << " py " <<  met.py() 
       << " phi " <<  met.phi() 
       << std::endl;

  nEvent++;
}


// ------------ method called once each job just before starting event loop  ------------
void 
METAnalyzer::beginJob()
{
}

// ------------ method called once each job just after ending the event loop  ------------
void 
METAnalyzer::endJob() 
{
}

// ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
void
METAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
  //The following says we do not know what parameters are allowed so do no validation
  // Please change this to state exactly what you do use, even if it is no parameters
  edm::ParameterSetDescription desc;
  desc.setUnknown();
  descriptions.addDefault(desc);
}

//define this as a plug-in
DEFINE_FWK_MODULE(METAnalyzer);

  • Lesson: use verbatim if you want to have everything printed exactly. For instance:
<pat>
  • Use pre if you want to parse html code, with all that it means about parsing <> (same as above with pre shown here):
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2020-11-09 - MargueriteTonjes
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback