00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TGO4ANALYSISIMP_H
00015 #define TGO4ANALYSISIMP_H
00016
00017 #include "TGo4CommandReceiver.h"
00018 #include "TObject.h"
00019 #include "TString.h"
00020
00021 class TH1;
00022 class TH2;
00023 class TTree;
00024 class TCanvas;
00025 class TFolder;
00026 class TNamed;
00027 class TMutex;
00028 class TStopwatch;
00029 class TFile;
00030
00031 class TGo4AnalysisStepManager;
00032 class TGo4AnalysisObjectManager;
00033 class TGo4AnalysisObjectNames;
00034 class TGo4AnalysisSniffer;
00035 class TGo4AnalysisStatus;
00036 class TGo4AnalysisStep;
00037 class TGo4AnalysisClient;
00038 class TGo4HistogramStatus;
00039 class TGo4DynamicEntry;
00040 class TGo4Condition;
00041 class TGo4WinCond;
00042 class TGo4PolyCond;
00043 class TGo4Parameter;
00044 class TGo4ParameterStatus;
00045 class TGo4Picture;
00046 class TGo4Fitter;
00047 class TGo4ObjectStatus;
00048 class TGo4EventStoreParameter;
00049 class TGo4EventSourceParameter;
00050 class TGo4EventProcessorParameter;
00051 class TGo4EventElement;
00052 class TGo4EventStore;
00053 class TGo4EventSource;
00054 class TGo4EventProcessor;
00055 class TGo4TreeStructure;
00056 class TGo4InterruptHandler;
00057
00068 class TGo4Analysis : public TGo4CommandReceiver, public TObject {
00069
00070 friend class TGo4AnalysisStep;
00071 friend class TGo4AnalysisClient;
00072 friend class TGo4ComGetCurrentEvent;
00073 friend class TGo4ComGetNamesList;
00074 friend class TGo4ComGetEnvelope;
00075 friend class TGo4ComSetObject;
00076 friend class TGo4HisConnectorRunnable;
00077 friend class TGo4HistogramServer;
00078
00079 public:
00080
00082 static const Int_t fgiAUTOSAVECOUNTS;
00083
00085 static const Int_t fgiDYNLISTINTERVAL;
00086
00088 static const Int_t fgiMACROSTARTPOLL;
00089
00091 static const char* fgcDEFAULTFILENAME;
00092
00094 static const char* fgcDEFAULTSTATUSFILENAME;
00095
00097 static const char* fgcDEFAULTFILESUF;
00098
00100 static const char* fgcTOPDYNAMICLIST;
00101
00102 static TGo4Analysis* Instance();
00103
00104 static Bool_t Exists();
00105
00107 static Bool_t IsBatchMode();
00108
00110 static Bool_t IsClientMode();
00111
00113 static Bool_t IsServerMode();
00114
00115 static void SetRunningMode(int mode);
00116
00117 virtual ~TGo4Analysis();
00118
00119 virtual const char* GetName() const { return fAnalysisName.Data(); }
00120
00121 void SetAnalysisName(const char* name) { fAnalysisName = name; }
00122
00126 Int_t MainCycle();
00127
00130 Int_t PreLoop();
00131
00134 Int_t PostLoop();
00135
00140 Int_t Process();
00141
00142
00148 virtual Int_t UserEventFunc();
00149
00152 virtual Int_t UserPreLoop();
00153
00156 virtual Int_t UserPostLoop();
00157
00163 Int_t RunImplicitLoop(Int_t times, Bool_t showrate = kFALSE, Double_t process_event_interval = -1.);
00164
00167 virtual void CloseAnalysis();
00168
00172 virtual Bool_t InitEventClasses();
00173
00175 TGo4AnalysisObjectManager* ObjectManager() const { return fxObjectManager; }
00176
00186 Bool_t AddDynamicHistogram(const char* name,
00187 const char* histo,
00188 const char* hevx, const char* hmemx,
00189 const char* hevy=0, const char* hmemy=0,
00190 const char* hevz=0, const char* hmemz=0,
00191 const char* condition=0,
00192 const char* cevx=0, const char* cmemx=0,
00193 const char* cevy=0, const char* cmemy=0);
00194
00199 Bool_t AddDynamicEntry(TGo4DynamicEntry* entry);
00200
00204 Bool_t RemoveDynamicEntry(const char* entryname, const char* listname=0);
00205
00212 Bool_t AddObject(TNamed * anything, const char* subfolder=0, Bool_t replace=kTRUE);
00213
00218 TNamed * GetObject(const char* name, const char* folder=0);
00219
00223 Bool_t RemoveObject(const char* name, Bool_t del=kTRUE);
00224
00229 Bool_t DeleteObjects(const char * name);
00230
00235 Bool_t ClearObjects(const char* name);
00236
00244 Bool_t ProtectObjects(const char* name, const Option_t* flags);
00245
00249 Bool_t ResetBackStores(Bool_t clearflag=kFALSE);
00250
00257 TObject* NextMatchingObject(const char* expr=0,
00258 const char* folder=0,
00259 Bool_t reset=kFALSE);
00260
00262 TGo4TreeStructure* CreateTreeStructure(const char* treename);
00263
00266 Bool_t AddHistogram(TH1* his , const char* subfolder=0, Bool_t replace=kTRUE);
00267
00273 Bool_t AddTree(TTree* tree, const char* subfolder=0);
00274
00279 Bool_t RemoveTree(TTree * tree, const char* stepname=0);
00280
00285 Bool_t AddTreeHistogram(const char* hisname, const char* treename, const char* varexp, const char* cutexp);
00286
00288 TH1* GetHistogram(const char* name);
00289
00291 TTree * GetTree(const char* name);
00292
00296 Bool_t RemoveHistogram(const char* name, Bool_t del=kTRUE);
00297
00301 Bool_t AddAnalysisCondition(TGo4Condition * con, const char* subfolder=0);
00302
00307 Bool_t SetAnalysisCondition(const char* name, TGo4Condition* con, Bool_t counter=kTRUE);
00308
00312 TGo4Condition * GetAnalysisCondition(const char* name, const char* cond_cl = 0);
00313
00316 Bool_t RemoveAnalysisCondition(const char* name);
00317
00321 Bool_t AddParameter(TGo4Parameter * par, const char* subfolder=0);
00322
00327 Bool_t SetParameter(const char* name, TGo4Parameter * par);
00328
00333 Bool_t SetParameterStatus(const char* name, TGo4ParameterStatus* par);
00334
00338 TGo4Parameter * GetParameter(const char* name, const char* parameter_class = 0);
00339
00342 Bool_t RemoveParameter(const char* name);
00343
00347 Bool_t AddPicture(TGo4Picture * pic, const char* subfolder=0);
00348
00353 Bool_t SetPicture(const char* name, TGo4Picture * pic);
00354
00357 TGo4Picture * GetPicture(const char* name);
00358
00361 Bool_t RemovePicture(const char * name);
00362
00366 Bool_t AddCanvas(TCanvas * can, const char* subfolder=0);
00367
00370 TCanvas * GetCanvas(const char* name);
00371
00374 Bool_t RemoveCanvas(const char * name);
00375
00378 TGo4AnalysisStatus* CreateStatus();
00379
00383 TGo4ObjectStatus* CreateObjectStatus(const char * name, const char* folder=0);
00384
00386 TGo4AnalysisObjectNames * CreateNamesList();
00387
00389 TFolder * GetObjectFolder();
00390
00392 void UpdateStatus(TGo4AnalysisStatus* state);
00393
00402 void SetStatus(TGo4AnalysisStatus * state);
00403
00406 Bool_t LoadStatus(const char* filename=0);
00407
00410 Bool_t LoadObjects(const char* filename=0);
00411
00413 Bool_t SaveStatus(const char* filename=0);
00414
00418 void SetStepChecking(Bool_t on=kTRUE);
00419
00423 Bool_t SetFirstStep(const char* name);
00424
00429 Bool_t SetLastStep(const char* name);
00430
00441 Bool_t SetStepStorage(const char* name, Bool_t on);
00442
00446 Bool_t NewStepStore(const char* name, TGo4EventStoreParameter* par);
00447
00451 Bool_t NewStepSource(const char* name, TGo4EventSourceParameter * par);
00452
00456 Bool_t NewStepProcessor(const char* name, TGo4EventProcessorParameter * par);
00457
00459 void SetAutoSaveInterval(Int_t interval=0) { fiAutoSaveInterval=interval; }
00460
00462 void SetAutoSaveFile(const char* filename=0,
00463 Bool_t overwrite=kFALSE,
00464 Int_t compression=5);
00465
00467 Bool_t IsAutoSaveFileName() const;
00468
00470 Int_t LockAutoSave();
00471
00473 Int_t UnLockAutoSave();
00474
00476 void SetAutoSave(Bool_t on=kTRUE) { fbAutoSaveOn=on; }
00477
00479 Bool_t IsAutoSaveOn() const { return fbAutoSaveOn; }
00480
00482 void SetAutoSaveFileChange(Bool_t on=kTRUE) {fbAutoSaveFileChange=on;}
00483
00486 Bool_t IsAutoSaveFileChange() const { return fbAutoSaveFileChange; }
00487
00489 Bool_t IsInitDone() const { return fbInitIsDone; }
00490
00495 Bool_t IsRunning();
00496
00497
00501 void SetRunning(Bool_t on=kTRUE);
00502
00506 Int_t WaitForStart();
00507
00509 Int_t IsErrorStopEnabled();
00510
00512 void SetNewInputFile(Bool_t on=kTRUE) { fbNewInputFile=on; }
00513
00515 Bool_t IsNewInputFile() const { return fbNewInputFile; }
00516
00518 void SetInputFileName(const char* fname) { fxCurrentInputFileName = fname; }
00519
00521 const char* GetInputFileName() const { return fxCurrentInputFileName.Data(); }
00522
00523 void SetDynListInterval(Int_t val);
00524
00525 Int_t GetDynListInterval();
00526
00530 TGo4EventElement* GetInputEvent(const char* stepname);
00531
00536 TGo4EventElement* GetInputEvent(Int_t stepindex);
00537
00542 TGo4EventElement* GetOutputEvent(const char* stepname);
00543
00550 TGo4EventElement* GetOutputEvent(Int_t stepindex);
00551
00555 TGo4EventElement* GetOutputEvent();
00556
00558 TGo4EventElement * GetEventStructure(const char * name);
00559
00566 void Message(Int_t prio, const char* text,...);
00567
00570 void SendObjectToGUI(TObject* ob);
00571
00574 void StartObjectServer(const char* basename, const char* passwd);
00575
00577 void StopObjectServer();
00578
00579
00582 void SetAdministratorPassword(const char* passwd);
00583
00586 void SetControllerPassword(const char* passwd);
00587
00590 void SetObserverPassword(const char* passwd);
00591
00592
00594 virtual void Print(Option_t* opt="") const;
00595
00597 void PrintHistograms(const char* expression = 0);
00598
00600 void PrintConditions(const char* expression = 0);
00601
00603 void PrintParameters(const char* expression = 0);
00604
00606 void PrintDynamicList();
00607
00613 void ShowEvent(const char* stepname, Bool_t isoutput=kTRUE);
00614
00619 Int_t StoreParameter(const char * name, TGo4Parameter* par);
00620
00625 Int_t StoreCondition(const char * name, TGo4Condition* con);
00626
00631 Int_t StoreFitter(const char * name, TGo4Fitter* fit);
00632
00637 Int_t StoreFolder(const char * stepname, TFolder* folder);
00638
00642 Int_t StoreFolder(const char * stepname, const char* foldername);
00643
00646 void AutoSave();
00647
00655 Bool_t AddAnalysisStep(TGo4AnalysisStep* next);
00656
00659 TGo4AnalysisStep* GetAnalysisStep(const char* name);
00660
00662 TGo4AnalysisStep* GetAnalysisStepNum(Int_t number);
00663
00665 void DefineServerPasswords(const char* admin, const char* controller, const char* observer);
00666
00668 void SetBatchLoopCount(Int_t cnt = -1) { fBatchLoopCount = cnt; }
00669
00671 void SetMakeWithAutosave(Bool_t on = kTRUE) { fbMakeWithAutosave = on; }
00672
00675 Bool_t IsObjMade() { return fbObjMade; }
00676
00690 TH1* MakeTH1(char type, const char* fullname, const char* title,
00691 Int_t nbinsx, Double_t xlow, Double_t xup,
00692 const char* xtitle = 0, const char* ytitle = 0);
00693
00708 TH2* MakeTH2(char type, const char* fullname, const char* title,
00709 Int_t nbinsx, Double_t xlow, Double_t xup,
00710 Int_t nbinsy, Double_t ylow, Double_t yup,
00711 const char* xtitle = 0, const char* ytitle = 0, const char* ztitle = 0);
00712
00718 TGo4WinCond* MakeWinCond(const char* fullname,
00719 Double_t xmin, Double_t xmax,
00720 const char* HistoName = 0);
00721
00728 TGo4WinCond* MakeWinCond(const char* fullname,
00729 Double_t xmin, Double_t xmax,
00730 Double_t ymin, Double_t ymax,
00731 const char* HistoName = 0);
00732
00742 TGo4PolyCond* MakePolyCond(const char* fullname,
00743 Int_t npoints,
00744 Double_t (*points) [2],
00745 const char* HistoName = 0);
00746
00759 TGo4Parameter* MakeParameter(const char* fullname,
00760 const char* classname,
00761 const char* cmd = 0);
00762
00765 Long_t ExecuteScript(const char* script_name);
00766
00768 void ProcessCrtlCSignal();
00769
00771 void SetSniffer(TGo4AnalysisSniffer* sniff) { fSniffer = sniff; }
00772
00774 TGo4AnalysisSniffer* GetSniffer() const { return fSniffer; }
00775
00777 TGo4AnalysisClient* GetAnalysisClient() const { return fxAnalysisSlave; }
00778
00780 void StopAnalysis();
00781
00783 void StartAnalysis();
00784
00785 protected:
00786
00789 Bool_t fbInitIsDone;
00790
00793 Bool_t fbAutoSaveOn;
00794
00796 TGo4Analysis(const char* name = 0);
00797
00799 TGo4Analysis(int argc, char** argv);
00800
00802 void Constructor();
00803
00804
00810 Int_t ProcessAnalysisSteps();
00811
00812 private:
00813
00820 TTree* CreateSingleEventTree(const char* name, Bool_t isoutput=kTRUE);
00821
00823 TTree* CreateSingleEventTree(TGo4EventElement* event);
00824
00826 void UpdateNamesList();
00827
00830 TGo4AnalysisObjectNames * GetNamesList() const { return fxObjectNames; }
00831
00835 void SetOutputEvent(TGo4EventElement * event);
00836
00839 Bool_t AddEventStore(TGo4EventStore * store);
00840
00842 Bool_t RemoveEventStore(TGo4EventStore * store);
00843
00846 Bool_t AddEventSource(TGo4EventSource * source);
00847
00849 Bool_t RemoveEventSource(TGo4EventSource* source);
00850
00853 Bool_t AddEventProcessor(TGo4EventProcessor * pro);
00854
00856 Bool_t RemoveEventProcessor(TGo4EventProcessor * pro);
00857
00860 Bool_t AddEventStructure(TGo4EventElement * ev);
00861
00863 Bool_t RemoveEventStructure(TGo4EventElement * ev);
00864
00866 void SetAnalysisClient(TGo4AnalysisClient* cli) { fxAnalysisSlave = cli; }
00867
00872 void SendMessageToGUI(Int_t level, Bool_t printout, const char* text);
00873
00875 void OpenAutoSaveFile(bool for_writing = false);
00876
00878 void CloseAutoSaveFile();
00879
00881 void StopWorking() { fxDoWorkingFlag = flagStop; }
00882
00884 Bool_t IsStopWorking() const { return fxDoWorkingFlag == flagStop; }
00885
00886
00887 void ShutdownServer();
00888
00889
00891 static TGo4Analysis* fxInstance;
00892
00896 static Bool_t fbExists;
00897
00900 static Int_t fiRunningMode;
00901
00903 TGo4AnalysisClient* fxAnalysisSlave;
00904
00907 TGo4AnalysisStepManager* fxStepManager;
00908
00911 TGo4AnalysisObjectManager* fxObjectManager;
00912
00914 Int_t fiAutoSaveCount;
00915
00917 TStopwatch* fxAutoSaveClock;
00918
00922 Int_t fiAutoSaveInterval;
00923
00925 Int_t fiAutoSaveCompression;
00926
00930 TMutex* fxAutoSaveMutex;
00931
00933 TFile* fxAutoFile;
00934
00936 TString fxAutoFileName;
00937
00939 Bool_t fbAutoSaveOverwrite;
00940
00942 TString fxConfigFilename;
00943
00946 Bool_t fbNewInputFile;
00947
00949 TString fxCurrentInputFileName;
00950
00953 Bool_t fbAutoSaveFileChange;
00954
00957 TGo4EventElement* fxSampleEvent;
00958
00961 TGo4AnalysisObjectNames * fxObjectNames;
00962
00964 enum { flagStop, flagPause, flagRunning } fxDoWorkingFlag;
00965
00967 TGo4InterruptHandler* fxInterruptHandler;
00968
00970 TString fAnalysisName;
00971
00973 Int_t fBatchLoopCount;
00974
00976 TString fServerAdminPass;
00977
00979 TString fServerCtrlPass;
00980
00982 TString fServerObserverPass;
00983
00985 Bool_t fbMakeWithAutosave;
00986
00988 Bool_t fbObjMade;
00989
00991 Int_t fNumCtrlC;
00992
00994 TGo4AnalysisSniffer* fSniffer;
00995
00996 ClassDef(TGo4Analysis,4)
00997 };
00998
00999 #endif