xAOD Analysis @ UM

To setup the ATLAS environment on UM add this to you .bashrc file

In ~/.bashrc add
 
alias setupATLAS='source /usr/local/bin/setup/cvmfs_atlas.sh'
export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH

From here you can now type

setupATLAS

This makes a bunch of setup command available to access standard ATLAS software. To start make a directory.

mkdir RootAnalysisTest
cd RootAnalysisTest
rcSetup 2.0.18,Base
 

Now grab the xAOD analysis code. On the UM cluster the quickest way is to grab it from here.

cp -r /atlas/data19/jsearcy/Stable_Packages/* ./
 

There are some helpful scripts in the QuickEventAna folder that you can make available in bash with

export PATH=$PATH:$PWD/QuickEventAna/scripts/
 

One of the scripts creates a new analysis in this case called my_study

mk_ana_skeleton my_study
 

Now compile everything with

rc find_packages
rc compile
 

To run the code there is another script try

submit_ana --study my_study -R /atlas/data18d/Run2xAOD/8TeV/mc/mc14_8TeV.126940.PowhegPythia8_AU2CT10_ZZ_4mu_mll4_2pt5.merge.AOD.e1280_s1933_s1911_r5591_r5625_tid01512665_00/AOD.01512665._000036.pool.root.1 -O testdir
 

This will make a directory with some output in it, which you can check by doing.

root -l testdir/hist-New_Sample.root 
>>   met_nominal.Draw()
 

The submit script has a bunch of options

>> submit_ana --help 
 Options:

  -h, --help            show this help message and exit
  -R RUN, --Run=RUN     File,Directory,or Datasetname to run over
  -S, --doSys           Run all sytematics
  -G, --doGrid          Submit to Grid
  -C, --doCondor        Submit to Condor
  -O OUT_DIR, --Output=OUT_DIR
                        Submit to Condor
  -F, --Force           Overwrite Existing Directories
  -N SAMPLE_NAME, --SName=SAMPLE_NAME
                        Sample Name
  --study=STUDY         Name of class to run
  --nevts=NEVTS         Number of events to run
  --conf=CONFIGFILE     Additonal Configuration File

--study=my_study is the name of the class you created earlier. You can take a look at the code in my_study/Root/my_study.cxx All the code to make plots and trees should go here

#include <xAODMuon/Muon.h>
#include <xAODJet/Jet.h>
#include <xAODTau/TauJet.h>
#include <xAODEgamma/Electron.h>
#include <xAODMissingET/MissingETContainer.h>
#include <xAODRootAccess/Init.h>
#include <QuickAna/QuickAna.h>
#include "my_study/my_study.h"
#include <iostream>
ClassImp(my_study)

int my_study::Execute(std::string sysName,xAOD::TEvent& event){
  //Count how many 20 GeV muon are in sample                                                                                                                                                                        
  m_met=m_qaa->met().met();
  m_hist_helper["met_"+sysName]->Fill (m_met/1000., m_qaa->weight());
  for(auto muon : m_qaa->muons()) //Here we loop over muons                                                                                                                                                         
    {
      if (true)
        {
          m_mu_weight *= muon->auxdata<float> ("ana_weight");//This gets the efficiency correction for the muon                                                                                                     
          if (muon->pt() > 20000){
            m_mu_pt->push_back(muon->pt());
            m_mu_n+=1;
          }
        }
    }
   for(auto tau : m_qaa->taus()) //Here we loop over muons                                                                                                                                                          
   {
     //Do some things with tau here                                                                                                                                                                                 
   }
  for(auto jet : m_qaa->jets()) //Here we loop over muons                                                                                                                                                           
    {
      //Do some jet things here                                                                                                                                                                                     
    }

  for(auto el : m_qaa->electrons()) //Here we loop over muons                                                                                                                                                       
    {
      //Do some electon things here                                                                                                                                                                                 
    }

  m_hist_helper["muon_n_"+sysName]->Fill(m_mu_n,m_mu_weight);    //Fills a histogram the sysName is important or you might overwrite another histogram                                                              
  if(m_mu_n < 2) return 0;
  //  std::cout <<sysName << " MET: "<< m_met << std::endl;                                                                                                                                                         
  return 1;

 };

void my_study::Setup(){

std::cout << "Setup" << std::endl;
 m_mu_pt=new std::vector<float>();

};

void my_study::Clean(){
  m_mu_pt->clear();
  m_mu_n= 0;
  m_mu_weight=1;
};

void my_study::Finish(){std::cout << "Finish" << std::endl;};

void my_study::BookNTuple(TTree* tree){
  tree->Branch ("mu_n", &m_mu_n, "mu_n/I");//Make a Branch                                                                                                                                                          
  tree->Branch ("mu_weight", &m_mu_weight, "mu_weight/F");//Make a Branch                                                                                                                                           
  tree->Branch ("mu_pt", &m_mu_pt);//Make a Branch                                                                                                                                                                  
  tree->Branch ("met", &m_met);//Make a Branch                                                                                                                                                                      
};

void my_study::BookHists(std::string sysName){
  m_hist_helper["muon_n_"+sysName]=new TH1F( ("muon_n_"+sysName).c_str() ,("muon_n_"+sysName).c_str(),10.,0.,10.);
  m_hist_helper["met_"+sysName]=new TH1F( ("met_"+sysName).c_str() ,("met_"+sysName).c_str(),20.,0.,100.);
}
 

You can see the histogram being filled in Execute. The histograms and trees are made by BookHists, and BookNTuple.

Try running submit_ana again with the -S. This will automatically run all the systematic variations that are recommended.

You can configure how objects are selected by create a new file. This is formated in python and will be executed before your job runs. For example. Create a file and add the following lines

 alg.electronDef = "default"
alg.muonDef = "default"
alg.tauDef = "default"
alg.jetDef = "default"
alg.metDef = "default"
alg.photonDef = "default"

currently "default" and "none" turn on/off the object selections.

re-run submit-ana with --conf=ConfFile

Careful if you access anything you've set to none you'll get a segfault.

-- JacobSearcy - 23-Nov-2014

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt hoistJob.py.txt r1 manage 1.4 K 2010-04-27 - 12:49 Jsearcy1  
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2014-11-23 - JacobSearcy
 
    • 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