Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-04 08:10:20

0001 struct EfficiencyCorrection
0002 {
0003   std::vector<float> pt_center = {0.65,      0.95,     1.25,      1.6,       2.,        2.6,       3.5     };
0004   std::vector<float> pt_low    = {0.5,       0.8,      1.1,       1.4,       1.8,       2.2,       3.      };
0005   std::vector<float> pt_high   = {0.8,       1.1,      1.4,       1.8,       2.2,       3.,        4.      };
0006   std::vector<float> eff       = {0.975164,  1.02684,  1.09048,   1.11564,   1.05061,   1.02402,   1.03747 };
0007   std::vector<float> eff_err   = {0.0167643, 0.013714, 0.0173775, 0.0218095, 0.0325241, 0.0452745, 0.111922};
0008 /*
0009   // get efficiency for a particular bin
0010   float get_bin_eff(float bin_low, float bin_high)
0011   {
0012     int low_index = -1;
0013     int high_index = -1;
0014     for(int i=0; i<pt_center.size(); i++)
0015     {
0016       if(pt_low[i]<bin_low) low_index = i;
0017     }
0018 
0019     for(int i=pt_center.size()-1; i>=0; i--)
0020     {
0021       if(pt_high[i]>bin_high) high_index = i;
0022     }
0023     
0024     if(low_index==high_index)
0025     {
0026       if(bin_low<pt_center[low_index] && bin_high<pt_center[low_index])
0027       {
0028         
0029       }
0030     }
0031     else
0032     {
0033       float low_bin_frac, high_bin_frac;
0034       if(bin_low<pt_center[low_index])
0035       {
0036         low_bin_frac = 0.5 + 0.5*(pt_center[low_index]-bin_low)/(pt_center[low_index]-pt_low[low_index]);
0037       }
0038       else
0039       {
0040         low_bin_frac = 0.5*(bin_low-pt_center[low_index])/(pt_high[low_index]-pt_center[low_index]);
0041       }
0042       if(bin_high>pt_center[high_index])
0043       {
0044         high_bin_frac = 0.5 + 0.5*(bin_high-pt_center[high_index])/(pt_high[high_index]-pt_center[high_index]);
0045       }
0046       else
0047       {
0048         high_bin_frac = 0.5*(bin_high-pt_center[high_index]
0049       }
0050   }
0051 */
0052 
0053   float get_binval(float pt, std::vector<float>& v)
0054   {
0055     int index = -1;
0056     for(int i=0;i<v.size();i++)
0057     {
0058       if(pt>pt_low[i]) index = i;
0059     }
0060     if(index==-1 && pt<pt_high.back()) index = v.size()-1;
0061     if(index!=-1)
0062     {
0063       return v[index];
0064     }
0065     else return 0.;
0066   }
0067 
0068   float get_eff(float pt)
0069   {
0070     return get_binval(pt,eff);
0071   }
0072 
0073   float get_eff_error(float pt)
0074   {
0075     return get_binval(pt,eff_err);
0076   }
0077 };
0078 
0079 /* from Tony:
0080 
0081 pT 0.65 ptlow 0.5 pthigh 0.8 double ratio 0.975164 error 0.0167643
0082 pT 0.95 ptlow 0.8 pthigh 1.1 double ratio 1.02684 error 0.013714
0083 pT 1.25 ptlow 1.1 pthigh 1.4 double ratio 1.09048 error 0.0173775
0084 pT 1.6 ptlow 1.4 pthigh 1.8 double ratio 1.11564 error 0.0218095
0085 pT 2 ptlow 1.8 pthigh 2.2 double ratio 1.05061 error 0.0325241
0086 pT 2.6 ptlow 2.2 pthigh 3 double ratio 1.02402 error 0.0452745
0087 pT 3.5 ptlow 3 pthigh 4 double ratio 1.03747 error 0.111922
0088 
0089 */