Skip to content

Commit

Permalink
Improving SyncTreeProducer 1.2
Browse files Browse the repository at this point in the history
Added AnalyzerData container and Cutter for efficiencies
  • Loading branch information
clacaputo committed Oct 26, 2015
1 parent 464aa98 commit de0c9bf
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions microAODProduction/plugins/SyncTreeProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,25 @@
//HHbbTauTau Framework
#include "HHbbTauTau/AnalysisBase/include/SyncTree.h"
#include "HHbbTauTau/TreeProduction/interface/Tau.h"
#include "AnalysisBase/include/AnalyzerData.h"
#include "AnalysisBase/include/CutTools.h"
#include "Analysis/include/SelectionResults.h"

#include "TTree.h"
#include "Math/VectorUtil.h"


//Analyzer Data Class
namespace analisys {
class SyncAnalyzerData : public root_ext::AnalyzerData {
public:
BaseAnalyzerData(std::shared_ptr<TFile> outputFile) : AnalyzerData(outputFile) {}

SELECTION_ENTRY(Selection)

};
}

//
// class declaration
//
Expand All @@ -84,6 +99,8 @@ class SyncTreeProducer : public edm::EDAnalyzer {
//virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
//virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;

analysis::SyncAnalyzerData& GetAnaData() override { return anaData; }

int matchToTruth(const edm::Ptr<reco::GsfElectron> el,
const edm::Handle<edm::View<reco::GenParticle>> &genParticles);

Expand Down Expand Up @@ -111,6 +128,8 @@ class SyncTreeProducer : public edm::EDAnalyzer {
edm::EDGetToken tausMiniAODToken_;

ntuple::SyncTree syncTree;

analisys::SyncAnalyzerData anaData;
};

//
Expand All @@ -126,7 +145,8 @@ class SyncTreeProducer : public edm::EDAnalyzer {
//
SyncTreeProducer::SyncTreeProducer(const edm::ParameterSet& iConfig):
tausMiniAODToken_(mayConsume<edm::View<pat::Tau> >(iConfig.getParameter<edm::InputTag>("tauSrc"))),
syncTree(&edm::Service<TFileService>()->file(),false)
syncTree(&edm::Service<TFileService>()->file(),false),
anaData(&edm::Service<TFileService>()->file(),"Taus")
{

genParticlesMiniAODToken_ = mayConsume<edm::View<reco::GenParticle> >
Expand Down Expand Up @@ -157,6 +177,8 @@ SyncTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
using namespace edm;
using namespace reco;

cuts::Cutter cut(&GetAnaData().Selection("events"));

// Save global info right away
syncTree.run() = iEvent.id().run();
syncTree.lumi() = iEvent.id().luminosityBlock();
Expand All @@ -171,6 +193,9 @@ SyncTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
//Usare ntuple::Muon e Tau definiti in TreeProduction in modo da poter utilizzare i metodi del BaseAnalyzer
ntuple::TauVector tausV;

try{

cut(true,"events");
for (const pat::Tau &tau : *taus){
ntuple::Tau tmp_tau;

Expand All @@ -190,8 +215,11 @@ SyncTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu

}

if(!tausV.size()) return;
std::cout<<"Taus size: "<<tausV.size()<<std::endl;
//if(!tausV.size()) return;
cut(tausV.size(),"taus");
std::cout<<"Taus size: "<<tausV.size()<<std::endl;
}catch(cuts::cut_failed&){}

syncTree.pt_1() = tausV.at(0).pt;
syncTree.Fill();

Expand Down

0 comments on commit de0c9bf

Please sign in to comment.