/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
PhysicsTools/PatExamples/bin/PatBasicFWLiteAnalyzer.py
44 строки
931 B
Shahzad Malik Muzaffar
[ANALYSIS] py2/3 compatibility:drop use of __future__
22 ноя 2024, 20:16
22 ноя 2024, 20:16
8d027cc
Код
Авторство
О чём код?
#! /usr/bin/env python import ROOT import sys from DataFormats.FWLite import Events, Handle files = ["patTuple.root"] events = Events (files) handle = Handle ("std::vector<pat::Muon>") # for now, label is just a tuple of strings that is initialized just # like and edm::InputTag label = ("cleanPatMuons") f = ROOT.TFile("analyzerPython.root", "RECREATE") f.cd() muonPt = ROOT.TH1F("muonPt", "pt", 100, 0.,300.) muonEta = ROOT.TH1F("muonEta","eta", 100, -3., 3.) muonPhi = ROOT.TH1F("muonPhi","phi", 100, -5., 5.) # loop over events i = 0 for event in events: i = i + 1 print(i) # use getByLabel, just like in cmsRun event.getByLabel (label, handle) # get the product muons = handle.product() for muon in muons : muonPt.Fill( muon.pt() ) muonEta.Fill( muon.eta() ) muonPhi.Fill( muon.phi() ) f.cd() muonPt.Write() muonEta.Write() muonPhi.Write() f.Close()