00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef DETECTOR_H
00011 #define DETECTOR_H
00012
00013 #include <map>
00014 #include <math.h>
00015 #include <string>
00016 #include <Math/SMatrix.h>
00017 #include <Math/SVector.h>
00018 #include <TObject.h>
00019
00020 #include "ROC.h"
00021 #include "MessageTools.h"
00022 namespace monicelli
00023 {
00024
00025 class Detector: public TObject
00026 {
00027 public:
00028 Detector(std::string ID = "", bool isDUT = false);
00029 virtual ~Detector(void);
00030
00031 ROC* addROC(unsigned int ROCPosition, int ROCID , unsigned int rotationDegrees = 0);
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 typedef ROOT::Math::SMatrix<double,3,3> matrix33Def;
00052 typedef ROOT::Math::SMatrix<double,4,4> matrix44Def;
00053 typedef std::pair<double, double> xyPair ;
00054 typedef std::pair<int,int > rowColPair ;
00055
00056 void setupVariables (void);
00057 ROC* convertPixelToROC (unsigned int* detector_row, unsigned int* detector_col);
00058 void convertPixelFromROC (ROC* roc, unsigned int* roc_row, unsigned int* roc_col);
00059 void fromGlobalToLocal (double* x, double* y, double* z, double* xErr, double* yErr, double* zErr);
00060 void fromGlobalToLocal (double* x, double* y, double* z);
00061 double fromLocalToGlobal (double* x, double* y, double* z, double* xErr, double* yErr, double* zErr);
00062 void fromLocalToGlobal (double* x, double* y, double* z);
00063 void fromLocalToGlobalNoRotation (double* x, double* y, double* xErr, double* yErr);
00064 void flipPositionLocal (double* x, double* y, double* xErr=0, double* yErr=0 );
00065 void flipBackPositionLocal (double* x, double* y, double* xErr=0, double* yErr=0 );
00066 void flipPixel (unsigned int* row, unsigned int* col );
00067 void flipBackPixel (unsigned int* row, unsigned int* col );
00068 void flipDistance (double* deltaX, double* deltaY );
00069 void flipBackDistance (double* deltaX, double* deltaY );
00070
00071 bool switchXYFromLocaToGlobal (void);
00072
00073 matrix33Def getRotationMatrix ( );
00074
00075 unsigned int getNumberOfCols (bool global = false ) ;
00076 unsigned int getNumberOfRows (bool global = false ) ;
00077 unsigned int getLastCol (void ) {return (this->getNumberOfCols()-1) ;}
00078 unsigned int getLastRow (void ) {return (this->getNumberOfRows()-1) ;}
00079 ROC * getROC (int chipID ) ;
00080 ROC * getROCByPosition (unsigned int chipPosition) ;
00081 ROC * findROC (unsigned int row, unsigned int col ) ;
00082 unsigned int getNumberOfROCs ( void ) {return numberOfROCs_ ;}
00083 unsigned int getROCPositionLocalX (int chipID ) ;
00084 unsigned int getROCPositionLocalY (int chipID ) ;
00085 unsigned int getROCPositionLocalXFromCol (unsigned int col ) ;
00086 unsigned int getROCPositionLocalYFromRow (unsigned int row ) ;
00087 unsigned int getNumberOfROCsLocalX (void ) {return xNumberOfROCs_ ;}
00088 unsigned int getNumberOfROCsLocalY (void ) {return yNumberOfROCs_ ;}
00089
00090 double getPixelCenterLocalX (unsigned int col ) ;
00091 double getPixelCenterLocalY (unsigned int row ) ;
00092 double getPixelLowEdgeLocalX (unsigned int col ) ;
00093 double getPixelLowEdgeLocalY (unsigned int row ) ;
00094 double getPixelPitchLocalX (unsigned int col ) ;
00095 double getPixelPitchLocalY (unsigned int row ) ;
00096 int getPixelColFromLocalX (double xLocal ) ;
00097 int getPixelRowFromLocalY (double yLocal ) ;
00098 rowColPair getPixelCellFromLocal (double x, double y ) ;
00099 rowColPair getPixelCellFromGlobal (double x, double y, double z ) ;
00100 double getAlignmentPredictedGlobal (ROOT::Math::SVector<double,4>& trackPars, matrix33Def& RInv, double z, double& predX, double& predY);
00101 void getPredictedGlobal (ROOT::Math::SVector<double,4>& trackPars, double& predX, double& predY, double& predZ) ;
00102 void getPredictedLocal (ROOT::Math::SVector<double,4>& trackPars, double& predX, double& predY) ;
00103 xyPair getTrackErrorsOnPlane (ROOT::Math::SVector<double,4>& trackPars, matrix44Def& AtVAInv) ;
00104 xyPair propagateTrackErrors (ROOT::Math::SVector<double,4>& trackPars, matrix44Def& AtVAInv, Detector::matrix33Def& RInv, double z);
00105 std::string getID (void ) {return ID_;}
00106 double getDetectorLengthX (bool global = false ) ;
00107 double getDetectorLengthY (bool global = false ) ;
00108
00109 double getXPositionTotal (void ) {return xPosition_+xPositionCorrection_;}
00110 double getYPositionTotal (void ) {return yPosition_+yPositionCorrection_;}
00111 double getZPositionTotal (void ) {return zPosition_+zPositionCorrection_;}
00112 double getXPosition (void ) {return xPosition_ ;}
00113 double getXPositionCorrection (void ) {return xPositionCorrection_ ;}
00114 double getXPositionError (void ) {return xPositionError_ ;}
00115 double getYPosition (void ) {return yPosition_ ;}
00116 double getYPositionCorrection (void ) {return yPositionCorrection_ ;}
00117 double getYPositionError (void ) {return yPositionError_ ;}
00118 double getZPosition (void ) {return zPosition_ ;}
00119 double getZPositionCorrection (void ) {return zPositionCorrection_ ;}
00120 double getZPositionError (void ) {return zPositionError_ ;}
00121 double getXRotation (bool global_coordinate = true ) ;
00122 double getXRotationCorrection (void ) {return xRotationCorrection_ ;}
00123 double getXRotationCorrectionError (void ) {return xRotationCorrectionError_;}
00124 double getYRotation (bool global_coordinate = true ) ;
00125 double getYRotationCorrection (void ) {return yRotationCorrection_ ;}
00126 double getYRotationCorrectionError (void ) {return yRotationCorrectionError_;}
00127 double getZRotation (void ) {return zRotation_ ;}
00128 double getZRotationCorrection (void ) {return zRotationCorrection_ ;}
00129 double getZRotationCorrectionError (void ) {return zRotationCorrectionError_;}
00130
00131 bool isDUT (void ) {return isDUT_ ;}
00132 bool isXBackFlipped (void ) {return xBackFlipped_ ;}
00133 bool isYBackFlipped (void ) {return yBackFlipped_ ;}
00134
00135 static matrix33Def rotationMatrix (double alpha, double beta, double gamma );
00136
00137 void setDUT (bool isDUT = true ) {isDUT_=isDUT ;}
00138
00139 void setXBackFlipped ( bool isIt ) {xBackFlipped_ = isIt ;}
00140 void setYBackFlipped ( bool isIt ) {yBackFlipped_ = isIt ;}
00141 void setPosition (double x, double y, double z) {xPosition_ = x; yPosition_ = y; zPosition_ = z;}
00142 void setNumberOfROCs (unsigned int xNumberOfROCs, unsigned int yNumberOfROCs ) ;
00143 void setXNumberOfROCs (unsigned int xNumberOfROCs) {xNumberOfROCs_=xNumberOfROCs; this->updateNumberOfROCs() ;}
00144 void setYNumberOfROCs (unsigned int yNumberOfROCs) {yNumberOfROCs_=yNumberOfROCs; this->updateNumberOfROCs() ;}
00145
00146 void setXPosition (double x) {xPosition_ = x ;}
00147 void setXPositionCorrection (double xCorr) {xPositionCorrection_ = xCorr ;}
00148 void setXPositionError (double xErr) {xPositionError_ = xErr ;}
00149 void setYPosition (double y) {yPosition_ = y ;}
00150 void setYPositionCorrection (double yCorr) {yPositionCorrection_ = yCorr ;}
00151 void setYPositionError (double yErr) {yPositionError_ = yErr ;}
00152 void setZPosition (double z) {zPosition_ = z ;}
00153 void setZPositionCorrection (double zCorr) {zPositionCorrection_ = zCorr ;}
00154 void setZPositionError (double zErr) {zPositionError_ = zErr ;}
00155 void setXRotation (double xRot) {xRotation_ = xRot ;}
00156 void setXRotationCorrection (double xRotCor) {xRotationCorrection_ = xRotCor ;}
00157 void setXRotationCorrectionError (double xRotCorErr) {xRotationCorrectionError_ = xRotCorErr;}
00158 void setYRotation (double y) {yRotation_ = y ;}
00159 void setYRotationCorrection (double yRotCor) {yRotationCorrection_ = yRotCor ;}
00160 void setYRotationCorrectionError (double yRotCorErr) {yRotationCorrectionError_ = yRotCorErr;}
00161 void setZRotation (double z) {zRotation_ = z ;}
00162 void setZRotationCorrection (double zRotCor) {zRotationCorrection_ = zRotCor ;}
00163 void setZRotationCorrectionError (double zRotCorErr) {zRotationCorrectionError_ = zRotCorErr;}
00164
00165 void dump (void);
00166 typedef std::map<int, ROC*>::iterator iterator;
00167 iterator begin(void) {return ROCsChipIDMap_.begin();}
00168 iterator end (void) {return ROCsChipIDMap_.end(); }
00169 void test(double* x, double* y, double* z,double* xErr, double* yErr, double* zErr);
00170
00171
00172 private:
00173 void XYZRotation (double* x, double* y, double* z, double* xErr, double* yErr, double* zErr, bool backward = false);
00174 void XYZRotation (double* x, double* y, double* z, bool backward = false);
00175 void XRotation (double* y, double* z, double* yErr, double* zErr, bool backward = false);
00176 void YRotation (double* x, double* z, double* xErr, double* zErr, bool backward = false);
00177 void ZRotation (double* x, double* y, double* xErr, double* yErr, bool backward = false);
00178 void XRotation (double* y, double* z, bool backward = false);
00179 void YRotation (double* x, double* z, bool backward = false);
00180 void ZRotation (double* x, double* y, bool backward = false);
00181 void translateXY (double* x, double* y, bool backward = false);
00182 void translateCorrection (double* x, double* y, bool backward = false);
00183
00184 void updateNumberOfROCs (void){numberOfROCs_=xNumberOfROCs_*yNumberOfROCs_ ;}
00185
00186 typedef std::map<int, ROC*> ROCsMapDef ;
00187 ROCsMapDef ROCsChipIDMap_ ;
00188 ROCsMapDef ROCsPositionMap_ ;
00189
00190 std::string ID_ ;
00191 bool isDUT_ ;
00192
00193 double xPosition_ ;
00194 double xPositionCorrection_ ;
00195 double xPositionError_ ;
00196 double yPosition_ ;
00197 double yPositionCorrection_ ;
00198 double yPositionError_ ;
00199 double zPosition_ ;
00200 double zPositionCorrection_ ;
00201 double zPositionError_ ;
00202
00203
00204 unsigned int xNumberOfROCs_ ;
00205 unsigned int yNumberOfROCs_ ;
00206 unsigned int numberOfROCs_ ;
00207 unsigned int numberOfRows_ ;
00208 unsigned int numberOfCols_ ;
00209
00210
00211 bool xBackFlipped_ ;
00212 bool yBackFlipped_ ;
00213
00214 double xRotation_ ;
00215 double xRotationCorrection_ ;
00216 double xRotationCorrectionError_ ;
00217 double yRotation_ ;
00218 double yRotationCorrection_ ;
00219 double yRotationCorrectionError_ ;
00220 double zRotation_ ;
00221 double zRotationCorrection_ ;
00222 double zRotationCorrectionError_ ;
00223
00224
00225
00226 ClassDef(Detector,1)
00227
00228 } ;
00229 }
00230 #endif // DETECTOR_H