#ifndef HGEOSET_H #define HGEOSET_H #include "hgeoparam.h" #include "hnamedlist.h" #include "hgeoinfo.h" #include "hgeomedia.h" #include "hgeoshapes.h" #include "hadesstd.h" // // base class for Cave, sectors, coils, support structur and all detectors; // // It is implemented as a linked list via the template class HNamedList. // Each listelement has a name and a value (class) of type HGeoParam. The // listelements are accessed by their names. // Successively all volumes of a detector are read and appended to the list with // their names and values. // All derived classes must have functions readDet(...) to read the geometrical // informations from database or file. // Also all derived classes must have a function createDet(...) to create the // detector and a funtion createHits(...) if this detector contains // sensitive volumes. // All other functions in this baseclass are helperfunctions used in the derived // classes to build these virtual functions. (minimizes codewriting) // // The elements keepinNmame, detName, eleName are defined in the derived classes. // ( keepinNmame must not be defined if the detector has no special keepin-volume // or it can be used to read parts on an other detectors for exemple in Tof.) // // The element pShapes is a pointer to the class HGeoShapes, which is used in // all detector-classes for shapedependent reads and calculations. This class // is instantiated only once in hgeocreatesetup.cc. // typedef HVector DVec; class HGeoSet : public HNamedList { public: HGeoSet() : HNamedList(), uniRot(0.0F,9) { pShapes=0; nhmax=30; nvmax=10; nv=0; for(int i=0;i<3;i++) {uniRot[3*i+i]=1.F;} noCopyNames=0; } ~HGeoSet(){} // reads the detector from the database; // code in the derived classes; virtual int readDet(HGeoInfo & geoInfo, HGeoMedia & geoMedia) { return HFAILURE; } // reads the detector from file // code in the derived classes; virtual int readDet(HGeoInfo & geoInfo) { return HFAILURE; } // creates detector // code in the derived classes; virtual int createDet(HGeoInfo & geoInfo, HGeoMedia & geoMedia){ return HFAILURE; } // defines sensitive detector and hitparameter // code in the derived classes; virtual int createHits(HString & volName) { return HFAILURE; } // writes the the whole detector read from database to file virtual int writeToFile(HString & modName, HGeoInfo & geoInfo); // reads 6 volumes (one in each sector) with the substring keepinName // in its name from file // (used for example to read keepin-volumes of shower detectors) int readKeepIn(HGeoInfo & geoInfo); // reads a module with the substring detName in its name from file // (used for example to read one driftchamber) int readModule(HGeoInfo & geoInfo); // reads mother, shape, material, points and coordiate-system from file int readParam(HGeoInfo & geoInfo, HGeoParam & ele); // reads mother and coordiate-system from file // (used to read the copies of a volume) int readCopy(HGeoInfo & geoInfo, HGeoParam & ele); // reads inout-flag from file void readInout(HGeoInfo & geoInfo, HGeoParam & ele); // reads points and coordiate-system from file int readVol(HGeoInfo & geoInfo, HGeoParam & ele); // reads 6 volumes (one in each sector) with the substring keepinName // in its name from the database int readKeepIn(HGeoInfo & geoInfo, HGeoMedia & geoMedia); // reads a module with the substring detName in its name from the // database // used for all modules in the sectors (e.g. MDC) int readModule(HGeoInfo & geoInfo, HGeoMedia & geoMedia); // reads one module with the name detName from the database // used for all modules in the cave (e.g. RICH) // daughters of index breakLoop will not be read int readSingleModule(HGeoInfo & geoInfo, HGeoMedia & geoMedia, int breakLoop=0); // reads mother, shape, material, points and coordiate-system from the // database int readParam(HGeoInfo & geoInfo, HString & volName, HGeoParam & ele, HGeoMedia & geoMedia); // reads mother and coordiate-system from the database // (used for volumes in sector 2-6, where the name is known) int readCopyParam(HGeoInfo & geoInfo, HGeoParam & ele); // reads all informations of all daughters of a mothervolume from the // database // daughters of index breakLoop will not be read int readDaughters(HGeoInfo & geoInfo, int iMo, HGeoMedia & geoMedia, int breakLoop=0); // creates all volumes with the substring keepinName in its name int createKeepIn(HGeoInfo & geoInfo,HGeoMedia & geoMedia); // creates all volumes of a module with the substring detName in its name int createModule(HGeoInfo & geoInfo,HGeoMedia & geoMedia); // writes the the whole detector read from database to file int connectOutputFile(HString & modName, HGeoInfo & geoInfo, ofstream & fout); // showes name and input-parameters of a volume void showAll(HString & volName, HGeoParam & ele); // reads hits from file with name hitsFileName int readHits(HString & hitsFileName); // sets these variables needed for hit definitions in Geant, which // depend of the tree int restoreTree(HString & volName); // calculates the GEANT position of a volume in the reference // (intrinsic) coordinate system of the module void calcRefPos(HString & volName, FVec & refPos, HString & shape); // shows the hit definition for the sensitive volumes void showHits(HString & volName,int idtype); // shows the element keepinName; HString showKeepinName(); // shows the element detName; HString showDetName(); // shows the element eleName; HString showEleName(); protected: // calculates transformation relative to the coordinate system of // the mother from the lab transformations read from database int calcMotherTransform(HGeoInfo & geoInfo, HGeoParam & ele); // some helperfunctions to make transformations void transposeMatrix(DVec & r, DVec & tr); void multiplyMatrices(DVec & lr, DVec & rr, DVec & pr); void rotateVector(DVec & r, DVec & v, DVec & rv); // rounds DVec to precision n void roundDVec(DVec & v, const int n); // unity matrix FVec uniRot; // unique substring of the name of the keepin-volume HString keepinName; // unique substring of the name of the module HString detName; // substring of the names of all daughtervolumes of the module HString eleName; // pointer to the class HGeoShapes // All shapedependent reads and calculations are done within this class. HGeoShapes *pShapes; // list of volumes with copies; noCopyNames=actual length HString copyNames[100]; int noCopyNames; // filename for hit definition HString hitsFileName; // readHits==0, if hits not yet read; set to 1 after successful read int hitsRead; // maximum number of hit components int nhmax; // set name HString chset; // number of hit components int nh; // names of the hit components char chnamh[30][5]; // array for the number of bits in which to pack the components of a hit int nbitsh[30]; // array for the offsets applied before packing the hit values float orig[30]; // array for the scale factors applied before packing the hit values float fact[30]; // maximum number of levels in tree of module int nvmax; // number of volume descriptors (derived from tree) int nv; // array of nv names to decribe the volume (derived from tree) char chnmsv[10][5]; // array of bits in which to pack the copy number of the volume chnmsv // (derived from tree) int nbitsv[10]; }; #endif