CMS 3D CMS Logo

Public Member Functions | Private Attributes

SiPixelTemplate Class Reference

#include <SiPixelTemplate.h>

List of all members.

Public Member Functions

float chi2xavg (int i)
 averaage x chi^2 in 4 charge bins
float chi2xavgc2m (int i)
 1st pass chi2 min search: average x-chisq for merged clusters
float chi2xavgone ()
 //!< average x chi^2 for 1 pixel clusters
float chi2xmin (int i)
 minimum y chi^2 in 4 charge bins
float chi2xminc2m (int i)
 1st pass chi2 min search: minimum x-chisq for merged clusters
float chi2xminone ()
 //!< minimum of x chi^2 for 1 pixel clusters
float chi2yavg (int i)
 average y chi^2 in 4 charge bins
float chi2yavgc2m (int i)
 1st pass chi2 min search: average y-chisq for merged clusters
float chi2yavgone ()
 //!< average y chi^2 for 1 pixel clusters
float chi2ymin (int i)
 minimum y chi^2 in 4 charge bins
float chi2yminc2m (int i)
 1st pass chi2 min search: minimum y-chisq for merged clusters
float chi2yminone ()
 //!< minimum of y chi^2 for 1 pixel clusters
float clslenx ()
 x-size of smaller interpolated template in pixels
float clsleny ()
 y-size of smaller interpolated template in pixels
int cxtemp ()
 Return central pixel of x-template pixels above readout threshold.
int cytemp ()
 Return central pixel of y template pixels above readout threshold.
float dxone ()
 mean offset/correction for one pixel x-clusters
float dxtwo ()
 mean offset/correction for one double-pixel x-clusters
float dyone ()
 mean offset/correction for one pixel y-clusters
float dytwo ()
 mean offset/correction for one double-pixel y-clusters
bool interpolate (int id, float cotalpha, float cotbeta, float locBz)
bool interpolate (int id, float cotalpha, float cotbeta)
float kappavav ()
 kappa parameter for Vavilov distribution
float kappavav2 ()
 kappa parameter for 2-cluster Vavilov distribution
float lorxwidth ()
 signed lorentz x-width (microns)
float lorywidth ()
 signed lorentz y-width (microns)
float mpvvav ()
 most probable charge in Vavilov distribution (not actually for larger kappa)
float mpvvav2 ()
 most probable charge in 2-cluster Vavilov distribution (not actually for larger kappa)
float pixmax ()
 maximum pixel charge
bool pushfile (int filenum)
bool pushfile (const SiPixelTemplateDBObject &dbobject)
float qavg ()
 average cluster charge for this set of track angles
int qbin (int id, float cotalpha, float cotbeta, float locBz, float qclus, float &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2)
int qbin (int id, float cotalpha, float cotbeta, float qclus)
int qbin (int id, float cotbeta, float qclus)
int qbin (int id, float cotalpha, float cotbeta, float locBz, float qclus, float &pixmx, float &sigmay, float &deltay, float &sigmax, float &deltax, float &sy1, float &dy1, float &sy2, float &dy2, float &sx1, float &dx1, float &sx2, float &dx2, float &lorywidth, float &lorxwidth)
void qbin_dist (int id, float cotalpha, float cotbeta, float qbin_frac[4], float &ny1_frac, float &ny2_frac, float &nx1_frac, float &nx2_frac)
float qmin ()
 minimum cluster charge for valid hit (keeps 99.9% of simulated hits)
float qmin (int i)
 minimum cluster charge for valid hit (keeps 99.9% or 99.8% of simulated hits)
float qscale ()
 charge scaling factor
float s50 ()
 1/2 of the pixel threshold signal in electrons
float sigmavav ()
 "sigma" scale fctor for Vavilov distribution
float sigmavav2 ()
 "sigma" scale fctor for 2-cluster Vavilov distribution
bool simpletemplate2D (float xhitp, float yhitp, std::vector< bool > &ydouble, std::vector< bool > &xdouble, float template2d[BXM2][BYM2])
 Make simple 2-D templates from track angles set in interpolate and hit position.
 SiPixelTemplate ()
 Default constructor.
float sxmax ()
 average pixel signal for x-projection of cluster
float sxone ()
 rms for one pixel x-clusters
float sxtwo ()
 rms for one double-pixel x-clusters
float symax ()
 average pixel signal for y-projection of cluster
float syone ()
 rms for one pixel y-clusters
float sytwo ()
 rms for one double-pixel y-clusters
void temperrors (int id, float cotalpha, float cotbeta, int qBin, float &sigmay, float &sigmax, float &sy1, float &sy2, float &sx1, float &sx2)
void vavilov2_pars (double &mpv, double &sigma, double &kappa)
void vavilov_pars (double &mpv, double &sigma, double &kappa)
float xavg (int i)
 average x-bias of reconstruction binned in 4 charge bins
float xavgc2m (int i)
 1st pass chi2 min search: average x-bias of reconstruction binned in 4 charge bins
float xflcorr (int binq, float qflx)
float xgsig (int i)
 average sigma_x from Gaussian fit binned in 4 charge bins
float xgx0 (int i)
 average x0 from Gaussian fit binned in 4 charge bins
float xrms (int i)
 average x-rms of reconstruction binned in 4 charge bins
float xrmsc2m (int i)
 1st pass chi2 min search: average x-rms of reconstruction binned in 4 charge bins
void xsigma2 (int fxpix, int lxpix, float sxthr, float xsum[BXSIZE], float xsig2[BXSIZE])
float xsize ()
 pixel x-size (microns)
void xtemp (int fxbin, int lxbin, float xtemplate[41][BXSIZE])
void xtemp3d (int j, int k, std::vector< float > &xtemplate)
void xtemp3d_int (int nxpix, int &nxbins)
float xxratio ()
 fractional distance in x between cotalpha templates
float yavg (int i)
 average y-bias of reconstruction binned in 4 charge bins
float yavgc2m (int i)
 1st pass chi2 min search: average y-bias of reconstruction binned in 4 charge bins
float yflcorr (int binq, float qfly)
float ygsig (int i)
 average sigma_y from Gaussian fit binned in 4 charge bins
float ygx0 (int i)
 average y0 from Gaussian fit binned in 4 charge bins
float yratio ()
 fractional distance in y between cotbeta templates
float yrms (int i)
 average y-rms of reconstruction binned in 4 charge bins
float yrmsc2m (int i)
 1st pass chi2 min search: average y-rms of reconstruction binned in 4 charge bins
void ysigma2 (int fypix, int lypix, float sythr, float ysum[BYSIZE], float ysig2[BYSIZE])
void ysigma2 (float qpixel, int index, float &ysig2)
float ysize ()
 pixel y-size (microns)
void ytemp (int fybin, int lybin, float ytemplate[41][BYSIZE])
void ytemp3d (int j, int k, std::vector< float > &ytemplate)
void ytemp3d_int (int nypix, int &nybins)
float yxratio ()
 fractional distance in y between cotalpha templates slices
float zsize ()
 pixel z-size or thickness (microns)

Private Attributes

float abs_cotb_
 absolute value of cot beta
float chi2xavg_ [4]
 average x chi^2 in 4 charge bins
float chi2xavgc2m_ [4]
 1st pass chi2 min search: average x-chisq for merged clusters
float chi2xavgone_
 average x chi^2 for 1 pixel clusters
float chi2xmin_ [4]
 minimum of x chi^2 in 4 charge bins
float chi2xminc2m_ [4]
 1st pass chi2 min search: minimum x-chisq for merged clusters
float chi2xminone_
 minimum of x chi^2 for 1 pixel clusters
float chi2yavg_ [4]
 average y chi^2 in 4 charge bins
float chi2yavgc2m_ [4]
 1st pass chi2 min search: average y-chisq for merged clusters
float chi2yavgone_
 average y chi^2 for 1 pixel clusters
float chi2ymin_ [4]
 minimum of y chi^2 in 4 charge bins
float chi2yminc2m_ [4]
 1st pass chi2 min search: minimum y-chisq for merged clusters
float chi2yminone_
 minimum of y chi^2 for 1 pixel clusters
float clslenx_
 x-cluster length of smaller interpolated template in pixels
float clsleny_
 y-cluster length of smaller interpolated template in pixels
float cota_current_
 current cot alpha
float cotb_current_
 current cot beta
float dxone_
 mean offset/correction for one pixel x-clusters
float dxtwo_
 mean offset/correction for one double-pixel x-clusters
float dyone_
 mean offset/correction for one pixel y-clusters
float dytwo_
 mean offset/correction for one double-pixel y-clusters
int id_current_
 current id
int index_id_
 current index
float kappavav2_
 kappa parameter for 2-cluster Vavilov distribution
float kappavav_
 kappa parameter for Vavilov distribution
float lorxwidth_
 Lorentz x-width.
float lorywidth_
 Lorentz y-width (sign corrected for fpix frame)
float mpvvav2_
 most probable charge in 2-cluster Vavilov distribution (not actually for larger kappa)
float mpvvav_
 most probable charge in Vavilov distribution (not actually for larger kappa)
float nxbins_
 number of bins in each dimension of the x-splitting template
float nybins_
 number of bins in each dimension of the y-splitting template
float pixmax_
 maximum pixel charge
float qavg_
 average cluster charge for this set of track angles
float qavg_avg_
 average of cluster charge less than qavg
float qmin2_
 tighter minimum cluster charge for valid hit (keeps 99.8% of simulated hits)
float qmin_
 minimum cluster charge for valid hit (keeps 99.9% of simulated hits)
float qscale_
 charge scaling factor
float s50_
 1/2 of the pixel threshold signal in adc units
float sigmavav2_
 "sigma" scale fctor for 2-cluster Vavilov distribution
float sigmavav_
 "sigma" scale fctor for Vavilov distribution
bool success_
 true if cotalpha, cotbeta are inside of the acceptance (dynamically loaded)
float sxmax_
 average pixel signal for x-projection of cluster
float sxone_
 rms for one pixel x-clusters
float sxparmax_
 maximum pixel signal for parameterization of x uncertainties
float sxtwo_
 rms for one double-pixel x-clusters
float symax_
 average pixel signal for y-projection of cluster
float syone_
 rms for one pixel y-clusters
float syparmax_
 maximum pixel signal for parameterization of y uncertainties
float sytwo_
 rms for one double-pixel y-clusters
boost::multi_array< float, 2 > temp2dx_
 2d-primitive for spltting 3-d template
boost::multi_array< float, 2 > temp2dy_
 2d-primitive for spltting 3-d template
std::vector< SiPixelTemplateStorethePixelTemp_
float xavg_ [4]
 average x-bias of reconstruction binned in 4 charge bins
float xavgc2m_ [4]
 1st pass chi2 min search: average x-bias of reconstruction binned in 4 charge bins
float xflparhh_ [4][6]
 Aqfl-parameterized x-correction in 4 charge bins for larger cotbeta, cotalpha.
float xflparhl_ [4][6]
 Aqfl-parameterized x-correction in 4 charge bins for larger cotbeta, smaller cotalpha.
float xflparlh_ [4][6]
 Aqfl-parameterized x-correction in 4 charge bins for smaller cotbeta, larger cotalpha.
float xflparll_ [4][6]
 Aqfl-parameterized x-correction in 4 charge bins for smaller cotbeta, cotalpha.
float xgsig_ [4]
 sigma from Gaussian fit binned in 4 charge bins
float xgx0_ [4]
 average x0 from Gaussian fit binned in 4 charge bins
float xpar0_ [2][5]
 projected x-pixel uncertainty parameterization for central cotalpha
float xparh_ [2][5]
 projected x-pixel uncertainty parameterization for larger cotalpha
float xparhy0_ [2][5]
 projected x-pixel uncertainty parameterization for larger cotbeta (central alpha)
float xparl_ [2][5]
 projected x-pixel uncertainty parameterization for smaller cotalpha
float xparly0_ [2][5]
 projected x-pixel uncertainty parameterization for smaller cotbeta (central alpha)
float xrms_ [4]
 average x-rms of reconstruction binned in 4 charge bins
float xrmsc2m_ [4]
 1st pass chi2 min search: average x-rms of reconstruction binned in 4 charge bins
float xsize_
 Pixel x-size.
float xtemp_ [9][BXSIZE]
 templates for x-reconstruction (binned over 5 central pixels)
float xxratio_
 fractional distance in x between cotalpha templates
float yavg_ [4]
 average y-bias of reconstruction binned in 4 charge bins
float yavgc2m_ [4]
 1st pass chi2 min search: average y-bias of reconstruction binned in 4 charge bins
float yflparh_ [4][6]
 Aqfl-parameterized y-correction in 4 charge bins for larger cotbeta.
float yflparl_ [4][6]
 Aqfl-parameterized y-correction in 4 charge bins for smaller cotbeta.
float ygsig_ [4]
 average sigma_y from Gaussian fit binned in 4 charge bins
float ygx0_ [4]
 average y0 from Gaussian fit binned in 4 charge bins
float yparh_ [2][5]
 projected y-pixel uncertainty parameterization for larger cotbeta
float yparl_ [2][5]
 projected y-pixel uncertainty parameterization for smaller cotbeta
float yratio_
 fractional distance in y between cotbeta templates
float yrms_ [4]
 average y-rms of reconstruction binned in 4 charge bins
float yrmsc2m_ [4]
 1st pass chi2 min search: average y-rms of reconstruction binned in 4 charge bins
float ysize_
 Pixel y-size.
float ytemp_ [9][BYSIZE]
 templates for y-reconstruction (binned over 5 central pixels)
float yxratio_
 fractional distance in y between x-slices of cotalpha templates
float zsize_
 Pixel z-size (thickness)

Detailed Description

A template management class. SiPixelTemplate contains thePixelTemp (a std::vector of SiPixelTemplateStore, each of which is a collection of many SiPixelTemplateEntries). Each SiPixelTemplateStore corresponds to a given detector condition, and is valid for a range of runs. We allow more than one Store since the may change over time.

This class reads templates from files via pushfile() method.

The main functionality of SiPixelTemplate is interpolate(), which produces a template on the fly, given a specific track's alpha and beta. The results are kept in data members and accessed via inline getters.

The resulting template is then used by PixelTempReco2D() (a global function) which get the reference for SiPixelTemplate & templ and uses the current template to reconstruct the SiPixelRecHit.

Definition at line 221 of file SiPixelTemplate.h.


Constructor & Destructor Documentation

SiPixelTemplate::SiPixelTemplate ( ) [inline]

Default constructor.

Definition at line 223 of file SiPixelTemplate.h.

References cota_current_, cotb_current_, id_current_, and index_id_.


Member Function Documentation

float SiPixelTemplate::chi2xavg ( int  i) [inline]

averaage x chi^2 in 4 charge bins

Definition at line 398 of file SiPixelTemplate.h.

References chi2xavg_, Exception, and i.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::chi2xavgc2m ( int  i) [inline]

1st pass chi2 min search: average x-chisq for merged clusters

Definition at line 454 of file SiPixelTemplate.h.

References chi2xavgc2m_, Exception, and i.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::chi2xavgone ( ) [inline]

//!< average x chi^2 for 1 pixel clusters

Definition at line 470 of file SiPixelTemplate.h.

References chi2xavgone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::chi2xmin ( int  i) [inline]

minimum y chi^2 in 4 charge bins

Definition at line 405 of file SiPixelTemplate.h.

References chi2xmin_, Exception, and i.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::chi2xminc2m ( int  i) [inline]

1st pass chi2 min search: minimum x-chisq for merged clusters

Definition at line 461 of file SiPixelTemplate.h.

References chi2xminc2m_, Exception, and i.

float SiPixelTemplate::chi2xminone ( ) [inline]

//!< minimum of x chi^2 for 1 pixel clusters

Definition at line 471 of file SiPixelTemplate.h.

References chi2xminone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::chi2yavg ( int  i) [inline]

average y chi^2 in 4 charge bins

Definition at line 384 of file SiPixelTemplate.h.

References chi2yavg_, Exception, and i.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::chi2yavgc2m ( int  i) [inline]

1st pass chi2 min search: average y-chisq for merged clusters

Definition at line 426 of file SiPixelTemplate.h.

References chi2yavgc2m_, Exception, and i.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::chi2yavgone ( ) [inline]

//!< average y chi^2 for 1 pixel clusters

Definition at line 468 of file SiPixelTemplate.h.

References chi2yavgone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::chi2ymin ( int  i) [inline]

minimum y chi^2 in 4 charge bins

Definition at line 391 of file SiPixelTemplate.h.

References chi2ymin_, Exception, and i.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::chi2yminc2m ( int  i) [inline]

1st pass chi2 min search: minimum y-chisq for merged clusters

Definition at line 433 of file SiPixelTemplate.h.

References chi2yminc2m_, Exception, and i.

float SiPixelTemplate::chi2yminone ( ) [inline]

//!< minimum of y chi^2 for 1 pixel clusters

Definition at line 469 of file SiPixelTemplate.h.

References chi2yminone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::clslenx ( ) [inline]

x-size of smaller interpolated template in pixels

Definition at line 324 of file SiPixelTemplate.h.

References clslenx_.

float SiPixelTemplate::clsleny ( ) [inline]

y-size of smaller interpolated template in pixels

Definition at line 323 of file SiPixelTemplate.h.

References clsleny_.

int SiPixelTemplate::cxtemp ( )

Return central pixel of x-template pixels above readout threshold.

Definition at line 1874 of file SiPixelTemplate.cc.

References BXM1, BXM2, BXSIZE, and j.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

{
        // Retrieve already interpolated quantities
        
        // Local variables 
        int j;
        
        // Analyze only pixels along the central entry
        // First, find the maximum signal and then work out to the edges
        
        float sigmax = 0.f;
        float qedge = 2.*s50_;
        int jmax = -1;
        
        for(j=0; j<BXSIZE; ++j) {
                if(xtemp_[4][j] > sigmax) {
                        sigmax = xtemp_[4][j];
                        jmax = j;
                }       
        }
        if(sigmax < qedge) {qedge = s50_;}
        if(sigmax < qedge || jmax<1 || jmax>BXM2) {return -1;}
        
        //  Now search forward and backward
        
        int jend = jmax;
        
        for(j=jmax+1; j<BXM1; ++j) {
                if(xtemp_[4][j] < qedge) break;
           jend = j;
   }

   int jbeg = jmax;

   for(j=jmax-1; j>0; --j) {
           if(xtemp_[4][j] < qedge) break;
           jbeg = j;
   }

   return (jbeg+jend)/2;

} // End cxtemp
int SiPixelTemplate::cytemp ( )

Return central pixel of y template pixels above readout threshold.

Definition at line 1825 of file SiPixelTemplate.cc.

References BYM1, BYM2, BYSIZE, and j.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

{
        // Retrieve already interpolated quantities
        
        // Local variables 
        int j;
        
// Analyze only pixels along the central entry
// First, find the maximum signal and then work out to the edges
        
        float sigmax = 0.f;
        float qedge = 2.*s50_;
        int jmax = -1;
        
        for(j=0; j<BYSIZE; ++j) {
                if(ytemp_[4][j] > sigmax) {
                        sigmax = ytemp_[4][j];
                        jmax = j;
                }       
        }
        if(sigmax < qedge) {qedge = s50_;}
        if(sigmax < qedge || jmax<1 || jmax>BYM2) {return -1;}
        
//  Now search forward and backward
        
        int jend = jmax;
        
        for(j=jmax+1; j<BYM1; ++j) {
                if(ytemp_[4][j] < qedge) break;
           jend = j;
        }

   int jbeg = jmax;

for(j=jmax-1; j>0; --j) {
                if(ytemp_[4][j] < qedge) break;
                jbeg = j;
        }
                
        return (jbeg+jend)/2;
        
} // End cytemp
float SiPixelTemplate::dxone ( ) [inline]

mean offset/correction for one pixel x-clusters

Definition at line 311 of file SiPixelTemplate.h.

References dxone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::dxtwo ( ) [inline]

mean offset/correction for one double-pixel x-clusters

Definition at line 313 of file SiPixelTemplate.h.

References dxtwo_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::dyone ( ) [inline]

mean offset/correction for one pixel y-clusters

Definition at line 306 of file SiPixelTemplate.h.

References dyone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::dytwo ( ) [inline]

mean offset/correction for one double-pixel y-clusters

Definition at line 308 of file SiPixelTemplate.h.

References dytwo_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

bool SiPixelTemplate::interpolate ( int  id,
float  cotalpha,
float  cotbeta 
)

Interpolate input alpha and beta angles to produce a working template for each individual hit.

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)

Definition at line 1294 of file SiPixelTemplate.cc.

References f, and interpolate().

{
    // Interpolate for a new set of track angles 
    
    // Local variables 
    float locBz;
        locBz = -1.f;
        if(cotbeta < 0.f) {locBz = -locBz;}
    return SiPixelTemplate::interpolate(id, cotalpha, cotbeta, locBz);
}
bool SiPixelTemplate::interpolate ( int  id,
float  cotalpha,
float  cotbeta,
float  locBz 
)

Interpolate input alpha and beta angles to produce a working template for each individual hit.

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
locBz- (input) the sign of this quantity is used to determine whether to flip cot(beta)<0 quantities from cot(beta)>0 (FPix only) for FPix IP-related tracks, locBz < 0 for cot(beta) > 0 and locBz > 0 for cot(beta) < 0

Definition at line 877 of file SiPixelTemplate.cc.

References abs, BXM1, BXM2, BYM1, BYM2, BYM3, Exception, f, i, errorMatrix2Lands_multiChannel::id, j, mathSSE::sqrt(), TXSIZE, and TYSIZE.

Referenced by interpolate(), SiPixelTemplateReco::PixelTempReco2D(), SiPixelTemplateSplit::PixelTempSplit(), and SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit().

                                                                                   {
    // Interpolate for a new set of track angles 
    
    // Local variables 
    int i, j;
        int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, imidy, imaxx;
        float yratio, yxratio, xxratio, sxmax, qcorrect, qxtempcor, symax, chi2xavgone, chi2xminone, cotb, cotalpha0, cotbeta0;
        bool flip_y;
//      std::vector <float> xrms(4), xgsig(4), xrmsc2m(4);
        float chi2xavg[4], chi2xmin[4], chi2xavgc2m[4], chi2xminc2m[4];


// Check to see if interpolation is valid     

if(id != id_current_ || cotalpha != cota_current_ || cotbeta != cotb_current_) {

        cota_current_ = cotalpha; cotb_current_ = cotbeta; success_ = true;
        
        if(id != id_current_) {

// Find the index corresponding to id

       index_id_ = -1;
       for(i=0; i<(int)thePixelTemp_.size(); ++i) {
        
              if(id == thePixelTemp_[i].head.ID) {
           
                 index_id_ = i;
                      id_current_ = id;
                                
// Copy the charge scaling factor to the private variable     
                                
                                qscale_ = thePixelTemp_[index_id_].head.qscale;
                                
// Copy the pseudopixel signal size to the private variable     
                                
                                s50_ = thePixelTemp_[index_id_].head.s50;
                        
// Pixel sizes to the private variables     
                                
                                xsize_ = thePixelTemp_[index_id_].head.xsize;
                                ysize_ = thePixelTemp_[index_id_].head.ysize;
                                zsize_ = thePixelTemp_[index_id_].head.zsize;
                                
                                break;
          }
            }
     }
         
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
    if(index_id_ < 0 || index_id_ >= (int)thePixelTemp_.size()) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::interpolate can't find needed template ID = " << id << std::endl;
        }
#else
        assert(index_id_ >= 0 && index_id_ < (int)thePixelTemp_.size());
#endif
         
// Interpolate the absolute value of cot(beta)     
    
        abs_cotb_ = std::abs(cotbeta);
        
//      qcorrect corrects the cot(alpha)=0 cluster charge for non-zero cot(alpha)       

        cotalpha0 =  thePixelTemp_[index_id_].enty[0].cotalpha;
        qcorrect=std::sqrt((1.f+cotbeta*cotbeta+cotalpha*cotalpha)/(1.f+cotbeta*cotbeta+cotalpha0*cotalpha0));
        
// for some cosmics, the ususal gymnastics are incorrect   
        if(thePixelTemp_[index_id_].head.Dtype == 0) {
                cotb = abs_cotb_;
                flip_y = false;
                if(cotbeta < 0.f) {flip_y = true;}
        } else {
            if(locBz < 0.f) {
                        cotb = cotbeta;
                        flip_y = false;
                } else {
                        cotb = -cotbeta;
                        flip_y = true;
                }       
        }
                
        Ny = thePixelTemp_[index_id_].head.NTy;
        Nyx = thePixelTemp_[index_id_].head.NTyx;
        Nxx = thePixelTemp_[index_id_].head.NTxx;
                
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(Ny < 2 || Nyx < 1 || Nxx < 2) {
                throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny/Nyx/Nxx = " << Ny << "/" << Nyx << "/" << Nxx << std::endl;
        }
#else
        assert(Ny > 1 && Nyx > 0 && Nxx > 1);
#endif
        imaxx = Nyx - 1;
        imidy = Nxx/2;
        
// next, loop over all y-angle entries   

        ilow = 0;
        yratio = 0.f;

        if(cotb >= thePixelTemp_[index_id_].enty[Ny-1].cotbeta) {
        
                ilow = Ny-2;
                yratio = 1.;
                success_ = false;
                
        } else {
           
                if(cotb >= thePixelTemp_[index_id_].enty[0].cotbeta) {

                        for (i=0; i<Ny-1; ++i) { 
    
                        if( thePixelTemp_[index_id_].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index_id_].enty[i+1].cotbeta) {
                  
                                ilow = i;
                                yratio = (cotb - thePixelTemp_[index_id_].enty[i].cotbeta)/(thePixelTemp_[index_id_].enty[i+1].cotbeta - thePixelTemp_[index_id_].enty[i].cotbeta);
                                break;                   
                        }
                }
        } else { success_ = false; }
  }
        
        ihigh=ilow + 1;
                          
// Interpolate/store all y-related quantities (flip displacements when flip_y)

        yratio_ = yratio;
        qavg_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].qavg + yratio*thePixelTemp_[index_id_].enty[ihigh].qavg;
        qavg_ *= qcorrect;
        symax = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].symax + yratio*thePixelTemp_[index_id_].enty[ihigh].symax;
        syparmax_ = symax;
        sxmax = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sxmax + yratio*thePixelTemp_[index_id_].enty[ihigh].sxmax;
        dyone_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].dyone + yratio*thePixelTemp_[index_id_].enty[ihigh].dyone;
        if(flip_y) {dyone_ = -dyone_;}
        syone_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].syone + yratio*thePixelTemp_[index_id_].enty[ihigh].syone;
        dytwo_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].dytwo + yratio*thePixelTemp_[index_id_].enty[ihigh].dytwo;
        if(flip_y) {dytwo_ = -dytwo_;}
        sytwo_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sytwo + yratio*thePixelTemp_[index_id_].enty[ihigh].sytwo;
        qmin_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].qmin + yratio*thePixelTemp_[index_id_].enty[ihigh].qmin;
        qmin_ *= qcorrect;
        qmin2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].qmin2 + yratio*thePixelTemp_[index_id_].enty[ihigh].qmin2;
        qmin2_ *= qcorrect;
        mpvvav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].mpvvav + yratio*thePixelTemp_[index_id_].enty[ihigh].mpvvav;
        mpvvav_ *= qcorrect;
        sigmavav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sigmavav + yratio*thePixelTemp_[index_id_].enty[ihigh].sigmavav;
        kappavav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].kappavav + yratio*thePixelTemp_[index_id_].enty[ihigh].kappavav;
        mpvvav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].mpvvav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].mpvvav2;
        mpvvav2_ *= qcorrect;
        sigmavav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sigmavav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].sigmavav2;
        kappavav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].kappavav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].kappavav2;
        clsleny_ = fminf(thePixelTemp_[index_id_].enty[ilow].clsleny, thePixelTemp_[index_id_].enty[ihigh].clsleny);
        qavg_avg_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].qavg_avg + yratio*thePixelTemp_[index_id_].enty[ihigh].qavg_avg;
        qavg_avg_ *= qcorrect;
        for(i=0; i<2 ; ++i) {
                for(j=0; j<5 ; ++j) {
// Charge loss switches sides when cot(beta) changes sign
                        if(flip_y) {
                    yparl_[1-i][j] = thePixelTemp_[index_id_].enty[ilow].ypar[i][j];
                    yparh_[1-i][j] = thePixelTemp_[index_id_].enty[ihigh].ypar[i][j];
                        } else {
                    yparl_[i][j] = thePixelTemp_[index_id_].enty[ilow].ypar[i][j];
                    yparh_[i][j] = thePixelTemp_[index_id_].enty[ihigh].ypar[i][j];
                        }
                        xparly0_[i][j] = thePixelTemp_[index_id_].enty[ilow].xpar[i][j];
                        xparhy0_[i][j] = thePixelTemp_[index_id_].enty[ihigh].xpar[i][j];
                }
        }
        for(i=0; i<4; ++i) {
                yavg_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].yavg[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].yavg[i];
                if(flip_y) {yavg_[i] = -yavg_[i];}
                yrms_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].yrms[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].yrms[i];
//            ygx0_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].ygx0[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].ygx0[i];
//            if(flip_y) {ygx0_[i] = -ygx0_[i];}
//            ygsig_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].ygsig[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].ygsig[i];
//            xrms[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].xrms[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].xrms[i];
//            xgsig[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].xgsig[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].xgsig[i];
                chi2yavg_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2yavg[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2yavg[i];
                chi2ymin_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2ymin[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2ymin[i];
                chi2xavg[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xavg[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xavg[i];
                chi2xmin[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xmin[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xmin[i];
                yavgc2m_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].yavgc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].yavgc2m[i];
                if(flip_y) {yavgc2m_[i] = -yavgc2m_[i];}
                yrmsc2m_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].yrmsc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].yrmsc2m[i];
                chi2yavgc2m_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2yavgc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2yavgc2m[i];
//            if(flip_y) {chi2yavgc2m_[i] = -chi2yavgc2m_[i];}
                chi2yminc2m_[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2yminc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2yminc2m[i];
//            xrmsc2m[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].xrmsc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].xrmsc2m[i];
                chi2xavgc2m[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xavgc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xavgc2m[i];
                chi2xminc2m[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xminc2m[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xminc2m[i];
                for(j=0; j<6 ; ++j) {
                        yflparl_[i][j] = thePixelTemp_[index_id_].enty[ilow].yflpar[i][j];
                        yflparh_[i][j] = thePixelTemp_[index_id_].enty[ihigh].yflpar[i][j];
                         
// Since Q_fl is odd under cotbeta, it flips qutomatically, change only even terms

                        if(flip_y && (j == 0 || j == 2 || j == 4)) {
                           yflparl_[i][j] = - yflparl_[i][j];
                           yflparh_[i][j] = - yflparh_[i][j];
                        }
                }
        }
           

        chi2yavgone_=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2yavgone + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2yavgone;
        chi2yminone_=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2yminone + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2yminone;
        chi2xavgone=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xavgone + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xavgone;
        chi2xminone=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].chi2xminone + yratio*thePixelTemp_[index_id_].enty[ihigh].chi2xminone;
                //       for(i=0; i<10; ++i) {
//                  pyspare[i]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].yspare[i] + yratio*thePixelTemp_[index_id_].enty[ihigh].yspare[i];
//       }
                          
// Interpolate and build the y-template 
        
        for(i=0; i<9; ++i) {
                ytemp_[i][0] = 0.f;
                ytemp_[i][1] = 0.f;
                ytemp_[i][BYM2] = 0.f;
                ytemp_[i][BYM1] = 0.f;
                for(j=0; j<TYSIZE; ++j) {
                  
// Flip the basic y-template when the cotbeta is negative

                        if(flip_y) {
                           ytemp_[8-i][BYM3-j]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].ytemp[i][j] + yratio*thePixelTemp_[index_id_].enty[ihigh].ytemp[i][j];
                        } else {
                           ytemp_[i][j+2]=(1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].ytemp[i][j] + yratio*thePixelTemp_[index_id_].enty[ihigh].ytemp[i][j];
                        }
                }
        }
        
// next, loop over all x-angle entries, first, find relevant y-slices   
        
        iylow = 0;
        yxratio = 0.f;

        if(abs_cotb_ >= thePixelTemp_[index_id_].entx[Nyx-1][0].cotbeta) {
        
                iylow = Nyx-2;
                yxratio = 1.f;
                
        } else if(abs_cotb_ >= thePixelTemp_[index_id_].entx[0][0].cotbeta) {

                for (i=0; i<Nyx-1; ++i) { 
    
                        if( thePixelTemp_[index_id_].entx[i][0].cotbeta <= abs_cotb_ && abs_cotb_ < thePixelTemp_[index_id_].entx[i+1][0].cotbeta) {
                  
                           iylow = i;
                           yxratio = (abs_cotb_ - thePixelTemp_[index_id_].entx[i][0].cotbeta)/(thePixelTemp_[index_id_].entx[i+1][0].cotbeta - thePixelTemp_[index_id_].entx[i][0].cotbeta);
                           break;                        
                        }
                }
        }
        
        iyhigh=iylow + 1;

        ilow = 0;
        xxratio = 0.f;

        if(cotalpha >= thePixelTemp_[index_id_].entx[0][Nxx-1].cotalpha) {
        
                ilow = Nxx-2;
                xxratio = 1.f;
                success_ = false;
                
        } else {
           
                if(cotalpha >= thePixelTemp_[index_id_].entx[0][0].cotalpha) {

                        for (i=0; i<Nxx-1; ++i) { 
    
                           if( thePixelTemp_[index_id_].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp_[index_id_].entx[0][i+1].cotalpha) {
                  
                                  ilow = i;
                                  xxratio = (cotalpha - thePixelTemp_[index_id_].entx[0][i].cotalpha)/(thePixelTemp_[index_id_].entx[0][i+1].cotalpha - thePixelTemp_[index_id_].entx[0][i].cotalpha);
                                  break;
                        }
                  }
                } else { success_ = false; }
        }
        
        ihigh=ilow + 1;
                          
// Interpolate/store all x-related quantities 

        yxratio_ = yxratio;
        xxratio_ = xxratio;             
                          
// sxparmax defines the maximum charge for which the parameters xpar are defined (not rescaled by cotbeta) 

        sxparmax_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[imaxx][ilow].sxmax + xxratio*thePixelTemp_[index_id_].entx[imaxx][ihigh].sxmax;
        sxmax_ = sxparmax_;
        if(thePixelTemp_[index_id_].entx[imaxx][imidy].sxmax != 0.f) {sxmax_=sxmax_/thePixelTemp_[index_id_].entx[imaxx][imidy].sxmax*sxmax;}
        symax_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[imaxx][ilow].symax + xxratio*thePixelTemp_[index_id_].entx[imaxx][ihigh].symax;
        if(thePixelTemp_[index_id_].entx[imaxx][imidy].symax != 0.f) {symax_=symax_/thePixelTemp_[index_id_].entx[imaxx][imidy].symax*symax;}
        dxone_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[0][ilow].dxone + xxratio*thePixelTemp_[index_id_].entx[0][ihigh].dxone;
        sxone_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[0][ilow].sxone + xxratio*thePixelTemp_[index_id_].entx[0][ihigh].sxone;
        dxtwo_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[0][ilow].dxtwo + xxratio*thePixelTemp_[index_id_].entx[0][ihigh].dxtwo;
        sxtwo_ = (1.f - xxratio)*thePixelTemp_[index_id_].entx[0][ilow].sxtwo + xxratio*thePixelTemp_[index_id_].entx[0][ihigh].sxtwo;
        clslenx_ = fminf(thePixelTemp_[index_id_].entx[0][ilow].clslenx, thePixelTemp_[index_id_].entx[0][ihigh].clslenx);
        for(i=0; i<2 ; ++i) {
                for(j=0; j<5 ; ++j) {
                 xpar0_[i][j] = thePixelTemp_[index_id_].entx[imaxx][imidy].xpar[i][j];
                 xparl_[i][j] = thePixelTemp_[index_id_].entx[imaxx][ilow].xpar[i][j];
                 xparh_[i][j] = thePixelTemp_[index_id_].entx[imaxx][ihigh].xpar[i][j];
                }
        }
                          
// pixmax is the maximum allowed pixel charge (used for truncation)

        pixmax_=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].pixmax + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].pixmax)
                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].pixmax + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].pixmax);
                          
        for(i=0; i<4; ++i) {
                xavg_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xavg[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xavg[i])
                                +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xavg[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xavg[i]);
                  
                xrms_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xrms[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xrms[i])
                                +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xrms[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xrms[i]);
                  
//            xgx0_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xgx0[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xgx0[i])
//                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xgx0[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xgx0[i]);
                                                        
//            xgsig_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xgsig[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xgsig[i])
//                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xgsig[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xgsig[i]);
                                  
                xavgc2m_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xavgc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xavgc2m[i])
                                +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xavgc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xavgc2m[i]);
                  
                xrmsc2m_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xrmsc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xrmsc2m[i])
                                +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xrmsc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xrmsc2m[i]);
                  
//            chi2xavgc2m_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].chi2xavgc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].chi2xavgc2m[i])
//                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xavgc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xavgc2m[i]);
                                                        
//            chi2xminc2m_[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].chi2xminc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].chi2xminc2m[i])
//                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xminc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xminc2m[i]);
//
//  Try new interpolation scheme
//                                                                                                                      
//            chi2xavg_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[imaxx][ilow].chi2xavg[i] + xxratio*thePixelTemp_[index_id_].entx[imaxx][ihigh].chi2xavg[i]);
//                if(thePixelTemp_[index_id_].entx[imaxx][imidy].chi2xavg[i] != 0.f) {chi2xavg_[i]=chi2xavg_[i]/thePixelTemp_[index_id_].entx[imaxx][imidy].chi2xavg[i]*chi2xavg[i];}
//                                                      
//            chi2xmin_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[imaxx][ilow].chi2xmin[i] + xxratio*thePixelTemp_[index_id_].entx[imaxx][ihigh].chi2xmin[i]);
//                if(thePixelTemp_[index_id_].entx[imaxx][imidy].chi2xmin[i] != 0.f) {chi2xmin_[i]=chi2xmin_[i]/thePixelTemp_[index_id_].entx[imaxx][imidy].chi2xmin[i]*chi2xmin[i];}
//                
                chi2xavg_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xavg[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xavg[i]);
                if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavg[i] != 0.f) {chi2xavg_[i]=chi2xavg_[i]/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavg[i]*chi2xavg[i];}
                                                        
                chi2xmin_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xmin[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xmin[i]);
                if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xmin[i] != 0.f) {chi2xmin_[i]=chi2xmin_[i]/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xmin[i]*chi2xmin[i];}
                
                chi2xavgc2m_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xavgc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xavgc2m[i]);
                if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavgc2m[i] != 0.f) {chi2xavgc2m_[i]=chi2xavgc2m_[i]/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavgc2m[i]*chi2xavgc2m[i];}
                
                chi2xminc2m_[i]=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xminc2m[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xminc2m[i]);
                if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xminc2m[i] != 0.f) {chi2xminc2m_[i]=chi2xminc2m_[i]/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xminc2m[i]*chi2xminc2m[i];}
                
                for(j=0; j<6 ; ++j) {
                 xflparll_[i][j] = thePixelTemp_[index_id_].entx[iylow][ilow].xflpar[i][j];
                 xflparlh_[i][j] = thePixelTemp_[index_id_].entx[iylow][ihigh].xflpar[i][j];
                 xflparhl_[i][j] = thePixelTemp_[index_id_].entx[iyhigh][ilow].xflpar[i][j];
                 xflparhh_[i][j] = thePixelTemp_[index_id_].entx[iyhigh][ihigh].xflpar[i][j];
                }
        }
           
// Do the spares next

        chi2xavgone_=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xavgone + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xavgone);
        if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavgone != 0.f) {chi2xavgone_=chi2xavgone_/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xavgone*chi2xavgone;}
                
        chi2xminone_=((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].chi2xminone + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].chi2xminone);
        if(thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xminone != 0.f) {chi2xminone_=chi2xminone_/thePixelTemp_[index_id_].entx[iyhigh][imidy].chi2xminone*chi2xminone;}
                //       for(i=0; i<10; ++i) {
//            pxspare[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iylow][ilow].xspare[i] + xxratio*thePixelTemp_[index_id_].entx[iylow][ihigh].xspare[i])
//                        +yxratio*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xspare[i] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xspare[i]);
//       }
                          
// Interpolate and build the x-template 
        
//      qxtempcor corrects the total charge to the actual track angles (not actually needed for the template fits, but useful for Guofan)
        
        cotbeta0 =  thePixelTemp_[index_id_].entx[iyhigh][0].cotbeta;
        qxtempcor=std::sqrt((1.f+cotbeta*cotbeta+cotalpha*cotalpha)/(1.f+cotbeta0*cotbeta0+cotalpha*cotalpha));
        
        for(i=0; i<9; ++i) {
                xtemp_[i][0] = 0.f;
                xtemp_[i][1] = 0.f;
                xtemp_[i][BXM2] = 0.f;
                xtemp_[i][BXM1] = 0.f;
                for(j=0; j<TXSIZE; ++j) {
//  Take next largest x-slice for the x-template (it reduces bias in the forward direction after irradiation)
//                 xtemp_[i][j+2]=(1.f - xxratio)*thePixelTemp_[index_id_].entx[imaxx][ilow].xtemp[i][j] + xxratio*thePixelTemp_[index_id_].entx[imaxx][ihigh].xtemp[i][j];
//                 xtemp_[i][j+2]=(1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xtemp[i][j] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xtemp[i][j];
         xtemp_[i][j+2]=qxtempcor*((1.f - xxratio)*thePixelTemp_[index_id_].entx[iyhigh][ilow].xtemp[i][j] + xxratio*thePixelTemp_[index_id_].entx[iyhigh][ihigh].xtemp[i][j]);
                }
        }
        
        lorywidth_ = thePixelTemp_[index_id_].head.lorywidth;
        if(locBz > 0.f) {lorywidth_ = -lorywidth_;}
        lorxwidth_ = thePixelTemp_[index_id_].head.lorxwidth;
        
  }
        
  return success_;
} // interpolate
float SiPixelTemplate::kappavav ( ) [inline]

kappa parameter for Vavilov distribution

Definition at line 476 of file SiPixelTemplate.h.

References kappavav_.

float SiPixelTemplate::kappavav2 ( ) [inline]

kappa parameter for 2-cluster Vavilov distribution

Definition at line 479 of file SiPixelTemplate.h.

References kappavav2_.

float SiPixelTemplate::lorxwidth ( ) [inline]

signed lorentz x-width (microns)

Definition at line 473 of file SiPixelTemplate.h.

References lorxwidth_.

float SiPixelTemplate::lorywidth ( ) [inline]

signed lorentz y-width (microns)

Definition at line 472 of file SiPixelTemplate.h.

References lorywidth_.

float SiPixelTemplate::mpvvav ( ) [inline]

most probable charge in Vavilov distribution (not actually for larger kappa)

Definition at line 474 of file SiPixelTemplate.h.

References mpvvav_.

float SiPixelTemplate::mpvvav2 ( ) [inline]

most probable charge in 2-cluster Vavilov distribution (not actually for larger kappa)

Definition at line 477 of file SiPixelTemplate.h.

References mpvvav2_.

float SiPixelTemplate::pixmax ( ) [inline]

maximum pixel charge

Definition at line 302 of file SiPixelTemplate.h.

References pixmax_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

bool SiPixelTemplate::pushfile ( const SiPixelTemplateDBObject dbobject)

This routine initializes the global template structures from an external file template_summary_zpNNNN where NNNN are four digits

Parameters:
dbobject- db storing multiple template calibrations

Definition at line 506 of file SiPixelTemplate.cc.

References SiPixelTemplateEntry::alpha, SiPixelTemplateEntry::beta, SiPixelTemplateHeader::Bfield, SiPixelTemplateDBObject::char2float::c, SiPixelTemplateEntry::chi2xavg, SiPixelTemplateEntry::chi2xavgc2m, SiPixelTemplateEntry::chi2xavgone, SiPixelTemplateEntry::chi2xmin, SiPixelTemplateEntry::chi2xminc2m, SiPixelTemplateEntry::chi2xminone, SiPixelTemplateEntry::chi2yavg, SiPixelTemplateEntry::chi2yavgc2m, SiPixelTemplateEntry::chi2yavgone, SiPixelTemplateEntry::chi2ymin, SiPixelTemplateEntry::chi2yminc2m, SiPixelTemplateEntry::chi2yminone, SiPixelTemplateEntry::clslenx, SiPixelTemplateEntry::clsleny, SiPixelTemplateEntry::costrk, SiPixelTemplateEntry::cotalpha, SiPixelTemplateEntry::cotbeta, EcalCondDB::db, SiPixelTemplateHeader::Dtype, SiPixelTemplateEntry::dxone, SiPixelTemplateEntry::dxtwo, SiPixelTemplateEntry::dyone, SiPixelTemplateEntry::dytwo, ENDL, SiPixelTemplateStore::entx, SiPixelTemplateStore::enty, SiPixelTemplateDBObject::char2float::f, SiPixelTemplateDBObject::fail(), SiPixelTemplateHeader::fluence, SiPixelTemplateEntry::fracxone, SiPixelTemplateEntry::fracxtwo, SiPixelTemplateEntry::fracyone, SiPixelTemplateEntry::fracytwo, SiPixelTemplateStore::head, i, SiPixelTemplateHeader::ID, SiPixelTemplateDBObject::incrementIndex(), SiPixelTemplateDBObject::index(), j, gen::k, SiPixelTemplateEntry::kappavav, SiPixelTemplateEntry::kappavav2, prof2calltree::l, LOGERROR, LOGINFO, SiPixelTemplateHeader::lorxwidth, SiPixelTemplateHeader::lorywidth, m, SiPixelTemplateEntry::mpvvav, SiPixelTemplateEntry::mpvvav2, SiPixelTemplateHeader::NTxx, SiPixelTemplateHeader::NTy, SiPixelTemplateHeader::NTyx, SiPixelTemplateDBObject::numOfTempl(), SiPixelTemplateEntry::pixmax, SiPixelTemplateEntry::qavg, SiPixelTemplateEntry::qavg_avg, SiPixelTemplateEntry::qavg_spare, SiPixelTemplateEntry::qbfrac, SiPixelTemplateEntry::qmin, SiPixelTemplateEntry::qmin2, SiPixelTemplateHeader::qscale, SiPixelTemplateEntry::runnum, SiPixelTemplateHeader::s50, SiPixelTemplateEntry::sigmavav, SiPixelTemplateEntry::sigmavav2, SiPixelTemplateEntry::spare, SiPixelTemplateDBObject::sVector(), SiPixelTemplateEntry::sxmax, SiPixelTemplateEntry::sxone, SiPixelTemplateEntry::sxtwo, SiPixelTemplateEntry::symax, SiPixelTemplateEntry::syone, SiPixelTemplateEntry::sytwo, groupFilesInBlocks::temp, SiPixelTemplateHeader::temperature, SiPixelTemplateHeader::templ_version, SiPixelTemplateHeader::title, TXSIZE, TYSIZE, SiPixelTemplateHeader::Vbias, SiPixelTemplateEntry::xavg, SiPixelTemplateEntry::xavgc2m, SiPixelTemplateEntry::xavggen, SiPixelTemplateEntry::xflpar, SiPixelTemplateEntry::xgsig, SiPixelTemplateEntry::xgsiggen, SiPixelTemplateEntry::xgx0, SiPixelTemplateEntry::xgx0gen, SiPixelTemplateEntry::xpar, SiPixelTemplateEntry::xrms, SiPixelTemplateEntry::xrmsc2m, SiPixelTemplateEntry::xrmsgen, SiPixelTemplateHeader::xsize, SiPixelTemplateEntry::xtemp, SiPixelTemplateEntry::yavg, SiPixelTemplateEntry::yavgc2m, SiPixelTemplateEntry::yavggen, SiPixelTemplateEntry::yflpar, SiPixelTemplateEntry::ygsig, SiPixelTemplateEntry::ygsiggen, SiPixelTemplateEntry::ygx0, SiPixelTemplateEntry::ygx0gen, SiPixelTemplateEntry::ypar, SiPixelTemplateEntry::yrms, SiPixelTemplateEntry::yrmsc2m, SiPixelTemplateEntry::yrmsgen, SiPixelTemplateHeader::ysize, SiPixelTemplateEntry::ytemp, and SiPixelTemplateHeader::zsize.

{
        // Add template stored in external dbobject to theTemplateStore
    
        // Local variables 
        int i, j, k, l;
        float qavg_avg;
        //      const char *tempfile;
        const int code_version={16};
        
        // We must create a new object because dbobject must be a const and our stream must not be
        SiPixelTemplateDBObject db = dbobject;
        
        // Create a local template storage entry
        SiPixelTemplateStore theCurrentTemp;
        
        // Fill the template storage for each template calibration stored in the db
        for(int m=0; m<db.numOfTempl(); ++m)
        {
                
                // Read-in a header string first and print it    
                
                SiPixelTemplateDBObject::char2float temp;
                for (i=0; i<20; ++i) {
                        temp.f = db.sVector()[db.index()];
                        theCurrentTemp.head.title[4*i] = temp.c[0];
                        theCurrentTemp.head.title[4*i+1] = temp.c[1];
                        theCurrentTemp.head.title[4*i+2] = temp.c[2];
                        theCurrentTemp.head.title[4*i+3] = temp.c[3];
                        db.incrementIndex(1);
                }
                theCurrentTemp.head.title[79] = '\0';
                LOGINFO("SiPixelTemplate") << "Loading Pixel Template File - " << theCurrentTemp.head.title << ENDL;
                
                // next, the header information     
                
                db >> theCurrentTemp.head.ID  >> theCurrentTemp.head.templ_version >> theCurrentTemp.head.Bfield >> theCurrentTemp.head.NTy >> theCurrentTemp.head.NTyx >> theCurrentTemp.head.NTxx
                >> theCurrentTemp.head.Dtype >> theCurrentTemp.head.Vbias >> theCurrentTemp.head.temperature >> theCurrentTemp.head.fluence >> theCurrentTemp.head.qscale
                >> theCurrentTemp.head.s50 >> theCurrentTemp.head.lorywidth >> theCurrentTemp.head.lorxwidth >> theCurrentTemp.head.ysize >> theCurrentTemp.head.xsize >> theCurrentTemp.head.zsize;
                
                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file, no template load" << ENDL; return false;}
                
                LOGINFO("SiPixelTemplate") << "Template ID = " << theCurrentTemp.head.ID << ", Template Version " << theCurrentTemp.head.templ_version << ", Bfield = " << theCurrentTemp.head.Bfield 
                << ", NTy = " << theCurrentTemp.head.NTy << ", NTyx = " << theCurrentTemp.head.NTyx<< ", NTxx = " << theCurrentTemp.head.NTxx << ", Dtype = " << theCurrentTemp.head.Dtype
                << ", Bias voltage " << theCurrentTemp.head.Vbias << ", temperature "
                << theCurrentTemp.head.temperature << ", fluence " << theCurrentTemp.head.fluence << ", Q-scaling factor " << theCurrentTemp.head.qscale
                << ", 1/2 threshold " << theCurrentTemp.head.s50 << ", y Lorentz Width " << theCurrentTemp.head.lorywidth << ", x Lorentz width " << theCurrentTemp.head.lorxwidth    
                << ", pixel x-size " << theCurrentTemp.head.xsize << ", y-size " << theCurrentTemp.head.ysize << ", zsize " << theCurrentTemp.head.zsize << ENDL;
                
                if(theCurrentTemp.head.templ_version < code_version) {LOGERROR("SiPixelTemplate") << "code expects version " << code_version << ", no template load" << ENDL; return false;}
                
                
#ifdef SI_PIXEL_TEMPLATE_USE_BOOST 
                
// next, layout the 1-d/2-d structures needed to store template
                
                theCurrentTemp.enty.resize(boost::extents[theCurrentTemp.head.NTy]);
                
                theCurrentTemp.entx.resize(boost::extents[theCurrentTemp.head.NTyx][theCurrentTemp.head.NTxx]);
                
#endif
                                
// next, loop over all barrel y-angle entries   
                
                for (i=0; i < theCurrentTemp.head.NTy; ++i) {     
                        
                        db >> theCurrentTemp.enty[i].runnum >> theCurrentTemp.enty[i].costrk[0] 
                        >> theCurrentTemp.enty[i].costrk[1] >> theCurrentTemp.enty[i].costrk[2]; 
                        
                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 1, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
// Calculate the alpha, beta, and cot(beta) for this entry 
                        
                        theCurrentTemp.enty[i].alpha = static_cast<float>(atan2((double)theCurrentTemp.enty[i].costrk[2], (double)theCurrentTemp.enty[i].costrk[0]));
                        
                        theCurrentTemp.enty[i].cotalpha = theCurrentTemp.enty[i].costrk[0]/theCurrentTemp.enty[i].costrk[2];
                        
                        theCurrentTemp.enty[i].beta = static_cast<float>(atan2((double)theCurrentTemp.enty[i].costrk[2], (double)theCurrentTemp.enty[i].costrk[1]));
                        
                        theCurrentTemp.enty[i].cotbeta = theCurrentTemp.enty[i].costrk[1]/theCurrentTemp.enty[i].costrk[2];
                        
                        db >> theCurrentTemp.enty[i].qavg >> theCurrentTemp.enty[i].pixmax >> theCurrentTemp.enty[i].symax >> theCurrentTemp.enty[i].dyone
                        >> theCurrentTemp.enty[i].syone >> theCurrentTemp.enty[i].sxmax >> theCurrentTemp.enty[i].dxone >> theCurrentTemp.enty[i].sxone;
                        
                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 2, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        db >> theCurrentTemp.enty[i].dytwo >> theCurrentTemp.enty[i].sytwo >> theCurrentTemp.enty[i].dxtwo 
                        >> theCurrentTemp.enty[i].sxtwo >> theCurrentTemp.enty[i].qmin >> theCurrentTemp.enty[i].clsleny >> theCurrentTemp.enty[i].clslenx;
                        //                           >> theCurrentTemp.enty[i].mpvvav >> theCurrentTemp.enty[i].sigmavav >> theCurrentTemp.enty[i].kappavav;
                        
                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 3, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        for (j=0; j<2; ++j) {
                                
                                db >> theCurrentTemp.enty[i].ypar[j][0] >> theCurrentTemp.enty[i].ypar[j][1] 
                                >> theCurrentTemp.enty[i].ypar[j][2] >> theCurrentTemp.enty[i].ypar[j][3] >> theCurrentTemp.enty[i].ypar[j][4];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 4, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                                
                        }
                        
                        for (j=0; j<9; ++j) {
                                
                                for (k=0; k<TYSIZE; ++k) {db >> theCurrentTemp.enty[i].ytemp[j][k];}
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 5, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<2; ++j) {
                                
                                db >> theCurrentTemp.enty[i].xpar[j][0] >> theCurrentTemp.enty[i].xpar[j][1] 
                                >> theCurrentTemp.enty[i].xpar[j][2] >> theCurrentTemp.enty[i].xpar[j][3] >> theCurrentTemp.enty[i].xpar[j][4];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 6, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                                
                        }
                        
                        qavg_avg = 0.f;
                        for (j=0; j<9; ++j) {
                                
                                for (k=0; k<TXSIZE; ++k) {db >> theCurrentTemp.enty[i].xtemp[j][k]; qavg_avg += theCurrentTemp.enty[i].xtemp[j][k];} 
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 7, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        theCurrentTemp.enty[i].qavg_avg = qavg_avg/9.;
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].yavg[j] >> theCurrentTemp.enty[i].yrms[j] >> theCurrentTemp.enty[i].ygx0[j] >> theCurrentTemp.enty[i].ygsig[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 8, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].yflpar[j][0] >> theCurrentTemp.enty[i].yflpar[j][1] >> theCurrentTemp.enty[i].yflpar[j][2] 
                                >> theCurrentTemp.enty[i].yflpar[j][3] >> theCurrentTemp.enty[i].yflpar[j][4] >> theCurrentTemp.enty[i].yflpar[j][5];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 9, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].xavg[j] >> theCurrentTemp.enty[i].xrms[j] >> theCurrentTemp.enty[i].xgx0[j] >> theCurrentTemp.enty[i].xgsig[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 10, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].xflpar[j][0] >> theCurrentTemp.enty[i].xflpar[j][1] >> theCurrentTemp.enty[i].xflpar[j][2] 
                                >> theCurrentTemp.enty[i].xflpar[j][3] >> theCurrentTemp.enty[i].xflpar[j][4] >> theCurrentTemp.enty[i].xflpar[j][5];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 11, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].chi2yavg[j] >> theCurrentTemp.enty[i].chi2ymin[j] >> theCurrentTemp.enty[i].chi2xavg[j] >> theCurrentTemp.enty[i].chi2xmin[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 12, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].yavgc2m[j] >> theCurrentTemp.enty[i].yrmsc2m[j] >> theCurrentTemp.enty[i].chi2yavgc2m[j] >> theCurrentTemp.enty[i].chi2yminc2m[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 13, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].xavgc2m[j] >> theCurrentTemp.enty[i].xrmsc2m[j] >> theCurrentTemp.enty[i].chi2xavgc2m[j] >> theCurrentTemp.enty[i].chi2xminc2m[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        } 
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].yavggen[j] >> theCurrentTemp.enty[i].yrmsgen[j] >> theCurrentTemp.enty[i].ygx0gen[j] >> theCurrentTemp.enty[i].ygsiggen[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14a, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                db >> theCurrentTemp.enty[i].xavggen[j] >> theCurrentTemp.enty[i].xrmsgen[j] >> theCurrentTemp.enty[i].xgx0gen[j] >> theCurrentTemp.enty[i].xgsiggen[j];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14b, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        } 
                        
                        
                        db >> theCurrentTemp.enty[i].chi2yavgone >> theCurrentTemp.enty[i].chi2yminone >> theCurrentTemp.enty[i].chi2xavgone >> theCurrentTemp.enty[i].chi2xminone >> theCurrentTemp.enty[i].qmin2
                        >> theCurrentTemp.enty[i].mpvvav >> theCurrentTemp.enty[i].sigmavav >> theCurrentTemp.enty[i].kappavav >> theCurrentTemp.enty[i].qavg_spare >> theCurrentTemp.enty[i].spare[0];
                        
                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 15, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        db >> theCurrentTemp.enty[i].mpvvav2 >> theCurrentTemp.enty[i].sigmavav2 >> theCurrentTemp.enty[i].kappavav2 >> theCurrentTemp.enty[i].qbfrac[0] >> theCurrentTemp.enty[i].qbfrac[1]
                        >> theCurrentTemp.enty[i].qbfrac[2] >> theCurrentTemp.enty[i].fracyone >> theCurrentTemp.enty[i].fracxone >> theCurrentTemp.enty[i].fracytwo >> theCurrentTemp.enty[i].fracxtwo;
                        //                      theCurrentTemp.enty[i].qbfrac[3] = 1. - theCurrentTemp.enty[i].qbfrac[0] - theCurrentTemp.enty[i].qbfrac[1] - theCurrentTemp.enty[i].qbfrac[2];
                        
                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 16, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                }
                
                // next, loop over all barrel x-angle entries   
                
                for (k=0; k < theCurrentTemp.head.NTyx; ++k) { 
                        
                        for (i=0; i < theCurrentTemp.head.NTxx; ++i) { 
                                
                                db >> theCurrentTemp.entx[k][i].runnum >> theCurrentTemp.entx[k][i].costrk[0] 
                                >> theCurrentTemp.entx[k][i].costrk[1] >> theCurrentTemp.entx[k][i].costrk[2]; 
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 17, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                // Calculate the alpha, beta, and cot(beta) for this entry 
                                
                                theCurrentTemp.entx[k][i].alpha = static_cast<float>(atan2((double)theCurrentTemp.entx[k][i].costrk[2], (double)theCurrentTemp.entx[k][i].costrk[0]));
                                
                                theCurrentTemp.entx[k][i].cotalpha = theCurrentTemp.entx[k][i].costrk[0]/theCurrentTemp.entx[k][i].costrk[2];
                                
                                theCurrentTemp.entx[k][i].beta = static_cast<float>(atan2((double)theCurrentTemp.entx[k][i].costrk[2], (double)theCurrentTemp.entx[k][i].costrk[1]));
                                
                                theCurrentTemp.entx[k][i].cotbeta = theCurrentTemp.entx[k][i].costrk[1]/theCurrentTemp.entx[k][i].costrk[2];
                                
                                db >> theCurrentTemp.entx[k][i].qavg >> theCurrentTemp.entx[k][i].pixmax >> theCurrentTemp.entx[k][i].symax >> theCurrentTemp.entx[k][i].dyone
                                >> theCurrentTemp.entx[k][i].syone >> theCurrentTemp.entx[k][i].sxmax >> theCurrentTemp.entx[k][i].dxone >> theCurrentTemp.entx[k][i].sxone;
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 18, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                db >> theCurrentTemp.entx[k][i].dytwo >> theCurrentTemp.entx[k][i].sytwo >> theCurrentTemp.entx[k][i].dxtwo 
                                >> theCurrentTemp.entx[k][i].sxtwo >> theCurrentTemp.entx[k][i].qmin >> theCurrentTemp.entx[k][i].clsleny >> theCurrentTemp.entx[k][i].clslenx;
                                //                     >> theCurrentTemp.entx[k][i].mpvvav >> theCurrentTemp.entx[k][i].sigmavav >> theCurrentTemp.entx[k][i].kappavav;
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 19, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                for (j=0; j<2; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].ypar[j][0] >> theCurrentTemp.entx[k][i].ypar[j][1] 
                                        >> theCurrentTemp.entx[k][i].ypar[j][2] >> theCurrentTemp.entx[k][i].ypar[j][3] >> theCurrentTemp.entx[k][i].ypar[j][4];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 20, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<9; ++j) {
                                        
                                        for (l=0; l<TYSIZE; ++l) {db >> theCurrentTemp.entx[k][i].ytemp[j][l];} 
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 21, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<2; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].xpar[j][0] >> theCurrentTemp.entx[k][i].xpar[j][1] 
                                        >> theCurrentTemp.entx[k][i].xpar[j][2] >> theCurrentTemp.entx[k][i].xpar[j][3] >> theCurrentTemp.entx[k][i].xpar[j][4];
                                        
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 22, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                qavg_avg = 0.f;
                                for (j=0; j<9; ++j) {
                                        
                                        for (l=0; l<TXSIZE; ++l) {db >> theCurrentTemp.entx[k][i].xtemp[j][l]; qavg_avg += theCurrentTemp.entx[k][i].xtemp[j][l];} 
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 23, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                theCurrentTemp.entx[k][i].qavg_avg = qavg_avg/9.;
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].yavg[j] >> theCurrentTemp.entx[k][i].yrms[j] >> theCurrentTemp.entx[k][i].ygx0[j] >> theCurrentTemp.entx[k][i].ygsig[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 24, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].yflpar[j][0] >> theCurrentTemp.entx[k][i].yflpar[j][1] >> theCurrentTemp.entx[k][i].yflpar[j][2] 
                                        >> theCurrentTemp.entx[k][i].yflpar[j][3] >> theCurrentTemp.entx[k][i].yflpar[j][4] >> theCurrentTemp.entx[k][i].yflpar[j][5];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 25, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].xavg[j] >> theCurrentTemp.entx[k][i].xrms[j] >> theCurrentTemp.entx[k][i].xgx0[j] >> theCurrentTemp.entx[k][i].xgsig[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 26, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].xflpar[j][0] >> theCurrentTemp.entx[k][i].xflpar[j][1] >> theCurrentTemp.entx[k][i].xflpar[j][2] 
                                        >> theCurrentTemp.entx[k][i].xflpar[j][3] >> theCurrentTemp.entx[k][i].xflpar[j][4] >> theCurrentTemp.entx[k][i].xflpar[j][5];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 27, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].chi2yavg[j] >> theCurrentTemp.entx[k][i].chi2ymin[j] >> theCurrentTemp.entx[k][i].chi2xavg[j] >> theCurrentTemp.entx[k][i].chi2xmin[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 28, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].yavgc2m[j] >> theCurrentTemp.entx[k][i].yrmsc2m[j] >> theCurrentTemp.entx[k][i].chi2yavgc2m[j] >> theCurrentTemp.entx[k][i].chi2yminc2m[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 29, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].xavgc2m[j] >> theCurrentTemp.entx[k][i].xrmsc2m[j] >> theCurrentTemp.entx[k][i].chi2xavgc2m[j] >> theCurrentTemp.entx[k][i].chi2xminc2m[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].yavggen[j] >> theCurrentTemp.entx[k][i].yrmsgen[j] >> theCurrentTemp.entx[k][i].ygx0gen[j] >> theCurrentTemp.entx[k][i].ygsiggen[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30a, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        db >> theCurrentTemp.entx[k][i].xavggen[j] >> theCurrentTemp.entx[k][i].xrmsgen[j] >> theCurrentTemp.entx[k][i].xgx0gen[j] >> theCurrentTemp.entx[k][i].xgsiggen[j];
                                        
                                        if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30b, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                
                                db >> theCurrentTemp.entx[k][i].chi2yavgone >> theCurrentTemp.entx[k][i].chi2yminone >> theCurrentTemp.entx[k][i].chi2xavgone >> theCurrentTemp.entx[k][i].chi2xminone >> theCurrentTemp.entx[k][i].qmin2
                                >> theCurrentTemp.entx[k][i].mpvvav >> theCurrentTemp.entx[k][i].sigmavav >> theCurrentTemp.entx[k][i].kappavav >> theCurrentTemp.entx[k][i].qavg_spare >> theCurrentTemp.entx[k][i].spare[0];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 31, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                db >> theCurrentTemp.entx[k][i].mpvvav2 >> theCurrentTemp.entx[k][i].sigmavav2 >> theCurrentTemp.entx[k][i].kappavav2 >> theCurrentTemp.entx[k][i].qbfrac[0] >> theCurrentTemp.entx[k][i].qbfrac[1]
                                >> theCurrentTemp.entx[k][i].qbfrac[2] >> theCurrentTemp.entx[k][i].fracyone >> theCurrentTemp.entx[k][i].fracxone >> theCurrentTemp.entx[k][i].fracytwo >> theCurrentTemp.entx[k][i].fracxtwo;
                                //                              theCurrentTemp.entx[k][i].qbfrac[3] = 1. - theCurrentTemp.entx[k][i].qbfrac[0] - theCurrentTemp.entx[k][i].qbfrac[1] - theCurrentTemp.entx[k][i].qbfrac[2];
                                
                                if(db.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 32, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                        }
                }       
                
                
                // Add this template to the store
                
                thePixelTemp_.push_back(theCurrentTemp);
                
        }
        return true;
        
} // TempInit 
bool SiPixelTemplate::pushfile ( int  filenum)

This routine initializes the global template structures from an external file template_summary_zpNNNN where NNNN are four digits of filenum.

Parameters:
filenum- an integer NNNN used in the filename template_summary_zpNNNN

Definition at line 115 of file SiPixelTemplate.cc.

References SiPixelTemplateEntry::alpha, SiPixelTemplateEntry::beta, SiPixelTemplateHeader::Bfield, trackerHits::c, SiPixelTemplateEntry::chi2xavg, SiPixelTemplateEntry::chi2xavgc2m, SiPixelTemplateEntry::chi2xavgone, SiPixelTemplateEntry::chi2xmin, SiPixelTemplateEntry::chi2xminc2m, SiPixelTemplateEntry::chi2xminone, SiPixelTemplateEntry::chi2yavg, SiPixelTemplateEntry::chi2yavgc2m, SiPixelTemplateEntry::chi2yavgone, SiPixelTemplateEntry::chi2ymin, SiPixelTemplateEntry::chi2yminc2m, SiPixelTemplateEntry::chi2yminone, SiPixelTemplateEntry::clslenx, SiPixelTemplateEntry::clsleny, SiPixelTemplateEntry::costrk, SiPixelTemplateEntry::cotalpha, SiPixelTemplateEntry::cotbeta, SiPixelTemplateHeader::Dtype, SiPixelTemplateEntry::dxone, SiPixelTemplateEntry::dxtwo, SiPixelTemplateEntry::dyone, SiPixelTemplateEntry::dytwo, ENDL, SiPixelTemplateStore::entx, SiPixelTemplateStore::enty, mergeVDriftHistosByStation::file, SiPixelTemplateHeader::fluence, SiPixelTemplateEntry::fracxone, SiPixelTemplateEntry::fracxtwo, SiPixelTemplateEntry::fracyone, SiPixelTemplateEntry::fracytwo, SiPixelTemplateStore::head, i, SiPixelTemplateHeader::ID, recoMuon::in, j, gen::k, SiPixelTemplateEntry::kappavav, SiPixelTemplateEntry::kappavav2, prof2calltree::l, LOGERROR, LOGINFO, SiPixelTemplateHeader::lorxwidth, SiPixelTemplateHeader::lorywidth, SiPixelTemplateEntry::mpvvav, SiPixelTemplateEntry::mpvvav2, SiPixelTemplateHeader::NTxx, SiPixelTemplateHeader::NTy, SiPixelTemplateHeader::NTyx, SiPixelTemplateEntry::pixmax, SiPixelTemplateEntry::qavg, SiPixelTemplateEntry::qavg_avg, SiPixelTemplateEntry::qavg_spare, SiPixelTemplateEntry::qbfrac, SiPixelTemplateEntry::qmin, SiPixelTemplateEntry::qmin2, SiPixelTemplateHeader::qscale, SiPixelTemplateEntry::runnum, SiPixelTemplateHeader::s50, SiPixelTemplateEntry::sigmavav, SiPixelTemplateEntry::sigmavav2, SiPixelTemplateEntry::spare, SiPixelTemplateEntry::sxmax, SiPixelTemplateEntry::sxone, SiPixelTemplateEntry::sxtwo, SiPixelTemplateEntry::symax, SiPixelTemplateEntry::syone, SiPixelTemplateEntry::sytwo, SiPixelTemplateHeader::temperature, SiPixelTemplateHeader::templ_version, SiPixelTemplateHeader::title, TXSIZE, TYSIZE, SiPixelTemplateHeader::Vbias, SiPixelTemplateEntry::xavg, SiPixelTemplateEntry::xavgc2m, SiPixelTemplateEntry::xavggen, SiPixelTemplateEntry::xflpar, SiPixelTemplateEntry::xgsig, SiPixelTemplateEntry::xgsiggen, SiPixelTemplateEntry::xgx0, SiPixelTemplateEntry::xgx0gen, SiPixelTemplateEntry::xpar, SiPixelTemplateEntry::xrms, SiPixelTemplateEntry::xrmsc2m, SiPixelTemplateEntry::xrmsgen, SiPixelTemplateHeader::xsize, SiPixelTemplateEntry::xtemp, SiPixelTemplateEntry::yavg, SiPixelTemplateEntry::yavgc2m, SiPixelTemplateEntry::yavggen, SiPixelTemplateEntry::yflpar, SiPixelTemplateEntry::ygsig, SiPixelTemplateEntry::ygsiggen, SiPixelTemplateEntry::ygx0, SiPixelTemplateEntry::ygx0gen, SiPixelTemplateEntry::ypar, SiPixelTemplateEntry::yrms, SiPixelTemplateEntry::yrmsc2m, SiPixelTemplateEntry::yrmsgen, SiPixelTemplateHeader::ysize, SiPixelTemplateEntry::ytemp, and SiPixelTemplateHeader::zsize.

Referenced by PixelCPEGeneric::PixelCPEGeneric(), PixelCPETemplateReco::PixelCPETemplateReco(), SiPixelGaussianSmearingRecHitConverterAlgorithm::SiPixelGaussianSmearingRecHitConverterAlgorithm(), and TrackClusterSplitter::TrackClusterSplitter().

{
    // Add template stored in external file numbered filenum to theTemplateStore
    
    // Local variables 
    int i, j, k, l;
        float qavg_avg;
        const char *tempfile;
        //      char title[80]; remove this
    char c;
        const int code_version={17};
        
        
        
        //  Create a filename for this run 
        
        std::ostringstream tout;
        
        //  Create different path in CMSSW than standalone
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        tout << "CalibTracker/SiPixelESProducers/data/template_summary_zp" 
        << std::setw(4) << std::setfill('0') << std::right << filenum << ".out" << std::ends;
        std::string tempf = tout.str();
        edm::FileInPath file( tempf.c_str() );
        tempfile = (file.fullPath()).c_str();
#else
        tout << "template_summary_zp" << std::setw(4) << std::setfill('0') << std::right << filenum << ".out" << std::ends;
        std::string tempf = tout.str();
        tempfile = tempf.c_str();
#endif
        
        //  open the template file 
        
        std::ifstream in_file(tempfile, std::ios::in);
        
        if(in_file.is_open()) {
                
                // Create a local template storage entry
                
                SiPixelTemplateStore theCurrentTemp;
                
                // Read-in a header string first and print it    
                
                for (i=0; (c=in_file.get()) != '\n'; ++i) {
                        if(i < 79) {theCurrentTemp.head.title[i] = c;}
                }
                if(i > 78) {i=78;}
                theCurrentTemp.head.title[i+1] ='\0';
                LOGINFO("SiPixelTemplate") << "Loading Pixel Template File - " << theCurrentTemp.head.title << ENDL;
                
                // next, the header information     
                
                in_file >> theCurrentTemp.head.ID  >> theCurrentTemp.head.templ_version >> theCurrentTemp.head.Bfield >> theCurrentTemp.head.NTy >> theCurrentTemp.head.NTyx >> theCurrentTemp.head.NTxx
                >> theCurrentTemp.head.Dtype >> theCurrentTemp.head.Vbias >> theCurrentTemp.head.temperature >> theCurrentTemp.head.fluence >> theCurrentTemp.head.qscale
                >> theCurrentTemp.head.s50 >> theCurrentTemp.head.lorywidth >> theCurrentTemp.head.lorxwidth >> theCurrentTemp.head.ysize >> theCurrentTemp.head.xsize >> theCurrentTemp.head.zsize;
                
                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file, no template load" << ENDL; return false;}
                
                LOGINFO("SiPixelTemplate") << "Template ID = " << theCurrentTemp.head.ID << ", Template Version " << theCurrentTemp.head.templ_version << ", Bfield = " << theCurrentTemp.head.Bfield 
                << ", NTy = " << theCurrentTemp.head.NTy << ", NTyx = " << theCurrentTemp.head.NTyx<< ", NTxx = " << theCurrentTemp.head.NTxx << ", Dtype = " << theCurrentTemp.head.Dtype
                << ", Bias voltage " << theCurrentTemp.head.Vbias << ", temperature "
                << theCurrentTemp.head.temperature << ", fluence " << theCurrentTemp.head.fluence << ", Q-scaling factor " << theCurrentTemp.head.qscale
                << ", 1/2 threshold " << theCurrentTemp.head.s50 << ", y Lorentz Width " << theCurrentTemp.head.lorywidth << ", x Lorentz width " << theCurrentTemp.head.lorxwidth    
                << ", pixel x-size " << theCurrentTemp.head.xsize << ", y-size " << theCurrentTemp.head.ysize << ", zsize " << theCurrentTemp.head.zsize << ENDL;
                
                if(theCurrentTemp.head.templ_version < code_version) {LOGERROR("SiPixelTemplate") << "code expects version " << code_version << ", no template load" << ENDL; return false;}
                
#ifdef SI_PIXEL_TEMPLATE_USE_BOOST 
                
// next, layout the 1-d/2-d structures needed to store template
                                
                theCurrentTemp.enty.resize(boost::extents[theCurrentTemp.head.NTy]);

                theCurrentTemp.entx.resize(boost::extents[theCurrentTemp.head.NTyx][theCurrentTemp.head.NTxx]);
                
#endif
                
// next, loop over all y-angle entries   
                
                for (i=0; i < theCurrentTemp.head.NTy; ++i) {     
                        
                        in_file >> theCurrentTemp.enty[i].runnum >> theCurrentTemp.enty[i].costrk[0] 
                        >> theCurrentTemp.enty[i].costrk[1] >> theCurrentTemp.enty[i].costrk[2]; 
                        
                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 1, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        // Calculate the alpha, beta, and cot(beta) for this entry 
                        
                        theCurrentTemp.enty[i].alpha = static_cast<float>(atan2((double)theCurrentTemp.enty[i].costrk[2], (double)theCurrentTemp.enty[i].costrk[0]));
                        
                        theCurrentTemp.enty[i].cotalpha = theCurrentTemp.enty[i].costrk[0]/theCurrentTemp.enty[i].costrk[2];
                        
                        theCurrentTemp.enty[i].beta = static_cast<float>(atan2((double)theCurrentTemp.enty[i].costrk[2], (double)theCurrentTemp.enty[i].costrk[1]));
                        
                        theCurrentTemp.enty[i].cotbeta = theCurrentTemp.enty[i].costrk[1]/theCurrentTemp.enty[i].costrk[2];
                        
                        in_file >> theCurrentTemp.enty[i].qavg >> theCurrentTemp.enty[i].pixmax >> theCurrentTemp.enty[i].symax >> theCurrentTemp.enty[i].dyone
                        >> theCurrentTemp.enty[i].syone >> theCurrentTemp.enty[i].sxmax >> theCurrentTemp.enty[i].dxone >> theCurrentTemp.enty[i].sxone;
                        
                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 2, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        in_file >> theCurrentTemp.enty[i].dytwo >> theCurrentTemp.enty[i].sytwo >> theCurrentTemp.enty[i].dxtwo 
                        >> theCurrentTemp.enty[i].sxtwo >> theCurrentTemp.enty[i].qmin >> theCurrentTemp.enty[i].clsleny >> theCurrentTemp.enty[i].clslenx;
                        
                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 3, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        for (j=0; j<2; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].ypar[j][0] >> theCurrentTemp.enty[i].ypar[j][1] 
                                >> theCurrentTemp.enty[i].ypar[j][2] >> theCurrentTemp.enty[i].ypar[j][3] >> theCurrentTemp.enty[i].ypar[j][4];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 4, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                                
                        }
                        
                        for (j=0; j<9; ++j) {
                                
                                for (k=0; k<TYSIZE; ++k) {in_file >> theCurrentTemp.enty[i].ytemp[j][k];}
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 5, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<2; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].xpar[j][0] >> theCurrentTemp.enty[i].xpar[j][1] 
                                >> theCurrentTemp.enty[i].xpar[j][2] >> theCurrentTemp.enty[i].xpar[j][3] >> theCurrentTemp.enty[i].xpar[j][4];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 6, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                                
                        }
                        
                        qavg_avg = 0.f;
                        for (j=0; j<9; ++j) {
                                
                                for (k=0; k<TXSIZE; ++k) {in_file >> theCurrentTemp.enty[i].xtemp[j][k]; qavg_avg += theCurrentTemp.enty[i].xtemp[j][k];} 
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 7, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        theCurrentTemp.enty[i].qavg_avg = qavg_avg/9.;
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].yavg[j] >> theCurrentTemp.enty[i].yrms[j] >> theCurrentTemp.enty[i].ygx0[j] >> theCurrentTemp.enty[i].ygsig[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 8, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].yflpar[j][0] >> theCurrentTemp.enty[i].yflpar[j][1] >> theCurrentTemp.enty[i].yflpar[j][2] 
                                >> theCurrentTemp.enty[i].yflpar[j][3] >> theCurrentTemp.enty[i].yflpar[j][4] >> theCurrentTemp.enty[i].yflpar[j][5];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 9, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].xavg[j] >> theCurrentTemp.enty[i].xrms[j] >> theCurrentTemp.enty[i].xgx0[j] >> theCurrentTemp.enty[i].xgsig[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 10, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].xflpar[j][0] >> theCurrentTemp.enty[i].xflpar[j][1] >> theCurrentTemp.enty[i].xflpar[j][2] 
                                >> theCurrentTemp.enty[i].xflpar[j][3] >> theCurrentTemp.enty[i].xflpar[j][4] >> theCurrentTemp.enty[i].xflpar[j][5];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 11, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].chi2yavg[j] >> theCurrentTemp.enty[i].chi2ymin[j] >> theCurrentTemp.enty[i].chi2xavg[j] >> theCurrentTemp.enty[i].chi2xmin[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 12, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].yavgc2m[j] >> theCurrentTemp.enty[i].yrmsc2m[j] >> theCurrentTemp.enty[i].chi2yavgc2m[j] >> theCurrentTemp.enty[i].chi2yminc2m[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 13, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].xavgc2m[j] >> theCurrentTemp.enty[i].xrmsc2m[j] >> theCurrentTemp.enty[i].chi2xavgc2m[j] >> theCurrentTemp.enty[i].chi2xminc2m[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        } 
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].yavggen[j] >> theCurrentTemp.enty[i].yrmsgen[j] >> theCurrentTemp.enty[i].ygx0gen[j] >> theCurrentTemp.enty[i].ygsiggen[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14a, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        }
                        
                        for (j=0; j<4; ++j) {
                                
                                in_file >> theCurrentTemp.enty[i].xavggen[j] >> theCurrentTemp.enty[i].xrmsgen[j] >> theCurrentTemp.enty[i].xgx0gen[j] >> theCurrentTemp.enty[i].xgsiggen[j];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 14b, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        } 
                        
                        in_file >> theCurrentTemp.enty[i].chi2yavgone >> theCurrentTemp.enty[i].chi2yminone >> theCurrentTemp.enty[i].chi2xavgone >> theCurrentTemp.enty[i].chi2xminone >> theCurrentTemp.enty[i].qmin2
                        >> theCurrentTemp.enty[i].mpvvav >> theCurrentTemp.enty[i].sigmavav >> theCurrentTemp.enty[i].kappavav >> theCurrentTemp.enty[i].qavg_spare >> theCurrentTemp.enty[i].spare[0];
                        
                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 15, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                        in_file >> theCurrentTemp.enty[i].mpvvav2 >> theCurrentTemp.enty[i].sigmavav2 >> theCurrentTemp.enty[i].kappavav2 >> theCurrentTemp.enty[i].qbfrac[0] >> theCurrentTemp.enty[i].qbfrac[1]
                        >> theCurrentTemp.enty[i].qbfrac[2] >> theCurrentTemp.enty[i].fracyone >> theCurrentTemp.enty[i].fracxone >> theCurrentTemp.enty[i].fracytwo >> theCurrentTemp.enty[i].fracxtwo;
                        //              theCurrentTemp.enty[i].qbfrac[3] = 1. - theCurrentTemp.enty[i].qbfrac[0] - theCurrentTemp.enty[i].qbfrac[1] - theCurrentTemp.enty[i].qbfrac[2];
                        
                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 16, no template load, run # " << theCurrentTemp.enty[i].runnum << ENDL; return false;}
                        
                }
                
                // next, loop over all barrel x-angle entries   
                
                for (k=0; k < theCurrentTemp.head.NTyx; ++k) { 
                        
                        for (i=0; i < theCurrentTemp.head.NTxx; ++i) { 
                                
                                in_file >> theCurrentTemp.entx[k][i].runnum >> theCurrentTemp.entx[k][i].costrk[0] 
                                >> theCurrentTemp.entx[k][i].costrk[1] >> theCurrentTemp.entx[k][i].costrk[2]; 
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 17, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                // Calculate the alpha, beta, and cot(beta) for this entry 
                                
                                theCurrentTemp.entx[k][i].alpha = static_cast<float>(atan2((double)theCurrentTemp.entx[k][i].costrk[2], (double)theCurrentTemp.entx[k][i].costrk[0]));
                                
                                theCurrentTemp.entx[k][i].cotalpha = theCurrentTemp.entx[k][i].costrk[0]/theCurrentTemp.entx[k][i].costrk[2];
                                
                                theCurrentTemp.entx[k][i].beta = static_cast<float>(atan2((double)theCurrentTemp.entx[k][i].costrk[2], (double)theCurrentTemp.entx[k][i].costrk[1]));
                                
                                theCurrentTemp.entx[k][i].cotbeta = theCurrentTemp.entx[k][i].costrk[1]/theCurrentTemp.entx[k][i].costrk[2];
                                
                                in_file >> theCurrentTemp.entx[k][i].qavg >> theCurrentTemp.entx[k][i].pixmax >> theCurrentTemp.entx[k][i].symax >> theCurrentTemp.entx[k][i].dyone
                                >> theCurrentTemp.entx[k][i].syone >> theCurrentTemp.entx[k][i].sxmax >> theCurrentTemp.entx[k][i].dxone >> theCurrentTemp.entx[k][i].sxone;
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 18, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                in_file >> theCurrentTemp.entx[k][i].dytwo >> theCurrentTemp.entx[k][i].sytwo >> theCurrentTemp.entx[k][i].dxtwo 
                                >> theCurrentTemp.entx[k][i].sxtwo >> theCurrentTemp.entx[k][i].qmin >> theCurrentTemp.entx[k][i].clsleny >> theCurrentTemp.entx[k][i].clslenx;
                                //                         >> theCurrentTemp.entx[k][i].mpvvav >> theCurrentTemp.entx[k][i].sigmavav >> theCurrentTemp.entx[k][i].kappavav;
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 19, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                for (j=0; j<2; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].ypar[j][0] >> theCurrentTemp.entx[k][i].ypar[j][1] 
                                        >> theCurrentTemp.entx[k][i].ypar[j][2] >> theCurrentTemp.entx[k][i].ypar[j][3] >> theCurrentTemp.entx[k][i].ypar[j][4];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 20, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<9; ++j) {
                                        
                                        for (l=0; l<TYSIZE; ++l) {in_file >> theCurrentTemp.entx[k][i].ytemp[j][l];} 
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 21, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<2; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].xpar[j][0] >> theCurrentTemp.entx[k][i].xpar[j][1] 
                                        >> theCurrentTemp.entx[k][i].xpar[j][2] >> theCurrentTemp.entx[k][i].xpar[j][3] >> theCurrentTemp.entx[k][i].xpar[j][4];
                                        
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 22, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                qavg_avg = 0.f;
                                for (j=0; j<9; ++j) {
                                        
                                        for (l=0; l<TXSIZE; ++l) {in_file >> theCurrentTemp.entx[k][i].xtemp[j][l]; qavg_avg += theCurrentTemp.entx[k][i].xtemp[j][l];} 
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 23, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                theCurrentTemp.entx[k][i].qavg_avg = qavg_avg/9.;
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].yavg[j] >> theCurrentTemp.entx[k][i].yrms[j] >> theCurrentTemp.entx[k][i].ygx0[j] >> theCurrentTemp.entx[k][i].ygsig[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 24, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].yflpar[j][0] >> theCurrentTemp.entx[k][i].yflpar[j][1] >> theCurrentTemp.entx[k][i].yflpar[j][2] 
                                        >> theCurrentTemp.entx[k][i].yflpar[j][3] >> theCurrentTemp.entx[k][i].yflpar[j][4] >> theCurrentTemp.entx[k][i].yflpar[j][5];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 25, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].xavg[j] >> theCurrentTemp.entx[k][i].xrms[j] >> theCurrentTemp.entx[k][i].xgx0[j] >> theCurrentTemp.entx[k][i].xgsig[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 26, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].xflpar[j][0] >> theCurrentTemp.entx[k][i].xflpar[j][1] >> theCurrentTemp.entx[k][i].xflpar[j][2] 
                                        >> theCurrentTemp.entx[k][i].xflpar[j][3] >> theCurrentTemp.entx[k][i].xflpar[j][4] >> theCurrentTemp.entx[k][i].xflpar[j][5];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 27, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].chi2yavg[j] >> theCurrentTemp.entx[k][i].chi2ymin[j] >> theCurrentTemp.entx[k][i].chi2xavg[j] >> theCurrentTemp.entx[k][i].chi2xmin[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 28, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].yavgc2m[j] >> theCurrentTemp.entx[k][i].yrmsc2m[j] >> theCurrentTemp.entx[k][i].chi2yavgc2m[j] >> theCurrentTemp.entx[k][i].chi2yminc2m[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 29, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].xavgc2m[j] >> theCurrentTemp.entx[k][i].xrmsc2m[j] >> theCurrentTemp.entx[k][i].chi2xavgc2m[j] >> theCurrentTemp.entx[k][i].chi2xminc2m[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].yavggen[j] >> theCurrentTemp.entx[k][i].yrmsgen[j] >> theCurrentTemp.entx[k][i].ygx0gen[j] >> theCurrentTemp.entx[k][i].ygsiggen[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30a, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                for (j=0; j<4; ++j) {
                                        
                                        in_file >> theCurrentTemp.entx[k][i].xavggen[j] >> theCurrentTemp.entx[k][i].xrmsgen[j] >> theCurrentTemp.entx[k][i].xgx0gen[j] >> theCurrentTemp.entx[k][i].xgsiggen[j];
                                        
                                        if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 30b, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                }
                                
                                in_file >> theCurrentTemp.entx[k][i].chi2yavgone >> theCurrentTemp.entx[k][i].chi2yminone >> theCurrentTemp.entx[k][i].chi2xavgone >> theCurrentTemp.entx[k][i].chi2xminone >> theCurrentTemp.entx[k][i].qmin2
                                >> theCurrentTemp.entx[k][i].mpvvav >> theCurrentTemp.entx[k][i].sigmavav >> theCurrentTemp.entx[k][i].kappavav >> theCurrentTemp.entx[k][i].qavg_spare >> theCurrentTemp.entx[k][i].spare[0];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 31, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                                in_file >> theCurrentTemp.entx[k][i].mpvvav2 >> theCurrentTemp.entx[k][i].sigmavav2 >> theCurrentTemp.entx[k][i].kappavav2 >> theCurrentTemp.entx[k][i].qbfrac[0] >> theCurrentTemp.entx[k][i].qbfrac[1]
                                >> theCurrentTemp.entx[k][i].qbfrac[2] >> theCurrentTemp.entx[k][i].fracyone >> theCurrentTemp.entx[k][i].fracxone >> theCurrentTemp.entx[k][i].fracytwo >> theCurrentTemp.entx[k][i].fracxtwo;
                                //              theCurrentTemp.entx[k][i].qbfrac[3] = 1. - theCurrentTemp.entx[k][i].qbfrac[0] - theCurrentTemp.entx[k][i].qbfrac[1] - theCurrentTemp.entx[k][i].qbfrac[2];
                                
                                if(in_file.fail()) {LOGERROR("SiPixelTemplate") << "Error reading file 32, no template load, run # " << theCurrentTemp.entx[k][i].runnum << ENDL; return false;}
                                
                        }
                }       
                
                
                in_file.close();
                
                // Add this template to the store
                
                thePixelTemp_.push_back(theCurrentTemp);
                
                return true;
                
        } else {
                
                // If file didn't open, report this
                
                LOGERROR("SiPixelTemplate") << "Error opening File" << tempfile << ENDL;
                return false;
                
        }
        
} // TempInit 
float SiPixelTemplate::qavg ( ) [inline]

average cluster charge for this set of track angles

Definition at line 301 of file SiPixelTemplate.h.

References qavg_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

int SiPixelTemplate::qbin ( int  id,
float  cotalpha,
float  cotbeta,
float  locBz,
float  qclus,
float &  pixmx,
float &  sigmay,
float &  deltay,
float &  sigmax,
float &  deltax,
float &  sy1,
float &  dy1,
float &  sy2,
float &  dy2,
float &  sx1,
float &  dx1,
float &  sx2,
float &  dx2 
)

Interpolate beta/alpha angles to produce an expected average charge. Return int (0-4) describing the charge of the cluster [0: 1.5<Q/Qavg, 1: 1<Q/Qavg<1.5, 2: 0.85<Q/Qavg<1, 3: 0.95Qmin<Q<0.85Qavg, 4: Q<0.95Qmin].

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
locBz- (input) the sign of this quantity is used to determine whether to flip cot(beta)<0 quantities from cot(beta)>0 (FPix only) for FPix IP-related tracks, locBz < 0 for cot(beta) > 0 and locBz > 0 for cot(beta) < 0
qclus- (input) the cluster charge in electrons
pixmax- (output) the maximum pixel charge in electrons (truncation value)
sigmay- (output) the estimated y-error for CPEGeneric in microns
deltay- (output) the estimated y-bias for CPEGeneric in microns
sigmax- (output) the estimated x-error for CPEGeneric in microns
deltax- (output) the estimated x-bias for CPEGeneric in microns
sy1- (output) the estimated y-error for 1 single-pixel clusters in microns
dy1- (output) the estimated y-bias for 1 single-pixel clusters in microns
sy2- (output) the estimated y-error for 1 double-pixel clusters in microns
dy2- (output) the estimated y-bias for 1 double-pixel clusters in microns
sx1- (output) the estimated x-error for 1 single-pixel clusters in microns
dx1- (output) the estimated x-bias for 1 single-pixel clusters in microns
sx2- (output) the estimated x-error for 1 double-pixel clusters in microns
dx2- (output) the estimated x-bias for 1 double-pixel clusters in microns

Definition at line 2421 of file SiPixelTemplate.cc.

References qbin().

{
        float lorywidth, lorxwidth;
        return SiPixelTemplate::qbin(id, cotalpha, cotbeta, locBz, qclus, pixmx, sigmay, deltay, sigmax, deltax, 
                                                                 sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, lorywidth, lorxwidth);
        
} // qbin
int SiPixelTemplate::qbin ( int  id,
float  cotalpha,
float  cotbeta,
float  qclus 
)

Interpolate beta/alpha angles to produce an expected average charge. Return int (0-4) describing the charge of the cluster [0: 1.5<Q/Qavg, 1: 1<Q/Qavg<1.5, 2: 0.85<Q/Qavg<1, 3: 0.95Qmin<Q<0.85Qavg, 4: Q<0.95Qmin].

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
qclus- (input) the cluster charge in electrons

Definition at line 2439 of file SiPixelTemplate.cc.

References f, and qbin().

{
        // Interpolate for a new set of track angles 
        
        // Local variables 
        float pixmx, sigmay, deltay, sigmax, deltax, sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, locBz, lorywidth, lorxwidth;
        locBz = -1.f;
        if(cotbeta < 0.f) {locBz = -locBz;}
        return SiPixelTemplate::qbin(id, cotalpha, cotbeta, locBz, qclus, pixmx, sigmay, deltay, sigmax, deltax, 
                                                                                  sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, lorywidth, lorxwidth);
        
} // qbin
int SiPixelTemplate::qbin ( int  id,
float  cotbeta,
float  qclus 
)

Interpolate beta/alpha angles to produce an expected average charge. Return int (0-4) describing the charge of the cluster [0: 1.5<Q/Qavg, 1: 1<Q/Qavg<1.5, 2: 0.85<Q/Qavg<1, 3: 0.95Qmin<Q<0.85Qavg, 4: Q<0.95Qmin].

Parameters:
id- (input) index of the template to use
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
qclus- (input) the cluster charge in electrons

Definition at line 2459 of file SiPixelTemplate.cc.

References f, and qbin().

{
// Interpolate for a new set of track angles 
                                
// Local variables 
        float pixmx, sigmay, deltay, sigmax, deltax, sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, locBz, lorywidth, lorxwidth;
        const float cotalpha = 0.f;
        locBz = -1.f;
        if(cotbeta < 0.f) {locBz = -locBz;}
        return SiPixelTemplate::qbin(id, cotalpha, cotbeta, locBz, qclus, pixmx, sigmay, deltay, sigmax, deltax, 
                                                                sy1, dy1, sy2, dy2, sx1, dx1, sx2, dx2, lorywidth, lorxwidth);
                                
} // qbin
int SiPixelTemplate::qbin ( int  id,
float  cotalpha,
float  cotbeta,
float  locBz,
float  qclus,
float &  pixmx,
float &  sigmay,
float &  deltay,
float &  sigmax,
float &  deltax,
float &  sy1,
float &  dy1,
float &  sy2,
float &  dy2,
float &  sx1,
float &  dx1,
float &  sx2,
float &  dx2,
float &  lorywidth,
float &  lorxwidth 
)

Interpolate beta/alpha angles to produce an expected average charge. Return int (0-4) describing the charge of the cluster [0: 1.5<Q/Qavg, 1: 1<Q/Qavg<1.5, 2: 0.85<Q/Qavg<1, 3: 0.95Qmin<Q<0.85Qavg, 4: Q<0.95Qmin].

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
locBz- (input) the sign of this quantity is used to determine whether to flip cot(beta)<0 quantities from cot(beta)>0 (FPix only) for FPix IP-related tracks, locBz < 0 for cot(beta) > 0 and locBz > 0 for cot(beta) < 0
qclus- (input) the cluster charge in electrons
pixmax- (output) the maximum pixel charge in electrons (truncation value)
sigmay- (output) the estimated y-error for CPEGeneric in microns
deltay- (output) the estimated y-bias for CPEGeneric in microns
sigmax- (output) the estimated x-error for CPEGeneric in microns
deltax- (output) the estimated x-bias for CPEGeneric in microns
sy1- (output) the estimated y-error for 1 single-pixel clusters in microns
dy1- (output) the estimated y-bias for 1 single-pixel clusters in microns
sy2- (output) the estimated y-error for 1 double-pixel clusters in microns
dy2- (output) the estimated y-bias for 1 double-pixel clusters in microns
sx1- (output) the estimated x-error for 1 single-pixel clusters in microns
dx1- (output) the estimated x-bias for 1 single-pixel clusters in microns
sx2- (output) the estimated x-error for 1 double-pixel clusters in microns
dx2- (output) the estimated x-bias for 1 double-pixel clusters in microns
lorywidth- (output) the estimated y Lorentz width
lorxwidth- (output) the estimated x Lorentz width

Definition at line 2149 of file SiPixelTemplate.cc.

References Exception, f, i, getHLTprescales::index, and mathSSE::sqrt().

Referenced by PixelCPEGeneric::localPosition(), qbin(), and TrackClusterSplitter::splitCluster().

{
    // Interpolate for a new set of track angles 
    
    // Local variables 
    int i, binq;
        int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, index;
        float yratio, yxratio, xxratio;
        float acotb, qscale, qavg, qmin, qmin2, fq, qtotal, qcorrect, cotb, cotalpha0;
        float yavggen[4], yrmsgen[4], xavggen[4], xrmsgen[4];
        bool flip_y;
        

// Find the index corresponding to id

       index = -1;
       for(i=0; i<(int)thePixelTemp_.size(); ++i) {
        
              if(id == thePixelTemp_[i].head.ID) {
           
                 index = i;
                     break;
          }
            }
         
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
           if(index < 0 || index >= (int)thePixelTemp_.size()) {
              throw cms::Exception("DataCorrupt") << "SiPixelTemplate::qbin can't find needed template ID = " << id << std::endl;
           }
#else
           assert(index >= 0 && index < (int)thePixelTemp_.size());
#endif
         
//              

// Interpolate the absolute value of cot(beta)     
    
    acotb = fabs((double)cotbeta);
        
//      qcorrect corrects the cot(alpha)=0 cluster charge for non-zero cot(alpha)       

        //      qcorrect corrects the cot(alpha)=0 cluster charge for non-zero cot(alpha)       
        
        cotalpha0 =  thePixelTemp_[index].enty[0].cotalpha;
        qcorrect=std::sqrt((1.f+cotbeta*cotbeta+cotalpha*cotalpha)/(1.f+cotbeta*cotbeta+cotalpha0*cotalpha0));
                                
        // for some cosmics, the ususal gymnastics are incorrect   
        
        if(thePixelTemp_[index].head.Dtype == 0) {
                cotb = acotb;
                flip_y = false;
                if(cotbeta < 0.f) {flip_y = true;}
        } else {
            if(locBz < 0.f) {
                        cotb = cotbeta;
                        flip_y = false;
                } else {
                        cotb = -cotbeta;
                        flip_y = true;
                }       
        }
        
        // Copy the charge scaling factor to the private variable     
                
           qscale = thePixelTemp_[index].head.qscale;
                
       Ny = thePixelTemp_[index].head.NTy;
       Nyx = thePixelTemp_[index].head.NTyx;
       Nxx = thePixelTemp_[index].head.NTxx;
                
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
                if(Ny < 2 || Nyx < 1 || Nxx < 2) {
                        throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny/Nyx/Nxx = " << Ny << "/" << Nyx << "/" << Nxx << std::endl;
                }
#else
                assert(Ny > 1 && Nyx > 0 && Nxx > 1);
#endif
        
// next, loop over all y-angle entries   

           ilow = 0;
           yratio = 0.f;

           if(cotb >= thePixelTemp_[index].enty[Ny-1].cotbeta) {
        
               ilow = Ny-2;
                   yratio = 1.f;
                
           } else {
           
              if(cotb >= thePixelTemp_[index].enty[0].cotbeta) {

             for (i=0; i<Ny-1; ++i) { 
    
                if( thePixelTemp_[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index].enty[i+1].cotbeta) {
                  
                       ilow = i;
                           yratio = (cotb - thePixelTemp_[index].enty[i].cotbeta)/(thePixelTemp_[index].enty[i+1].cotbeta - thePixelTemp_[index].enty[i].cotbeta);
                           break;                        
                        }
                 }
                  } 
           }
        
           ihigh=ilow + 1;
                          
// Interpolate/store all y-related quantities (flip displacements when flip_y)

           qavg = (1.f - yratio)*thePixelTemp_[index].enty[ilow].qavg + yratio*thePixelTemp_[index].enty[ihigh].qavg;
           qavg *= qcorrect;
           dy1 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].dyone + yratio*thePixelTemp_[index].enty[ihigh].dyone;
           if(flip_y) {dy1 = -dy1;}
           sy1 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].syone + yratio*thePixelTemp_[index].enty[ihigh].syone;
           dy2 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].dytwo + yratio*thePixelTemp_[index].enty[ihigh].dytwo;
           if(flip_y) {dy2 = -dy2;}
           sy2 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].sytwo + yratio*thePixelTemp_[index].enty[ihigh].sytwo;
           qmin = (1.f - yratio)*thePixelTemp_[index].enty[ilow].qmin + yratio*thePixelTemp_[index].enty[ihigh].qmin;
           qmin *= qcorrect;
           qmin2 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].qmin2 + yratio*thePixelTemp_[index].enty[ihigh].qmin2;
           qmin2 *= qcorrect;
           for(i=0; i<4; ++i) {
              yavggen[i]=(1.f - yratio)*thePixelTemp_[index].enty[ilow].yavggen[i] + yratio*thePixelTemp_[index].enty[ihigh].yavggen[i];
              if(flip_y) {yavggen[i] = -yavggen[i];}
              yrmsgen[i]=(1.f - yratio)*thePixelTemp_[index].enty[ilow].yrmsgen[i] + yratio*thePixelTemp_[index].enty[ihigh].yrmsgen[i];
           }
           
        
// next, loop over all x-angle entries, first, find relevant y-slices   
        
           iylow = 0;
           yxratio = 0.f;

           if(acotb >= thePixelTemp_[index].entx[Nyx-1][0].cotbeta) {
        
               iylow = Nyx-2;
                   yxratio = 1.f;
                
           } else if(acotb >= thePixelTemp_[index].entx[0][0].cotbeta) {

          for (i=0; i<Nyx-1; ++i) { 
    
             if( thePixelTemp_[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp_[index].entx[i+1][0].cotbeta) {
                  
                    iylow = i;
                        yxratio = (acotb - thePixelTemp_[index].entx[i][0].cotbeta)/(thePixelTemp_[index].entx[i+1][0].cotbeta - thePixelTemp_[index].entx[i][0].cotbeta);
                        break;                   
                     }
              }
           }
        
           iyhigh=iylow + 1;

           ilow = 0;
           xxratio = 0.f;

           if(cotalpha >= thePixelTemp_[index].entx[0][Nxx-1].cotalpha) {
        
               ilow = Nxx-2;
                   xxratio = 1.f;
                
           } else {
           
              if(cotalpha >= thePixelTemp_[index].entx[0][0].cotalpha) {

             for (i=0; i<Nxx-1; ++i) { 
    
                if( thePixelTemp_[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp_[index].entx[0][i+1].cotalpha) {
                  
                       ilow = i;
                           xxratio = (cotalpha - thePixelTemp_[index].entx[0][i].cotalpha)/(thePixelTemp_[index].entx[0][i+1].cotalpha - thePixelTemp_[index].entx[0][i].cotalpha);
                           break;
                            }
                     }
                  } 
           }
        
           ihigh=ilow + 1;
                          
           dx1 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].dxone + xxratio*thePixelTemp_[index].entx[0][ihigh].dxone;
           sx1 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].sxone + xxratio*thePixelTemp_[index].entx[0][ihigh].sxone;
           dx2 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].dxtwo + xxratio*thePixelTemp_[index].entx[0][ihigh].dxtwo;
           sx2 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].sxtwo + xxratio*thePixelTemp_[index].entx[0][ihigh].sxtwo;
                          
// pixmax is the maximum allowed pixel charge (used for truncation)

           pixmx=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].pixmax + xxratio*thePixelTemp_[index].entx[iylow][ihigh].pixmax)
                          +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].pixmax + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].pixmax);
                          
           for(i=0; i<4; ++i) {
                                  
              xavggen[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].xavggen[i] + xxratio*thePixelTemp_[index].entx[iylow][ihigh].xavggen[i])
                          +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].xavggen[i] + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].xavggen[i]);
                  
              xrmsgen[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].xrmsgen[i] + xxratio*thePixelTemp_[index].entx[iylow][ihigh].xrmsgen[i])
                          +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].xrmsgen[i] + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].xrmsgen[i]);            
           }
           
                lorywidth = thePixelTemp_[index].head.lorywidth;
            if(locBz > 0.f) {lorywidth = -lorywidth;}
                lorxwidth = thePixelTemp_[index].head.lorxwidth;
                
        
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(qavg <= 0.f || qmin <= 0.f) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::qbin, qavg or qmin <= 0," 
                << " Probably someone called the generic pixel reconstruction with an illegal trajectory state" << std::endl;
        }
#else
        assert(qavg > 0.f && qmin > 0.f);
#endif
        
//  Scale the input charge to account for differences between pixelav and CMSSW simulation or data      
        
        qtotal = qscale*qclus;
        
// uncertainty and final corrections depend upon total charge bin          
           
        fq = qtotal/qavg;
        if(fq > 1.5f) {
           binq=0;
        } else {
           if(fq > 1.0f) {
              binq=1;
           } else {
                  if(fq > 0.85f) {
                         binq=2;
                  } else {
                         binq=3;
                  }
           }
        }
        
//  Take the errors and bias from the correct charge bin
        
        sigmay = yrmsgen[binq]; deltay = yavggen[binq];
        
        sigmax = xrmsgen[binq]; deltax = xavggen[binq];
        
// If the charge is too small (then flag it)
        
        if(qtotal < 0.95f*qmin) {binq = 5;} else {if(qtotal < 0.95f*qmin2) {binq = 4;}}
                
    return binq;
  
} // qbin
void SiPixelTemplate::qbin_dist ( int  id,
float  cotalpha,
float  cotbeta,
float  qbin_frac[4],
float &  ny1_frac,
float &  ny2_frac,
float &  nx1_frac,
float &  nx2_frac 
)

Interpolate beta/alpha angles to produce estimated errors for fastsim

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
qbin_frac[4]- (output) the integrated probability for qbin=0, 0+1, 0+1+2, 0+1+2+3 (1.)
ny1_frac- (output) the probability for ysize = 1 for a single-size pixel
ny2_frac- (output) the probability for ysize = 1 for a double-size pixel
nx1_frac- (output) the probability for xsize = 1 for a single-size pixel
nx2_frac- (output) the probability for xsize = 1 for a double-size pixel

Definition at line 2687 of file SiPixelTemplate.cc.

References Exception, f, i, and getHLTprescales::index.

Referenced by SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit().

{
    // Interpolate for a new set of track angles 
    
    // Local variables 
    int i;
        int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, index;
        float yratio, yxratio, xxratio;
        float acotb, cotb;
        float qfrac[4];
        //bool flip_y;
                        
                // Find the index corresponding to id
                
                index = -1;
                for(i=0; i<(int)thePixelTemp_.size(); ++i) {
                        
                        if(id == thePixelTemp_[i].head.ID) {
                                
                                index = i;
//                              id_current_ = id;
                                break;
                        }
            }
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(index < 0 || index >= (int)thePixelTemp_.size()) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::temperrors can't find needed template ID = " << id << std::endl;
        }
#else
        assert(index >= 0 && index < (int)thePixelTemp_.size());
#endif
        
        //              
        
        // Interpolate the absolute value of cot(beta)     
    
    acotb = fabs((double)cotbeta);
        cotb = cotbeta;
        
        
        // for some cosmics, the ususal gymnastics are incorrect   
        
//      if(thePixelTemp_[index].head.Dtype == 0) {
            cotb = acotb;
                //flip_y = false;
                //if(cotbeta < 0.f) {flip_y = true;}
//      } else {
//          if(locBz < 0.f) {
//                      cotb = cotbeta;
//                      flip_y = false;
//              } else {
//                      cotb = -cotbeta;
//                      flip_y = true;
//              }       
//      }
                
                // Copy the charge scaling factor to the private variable     
                
                Ny = thePixelTemp_[index].head.NTy;
                Nyx = thePixelTemp_[index].head.NTyx;
                Nxx = thePixelTemp_[index].head.NTxx;
                
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
                if(Ny < 2 || Nyx < 1 || Nxx < 2) {
                        throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny/Nyx/Nxx = " << Ny << "/" << Nyx << "/" << Nxx << std::endl;
                }
#else
                assert(Ny > 1 && Nyx > 0 && Nxx > 1);
#endif
        
                // next, loop over all y-angle entries   
                
                ilow = 0;
                yratio = 0.f;
                
                if(cotb >= thePixelTemp_[index].enty[Ny-1].cotbeta) {
                        
                        ilow = Ny-2;
                        yratio = 1.f;
                        
                } else {
                        
                        if(cotb >= thePixelTemp_[index].enty[0].cotbeta) {
                                
                                for (i=0; i<Ny-1; ++i) { 
                                        
                                        if( thePixelTemp_[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index].enty[i+1].cotbeta) {
                                                
                                                ilow = i;
                                                yratio = (cotb - thePixelTemp_[index].enty[i].cotbeta)/(thePixelTemp_[index].enty[i+1].cotbeta - thePixelTemp_[index].enty[i].cotbeta);
                                                break;                   
                                        }
                                }
                        } 
                }
                
                ihigh=ilow + 1;
                
                // Interpolate/store all y-related quantities (flip displacements when flip_y)
                ny1_frac = (1.f - yratio)*thePixelTemp_[index].enty[ilow].fracyone + yratio*thePixelTemp_[index].enty[ihigh].fracyone;
            ny2_frac = (1.f - yratio)*thePixelTemp_[index].enty[ilow].fracytwo + yratio*thePixelTemp_[index].enty[ihigh].fracytwo;
                
                // next, loop over all x-angle entries, first, find relevant y-slices   
                
                iylow = 0;
                yxratio = 0.f;
                
                if(acotb >= thePixelTemp_[index].entx[Nyx-1][0].cotbeta) {
                        
                        iylow = Nyx-2;
                        yxratio = 1.f;
                        
                } else if(acotb >= thePixelTemp_[index].entx[0][0].cotbeta) {
                        
                        for (i=0; i<Nyx-1; ++i) { 
                                
                                if( thePixelTemp_[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp_[index].entx[i+1][0].cotbeta) {
                                        
                                        iylow = i;
                                        yxratio = (acotb - thePixelTemp_[index].entx[i][0].cotbeta)/(thePixelTemp_[index].entx[i+1][0].cotbeta - thePixelTemp_[index].entx[i][0].cotbeta);
                                        break;                   
                                }
                        }
                }
                
                iyhigh=iylow + 1;
                
                ilow = 0;
                xxratio = 0.f;
                
                if(cotalpha >= thePixelTemp_[index].entx[0][Nxx-1].cotalpha) {
                        
                        ilow = Nxx-2;
                        xxratio = 1.f;
                        
                } else {
                        
                        if(cotalpha >= thePixelTemp_[index].entx[0][0].cotalpha) {
                                
                                for (i=0; i<Nxx-1; ++i) { 
                                        
                                        if( thePixelTemp_[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp_[index].entx[0][i+1].cotalpha) {
                                                
                                                ilow = i;
                                                xxratio = (cotalpha - thePixelTemp_[index].entx[0][i].cotalpha)/(thePixelTemp_[index].entx[0][i+1].cotalpha - thePixelTemp_[index].entx[0][i].cotalpha);
                                                break;
                                        }
                                }
                        } 
                }
                
                ihigh=ilow + 1;
                
                for(i=0; i<3; ++i) {
                   qfrac[i]=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].qbfrac[i] + xxratio*thePixelTemp_[index].entx[iylow][ihigh].qbfrac[i])
                   +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].qbfrac[i] + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].qbfrac[i]);             
                }
                nx1_frac = (1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].fracxone + xxratio*thePixelTemp_[index].entx[iylow][ihigh].fracxone)
                   +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].fracxone + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].fracxone);               
                nx2_frac = (1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].fracxtwo + xxratio*thePixelTemp_[index].entx[iylow][ihigh].fracxtwo)
                   +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].fracxtwo + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].fracxtwo);               
                
        

        qbin_frac[0] = qfrac[0];
        qbin_frac[1] = qbin_frac[0] + qfrac[1];
        qbin_frac[2] = qbin_frac[1] + qfrac[2];
        qbin_frac[3] = 1.f;
    return;
        
} // qbin
float SiPixelTemplate::qmin ( ) [inline]

minimum cluster charge for valid hit (keeps 99.9% of simulated hits)

Definition at line 315 of file SiPixelTemplate.h.

References qmin_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::qmin ( int  i) [inline]

minimum cluster charge for valid hit (keeps 99.9% or 99.8% of simulated hits)

Definition at line 316 of file SiPixelTemplate.h.

References Exception, qmin2_, and qmin_.

float SiPixelTemplate::qscale ( ) [inline]

charge scaling factor

Definition at line 303 of file SiPixelTemplate.h.

References qscale_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::s50 ( ) [inline]
float SiPixelTemplate::sigmavav ( ) [inline]

"sigma" scale fctor for Vavilov distribution

Definition at line 475 of file SiPixelTemplate.h.

References sigmavav_.

float SiPixelTemplate::sigmavav2 ( ) [inline]

"sigma" scale fctor for 2-cluster Vavilov distribution

Definition at line 478 of file SiPixelTemplate.h.

References sigmavav2_.

bool SiPixelTemplate::simpletemplate2D ( float  xhit,
float  yhit,
std::vector< bool > &  ydouble,
std::vector< bool > &  xdouble,
float  template2d[BXM2][BYM2] 
)

Make simple 2-D templates from track angles set in interpolate and hit position.

Parameters:
xhit- (input) x-position of hit relative to the lower left corner of pixel[1][1] (to allow for the "padding" of the two-d clusters in the splitter)
yhit- (input) y-position of hit relative to the lower left corner of pixel[1][1]
ydouble- (input) STL vector of 21 element array to flag a double-pixel starting at cluster[1][1]
xdouble- (input) STL vector of 11 element array to flag a double-pixel starting at cluster[1][1]
template2d- (output) 2d template of size matched to the cluster. Input must be zeroed since charge is added only.

Definition at line 2871 of file SiPixelTemplate.cc.

References abs, any, SimplePixel::btype, BXM3, BYM3, f, SimplePixel::i, i, SimplePixel::j, j, list(), edm::max(), SimplePixel::s, mathSSE::sqrt(), SimplePixel::x, and SimplePixel::y.

Referenced by SiPixelTemplateSplit::PixelTempSplit(), and TrackClusterSplitter::splitCluster().

{
        
        // Local variables
        
        float x0, y0, xf, yf, xi, yi, sf, si, s0, qpix, slopey, slopex, ds;
        int i, j, jpix0, ipix0, jpixf, ipixf, jpix, ipix, nx, ny, anx, any, jmax, imax;
        float qtotal;
        //      double path;
        std::list<SimplePixel> list;
        std::list<SimplePixel>::iterator listIter, listEnd;     
        
        // Calculate the entry and exit points for the line charge from the track
        
        x0 = xhit - 0.5*zsize_*cota_current_;
        y0 = yhit - 0.5*zsize_*cotb_current_;
        
        jpix0 = floor(x0/xsize_)+1;
        ipix0 = floor(y0/ysize_)+1;
        
        if(jpix0 < 0 || jpix0 > BXM3) {return false;}
        if(ipix0 < 0 || ipix0 > BYM3) {return false;}
        
        xf = xhit + 0.5*zsize_*cota_current_ + lorxwidth_;
        yf = yhit + 0.5*zsize_*cotb_current_ + lorywidth_;
        
        jpixf = floor(xf/xsize_)+1;
        ipixf = floor(yf/ysize_)+1;
        
        if(jpixf < 0 || jpixf > BXM3) {return false;}
        if(ipixf < 0 || ipixf > BYM3) {return false;}
        
// total charge length 
        
        sf = std::sqrt((xf-x0)*(xf-x0) + (yf-y0)*(yf-y0));
        if((xf-x0) != 0.f) {slopey = (yf-y0)/(xf-x0);} else { slopey = 1.e10;}
        if((yf-y0) != 0.f) {slopex = (xf-x0)/(yf-y0);} else { slopex = 1.e10;}
        
// use average charge in this direction
        
        qtotal = qavg_avg_;
        
        SimplePixel element;
        element.s = sf;
        element.x = xf;
        element.y = yf;
        element.i = ipixf;
        element.j = jpixf;
        element.btype = 0;
        list.push_back(element);
        
        //  nx is the number of x interfaces crossed by the line charge 
        
        nx = jpixf - jpix0;
        anx = abs(nx);
        if(anx > 0) {
                if(nx > 0) {
                        for(j=jpix0; j<jpixf; ++j) {
                                xi = xsize_*j;
                                yi = slopey*(xi-x0) + y0;
                                ipix = (int)(yi/ysize_)+1;
                                si = std::sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
                                element.s = si;
                                element.x = xi;
                                element.y = yi;
                                element.i = ipix;
                                element.j = j;
                                element.btype = 1;
                                list.push_back(element);
                        }
                } else {
                        for(j=jpix0; j>jpixf; --j) {
                                xi = xsize_*(j-1);
                                yi = slopey*(xi-x0) + y0;
                                ipix = (int)(yi/ysize_)+1;
                                si = std::sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
                                element.s = si;
                                element.x = xi;
                                element.y = yi;
                                element.i = ipix;
                                element.j = j;
                                element.btype = 1;
                                list.push_back(element);
                        }
                }
        }
        
        ny = ipixf - ipix0;
        any = abs(ny);
        if(any > 0) {
                if(ny > 0) {
                        for(i=ipix0; i<ipixf; ++i) {
                                yi = ysize_*i;
                                xi = slopex*(yi-y0) + x0;
                                jpix = (int)(xi/xsize_)+1;
                                si = std::sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
                                element.s = si;
                                element.x = xi;
                                element.y = yi;
                                element.i = i;
                                element.j = jpix;
                                element.btype = 2;
                                list.push_back(element);
                        }
                } else {
                        for(i=ipix0; i>ipixf; --i) {
                                yi = ysize_*(i-1);
                                xi = slopex*(yi-y0) + x0;
                                jpix = (int)(xi/xsize_)+1;
                                si = std::sqrt((xi-x0)*(xi-x0) + (yi-y0)*(yi-y0));
                                element.s = si;
                                element.x = xi;
                                element.y = yi;
                                element.i = i;
                                element.j = jpix;
                                element.btype = 2;
                                list.push_back(element);
                        }
                }
        }
        
        imax = std::max(ipix0, ipixf);
        jmax = std::max(jpix0, jpixf);
        
        // Sort the list according to the distance from the initial point
        
        list.sort();
        
        // Look for double pixels and adjust the list appropriately
        
        for(i=1; i<imax; ++i) {
                if(ydouble[i-1]) {
                        listIter = list.begin();
                        if(ny > 0) {
                                while(listIter != list.end()) {
                                        if(listIter->i == i && listIter->btype == 2) {
                                                listIter = list.erase(listIter);
                                                continue;
                                        }
                                        if(listIter->i > i) {
                                                --(listIter->i);
                                        }
                                        ++listIter;
                                }
                        } else {
                                while(listIter != list.end()) {
                                        if(listIter->i == i+1 && listIter->btype == 2) {
                                                listIter = list.erase(listIter);
                                                continue;
                                        }
                                        if(listIter->i > i+1) {
                                                --(listIter->i);
                                        }
                                        ++listIter;
                                }                               
                        }
                }
        }
        
        for(j=1; j<jmax; ++j) {
                if(xdouble[j-1]) {
                        listIter = list.begin();
                        if(nx > 0) {
                                while(listIter != list.end()) {
                                        if(listIter->j == j && listIter->btype == 1) {
                                                listIter = list.erase(listIter);
                                                continue;
                                        }
                                        if(listIter->j > j) {
                                                --(listIter->j);
                                        }
                                        ++listIter;
                                }
                        } else {
                                while(listIter != list.end()) {
                                        if(listIter->j == j+1 && listIter->btype == 1) {
                                                listIter = list.erase(listIter);
                                                continue;
                                        }
                                        if(listIter->j > j+1) {
                                                --(listIter->j);
                                        }
                                        ++listIter;
                                }                               
                        }
                }
        }
        
        // The list now contains the path lengths of the line charge in each pixel from (x0,y0).  Cacluate the lengths of the segments and the charge. 
        
        s0 = 0.f;
        listIter = list.begin();
        listEnd = list.end();
        for( ;listIter != listEnd; ++listIter) {
                si = listIter->s;
                ds = si - s0;
                s0 = si;
                j = listIter->j;
                i = listIter->i;
                if(sf > 0.f) { qpix = qtotal*ds/sf;} else {qpix = qtotal;}
                template2d[j][i] += qpix;
        }
        
        return true;
        
}  // simpletemplate2D
float SiPixelTemplate::sxmax ( ) [inline]

average pixel signal for x-projection of cluster

Definition at line 310 of file SiPixelTemplate.h.

References sxmax_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::sxone ( ) [inline]

rms for one pixel x-clusters

Definition at line 312 of file SiPixelTemplate.h.

References sxone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::sxtwo ( ) [inline]

rms for one double-pixel x-clusters

Definition at line 314 of file SiPixelTemplate.h.

References sxtwo_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::symax ( ) [inline]

average pixel signal for y-projection of cluster

Definition at line 305 of file SiPixelTemplate.h.

References symax_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::syone ( ) [inline]

rms for one pixel y-clusters

Definition at line 307 of file SiPixelTemplate.h.

References syone_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::sytwo ( ) [inline]

rms for one double-pixel y-clusters

Definition at line 309 of file SiPixelTemplate.h.

References sytwo_.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelTemplateSplit::PixelTempSplit().

void SiPixelTemplate::temperrors ( int  id,
float  cotalpha,
float  cotbeta,
int  qBin,
float &  sigmay,
float &  sigmax,
float &  sy1,
float &  sy2,
float &  sx1,
float &  sx2 
)

Interpolate beta/alpha angles to produce estimated errors for fastsim

Parameters:
id- (input) index of the template to use
cotalpha- (input) the cotangent of the alpha track angle (see CMS IN 2004/014)
cotbeta- (input) the cotangent of the beta track angle (see CMS IN 2004/014)
qBin- (input) charge bin from 0-3
sigmay- (output) the estimated y-error for CPETemplate in microns
sigmax- (output) the estimated x-error for CPETemplate in microns
sy1- (output) the estimated y-error for 1 single-pixel clusters in microns
sy2- (output) the estimated y-error for 1 double-pixel clusters in microns
sx1- (output) the estimated x-error for 1 single-pixel clusters in microns
sx2- (output) the estimated x-error for 1 double-pixel clusters in microns

Definition at line 2488 of file SiPixelTemplate.cc.

References Exception, f, i, and getHLTprescales::index.

Referenced by SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit().

{
    // Interpolate for a new set of track angles 
    
    // Local variables 
    int i;
        int ilow, ihigh, iylow, iyhigh, Ny, Nxx, Nyx, index;
        float yratio, yxratio, xxratio;
        float acotb, cotb;
        float yrms, xrms;
        //bool flip_y;
        
                
                // Find the index corresponding to id
                
                index = -1;
                for(i=0; i<(int)thePixelTemp_.size(); ++i) {
                        
                        if(id == thePixelTemp_[i].head.ID) {
                                
                                index = i;
                                break;
                        }
            }
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(index < 0 || index >= (int)thePixelTemp_.size()) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::temperrors can't find needed template ID = " << id << std::endl;
        }
#else
        assert(index >= 0 && index < (int)thePixelTemp_.size());
#endif
        
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(qBin < 0 || qBin > 5) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::temperrors called with illegal qBin = " << qBin << std::endl;
        }
#else
        assert(qBin >= 0 && qBin < 6);
#endif
        
// The error information for qBin > 3 is taken to be the same as qBin=3 
        
        if(qBin > 3) {qBin = 3;}
        //              
        
        // Interpolate the absolute value of cot(beta)     
    
    acotb = fabs((double)cotbeta);
        cotb = cotbeta;
        
        // for some cosmics, the ususal gymnastics are incorrect   
        
//      if(thePixelTemp_[index].head.Dtype == 0) {
                cotb = acotb;
                //flip_y = false;
                //if(cotbeta < 0.f) {flip_y = true;}
//      } else {
//          if(locBz < 0.f) {
//                      cotb = cotbeta;
//                      flip_y = false;
//              } else {
//                      cotb = -cotbeta;
//                      flip_y = true;
//              }       
//      }
                                
                // Copy the charge scaling factor to the private variable     
                
                Ny = thePixelTemp_[index].head.NTy;
                Nyx = thePixelTemp_[index].head.NTyx;
                Nxx = thePixelTemp_[index].head.NTxx;
                
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
                if(Ny < 2 || Nyx < 1 || Nxx < 2) {
                        throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny/Nyx/Nxx = " << Ny << "/" << Nyx << "/" << Nxx << std::endl;
                }
#else
                assert(Ny > 1 && Nyx > 0 && Nxx > 1);
#endif
        
                // next, loop over all y-angle entries   
                
                ilow = 0;
                yratio = 0.f;
                
                if(cotb >= thePixelTemp_[index].enty[Ny-1].cotbeta) {
                        
                        ilow = Ny-2;
                        yratio = 1.f;
                        
                } else {
                        
                        if(cotb >= thePixelTemp_[index].enty[0].cotbeta) {
                                
                                for (i=0; i<Ny-1; ++i) { 
                                        
                                        if( thePixelTemp_[index].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index].enty[i+1].cotbeta) {
                                                
                                                ilow = i;
                                                yratio = (cotb - thePixelTemp_[index].enty[i].cotbeta)/(thePixelTemp_[index].enty[i+1].cotbeta - thePixelTemp_[index].enty[i].cotbeta);
                                                break;                   
                                        }
                                }
                        } 
                }
                
                ihigh=ilow + 1;
                
                // Interpolate/store all y-related quantities (flip displacements when flip_y)
                
                sy1 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].syone + yratio*thePixelTemp_[index].enty[ihigh].syone;
                sy2 = (1.f - yratio)*thePixelTemp_[index].enty[ilow].sytwo + yratio*thePixelTemp_[index].enty[ihigh].sytwo;
                yrms=(1.f - yratio)*thePixelTemp_[index].enty[ilow].yrms[qBin] + yratio*thePixelTemp_[index].enty[ihigh].yrms[qBin];
                
                
                // next, loop over all x-angle entries, first, find relevant y-slices   
                
                iylow = 0;
                yxratio = 0.f;
                
                if(acotb >= thePixelTemp_[index].entx[Nyx-1][0].cotbeta) {
                        
                        iylow = Nyx-2;
                        yxratio = 1.f;
                        
                } else if(acotb >= thePixelTemp_[index].entx[0][0].cotbeta) {
                        
                        for (i=0; i<Nyx-1; ++i) { 
                                
                                if( thePixelTemp_[index].entx[i][0].cotbeta <= acotb && acotb < thePixelTemp_[index].entx[i+1][0].cotbeta) {
                                        
                                        iylow = i;
                                        yxratio = (acotb - thePixelTemp_[index].entx[i][0].cotbeta)/(thePixelTemp_[index].entx[i+1][0].cotbeta - thePixelTemp_[index].entx[i][0].cotbeta);
                                        break;                   
                                }
                        }
                }
                
                iyhigh=iylow + 1;
                
                ilow = 0;
                xxratio = 0.f;
                
                if(cotalpha >= thePixelTemp_[index].entx[0][Nxx-1].cotalpha) {
                        
                        ilow = Nxx-2;
                        xxratio = 1.f;
                        
                } else {
                        
                        if(cotalpha >= thePixelTemp_[index].entx[0][0].cotalpha) {
                                
                                for (i=0; i<Nxx-1; ++i) { 
                                        
                                        if( thePixelTemp_[index].entx[0][i].cotalpha <= cotalpha && cotalpha < thePixelTemp_[index].entx[0][i+1].cotalpha) {
                                                
                                                ilow = i;
                                                xxratio = (cotalpha - thePixelTemp_[index].entx[0][i].cotalpha)/(thePixelTemp_[index].entx[0][i+1].cotalpha - thePixelTemp_[index].entx[0][i].cotalpha);
                                                break;
                                        }
                                }
                        } 
                }
                
                ihigh=ilow + 1;
                
                sx1 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].sxone + xxratio*thePixelTemp_[index].entx[0][ihigh].sxone;
                sx2 = (1.f - xxratio)*thePixelTemp_[index].entx[0][ilow].sxtwo + xxratio*thePixelTemp_[index].entx[0][ihigh].sxtwo;
                
                xrms=(1.f - yxratio)*((1.f - xxratio)*thePixelTemp_[index].entx[iylow][ilow].xrms[qBin] + xxratio*thePixelTemp_[index].entx[iylow][ihigh].xrms[qBin])
                        +yxratio*((1.f - xxratio)*thePixelTemp_[index].entx[iyhigh][ilow].xrms[qBin] + xxratio*thePixelTemp_[index].entx[iyhigh][ihigh].xrms[qBin]);              
                
        
        
        
        //  Take the errors and bias from the correct charge bin
        
        sigmay = yrms;
        
        sigmax = xrms;
                
    return;
        
} // temperrors
void SiPixelTemplate::vavilov2_pars ( double &  mpv,
double &  sigma,
double &  kappa 
)

Interpolate beta/alpha angles to produce Vavilov parameters for the 2-cluster charge distribution

Parameters:
mpv- (output) the Vavilov most probable charge (well, not really the most probable esp at large kappa)
sigma- (output) the Vavilov sigma parameter
kappa- (output) the Vavilov kappa parameter [0.01 (Landau-like) < kappa < 10 (Gaussian-like)

Definition at line 3163 of file SiPixelTemplate.cc.

References cmsCodeRulesChecker::arg, Exception, f, i, and mathSSE::sqrt().

Referenced by SiPixelTemplateSplit::PixelTempSplit().

{
        // Local variables 
        int i;
        int ilow, ihigh, Ny;
        float yratio, cotb, cotalpha0, arg;
        
    // Interpolate in cotbeta only for the correct total path length (converts cotalpha, cotbeta into an effective cotbeta) 
        
        cotalpha0 =  thePixelTemp_[index_id_].enty[0].cotalpha;
    arg = cotb_current_*cotb_current_ + cota_current_*cota_current_ - cotalpha0*cotalpha0;
    if(arg < 0.f) arg = 0.f;
        cotb = std::sqrt(arg);
        
        // Copy the charge scaling factor to the private variable     
        
        Ny = thePixelTemp_[index_id_].head.NTy;
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(Ny < 2) {
                throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny = " << Ny << std::endl;
        }
#else
        assert(Ny > 1);
#endif
        
        // next, loop over all y-angle entries   
        
        ilow = 0;
        yratio = 0.f;
        
        if(cotb >= thePixelTemp_[index_id_].enty[Ny-1].cotbeta) {
                
                ilow = Ny-2;
                yratio = 1.f;
                
        } else {
                
                if(cotb >= thePixelTemp_[index_id_].enty[0].cotbeta) {
                        
                        for (i=0; i<Ny-1; ++i) { 
                                
                                if( thePixelTemp_[index_id_].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index_id_].enty[i+1].cotbeta) {
                                        
                                        ilow = i;
                                        yratio = (cotb - thePixelTemp_[index_id_].enty[i].cotbeta)/(thePixelTemp_[index_id_].enty[i+1].cotbeta - thePixelTemp_[index_id_].enty[i].cotbeta);
                                        break;                   
                                }
                        }
                } 
        }
        
        ihigh=ilow + 1;
        
        // Interpolate Vavilov parameters
        
        mpvvav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].mpvvav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].mpvvav2;
        sigmavav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sigmavav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].sigmavav2;
        kappavav2_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].kappavav2 + yratio*thePixelTemp_[index_id_].enty[ihigh].kappavav2;
        
        // Copy to parameter list
                
        mpv = (double)mpvvav2_;
        sigma = (double)sigmavav2_;
        kappa = (double)kappavav2_;
        
        return;
        
} // vavilov2_pars
void SiPixelTemplate::vavilov_pars ( double &  mpv,
double &  sigma,
double &  kappa 
)

Interpolate beta/alpha angles to produce Vavilov parameters for the charge distribution

Parameters:
mpv- (output) the Vavilov most probable charge (well, not really the most probable esp at large kappa)
sigma- (output) the Vavilov sigma parameter
kappa- (output) the Vavilov kappa parameter [0.01 (Landau-like) < kappa < 10 (Gaussian-like)

Definition at line 3085 of file SiPixelTemplate.cc.

References cmsCodeRulesChecker::arg, Exception, f, i, and mathSSE::sqrt().

Referenced by SiPixelTemplateReco::PixelTempReco2D().

{
        // Local variables 
        int i;
        int ilow, ihigh, Ny;
        float yratio, cotb, cotalpha0, arg;
        
// Interpolate in cotbeta only for the correct total path length (converts cotalpha, cotbeta into an effective cotbeta) 
        
        cotalpha0 =  thePixelTemp_[index_id_].enty[0].cotalpha;
    arg = cotb_current_*cotb_current_ + cota_current_*cota_current_ - cotalpha0*cotalpha0;
    if(arg < 0.f) arg = 0.f;
        cotb = std::sqrt(arg);
                
// Copy the charge scaling factor to the private variable     
        
        Ny = thePixelTemp_[index_id_].head.NTy;
        
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(Ny < 2) {
                throw cms::Exception("DataCorrupt") << "template ID = " << id_current_ << "has too few entries: Ny = " << Ny << std::endl;
        }
#else
        assert(Ny > 1);
#endif
        
// next, loop over all y-angle entries   
        
        ilow = 0;
        yratio = 0.f;
        
        if(cotb >= thePixelTemp_[index_id_].enty[Ny-1].cotbeta) {
                
                ilow = Ny-2;
                yratio = 1.f;
                
        } else {
                
                if(cotb >= thePixelTemp_[index_id_].enty[0].cotbeta) {
                        
                        for (i=0; i<Ny-1; ++i) { 
                                
                                if( thePixelTemp_[index_id_].enty[i].cotbeta <= cotb && cotb < thePixelTemp_[index_id_].enty[i+1].cotbeta) {
                                        
                                        ilow = i;
                                        yratio = (cotb - thePixelTemp_[index_id_].enty[i].cotbeta)/(thePixelTemp_[index_id_].enty[i+1].cotbeta - thePixelTemp_[index_id_].enty[i].cotbeta);
                                        break;                   
                                }
                        }
                } 
        }
        
        ihigh=ilow + 1;
        
// Interpolate Vavilov parameters
        
        mpvvav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].mpvvav + yratio*thePixelTemp_[index_id_].enty[ihigh].mpvvav;
        sigmavav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].sigmavav + yratio*thePixelTemp_[index_id_].enty[ihigh].sigmavav;
        kappavav_ = (1.f - yratio)*thePixelTemp_[index_id_].enty[ilow].kappavav + yratio*thePixelTemp_[index_id_].enty[ihigh].kappavav;
        
// Copy to parameter list
        
        
        mpv = (double)mpvvav_;
        sigma = (double)sigmavav_;
        kappa = (double)kappavav_;
        
        return;
        
} // vavilov_pars
float SiPixelTemplate::xavg ( int  i) [inline]

average x-bias of reconstruction binned in 4 charge bins

Definition at line 356 of file SiPixelTemplate.h.

References Exception, i, and xavg_.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::xavgc2m ( int  i) [inline]

1st pass chi2 min search: average x-bias of reconstruction binned in 4 charge bins

Definition at line 440 of file SiPixelTemplate.h.

References Exception, i, and xavgc2m_.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::xflcorr ( int  binq,
float  qflx 
)

Return interpolated x-correction for input charge bin and qflx

Parameters:
binq- (input) charge bin [0-3]
qflx- (input) (Q_f-Q_l)/(Q_f+Q_l) for this cluster

Definition at line 1621 of file SiPixelTemplate.cc.

References Exception, and f.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

{
    // Interpolate using quantities already stored in the private variables
    
    // Local variables 
        float qfl, qfl2, qfl3, qfl4, qfl5, dx;
        
    // Make sure that input is OK
    
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(binq < 0 || binq > 3) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xflcorr called with binq = " << binq << std::endl;
        }
#else
        assert(binq >= 0 && binq < 4);
#endif
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(fabs((double)qflx) > 1.) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xflcorr called with qflx = " << qflx << std::endl;
        }
#else
        assert(fabs((double)qflx) <= 1.);
#endif
                     
// Define the maximum signal to allow before de-weighting a pixel 

       qfl = qflx;

       if(qfl < -0.9f) {qfl = -0.9f;}
           if(qfl > 0.9f) {qfl = 0.9f;}
           
// Interpolate between the two polynomials

           qfl2 = qfl*qfl; qfl3 = qfl2*qfl; qfl4 = qfl3*qfl; qfl5 = qfl4*qfl;
           dx = (1.f - yxratio_)*((1.f-xxratio_)*(xflparll_[binq][0]+xflparll_[binq][1]*qfl+xflparll_[binq][2]*qfl2+xflparll_[binq][3]*qfl3+xflparll_[binq][4]*qfl4+xflparll_[binq][5]*qfl5)
                  + xxratio_*(xflparlh_[binq][0]+xflparlh_[binq][1]*qfl+xflparlh_[binq][2]*qfl2+xflparlh_[binq][3]*qfl3+xflparlh_[binq][4]*qfl4+xflparlh_[binq][5]*qfl5))
              + yxratio_*((1.f-xxratio_)*(xflparhl_[binq][0]+xflparhl_[binq][1]*qfl+xflparhl_[binq][2]*qfl2+xflparhl_[binq][3]*qfl3+xflparhl_[binq][4]*qfl4+xflparhl_[binq][5]*qfl5)
                  + xxratio_*(xflparhh_[binq][0]+xflparhh_[binq][1]*qfl+xflparhh_[binq][2]*qfl2+xflparhh_[binq][3]*qfl3+xflparhh_[binq][4]*qfl4+xflparhh_[binq][5]*qfl5));
        
        return dx;
        
} // End xflcorr
float SiPixelTemplate::xgsig ( int  i) [inline]

average sigma_x from Gaussian fit binned in 4 charge bins

Definition at line 377 of file SiPixelTemplate.h.

References Exception, i, and xgsig_.

float SiPixelTemplate::xgx0 ( int  i) [inline]

average x0 from Gaussian fit binned in 4 charge bins

Definition at line 370 of file SiPixelTemplate.h.

References Exception, i, and xgx0_.

float SiPixelTemplate::xrms ( int  i) [inline]

average x-rms of reconstruction binned in 4 charge bins

Definition at line 363 of file SiPixelTemplate.h.

References Exception, i, and xrms_.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::xrmsc2m ( int  i) [inline]

1st pass chi2 min search: average x-rms of reconstruction binned in 4 charge bins

Definition at line 447 of file SiPixelTemplate.h.

References Exception, i, and xrmsc2m_.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

void SiPixelTemplate::xsigma2 ( int  fxpix,
int  lxpix,
float  sxthr,
float  xsum[BXSIZE],
float  xsig2[BXSIZE] 
)
float SiPixelTemplate::xsize ( ) [inline]
void SiPixelTemplate::xtemp ( int  fxbin,
int  lxbin,
float  xtemplate[41][BXSIZE] 
)

Return interpolated y-template in single call

Parameters:
fxbin- (input) index of first bin (0-40) to fill
fxbin- (input) index of last bin (0-40) to fill
xtemplate- (output) a 41x11 output buffer

Definition at line 1751 of file SiPixelTemplate.cc.

References BXM1, BXM2, BXSIZE, Exception, i, and j.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit().

{
    // Retrieve already interpolated quantities
    
    // Local variables 
    int i, j;

   // Verify that input parameters are in valid range

#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(fxbin < 0 || fxbin > 40) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xtemp called with fxbin = " << fxbin << std::endl;
        }
#else
        assert(fxbin >= 0 && fxbin < 41);
#endif
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(lxbin < 0 || lxbin > 40) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xtemp called with lxbin = " << lxbin << std::endl;
        }
#else
        assert(lxbin >= 0 && lxbin < 41);
#endif

// Build the x-template, the central 25 bins are here in all cases
        
        for(i=0; i<9; ++i) {
           for(j=0; j<BXSIZE; ++j) {
              xtemplate[i+16][j]=xtemp_[i][j];
           }
        }
        for(i=0; i<8; ++i) {
           xtemplate[i+8][BXM1] = 0.f;
           for(j=0; j<BXM1; ++j) {
              xtemplate[i+8][j]=xtemp_[i][j+1];
           }
        }
        for(i=1; i<9; ++i) {
           xtemplate[i+24][0] = 0.f;
           for(j=0; j<BXM1; ++j) {
              xtemplate[i+24][j+1]=xtemp_[i][j];
           }
        }
        
//  Add more bins if needed     
        
        if(fxbin < 8) {
           for(i=0; i<8; ++i) {
          xtemplate[i][BXM2] = 0.f;
              xtemplate[i][BXM1] = 0.f;
              for(j=0; j<BXM2; ++j) {
                xtemplate[i][j]=xtemp_[i][j+2];
              }
           }
        }
        if(lxbin > 32) {
           for(i=1; i<9; ++i) {
          xtemplate[i+32][0] = 0.f;
              xtemplate[i+32][1] = 0.f;
              for(j=0; j<BXM2; ++j) {
                xtemplate[i+32][j+2]=xtemp_[i][j];
              }
           }
        }
        
        return;
        
} // End xtemp
void SiPixelTemplate::xtemp3d ( int  i,
int  j,
std::vector< float > &  xtemplate 
)

Return interpolated 3d x-template in single call

Parameters:
i,j- (input) template indices
xtemplate- (output) a boost 3d array containing two sets of temlate indices and the combined pixel signals

Definition at line 2105 of file SiPixelTemplate.cc.

References BXSIZE, i, j, and gen::k.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

{       
    // Sum two 2-d templates to make the 3-d template
        if(i >= 0 && i < nxbins_ && j <= i) {
        for(int k=0; k<BXSIZE; ++k) {
            xtemplate[k]=temp2dx_[i][k]+temp2dx_[j][k]; 
        }
    } else {
        for(int k=0; k<BXSIZE; ++k) {
            xtemplate[k]=0.;    
        } 
    }
        
        return;
        
} // End xtemp3d
void SiPixelTemplate::xtemp3d_int ( int  nxpix,
int &  nxbins 
)

Make interpolated 3d x-template (stored as class variables)

Parameters:
nxpix- (input) number of pixels in cluster (needed to size template)
nxbins- (output) number of bins needed for each template projection

Definition at line 2026 of file SiPixelTemplate.cc.

References BXM1, BXM3, BXSIZE, diffTreeTool::diff, Exception, i, j, and gen::k.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

{       
    // Retrieve already interpolated quantities
    
    // Local variables 
    int i, j, k;
        int ioff0, ioffp, ioffm;

   // Verify that input parameters are in valid range

#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(nxpix < 1 || nxpix >= BXM3) {
           throw cms::Exception("DataCorrupt") << "SiPixelTemplate::xtemp3d called with nxpix = " << nxpix << std::endl;
        }
#else
        assert(nxpix > 0 && nxpix < BXM3);
#endif
        
// Calculate the size of the shift in pixels needed to span the entire cluster

    float diff = fabsf(nxpix - clslenx_)/2. + 1.f;
        int nshift = (int)diff;
        if((diff - nshift) > 0.5f) {++nshift;}

// Calculate the number of bins needed to specify each hit range

    nxbins_ = 9 + 16*nshift;
        
// Create a 2-d working template with the correct size

        temp2dx_.resize(boost::extents[nxbins_][BXSIZE]);
        
//  The 9 central bins are copied from the interpolated private store

        ioff0 = 8*nshift;
        
        for(i=0; i<9; ++i) {
           for(j=0; j<BXSIZE; ++j) {
          temp2dx_[i+ioff0][j]=xtemp_[i][j];
           }
        }
        
// Add the +- shifted templates 

        for(k=1; k<=nshift; ++k) {
          ioffm=ioff0-k*8;
          for(i=0; i<8; ++i) {
             for(j=0; j<k; ++j) {
                temp2dx_[i+ioffm][BXM1-j] = 0.f;
                 }
             for(j=0; j<BXSIZE-k; ++j) {
                temp2dx_[i+ioffm][j]=xtemp_[i][j+k];
             }
           }
           ioffp=ioff0+k*8;
           for(i=1; i<9; ++i) {
              for(j=0; j<k; ++j) {
                 temp2dx_[i+ioffp][j] = 0.f;
              }
              for(j=0; j<BXSIZE-k; ++j) {
                 temp2dx_[i+ioffp][j+k]=xtemp_[i][j];
              }
           }
        }
    
    nxbins = nxbins_;                                   
        
        return;
        
} // End xtemp3d_int
float SiPixelTemplate::xxratio ( ) [inline]

fractional distance in x between cotalpha templates

Definition at line 327 of file SiPixelTemplate.h.

References xxratio_.

float SiPixelTemplate::yavg ( int  i) [inline]

average y-bias of reconstruction binned in 4 charge bins

Definition at line 328 of file SiPixelTemplate.h.

References Exception, i, and yavg_.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::yavgc2m ( int  i) [inline]

1st pass chi2 min search: average y-bias of reconstruction binned in 4 charge bins

Definition at line 412 of file SiPixelTemplate.h.

References Exception, i, and yavgc2m_.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

float SiPixelTemplate::yflcorr ( int  binq,
float  qfly 
)

Return interpolated y-correction for input charge bin and qfly

Parameters:
binq- (input) charge bin [0-3]
qfly- (input) (Q_f-Q_l)/(Q_f+Q_l) for this cluster

Definition at line 1569 of file SiPixelTemplate.cc.

References Exception, and f.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

{
    // Interpolate using quantities already stored in the private variables
    
    // Local variables 
        float qfl, qfl2, qfl3, qfl4, qfl5, dy;
        
    // Make sure that input is OK
    
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(binq < 0 || binq > 3) {
           throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yflcorr called with binq = " << binq << std::endl;
        }
#else
         assert(binq >= 0 && binq < 4);
#endif
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
         if(fabs((double)qfly) > 1.) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::yflcorr called with qfly = " << qfly << std::endl;
         }
#else
         assert(fabs((double)qfly) <= 1.);
#endif
                     
// Define the maximum signal to allow before de-weighting a pixel 

       qfl = qfly;

       if(qfl < -0.9f) {qfl = -0.9f;}
           if(qfl > 0.9f) {qfl = 0.9f;}
           
// Interpolate between the two polynomials

           qfl2 = qfl*qfl; qfl3 = qfl2*qfl; qfl4 = qfl3*qfl; qfl5 = qfl4*qfl;
           dy = (1.f-yratio_)*(yflparl_[binq][0]+yflparl_[binq][1]*qfl+yflparl_[binq][2]*qfl2+yflparl_[binq][3]*qfl3+yflparl_[binq][4]*qfl4+yflparl_[binq][5]*qfl5)
                  + yratio_*(yflparh_[binq][0]+yflparh_[binq][1]*qfl+yflparh_[binq][2]*qfl2+yflparh_[binq][3]*qfl3+yflparh_[binq][4]*qfl4+yflparh_[binq][5]*qfl5);
        
        return dy;
        
} // End yflcorr
float SiPixelTemplate::ygsig ( int  i) [inline]

average sigma_y from Gaussian fit binned in 4 charge bins

Definition at line 349 of file SiPixelTemplate.h.

References Exception, i, and ygsig_.

float SiPixelTemplate::ygx0 ( int  i) [inline]

average y0 from Gaussian fit binned in 4 charge bins

Definition at line 342 of file SiPixelTemplate.h.

References Exception, i, and ygx0_.

float SiPixelTemplate::yratio ( ) [inline]

fractional distance in y between cotbeta templates

Definition at line 325 of file SiPixelTemplate.h.

References yratio_.

float SiPixelTemplate::yrms ( int  i) [inline]

average y-rms of reconstruction binned in 4 charge bins

Definition at line 335 of file SiPixelTemplate.h.

References Exception, i, and yrms_.

Referenced by SiPixelTemplateReco::PixelTempReco2D().

float SiPixelTemplate::yrmsc2m ( int  i) [inline]

1st pass chi2 min search: average y-rms of reconstruction binned in 4 charge bins

Definition at line 419 of file SiPixelTemplate.h.

References Exception, i, and yrmsc2m_.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

void SiPixelTemplate::ysigma2 ( float  qpixel,
int  index,
float &  ysig2 
)

Return y error (squared) for an input signal and yindex Add large Q scaling for use in cluster splitting.

Parameters:
qpixel- (input) pixel charge
index- (input) y-index index of pixel
ysig2- (output) square error

Definition at line 1395 of file SiPixelTemplate.cc.

References BHY, BYM2, ENDL, Exception, f, and LOGERROR.

{
    // Interpolate using quantities already stored in the private variables
    
    // Local variables 
        float sigi, sigi2, sigi3, sigi4, symax, qscale, err2;
        
    // Make sure that input is OK
    
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
    if(index < 2 || index >= BYM2) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ysigma2 called with index = " << index << std::endl;
        }
#else
        assert(index > 1 && index < BYM2);
#endif
        
        // Define the maximum signal to use in the parameterization 
        
        symax = symax_;
        if(symax_ > syparmax_) {symax = syparmax_;}
        
        // Evaluate pixel-by-pixel uncertainties (weights) for the templ analysis 
        
                        if(qpixel < symax) {
                                sigi = qpixel;
                                qscale = 1.f;
                        } else {
                                sigi = symax;
                                qscale = qpixel/symax;
                        }
                        sigi2 = sigi*sigi; sigi3 = sigi2*sigi; sigi4 = sigi3*sigi;
                        if(index <= BHY) {
                                err2 = (1.f-yratio_)*
                                (yparl_[0][0]+yparl_[0][1]*sigi+yparl_[0][2]*sigi2+yparl_[0][3]*sigi3+yparl_[0][4]*sigi4)
                                + yratio_*
                                (yparh_[0][0]+yparh_[0][1]*sigi+yparh_[0][2]*sigi2+yparh_[0][3]*sigi3+yparh_[0][4]*sigi4);
                        } else {
                                err2 = (1.f-yratio_)*
                                (yparl_[1][0]+yparl_[1][1]*sigi+yparl_[1][2]*sigi2+yparl_[1][3]*sigi3+yparl_[1][4]*sigi4)
                                + yratio_*
                            (yparh_[1][0]+yparh_[1][1]*sigi+yparh_[1][2]*sigi2+yparh_[1][3]*sigi3+yparh_[1][4]*sigi4);
                        }
                        ysig2 =qscale*err2;
                        if(ysig2 <= 0.f) {LOGERROR("SiPixelTemplate") << "neg y-error-squared, id = " << id_current_ << ", index = " << index_id_ << 
                        ", cot(alpha) = " << cota_current_ << ", cot(beta) = " << cotb_current_ <<  ", sigi = " << sigi << ENDL;}
        
        return;
        
} // End ysigma2
void SiPixelTemplate::ysigma2 ( int  fypix,
int  lypix,
float  sythr,
float  ysum[BYSIZE],
float  ysig2[BYSIZE] 
)
float SiPixelTemplate::ysize ( ) [inline]
void SiPixelTemplate::ytemp ( int  fybin,
int  lybin,
float  ytemplate[41][BYSIZE] 
)

Return interpolated y-template in single call

Parameters:
fybin- (input) index of first bin (0-40) to fill
fybin- (input) index of last bin (0-40) to fill
ytemplate- (output) a 41x25 output buffer

Definition at line 1673 of file SiPixelTemplate.cc.

References BYM1, BYM2, BYSIZE, Exception, i, and j.

Referenced by SiPixelTemplateReco::PixelTempReco2D(), and SiPixelGaussianSmearingRecHitConverterAlgorithm::smearHit().

{
    // Retrieve already interpolated quantities
    
    // Local variables 
    int i, j;

   // Verify that input parameters are in valid range

#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(fybin < 0 || fybin > 40) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ytemp called with fybin = " << fybin << std::endl;
        }
#else
        assert(fybin >= 0 && fybin < 41);
#endif
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(lybin < 0 || lybin > 40) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ytemp called with lybin = " << lybin << std::endl;
        }
#else
        assert(lybin >= 0 && lybin < 41);
#endif

// Build the y-template, the central 25 bins are here in all cases
        
        for(i=0; i<9; ++i) {
           for(j=0; j<BYSIZE; ++j) {
                        ytemplate[i+16][j]=ytemp_[i][j];
           }
        }
        for(i=0; i<8; ++i) {
           ytemplate[i+8][BYM1] = 0.f;
           for(j=0; j<BYM1; ++j) {
              ytemplate[i+8][j]=ytemp_[i][j+1];
           }
        }
        for(i=1; i<9; ++i) {
           ytemplate[i+24][0] = 0.f;
           for(j=0; j<BYM1; ++j) {
              ytemplate[i+24][j+1]=ytemp_[i][j];
           }
        }
        
//  Add more bins if needed

        if(fybin < 8) {
           for(i=0; i<8; ++i) {
              ytemplate[i][BYM2] = 0.f;
              ytemplate[i][BYM1] = 0.f;
              for(j=0; j<BYM2; ++j) {
                ytemplate[i][j]=ytemp_[i][j+2];
              }
           }
        }
        if(lybin > 32) {
           for(i=1; i<9; ++i) {
          ytemplate[i+32][0] = 0.f;
              ytemplate[i+32][1] = 0.f;
              for(j=0; j<BYM2; ++j) {
                 ytemplate[i+32][j+2]=ytemp_[i][j];
              }
           }
        }
        
        return;
        
} // End ytemp
void SiPixelTemplate::ytemp3d ( int  i,
int  j,
std::vector< float > &  ytemplate 
)

Return interpolated 3d y-template in single call

Parameters:
i,j- (input) template indices
ytemplate- (output) a boost 3d array containing two sets of temlate indices and the combined pixel signals

Definition at line 2002 of file SiPixelTemplate.cc.

References BYSIZE, i, j, and gen::k.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

{       
    // Sum two 2-d templates to make the 3-d template
        if(i >= 0 && i < nybins_ && j <= i) {
       for(int k=0; k<BYSIZE; ++k) {
          ytemplate[k]=temp2dy_[i][k]+temp2dy_[j][k];   
       }
    } else {
        for(int k=0; k<BYSIZE; ++k) {
            ytemplate[k]=0.;    
        } 
    }
        
        return;
        
} // End ytemp3d
void SiPixelTemplate::ytemp3d_int ( int  nypix,
int &  nybins 
)

Make interpolated 3d y-template (stored as class variables)

Parameters:
nypix- (input) number of pixels in cluster (needed to size template)
nybins- (output) number of bins needed for each template projection

Definition at line 1924 of file SiPixelTemplate.cc.

References BYM1, BYM3, BYSIZE, diffTreeTool::diff, Exception, i, j, and gen::k.

Referenced by SiPixelTemplateSplit::PixelTempSplit().

{
        
    // Retrieve already interpolated quantities
    
    // Local variables 
    int i, j, k;
        int ioff0, ioffp, ioffm;
    
    // Verify that input parameters are in valid range
    
#ifndef SI_PIXEL_TEMPLATE_STANDALONE
        if(nypix < 1 || nypix >= BYM3) {
                throw cms::Exception("DataCorrupt") << "SiPixelTemplate::ytemp3d called with nypix = " << nypix << std::endl;
        }
#else
        assert(nypix > 0 && nypix < BYM3);
#endif
        
    // Calculate the size of the shift in pixels needed to span the entire cluster
    
    float diff = fabsf(nypix - clsleny_)/2. + 1.f;
        int nshift = (int)diff;
        if((diff - nshift) > 0.5f) {++nshift;}
    
    // Calculate the number of bins needed to specify each hit range
    
    nybins_ = 9 + 16*nshift;
        
    // Create a 2-d working template with the correct size
    
        temp2dy_.resize(boost::extents[nybins_][BYSIZE]);
        
    //  The 9 central bins are copied from the interpolated private store
    
        ioff0 = 8*nshift;
        
        for(i=0; i<9; ++i) {
        for(j=0; j<BYSIZE; ++j) {
            temp2dy_[i+ioff0][j]=ytemp_[i][j];
        }
        }
        
    // Add the +- shifted templates     
    
        for(k=1; k<=nshift; ++k) {
        ioffm=ioff0-k*8;
        for(i=0; i<8; ++i) {
            for(j=0; j<k; ++j) {
                temp2dy_[i+ioffm][BYM1-j] = 0.f;
            }
            for(j=0; j<BYSIZE-k; ++j) {
                temp2dy_[i+ioffm][j]=ytemp_[i][j+k];
            }
        }
        ioffp=ioff0+k*8;
        for(i=1; i<9; ++i) {
            for(j=0; j<k; ++j) {
                temp2dy_[i+ioffp][j] = 0.f;
            }
            for(j=0; j<BYSIZE-k; ++j) {
                temp2dy_[i+ioffp][j+k]=ytemp_[i][j];
            }
        }
        }
    
    nybins = nybins_;   
        return;
        
} // End ytemp3d_int
float SiPixelTemplate::yxratio ( ) [inline]

fractional distance in y between cotalpha templates slices

Definition at line 326 of file SiPixelTemplate.h.

References yxratio_.

float SiPixelTemplate::zsize ( ) [inline]

pixel z-size or thickness (microns)

Definition at line 482 of file SiPixelTemplate.h.

References zsize_.


Member Data Documentation

float SiPixelTemplate::abs_cotb_ [private]

absolute value of cot beta

Definition at line 495 of file SiPixelTemplate.h.

float SiPixelTemplate::chi2xavg_[4] [private]

average x chi^2 in 4 charge bins

Definition at line 548 of file SiPixelTemplate.h.

Referenced by chi2xavg().

float SiPixelTemplate::chi2xavgc2m_[4] [private]

1st pass chi2 min search: average x-chisq for merged clusters

Definition at line 556 of file SiPixelTemplate.h.

Referenced by chi2xavgc2m().

average x chi^2 for 1 pixel clusters

Definition at line 560 of file SiPixelTemplate.h.

Referenced by chi2xavgone().

float SiPixelTemplate::chi2xmin_[4] [private]

minimum of x chi^2 in 4 charge bins

Definition at line 549 of file SiPixelTemplate.h.

Referenced by chi2xmin().

float SiPixelTemplate::chi2xminc2m_[4] [private]

1st pass chi2 min search: minimum x-chisq for merged clusters

Definition at line 557 of file SiPixelTemplate.h.

Referenced by chi2xminc2m().

minimum of x chi^2 for 1 pixel clusters

Definition at line 561 of file SiPixelTemplate.h.

Referenced by chi2xminone().

float SiPixelTemplate::chi2yavg_[4] [private]

average y chi^2 in 4 charge bins

Definition at line 546 of file SiPixelTemplate.h.

Referenced by chi2yavg().

float SiPixelTemplate::chi2yavgc2m_[4] [private]

1st pass chi2 min search: average y-chisq for merged clusters

Definition at line 552 of file SiPixelTemplate.h.

Referenced by chi2yavgc2m().

average y chi^2 for 1 pixel clusters

Definition at line 558 of file SiPixelTemplate.h.

Referenced by chi2yavgone().

float SiPixelTemplate::chi2ymin_[4] [private]

minimum of y chi^2 in 4 charge bins

Definition at line 547 of file SiPixelTemplate.h.

Referenced by chi2ymin().

float SiPixelTemplate::chi2yminc2m_[4] [private]

1st pass chi2 min search: minimum y-chisq for merged clusters

Definition at line 553 of file SiPixelTemplate.h.

Referenced by chi2yminc2m().

minimum of y chi^2 for 1 pixel clusters

Definition at line 559 of file SiPixelTemplate.h.

Referenced by chi2yminone().

float SiPixelTemplate::clslenx_ [private]

x-cluster length of smaller interpolated template in pixels

Definition at line 519 of file SiPixelTemplate.h.

Referenced by clslenx().

float SiPixelTemplate::clsleny_ [private]

y-cluster length of smaller interpolated template in pixels

Definition at line 518 of file SiPixelTemplate.h.

Referenced by clsleny().

current cot alpha

Definition at line 493 of file SiPixelTemplate.h.

Referenced by SiPixelTemplate().

current cot beta

Definition at line 494 of file SiPixelTemplate.h.

Referenced by SiPixelTemplate().

float SiPixelTemplate::dxone_ [private]

mean offset/correction for one pixel x-clusters

Definition at line 513 of file SiPixelTemplate.h.

Referenced by dxone().

float SiPixelTemplate::dxtwo_ [private]

mean offset/correction for one double-pixel x-clusters

Definition at line 515 of file SiPixelTemplate.h.

Referenced by dxtwo().

float SiPixelTemplate::dyone_ [private]

mean offset/correction for one pixel y-clusters

Definition at line 507 of file SiPixelTemplate.h.

Referenced by dyone().

float SiPixelTemplate::dytwo_ [private]

mean offset/correction for one double-pixel y-clusters

Definition at line 509 of file SiPixelTemplate.h.

Referenced by dytwo().

current id

Definition at line 491 of file SiPixelTemplate.h.

Referenced by SiPixelTemplate().

current index

Definition at line 492 of file SiPixelTemplate.h.

Referenced by SiPixelTemplate().

float SiPixelTemplate::kappavav2_ [private]

kappa parameter for 2-cluster Vavilov distribution

Definition at line 568 of file SiPixelTemplate.h.

Referenced by kappavav2().

float SiPixelTemplate::kappavav_ [private]

kappa parameter for Vavilov distribution

Definition at line 565 of file SiPixelTemplate.h.

Referenced by kappavav().

float SiPixelTemplate::lorxwidth_ [private]

Lorentz x-width.

Definition at line 570 of file SiPixelTemplate.h.

Referenced by lorxwidth().

float SiPixelTemplate::lorywidth_ [private]

Lorentz y-width (sign corrected for fpix frame)

Definition at line 569 of file SiPixelTemplate.h.

Referenced by lorywidth().

float SiPixelTemplate::mpvvav2_ [private]

most probable charge in 2-cluster Vavilov distribution (not actually for larger kappa)

Definition at line 566 of file SiPixelTemplate.h.

Referenced by mpvvav2().

float SiPixelTemplate::mpvvav_ [private]

most probable charge in Vavilov distribution (not actually for larger kappa)

Definition at line 563 of file SiPixelTemplate.h.

Referenced by mpvvav().

float SiPixelTemplate::nxbins_ [private]

number of bins in each dimension of the x-splitting template

Definition at line 576 of file SiPixelTemplate.h.

float SiPixelTemplate::nybins_ [private]

number of bins in each dimension of the y-splitting template

Definition at line 575 of file SiPixelTemplate.h.

float SiPixelTemplate::pixmax_ [private]

maximum pixel charge

Definition at line 502 of file SiPixelTemplate.h.

Referenced by pixmax().

float SiPixelTemplate::qavg_ [private]

average cluster charge for this set of track angles

Definition at line 501 of file SiPixelTemplate.h.

Referenced by qavg().

float SiPixelTemplate::qavg_avg_ [private]

average of cluster charge less than qavg

Definition at line 574 of file SiPixelTemplate.h.

float SiPixelTemplate::qmin2_ [private]

tighter minimum cluster charge for valid hit (keeps 99.8% of simulated hits)

Definition at line 562 of file SiPixelTemplate.h.

Referenced by qmin().

float SiPixelTemplate::qmin_ [private]

minimum cluster charge for valid hit (keeps 99.9% of simulated hits)

Definition at line 517 of file SiPixelTemplate.h.

Referenced by qmin().

float SiPixelTemplate::qscale_ [private]

charge scaling factor

Definition at line 503 of file SiPixelTemplate.h.

Referenced by qscale().

float SiPixelTemplate::s50_ [private]

1/2 of the pixel threshold signal in adc units

Definition at line 504 of file SiPixelTemplate.h.

Referenced by s50().

float SiPixelTemplate::sigmavav2_ [private]

"sigma" scale fctor for 2-cluster Vavilov distribution

Definition at line 567 of file SiPixelTemplate.h.

Referenced by sigmavav2().

float SiPixelTemplate::sigmavav_ [private]

"sigma" scale fctor for Vavilov distribution

Definition at line 564 of file SiPixelTemplate.h.

Referenced by sigmavav().

bool SiPixelTemplate::success_ [private]

true if cotalpha, cotbeta are inside of the acceptance (dynamically loaded)

Definition at line 496 of file SiPixelTemplate.h.

float SiPixelTemplate::sxmax_ [private]

average pixel signal for x-projection of cluster

Definition at line 511 of file SiPixelTemplate.h.

Referenced by sxmax().

float SiPixelTemplate::sxone_ [private]

rms for one pixel x-clusters

Definition at line 514 of file SiPixelTemplate.h.

Referenced by sxone().

float SiPixelTemplate::sxparmax_ [private]

maximum pixel signal for parameterization of x uncertainties

Definition at line 512 of file SiPixelTemplate.h.

float SiPixelTemplate::sxtwo_ [private]

rms for one double-pixel x-clusters

Definition at line 516 of file SiPixelTemplate.h.

Referenced by sxtwo().

float SiPixelTemplate::symax_ [private]

average pixel signal for y-projection of cluster

Definition at line 505 of file SiPixelTemplate.h.

Referenced by symax().

float SiPixelTemplate::syone_ [private]

rms for one pixel y-clusters

Definition at line 508 of file SiPixelTemplate.h.

Referenced by syone().

float SiPixelTemplate::syparmax_ [private]

maximum pixel signal for parameterization of y uncertainties

Definition at line 506 of file SiPixelTemplate.h.

float SiPixelTemplate::sytwo_ [private]

rms for one double-pixel y-clusters

Definition at line 510 of file SiPixelTemplate.h.

Referenced by sytwo().

boost::multi_array<float,2> SiPixelTemplate::temp2dx_ [private]

2d-primitive for spltting 3-d template

Definition at line 578 of file SiPixelTemplate.h.

boost::multi_array<float,2> SiPixelTemplate::temp2dy_ [private]

2d-primitive for spltting 3-d template

Definition at line 577 of file SiPixelTemplate.h.

Definition at line 583 of file SiPixelTemplate.h.

float SiPixelTemplate::xavg_[4] [private]

average x-bias of reconstruction binned in 4 charge bins

Definition at line 538 of file SiPixelTemplate.h.

Referenced by xavg().

float SiPixelTemplate::xavgc2m_[4] [private]

1st pass chi2 min search: average x-bias of reconstruction binned in 4 charge bins

Definition at line 554 of file SiPixelTemplate.h.

Referenced by xavgc2m().

float SiPixelTemplate::xflparhh_[4][6] [private]

Aqfl-parameterized x-correction in 4 charge bins for larger cotbeta, cotalpha.

Definition at line 545 of file SiPixelTemplate.h.

float SiPixelTemplate::xflparhl_[4][6] [private]

Aqfl-parameterized x-correction in 4 charge bins for larger cotbeta, smaller cotalpha.

Definition at line 544 of file SiPixelTemplate.h.

float SiPixelTemplate::xflparlh_[4][6] [private]

Aqfl-parameterized x-correction in 4 charge bins for smaller cotbeta, larger cotalpha.

Definition at line 543 of file SiPixelTemplate.h.

float SiPixelTemplate::xflparll_[4][6] [private]

Aqfl-parameterized x-correction in 4 charge bins for smaller cotbeta, cotalpha.

Definition at line 542 of file SiPixelTemplate.h.

float SiPixelTemplate::xgsig_[4] [private]

sigma from Gaussian fit binned in 4 charge bins

Definition at line 541 of file SiPixelTemplate.h.

Referenced by xgsig().

float SiPixelTemplate::xgx0_[4] [private]

average x0 from Gaussian fit binned in 4 charge bins

Definition at line 540 of file SiPixelTemplate.h.

Referenced by xgx0().

float SiPixelTemplate::xpar0_[2][5] [private]

projected x-pixel uncertainty parameterization for central cotalpha

Definition at line 528 of file SiPixelTemplate.h.

float SiPixelTemplate::xparh_[2][5] [private]

projected x-pixel uncertainty parameterization for larger cotalpha

Definition at line 530 of file SiPixelTemplate.h.

float SiPixelTemplate::xparhy0_[2][5] [private]

projected x-pixel uncertainty parameterization for larger cotbeta (central alpha)

Definition at line 524 of file SiPixelTemplate.h.

float SiPixelTemplate::xparl_[2][5] [private]

projected x-pixel uncertainty parameterization for smaller cotalpha

Definition at line 529 of file SiPixelTemplate.h.

float SiPixelTemplate::xparly0_[2][5] [private]

projected x-pixel uncertainty parameterization for smaller cotbeta (central alpha)

Definition at line 523 of file SiPixelTemplate.h.

float SiPixelTemplate::xrms_[4] [private]

average x-rms of reconstruction binned in 4 charge bins

Definition at line 539 of file SiPixelTemplate.h.

Referenced by xrms().

float SiPixelTemplate::xrmsc2m_[4] [private]

1st pass chi2 min search: average x-rms of reconstruction binned in 4 charge bins

Definition at line 555 of file SiPixelTemplate.h.

Referenced by xrmsc2m().

float SiPixelTemplate::xsize_ [private]

Pixel x-size.

Definition at line 571 of file SiPixelTemplate.h.

Referenced by xsize().

float SiPixelTemplate::xtemp_[9][BXSIZE] [private]

templates for x-reconstruction (binned over 5 central pixels)

Definition at line 531 of file SiPixelTemplate.h.

float SiPixelTemplate::xxratio_ [private]

fractional distance in x between cotalpha templates

Definition at line 527 of file SiPixelTemplate.h.

Referenced by xxratio().

float SiPixelTemplate::yavg_[4] [private]

average y-bias of reconstruction binned in 4 charge bins

Definition at line 532 of file SiPixelTemplate.h.

Referenced by yavg().

float SiPixelTemplate::yavgc2m_[4] [private]

1st pass chi2 min search: average y-bias of reconstruction binned in 4 charge bins

Definition at line 550 of file SiPixelTemplate.h.

Referenced by yavgc2m().

float SiPixelTemplate::yflparh_[4][6] [private]

Aqfl-parameterized y-correction in 4 charge bins for larger cotbeta.

Definition at line 537 of file SiPixelTemplate.h.

float SiPixelTemplate::yflparl_[4][6] [private]

Aqfl-parameterized y-correction in 4 charge bins for smaller cotbeta.

Definition at line 536 of file SiPixelTemplate.h.

float SiPixelTemplate::ygsig_[4] [private]

average sigma_y from Gaussian fit binned in 4 charge bins

Definition at line 535 of file SiPixelTemplate.h.

Referenced by ygsig().

float SiPixelTemplate::ygx0_[4] [private]

average y0 from Gaussian fit binned in 4 charge bins

Definition at line 534 of file SiPixelTemplate.h.

Referenced by ygx0().

float SiPixelTemplate::yparh_[2][5] [private]

projected y-pixel uncertainty parameterization for larger cotbeta

Definition at line 522 of file SiPixelTemplate.h.

float SiPixelTemplate::yparl_[2][5] [private]

projected y-pixel uncertainty parameterization for smaller cotbeta

Definition at line 521 of file SiPixelTemplate.h.

float SiPixelTemplate::yratio_ [private]

fractional distance in y between cotbeta templates

Definition at line 520 of file SiPixelTemplate.h.

Referenced by yratio().

float SiPixelTemplate::yrms_[4] [private]

average y-rms of reconstruction binned in 4 charge bins

Definition at line 533 of file SiPixelTemplate.h.

Referenced by yrms().

float SiPixelTemplate::yrmsc2m_[4] [private]

1st pass chi2 min search: average y-rms of reconstruction binned in 4 charge bins

Definition at line 551 of file SiPixelTemplate.h.

Referenced by yrmsc2m().

float SiPixelTemplate::ysize_ [private]

Pixel y-size.

Definition at line 572 of file SiPixelTemplate.h.

Referenced by ysize().

float SiPixelTemplate::ytemp_[9][BYSIZE] [private]

templates for y-reconstruction (binned over 5 central pixels)

Definition at line 525 of file SiPixelTemplate.h.

float SiPixelTemplate::yxratio_ [private]

fractional distance in y between x-slices of cotalpha templates

Definition at line 526 of file SiPixelTemplate.h.

Referenced by yxratio().

float SiPixelTemplate::zsize_ [private]

Pixel z-size (thickness)

Definition at line 573 of file SiPixelTemplate.h.

Referenced by zsize().