Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:57

0001 #ifndef SIGMAEFF_H
0002 #define SIGMAEFF_H
0003 
0004 vector<float> sigmaEff(vector<float> v, float threshold)
0005 {
0006 
0007   std::sort(v.begin(),v.end());
0008 
0009   int total = v.size();
0010   int max = (int)(threshold * total);
0011 
0012   vector<float>  start;
0013   vector<float>  stop;
0014   vector<float>  width;
0015 
0016   unsigned i = 0 ;
0017   while (i != v.size()-1){
0018 
0019     int count = 0;
0020     unsigned j = i;
0021     while (j != v.size()-1 && count < max){
0022 
0023       ++count;
0024       ++j;
0025 
0026     }
0027 
0028     if ( j != v.size()-1){
0029       start.push_back(v[i]);
0030       stop .push_back(v[j]);
0031       width.push_back(v[j] - v[i]);
0032 
0033     }
0034     ++i;
0035   }
0036 
0037   float minwidth = *min_element(width.begin(), width.end());
0038 
0039   unsigned pos = min_element(width.begin(), width.end()) - width.begin();
0040 
0041   float xmin = start[pos];
0042   float xmax = stop [pos];
0043 
0044   // cout<<"sigEffi test return width : "<<minwidth<<" edgel - edger : "<<xmin-xmax<<endl;
0045 
0046   return {minwidth, xmin, xmax};
0047 
0048 }
0049 
0050 float  vector_average (vector <float> input_vector)
0051 {
0052     return accumulate( input_vector.begin(), input_vector.end(), 0.0 ) / double(input_vector.size());
0053 }
0054 
0055 vector<float> sigmaEff_avg (vector<float> v, float threshold)
0056 {
0057   
0058   vector<float> sigmaEff_vec = sigmaEff(v,threshold);
0059 
0060   vector<float> v_range; v_range.clear(); 
0061 
0062   for (int i = 0; i < v.size(); i++){
0063     if (v[i] >= sigmaEff_vec[1] && v[i] <= sigmaEff_vec[2]){
0064       v_range.push_back( v[i] );
0065     }
0066   }
0067 
0068   // note : return the
0069   // note : 0. the avg among the sigeff range 
0070   // note : 1. xmin
0071   // note : 2. xmax
0072   return {vector_average(v_range),sigmaEff_vec[1],sigmaEff_vec[2]};
0073 
0074 }
0075 
0076 #endif