#ifndef BEAMWRAPPER_HH #define BEAMWRAPPER_HH //**********************************************************************\ // file: BeamWrapper.hh // ---------------------------------------------------------------------- // Content: // Type: Class implementation // Class: BeamWrapper // Language: C++ // Package: Run 2 Upgrade // Project: CDF Analysis // // Author: Andreas Korn // Company: Massachusetts Institute of Technology // Date: Feb-02 // // Details: A common interface to all beamlines // COT, SVX and custom // Alignment correction option // Incorporated Ideas from Christoph, Ivan and rlc // // alignmentfile format: // commentline1 // commentline2 // runS runE x ax y ay btype // example: // #### Alignment for 130022 137026 runs ########## // ################################################## // 130022 137026 -0.10106 0.0003540 0.13742 0.0007609 S // // btype is optional: 'M','S','C' for seperate CUSTOM, SVX and COT // beamline corrections, default SVX //************************************************************************ #include "Alignment/AbsBeam.hh" #include "Alignment/CotBeam.hh" #include "Alignment/SvxBeam.hh" #include "Alignment/CustomBeam.hh" #include "Framework/AbsParmGeneral.hh" #include "Framework/AbsParmEnum.hh" #include "Framework/AbsParmString.hh" #include "Framework/APPMenu.hh" #include "Framework/APPModule.hh" #define BEAM_MAXLINES 500 class Beamline; class BeamWrapper : public AbsBeam { public: // opens a conection to the database CalibrationManager // and keeps a database container filled with the contents specified // via used sets mechanism BeamWrapper(std::string dbid = "default"); bool isValid(); HepPoint3D position (double z = 0.0); HepVector positionVector(double z = 0.0); 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); void printSummary(); void printAll (); // a container with all the information, this should be in AbsBeam Beamline getBeamline(int eventFlag = -1); enum beamtype {B_COT = 0, B_SVX = 1, B_CUSTOM = 2, B_BEST = 3}; enum prodversion {V_UNINIT = 0, V_NONE = 1, V_430 = 2, V_452 = 3, V_484 = 4, V_491 = 5}; enum alignoption {O_FILE = 0, O_DB = 1, O_FILENODBUSE = 2}; ///////////////////////////////////////////////////////////////////////// // expert interface below here, typical user does not need these ///////////////////////////////////////////////////////////////////////// int writeToOutput(); void setReadFromFile(bool x); void setDbFallback(bool b); // this is an expert function and somewhat dangerous ... void setHistoryCode(int history); int getHistoryCode(); int getVersion(){return (getCurrent()->getVersion());} //All dummy as no database: void setStatus(std::string status){} void setAlgorithm(int algorithm){} void setSource(int source){} std::string getStatus(); int getCid() ; int loadCid(int cid); APPMenu* getTalkTo(AppModule* theTarget, APPMenu* parent); //if set to 1, prints a summary for all entries, if set to 2 prints all void printLevel(int level); // set run and version number, -1 means current run/latest version int loadRun(int run, int version = -1); int loadRun() { return loadRun(-1,-1); } void Init(); void readAlign(int run, int version); void decodeBeamSelector(std::string beam); void decodeAlignPrecedence(std::string align); void decodeProductionVersion(std::string version); beamtype getCurrentType(); int getCurrentValid(){return _validBeams;} private: AbsBeam* getCurrent(); void readAlignFile(std::string filename); bool fetchDBAlignment(std::string alignDBsource); bool updateDBAlignment(); CotBeam & cotBeam(); SvxBeam & svxBeam(); APPMenu _Menu; AbsParmGeneral _Verbose; AbsParmEnum _productionVersion; AbsParmEnum _beamSelector; AbsParmEnum _alignPrecedence; AbsParmBool _useAlign,_substractoldAlign,_noDB; AbsParmString _customFile; AbsParmString _alignFile; beamtype _selectedBeam; beamtype _currentBeam; CustomBeam _custBeam; prodversion _prodVersion; alignoption _precedence; static int _currentRun; static prodversion _currentprodVersion; static std::string _dbid; static bool _first; static const std::string _defdbid; static const std::string _defstring; static const std::string _dbversion[14]; static const int _lasthistoryversion; static int _historyversion; FILE* _fhandle; AppModule* _target; int _printLevel; int _validBeams; bool _init; struct malign{ int runS; int runE; double Tx; double Ty; double Ax; double Ay; beamtype type; }; struct malign _align[4]; struct malign _listoalign[BEAM_MAXLINES]; int _nalignlines; static struct malign _alignDB; }; #endif