7.11 Particle Flow Tutorial: The PFRootEvent ROOT interface
Complete:
Detailed Review status
Overview
This page will teach you how to use the
PFRootEvent ROOT interface for particle flow to:
- do an event display of the objects relevant to particle flow
- redo clustering and/or particle flow using the same algorithm libraries as in the full CMSSW
Introduction
The ROOT interface is located in
src/RecoParticleFlow/CMS.PFRootEvent
. It is able to read the CMSSW output tree, which may contain collections of
PFRecHits
,
PFClusters
,
CMS.PFRecTracks
,
PFCandidates
,
PFSimParticles
, jets, etc.
It has the advantage of being very fast. The main reason for it is that the geometry of the CMS detector does not have to be initialized, since it is hardwired in the various objects that are considered. For example,
PFRecHits
carry the position and axis direction of the corresponding calorimeter cell.
Example control files
The ROOT interface makes use of an homemade option file parsing system instead of the official configuration system (.cfg files), which is too rigid for us.
particleFlow.opt
is an example of option file, and is documented.
The option file is used in root macros located in
CMS.PFRootEvent/test/Macros
:
Software architecture
CMS.PFRootEvent
is based on two classes:
- PFRootEventManager
, which handles event processing:
- read data from the CMSSW
Events
TTree.
- perform clustering
- perform particle flow
- hold the various collections of data:
- read from the CMSSW
Events
Tree
- obtained after clustering (clusters) or particle flow (blocks, candidates)
- various printouts
- DisplayManager
, which is resonsible for the display of the PFRootEventManager
.
The
PFRootEventManager
and the
DisplayManager
can be manipulated directly from the ROOT command line. In section
Getting started with the display, we will see how to display an event using the member function
display
of the
DisplayManager
.
Getting started with the display (Fast Sim case)

To get the input file for
PFRootEvent, please complete
WorkBookParticleFlow#ParticleFlowHowtoFastSim
cd RecoParticleFlow/CMS.PFRootEvent/test
root
.x Macros/tauBenchmarkDisplay_famos.C
Several windows should open, showing different views of the first event: eta/phi view of the ECAL surface, eta/phi view of the HCAL surface, XY (the CMS detector is viewed along the z axis and appears as concentric circles), RZ (the CMS detector is viewed from the side, with the z axis horizontal).
To display the next event, simply do:
dm.display(i++); dm.lookForGenParticle(1)
Try to click on the various objects on the displays, and to zoom on the support axes.
Legend
- legend for CMS.PFRootEvent display, XY view:
- legend for CMS.PFRootEvent display, eta/phi view of ECAL surface:
- legend for CMS.PFRootEvent display, second eta/phi view of ECAL surface:
Display Controls
Direct control
CMS.PFRootEvent
is based on two classes:
- PFRootEventManager
, which handles event processing:
- read data from the CMSSW
Events
TTree.
- perform clustering
- perform particle flow
- hold the various collections of data:
- read from the CMSSW
Events
Tree
- obtained after clustering (clusters) or particle flow (blocks, candidates)
- various printouts
- DisplayManager
, which is resonsible for the display of the PFRootEventManager
.
The
PFRootEventManager
and the
DisplayManager
can be manipulated directly from the ROOT command line. In section
Getting started with the display, we have already seen how to display an event using the member function
display
of the
DisplayManager
.
Most functions can be used in the same way, and most data members can be modified to fit your needs.
For example, here is how the default printout is performed:
em.print()
To modify the printout:
em.printMCtruth_ = true
em.printPFCandidates_ = false
em.printCluster_ = false
em.print()
Control through the option file
A good way to control
PFRootEventManager
and
DisplayManager
is to edit the option file, and to reload it.
Assuming
particleFlow.opt
is in use (this depends on the macro that you have called), you could edit this file and leave it opened in the backround.
For example, modify the following lines as you wish, and save the option file.
// print rechits yes/no
print rechits 0
// print clusters yes/no
print clusters 0
// print particle flow blocks yes/no
print PFBlocks 0
// print true particles yes/no
print true_particles 1
// print MC Truth
print MC_truth 0
// print reconstructed particles yes/no
print PFCandidates 1
Reload the file in the
PFRootEventManager
, and see the effect:
em.readOptions( "particleFlow.opt" )
dm.display( em.iEvent_ );
In case display options are modified, you need to reload the file into the
DisplayManager
:
dm.readOptions( "particleFlow.opt" )
dm.display( em.iEvent_ );
Graphical User Interface (GUI)
Finally, it now possible to manipulate some of the display options from an experimental GUI. To start the GUI:
DialogFrame *win = new DialogFrame(&em,&dm,gClient->GetRoot(), 200,220);
FAQ
How to print some information ?
To do a printout:
em.print()
The following options control the printout:
// print rechits yes/no
print rechits 0
// print clusters yes/no
print clusters 0
// print particle flow blocks yes/no
print PFBlocks 0
// print true particles yes/no
print true_particles 1
// print MC Truth
print MC_truth 0
// print reconstructed particles yes/no
print PFCandidates 1
IMPORTANT NOTE: "true particles" should in fact be called "simulated particles", while MC truth should be called "generated particles". The current names are misleading, and will be modified soon.
To print the first 30 generated particles in the GenEvent to
std::cout
:
em.printMCTruth( cout, 30 )
To print all particles to a file:
ostream out("out.txt")
em.printMCTruth( out )
How to center the view on a given GenParticle ?
First print the GenEvent (see
How to print some information ?).
To center the eta/phi view on the 10th particle in the GenEvent:
dm.lookForGenParticle(10);
How to save the results ?
To save all the displays and the printout, in a directory MyDir_
(automatically created):
dm.printDisplay("MyDir_");
How to redo clustering and particle flow ?
As an example, let's redo clustering with different parameters.
- edit particleFlow.opt
to increase the seed threshold for ECAL barrel rechits. Set the following parameter to 1 GeV:
// seed threshold for ECAL barrel rechits
clustering thresh_Seed_Ecal_Barrel 0.15
- read the option file from the ROOT interface:
em.readOptions("particleFlow.opt")
- redo clustering, particle flow and display for the same event; center on most energetic rechit in ECAL:
dm.display( em.iEvent_ ); dm.lookForGenParticle(1)
Do not hesitate to play around with the various parameters driving clustering and particle flow, and watch the results on the display.
Review status
Responsible: Colin Bernet
-- ColinBernet - 27 Jul 2009