• Workflow of HWWFramework:

Links to various places

Code this tutorial uses

You can find all the scripts on lxplus /afs/cern.ch/user/c/cburgard/public/2014-12-tutorial

Setting up sample structures

In most of the analyses, there are quite a large number of MC samples. For instance, there are multiple separate AOD files contributing to "Z+jets". So it's useful to have some organization like the following,

  • Z+jets
    • Z→ee+jets
      • Z→ee + 1 jets (DSID=xxxxxxx)
      • Z→ee + 2 jets (DSID=xxxxxxx)
      • ...
      • Z→ee + n+ jets (DSID=xxxxxxx)
    • Z→µµ+jets
      • ...
      • ...
    • Z→ττ+jets
      • ...
      • ...

QFramework (or Q) first starts with organizing samples like this with appropriate xsection information by providing a .csv file. For example,

SampleID , xsection     ,filtereff , kfactor ,  mh , generator      ,                 process , simulation,  path
 117050  ,  252.89      ,     1.0  , 0.543   , --- , Powheg+Pythia6 ,       ttbar(w/oFullHad) ,       AFII,  bkg/$(channel)/top/ttbar
 147771  , 1241.2       ,     1.0  , 1.0     , --- , Sherpa         ,           Z->mumu(40<M) ,       Full,  bkg/$(channel)/Zjets/Z/mm
 161055  ,    0.0356152 ,     1.0  , 0.5071  , 125 , PowHeg+Pythia8 ,       VBF H->WW->leplep ,       Full,  sig/$(channel)/vbf

Here, we have ttbar, and one of the Z+jets file and VBF higgs signal. As you can see the folder structures are defined. The $(...) notation is used to generically define a path. When creating a complete folder structure users provide to python code what these placeholder variables can be and Q will generate a folder structure for you. Now run,

python tqxsecparserexample.py

Where the content of the code is,

#!/usr/bin/env python2
# this files name is 'tqxsecparserexample.py'
# you will also need a file named 'xsection.csv'
from QFramework import *
from ROOT import *
samples = TQSampleFolder("samples")
# cross section parsers can parse cross section files
# and populate sample folders with the appropriate samples
# lets start by creating one
xsp = TQXSecParser(samples)
# of course, we need to parse the cross section file
# this time, we will use a CSV table
# but we can also read other file formats
# we need to tell the parser where to put the sampeles in the folder
# this time, the information is stored in a column of the file
# but we could also use an external file for that
# we need to announce the realizations of the placeholder variables
# this time, we will only run over the mm channel
# xsp.addPathVariant("channel='ee'")
# if we tell the parser the name of the tree,
# it will deposit this information in the samples
# this will make our life a bit easier later on
# the tree name may also contain placeholder variables
# now, populate the folder structure
# in the end, we can write the result to a root file

After a moment, you'll see an output of resulting folder structure.

Name                                                        Class                         Details                                                                                 
bkg/                                                        TQSampleFolder                1 object, no tags                                                                       
  mm/                                                       TQSampleFolder                2 objects, no tags                                                                      
    top/                                                    TQSampleFolder                1 object, no tags                                                                       
      ttbar/                                                TQSampleFolder                1 object, no tags                                                                       
        117050/                                             TQSample                      Powheg+Pythia6 (AFII): ttbar(w/oFullHad)                                                
    Zjets/                                                  TQSampleFolder                1 object, no tags                                                                       
      Z/                                                    TQSampleFolder                1 object, no tags                                                                       
        mm/                                                 TQSampleFolder                1 object, no tags                                                                       
          147771/                                           TQSample                      Sherpa (Full): Z->mumu(40<M)                                                            
sig/                                                        TQSampleFolder                1 object, no tags                                                                       
  mm/                                                       TQSampleFolder                1 object, no tags                                                                       
    vbf/                                                    TQSampleFolder                1 object, no tags                                                                       
      161055/                                               TQSample                      PowHeg+Pythia8 (Full): VBF H->WW->leplep   

One can see the structure of samples. Here since the tqxsecparserexample.py only "expanded" the $(channel) placeholder as mm, only the dimuon channel folder structure is created. One can surely add to generate more. So far only the abstract folder structure is created. No actual xAODs are linked to these samples.

Initialize samples

Now let's actually link the xAOD files to the sample folder structure we just created. The example script is

#!/usr/bin/env python2
# this files name is 'tqsampleinitializerexample.py'
# you will also need the file 'samples-bare.root' produced by 'tqxsecparserexample.py'
# you will also need the 'Nominal' folder in 'data'
from QFramework import *
from ROOT import *
# lets re-use the sample folder from the previous example 
samples = TQSampleFolder.loadSampleFolder("samples-bare.root:samples")
# create a sample initializer
init = TQSampleInitializer()
# the event book keepers are not yet completely ready
# hence, we use a "hack" to access their information
# on the sum of weights in the file
# we can tell the sample initializer to deposit the nominal (xsection) value as a counter
# that way, we can later put it in our cutflow
# we need to tell the initializer how the filenames look like
# if we wouldn't have announced the tree name to the xsection parser already
# we would now need the following line
# init.setTagString("treeName","CollectionTree")
# now, we need to feed the location of the samples to the initializer
# then, we let the initializer 'visit' each sample to initialize it
# init.setVerbose(True)
# in the end, we can investigate and save the results

and we run by

python tqsampleinitializerexample.py

Then one should obtain an output like the following,

Name                                                        Class                         Details                                                                                 
<name>                                                      <Tag:string>                  "117050"                                                                                
<xsection>                                                  <Tag:string>                  "252.89"                                                                                
<filtereff>                                                 <Tag:string>                  "1.0"                                                                                   
<kfactor>                                                   <Tag:string>                  "0.543"                                                                                 
<mh>                                                        <Tag:string>                  "---"                                                                                   
<generator>                                                 <Tag:string>                  "Powheg+Pythia6"                                                                        
<process>                                                   <Tag:string>                  "ttbar(w/oFullHad)"                                                                     
<simulation>                                                <Tag:string>                  "AFII"                                                                                  
<path>                                                      <Tag:string>                  "bkg/$(channel)/top/ttbar"                                                              
<.xsp.xSection>                                             <Tag:double>                  252.89                                                                                  
<.xsp.filterEfficiency>                                     <Tag:double>                  1                                                                                       
<.xsp.kFactor>                                              <Tag:double>                  0.543                                                                                   
<.xsp.process>                                              <Tag:string>                  "ttbar(w/oFullHad)"                                                                     
<.xsp.generator>                                            <Tag:string>                  "Powheg+Pythia6"                                                                        
<.xsp.simulation>                                           <Tag:string>                  "AFII"                                                                                  
<.xsp.treename>                                             <Tag:string>                  "CollectionTree"                                                                        
<.init.filestamp.moddate>                                   <Tag:string>                  "Fri Dec  5 03:53:50 2014"                                                              
<.init.filestamp.md5sum>                                    <Tag:string>                  "2f67f205d25d08a29a8f9de8a3d2aa0a"                                                      
<.init.filepath>                                            <Tag:string>                  "data/Nominal/117050/HWWlnulnuMinixAOD_010009.pool.root"                                
<.init.treename>                                            <Tag:string>                  "CollectionTree"                                                                        
<.init.nevents>                                             <Tag:double>                  4                                                                                       
<.init.nentries>                                            <Tag:double>                  4                                                                                       
.cutflow/                                                   TQFolder                      1 object, no tags                                                                       
  nominal                                                   TQCounter                     9.63644 +/- 0 [raw: 1]     

-- PhilipChang - 2014-12-18

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng Screenshot_2014-12-18_11.27.47.png r1 manage 89.5 K 2014-12-18 - 18:42 PhilipChang Workflow of HWWFramework
Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2014-12-18 - PhilipChang
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback