#ifndef ALHOLDER_HH #define AHOLDER_HH 1 // // This class holds one set of alignment constants for the silicon system // It has operators to add or subtract alignments for combining pieces // or comparing. It can read or write them to files or to the database // On input, files may be incomplete, they might contain only lines from // one detector for example. Each line is self-identified and self-contained. // // // // AlHolder a,b,c; // a.readFromFile("a.txt"); // read SVX data from a, for example // a.readFromFile("b.txt"); // read ISL data from b // c=a+b; // b.putDatabase("ofotl_dev",100000,1); // db, run, version // c=10000.0*c; // scale it up for easier reading // std::cout << c; // // // Ray Culbertson, FNAL // 10/7/00 - original // 11/2/01 - move db access to a subclass // #include class AlDigiCode; class AlTransform { friend std::ostream& operator << (std::ostream& os, const AlTransform& rhs); friend std::istream& operator >> (std::istream& is, AlTransform& rhs); friend const AlTransform operator * (const double& lhs, const AlTransform& rhs); public: AlTransform():tx(0),ty(0),tz(0),ax(0),ay(0),az(0) {} AlTransform(double tx, double ty, double tz, double ax, double ay, double az): tx(tx),ty(ty),tz(tz),ax(ax),ay(ay),az(az) {} AlTransform operator + (const AlTransform& rhs) { return AlTransform(tx + rhs.tx, ty + rhs.ty, tz + rhs.tz, ax + rhs.ax, ay + rhs.ay, az + rhs.az); } const AlTransform operator - (const AlTransform& rhs) { return AlTransform(tx - rhs.tx, ty - rhs.ty, tz - rhs.tz, ax - rhs.ax, ay - rhs.ay, az - rhs.az); } double tx,ty,tz,ax,ay,az; }; class AlWaferTable { friend std::ostream& operator << (std::ostream& os, const AlWaferTable& rhs); friend std::istream& operator >> (std::istream& is, AlWaferTable& rhs); friend const AlWaferTable operator * (const double& lhs, const AlWaferTable& rhs); public: AlWaferTable():dr(0),sty(0),stz(0),sax(0) {}; AlWaferTable(AlTransform tr, double dr, double sty, double stz, double sax): tr(tr),dr(dr),sty(sty),stz(stz),sax(sax) {}; const AlWaferTable operator + (const AlWaferTable& rhs) { return AlWaferTable(tr + rhs.tr, dr + rhs.dr, sty + rhs.sty, stz + rhs.stz, sax + rhs.sax); } const AlWaferTable operator - (const AlWaferTable& rhs) { return AlWaferTable(tr - rhs.tr, dr - rhs.dr, sty - rhs.sty, stz - rhs.stz, sax - rhs.sax); } AlTransform tr; double dr; // stereo layer relative to r-phi double sty,stz,sax; }; class AlWaferWarpTable { friend std::ostream& operator << (std::ostream& os, const AlWaferWarpTable& rhs); friend std::istream& operator >> (std::istream& is, AlWaferWarpTable& rhs); friend const AlWaferWarpTable operator * (const double& lhs, const AlWaferWarpTable& rhs); public: AlWaferWarpTable():byy(0),byz(0),bzz(0) {}; AlWaferWarpTable(double byy, double byz, double bzz): byy(byy),byz(byz),bzz(bzz) {}; const AlWaferWarpTable operator + (const AlWaferWarpTable& rhs) { return AlWaferWarpTable(byy + rhs.byy, byz + rhs.byz, bzz + rhs.bzz); } const AlWaferWarpTable operator - (const AlWaferWarpTable& rhs) { return AlWaferWarpTable(byy - rhs.byy, byz - rhs.byz, bzz - rhs.bzz); } double byy,byz,bzz; }; class AlHolder { public: AlHolder(); ~AlHolder(); //read or write to a file in easy-to-read format int writeToFile(char* filename); int readFromFile(char* filename); // read them or write them in a readable format friend std::ostream& operator << (std::ostream& os, const AlHolder& rhs); friend std::istream& operator >> (std::istream& is, AlHolder& rhs); // set the constants to a regular pattern, for tests void setToTestPattern0(); // or random, for tests void setToRandom(int seed = 0); const AlHolder operator + (const AlHolder& rhs); const AlHolder operator - (const AlHolder& rhs); // this allows scaling of the constants which might // be convenient for tests or for visualization friend const AlHolder operator * (const double& lhs, const AlHolder& rhs); friend const AlHolder operator * (const AlHolder& lhs, const double& rhs) {return rhs*lhs;}; // set values from arbitrary sources void setFrame(const double tx, const double ty, const double tz, const double ax, const double ay, const double az); void setBarrel(AlDigiCode& al, const double tx, const double ty, const double tz, const double ax, const double ay, const double az); void setLadder(AlDigiCode& al, const double tx, const double ty, const double tz, const double ax, const double ay, const double az); void setWafer(AlDigiCode& al, const double tx, const double ty, const double tz, const double ax, const double ay, const double az, const double dr, const double sty, const double stz, const double sax); void setWarp(AlDigiCode& al, const double byy, const double byz, const double bzz); // get values to arbitrary caller // arguments are filled on return except for AlDigiCode, // which is an input void getFrame(double& tx, double& ty, double& tz, double& ax, double& ay, double& az); void getBarrel(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az); void getLadder(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az); void getWafer(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az, double& dr, double& sty, double& stz, double& sax); void getWarp(AlDigiCode& al, double& byy, double& byz, double& bzz); // get values to arbitrary caller AlTransform getFrame(); AlTransform getBarrel(AlDigiCode al); AlTransform getLadder(AlDigiCode al); AlWaferTable getWafer(AlDigiCode al); AlWaferWarpTable getWarp(AlDigiCode al); protected: // the numbers of entries in each type of alignment database table enum ALNUMBER {NWAFERS=1752, NLADDERS=352, NBARRELS=8}; // these contain the alignment data AlWaferTable _wafer[NWAFERS]; AlWaferWarpTable _waferwarp[NWAFERS]; AlTransform _ladder[NLADDERS]; AlTransform _barrel[NBARRELS]; AlTransform _spaceframe; // these are very approximate sizes of the parameters that // will lead to deviations on the order of 5microns if applied to a wafer static const double SMALLTX,SMALLTY,SMALLTZ,SMALLAX,SMALLAY,SMALLAZ; static const double SMALLDR,SMALLBYY,SMALLBYZ,SMALLBZZ; static const double SMALLSTY,SMALLSTZ,SMALLSAX; // the same for a ladder static const double SMALLLADTX,SMALLLADTY,SMALLLADTZ; static const double SMALLLADAX,SMALLLADAY,SMALLLADAZ; // the same for a barrel static const double SMALLBARTX,SMALLBARTY,SMALLBARTZ; static const double SMALLBARAX,SMALLBARAY,SMALLBARAZ; // the same for the spaceframe static const double SMALLFRATX,SMALLFRATY,SMALLFRATZ; static const double SMALLFRAAX,SMALLFRAAY,SMALLFRAAZ; }; // end class #endif