Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

IoInputModule.h

Go to the documentation of this file.
00001 
00002 // $Id: IoInputModule.h,v 1.38 2009/01/05 05:55:13 schubert Exp $
00003 //
00004 // messier@huhepl.harvard.edu
00006 #ifndef IOINPUTMODULE_H
00007 #define IOINPUTMODULE_H
00008 #include "TStopwatch.h"
00009 
00010 #ifndef MAP
00011 #include <map>
00012 #define MAP
00013 #endif
00014 #ifndef STRING
00015 #include <string>
00016 #define STRING
00017 #endif
00018 #ifndef LIST
00019 #include <list>
00020 #define LIST
00021 #endif
00022 using namespace std;
00023 
00024 #include "JobControl/JobCInputModule.h"
00025 #include "Dispatcher/DDS.h"
00026 
00027 #ifndef IOFILELISTITEM_H
00028 #include "IoModules/IoFileListItem.h"
00029 #endif
00030 #ifndef PER_H
00031 #include "Persistency/Per.h"
00032 #endif
00033 #ifdef SITE_HAS_SAM
00034 #include "sam_cpp_api/SamProject.hpp"
00035 #endif
00036 
00037 class IoDataStreamItr;
00038 class Registry;
00039 class VldContext;
00040 class MomNavigator;
00041 
00042 class IoInputModule : public JobCInputModule {
00043 
00044 public:
00045   IoInputModule();
00046   ~IoInputModule();
00047   
00048   // JobCModule interface
00049   void BeginJob();
00050   void EndJob();
00051   const Registry& DefaultConfig() const;
00052   void            Config(const Registry& r);
00053   
00054   // JobCInputModule interface
00055   JobCResult Get();
00056 
00057   JobCResult Next(int n=1);
00058   JobCResult Prev(int n=1);
00059   JobCResult GoTo(int run, int snarl, int searchDir=0);
00060   JobCResult GoTo(const VldContext& vld);
00061 
00062   void List(const char* streamlist = "*") const;
00063   void AddFile(const char *filename, const char* streamlist = "*",int at = -1);
00064   void RemoveFile(const char* filename, const char* streamlist = "*");
00065 
00066   JobCResult NextFile(int n=1, const char* streamlist = "*");
00067   JobCResult PrevFile(int n=1, const char* streamlist = "*");
00068   JobCResult GoToFile(int i, const char* streamlist = "*");
00069   JobCResult GoToFile(const char* filename, const char* streamlist = "*");
00070   
00071   void DefineStream(const char* stream, const char* tree);
00072   void Select(const char* stream, const char* select, bool isRequired = false);
00073   void SetSequenceMode(const char* stream, 
00074                        Per::ESequenceMode sequenceMode = Per::kKey);
00075   void SetPerOwnedDisabled(const char* stream,
00076                            bool perowneddisabled = true);
00077   void SetTestMode(const char* stream, 
00078                    bool testMode);
00079   void SetWindow(const char* stream, double lower, double upper);
00080 
00081   void SetMaxFileRepeat(const char* stream,int numRepeat); // for Per::kSequential & Per::kRandom
00082   void SetMeanMom(const char* stream, double mean);    // for Per::kSequential & Per::kRandom
00083   void SetPushRandom(const char* stream, bool setRandom); // for Per::kSequential & Per::kRandom
00084   void SetRandomSeed(int rSeed); // for Per::kSequential & Per::kRandom
00085 
00086   // Query methods
00087   Int_t GetCurrentRun()   const { return fCurrentRun; };
00088   Int_t GetLastRun()   const { return fLastRun; };
00089   const char* GetCurrentFile(const char* streamname = "*") const;
00090   const char* GetLastFile(const char* streamname = "*") const;
00091   Int_t GetCurrentSnarl() const { return fCurrentSnarl; }; 
00092   
00093 private:
00094 
00095   void LoadFilesFromCommandLine();
00096   int  ReadHeader();
00097   void UpdateDDSConfig();
00098   void UpdateFormatConfig();
00099   void UpdateFileList();
00100   void UpdateStreamConfig();
00101   int  OpenStreamItr();
00102   void CloseStreamItr();
00103 
00104   // Quell "hiding method" compiler warnings
00105   JobCResult Get(MomNavigator*) { return JobCResult::kAOK; }
00106 
00107 private:
00108   std::map<std::string,std::string> fStreamSelectionMap; // map of stream/cut
00109   std::map<std::string,bool> fStreamRequiredMap; // map of stream/isrequired
00110   std::map<std::string,std::string> fStreamDefMap; // map of stream/definition
00111   std::map<std::string,Per::ESequenceMode> fStreamSeqModeMap;
00112   std::map<std::string,bool> fStreamPerOwnedDisabledMap;
00113   std::map<std::string,bool> fStreamTestModeMap; 
00114   std::map<std::string,std::pair<double,double> > fStreamWindowMap; 
00115                                                 // map of stream/sequence mode
00116   std::list<IoFileListItem>         fFileList;    // Files to get events from
00117   IoDataStreamItr*                  fDataStreamItr; // Current stream itr
00118 
00119   std::string fFormat;     // Format of data stream
00120   std::string fStreamList; // Comma sep list of streams to open
00121 
00122   std::map<std::string,int> fStreamMaxRepeatMap; // map of stream/max file repeat
00123   std::map<std::string,double> fStreamMeanMap; // map of stream/mean
00124   std::map<std::string,bool> fStreamPushRandomMap; // map of stream/push (rand/const)
00125   int fRandomSeed; // for kSequential & kRandom seq modes
00126  
00127   // DDS options
00128   std::string fServer;       // DDS server hostname
00129   int         fPort;         // DDS port number
00130   int         fTimeOut;      // DDS time out limit (seconds)
00131   int         fDataSource;   // DDS data source
00132   int         fKeepUpMode;   // DDS keep up mode
00133   int         fMaxSyncDelay; // DDS max sync delay (seconds)
00134   bool        fOffLine;      // DDS offline symbolic link bool
00135   int         fMaxRetry;     // DDS retry count for failed connections
00136   int         fRetryDelay;   // DDS wait n seconds between retries
00137   DDS::EClientType fClientType;   // DDS client type
00138   string      fClientName;   // DDS client name
00139 
00140   // Information about the current state
00141   JobCResult    fStatus;       // Status of input stream
00142   int           fLastRun;      // Last recorded run number
00143   int           fLastSnarl;    // Last recorded snarl number
00144   int           fCurrentRun;   // Current run number
00145   int           fCurrentSnarl; // Current snarl number
00146   std::map<std::string,std::string> fCurrentFileMap;//used to track file change
00147   std::map<std::string,std::string> fLastFileMap;//used to track file change
00148   std::string                       fLastBeginFile;
00149   std::string                       fLastEndFile;
00150   bool          fLoadedCommandLineFiles; // Have we read the command line?
00151   TStopwatch    fStopwatch;    // used for i/o timing stats
00152 
00153 #ifdef SITE_HAS_SAM
00154 
00155   // SAM options
00156 
00157   std::string fStation;         // SAM Station to use e.g. minos-sam
00158   int  fSnapShotVers;           // Dataset snapshot to use
00159   std::string fWorkGroupName;   // Work group e.g. minos
00160   std::string fApplicationName; // Application name, e.g. loon
00161   std::string fApplicationVers; // Application version
00162   std::string fProjectName;     // Project name - timestamp will be appended
00163   int  fMaxNumberOfFiles;       // Maximum number of files to process 
00164   int  fStartNewProject;             // Is this a new project
00165   sam::SamProject* fsamProject;
00166 #endif
00167 
00168 };
00169 
00170 #endif // IOINPUTMODULE_H
00171 
00172 

Generated on Mon Feb 15 11:06:48 2010 for loon by  doxygen 1.3.9.1