<file_sep>#include <iostream>

#include "TTree.h"
#include "TClonesArray.h"
#include "VHTauTau/TreeMaker/plugins/GenJetBlock.h"
#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

GenJetBlock::GenJetBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("genJetSrc"))
{
}
void GenJetBlock::beginJob() {
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneGenJet = new TClonesArray("vhtm::GenJet");
  tree->Branch("GenJet", &cloneGenJet, 32000, 2);
  tree->Branch("nGenJet", &fnGenJet,  "fnGenJet/I");
}
void GenJetBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneGenJet->Clear();
  fnGenJet = 0;

  if (!iEvent.isRealData()) {
    edm::Handle<reco::GenJetCollection> genJets;
    iEvent.getByLabel(_inputTag, genJets);

    if (genJets.isValid()) {
      edm::LogInfo("GenJetBlock") << "Total # GenJets: " << genJets->size();

      for (reco::GenJetCollection::const_iterator it = genJets->begin(); 
                                                 it != genJets->end(); ++it) {

        if (fnGenJet == kMaxGenJet) {
	  edm::LogInfo("GenJetBlock") << "Too many Gen Jets, fnGenJet = " << fnGenJet; 
	  break;
        }
        genJetB = new ((*cloneGenJet)[fnGenJet++]) vhtm::GenJet();

        // fill in all the vectors
        genJetB->eta    = it->eta();
        genJetB->phi    = it->phi();
        genJetB->p      = it->p();
        genJetB->pt     = it->pt();
        double energy   = it->energy();
        genJetB->energy = energy;
        genJetB->emf    = (energy>0) ? it->emEnergy()/energy : 0;
        genJetB->hadf   = (energy>0) ? it->hadEnergy()/energy : 0;
      }
    } 
    else {
      edm::LogError("GenJetBlock") << "Error >> Failed to get GenJetCollection for label: " 
                                   << _inputTag;
    }
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GenJetBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

triggerBlock = cms.EDAnalyzer("TriggerBlock",
  verbosity = cms.int32(1),
  l1InputTag  = cms.InputTag('gtDigis'),
  hltInputTag = cms.InputTag('TriggerResults','','HLT'),
  hltPathsOfInterest = cms.vstring ("HLT_DoubleMu",
                                    "HLT_Mu",
                                    "HLT_IsoMu", 
                                    "HLT_TripleMu",
                                    "IsoPFTau",
                                    "TrkIsoT", 
                                    "HLT_Ele")
)
<file_sep>#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

namespace {
  struct dictionary {
    vhtm::Event             rv1;
    vhtm::GenEvent          rv2;
    vhtm::Electron          rv3;
    vhtm::GenParticle       rv4;
    vhtm::GenJet            rv5;
    vhtm::GenMET            rv6;
    vhtm::MET               rv7;
    vhtm::Tau               rv8;
    vhtm::Muon              rva;
    vhtm::Jet               rvb;
    vhtm::Vertex            rvd;
    vhtm::Track             rvf;
    vhtm::TriggerObject     rvh;
  };
}
<file_sep>#ifndef __VHTauTau_TreeMaker_MuonBlock_h
#define __VHTauTau_TreeMaker_MuonBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class Muon;

class MuonBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob(){}

public:
  explicit MuonBlock(const edm::ParameterSet& iConfig);
  virtual ~MuonBlock();

  enum {
    kMaxMuon = 100
  };

private:
  TClonesArray* cloneMuon; 
  int  fnMuon;

  int _verbosity;

  edm::InputTag _muonInputTag;
  edm::InputTag _vtxInputTag;
  edm::InputTag _beamSpotInputTag;
  bool _beamSpotCorr;
  std::string _muonID;

  vhtm::Muon* muonB;
};
#endif
<file_sep>void plotres2(){
  hMCMatchBa->SetLineColor(1);
  //h1PtReco->SetLineColor(4);
  //h1PtReco->SetXTitle("GeV/c");
  hMCMatchBa->SetYTitle("Events");
  hMCMatchBa->GetYaxis()->SetTitleOffset(1.3);
  hMCMatchBa->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
  hMCMatchBa->GetXaxis()->SetTitleOffset(1.1);
  hMCMatchBa->Draw();          //draw hist_2 first as it has a larger range
  hMCMatchBa->Draw("c hist same");          //draw hist_2 first as it has a larger range
  c1->SaveAs("plot_res_2.eps");
  c1->SaveAs("plot_res_2.png");
  //h1PtReco->Draw("same");
  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms");
  leg_hist->AddEntry(hMCMatchEC,"Gen Pt","l");
  leg_hist->AddEntry(h1PtReco,"Reco Pt","l");
  leg_hist->Draw();*/
}
<file_sep>./copyfile.sh > copy.sh
sed -e "s|Pythia6_Tauola_GluGluH_tautau_mumu_14TeV_RECOSIM_2019_private_standardpat//cms/data/store/user/amohapat/||" copy.sh >> copy_1.sh ; mv copy_1.sh copy.sh
chmod +x copy.sh
source copy.sh
<file_sep>#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

#define NEL(x) (sizeof((x))/sizeof((x)[0]))

vhtm::Event::Event() :
  run(0), 
  event(0), 
  lumis(0), 
  bunch(0), 
  orbit(0), 
  time(-1), 
  isdata(false), 
  isPhysDeclared(false),
  isBPTX0(false),
  isBSCMinBias(false),
  isBSCBeamHalo(false),
  isPrimaryVertex(false),
  isBeamScraping(false)
{
  nPU.clear();
  bunchCrossing.clear();
  trueNInt.clear();
}

vhtm::GenEvent::GenEvent() :
  processID(0),
  ptHat(-999)
{
  pdfWeights.clear();
}

vhtm::Electron::Electron() :
  eta(-999),
  phi(-999),
  pt(-999),
  ecalDriven(false),
  hasGsfTrack(false),
  trackPt(-999),
  trackPtError(-999),
  energy(-999),
  caloEnergy(-999),
  caloEnergyError(-999),
  charge(-999),
  pixHits(-1),
  trkHits(-1),
  nValidHits(-1),
  trkD0(-999),
  trkD0Error(-999),
  hoe(-999),
  hoeDepth1(-999),
  eop(-999),
  sigmaEtaEta(-999),
  sigmaIEtaIEta(-999),
  deltaPhiTrkSC(-999),
  deltaEtaTrkSC(-999),
  classif(-1),
  e1x5overe5x5(-999),
  e2x5overe5x5(-99), 
  isoEcal03(-999),
  isoHcal03(-999),
  isoTrk03(-999),
  isoEcal04(-999),
  isoHcal04(-999),
  isoTrk04(-999),
  isoRel03(-999),
  isoRel04(-999),
  vx(-999),
  vy(-999),
  vz(-999),
  scEn(-999),
  scEta(-999),
  scPhi(-999),
  scET(-999),
  scRawEnergy(-999),
  vtxDist3D(-999),
  vtxIndex(-1),
  vtxDistZ(-999),
  relIso(-999), 
  pfRelIso(-999), 
  chargedHadronIso(-999),
  neutralHadronIso(-999),
  photonIso(-999),
  missingHits(-1),
  dB(-999),
  edB(-999),
  dB3d(-999),
  edB3d(-999),
  scE1E9(-999),
  scS4S1(-999),
  sckOutOfTime(-999),
  scEcalIso(-999),
  scHEEPEcalIso(-999),
  scHEEPTrkIso(-999),
  nBrems(-1),
  fbrem(-999),
  dist_vec(-999),
  dCotTheta(-99),
  hasMatchedConv(false),
  mva(-999),
  mvaPOGTrig(-999),
  mvaPOGNonTrig(-999),
  mvaPreselection(false),
  isTriggerElectron(false),
  isoMVA(-999),
  pfRelIso03v1(-999),
  pfRelIso03v2(-999),
  pfRelIsoDB03v1(-999),
  pfRelIsoDB03v2(-999),
  pfRelIsoDB03v3(-999),
  pfRelIso04v1(-999),
  pfRelIso04v2(-999),
  pfRelIsoDB04v1(-999),
  pfRelIsoDB04v2(-999),
  pfRelIsoDB04v3(-999),
  pfRelIso03(-999),
  pfRelIso04(-999),
  pfRelIsoDB03(-999),
  pfRelIsoDB04(-999),
  selbit(0),
  fidFlag(0) 
{}

vhtm::GenParticle::GenParticle() :
  eta(-999),
  phi(-999),
  p(-999),
  px(-999),
  py(-999),
  pz(-999),
  pt(-999),
  energy(-999),
  pdgId(-999),
  vx(-999),
  vy(-999),
  vz(-999),
  status(-999),
  charge(-999),
  numDaught(-1),
  numMother(-1),
  motherIndex(-1)
{
  motherIndices.clear();
  daughtIndices.clear();
}

vhtm::GenJet::GenJet() :
  eta(-999),
  phi(-999),
  p(-999),
  pt(-999),
  energy(-999),
  emf(-999),
  hadf(-999) 
{}

vhtm::MET::MET() :
  metx(-999),
  mety(-999),
  met(-999),
  metphi(-999),
  sumet(-999),
  metuncorr(-999),
  metphiuncorr(-999),
  sumetuncorr(-999) 
{}

vhtm::GenMET::GenMET() :
  met(-999),
  metphi(-999),
  sumet(-999) 
{}

vhtm::Tau::Tau():
  eta(-999),
  phi(-999),
  pt(-999),
  energy(-999),
  charge(-999),
  mass(-999),
  px(-999),
  py(-999),
  pz(-999),
  leadTrkPt(-999),
  leadTrkPtError(-999),
  leadTrkEta(-999),
  leadTrkPhi(-999),
  leadTrkCharge(-999),
  leadTrkD0(-999),
  leadTrkD0Error(-999),
  leadTrkDz(-999),
  leadTrkDzError(-999),
  vtxIndex(-1),
  vtxDxy(-999),
  vtxDz(-999),
  leadChargedParticlePt(-999),
  leadNeutralParticlePt(-999),
  leadParticlePt(-999),
  numChargedHadronsSignalCone(-1),
  numNeutralHadronsSignalCone(-1),
  numPhotonsSignalCone(-1),
  numParticlesSignalCone(-1),
  numChargedHadronsIsoCone(-1),
  numNeutralHadronsIsoCone(-1),
  numPhotonsIsoCone(-1),
  numParticlesIsoCone(-1),
  ptSumPFChargedHadronsIsoCone(-999),
  ptSumPFNeutralHadronsIsoCone(-999),
  ptSumPhotonsIsoCone(-999),

  decayModeFinding(-1),
  decayModeFindingNewDMs(-1),
  decayModeFindingOldDMs(-1),
  chargedIsoPtSum(-1),
  neutralIsoPtSum(-1),
  puCorrPtSum(-1),

CombinedIsolationDeltaBetaCorrRaw3Hits(-1),
  CombinedIsolationDeltaBetaCorrRaw(-1),
  byIsolationMVA3newDMwLTraw(-1),
  byIsolationMVA3newDMwoLTraw(-1),
  byIsolationMVA3oldDMwLTraw(-1),
  byIsolationMVA3oldDMwoLTraw(-1),

  byLooseCombinedIsolationDeltaBetaCorr(-1),
  byLooseCombinedIsolationDeltaBetaCorr3Hits(-1),

  byMediumCombinedIsolationDeltaBetaCorr(-1),
  byMediumCombinedIsolationDeltaBetaCorr3Hits(-1),


  byTightCombinedIsolationDeltaBetaCorr(-1),
  byTightCombinedIsolationDeltaBetaCorr3Hits(-1),

  byLooseIsolationMVA3newDMwLT(-1),
  byLooseIsolationMVA3newDMwoLT(-1),
  byLooseIsolationMva3oldDMwLT(-1),
  byLooseIsolationMVA3oldDMwoLT(-1),

  byMediumIsolationMVA3newDMwLT(-1),

  byMediumIsolationMVA3newDMwoLT(-1),
  byMediumIsolationMva3oldDMwLT(-1),
  byMediumIsolationMVA3oldDMwoLT(-1),

  byTightIsolationMVA3newDMwLT(-1),
  byTightIsolationMVA3newDMwoLT(-1),
  byTightIsolationMva3oldDMwLT(-1),
  byTightIsolationMVA3oldDMwoLT(-1),


      // discriminators against electrons/muons
  againstMuonLoose(-1),      
  againstMuonLoose2(-1),     
  againstMuonLoose3(-1),     
  againstMuonLooseMVA(-1),   
  againstMuonTight(-1),
  
  againstMuonTight2(-1),    
  againstMuonTight3(-1),    
  againstMuonTightMVA(-1),  
  againstElectronLoose(-1), 
  againstElectronMedium(-1),
  againstElectronTight(-1),
  pfElectronMVA(-1),        
                            

      // ElectronIDMVA, electron faking tau
  againstElectronMVALooseMVA5(-1),
  againstElectronMVAMediumMVA5(-1),
  againstElectronMVATightMVA5(-1), 

  byVLooseCombinedIsolationDeltaBetaCorr(-1),
     
   
      // MVA based isolation
  byLooseIsolationMVA(-1),                   
  byMediumIsolationMVA(-1),                  
  byTightIsolationMVA(-1),                  



 


  jetPt(-999),
  jetEta(-999),
  jetPhi(-999),
  emFraction(-999),
  maximumHCALPFClusterEt(-999),
  ecalStripSumEOverPLead(-999),
  bremsRecoveryEOverPLead(-999),
  hcalTotOverPLead(-999),
  hcalMaxOverPLead(-999),
  hcal3x3OverPLead(-999),
  etaetaMoment(-999),
  phiphiMoment(-999),
  etaphiMoment(-999),
  vx(-999), vy(-999), vz(-999),
  zvertex(-999), ltsipt(-999),
  selbit(0) 
{
  for (int i = 0; i < kMaxPFChargedCand; ++i) {
    sigChHadCandPt[i] = sigChHadCandEta[i] = sigChHadCandPhi[i] = 
    isoChHadCandPt[i] = isoChHadCandEta[i] = isoChHadCandPhi[i] = -10;
  }
  for (int i = 0; i < kMaxPFNeutralCand; ++i) {
    sigNeHadCandPt[i] = sigNeHadCandEta[i] = sigNeHadCandPhi[i] =
    isoNeHadCandPt[i] = isoNeHadCandEta[i] = isoNeHadCandPhi[i] =
    sigGammaCandPt[i] = sigGammaCandEta[i] = sigGammaCandPhi[i] =
    isoGammaCandPt[i] = isoGammaCandEta[i] = isoGammaCandPhi[i] = -10;
  }
}
vhtm::Muon::Muon() :
  isTrackerMuon(false),
  isPFMuon(false),
  ptgen(-999),
  eta(-999),
  phi(-999),
  pt(-999),
  ptError(-999),
  px(-999),
  py(-999),
  pz(-999),
  energy(-999),
  charge(-999),
  trkD0(-999),
  trkD0Error(-999),
  trkDz(-999),
  trkDzError(-999),
  globalChi2(-999),
  
  trkIso(-999),
  ecalIso(-999),
  hcalIso(-999),
  hoIso(-999),
  relIso(-999),
  passID(false),
  vtxDist3D(-999),
  vtxIndex(-1),
  vtxDistZ(-999),
  pixHits(-1),
  trkHits(-1),
  muoHits(-1),
  matches(-1),
  trackerLayersWithMeasurement(-1),
  pfRelIso(-999),
  vx(-999),
  vy(-999),
  vz(-999),
  dB(-999), 
  edB(-999),
  dB3d(-999),
  edB3d(-999),
  isGlobalMuonPromptTight(false),
  isAllArbitrated(false),
  nChambers(-1),
  nMatches(-1),
  nMatchedStations(-1),
  stationMask(0),
  stationGapMaskDistance(0),
  stationGapMaskPull(0),
  muonID(-1), 
  idMVA(-999),
  isoRingsMVA(-999),
  isoRingsRadMVA(-999),
  idIsoCombMVA(-999),
  pfRelIso03v1(-999),
  pfRelIso03v2(-999),
  pfRelIsoDB03v1(-999),
  pfRelIsoDB03v2(-999),
  pfRelIso04v1(-999),
  pfRelIso04v2(-999),
  pfRelIsoDB04v1(-999),
  pfRelIsoDB04v2(-999),
  selbit(0)
{}

vhtm::Jet::Jet() :
  eta(-999),
  phi(-999),
  pt(-999),
  pt_raw(-999),
  energy(-999),
  energy_raw(-999),
  jecUnc(-999),
  resJEC(-999),
  partonFlavour(-1),
  puIdMVA(-999),
  puIdFlag(-1),
  puIdBits(-1),
  chargedEmEnergyFraction(-999),
  chargedHadronEnergyFraction(-999),
  chargedMuEnergyFraction(-999),
  electronEnergyFraction(-999),
  muonEnergyFraction(-999),
  neutralEmEnergyFraction(-999),
  neutralHadronEnergyFraction(-999),
  photonEnergyFraction(-999),
  chargedHadronMultiplicity(-1),
  chargedMultiplicity(-1),
  electronMultiplicity(-1),
  muonMultiplicity(-1),
  neutralHadronMultiplicity(-1),
  neutralMultiplicity(-1),
  photonMultiplicity(-1),
  nConstituents(-1),
  trackCountingHighEffBTag(-999),
  trackCountingHighPurBTag(-999),
  simpleSecondaryVertexHighEffBTag(-999),
  simpleSecondaryVertexHighPurBTag(-999),
  jetProbabilityBTag(-999),
  jetBProbabilityBTag(-999),
  combinedSecondaryVertexBTag(-999),
  combinedSecondaryVertexMVABTag(-999),
  combinedInclusiveSecondaryVertexBTag(-999),
  combinedMVABTag(-999),
  passLooseID(-1),
  passTightID(-1),
  selbit(0) {}

vhtm::Vertex::Vertex() :
  x(-999),
  y(-999),
  z(-999),
  xErr(-999),
  yErr(-999),
  zErr(-999),
  rho(-999),
  chi2(-999),
  ndf(-1),
  ntracks(-1),
  ntracksw05(-1),
  isfake(true),
  isvalid(false),
  sumPt(-999),
  selbit(0) {}

vhtm::Track::Track()
  : eta(-999),
    etaError(-999),
    theta(-999),
    thetaError(-999),
    phi(-999),
    phiError(-999),
    p(-999),
    pt(-999),
    ptError(-999),
    qoverp(-999),
    qoverpError(-999),
    charge(-999),
    nValidHits(-1),
    nLostHits(-1),
    validFraction(-999),
    nValidTrackerHits(-1),
    nValidPixelHits(-1),
    nValidStripHits(-1),
    trackerLayersWithMeasurement(-1),
    pixelLayersWithMeasurement(-1),
    stripLayersWithMeasurement(-1),
    dxy(-999),
    dxyError(-999),
    dz(-999),
    dzError(-999),
    chi2(-999),
    ndof(-1),
    vx(-999), vy(-999), vz(-999),
    selbit(0) {}

vhtm::TriggerObject::TriggerObject() :
  energy(-999),
  pt(-999),
  eta(-999),
  phi(-999)
{
  pathList.clear();
}
<file_sep>import FWCore.ParameterSet.Config as cms

process = cms.Process("PAT")

## MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")

## Options and Output Report
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )

## Source
process.source = cms.Source("PoolSource",
                                fileNames = cms.untracked.vstring()
                            )
## Maximal Number of Events
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )

## Geometry and Detector Conditions (needed for a few patTuple production steps)
process.load('Configuration.Geometry.GeometryExtended2019Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2019_cff')

process.load('Configuration.StandardSequences.MagneticField_38T_cff')

#process.load("RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi")

process.load('Configuration.StandardSequences.Services_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
#process.GlobalTag.globaltag = 'STAR17_61_V5A::All'
#process.GlobalTag.globaltag = 'DES17_61_V4::All'

process.GlobalTag.globaltag = 'DES19_62_V8::All'
process.load("Configuration.StandardSequences.MagneticField_cff")

## Output Module Configuration (expects a path 'p')

from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning
process.out = cms.OutputModule("PoolOutputModule",
                                                              fileName = cms.untracked.string('patTuple.root'),
                                                              ## save only events passing the full path
                                                              #SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),
                                                              ## save PAT output; you need a '*' to unpack the list of commands
                                                              ## 'patEventContent'
                                                              outputCommands = cms.untracked.vstring('drop *', *patEventContentNoCleaning )
                                                              )

process.outpath = cms.EndPath(process.out)

#from PhysicsTools.PatAlgos.mcMatchLayer0 import *
#process.load("PhysicsTools.PatAlgos.patSequences_cff")
#process.load('PhysicsTools.PatAlgos.mcMatchLayer0.muonMatch_cfi')
process.load('PhysicsTools.PatAlgos.producersLayer1.muonProducer_cff')
#process.muMatch1 = process.muonMatch.clone(mcStatus = [1])

# verbose flags for the PF2PAT modules
process.options.allowUnscheduled = cms.untracked.bool(True)
#process.Tracer = cms.Service("Tracer")


# Configure PAT to use PF2PAT instead of AOD sources
# this function will modify the PAT sequences.
from PhysicsTools.PatAlgos.tools.pfTools import *
postfix = "PFlow"
jetAlgo="AK5"
usePF2PAT(process,runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=True, postfix=postfix)


# to turn on type-1 MET corrections, use the following call
#usePF2PAT(process,runPF2PAT=True, jetAlgo=jetAlgo, runOnMC=True, postfix=postfix, typeIMetCorrections=True)

# to switch default tau (HPS) to old default tau (shrinking cone) uncomment
# the following:
# note: in current default taus are not preselected i.e. you have to apply
# selection yourself at analysis level!
#adaptPFTaus(process,"shrinkingConePFTau",postfix=postfix)

# Add PF2PAT output to the created file
from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning
#process.load("CommonTools.ParticleFlow.PF2PAT_EventContent_cff")
#process.out.outputCommands =  cms.untracked.vstring('drop *')
process.out.outputCommands = cms.untracked.vstring('drop *',
                                                   'keep recoPFCandidates_particleFlow_*_*',
						   'keep *_selectedPatJets*_*_*',
						   'drop *_selectedPatJets*_caloTowers_*',
						   'keep *_selectedPatElectrons*_*_*',
						   'keep *_selectedPatMuons*_*_*',
						   'keep *_selectedPatTaus*_*_*',
						   'keep *_patMETs*_*_*',
						   'keep *_selectedPatPhotons*_*_*',
						   'keep *_selectedPatTaus*_*_*',
                                                   'keep *_generalTracks_*_*',
                                                   'keep *_genParticles_*_*',
                                                   'keep *_offlineBeamSpot_*_*',
                                                   'keep *_offlinePrimaryVertices_*_*',
                                                   'keep *_gtDigis_*_*'
                                                   )


# top projections in PF2PAT:
#getattr(process,"pfNoPileUp"+postfix).enable = True
#getattr(process,"pfNoMuon"+postfix).enable = True
#getattr(process,"pfNoElectron"+postfix).enable = True
#getattr(process,"pfNoTau"+postfix).enable = False
#getattr(process,"pfNoJet"+postfix).enable = True
# to use tau-cleaned jet collection uncomment the following:
#getattr(process,"pfNoTau"+postfix).enable = True

# verbose flags for the PF2PAT modules
#getattr(process,"pfNoMuon"+postfix).verbose = False

# enable delta beta correction for muon selection in PF2PAT?
#getattr(process,"pfIsolatedMuons"+postfix).doDeltaBetaCorrection = cms.bool(False)
#MCTruthMatching
#getattr(process,muMatch1).enable = True
process.p=cms.Path(
    process.muonMatch +
    getattr(process,"pfNoPileUp"+postfix)+
    getattr(process,"pfNoMuon"+postfix)+
    getattr(process,"pfNoElectron"+postfix)+
    #getattr(process,"pfNoTau"+postfix).enable =
    getattr(process,"pfNoJet"+postfix)
    #process.analyzePatMCMatching
    )

#process.patDefaultSequence.replace(process.patDefaultSequence,
#    getattr(process,"pfNoPileUp"+postfix)+
#    getattr(process,"pfNoMuon"+postfix)+
#    getattr(process,"pfNoElectron"+postfix)+
    #getattr(process,"pfNoTau"+postfix).enable =
#    getattr(process,"pfNoJet"+postfix)
#    process.muonMatch
#    )

#process.p=cms.Path(process.patDefaultSequence)


## ------------------------------------------------------
#  In addition you usually want to change the following
#  parameters:
## ------------------------------------------------------
#
#   process.GlobalTag.globaltag =  ...    ##  (according to https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFrontierConditions)
#                                         ##
#from PhysicsTools.PatAlgos.patInputFiles_cff import filesRelValProdTTbarAODSIM
#process.source.fileNames = filesRelValProdTTbarAODSIM
process.source = cms.Source("PoolSource",
                            fileNames = cms.untracked.vstring(
    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_100_1_uUb.root'
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_101_1_2qJ.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_102_2_Rqu.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_103_1_d85.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_104_1_yTR.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_105_1_BFe.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_106_1_z6e.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_107_1_bhH.root',
#    'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluGluH_tautau_14TeV_620slhc5_v5_gaussBeamSpot_108_3_AIL.root'
    )
                            )

#                                         ##
#process.maxEvents.input = 10
#                                         ##
#   process.out.outputCommands = [ ... ]  ##  (e.g. taken from PhysicsTools/PatAlgos/python/patEventContent_cff.py)
#                                         ##
process.out.fileName = 'patTuple_PF2PAT.root'
#                                         ##
#   process.options.wantSummary = False   ##  (to suppress the long output at the end of the job)
<file_sep>#ifndef __VHTauTau_TreeMaker_GenEventBlock_h
#define __VHTauTau_TreeMaker_GenEventBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class GenEvent;

class GenEventBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup);
  virtual void endJob() {}

public:
  explicit GenEventBlock(const edm::ParameterSet& iConfig);
  virtual ~GenEventBlock();

private:
  TClonesArray* cloneGenEvent; 
  int _verbosity;

  const edm::InputTag _genEvtInfoInputTag;
  const bool          _storePDFWeights;
  const edm::InputTag _pdfWeightsInputTag;

  std::vector<double> *_pdfWeights;

  vhtm::GenEvent* genEventB;
};
#endif
<file_sep>#include "TPaveStats.h"

void plot_dimuoneta(){
  //TCanvas *c1 = new TCanvas("c1","c1",59,80,1288,535);
  //c1->Divide(3,1);
  //c1->cd(1);
  h1DiMuonPtReco->SetLineColor(1);
  h1SumMuonPtReco->SetLineColor(4);
  h1DiMuonPtReco->SetXTitle("Reco. Muon p_{T} in GeV/c");
  h1SumMuonPtReco->SetXTitle("Reco. Muon p_{T} in GeV/c");
  h1DiMuonPtReco->SetYTitle("Number of Events/GeV");
  h1SumMuonPtReco->SetYTitle("Number of Events/GeV");
  //h1SumMuonPtReco->GetXaxis()->SetTitleOffset(1.4);
  //h1DiMuonPtReco->GetXaxis()->SetTitleOffset(1.4);

  h1SumMuonPtReco->Draw();
  gPad->Update();
  h1DiMuonPtReco->Draw();          //draw hist_2 first as it has a larger range
  gPad->Update();


  TPaveStats *tps1 = (TPaveStats*) h1DiMuonPtReco->FindObject("stats");
  tps1->SetName("Hist1 Stats");
  double X1 = tps1->GetX1NDC();
  double Y1 = tps1->GetY1NDC();
  double X2 = tps1->GetX2NDC();
  double Y2 = tps1->GetY2NDC();

  TPaveStats *tps2 = (TPaveStats*) h1SumMuonPtReco->FindObject("stats");
  tps2->SetTextColor(kRed);
  tps2->SetLineColor(kRed);
  tps2->SetX1NDC(X1);
  tps2->SetX2NDC(X2);
  tps2->SetY1NDC(Y1-(Y2-Y1));
  tps2->SetY2NDC(Y1);

  
  
  h1DiMuonPtReco->Draw();
  h1SumMuonPtReco->Draw("same");          //draw hist_2 first as it has a larger range

  tps2->Draw("same");
  tps1->Draw("same");

  leg_hist = new TLegend(0.4770115,0.6038136,0.7658046,0.7923729);
  leg_hist->SetHeader("p_{T} histograms");
  leg_hist->SetFillColor(0);
  leg_hist->AddEntry(h1DiMuonPtReco,"Di muon p_{T}","l");
  leg_hist->AddEntry(h1SumMuonPtReco,"Sum of the muon p_{T}","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();
  
  c1->SaveAs("muonpt.png");
  
}
<file_sep>import FWCore.ParameterSet.Config as cms

genParticleBlock = cms.EDAnalyzer("GenParticleBlock",
  verbosity      = cms.int32(0),
  genParticleSrc = cms.InputTag('genParticles')
)
<file_sep>import FWCore.ParameterSet.Config as cms
process = cms.Process("HTauTauTree")
#------------------------
# Message Logger Settings
#------------------------
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1
#--------------------------------------
# Event Source & # of Events to process
#---------------------------------------
process.source = cms.Source("PoolSource",
                            fileNames = cms.untracked.vstring()
                            )
process.maxEvents = cms.untracked.PSet(
    input = cms.untracked.int32(-1)
    )
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )

#-----------------------------
# Geometry
#-----------------------------
process.load("Configuration.StandardSequences.Geometry_cff")
#-----------------------------
# Magnetic Field
#-----------------------------
process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
#-------------
# Global Tag
#-------------
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag = 'START53_V11::All'
#-------------
# Output ROOT file
#-------------
process.TFileService = cms.Service("TFileService",
                                   fileName = cms.string('test_higgs.root')
                                   )
#--------------------------------------------------
# VHTauTau Tree Specific
#--------------------------------------------------
process.load("VHTauTau.TreeMaker.TreeCreator_cfi")
process.load("VHTauTau.TreeMaker.TreeWriter_cfi")
process.load("VHTauTau.TreeMaker.TreeContentConfig_cff")

#-------------------------------------------------------
# PAT 
#------------------------------------------------------
process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
process.load("PhysicsTools.PatAlgos.patSequences_cff")

#import PhysicsTools.PatAlgos.tools.tauTools as tauTools
#tauTools.switchToPFTauHPS(process) # For HPS Taus

## --
## Switch on PAT trigger
## --
import PhysicsTools.PatAlgos.tools.trigTools as trigTools
trigTools.switchOnTrigger( process, outputModule='' ) # This is optional and can be omitted.

process.p = cms.Path(
  process.treeCreator +
  process.treeContentSequence +
  process.treeWriter
)

# List File names here
#---------------------------------------
process.PoolSource.fileNames = [
'file:./patTuple_higgs.root' 
]
<file_sep>void plot_accept_pt_3d_graph(){
  //h2->SetLineColor(1);
  
  TTree *MyTree = new TTree("MyTree", "MyTree");
  MyTree->ReadFile("acceptance2.file", "lead:sublead:weight");
  //MyTree->SetEstimate(MyTree->GetEntries());
  MyTree->Draw("sublead:lead:weight>>htemp", "", "COLZ");
  //htemp->Rebin(0.5);
  //cout<<htemp->GetAize
  htemp->SetXTitle("Reco leading muon p_{T} in GeV/c");
  htemp->SetYTitle("Reco subleading muon p_{T} in GeV/c");
  htemp->SetTitle("2-D acceptance plot");
  htemp->SetStats(0);
  htemp->Draw("COLZ");
  c1->SaveAs("acceptance_2d_100.png");
  //gROOT->ProcessLine(".q");
}
<file_sep>void ratio(){
  TFile* f1= new TFile("histos_signal.root");
  TH1F *h1=(TH1F*)f1->Get("h1DiMuonEtaReco");
  
  TFile* f2=new TFile("/home/amohapatra/work/CMSSW_6_2_0_SLHC12/src/bkg_dymu_pu_50/histos_bkg.root");
  TH1F *h2=(TH1F*)f2->Get("h1DiMuonEtaReco");
  //h2->Draw("COLZ");
  //TH2F *h3 = new TH2F("h3","S/B acceptance plot ",120,0,30,102,0,30);
    
  h1->SetLineColor(1);
  h2->SetLineColor(4);


  h1->SetStats(0);  
  h2->SetStats(0);  
  h1->SetTitle("Dimuon Eta");
  h1->SetXTitle("Dimuon Eta for reco muons");
  //h1->GetXaxis()->SetTitleOffset(1.44);
  h1->SetYTitle("Events");
  //h1->GetYaxis()->SetTitleOffset(1.44);
  //h1->SetZTitle("Ratio");
  
  h1->Draw();
  h2->Draw("SAME");
  
  leg_hist = new TLegend(0.4770115,0.6038136,0.7658046,0.7923729);
  leg_hist->SetFillColor(0);
  leg_hist->AddEntry(h1,"Signal","l");
  leg_hist->AddEntry(h2,"Background","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();


  c1->SaveAs("dimuon_eta.png");
  //h2->Draw("SAME");
}
  
  
  
<file_sep>import FWCore.ParameterSet.Config as cms

metBlock = cms.EDAnalyzer("METBlock",
                          verbosity = cms.int32(0),
                          metSrc    = cms.InputTag('patMETsPFlow'),
                          #metSrc    = cms.InputTag('patMETs')
  #metSrc    = cms.InputTag('patPFMETsTypeIcorrected'), 
                          #corrmetSrc = cms.InputTag('patPFMETsTypeIcorrected'),
                          #mvametSrc = cms.InputTag('patPFMETsTypeIcorrected')  
                          )
<file_sep>void plot_int_3(){
  
  hLeadMuon3->ComputeIntegral();
  Double_t *integral = (hLeadMuon3->GetIntegral());
  hLeadMuon3->SetContent(integral);
  //TH1F *hLeadMuon3=1-(*hLeadMuon3);
  //TH1F *hLeadMuon3i = new TH1F("hLeadMuon3i","histogram with 1 as entries",100,0,60);
  Int_t binsize=hLeadMuon3->GetSize();
  for (int i=1;i<binsize-1;i++){
    Double_t entry=hLeadMuon3->GetBinContent(i);
    hLeadMuon3->SetBinContent(i,1-entry);
  }

  hSubLeadMuon3->ComputeIntegral();
  Double_t *integral = (hSubLeadMuon3->GetIntegral());
  hSubLeadMuon3->SetContent(integral);
  binsize=hSubLeadMuon3->GetSize();
  //hSubLeadMuon3=1-(*hSubLeadMuon3);
  for (int i=1;i<binsize-1;i++){
    entry=hSubLeadMuon3->GetBinContent(i);
    hSubLeadMuon3->SetBinContent(i,1-entry);
  }


  hLeadMuon3->SetLineColor(1);
  hSubLeadMuon3->SetLineColor(4);
  hLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
  hSubLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
  hLeadMuon3->SetYTitle("Kinematic Acceptance");
  hSubLeadMuon3->SetYTitle("Kinematic Acceptance");
  
  hSubLeadMuon3->Draw();
  
  hLeadMuon3->Draw("same");          //draw hist_2 first as it has a larger range
  
  
  leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 3");
  leg_hist->AddEntry(hLeadMuon3,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon3,"subleading muon pt","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();

  //c1->SaveAs("case1.png");
  
}
<file_sep>void plot_imp_par_Ba(){
  hImPEC->SetLineColor(1);
  //h1PtReco->SetLineColor(4);
  //h1PtReco->SetXTitle("GeV/c");
  hImPBa->SetYTitle("Events");
  hImPBa->GetYaxis()->SetTitleOffset(1.35);
  hImPBa->SetXTitle("d_{xy} in cm");
  hImPBa->Draw();          //draw hist_2 first as it has a larger range
  hImPBa->Draw("c hist same");          //draw hist_2 first as it has a larger range
  c1->SaveAs("plot_imp_2.eps");
  c1->SaveAs("plot_imp_2.png");
  //h1PtReco->Draw("same");
  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms");
  leg_hist->AddEntry(hImPEC,"Gen Pt","l");
  leg_hist->AddEntry(h1PtReco,"Reco Pt","l");
  leg_hist->Draw();*/
}
<file_sep>void plot_int_2d_1(){
  TH3F *h2 = new TH3F("h2","acceptance plot",100,0,60,100,0,60,100,0,1);  
  Double_t weight=0.;
  hLeadMuon1->ComputeIntegral();
  Double_t *integral = (hLeadMuon1->GetIntegral());
  hLeadMuon1->SetContent(integral);
  Int_t binsize=hLeadMuon1->GetSize();
  for (int i=1;i<binsize-1;i++){
    Double_t entry=hLeadMuon1->GetBinContent(i);
    hLeadMuon1->SetBinContent(i,1-entry);
  }

  hSubLeadMuon1->ComputeIntegral();
  Double_t *integral = (hSubLeadMuon1->GetIntegral());
  hSubLeadMuon1->SetContent(integral);
  binsize=hSubLeadMuon1->GetSize();
  
  for (int i=1;i<binsize-1;i++){
    entry=hSubLeadMuon1->GetBinContent(i);
    hSubLeadMuon1->SetBinContent(i,1-entry);
  }
  
  for (int i=1;i<leadmuonpt.size();i++){
    for (int j=1;j<subleadmuonpt.size();j++){
      weight=0;
      int k=hleadMuon1->GetXaxis()->FindBin(leadmuonpt[i]);
      int m=hSubLeadMuon1->GetXaxis()->FindBin(subleadmuonpt[j]);
      if (hLeadMuon1->GetBinContent(k) < hSubLeadMuon1->GetBinContent(m))
	weight=hLeadMuon1->GetBinContent(k);
      else if (hLeadMuon1->GetBinContent(k) > hSubLeadMuon1->GetBinContent(m))
	weight=hSubLeadMuon1->GetBinContent(m);
      else
	weight=hSubLeadMuon1->GetBinContent(m);
      h2->Fill(leadmuonpt[i],subleadmuonpt[j],weight);
    }
  }
}
<file_sep>import FWCore.ParameterSet.Config as cms

treeWriter = cms.EDAnalyzer("TreeMakerModule",
  verbosity  = cms.int32(0),
  createTree = cms.bool(False)
)
<file_sep>void plot2(){
  hMC
  h1PtGen->SetLineColor(1);
  h1PtReco->SetLineColor(4);
  h1PtReco->SetXTitle("GeV/c");
  h1PtGen->SetXTitle("GeV/c");
  h1PtGen->Draw();          //draw hist_2 first as it has a larger range
  h1PtReco->Draw("same");
  
  leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms");
  leg_hist->AddEntry(h1PtGen,"Gen Pt","l");
  leg_hist->AddEntry(h1PtReco,"Reco Pt","l");
  leg_hist->Draw();
}
<file_sep>#ifndef __VHTauTau_TreeMaker_TrackBlock_h
#define __VHTauTau_TreeMaker_TrackBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class Track;

class TrackBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob(){}

public:
  explicit TrackBlock(const edm::ParameterSet& iConfig);
  virtual ~TrackBlock() {}

  enum {
    kMaxTrack = 200
  };

private:
  TClonesArray* cloneTrack; 
  int  fnTrack;

  int _verbosity;

  edm::InputTag _inputTag;
  edm::InputTag _beamSpot;

  vhtm::Track* trackB;
};
#endif
<file_sep>#ifndef __VHTauTau_TreeMaker_PhysicsObjects_h
#define __VHTauTau_TreeMaker_PhysicsObjects_h

#include <vector>
#include <map>
#include <string>

#include "TObject.h"

namespace vhtm {
  class Event: public TObject {
  public:
    Event();
    ~Event() {}
  
    unsigned int run;
    unsigned int event;
    unsigned int lumis;
    unsigned int bunch;
    unsigned int orbit;
          double time;
            bool isdata;
  
    bool isPhysDeclared;
    bool isBPTX0;
    bool isBSCMinBias;
    bool isBSCBeamHalo;
    bool isPrimaryVertex;
    bool isBeamScraping;
    bool passHBHENoiseFilter;
  
    std::vector<int> nPU;
    std::vector<int> bunchCrossing;
    std::vector<int> trueNInt;
  
    ClassDef(Event,1) 
  };
  class GenEvent: public TObject {
  public:
    GenEvent();
    ~GenEvent() {}
  
    unsigned int processID;
    double ptHat;
    std::vector<double> pdfWeights;
  
    ClassDef(GenEvent,1) 
  };
  
  class Electron: public TObject {
  public:
    Electron();
    ~Electron() {}
    double eta;
    double phi;
    double pt;
      bool ecalDriven;
      bool hasGsfTrack;
    double trackPt;
    double trackPtError;
    double energy;
    double caloEnergy;
    double caloEnergyError;
       int charge;
       int pixHits;
       int trkHits;
       int nValidHits;
     float trkD0;
     float trkD0Error;
  
    // ID variables
    double hoe;
    double hoeDepth1;
    double eop;
    double sigmaEtaEta;
    double sigmaIEtaIEta;
    double deltaPhiTrkSC;
    double deltaEtaTrkSC;
       int classif;
    double e1x5overe5x5;
    double e2x5overe5x5; 
  
    // Iso variables
    double isoEcal03;
    double isoHcal03;
    double isoTrk03;
    double isoEcal04;
    double isoHcal04;
    double isoTrk04;
    double isoRel03;
    double isoRel04;
  
    // Vertex
    double vx;
    double vy;
    double vz;

    // SC associated with electron
    double scEn;
    double scEta;
    double scPhi;
    double scET;
    double scRawEnergy;
  
    // Vertex association variables
    double vtxDist3D;
       int vtxIndex;
    double vtxDistZ;
    double relIso;
    double pfRelIso;
  
     // PFlow isolation variable
     float chargedHadronIso;
     float neutralHadronIso;
     float photonIso;

       int missingHits;

    double dB;
    double edB;
  
    double dB3d;
    double edB3d;
  
    double scE1E9;
    double scS4S1;
    double sckOutOfTime;
    double scEcalIso;
    double scHEEPEcalIso;
    double scHEEPTrkIso;
  
       int nBrems;
     float fbrem;
  
     float dist_vec;
     float dCotTheta;
     float hasMatchedConv;
    
     float mva;
     float mvaPOGTrig;
     float mvaPOGNonTrig;
     bool mvaPreselection;
     bool isTriggerElectron;

     float isoMVA;
   
     float pfRelIso03v1;
     float pfRelIso03v2;
     float pfRelIsoDB03v1;
     float pfRelIsoDB03v2;
     float pfRelIsoDB03v3;

     float pfRelIso04v1;
     float pfRelIso04v2;
     float pfRelIsoDB04v1;
     float pfRelIsoDB04v2;
     float pfRelIsoDB04v3;

     float pfRelIso03;
     float pfRelIso04;
     float pfRelIsoDB03;
     float pfRelIsoDB04;

       int selbit;
       int fidFlag;

    ClassDef(Electron, 1) 
  };
  class GenParticle: public TObject {
  public:
    GenParticle();
    ~GenParticle() {}
  
    double eta;
    double phi;
    double p;
    double px;
    double py;
    double pz;
    double pt;
    double energy;
       int pdgId;
    double vx;
    double vy;
    double vz;
       int status;
    double charge; 
       int numDaught;
       int numMother;
       int motherIndex;
    std::vector<int> motherIndices;
    std::vector<int> daughtIndices;
  
    ClassDef(GenParticle,1) 
  };
  class GenJet: public TObject {
  public:
    GenJet();
    ~GenJet() {}
  
    double eta;
    double phi;
    double p;
    double pt;
    double energy;
    double emf;
    double hadf;
  
    ClassDef(GenJet,1) 
  };
  class MET: public TObject {
  public:
    MET();
    ~MET() {}
    double metx;
    double mety;
    double met;
    double metphi;
    double sumet;
    double metuncorr;
    double metphiuncorr;
    double sumetuncorr;
  
    ClassDef(MET,2) 
  };
  class Tau: public TObject {
  public:
    Tau();
    ~Tau() {}
  
    enum {
      kMaxPFChargedCand = 40,
      kMaxPFNeutralCand = 20
    };
    double eta;
    double phi;
    double pt;
    double energy;
       int charge;
    double mass;
    double px;
    double py;
    double pz;
    
    double leadTrkPt; 
    double leadTrkPtError; 
    double leadTrkEta;
    double leadTrkPhi;
    double leadTrkCharge;
    double leadTrkD0;
    double leadTrkD0Error;
    double leadTrkDz;
    double leadTrkDzError;

       int vtxIndex;
    double vtxDxy;
    double vtxDz;

    // Leading particle pT
    double leadChargedParticlePt;
    double leadNeutralParticlePt;
    double leadParticlePt;
  
    // Number of charged/neutral candidates and photons in different cones
       int numChargedHadronsSignalCone;
       int numNeutralHadronsSignalCone;
       int numPhotonsSignalCone;
       int numParticlesSignalCone;
       int numChargedHadronsIsoCone;
       int numNeutralHadronsIsoCone;
       int numPhotonsIsoCone;
       int numParticlesIsoCone;
    double ptSumPFChargedHadronsIsoCone;
    double ptSumPFNeutralHadronsIsoCone;
    double ptSumPhotonsIsoCone;
    
    double sigChHadCandPt[kMaxPFChargedCand];
    double sigChHadCandEta[kMaxPFChargedCand];
    double sigChHadCandPhi[kMaxPFChargedCand];
    double sigNeHadCandPt[kMaxPFNeutralCand];
    double sigNeHadCandEta[kMaxPFNeutralCand];
    double sigNeHadCandPhi[kMaxPFNeutralCand];
    double sigGammaCandPt[kMaxPFNeutralCand];
    double sigGammaCandEta[kMaxPFNeutralCand];
    double sigGammaCandPhi[kMaxPFNeutralCand];

    double isoChHadCandPt[kMaxPFChargedCand];
    double isoChHadCandEta[kMaxPFChargedCand];
    double isoChHadCandPhi[kMaxPFChargedCand];
    double isoNeHadCandPt[kMaxPFNeutralCand];
    double isoNeHadCandEta[kMaxPFNeutralCand];
    double isoNeHadCandPhi[kMaxPFNeutralCand];
    double isoGammaCandPt[kMaxPFNeutralCand];
    double isoGammaCandEta[kMaxPFNeutralCand];
    double isoGammaCandPhi[kMaxPFNeutralCand];

    /////////////////
    float decayModeFinding;
    float   decayModeFindingNewDMs; 
    float   decayModeFindingOldDMs;

    float  chargedIsoPtSum ;
    float neutralIsoPtSum;
    float puCorrPtSum;

float CombinedIsolationDeltaBetaCorrRaw3Hits;
float  CombinedIsolationDeltaBetaCorrRaw;
float   byIsolationMVA3newDMwLTraw;
  float byIsolationMVA3newDMwoLTraw;
  float byIsolationMVA3oldDMwLTraw;
  float byIsolationMVA3oldDMwoLTraw;

  float byLooseCombinedIsolationDeltaBetaCorr;
  float byLooseCombinedIsolationDeltaBetaCorr3Hits;

  float byMediumCombinedIsolationDeltaBetaCorr;
  float byMediumCombinedIsolationDeltaBetaCorr3Hits;


  float byTightCombinedIsolationDeltaBetaCorr;
  float byTightCombinedIsolationDeltaBetaCorr3Hits;

  float byLooseIsolationMVA3newDMwLT;
  float byLooseIsolationMVA3newDMwoLT;
  float byLooseIsolationMva3oldDMwLT;
  float byLooseIsolationMVA3oldDMwoLT;

  float byMediumIsolationMVA3newDMwLT;

  float byMediumIsolationMVA3newDMwoLT;
  float byMediumIsolationMva3oldDMwLT;
  float byMediumIsolationMVA3oldDMwoLT;

  float byTightIsolationMVA3newDMwLT;
  float byTightIsolationMVA3newDMwoLT;
  float byTightIsolationMva3oldDMwLT;
  float byTightIsolationMVA3oldDMwoLT;


    // discriminators against electrons/muons
  float againstMuonLoose;      
  float againstMuonLoose2;     
  float againstMuonLoose3;     
  float againstMuonLooseMVA;   
  float againstMuonTight;
  
  float againstMuonTight2;    
  float againstMuonTight3;    
  float againstMuonTightMVA;  
  float againstElectronLoose; 
  float againstElectronMedium;
  float againstElectronTight;
 float  pfElectronMVA;        
                            

      // ElectronIDMVA, electron faking tau
  float againstElectronMVALooseMVA5;
  float againstElectronMVAMediumMVA5;
  float againstElectronMVATightMVA5; 

  float byVLooseCombinedIsolationDeltaBetaCorr;
     
   
      // MVA based isolation
  float byLooseIsolationMVA;                   
  float byMediumIsolationMVA;                  
  float byTightIsolationMVA;                  



    //////////// 


     // kinematic variables for PFJet associated to PFTau
    double jetPt;
    double jetEta;
    double jetPhi;
  
     float emFraction;
     float maximumHCALPFClusterEt;
     float ecalStripSumEOverPLead;
     float bremsRecoveryEOverPLead;
     float hcalTotOverPLead;
     float hcalMaxOverPLead;
     float hcal3x3OverPLead;
  
     float etaetaMoment;
     float phiphiMoment;
     float etaphiMoment;
  
    double vx;
    double vy;
    double vz;
  
    double zvertex;
    double ltsipt;
  
       int selbit;
  
    ClassDef(Tau, 2) 
  };
  class Muon: public TObject {
  public:
    Muon();
    ~Muon() {}
      bool isTrackerMuon;
      bool isPFMuon;
      double ptgen;
      /* double DR_status1Match;
      double DR_status3Match;
      double DR_defaultMatch;*/
      double eta;
      double phi;
      double pt;
      double ptError;
      double px;
      double py;
      double pz;
      double energy;
      int charge;
      double trkD0;
      double trkD0Error;
      double trkDz;
      double trkDzError;
      double globalChi2;
    double trkIso;
    double ecalIso;
    double hcalIso;
    double hoIso;
    double relIso;
       int passID;
    double vtxDist3D;
       int vtxIndex;
    double vtxDistZ;
       int pixHits;
       int trkHits;
       int muoHits;
       int matches;
       int trackerLayersWithMeasurement; 
    double pfRelIso;

    double vx;
    double vy;
    double vz;

    double dB;  // PV2D
    double edB;   

    double dB3d; // PV3D
    double edB3d;
  
    // UW Recommendation
      bool isGlobalMuonPromptTight;
      bool isAllArbitrated;
       int nChambers;
       int nMatches;
       int nMatchedStations;
       unsigned int stationMask;
       unsigned int stationGapMaskDistance;
       unsigned int stationGapMaskPull;
       int muonID;
     
       float idMVA;
       float isoRingsMVA;
       float isoRingsRadMVA;
       float idIsoCombMVA;

       float pfRelIso03v1;
       float pfRelIso03v2;
       float pfRelIsoDB03v1;
       float pfRelIsoDB03v2;
       float pfRelIso04v1;
       float pfRelIso04v2;
       float pfRelIsoDB04v1;
       float pfRelIsoDB04v2;

       int selbit;

     ClassDef(Muon, 4)
  };
  class Jet: public TObject {
  public:
    Jet();
    ~Jet() {}
    double eta;
    double phi;
    double pt;
    double pt_raw;
    double energy;
    double energy_raw;
    double jecUnc;
    double resJEC;
       int partonFlavour;

     float puIdMVA;
       int puIdFlag;
       int puIdBits;

    double chargedEmEnergyFraction;
    double chargedHadronEnergyFraction;
    double chargedMuEnergyFraction;
    double electronEnergyFraction;
    double muonEnergyFraction;
    double neutralEmEnergyFraction;
    double neutralHadronEnergyFraction;
    double photonEnergyFraction;
       int chargedHadronMultiplicity;
       int chargedMultiplicity;
       int electronMultiplicity;
       int muonMultiplicity;
       int neutralHadronMultiplicity;
       int neutralMultiplicity;
       int photonMultiplicity;
       int nConstituents;
    double trackCountingHighEffBTag;
    double trackCountingHighPurBTag;
    double simpleSecondaryVertexHighEffBTag;
    double simpleSecondaryVertexHighPurBTag;
    double jetProbabilityBTag;
    double jetBProbabilityBTag;
    double combinedSecondaryVertexBTag;
    double combinedSecondaryVertexMVABTag;
    double combinedInclusiveSecondaryVertexBTag;
    double combinedMVABTag;
       int passLooseID;
       int passTightID;
  
       int selbit;

    ClassDef(Jet, 1)
  };
  class Vertex: public TObject {
  public:
    Vertex();
    ~Vertex() {}
  
    double x;
    double y;
    double z;
    double xErr;
    double yErr;
    double zErr;
    double rho;
    double chi2;
    double ndf;
       int ntracks;
       int ntracksw05;
      bool isfake;
      bool isvalid;
    double sumPt; // vector sum
  
       int selbit;

    ClassDef(Vertex, 1)
  };
  class GenMET: public TObject {
  public:
    GenMET();
    ~GenMET() {}
  
    double met;
    double metphi;
    double sumet;
  
    ClassDef(GenMET, 1)
  };
  class Track: public TObject {
  public:
    Track();
    ~Track() {}
  
    double eta;
    double etaError;
    double theta;
    double thetaError;
    double phi;
    double phiError;
    double p;
    double pt;
    double ptError;
    double qoverp;
    double qoverpError;
     float charge;

       int nValidHits;
       int nLostHits;
    double validFraction;
       int nValidTrackerHits;
       int nValidPixelHits;
       int nValidStripHits;
       int trackerLayersWithMeasurement;
       int pixelLayersWithMeasurement;
       int stripLayersWithMeasurement;
  
    double dxy;
    double dxyError;
    double dz;
    double dzError;
  
    double chi2;
       int ndof;
    double vx;
    double vy;
    double vz;
  
       int selbit; 
         
    ClassDef(Track, 1)
  };
  class TriggerObject: public TObject {
  public:
    TriggerObject();
    ~TriggerObject() {}
  
    double energy;
    double pt;
    double eta;
    double phi;
  
    std::map< std::string, unsigned int > pathList;
  
    ClassDef(TriggerObject, 1)
  };
}
#endif
<file_sep>void plot_int_2(){
  
  hLeadMuon2->ComputeIntegral();
  Double_t *integral = (hLeadMuon2->GetIntegral());
  hLeadMuon2->SetContent(integral);
  //TH1F *hLeadMuon2=1-(*hLeadMuon2);
  //TH1F *hLeadMuon2i = new TH1F("hLeadMuon2i","histogram with 1 as entries",100,0,60);
  Int_t binsize=hLeadMuon2->GetSize();
  for (int i=1;i<binsize-1;i++){
    Double_t entry=hLeadMuon2->GetBinContent(i);
    hLeadMuon2->SetBinContent(i,1-entry);
  }

  hSubLeadMuon2->ComputeIntegral();
  Double_t *integral = (hSubLeadMuon2->GetIntegral());
  hSubLeadMuon2->SetContent(integral);
  binsize=hSubLeadMuon2->GetSize();
  //hSubLeadMuon2=1-(*hSubLeadMuon2);
  for (int i=1;i<binsize-1;i++){
    entry=hSubLeadMuon2->GetBinContent(i);
    hSubLeadMuon2->SetBinContent(i,1-entry);
  }


  hLeadMuon2->SetLineColor(1);
  hSubLeadMuon2->SetLineColor(4);
  hLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
  hSubLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
  hLeadMuon2->SetYTitle("Kinematic Acceptance");
  hSubLeadMuon2->SetYTitle("Kinematic Acceptance");
  
  hSubLeadMuon2->Draw();
  
  hLeadMuon2->Draw("same");          //draw hist_2 first as it has a larger range
  
  
  leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 2");
  leg_hist->AddEntry(hLeadMuon2,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon2,"subleading muon pt","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();

  //c1->SaveAs("case1.png");
  
}
<file_sep>void plot_accept_pt_3d(){
  //hAcceptAll->SetLineColor(1);
  
  hAcceptAll->GetXaxis()->SetRangeUser(5, 30);
  hAcceptAll->GetYaxis()->SetRangeUser(5, 30);

  hAcceptAll->SetXTitle("Reco. leading muon p_{T} in GeV/c");
  hAcceptAll->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //hAcceptAll->SetZTitle("Kinematic acceptance");
  hAcceptAll->SetStats(0);
  hAcceptAll->Draw("cont3 colz");
  //HLT_PATH Mu17_Mu8
  //gStyle->SetPalette(0,100);
  Int_t a=hAcceptAll->GetXaxis()->FindBin(17);
  Int_t b = hAcceptAll->GetYaxis()->FindBin(8);
  Double_t c = hAcceptAll->GetBinContent(a,b);
  //Double_t a = hAcceptAll->GetBinContent(hAcceptAll->GetXaxis()->FindBin(17),hAcceptAll->GetYaxis()->FindBin(8)));
  //HLT_PATH Mu13_Mu8
  //Double_t f=hAcceptAll->GetBinContent(

  //TPaletteAxis *pal = hAcceptAll->GetListOfFunctions()->FindObject("palette");
  //pal->GetAxis()->SetName("A_kin");
  
  cout<<"17-18 "<<c<<endl;

  Int_t d = hAcceptAll->GetXaxis()->FindBin(13);
  Int_t e = hAcceptAll->GetYaxis()->FindBin(8);
  Double_t f = hAcceptAll->GetBinContent(d,e);
  
  cout<<"13-18 "<<f<<endl;

  //Offline Cuts
  
  Int_t g=hAcceptAll->GetXaxis()->FindBin(20);
  Int_t h=hAcceptAll->GetYaxis()->FindBin(10);
  Double_t z=hAcceptAll->GetBinContent(g,h);
  //Double_t i=GetBinContenthAcceptAll->GetXaxis()->FindBin(20),hAcceptAll->GetYaxis()->FindBin(10));
  
  cout<<"20-10 "<<z<<endl;
  
  //Double_t m=hAcceptAll->GetBinContent(k,l);
  //draw hist_2 first as it has a larger range
  
  TLatex latex;
  //latex.DrawLatex(17,8,TString::Format("#bullet %f ",a));
  //latex.DrawLatex(17,8,TString::Format("#bullet %2f %",c*100));
  latex.DrawLatex(17,8,"#bullet 62%");
  latex.DrawLatex(13,8,"#diamond 71%");
  latex.DrawLatex(20,10,"#color[2]{#bullet} 42%");
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(13,8,TString::Format("#diamond %f ",f));
  
  //latex.DrawLatex(20,10,TString::Format("#circ %f ",i));
  
  latex.DrawLatex(3,22,"#bullet");
  latex.DrawLatex(2.83,25,"#diamond");
  
  
  
  latex.DrawLatex(4,28,"#scale[0.8]{HLT Paths(Run-1)}");
  latex.DrawLatex(4,22,"#scale[0.8]{Mu17_Mu8 (Luminosity 19.1 fb^{-1})}");
  latex.DrawLatex(4,25,"#scale[0.8]{Mu13_Mu8 (Luminosity 3.7 fb^{-1})}");
  
  latex.DrawLatex(4,19,"#scale[0.8]{Offline selection}");
  latex.DrawLatex(3,16,"#color[2]{#bullet}");
  latex.DrawLatex(4,16,"#scale[0.8]{Mu20_Mu10}");
  
  


  
  c1->SaveAs("acceptance_2d_all_cont3.png");
  c1->SaveAs("acceptance_2d_all_cont3.eps");
  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 1 (both muons in endcap)");
  leg_hist->AddEntry(hAcceptAll,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon pt","l");
  leg_hist->Draw();
  */
  
  
}
<file_sep>#ifndef __VHTauTau_TreeMaker_METBlock_h
#define __VHTauTau_TreeMaker_METBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class MET;

class METBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit METBlock(const edm::ParameterSet& iConfig);
  virtual ~METBlock() {}

  enum {
    kMaxMET = 100
  };

  //void fillMET(const edm::Event& iEvent, 
  //            const edm::EventSetup& iSetup,
  //            TClonesArray* cloneMET,
  //            int fnMET,
  //            edm::InputTag iTag,
  //            vhtm::MET* metB);

private:
  TClonesArray* clonePFMET; 
  int  fnPFMET;

  //  TClonesArray* cloneCorrMET; 
  //int  fnCorrMET;

  //TClonesArray* cloneMVAMET; 
  //int  fnMVAMET;

  int _verbosity;
  edm::InputTag _pfInputTag;
  //edm::InputTag _corrinputTag;
  //edm::InputTag _mvainputTag;

  vhtm::MET* metB;
  //vhtm::MET* corrmetB;
  //vhtm::MET* mvametB;
};
#endif
<file_sep>#include <cassert>
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "TTree.h"
#include "VHTauTau/TreeMaker/plugins/TreeMakerModule.h"
#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"


TreeMakerModule::TreeMakerModule(const edm::ParameterSet& iConfig) : 
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _createTree(iConfig.getParameter<bool>("createTree"))
{
}
void TreeMakerModule::beginJob() 
{
  if (!_createTree) return;
  edm::Service<TFileService> fs;
  fs->file().cd("/");
  TTree* tree = fs->make<TTree>("vhtree", "VH Analysis Tree");
  assert(tree);
  fs->file().ls();
}
//
// -- Analyze
//
void TreeMakerModule::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Get TTree pointer
  if (_createTree) return;
  TTree* tree = vhtm::Utility::getTree("vhtree");
  tree->Fill();
}
void TreeMakerModule::endJob() {
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TreeMakerModule);
<file_sep>void plot_int_1(){
  
  hLeadMuon1->ComputeIntegral();
  Double_t *integral = (hLeadMuon1->GetIntegral());
  hLeadMuon1->SetContent(integral);
  //TH1F *hLeadMuon1=1-(*hLeadMuon1);
  //TH1F *hLeadMuon1i = new TH1F("hLeadMuon1i","histogram with 1 as entries",100,0,60);
  Int_t binsize=hLeadMuon1->GetSize();
  for (int i=1;i<binsize-1;i++){
    //    std::cout<<i<<"\t"<<(*integral)<<endl;
    Double_t entry=hLeadMuon1->GetBinContent(i);
    hLeadMuon1->SetBinContent(i,1-entry);
  }

  hSubLeadMuon1->ComputeIntegral();
  Double_t *integral = (hSubLeadMuon1->GetIntegral());
  hSubLeadMuon1->SetContent(integral);
  binsize=hSubLeadMuon1->GetSize();
  //hSubLeadMuon1=1-(*hSubLeadMuon1);
  for (int i=1;i<binsize-1;i++){
    entry=hSubLeadMuon1->GetBinContent(i);
    hSubLeadMuon1->SetBinContent(i,1-entry);
  }


  hLeadMuon1->SetLineColor(1);
  hSubLeadMuon1->SetLineColor(4);
  hLeadMuon1->SetXTitle("Reco Muon p_{T} in GeV/c");
  hSubLeadMuon1->SetXTitle("Reco Muon p_{T} in GeV/c");
  hLeadMuon1->SetYTitle("kinematic acceptance");
  hSubLeadMuon1->SetYTitle("kinematic acceptance");
  
  hSubLeadMuon1->Draw();
  
  hLeadMuon1->Draw("same");          //draw hist_2 first as it has a larger range
  
  
  leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 1");
  leg_hist->AddEntry(hLeadMuon1,"leading muon p_{T}","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon p_{T}","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();

  //c1->SaveAs("case1.png");
  
}
<file_sep>#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h" 

#include "TTree.h"
#include "TClonesArray.h"

#include "VHTauTau/TreeMaker/plugins/EventBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

EventBlock::EventBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _l1InputTag(iConfig.getParameter<edm::InputTag>("l1InputTag")),
  _vtxInputTag(iConfig.getParameter<edm::InputTag>("vertexInputTag")),
  _trkInputTag(iConfig.getParameter<edm::InputTag>("trkInputTag")),
  _vtxMinNDOF(iConfig.getParameter<unsigned int>("vertexMinimumNDOF")),
  _vtxMaxAbsZ(iConfig.getParameter<double>("vertexMaxAbsZ")),
  _vtxMaxd0(iConfig.getParameter<double>("vertexMaxd0")),
  _numTracks(iConfig.getParameter<unsigned int>("numTracks")),
  _hpTrackThreshold(iConfig.getParameter<double>("hpTrackThreshold"))
{
}
EventBlock::~EventBlock() {
  delete _nPU;
  delete _bunchCrossing;
  delete _trueNInt;
}
void EventBlock::beginJob() {
  _nPU = new std::vector<int>();
  _bunchCrossing = new std::vector<int>();
  _trueNInt = new std::vector<int>();

  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneEvent = new TClonesArray("vhtm::Event");
  tree->Branch("Event", &cloneEvent, 32000, 2);

  tree->Branch("nPU", "std::vector<int>", &_nPU);
  tree->Branch("bunchCrossing", "std::vector<int>", &_bunchCrossing);
  tree->Branch("trueNInt", "std::vector<int>", &_trueNInt);
}
void EventBlock::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
  // Reset the TClonesArray
  cloneEvent->Clear();

  // Clear the two independent vectors
  _nPU->clear();
  _bunchCrossing->clear();
  _trueNInt->clear();

  // Create Event Object
  eventB = new ( (*cloneEvent)[0] ) vhtm::Event();
  eventB->run   = iEvent.id().run();
  eventB->event = iEvent.id().event();
  eventB->lumis = iEvent.id().luminosityBlock();
  eventB->bunch = iEvent.bunchCrossing();
  eventB->orbit = iEvent.orbitNumber();

  double sec  = iEvent.time().value() >> 32 ;
  double usec = 0xFFFFFFFF & iEvent.time().value();
  double conv = 1e6;
  eventB->time = sec+usec/conv;
  eventB->isdata = iEvent.isRealData();
 
  edm::Handle<L1GlobalTriggerReadoutRecord> l1GtReadoutRecord;
  iEvent.getByLabel(_l1InputTag, l1GtReadoutRecord);

  // Technical Trigger Part
  if (l1GtReadoutRecord.isValid()) {
    edm::LogInfo("EventBlock") << "Successfully obtained L1GlobalTriggerReadoutRecord for label: " 
                               << _l1InputTag;

    L1GtFdlWord fdlWord = l1GtReadoutRecord->gtFdlWord();
    if (fdlWord.physicsDeclared() == 1)
      eventB->isPhysDeclared = true;

    // BPTX0
    if (l1GtReadoutRecord->technicalTriggerWord()[0])
      eventB->isBPTX0 = true;

    // MinBias
    if (l1GtReadoutRecord->technicalTriggerWord()[40] || l1GtReadoutRecord->technicalTriggerWord()[41])
      eventB->isBSCMinBias = true;

    // BeamHalo
    if ( (l1GtReadoutRecord->technicalTriggerWord()[36] || l1GtReadoutRecord->technicalTriggerWord()[37] ||
          l1GtReadoutRecord->technicalTriggerWord()[38] || l1GtReadoutRecord->technicalTriggerWord()[39]) ||
         ((l1GtReadoutRecord->technicalTriggerWord()[42] && !l1GtReadoutRecord->technicalTriggerWord()[43]) ||
          (l1GtReadoutRecord->technicalTriggerWord()[43] && !l1GtReadoutRecord->technicalTriggerWord()[42])) )
      eventB->isBSCBeamHalo = true;
  } 
  else {
    edm::LogError("EventBlock") << "Error >> Failed to get L1GlobalTriggerReadoutRecord for label:" 
                                << _l1InputTag;
  }

  // Good Primary Vertex Part
  edm::Handle<reco::VertexCollection> primaryVertices;
  iEvent.getByLabel(_vtxInputTag, primaryVertices);

  if (primaryVertices.isValid()) {
    edm::LogInfo("EventBlock") << "Total # Primary Vertices: " << primaryVertices->size();
    for (reco::VertexCollection::const_iterator it = primaryVertices->begin(); 
                                               it != primaryVertices->end(); ++it) {
      if (!(it->isFake()) && it->ndof() > _vtxMinNDOF &&
            fabs(it->z()) <= _vtxMaxAbsZ && fabs(it->position().rho()) <= _vtxMaxd0
	  ) 
      {
        eventB->isPrimaryVertex = true;
        break;
      }
    }
  } 
  else {
    edm::LogError("EventBlock") << "Error >> Failed to get VertexCollection for label:" 
                                << _vtxInputTag;
  }

  // Scraping Events Part
  edm::Handle<reco::TrackCollection> tracks;
  iEvent.getByLabel(_trkInputTag, tracks);

  if (tracks.isValid()) {
    edm::LogInfo("EventBlock") << "Total # Tracks: " << tracks->size();

    int numhighpurity = 0;
    double fraction   = 1.;
    reco::TrackBase::TrackQuality trackQuality = reco::TrackBase::qualityByName("highPurity");
    if (tracks->size() > _numTracks) {
      for (reco::TrackCollection::const_iterator it = tracks->begin(); 
                                                it != tracks->end(); ++it) {
        if (it->quality(trackQuality)) numhighpurity++;
      }
      fraction = (double)numhighpurity/(double)tracks->size();
      if (fraction < _hpTrackThreshold)
        eventB->isBeamScraping = true;
    }
  } 
  else {
    edm::LogError("EventBlock") << "Error >> Failed to get TrackCollection for label:" 
                                << _trkInputTag;
  }
  // Access PU information
  /*if (!iEvent.isRealData()) {
    edm::Handle<std::vector<PileupSummaryInfo> > PupInfo;
    iEvent.getByLabel("addPileupInfo", PupInfo);

    std::vector<PileupSummaryInfo>::const_iterator PVI;
    for (PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
      eventB->bunchCrossing.push_back(PVI->getBunchCrossing());
      _bunchCrossing->push_back(PVI->getBunchCrossing());
      eventB->nPU.push_back(PVI->getPU_NumInteractions());      
      _nPU->push_back(PVI->getPU_NumInteractions());      
      eventB->trueNInt.push_back(PVI->getTrueNumInteractions());      
      _trueNInt->push_back(PVI->getTrueNumInteractions());    
    }

    // More info about PU is here:
    // https://twiki.cern.ch/twiki/bin/viewauth/CMS/PileupInformation#Accessing_PileupSummaryInfo_in_r
    }*/ 
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(EventBlock);
<file_sep>#include <iostream>
#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"

#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

#include "Utilities/General/interface/FileInPath.h"

#include "VHTauTau/TreeMaker/plugins/TauBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"


const reco::GenParticle* getGenTau(const pat::Tau& pt)
{
  std::vector<reco::GenParticleRef> associatedGenParticles = pt.genParticleRefs();
  for ( std::vector<reco::GenParticleRef>::const_iterator im = associatedGenParticles.begin(); 
	im != associatedGenParticles.end(); ++im ) {
    if ( im->isAvailable() ) {
      const reco::GenParticleRef& genParticle = (*im);
      if ( genParticle->pdgId() == -15 || genParticle->pdgId() == +15 ) return genParticle.get();
    }
  }
  return 0;
}



namespace tb 
{
  template<typename T>
  bool isValidRef(const edm::Ref<T>& ref)
  //  bool isValidRef(const PFCandidatePtr ref))
  {
    return ( (ref.isAvailable() || ref.isTransient()) && ref.isNonnull() );
  }
}
TauBlock::TauBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("patTauSrc")),
  _vtxInputTag(iConfig.getParameter<edm::InputTag>("vertexSrc"))
{
}
TauBlock::~TauBlock() { }
void TauBlock::beginJob() 
{
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneTau = new TClonesArray("vhtm::Tau");
  tree->Branch("Tau", &cloneTau, 32000, 2);
  tree->Branch("nTau", &fnTau, "fnTau/I");
}
void TauBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneTau->Clear();
  fnTau = 0;

  edm::Handle<reco::VertexCollection> primaryVertices;
  iEvent.getByLabel(_vtxInputTag, primaryVertices);

  edm::Handle<std::vector<pat::Tau> > taus;
  iEvent.getByLabel(_inputTag, taus);
  
  if (taus.isValid()) {
    edm::LogInfo("TauBlock") << "Total # PAT Taus: " << taus->size();
    
    for (std::vector<pat::Tau>::const_iterator it  = taus->begin(); 
                                               it != taus->end(); ++it) {
      if (fnTau == kMaxTau) {
	edm::LogInfo("TauBlock") << "Too many PAT Taus, fnTau = " << fnTau;
	break;
      }
      tauB = new ((*cloneTau)[fnTau++]) vhtm::Tau();

      const reco::GenParticle* genTau = getGenTau(*it);
      if (!genTau) continue;

      

      // Store Tau variables
      tauB->eta    = it->eta();
      tauB->phi    = it->phi();
      tauB->pt     = it->pt();
      tauB->energy = it->energy();
      tauB->charge = it->charge();
      tauB->px     = it->px();
      tauB->py     = it->py();
      tauB->pz     = it->pz();

      
      // if (tb::isValidRef(it->leadPFChargedHadrCand()) /*&& tb::isValidRef(it->leadPFChargedHadrCand()->trackRef())*/) {
      /*
	reco::TrackRef trk = it->leadPFChargedHadrCand()->trackRef();
        tauB->leadTrkPt      = trk->pt();
        tauB->leadTrkPtError = trk->ptError();
        tauB->leadTrkEta     = trk->eta();
        tauB->leadTrkPhi     = trk->phi();
        tauB->leadTrkCharge  = trk->charge();
        tauB->leadTrkD0      = trk->d0();
        tauB->leadTrkD0Error = trk->d0Error();
        tauB->leadTrkDz      = trk->dz();
        tauB->leadTrkDzError = trk->dzError();
        if (0) std::cout << trk->pt() << " "
                         << trk->eta() << " "
                         << trk->phi() << " "
                         << trk->charge() << " "
                         << trk->d0() <<  " "
                         << trk->dz()
                         << std::endl;

        // IP of leadPFChargedHadrCand wrt PV
        // Vertex association
        double minVtxDist3D = 9999.;
        int indexVtx = -1;
        double vertexDz = 9999.;
        double vertexDxy = 9999.;
        if (primaryVertices.isValid()) {
          edm::LogInfo("TauBlock") << "Total # Primary Vertices: " << primaryVertices->size();
          for (reco::VertexCollection::const_iterator vit  = primaryVertices->begin();
                                                      vit != primaryVertices->end(); ++vit) {
            double dxy = trk->dxy(vit->position());
            double dz  = trk->dz(vit->position());
            double dist3D = std::sqrt(pow(dxy,2) + pow(dz,2));
            if (dist3D < minVtxDist3D) {
              minVtxDist3D = dist3D;
              indexVtx = int(std::distance(primaryVertices->begin(), vit));
              vertexDxy = dxy;
              vertexDz = dz;
            }
          }
	}
        else {
  	  edm::LogError("TauBlock") << "Error >> Failed to get VertexCollection for label: "
                                    << _vtxInputTag;
        }
        tauB->vtxIndex = indexVtx;
        tauB->vtxDxy   = vertexDxy;
        tauB->vtxDz    = vertexDz;
        if (0) std::cout << indexVtx << " " << vertexDxy << " " << vertexDz << std::endl;
      */
	//      }  //if is valid ref

      

      // Leading particle pT
      tauB->leadChargedParticlePt = it->leadPFChargedHadrCand().isNonnull() 
                                      ? it->leadPFChargedHadrCand()->pt(): 0.;
            tauB->leadNeutralParticlePt = it->leadPFNeutralCand().isNonnull() 
                                      ? it->leadPFNeutralCand()->et(): 0.;
      tauB->leadParticlePt        = it->leadPFCand().isNonnull() 
                                      ? it->leadPFCand()->et(): 0.;      
      // Number of charged/neutral candidates and photons in different cones
      tauB->numChargedHadronsSignalCone = it->signalPFChargedHadrCands().size();
      tauB->numNeutralHadronsSignalCone = it->signalPFNeutrHadrCands().size();
      tauB->numPhotonsSignalCone        = it->signalPFGammaCands().size();
      tauB->numParticlesSignalCone      = it->signalPFCands().size();
      
      tauB->numChargedHadronsIsoCone = it->isolationPFChargedHadrCands().size();
      tauB->numNeutralHadronsIsoCone = it->isolationPFNeutrHadrCands().size();
      tauB->numPhotonsIsoCone        = it->isolationPFGammaCands().size();
      tauB->numParticlesIsoCone      = it->isolationPFCands().size();
      
      tauB->ptSumPFChargedHadronsIsoCone = it->isolationPFChargedHadrCandsPtSum();
      tauB->ptSumPhotonsIsoCone          = it->isolationPFGammaCandsEtSum();

      // Signal Constituents
      // Charged hadrons
      //      int indx = 0;

      /*for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand  = it->signalPFChargedHadrCands().begin(); iCand != it->signalPFChargedHadrCands().end(); ++iCand,indx++) {
      // for (reco::PFCandidateRefVector::const_iterator iCand  = it->signalPFChargedHadrCands().begin(); 
      // iCand != it->signalPFChargedHadrCands().end(); ++iCand,indx++) {
        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFChargedCand) {
          tauB->sigChHadCandPt[indx]  = cand.pt();
          tauB->sigChHadCandEta[indx] = cand.eta();
          tauB->sigChHadCandPhi[indx] = cand.phi();

        }
      }  
      // Neutral hadrons
      indx = 0; // reset
      for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand  = it->signalPFNeutrHadrCands().begin(); iCand != it->signalPFNeutrHadrCands().end(); ++iCand,indx++) {
	//for (reco::PFCandidateRefVector::const_iterator iCand  = it->signalPFNeutrHadrCands().begin(); 
    	                                             //iCand != it->signalPFNeutrHadrCands().end(); ++iCand,indx++) {
        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFNeutralCand) {
          tauB->sigNeHadCandPt[indx]  = cand.pt();
          tauB->sigNeHadCandEta[indx] = cand.eta();
          tauB->sigNeHadCandPhi[indx] = cand.phi();
        }
      }  
      // Photons
      indx = 0; // reset
      // for (reco::PFCandidateRefVector::const_iterator iCand  = it->signalPFGammaCands().begin(); 
      //iCand != it->signalPFGammaCands().end(); ++iCand,indx++) 
for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand  = it->signalPFGammaCands().begin(); 
     iCand != it->signalPFGammaCands().end(); ++iCand,indx++){

        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFNeutralCand) {
          tauB->sigGammaCandPt[indx]  = cand.pt();
          tauB->sigGammaCandEta[indx] = cand.eta();
          tauB->sigGammaCandPhi[indx] = cand.phi();
        }
      }  
      // Isolation Constituents
      // Charged hadrons
      indx = 0; // reset
      // for (reco::PFCandidateRefVector::const_iterator iCand  = it->isolationPFChargedHadrCands().begin(); 
      //   iCand != it->isolationPFChargedHadrCands().end(); ++iCand,indx++) {
      for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand = it->isolationPFChargedHadrCands().begin(); 
	   iCand != it->isolationPFChargedHadrCands().end(); ++iCand,indx++) {
        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFChargedCand) {
          tauB->isoChHadCandPt[indx]  = cand.pt();
          tauB->isoChHadCandEta[indx] = cand.eta();
          tauB->isoChHadCandPhi[indx] = cand.phi();
        }
      }  
      
      // Neutral hadrons
      double ptSum = 0;
      indx = 0; // reset
      //      for (reco::PFCandidateRefVector::const_iterator iCand  = it->isolationPFNeutrHadrCands().begin(); 
      //                                              iCand != it->isolationPFNeutrHadrCands().end(); ++iCand,indx++) {
      for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand = it->isolationPFNeutrHadrCands().begin(); 
	   iCand != it->isolationPFNeutrHadrCands().end(); ++iCand,indx++) {
        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFNeutralCand) {
          tauB->isoNeHadCandPt[indx]  = cand.pt();
          tauB->isoNeHadCandEta[indx] = cand.eta();
          tauB->isoNeHadCandPhi[indx] = cand.phi();
        }
	ptSum += std::abs(cand.pt());
      }  
      tauB->ptSumPFNeutralHadronsIsoCone = ptSum;

      // Photons
      indx = 0; // reset
      //for (reco::PFCandidateRefVector::const_iterator iCand  = it->isolationPFGammaCands().begin(); 
      //                                              iCand != it->isolationPFGammaCands().end(); ++iCand,indx++) {
      for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iCand = it->isolationPFGammaCands().begin(); 
	   iCand != it->isolationPFGammaCands().end(); ++iCand,indx++) {
        const reco::PFCandidate& cand = (**iCand);
        if (indx < vhtm::Tau::kMaxPFNeutralCand) {
          tauB->isoGammaCandPt[indx]  = cand.pt();
          tauB->isoGammaCandEta[indx] = cand.eta();
          tauB->isoGammaCandPhi[indx] = cand.phi();
        }
      }  
      */
      // tau id. discriminators
      /*
      tauB->decayModeFinding = it->tauID("decayModeFinding");
      //tauB->decayModeFindingNewDMs = it->tauID("decayModeFindingNewDMs");
      //tauB->decayModeFindingOldDMs = it->tauID("decayModeFindingOldDMs");

      tauB->chargedIsoPtSum  =it->tauID("chargedIsoPtSum");
      tauB->neutralIsoPtSum =it->tauID("neutralIsoPtSum");
      tauB->puCorrPtSum =it->tauID("puCorrPtSum");

      tauB->CombinedIsolationDeltaBetaCorrRaw3Hits   = it->tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits");
      tauB->CombinedIsolationDeltaBetaCorrRaw   = it->tauID("byCombinedIsolationDeltaBetaCorrRaw");
      tauB->byIsolationMVA3newDMwLTraw = it->tauID("byIsolationMVA3newDMwLTraw");
      tauB->byIsolationMVA3newDMwoLTraw=  it->tauID("byIsolationMVA3newDMwoLTraw");
      tauB->byIsolationMVA3oldDMwLTraw=  it->tauID("byIsolationMVA3oldDMwLTraw");
      tauB-> byIsolationMVA3oldDMwoLTraw = it->tauID("byIsolationMVA3oldDMwoLTraw");

      tauB->byLooseCombinedIsolationDeltaBetaCorr=it->tauID("byLooseCombinedIsolationDeltaBetaCorr");
      tauB->byLooseCombinedIsolationDeltaBetaCorr3Hits=it->tauID("byLooseCombinedIsolationDeltaBetaCorr3Hits");
 
      tauB->byMediumCombinedIsolationDeltaBetaCorr=it->tauID("byMediumCombinedIsolationDeltaBetaCorr");
      tauB->byMediumCombinedIsolationDeltaBetaCorr3Hits=it->tauID("byMediumCombinedIsolationDeltaBetaCorr3Hits");


      tauB->byTightCombinedIsolationDeltaBetaCorr=it->tauID("byTightCombinedIsolationDeltaBetaCorr");
      tauB->byTightCombinedIsolationDeltaBetaCorr3Hits=it->tauID("byTightCombinedIsolationDeltaBetaCorr3Hits");

      tauB->byLooseIsolationMVA3newDMwLT=it->tauID("byLooseIsolationMVA3newDMwLT");
      tauB->byLooseIsolationMVA3newDMwoLT=it->tauID("byLooseIsolationMVA3newDMwoLT");
      tauB->byLooseIsolationMva3oldDMwLT=it->tauID("byLooseIsolationMVA3oldDMwLT");
      tauB->byLooseIsolationMVA3oldDMwoLT=it->tauID("byLooseIsolationMVA3oldDMwoLT");

      tauB->byMediumIsolationMVA3newDMwLT=it->tauID("byMediumIsolationMVA3newDMwLT");
      tauB->byMediumIsolationMVA3newDMwoLT=it->tauID("byMediumIsolationMVA3newDMwoLT");
      tauB->byMediumIsolationMva3oldDMwLT=it->tauID("byMediumIsolationMVA3oldDMwLT");
      tauB->byMediumIsolationMVA3oldDMwoLT=it->tauID("byMediumIsolationMVA3oldDMwoLT");

      tauB->byTightIsolationMVA3newDMwLT=it->tauID("byTightIsolationMVA3newDMwLT");
      tauB->byTightIsolationMVA3newDMwoLT=it->tauID("byTightIsolationMVA3newDMwoLT");
      tauB->byTightIsolationMva3oldDMwLT=it->tauID("byTightIsolationMVA3oldDMwLT");
      tauB->byTightIsolationMVA3oldDMwoLT=it->tauID("byTightIsolationMVA3oldDMwoLT");

      */
      // discriminators against electrons/muons
      tauB->againstMuonLoose      = it->tauID("againstMuonLoose");
      tauB->againstMuonLoose2      = it->tauID("againstMuonLoose2");
      tauB->againstMuonLoose3      = it->tauID("againstMuonLoose3");
      //tauB->againstMuonLooseMVA      = it->tauID("againstMuonLooseMVA");
      tauB->againstMuonTight      = it->tauID("againstMuonTight");
      tauB->againstMuonTight2      = it->tauID("againstMuonTight2");
      tauB->againstMuonTight3      = it->tauID("againstMuonTight3");
      //tauB->againstMuonTightMVA      = it->tauID("againstMuonTightMVA");
      tauB->againstElectronLoose  = it->tauID("againstElectronLoose");
      tauB->againstElectronMedium = it->tauID("againstElectronMedium");
      tauB->againstElectronTight  = it->tauID("againstElectronTight");
      tauB->pfElectronMVA         = it->leadPFCand().isNonnull() 
                                  ? it->leadPFCand()->mva_e_pi() : 1.;

      // ElectronIDMVA, electron faking tau
      // tauB->againstElectronMVALooseMVA5    = it->tauID("againstElectronLooseMVA5");
      //tauB->againstElectronMVAMediumMVA5    = it->tauID("againstElectronLooseMVA5");
      //tauB->againstElectronMVATightMVA5    = it->tauID("againstElectronLooseMVA5");

      //tauB->byVLooseCombinedIsolationDeltaBetaCorr = it->tauID("byVLooseCombinedIsolationDeltaBetaCorr");
     
   
      // MVA based isolation
      /*      tauB->byLooseIsolationMVA                    = it->tauID("byLooseIsolationMVA"); 
      tauB->byMediumIsolationMVA                   = it->tauID("byMediumIsolationMVA"); 
      tauB->byTightIsolationMVA                    = it->tauID("byTightIsolationMVA"); 
      */
      // kinematic variables for PFJet associated to PFTau
      //      if (tb::isValidRef(it->pfJetRef())) {

      /*	const reco::PFJetRef &jtr = it->pfJetRef();
        tauB->jetPt  = jtr->pt();
        tauB->jetEta = jtr->eta();
        tauB->jetPhi = jtr->phi();
        if (0) std::cout << jtr->pt() << " " << jtr->eta() << " " << jtr->phi() << std::endl;
	//}
	*/

      // NEW quantities
      tauB->emFraction              = it->emFraction(); 
      tauB->maximumHCALPFClusterEt  = it->maximumHCALPFClusterEt();
      tauB->ecalStripSumEOverPLead  = it->ecalStripSumEOverPLead();
      tauB->bremsRecoveryEOverPLead = it->bremsRecoveryEOverPLead();
      tauB->hcalTotOverPLead        = it->hcalTotOverPLead();
      tauB->hcalMaxOverPLead        = it->hcalMaxOverPLead();
      tauB->hcal3x3OverPLead        = it->hcal3x3OverPLead();

      tauB->etaetaMoment = it->etaetaMoment();
      tauB->phiphiMoment = it->phiphiMoment();
      tauB->phiphiMoment = it->etaphiMoment();
      
      // Vertex information
      const reco::Candidate::Point& vertex = it->vertex();
      tauB->vx = vertex.x();             
      tauB->vy = vertex.y();             
      tauB->vz = vertex.z();             

      tauB->zvertex = it->vz(); // distance from the primary vertex
      tauB->mass    = it->p4().M();
      tauB->ltsipt  = TMath::Abs(it->leadPFChargedHadrCandsignedSipt());
    }
  }
  else {
    edm::LogError("TauBlock") << "Error! Failed to get pat::Tau collection for label: " 
                              << _inputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TauBlock);
<file_sep>void plot_accept_pt_3d_2(){
  //hAccept1->SetLineColor(1);
  
  
  

     hAccept2->SetXTitle("Reco. leading muon p_{T} in GeV/c");
     hAccept2->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //hAccept2->SetZTitle("Kinematic acceptance");
     hAccept2->SetStats(0);
     hAccept2->Draw("cont3 colz");
   //HLT_PATH Mu17_Mu8
   
     Int_t a=hAccept2->GetXaxis()->FindBin(17);
     Int_t b = hAccept2->GetYaxis()->FindBin(8);
     Double_t c = hAccept2->GetBinContent(a,b);
     cout<<"17-18 "<<c<<endl;
     //Double_t a = hAccept2->GetBinContent(hAccept2->GetXaxis()->FindBin(17),hAccept2->GetYaxis()->FindBin(8)));
   //HLT_PATH Mu13_Mu8
   //Double_t f=hAccept2->GetBinContent(
     Int_t d = hAccept2->GetXaxis()->FindBin(13);
     Int_t e = hAccept2->GetYaxis()->FindBin(8);
     Double_t f = hAccept2->GetBinContent(d,e);
     cout<<"13-18 "<<f<<endl;
     //Offline Cuts
  
     Int_t g=hAccept2->GetXaxis()->FindBin(20);
     Int_t h=hAccept2->GetYaxis()->FindBin(10);
     Double_t z=hAccept2->GetBinContent(g,h);
     cout<<"20-10 "<<z<<endl;
  //Double_t i=GetBinContenthAccept2->GetXaxis()->FindBin(20),hAccept2->GetYaxis()->FindBin(10));

  
  
  //Double_t m=hAccept2->GetBinContent(k,l);
  //draw hist_2 first as it has a larger range
  
     TLatex latex;
  //latex.DrawLatex(17,8,TString::Format("#bullet %f ",a));
  //latex.DrawLatex(17,8,TString::Format("#bullet %2f %",c*100));
     latex.DrawLatex(17,8,"#bullet 63%");
     latex.DrawLatex(13,8,"#diamond 72%");
     latex.DrawLatex(20,10,"#color[2]{#bullet} 42%");
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(13,8,TString::Format("#diamond %f ",f));
  
  //latex.DrawLatex(20,10,TString::Format("#circ %f ",i));
  
     latex.DrawLatex(3,22,"#bullet");
     latex.DrawLatex(2.83,25,"#diamond");
  
  
  
     latex.DrawLatex(4,28,"#scale[0.8]{HLT Paths(Run-1)}");
     latex.DrawLatex(4,22,"#scale[0.8]{Mu17_Mu8 (Luminosity 19.1 fb^{-1})}");
     latex.DrawLatex(4,25,"#scale[0.8]{Mu13_Mu8 (Luminosity 3.7 fb^{-1})}");
  
     latex.DrawLatex(4,19,"#scale[0.8]{Offline selection}");
     latex.DrawLatex(3,16,"#color[2]{#bullet}");
     latex.DrawLatex(4,16,"#scale[0.8]{Mu20_Mu10}");
     
     c1->SaveAs("acceptance_2d_2.png");  
     c1->SaveAs("acceptance_2d_2.eps");  
   

  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 1 (both muons in endcap)");
  leg_hist->AddEntry(hAccept2,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon pt","l");
  leg_hist->Draw();
  */
  
  
}
<file_sep>#include <iostream>
#include <algorithm>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "TTree.h"
#include "TClonesArray.h"
#include "TPRegexp.h"

#include "VHTauTau/TreeMaker/plugins/TriggerBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/Common/interface/TriggerResults.h"

static const unsigned int NmaxL1AlgoBit = 128;
static const unsigned int NmaxL1TechBit = 64;

// Constructor
TriggerBlock::TriggerBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _l1InputTag(iConfig.getParameter<edm::InputTag>("l1InputTag")),
  _hltInputTag(iConfig.getParameter<edm::InputTag>("hltInputTag")),
  _hltPathsOfInterest(iConfig.getParameter<std::vector<std::string> > ("hltPathsOfInterest"))
{
}
TriggerBlock::~TriggerBlock() {
  delete _l1physbits;
  delete _l1techbits;
  delete _hltpaths;
  delete _hltresults;
  delete _hltprescales;
}
void TriggerBlock::beginJob() 
{
  _l1physbits = new std::vector<int>();
  _l1techbits = new std::vector<int>();
  _hltpaths = new std::vector<std::string>();
  _hltresults = new std::vector<int>();
  _hltprescales = new std::vector<int>();

  std::string tree_name = "vhtree";
  TTree* tree = vhtm::Utility::getTree(tree_name);
  tree->Branch("l1physbits", "vector<int>", &_l1physbits);
  tree->Branch("l1techbits", "vector<int>", &_l1techbits);
  tree->Branch("hltpaths", "vector<string>", &_hltpaths);
  tree->Branch("hltresults", "vector<int>", &_hltresults);
  tree->Branch("hltprescales", "vector<int>", &_hltprescales);
}
void TriggerBlock::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
  bool changed = true;
  if (hltConfig.init(iRun, iSetup, _hltInputTag.process(), changed)) {
    // if init returns TRUE, initialisation has succeeded!
    edm::LogInfo("TriggerBlock") << "HLT config with process name " 
                                 << _hltInputTag.process() << " successfully extracted";
  } 
  else {
    // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
    // with the file and/or code and needs to be investigated!
    edm::LogError("TriggerBlock") << "Error! HLT config extraction with process name " 
                                  << _hltInputTag.process() << " failed";
    // In this case, all access methods will return empty values!
  }
  
}
void TriggerBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  //cloneTrigger->Clear();
  _l1physbits->clear();
  _l1techbits->clear();
  _hltpaths->clear();
  _hltresults->clear();
  _hltprescales->clear();

  edm::Handle<L1GlobalTriggerReadoutRecord> l1GtReadoutRecord;
  iEvent.getByLabel(_l1InputTag, l1GtReadoutRecord);

  if (l1GtReadoutRecord.isValid()) {
    edm::LogInfo("TriggerBlock") << "Successfully obtained L1GlobalTriggerReadoutRecord for label: " 
                                 << _l1InputTag;
    for (unsigned int i = 0; i < NmaxL1AlgoBit; ++i) {
      _l1physbits->push_back(l1GtReadoutRecord->decisionWord()[i] ? 1 : 0);
    }
    for (unsigned int i = 0; i < NmaxL1TechBit; ++i) {
      _l1techbits->push_back(l1GtReadoutRecord->technicalTriggerWord()[i] ? 1 : 0 );
    }
  } 
  else {
    edm::LogError("TriggerBlock") << "Error >> Failed to get L1GlobalTriggerReadoutRecord for label: " 
                                  << _l1InputTag;
  }
  edm::Handle<edm::TriggerResults> triggerResults;
  iEvent.getByLabel(_hltInputTag, triggerResults);
  if (triggerResults.isValid()) {
    edm::LogInfo("TriggerBlock") << "Successfully obtained " << _hltInputTag;
    const std::vector<std::string>& pathList = hltConfig.triggerNames();
    for (std::vector<std::string>::const_iterator it = pathList.begin();
                                                 it != pathList.end(); ++it) {
      if (_hltPathsOfInterest.size()) {
        int nmatch = 0;
        for (std::vector<std::string>::const_iterator kt = _hltPathsOfInterest.begin();
                                                     kt != _hltPathsOfInterest.end(); ++kt) {
	  nmatch += TPRegexp(*kt).Match(*it);
        }
        if (!nmatch) continue; 
      }
      _hltpaths->push_back(*it);

      int fired = 0;
      unsigned int index = hltConfig.triggerIndex(*it);
      if (index < triggerResults->size()) {
        if (triggerResults->accept(index)) fired = 1;
      }
      else {
	edm::LogInfo("TriggerBlock") << "Requested HLT path \"" << (*it) << "\" does not exist";
      }
      _hltresults->push_back(fired);

      int prescale = -1;
      if (hltConfig.prescaleSet(iEvent, iSetup) < 0) {
	edm::LogError("TriggerBlock") << "Error >> The prescale set index number could not be obtained";
      } 
      else {
        prescale = hltConfig.prescaleValue(iEvent, iSetup, *it);
      }
      _hltprescales->push_back(prescale);

      if (_verbosity)
	std::cout << ">>> Path: " << (*it) 
                  << ", prescale: " << prescale 
                  << ", fired: " << fired
                  << std::endl; 
    }
  } else {
    edm::LogError("TriggerBlock") << "Error >> Failed to get TriggerResults for label: " 
                                  << _hltInputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TriggerBlock);
<file_sep>void plot_corr(){
  //h2->SetLineColor(1);
  TCanvas *c1 = new TCanvas("c1","c1",700,400);
  c1->Divide(2,2);
  c1->cd(1);
  h1->SetXTitle("Reco. leading muon p_{T} in GeV/c");
  h1->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //h2->SetZTitle("Kinematic acceptance");
  //h2->GetZaxis()->SetRangeUser(0,1);
  //h2->SetStats(0);
  h1->Draw("COLZ");          //draw hist_2 first as it has a larger range
  
  c1->cd(2);
  h11->SetXTitle("Reco. leading muon p_{T} in GeV/c");
  h11->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  h11->Draw("COLZ");          //draw hist_2 first as it has a larger range
  c1->cd(3);
  h12->SetXTitle("Reco. leading muon p_{T} in GeV/c");
  h12->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  h12->Draw("COLZ");          //draw hist_2 first as it has a larger range
  c1->cd(4);
  h13->SetXTitle("Reco. leading muon p_{T} in GeV/c");
  h13->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  h13->Draw("COLZ");
            //draw hist_2 first as it has a larger range
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 1 (both muons in endcap)");
  leg_hist->AddEntry(h2,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon pt","l");
  leg_hist->Draw();
  */
  
  
}
<file_sep>#!/bin/sh
source ~/.bashrc
source /cmssoft/cms/cmsset_default.sh
export SCRAM_ARCH=slc6_amd64_gcc472
cd /home/amohapatra/samples_gem_studies/Backgrounds/CMSSW_6_2_0_SLHC23_patch1/src/
cmsenv
sed -e 's|file.txt|'$1'|' -e 's/dytaumu_14TeV_pu0.root/dytaumu_14TeV_pu0_'$1'.root/' test_skimmer_condor.py >& test_skimmer_condor_$1.py
cmsRun test_skimmer_condor_$1.py
sed -e "s|local|$1|g" condor_makeclass_local.C >& condor_makeclass_$1.C
root -b condor_makeclass_$1.C
sed -e "s|local|$1|g" condor_vhtree_local.C >& condor_vhtree_$1.C
root -b condor_vhtree_$1.C
<file_sep>#define GemAnalyze_cxx
#include "GemAnalyze.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>

void GemAnalyze::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L GemAnalyze.C
//      Root > GemAnalyze t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
   if (fChain == 0) return;

   double delRMin=1000.;
   double delR=0.;
   //double GenPtMatch=0.;
   double delphi=0.;
   double deleta=0.;
   double RecoMuonPtMatch=0.;
   double MuonInvariantMass=0.;
   TH1F *h1PtReco = new TH1F("h1PtReco","Reco Muon Pt",100,0,200);
   TH1F *h1PtGen = new TH1F("h1PtGen","Gen Muon Pt",100,0,200);
   TH1F *hMCMatch = new TH1F("hMCMatch","Muon Pt resolution",100,-3,3);
   TH1F *hInvMuon = new TH1F("hInvMuon","Invariant Mass plot",100,0,3);

   Long64_t nentries = fChain->GetEntriesFast();
   cout<<"Number of Entries is: "<<nentries<<endl;
   Long64_t nbytes = 0, nb = 0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
      Long64_t ientry = LoadTree(jentry);
      if (ientry < 0) break;
      nb = fChain->GetEntry(jentry);   nbytes += nb;
      // cout<<nMuon<<endl;
      /* for (int i=0 ; i<nMuon; i++){
	h1PtReco->Fill(Muon_pt[i]);
      }
      //cout<<GenParticle_pdgId<<endl;
      
	
      for (int i=0; i<nGenParticle; i++){
	if (GenParticle_pdgId[i] == 13){
	  h1PtGen->Fill(GenParticle_pt[i]);
	}
	}*/
      cout<<nGenParticle<<endl;
      //MC Truth Matching
       for (int i=0;i<nGenParticle; i++){
	if (GenParticle_pdgId[i] == 13 && ((fabs(GenParticle_eta[i]) > 1.6) && (fabs(GenParticle_eta[i]) < 2.2))){

	  delRMin=1000;
	  delR=0.;
	  RecoMuonPtMatch=0.;
	  for (int j=0; j<nMuon; j++){
	    if ((fabs(Muon_eta[j]) > 1.6) && (fabs(Muon_eta[j]) < 2.2)){
	      delphi=Muon_phi[j]-GenParticle_phi[i];
	      deleta=Muon_eta[j]-GenParticle_eta[i];
	      delR=sqrt((delphi*delphi)+(deleta*deleta));
	      if (delR<=delRMin){
		delRMin=delR;
		RecoMuonPtMatch=Muon_pt[j];
	      //cout<<GenPtMatch<<endl;
	      }
	    }
	  }
	  
	  hMCMatch->Fill(RecoMuonPtMatch-GenParticle_pt[i]);
	  h1PtGen->Fill(GenParticle_pt[i]);
	  h1PtReco->Fill(RecoMuonPtMatch);
	}
      }    
      /*for (int i=0; i<nGenParticle; i++){
	if (GenParticle_pdgId[i]==15) cout<<nGenParticle<<endl;
	}*/

      /*      
      for (int i=0; i<nGenParticle; i++){
	for (int j=0; j<nGenParticle; j++){
	  if (i != j){
	    if (GenParticle_pdgId[i] == 13 && GenParticle_pdgId[j]==13){
	      //cout<<"hi"<<endl;
	      MuonInvariantMass=sqrt(fabs(((GenParticle_energy[i]+GenParticle_energy[j])*(GenParticle_energy[i]+GenParticle_energy[j]))-((GenParticle_p[i]+GenParticle_p[j])*(GenParticle_p[i]+GenParticle_p[j]))));
	      if (MuonInvariantMass != 0) {hInvMuon->Fill(MuonInvariantMass);}
	    }
	  }
	}
	}*/
   }
}
<file_sep>#define vhtree_cxx
#include "vhtree.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <vector>
#include <fstream>
#include <TMath.h>
void vhtree::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L vhtree.C
//      Root > vhtree t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
   if (fChain == 0) return;
   double delRMin=0.03;
   double delR=0.;
   double GenMuonPt=0.;                                                                                                            
   double delphi=0.;
   double deleta=0.;
   Double_t RecoMuonPt=0.;
   double RecoMuonEta=0.;
   double inv_mass=0.;
   double ImpParam=0.;
   double MuonDZ=0.;
   double MuonChi2=0.;
   double SumMuonChi2=0.;
   double e1=0.;
   double e2=0.;
   double p1x=0.;
   double p2x=0.;
   double p1y=0.;
   double p2y=0.;
   double p1z=0.;
   double p2z=0.;
   double phi_1=0.;
   double phi_tau_1=0.;
   double phi_2=0.;
   double phi_tau_2=0.;
   double theta_1=0;
   double theta_2=0;
   double metx=0.;
   double mety=0.;
   double p_1=0.;
   double p_2=0.;
   double x_1=0;
   double x_2=0;
   double pvis_1=0;
   double pvis_2=0;
   double inv_mass_vis=0;
   Double_t total_events=0;
   Double_t events=0;
   Double_t mag=0;
   Double_t dimuoneta=0;
   Double_t dimuonratiopt=0;
   Int_t counter=0;
   Double_t GenMuonCharge=0;
   Double_t RecoMuonCharge=0;
   Double_t numerator=0;
   Double_t denominator=0;
   Int_t counter_ba=0;
   Int_t counter_ec=0;
   Int_t counter_out=0;
   Double_t cost=0.;
   double dimuonpt=0;
   double summuonpt=0;
   double count=0;
   double dcasig[2]={0};
   double phi_pmuon_met = 0;
   ofstream myfile("acceptance.file",ios::app);
   ofstream myfile2("acceptance2.file",ios::app);
   
   //TH1F::SetDefaultSumw2();
   
   TH1F *h1PtReco = new TH1F("h1PtReco","Reco Muon Pt",300,0,300);
   TH1F *h1PtGen = new TH1F("h1PtGen","Gen Muon Pt",300,0,300);

   TH1F *h1DiMuonPtReco = new TH1F("h1DiMuonPtReco","Reco DiMuon Pt",300,0,300);
   
   TH1F *h1SumMuonPtReco = new TH1F("h1SumMuonPtReco","Reco Sum Muon Pt",300,0,300);
   
   TH1F *h1DiMuonSumPtRatio = new TH1F("h1DiMuonSumPtRatio","Ratio of dimuon pT to the muon sum pT",200,0,2);

   TH1F *h1MuonImpParSig = new TH1F("h1MuonImpParSig","DCA Significance of muons",100,-5,5);
   
   TH1F *h1PhiPMuonMet = new TH1F("h1PhiPMuonMet","Azimuthal Angle between the positive muon and MET ",10,0,3);

   TH1F *h1DecayAngleDiMuonRest = new TH1F("h1DecayAngleDiMuonRest","Decay Angle of the positive muon in the dimuon rest frame",10,-1,1);

   TH2F *hSumMuonDiMuon=new TH2F("hSumMuonDiMuon","Corr",300,0,300,300,0,300);

   
   TH1F *h1PtLeading = new TH1F("h1PtLeading","Leading Muon Pt",100,0,100);
   TH1F *h1PtSubLeading = new TH1F("h1PtSubLeading","SubLeading Muon Pt",100,0,100);
   
   TH1F *h1PtLeadingi = new TH1F("h1PtLeadingi","Integrated Leading Muon Pt",100,0,100);
   TH1F *h1PtSubLeadingi = new TH1F("h1PtSubLeadingi","Integrated SubLeading Muon Pt",100,0,100);
   


   TH1F *h1EtaReco = new TH1F("h1EtaReco","Reco Muon Eta",100,-7,+7);
   //TH1F *h1EtaGen = new TH1F("h1EtaGen","Gen Muon Eta",100,-5,+5);
   TH1F *h1DiMuonEtaReco = new TH1F("h1DiMuonEtaReco","Dimuon Eta (with GEMs)",100,-5,5);
   
   TH1F *hPhiReco = new TH1F("hPhiReco","Difference in Phi between the two muons in multiples of #pi",100,-2,2);

   
   
   TH1F *hMCMatchEC = new TH1F("hMCMatchEC","Muon pT resolution in 1.5<|#eta|<2.2",200,-0.1,0.1);
   TH1F *hMCMatchBa = new TH1F("hMCMatchBa","Muon pT resolution in |#eta|<1.5",200,-0.1,0.1);
   
   TH1F *hLeadMuon1 = new TH1F("hLeadMuon1","Leading Muon and Subleading Muon in 1.5<|#eta|<2.2",100,0,100);
   TH1F *hLeadMuon2 = new TH1F("hLeadMuon2","Leading Muon in 1.5<|#eta|<2.2, subleading muon in |#eta|<1.5 ",100,0,100);
   TH1F *hLeadMuon3 = new TH1F("hLeadMuon3","Leading Muon in |#eta|<1.5, subleading muon in 1.5<|#eta|<2.2",100,0,100);
   //TH1F *hLeadMuonAll = new TH1F("hLeadMuonAll","Overall Leading muon distribution",100,0,100);
   
   

   TH1F *hSubLeadMuon1 = new TH1F("hSubLeadMuon1","Leading Muon and Subleading Muon in 1.5<|#eta|<2.2",100,0,100);
   TH1F *hSubLeadMuon2 = new TH1F("hSubLeadMuon2","Leading Muon in 1.5<|#eta|<2.2, subleading muon in |#eta|<1.5",100,0,100);
   TH1F *hSubLeadMuon3 = new TH1F("hSubLeadMuon3","Leading Muon in |#eta|<1.5, subleading muon in 1.5<|#eta|<2.2",100,0,100);
   //TH1F *hSubLeadMuonAll = new TH1F("hSubLeadMuonAll","Overall Subleading muon distribution",100,0,100);


   TH2F *h1 = new TH2F("h1","Correlation plot between Subleading and leading muon Pt(Overall)",30,0,30,30,0,30);
   TH2F *h11 = new TH2F("h11","Correlation plot between Subleading and leading muon Pt(EC(Lead), EC(sublead))",30,0,30,30,0,30);
   TH2F *h12 = new TH2F("h12","Correlation plot between Subleading and leading muon Pt(EC(Lead),Barrel(Sublead))",30,0,30,30,0,30);
   TH2F *h13 = new TH2F("h13","Correlation plot between Subleading and leading muon Pt(EC(sublead),Barrel(Lead))",30,0,30,30,0,30);
   //TH3F *h2 = new TH3F("h2","acceptance plot",300,0,300,100,0,150,100,0,1);
   TH2F *hAcceptAll = new TH2F("hAcceptAll","Overall acceptance plot",120,0,30,120,0,30);
   TH2F *hAccept1 = new TH2F("hAccept1","Leading Muon and Subleading Muon in 1.5<|#eta|<2.2      ",120,0,30,120,0,30);
   TH2F *hAccept2 = new TH2F("hAccept2","Leading Muon in 1.5<|#eta|<2.2, subleading muon in |#eta|<1.5",120,0,30,120,0,30);
   TH2F *hAccept3 = new TH2F("hAccept3","Leading Muon in |#eta|<1.5, subleading muon in 1.5<|#eta|<2.2      ",120,0,30,120,0,30);
   
   //TProfile2D *h2 = new TProfile2D("h2","acceptance plot",100,0,300,100,0,300,0,1);  
   //TGraph2D *t2 = new TGraph2D();
   TH1F *hInvTau = new TH1F("hInvTau","Invariant Mass plot for Taus",100,0,300);
   TH1F *hInvMuon = new TH1F("hInvMuon","Invariant Mass plot for Muons(visible)",100,0,300);

   
   
   TH1F *hImPEC = new TH1F("hImPEC","Impact parameter plot in 1.5<|#eta|<2.2",100,-0.06,0.06);
   TH1F *hImPBa = new TH1F("hImPBa","Impact parameter plot in |#eta|<1.5",100,-0.06,0.06);
   
   TH1F *hDZEC = new TH1F("hDZEC","Muon DZ plot End cap",100,-10,10);
   TH1F *hDZBa = new TH1F("hDZBa","Muon DZ plot barrel",100,-10,10);

   TH1F *hChiEC = new TH1F("hChiEC","Muon Chi plot End cap",100,0,16);
   TH1F *hChiBa = new TH1F("hChiBa","Muon Chi plot barrel",100,0,16);

   TH1F *hImPECEr = new TH1F("hImPECEr","Error in Impact parameter plot End cap",100,0,16);
   TH1F *hImPBaEr = new TH1F("hImPBaEr","Error in Impact parameter plot barrel",100,0,16);

   //Muon eta plots for pT threshold !

   TH1F *hEtaPt10 = new TH1F("hEtaPt10","Reco Muon Eta 10",30,0,3);
   TH1F *hEtaPt15 = new TH1F("hEtaPt15","Reco Muon Eta 15",30,0,3);
   TH1F *hEtaPt20 = new TH1F("hEtaPt20","Reco Muon Eta 20",30,0,3);
   TH1F *hEtaPt25 = new TH1F("hEtaPt25","Reco Muon Eta 25",30,0,3);
   TH1F *hEtaPt30 = new TH1F("hEtaPt30","Reco Muon Eta 30",30,0,3);
   TH1F *hEtaPt35 = new TH1F("hEtaPt35","Reco Muon Eta 35",30,0,3);

   //2-D histograms

   TH2F *hEtaResEC = new TH2F("hEtaResEC","Eta vs MuonPt resolution in Endcap",100,-3,3,100,-5,5);
   TH2F *hEtaResBa = new TH2F("hEtaResBa","Eta vs MuonPt resolution in barrel",100,-3,3,100,-5,5);
   TH2F *hEtaResAll = new TH2F("hEtaResAll","Eta vs MuonPt resolution Overall",100,-3,3,100,-5,5);
   
   TH2F *hEtaPtEC = new TH2F("hEtaPtEC","Eta vs MuonPt in Endcap",100,-3,3,100,0,200);
   TH2F *hEtaPtBa = new TH2F("hEtaPtBa","Eta vs MuonPt in barrel",100,-3,3,100,0,200);
   TH2F *hEtaPtAll = new TH2F("hEtaPtAll","Reco Muon |#eta| vs p_{T}",100,0,3,100,0,200);
   


   //std::vector<double> leadmuonpt;
   //std::vector<double> subleadmuonpt;
   Double_t pt_cut=30.;
   Double_t bin_width=0.25;
   const int bin_size_sl=pt_cut/bin_width;
   const int bin_size_l=pt_cut/bin_width;
   
   Double_t leadmuonpt[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt[bin_size_sl]={0};
   
   Double_t leadmuonpt1[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt1[bin_size_sl]={0};
   
   Double_t leadmuonpt2[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt2[bin_size_sl]={0};
   
   Double_t leadmuonpt3[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt3[bin_size_sl]={0};

   //TFile f("~/histos_mva_dytt.root","recreate");
   

   TFile *f = new TFile("~/histos_mva_dytt.root","recreate");
   //cout<<"New file created"<<endl;
   TTree *tree = new TTree("gluHsignal","variables");
   //cout<<"New tree created"<<endl;
   tree->Branch("dimuoneta",&dimuoneta,"dimuoneta/D");
   //tree->Branch("h1DiMuonEtaReco","TH1F",&h1DiMuonEtaReco,32000,0);
   tree->Branch("dimuonratiopt",&dimuonratiopt,"dimuonratiopt/D");
   //tree->Branch("coll_approx",&dimuonratiopt,"coll_approx/D");
   tree->Branch("dcasig",&dcasig,"dcasig[2]/D");
   tree->Branch("phi_pmuon_met",&phi_pmuon_met,"phi_pmuon_met/D");
   tree->Branch("cost",&dcasig,"cost/D");
   
   Long64_t nentries = fChain->GetEntriesFast();
   cout<<"Number of events "<<nentries<<endl;
   int dimuon=0;
   Long64_t nbytes = 0, nb = 0;
   //for (Long64_t jentry=0;jentry<nentries;jentry++) {
   for (Long64_t jentry=0;jentry<nentries;jentry++) {
     Long64_t ientry = LoadTree(jentry);
     if (ientry < 0) break;
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     
     if (nMuon<2) continue;
     if ((fabs(Muon_eta[0]) >= 2.1))continue;
     if ((fabs(Muon_eta[1]) >= 2.1))continue;
     if ((fabs(Muon_pt[0]) <= 20))continue;
     if ((fabs(Muon_pt[1]) <= 10))continue;
     if ((Muon_nMatchedStations[0])<1)continue; 
     if ((Muon_nMatchedStations[1])<1)continue; 
     if ((Muon_trackerLayersWithMeasurement[0])<=5)continue; 
     if ((Muon_trackerLayersWithMeasurement[1])<=5)continue; 
     if ((Muon_pixHits[0])<1)continue; 
     if ((Muon_pixHits[1])<1)continue; 
     
     if ((Muon_globalChi2[0])>=10)continue; 
     if ((Muon_globalChi2[1])>=10)continue; 
     if (fabs(Muon_trkD0[0])>=0.04)continue; 
     if (fabs(Muon_trkD0[1])>=0.04)continue; 
     //if (fabs(Muon_trkDz[0])>=1)continue; 
     //if (fabs(Muon_trkDz[1])>=1)continue; 
     if (fabs(Muon_vtxDistZ[0])>=0.1)continue; 
     if (fabs(Muon_vtxDistZ[1])>=0.1)continue; 
     if ((Muon_ptError[0]/Muon_pt[0])*100>=10) continue;
     if ((Muon_ptError[1]/Muon_pt[1])*100>=10) continue;
     if (fabs((Muon_phi[0]-Muon_phi[1])) <= 2) continue;
     //if ((fabs(Muon_pt[0]) < 5))continue;
     //if ((fabs(Muon_pt[1]) < 5))continue;
     //if (abs(Muon_phi[0]-Muon_phi[1] < 2.0))continue;
     
     e1=Muon_energy[0];
     e2=Muon_energy[1];
     p1x=Muon_px[0];
     p2x=Muon_px[1];
     p1y=Muon_py[0];
     p2y=Muon_py[1];
     p1z=Muon_pz[0];
     p2z=Muon_pz[1];
     inv_mass_vis=sqrt((e1+e2)*(e1+e2)-((p1x+p2x)*(p1x+p2x)+(p1y+p2y)*(p1y+p2y)+(p1z+p2z)*(p1z+p2z)));
     if (inv_mass_vis<=35) continue;
     
     /*count=0;
     for (int i=0;i<nJet;i++){
       if (Jet_pt[i]<30) ++count;
     }
     if (count<1) continue;
     */
     ++dimuon;

     phi_1=Muon_phi[0];
     phi_2=Muon_phi[1];
     phi_tau_1=Tau_phi[0];
     phi_tau_2=Tau_phi[1];
     //cout<<phi_tau_1<<endl;
     hInvTau->Fill(phi_tau_1-phi_tau_2);
     //phi_tau_2=Tau_phi[1];
     theta_1=2*atan(exp(-1*Muon_eta[0]));
     theta_2=2*atan(exp(-1*Muon_eta[1]));
     metx=MET_metx[0];
     mety=MET_mety[0];
     //cout<<metx<<" "<<mety<<endl;
     p_1=(metx*sin(phi_2)-mety*cos(phi_2))/(sin(theta_1)*(cos(phi_1)-sin(phi_1)));
     p_2=(metx*sin(phi_1)-mety*cos(phi_1))/(sin(theta_2)*(cos(phi_2)-sin(phi_2)));
     pvis_1=sqrt(Muon_px[0]*Muon_px[0]+Muon_py[0]*Muon_py[0]+Muon_pz[0]*Muon_pz[0]);
     pvis_2=sqrt(Muon_px[1]*Muon_px[1]+Muon_py[1]*Muon_py[1]+Muon_pz[1]*Muon_pz[1]);
     //cout<<p_1<<endl;
     x_1=pvis_1/(pvis_1+p_1);
     x_2=pvis_2/(pvis_2+p_2);
     
     /*e1=Muon_energy[0];
     e2=Muon_energy[1];
     p1x=Muon_px[0];
     p2x=Muon_px[1];
     p1y=Muon_py[0];
     p2y=Muon_py[1];
     p1z=Muon_pz[0];
     p2z=Muon_pz[1];
     inv_mass_vis=sqrt((e1+e2)*(e1+e2)-((p1x+p2x)*(p1x+p2x)+(p1y+p2y)*(p1y+p2y)+(p1z+p2z)*(p1z+p2z)));*/
     inv_mass=inv_mass_vis/sqrt(fabs(x_1*x_2));
     hPhiReco->Fill(((Muon_phi[0]-Muon_phi[1])/(22.0/7.0)));
     //if ((fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) >= 1.1 || (fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) <= 0.9) cout<<(Muon_phi[0]-Muon_phi[1])/(22.0/7.0)<<" Pi"<<endl;
     if (inv_mass>0) {
       /*if ((fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) >= 1.3 || (fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) <= 0.7)hInvTau->Fill(inv_mass);*/
       hInvMuon->Fill(inv_mass_vis);
     }
     if (inv_mass<0) {
       /*if ((fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) >= 1.3 || (fabs((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))) <= 0.7)hInvTau->Fill(inv_mass);*/
       cout<<"less than zero"<<endl;
     }
     
     
     h1DiMuonPtReco->Fill(sqrt(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1]))));
     h1SumMuonPtReco->Fill(Muon_pt[0]+Muon_pt[1]);
     if ((Muon_pt[0]+Muon_pt[1])!=0) dimuonratiopt=(sqrt(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1])))/(Muon_pt[0]+Muon_pt[1]));
     //dimuonratiopt=(dimuonpt/SumMuonPt);
     h1DiMuonSumPtRatio->Fill(dimuonratiopt);
     summuonpt=Muon_pt[0]+Muon_pt[1];
     dimuonpt=sqrt(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1])));
     hSumMuonDiMuon->Fill(summuonpt,dimuonpt);
     //cout<<(Muon_pt[0]+Muon_pt[1])<<endl;
     //cout<<dimuonratiopt<<endl;
     //cout<<"DiMuon pT"<<sqrt(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1])))<<"Sum of pT "<<Muon_pt[0]+Muon_pt[1]<<endl;

     mag=sqrt(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1]))+((Muon_pz[0]+Muon_pz[1])*(Muon_pz[0]+Muon_pz[1])));
     /*if ((mag-Muon_pz[0]+Muon_pz[1])!=0)*/dimuoneta=0.5*log((mag+Muon_pz[0]+Muon_pz[1])/(mag-(Muon_pz[0]+Muon_pz[1])));
     h1DiMuonEtaReco->Fill(dimuoneta);
     
     //h1MuonImpParSig->Fill(log10(Muon_trkD0[0]/Muon_trkD0Error[0]));
     //h1MuonImpParSig->Fill(log10(Muon_trkD0[1]/Muon_trkD0Error[1]));
     dcasig[0]=log10(Muon_trkD0[0]/Muon_trkD0Error[0]);
     dcasig[1]=log10(Muon_trkD0[1]/Muon_trkD0Error[1]);

     if (Muon_charge[0]>0)h1PhiPMuonMet->Fill(Muon_phi[0]-MET_metphi[0]);
     if (Muon_charge[1]>0)h1PhiPMuonMet->Fill(Muon_phi[1]-MET_metphi[1]);

     phi_pmuon_met=Muon_phi[0]-MET_metphi[0];

     //if (((Muon_phi[0]-Muon_phi[1])/(22.0/7.0))==1) cout<<"meow"<<endl;

       //Routine to calculate dimuon rest frame

     // --- Get the muons parameters in the CM frame
     //
     TLorentzVector pMu1CM(p1x,p1y,p1z,e1);
     TLorentzVector pMu2CM(p2x,p2y,p2z,e2);
     //
     // --- Obtain the dimuon parameters in the CM frame
     //
     TLorentzVector pDimuCM=pMu1CM+pMu2CM;
     //
     // --- Translate the dimuon parameters in the dimuon rest frame
     //
     TVector3 beta=(-1./pDimuCM.E())*pDimuCM.Vect();
     TLorentzVector pMu1Dimu=pMu1CM;
     TLorentzVector pMu2Dimu=pMu2CM;
     pMu1Dimu.Boost(beta);
     pMu2Dimu.Boost(beta);
     //
     // --- Determine the z axis for the calculation of the polarization angle
     // (i.e. the direction of the dimuon in the CM system)
     //
     TVector3 zaxis;
     zaxis=(pDimuCM.Vect()).Unit();

     if (Muon_charge[0]>0)cost = zaxis.Dot((pMu1Dimu.Vect()).Unit());
     if (Muon_charge[1]>0)cost = zaxis.Dot((pMu2Dimu.Vect()).Unit());
     
     //h1DecayAngleDiMuonRest->Fill(cost);
     //cout<<cost<<endl;
     
     //cout<<dimuoneta<<endl;
     //if ((((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1]))+((Muon_pz[0]+Muon_pz[1])*(Muon_pz[0]+Muon_pz[1])))<0.)
     //cout<<(((Muon_px[0]+Muon_px[1])*(Muon_px[0]+Muon_px[1]))+((Muon_py[0]+Muon_py[1])*(Muon_py[0]+Muon_py[1]))+((Muon_pz[0]+Muon_pz[1])*(Muon_pz[0]+Muon_pz[1])))<<endl;
     //tree->Fill();
     //if (((mag+Muon_pz[0]+Muon_pz[1])/(mag-Muon_pz[0]+Muon_pz[1]))<0)cout<<"neg"<<endl;
     
     /*
     if (Muon_pt[0]>=Muon_pt[1]){
       h1PtLeading->Fill(Muon_pt[0]);
       h1PtSubLeading->Fill(Muon_pt[1]);
     }
     
     else if (Muon_pt[0]<Muon_pt[1]){
       h1->Fill(Muon_pt[1],Muon_pt[0]);
       //cout<<Muon_pt[1]<<" "<<Muon_pt[0]<<endl;
     }
     
     

     //Different cases
     if (Muon_pt[0]>Muon_pt[1]){
       if (((fabs(Muon_eta[0]) > 1.5) && (fabs(Muon_eta[0]) < 2.2)) && ((fabs(Muon_eta[1]) > 1.5) && (fabs(Muon_eta[1]) < 2.2))){
	   hLeadMuon1->Fill(Muon_pt[0]);
	   hSubLeadMuon1->Fill(Muon_pt[1]);
	   h1->Fill(Muon_pt[0],Muon_pt[1]);
	   h11->Fill(Muon_pt[0],Muon_pt[1]);
	   if (Muon_pt[0]<pt_cut){
	     for (int i=0;i<bin_size_l;i++){
	       if (Muon_pt[0]>=i*bin_width && Muon_pt[0]<(i+1)*bin_width){
		 leadmuonpt[i]+=1;
		 leadmuonpt1[i]+=1;
	       }
	     }
	   }
       
	   if (Muon_pt[1]<pt_cut){
	     for (int i=0;i<bin_size_sl;i++){
	       if (Muon_pt[1]>i*bin_width && Muon_pt[1]<=(i+1)*bin_width){
		 subleadmuonpt[i]+=1;
		 subleadmuonpt1[i]+=1;
	       }
	     }
	   }
	 }
	 if (((fabs(Muon_eta[0]) > 1.5) && (fabs(Muon_eta[0]) < 2.2)) && (fabs(Muon_eta[1]) < 1.5)){
	   h1->Fill(Muon_pt[0],Muon_pt[1]);
	   h12->Fill(Muon_pt[0],Muon_pt[1]);
	   hLeadMuon2->Fill(Muon_pt[0]);
	   hSubLeadMuon2->Fill(Muon_pt[1]);
	   if (Muon_pt[0]<pt_cut){
	     for (int i=0;i<bin_size_l;i++){
	       if (Muon_pt[0]>=i*bin_width && Muon_pt[0]<(i+1)*bin_width){
		 leadmuonpt[i]+=1;
		 leadmuonpt2[i]+=1;
	       }
	     }
	   }
       
	   if (Muon_pt[1]<pt_cut){
	     for (int i=0;i<bin_size_sl;i++){
	       if (Muon_pt[1]>i*bin_width && Muon_pt[1]<=(i+1)*bin_width){
		 subleadmuonpt[i]+=1;
		 subleadmuonpt2[i]+=1;
	       }
	     }
	   }
	 }
	 if ((fabs(Muon_eta[0]) < 1.5) && ((fabs(Muon_eta[1]) > 1.5) && (fabs(Muon_eta[1]) < 2.2))){
	   h1->Fill(Muon_pt[0],Muon_pt[1]);
	   h13->Fill(Muon_pt[0],Muon_pt[1]);
	   hLeadMuon3->Fill(Muon_pt[0]);
           hSubLeadMuon3->Fill(Muon_pt[1]);
	   if (Muon_pt[0]<pt_cut){
	     for (int i=0;i<bin_size_l;i++){
	       if (Muon_pt[0]>=i*bin_width && Muon_pt[0]<(i+1)*bin_width){
		 leadmuonpt[i]+=1;
		 leadmuonpt3[i]+=1;
	       }
	     }
	   }
       
	   if (Muon_pt[1]<pt_cut){
	     for (int i=0;i<bin_size_sl;i++){
	       if (Muon_pt[1]>i*bin_width && Muon_pt[1]<=(i+1)*bin_width){
		 subleadmuonpt[i]+=1;
		 subleadmuonpt3[i]+=1;
	       }
	     }
	   }
	 }
     } 
       else{
	 if (((fabs(Muon_eta[1]) > 1.5) && (fabs(Muon_eta[1]) < 2.2)) && ((fabs(Muon_eta[0]) > 1.5) && (fabs(Muon_eta[0]) < 2.2))){
	   hLeadMuon1->Fill(Muon_pt[1]);
	   hSubLeadMuon1->Fill(Muon_pt[0]);
	 }
	 if (((fabs(Muon_eta[1]) > 1.5) && (fabs(Muon_eta[1]) < 2.2)) && (fabs(Muon_eta[0]) < 1.5)){
	   hLeadMuon2->Fill(Muon_pt[1]);
	   hSubLeadMuon2->Fill(Muon_pt[0]);
	 }
	 if ((fabs(Muon_eta[1]) < 1.5) && ((fabs(Muon_eta[0]) > 1.5) && (fabs(Muon_eta[0]) < 2.2))){
	   hLeadMuon3->Fill(Muon_pt[1]);
           hSubLeadMuon3->Fill(Muon_pt[0]);
	 }
      
       }
     /*for (int j=0;j<nGenParticle;j++){
       delRMin=0.03;
       for (int i=0;i<nMuon; i++){
	 
	 //counter=0;
	 RecoMuonEta=Muon_eta[i];
       
	 
	 delphi=Muon_phi[i]-GenParticle_phi[j];
	 deleta=Muon_eta[i]-GenParticle_eta[j];
	 delR=sqrt(delphi*delphi+deleta*deleta);
	 if (delR < delRMin){
	   delRMin=delR;
	   if ((fabs(RecoMuonEta) > 1.5) && (fabs(RecoMuonEta) < 2.2)){
	     //cout<<"haha"<<endl;
	     denominator++;
	     //cout<<"Reco Muon Charge "<<Muon_charge[i]<<"Gen Muon Charge "<<GenParticle_charge[j]<<endl;
	     GenMuonCharge=GenParticle_charge[j];
	     RecoMuonCharge=Muon_charge[i];
	     if (GenMuonCharge-RecoMuonCharge != 0) cout<<"MISMATCH"<<endl;//numerator++;
	   }
	 }
	 //cout<<delR<<endl;
       }
       }
     //if (denominator!=0)cout<<"MIS ID "<<numerator/denominator<<endl;
     for (int i=0;i<nMuon; i++){
       RecoMuonEta=Muon_eta[i];
       if (fabs(RecoMuonEta)>2.4) cout<<"one"<<endl;
       GenMuonPt=Muon_ptgen[i];
       ImpParam=Muon_trkD0[i];
       MuonDZ=Muon_trkDz[i];
       MuonChi2=Muon_globalChi2[i];
       RecoMuonPt=Muon_pt[i];
     
       if ((fabs(RecoMuonEta) > 1.5) && (fabs(RecoMuonEta) < 2.2)){
	 hMCMatchEC->Fill((GenMuonPt-RecoMuonPt)/GenMuonPt);
	 hImPEC->Fill(ImpParam);
	 hDZEC->Fill(MuonDZ);
	 hChiEC->Fill(MuonChi2);
	 hEtaPtEC->Fill(RecoMuonEta,RecoMuonPt);
	 //if(Muon_charge[i]-Muon_chargegen[i]!=0) cout<<"MISMATCH"<<endl;
	 //hEtaResEC->Fill(RecoMuonPt-GenMuonPt,RecoMuonEta);
       }
       if ((fabs(Muon_eta[i]) < 1.5)){
	 hMCMatchBa->Fill((GenMuonPt-RecoMuonPt)/GenMuonPt);
	 hImPBa->Fill(ImpParam);
	 hDZBa->Fill(MuonDZ);
	 hChiBa->Fill(MuonChi2);
	 hEtaPtBa->Fill(RecoMuonEta,RecoMuonPt);
       }
       h1PtGen->Fill(GenMuonPt);
       h1PtReco->Fill(RecoMuonPt);
       h1EtaReco->Fill(RecoMuonEta);
       hEtaPtAll->Fill(fabs(RecoMuonEta),RecoMuonPt);
       if (RecoMuonPt>10.){
	 hEtaPt10->Fill(fabs(RecoMuonEta));
	 //if(fabs(RecoMuonEta) < 1.5)counter_barrel++;
       }
       if (RecoMuonPt>15.){
	 hEtaPt15->Fill(fabs(RecoMuonEta));
       }
       if (RecoMuonPt>20.){hEtaPt20->Fill(fabs(RecoMuonEta));}
       if (RecoMuonPt>25.){hEtaPt25->Fill(fabs(RecoMuonEta));}
       if (RecoMuonPt>30.){hEtaPt30->Fill(fabs(RecoMuonEta));}
       if (RecoMuonPt>35.){hEtaPt35->Fill(fabs(RecoMuonEta));}
       
       if(fabs(RecoMuonEta) < 1.5)counter_ba++;
       if((fabs(RecoMuonEta) > 1.5) && (fabs(RecoMuonEta) < 2.2))counter_ec++;
       if((fabs(RecoMuonEta) > 2.2) && (fabs(RecoMuonEta) < 2.4))counter_out++;
       
       
       //if ()
       }*/
     tree->Fill();
     //f->cd();
     //f1->Write();
     //f->Close();
     }
   //   
   
   //h1DiMuonSumPtRatio->Write();
   //h1MuonImpParSig->Write();   
   //h1DiMuonEtaReco->Write();
   //h1PhiPMuonMet->Write();   
   //hSumMuonDiMuon->Write();
   //f->Close();
     cout<<"Number of dimuon events "<<dimuon<<" BR of di tau to dimuon "<<((float)dimuon/(float)nentries)*100<<endl;
   cout<<"Number of muons in barrel "<<(float)counter_ba/(float)(dimuon*2)<<" Number of muons in endcap "<<(float)counter_ec/(float)(dimuon*2)<<" Number of muons outside "<<(float)counter_out/(float)(dimuon*2)<<endl; 
   f->cd();
   tree->Write();
   f->Close();
   

  //Overall
   /*       
   total_events=0;
   events=0;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       if(leadmuonpt[i]!=0 && subleadmuonpt[j]!=0)total_events+=leadmuonpt[i]*subleadmuonpt[j];
     }
   }
   cout<<total_events<<endl;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       events=0;
       for (int k=i;k<bin_size_l;k++){
	 for (int l=j;l<k;l++){
	   if(leadmuonpt[k]!=0 && subleadmuonpt[l]!=0)events+=leadmuonpt[k]*subleadmuonpt[l];
	 }
       }
       hAcceptAll->Fill(i*bin_width,j*bin_width,((Double_t)events/(Double_t)total_events)*100);
     }
   }
   

   //Case-1
   
   total_events=0;
   events=0;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       if(leadmuonpt1[i]!=0 && subleadmuonpt1[j]!=0)total_events+=leadmuonpt1[i]*subleadmuonpt1[j];
     }
   }
   cout<<total_events<<endl;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       events=0;
       for (int k=i;k<bin_size_l;k++){
	 for (int l=j;l<k;l++){
	   if(leadmuonpt1[k]!=0 && subleadmuonpt1[l]!=0)events+=leadmuonpt1[k]*subleadmuonpt1[l];
	 }
       }
       hAccept1->Fill(i*bin_width,j*bin_width,((Double_t)events/(Double_t)total_events)*100);
     }
   }
   
   //Case-2
   total_events=0;
   events=0;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       if(leadmuonpt2[i]!=0 && subleadmuonpt2[j]!=0)total_events+=leadmuonpt2[i]*subleadmuonpt2[j];
     }
   }
   cout<<total_events<<endl;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       events=0;
       for (int k=i;k<bin_size_l;k++){
	 for (int l=j;l<k;l++){
	   if(leadmuonpt2[k]!=0 && subleadmuonpt2[l]!=0)events+=leadmuonpt2[k]*subleadmuonpt2[l];
	 }
       }
       hAccept2->Fill(i*bin_width,j*bin_width,((Double_t)events/(Double_t)total_events)*100);
     }
   }

   //Case-3

   total_events=0;
   events=0;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       if(leadmuonpt3[i]!=0 && subleadmuonpt3[j]!=0)total_events+=leadmuonpt3[i]*subleadmuonpt3[j];
     }
   }
   cout<<total_events<<endl;
   for (int i=0;i<bin_size_l;i++){
     for (int j=0;j<i;j++){
       events=0;
       for (int k=i;k<bin_size_l;k++){
	 for (int l=j;l<k;l++){
	   if(leadmuonpt3[k]!=0 && subleadmuonpt3[l]!=0)events+=leadmuonpt3[k]*subleadmuonpt3[l];
	 }
       }
       //myfile2<<i<<" "<<j<<" "<<" "<<events<<" "<<total_events<<" "<<(Double_t)events/(Double_t)total_events<<endl;
       //myfile2<<i*bin_width<<" "<<j*bin_width<<" "<<(Double_t)events/(Double_t)total_events<<endl;
       hAccept3->Fill(i*bin_width,j*bin_width,((Double_t)events/(Double_t)total_events)*100);
       //hAccept1->Fill(i*bin_width,j*bin_width);
     }
   }
   */
}

   //hAcceptAll->Write();
   /*
   //Time to beautify most of the plots
   hLeadMuon1->SetLineColor(1);
   hSubLeadMuon1->SetLineColor(4);
   hLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
   hSubLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
   hLeadMuon1->SetYTitle("Number of Events/GeV");
   hSubLeadMuon1->SetYTitle("Number of Events/GeV");
   hSubLeadMuon1->Draw();
   gPad->Update();
   hLeadMuon1->Draw();          //draw hist_2 first as it has a larger range
   gPad->Update();


   TPaveStats *tps1 = (TPaveStats*) hLeadMuon1->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
  
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon1->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
  
  
   hSubLeadMuon1->Draw();
   hLeadMuon1->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 1");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon1,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon1,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
  
   c1->SaveAs("case1.pdf");
   c1->Clear();
   

   hLeadMuon2->SetLineColor(1);
   hSubLeadMuon2->SetLineColor(4);
   hLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
   hSubLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
   hLeadMuon2->SetYTitle("Number of Events/GeV");
   hSubLeadMuon2->SetYTitle("Number of Events/GeV");
   hSubLeadMuon2->Draw();
   gPad->Update();
   hLeadMuon2->Draw();
   gPad->Update();
   //draw hist_2 first as it has a larger range
   TPaveStats *tps1 = (TPaveStats*) hLeadMuon2->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
   
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon2->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
  
  
   hSubLeadMuon2->Draw();
   hLeadMuon2->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 2");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon2,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon2,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
   
   c1->SaveAs("case2.pdf");
  
   
   hLeadMuon3->SetLineColor(1);
   hSubLeadMuon3->SetLineColor(4);
   hLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
   hSubLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
   hLeadMuon3->SetYTitle("Number of Events/GeV");
   hSubLeadMuon3->SetYTitle("Number of Events/GeV");
   hSubLeadMuon3->Draw();
   gPad->Update();
   hLeadMuon3->Draw();          //draw hist_2 first as it has a larger range
   gPad->Update();
   
   TPaveStats *tps1 = (TPaveStats*) hLeadMuon3->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
   
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon3->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
   
   
   hSubLeadMuon3->Draw();
   hLeadMuon3->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 3");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon3,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon3,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
   
   c1->SaveAs("case3.pdf");
   c1->Clear();
   
   //pT resolution plots

   hMCMatchEC->SetLineColor(1);
   
   hMCMatchEC->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
   hMCMatchEC->Draw();          //draw hist_2 first as it has a larger range
   hMCMatchEC->Draw("esame");          //draw hist_2 first as it has a larger range
   c1->SaveAs("plot_res_1.pdf");
   c1->Clear();

   hMCMatchBa->SetLineColor(1);
   
   hMCMatchBa->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
   hMCMatchBa->Draw();          //draw hist_2 first as it has a larger range
   hMCMatchBa->Draw("esame");          //draw hist_2 first as it has a larger range
   c1->SaveAs("plot_res_2.pdf");
   c1->Clear();

   //Acceptance plots
   
   //Overall Acceptance
   
   hAcceptAll->SetXTitle("Reco. leading muon p_{T} in GeV/c");
   hAcceptAll->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //hAcceptAll->SetZTitle("Kinematic acceptance");
   hAcceptAll->SetStats(0);
   hAcceptAll->Draw("cont3 colz");
   //HLT_PATH Mu17_Mu8
   
   Int_t a=hAcceptAll->GetXaxis()->FindBin(17);
   Int_t b = hAcceptAll->GetYaxis()->FindBin(8);
   Double_t c = hAcceptAll->GetBinContent(a,b);
   //Double_t a = hAcceptAll->GetBinContent(hAcceptAll->GetXaxis()->FindBin(17),hAcceptAll->GetYaxis()->FindBin(8)));
   //HLT_PATH Mu13_Mu8
   //Double_t f=hAcceptAll->GetBinContent(
   Int_t d = hAcceptAll->GetXaxis()->FindBin(13);
   Int_t e = hAcceptAll->GetYaxis()->FindBin(8);
   Double_t f = hAcceptAll->GetBinContent(d,e);
  //Offline Cuts
  
   Int_t g=hAcceptAll->GetXaxis()->FindBin(20);
   Int_t h=hAcceptAll->GetYaxis()->FindBin(10);
   Double_t z=hAcceptAll->GetBinContent(g,h);
  //Double_t i=GetBinContenthAcceptAll->GetXaxis()->FindBin(20),hAcceptAll->GetYaxis()->FindBin(10));

   cout<<c<<" "<<f<<" "<<z<<endl;
  
  //Double_t m=hAcceptAll->GetBinContent(k,l);
  //draw hist_2 first as it has a larger range
  
   TLatex latex;
  //latex.DrawLatex(17,8,TString::Format("#bullet %f ",a));
  //latex.DrawLatex(17,8,TString::Format("#bullet %2f %",c*100));
   latex.DrawLatex(17,8,"#bullet 64%");
   latex.DrawLatex(13,8,"#diamond 72%");
   latex.DrawLatex(20,10,"#color[2]{#bullet} 43%");
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(13,8,TString::Format("#diamond %f ",f));
  
  //latex.DrawLatex(20,10,TString::Format("#circ %f ",i));
  
   latex.DrawLatex(3,22,"#bullet");
   latex.DrawLatex(2.83,25,"#diamond");
  
  
  
   latex.DrawLatex(4,28,"#scale[0.8]{HLT Paths(Run-1)}");
   latex.DrawLatex(4,22,"#scale[0.8]{Mu17_Mu8 (Luminosity 19.1 fb^{-1})}");
   latex.DrawLatex(4,25,"#scale[0.8]{Mu13_Mu8 (Luminosity 3.7 fb^{-1})}");
  
   latex.DrawLatex(4,19,"#scale[0.8]{Offline selection}");
   latex.DrawLatex(3,16,"#color[2]{#bullet}");
   latex.DrawLatex(4,16,"#scale[0.8]{Mu20_Mu10}");
   c1->SaveAs("acceptance_2d_all_cont3.pdf");
  
   //Case-1
   */

<file_sep>#include "TPaveStats.h"

void plot1(){
  //TCanvas *c1 = new TCanvas("c1","c1",59,80,1288,535);
  //c1->Divide(3,1);
  //c1->cd(1);
  hLeadMuon1->SetLineColor(1);
  hSubLeadMuon1->SetLineColor(4);
  hLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
  hSubLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
  hLeadMuon1->SetYTitle("Number of Events/GeV");
  hSubLeadMuon1->SetYTitle("Number of Events/GeV");
  //hSubLeadMuon1->GetXaxis()->SetTitleOffset(1.4);
  //hLeadMuon1->GetXaxis()->SetTitleOffset(1.4);

  hSubLeadMuon1->Draw();
  gPad->Update();
  hLeadMuon1->Draw();          //draw hist_2 first as it has a larger range
  gPad->Update();


  TPaveStats *tps1 = (TPaveStats*) hLeadMuon1->FindObject("stats");
  tps1->SetName("Hist1 Stats");
  double X1 = tps1->GetX1NDC();
  double Y1 = tps1->GetY1NDC();
  double X2 = tps1->GetX2NDC();
  double Y2 = tps1->GetY2NDC();

  TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon1->FindObject("stats");
  tps2->SetTextColor(kRed);
  tps2->SetLineColor(kRed);
  tps2->SetX1NDC(X1);
  tps2->SetX2NDC(X2);
  tps2->SetY1NDC(Y1-(Y2-Y1));
  tps2->SetY2NDC(Y1);

  
  
  hSubLeadMuon1->Draw();
  hLeadMuon1->Draw("same");          //draw hist_2 first as it has a larger range
  tps2->Draw("same");
  tps1->Draw("same");

  leg_hist = new TLegend(0.4770115,0.6038136,0.7658046,0.7923729);
  leg_hist->SetHeader("P_{T} histograms for case 1");
  leg_hist->SetFillColor(0);
  leg_hist->AddEntry(hLeadMuon1,"leading muon p_{T}","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon p_{T}","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();
  
  c1->SaveAs("case1.png");
  
}
<file_sep>#include "TPaveStats.h"

void plot_dimuoneta(){
  //TCanvas *c1 = new TCanvas("c1","c1",59,80,1288,535);
  //c1->Divide(3,1);
  //c1->cd(1);
  h1DiMuonEtaReco->SetLineColor(1);
  
  h1DiMuonEtaReco->SetXTitle("Reco. Muon #eta");
  
  h1DiMuonEtaReco->SetYTitle("Number of Events/GeV");
  
  //h1SumMuonPtReco->GetXaxis()->SetTitleOffset(1.4);
  //h1DiMuonPtReco->GetXaxis()->SetTitleOffset(1.4);

  //h1SumMuonPtReco->Draw();
  //gPad->Update();
  


  /*  TPaveStats *tps1 = (TPaveStats*) h1DiMuonEtaReco->FindObject("stats");
  tps1->SetName("Hist1 Stats");
  double X1 = tps1->GetX1NDC();
  double Y1 = tps1->GetY1NDC();
  double X2 = tps1->GetX2NDC();
  double Y2 = tps1->GetY2NDC();
  */
    
  
  h1DiMuonEtaReco->Draw();
  

  
  //tps1->Draw("same");

  c1->SaveAs("muoneta.png");
  
}
<file_sep>import FWCore.ParameterSet.Config as cms

from VHTauTau.TreeMaker.EventBlock_cfi import eventBlock 
from VHTauTau.TreeMaker.VertexBlock_cfi import vertexBlock 
from VHTauTau.TreeMaker.ElectronBlock_cfi import electronBlock 
from VHTauTau.TreeMaker.MuonBlock_cfi import muonBlock 
from VHTauTau.TreeMaker.TauBlock_cfi import tauBlock 
from VHTauTau.TreeMaker.JetBlock_cfi import jetBlock 
from VHTauTau.TreeMaker.METBlock_cfi import metBlock 
from VHTauTau.TreeMaker.TriggerBlock_cfi import triggerBlock 
from VHTauTau.TreeMaker.TriggerObjectBlock_cfi import triggerObjectBlock

treeContentSequence = cms.Sequence(
   eventBlock
 + vertexBlock
 + electronBlock
 + muonBlock
 + tauBlock
 + jetBlock  
 + metBlock
 + triggerBlock
 + triggerObjectBlock
)
<file_sep>#ifndef __VHTauTau_TreeMaker_GenMETBlock_h
#define __VHTauTau_TreeMaker_GenMETBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class GenMET;

class GenMETBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit GenMETBlock(const edm::ParameterSet& iConfig);
  virtual ~GenMETBlock() {}

  enum {
    kMaxGenMET = 100
  };

private:
  TClonesArray* cloneGenMET; 
  int  fnGenMET;
  int _verbosity;
  edm::InputTag _inputTag;

  vhtm::GenMET* genMetB;
};
#endif
<file_sep>#ifndef __VHTauTau_TreeMaker_EventBlock_h
#define __VHTauTau_TreeMaker_EventBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"
class Event;

class EventBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup);
  virtual void endJob(){}

public:
  explicit EventBlock(const edm::ParameterSet& iConfig);
  virtual ~EventBlock();

private:
  TClonesArray* cloneEvent; 
  int _verbosity;

  const edm::InputTag   _l1InputTag;
  const edm::InputTag   _vtxInputTag;
  const edm::InputTag   _trkInputTag;
  const unsigned int    _vtxMinNDOF;
  const double          _vtxMaxAbsZ, _vtxMaxd0;
  const unsigned int    _numTracks;
  const double          _hpTrackThreshold;

  std::vector<int> *_nPU;
  std::vector<int> *_bunchCrossing;
  std::vector<int> *_trueNInt;

  vhtm::Event* eventB;
};
#endif
<file_sep>void plot_imp_par_EC(){
  hImPEC->SetLineColor(1);
  //h1PtReco->SetLineColor(4);
  //h1PtReco->SetXTitle("GeV/c");
  hImPEC->SetXTitle("d_{xy} in cm");
  hImPEC->GetYaxis()->SetTitleOffset(1.3);
  hImPEC->SetYTitle("Events");
  hImPEC->Draw();          //draw hist_2 first as it has a larger range
  hImPEC->Draw("c hist same");          //draw hist_2 first as it has a larger range
  c1->SaveAs("plot_imp_1.eps");
  c1->SaveAs("plot_imp_1.png");
  //h1PtReco->Draw("same");
  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms");
  leg_hist->AddEntry(hImPEC,"Gen Pt","l");
  leg_hist->AddEntry(h1PtReco,"Reco Pt","l");
  leg_hist->Draw();*/
}
<file_sep>#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

#include "VHTauTau/TreeMaker/plugins/VertexBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

VertexBlock::VertexBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("vertexSrc"))
{
}
void VertexBlock::beginJob() {
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneVertex = new TClonesArray("vhtm::Vertex");
  tree->Branch("Vertex", &cloneVertex, 32000, 2);
  tree->Branch("nVertex", &fnVertex, "fnVertex/I");
}
void VertexBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneVertex->Clear();
  fnVertex = 0;

  edm::Handle<reco::VertexCollection> primaryVertices;
  iEvent.getByLabel(_inputTag, primaryVertices);

  if (primaryVertices.isValid()) {
    edm::LogInfo("VertexBlock") << "Total # Primary Vertices: " << primaryVertices->size();

    for (reco::VertexCollection::const_iterator it = primaryVertices->begin(); 
                                               it != primaryVertices->end(); ++it) {
      if (fnVertex == kMaxVertex) {
	edm::LogInfo("VertexBlock") << "Too many Vertex, fnVertex = " << fnVertex; 
	break;
      }
      vertexB = new ((*cloneVertex)[fnVertex++]) vhtm::Vertex();
      vertexB->x = it->x();
      vertexB->y = it->y();
      vertexB->z = it->z();
      vertexB->xErr = it->xError();
      vertexB->yErr = it->yError();
      vertexB->zErr = it->zError();
      vertexB->rho =  it->position().rho();
      vertexB->chi2 = it->chi2();
      vertexB->ndf = it->ndof();
      vertexB->ntracks = int(it->tracksSize());
      vertexB->ntracksw05 = it->nTracks(0.5); // number of tracks in the vertex with weight above 0.5
      vertexB->isfake = it->isFake();
      vertexB->isvalid = it->isValid();
      vertexB->sumPt = it->p4().pt();
    }
  } 
  else {
    edm::LogError("VertexBlock") << "Error >> Failed to get VertexCollection for label: " 
                                 << _inputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(VertexBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

treeCreator = cms.EDAnalyzer("TreeMakerModule",
  verbosity  = cms.int32(0),
  createTree = cms.bool(True)
)
<file_sep>rm -f submit_skimmer-*.jdl
rm -f test_skimmer_condor_file*.py
cp file test/
rm -f file*
cp test/file .
cp condor_vhtree_local.C condor_makeclass_local.C test/
rm condor_vhtree*.C condor_makeclass_*.C
cp test/condor_vhtree_local.C test/condor_makeclass_local.C .
rm -f vhtree_file*
rm -f *~<file_sep>import FWCore.ParameterSet.Config as cms

muonBlock = cms.EDAnalyzer("MuonBlock",
                           verbosity       = cms.int32(0),
                           #muonSrc         = cms.InputTag('muonVariables'),
                           muonSrc         = cms.InputTag('selectedPatMuonsPFlow'),
                           #muonSrc         = cms.InputTag('selectedPatMuons'),
                           vertexSrc       = cms.InputTag('offlinePrimaryVertices'),
                           offlineBeamSpot = cms.InputTag('offlineBeamSpot'),
                           beamSpotCorr    = cms.bool(True),
                           muonID          = cms.string('GlobalMuonPromptTight')
                           )
<file_sep>void plotres1(){
  hMCMatchEC->SetLineColor(1);
  //h1PtReco->SetLineColor(4);
  //h1PtReco->SetXTitle("GeV/c");
  hMCMatchEC->GetYaxis()->SetTitleOffset(1.3);
  hMCMatchEC->SetYTitle("Events");
  hMCMatchEC->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
  hMCMatchEC->GetXaxis()->SetTitleOffset(1.1);  
  hMCMatchEC->Draw();          //draw hist_2 first as it has a larger range
  hMCMatchEC->Draw("c hist same");          //draw hist_2 first as it has a larger range
  c1->SaveAs("plot_res_1.eps");
  c1->SaveAs("plot_res_1.png");
  //h1PtReco->Draw("same");
  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms");
  leg_hist->AddEntry(hMCMatchEC,"Gen Pt","l");
  leg_hist->AddEntry(h1PtReco,"Reco Pt","l");
  leg_hist->Draw();*/
}
<file_sep>void plot_eta_pt(){
  hEtaPt10->SetLineColor(8);
  hEtaPt15->SetLineColor(9);
  hEtaPt20->SetLineColor(6);
  hEtaPt25->SetLineColor(2);
  hEtaPt30->SetLineColor(5);
  hEtaPt35->SetLineColor(30);

  
  hEtaPt10->SetStats(0);
  hEtaPt10->SetTitle("|#eta| as a function of p_{T} threshold");

  hEtaPt10->SetXTitle("|#eta_{#mu}^{Reco}|");
  hEtaPt10->GetYaxis()->SetTitleOffset(1.23);  
  hEtaPt10->SetYTitle("Events/0.1");

  
  
  hEtaPt10->Draw("hist e");
  hEtaPt15->Draw("hist e SAME");
  hEtaPt20->Draw("hist e SAME");
  hEtaPt25->Draw("hist e SAME");
  hEtaPt30->Draw("hist e SAME");
  hEtaPt35->Draw("hist e SAME");

TPaveText *pt = new TPaveText(0.9856374,1222.805,1.427289,1392.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   TText *text = pt->AddText("0 < |#eta| < 1.5");
   text = pt->AddText("77 %");
   pt->Draw();
   
   pt = new TPaveText(1.627644,1222.805,2.076191,1392.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   text = pt->AddText("1.5 < |#eta| < 2.2");
   text = pt->AddText("20 %");
   pt->Draw();
   
   pt = new TPaveText(2.278276,822.805,2.7307,992.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   text = pt->AddText("2.2 < |#eta| < 2.4");
   text = pt->AddText("3 %");
   pt->Draw();



   leg_hist = new TLegend(0.7586207,0.6772152,0.9382184,0.8649789);
  //leg_hist->SetHeader("Pt histograms");
   leg_hist->SetBorderSize(0); 
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hEtaPt10,"p_{T} > 10 GeV","f");
   leg_hist->AddEntry(hEtaPt15,"p_{T} > 15 GeV","f");
   leg_hist->AddEntry(hEtaPt20,"p_{T} > 20 GeV","f");
   leg_hist->AddEntry(hEtaPt25,"p_{T} > 25 GeV","f");
   leg_hist->AddEntry(hEtaPt30,"p_{T} > 30 GeV","f");
   leg_hist->AddEntry(hEtaPt35,"p_{T} > 35 GeV","f");
   leg_hist->Draw();

  TLine *line1=new TLine(1.5,0,1.5,1500);
  line1->SetLineStyle(2);
  line1->SetLineColor(9);
  line1->SetLineWidth(3);
  line1->Draw("SAME");
  
  TLine *line2=new TLine(2.2,0,2.2,1500);
  line2->SetLineStyle(2);
  line2->SetLineColor(2);
  line2->SetLineWidth(3);
  line2->Draw("SAME");
  
  TLine *line3=new TLine(2.4,0,2.4,1500);
  line3->SetLineStyle(2);
  line3->SetLineColor(8);
  line3->SetLineWidth(3);
  line3->Draw("SAME");
  
  


  c1->SaveAs("plot_eta_pt.png");

}
<file_sep>#include <iostream>
#include <algorithm>

#include "TFile.h"
#include "TTree.h"
#include "TROOT.h"
#include "TClonesArray.h"
#include "TVector3.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/TrackReco/interface/HitPattern.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

#include "VHTauTau/TreeMaker/plugins/ElectronBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

// Constructor
ElectronBlock::ElectronBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _bsInputTag(iConfig.getParameter<edm::InputTag>("offlineBeamSpot")),
  _trkInputTag(iConfig.getParameter<edm::InputTag>("trackSrc")),
  _vtxInputTag(iConfig.getParameter<edm::InputTag>("vertexSrc")),
  _electronInputTag(iConfig.getParameter<edm::InputTag>("electronSrc"))
{
}
ElectronBlock::~ElectronBlock() { 
}
void ElectronBlock::beginJob() 
{
  // Get TTree pointer
  std::string tree_name = "vhtree";
  TTree* tree = vhtm::Utility::getTree(tree_name);
  cloneElectron = new TClonesArray("vhtm::Electron");
  tree->Branch("Electron", &cloneElectron, 32000, 2);
  tree->Branch("nElectron", &fnElectron,  "fnElectron/I");
}
void ElectronBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneElectron->Clear();
  fnElectron = 0;

  edm::Handle<reco::BeamSpot> beamSpot;
  iEvent.getByLabel(_bsInputTag, beamSpot);

  edm::Handle<reco::VertexCollection> primaryVertices;
  iEvent.getByLabel(_vtxInputTag, primaryVertices);

  edm::Handle<std::vector<pat::Electron> > electrons;
  iEvent.getByLabel(_electronInputTag, electrons);

  if (electrons.isValid()) {
    edm::LogInfo("ElectronBlock") << "Total # PAT Electrons: " << electrons->size();
    for (std::vector<pat::Electron>::const_iterator it  = electrons->begin(); 
                                                    it != electrons->end(); ++it) {
      if (fnElectron == kMaxElectron) {
	edm::LogInfo("ElectronBlock") << "Too many PAT Electrons, fnElectron = " 
                                      << fnElectron; 
	break;
      }
      bool hasGsfTrack  = it->gsfTrack().isNonnull() ? true : false;
      reco::GsfTrackRef tk = it->gsfTrack();

      electronB = new ((*cloneElectron)[fnElectron++]) vhtm::Electron();
      electronB->ecalDriven = it->ecalDrivenSeed();
      electronB->eta         = it->eta();
      electronB->phi         = it->phi();
      electronB->pt          = it->pt();
      electronB->hasGsfTrack = hasGsfTrack;
      electronB->energy      = it->energy();
      electronB->caloEnergy  = it->ecalEnergy();
      electronB->caloEnergyError = it->ecalEnergyError();
      electronB->charge      = it->charge();
  
      if (hasGsfTrack) {
        electronB->trackPt      = tk->pt();
        electronB->trackPtError = tk->ptError();

	// Hit pattern
	const reco::HitPattern& hitp = tk->hitPattern();
	electronB->pixHits = hitp.numberOfValidPixelHits();
	electronB->trkHits = hitp.numberOfValidTrackerHits();

        electronB->nValidHits   = tk->numberOfValidHits(); 
        //electronB->missingHits  = tk->trackerExpectedHitsInner().numberOfHits();

        electronB->trkD0        = tk->d0();
        electronB->trkD0Error   = tk->d0Error();
      }
      // ID variables
      electronB->hoe           = it->hcalOverEcal();
      electronB->hoeDepth1     = it->hcalDepth1OverEcal();
      electronB->eop           = it->eSuperClusterOverP(); 
      electronB->sigmaEtaEta   = it->sigmaEtaEta();
      electronB->sigmaIEtaIEta = it->sigmaIetaIeta();
      electronB->deltaPhiTrkSC = it->deltaPhiSuperClusterTrackAtVtx();
      electronB->deltaEtaTrkSC = it->deltaEtaSuperClusterTrackAtVtx();
      electronB->classif       = it->classification();
      electronB->e1x5overe5x5  = (it->e5x5() > 0) ? (it->e1x5()/it->e5x5()) : 0;
      electronB->e2x5overe5x5  = (it->e5x5() > 0) ? (it->e2x5Max()/it->e5x5()) : 0;

      // Iso variables
      electronB->isoEcal03 = it->dr03EcalRecHitSumEt();
      electronB->isoHcal03 = it->dr03HcalTowerSumEt();
      electronB->isoTrk03  = it->dr03TkSumPt();
      electronB->isoEcal04 = it->dr04EcalRecHitSumEt(); // ecalIso
      electronB->isoHcal04 = it->dr04HcalTowerSumEt(); // hcalIso
      electronB->isoTrk04  = it->dr04TkSumPt(); // trackIso
      electronB->isoRel03  = (it->dr03EcalRecHitSumEt()
                            + it->dr03HcalTowerSumEt()
                            + it->dr03TkSumPt())/it->pt();
      electronB->isoRel04  = (it->dr04EcalRecHitSumEt()
                            + it->dr04HcalTowerSumEt()
                            + it->dr04TkSumPt())/it->pt();

      // SC associated with electron
      electronB->scEn        = it->superCluster()->energy();
      electronB->scEta       = it->superCluster()->eta();
      electronB->scPhi       = it->superCluster()->phi();
      electronB->scET        = it->superCluster()->energy()/cosh(it->superCluster()->eta());
      electronB->scRawEnergy = it->superCluster()->rawEnergy();

      electronB->dist_vec  = it->userFloat("dist");
      electronB->dCotTheta = it->userFloat("dcot");
      electronB->hasMatchedConv = (it->userInt("antiConv") ? true : false);

      // Vertex association
      double minVtxDist3D = 9999.;
      int indexVtx = -1;
      double vertexDistZ = 9999.;
      if (hasGsfTrack) {
        if (primaryVertices.isValid()) {
	  edm::LogInfo("ElectronBlock") << "Total # Primary Vertices: " << primaryVertices->size();
          for (reco::VertexCollection::const_iterator vit  = primaryVertices->begin(); 
                                                      vit != primaryVertices->end(); ++vit) {
            double dxy = tk->dxy(vit->position());
            double dz  = tk->dz(vit->position());
            double dist3D = std::sqrt(pow(dxy, 2) + pow(dz, 2));
            if (dist3D < minVtxDist3D) {
              minVtxDist3D = dist3D;
              indexVtx = int(std::distance(primaryVertices->begin(), vit));
              vertexDistZ = dz;
            }
          }
        } 
        else {
	  edm::LogError("ElectronBlock") << "Error >> Failed to get VertexCollection for label: " 
                                         << _vtxInputTag;
        }      
      }
      // Vertex association variables
      electronB->vtxDist3D = minVtxDist3D;
      electronB->vtxIndex  = indexVtx;
      electronB->vtxDistZ  = vertexDistZ;

      electronB->relIso   = (it->trackIso() + it->ecalIso() + it->hcalIso())/it->pt();

      // PF based isolation
      electronB->pfRelIso = it->userFloat("PFRelIsoDB04");

      // PFlow isolation information
      electronB->chargedHadronIso = it->chargedHadronIso();
      electronB->neutralHadronIso = it->neutralHadronIso();
      electronB->photonIso        = it->photonIso();
  
      // IP information
      electronB->dB  = it->dB(pat::Electron::PV2D);
      electronB->edB = it->edB(pat::Electron::PV2D);

      electronB->dB3d  = it->dB(pat::Electron::PV3D);
      electronB->edB3d = it->edB(pat::Electron::PV3D);

      // Bremstrahlung information
      electronB->nBrems = it->numberOfBrems();
      electronB->fbrem  = it->fbrem();

      // MVA
      electronB->mva = it->userFloat("mva");
      electronB->mvaPOGTrig = it->userFloat("mvaPOGTrig");
      electronB->mvaPOGNonTrig = it->userFloat("mvaPOGNonTrig");
      electronB->mvaPreselection = (it->userInt("mvaPreselection") ? true : false); 
      electronB->isTriggerElectron = (it->userInt("isTriggerElectron") ? true : false); 

      // MVA Iso
      electronB->isoMVA = it->userFloat("eleIsoMVA");

      // Fiducial flag 
      int fidFlag = 0;
      if (it->isEB())        fidFlag |= (1 << 0);
      if (it->isEE())        fidFlag |= (1 << 1);
      if (it->isEBEtaGap())  fidFlag |= (1 << 2);
      if (it->isEBPhiGap())  fidFlag |= (1 << 3);
      if (it->isEERingGap()) fidFlag |= (1 << 4);
      if (it->isEEDeeGap())  fidFlag |= (1 << 5);
      if (it->isEBEEGap())   fidFlag |= (1 << 6);
      electronB->fidFlag = fidFlag;

      // Vertex information
      const reco::Candidate::Point& vertex = it->vertex();
      electronB->vx = vertex.x();             
      electronB->vy = vertex.y();             
      electronB->vz = vertex.z();             
     
      electronB->pfRelIso03v1 = it->userFloat("PFRelIso03v1");
      electronB->pfRelIso03v2 = it->userFloat("PFRelIso03v2");
      electronB->pfRelIsoDB03v1 = it->userFloat("PFRelIsoDB03v1");
      electronB->pfRelIsoDB03v2 = it->userFloat("PFRelIsoDB03v2");
      electronB->pfRelIsoDB03v3 = it->userFloat("PFRelIsoDB03v3");

      electronB->pfRelIso04v1 = it->userFloat("PFRelIso04v1");
      electronB->pfRelIso04v2 = it->userFloat("PFRelIso04v2");
      electronB->pfRelIsoDB04v1 = it->userFloat("PFRelIsoDB04v1");
      electronB->pfRelIsoDB04v2 = it->userFloat("PFRelIsoDB04v2");
      electronB->pfRelIsoDB04v3 = it->userFloat("PFRelIsoDB04v3");

      // 2012
      electronB->pfRelIso03 = it->userFloat("PFRelIso03");
      electronB->pfRelIso04 = it->userFloat("PFRelIso04");
      electronB->pfRelIsoDB03 = it->userFloat("PFRelIsoDB03");
      electronB->pfRelIsoDB04 = it->userFloat("PFRelIsoDB04");
    }
  } 
  else {
    edm::LogError("ElectronBlock") << "Error >> Failed to get pat::Electron Collection for label: " 
                                   << _electronInputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(ElectronBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

triggerObjectBlock = cms.EDAnalyzer("TriggerObjectBlock",
  verbosity = cms.int32(0),
  hltInputTag = cms.InputTag('TriggerResults','','HLT'),
  triggerEventTag = cms.InputTag('patTriggerEvent'),
  hltPathsOfInterest = cms.vstring ("HLT_DoubleMu",
                                    "HLT_Mu13_Mu8_v",
                                    "HLT_Mu17_Mu8_v",
                                    "HLT_Mu1",
                                    "HLT_Mu2",
                                    "HLT_Mu3",
                                    "HLT_Mu4",
                                    "HLT_IsoMu1",
                                    "HLT_IsoMu2",
                                    "HLT_IsoMu3",
                                    "HLT_IsoMu4",
                                    "HLT_Mu17_Ele8_Calo",
                                    "HLT_Mu8_Ele17_",
                                    "HLT_Ele1",
                                    "HLT_Ele2",
                                    "HLT_Ele3",
                                    "HLT_Ele4",
                                    "IsoPFTau"),
  May10ReRecoData = cms.bool(False)
)
<file_sep>void plot_dimuon_ratio(){
  h1DiMuonEtaReco->SetLineColor(1);
  

  
  h1DiMuonEtaReco->SetStats(0);
  //h1DiMuonEtaReco->SetTitle("#eta as a function of p_{T} threshold");

  h1DiMuonEtaReco->SetXTitle("Ratio of dimuon pT to scalar sum");
  h1DiMuonEtaReco->SetYTitle("Events");
  
  h1DiMuonEtaReco->Draw();
    
  /*leg_hist = new TLegend(0.6724138,0.684322,0.8520115,0.8728814);
  //leg_hist->SetHeader("Pt histograms");
  leg_hist->SetFillColor(0);
  leg_hist->AddEntry(hEtaPt10,"p_{T} > 10 GeV/c","l");
  leg_hist->AddEntry(hEtaPt15,"p_{T} > 15 GeV/c","l");
  leg_hist->AddEntry(hEtaPt20,"p_{T} > 20 GeV/c","l");
  leg_hist->AddEntry(hEtaPt25,"p_{T} > 25 GeV/c","l");
  leg_hist->AddEntry(hEtaPt30,"p_{T} > 30 GeV/c","l");
  leg_hist->AddEntry(hEtaPt35,"p_{T} > 35 GeV/c","l");
  leg_hist->Draw();*/
  c1->SaveAs("plot_pt_ratio.png");
}
<file_sep>#!/bin/bash
echo -n "Enter the name of the file which you got after running the trick.sh file (exact path name)"
read text
echo "You entered: $text"
lines=$(cat $text | wc -l)
echo "Number of input files: $lines"
echo "How do you want to divide them? (if they have 200 lines/files, enter 50 to have 4 files with 50 files in them)"
read number
awk '{filename = "file"  int((NR-1)/'$number'); print >> filename}' $text
loop_index=$((lines/number))
echo $loop_index
for((i=0;i<=loop_index;i++))
do
    sed -e 's/file/file'$i'/' submit_skimmer >> submit_skimmer-$i.jdl
    condor_submit submit_skimmer-$i.jdl
done
<file_sep>void plot_eta_pt_2d(){
  hEtaPtAll->SetXTitle("|#eta_{#mu}^{Reco}|");
  hEtaPtAll->SetYTitle("Reco Muon p_{T} in GeV/c");
  hEtaPtAll->SetStats(0);
  hEtaPtAll->Draw("COLZ");
  c1->SaveAs("plot_eta_pt_2d.png");
}
<file_sep>#include <iostream>

#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/TrackReco/interface/HitPattern.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "Math/GenVector/VectorUtil.h"

#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/VectorUtil.h"

#include "VHTauTau/TreeMaker/plugins/MuonBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"


const reco::GenParticle* getGenMuon(const pat::Muon& pm)
{
  std::vector<reco::GenParticleRef> associatedGenParticles = pm.genParticleRefs();
  for ( std::vector<reco::GenParticleRef>::const_iterator im = associatedGenParticles.begin(); 
	im != associatedGenParticles.end(); ++im ) {
    if ( im->isAvailable() ) {
      const reco::GenParticleRef& genParticle = (*im);
      if ( genParticle->pdgId() == -13 || genParticle->pdgId() == +13 ) return genParticle.get();
    }
  }
  return 0;
}

const reco::GenParticle* findMotherWithPdgId(const reco::GenParticle* genParticle, unsigned absPdgId)
{
  // If this doesn't have any valid mother, return null
  const reco::GenParticle* retVal = 0;
  
  if ( genParticle ) {
    // Get list of mothers. Not sure why this would be more than one.
    size_t nGenMothers = genParticle->numberOfMothers();
    for ( size_t iGenMother = 0; iGenMother < nGenMothers; ++iGenMother ) {
      const reco::GenParticle* genMother = dynamic_cast<const reco::GenParticle*>(genParticle->mother(iGenMother));
      if ( genMother ) {
	unsigned genMotherPdgId = TMath::Abs(genMother->pdgId());
	if ( genMotherPdgId == absPdgId ) {
	  retVal = genMother;
        } else {
	  const reco::GenParticle* genGrandMother = findMotherWithPdgId(genMother, absPdgId);
	  if ( genGrandMother != 0 ) retVal = genGrandMother;
	}
      }

      if ( retVal != 0 ) break;
    }
  }

  return retVal;
}




MuonBlock::MuonBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _muonInputTag(iConfig.getParameter<edm::InputTag>("muonSrc")),
  _vtxInputTag(iConfig.getParameter<edm::InputTag>("vertexSrc")),
  _beamSpotInputTag(iConfig.getParameter<edm::InputTag>("offlineBeamSpot")),
  _beamSpotCorr(iConfig.getParameter<bool>("beamSpotCorr")),
 _muonID(iConfig.getParameter<std::string>("muonID"))
{
}
MuonBlock::~MuonBlock() {
}
void MuonBlock::beginJob() 
{
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneMuon = new TClonesArray("vhtm::Muon");
  tree->Branch("Muon", &cloneMuon, 32000, 2);
  tree->Branch("nMuon", &fnMuon,  "fnMuon/I");
}
void MuonBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneMuon->Clear();
  fnMuon = 0;

  edm::Handle<std::vector<pat::Muon> > muons;
  iEvent.getByLabel(_muonInputTag, muons);

  edm::Handle<reco::VertexCollection> primaryVertices;
  iEvent.getByLabel(_vtxInputTag, primaryVertices);

  edm::Handle<reco::BeamSpot> beamSpot;
  iEvent.getByLabel(_beamSpotInputTag, beamSpot);

  if (muons.isValid()) {
    
    
    edm::LogInfo("MuonBlock") << "Total # Muons: " << muons->size();
    for (std::vector<pat::Muon>::const_iterator it  = muons->begin(); 
                                                it != muons->end(); ++it) {
      // consider only global muons
      //if (muons->size() == 2){
	//std::cout<<muons->size()<<std::endl;
      if (!it->isGlobalMuon()) continue;
      
      

      
      //remove those patmuons which were not matched with gen particles
      //const reco::GenParticle* genMuon = getGenMuon(*it);
      //if (!genMuon) continue;

      // Choose only those pat muons which have taus as mother particles
      
      const reco::GenParticle* genTau = findMotherWithPdgId(it->genLepton(), 15);
      if(!genTau) continue;
      
      
      if (fnMuon == kMaxMuon) {
	edm::LogInfo("MuonBlock") << "Too many PAT Muons, fnMuon = " << fnMuon; 
	break;
      }

      reco::TrackRef tk  = it->innerTrack();  // tracker segment only
      reco::TrackRef gtk = it->globalTrack(); 

      muonB = new ((*cloneMuon)[fnMuon++]) vhtm::Muon();
      muonB->isTrackerMuon = (it->isTrackerMuon()) ? true : false;
      muonB->isPFMuon = it->userInt("isPFMuon") ? true :  false; 
      
      //kinematic variables for the gen lepton
      muonB->ptgen   = it->genLepton()->pt(); 

      
      muonB->eta     = it->eta();
      muonB->phi     = it->phi();
      muonB->pt      = it->pt();
      muonB->ptError = tk->ptError();
      muonB->px      = it->px();
      muonB->py      = it->py();
      muonB->pz      = it->pz(); 
      muonB->energy  = it->energy();
      muonB->charge  = it->charge();

      double trkd0 = tk->d0();
      double trkdz = tk->dz();
      if (_beamSpotCorr) {
        if (beamSpot.isValid()) {
          trkd0 = -(tk->dxy(beamSpot->position()));
          trkdz = tk->dz(beamSpot->position());
        }
        else
          edm::LogError("MuonsBlock") << "Error >> Failed to get BeamSpot for label: "
                                      << _beamSpotInputTag;
      }
      muonB->trkD0      = trkd0;
      muonB->trkD0Error = tk->d0Error();
      muonB->trkDz      = trkdz;
      muonB->trkDzError = tk->dzError();
      muonB->globalChi2 = it->normChi2();
      muonB->passID     = (it->muonID(_muonID)) ? true : false;

      // Vertex association
      double minVtxDist3D = 9999.;
         int indexVtx = -1;
      double vertexDistZ = 9999.;
      if (primaryVertices.isValid()) {
	edm::LogInfo("MuonBlock") << "Total # Primary Vertices: " << primaryVertices->size();

        for (reco::VertexCollection::const_iterator vit  = primaryVertices->begin(); 
                                                    vit != primaryVertices->end(); ++vit) {

          double dxy = tk->dxy(vit->position());
          double dz  = tk->dz(vit->position());
          double dist3D = std::sqrt(pow(dxy,2) + pow(dz,2));
          if (dist3D < minVtxDist3D) {
            minVtxDist3D = dist3D;
            indexVtx     = int(std::distance(primaryVertices->begin(), vit));
            vertexDistZ  = dz;
          }
        }
      } 
      else {
	edm::LogError("MuonBlock") << "Error >> Failed to get VertexCollection for label: " 
                                   << _vtxInputTag;
      }
      muonB->vtxDist3D = minVtxDist3D;
      muonB->vtxIndex  = indexVtx;
      muonB->vtxDistZ  = vertexDistZ;

 
    // Hit pattern
      const reco::HitPattern& hitp = gtk->hitPattern();  // innerTrack will not provide Muon Hits 
      muonB->pixHits = hitp.numberOfValidPixelHits();
      muonB->trkHits = hitp.numberOfValidTrackerHits();
      muonB->muoHits = hitp.numberOfValidMuonHits();
      muonB->matches = it->numberOfMatches();
      muonB->trackerLayersWithMeasurement = hitp.trackerLayersWithMeasurement();

      // Isolation
      muonB->trkIso  = it->trackIso();
      muonB->ecalIso = it->ecalIso();
      muonB->hcalIso = it->hcalIso();
      muonB->hoIso   = it->isolationR03().hoEt;
      double reliso  = (it->trackIso() + it->ecalIso() + it->hcalIso())/it->pt();
      muonB->relIso  = reliso;

      muonB->pfRelIso = it->userFloat("PFRelIsoDB04v2");

      // IP information
      muonB->dB  = it->dB(pat::Muon::PV2D);
      muonB->edB = it->edB(pat::Muon::PV2D);
      //  muonB->dB_BS  = it->dB(pat::Muon::BS2D);
    
      if (primaryVertices.isValid()) {
	std::cout<<" db  "<<it->dB(pat::Muon::PV2D)<<" db with bs  "<<it->dB(pat::Muon::BS2D)<<std::endl;
	//	std::cout<<"  dxy  "<<it->globalTrack()->dxy((primaryVertices->begin())->position())<<std::endl;
      }


      muonB->dB3d  = it->dB(pat::Muon::PV3D);
      muonB->edB3d = it->edB(pat::Muon::PV3D);

      // UW recommendation
      muonB->isGlobalMuonPromptTight = muon::isGoodMuon(*it, muon::GlobalMuonPromptTight);
      muonB->isAllArbitrated         = muon::isGoodMuon(*it, muon::AllArbitrated);
      muonB->nChambers               = it->numberOfChambers();
      muonB->nMatches                = it->numberOfMatches();
      muonB->nMatchedStations        = it->numberOfMatchedStations();
      muonB->stationMask             = it->stationMask();
      muonB->stationGapMaskDistance  = it->stationGapMaskDistance();
      muonB->stationGapMaskPull      = it->stationGapMaskPull();
      muonB->muonID                  = it->userInt("muonID");

      // Vertex information
      const reco::Candidate::Point& vertex = it->vertex();
      muonB->vx = vertex.x();             
      muonB->vy = vertex.y();             
      muonB->vz = vertex.z();             

      muonB->idMVA = it->userFloat("muonIdMVA");
      muonB->isoRingsMVA = it->userFloat("muonIsoRingsMVA");
      muonB->isoRingsRadMVA = it->userFloat("muonIsoRingsRadMVA");
      muonB->idIsoCombMVA = it->userFloat("muonIdIsoCombMVA");

      muonB->pfRelIso03v1 = it->userFloat("PFRelIso03v1");
      muonB->pfRelIso03v2 = it->userFloat("PFRelIso03v2");
      muonB->pfRelIsoDB03v1 = it->userFloat("PFRelIsoDB03v1");
      muonB->pfRelIsoDB03v2 = it->userFloat("PFRelIsoDB03v2");

      muonB->pfRelIso04v1 = it->userFloat("PFRelIso04v1");
      muonB->pfRelIso04v2 = it->userFloat("PFRelIso04v2");
      muonB->pfRelIsoDB04v1 = it->userFloat("PFRelIsoDB04v1");
      muonB->pfRelIsoDB04v2 = it->userFloat("PFRelIsoDB04v2");
      }
    
} 
  else {
    edm::LogError("MuonBlock") << "Error >> Failed to get pat::Muon collection for label: " 
                               << _muonInputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(MuonBlock);
<file_sep>#include <iostream>
#include <algorithm>

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "PhysicsTools/PatUtils/interface/TriggerHelper.h"
#include "DataFormats/PatCandidates/interface/TriggerEvent.h"

#include "VHTauTau/TreeMaker/plugins/TriggerObjectBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"
#include "DataFormats/PatCandidates/interface/TriggerFilter.h"

#include "TMath.h"
#include "TTree.h"
#include "TClonesArray.h"
#include "TPRegexp.h"

// Constructor
TriggerObjectBlock::TriggerObjectBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _hltInputTag(iConfig.getParameter<edm::InputTag>("hltInputTag")),
  _triggerEventTag(iConfig.getParameter<edm::InputTag>("triggerEventTag")),
  _hltPathsOfInterest(iConfig.getParameter<std::vector<std::string> > ("hltPathsOfInterest")),
  _may10ReRecoData(iConfig.getParameter<bool>("May10ReRecoData"))
{
  std::cout << "==> TriggerObjectBlock::TriggerObjectBlock()" << std::endl;
}
TriggerObjectBlock::~TriggerObjectBlock() {
}
void TriggerObjectBlock::beginJob() 
{
  std::string tree_name = "vhtree";
  TTree* tree = vhtm::Utility::getTree(tree_name);
  cloneTriggerObject = new TClonesArray("vhtm::TriggerObject");
  tree->Branch("TriggerObject", &cloneTriggerObject, 32000, 2);
  tree->Branch("nTriggerObject", &fnTriggerObject, "fnTriggerObject/I");

  _firingFlag = (_may10ReRecoData) ? false : true; 
}
void TriggerObjectBlock::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
  bool changed = true;
  if (hltConfig.init(iRun, iSetup, _hltInputTag.process(), changed)) {
    // if init returns TRUE, initialisation has succeeded!
    edm::LogInfo("TriggerObjectBlock") << "HLT config with process name " 
                                       << _hltInputTag.process() 
                                       << " successfully extracted";
  } 
  else {
    // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
    // with the file and/or code and needs to be investigated!
    edm::LogError("TriggerObjectBlock") << "Error! HLT config extraction with process name " 
                                        << _hltInputTag.process() << " failed";
    // In this case, all access methods will return empty values!
  }
}
void TriggerObjectBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneTriggerObject->Clear();
  fnTriggerObject = 0;  

  if (_verbosity) {
    std::cout << setiosflags(std::ios::fixed); 
    std::cout << "Indx     Eta     Phi      Pt  Energy            =Trigger path list=" << std::endl;
  }
  // trigger event
  edm::Handle<pat::TriggerEvent> triggerEvent;
  iEvent.getByLabel(_triggerEventTag, triggerEvent);

  // get the trigger objects corresponding to the used matching (HLT muons) and
  // loop over selected trigger objects
  pat::TriggerObjectRefVector myObjects(triggerEvent->objectRefs());
  for (pat::TriggerObjectRefVector::const_iterator it  = myObjects.begin();                                                 
                                                   it != myObjects.end(); 
                                                 ++it) {                                 
    pat::TriggerPathRefVector myPaths = triggerEvent->objectPaths((*it));
    std::map <std::string, unsigned int> pathInfoMap;

    for (pat::TriggerPathRefVector::const_iterator ipath  = myPaths.begin();
	                                           ipath != myPaths.end();   
                                                 ++ipath) {
      std::string name = (**ipath).name();
      for (std::vector<std::string>::const_iterator kt  = _hltPathsOfInterest.begin();
	                                            kt != _hltPathsOfInterest.end(); 
                                                  ++kt) {
	std::string path_int = (*kt);
        if (name.find(path_int) == std::string::npos) continue;
        bool matched = true; 
	// Get the filters and access the L3 filter (needed for May10ReReco data) 
	if (_may10ReRecoData) {
	  matched = false;
          pat::TriggerFilterRefVector filters( triggerEvent->pathFilters( name, _firingFlag) );
	  if ( filters.empty() ) continue;
          pat::TriggerFilterRef lastFilter( filters.at( filters.size() - 1 ) );
          if ( triggerEvent->objectInFilter( (*it), lastFilter->label() ) ) matched = true;
	}
	if (matched) {
	  unsigned int val = 0;
	  if (triggerEvent->path(name)->wasRun() && triggerEvent->path(name)->wasAccept()) val = 1;
	  pathInfoMap.insert(std::pair<std::string, unsigned int> (name, val));
	}
      }
    }
    if (pathInfoMap.size() > 0)  {
      if (fnTriggerObject == kMaxTriggerObject) {
	edm::LogInfo("TriggerObjectBlock") << "Too many Trigger Muons (HLT), fnTriggerObject = " 
                                           << fnTriggerObject; 
	break;
      }
      _triggerObject = new ((*cloneTriggerObject)[fnTriggerObject++]) vhtm::TriggerObject();
      _triggerObject->eta    = (**it).eta();
      _triggerObject->phi    = (**it).phi();
      _triggerObject->pt     = (**it).pt();
      _triggerObject->energy = (**it).energy();
      for (std::map <std::string, unsigned int>::iterator imap  = pathInfoMap.begin(); 
                                                          imap != pathInfoMap.end(); 
                                                        ++imap) {
	_triggerObject->pathList.insert(std::pair<std::string, unsigned int> (imap->first, imap->second));
      }
      if (_verbosity) {
	std::cout << std::setprecision(2);
	std::cout << std::setw(4) << fnTriggerObject
                  << std::setw(8) << _triggerObject->eta 
		  << std::setw(8) << _triggerObject->phi 
		  << std::setw(8) << _triggerObject->pt 
		  << std::setw(8) << _triggerObject->energy
		  << std::endl;
	for (std::map<std::string, unsigned int>::const_iterator jt  = _triggerObject->pathList.begin();
	                                                         jt != _triggerObject->pathList.end(); 
                                                               ++jt)
        {
	  std::cout << "\t\t\t\t\t" << jt->first << " " << jt->second << std::endl;
	}
      }
    }
  }
  if (_verbosity) std::cout << " # of Trigger Objects " << fnTriggerObject << std::endl;
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TriggerObjectBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

jetBlock = cms.EDAnalyzer("JetBlock",
  verbosity        = cms.int32(0),
  jetSrc           = cms.InputTag('patJets'),
  jecUncertainty   = cms.string('CondFormats/JetMETObjects/data/Spring10_Uncertainty_AK5PF.txt'),
  applyResidualJEC = cms.bool(False),
  residualJEC      = cms.string('CondFormats/JetMETObjects/data/Spring10_L2L3Residual_AK5PF.txt')
)
<file_sep>#include <iostream>

#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/PatCandidates/interface/MET.h"

#include "VHTauTau/TreeMaker/plugins/METBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

METBlock::METBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _pfInputTag(iConfig.getParameter<edm::InputTag>("metSrc"))
  // _corrinputTag(iConfig.getParameter<edm::InputTag>("corrmetSrc")),
  //_mvainputTag(iConfig.getParameter<edm::InputTag>("mvametSrc"))
{
}
//METBlock::~METBlock(){
//}
void METBlock::beginJob() 
{
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");

  clonePFMET = new TClonesArray("vhtm::MET");
  tree->Branch("MET", &clonePFMET, 32000, 2);
  tree->Branch("nMET", &fnPFMET,  "fnPFMET/I");

  /*cloneCorrMET = new TClonesArray("vhtm::MET");
  tree->Branch("corrMET", &cloneCorrMET, 32000, 2);
  tree->Branch("corrnMET", &fnCorrMET,  "fnCorrMET/I");

  cloneMVAMET = new TClonesArray("vhtm::MET");
  tree->Branch("mvaMET", &cloneMVAMET, 32000, 2);
  tree->Branch("mvanMET", &fnMVAMET,  "fnMVAMET/I");*/
}
void METBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  //fillMET(iEvent, iSetup, clonePFMET, fnPFMET, _pfinputTag, pfmetB);
  //fillMET(iEvent, iSetup, cloneCorrMET, fnCorrMET, _corrinputTag, corrmetB);
  //fillMET(iEvent, iSetup, cloneMVAMET, fnMVAMET, _mvainputTag, mvametB);



  // Reset the TClonesArray and the nObj variables
  clonePFMET->Clear();
  fnPFMET = 0;
  
  edm::Handle<std::vector<pat::MET> > mets;
  iEvent.getByLabel(_pfInputTag, mets);

  if (mets.isValid()) {
    edm::LogInfo("METBlock") << "Total # PAT METs: " << mets->size();

    for (std::vector<pat::MET>::const_iterator it = mets->begin(); 
                                              it != mets->end(); ++it) {
      if (fnPFMET == kMaxMET) {
	edm::LogInfo("METBlock") << "Too many PAT MET, nMET = " << fnPFMET 
                                 << ", label: " << _pfInputTag; 
	break;
      }
      metB = new ((*clonePFMET)[fnPFMET++]) vhtm::MET();

      // fill in all the vectors
      metB->met          = it->pt();
      metB->metphi       = it->phi();
      metB->metx         = it->px();
      metB->mety         = it->py();
      metB->sumet        = it->sumEt();
      metB->metuncorr    = it->uncorrectedPt(pat::MET::uncorrALL);
      metB->metphiuncorr = it->uncorrectedPhi(pat::MET::uncorrALL);
      metB->sumetuncorr  = it->sumEt() - it->corSumEt(pat::MET::uncorrALL);
    }
  } 
  else {
    edm::LogError("METBlock") << "Error >> Failed to get pat::MET collection for label: " 
                              << _pfInputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(METBlock);
<file_sep>void plot_accept_pt_3d_1(){
  //hAccept1->SetLineColor(1);
  
     hAccept1->SetXTitle("Reco. leading muon p_{T} in GeV/c");
     hAccept1->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //hAccept1->SetZTitle("Kinematic acceptance");
     hAccept1->SetStats(0);
     hAccept1->Draw("cont3 colz");
   //HLT_PATH Mu17_Mu8
   
     Int_t a=hAccept1->GetXaxis()->FindBin(17);
     Int_t b = hAccept1->GetYaxis()->FindBin(8);
     Double_t c = hAccept1->GetBinContent(a,b);
     cout<<"17-18 "<<c<<endl;
     //Double_t a = hAccept1->GetBinContent(hAccept1->GetXaxis()->FindBin(17),hAccept1->GetYaxis()->FindBin(8)));
   //HLT_PATH Mu13_Mu8
   //Double_t f=hAccept1->GetBinContent(
     Int_t d = hAccept1->GetXaxis()->FindBin(13);
     Int_t e = hAccept1->GetYaxis()->FindBin(8);
     Double_t f = hAccept1->GetBinContent(d,e);
     cout<<"13-18 "<<f<<endl;
     //Offline Cuts
  
     Int_t g=hAccept1->GetXaxis()->FindBin(20);
     Int_t h=hAccept1->GetYaxis()->FindBin(10);
     Double_t z=hAccept1->GetBinContent(g,h);
     cout<<"20-10 "<<z<<endl;
  //Double_t i=GetBinContenthAccept1->GetXaxis()->FindBin(20),hAccept1->GetYaxis()->FindBin(10));

  
  
  //Double_t m=hAccept1->GetBinContent(k,l);
  //draw hist_2 first as it has a larger range
  
     TLatex latex;
  //latex.DrawLatex(17,8,TString::Format("#bullet %f ",a));
  //latex.DrawLatex(17,8,TString::Format("#bullet %2f %",c*100));
     latex.DrawLatex(17,8,"#bullet 64%");
     latex.DrawLatex(13,8,"#diamond 72%");
     latex.DrawLatex(20,10,"#color[2]{#bullet} 45%");
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(13,8,TString::Format("#diamond %f ",f));
  
  //latex.DrawLatex(20,10,TString::Format("#circ %f ",i));
  
     latex.DrawLatex(3,22,"#bullet");
     latex.DrawLatex(2.83,25,"#diamond");
  
  
  
     latex.DrawLatex(4,28,"#scale[0.8]{HLT Paths(Run-1)}");
     latex.DrawLatex(4,22,"#scale[0.8]{Mu17_Mu8 (Luminosity 19.1 fb^{-1})}");
     latex.DrawLatex(4,25,"#scale[0.8]{Mu13_Mu8 (Luminosity 3.7 fb^{-1})}");
  
     latex.DrawLatex(4,19,"#scale[0.8]{Offline selection}");
     latex.DrawLatex(3,16,"#color[2]{#bullet}");
     latex.DrawLatex(4,16,"#scale[0.8]{Mu20_Mu10}");
     
     c1->SaveAs("acceptance_2d_1.png");  
     c1->SaveAs("acceptance_2d_1.eps");  
   

  
  /*leg_hist = new TLegend(0.5,0.6,0.79,0.79);
  leg_hist->SetHeader("Pt histograms for case 1 (both muons in endcap)");
  leg_hist->AddEntry(hAccept1,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon1,"subleading muon pt","l");
  leg_hist->Draw();
  */
  
  
}
<file_sep>import FWCore.ParameterSet.Config as cms

from VHTauTau.TreeMaker.EventBlock_cfi import eventBlock
from VHTauTau.TreeMaker.VertexBlock_cfi import vertexBlock
from VHTauTau.TreeMaker.JetBlock_cfi import jetBlock
from VHTauTau.TreeMaker.ElectronBlock_cfi import electronBlock
from VHTauTau.TreeMaker.METBlock_cfi import metBlock
from VHTauTau.TreeMaker.MuonBlock_cfi import muonBlock
from VHTauTau.TreeMaker.TauBlock_cfi import tauBlock
from VHTauTau.TreeMaker.GenParticleBlock_cfi import genParticleBlock
from VHTauTau.TreeMaker.TriggerBlock_cfi import triggerBlock
from VHTauTau.TreeMaker.TriggerObjectBlock_cfi import triggerObjectBlock
from VHTauTau.TreeMaker.TrackBlock_cfi import trackBlock
#from VHTauTau.TreeMaker.PatMCMatching_cfi import PatMCMatching


treeContentSequence = cms.Sequence(
    eventBlock + 
    vertexBlock +
    #+ electronBlock
    trackBlock +
    #genParticleBlock +
    #+ jetBlock  
    metBlock +
    muonBlock 
    #+ PatMCMatching
    #tauBlock 
    #+ triggerBlock
    )
<file_sep>void plot_int(){
  
  h1->ComputeIntegral();
  Double_t *integral = (h1->GetIntegral());
  h1->SetContent(integral);
  //TH1F *h1=1-(*h1);
  //TH1F *h1i = new TH1F("h1i","histogram with 1 as entries",100,0,60);
  //Int_t binsize=h1->GetSize();
  //for (int i=1;i<binsize-1;i++){
    //    std::cout<<i<<"\t"<<(*integral)<<endl;
    //Double_t entry=h1->GetBinContent(i);
    //h1->SetBinContent(i,1-entry);
  //}

    //c1->SaveAs("case1.png");
  
}
<file_sep>{
//=========Macro generated from canvas: c1/c1
//=========  (Tue Jan 13 17:15:16 2015) by ROOT version5.34/18
   TCanvas *c1 = new TCanvas("c1", "c1",65,52,700,500);
   c1->Range(-0.3770197,-211.4001,3.371634,1753.377);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetFrameBorderMode(0);
   c1->SetFrameBorderMode(0);
   
   TH1F *hEtaPt10 = new TH1F("hEtaPt10","|#eta| as a function of p_{T} threshold",30,0,3);
   hEtaPt10->SetBinContent(1,1458);
   hEtaPt10->SetBinContent(2,1343);
   hEtaPt10->SetBinContent(3,1234);
   hEtaPt10->SetBinContent(4,1327);
   hEtaPt10->SetBinContent(5,1353);
   hEtaPt10->SetBinContent(6,1382);
   hEtaPt10->SetBinContent(7,1280);
   hEtaPt10->SetBinContent(8,1191);
   hEtaPt10->SetBinContent(9,1186);
   hEtaPt10->SetBinContent(10,1125);
   hEtaPt10->SetBinContent(11,1061);
   hEtaPt10->SetBinContent(12,1056);
   hEtaPt10->SetBinContent(13,1051);
   hEtaPt10->SetBinContent(14,914);
   hEtaPt10->SetBinContent(15,848);
   hEtaPt10->SetBinContent(16,811);
   hEtaPt10->SetBinContent(17,764);
   hEtaPt10->SetBinContent(18,683);
   hEtaPt10->SetBinContent(19,641);
   hEtaPt10->SetBinContent(20,581);
   hEtaPt10->SetBinContent(21,517);
   hEtaPt10->SetBinContent(22,466);
   hEtaPt10->SetBinContent(23,359);
   hEtaPt10->SetBinContent(24,343);
   hEtaPt10->SetBinError(1,38.18377);
   hEtaPt10->SetBinError(2,36.64696);
   hEtaPt10->SetBinError(3,35.12834);
   hEtaPt10->SetBinError(4,36.42801);
   hEtaPt10->SetBinError(5,36.78315);
   hEtaPt10->SetBinError(6,37.17526);
   hEtaPt10->SetBinError(7,35.77709);
   hEtaPt10->SetBinError(8,34.51087);
   hEtaPt10->SetBinError(9,34.43835);
   hEtaPt10->SetBinError(10,33.54102);
   hEtaPt10->SetBinError(11,32.57299);
   hEtaPt10->SetBinError(12,32.49615);
   hEtaPt10->SetBinError(13,32.41913);
   hEtaPt10->SetBinError(14,30.23243);
   hEtaPt10->SetBinError(15,29.12044);
   hEtaPt10->SetBinError(16,28.47806);
   hEtaPt10->SetBinError(17,27.64055);
   hEtaPt10->SetBinError(18,26.13427);
   hEtaPt10->SetBinError(19,25.31798);
   hEtaPt10->SetBinError(20,24.10394);
   hEtaPt10->SetBinError(21,22.73763);
   hEtaPt10->SetBinError(22,21.58703);
   hEtaPt10->SetBinError(23,18.9473);
   hEtaPt10->SetBinError(24,18.52026);
   hEtaPt10->SetEntries(22974);
   hEtaPt10->SetStats(0);
   hEtaPt10->SetLineColor(8);
   hEtaPt10->GetXaxis()->SetTitle("|#eta_{#mu}^{Reco}|");
   hEtaPt10->GetYaxis()->SetTitle("Events/0.1");
   hEtaPt10->GetYaxis()->SetTitleOffset(1.23);
   hEtaPt10->Draw("hist e");
   
   TH1F *hEtaPt15 = new TH1F("hEtaPt15","Reco Muon Eta 15",30,0,3);
   hEtaPt15->SetBinContent(1,1224);
   hEtaPt15->SetBinContent(2,1111);
   hEtaPt15->SetBinContent(3,1031);
   hEtaPt15->SetBinContent(4,1073);
   hEtaPt15->SetBinContent(5,1114);
   hEtaPt15->SetBinContent(6,1139);
   hEtaPt15->SetBinContent(7,1075);
   hEtaPt15->SetBinContent(8,979);
   hEtaPt15->SetBinContent(9,980);
   hEtaPt15->SetBinContent(10,928);
   hEtaPt15->SetBinContent(11,868);
   hEtaPt15->SetBinContent(12,853);
   hEtaPt15->SetBinContent(13,896);
   hEtaPt15->SetBinContent(14,751);
   hEtaPt15->SetBinContent(15,693);
   hEtaPt15->SetBinContent(16,632);
   hEtaPt15->SetBinContent(17,632);
   hEtaPt15->SetBinContent(18,538);
   hEtaPt15->SetBinContent(19,513);
   hEtaPt15->SetBinContent(20,471);
   hEtaPt15->SetBinContent(21,429);
   hEtaPt15->SetBinContent(22,386);
   hEtaPt15->SetBinContent(23,266);
   hEtaPt15->SetBinContent(24,262);
   hEtaPt15->SetBinError(1,34.98571);
   hEtaPt15->SetBinError(2,33.33167);
   hEtaPt15->SetBinError(3,32.10919);
   hEtaPt15->SetBinError(4,32.75668);
   hEtaPt15->SetBinError(5,33.37664);
   hEtaPt15->SetBinError(6,33.74907);
   hEtaPt15->SetBinError(7,32.78719);
   hEtaPt15->SetBinError(8,31.28898);
   hEtaPt15->SetBinError(9,31.30495);
   hEtaPt15->SetBinError(10,30.46309);
   hEtaPt15->SetBinError(11,29.46184);
   hEtaPt15->SetBinError(12,29.20616);
   hEtaPt15->SetBinError(13,29.93326);
   hEtaPt15->SetBinError(14,27.40438);
   hEtaPt15->SetBinError(15,26.32489);
   hEtaPt15->SetBinError(16,25.13961);
   hEtaPt15->SetBinError(17,25.13961);
   hEtaPt15->SetBinError(18,23.19483);
   hEtaPt15->SetBinError(19,22.6495);
   hEtaPt15->SetBinError(20,21.70253);
   hEtaPt15->SetBinError(21,20.71232);
   hEtaPt15->SetBinError(22,19.64688);
   hEtaPt15->SetBinError(23,16.30951);
   hEtaPt15->SetBinError(24,16.18641);
   hEtaPt15->SetEntries(18844);
   hEtaPt15->SetLineColor(9);
   hEtaPt15->Draw("hist e SAME");
   
   TH1F *hEtaPt20 = new TH1F("hEtaPt20","Reco Muon Eta 20",30,0,3);
   hEtaPt20->SetBinContent(1,983);
   hEtaPt20->SetBinContent(2,899);
   hEtaPt20->SetBinContent(3,861);
   hEtaPt20->SetBinContent(4,850);
   hEtaPt20->SetBinContent(5,878);
   hEtaPt20->SetBinContent(6,915);
   hEtaPt20->SetBinContent(7,856);
   hEtaPt20->SetBinContent(8,805);
   hEtaPt20->SetBinContent(9,783);
   hEtaPt20->SetBinContent(10,749);
   hEtaPt20->SetBinContent(11,691);
   hEtaPt20->SetBinContent(12,666);
   hEtaPt20->SetBinContent(13,700);
   hEtaPt20->SetBinContent(14,580);
   hEtaPt20->SetBinContent(15,555);
   hEtaPt20->SetBinContent(16,491);
   hEtaPt20->SetBinContent(17,499);
   hEtaPt20->SetBinContent(18,443);
   hEtaPt20->SetBinContent(19,393);
   hEtaPt20->SetBinContent(20,374);
   hEtaPt20->SetBinContent(21,325);
   hEtaPt20->SetBinContent(22,309);
   hEtaPt20->SetBinContent(23,201);
   hEtaPt20->SetBinContent(24,187);
   hEtaPt20->SetBinError(1,31.35283);
   hEtaPt20->SetBinError(2,29.98333);
   hEtaPt20->SetBinError(3,29.3428);
   hEtaPt20->SetBinError(4,29.15476);
   hEtaPt20->SetBinError(5,29.63106);
   hEtaPt20->SetBinError(6,30.24897);
   hEtaPt20->SetBinError(7,29.25748);
   hEtaPt20->SetBinError(8,28.37252);
   hEtaPt20->SetBinError(9,27.98214);
   hEtaPt20->SetBinError(10,27.36786);
   hEtaPt20->SetBinError(11,26.28688);
   hEtaPt20->SetBinError(12,25.80698);
   hEtaPt20->SetBinError(13,26.45751);
   hEtaPt20->SetBinError(14,24.08319);
   hEtaPt20->SetBinError(15,23.55844);
   hEtaPt20->SetBinError(16,22.15852);
   hEtaPt20->SetBinError(17,22.33831);
   hEtaPt20->SetBinError(18,21.04757);
   hEtaPt20->SetBinError(19,19.82423);
   hEtaPt20->SetBinError(20,19.33908);
   hEtaPt20->SetBinError(21,18.02776);
   hEtaPt20->SetBinError(22,17.5784);
   hEtaPt20->SetBinError(23,14.17745);
   hEtaPt20->SetBinError(24,13.67479);
   hEtaPt20->SetEntries(14993);
   hEtaPt20->SetLineColor(6);
   hEtaPt20->Draw("hist e SAME");
   
   TH1F *hEtaPt25 = new TH1F("hEtaPt25","Reco Muon Eta 25",30,0,3);
   hEtaPt25->SetBinContent(1,770);
   hEtaPt25->SetBinContent(2,684);
   hEtaPt25->SetBinContent(3,673);
   hEtaPt25->SetBinContent(4,666);
   hEtaPt25->SetBinContent(5,674);
   hEtaPt25->SetBinContent(6,709);
   hEtaPt25->SetBinContent(7,649);
   hEtaPt25->SetBinContent(8,640);
   hEtaPt25->SetBinContent(9,610);
   hEtaPt25->SetBinContent(10,597);
   hEtaPt25->SetBinContent(11,544);
   hEtaPt25->SetBinContent(12,503);
   hEtaPt25->SetBinContent(13,551);
   hEtaPt25->SetBinContent(14,441);
   hEtaPt25->SetBinContent(15,434);
   hEtaPt25->SetBinContent(16,379);
   hEtaPt25->SetBinContent(17,380);
   hEtaPt25->SetBinContent(18,328);
   hEtaPt25->SetBinContent(19,308);
   hEtaPt25->SetBinContent(20,281);
   hEtaPt25->SetBinContent(21,248);
   hEtaPt25->SetBinContent(22,242);
   hEtaPt25->SetBinContent(23,146);
   hEtaPt25->SetBinContent(24,130);
   hEtaPt25->SetBinError(1,27.74887);
   hEtaPt25->SetBinError(2,26.15339);
   hEtaPt25->SetBinError(3,25.94224);
   hEtaPt25->SetBinError(4,25.80698);
   hEtaPt25->SetBinError(5,25.96151);
   hEtaPt25->SetBinError(6,26.62705);
   hEtaPt25->SetBinError(7,25.47548);
   hEtaPt25->SetBinError(8,25.29822);
   hEtaPt25->SetBinError(9,24.69818);
   hEtaPt25->SetBinError(10,24.43358);
   hEtaPt25->SetBinError(11,23.32381);
   hEtaPt25->SetBinError(12,22.42766);
   hEtaPt25->SetBinError(13,23.47339);
   hEtaPt25->SetBinError(14,21);
   hEtaPt25->SetBinError(15,20.83267);
   hEtaPt25->SetBinError(16,19.46792);
   hEtaPt25->SetBinError(17,19.49359);
   hEtaPt25->SetBinError(18,18.11077);
   hEtaPt25->SetBinError(19,17.54993);
   hEtaPt25->SetBinError(20,16.76305);
   hEtaPt25->SetBinError(21,15.74802);
   hEtaPt25->SetBinError(22,15.55635);
   hEtaPt25->SetBinError(23,12.08305);
   hEtaPt25->SetBinError(24,11.40175);
   hEtaPt25->SetEntries(11587);
   hEtaPt25->SetLineColor(2);
   hEtaPt25->Draw("hist e SAME");
   
   TH1F *hEtaPt30 = new TH1F("hEtaPt30","Reco Muon Eta 30",30,0,3);
   hEtaPt30->SetBinContent(1,606);
   hEtaPt30->SetBinContent(2,514);
   hEtaPt30->SetBinContent(3,514);
   hEtaPt30->SetBinContent(4,487);
   hEtaPt30->SetBinContent(5,517);
   hEtaPt30->SetBinContent(6,539);
   hEtaPt30->SetBinContent(7,474);
   hEtaPt30->SetBinContent(8,496);
   hEtaPt30->SetBinContent(9,463);
   hEtaPt30->SetBinContent(10,459);
   hEtaPt30->SetBinContent(11,414);
   hEtaPt30->SetBinContent(12,382);
   hEtaPt30->SetBinContent(13,423);
   hEtaPt30->SetBinContent(14,341);
   hEtaPt30->SetBinContent(15,344);
   hEtaPt30->SetBinContent(16,293);
   hEtaPt30->SetBinContent(17,274);
   hEtaPt30->SetBinContent(18,239);
   hEtaPt30->SetBinContent(19,233);
   hEtaPt30->SetBinContent(20,226);
   hEtaPt30->SetBinContent(21,176);
   hEtaPt30->SetBinContent(22,167);
   hEtaPt30->SetBinContent(23,103);
   hEtaPt30->SetBinContent(24,92);
   hEtaPt30->SetBinError(1,24.61707);
   hEtaPt30->SetBinError(2,22.67157);
   hEtaPt30->SetBinError(3,22.67157);
   hEtaPt30->SetBinError(4,22.06808);
   hEtaPt30->SetBinError(5,22.73763);
   hEtaPt30->SetBinError(6,23.21637);
   hEtaPt30->SetBinError(7,21.77154);
   hEtaPt30->SetBinError(8,22.27106);
   hEtaPt30->SetBinError(9,21.51743);
   hEtaPt30->SetBinError(10,21.42429);
   hEtaPt30->SetBinError(11,20.34699);
   hEtaPt30->SetBinError(12,19.54482);
   hEtaPt30->SetBinError(13,20.56696);
   hEtaPt30->SetBinError(14,18.46619);
   hEtaPt30->SetBinError(15,18.54724);
   hEtaPt30->SetBinError(16,17.11724);
   hEtaPt30->SetBinError(17,16.55295);
   hEtaPt30->SetBinError(18,15.45962);
   hEtaPt30->SetBinError(19,15.26434);
   hEtaPt30->SetBinError(20,15.0333);
   hEtaPt30->SetBinError(21,13.2665);
   hEtaPt30->SetBinError(22,12.92285);
   hEtaPt30->SetBinError(23,10.14889);
   hEtaPt30->SetBinError(24,9.591663);
   hEtaPt30->SetEntries(8776);
   hEtaPt30->SetLineColor(5);
   hEtaPt30->Draw("hist e SAME");
   
   TH1F *hEtaPt35 = new TH1F("hEtaPt35","Reco Muon Eta 35",30,0,3);
   hEtaPt35->SetBinContent(1,461);
   hEtaPt35->SetBinContent(2,388);
   hEtaPt35->SetBinContent(3,369);
   hEtaPt35->SetBinContent(4,365);
   hEtaPt35->SetBinContent(5,397);
   hEtaPt35->SetBinContent(6,407);
   hEtaPt35->SetBinContent(7,350);
   hEtaPt35->SetBinContent(8,360);
   hEtaPt35->SetBinContent(9,345);
   hEtaPt35->SetBinContent(10,349);
   hEtaPt35->SetBinContent(11,316);
   hEtaPt35->SetBinContent(12,290);
   hEtaPt35->SetBinContent(13,318);
   hEtaPt35->SetBinContent(14,252);
   hEtaPt35->SetBinContent(15,251);
   hEtaPt35->SetBinContent(16,218);
   hEtaPt35->SetBinContent(17,191);
   hEtaPt35->SetBinContent(18,178);
   hEtaPt35->SetBinContent(19,174);
   hEtaPt35->SetBinContent(20,155);
   hEtaPt35->SetBinContent(21,128);
   hEtaPt35->SetBinContent(22,111);
   hEtaPt35->SetBinContent(23,71);
   hEtaPt35->SetBinContent(24,63);
   hEtaPt35->SetBinError(1,21.47091);
   hEtaPt35->SetBinError(2,19.69772);
   hEtaPt35->SetBinError(3,19.20937);
   hEtaPt35->SetBinError(4,19.10497);
   hEtaPt35->SetBinError(5,19.92486);
   hEtaPt35->SetBinError(6,20.17424);
   hEtaPt35->SetBinError(7,18.70829);
   hEtaPt35->SetBinError(8,18.97367);
   hEtaPt35->SetBinError(9,18.57418);
   hEtaPt35->SetBinError(10,18.68154);
   hEtaPt35->SetBinError(11,17.77639);
   hEtaPt35->SetBinError(12,17.02939);
   hEtaPt35->SetBinError(13,17.83255);
   hEtaPt35->SetBinError(14,15.87451);
   hEtaPt35->SetBinError(15,15.84298);
   hEtaPt35->SetBinError(16,14.76482);
   hEtaPt35->SetBinError(17,13.82027);
   hEtaPt35->SetBinError(18,13.34166);
   hEtaPt35->SetBinError(19,13.19091);
   hEtaPt35->SetBinError(20,12.4499);
   hEtaPt35->SetBinError(21,11.31371);
   hEtaPt35->SetBinError(22,10.53565);
   hEtaPt35->SetBinError(23,8.42615);
   hEtaPt35->SetBinError(24,7.937254);
   hEtaPt35->SetEntries(6507);
   hEtaPt35->SetLineColor(30);
   hEtaPt35->Draw("hist e SAME");
   
   TPaveText *pt = new TPaveText(0.9856374,1222.805,1.427289,1392.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   TText *text = pt->AddText("0 < |#eta| < 1.5");
   text = pt->AddText("78 %");
   pt->Draw();
   
   pt = new TPaveText(1.627644,1222.805,2.076191,1392.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   text = pt->AddText("1.5 < |#eta| < 2.2");
   text = pt->AddText("15 %");
   pt->Draw();
   
   pt = new TPaveText(2.278276,1222.805,2.7307,1392.754,"br");
   pt->SetBorderSize(2);
   pt->SetFillColor(0);
   text = pt->AddText("2.2 < |#eta| < 2.4");
   text = pt->AddText("7 %");
   pt->Draw();
   
   TLegend *leg = new TLegend(0.7586207,0.6772152,0.9382184,0.8649789,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(62);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("hEtaPt10","p_{T} > 10 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(8);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hEtaPt15","p_{T} > 15 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(9);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hEtaPt20","p_{T} > 20 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(6);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hEtaPt25","p_{T} > 25 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hEtaPt30","p_{T} > 30 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(5);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   entry=leg->AddEntry("hEtaPt35","p_{T} > 35 GeV","f");
   entry->SetFillStyle(1001);
   entry->SetLineColor(30);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(62);
   leg->Draw();
   TLine *line = new TLine(1.5,0,1.5,7000);
   line->SetLineColor(9);
   line->SetLineStyle(2);
   line->SetLineWidth(3);
   line->Draw();
   line = new TLine(2.2,0,2.2,7000);
   line->SetLineColor(2);
   line->SetLineStyle(2);
   line->SetLineWidth(3);
   line->Draw();
   line = new TLine(2.4,0,2.4,7000);
   line->SetLineColor(8);
   line->SetLineStyle(2);
   line->SetLineWidth(3);
   line->Draw();
   
   pt = new TPaveText(0.01,0.9241139,0.496954,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(1);
   pt->SetFillColor(0);
   text = pt->AddText("|#eta| as a function of p_{T} threshold");
   pt->Draw();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
<file_sep>void plot3(){
  hLeadMuon3->SetLineColor(1);
  hSubLeadMuon3->SetLineColor(4);
  hLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
  hSubLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
  hLeadMuon3->SetYTitle("Number of Events/GeV");
  hSubLeadMuon3->SetYTitle("Number of Events/GeV");
  hSubLeadMuon3->Draw();
  gPad->Update();
  hLeadMuon3->Draw();          //draw hist_2 first as it has a larger range
  gPad->Update();

  TPaveStats *tps1 = (TPaveStats*) hLeadMuon3->FindObject("stats");
  tps1->SetName("Hist1 Stats");
  double X1 = tps1->GetX1NDC();
  double Y1 = tps1->GetY1NDC();
  double X2 = tps1->GetX2NDC();
  double Y2 = tps1->GetY2NDC();

  TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon3->FindObject("stats");
  tps2->SetTextColor(kRed);
  tps2->SetLineColor(kRed);
  tps2->SetX1NDC(X1);
  tps2->SetX2NDC(X2);
  tps2->SetY1NDC(Y1-(Y2-Y1));
  tps2->SetY2NDC(Y1);

  
  
  hSubLeadMuon3->Draw();
  hLeadMuon3->Draw("same");          //draw hist_2 first as it has a larger range
  tps2->Draw("same");
  tps1->Draw("same");

  
  leg_hist = new TLegend(0.4770115,0.6038136,0.7658046,0.7923729);
  leg_hist->SetHeader("Pt histograms for case 3");
  leg_hist->SetFillColor(0);
  leg_hist->AddEntry(hLeadMuon3,"leading muon Pt","l");
  leg_hist->AddEntry(hSubLeadMuon3,"subleading muon pt","l");
  leg_hist->SetTextSize(0.03);
  leg_hist->Draw();

  c1->SaveAs("case3.png");
  

}
<file_sep>#ifndef __VHTauTau_TreeMaker_TriggerObjectBlock_h
#define __VHTauTau_TreeMaker_TriggerObjectBlock_h

#include <string>
#include <vector>
#include <map>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DataFormats/Common/interface/Ref.h"

#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/ParameterSet/interface/ProcessDesc.h"

#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class TriggerObject;

class TriggerObjectBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup);
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit TriggerObjectBlock(const edm::ParameterSet& iConfig);
  virtual ~TriggerObjectBlock();

  enum {
    kMaxTriggerObject = 100
  };

private:
  TClonesArray* cloneTriggerObject; 
  int  fnTriggerObject;

  int _verbosity;
  const edm::InputTag _hltInputTag;
  edm::InputTag _triggerEventTag;
  const std::string  _tagPathLabel;
  const std::string  _probePathLabel;
  const std::vector<std::string> _hltPathsOfInterest;
  bool _may10ReRecoData;
  bool _firingFlag;

  vhtm::TriggerObject* _triggerObject;

  HLTConfigProvider hltConfig;
};
#endif
<file_sep>import FWCore.ParameterSet.Config as cms

trackBlock = cms.EDAnalyzer("TrackBlock",
  verbosity       = cms.int32(0),
  trackSrc        = cms.InputTag('generalTracks'),
  offlineBeamSpot = cms.InputTag('offlineBeamSpot')
)
<file_sep>void condor_makeclass_local(){
  gROOT->ProcessLine("TFile f(\"/home/amohapatra/ankit_storage/gem_physics/DYTauMu_PU0/dytaumu_14TeV_pu0_local.root\")");
  gROOT->ProcessLine("treeCreator->cd()");
  gROOT->ProcessLine("vhtree->MakeClass(\"vhtree_local\")");
  gROOT->ProcessLine(".! cp vhtree.C vhtree_local.C");
  gROOT->ProcessLine(".! sed -i 's|histos_mva_dytt.root|histos_mva_dytt_local.root|g' vhtree_local.C");
  gROOT->ProcessLine(".! sed -i 's|vhtree|vhtree_local|g' vhtree_local.C");
  gROOT->ProcessLine(".q");
}
<file_sep>void ankit(){
  // gROOT->ProcessLine(".L vhtree_better_script.C");
  gROOT->ProcessLine(".L vhtree.C");
  gROOT->ProcessLine("vhtree gem");
  gROOT->ProcessLine("gem.Loop()");
}
<file_sep>#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

#include "VHTauTau/TreeMaker/plugins/GenParticleBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

GenParticleBlock::GenParticleBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("genParticleSrc"))
{
}
GenParticleBlock::~GenParticleBlock() {
}
void GenParticleBlock::beginJob() {
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneGenParticle = new TClonesArray("vhtm::GenParticle");
  tree->Branch("GenParticle", &cloneGenParticle, 32000, 2);
  tree->Branch("nGenParticle", &fnGenParticle,  "fnGenParticle/I");
}
void GenParticleBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneGenParticle->Clear();
  fnGenParticle = 0;

  if (!iEvent.isRealData()) {
    edm::Handle<reco::GenParticleCollection> genParticles;
    iEvent.getByLabel(_inputTag, genParticles);
    if (genParticles.isValid()) {
      edm::LogInfo("GenParticleBlock") << "Total # GenParticles: " << genParticles->size();
      for (reco::GenParticleCollection::const_iterator it = genParticles->begin(); 
                                                      it != genParticles->end(); ++it ) {
        if (fnGenParticle == kMaxGenParticle) {
	  edm::LogInfo("GenParticleBlock") << "Too many GenParticles, fnGenParticle = " 
                                           << fnGenParticle;
	  break;
        }
        // Doat store low energy gluons
        int pdgid     = it->pdgId(); 
        double pt     = it->pt();  

        genParticleB = new ((*cloneGenParticle)[fnGenParticle++]) vhtm::GenParticle();

        // fill in all the vectors
        genParticleB->eta       = it->eta();
        genParticleB->phi       = it->phi();
        genParticleB->p         = it->p();
        genParticleB->px        = it->px();
        genParticleB->py        = it->py();
        genParticleB->pz        = it->pz();
        genParticleB->pt        = pt;
        genParticleB->energy    = it->energy();
        genParticleB->pdgId     = pdgid;
        genParticleB->vx        = it->vx();
        genParticleB->vy        = it->vy();
        genParticleB->vz        = it->vz();
        genParticleB->status    = it->status();
	genParticleB->charge    = it->charge();
        genParticleB->numDaught = it->numberOfDaughters();
        genParticleB->numMother = it->numberOfMothers();
        int idx = -1;
        for (reco::GenParticleCollection::const_iterator mit = genParticles->begin(); 
                                                        mit != genParticles->end(); ++mit ) {
          if ( it->mother() == &(*mit) ) {
	    idx = std::distance(genParticles->begin(),mit);
	    break;
          }
        }
        genParticleB->motherIndex = idx;

	if (_verbosity > 0) std::cout << "pdgId=" << it->pdgId() << std::endl;
        for (size_t j = 0; j < it->numberOfMothers(); ++j) {
	  const reco::Candidate* m = it->mother(j);
          for (reco::GenParticleCollection::const_iterator mit = genParticles->begin(); 
                                                          mit != genParticles->end(); ++mit) {
            if (m == &(*mit) ) { // -- keep all the entries && it->pdgId() != mit->pdgId() ) {
	      int idx = std::distance(genParticles->begin(), mit);
	      if (_verbosity > 0) 
                std::cout << "mother index/pdgId: " << idx << "/" << mit->pdgId() << std::endl;
              genParticleB->motherIndices.push_back(idx);
              break;
            }
          } 
        }
        for (size_t j = 0; j < it->numberOfDaughters(); ++j) {
	  const reco::Candidate* d = it->daughter(j);
          for (reco::GenParticleCollection::const_iterator mit = genParticles->begin(); 
                                                          mit != genParticles->end(); ++mit) {
            if (d == &(*mit) ) { // -- keep all the entries  && it->pdgId() != mit->pdgId() ) {
	      int idx = std::distance(genParticles->begin(), mit);
	      if (_verbosity > 0) 
                std::cout << "daughter index/pdgId: " << idx << "/" << mit->pdgId() << std::endl;
              genParticleB->daughtIndices.push_back(idx);
              break;
            }
          } 
        }
        if (_verbosity > 0) std::cout << "# of mother/daughter: "  
                  << genParticleB->motherIndices.size() << "/" 
		  << genParticleB->daughtIndices.size() << std::endl;
      }
    } 
    else {
      edm::LogError("GenParticleBlock") << "Error >> Failed to get GenParticleCollection for label: " 
                                        << _inputTag;
    }
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GenParticleBlock);
<file_sep>#define vhtree_cxx
#include "vhtree.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <vector>
#include <fstream>
void vhtree::Loop()
{
//   In a ROOT session, you can do:
//      Root > .L vhtree.C
//      Root > vhtree t
//      Root > t.GetEntry(12); // Fill t data members with entry number 12
//      Root > t.Show();       // Show values of entry 12
//      Root > t.Show(16);     // Read and show values of entry 16
//      Root > t.Loop();       // Loop on all entries
//

//     This is the loop skeleton where:
//    jentry is the global entry number in the chain
//    ientry is the entry number in the current Tree
//  Note that the argument to GetEntry must be:
//    jentry for TChain::GetEntry
//    ientry for TTree::GetEntry and TBranch::GetEntry
//
//       To read only selected branches, Insert statements like:
// METHOD1:
//    fChain->SetBranchStatus("*",0);  // disable all branches
//    fChain->SetBranchStatus("branchname",1);  // activate branchname
// METHOD2: replace line
//    fChain->GetEntry(jentry);       //read all branches
//by  b_branchname->GetEntry(ientry); //read only this branch
   if (fChain == 0) return;
   double delRMin=0.03;
   double delR=0.;
   double GenMuonPt=0.;                                                                                                            
   double delphi=0.;
   double deleta=0.;
   double RecoMuonPt=0.;
   double RecoMuonEta=0.;
   double inv_mass=0.;
   double ImpParam=0.;
   double MuonDZ=0.;
   double MuonChi2=0.;
   double SumMuonChi2=0.;
   double e1=0.;
   double e2=0.;
   double p1x=0.;
   double p2x=0.;
   double p1y=0.;
   double p2y=0.;
   double p1z=0.;
   double p2z=0.;
   double phi_1=0.;
   double phi_2=0;
   double theta_1=0;
   double theta_2=0;
   double metx=0.;
   double mety=0.;
   double p_1=0.;
   double p_2=0.;
   double x_1=0;
   double x_2=0;
   double pvis_1=0;
   double pvis_2=0;
   double inv_mass_vis=0;
   Double_t total_events=0;
   Double_t events=0;
   Double_t mag=0;
   Double_t dimuoneta=0;
   Double_t dimuonratiopt=0;

   ofstream myfile("acceptance.file",ios::app);
   ofstream myfile2("acceptance2.file",ios::app);
   
   TH1F *h1PtReco = new TH1F("h1PtReco","Reco Muon Pt",100,0,300);
   TH1F *h1PtGen = new TH1F("h1PtGen","Gen Muon Pt",100,0,300);

   TH1F *h1DiMuonPtReco = new TH1F("h1DiMuonPtReco","Reco DiMuon Pt",100,0,300);
   
   TH1F *h1SumMuonPtReco = new TH1F("h1SumMuonPtReco","Reco Sum Muon Pt",100,0,300);
   
   
   
   TH1F *h1PtLeading = new TH1F("h1PtLeading","Leading Muon Pt",100,0,100);
   TH1F *h1PtSubLeading = new TH1F("h1PtSubLeading","SubLeading Muon Pt",100,0,100);
   
   TH1F *h1PtLeadingi = new TH1F("h1PtLeadingi","Integrated Leading Muon Pt",100,0,100);
   TH1F *h1PtSubLeadingi = new TH1F("h1PtSubLeadingi","Integrated SubLeading Muon Pt",100,0,100);
   


   TH1F *h1EtaReco = new TH1F("h1EtaReco","Reco Muon Eta",100,-5,+5);
   //TH1F *h1EtaGen = new TH1F("h1EtaGen","Gen Muon Eta",100,-5,+5);
   TH1F *h1DiMuonEtaReco = new TH1F("h1DiMuonEtaReco","Reco DiMuon Eta",100,-10,+10);
   
   TH1F *hPhiReco = new TH1F("hPhiReco","Difference in Phi between the two muons in multiples of #pi",100,-2,2);

   
   
   TH1F *hMCMatchEC = new TH1F("hMCMatchEC","Muon Pt resolution in End cap region",200,-0.5,0.5);
   TH1F *hMCMatchBa = new TH1F("hMCMatchBa","Muon Pt resolution in barrel region",200,-0.5,0.5);
   
   TH1F *hLeadMuon1 = new TH1F("hLeadMuon1","Leading Muon and Subleading Muon in EndCap",100,0,100);
   TH1F *hLeadMuon2 = new TH1F("hLeadMuon2","Leading Muon in Endcap, subleading muon in barrel",100,0,100);
   TH1F *hLeadMuon3 = new TH1F("hLeadMuon3","Leading Muon in Barrel, subleading muon in endcap",100,0,100);
   //TH1F *hLeadMuonAll = new TH1F("hLeadMuonAll","Overall Leading muon distribution",100,0,100);
   
   

   TH1F *hSubLeadMuon1 = new TH1F("hSubLeadMuon1","Leading Muon and Subleading Muon in EndCap",100,0,100);
   TH1F *hSubLeadMuon2 = new TH1F("hSubLeadMuon2","Leading Muon in Endcap, subleading muon in barrel",100,0,100);
   TH1F *hSubLeadMuon3 = new TH1F("hSubLeadMuon3","Leading Muon in Barrel, subleading muon in endcap",100,0,100);
   //TH1F *hSubLeadMuonAll = new TH1F("hSubLeadMuonAll","Overall Subleading muon distribution",100,0,100);


   TH2F *h1 = new TH2F("h1","Correlation plot between Subleading and leading muon Pt(Overall)",30,0,30,30,0,30);
   TH2F *h11 = new TH2F("h11","Correlation plot between Subleading and leading muon Pt(EC(Lead), EC(sublead))",30,0,30,30,0,30);
   TH2F *h12 = new TH2F("h12","Correlation plot between Subleading and leading muon Pt(EC(Lead),Barrel(Sublead))",30,0,30,30,0,30);
   TH2F *h13 = new TH2F("h13","Correlation plot between Subleading and leading muon Pt(EC(sublead),Barrel(Lead))",30,0,30,30,0,30);
   //TH3F *h2 = new TH3F("h2","acceptance plot",300,0,300,100,0,150,100,0,1);
   TH2F *hAcceptAll = new TH2F("hAcceptAll","Overall acceptance plot",120,0,30,120,0,30);
   TH2F *hAccept1 = new TH2F("hAccept1","Leading Muon and Subleading Muon in EndCap",120,0,30,120,0,30);
   TH2F *hAccept2 = new TH2F("hAccept2","Leading Muon in Endcap, subleading muon in barrel",120,0,30,120,0,30);
   TH2F *hAccept3 = new TH2F("hAccept3","Leading Muon in Barrel, subleading muon in endcap",120,0,30,120,0,30);
   
   //TProfile2D *h2 = new TProfile2D("h2","acceptance plot",100,0,300,100,0,300,0,1);  
   //TGraph2D *t2 = new TGraph2D();
   TH1F *hInvTau = new TH1F("hInvTau","Invariant Mass plot for Taus",100,0,300);
   TH1F *hInvMuon = new TH1F("hInvMuon","Invariant Mass plot for Muons(visible)",100,0,300);

   
   
   TH1F *hImPEC = new TH1F("hImPEC","Impact parameter plot End cap",100,-0.3,0.3);
   TH1F *hImPBa = new TH1F("hImPBa","Impact parameter plot barrel",100,-0.3,0.3);
   
   TH1F *hDZEC = new TH1F("hDZEC","Muon DZ plot End cap",100,-10,10);
   TH1F *hDZBa = new TH1F("hDZBa","Muon DZ plot barrel",100,-10,10);

   TH1F *hChiEC = new TH1F("hChiEC","Muon Chi plot End cap",100,0,16);
   TH1F *hChiBa = new TH1F("hChiBa","Muon Chi plot barrel",100,0,16);

   TH1F *hImPECEr = new TH1F("hImPECEr","Error in Impact parameter plot End cap",100,0,16);
   TH1F *hImPBaEr = new TH1F("hImPBaEr","Error in Impact parameter plot barrel",100,0,16);

   //Muon eta plots for pT threshold !

   TH1F *hEtaPt10 = new TH1F("hEtaPt10","Reco Muon Eta 10",100,-3,3);
   TH1F *hEtaPt15 = new TH1F("hEtaPt15","Reco Muon Eta 15",100,-3,3);
   TH1F *hEtaPt20 = new TH1F("hEtaPt20","Reco Muon Eta 20",100,-3,3);
   TH1F *hEtaPt25 = new TH1F("hEtaPt25","Reco Muon Eta 25",100,-3,3);
   TH1F *hEtaPt30 = new TH1F("hEtaPt30","Reco Muon Eta 30",100,-3,3);
   TH1F *hEtaPt35 = new TH1F("hEtaPt35","Reco Muon Eta 35",100,-3,3);

   //2-D histograms

   TH2F *hEtaResEC = new TH2F("hEtaResEC","Eta vs MuonPt resolution in Endcap",100,-3,3,100,-5,5);
   TH2F *hEtaResBa = new TH2F("hEtaResBa","Eta vs MuonPt resolution in barrel",100,-3,3,100,-5,5);
   TH2F *hEtaResAll = new TH2F("hEtaResAll","Eta vs MuonPt resolution Overall",100,-3,3,100,-5,5);
   
   TH2F *hEtaPtEC = new TH2F("hEtaPtEC","Eta vs MuonPt in Endcap",100,-3,3,100,0,200);
   TH2F *hEtaPtBa = new TH2F("hEtaPtBa","Eta vs MuonPt in barrel",100,-3,3,100,0,200);
   TH2F *hEtaPtAll = new TH2F("hEtaPtAll","Eta vs MuonPt Overall",100,-3,3,100,0,200);
   


   //std::vector<double> leadmuonpt;
   //std::vector<double> subleadmuonpt;
   Double_t pt_cut=30.;
   Double_t bin_width=0.25;
   const int bin_size_sl=pt_cut/bin_width;
   const int bin_size_l=pt_cut/bin_width;
   
   Double_t leadmuonpt[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt[bin_size_sl]={0};
   
   Double_t leadmuonpt1[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt1[bin_size_sl]={0};
   
   Double_t leadmuonpt2[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt2[bin_size_sl]={0};
   
   Double_t leadmuonpt3[bin_size_l]={0}; //100 is the number of bins
   Double_t subleadmuonpt3[bin_size_sl]={0};

   //TFile *f1 = new TFile("histos_signal.root","RECREATE");
   //f1->cd();
   //TTree *tree = new TTree("gemtree","variables");
   //tree->Branch("dimuoneta",&dimuoneta,"dimuoneta/D");
   //tree->Branch("dimuonratiopt",&dimuonratiopt,"dimuonratiopt/D");
   
   
   Long64_t nentries = fChain->GetEntriesFast();
   cout<<"Number of events "<<nentries<<endl;
   //int dimuon=0;
   Long64_t nbytes = 0, nb = 0;
   //for (Long64_t jentry=0;jentry<nentries;jentry++) {
   for (Long64_t jentry=0;jentry<nentries;jentry++) {
     Long64_t ientry = LoadTree(jentry);
     if (ientry < 0) break;
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     
     //if (nMuon!=2) continue;
     //if (abs(Muon_phi[0]-Muon_phi[1] < 2.0))continue;
     //++dimuon;
     
     
     for (int i=0;i<nMuon; i++){
       if (Muon_pt[i]<0.3) cout<<"found it"<<endl;
       RecoMuonPt=Muon_pt[i];
       RecoMuonEta=Muon_eta[i];
       GenMuonPt=Muon_ptgen[i];
       ImpParam=Muon_trkD0[i];
       MuonDZ=Muon_trkDz[i];
       MuonChi2=Muon_globalChi2[i];
     
       h1PtGen->Fill(GenMuonPt);
       h1PtReco->Fill(RecoMuonPt);
       h1EtaReco->Fill(RecoMuonEta);
       hEtaPtAll->Fill(RecoMuonEta,RecoMuonPt);
       
     }
     //f1->cd();
     //tree->Write();
     //f1->Close();
   }
   
}

   //hAcceptAll->Write();
   /*
   //Time to beautify most of the plots
   hLeadMuon1->SetLineColor(1);
   hSubLeadMuon1->SetLineColor(4);
   hLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
   hSubLeadMuon1->SetXTitle("Reco. Muon p_{T} in GeV/c");
   hLeadMuon1->SetYTitle("Number of Events/GeV");
   hSubLeadMuon1->SetYTitle("Number of Events/GeV");
   hSubLeadMuon1->Draw();
   gPad->Update();
   hLeadMuon1->Draw();          //draw hist_2 first as it has a larger range
   gPad->Update();


   TPaveStats *tps1 = (TPaveStats*) hLeadMuon1->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
  
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon1->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
  
  
   hSubLeadMuon1->Draw();
   hLeadMuon1->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 1");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon1,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon1,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
  
   c1->SaveAs("case1.pdf");
   c1->Clear();
   

   hLeadMuon2->SetLineColor(1);
   hSubLeadMuon2->SetLineColor(4);
   hLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
   hSubLeadMuon2->SetXTitle("Reco Muon p_{T} in GeV/c");
   hLeadMuon2->SetYTitle("Number of Events/GeV");
   hSubLeadMuon2->SetYTitle("Number of Events/GeV");
   hSubLeadMuon2->Draw();
   gPad->Update();
   hLeadMuon2->Draw();
   gPad->Update();
   //draw hist_2 first as it has a larger range
   TPaveStats *tps1 = (TPaveStats*) hLeadMuon2->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
   
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon2->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
  
  
   hSubLeadMuon2->Draw();
   hLeadMuon2->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 2");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon2,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon2,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
   
   c1->SaveAs("case2.pdf");
  
   
   hLeadMuon3->SetLineColor(1);
   hSubLeadMuon3->SetLineColor(4);
   hLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
   hSubLeadMuon3->SetXTitle("Reco Muon p_{T} in GeV/c");
   hLeadMuon3->SetYTitle("Number of Events/GeV");
   hSubLeadMuon3->SetYTitle("Number of Events/GeV");
   hSubLeadMuon3->Draw();
   gPad->Update();
   hLeadMuon3->Draw();          //draw hist_2 first as it has a larger range
   gPad->Update();
   
   TPaveStats *tps1 = (TPaveStats*) hLeadMuon3->FindObject("stats");
   tps1->SetName("Hist1 Stats");
   double X1 = tps1->GetX1NDC();
   double Y1 = tps1->GetY1NDC();
   double X2 = tps1->GetX2NDC();
   double Y2 = tps1->GetY2NDC();
   
   TPaveStats *tps2 = (TPaveStats*) hSubLeadMuon3->FindObject("stats");
   tps2->SetTextColor(kRed);
   tps2->SetLineColor(kRed);
   tps2->SetX1NDC(X1);
   tps2->SetX2NDC(X2);
   tps2->SetY1NDC(Y1-(Y2-Y1));
   tps2->SetY2NDC(Y1);
   
   
   
   hSubLeadMuon3->Draw();
   hLeadMuon3->Draw("same");          //draw hist_2 first as it has a larger range
   tps2->Draw("same");
   tps1->Draw("same");
   
   
   leg_hist = new TLegend(0.4712644,0.5886076,0.7600575,0.778481,NULL,"brNDC");
   leg_hist->SetHeader("p_{T} histograms for case 3");
   leg_hist->SetFillColor(0);
   leg_hist->AddEntry(hLeadMuon3,"leading muon p_{T}","l");
   leg_hist->AddEntry(hSubLeadMuon3,"subleading muon p_{T}","l");
   leg_hist->SetTextSize(0.03);
   leg_hist->Draw();
   
   c1->SaveAs("case3.pdf");
   c1->Clear();
   
   //pT resolution plots

   hMCMatchEC->SetLineColor(1);
   
   hMCMatchEC->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
   hMCMatchEC->Draw();          //draw hist_2 first as it has a larger range
   hMCMatchEC->Draw("esame");          //draw hist_2 first as it has a larger range
   c1->SaveAs("plot_res_1.pdf");
   c1->Clear();

   hMCMatchBa->SetLineColor(1);
   
   hMCMatchBa->SetXTitle("p_{T}^{gen}-p_{T}^{reco}/p_{T}^{gen}");
   hMCMatchBa->Draw();          //draw hist_2 first as it has a larger range
   hMCMatchBa->Draw("esame");          //draw hist_2 first as it has a larger range
   c1->SaveAs("plot_res_2.pdf");
   c1->Clear();

   //Acceptance plots
   
   //Overall Acceptance
   
   hAcceptAll->SetXTitle("Reco. leading muon p_{T} in GeV/c");
   hAcceptAll->SetYTitle("Reco. subleading muon p_{T} in GeV/c");
  //hAcceptAll->SetZTitle("Kinematic acceptance");
   hAcceptAll->SetStats(0);
   hAcceptAll->Draw("cont3 colz");
   //HLT_PATH Mu17_Mu8
   
   Int_t a=hAcceptAll->GetXaxis()->FindBin(17);
   Int_t b = hAcceptAll->GetYaxis()->FindBin(8);
   Double_t c = hAcceptAll->GetBinContent(a,b);
   //Double_t a = hAcceptAll->GetBinContent(hAcceptAll->GetXaxis()->FindBin(17),hAcceptAll->GetYaxis()->FindBin(8)));
   //HLT_PATH Mu13_Mu8
   //Double_t f=hAcceptAll->GetBinContent(
   Int_t d = hAcceptAll->GetXaxis()->FindBin(13);
   Int_t e = hAcceptAll->GetYaxis()->FindBin(8);
   Double_t f = hAcceptAll->GetBinContent(d,e);
  //Offline Cuts
  
   Int_t g=hAcceptAll->GetXaxis()->FindBin(20);
   Int_t h=hAcceptAll->GetYaxis()->FindBin(10);
   Double_t z=hAcceptAll->GetBinContent(g,h);
  //Double_t i=GetBinContenthAcceptAll->GetXaxis()->FindBin(20),hAcceptAll->GetYaxis()->FindBin(10));

   cout<<c<<" "<<f<<" "<<z<<endl;
  
  //Double_t m=hAcceptAll->GetBinContent(k,l);
  //draw hist_2 first as it has a larger range
  
   TLatex latex;
  //latex.DrawLatex(17,8,TString::Format("#bullet %f ",a));
  //latex.DrawLatex(17,8,TString::Format("#bullet %2f %",c*100));
   latex.DrawLatex(17,8,"#bullet 64%");
   latex.DrawLatex(13,8,"#diamond 72%");
   latex.DrawLatex(20,10,"#color[2]{#bullet} 43%");
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(17,8,TString::Format("%f",c));
  //latex.DrawLatex(13,8,TString::Format("#diamond %f ",f));
  
  //latex.DrawLatex(20,10,TString::Format("#circ %f ",i));
  
   latex.DrawLatex(3,22,"#bullet");
   latex.DrawLatex(2.83,25,"#diamond");
  
  
  
   latex.DrawLatex(4,28,"#scale[0.8]{HLT Paths(Run-1)}");
   latex.DrawLatex(4,22,"#scale[0.8]{Mu17_Mu8 (Luminosity 19.1 fb^{-1})}");
   latex.DrawLatex(4,25,"#scale[0.8]{Mu13_Mu8 (Luminosity 3.7 fb^{-1})}");
  
   latex.DrawLatex(4,19,"#scale[0.8]{Offline selection}");
   latex.DrawLatex(3,16,"#color[2]{#bullet}");
   latex.DrawLatex(4,16,"#scale[0.8]{Mu20_Mu10}");
   c1->SaveAs("acceptance_2d_all_cont3.pdf");
  
   //Case-1
   */

<file_sep>{
  // Set up FW Lite for automatic loading of CMS libraries
  // and data formats.   As you may have other user-defined setup
  // in your rootlogon.C, the CMS setup is executed only if the CMS
  // environment is set up.
  //
  TString cmsswbase = getenv("CMSSW_BASE");
  if (cmsswbase.Length() > 0) {
    //
    // The CMSSW environment is defined (this is true even for FW Lite)
    // so set up the rest.
    //
    cout << "Loading FW Lite setup." << endl;
    gSystem->Load("libFWCoreFWLite.so");
    AutoLibraryLoader::enable();
    gSystem->Load("libDataFormatsFWLite.so");
    gSystem->Load("libDataFormatsPatCandidates.so");
    //TStyle *gStyle= new TStyle("BABAR","BaBar approved plots style");
    gStyle->SetFrameBorderMode(0);
    gStyle->SetCanvasBorderMode(0);
    gStyle->SetPadBorderMode(0);
    gStyle->SetPadColor(0);
    gStyle->SetCanvasColor(0);
    gStyle->SetStatColor(0);
    

    // set the paper & margin sizes
    gStyle->SetPaperSize(20,26);
    gStyle->SetPadTopMargin(0.05);
    gStyle->SetPadRightMargin(0.05);
    gStyle->SetPadBottomMargin(0.16);
    gStyle->SetPadLeftMargin(0.12);

    // use large Times-Roman fonts
    gStyle->SetTextFont(132);
    gStyle->SetTextSize(0.08);
    gStyle->SetLabelFont(132,"x");
    gStyle->SetLabelFont(132,"y");
    gStyle->SetLabelFont(132,"z");
    gStyle->SetLabelSize(0.05,"x");
    gStyle->SetTitleSize(0.06,"x");
    gStyle->SetLabelSize(0.05,"y");
    gStyle->SetTitleSize(0.06,"y");
    gStyle->SetLabelSize(0.05,"z");
    gStyle->SetTitleSize(0.06,"z");

    // use bold lines and markers
    gStyle->SetMarkerStyle(20);
    gStyle->SetHistLineWidth(1.85);
    gStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes

    // get rid of X error bars and y error bar caps
    gStyle->SetErrorX(0.001);

    // do not display any of the standard histogram decorations
    gStyle->SetOptTitle(0);
    gStyle->SetOptStat(0);
    gStyle->SetOptFit(0);
    
    // put tick marks on top and RHS of plots
    
    
    gROOT->SetStyle("Plain");
    gStyle->SetOptStat(1111111);
    gStyle->SetPadTickX(1);
    gStyle->SetPadTickY(1);
    
  }
}



<file_sep>import FWCore.ParameterSet.Config as cms
## ---
## PAT trigger matching
## --
matchHLTMuons = cms.EDProducer(
   # matching in DeltaR, sorting by best DeltaR
   "PATTriggerMatcherDRLessByR"
   # matcher input collections
   , src     = cms.InputTag( 'selectedPatMuons' )
   , matched = cms.InputTag( 'patTrigger' )
   # selections of trigger objects
   , matchedCuts = cms.string( 'type( "TriggerMuon" ) && ( path( "HLT_IsoMu24_v*" ) || path( "HLT_IsoMu24" ) )' )
   # selection of matches
   , maxDPtRel   = cms.double( 0.5 ) # no effect here
   , maxDeltaR   = cms.double( 0.5 )
   , maxDeltaEta = cms.double( 0.2 ) # no effect here
   # definition of matcher output
   , resolveAmbiguities    = cms.bool( True )
   , resolveByMatchQuality = cms.bool( True )
  )
<file_sep>#Automatically created by SCRAM
import os
__path__.append(os.path.dirname(os.path.abspath(__file__).rsplit('/VHTauTau/TreeMaker/',1)[0])+'/cfipython/slc6_amd64_gcc481/VHTauTau/TreeMaker')
<file_sep>#include <iostream>
#include <algorithm>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h"
#include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
#include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h"
 
#include "TTree.h"
#include "TClonesArray.h"

#include "VHTauTau/TreeMaker/plugins/JetBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

PFJetIDSelectionFunctor pfjetIDLoose(PFJetIDSelectionFunctor::FIRSTDATA, PFJetIDSelectionFunctor::LOOSE);
PFJetIDSelectionFunctor pfjetIDTight(PFJetIDSelectionFunctor::FIRSTDATA, PFJetIDSelectionFunctor::TIGHT);
pat::strbitset retpf = pfjetIDLoose.getBitTemplate();

// Constructor
JetBlock::JetBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("jetSrc")),
  _jecUncPath(iConfig.getParameter<std::string>("jecUncertainty")),
  _applyResJEC (iConfig.getParameter<bool>     ("applyResidualJEC")),
  _resJEC (iConfig.getParameter<std::string>   ("residualJEC"))
{}
void JetBlock::beginJob() 
{
  std::string tree_name = "vhtree";
  TTree* tree = vhtm::Utility::getTree(tree_name);
  cloneJet = new TClonesArray("vhtm::Jet");
  tree->Branch("Jet", &cloneJet, 32000, 2);
  tree->Branch("nJet", &fnJet, "fnJet/I");
}
void JetBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneJet->Clear();
  fnJet = 0;

  JetCorrectionUncertainty *jecUnc = 0;
  JetCorrectorParameters *ResJetCorPar = 0;
  FactorizedJetCorrector *JEC = 0;
  bool applyResJECLocal = _applyResJEC;
  if (_applyResJEC) {
    try {
      edm::FileInPath fipUnc(_jecUncPath);;
      jecUnc = new JetCorrectionUncertainty(fipUnc.fullPath());

      edm::FileInPath fipRes(_resJEC);
      ResJetCorPar = new JetCorrectorParameters(fipRes.fullPath());
      std::vector<JetCorrectorParameters> vParam;
      vParam.push_back(*ResJetCorPar);
      JEC = new FactorizedJetCorrector(vParam);
    }
    catch (std::exception& ex) {
      edm::LogInfo("JetBlock") << "The following exception occurred:" 
                               << std::endl 
                               << ex.what();
      applyResJECLocal = false; 
    } 
  }
  edm::Handle<edm::View<pat::Jet> > jets;
  iEvent.getByLabel(_inputTag, jets);

  if (jets.isValid()) {
    unsigned int njets = jets->size();
    edm::LogInfo("JetBlock") << "Total # PAT Jets: " << njets;
    for (size_t i = 0; i < njets; ++i) {
      if (fnJet == kMaxJet) {
	edm::LogInfo("JetBlock") << "Too many PAT Jets, fnJet = " << fnJet; 
	break;
      }
      const pat::Jet& jet = jets->at(i);
      retpf.set(false);
      int passjetLoose = (pfjetIDLoose(jet, retpf)) ? 1 : 0;

      retpf.set(false);
      int passjetTight = (pfjetIDTight(jet, retpf)) ? 1 : 0;

      double corr = 1.;
      if (applyResJECLocal && iEvent.isRealData() ) {
        JEC->setJetEta(jet.eta());
        JEC->setJetPt(jet.pt()); // here you put the L2L3 Corrected jet pt
        corr = JEC->getCorrection();
      }

      if (jecUnc) {
        jecUnc->setJetEta(jet.eta());
        jecUnc->setJetPt(jet.pt()*corr); // the uncertainty is a function of the corrected pt
      }
      jetB = new ((*cloneJet)[fnJet++]) vhtm::Jet();

      // fill in all the vectors
      jetB->eta        = jet.eta();
      jetB->phi        = jet.phi();
      jetB->pt         = jet.pt()*corr;
      jetB->pt_raw     = jet.correctedJet("Uncorrected").pt();
      jetB->energy     = jet.energy()*corr;
      jetB->energy_raw = jet.correctedJet("Uncorrected").energy();
      jetB->jecUnc     = (jecUnc) ? jecUnc->getUncertainty(true) : -1;
      jetB->resJEC     = corr;
      jetB->partonFlavour = jet.partonFlavour();

      // Jet identification in high pile-up environment
      float mvaValue = jet.userFloat("pileupJetIdProducer:fullDiscriminant");
      jetB->puIdMVA = mvaValue;
      jetB->puIdBits = jet.userInt("pileupJetIdProducer:fullId"); // Bits: 0:Tight,1:Medium,2:Loose

      jetB->chargedEmEnergyFraction     = jet.chargedEmEnergyFraction();
      jetB->chargedHadronEnergyFraction = jet.chargedHadronEnergyFraction();
      jetB->chargedMuEnergyFraction     = jet.chargedMuEnergyFraction();
      jetB->electronEnergyFraction      = jet.electronEnergy()/jet.energy();
      jetB->muonEnergyFraction          = jet.muonEnergyFraction();
      jetB->neutralEmEnergyFraction     = jet.neutralEmEnergyFraction();
      jetB->neutralHadronEnergyFraction = jet.neutralHadronEnergyFraction();
      jetB->photonEnergyFraction        = jet.photonEnergyFraction();

      jetB->chargedHadronMultiplicity   = jet.chargedHadronMultiplicity();
      jetB->chargedMultiplicity         = jet.chargedMultiplicity();
      jetB->electronMultiplicity        = jet.electronMultiplicity();
      jetB->muonMultiplicity            = jet.muonMultiplicity();
      jetB->neutralHadronMultiplicity   = jet.neutralHadronMultiplicity();
      jetB->neutralMultiplicity         = jet.neutralMultiplicity();
      jetB->photonMultiplicity          = jet.photonMultiplicity();

      jetB->nConstituents               = jet.numberOfDaughters();
      jetB->trackCountingHighEffBTag         = jet.bDiscriminator("trackCountingHighEffBJetTags");
      jetB->trackCountingHighPurBTag         = jet.bDiscriminator("trackCountingHighPurBJetTags");
      jetB->simpleSecondaryVertexHighEffBTag = jet.bDiscriminator("simpleSecondaryVertexHighEffBJetTags");
      jetB->simpleSecondaryVertexHighPurBTag = jet.bDiscriminator("simpleSecondaryVertexHighPurBJetTags");
      jetB->jetProbabilityBTag               = jet.bDiscriminator("jetProbabilityBJetTags");
      jetB->jetBProbabilityBTag              = jet.bDiscriminator("jetBProbabilityBJetTags");
      jetB->combinedSecondaryVertexBTag      = jet.bDiscriminator("combinedSecondaryVertexBJetTags");
      jetB->combinedSecondaryVertexMVABTag   = jet.bDiscriminator("combinedSecondaryVertexMVABJetTags");
      jetB->combinedInclusiveSecondaryVertexBTag = jet.bDiscriminator("combinedInclusiveSecondaryVertexBJetTags");
      jetB->combinedMVABTag                  = jet.bDiscriminator("combinedMVABJetTags");
      jetB->passLooseID = passjetLoose;
      jetB->passTightID = passjetTight;
      if (_verbosity > 0) 
      std::cout << "JetBlock: trackCountingHighEffBJetTag = " << jetB->trackCountingHighEffBTag
                << ", trackCountingHighPurBJetTag = " << jetB->trackCountingHighPurBTag
                << ", jetProbabilityBTag = " << jetB->jetProbabilityBTag  
                << ", jetBProbabilityBTag = " << jetB->jetBProbabilityBTag  
                << std::endl;
    }
  } 
  else {
    edm::LogError("JetBlock") << "Error >> Failed to get pat::Jet collection for label: " 
                              << _inputTag;
  }
  if (jecUnc) delete jecUnc;
  if (ResJetCorPar) delete ResJetCorPar;
  if (JEC) delete JEC;
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(JetBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

vertexBlock = cms.EDAnalyzer("VertexBlock",
  verbosity = cms.int32(1),
  vertexSrc = cms.InputTag('offlinePrimaryVertices')
)
<file_sep>#ifndef __VHTauTau_TreeMaker_TriggerBlock_h
#define __VHTauTau_TreeMaker_TriggerBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DataFormats/Common/interface/Ref.h"

#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/ParameterSet/interface/ProcessDesc.h"

#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

class TClonesArray;
//class Trigger;

class TriggerBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup);
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit TriggerBlock(const edm::ParameterSet& iConfig);
  virtual ~TriggerBlock();

private:
  //TClonesArray* cloneTrigger; 

  int _verbosity;
  edm::InputTag _inputTag;

  const edm::InputTag _l1InputTag;
  const edm::InputTag _hltInputTag;
  const std::vector<std::string> _hltPathsOfInterest;
  HLTConfigProvider hltConfig;

  std::vector<int> *_l1physbits;
  std::vector<int> *_l1techbits;
  std::vector<std::string> *_hltpaths;
  std::vector<int> *_hltresults;
  std::vector<int> *_hltprescales;
};
#endif
<file_sep>#ifndef __VHTauTau_TreeMaker_GenJetBlock_h
#define __VHTauTau_TreeMaker_GenJetBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class GenJet;

class GenJetBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit GenJetBlock(const edm::ParameterSet& iConfig);
  virtual ~GenJetBlock() {}

  enum {
    kMaxGenJet = 100
  };

private:
  TClonesArray* cloneGenJet; 
  int  fnGenJet;
  int _verbosity;
  edm::InputTag _inputTag;

  vhtm::GenJet* genJetB; 
};
#endif
<file_sep>#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/Common/interface/View.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/HitPattern.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "Math/GenVector/VectorUtil.h"

#include "VHTauTau/TreeMaker/plugins/TrackBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

TrackBlock::TrackBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("trackSrc")),
  _beamSpot(iConfig.getParameter<edm::InputTag>("offlineBeamSpot"))
{}
void TrackBlock::beginJob() 
{
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneTrack = new TClonesArray("vhtm::Track");
  tree->Branch("Track", &cloneTrack);
  tree->Branch("nTrack", &fnTrack,  "fnTrack/I");
}
void TrackBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneTrack->Clear();
  fnTrack = 0;

  // read the beam spot
  edm::Handle<reco::BeamSpot> beamSpot;
  iEvent.getByLabel(_beamSpot, beamSpot);

  edm::Handle<reco::TrackCollection> tracks;
  iEvent.getByLabel(_inputTag, tracks);

  if (tracks.isValid()) {
    edm::LogInfo("TrackBlock") << "Total # of Tracks: " << tracks->size();
    reco::Track::TrackQuality quality = reco::Track::qualityByName("loose");
    for (reco::TrackCollection::const_iterator  it  = tracks->begin(); 
                                                it != tracks->end(); ++it) {
      const reco::Track &track = *it;
      if (!track.quality(quality)) continue;

      if (fnTrack == kMaxTrack) {
	edm::LogInfo("TrackBlock") << "Too many Tracks in the event, fnTrack = " << fnTrack; 
	break;
      }
      trackB = new ((*cloneTrack)[fnTrack++]) vhtm::Track();
      trackB->eta         = track.eta();
      trackB->etaError    = track.etaError();
      trackB->theta       = track.theta();
      trackB->thetaError  = track.thetaError();
      trackB->phi         = track.phi();
      trackB->phiError    = track.phiError();
      trackB->p           = track.p();
      trackB->pt          = track.pt();
      trackB->ptError     = track.ptError();
      trackB->qoverp      = track.qoverp();
      trackB->qoverpError = track.qoverpError(); 
      trackB->charge      = track.charge();

      trackB->nValidHits  = track.numberOfValidHits();
      trackB->nLostHits   = track.numberOfLostHits();
      trackB->validFraction = track.validFraction();

      const reco::HitPattern& hitp = track.hitPattern();
      trackB->nValidTrackerHits  = hitp.numberOfValidTrackerHits();      
      trackB->nValidPixelHits    = hitp.numberOfValidPixelHits();
      trackB->nValidStripHits    = hitp.numberOfValidStripHits();
      trackB->trackerLayersWithMeasurement = hitp.trackerLayersWithMeasurement(); 
      trackB->pixelLayersWithMeasurement   = hitp.pixelLayersWithMeasurement();
      trackB->stripLayersWithMeasurement   = hitp.stripLayersWithMeasurement();
 
      trackB->dxy       = track.dxy(beamSpot->position());
      trackB->dxyError  = track.dxyError();
      trackB->dz        = track.dz(beamSpot->position());
      trackB->dzError   = track.dzError();
      //     trackB->d0        = track.d0();

      trackB->chi2      = track.chi2();
      trackB->ndof      = track.ndof();
      trackB->vx        = track.vx();
      trackB->vy        = track.vy();
      trackB->vz        = track.vz();
    }
  } 
  else {
    edm::LogError("TrackBlock") << "Error! Failed to get reco::Track collection, " 
                                << _inputTag;
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(TrackBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

electronBlock = cms.EDAnalyzer("ElectronBlock",
  verbosity       = cms.int32(0),
  offlineBeamSpot = cms.InputTag('offlineBeamSpot'),
  trackSrc        = cms.InputTag('generalTracks'),
  vertexSrc       = cms.InputTag('offlinePrimaryVertices'),
  electronSrc     = cms.InputTag('electronVariables')
)
<file_sep>#include <algorithm>
#include <iostream>

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"

#include "TTree.h"
#include "TClonesArray.h"

#include "VHTauTau/TreeMaker/plugins/GenEventBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

GenEventBlock::GenEventBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getUntrackedParameter<int>("verbosity", 0)),
  _genEvtInfoInputTag(iConfig.getParameter<edm::InputTag>("GenEventInfoInputTag")),
  _storePDFWeights(iConfig.getParameter<bool>("StorePDFWeights")),
  _pdfWeightsInputTag(iConfig.getParameter<edm::InputTag>("PDFWeightsInputTag"))
{}
GenEventBlock::~GenEventBlock() {
  delete _pdfWeights;
}
void GenEventBlock::beginJob() 
{
  _pdfWeights = new std::vector<double>();

  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneGenEvent = new TClonesArray("vhtm::GenEvent");
  tree->Branch("GenEvent", &cloneGenEvent, 32000, 2);
  tree->Branch("pdfWeights", "vector<double>", &_pdfWeights);
}
void GenEventBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray 
  cloneGenEvent->Clear();

  // Clear the two independent vectors
  _pdfWeights->clear();

  if (!iEvent.isRealData()) {
    // Create Event Object
    genEventB = new ( (*cloneGenEvent)[0] ) vhtm::GenEvent();

    // GenEventInfo Part
    edm::Handle<GenEventInfoProduct> genEvtInfoProduct;
    iEvent.getByLabel(_genEvtInfoInputTag, genEvtInfoProduct);
    if (genEvtInfoProduct.isValid()) {
      edm::LogInfo("GenEventBlock") << "Success >> obtained GenEventInfoProduct for label:" 
                                    << _genEvtInfoInputTag;
      genEventB->processID = genEvtInfoProduct->signalProcessID();
      genEventB->ptHat     = genEvtInfoProduct->hasBinningValues() 
                         ? genEvtInfoProduct->binningValues()[0] : 0.;
    } 
    else {
      edm::LogError("GenEventBlock") << "Error >> Failed to get GenEventInfoProduct for label: " 
                                     << _genEvtInfoInputTag;
    }
    // PDF Weights Part
    if (_storePDFWeights) {
      edm::Handle<std::vector<double> > pdfWeightsHandle;
      iEvent.getByLabel(_pdfWeightsInputTag, pdfWeightsHandle);
      if (pdfWeightsHandle.isValid()) {
	edm::LogInfo("GenEventBlock") << "Success >> obtained PDF handle for label: " 
                                      << _pdfWeightsInputTag;
	copy(pdfWeightsHandle->begin(), pdfWeightsHandle->end(), genEventB->pdfWeights.begin());
	copy(pdfWeightsHandle->begin(), pdfWeightsHandle->end(), _pdfWeights->begin());
      } 
      else {
	edm::LogError("GenEventBlock") << "Error >>  Failed to get PDF handle for label: " 
                                       << _pdfWeightsInputTag;
      }
    }
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GenEventBlock);
<file_sep>#include "TTree.h"
#include "TClonesArray.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/METReco/interface/GenMET.h"
#include "DataFormats/METReco/interface/GenMETFwd.h"

#include "VHTauTau/TreeMaker/plugins/GenMETBlock.h"
#include "VHTauTau/TreeMaker/interface/Utility.h"

GenMETBlock::GenMETBlock(const edm::ParameterSet& iConfig) :
  _verbosity(iConfig.getParameter<int>("verbosity")),
  _inputTag(iConfig.getParameter<edm::InputTag>("genMETSrc"))
{
}
void GenMETBlock::beginJob() 
{
  // Get TTree pointer
  TTree* tree = vhtm::Utility::getTree("vhtree");
  cloneGenMET = new TClonesArray("vhtm::GenMET");
  tree->Branch("GenMET", &cloneGenMET, 32000, 2);
  tree->Branch("nGenMET", &fnGenMET,  "fnGenMET/I");
}
void GenMETBlock::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
  // Reset the TClonesArray and the nObj variables
  cloneGenMET->Clear();
  fnGenMET = 0;

  if (!iEvent.isRealData()) {
    edm::Handle<reco::GenMETCollection> mets;
    iEvent.getByLabel(_inputTag, mets);
    if (mets.isValid()) {
      edm::LogInfo("GenMETBlock") << "Total # GenMETs: " << mets->size();
      for (reco::GenMETCollection::const_iterator it = mets->begin(); 
                                                 it != mets->end(); ++it ) {
        if (fnGenMET == kMaxGenMET) {
	  edm::LogInfo("GenMETBlock") << "Too many GenMET, fnGenMET = " << fnGenMET; 
	  break;
        }
        genMetB = new ((*cloneGenMET)[fnGenMET++]) vhtm::GenMET();

        // fill in all the vectors
        genMetB->met    = it->pt();
        genMetB->metphi = it->phi();
        genMetB->sumet  = it->sumEt();
      }
    } 
    else {
      edm::LogError("GenMETBlock") << "Error >>  Failed to get GenMETCollection for label: " 
                                   << _inputTag;
    }
  }
}
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(GenMETBlock);
<file_sep>import FWCore.ParameterSet.Config as cms

tauBlock = cms.EDAnalyzer("TauBlock",
                          verbosity = cms.int32(0),
                          #patTauSrc = cms.InputTag('tauVariables'),
                          patTauSrc = cms.InputTag('selectedPatTausPFlow'),
                          vertexSrc = cms.InputTag('offlinePrimaryVertices')
                          )
<file_sep>import FWCore.ParameterSet.Config as cms

genJetBlock = cms.EDAnalyzer("GenJetBlock",
  verbosity = cms.int32(0),
  genJetSrc = cms.InputTag('ak5GenJets')
)
<file_sep>import FWCore.ParameterSet.Config as cms
                  
#channel = "BLABLA"

process = cms.Process("HTauTauTree")


## MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1

#from CalibCalorimetry.EcalTrivialCondModules.EcalTrivialCondRetriever_cfi import *
#process.myCond = EcalTrivialConditionRetriever.clone()
#process.es_prefer_gt = cms.ESPrefer("PoolDBESSource","GlobalTag")


## Options and Output Report
process.options   = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )

process.options.allowUnscheduled = cms.untracked.bool( True )

## Geometry and Detector Conditions (needed for a few patTuple production steps)
#process.load('Configuration.Geometry.GeometryExtended2017Reco_cff') 
#process.load('Configuration.Geometry.GeometryExtended2017_cff')
process.load('Configuration.Geometry.GeometryExtended2019Reco_cff')
process.load('Configuration.Geometry.GeometryExtended2019_cff')

process.load('Configuration.StandardSequences.MagneticField_38T_cff')

#process.load("RecoLocalCalo.EcalRecAlgos.EcalSeverityLevelESProducer_cfi")

process.load('Configuration.StandardSequences.Services_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
#process.GlobalTag.globaltag = 'STAR17_61_V5A::All'
#process.GlobalTag.globaltag = 'DES17_61_V4::All'

#for Archana di

process.GlobalTag.globaltag = 'DES19_62_V8::All'
process.load("Configuration.StandardSequences.MagneticField_cff")
process.source = cms.Source("PoolSource", 
                            fileNames = cms.untracked.vstring(
#'root://xrootd.unl.edu//store/mc/Fall13dr/DYJetsToLL_M-50_13TeV-pythia6/AODSIM/tsg_PU40bx50_POSTLS162_V1-v1/00000/0659AA61-2175-E311-8B63-00266CFFA2B8.root'  
#'root://xrootd.unl.edu//store/mc/Summer13/VBF_HToTauTau_M-125_14TeV-powheg-pythia6/GEN-SIM-RECO/UpgradePhase1Age0DES_DR61SLHCx_NoPileUp_DES17_61_V5-v1/10000/00A38233-7E02-E311-A483-002618943964.root'
#'root://xrootd.unl.edu//store/mc/Summer13/DYToTauTau_M-20_TuneZ2star_14TeV-pythia6-tauola/GEN-SIM-RECO/UpgradePhase1Age5H_DR61SLHCx_PU140Bx25_STAR17_61_V5A-v1/10000/0005C614-5DF2-E211-9BA8-0026189438ED.root'
#'file:/afs/cern.ch/work/a/archie/public/minbias/MinBias_TuneZ2star_14TeV_pythia6_CMSSW620_slhc5_996_1_Qy8.root',
#'file:/afs/cern.ch/work/a/archie/public/minbias/MinBias_TuneZ2star_14TeV_pythia6_CMSSW620_slhc5_997_1_1yO.root',
#'file:/afs/cern.ch/work/a/archie/public/minbias/MinBias_TuneZ2star_14TeV_pythia6_CMSSW620_slhc5_998_1_Tqc.root'
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_991_1_3qc.root',
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_996_1_kGt.root',
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_992_1_Ley.root',
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_997_1_cg0.root',
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_993_1_BdQ.root',
##'file:/afs/cern.ch/work/a/aabdelal/public/beamspotGauss/MinBias/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_998_1_QuQ.root',
'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1000_1_ESt.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1001_1_V3z.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1002_1_8rt.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1003_1_Jyg.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1004_1_cXq.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1005_1_YZ0.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1006_3_J9v.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1007_1_QBm.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1008_1_KS4.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1009_1_puE.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_100_1_En4.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1010_1_IFd.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1011_3_hFJ.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1012_1_dwz.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1013_1_xV0.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1014_1_Icy.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1015_1_tvI.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1016_1_SkU.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1017_1_jC3.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1018_1_NFq.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1019_1_YgP.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_101_1_L9f.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1020_1_Nz2.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1021_1_pds.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1022_1_Yg6.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1023_4_cu4.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1024_2_RF2.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1025_1_f4D.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1026_1_5NT.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1027_1_T4x.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1028_1_hqF.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1029_1_Vix.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1030_1_7Aj.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1031_1_flV.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1032_1_h62.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1033_1_Kvc.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1034_1_QOT.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1035_1_mWE.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1036_1_qYF.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1038_1_8CV.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1039_1_hTe.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_103_1_7NH.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1040_1_cAT.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1041_1_4N5.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1042_1_2La.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1043_1_5F0.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1044_1_hlt.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1045_1_2Pm.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1046_1_GHO.root',
#'root://xrootd.unl.edu//store/user/aabdelal/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/aabdelal_MinBias_TuneZ2star_14TeV_pythia6_14TeV_GaussBS_RECO_aod_CMSSW_6_2_0_SLHC5/4b73dbaf4bf75a21ad171c02dcd12bab/MinBias_TuneZ2star_14TeV_GaussBS_RECO_620slhc5_1047_1_ZpV.root'

)
                            )

process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) )

## Output Module Configuration (expects a path 'p')
#process.load("HighMassAnalysis.Configuration.patTupleEventContentForHiMassTau_cff")
###from HighMassAnalysis.Configuration.patTupleEventContentForHiMassTau_cff import *
###process.out = cms.OutputModule("PoolOutputModule",
###                               fileName = cms.untracked.string('skimPat.root'),
###                               # save only events passing the full path
###                               SelectEvents   = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),
###                            #   outputCommands = cms.untracked.vstring('drop *', *patTupleEventContent ),
###                               fastCloning = cms.untracked.bool(False)
###                               )

#from PhysicsTools.PatAlgos.patEventContent_cff import patEventContentNoCleaning
#process.out = cms.OutputModule("PoolOutputModule",
                               #fileName = cms.untracked.string('patTuple.root'),
                               ## save only events passing the full path
                               #SelectEvents = cms.untracked.PSet( SelectEvents = cms.vstring('p') ),
                               ## save PAT output; you need a '*' to unpack the list of commands
                               ## 'patEventContent'
                               #outputCommands = cms.untracked.vstring('drop *', *patEventContentNoCleaning )
                               #)

process.TFileService = cms.Service("TFileService",
  fileName = cms.string('test_53x.root')
)


#process.scrapingVeto = cms.EDFilter("FilterOutScraping",
#                                    applyfilter = cms.untracked.bool(True),
#                                    debugOn = cms.untracked.bool(False),
#                                    numtrack = cms.untracked.uint32(10),
#                                    thresh = cms.untracked.double(0.2)
#                                    )

#process.selectedVertices = cms.EDFilter("VertexSelector",
#    src = cms.InputTag('offlinePrimaryVertices'),
#    cut = cms.string('!isFake && isValid && ndof >= 4.0 && position.Rho < 2.0 && abs(z) < 24'),
#    cut = cms.string('!isFake && isValid'),
#    filter = cms.bool(True)
#)



#process.demo = cms.EDAnalyzer('TreeMaker',
#   fillHZZInfo_  = cms.bool(True),
#   patMuons = cms.InputTag("selectedPatMuons"),
#   PFMET     = cms.InputTag("pfMet"),
#   Vertex=cms.InputTag("selectedVertices"),
#   PileUpTag = cms.InputTag("addPileupInfo"),
#   fastjetTag = cms.InputTag("kt6PFJets", "rho"),
#   rhoConeSize = cms.double(0.5),
#   rhoUEOffsetCorrection = cms.double(1.0),
#   outputCommands = cms.untracked.vstring('drop *',
#        'keep *_*_*_ANA',
#        'keep *_gsfElectron*_*_*',
#        'keep *_muons_*_*',
#        'keep *_selectedPatMuons_*_*',
#        'keep *_zmm_*_*',
#        'keep *_pfMet_*_*',
#        'keep *_tcMet_*_*',
#        'keep *_ak5PFJets_*_*',
#        'keep *_TriggerResults_*_*',
#        'keep *_gtDigis_*_*',
#        'keep *_trackCountingHighEffBJetTags_*_*',
#        'keep *_ak5CaloJets_*_*',
#        'keep *_kt6PFJets_*_*',
#        'keep *_kt4PFJets_*_*',
#        'keep *_GlobalMuonPromptTight_*_*',
#        'keep *_offlinePrimaryVerticesWithBS_*_*',
#        'keep PileupSummaryInfos_*_*_*',
#        'keep *_offlinePrimaryVertices_*_*',
#        'keep *_selectedVertices_*_*',
#        'keep *_kt6PFJets_*_*',
#        'keep *_TriggerResults_*_*',
#        'keep triggerTriggerEvent_*_*_*',
#        'keep *_ak5CaloJets_*_*',
#        'keep recoPFClusters_*_*_*',
#        'keep *_selectedPatJets__*',
#        'keep *_selectedPatJetsFast__*',
#        'keep *_kt4PFJets_rho_PAT',
#        'keep *_kt4PFJetsIso_rho_PAT',
#
#    )
#
#)

## Output Module Configuration (expects a path 'p')

#process.TFileService = cms.Service("TFileService",
#                                   fileName = cms.string("analysis.root")
#                                   )
#process.outpath = cms.EndPath(process.out)
# trigger + Skim sequence
###process.load("HighMassAnalysis.Skimming.triggerReq_cfi")
###process.load("HighMassAnalysis.Skimming.genLevelSequence_cff")

###if(channel == "BLABLA"):
###  process.load("HighMassAnalysis.Skimming.TauSkimSequence_cff")
###  process.theSkim = cms.Sequence( )
###  process.hltFilter = cms.Sequence( )
###  process.genLevelSelection = cms.Sequence(  )
  
  # Standard pat sequences
process.load('RecoJets.Configuration.RecoPFJets_cff')
process.load("PhysicsTools.PatAlgos.patSequences_cff")


  # --------------------Modifications for taus--------------------
###  process.load("PhysicsTools.JetMCAlgos.TauGenJets_cfi")
  
###  process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
###  from PhysicsTools.PatAlgos.tools.tauTools import *
###  switchToPFTauHPS(process)
  
  
#from RecoJets.JetProducers.kt4PFJets_cfi import kt4PFJets
#process.kt6PFJetsForIsolation = kt4PFJets.clone( rParam = 0.6, doRhoFastjet = True )
#process.kt6PFJetsForIsolation.Rho_EtaMax = cms.double(2.5)
  
  # --------------------Modifications for jets--------------------
  
#from PhysicsTools.PatAlgos.tools.jetTools import *
## uncomment the following lines to add ak5PFJets to your PAT output
#switchJetCollection(
#    process,
#    jetSource = cms.InputTag('ak5PFJets'),
#    jetCorrections = ('AK5PF', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'Type-2'),
#    btagDiscriminators = [
#    'combinedSecondaryVertexBJetTags',
    #   'combinedSecondaryVertexMVABJetTags',
    #   'jetBProbabilityBJetTags',
    #   'jetProbabilityBJetTags',
    #   'simpleSecondaryVertexHighEffBJetTags',
    #   'simpleSecondaryVertexHighPurBJetTags',
#    ],
#    )
#process.selectedPatJets.cut = cms.string("pt > 0 && abs(eta) < 5")
  
  # --------------------Modifications for MET--------------------
###  process.load("JetMETCorrections.Type1MET.pfMETCorrections_cff")
###  process.load("JetMETCorrections.Type1MET.pfMETCorrectionType0_cfi")
###  process.pfType1CorrectedMet.applyType0Corrections = cms.bool(False)
###  process.pfType1CorrectedMet.srcType1Corrections = cms.VInputTag(
###    cms.InputTag('pfMETcorrType0'),
###    cms.InputTag('pfJetMETcorr', 'type1')        
###    )
  
  
  # Let it run

process.load("VHTauTau.TreeMaker.TreeCreator_cfi")
process.load("VHTauTau.TreeMaker.TreeWriter_cfi")
process.load("VHTauTau.TreeMaker.TreeContentConfig_cff")

#-------------------------------------------------------
# PAT 
#------------------------------------------------------
process.load("RecoTauTag.Configuration.RecoPFTauTag_cff")
process.load("PhysicsTools.PatAlgos.patSequences_cff")

import PhysicsTools.PatAlgos.tools.tauTools as tauTools
tauTools.switchToPFTauHPS(process) # For HPS Taus
process.p = cms.Path(
    #      process.type0PFMEtCorrection +
    #      process.producePFMETCorrections +
    #      process.tauGenJets +
    #      process.recoTauClassicHPSSequence +
    process.patDefaultSequence 
    #    process.treeCreator +
    #    process.treeContentSequence +
    #    process.treeWriter
    #      process.kt6PFJetsForIsolation + 
    #      process.demo
    )
<file_sep>import FWCore.ParameterSet.Config as cms
process = cms.Process("HTauTauTree")
#------------------------
# Message Logger Settings
#------------------------
process.load("FWCore.MessageLogger.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1
#--------------------------------------
# Event Source & # of Events to process
#---------------------------------------
process.source = cms.Source("PoolSource",
  fileNames = cms.untracked.vstring()
)
process.maxEvents = cms.untracked.PSet(
  input = cms.untracked.int32(1)
)
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) )

#-----------------------------
# Geometry
#-----------------------------
process.load("Configuration.StandardSequences.Geometry_cff")
#-----------------------------
# Magnetic Field
#-----------------------------
process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
#-------------
# Global Tag
#-------------
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag = 'START53_V11::All'
#-------------
# Output ROOT file
#-------------

process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
process.printTree = cms.EDAnalyzer("ParticleListDrawer",
                                     maxEventsToPrint = cms.untracked.int32(1),
                                     printVertex = cms.untracked.bool(False),
                                     src = cms.InputTag("genParticles")
                                   )
process.p = cms.Path(process.printTree)

process.PoolSource.fileNames = [
#'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/htotautomu_test.root',
#'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu_2/htotautomu_test_1_1_Hii.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/VHTauTau/TreeMaker/test/00E903E2-9FE9-E111-8B1E-003048FF86CA.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu_1/htotautomu_test_1_1_uIk.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu_1/htotautomu_test_3_1_wvk.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_1_1_zfD.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_2_1_1KO.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_6_1_Iwi.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_5_1_bow.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_12_1_DKN.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_13_1_lxR.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_7_1_r99.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_14_1_Y2O.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_4_1_7d9.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_10_1_72r.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_11_1_dgO.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_9_1_06x.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_15_1_36z.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_19_1_5Lg.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_22_1_Mi5.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_20_1_Fzy.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_17_1_O0L.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_16_1_fYJ.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_8_1_OgL.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_21_1_8jw.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_23_1_IkX.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_29_1_To5.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_28_1_zWe.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_30_1_WXO.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_18_1_ilY.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_25_1_UfF.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_24_1_j6W.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_26_1_csG.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_27_1_9DE.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_31_1_VR9.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_40_1_Eeb.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_38_1_ZYz.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_39_1_dq7.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_32_1_e7e.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_35_1_KDG.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_33_1_PJV.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_36_1_Nxk.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_37_1_Nq9.root',
'file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/htotautomu_test_34_1_6uG.root',
]
<file_sep>#ifndef __VHTauTau_TreeMaker_JetBlock_h
#define __VHTauTau_TreeMaker_JetBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "DataFormats/Common/interface/Ref.h"

#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "FWCore/ParameterSet/interface/ProcessDesc.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class Jet;

class JetBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit JetBlock(const edm::ParameterSet& iConfig);
  virtual ~JetBlock() {}

  enum {
    kMaxJet = 100
  };
private:
  TClonesArray* cloneJet; 
  int fnJet;

  int _verbosity;
  edm::InputTag _inputTag;
  std::string _jecUncPath;
  bool _applyResJEC;
  std::string _resJEC;

  vhtm::Jet* jetB;
};
#endif
<file_sep>ls -ltr $1/| grep root | awk '{print ""$NF""}' > file
sed 's/^/file:/' file > newfile ; mv newfile file
sed -e "s|file:|file:$1|g" file > file1; mv file1 file
#sed -e "s/\(.*\)/'\1'/" file > file1; mv file1 file
#sed 's/$/,/' file > file1; mv file1 file
#xargs <file1 | sed -e "s|file:|file:/home/amohapatra/work/test/CMSSW_6_2_0_SLHC5/src/GluHTauMuMu/|g" > file<file_sep>#ifndef __VHTauTau_TreeMaker_TauBlock_h
#define __VHTauTau_TreeMaker_TauBlock_h

#include <string>
#include <vector>

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"

#include "VHTauTau/TreeMaker/interface/PhysicsObjects.h"

class TClonesArray;
class Tau;

class TauBlock : public edm::EDAnalyzer 
{
private:
  virtual void beginJob();
  virtual void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
  virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
  virtual void endJob() {}

public:
  explicit TauBlock(const edm::ParameterSet& iConfig);
  virtual ~TauBlock();

  static const reco::PFJetRef& getJetRef(const reco::PFTau& tau);

  enum {
    kMaxTau = 100
  };

private:
  TClonesArray* cloneTau; 
  int  fnTau;
  int _verbosity;
  edm::InputTag _inputTag;
  edm::InputTag _vtxInputTag;

  vhtm::Tau* tauB;
};
#endif
