Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions CondFormats/SiPixelTransient/src/SiPixelUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace SiPixelUtils {
//! are passed by the caller.
//-----------------------------------------------------------------------------
float generic_position_formula(int size, //!< Size of this projection.
int Q_f, //!< Charge in the first pixel.
int Q_l, //!< Charge in the last pixel.
int q_f, //!< Charge in the first pixel.
int q_l, //!< Charge in the last pixel.
float upper_edge_first_pix, //!< As the name says.
float lower_edge_last_pix, //!< As the name says.
float lorentz_shift, //!< L-shift at half thickness
Expand All @@ -24,8 +24,8 @@ namespace SiPixelUtils {
float pitch, //!< thePitchX or thePitchY
bool first_is_big, //!< true if the first is big
bool last_is_big, //!< true if the last is big
float eff_charge_cut_low, //!< Use edge if > W_eff &&&
float eff_charge_cut_high, //!< Use edge if < W_eff &&&
float eff_charge_cut_low, //!< Use edge if > w_eff &&&
float eff_charge_cut_high, //!< Use edge if < w_eff &&&
float size_cut //!< Use edge when size == cuts
) {
//cout<<" in PixelCPEGeneric:generic_position_formula - "<<endl; //dk
Expand All @@ -41,13 +41,13 @@ namespace SiPixelUtils {

//--- Width of the clusters minus the edge (first and last) pixels.
//--- In the note, they are denoted x_F and x_L (and y_F and y_L)
float W_inner = lower_edge_last_pix - upper_edge_first_pix; // in cm
float w_inner = lower_edge_last_pix - upper_edge_first_pix; // in cm

//--- Predicted charge width from geometry
float W_pred = theThickness * cot_angle // geometric correction (in cm)
float w_pred = theThickness * cot_angle // geometric correction (in cm)
- lorentz_shift; // (in cm) &&& check fpix!

//cout<<" in PixelCPEGeneric:generic_position_formula - "<<W_inner<<" "<<W_pred<<endl; //dk
//cout << " in PixelCPEGeneric:generic_position_formula - " << w_inner << " " << w_pred << endl; // dk

//--- Total length of the two edge pixels (first+last)
float sum_of_edge = 2.0f;
Expand All @@ -57,29 +57,29 @@ namespace SiPixelUtils {
sum_of_edge += 1.0f;

//--- The `effective' charge width -- particle's path in first and last pixels only
float W_eff = std::abs(W_pred) - W_inner;
float w_eff = std::abs(w_pred) - w_inner;

//--- If the observed charge width is inconsistent with the expectations
//--- based on the track, do *not* use W_pred-W_innner. Instead, replace
//--- based on the track, do *not* use w_pred-W_innner. Instead, replace
//--- it with an *average* effective charge width, which is the average
//--- length of the edge pixels.
//
// bool usedEdgeAlgo = false;
if ((size >= size_cut) || ((W_eff / pitch < eff_charge_cut_low) | (W_eff / pitch > eff_charge_cut_high))) {
W_eff = pitch * 0.5f * sum_of_edge; // ave. length of edge pixels (first+last) (cm)
if ((size >= size_cut) || ((w_eff / pitch < eff_charge_cut_low) | (w_eff / pitch > eff_charge_cut_high))) {
w_eff = pitch * 0.5f * sum_of_edge; // ave. length of edge pixels (first+last) (cm)
// usedEdgeAlgo = true;
}

//--- Finally, compute the position in this projection
float Qdiff = Q_l - Q_f;
float Qsum = Q_l + Q_f;
float qdiff = q_l - q_f;
float qsum = q_l + q_f;

//--- Temporary fix for clusters with both first and last pixel with charge = 0
if (Qsum == 0)
Qsum = 1.0f;
if (qsum == 0)
qsum = 1.0f;

//float hit_pos = geom_center + 0.5f*(Qdiff/Qsum) * W_eff + half_lorentz_shift;
float hit_pos = geom_center + 0.5f * (Qdiff / Qsum) * W_eff;
//float hit_pos = geom_center + 0.5f*(qdiff/qsum) * w_eff + half_lorentz_shift;
float hit_pos = geom_center + 0.5f * (qdiff / qsum) * w_eff;

return hit_pos;
}
Expand Down
8 changes: 4 additions & 4 deletions RecoLocalTracker/SiPixelRecHits/interface/PixelCPEGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ class PixelCPEGeneric final : public PixelCPEBase {
// Methods.
//------------------------------------------------------------------
void collect_edge_charges(ClusterParam &theClusterParam, //!< input, the cluster
int &Q_f_X, //!< output, Q first in X
int &Q_l_X, //!< output, Q last in X
int &Q_f_Y, //!< output, Q first in Y
int &Q_l_Y //!< output, Q last in Y
int &q_f_X, //!< output, Q first in X
int &q_l_X, //!< output, Q last in X
int &q_f_Y, //!< output, Q first in Y
int &q_l_Y //!< output, Q last in Y
) const;

//--- Errors squared in x and y. &&& Need to be revisited.
Expand Down
90 changes: 44 additions & 46 deletions RecoLocalTracker/SiPixelRecHits/src/PixelCPEGeneric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,11 @@ LocalPoint PixelCPEGeneric::localPosition(DetParam const& theDetParam, ClusterPa
theClusterParam.qBin_ = 0;
}

int Q_f_X; //!< Q of the first pixel in X
int Q_l_X; //!< Q of the last pixel in X
int Q_f_Y; //!< Q of the first pixel in Y
int Q_l_Y; //!< Q of the last pixel in Y
collect_edge_charges(theClusterParam, Q_f_X, Q_l_X, Q_f_Y, Q_l_Y);
int q_f_X; //!< Q of the first pixel in X
int q_l_X; //!< Q of the last pixel in X
int q_f_Y; //!< Q of the first pixel in Y
int q_l_Y; //!< Q of the last pixel in Y
collect_edge_charges(theClusterParam, q_f_X, q_l_X, q_f_Y, q_l_Y);

//--- Find the inner widths along X and Y in one shot. We
//--- compute the upper right corner of the inner pixels
Expand Down Expand Up @@ -306,8 +306,8 @@ LocalPoint PixelCPEGeneric::localPosition(DetParam const& theDetParam, ClusterPa

float xPos = SiPixelUtils::generic_position_formula(
theClusterParam.theCluster->sizeX(),
Q_f_X,
Q_l_X,
q_f_X,
q_l_X,
local_URcorn_LLpix.x(),
local_LLcorn_URpix.x(),
chargeWidthX, // lorentz shift in cm
Expand All @@ -330,8 +330,8 @@ LocalPoint PixelCPEGeneric::localPosition(DetParam const& theDetParam, ClusterPa

float yPos = SiPixelUtils::generic_position_formula(
theClusterParam.theCluster->sizeY(),
Q_f_Y,
Q_l_Y,
q_f_Y,
q_l_Y,
local_URcorn_LLpix.y(),
local_LLcorn_URpix.y(),
chargeWidthY, // lorentz shift in cm
Expand Down Expand Up @@ -398,16 +398,16 @@ LocalPoint PixelCPEGeneric::localPosition(DetParam const& theDetParam, ClusterPa
//! and the inner cluster charge, projected in x and y.
//-----------------------------------------------------------------------------
void PixelCPEGeneric::collect_edge_charges(ClusterParam& theClusterParamBase, //!< input, the cluster
int& Q_f_X, //!< output, Q first in X
int& Q_l_X, //!< output, Q last in X
int& Q_f_Y, //!< output, Q first in Y
int& Q_l_Y //!< output, Q last in Y
int& q_f_X, //!< output, Q first in X
int& q_l_X, //!< output, Q last in X
int& q_f_Y, //!< output, Q first in Y
int& q_l_Y //!< output, Q last in Y
) const {
ClusterParamGeneric& theClusterParam = static_cast<ClusterParamGeneric&>(theClusterParamBase);

// Initialize return variables.
Q_f_X = Q_l_X = 0.0;
Q_f_Y = Q_l_Y = 0.0;
q_f_X = q_l_X = 0.0;
q_f_Y = q_l_Y = 0.0;

// Obtain boundaries in index units
int xmin = theClusterParam.theCluster->minPixelRow();
Expand All @@ -427,15 +427,15 @@ void PixelCPEGeneric::collect_edge_charges(ClusterParam& theClusterParamBase, /
//
// X projection
if (pixel.x == xmin)
Q_f_X += pix_adc;
q_f_X += pix_adc;
if (pixel.x == xmax)
Q_l_X += pix_adc;
q_l_X += pix_adc;
//
// Y projection
if (pixel.y == ymin)
Q_f_Y += pix_adc;
q_f_Y += pix_adc;
if (pixel.y == ymax)
Q_l_Y += pix_adc;
q_l_Y += pix_adc;
}

return;
Expand Down Expand Up @@ -494,42 +494,40 @@ LocalError PixelCPEGeneric::localError(DetParam const& theDetParam, ClusterParam
bool useTempErrors =
UseErrorsFromTemplates_ && (!NoTemplateErrorsWhenNoTrkAngles_ || theClusterParam.with_track_angle);

if
LIKELY(useTempErrors) {
//
// Use template errors

if (!edgex) { // Only use this for non-edge clusters
if (sizex == 1) {
if (!bigInX) {
xerr = theClusterParam.sx1;
} else {
xerr = theClusterParam.sx2;
}
if LIKELY (useTempErrors) {
//
// Use template errors

if (!edgex) { // Only use this for non-edge clusters
if (sizex == 1) {
if (!bigInX) {
xerr = theClusterParam.sx1;
} else {
xerr = theClusterParam.sigmax;
xerr = theClusterParam.sx2;
}
} else {
xerr = theClusterParam.sigmax;
}
}

if (!edgey) { // Only use for non-edge clusters
if (sizey == 1) {
if (!bigInY) {
yerr = theClusterParam.sy1;
} else {
yerr = theClusterParam.sy2;
}
if (!edgey) { // Only use for non-edge clusters
if (sizey == 1) {
if (!bigInY) {
yerr = theClusterParam.sy1;
} else {
yerr = theClusterParam.sigmay;
yerr = theClusterParam.sy2;
}
} else {
yerr = theClusterParam.sigmay;
}
}

if (localPrint) {
cout << " in if " << edgex << " " << edgey << " " << sizex << " " << sizey << endl;
cout << " errors " << xerr << " " << yerr << " " << theClusterParam.sx1 << " " << theClusterParam.sx2 << " "
<< theClusterParam.sigmax << endl; //dk
}
if (localPrint) {
cout << " in if " << edgex << " " << edgey << " " << sizex << " " << sizey << endl;
cout << " errors " << xerr << " " << yerr << " " << theClusterParam.sx1 << " " << theClusterParam.sx2 << " "
<< theClusterParam.sigmax << endl; //dk
}
else { // simple errors
} else { // simple errors

// This are the simple errors, hardcoded in the code
//cout << "Track angles are not known " << endl;
Expand Down