Old README file

1. Running SBU/Atlas analysis code for D3PD analysis, with an example job,

    1. A. The master configuration file

1B
Running the example job

2. Augmenting the analysis code (directory pyAnalysis), and

2A
Existing analysis segments

    1. B Adding new functionality
3. Adding new classes corresponding to D3PD variables (directory pyClasses)

3A
Existing objects

3B
Adding new functionality

4. Other code

==========================================================================

1. Running SBU/Atlas analysis code for D3PD analysis

================================================

1. Get the packages

From the ATLAS group svn server get the SBD3PDAnalysis package (https://svnweb.cern.ch/trac/atlasgrp/browser/Institutes/StonyBrook/SBD3PDAnalysis)

Use the command:

> svn co $SVNGRP/Institutes/StonyBrook/SBD3PDAnalysis/trunk

(note, Dean has aliased $SVNGRP to represent svn+ssh://svn.cern.ch/reps/atlasgrp/, but you can substitute that in if you are somewhere else)

Now go to SBD3PDAnalysis/scripts and:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Do not do this! pytuple is temporarily in SBD3PDAnalysis/python in SVN until Scott updates with a fix we need.

!!!> source getPytuple.sh

!!!

!!!this will install the folder pytuple from Scott's code into our python folder.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2. Setup your account

Now setup your install with:

>source setup.sh

This will add the SBD3PDAnalysis/python to the python path and alias a run command. This should be done everytime you work with SBD3PDAnalysis.

Note, both of these scripts work relative to the location of the script folder, so they must run inside the script folder.

3. Make a master configuration file

These are analogous to top and job options in athena; an example is pyAnalysis/looperConfig.py

looperConfig is a standard file users can use, or they can write their own. All configuration files are just python code and

the master config tells which pieces of an analysis will be run and

which input tuples will be read. The master configuration file params

are described below in section 1A

4. Execute the code

Using looperConfig.py as an example, if you wanted to run it, just do:

> apollo looperConfig

You can also leave the .py on looperConfig, that will be checked for.

Or you can also do (or have to do if you didn't source the setup.sh script):

> ./looper.py looperConfig

or

> python looper.py looperConfig

A root file with histograms will appear. In looperConfig.py the default name is myAnalysis.root

1A. The master configuration file


The master configuration file is a python script, and it must have the following

three variables:

inputTuples - a list of 2-element lists. Each of the elements is a pair

consisting of a root file name and the name of the tuple tree within

the file to be read. CAVEAT: In the current version, only one file

can be read at a time. This will be improved soon. An example is

inputTuples = "myRootFileName.root","theTupleName"

analysisCodes - a list of lists. Each of the elements must be a triple, but could also be a quintuplet. The required members are:

1) An instance name for the analysis loop, used for printing and identification. Must be unique.

2) The name of the analysis segment, perhaps a selector or getter

3) The name/location of the configuration file

(optional)

4) The class type the analysis uses, e.g., electron, jet, muon, &.c

5) an alias for the class. For instance, with jets, one might have AntiKt4H1TopoJets and Cone4H1TopoJets running.

Example:

analysisCode = [

["GoodElectronSelector", "electronSelector","pyConfig/goodZElectronConfig"],

["AntiKt4H1TopoJetSelector", "JetSelector", "pyConfig/JetConfig", "jet", "jet"],

["AntiKt4TruthJetSelector", "JetSelector", "pyConfig/JetConfig", "jet", "AntiKt4TruthJets"],

["Cone4TruthJetSelector", "JetSelector", "pyConfig/JetConfig", "jet", "Cone4TruthJets"],

["AnalysisMain", "basicAnalysis","pyConfig/basicAnalysisConfig"]

]

You can see that the instance "GoodElectricSelector" does not have class or alias info, but the jet analyses do.

Existing analysis segments are found in the pyAnalysis area. This example

means that the electronSelector.py analysis is run with goodZElectronConfig.py

as its configuration (in pyConfig/), then JetSelector.py is run with JetConfig.py,

and finally basicAnalysis.py is run with

basicAnalysisConfig.py as its configuration. The arbitrary first element

can be used in message and root issues to identify the segment.

1B. The example job


To run the example job do

apollo looperConfig

The user-related code (see looperConfig.py)is

basicAnalysis.py -- this actually calls to the good electron and resonance selector

classes which implement cuts in the basicAnalysisConfig.py file

basicAnalysisConfig.py -- basic requirements for my electrons

electronSelector.py -- class where I've defined the cuts for a good electron

goodZElectronConfig.py -- the config file for the goodElectron class that

selects a good electron for a Z analysis

resSelector.py -- reconstructs a resonance from 2 input objects. Must input mass

of resonance too (like Zs for example)

ZSelectorConfig.py -- the configuration file to make Zs in the resSelector

METGetter.py -- gets MET for the analysis. The getter can get multiple types of

MET, which can be configured in pyConfig/METConfig.py. The types

of MET that may be availble can be seen in pyClasses/MET.py

METConfig.py -- configured which types of MET to get, whether to MET truth, and

whether to get the pre-cut plots of MET in METGetter.py

JetSelector.py -- Generic jet selector.

JetConfig.py -- configuration for JetSelector.py

2. Adding new parts of the analysis

===============================

A new analysis step is created by making a new class as described in 2B below.

All inputs to and results from analysis steps are communicated to later steps

via the dataMap.data python dictionary. Two elements always exist in the

dictionary:

dataMap.data["output"] - a root output file

dataMap.data["event"] - the current event (only in UserProcessEvent)

with the classes from the root -> object mapping

A complete analysis is just a sequent of analysis steps specified by a master

configuration file with results communicated via adding them to dataMap.data.

2A. Existing analysis code


- electronSelector.py - chooses electrons from the input tuple and puts a

list of chosen electrons in dataMap.data

- trackSelector.py - chooses tracks from the input tuple and puts a list

of chosen tracks in dataMap.data

- resSelector.py - using a list of particles (e.g. from electronSelector),

see if any pairs match a specified (resonance) mass range. If so,

the pairs are added to dataMap.data

- JetSelector.py - gets jets. Can be aliased to get multiple jet collections (AntiKt4Topo, Cone4H1, truth, etc)

- METGetter.py - gets and plots MET types based on a list in its config file

- basicAnalysis.py - a test histogram maker

2B. Adding new analysis code


New analyses are added by writing new python classes or extending existing

classes. The requirements for new analyses are

1. The class inherits from analysisBase.py

2. The class has a constructor of the form constructor(configName,iName)

which must call the analysisBase constructor. The first lines of the

constructor are

class className(analysisBase):

def __init__(self,configname,instancename):

analysisBase.__init__(self,configname,instancename)

... get configuration options here ...

The argument configname is the name of the configuration file for

this instance.

The argument instancename is the 3rd element in the entry for this

class in the master configuration file.

3. The class overrides methods UserInit, UserProcessEvent, UserFinish defined

by analysisBase.py.

In the constructor, the arguement

The instancename variable is the third arguement for the analysis in the

corresponding master configuration file, and it is stored in the variable

self.myName by the analysisBase constructory.

Each of these classes gets configuration information from a configuration file

which is (simple) python code. The configuration file is loaded by the

analysisBase constuctor, and can be accessed via the variable self.cfg.

See electronSelector.py and goodZElectronConfig.py for examples of an analysis

and configuration file respectively.

3. Adding new tuple -> object mapping classes

=========================================

Objects corresponding to sets of tuple variables are creating using the pytuple

infrastructure from Scott Snyder. A basic description is available at:

svn+ssh://svn.cern.ch/reps/atlasgrp/Institutes/BNL/pyAnalysis/trunk/python/pytuple/README

https://svnweb.cern.ch/trac/atlasgrp/browser/Institutes/BNL/pyAnalysis/trunk/python/pytuple/README

but we(SBU) also keeps a set of predefined classes in our pyClasses directory.

Classes are automatically imported into the python code (if they are properly

structured, see below).

3A. Existing classes


Predefined classes are kept in our pyClasses directory. The following classes

are defined for tuples created with the standard tupleMaker naming scheme:

general.py -- the fourvector class and the global (run number, etc) class

electron.py -- the electron class (inherits from fourvector)

track.py -- the track class

3B. Adding new classes


Classes are defined using the methods provided by the pytuple class. As an

example, see pyClasses/electron.py. In addition, in the python source file

defining the class must contain the following lines (typically at the bottom)

# Needed to allow tuple assocation at runtime

def connect (wrappedTuple):

print "Associating electron to tuple"

wrappedTuple.add_list(<class name>, 'tuple prefix',100,count = 'n')

# This gets the class<->tuple association done at run time

print "Adding <class name> definition to class list"

knownClasses.append(connect)

Here, the routine must be called 'connect". The text above denoted <class name>

must be replace by the actual class name (not in quotes), and the text denoted

<tuple prefix> must be replaced by the (common) beginning string for all entries

in the class. For example, the electron class uses tuple variables the names of

which all begin with "el_", so <tuple prefix> must be el_.

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2013-04-20 - KarenChen
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox All webs login

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