8 #include "TSystemDirectory.h"
16 std::cout <<
"Emulator already running " <<
std::endl;
20 fIsRunning =
true; fNbLoop = max_loop;
22 fTimer->SetObject(
this);
23 fTimer->Start(20, kTRUE);
37 fTimer->SetObject(
this);
52 Bool_t EmulatorControl::HandleTimer(TTimer* )
55 fEmulator->
Run(fNbLoop);
60 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)
62 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;
64 if ( !t_path.EndsWith(
"/") )
68 TString dir_name =
""; TSystemDirectory dir; dir.SetDirectory(t_path.Data());
70 TList *list = dir.GetListOfFiles();
74 while ( (entry = iter()) )
76 if ( entry->InheritsFrom(
"TSystemDirectory") )
79 TString fname = entry->GetName();
80 if ( fname.Contains( Form(
"%s%4.4d",run_name_pattern.Data(),which_run) ) ) {
81 dir_name = t_path.Data();
82 dir_name += entry->GetName();
83 if ( path_in_exp.Sizeof() ) {
84 if ( !path_in_exp.BeginsWith(
"/") )
86 dir_name += which_adf_data;
87 if ( !path_in_exp.EndsWith(
"/") )
90 result = entry->GetName();
98 std::cout <<
" **** !! **** Run # " << which_run <<
" has not been found in path " << path <<
std::endl;
102 if ( !dir_name.EndsWith(
"/") )
104 std::cout <<
" Run # " << which_run <<
" has been found in path " << path <<
" - full directory is " << dir_name <<
std::endl;
107 TSystemDirectory dir_run; dir_run.SetDirectory(dir_name); TList list_of_final_file;
109 list = dir_run.GetListOfFiles();
112 std::cout << dir_name <<
" Is Empty " <<
std::endl;
116 TIter iter_file(list);
118 while ( (entry = iter_file()) )
120 TString fname = entry->GetName();
122 Bool_t wildcard =
false;
123 if ( opt.Contains(
"*") )
125 TRegexp all(
"*",kTRUE), pattern(opt.Data(),wildcard);
127 if ( pattern.Status() != TRegexp::kOK )
130 std::cerr <<
"pattern [*] intead of " << opt.Data()<<
std::endl;
135 if ( gDebug > 0 ) std::cerr <<
"pattern " << opt.Data() <<
std::endl ;
137 if ( entry->InheritsFrom(
"TSystemFile") )
139 if ( fname.Contains( pattern ) ) {
140 list_of_final_file.Add(
new TNamed(dir_name.Data(),fname.Data()) );
141 std::cout <<
" + ADD ADF " << fname.Data() <<
" file to the list of files to be read " <<
std::endl;
145 if ( list_of_final_file.GetEntries() ) {
146 std::ofstream outputfile(tmp_rootafp_filename);
147 std::cout <<
" A new file, " << tmp_rootafp_filename <<
", suitable to configure the RootAFP producer, has been created " <<
std::endl;
148 for ( Int_t i = 0; i < list_of_final_file.GetSize(); i++ )
150 outputfile <<
"l " << list_of_final_file.At(i)->GetName() << list_of_final_file.At(i)->GetTitle() <<
std::endl;
156 RunNumber = which_run; RunDir = result;
163 TString RootAFPConf = rootafpconf; Bool_t is_default_rootafp =
false;
165 if ( RootAFPConf ==
"" ) {
166 is_default_rootafp =
true;
169 if ( gSystem->AccessPathName(rootafpconf) ) {
170 std::cout <<
" File " << rootafpconf <<
" does not exist ! - Cannot proceed " <<
std::endl;
174 gSystem->Rename(
"RootAFP.conf",
".RootAFP.conf.keep"); gSystem->CopyFile(rootafpconf,
"RootAFP.conf");
178 if ( ! this->
Init() ) {
179 if ( !is_default_rootafp )
180 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf"); std::cout <<
"Cannot Init emulator" <<
std::endl;
184 if ( !is_default_rootafp )
185 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf");
192 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)
194 TString result = BaseEmulatorChain::DoROOTAFPConf(which_run,which_experiment,which_adf_data,run_name_pattern,opt_adf_pattern,
".RootAFP.conf.tmp");
195 if ( result ==
"" ) {
198 return Init(
".RootAFP.conf.tmp");
void Save(Option_t *opt="*")
Save the spectra.
virtual Bool_t Run(UInt_t=kMaxUInt)
loop
virtual ADF::NarvalConsumer * GetBaseConsumer()
virtual Bool_t Init()
It should be overwritten !
void Run(UInt_t max_loop=kMaxUInt)
Run the emulator.
ADF::LogMessage & endl(ADF::LogMessage &log)
virtual void Print(std::ostream &out=std::cout) const
Print some informations (statistics)