Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4TreeHistogramEntry.h"
00015
00016 #include "Riostream.h"
00017 #include "TTree.h"
00018 #include "TROOT.h"
00019
00020 #include "TGo4Log.h"
00021 #include "TGo4Status.h"
00022 #include "TGo4DynamicListException.h"
00023
00024 const char* TGo4TreeHistogramEntry::fgcENTRYSUF="-DL";
00025
00026 TGo4TreeHistogramEntry::TGo4TreeHistogramEntry() :
00027 TGo4DynamicEntry(),
00028 fxHistogramName(),
00029 fxVarExp(),
00030 fxCutExp(),
00031 fiDynListInterval(1000),
00032 fbNewHistogram(kTRUE),
00033 fiLastEvent(0)
00034 {
00035 GO4TRACE((15,"TGo4TreeHistogramEntry::TGo4TreeHistogramEntry()",__LINE__, __FILE__));
00036 fxTreeName="Go4Tree";
00037 EnableProcessing(kTRUE);
00038 }
00039
00040 TGo4TreeHistogramEntry::TGo4TreeHistogramEntry(const char* histogramname,
00041 const char* treename,
00042 const char* varexp,
00043 const char* cutexp) :
00044 TGo4DynamicEntry(histogramname),
00045 fxHistogramName(histogramname),
00046 fxTreeName(treename),
00047 fxVarExp(varexp),
00048 fxCutExp(cutexp),
00049 fiDynListInterval(1000),
00050 fbNewHistogram(kTRUE),
00051 fiLastEvent(0)
00052 {
00053 GO4TRACE((15,"TGo4TreeHistogramEntry::TGo4TreeHistogramEntry(const char*, const char*, const char*, const char*)",__LINE__, __FILE__));
00054 SetName(Form("%s%s",histogramname,fgcENTRYSUF));
00055 EnableProcessing(kTRUE);
00056
00057 Reset();
00058 }
00059
00060 TGo4TreeHistogramEntry::~TGo4TreeHistogramEntry()
00061 {
00062 GO4TRACE((15,"TGo4TreeHistogramEntry::~TGo4TreeHistogramEntry()",__LINE__, __FILE__));
00063 }
00064
00065 void TGo4TreeHistogramEntry::Reset()
00066 {
00067 GO4TRACE((12,"TGo4TreeHistogramEntry::Reset()",__LINE__, __FILE__));
00068 TGo4DynamicEntry::Reset();
00069 fiLastEvent=0;
00070 fbNewHistogram=kTRUE;
00071 }
00072
00073 void TGo4TreeHistogramEntry::ProcessTreeNew(TTree* tree, Int_t times)
00074 {
00075 if(times<=0) times=1;
00076
00077 Int_t lastentrynumber = static_cast<Int_t> (tree->GetEntries());
00078 if(tree->TestBit(TGo4Status::kGo4BackStoreReset))
00079 fiLastEvent=0;
00080
00081 if(fiLastEvent==lastentrynumber)
00082 throw TGo4DynamicListException(this,
00083 "Tree Histogram Entry: %s Reached end of tree %s. Draw() is stopped. ",
00084 GetName(), tree->GetName());
00085 Int_t startindex= lastentrynumber -times;
00086
00087 if(startindex<fiLastEvent)
00088 {
00089
00090
00091 if(startindex>0)
00092 {
00093
00094 startindex=fiLastEvent;
00095 }
00096 else
00097 {
00098
00099
00100 startindex=0;
00101 }
00102 times=lastentrynumber-startindex;
00103 }
00104 else
00105 {
00106
00107
00108 startindex=fiLastEvent;
00109
00110
00111
00112 }
00113
00114 fiLastEvent=startindex+times;
00115
00116 if(fiLastEvent>lastentrynumber) {
00117 std::cout <<"Passing over end of tree - NEVER COME HERE!!!" << std::endl;
00118 fiLastEvent=lastentrynumber;
00119 times=fiLastEvent-startindex;
00120 std::cout << "\t -- startindex: "<< startindex<< std::endl;
00121 std::cout << "\t -- times: "<< times<< std::endl;
00122 std::cout << "\t -- treeentries: "<< lastentrynumber<< std::endl;
00123 }
00124
00125 TString drawexp = GetVarExp();
00126 drawexp += ">>+";
00127 drawexp += GetHistogramName();
00128
00129 TDirectory* savdir = gDirectory;
00130 gROOT->cd();
00131 tree->Draw(drawexp.Data(), fxCutExp.Data(), "goff", times, startindex);
00132 savdir->cd();
00133 }
00134
00135
00136 void TGo4TreeHistogramEntry::Print(Option_t* dummy) const
00137 {
00138
00139 TROOT::IndentLevel();
00140 std::cout <<"-Dynamic TreeDraw Entry " << GetName() << " :" << std::endl;
00141 TROOT::IncreaseDirLevel();
00142 if(IsEnabledProcessing()) std::cout <<"\t-- Enabled --" << std::endl;
00143 else std::cout <<"\t-- Disabled --" << std::endl;
00144
00145 TROOT::IndentLevel();
00146 std::cout <<"\tHistogram:\t"<< GetHistogramName()<<std::endl;
00147 TROOT::IndentLevel();
00148 std::cout <<"\tTree:\t"<< GetTreeName()<<std::endl;
00149 TROOT::IndentLevel();
00150 std::cout <<"\tDraw Expression:\t" << GetVarExp() <<std::endl;
00151 TROOT::IndentLevel();
00152 std::cout <<"\tCut Expression:\t" << GetCutExp() << std::endl;
00153 TROOT::DecreaseDirLevel();
00154 TROOT::IndentLevel();
00155 std::cout <<"-End "<<GetName()<<"-----------" << std::endl;
00156 }