CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Calibration/Tools/interface/smartSelector.h

Go to the documentation of this file.
00001 /* 
00002     $Date: 2008/02/25 17:40:43 $
00003     $Revision: 1.2 $
00004     $Id: smartSelector.h,v 1.2 2008/02/25 17:40:43 malberti Exp $ 
00005     $Author: malberti $
00006 */
00007 
00008 #ifndef smartSelector_h
00009 #define smartSelector_h
00010 
00011 #include <iostream>
00012 
00013 class smartSelector
00014 {
00015   public :
00016   
00018     smartSelector (int smallestPart = 0) : 
00019       m_smallestPart (smallestPart) {}
00020 
00022     int setSmallestPart (int smallestPart)
00023       {
00024         if (!m_smallestPart) 
00025           {
00026             m_smallestPart = smallestPart ;
00027             return 0 ;
00028           }
00029         else return 1 ;          
00030       }
00031 
00033     int accept (int eventNb, const int numberOfFractions) const
00034       {      
00035         if (!m_smallestPart) return 1 ;
00036         if (m_smallestPart == numberOfFractions) return 1 ;
00037         int position = eventNb % m_smallestPart ;
00038         int sum = 0 ; 
00039         for (int i=1 ; i<numberOfFractions ; i *= 2) sum += i ;
00040 //        std::cout << "debug f_" << numberOfFractions
00041 //                  << "  " << sum  
00042 //                  << "  " << sum+numberOfFractions << "\n" ;
00043         if (position >= sum &&
00044             position < sum + numberOfFractions)
00045           return 1 ;  
00046         return 0 ;
00047       }
00048     
00049   private :
00050 
00051     int m_smallestPart ;
00052 
00053 } ;
00054 
00055 
00056 #endif