9 #include "TSystemDirectory.h"
20 fBashColor->SetWarningOut();
21 std::cout <<
"Emulator already running " <<
std::endl;
22 fBashColor->ResetColor();
25 fIsRunning =
true; fNbLoop = max_loop;
27 fTimer->SetObject(
this);
28 fTimer->Start(20, kTRUE);
42 fTimer->SetObject(
this);
54 fBashColor->SetInfoOut();
56 std::cout<<
"Watchers properties:"<<
std::endl;
62 TIter iter(ListOfWatchers);
65 while( (o = iter.Next()) )
70 fBashColor->ResetColor();
76 fEmulator->GetBaseConsumer()->GetFrameIO().Print();
84 Bool_t EmulatorControl::HandleTimer(TTimer* )
87 fEmulator->Run(fNbLoop);
92 TString BaseEmulatorChain::DoROOTAFPConf(Int_t which_run,
const char *path,
const char *which_adf_data,
const char *run_pat, Option_t *opt_adf_pattern,
const char *tmp_rootafp_filename)
94 TString result =
"", t_path = path, path_in_exp = which_adf_data, opt = opt_adf_pattern, run_name_pattern=run_pat; Bool_t ok_dir =
false;
96 if ( !t_path.EndsWith(
"/") )
100 TString dir_name =
""; TSystemDirectory dir; dir.SetDirectory(t_path.Data());
102 TList *list = dir.GetListOfFiles();
106 while ( (entry = iter()) )
108 if ( entry->InheritsFrom(
"TSystemDirectory") )
111 TString fname = entry->GetName();
112 if ( fname.Contains( Form(
"%s%4.4d",run_pat,which_run) ) ) {
113 dir_name = t_path.Data();
114 dir_name += entry->GetName();
115 if ( path_in_exp.Sizeof() ) {
116 if ( !path_in_exp.BeginsWith(
"/") )
118 dir_name += which_adf_data;
119 if ( !path_in_exp.EndsWith(
"/") )
122 result = entry->GetName();
130 std::cout <<
" **** !! **** Run # " << which_run <<
" has not been found in path " << path <<
std::endl;
134 if ( !dir_name.EndsWith(
"/") )
136 std::cout <<
" Run # " << which_run <<
" has been found in path " << path <<
" - full directory is " << dir_name <<
std::endl;
139 TSystemDirectory dir_run; dir_run.SetDirectory(dir_name); TList list_of_final_file;
141 list = dir_run.GetListOfFiles();
144 std::cout << dir_name <<
" Is Empty " <<
std::endl;
148 TIter iter_file(list);
150 while ( (entry = iter_file()) )
152 TString fname = entry->GetName();
154 Bool_t wildcard =
false;
155 if ( opt.Contains(
"*") )
157 TRegexp all(
"*",kTRUE), pattern(opt.Data(),wildcard);
159 if ( pattern.Status() != TRegexp::kOK )
162 std::cerr <<
"pattern [*] intead of " << opt.Data()<<
std::endl;
167 if ( gDebug > 0 ) std::cerr <<
"pattern " << opt.Data() <<
std::endl ;
169 if ( entry->InheritsFrom(
"TSystemFile") )
171 if ( fname.Contains( pattern ) ) {
172 list_of_final_file.Add(
new TNamed(dir_name.Data(),fname.Data()) );
173 std::cout <<
" + ADD ADF " << fname.Data() <<
" file to the list of files to be read " <<
std::endl;
177 if ( list_of_final_file.GetEntries() ) {
178 std::ofstream outputfile(tmp_rootafp_filename);
179 std::cout <<
" A new file, " << tmp_rootafp_filename <<
", suitable to configure the RootAFP producer, has been created " <<
std::endl;
180 for ( Int_t i = 0; i < list_of_final_file.GetSize(); i++ )
182 outputfile <<
"l " << list_of_final_file.At(i)->GetName() << list_of_final_file.At(i)->GetTitle() <<
std::endl;
188 RunNumber = which_run; RunDir = result;
195 TString RootAFPConf = rootafpconf; Bool_t is_default_rootafp =
false;
197 if ( RootAFPConf ==
"" ) {
198 is_default_rootafp =
true;
201 if ( gSystem->AccessPathName(rootafpconf) ) {
202 std::cout <<
" File " << rootafpconf <<
" does not exist ! - Cannot proceed " <<
std::endl;
206 gSystem->Rename(
"RootAFP.conf",
".RootAFP.conf.keep"); gSystem->CopyFile(rootafpconf,
"RootAFP.conf");
210 if ( ! this->Init() ) {
211 if ( !is_default_rootafp )
212 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf"); std::cout <<
"Cannot Init emulator" <<
std::endl;
216 if ( !is_default_rootafp )
217 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf");
224 Bool_t
BaseEmulatorChain::Init(Int_t which_run,
const char *which_experiment,
const char *which_adf_data,
const char *run_name_pattern, Option_t *opt_adf_pattern)
226 TString result = BaseEmulatorChain::DoROOTAFPConf(which_run,which_experiment,which_adf_data,run_name_pattern,opt_adf_pattern,
".RootAFP.conf.tmp");
227 if ( result ==
"" ) {
230 return Init(
".RootAFP.conf.tmp");
Process a buffer, trigg and dispachs the work to sub-watchers.
void Save(Option_t *opt="*")
Save the spectra.
virtual void Print(Option_t *option="") const
virtual Bool_t Init()
It should be overwritten !
static const TList * GetListOfWatchers()
void Run(UInt_t max_loop=kMaxUInt)
Run the emulator.
virtual UInt_t Snapshot(Option_t *="*")
change kind of Watcher
ADF::LogMessage & endl(ADF::LogMessage &log)