Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:34

0001 //
0002 //  SiPixelGenError.h (v2.20)
0003 //
0004 //  Object to contain Lorentz drift and error information for the Generic Algorithm
0005 //
0006 // Created by Morris Swartz on 1/10/2014.
0007 //
0008 // Update for Phase 1 FPix, M.S. 1/15/17
0009 //  V2.01 - Allow subdetector ID=5 for FPix R2P2, Fix error message
0010 //  V2.10 - Update the variable size [SI_PIXEL_TEMPLATE_USE_BOOST] option so that it works with VI's enhancements
0011 //  V2.20 - Add directory path selection to the ascii pushfile method
0012 //  V2.21 - Move templateStore to the heap, fix variable name in pushfile()
0013 //  V2.30 - Fix interpolation of IrradiationBias corrections
0014 
0015 // Build the template storage structure from several pieces
0016 
0017 #ifndef SiPixelGenError_h
0018 #define SiPixelGenError_h 1
0019 
0020 #include "SiPixelTemplateDefs.h"
0021 
0022 #include <vector>
0023 #include <cassert>
0024 #include "boost/multi_array.hpp"
0025 
0026 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
0027 #include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h"
0028 #include "FWCore/Utilities/interface/Exception.h"
0029 #endif
0030 
0031 struct SiPixelGenErrorEntry {  //!< Basic template entry corresponding to a single set of track angles
0032   int runnum;                  //!< number of pixelav run used to generate this entry
0033   float cotalpha;              //!< cot(alpha) is proportional to cluster length in x and is basis of interpolation
0034   float cotbeta;               //!< cot(beta) is proportional to cluster length in y and is basis of interpolation
0035   float qavg;                  //!< average cluster charge for this set of track angles (now includes threshold effects)
0036   float pixmax;                //!< maximum charge for individual pixels in cluster
0037   float dyone;                 //!< mean offset/correction for one pixel y-clusters
0038   float syone;                 //!< rms for one pixel y-clusters
0039   float dxone;                 //!< mean offset/correction for one pixel x-clusters
0040   float sxone;                 //!< rms for one pixel x-clusters
0041   float dytwo;                 //!< mean offset/correction for one double-pixel y-clusters
0042   float sytwo;                 //!< rms for one double-pixel y-clusters
0043   float dxtwo;                 //!< mean offset/correction for one double-pixel x-clusters
0044   float sxtwo;                 //!< rms for one double-pixel x-clusters
0045   float qmin;                  //!< minimum cluster charge for valid hit (keeps 99.9% of simulated hits)
0046   float qmin2;
0047   float yavggen[4];  //!< generic algorithm: average y-bias of reconstruction binned in 4 charge bins
0048   float yrmsgen[4];  //!< generic algorithm: average y-rms of reconstruction binned in 4 charge bins
0049   float xavggen[4];  //!< generic algorithm: average x-bias of reconstruction binned in 4 charge bins
0050   float xrmsgen[4];  //!< generic algorithm: average x-rms of reconstruction binned in 4 charge bins
0051 };
0052 
0053 struct SiPixelGenErrorHeader {  //!< template header structure
0054   int ID;                       //!< template ID number
0055   int NTy;                      //!< number of Template y entries
0056   int NTyx;                     //!< number of Template y-slices of x entries
0057   int NTxx;                     //!< number of Template x-entries in each slice
0058   int Dtype;                    //!< detector type (0=BPix, 1=FPix)
0059   float qscale;                 //!< Charge scaling to match cmssw and pixelav
0060   float lorywidth;              //!< estimate of y-lorentz width for optimal resolution
0061   float lorxwidth;              //!< estimate of x-lorentz width for optimal resolution
0062   float lorybias;               //!< estimate of y-lorentz bias
0063   float lorxbias;               //!< estimate of x-lorentz bias
0064   float Vbias;                  //!< detector bias potential in Volts
0065   float temperature;            //!< detector temperature in deg K
0066   float fluence;                //!< radiation fluence in n_eq/cm^2
0067   float s50;                    //!< 1/2 of the multihit dcol threshold in electrons
0068   float ss50;                   //!< 1/2 of the single hit dcol threshold in electrons
0069   char title[80];               //!< template title
0070   int templ_version;            //!< Version number of the template to ensure code compatibility
0071   float Bfield;                 //!< Bfield in Tesla
0072   float fbin[3];                //!< The QBin definitions in Q_clus/Q_avg
0073   float xsize;                  //!< pixel size (for future use in upgraded geometry)
0074   float ysize;                  //!< pixel size (for future use in upgraded geometry)
0075   float zsize;                  //!< pixel size (for future use in upgraded geometry)
0076 };
0077 
0078 struct SiPixelGenErrorStore {  //!< template storage structure
0079   SiPixelGenErrorHeader head;
0080 #ifndef SI_PIXEL_TEMPLATE_USE_BOOST
0081   float cotbetaY[TEMP_ENTRY_SIZEY];
0082   float cotbetaX[TEMP_ENTRY_SIZEX_B];
0083   float cotalphaX[TEMP_ENTRY_SIZEX_A];
0084   //!< 60 y templates spanning cluster lengths from 0px to +18px
0085   SiPixelGenErrorEntry enty[TEMP_ENTRY_SIZEY];
0086   //!< 60 x templates spanning cluster lengths from -6px (-1.125Rad) to +6px (+1.125Rad) in each of 60 slices
0087   SiPixelGenErrorEntry entx[TEMP_ENTRY_SIZEX_B][TEMP_ENTRY_SIZEX_A];
0088 #else
0089   float* cotbetaY;
0090   float* cotbetaX;
0091   float* cotalphaX;
0092   boost::multi_array<SiPixelGenErrorEntry, 1> enty;  //!< use 1d entry to store [60] entries
0093   //!< use 2d entry to store [60][60] entries
0094   boost::multi_array<SiPixelGenErrorEntry, 2> entx;
0095 #endif
0096 };
0097 
0098 // ******************************************************************************************
0099 //! \class SiPixelGenError
0100 //!
0101 //!  A Generic Algorithm info management class.  SiPixelGenError contains thePixelTemp
0102 //!  (a std::vector  of SiPixelGenErrorStore, each of which is a collection of many
0103 //!  SiPixelGenErrorEntries).  Each SiPixelGenErrorStore corresponds to a given detector
0104 //!  condition, and is valid for a range of runs.  We allow more than one Store since the
0105 //!  may change over time.
0106 //!
0107 //!  This class reads templates from files via pushfile() method.
0108 //!
0109 //!  The main functionality of SiPixelGenError is qbin(), which produces algorithm info
0110 //!  on the fly, given a specific track's alpha and beta.
0111 //!
0112 // ******************************************************************************************
0113 class SiPixelGenError {
0114 public:
0115   SiPixelGenError(const std::vector<SiPixelGenErrorStore>& thePixelTemp)
0116       : id_current_(-1),
0117         index_id_(-1),
0118         lorxwidth_(0),
0119         lorywidth_(0),
0120         lorxbias_(0),
0121         lorybias_(0),
0122         fbin_{0, 0, 0},
0123         xsize_(0),
0124         ysize_(0),
0125         zsize_(0),
0126         thePixelTemp_(thePixelTemp) {}  //!< Constructor for cases in which template store already exists
0127 
0128   // Load the private store with info from the file with the index (int) filenum from directory dir:
0129   //   ${dir}generror_summary_zp${filenum}.out
0130   static bool pushfile(int filenum, std::vector<SiPixelGenErrorStore>& pixelTemp, std::string dir = "");
0131 
0132 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
0133   // load the private store with info from db
0134   static bool pushfile(const SiPixelGenErrorDBObject& dbobject, std::vector<SiPixelGenErrorStore>& pixelTemp);
0135 #endif
0136 
0137   // initialize the binary search information;
0138   static void postInit(std::vector<SiPixelGenErrorStore>& thePixelTemp_);
0139 
0140   // Interpolate input beta angle to estimate the average charge. return qbin flag for input cluster charge, and estimate y/x errors and biases for the Generic Algorithm.
0141   int qbin(int id,
0142            float cotalpha,
0143            float cotbeta,
0144            float locBz,
0145            float locBx,
0146            float qclus,
0147            bool irradiationCorrections,
0148            int& pixmx,
0149            float& sigmay,
0150            float& deltay,
0151            float& sigmax,
0152            float& deltax,
0153            float& sy1,
0154            float& dy1,
0155            float& sy2,
0156            float& dy2,
0157            float& sx1,
0158            float& dx1,
0159            float& sx2,
0160            float& dx2);
0161 
0162   // Overload to provide backward compatibility
0163 
0164   int qbin(int id,
0165            float cotalpha,
0166            float cotbeta,
0167            float locBz,
0168            float locBx,
0169            float qclus,
0170            float& pixmx,
0171            float& sigmay,
0172            float& deltay,
0173            float& sigmax,
0174            float& deltax,
0175            float& sy1,
0176            float& dy1,
0177            float& sy2,
0178            float& dy2,
0179            float& sx1,
0180            float& dx1,
0181            float& sx2,
0182            float& dx2);
0183   // Overloaded method to provide only the LA parameters
0184   int qbin(int id);
0185 
0186   float lorywidth() { return lorywidth_; }  //!< signed lorentz y-width (microns)
0187   float lorxwidth() { return lorxwidth_; }  //!< signed lorentz x-width (microns)
0188   float lorybias() { return lorybias_; }    //!< signed lorentz y-bias (microns)
0189   float lorxbias() { return lorxbias_; }    //!< signed lorentz x-bias (microns)
0190 
0191   float fbin(int i) {
0192 #ifndef SI_PIXEL_TEMPLATE_STANDALONE
0193     if (i < 0 || i > 2) {
0194       throw cms::Exception("DataCorrupt")
0195           << "SiPixelTemplate::chi2xminc2m called with illegal index = " << i << std::endl;
0196     }
0197 #else
0198     assert(i >= 0 && i < 3);
0199 #endif
0200     return fbin_[i];
0201   }                                 //!< Return lower bound of Qbin definition
0202   float xsize() { return xsize_; }  //!< pixel x-size (microns)
0203   float ysize() { return ysize_; }  //!< pixel y-size (microns)
0204   float zsize() { return zsize_; }  //!< pixel z-size or thickness (microns)
0205 
0206 private:
0207   // Keep current template interpolaion parameters
0208 
0209   int id_current_;  //!< current id
0210   int index_id_;    //!< current index
0211 
0212   // Keep results of last interpolation to return through member functions
0213 
0214   float lorxwidth_;  //!< Lorentz x-width
0215   float lorywidth_;  //!< Lorentz y-width (sign corrected for fpix frame)
0216   float lorxbias_;   //!< Lorentz x-width
0217   float lorybias_;   //!< Lorentz y-width (sign corrected for fpix frame)
0218   float fbin_[3];    //!< The QBin definitions in Q_clus/Q_avg
0219   float xsize_;      //!< Pixel x-size
0220   float ysize_;      //!< Pixel y-size
0221   float zsize_;      //!< Pixel z-size (thickness)
0222 
0223   // The actual template store is a std::vector container
0224 
0225   const std::vector<SiPixelGenErrorStore>& thePixelTemp_;
0226 };
0227 
0228 #endif