Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-22 04:02:47

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                                  float pitchfraction_first,
0026                                  float pitchfraction_last,
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 = pitchfraction_first + pitchfraction_last;
0050 
0051     //--- The `effective' charge width -- particle's path in first and last pixels only
0052     float w_eff = std::abs(w_pred) - w_inner;
0053 
0054     //--- If the observed charge width is inconsistent with the expectations
0055     //--- based on the track, do *not* use w_pred-w_innner.  Instead, replace
0056     //--- it with an *average* effective charge width, which is the average
0057     //--- length of the edge pixels.
0058     //
0059     //  bool usedEdgeAlgo = false;
0060     if ((size >= size_cut) || ((w_eff / pitch < eff_charge_cut_low) | (w_eff / pitch > eff_charge_cut_high))) {
0061       w_eff = pitch * 0.5f * sum_of_edge;  // ave. length of edge pixels (first+last) (cm)
0062                                            //  usedEdgeAlgo = true;
0063     }
0064 
0065     //--- Finally, compute the position in this projection
0066     float q_diff = q_l - q_f;
0067     float q_sum = q_l + q_f;
0068 
0069     //--- Temporary fix for clusters with both first and last pixel with charge = 0
0070     if (q_sum == 0)
0071       q_sum = 1.0f;
0072 
0073     float hit_pos = geom_center + 0.5f * (q_diff / q_sum) * w_eff;
0074 
0075     return hit_pos;
0076   }
0077 }  // namespace siPixelUtils