Example #1
0
def buildNtuple3l(channel):
    "Build a tree for storing important values"
    strToProcess = "struct structSelect_t {"
    strForBranch = ""
    strToProcess += "Int_t   passTight;"
    strForBranch += "passTight/I:"
    strToProcess += "Int_t   passLoose;"
    strForBranch += "passLoose/I:"
    for ne in range(4):
        for nm in range(4-ne):
            strToProcess += "Int_t   pass_%i%i;" %(ne,nm)
            strForBranch += "pass_%i%i/I:" %(ne,nm)
    strToProcess += "};"
    strForBranch = strForBranch[:-1] # remove trailing :
    rt.gROOT.ProcessLine(strToProcess)
    rt.gROOT.ProcessLine(
    "struct structEvent_t {\
       Int_t   evt;\
       Int_t   run;\
       Int_t   lumi;\
       Int_t   nvtx;\
       Float_t lep_scale;\
       Float_t lep_scale_up;\
       Float_t lep_scale_down;\
       Float_t trig_scale;\
       Float_t pu_weight;\
    };");
    rt.gROOT.ProcessLine(
    "struct structChannel_t {\
       Char_t  channel[5];\
    };");
    rt.gROOT.ProcessLine(
    "struct struct3l_t {\
       Float_t mass;\
       Float_t sT;\
       Float_t met;\
       Float_t metPhi;\
       Int_t   jetVeto20;\
       Int_t   jetVeto30;\
       Int_t   jetVeto40;\
       Int_t   bjetVeto20;\
       Int_t   bjetVeto30;\
       Int_t   muonVeto5;\
       Int_t   muonVeto10Loose;\
       Int_t   muonVeto15;\
       Int_t   elecVeto10;\
    };");
    rt.gROOT.ProcessLine(
    "struct structH_t {\
       Float_t mass;\
       Float_t sT;\
       Float_t dPhi;\
       Float_t Pt1;\
       Float_t Eta1;\
       Float_t Phi1;\
       Float_t Pt2;\
       Float_t Eta2;\
       Float_t Phi2;\
       Int_t   Chg1;\
       Int_t   Chg2;\
    };");
    rt.gROOT.ProcessLine(
    "struct structW_t {\
       Float_t mass;\
       Float_t sT;\
       Float_t dPhi;\
       Float_t Pt1;\
       Float_t Eta1;\
       Float_t Phi1;\
       Float_t met;\
       Int_t   Chg1;\
    };");
    rt.gROOT.ProcessLine(
    "struct structHChar_t {\
       Char_t  Flv[3];\
    };");
    rt.gROOT.ProcessLine(
    "struct structLepton_t {\
       Float_t Pt;\
       Float_t Eta;\
       Float_t Phi;\
       Float_t Iso;\
       Int_t   Chg;\
    };");
    rt.gROOT.ProcessLine(
    "struct structLepChar_t {\
       Char_t  Flv[2];\
    };");

    tree = rt.TTree(channel,'H++H- 3l')
    structSelect = rt.structSelect_t()
    structEvent = rt.structEvent_t()
    structChannel = rt.structChannel_t()
    struct3l = rt.struct3l_t()
    structH1 = rt.structH_t()
    structH2 = rt.structW_t()
    structH1f = rt.structHChar_t()
    structH2f = rt.structHChar_t()
    structZ1 = rt.structH_t()
    structZ1f = rt.structHChar_t()
    structW1 = rt.structW_t()
    structW1f = rt.structHChar_t()
    structTTf = rt.structHChar_t()
    structL1 = rt.structLepton_t()
    structL2 = rt.structLepton_t()
    structL3 = rt.structLepton_t()
    structL1f = rt.structLepChar_t()
    structL2f = rt.structLepChar_t()
    structL3f = rt.structLepChar_t()
    tree.Branch('select',structSelect,strForBranch)
    tree.Branch('event',structEvent,'evt/I:run:lumi:nvtx:lep_scale/F:lep_scale_up:lep_scale_down:trig_scale:pu_weight')
    tree.Branch('channel',rt.AddressOf(structChannel,'channel'),'channel/C')
    tree.Branch('3l',struct3l,'mass/F:sT:met:metPhi:jetVeto20/I:jetVeto30:jetVeto40:bjetVeto20:bjetVeto30:muonVeto5:muonVeto10Loose:muonVeto15:elecVeto10')
    tree.Branch('h1',structH1,'mass/F:sT:dPhi:Pt1:Eta1:Phi1:Pt2:Eta2:Phi2:Chg1/I:Chg2')
    tree.Branch('h2',structH2,'mass/F:sT:dPhi:Pt1:Eta1:Phi1:met:Chg1/I')
    tree.Branch('h1Flv',rt.AddressOf(structH1f,'Flv'),'Flv/C')
    tree.Branch('h2Flv',rt.AddressOf(structH2f,'Flv'),'Flv/C')
    tree.Branch('z1',structZ1,'mass/F:sT:dPhi:Pt1:Eta1:Phi1:Pt2:Eta2:Phi2:Chg1/I:Chg2')
    tree.Branch('z1Flv',rt.AddressOf(structZ1f,'Flv'),'Flv/C')
    tree.Branch('w1',structW1,'mass/F:sT:dPhi:Pt1:Eta1:Phi1:met:Chg1/I')
    tree.Branch('w1Flv',rt.AddressOf(structW1f,'Flv'),'Flv/C')
    tree.Branch('ttFlv',rt.AddressOf(structTTf,'Flv'),'Flv/C')
    tree.Branch('l1',structL1,'Pt/F:Eta:Phi:Iso:Chg/I')
    tree.Branch('l2',structL2,'Pt/F:Eta:Phi:Iso:Chg/I')
    tree.Branch('l3',structL3,'Pt/F:Eta:Phi:Iso:Chg/I')
    tree.Branch('l1Flv',rt.AddressOf(structL1f,'Flv'),'Flv/C')
    tree.Branch('l2Flv',rt.AddressOf(structL2f,'Flv'),'Flv/C')
    tree.Branch('l3Flv',rt.AddressOf(structL3f,'Flv'),'Flv/C')
    return tree, structSelect, structEvent, structChannel, struct3l, structH1, structH2, structH1f, structH2f,\
           structZ1, structZ1f, structW1, structW1f, structTTf, structL1, structL2, structL3, structL1f, structL2f, structL3f