CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DQMOffline/JetMET/interface/SusyDQM/alpha_T.h

Go to the documentation of this file.
00001 #ifndef ALPHA_T_H
00002 #define ALPHA_T_H
00003 
00004 #include <cmath>
00005 #include <vector>
00006 #include <numeric>
00007 #include <functional>
00008 #include <algorithm>
00009 #include "special_less.h"
00010 
00011 struct alpha_T {
00012   
00013   template<class LVs>
00014   double operator()(const LVs& p4s) const {  typedef typename LVs::value_type LorentzV;
00015     if( p4s.size() < 2 ) return 0;
00016     
00017     std::vector<double> pTs;  
00018     transform( p4s.begin(), p4s.end(), back_inserter(pTs), std::mem_fun_ref(&LorentzV::Pt));
00019     
00020     const double DsumPT = minimum_deltaSumPT( pTs );
00021     const double sumPT = accumulate( pTs.begin(), pTs.end(), double(0) );
00022     const LorentzV sumP4 = accumulate( p4s.begin(), p4s.end(), LorentzV() );
00023     
00024     return 0.5 * ( sumPT - DsumPT ) / sqrt( sumPT*sumPT - sumP4.Perp2() );
00025   }
00026   
00027   static double minimum_deltaSumPT(const std::vector<double>& pTs) {
00028     std::vector<double> diff( 1<<(pTs.size()-1) , 0. );
00029     for(unsigned i=0; i < diff.size(); i++)
00030       for(unsigned j=0; j < pTs.size(); j++)
00031         diff[i] += pTs[j] * ( 1 - 2 * (int(i>>j)&1) ) ;
00032     
00033     return fabs( *min_element( diff.begin(), diff.end(), fabs_less() ) );
00034   }
00035   
00036 };
00037 
00038 #endif