#ifndef HGEOBASICSHAPES_H #define HGEOBASICSHAPES_H #include "geantdef.h" // // baseclass for all shapes // // The routines readPoints(...) read 8 points (x,y,z) from database ore file and // are used to read a BOX, TRAP or TRD1. (These shapes have 8 corners in the // technical drawings. The enumeration starts at the lower left corner of the // bottom plane and reads the points in clockwise direction.) The values are // stored in the vector vol of class HGeoParam. // All other shapes have their own routines readPoints(...) both for reading // from file or database. // // Every derived shapeclass have their own routines calcShape(...) and // posShape(...). // In the function calcShape(...) of the derived classes the shape-parameters for // Geant are calculated and stored in the vector volPar of class HGeoShapePar. // In the function posShape(...) of the derived classes different functions are // called position a volume in a mothers depending on their shapes. These // informations are stored in the class HGeoShapePar. // #include "hgeoparam.h" #include "hgeoshapepar.h" #include "hgeoinfo.h" #include "hadesstd.h" #include #include "hmathfnt.h" //#include #if defined (WITHGEANT) || (WITHFORTRAN) #include "cfortran.h" #endif #ifdef WITHGEANT #include "geant321.h" #endif typedef HFloatVec FVec; class HGeoBasicShapes { public: HGeoBasicShapes() : uniRot(0.F,9),cgRot(0.F,9) { for(int i=0;i<3;i++) {uniRot[3*i+i]=1.F;} nCorners=8; } ~HGeoBasicShapes(){} // reads points (x,y,z) from database virtual int readPointsDb(HGeoInfo & geoInfo, HGeoParam & ele); // reads 8 points (x,y,z) from file virtual int readPoints(HGeoInfo & geoInfo, HGeoParam & ele); // purely virtual function to calculate shape-parameters for Geant virtual void calcShape(HGeoParam & ele, HGeoShapePar & shapePar){}; // purely virtual function to call different functions depending on the // the shape of the volume (ele). In these functions // the position of the volume inside its mother is calculated. virtual int posShape(HGeoParam & ele, HGeoParam & mo, HGeoShapePar & shapePar) { return HFAILURE; } // makes the Geant rotation and calculates the Geant position int posInMother(HGeoParam & ele, HGeoParam & mo,HGeoShapePar & shapePar); // writes 8 points (x,y,z) to file virtual int writePoints(ofstream & fout, HGeoParam & ele); private: // some helperfuntions to make the transformations // a matrix is described as a float vector with 9 elements listed // rowwise // checks if a rotation matrix described a a vector with 9 elements // is a unity matrix bool checkUnity(FVec & r); // transposes a matrix void transposeMatrix(FVec & r, FVec & tr); // multiplies two matrices void multiplyMatrices(FVec & lr, FVec & rr, FVec & pr); // multipies a matrix and a vector (rotates the vector) void rotateVector(FVec & r, FVec & v, FVec & rv); protected: // number of 'corners' int nCorners; // unity matrix (no rotation); FVec uniRot; // rotational matrix to transform the technical coordinate system of the // shape to the coordinate system defined in Geant; // only for TRAP and TRD1 the definitions are different FVec cgRot; }; #endif