runinfo.hh

Go to the documentation of this file.
00001 
00006 #ifndef RUNINFO_h
00007 #define RUNINFO_h
00008 
00009 //hide this from ROOT
00010 #include "Rtypes.h"
00011 #ifndef __CINT__
00012 #include "ParameterList.hh"
00013 #endif 
00014 
00015 
00016 #include <vector>
00017 #include <map>
00018 #include <string>
00019 #include <set>
00020 #include <sstream>
00021 #include <time.h>
00022 
00023 class TMacro;
00024 
00029 #ifndef __CINT__
00030 class runinfo : public ParameterList{
00031 #else
00032 class runinfo{
00033 #endif
00034 public:
00036   runinfo(long id=-1);
00038   virtual ~runinfo() {}
00040   void Init(bool reset=false);
00042   void InitializeParameterList(); 
00043 
00045   void ResetRunStats();
00046   
00048   int LoadSavedInfo(TMacro* mac);
00049   
00050   //metadata to save for all runs, determined automatically from daq settings
00051   
00052   /* note: By default runs have a prefix (per experiment, default 'rawdaq') 
00053      and suffix (the date expressed as yymmddHHMM). 
00054      The suffix is equivalent to the runid in this case. 
00055      
00056      Alternatively, if the filename is given as *Run######", then the 6 digit
00057      suffix will be interpreted as the run id. In this case it is up to the 
00058      user to ensure unique IDs
00059   */
00060 
00061   long runid;                  
00062   time_t starttime;            
00063   time_t endtime;              
00064   long triggers;               
00065   long events;                 
00066   
00067 
00068 public:
00069   typedef std::set<std::string> stringset;
00070   typedef std::vector<std::string> stringvec;
00071   typedef std::map<std::string, std::string> stringmap;
00072   
00077 #ifndef __CINT__
00078   class DialogField : public ParameterList{
00079   public:
00080     DialogField(const std::string& field_="", const std::string& desc = "",
00081                 bool required_=true, const std::string& default_="");
00082     virtual ~DialogField() {}
00083     bool IsValueValid(const std::string& val) const;
00084     std::string fieldname;
00085     std::string description;
00086     std::vector<std::string> allowed_values;
00087     bool required;
00088     std::string defaultvalue;
00089   };
00090   
00091   typedef std::vector<DialogField> FieldList;
00092 #endif
00093 
00094 private:
00095   //these fields allow the user to define additional metadata via config files
00097   stringmap metadata; 
00098   
00099 #ifndef __CINT__
00100   //All the dialog fields refer to entries in the main metadata map
00102   FieldList prerun_dialog_fields;
00104   FieldList postrun_dialog_fields;
00105 #endif
00106 
00108   bool force_prerun_dialog;
00110   bool force_postrun_dialog;
00111     
00113   std::map<int, stringmap > channel_metadata;
00114   //(may add a required_channel_metadata in the future)
00115   
00116 public:
00117   //all of the following return 0 for success, 1 for user cancelled, <0 on error
00118   enum FILLTIME {RUNSTART, RUNEND};
00120   int FillDataForRun(FILLTIME when=RUNSTART);
00121 
00123   std::string GetMetadata(const std::string& key)
00124   { stringmap::iterator it = metadata.find(key);
00125     return it == metadata.end() ? std::string("") : it->second ; }
00127   void SetMetadata(const std::string& key, const std::string& val)
00128   { metadata[key] = val; }
00129 
00131   template<class T> void SetMetadata(const std::string& key, const T& val){
00132     std::stringstream s;
00133     s<<val;
00134     metadata[key] = s.str();
00135   }
00136 
00137   
00138 private:
00139   ClassDef(runinfo,1);
00140 }; 
00141 
00142 
00143 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1