6 #include "TSystemDirectory.h"
15 fIsRunning =
true; fNbLoop = max_loop;
17 fTimer->SetObject(
this);
18 fTimer->Start(20, kTRUE);
29 fTimer->SetObject(
this);
44 Bool_t EmulatorControl::HandleTimer(TTimer* )
47 fEmulator->
Run(fNbLoop);
52 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)
54 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;
56 if ( !t_path.EndsWith(
"/") )
60 TString dir_name =
""; TSystemDirectory dir; dir.SetDirectory(t_path.Data());
62 TList *list = dir.GetListOfFiles();
66 while ( (entry = iter()) )
68 if ( entry->InheritsFrom(
"TSystemDirectory") )
71 TString fname = entry->GetName();
72 if ( fname.Contains( Form(
"%s%4.4d",run_name_pattern.Data(),which_run) ) ) {
73 dir_name = t_path.Data();
74 dir_name += entry->GetName();
75 if ( path_in_exp.Sizeof() ) {
76 if ( !path_in_exp.BeginsWith(
"/") )
78 dir_name += which_adf_data;
79 if ( !path_in_exp.EndsWith(
"/") )
82 result = entry->GetName();
90 std::cout <<
" **** !! **** Run # " << which_run <<
" has not been found in path " << path <<
std::endl;
94 if ( !dir_name.EndsWith(
"/") )
96 std::cout <<
" Run # " << which_run <<
" has been found in path " << path <<
" - full directory is " << dir_name <<
std::endl;
99 TSystemDirectory dir_run; dir_run.SetDirectory(dir_name); TList list_of_final_file;
101 list = dir_run.GetListOfFiles();
104 std::cout << dir_name <<
" Is Empty " <<
std::endl;
108 TIter iter_file(list);
110 while ( (entry = iter_file()) )
112 TString fname = entry->GetName();
114 Bool_t wildcard =
false;
115 if ( opt.Contains(
"*") )
117 TRegexp all(
"*",kTRUE), pattern(opt.Data(),wildcard);
119 if ( pattern.Status() != TRegexp::kOK )
122 std::cerr <<
"pattern [*] intead of " << opt.Data()<<
std::endl;
127 if ( gDebug > 0 ) std::cerr <<
"pattern " << opt.Data() <<
std::endl ;
129 if ( entry->InheritsFrom(
"TSystemFile") )
131 if ( fname.Contains( pattern ) ) {
132 list_of_final_file.Add(
new TNamed(dir_name.Data(),fname.Data()) );
133 std::cout <<
" + ADD ADF " << fname.Data() <<
" file to the list of files to be read " <<
std::endl;
137 if ( list_of_final_file.GetEntries() ) {
138 std::ofstream outputfile(tmp_rootafp_filename);
139 std::cout <<
" A new file, " << tmp_rootafp_filename <<
", suitable to configure the RootAFP producer, has been created " <<
std::endl;
140 for ( Int_t i = 0; i < list_of_final_file.GetSize(); i++ )
142 outputfile <<
"l " << list_of_final_file.At(i)->GetName() << list_of_final_file.At(i)->GetTitle() <<
std::endl;
148 RunNumber = which_run; RunDir = result;
155 TString RootAFPConf = rootafpconf; Bool_t is_default_rootafp =
false;
157 if ( RootAFPConf ==
"" ) {
158 is_default_rootafp =
true;
161 if ( gSystem->AccessPathName(rootafpconf) ) {
162 std::cout <<
" File " << rootafpconf <<
" does not exist ! - Cannot proceed " <<
std::endl;
166 gSystem->Rename(
"RootAFP.conf",
".RootAFP.conf.keep"); gSystem->CopyFile(rootafpconf,
"RootAFP.conf");
170 if ( ! this->
Init() ) {
171 if ( !is_default_rootafp )
172 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf"); std::cout <<
"Cannot Init emulator" <<
std::endl;
176 if ( !is_default_rootafp )
177 gSystem->Rename(
".RootAFP.conf.keep",
"RootAFP.conf");
184 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)
186 TString result = BaseEmulatorChain::DoROOTAFPConf(which_run,which_experiment,which_adf_data,run_name_pattern,opt_adf_pattern,
".RootAFP.conf.tmp");
187 if ( result ==
"" ) {
190 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)