Changeset 2692


Ignore:
Timestamp:
12/17/03 16:48:25 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtools/MTFillMatrix.cc

    r2690 r2692  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 //   MTFillMatrix
     27// MTFillMatrix
     28//
     29// Use this tool to fill eg trainings and test-matrices, while the matrix
     30// to be filled can be a real matrix (MHMatrix) or a file (MWriteRootFile)
     31// or both.
     32//
     33// First create a reference histogram (MH3). For more details see
     34// MFEventSelector2 which is used to select events according to the
     35// reference histogram.
     36//
     37//
     38// Here is an example of how to choose 1000 events somehow distributed in
     39// size from a file.
     40// -----------------------------------------------------------------------
     41//
     42// MH3 ref("MHillas.fSize");          // choose a predefined size distribution
     43// // Now setup the distribution
     44//
     45// MHMatrix matrix1;                   // create matrix to fill
     46// matrix.AddColumn("MHillas.fWidth"); // setup columns of your matrix
     47//
     48// MReadMarsFile read("myfile.root");  // Setup your 'reader'
     49// read.DisableAutoScheme();           // make sure everything is read
     50//
     51// MTFillMatrix fill(ref);             // setup MTFillMatrix
     52// fill.SetNumDestEvents1(1000);       // setup number of events to select
     53// fill.SetDestMatrix1(&matrix1);      // setup destination matrix
     54// if (!fill.Process())                // check if everything worked
     55//    return;
     56// fill.WriteMatrix1("myoutput.root"); // write matrix to file
     57//
     58//
     59// To get two matrices instead of one (splitted randomly) you can add
     60// the following before calling Process():
     61// ------------------------------------------------------------------------
     62//
     63// MHMatrix matrix2;
     64// fill.SetNumDestEvents2(500);        // setup number of events to select
     65// fill.SetDestMatrix2(&matrix2);      // setup destination matrix
     66// [...]
     67// fill.WriteMatrix2("myoutput2.root");
     68//
     69//
     70// To write both matrices into a single file use:
     71// ----------------------------------------------
     72//
     73// fill.WriteMatrices("myfile.root");
    2874//
    2975/////////////////////////////////////////////////////////////////////////////
     
    5298using namespace std;
    5399
     100// --------------------------------------------------------------------------
     101//
     102// Print Size and contained columns.
     103// Check whether the number of generated events is compatible with
     104// the number of requested events.
     105//
    54106Bool_t MTFillMatrix::CheckResult(MHMatrix *m, Int_t num) const
    55107{
     
    70122}
    71123
     124// --------------------------------------------------------------------------
     125//
     126// Write the given MHMatrix with its name as default name to a
     127// file fname.
     128//
    72129Bool_t MTFillMatrix::WriteMatrix(MHMatrix *m, const TString &fname, Int_t i) const
    73130{
     
    83140}
    84141
     142// --------------------------------------------------------------------------
     143//
     144// Constructor. Takes an MH3 as argument. This MH3 is the reference
     145// distribution to fill the matrix. More information can be found
     146// at MFEventSelector2 which is used to select the events.
     147//
    85148MTFillMatrix::MTFillMatrix(const MH3 &ref)
    86149: fReference(ref), fReader(0), fDestMatrix1(0),
     
    92155}
    93156
     157// --------------------------------------------------------------------------
     158//
     159// Fill the matrix (FIXME: Flow diagram missing)
     160//
    94161Bool_t MTFillMatrix::Process()
    95162{
     
    186253    }
    187254
     255    // Print execution statistics of the tasklist
    188256    tlist.PrintStatistics();
    189257
     258    // Check the result of filling...
    190259    CheckResult(fDestMatrix1, fNumDestEvents1);
    191260    CheckResult(fDestMatrix2, fNumDestEvents2);
     
    195264}
    196265
     266// --------------------------------------------------------------------------
     267//
     268// Write both matrices to a file. Return kFALSE if writing one of them
     269// failed or both have the same name.
     270//
    197271Bool_t MTFillMatrix::WriteMatrices(const TString &fname) const
    198272{
Note: See TracChangeset for help on using the changeset viewer.