Fork me on GitHub

Changeset b03c0d0 in git


Ignore:
Timestamp:
May 26, 2021, 4:46:34 PM (3 years ago)
Author:
Michele Selvaggi <michele.selvaggi@…>
Branches:
master
Children:
c1780a5
Parents:
db316cd
Message:

updated examples to include gen/LHE weights

Location:
examples
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • examples/Example7.C

    rdb316cd rb03c0d0  
    3030  TClonesArray *branchElectron = treeReader->UseBranch("ElectronMedium");
    3131  TClonesArray *branchWeight = treeReader->UseBranch("Weight");
     32  TClonesArray *branchEvent = treeReader->UseBranch("Event");
    3233
    3334  // Book histograms
     
    4041    // Load selected branches with data from specified event
    4142    treeReader->ReadEntry(entry);
    42 
    43     Double_t w =1.0;
    44     // read MC event weight
     43   
     44    // main MC event weight
     45    HepMCEvent *event = (HepMCEvent*) branchEvent -> At(0);
     46    Double_t w = event->Weight;
     47   
     48    // read lhe event weights
    4549    if(branchWeight->GetEntries() > 0)
    4650    {
    4751      Weight *weight = (Weight*) branchWeight -> At(0);
    48       w = weight->Weight;
     52      Double_t lhe_weight = weight->Weight;
     53     
     54      //cout<<lhe_weight<<endl;
     55      // do stuff ...
    4956    }
    50    
     57
    5158    // If event contains at least 1 jet
    5259    if(branchJet->GetEntries() > 0)
     
    6673        histJetPT->Fill(jet->PT, w);
    6774    }
    68 
    6975
    7076    // If event contains at least 1 jet
  • examples/Example7.py

    rdb316cd rb03c0d0  
    3333
    3434# Get pointers to branches used in this analysis
    35 branchJet = treeReader.UseBranch("JetPUPPITight")
     35branchJet      = treeReader.UseBranch("JetPUPPITight")
    3636branchElectron = treeReader.UseBranch("ElectronMedium")
    37 branchWeight = treeReader.UseBranch("Weight")
     37branchWeight   = treeReader.UseBranch("Weight")
     38branchEvent    = treeReader.UseBranch("Event")
    3839
    3940# Book histograms
     
    4647  treeReader.ReadEntry(entry)
    4748
    48   w = 1.0 
    49   ## read MC event weight
    50   if branchWeight.GetEntries() > 0: 
    51     weight = branchWeight.At(0).Weight
     49  ## main MC event weight
     50  w =  branchEvent[0].Weight
    5251
     52  ## read lhe event weight
     53  for weight in branchWeight: 
     54    lhe_weight = weight.Weight
     55    ## do stuff ...
     56    ## print lhe_weight
     57   
    5358  # If event contains at least 1 jet
    5459  if branchJet.GetEntries() > 0:
     
    7681    eta = abs(electron.Eta)
    7782
     83    ## looseCut = 0.3, mediumCut = 0.2, tightCut = 0.1
    7884    IsoCut = 0.2
    7985    IsoOk = electron.IsolationVar < IsoCut
Note: See TracChangeset for help on using the changeset viewer.