Logo ROOT  
Reference Guide
TSelectorScalar.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Maarten Ballintijn 13/02/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TSelectorScalar
13 \ingroup tree
14 
15 Named scalar type, based on Long64_t, streamable, storable and
16 mergable. Ideally to be used in tree selectors in the PROOF
17 environment due to its merge functionality which allows a single
18 merged value to be returned to the user.
19 */
20 
21 #include "TSelectorScalar.h"
22 #include "TCollection.h"
23 
25 
26 ////////////////////////////////////////////////////////////////////////////////
27 /// Increment scalar value by n.
28 
30 {
31  SetVal(GetVal() + n);
32 }
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Merge scalars with scalars in the list. The scalar values are added.
36 /// Returns the number of scalars that were in the list.
37 
39 {
40  TIter next(list);
41  Int_t n = 0;
42 
43  while (TObject *obj = next()) {
44  TSelectorScalar *c = dynamic_cast<TSelectorScalar*>(obj);
45  if (c) {
46  Inc(c->GetVal());
47  n++;
48  }
49  }
50 
51  return n;
52 }
c
#define c(i)
Definition: RSha256.hxx:119
n
const Int_t n
Definition: legend1.C:16
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TCollection.h
TSelectorScalar.h
TSelectorScalar
Definition: TSelectorScalar.h:35
TSelectorScalar::Merge
Int_t Merge(TCollection *list)
Merge scalars with scalars in the list.
Definition: TSelectorScalar.cxx:38
TParameter< Long64_t >::GetVal
const Long64_t & GetVal() const
Definition: TParameter.h:73
Long_t
long Long_t
Definition: RtypesCore.h:54
TParameter< Long64_t >::SetVal
void SetVal(const Long64_t &val)
Definition: TParameter.h:75
TObject
Definition: TObject.h:37
TSelectorScalar::Inc
void Inc(Long_t n=1)
Increment scalar value by n.
Definition: TSelectorScalar.cxx:29
TIter
Definition: TCollection.h:233
TCollection
Definition: TCollection.h:63
int