Histogram Sets

This page contains documentation of "Histogram Sets"

What is a Histogram Set?

A Histogram Set is a class that lets you to fill a set of histograms with one "Fill" method by passing it an object with all the variables of interest. For example, say I want to plot N properties (ie et, eta, phi, shower shape, etc.) for an electron at M points in my analysis code (ie. before cut x, after cut y, etc.). I could create N*M histograms, or I can create M histogram sets (each one will fill the N properties that I am interested in). Instead of filling N*M histograms, I now only need to fill M histogram sets. Instead of passing just the variable to the Fill command of the histogram, I pass a pointer to the entire electron object to the histogram set.

How to use a Histogram Set?

Examples of Histogram Sets have been created in the HistMakingTools package. They are currently designed to work in an AOD analysis (like the AnalysisSkeleton). To use a Histogram Set, do the following:

  • go to the top of your 'testarea'
  • check out the HistoMakingTools package:
    cmt co PhysicsAnalysis/HistoMakingTools
  • compile the package:
    cd PhysicsAnalysis/HistoMakingTools/cmt
    cmt config
    source setup.sh
  • add HistoMakingTools to your analysis requirements file with a line like:
    use HistoMakingTools    HistoMakingTools-*   PhysicsAnalysis
  • add the include statement and some declarations to your analysis header file:
    #include "HistoMakingTools/HistoSets.h"
    JetHists* allJet_hists;
    CompositeParticleHists* dijet_hists;
  • define the histogram sets in the "Initialize" method of you analysis source file:
    allJet_hists = new JetHists("allJets", mthistSvc, mLog);
    dijet_hists = new CompositeParticleHists("dijets", mthistSvc, mLog);
    (note that you need to pass it pointers to your THistSvc and MsgStream)
  • fill the histogram sets in the "Execute" method of you analysis source file:
    (where jet is a ParticleJet*, and dijet is a CompositeParticle*)
  • compile and run your analysis code
  • there should be folders in your AAN output file named "allJets" and "dijets" each containing several histograms.

If you run into problems, please contact me, AndrewHamilton

My Documentation

The following is for my own documentation, it will not help you implement the Histogram Sets.

Getting a TC account

8 Nov 2006

Ketevi Assamangan ketevi@bnl.gov is the physics analysis tools coordinator.
Ketevi created the package PhysicsAnalysis/HistoMakingTools for my histogram manager.
I need CVS privilages and a Tag Collector (TC) account, so Emil Obreshkov pointed me to the following page:

To login to the TC page:

My login and password are my normal CERN ones. After logging in, go to "powerUserHome" for an easier interface.

An Example of the Histogram Manager

21 Nov 2006

Here is an example of the Histogram Manager and how it can be used in an analysis job (I will assume you are using AnalysisSkeleton).

  • download the histogram_manager.tgz file histogram_manager.tgz
  • unzip it with tar -zxf histogram_manager.tgz
  • there are 2 source files and 2 header files (HistogramManager and MyHistogramSets), move the .cxx files to your src/ directory, and the .h files to your AnalysisSkeleton directory
  • compile (cd cmt/; gmake), just to be sure it compiles before you make any changes to your own code

Now edit your code to include the histogram managers:

  • #include AnalysisSkeleton/MyHistogramSets.h in your AnalysisSkeleton.h file
  • add an ElectronHists* electron_hists; declaration to your AnalysisSkeleton.h file
  • initialize the electron_hists object in the CBNT_Initialize() method of you AnalysisSkeleton.cxx file with a line like this
    electron_hists = new ElectronHists("electrons", m_thistSvc, *mLog);
  • fill the histogram manager object in your electron loop with a line like this
    electron_hists->Fill( (*elecItr) );
    where (*elecItr) is an Electron* type, as is is in the default AnalysisSkeleton.cxx code.

Compile and run your code. You should now have an "electron" directory in your AnalysisSkeleton.aan.root file. The "electron" directory should contain a bunch of histograms of the properties of the electrons you filled it with.

To change the properties that you plot, you can edit the MyHistogramSets files. These histogram sets inherit from the HistogramManager class, so you should not need to edit the HistogramManager files, only the MyHistogramSets. Of course, you can also make more histogram sets in the MyHistogramSets file (ie. one for muons). Obviously, you can create multiple ElectronHists objects in your code that you can have, for example, pass_cut_a_electrons and pass_cut_b_electrons directories in your output file. You can also use the Divide function to make efficiency plots for an entire histogram set.

Getting the Histogram Manager into a package

22 Dec 2006

I think I've got the Histogram Manager to compile in a package, /afs/cern.ch/user/a/ahamil/testarea/11.0.5/HistoMakingTools/, but it looks like I can not create my own constructor?

9 Jan 2007

Spoke to Edward Moyse (edward.moyse@cernNOSPAMPLEASE.ch) about the structure of AlgTools. I can not create my own constructor, I need to "retrieve" the tool, something like this:

IHistogramManager *tmp_histManager;
sc = toolSvc->retrieveTool("HistogramManager",tmp_histoManager);
if( StatusCode::SUCCESS != sc ){
  blah, blah, blah...
Then make a regHist type of method where I register the hist managers. I also need to be sure to add the DLL in my jobOptions file, something like theApp.Dlls + = [ "HistoMakingTools" ] (or maybe theApp.Dlls + = [ "HistogramManager" ])

23 Jan 2007

To check-out the empty package do: cmt co -r HistoMakingTools-00-00-00 PhysicsAnalysis/HistoMakingTools (do not make a new package...)

25 Jan 2007

I don't see how the Histogram Manager can be changed into an Alg Tool - you always need the Alg Tool constructor, and therefore always need to do the 'retrieve Tool' stuff... So, instead, I've just made it a HistoSetBase class and a HistoSets class.

I committed the HistoMakingTools package to CVS:
cvs -n upd -dA tells what files have changed (if ? then they need to be added)
cvs add file1 file2 add the files that are not yet in cvs
cvs commit -m "message" commits changes

21 Mar 2007

Ketevi idea - turn fill_histoset(histoset_name, object) into a templated class, where the object is templated.

This does not work because virtual template classes are forbidden in C++, the fill_histoset method needs to be have virtual method in the interface class IHistoSetTool

Till says you can make an AlgTool without the virtual interface class...

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivetgz histogram_manager.tgz r1 manage 2.5 K 2006-11-21 - 13:59 AndrewHamilton source code for the Histogram Manager Class
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r11 - 2007-04-12 - AndrewHamilton
    • 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