Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:47:37

0001 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
0002 #include "CondFormats/SiPixelTransient/interface/SiPixelUtils.h"
0003 #else
0004 #include "SiPixelUtils.h"
0005 #endif
0006 
0007 #include <cmath>
0008 
0009 namespace siPixelUtils {
0010 
0011   //-----------------------------------------------------------------------------
0012   //!  A generic version of the position formula.  Since it works for both
0013   //!  X and Y, in the interest of the simplicity of the code, all parameters
0014   //!  are passed by the caller.
0015   //-----------------------------------------------------------------------------
0016   float generic_position_formula(int size,                    //!< Size of this projection.
0017                                  int q_f,                     //!< Charge in the first pixel.
0018                                  int q_l,                     //!< Charge in the last pixel.
0019                                  float upper_edge_first_pix,  //!< As the name says.
0020                                  float lower_edge_last_pix,   //!< As the name says.
0021                                  float lorentz_shift,         //!< L-shift at half thickness
0022                                  float theThickness,          //detector thickness
0023                                  float cot_angle,             //!< cot of alpha_ or beta_
0024                                  float pitch,                 //!< thePitchX or thePitchY
0025                                  bool first_is_big,           //!< true if the first is big
0026                                  bool last_is_big,            //!< true if the last is big
0027                                  float eff_charge_cut_low,    //!< Use edge if > w_eff  &&&
0028                                  float eff_charge_cut_high,   //!< Use edge if < w_eff  &&&
0029                                  float size_cut               //!< Use edge when size == cuts
0030   ) {
0031     float geom_center = 0.5f * (upper_edge_first_pix + lower_edge_last_pix);
0032 
0033     //--- The case of only one pixel in this projection is separate.  Note that
0034     //--- here first_pix == last_pix, so the average of the two is still the
0035     //--- center of the pixel.
0036     if (size == 1) {
0037       return geom_center;
0038     }
0039 
0040     //--- Width of the clusters minus the edge (first and last) pixels.
0041     //--- In the note, they are denoted x_F and x_L (and y_F and y_L)
0042     float w_inner = lower_edge_last_pix - upper_edge_first_pix;  // in cm
0043 
0044     //--- Predicted charge width from geometry
0045     float w_pred = theThickness * cot_angle  // geometric correction (in cm)
0046                    - lorentz_shift;          // (in cm) &&& check fpix!
0047 
0048     //--- Total length of the two edge pixels (first+last)
0049     float sum_of_edge = 2.0f;
0050     if (first_is_big)
0051       sum_of_edge += 1.0f;
0052     if (last_is_big)
0053       sum_of_edge += 1.0f;
0054 
0055     //--- The `effective' charge width -- particle's path in first and last pixels only
0056     float w_eff = std::abs(w_pred) - w_inner;
0057 
0058     //--- If the observed charge width is inconsistent with the expectations
0059     //--- based on the track, do *not* use w_pred-w_innner.  Instead, replace
0060     //--- it with an *average* effective charge width, which is the average
0061     //--- length of the edge pixels.
0062     //
0063     //  bool usedEdgeAlgo = false;
0064     if ((size >= size_cut) || ((w_eff / pitch < eff_charge_cut_low) | (w_eff / pitch > eff_charge_cut_high))) {
0065       w_eff = pitch * 0.5f * sum_of_edge;  // ave. length of edge pixels (first+last) (cm)
0066                                            //  usedEdgeAlgo = true;
0067     }
0068 
0069     //--- Finally, compute the position in this projection
0070     float q_diff = q_l - q_f;
0071     float q_sum = q_l + q_f;
0072 
0073     //--- Temporary fix for clusters with both first and last pixel with charge = 0
0074     if (q_sum == 0)
0075       q_sum = 1.0f;
0076 
0077     float hit_pos = geom_center + 0.5f * (q_diff / q_sum) * w_eff;
0078 
0079     return hit_pos;
0080   }
0081 }  // namespace siPixelUtils