The output from PhotonNTupleDumper is generally compatible with the output from HiggsAnalysisUtils (now PhotonAnalysisUtils?) and the highly-anticipated common D3PD for egamma analyses. There are a few differences, but they're minor, and could probably be worked around with some effort.

There are a number of applications that have been built up around the NTupleDumper format. They fall into two categories: applications that take direct output from the NTupleDumper, and applications which want a "flattened" NTuple, corresponding to a particle-wise view of the event collection, rather than an event-wise view. The first category I'll call Eventuples - the second category gets the less-clever Flattuples.

The initial reason for the existence of Flattuples is as an input to applications like TMVA. TMVA will take ROOT TTrees as input, but it has no a priori knowledge of "events" in the NTupleDumper sense. It wants to say that each row in a TTree is either "signal" or "background", and use the information in the different columns to do the discrimination. In the NTupleDumper, there can be several sub-rows (particles, either truth or reconstructed, stored in vectors) for each row (event). The flattening process turns columns with entries of type "std:vector" into entries of type "blah". This destroys the context for any given particle (for instance, how many jets are in the event along with a photon candidate), so that can/should be encoded into additional columns in the flattened NTuple.

Eventuple Applications




This program was designed to reduce the volume of datasets like JF17 to a more manageable size for photon studies. It's similar in philosophy to normal DPD processes (skimming, thinning, slimming, etc), except this acts specifically on the structure of these photon ntuples. It takes as an argument either individual ROOT files or a list of ROOT files (in a text file), and outputs a single ROOT file (or a few, if it exceeds the 2GB limit on ROOT files) with all of the rows which passed the selection criteria.

./skim_ntuple -f root_files.list -f last_root_file.root -o output_file.root -c -v

The command above specifies a few things:

  • Some input ROOT files are listed in root_files.list, for instance:

at3f00 | dp_validation [25]: cat root_files.list
at3f00 | dp_validation [26]: 

  • A final ROOT file is specified as last_root_file.root, so four input ROOT files will be skimmed.
  • -c indicates that some isEM cuts should be made on the events. See the code for what that cut is - generally it's pretty loose, to allow for some studies on how effective some variables actually are. This option means that for each event, if at least one reconstructed photon candidate meets all of the criteria, the event is kept - if not, the event is discarded.
  • -v will have the program print out some status messages periodically - reassuring when running over large datasets, which may take quite a bit of time to finish.

In principle, this step could/should even be done by the process which fills the ntuples in the first place. So this step can and should be made redundant at some point by other techniques, which is why the program is kept simple.


This program performs the transform of an Eventuple into a Flattuple.

It will take the initial structure of the NTuple and copy it over, making the following transformations:

  • Anything of type int, unsigned int, or float gets copied over as is
  • Anything of type std::vector gets turned into X, where X is usually int, unsigned int, or float.

The program also does three other important things:

  • It will merge multiple NTuples into a single NTuple (via TChains)
  • It will (optionally) dump output into separate TTrees binned in pT and η
  • It will (optionally) apply some selection criteria for particles which end up in the flattened NTuple

For example, this will create a flattuple with from some JF17, JF35, and JF70 Eventuples:

create_flat_ntuple -n NewPhotons           -c -i -t -o mixed_jf.test.flat.nrmcuts.root                -f skimmed.jf17.0.root     -f skimmed.jf35.0.root     -f skimmed.jf70.0.root &

The -n NewPhotons option specifies the name of the TTree in the output root file (here specified by -o mixed_jf.test.flat.nrmcuts.root); -c means to apply some isEM cut on the photons that end up in the flattened NTuple (see the code for how the selection gets done), -i means to make a track isolation cut, -t means that this is a testing sample (so don't look at truth to see if this is signal or background - make the choices based entirely on reconstructed quantities), and -f X.root means to take as an input file X.root. Here we've specified three different input files - the resulting output file will have relevant entries from all three input files.

To create a signal(background) file, replace -t with -s(-b). Again, see the code for how the selections differ between signal/background/test cases.

The example above created an output ROOT file with only one TTree, i.e. no binning in pT and η was done. To add bins in either of those variables, add -p or -e . For instance:

create_flat_ntuple -n NewPhotons -p 6 -e 4 -c -i -t -o mixed_jf.test.binned_6_4.flat.nrmcuts.root     -f skimmed.jf17.0.root     -f skimmed.jf35.0.root     -f skimmed.jf70.0.root &

will create an output file with 6 pT bins and 4 η bins. To see how the bins are defined, see UsefulFunctions.h.

For historical reasons, this uses a different scheme for accessing the NTuple information than the rest of the Eventuple applications. Everything else got migrated over to a newer/better scheme for data access some time ago, but this was a bit trickier to do, and the advantages of making that change for this program weren't entirely clear.


Flattuple Applications


Obsolete. See showTrackPars2.



Structure-Independent Applications

These applications either don't care if the NTuples are flat or not.

There used to be some of these, not anymore. Hopefully some of the programs above will eventually migrate into this category, but likely not.

Tools for any NTuples, not just ones from PhotonNTupleDumper


This program will take an NTuple and then divide the rows randomly according to the fractions specified. For instance, if you want an NTuple split into three files, each with a random (unique) mixture of the events, one with 20% of the events, one with 30% of the events, and the last with the remaining 50%:

divideNTuple -i input_file.root -f .2 -f .3 -f .5

will create three files:

  • input_file.0.root will have 20% of the rows
  • input_file.1.root will have 30% of the rows
  • input_file.2.root will have 50% of the rows

It's not a terribly smart program, but it's useful for some things. For instance, the filtered jet samples are good for both generating PDFs for background distributions, as well as tests on a data-like sample for picking out signal from large backgrounds.

-- MikeHance - 01 Jul 2009

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2009-07-01 - MikeHance
    • 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