CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/RecoLocalTracker/SiPixelRecHits/interface/SiPixelTemplate2D.h

Go to the documentation of this file.
00001 //
00002 //  SiPixelTemplate2D.h (v1.03)
00003 //
00004 //  Full 2-D templates for cluster splitting, simulated cluster reweighting, and improved cluster probability
00005 //
00006 // Created by Morris Swartz on 12/01/09.
00007 // Copyright 2009 __TheJohnsHopkinsUniversity__. All rights reserved.
00008 // V1.01 - fix qavg_ filling
00009 // V1.02 - Add locBz to test if FPix use is out of range
00010 // V1.03 - Fix edge checking on final template to increase template size and to properly truncate cluster
00011 //
00012 //
00013  
00014 // Build the template storage structure from several pieces 
00015 
00016 #ifndef SiPixelTemplate2D_h
00017 #define SiPixelTemplate2D_h 1
00018 
00019 #include "RecoLocalTracker/SiPixelRecHits/interface/SiPixelTemplateDefs.h"
00020 
00021 #include<vector>
00022 #include<cassert>
00023 #include "boost/multi_array.hpp"
00024 
00025 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00026 #include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
00027 #include "FWCore/Utilities/interface/Exception.h"
00028 #endif
00029 
00030 struct SiPixelTemplateEntry2D { 
00031   int runnum;              
00032   float cotalpha;          
00033   float cotbeta;           
00034   float costrk[3];         
00035   float qavg;              
00036   float pixmax;            
00037   float sxymax;            
00038   int iymin;               
00039   int iymax;               
00040   int jxmin;               
00041   int jxmax;               
00042   float xypar[2][5];       
00043   float lanpar[2][5];      
00044   float xytemp[7][7][T2YSIZE][T2XSIZE];  
00045   float chi2avg[4];        
00046   float chi2min[4];        
00047   float chi2avgone;        
00048   float chi2minone;        
00049   float spare[20];
00050 } ;
00051 
00052 
00053 
00054 
00055 struct SiPixelTemplateHeader2D {           
00056   char title[80];         
00057   int ID;                 
00058   int templ_version;      
00059   float Bfield;           
00060   int NTy;                
00061   int NTyx;               
00062   int NTxx;               
00063   int Dtype;              
00064   float Vbias;            
00065   float temperature;      
00066   float fluence;          
00067   float qscale;           
00068   float s50;              
00069   float lorywidth;        
00070   float lorxwidth;        
00071   float xsize;            
00072   float ysize;            
00073   float zsize;            
00074 } ;
00075 
00076 
00077 
00078 struct SiPixelTemplateStore2D { 
00079   SiPixelTemplateHeader2D head;
00080   boost::multi_array<SiPixelTemplateEntry2D,2> entry;     
00081 } ;
00082 
00083 
00084 
00085 
00086 
00087 // ******************************************************************************************
00105 // ******************************************************************************************
00106 class SiPixelTemplate2D {
00107  public:
00108   SiPixelTemplate2D() {id_current_ = -1; index_id_ = -1; cota_current_ = 0.; cotb_current_ = 0.;} 
00109   bool pushfile(int filenum);     // load the private store with info from the 
00110                                   // file with the index (int) filenum
00111                                                                   
00112 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00113   bool pushfile(const SiPixelTemplateDBObject& dbobject);     // load the private store with info from db
00114 #endif
00115   
00116         
00117 // Interpolate input alpha and beta angles to produce a working template for each individual hit. 
00118         
00119   bool xytemp(int id, float cotalpha, float cotbeta, float locBz, float xhit, float yhit, std::vector<bool>& ydouble, std::vector<bool>& xdouble, float template2d[BXM2][BYM2]);
00120         
00121 // Overload to allow user to avoid the locBz information
00122         
00123   bool xytemp(int id, float cotalpha, float cotbeta, float xhit, float yhit, std::vector<bool>& ydouble, std::vector<bool>& xdouble, float template2d[BXM2][BYM2]);
00124         
00125 // Get pixel signal uncertainties 
00126         
00127   void xysigma2(float qpixel, int index, float& xysig2);
00128 
00129 // Get the interpolated Landau distribution parameters
00130         
00131   void landau_par(float lanpar[2][5]);
00132   
00133   float qavg() {return qavg_;}        
00134   float pixmax() {return pixmax_;}    
00135   float qscale() {return qscale_;}    
00136   float s50() {return s50_;}          
00137   float sxymax() {return sxymax_;}    
00138   float xytemp(int j, int i) {        
00139 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00140                 if(j < 0 || j > BXM3 || i < 0 || i > BYM3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate2D::xytemp called with illegal indices = " << j << "," << i << std::endl;}
00141 #else     
00142                 assert((j>=0 && j<BYM2) && (i>=0 && i<BYM2)); 
00143 #endif
00144         return xytemp_[j][i];} 
00145         float chi2avg(int i) {
00146 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00147           if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate2D::chi2yavg called with illegal index = " << i << std::endl;}
00148 #else     
00149           assert(i>=0 && i<4); 
00150 #endif
00151      return chi2avg_[i];} 
00152   float chi2min(int i) {
00153 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
00154           if(i < 0 || i > 3) {throw cms::Exception("DataCorrupt") << "SiPixelTemplate2D::chi2ymin called with illegal index = " << i << std::endl;}
00155 #else             
00156      assert(i>=0 && i<4); 
00157 #endif
00158   return chi2min_[i];} 
00159   float chi2avgone() {return chi2avgone_;}                        
00160   float chi2minone() {return chi2minone_;}                        
00161   float lorywidth() {return lorywidth_;}                            
00162   float lorxwidth() {return lorxwidth_;}                            
00163   float xsize() {return xsize_;}                                    
00164   float ysize() {return ysize_;}                                    
00165   float zsize() {return zsize_;}                                    
00166   int storesize() {return (int)thePixelTemp_.size();}                    
00167   
00168  private:
00169   
00170   // Keep current template interpolaion parameters      
00171   
00172         int id_current_;           
00173         int index_id_;             
00174         float cota_current_;       
00175         float cotb_current_;       
00176         int Nyx_;                  
00177         int Nxx_;                  
00178         int Dtype_;                
00179         float cotbeta0_;           
00180         float cotbeta1_;           
00181         float deltacotb_;          
00182         float cotalpha0_;          
00183         float cotalpha1_;          
00184         float deltacota_;          
00185         int iy0_;                  
00186         int iy1_;                  
00187         float adcotb_;             
00188         int jx0_;                  
00189         int jx1_;                  
00190         float adcota_;             
00191         bool success_;             
00192         
00193   
00194   // Keep results of last interpolation to return through member functions
00195   
00196   float qavg_;              
00197   float pixmax_;            
00198   float qscale_;            
00199   float s50_;               
00200   float sxymax_;            
00201   float xytemp_[BXM2][BYM2];
00202   float xypary0x0_[2][5];   
00203   float xypary1x0_[2][5];   
00204   float xypary0x1_[2][5];   
00205   float lanpar_[2][5];      
00206   float chi2avg_[4];       
00207   float chi2min_[4];       
00208   float chi2avgone_;       
00209   float chi2minone_;       
00210   float lorywidth_;         
00211   float lorxwidth_;         
00212   float xsize_;             
00213   float ysize_;             
00214   float zsize_;             
00215   
00216   // The actual template store is a std::vector container
00217 
00218   std::vector< SiPixelTemplateStore2D > thePixelTemp_;
00219 } ;
00220 
00221 
00222 #endif