00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4BackStore.h"
00017
00018 #include <iostream.h>
00019
00020 #include "Go4Log/TGo4Log.h"
00021 #include "Go4Event/TGo4EventElement.h"
00022 #include "Go4Event/TGo4CompositeEvent.h"
00023
00024 const Text_t TGo4BackStore::fgcTREESUF[] = "xTree";
00025 const Text_t TGo4BackStore::fgcEVBRANCHNAME[] = "Go4EventBranch.";
00026
00027 const Int_t TGo4BackStore::fgiMAXAUTOBYTES = 100000000;
00028
00029 TGo4BackStore::TGo4BackStore(TGo4BackStoreParameter* par)
00030 : TGo4EventStore("dummy"),
00031 fbBranchExists(kFALSE), fxEvent(0),
00032 fiSplit(par->fiSplit), fiBufsize(par->fiBufsize), fiFillCount(0)
00033
00034 {
00035 TRACE((15,"TGo4BackStore::TGo4BackStore(TGo4BackStoreParameter* par)", __LINE__, __FILE__));
00036
00037 Text_t buffer[TGo4EventStore::fguTXTLEN];
00038 snprintf(buffer,TGo4EventStore::fguTXTLEN -20, par->GetName());
00039 SetName(buffer);
00040
00041 const char* lastname = par->GetTitle();
00042 const char* oldname = lastname;
00043 lastname=strstr(oldname,"/");
00044 while(lastname!=0)
00045 {
00046 oldname=lastname+1;
00047 lastname=strstr(oldname,"/");
00048 }
00049 snprintf(buffer, TGo4EventStore::fguTXTLEN -10 , oldname);
00050 strcat(buffer,fgcTREESUF);
00051 TDirectory *dirsav = gDirectory;
00052 gROOT->cd();
00053 fxTree = new TTree(buffer, "Go4BackStore");
00054 fxTree->SetAutoSave(TGo4BackStore::fgiMAXAUTOBYTES);
00055 TGo4Log::Debug(" Tree %s has been created in memory ",buffer);
00056 dirsav->cd();
00057 }
00058
00059 TGo4BackStore::TGo4BackStore()
00060 :TGo4EventStore("Go4 Default Back Store"), fbBranchExists(kFALSE), fxEvent(0),
00061 fiSplit(1), fiBufsize(0), fiFillCount(0)
00062 {
00063 TRACE((15,"TGo4BackStore::TGo4BackStore()", __LINE__, __FILE__));
00064
00065 fxTree=0;
00066
00067
00068 }
00069
00070
00071 TGo4BackStore::~TGo4BackStore()
00072 {
00073 TRACE((15,"TGo4BackStore::~TGo4BackStore()", __LINE__, __FILE__));
00074 delete fxTree;
00075
00076 }
00077
00078
00079
00080
00081 Int_t TGo4BackStore::Store(TGo4Parameter* cali)
00082 {
00083 return 0;
00084 }
00085
00086 Int_t TGo4BackStore::Store(TGo4Condition* conny)
00087 {
00088 return 0;
00089 }
00090
00091 Int_t TGo4BackStore::Store(TGo4Fitter* fitty)
00092 {
00093 return 0;
00094 }
00095
00096 Int_t TGo4BackStore::Store(TFolder* foldy)
00097 {
00098 return 0;
00099 }
00100
00101
00102 Int_t TGo4BackStore::Store(TGo4EventElement* event)
00103 {
00104 TRACE((12,"TGo4BackStore::Store(TGo4EventElement*)", __LINE__, __FILE__));
00105
00106 fxEvent=event;
00107 if(!fbBranchExists)
00108 {
00109
00110
00111 if(fxEvent)
00112 {
00113 Text_t topbranchname [TGo4EventStore::fguTXTLEN];
00114 snprintf(topbranchname,TGo4EventStore::fguTXTLEN -20,"%s.", fxEvent->GetName());
00115 TBranch* go4branch= fxTree->GetBranch(topbranchname);
00116 if(go4branch)
00117 {
00118
00119 TGo4Log::Debug(" BackStore: Found existing branch %s , continue filling ",topbranchname );
00120
00121 go4branch->SetAddress(&fxEvent);
00122 fbBranchExists=kTRUE;
00123
00124 }
00125 else
00126 {
00127
00128 TBranch *topbranch=
00129 fxTree->Branch(topbranchname, fxEvent->ClassName(), &fxEvent, fiBufsize, fiSplit);
00130 TGo4Log::Debug(" BackStore: Created new branch %s ", topbranchname);
00131 fbBranchExists=kTRUE;
00132 if (fxEvent->InheritsFrom("TGo4CompositeEvent"))
00133 dynamic_cast<TGo4CompositeEvent*> (fxEvent)->makeBranch(topbranch);
00134 }
00135 }
00136 else
00137 {
00138
00139 return 1;
00140 }
00141 }
00142 else
00143 {
00144
00145 }
00146
00147 Double_t totbytes=fxTree->GetTotBytes();
00148 if(totbytes>TGo4BackStore::fgiMAXAUTOBYTES)
00149 {
00150 fxTree->Reset();
00151 TGo4Log::Debug(" BackStore: Tree %s was Reset after %f bytes ",
00152 fxTree->GetName(), totbytes);
00153 }
00154 fxTree->Fill();
00155 return 0;
00156 }
00157
00158 ClassImp(TGo4BackStore)
00159
00160
00161
00162
00163
00164