#include #include #include #include #include "Alignment/AlHolder.hh" #include "Alignment/AlDigiCode.hh" const double AlHolder::SMALLTX = 0.0020; const double AlHolder::SMALLTY = 0.0005; const double AlHolder::SMALLTZ = 0.0010; const double AlHolder::SMALLAX = 0.00025; const double AlHolder::SMALLAY = 0.001; const double AlHolder::SMALLAZ = 0.0010; const double AlHolder::SMALLDR = 0.0020; const double AlHolder::SMALLSTY = 0.0005; const double AlHolder::SMALLSTZ = 0.0020; const double AlHolder::SMALLSAX = 0.0002; const double AlHolder::SMALLBYY = 0.00025; const double AlHolder::SMALLBYZ = 0.0005; const double AlHolder::SMALLBZZ = 0.001; const double AlHolder::SMALLLADTX = 0.0020; const double AlHolder::SMALLLADTY = 0.0005; const double AlHolder::SMALLLADTZ = 0.0010; const double AlHolder::SMALLLADAX = 0.00006; const double AlHolder::SMALLLADAY = 0.00025; const double AlHolder::SMALLLADAZ = 0.0010; const double AlHolder::SMALLBARTX = 0.0010; const double AlHolder::SMALLBARTY = 0.0010; const double AlHolder::SMALLBARTZ = 0.0020; const double AlHolder::SMALLBARAX = 0.00006; const double AlHolder::SMALLBARAY = 0.00006; const double AlHolder::SMALLBARAZ = 0.00004; const double AlHolder::SMALLFRATX = 0.0010; const double AlHolder::SMALLFRATY = 0.0010; const double AlHolder::SMALLFRATZ = 0.0020; const double AlHolder::SMALLFRAAX = 0.00002; const double AlHolder::SMALLFRAAY = 0.00002; const double AlHolder::SMALLFRAAZ = 0.00004; AlHolder::AlHolder() { } AlHolder::~AlHolder() { } int AlHolder::writeToFile(char* file) { fstream os( file, ios::out ); os << *this; os.close(); return 0; } int AlHolder::readFromFile(char* file) { fstream is( file, ios::in ); is >> *this; is.close(); return 0; } void AlHolder::setToTestPattern0() { // set everything to zero *this = AlHolder(); AlDigiCode ad(AlDigiCode::LADDER,AlDigiCode::ALL); for(ad=0; ad=6 && l==(w%6) ) _ladder[ad].ty = SMALLLADTY; if( b==1 && w<=5 && l==(w%6) ) _ladder[ad].tz = SMALLLADTZ; if( b==1 && w>=6 && l==(w%6) ) _ladder[ad].ax = SMALLLADAX; if( b==2 && w<=5 && l==(w%6) ) _ladder[ad].ay = SMALLLADAY; if( b==2 && w>=6 && l==(w%6) ) _ladder[ad].az = SMALLLADAZ; } } void AlHolder::setToRandom(int seed ) { srand48(seed); for(int i=0; i> (std::istream& is, AlHolder& rhs) { AlDigiCode ad; ad.setUsedDetectors(AlDigiCode::ALL); char line[200]; char c; int temp; while(!is.eof()) { is.get(c); if(c=='!') { is.getline(line,199); } else if(c=='0') { is >> temp >> temp >> ad >> rhs._spaceframe ; } else if(c=='1') { ad.setResolution(AlDigiCode::BARREL); is >> temp >> temp >> ad; is >> rhs._barrel[ad]; } else if(c=='2') { ad.setResolution(AlDigiCode::LADDER); is >> temp >> temp >> ad; is >> rhs._ladder[ad]; } else if(c=='3' || c=='5' ) { ad.setResolution(AlDigiCode::WAFER); is >> temp >> temp >> ad; is >> rhs._wafer[ad]; if(c=='5') { is >> rhs._wafer[ad].sty >> rhs._wafer[ad].stz >> rhs._wafer[ad].sax; } } else if(c=='4') { ad.setResolution(AlDigiCode::WAFER); is >> temp >> temp >> ad; is >> rhs._waferwarp[ad]; } } // while loop for chars return is; } std::ostream& operator << (std::ostream& os, const AlHolder& rhs) { AlDigiCode ad; ad.setUsedDetectors(AlDigiCode::ALL); os << "! Si Alignment Table File V2"<< std::endl << "! t=table number: 0=spaceframe, 1=barrel, " << "2=ladder, 3=wafer, 4=waferwarp " << std::endl << "! 5=wafer with z side info " << std::endl << "! i=the table entry unofficial index " << std::endl << "! c=the table entry official ChannelID " << std::endl << "! b=barrel, l=layer, w=wedge, h=half-ladder, f=wafer, s=side" << std::endl << "! " << std::endl << "! " << std::endl << "! " << std::endl << "! Space Frame Table " << std::endl << "!t i c b l w h f s Tx Ty Tz " << "Ax Ay Az" << std::endl; // put out the spaceframe alignment ad.setResolution(AlDigiCode::FRAME); ad=0; os << setw(2) << 0 << setw(5) << 0 << setw(7) << ad.getCode() << " " << ad << rhs._spaceframe << std::endl; os << "! " << std::endl << "! Barrel Table " << std::endl << "!t i c b l w h f s Tx Ty Tz " << "Ax Ay Az" << std::endl; // put out the barrel alignment ad.setResolution(AlDigiCode::BARREL); for(ad=0; ad> (std::istream& is, AlTransform& rhs) { is >> rhs.tx >> rhs.ty >> rhs.tz >> rhs.ax >> rhs.ay >> rhs.az; return is; } std::istream& operator >> (std::istream& is, AlWaferTable& rhs) { is >> rhs.tr >> rhs.dr; // note the AlHolder operator reads sty, stz and sax if they are there return is; } std::istream& operator >> (std::istream& is, AlWaferWarpTable& rhs) { is >> rhs.byy >> rhs.byz >> rhs.bzz; return is; } //////////////////////////// set values form arbitrary source void AlHolder::setFrame(const double tx, const double ty, const double tz, const double ax, const double ay, const double az) { _spaceframe.tx = tx; _spaceframe.ty = ty; _spaceframe.tz = tz; _spaceframe.ax = ax; _spaceframe.ay = ay; _spaceframe.az = az; } void AlHolder::setBarrel(AlDigiCode& al, const double tx, const double ty, const double tz, const double ax, const double ay, const double az) { al.setResolution(AlDigiCode::BARREL); int i = al.getIndex(); _barrel[i].tx = tx; _barrel[i].ty = ty; _barrel[i].tz = tz; _barrel[i].ax = ax; _barrel[i].ay = ay; _barrel[i].az = az; } void AlHolder::setLadder(AlDigiCode& al, const double tx, const double ty, const double tz, const double ax, const double ay, const double az) { al.setResolution(AlDigiCode::LADDER); int i = al.getIndex(); if(i>=352 || i<0) cout << "AlHolder::setLadder: bad wafer index " << endl; _ladder[i].tx = tx; _ladder[i].ty = ty; _ladder[i].tz = tz; _ladder[i].ax = ax; _ladder[i].ay = ay; _ladder[i].az = az; } void AlHolder::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) { al.setResolution(AlDigiCode::WAFER); int i = al.getIndex(); if(i>=1752 || i<0) cout << "AlHolder::setWafer: bad wafer index " << endl; _wafer[i].tr.tx = tx; _wafer[i].tr.ty = ty; _wafer[i].tr.tz = tz; _wafer[i].tr.ax = ax; _wafer[i].tr.ay = ay; _wafer[i].tr.az = az; _wafer[i].dr = dr; _wafer[i].sty = sty; _wafer[i].stz = stz; _wafer[i].sax = sax; } void AlHolder::setWarp(AlDigiCode& al, const double byy, const double byz, const double bzz) { al.setResolution(AlDigiCode::WAFER); int i = al.getIndex(); _waferwarp[i].byy = byy; _waferwarp[i].byz = byz; _waferwarp[i].bzz = bzz; } //////////////////////////// get values for arbitrary caller void AlHolder::getFrame( double& tx, double& ty, double& tz, double& ax, double& ay, double& az) { tx = _spaceframe.tx; ty = _spaceframe.ty; tz = _spaceframe.tz; ax = _spaceframe.ax; ay = _spaceframe.ay; az = _spaceframe.az; } void AlHolder::getBarrel(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az) { al.setResolution(AlDigiCode::BARREL); int i = al.getIndex(); tx = _barrel[i].tx; ty = _barrel[i].ty; tz = _barrel[i].tz; ax = _barrel[i].ax; ay = _barrel[i].ay; az = _barrel[i].az; } void AlHolder::getLadder(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az) { al.setResolution(AlDigiCode::LADDER); int i = al.getIndex(); tx = _ladder[i].tx; ty = _ladder[i].ty; tz = _ladder[i].tz; ax = _ladder[i].ax; ay = _ladder[i].ay; az = _ladder[i].az; } void AlHolder::getWafer(AlDigiCode& al, double& tx, double& ty, double& tz, double& ax, double& ay, double& az, double& dr, double& sty, double& stz, double& sax) { al.setResolution(AlDigiCode::WAFER); int i = al.getIndex(); tx = _wafer[i].tr.tx; ty = _wafer[i].tr.ty; tz = _wafer[i].tr.tz; ax = _wafer[i].tr.ax; ay = _wafer[i].tr.ay; az = _wafer[i].tr.az; dr = _wafer[i].dr; sty = _wafer[i].sty; stz = _wafer[i].stz; sax = _wafer[i].sax; } void AlHolder::getWarp(AlDigiCode& al, double& byy, double& byz, double& bzz) { al.setResolution(AlDigiCode::WAFER); int i = al.getIndex(); byy = _waferwarp[i].byy; byz = _waferwarp[i].byz; bzz = _waferwarp[i].bzz; } // get values to arbitrary caller AlTransform AlHolder::getFrame() { return _spaceframe; } AlTransform AlHolder::getBarrel(AlDigiCode al) { al.setResolution(AlDigiCode::BARREL); return _barrel[al]; } AlTransform AlHolder::getLadder(AlDigiCode al) { al.setResolution(AlDigiCode::LADDER); return _ladder[al]; } AlWaferTable AlHolder::getWafer(AlDigiCode al) { al.setResolution(AlDigiCode::WAFER); return _wafer[al]; } AlWaferWarpTable AlHolder::getWarp(AlDigiCode al) { al.setResolution(AlDigiCode::WAFER); return _waferwarp[al]; }