#ifndef COTBEAM_HH #define COTBEAM_HH (1) // // This is the primary user interface for retrieving the bealine from // the database. Entries are for fits using cot tracks. // The best value for this run is determined by the database functionality. // Look for the alignment web page, currently // http://www-cdf.fnal.gov/internal/upgrades/align/beam.html // // // 4/2001 - creation, Ray Culbertson and Harmut Stadie // 12/2002 - added valid checks for used set case, added time dependence // added readfrom file capability, // still need loadRun even for use sets // // #include #include "Alignment/AbsBeam.hh" #include "VertexObjects/Beamline.hh" #include "AlignmentDB/CotBeamPosition.Defs.hh" class HepPoint3D; class HepVector; class Hep3Vector; class HepSymMatrix; #include "ErrorLogger/ErrorLog.h" class CotBeam : public AbsBeam { public: // opens a conection to the database CalibrationManager // and keeps a database container filled with the contents specified // via used sets mechanism CotBeam(); // call must be made at begin run int loadRun(); // true if the current contents are correct for this run // most common failure will be no data entered for this run bool isValid(); // the following accesors will give the best beam position // available in the database as indicated by the valid sets // the beam position: double beamx = position().x(); HepPoint3D position(double z = 0.0); HepVector positionVector(double z = 0.0); // the beam slope: double xslope = slope.x(); Hep3Vector slope(); // a 3x3 covariance matrix of position, element (3,3) = 35cm. // the x,y elements include intrinsic beam size and beam position // measurement errors (position and slope) HepSymMatrix cov3(double z = 0.0); int history() { return getBeamline(-2).History();} int algorithm() { return getBeamline(-2).Algorithm();} int source() { return getBeamline(-2).Source();} // these dump the contents, good for calling at begin run // to print a few lines void printSummary(); // print all information for this entry void printAll(); // a container with all the information // event = -1 means take current event number // event = -2 means get the run averaged result Beamline getBeamline(int eventFlag = -1); // write to output file, call at beginRun int writeToOutput(); //when true look at input for beamlines void setReadFromFile(bool x) { _readFromFile = x;} //set true (default) to allow a fallback to db if not in file void setDbFallback(bool b) { _dbFallback = b;} //set true (default is false) to allow time-dependence void setUseTimeDep(bool b) { _useTimeDep = b;} ///////////////////////////////////////////////////////////////////////// // expert interface below here, typical user does not need these ///////////////////////////////////////////////////////////////////////// // the following force access of specific results // the above accessors will provide the results //create with specified database source, this forces re-opening of db //necessary to use these access methods // if dbid = "default" it will be taken from calibration manager CotBeam(std::string dbid); // select "RAW", "GOOD", "TEST", or "COMPLETE" // this is the database "status" void setStatus(std::string status); // history code reflects alignments, code library versions void setHistoryCode(int history); // select which algorithm was used 40 = d-phi fit, 20 = vertices void setAlgorithm(int algorithm); // select data source 5 = online, 10=offline void setSource(int source); // set run and version number, -1 means current run/latest version // and retrieve db record // once this interface is triggered with setDatabase, this needs to be // called explicitly at begin run (database manager no longer does it) int loadRun(int run, int version = -1); //if set to 1, prints a summary for all entries, if set to 2 prints all void printLevel(int level); //copy db containers to vector of Beamlines int cache(); // expert function load table for a specified cid int loadCid(int cid); //return the whole record CotBeamPosition getRecord(); //if "best available table" was requested, see what was found std::string getStatus(); // DB table status word int getVersion(); // DB table version number int getCid() { return _cont->key().id();} RunListKey getKey() { return _cont->key();} CotBeamPositionContainer getContainer() { return *_cont;} // the whole raw list of beamlines: run averaged and time-dep BeamVector getBeamlines() { return _beamlines; } private: int getScore(Beamline& b); CotBeamPosition_mgr _beamIom; CotBeamPositionContainer_ptr _cont; // caches of the selected beamline BeamVector _beamlines; bool _expert; // true = expert interface triggered std::string _dbid, _reqStatus; // save values input in expert interface int _reqHistory, _reqAlgorithm, _reqSource; int _printLevel; bool _isValid; // true if the acessors can return valid numbers bool _readFromFile; bool _dbFallback; bool _useTimeDep; ErrorLog errlog; }; #endif