CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
smartSelector.h
Go to the documentation of this file.
1 /*
2  $Date: 2008/02/25 17:40:43 $
3  $Revision: 1.2 $
4  $Id: smartSelector.h,v 1.2 2008/02/25 17:40:43 malberti Exp $
5  $Author: malberti $
6 */
7 
8 #ifndef smartSelector_h
9 #define smartSelector_h
10 
11 #include <iostream>
12 
14 {
15  public :
16 
18  smartSelector (int smallestPart = 0) :
19  m_smallestPart (smallestPart) {}
20 
22  int setSmallestPart (int smallestPart)
23  {
24  if (!m_smallestPart)
25  {
26  m_smallestPart = smallestPart ;
27  return 0 ;
28  }
29  else return 1 ;
30  }
31 
33  int accept (int eventNb, const int numberOfFractions) const
34  {
35  if (!m_smallestPart) return 1 ;
36  if (m_smallestPart == numberOfFractions) return 1 ;
37  int position = eventNb % m_smallestPart ;
38  int sum = 0 ;
39  for (int i=1 ; i<numberOfFractions ; i *= 2) sum += i ;
40 // std::cout << "debug f_" << numberOfFractions
41 // << " " << sum
42 // << " " << sum+numberOfFractions << "\n" ;
43  if (position >= sum &&
44  position < sum + numberOfFractions)
45  return 1 ;
46  return 0 ;
47  }
48 
49  private :
50 
52 
53 } ;
54 
55 
56 #endif
int i
Definition: DBlmapReader.cc:9
int accept(int eventNb, const int numberOfFractions) const
actual selector
Definition: smartSelector.h:33
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
int setSmallestPart(int smallestPart)
set the smallest part only if was set to 0
Definition: smartSelector.h:22
smartSelector(int smallestPart=0)
ctor
Definition: smartSelector.h:18