Implementation of Iterative Cut Optimization

The following code implements an iterative cut optimization. Define a Figure of Merit (FOM) that quantifies the signal-to-noise ratio to be maximized. The process then consists of N iterations of the following:

  • Define a default, initial set of selection criteria on the variables. Denote this set as
  • Then choose (randomly) a variable on which to vary the selection. Denote this variable as . Relax the default selection criteria on this variable in preparation for a scan of possible selection criteria. Maintain the selection on the remaining variables, .
  • Then scan over possible selection criteria on . This scan may proceed from low-to-high (looking for a lower bound), high-to-low (looking for an upper bound), or from both sides simultaneously (looking for a two-sided selection). Choose the selection that maximizes the FOM across this scan space. Denote this improved selection on as .
  • Repeat the above, choosing for the scan and fixing . From this, obtain .
  • Continue this for each variable until you obtain a first set of improved selection criteria, .

This is one iteration. Repeat as necessary until the selection criteria stabilize.

Implementation

The implementation code is a ROOT C++ macro available here:

https://twiki.cern.ch/twiki/pub/Main/IterativeCutOptimization/iterativeCutOptimization.C

To run this, execute the following:

root -q -l -b ./iterativeCutOptimization.C'+(3)'

where the argument to the function is the number of iterations. To modify this code to accommodate your own files and variables, you need to do the following:

  • skip down toward the bottom of the code where the function iterativeCutOptimization() itself is defined (around line 435)
  • the first code you need to modify happens just after the comment block that says "NOTES TO THE USER"
    • first, define the variables you want to optimize. You do this by declaring OptVariable objects in the vars STL map (see examples in the code). This map is randomly iterated over in the main algorithm to perform the scan on each variable. When you define a variable, you pass the actual name in the ROOT file, the default minimum cut, the default maximum cut, and whether or not to scan up to find a lower bound, scan down to find an upper bound, or scan in both directions.
    • next, define any preCuts you want to apply BEFORE the optimization is applied. Do this by modifying the "preCuts" TString.
    • next, define the samples. Each sample is basically a TChain of ROOT files. A standard example is shown below:

  // Example of a single data set definition 

  // define the TChain and pass the name of the TTree in the ROOT files.
  TChain signal("data");

  // add files to the chain
  signal.Add("<PATH TO ROOT FILES>/*.root");

  // now that we've added files, change the name of the chain to something distinct
  signal.SetTitle("signal");

  // set the weight of this sample in the _weights std::map
 _weights[signal.GetTitle()] =  0.005;

  // define a TEventList object to store only the events that pass the precuts.
  TEventList signal_events;

  // apply the precuts
  signal.Draw(">>eventlist",preCuts);

  // get the event list and store it in the above-defined TEventList
  signal_events =  *((TEventList*)gROOT->FindObject("eventlist"));

  // set the default event list for this chain.
  signal.SetEventList( &signal_events );

  // create a list to hold this and other related samples
  TList signalTrees;

  // add this TChain to the TList
  signalTrees.AddLast( &signal );

    • Repeat the above for each sample that will go into the signalTrees, and then do the same for all the samples that will go into the backgroundTrees. These TLists are passed to the optimization method.

-- StephenSekula - 19-Aug-2010

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2010-08-19 - AidanRandleConde
 
    • 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-2024 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