// euso root application // $Id: SimuApplication.hh,v 1.3 2005/11/14 22:44:15 thea Exp $ // M. Pallavicini - created 28-12-2001 // - modified for ESAF 8/02/2002 // /***************************************************************************** * ESAF: Euso Simulation and Analysis Framework * * * * Id: SimuApplication * * Package: Gui * * Coordinator: MArco.Pallavicini * * * *****************************************************************************/ #ifndef __SIMUAPPLICATION_HH_ #define __SIMUAPPLICATION_HH_ #include #include "TRint.h" #include "TObjArray.h" #include "SimuRootFileManager.hh" using namespace std; class Detector; class LightToEuso; class TTree; class EEvent; class ERunParameters; const Int_t kNmodules=2; enum EsafElement { kESAFLight=0, kESAFDetector}; //////////////////////////////////////////////////////////////////////////////// // // // SimuApplication // // // // Main ESAF Simu application // // // //////////////////////////////////////////////////////////////////////////////// class SimuApplication : public TRint, public EsafMsgSource{ friend class EusoMainFrame; public: // constructor SimuApplication(Int_t argc, char **argv); // destructor virtual ~SimuApplication(); // print help messages on screen virtual void Help(const char* line); // end job void EndJob(); // simulate a single event Bool_t DoEvent(Bool_t WriteRoot=kFALSE, Bool_t WriteTelemetry=kFALSE); // simulate all events in this file (up to fEvMax events) Bool_t DoAll(); // set and return fEvMax inline Int_t EvMax() const {return fEvMax;} // lock / unlock event runnning void SetLock( Bool_t lk = kTRUE ); Bool_t isLocked() {return (fLock>0);} // set/unset config flag; if something changes in the config // the relevant object is rebuilt inline void SetChanged(EsafElement e, Bool_t val=kTRUE) { fHasChanged[e]=val;} inline Bool_t HasChanged(EsafElement e) const {return fHasChanged[e];} // enable/disable a module // void EnableModule(EsafElement e, Bool_t val=kTRUE); // inline Bool_t isModuleEnabled(EsafElement e) const {return fEnModule[e];} // event counter inline Int_t EvCounter() const { return fEvCount;} inline void ResetEvCounter() { fEvCount = 0;} // run number inline void SetRunNumber(Int_t val) {fRunNumber = val;} inline Int_t GetRunNumber() const {return fRunNumber;} // dump last event data on stdout or onto a buffer // return kTRUE if OK, kFALSE on error (no data available) Bool_t DumpLastEvent(string* buffer); /* * run sequence: * * Constructor * Init - config, arguments... * Build - ligttoeuso, detector * Open rootfile - create trees * Set the Event up - assemble the event * Lock - Branch the event, lint parameters to the tree's user info * Loop - generate all the events * Unlock - release the event, disconnect the parameters from the tree. * Close rootfile * Destructor */ private: enum ESimuFiles { kLog, kDump, kRoot, kTelemetry }; void Init(); void ParseCmdLine( Int_t argc, char** argv); // env string fEsafSys; // base elements LightToEuso* fLightToEuso; Detector* fDetector; // euso detector inline LightToEuso* Light() {return fLightToEuso;} inline Detector* Euso() {return fDetector;} // build simulation chain void Build(); // method that handles analysis of the optics void DoOpticsAnalysis(); Bool_t fHasChanged[kNmodules]; // needs re-configure // Bool_t fEnModule[kNmodules]; // enable/disable the module Int_t fLock; // lock the simulation Int_t fEvCount; // number of events processed Int_t fEvMax; // max number of events to process UInt_t fSeed; // random number seed Int_t fRunNumber; // run number TString fRunName; // name of the run // root SimuRootFileManager *fManager; Bool_t fWriteRoot; // kTRUE if root file must be written Bool_t fWriteTelemetry; // same for Telemetry file // filenames string fOutDir; string fOutFileName; map< ESimuFiles , string > fFileNames; vector fUsrKeys; vector fUsrValues; vector fUsrCfgs; // to allow comparisons, the same event can be simulated and // /or reconstructed many times in different conditions these // functions provide the tools to do this events are stored // in an array every time an event is "rerun" (see // EusoMainFrame::) a copy is stored TObjArray fEventCopies; public: // getters inline EEvent *Event() { return fManager->GetEvent(); } inline ERunParameters *RunPars() { return fManager->GetRunPars(); } inline SimuRootFileManager *Manager() { return fManager; } inline void CopyEvent() {if ( Event() ) fEventCopies.AddLast( (TObject*)Manager()->GetEvent() ); } inline TObjArray* GetCopies() { return &fEventCopies; } void ResetCopies(); ClassDef(SimuApplication,0) }; extern SimuApplication* gSimuApplication; #endif