00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ROC_H
00011 #define ROC_H
00012
00013 #include <string>
00014 #include <map>
00015 #include <string>
00016 #include <vector>
00017 #include <TObject.h>
00018
00019 #include <Math/SMatrix.h>
00020 #include <Math/SVector.h>
00021
00022 #include "MessageTools.h"
00023
00024 namespace monicelli
00025 {
00026
00027 class ROC : public TObject
00028 {
00029 public:
00030 ROC(unsigned int position=0, int chipID=-1, unsigned int degrees=0);
00031 ~ROC(void) {;}
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 static double calibrationFitFunction (double * x, double * par );
00061 double calibrationFitFunctionInv(double * x, double * par );
00062 bool calibratePixel (int row, int col, int adc, int& charge );
00063
00064 void setCalibrationFilePath (std::string path ) {calibrationFilePath_= path; }
00065
00066 void setCalibrationFunction (int row, int col, double *par, double *cov) ;
00067 void setStandardPixPitch (double raw_cm , double col_cm ) ;
00068 void setOneRowPitch (unsigned int raw , double row_cm ) ;
00069 void setOneColPitch (unsigned int col , double col_cm ) ;
00070 void setOrientation (unsigned int degrees ) ;
00071 void setNumberOfRowsCols (unsigned int maxRows , unsigned int maxCols ) ;
00072 void setNumberOfRows (unsigned int maxRows ) ;
00073 void setNumberOfCols (unsigned int maxCols ) ;
00074 void setLocalXPosition (unsigned int xLocalPosition ) {xLocalPosition_ = xLocalPosition;}
00075 void setLocalYPosition (unsigned int yLocalPosition ) {yLocalPosition_ = yLocalPosition;}
00076 void setFirstRow (unsigned int firstRow ) {firstRow_ = firstRow; }
00077 void setLastRow (unsigned int lastRow ) {lastRow_ = lastRow; }
00078 void setFirstCol (unsigned int firstCol ) {firstCol_ = firstCol; }
00079 void setLastCol (unsigned int lastCol ) {lastCol_ = lastCol; }
00080
00081 std::string getCalibrationFilePath (void ) {return calibrationFilePath_; }
00082 int getID (void ) {return chipID_; }
00083 unsigned int getOrientation (void ) {return orientation_; }
00084 unsigned int getPosition (void ) {return position_; }
00085 double getPixelCenterLocalX (unsigned int col ) ;
00086 double getPixelCenterLocalY (unsigned int row ) ;
00087 double getPixelHiEdgeLocalX (unsigned int col ) ;
00088 double getPixelHiEdgeLocalY (unsigned int row ) ;
00089 double getPixelLowEdgeLocalX (unsigned int col ) ;
00090 double getPixelLowEdgeLocalY (unsigned int row ) ;
00091 double getPixelPitchLocalX (unsigned int col ) ;
00092 double getPixelPitchLocalY (unsigned int row ) ;
00093 double getLengthLocalX (void ) ;
00094 double getLengthLocalY (void ) ;
00095
00096 double getCalibrationError (int row, int col ,int adc ) ;
00097 double* getCalibrationFunction (int row, int col ) ;
00098 bool isPixelCalibrated (int row, int col ) ;
00099
00100 unsigned int getNumberOfRows (void ) {return numberOfRows_; }
00101 unsigned int getNumberOfCols (void ) {return numberOfCols_; }
00102 unsigned int getPositionLocalX (void ) {return xLocalPosition_; }
00103 unsigned int getPositionLocalY (void ) {return yLocalPosition_; }
00104 unsigned int getFirstRow (void ) {return firstRow_; }
00105 unsigned int getLastRow (void ) {return lastRow_; }
00106 unsigned int getFirstCol (void ) {return firstCol_; }
00107 unsigned int getLastCol (void ) {return lastCol_; }
00108
00109
00110
00111 private:
00112
00113 typedef std::map< int,std::map<int, ROOT::Math::SMatrix<double,4> > > pixelCalibrationsCovDef ;
00114
00115 typedef std::pair<double, double > rowColPitchPairDef ;
00116
00117 typedef std::map<unsigned int , double> nonStandardPitchMapDef ;
00118
00119 typedef std::map< int,std::map<int, double*> > pixelCalibrationsMapDef ;
00120
00121 typedef std::map< int,std::map<int, std::vector<double> > > pixelCalibrationsTmpMapDef ;
00122
00123 bool goodRow (unsigned int row);
00124 bool goodCol (unsigned int col);
00125 void setRowPitchVector(void);
00126 void setColPitchVector(void);
00127 std::vector<double> rowPitches_;
00128 std::vector<double> colPitches_;
00129 std::vector<double> rowLowEdge_;
00130 std::vector<double> colLowEdge_;
00131 double rocLengthX_;
00132 double rocLengthY_;
00133
00134 unsigned int numberOfRows_ ;
00135
00136 unsigned int numberOfCols_ ;
00137
00138
00139 int chipID_ ;
00140 unsigned int orientation_ ;
00141 unsigned int position_ ;
00142 rowColPitchPairDef standardPixelPitch_ ;
00143 nonStandardPitchMapDef nonStandardRowPitch_ ;
00144 nonStandardPitchMapDef nonStandardColPitch_ ;
00145 std::string calibrationFilePath_ ;
00146
00147 pixelCalibrationsTmpMapDef pixelCalibrationFunctionTmp_ ;
00148 pixelCalibrationsCovDef pixelCalibrationCovMat_ ;
00149 double par_[4] ;
00150
00151
00152 unsigned int xLocalPosition_;
00153 unsigned int yLocalPosition_;
00154 unsigned int firstRow_;
00155 unsigned int lastRow_;
00156 unsigned int firstCol_;
00157 unsigned int lastCol_;
00158
00159
00160 std::stringstream ss_ ;
00161
00162 ClassDef(ROC,5)
00163
00164 } ;
00165 }
00166 #endif // ROC_H