// // File: FdNaming.hh // // Purpose: Header file for FdNaming.cc, // declaration of the class FdNaming // // $Id: FdNaming.hh 12190 2011-03-13 18:11:53Z mathes $ // /** @file FdNaming.hh * Declaration of the class FdNaming. * @author H.-J. Mathes, FzK */ #ifndef _FdUtil_FdNaming_hh_ #define _FdUtil_FdNaming_hh_ #include #include #include #include #ifndef NO_VERSION # include #endif // NO_VERSION #include #include namespace FdUtil { /** This class provided the file naming and directory structure rules to all applications. It makes use of the class FdUtil::FdConfig. These rules are: @li the base directory where for example Los Leones data is saved is /home/auger/FD-LosLeones. @li in this sense the data of the other telecopes is saved under /home/auger/FD-Coihuece and /home/auger/FD-LosMoraded @li data of the EyePC is saved then under ../eyepc/.. and data of the MirrorPCs under ../mirrorpc#/.. where # is the number of the MirrorPC. @li the next element of the directory tree is ../YYYY/MM/DD/... which is the date when the file was created (using astronomers convention @anchor gscheme General scheme: @li Get'Data'/'Cal'/'Aux'/'Test'Directory() = get directory on the host where the program is actually running @li GetEyeData/'Cal'/'...'Directory() = get directory for the EyePC if running on an AUGER computer, else default @li GetMirror'Data'/'Cal'/'...'Directory() = get directory for the specified MirrorPC if running on an AUGER computer, else default @li file naming options select from which components a name is built, RUN id, date and time can be switched off, the current default is, that the filename contains all these fields. */ class FdNaming : public FdUtil::Singleton { friend class FdUtil::Singleton; public: // --- options for SetOption() method /** Option settings for the SetOption() method. */ typedef enum { kDefaultOptions = 0, ///< use compile time options, see @ref gscheme "General scheme" kUseIsoDate, ///< use ISO date representation in file name kUseIsoTime, ///< use ISO time representation in file name kUseRunId, ///< use the RUN is in the file name kCreateDirectory ///< create also the directory where the data goes } ENamingOption; // --- these methods construct only filenames (Eye or Mirror ?) /** Get the file name for the calibration data file. * * Pattern(s): 'prefix_DATE.TIME.suffix'
* 'prefix_m##_DATE.TIME.suffix' * * Note: if 'mirror_id' == 0 then the Eye level is selected. */ const std::string GetAuxDataFilename(const std::string prefix, const std::string suffix, unsigned int mirror_id=0); /** Get the file name for the calibration data file. * * Pattern(s): 'cal_e#_#run_id#_DATE.TIME.suffix'
* 'cal_m##_#run_id#_DATE.TIME.suffix' * * Note: if 'mirror_id' == 0 then the Eye level is selected. */ const std::string GetCalibrationDataFilename(unsigned int run_id, const std::string suffix, unsigned int mirror_id=0) { return GetDataFilename( "cal", run_id, suffix, mirror_id ); } /** Get the file name for the APF data file. * * Pattern: 'apf_e#_#run_id#_DATE.TIME.suffix' */ const std::string GetAPFDataFilename(unsigned int run_id, const std::string suffix) { return GetDataFilename( "apf", run_id, suffix, 0 ); } /** Get the file name for the flasher data file. * * Pattern: 'flasher_e#_#run_id#_DATE.TIME.suffix' */ const std::string GetFlasherDataFilename(unsigned int run_id, const std::string suffix) { return GetDataFilename( "flasher", run_id, suffix, 0 ); } /** Get the file name for the laser data file. * * Pattern: 'laser_e#_#run_id#_DATE.TIME.suffix' */ const std::string GetLaserDataFilename(unsigned int run_id, const std::string suffix) { return GetDataFilename( "laser", run_id, suffix, 0 ); } /** Get the file name for the LIDAR data file. * * Pattern: 'lidar_e#_#run_id#_DATE.TIME.suffix' */ const std::string GetLidarDataFilename(unsigned int run_id, const std::string suffix) { return GetDataFilename( "lidar", run_id, suffix, 0 ); } /** Get the file name for the run data file. * * Pattern(s): 'run_e#_#run_id#_DATE.TIME.suffix' if mirror_id==0
* 'run_m##_#run_id#_DATE.TIME.suffix', m## from mirror_id
*/ const std::string GetRunDataFilename(unsigned int run_id, const std::string suffix, unsigned int mirror_id=0) { return GetDataFilename( "run", run_id, suffix, mirror_id ); } /** Get the file name for the test data file. * * Pattern(s): 'test_e#_#run_id#_DATE.TIME.suffix', e# automatic
* 'test_m##_#run_id#_DATE.TIME.suffix', m## from mirror_id
*/ const std::string GetTestDataFilename(unsigned int run_id, const std::string suffix, unsigned int mirror_id=0) { return GetDataFilename( "test", run_id, suffix, mirror_id ); } /** Get the file name for the min bias data file. * * Pattern(s): 'test_e#_#run_id#_DATE.TIME.suffix', e# automatic
* 'test_m##_#run_id#_DATE.TIME.suffix', m## from mirror_id
*/ const std::string GetMinBiasDataFilename(unsigned int run_id, const std::string suffix, unsigned int mirror_id=0) { return GetDataFilename( "minbias", run_id, suffix, mirror_id ); } /** Get the file name for the min bias data file. * * Pattern(s): 'prefix_[e#_]#run_id#_DATE.TIME.suffix', if mirror_id==0
* 'prefix_[m##_]#run_id#_DATE.TIME.suffix', m## from mirror_id */ const std::string GetDataFilename(const std::string prefix, unsigned int run_id, const std::string suffix, unsigned int mirror_id=0); // --- these methods construct directory names & create directories /** Get the name of (and construct) the directory for the auxiliary data. */ const std::string GetAuxDataDirectory() { return GetDataDirectory( GetSystemDirectoryName(), "aux" ); } /** Get the name of (and construct) the directory for the calibration data. */ const std::string GetCalibrationDataDirectory() { return GetDataDirectory( GetSystemDirectoryName(), "cal" ); } /** Get the name of (and construct) the directory for the run data. */ const std::string GetRunDataDirectory() { return GetDataDirectory( GetSystemDirectoryName(), "data" ); } /** Get the name of (and construct) the directory for the test data. * * Note: We assume, that in TEST mode all data go here, even the * calibration data ! */ const std::string GetTestDataDirectory() { return GetDataDirectory( GetSystemDirectoryName(), "test" ); } /** Get the name of the (and create it) data directory. * * This method will create the directory if option 'kCreateDirectory' * is set (default). */ const std::string GetDataDirectory(const std::string sysname, const std::string subdir); /** Get the name of the directory component which specifies the sub-system. * * Pattern(s): * /eyepc/ *, if running on EyePC
* * /mirrorpc#/ *, if running on MirrorPC
* * /'hostname'/ *, if not AUGER system */ const std::string GetSystemDirectoryName(); // --- construct directory names at Eye level & create the directories /** Get the name of the auxiliary data directory on Eye level. */ const std::string GetEyeAuxDataDirectory() { return GetDataDirectory( GetEyeDirectoryName(), "aux" ); } /** Get the name of the calibration data directory on Eye level. */ const std::string GetEyeCalibrationDataDirectory() { return GetDataDirectory( GetEyeDirectoryName(), "cal" ); } /** Get the name of the run data directory on Eye level. */ const std::string GetEyeRunDataDirectory() { return GetDataDirectory( GetEyeDirectoryName(), "data" ); } /** Get the name of the test data directory on Eye level. */ const std::string GetEyeTestDataDirectory() { return GetDataDirectory( GetEyeDirectoryName(), "test" ); } /** Get the name of the eye directory name component. * * Pattern(s): * /eyepc/ *, if AUGER system
* * /'hostname'/ *, if not AUGER system */ const std::string GetEyeDirectoryName(); // --- construct directory names at Mirror level & create the directories /** Get the name (and construct it) of the auxiliary data at Mirror level. * * If 'mirror_id' == 0 take the Id of the actual Mirror where this * software is running, so not on EyePC. */ const std::string GetMirrorAuxDataDirectory(unsigned int mirror_id=0) { return GetDataDirectory( GetMirrorDirectoryName( mirror_id ), "aux" ); } /** Get the name (and construct it) of the calibration data at Mirror level. * * If 'mirror_id' == 0 take the Id of the actual Mirror where this * software is running, so not on EyePC. */ const std::string GetMirrorCalibrationDataDirectory(unsigned int mirror_id=0) { return GetDataDirectory( GetMirrorDirectoryName( mirror_id ), "cal" ); } /** Get the name (and construct it) of the run data at Mirror level. * * If 'mirror_id' == 0 take the Id of the actual Mirror where this * software is running, so not on EyePC. */ const std::string GetMirrorRunDataDirectory(unsigned int mirror_id=0) { return GetDataDirectory( GetMirrorDirectoryName( mirror_id ), "data" ); } /** Get the name (and construct it) of the test data at Mirror level. * * If 'mirror_id' == 0 take the Id of the actual Mirror where this * software is running, so not on EyePC. */ const std::string GetMirrorTestDataDirectory(unsigned int mirror_id=0) { return GetDataDirectory( GetMirrorDirectoryName( mirror_id ), "test" ); } /** Get the name of the mirror specific name component of the directory * name. * * Pattern(s): * /mirrorpc#/ *, if running on MirrorPC * * /mirrorpc#/ *, #=fMirrorId, if mirror_id==0 and on MirrorPC * * /eyepc/ *, #=fMirrorId, if mirror_id==0 and on EyePC * * /'hostname'/ *, if not AUGER system */ const std::string GetMirrorDirectoryName(unsigned int mirror_id); // --- these methods construct only directory names /** Get the name of the config directory of the current DAQ system host, * either EyePC or MirrorPC. * * If the program is not running on an EyePC nor a MirrorPC the defaults * for EyeId and MirrorId are taken and it is assumed that the software * runs on an EyePC. * * Patterns: * @li /home/auger/general/eyepc * @li /home/auger/general/eyepc -> /export/mirror_home/auger/eyepc * @li /home/auger/general/mirrorpc# * @li /home/auger/general/mirrorpc# -> /export/mirror_home/auger/mirrorpc# * @li $HOME/general/'hostname' */ const std::string GetConfigDirectory(); /** Get the name of the config directory where configuration files of the * actual host are stored. * * If the program is not running on an EyePC nor a MirrorPC the defaults * for EyeId and MirrorId are taken and it is assumed that the software * runs on an EyePC. * * Patterns: * @li /home/auger/general/eyepc * @li /home/auger/general/eyepc -> /export/mirror_home/auger/eyepc * @li $HOME/general/'hostname' */ const std::string GetEyeConfigDirectory(); /** Get the name of the config directory where Mirror configuration files * are stored. * * @param mirror_id The Mirrors Id in the frame of the PAO, valid within * 1..24. If the program runs on a MirrorPC or an EyePC an additional * cross-check on the passed Id is done, but no exception is thrown. It is * not allowed (not possible) to access a directory in another FD building. * * If the program is not running on an EyePC nor a MirrorPC the defaults * for EyeId and MirrorId are taken and it is assumed that the software * runs on an EyePC. * * A std::invalid_argument exception is thrown if a wrong mirror_id is * passed. Passing a mirror_id in the range 1..6 always maps to the local * FD building. * * Patterns: * @li /home/auger/general/mirrorpc# * @li /home/auger/general/mirrorpc# -> /export/mirror_home/auger/mirrorpc# * @li $HOME/general/'hostname' */ const std::string GetMirrorConfigDirectory(unsigned int mirror_id) throw ( std::invalid_argument ); /** Return 'true' if this is a real AUGER system. */ bool IsAugerSystem() { return fIsAugerSystem; } /** Return 'true' if this is an AUGER test system (ipeauger1 or hpepc29). */ bool IsAugerTestSystem() { return fIsAugerTestSystem; } // --- special methods /** Set an option (enable/disable it) for the internal naming scheme. */ void SetOption(ENamingOption,bool enabled=true); /** Set the level of verbosity for this class. */ static void SetPrintLevel(unsigned int level=1) { fgPrintLevel = level; } /** Run the test procedure for this class. * * This will produce some verbose test output. */ void Test(std::ostream& ostr=std::cout); /** Get the name of the (Eye specific) base directory. * * This method constructs the requested name by using the Id of the * current Eye (where this software is running). */ const std::string GetBaseDirectory(); protected: // --- create the specified directory /** Create the specified directory (recursively). * * Note: Get*DataDirectories() methods will also create the directory !!! */ void CreateDirectory(const std::string); // void CreateEyeDirectory(const std::string); // void CreateMirrorDirectory(const std::string); /** Construct the date specific directory name component. */ const std::string GetDirectoryFromDate(); /** Get the home directory of the current user. */ const std::string GetHomeDirectory(); /** Get the home directory of the current user on the EyePC. * * This method assumes the AUGER FD DAQ directory mapping. An exception is * thrown if the program does not run on an EyePC or MirrorPC. */ const std::string GetEyeHomeDirectory() throw ( std::domain_error ); /** Get the home directory of the current user on the MirrorPC. An * exception is thrown if the program does not run on an EyePC or MirrorPC. * * This method assumes the AUGER FD DAQ directory mapping. */ const std::string GetMirrorHomeDirectory() throw ( std::domain_error ); /** Construct the ISO date specific component of the filename. * * The generation of the ISO data is steered by 'fUseIsoDate'. */ const std::string GetISODate(struct tm *tm=NULL); /** Construct the ISO date & time specific components of the filename. * * The generation of the ISO date and time is steered by 'fUseIsoDate' * and 'fUseIsoTime'. */ const std::string GetISODateTime(struct tm *tm=NULL); /** Construct the ISO time specific component of the filename. * * The generation of the ISO data is steered by 'fUseIsoTime'. */ const std::string GetISOTime(struct tm *tm=NULL); /** Get the mirrors id within all mirrors of the observatory. * * If the passed mirror_id is in the range 1..6, the current eye_id is * used to compute the observatories Mirror ID, else the passed value * is simply returned. * * In case of an error, 0 is returned. */ unsigned int GetObservatoryMirrorId(unsigned int); private: FdNaming(); virtual ~FdNaming(); FdNaming(const FdNaming&); FdNaming& operator=(const FdNaming&); unsigned int fEyeId; bool fIsAugerSystem; // MirrorPC or EyePC bool fIsAugerTestSystem; // hpepc29 or ipeauger1 bool fIsAugerUser; // the DAQ user unsigned int fMirrorId; // --- option settings bool fCreateDirectory; bool fUseIsoDate; bool fUseIsoTime; bool fUseRunId; static unsigned int fgPrintLevel; }; } // namespace FdUtil #endif // _FdUtil_FdNaming_hh_