CMS 3D CMS Logo

alpha_T.h
Go to the documentation of this file.
1 #ifndef ALPHA_T_H
2 #define ALPHA_T_H
3 
4 #include <cmath>
5 #include <vector>
6 #include <numeric>
7 #include <functional>
8 #include <algorithm>
9 
10 struct alpha_T {
11 
12  template<class LVs>
13  double operator()(const LVs& p4s) const { typedef typename LVs::value_type LorentzV;
14  if( p4s.size() < 2 ) return 0;
15 
16  std::vector<double> pTs;
17  transform( p4s.begin(), p4s.end(), back_inserter(pTs), std::mem_fun_ref(&LorentzV::Pt));
18 
19  const double DsumPT = minimum_deltaSumPT( pTs );
20  const double sumPT = accumulate( pTs.begin(), pTs.end(), double(0) );
21  const LorentzV sumP4 = accumulate( p4s.begin(), p4s.end(), LorentzV() );
22 
23  return 0.5 * ( sumPT - DsumPT ) / sqrt( sumPT*sumPT - sumP4.Perp2() );
24  }
25 
26  static double minimum_deltaSumPT(const std::vector<double>& pTs) {
27  std::vector<double> diff( 1<<(pTs.size()-1) , 0. );
28  for(unsigned i=0; i < diff.size(); i++)
29  for(unsigned j=0; j < pTs.size(); j++)
30  diff[i] += pTs[j] * ( 1 - 2 * (int(i>>j)&1) ) ;
31 
32  return fabs( *min_element( diff.begin(), diff.end(),
33  [](auto x, auto y){return fabs(x) < fabs(y);} ) );
34  }
35 
36 };
37 
38 #endif
static double minimum_deltaSumPT(const std::vector< double > &pTs)
Definition: alpha_T.h:26
T sqrt(T t)
Definition: SSEVec.h:18
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > LorentzV
double operator()(const LVs &p4s) const
Definition: alpha_T.h:13