-- TomaszBold - 10 Oct 2005

Histogramming Service for AthenaMT

In the Gaudi release (Gaudi 16) deployed in the Lvl2 ATLAS trigger there is available new histogramming service. It is based on ROOT i.e. the ROOT histograms and trees can be directly used in the code. The name of this service is THistSvc. This service is used for registering ROOT histograms and ntuples/trees and for discovery of them (reading of file resident histograms to be used in the code). To allow usage of this service, a similar Lvl2THistSvc is created. It differs only in implementation details. As the AthenaMT is a multi-thread application, each thread uses separate output file to store the histograms. There is also a difference in the TTress storage. The sample job options file content:
# load the "Lvl2THistSvc" service but and name it "THistSvc"

theApp.ExtSvc += [ "Lvl2THistSvc/THistSvc" ]
theApp.MultiThreadExtSvc += [ "Lvl2THistSvc/THistSvc" ]

#then define the output
THistSvc = Service( "THistSvc" )

#Keep Trees in memory until that number of events is found

# define the output files
THistSvc.Output = [ "MON DATAFILE='tuple.root'  OPT='NEW'" ]
THistSvc.Output += [ "EXMON DATAFILE='tuple-ex.root'  OPT='NEW'" ]
Of course file name (DATAFILE field in the Output property) can be arbitrary, (.root extension recommended). If the multi-thread option is chosen for the athenaMT then the thread id will be appended to the file name like: tuple.root__0, tuple.root__1 etc. The files must not exist when you start athenaMT, otherwise job will crash in initialization informing you about that problem. For the explanation of the first part of "Output" option keep reading.

The sample code to create and register histograms is as follows:

  // get the histogramming service
  ITHistSvc *rootHistSvc;
  if ( !service("Lvl2THistSvc", rootHistSvc, true).isSuccess() ) {
    log << MSG::ERROR << "Unable to locate Lvl2THistSvc" << endreq;
    return StatusCode::FAILURE;

  // create ROOT histograms
  m_h1fTest = new TH1F("h1ftest", "Mu eta / mu phi",
                       100, -0.6,0.6);
  m_h2muMon = new TH2D("muMon", "Mu eta .vs. mu phi",
                       11, 0,11, 36, 0, 36 );
  // and book them
  std::string path = "/MON/mu/technical/";
  rootHistSvc->regHist ( path+m_h1fTest->GetName(), m_h1fTest );
  rootHistSvc->regHist ( path+m_h2muMon->GetName(), m_h2muMon );

Since that moment you can use ROOT API of the histograms m_h1fTest->Fill(1); The service will take care of the histograms. If in job options you have specified the stream name NET ( like here we did ) the histograms are in appropriate file.

The std::string path variable has to be understood as follows: i.e. path=/PART1/PART2/.../PARTN/someid

  • PART1 - is a logical stream name, you can assign it to desired file
  • PART2/.../PARTN - is a directory name in the ROOT file
  • someid - is arbitrary name which makes whole path unique in order to have histogram or tree registered (Histogram name is good idea.)

If there is no file corresponding to the logical name then histograms are not persistified. Only the WARING message is printed at the end of the job. There is problem when trees are not persistified since they grow during run and occupy more and more memory space.

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2005-10-10 - TomaszBold
    • 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