ROOT logo
#ifndef HPR_HPR
#define HPR_HPR
//#define MAXHIST 10
#include "TROOT.h"
#include "TQObject.h"
#include "TArrayI.h"
#include "TArrayF.h"
#include <TH1.h>
#include <TH2.h>
#include <TPad.h>
#include <TButton.h>
#include <TCanvas.h>
#include <TControlBar.h>
#include <TTree.h>
#include <TList.h>
#include <TSocket.h>
#include "TRootCanvas.h"
#include <iostream>

#include "FitHist.h"
#include "TMrbHelpBrowser.h"
#include "TGMrbValuesAndText.h"
#include <list>

namespace std {} using namespace std;


const Int_t MAXCAN=10;
class FitHist;
class GroupOfHists;

class HistPresent : public TNamed , public TQObject {

friend class FitHist;
friend class GEdit;
friend class HTCanvas;
friend class HandleMenus;
friend class GroupOfHists;

protected:
   TCanvas *cHPr;                 // the main canvas
   HTCanvas *fFileList;                 // the main canvas
   TFile       *fRootFile;        // root file
   TH1 * fCurrentHist;
   TRootCanvas *fRootCanvas;
//   TRootCanvas *lastcanvas;
   TGMrbValuesAndText *fDialogShowTree;
   Bool_t fByTitle;
   Int_t fRebin, fRMethod;
   TVirtualPad *activeFile;
   TVirtualPad *activeHist;
   Float_t fOpfac;
   TString *fLeafCut;
   TString *fGraphCut;
   TString *fCutVarX;
   TString *fCutVarY;
   TString *fExpression;
	Int_t   fUseFileSelFromRun;
	Int_t   fFileSelFromRun;
	Int_t   fFileSelToRun;
   TString fFileSelMask;
   Int_t   fUseFileSelMask;
   TString fHistSelMask;
   Int_t   fUseHistSelMask;
	TString fLeafSelMask;
   Int_t   fUseLeafSelMask;
	TString fCanvasSelMask;
   Int_t   fUseCanvasSelMask;
	Int_t fFileUseRegexp;
	Int_t fHistUseRegexp;
	Int_t fLeafUseRegexp;
	Int_t fCanvasUseRegexp;
	Bool_t fApplyLeafCut;
   Bool_t fUseHist;
   Bool_t fApplyGraphCut;
   Bool_t fApplyExpression;
   TControlBar * fControlBar;
//   TList *fCanvasList;
   TList *fAllWindows;
   TList *fAllFunctions;
   TList *fAllCuts;
   TList *fHistLists;
   TList *fSelectHist;
	TList *fSelectCanvas;
	TList *fHistListList;
   TList *fSelectLeaf;
   TList *fSelectCut;
   TList *fSelectWindow;
   TList *fCmdLine;
   TList *fSelectContour;
   TList *fSelectGraph;
   TList *fAllContours;

   TMrbHelpBrowser * fHelpBrowser;
   Int_t fSeqNumberMany;
	Int_t fSeqNumberGraph;
	Int_t fPageNumber;

   TString  fGraphFile;

   Int_t fRememberTreeHists;
   Int_t fAlwaysFindLimits;
   Int_t fAlwaysRequestLimits;
   Int_t fNtupleVersioning;
   Int_t fNtupleSeqNr;
	Int_t fNtuplePrependFN;
	Int_t fNtuplePrependTN;
	Int_t f2dimAsGraph;
	Int_t fWriteLeafMinMaxtoFile;
	Int_t fWriteLeafNamesToFile;
   Style_t fMarkStyle;
   Size_t  fMarkSize;
   Color_t fMarkColor;
   Int_t fRealStack;
   TString * fHelpDir;
   Double_t fLogScaleMin;
   Double_t fLinScaleMin;
   Int_t    fAutoUpdateDelay;

   TButton * fRebin2;
   TButton * fRebin4;
   TButton * fRebinOth;
   TButton * fRebinSumAvg;
   TButton * fValButton;
   TButton * fCloseWindowsButton;
   Bool_t    fCanvasClosing;
   TString * fHostToConnect;
   Bool_t    fConnectedOnce;
   Int_t     fSocketToConnect;
   TSocket * fComSocket;
//   Bool_t  fSocketIsOpen;
   Bool_t  fAnyFromSocket;
   TGWindow * fLastWindow;
	TButton * fHfromM_aButton;
   Int_t         fLabelMaxDigits;

   Color_t       fFuncColor;
   Style_t       fFuncStyle;
   Width_t       fFuncWidth;

   Int_t      fEditUsXlow  ;
   Int_t      fEditUsYlow  ;
   Int_t      fEditUsXwidth;
   Int_t      fEditUsYwidth;
   Double_t   fEditUsXRange;

   Int_t      fEditLsXlow  ;
   Int_t      fEditLsYlow  ;
   Int_t      fEditLsXwidth;
   Int_t      fEditLsYwidth;
   Double_t   fEditLsXRange;

   Int_t      fEditPoXlow  ;
   Int_t      fEditPoYlow  ;
   Int_t      fEditPoXwidth;
   Int_t      fEditPoYwidth;
   Double_t   fEditPoXRange;
	TString 		fEditor;

public:
enum EHfromASCIImode { kNotDefined, kSpectrum, kSpectrumError, k1dimHist,
                       k1dimHistWeight, k2dimHist, k2dimHistWeight,
                       kGraph, kGraphError, kGraphAsymmError,
                       k3dimHist, k3dimHistWeight,};

   HistPresent(const Text_t *name = "mypres" , const Text_t *title = "mypres");
   ~HistPresent();
	void HandleTerminate(Int_t status);
   void RecursiveRemove(TObject *);
   TRootCanvas* GetRootCanvas(){return fRootCanvas;};
//   void  SetMyCanvas(TRootCanvas *myc){lastcanvas = myc;};
   void SaveOptions();
   void RestoreOptions();
   void EditAttrFile();
   void Editrootrc();
   void CloseAllCanvases();
   void CloseHistLists();
   void HandleDeleteCanvas(HTCanvas * htc);
   void SetRebinValue(Int_t);               //
   void SetRebinMethod();               //
   void DiffHist();                 //
   void RebinHist();               //
   void OperateHist(Int_t);               //
   void SetOperateVal();               //
   void ListSelect();
   void SetShowTreeOptions(TGWindow * win = 0);
   void SetShowTreeOptionsCint(const char *pointer = 0);

   void CRButtonPressed(Int_t, Int_t, TObject*);
   void CloseDown(Int_t wid);
//   void CheckAutoExecFiles();
   void ClearSelect();
   void ShowMain();               //
//   Bool_t IsSelected(const char * name);
   void ListMacros(const char* bp =0);               //
   void GetFileSelMask(const char* bp =0);               //
   void GetHistSelMask(const char* bp =0);               //
//   void SetHistSelMask();               //
   void SelectCut(const char* , const char*, const char* bp =0);
   void SelectContour(const char* , const char*, const char* bp =0);
   void SelectGraph(const char*  , const char* dir, const char*, const char* bp =0);
   void SelectLeaf(const char*, const char* bp =0);
   void EditLeafCut(const char* vl =0, const char* bp = 0);
   void ToggleLeafCut(const char* bp = 0);
   void UseHist(const char* bp =0);
   void ToggleUseHist(const char* bp = 0);
//   void DefineGraphCut(const char* bp =0);
//   void ToggleGraphCut(const char* bp =0);
   void EditExpression(const char* vl =0, const char* bp =0);
   void ToggleExpression(const char* bp =0);
   void ShowFiles(const char* , const char* bp =0);               //
   void SelectFromOtherDir();
	void SelectdCache();
	void ShowContents(const char* fname, const char* dir = 0,const char* bp =0);    //
   void ShowFunction(const char*, const char*, const char*, const char* bp =0);
   void LoadFunction(const char*, const char*, const char*, const char* bp =0);
   void ShowCanvas(const char* , const char*, const char*, const char* bp =0);
   void ShowContour(const char*, const char*, const char*, const char* bp =0);
   void ShowGraph(const char*, const char* , const char*, const char* bp =0);
	void HistsFromProof(const char* bp = NULL);
   void ComposeList(const char* bp =0);
   void ShowList(const char* , const char*, const char* bp =0);
   void PrintCut(const char* , const char*, const char* bp =0);
   void LoadCut(const char* , const char*, const char* bp =0);
   void CutsToASCII(const char *, const char* bp =0);
   void PrintWindow(const char* , const char*, const char* bp =0);
   void LoadWindow(const char* , const char*, const char* bp =0);
   void ShowHist(const char * fname , const char* dir, const char  * hname, const char* bp =0);
   void SelectHist(const char*  fname , const char* dir , const char * hname, const char* bp =0);
	void SelectCanvas(const char*  fname , const char* dir , const char * hname, const char* bp =0);
	void ShowStatOfAll(const char* , const char* , const char* bp =0);
   void PurgeEntries(const char* , const char* bp =0);
   void DeleteSelectedEntries(const char* , const char* bp =0);
   void ShowSelectedHists(const char* bp =0);
   void ShowSelectedHists(TList *, const char* title =0);
   void StackSelectedHists(const char* bp =0);
//	void StackSelectedHistsScaled(const char* bp =0);
	void StackSelectedHists(TList *, const char* title =0);
   void ShowInOneCanvas(const char* bp =0);
   void StackInOneCanvas(const char* bp =0);
   void ShowTree(const char*, const char*, const char*, const char* bp =0);
   void ShowLeaf(const char*, const char*, const char*, const char* l=0, const char* bp =0);  // display hist of leaf
   void MkClass(const char*, const char*, const char*, const char* l=0, const char* bp =0);  // display hist of leaf
   void HandleRemoveAllCuts();
   void CutsFromASCII(TGWindow * win = 0);
   void HistFromASCII(TGWindow * win = 0);
   void GraphFromASCII(TGWindow * win = 0);
   void NtupleFromASCII(TGWindow * win = 0);
   void SaveFromSocket(const char*, const char* bp =0);
   TH1*  GetHist(const char*, const char*, const char*);
   FitHist * ShowHist(TH1*, const char* origname=NULL, TButton *b = NULL);
//   TList* GetCanvasList(){return fCanvasList;};
   TList* GetHistList(){return fHistLists;};
   TList* GetSelectedHist(){return fSelectHist;};
	TList* GetSelectedCanvas(){return fSelectCanvas;};
	TList* GetWindowList(){return fAllWindows;};
   TList* GetFunctionList(){return fAllFunctions;};
   TList* GetCutList(){return fAllCuts;};
   TList* GetGraphList(){return fSelectGraph;};
	TH1*   GetSelHistAt(Int_t pos = 0, TList * hl = NULL, Bool_t try_memory = kFALSE,
							  const char * hsuffix = NULL);
   TObject* GetSelGraphAt(Int_t pos = 0);
   void TurnButtonGreen(TVirtualPad **);
   TList* GetSelections(){return fSelectHist;};

   TH1 *  GetCurrentHist(){return fCurrentHist;};
   void   SetCurrentHist(TH1 * hist){fCurrentHist = hist;};
   TMrbHelpBrowser * GetHelpBrowser(){return fHelpBrowser;};
   void WarnBox(const char *);
   void CleanWindowLists(TH1* hist);
//   void RemoveFromLists(TObject * obj);
   void DinA4Page(Int_t form);
   Int_t GetWindowPosition(Int_t * winx, Int_t * winy);
   void SuperimposeGraph(TCanvas * = NULL, Int_t mode = 0);

ClassDef(HistPresent,0)      // A histogram presenter
};

R__EXTERN HistPresent *gHpr;
R__EXTERN Int_t gHprDebug;
R__EXTERN Int_t gHprClosing;
R__EXTERN TString gHprWorkDir;
R__EXTERN TString gHprLocalEnv;
;
#endif
 HistPresent.h:1
 HistPresent.h:2
 HistPresent.h:3
 HistPresent.h:4
 HistPresent.h:5
 HistPresent.h:6
 HistPresent.h:7
 HistPresent.h:8
 HistPresent.h:9
 HistPresent.h:10
 HistPresent.h:11
 HistPresent.h:12
 HistPresent.h:13
 HistPresent.h:14
 HistPresent.h:15
 HistPresent.h:16
 HistPresent.h:17
 HistPresent.h:18
 HistPresent.h:19
 HistPresent.h:20
 HistPresent.h:21
 HistPresent.h:22
 HistPresent.h:23
 HistPresent.h:24
 HistPresent.h:25
 HistPresent.h:26
 HistPresent.h:27
 HistPresent.h:28
 HistPresent.h:29
 HistPresent.h:30
 HistPresent.h:31
 HistPresent.h:32
 HistPresent.h:33
 HistPresent.h:34
 HistPresent.h:35
 HistPresent.h:36
 HistPresent.h:37
 HistPresent.h:38
 HistPresent.h:39
 HistPresent.h:40
 HistPresent.h:41
 HistPresent.h:42
 HistPresent.h:43
 HistPresent.h:44
 HistPresent.h:45
 HistPresent.h:46
 HistPresent.h:47
 HistPresent.h:48
 HistPresent.h:49
 HistPresent.h:50
 HistPresent.h:51
 HistPresent.h:52
 HistPresent.h:53
 HistPresent.h:54
 HistPresent.h:55
 HistPresent.h:56
 HistPresent.h:57
 HistPresent.h:58
 HistPresent.h:59
 HistPresent.h:60
 HistPresent.h:61
 HistPresent.h:62
 HistPresent.h:63
 HistPresent.h:64
 HistPresent.h:65
 HistPresent.h:66
 HistPresent.h:67
 HistPresent.h:68
 HistPresent.h:69
 HistPresent.h:70
 HistPresent.h:71
 HistPresent.h:72
 HistPresent.h:73
 HistPresent.h:74
 HistPresent.h:75
 HistPresent.h:76
 HistPresent.h:77
 HistPresent.h:78
 HistPresent.h:79
 HistPresent.h:80
 HistPresent.h:81
 HistPresent.h:82
 HistPresent.h:83
 HistPresent.h:84
 HistPresent.h:85
 HistPresent.h:86
 HistPresent.h:87
 HistPresent.h:88
 HistPresent.h:89
 HistPresent.h:90
 HistPresent.h:91
 HistPresent.h:92
 HistPresent.h:93
 HistPresent.h:94
 HistPresent.h:95
 HistPresent.h:96
 HistPresent.h:97
 HistPresent.h:98
 HistPresent.h:99
 HistPresent.h:100
 HistPresent.h:101
 HistPresent.h:102
 HistPresent.h:103
 HistPresent.h:104
 HistPresent.h:105
 HistPresent.h:106
 HistPresent.h:107
 HistPresent.h:108
 HistPresent.h:109
 HistPresent.h:110
 HistPresent.h:111
 HistPresent.h:112
 HistPresent.h:113
 HistPresent.h:114
 HistPresent.h:115
 HistPresent.h:116
 HistPresent.h:117
 HistPresent.h:118
 HistPresent.h:119
 HistPresent.h:120
 HistPresent.h:121
 HistPresent.h:122
 HistPresent.h:123
 HistPresent.h:124
 HistPresent.h:125
 HistPresent.h:126
 HistPresent.h:127
 HistPresent.h:128
 HistPresent.h:129
 HistPresent.h:130
 HistPresent.h:131
 HistPresent.h:132
 HistPresent.h:133
 HistPresent.h:134
 HistPresent.h:135
 HistPresent.h:136
 HistPresent.h:137
 HistPresent.h:138
 HistPresent.h:139
 HistPresent.h:140
 HistPresent.h:141
 HistPresent.h:142
 HistPresent.h:143
 HistPresent.h:144
 HistPresent.h:145
 HistPresent.h:146
 HistPresent.h:147
 HistPresent.h:148
 HistPresent.h:149
 HistPresent.h:150
 HistPresent.h:151
 HistPresent.h:152
 HistPresent.h:153
 HistPresent.h:154
 HistPresent.h:155
 HistPresent.h:156
 HistPresent.h:157
 HistPresent.h:158
 HistPresent.h:159
 HistPresent.h:160
 HistPresent.h:161
 HistPresent.h:162
 HistPresent.h:163
 HistPresent.h:164
 HistPresent.h:165
 HistPresent.h:166
 HistPresent.h:167
 HistPresent.h:168
 HistPresent.h:169
 HistPresent.h:170
 HistPresent.h:171
 HistPresent.h:172
 HistPresent.h:173
 HistPresent.h:174
 HistPresent.h:175
 HistPresent.h:176
 HistPresent.h:177
 HistPresent.h:178
 HistPresent.h:179
 HistPresent.h:180
 HistPresent.h:181
 HistPresent.h:182
 HistPresent.h:183
 HistPresent.h:184
 HistPresent.h:185
 HistPresent.h:186
 HistPresent.h:187
 HistPresent.h:188
 HistPresent.h:189
 HistPresent.h:190
 HistPresent.h:191
 HistPresent.h:192
 HistPresent.h:193
 HistPresent.h:194
 HistPresent.h:195
 HistPresent.h:196
 HistPresent.h:197
 HistPresent.h:198
 HistPresent.h:199
 HistPresent.h:200
 HistPresent.h:201
 HistPresent.h:202
 HistPresent.h:203
 HistPresent.h:204
 HistPresent.h:205
 HistPresent.h:206
 HistPresent.h:207
 HistPresent.h:208
 HistPresent.h:209
 HistPresent.h:210
 HistPresent.h:211
 HistPresent.h:212
 HistPresent.h:213
 HistPresent.h:214
 HistPresent.h:215
 HistPresent.h:216
 HistPresent.h:217
 HistPresent.h:218
 HistPresent.h:219
 HistPresent.h:220
 HistPresent.h:221
 HistPresent.h:222
 HistPresent.h:223
 HistPresent.h:224
 HistPresent.h:225
 HistPresent.h:226
 HistPresent.h:227
 HistPresent.h:228
 HistPresent.h:229
 HistPresent.h:230
 HistPresent.h:231
 HistPresent.h:232
 HistPresent.h:233
 HistPresent.h:234
 HistPresent.h:235
 HistPresent.h:236
 HistPresent.h:237
 HistPresent.h:238
 HistPresent.h:239
 HistPresent.h:240
 HistPresent.h:241
 HistPresent.h:242
 HistPresent.h:243
 HistPresent.h:244
 HistPresent.h:245
 HistPresent.h:246
 HistPresent.h:247
 HistPresent.h:248
 HistPresent.h:249
 HistPresent.h:250
 HistPresent.h:251
 HistPresent.h:252
 HistPresent.h:253
 HistPresent.h:254
 HistPresent.h:255
 HistPresent.h:256
 HistPresent.h:257
 HistPresent.h:258
 HistPresent.h:259
 HistPresent.h:260
 HistPresent.h:261
 HistPresent.h:262
 HistPresent.h:263
 HistPresent.h:264
 HistPresent.h:265
 HistPresent.h:266
 HistPresent.h:267
 HistPresent.h:268
 HistPresent.h:269
 HistPresent.h:270
 HistPresent.h:271
 HistPresent.h:272
 HistPresent.h:273
 HistPresent.h:274
 HistPresent.h:275
 HistPresent.h:276
 HistPresent.h:277
 HistPresent.h:278
 HistPresent.h:279
 HistPresent.h:280
 HistPresent.h:281
 HistPresent.h:282
 HistPresent.h:283
 HistPresent.h:284
 HistPresent.h:285