TSelectorScalar.cxx

Go to the documentation of this file.
00001 // @(#)root/tree:$Id: TSelectorScalar.cxx 30749 2009-10-15 16:33:04Z brun $
00002 // Author: Maarten Ballintijn   13/02/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TSelectorScalar                                                      //
00015 //                                                                      //
00016 // Named scalar type, based on Long64_t, streamable, storable and       //
00017 // mergable. Ideally to be used in tree selectors in the PROOF          //
00018 // environment due to its merge functionality which allows a single     //
00019 // merged value to be returned to the user.                             //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #include "TSelectorScalar.h"
00024 #include "TCollection.h"
00025 
00026 
00027 ClassImp(TSelectorScalar)
00028 
00029 //______________________________________________________________________________
00030 void TSelectorScalar::Inc(Long_t n)
00031 {
00032    // Increment scalar value by n.
00033 
00034    SetVal(GetVal() + n);
00035 }
00036 
00037 //______________________________________________________________________________
00038 Int_t TSelectorScalar::Merge(TCollection *list)
00039 {
00040    // Merge scalars with scalars in the list. The scalar values are added.
00041    // Returns the number of scalars that were in the list.
00042 
00043    TIter next(list);
00044    Int_t n = 0;
00045 
00046    while (TObject *obj = next()) {
00047       TSelectorScalar *c = dynamic_cast<TSelectorScalar*>(obj);
00048       if (c) {
00049          Inc(c->GetVal());
00050          n++;
00051       }
00052    }
00053 
00054    return n;
00055 }

Generated on Tue Jul 5 15:34:08 2011 for ROOT_528-00b_version by  doxygen 1.5.1