26 #include "TInterpreter.h"
27 #include "TApplication.h"
39 #include "TStopwatch.h"
40 #include "TTimeStamp.h"
43 #include "TGo4LockGuard.h"
75 #if ROOT_VERSION_CODE > ROOT_VERSION(5,2,0)
76 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
84 TSignalHandler(kSigInterrupt, kFALSE)
101 void InstallGo4CtrlCHandler(
bool on);
125 GO4TRACE((14,
"TGo4Analysis::Instance()",__LINE__, __FILE__));
160 fbInitIsDone(kFALSE),
167 fiAutoSaveCompression(5),
169 fbAutoSaveOverwrite(kFALSE),
170 fbNewInputFile(kFALSE),
171 fxCurrentInputFileName(),
172 fbAutoSaveFileChange(kFALSE),
175 fxDoWorkingFlag(flagInit),
176 fxInterruptHandler(0),
181 fServerObserverPass(),
182 fbMakeWithAutosave(kTRUE),
184 fbPythonBound(kFALSE),
189 GO4TRACE((15,
"TGo4Analysis::TGo4Analysis(const char*)",__LINE__, __FILE__));
199 fbInitIsDone(kFALSE),
206 fiAutoSaveCompression(5),
208 fbAutoSaveOverwrite(kFALSE),
209 fbNewInputFile(kFALSE),
210 fxCurrentInputFileName(),
211 fbAutoSaveFileChange(kFALSE),
214 fxDoWorkingFlag(flagInit),
215 fxInterruptHandler(0),
220 fServerObserverPass(),
221 fbMakeWithAutosave(kTRUE),
223 fbPythonBound(kFALSE),
228 GO4TRACE((15,
"TGo4Analysis::TGo4Analysis(const char*)",__LINE__, __FILE__));
239 Message(-1,
"!!!! Analysis Base class:\n\t User Analysis was built with wrong \t\tGo4 Buildversion %d !!!!!",
242 Message(-1,
"\t >>make clean all<<");
243 Message(-1,
"Aborting in 20 s...");
244 gSystem->Sleep(20000);
248 Message(-1,
"Welcome to Go4 Analysis Framework Release %s (build %d) !",
253 gROOT->SetBatch(kTRUE);
275 InstallGo4CtrlCHandler(
true);
280 Message(2,
"Analysis BaseClass ctor -- analysis singleton already exists !!!");
283 #if ROOT_VERSION_CODE > ROOT_VERSION(6,12,0)
284 TInterpreter* theI = gROOT->GetInterpreter();
285 theI->SetProcessLineLock(kTRUE);
287 gROOT->ProcessLineSync(
"TGo4Analysis *go4 = TGo4Analysis::Instance();");
288 gROOT->ProcessLineSync(Form(
".x %s",
TGo4Log::subGO4SYS(
"macros/anamacroinit.C").Data()));
296 InstallGo4CtrlCHandler(
false);
304 GO4TRACE((15,
"TGo4Analysis::~TGo4Analysis()",__LINE__, __FILE__));
314 gROOT->ProcessLineSync(Form(
".x %s",
TGo4Log::subGO4SYS(
"macros/anamacroclose.C").Data()));
331 if (gApplication) gApplication->Terminate();
346 GO4TRACE((14,
"TGo4Analysis::InitEventClasses()",__LINE__, __FILE__));
355 TGo4Log::Info(
"Analysis -- Initializing EventClasses done.");
367 TGo4Log::Info(
"Analysis BaseClass -- EventClasses were already initialized.");
376 GO4TRACE((11,
"TGo4Analysis::MainCycle()",__LINE__, __FILE__));
418 GO4TRACE((11,
"TGo4Analysis::UserEventFunc()",__LINE__, __FILE__));
429 GO4TRACE((11,
"TGo4Analysis::Process()",__LINE__, __FILE__));
431 #if ROOT_VERSION_CODE > ROOT_VERSION(5,2,0)
432 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
433 Bool_t unlockedcint=kFALSE;
435 gCINTMutex->UnLock();
448 gSystem->ProcessEvents();
461 TDirectory* savdir = gDirectory;
480 Message(2,
"Analysis %s TIMEOUT for eventsource %s:%s.",
487 Message(2,
"End of event source %s: name:%s - msg:%s",
508 Message(3,
"Analysis %s ERROR: %s from event source %s:\n %s",
546 Message(3,
"Analysis %s ERROR: %s from dynamic list entry %s:%s",
562 Message(3,
"Analysis %s ERROR: %s in Analysis Step %s",
588 catch(std::exception& ex)
590 Message(3,
"Analysis %s got standard exception %s",
602 #if ROOT_VERSION_CODE > ROOT_VERSION(5,2,0)
603 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
604 if(gCINTMutex && unlockedcint) {
618 GO4TRACE((11,
"TGo4Analysis::RunImplicitLoop(Int_t)",__LINE__, __FILE__));
621 if (process_event_interval>1.) process_event_interval = 1.;
626 Bool_t userate = showrate || (process_event_interval > 0.);
627 Bool_t process_events = kFALSE;
632 TTimeStamp last_update;
637 Message(1,
"Analysis loop for %d cycles is starting...", times);
639 Message(1,
"Analysis loop is starting...");
643 if ((times > 0) && (cnt >= times)) {
654 process_events = kTRUE;
656 bool need_update =
false;
658 if ((now.AsDouble() - last_update.AsDouble()) >= 1.) {
659 last_update = now; need_update =
true;
686 if (process_events) {
688 process_events = kFALSE;
689 gSystem->ProcessEvents();
800 Message(1,
"!!! Unexpected exception in %d cycle !!!", cnt);
810 Message(1,
"Analysis implicit Loop has finished after %d cycles.", cnt);
818 Message(1,
"%s appeared in %d cycle.", ex.
What(), cnt);
821 catch(std::exception& ex) {
822 Message(1,
"standard exception %s appeared in %d cycle.", ex.what(), cnt);
825 Message(1,
"!!! Unexpected exception in %d cycle !!!", cnt);
829 printf(
"\n"); fflush(stdout);
843 GO4TRACE((11,
"TGo4Analysis::RemoveDynamicEntry(const char *, const char* )",__LINE__, __FILE__));
855 GO4TRACE((11,
"TGo4Analysis::UpdateStatus(TGo4AnalysisStatus*)",__LINE__, __FILE__));
869 GO4TRACE((11,
"TGo4Analysis::SetStatus(TGo4AnalysisStatus*)",__LINE__, __FILE__));
885 GO4TRACE((11,
"TGo4Analysis::LoadStatus(const char*)",__LINE__, __FILE__));
893 TFile* statusfile = TFile::Open(fname.Data(),
"READ");
894 if(statusfile && statusfile->IsOpen()) {
898 TIter iter(statusfile->GetListOfKeys());
900 while ((key = (TKey*)iter()) != 0) {
901 if (strcmp(key->GetClassName(),
"TGo4AnalysisStatus")==0)
break;
904 if (key!=0) state =
dynamic_cast<TGo4AnalysisStatus*
>( statusfile->Get( key->GetName() ) );
909 Message(1,
"Analysis %s: Found status object %s in file %s",
910 GetName(), state->GetName(), fname.Data());
913 Message(0,
"Analysis: New analysis state is set.");
916 Message(3,
"Analysis LoadStatus: Could not find status %s in file %s",
GetName(), fname.Data());
920 Message(3,
"Analysis LoadStatus: Failed to open file %s", fname.Data());
931 GO4TRACE((11,
"TGo4Analysis::SaveStatus(const char*)",__LINE__, __FILE__));
934 memset(buffer, 0,
sizeof(buffer));
936 strncpy(buffer, filename,
sizeof(buffer)-10);
941 TFile* statusfile = TFile::Open(buffer,
"RECREATE");
942 if(statusfile && statusfile->IsOpen()) {
951 Message(-1,
"Analysis SaveStatus: Saved Analysis settings to file %s", buffer);
953 Message(3,
"Analysis SaveStatus: FAILED to create status object !!!");
957 Message(3,
"Analysis SaveStatus: Failed to open file %s ",
966 GO4TRACE((11,
"TGo4Analysis::CreateStatus()",__LINE__, __FILE__));
967 TDirectory* filsav=gDirectory;
977 GO4TRACE((11,
"TGo4Analysis::CreateWebStatus()",__LINE__, __FILE__));
978 TDirectory* filsav=gDirectory;
999 GO4TRACE((11,
"TGo4Analysis::CreateSingleEventTree(TGo4EventElement*)",__LINE__, __FILE__));
1006 GO4TRACE((11,
"TGo4Analysis::CreateSingleEventTree(const char*, Bool_t)",__LINE__, __FILE__));
1018 GO4TRACE((14,
"TGo4Analysis::CloseAnalysis()",__LINE__, __FILE__));
1031 GO4TRACE((11,
"TGo4Analysis:PreLoop()",__LINE__, __FILE__));
1048 GO4TRACE((11,
"TGo4Analysis::PostLoop()",__LINE__, __FILE__));
1073 GO4TRACE((11,
"TGo4Analysis::UserPreLoop()",__LINE__, __FILE__));
1075 Message(0,
"Analysis BaseClass -- executing default User Preloop");
1081 GO4TRACE((11,
"TGo4Analysis::UserPostLoop()",__LINE__, __FILE__));
1083 Message(0,
"Analysis BaseClass -- executing default User Postloop");
1092 if(filename) buffer = filename;
1109 GO4TRACE((12,
"TGo4Analysis::LockAutoSave()",__LINE__, __FILE__));
1118 GO4TRACE((12,
"TGo4Analysis::UnLockAutoSave()",__LINE__, __FILE__));
1128 GO4TRACE((12,
"TGo4Analysis::AutoSave()",__LINE__, __FILE__));
1132 Message(0,
"Analysis -- AutoSaving....");
1138 Message(0,
"Analysis -- AutoSave done.");
1185 GO4TRACE((11,
"TGo4Analysis::UpdateNamesList()",__LINE__, __FILE__));
1191 Message(0,
"Analysis BaseClass -- Nameslist updated.");
1228 va_start(args, text);
1256 Message(2,
"Could not send object %s to GUI in batch mode.", ob->GetName());
1291 #if ROOT_VERSION_CODE > ROOT_VERSION(5,2,0)
1292 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
1293 Bool_t unlockedcint=kFALSE;
1296 gCINTMutex->UnLock();
1308 Bool_t sysret = gSystem->ProcessEvents();
1317 #if ROOT_VERSION_CODE > ROOT_VERSION(5,2,0)
1318 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
1319 if(gCINTMutex && unlockedcint)
1330 Message(1,
"Start object server not yet enabled.");
1333 Message(2,
"Could not start object server in batch mode.");
1341 Message(1,
"Stop object server not yet enabled.");
1343 Message(2,
"Could not stop object server in batch mode.");
1353 TGo4Log::Message(1,
"Analysis server is initiating shutdown after ctrl-c, please wait!!\n");
1366 Message(1,
"Showing Output Event %s of step %s",sevtree->GetName(),stepname);
1368 Message(1,
"Showing Input Event %s of step %s",sevtree->GetName(),stepname);
1370 std::cout << std::endl;
1380 const char* hevx,
const char* hmemx,
1381 const char* hevy,
const char* hmemy,
1382 const char* hevz,
const char* hmemz,
1383 const char* condition,
1384 const char* cevx,
const char* cmemx,
1385 const char* cevy,
const char* cmemy)
1388 histo, hevx, hmemx, hevy, hmemy, hevz, hmemz,
1389 condition, cevx, cmemx, cevy, cmemy);
1795 if ((fullname==0) || (strlen(fullname)==0))
return kFALSE;
1796 const char* separ = strrchr(fullname,
'/');
1798 objectname = separ + 1;
1799 foldername.Append(fullname, separ - fullname);
1801 objectname = fullname;
1809 Int_t nbinsx, Double_t xlow, Double_t xup,
1810 const char* xtitle,
const char* ytitle)
1813 TString foldername, histoname;
1815 TGo4Log::Error(
"Histogram name not specified, can be a hard error");
1826 const char* sclass =
"TH1I";
1828 case 'I':
case 'i': itype = 0; sclass =
"TH1I";
break;
1829 case 'F':
case 'f': itype = 1; sclass =
"TH1F";
break;
1830 case 'D':
case 'd': itype = 2; sclass =
"TH1D";
break;
1831 case 'S':
case 's': itype = 3; sclass =
"TH1S";
break;
1832 case 'C':
case 'c': itype = 4; sclass =
"TH1C";
break;
1833 default:
TGo4Log::Error(
"There is no histogram type: %c, use I instead", type);
break;
1840 if (title) oldh->SetTitle(title);
1841 if (xtitle) oldh->GetXaxis()->SetTitle(xtitle);
1842 if (ytitle) oldh->GetYaxis()->SetTitle(ytitle);
1847 TGo4Log::Info(
"There is histogram %s with type %s other than specified %s, create new and reuse content",
1848 fullname, oldh->ClassName(), sclass);
1854 oldh->SetName(
"___");
1860 case 0: newh =
new TH1I(histoname, title, nbinsx, xlow, xup);
break;
1861 case 1: newh =
new TH1F(histoname, title, nbinsx, xlow, xup);
break;
1862 case 2: newh =
new TH1D(histoname, title, nbinsx, xlow, xup);
break;
1863 case 3: newh =
new TH1S(histoname, title, nbinsx, xlow, xup);
break;
1864 case 4: newh =
new TH1C(histoname, title, nbinsx, xlow, xup);
break;
1867 newh->SetTitle(title);
1869 if (xtitle) newh->GetXaxis()->SetTitle(xtitle);
1870 if (ytitle) newh->GetYaxis()->SetTitle(ytitle);
1874 delete oldh; oldh = 0;
1877 if (foldername.Length() > 0)
1888 Int_t nbinsx, Double_t xlow, Double_t xup,
1889 Int_t nbinsy, Double_t ylow, Double_t yup,
1890 const char* xtitle,
const char* ytitle,
const char* ztitle)
1893 TString foldername, histoname;
1896 TGo4Log::Error(
"Histogram name not specified, can be a hard error");
1909 const char* sclass =
"TH2I";
1911 case 'I':
case 'i': itype = 0; sclass =
"TH2I";
break;
1912 case 'F':
case 'f': itype = 1; sclass =
"TH2F";
break;
1913 case 'D':
case 'd': itype = 2; sclass =
"TH2D";
break;
1914 case 'S':
case 's': itype = 3; sclass =
"TH2S";
break;
1915 case 'C':
case 'c': itype = 4; sclass =
"TH2C";
break;
1916 default:
TGo4Log::Error(
"There is no histogram type: %c, use I instead", type);
break;
1923 if (title) oldh->SetTitle(title);
1924 if (xtitle) oldh->GetXaxis()->SetTitle(xtitle);
1925 if (ytitle) oldh->GetYaxis()->SetTitle(ytitle);
1930 TGo4Log::Info(
"There is histogram %s with type %s other than specified %s, create new and reuse content",
1931 fullname, oldh->ClassName(), sclass);
1937 oldh->SetName(
"___");
1943 case 0: newh =
new TH2I(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
1944 case 1: newh =
new TH2F(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
1945 case 2: newh =
new TH2D(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
1946 case 3: newh =
new TH2S(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
1947 case 4: newh =
new TH2C(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
1950 newh->SetTitle(title);
1952 if (xtitle) newh->GetXaxis()->SetTitle(xtitle);
1953 if (ytitle) newh->GetYaxis()->SetTitle(ytitle);
1954 if (ztitle) newh->GetZaxis()->SetTitle(ztitle);
1962 if (foldername.Length() > 0)
1973 Double_t xmin, Double_t xmax,
1974 const char* HistoName)
1977 TString foldername, condname;
1980 TGo4Log::Error(
"Condition name not specified, can be a hard error");
1998 if (foldername.Length() > 0)
2009 Double_t xmin, Double_t xmax,
2010 Double_t ymin, Double_t ymax,
2011 const char* HistoName)
2014 TString foldername, condname;
2017 TGo4Log::Error(
"Condition name not specified, can be a hard error");
2031 wcond->
SetValues(xmin, xmax, ymin, ymax);
2035 if (foldername.Length() > 0)
2047 Double_t (*points) [2],
2048 const char* HistoName,
2052 TString foldername, condname;
2055 TGo4Log::Error(
"Condition name not specified, can be a hard error");
2069 TArrayD fullx(npoints+1), fully(npoints+1);
2071 for (
int i=0;i<npoints;i++) {
2072 fullx[i] = points[i][0];
2073 fully[i] = points[i][1];
2077 if ((fullx[0]!=fullx[npoints-1]) || (fully[0]!=fully[npoints-1])) {
2078 fullx[npoints] = fullx[0];
2079 fully[npoints] = fully[0];
2083 TCutG mycat(
"initialcut", npoints, fullx.GetArray(), fully.GetArray());
2089 pcond->SetValues(&mycat);
2092 pcond->SetHistogram(HistoName);
2094 if (foldername.Length() > 0)
2107 Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta,
2108 const char* HistoName)
2111 TString foldername, condname;
2114 TGo4Log::Error(
"Condition name not specified, can be a hard error");
2129 econd->
SetEllipse(cx,cy,a1,a2,theta,npoints);
2132 if (foldername.Length() > 0)
2144 Int_t npoints, Double_t cx, Double_t cy, Double_t r,
2145 const char* HistoName)
2153 const char* HistoName)
2164 Double_t (*points) [2],
2165 const char* HistoName)
2175 TString foldername, condname;
2178 TGo4Log::Error(
"Condition name not specified, can be a hard error");
2196 if (foldername.Length() > 0)
2227 TString foldername, graphname;
2229 TGo4Log::Error(
"TGraph name not specified, can be a hard error");
2233 TGraph* graph =
dynamic_cast<TGraph*
> (
GetObject( fullname ) );
2234 if(graph)
return graph;
2236 graph =
new TGraph ();
2238 graph =
new TGraph (points, xvalues, yvalues);
2239 graph->SetName(graphname.Data());
2240 graph->SetTitle(title);
2242 if (foldername.Length() > 0)
2254 TString foldername, graphname;
2257 TGo4Log::Error(
"TGraph name not specified, can be a hard error");
2261 TGraph* graph =
dynamic_cast<TGraph*
>(
GetObject(fullname));
2264 graph =
new TGraph(
function);
2265 graph->SetName(graphname.Data());
2266 graph->SetTitle(title);
2267 if (foldername.Length() > 0)
2278 TString foldername, graphname;
2281 TGo4Log::Error(
"TGraph name not specified, can be a hard error");
2288 graph->SetName(graphname.Data());
2289 graph->SetTitle(title);
2290 if (foldername.Length() > 0)
2302 const char* classname,
2306 TString foldername, paramname;
2308 if ((fullname==0) || (strlen(fullname)==0)) {
2309 TGo4Log::Error(
"Parameter name not specified, can be a hard error");
2312 const char* separ = strrchr(fullname,
'/');
2314 paramname = separ + 1;
2315 foldername.Append(fullname, separ - fullname);
2317 paramname = fullname;
2322 if (!param->InheritsFrom(classname)) {
2323 TGo4Log::Info(
"There is parameter %s with type %s other than specified %s, rebuild",
2324 fullname, param->ClassName(), classname);
2331 paramname = TString(
"\"") + paramname + TString(
"\"");
2334 if ((newcmd!=0) && (strstr(newcmd,
"new ")==newcmd))
2335 cmd = TString::Format(newcmd, paramname.Data());
2337 cmd = TString::Format(
"new %s(%s)", classname, paramname.Data());
2339 Long_t res = gROOT->ProcessLineFast(cmd.Data());
2342 TGo4Log::Error(
"Cannot create parameter of class %s", classname);
2348 if (foldername.Length() > 0)
2356 if ((newcmd!=0) && (strstr(newcmd,
"set_")==newcmd)) {
2378 if ((macro_name==0) || (strlen(macro_name)==0))
return -1;
2381 TString file_name(macro_name);
2382 Ssiz_t pos = file_name.First(
'(');
2383 if (pos > 0) file_name.Resize(pos);
2384 bool has_plus =
false;
2385 pos = file_name.First(
'+');
2386 if (pos > 0) { file_name.Resize(pos); has_plus =
true; }
2387 while ((file_name.Length() > 0) && (file_name[file_name.Length()-1] ==
' '))
2388 file_name.Resize(file_name.Length()-1);
2389 while ((file_name.Length() > 0) && (file_name[0] ==
' '))
2390 file_name.Remove(0, 1);
2392 if (gSystem->AccessPathName(file_name.Data())) {
2400 TString exec =
".x ";
2401 exec.Append(macro_name);
2404 #if ROOT_VERSION_CODE < ROOT_VERSION(6,22,0)
2405 res = gROOT->ProcessLineSync(exec.Data(), &error);
2406 if (error) res = -1;
2409 std::ifstream t(file_name.Data());
2410 std::string content = std::string(std::istreambuf_iterator<char>(t), {});
2411 if (content.empty()) {
2416 TString func_name = file_name;
2417 pos = func_name.Last(
'/');
2418 if (pos != kNPOS) func_name.Remove(0, pos+1);
2419 pos = func_name.Index(
".C");
2420 if (pos == kNPOS) pos = func_name.Index(
".cxx");
2421 if (pos != kNPOS) func_name.Resize(pos);
2423 bool fall_back =
false;
2424 if (has_plus) fall_back =
true;
2425 if (func_name.Length() == 0) fall_back =
true;
2427 std::string search = func_name.Data(); search +=
"(";
2428 auto name_pos = content.find(search);
2429 if (name_pos == std::string::npos) fall_back =
true;
2432 res = gROOT->ProcessLineSync(exec.Data(), &error);
2433 return error ? -1 : res;
2436 static std::vector<std::string> script_names;
2437 static std::vector<std::string> script_contents;
2438 static std::vector<std::string> script_func;
2439 static int findx = 1;
2443 for (
unsigned n = 0; n < script_names.size(); n++)
2444 if (script_names[n] == file_name.Data()) {
2450 script_names.push_back(file_name.Data());
2451 script_contents.push_back(content);
2452 script_func.push_back(func_name.Data());
2453 indx = script_names.size() - 1;
2455 if (!gInterpreter->LoadText(content.c_str())) {
2456 TGo4Log::Error(
"Cannot parse code of %s script", file_name.Data());
2459 }
else if (script_contents[indx] != content) {
2461 std::string new_name = func_name.Data();
2462 new_name += std::to_string(findx++);
2463 script_contents[indx] = content;
2464 script_func[indx] = new_name;
2466 content.erase(name_pos, func_name.Length());
2467 content.insert(name_pos, new_name);
2469 if (!gInterpreter->LoadText(content.c_str())) {
2470 TGo4Log::Error(
"Cannot parse modified code of %s script", file_name.Data());
2474 func_name = new_name.c_str();
2478 func_name = script_func[indx].c_str();
2481 TGo4Log::Error(
"Execute function %s from script %s", func_name.Data(), file_name.Data());
2484 func_name.Append(
"()");
2485 res = gROOT->ProcessLineSync(func_name.Data(), &error);
2486 if (error) res = -1;
2495 if ((macro_name==0) || (strlen(macro_name)==0))
return -1;
2496 TString comstring=macro_name;
2507 comstring = command;
2508 comstring = comstring.Strip(TString::kBoth);
2510 comstring = comstring.Strip(TString::kLeading);
2512 const TString PY_EXT =
".py";
2513 int imin = comstring.Index(PY_EXT +
" ");
2514 int imax = comstring.Length();
2518 imin += PY_EXT.Length();
2520 int ilen = imax - imin;
2521 TString scrstring = comstring(0, imin);
2522 TString argstring = comstring(imin, ilen);
2524 comstring =
"TPython::Exec(\"import sys; sys.argv = [\'" + scrstring +
"\'] + \'" + argstring +
"\'.split()\");";
2525 comstring +=
"TPython::LoadMacro(\"" + scrstring +
"\");";
2530 comstring.Prepend(
"TPython::LoadMacro(\"" + go4sys + pyinit +
"\");");
2531 comstring.Prepend(
"TPython::Bind(go4, \"go4\");" );
2536 const char* cursor = command;
2539 Ssiz_t len=strlen(cursor);
2540 at = strstr(cursor,
"@");
2543 len=(Ssiz_t) (at-cursor);
2544 comstring.Append(cursor,len);
2545 comstring.Append(
"TGo4Analysis::Instance()->");
2549 comstring.Append(cursor);
2566 Long_t rev=gROOT->ProcessLineSync(comstring, errcode);
2603 Message(2, TString::Format(
"Analysis %s was not initialized! Please SUBMIT settings first.",
GetName()));
2612 #include "windows.h"
2617 BOOL WINAPI Go4ConsoleSigHandler(DWORD sig)
2626 case CTRL_BREAK_EVENT:
2627 case CTRL_LOGOFF_EVENT:
2628 case CTRL_SHUTDOWN_EVENT:
2629 case CTRL_CLOSE_EVENT:
2631 printf(
" non CTRL-C signal - ignore\n");
2636 void InstallGo4CtrlCHandler(
bool on)
2638 SetConsoleCtrlHandler(Go4ConsoleSigHandler, on);
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
Bool_t SetParameter(const char *name, TGo4Parameter *par, TFolder *parent=0)
Int_t Store(const char *name, TGo4Parameter *obj)
void SetAutoFileName(const char *name)
void SetOutputEvent(TGo4EventElement *event)
void SetRunning(Bool_t on=kTRUE)
const char * GetErrMess() const
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=0, const char *ytitle=0)
Graphs that renew themselves iteratively to monitor a value.
Bool_t SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter=kTRUE, TFolder *parent=0)
void PrintParameters(const char *expression=0)
static const Int_t fgiMACROSTARTPOLL
TGo4ListCond * MakeListCond(const char *fullname, const Int_t num, const Int_t *values, const char *HistoName=0)
TGo4Analysis(const char *name=0)
static Bool_t IsServerMode()
static const char * fgcPYINIT
Bool_t NewStepProcessor(const char *name, TGo4EventProcessorParameter *par)
void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0)
Bool_t NewStepSource(const char *name, TGo4EventSourceParameter *par)
Bool_t RemoveEventProcessor(TGo4EventProcessor *pro)
Bool_t NewStepProcessor(const char *name, TGo4EventProcessorParameter *par)
virtual void StatusMessage(int level, Bool_t printout, const TString &)
void UpdateStatus(TGo4AnalysisStatus *state)
Bool_t RemoveEventStructure(TGo4EventElement *ev)
TGo4ShapedCond * MakeFreeShapeCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=0)
Bool_t SetStepStorage(const char *name, Bool_t on)
Bool_t LoadStatus(const char *filename=0)
Bool_t AddCanvas(TCanvas *can, const char *subfolder=0)
void SetDateTime(const char *str)
Int_t GetAutoSaveCompression() const
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
TGo4ShapedCond * MakeCircleCond(const char *fullname, Int_t npoints, Double_t cx, Double_t cy, Double_t r, const char *HistoName=0)
virtual Int_t UserPreLoop()
TGo4AnalysisClient * fxAnalysisSlave
void SetStatus(TGo4AnalysisStatus *state)
void SetStepChecking(Bool_t on=kTRUE)
void SetAnalysisName(const char *name)
Bool_t AddObject(TNamed *anything, const char *subfolder=0, Bool_t replace=kTRUE)
void SetOutputEvent(TGo4EventElement *event)
void DefineServerPasswords(const char *admin, const char *controller, const char *observer)
Bool_t RemoveParameter(const char *name)
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
void UpdateStatus(TGo4AnalysisStatus *state)
const char * GetStatusMessage() const
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
static void SetCommandList(TGo4CommandProtoList *list)
virtual void UserPreLoop()
Bool_t SetParameter(const char *name, TGo4Parameter *par)
static void UnRegister(TGo4CommandReceiver *p)
TGo4ShapedCond * MakeEllipseCond(const char *fullname, Int_t npoints, Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, const char *HistoName=0)
static Bool_t CheckVersion(Int_t version)
virtual void CloseAnalysis()
Int_t StoreFolder(const char *stepname, TFolder *folder)
void SetCurrentSource(const char *str)
Bool_t LoadObjects(const char *filename=0)
const char * GetErrMess() const
TGo4TreeStructure * CreateTreeStructure(const char *treename)
void SetObserverPassword(const char *passwd)
Int_t StoreParameter(const char *name, TGo4Parameter *par)
TGo4InterruptHandler * fxInterruptHandler
Bool_t RemovePicture(const char *name)
virtual const char * What()
void SetAutoSaveOn(Bool_t on=kTRUE)
Bool_t AddDynamicHistogram(const char *name, const char *histo, const char *hevx, const char *hmemx, const char *hevy=0, const char *hmemy=0, const char *hevz=0, const char *hmemz=0, const char *condition=0, const char *cevx=0, const char *cmemx=0, const char *cevy=0, const char *cmemy=0)
Int_t ProcessAnalysisSteps()
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
virtual void SetValues(const Int_t num, const Int_t *values)
static void CloseLogfile()
void SetControllerPassword(const char *passwd)
void SetSortedOrder(Bool_t on=kTRUE)
static Bool_t IsOutputEnabled()
Bool_t ClearObjects(const char *name)
Bool_t EvaluateFolderpath(const char *fullname, TString &object, TString &folder)
Bool_t DeleteObjects(const char *name)
void SetSortedOrder(Bool_t on=kTRUE)
Bool_t RemoveObject(const char *name, Bool_t del=kTRUE)
static const char * fgcDEFAULTSTATUSFILENAME
TGo4Picture * GetPicture(const char *name)
Int_t IsErrorStopEnabled()
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
void SetStepChecking(Bool_t on=kTRUE)
static Bool_t IsClientMode()
Bool_t AddCanvas(TCanvas *can, const char *subfolder=0)
TGo4AnalysisObjectNames * fxObjectNames
Int_t StoreFitter(const char *name, TGo4Fitter *fit)
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=0)
Bool_t RemoveEventSource(TGo4EventSource *source)
Bool_t RemoveDynamicEntry(const char *entryname)
TH1 * GetHistogram(const char *name)
void ShowEvent(const char *stepname, Bool_t isoutput=kTRUE)
friend class TGo4AnalysisWebStatus
void SetUpdateInterval(double v)
TString fxDefaultTestFileName
Bool_t SetParameterStatus(const char *name, TGo4ParameterStatus *par)
static void Register(const char *name, TGo4CommandReceiver *p)
virtual void RatemeterUpdate(TGo4Ratemeter *)
Bool_t RemoveAnalysisCondition(const char *name)
TGo4AnalysisObjectManager * fxObjectManager
virtual Int_t UserEventFunc()
Bool_t SetFirstStep(const char *name)
static void OutputEnable(Bool_t on=kTRUE)
Int_t GetPriority() const
TH2 * MakeTH2(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char *xtitle=0, const char *ytitle=0, const char *ztitle=0)
Bool_t FindObjectPathName(TObject *obj, TString &pathname, TFolder *fold=0)
TGo4AnalysisStepManager * fxStepManager
void PrintHistograms(const char *expression=0)
void SetDynListInterval(Int_t val)
void SetRunning(Bool_t on=kTRUE)
TGo4AnalysisObjectNames * CreateNamesList()
void PrintConditions(const char *expression=0)
virtual void ResetCounts()
TGo4EventElement * GetOutputEvent()
TTree * CreateSingleEventTree(const char *name, Bool_t isoutput=kTRUE)
Bool_t fbMakeWithAutosave
TGo4EventElement * GetEventStructure(const char *name)
const char * GetEntryClass() const
Bool_t RemoveEventStructure(TGo4EventElement *ev)
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=0)
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
Bool_t RemoveEventStore(TGo4EventStore *store)
TGo4AnalysisStep * GetAnalysisStep(const char *name)
static const char * fgcTOPDYNAMICLIST
virtual void UserPostLoop()
void SetAdministratorPassword(const char *passwd)
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
Bool_t AddEventProcessor(TGo4EventProcessor *pro)
Long_t ExecutePython(const char *script_name, Int_t *errcode=0)
Bool_t AddEventSource(TGo4EventSource *source)
static const char fgcPYPROMPT
void SetNewInputFile(Bool_t on=kTRUE)
Bool_t IsSortedOrder() const
void ProcessCrtlCSignal()
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
Bool_t SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter=kTRUE)
Bool_t ResetBackStores(Bool_t clearflag=kFALSE)
Bool_t SetStepStorage(const char *name, Bool_t on)
static const char * fgcDEFAULTFILENAME
const char * GetAutoFileName() const
TGo4Parameter * MakeParameter(const char *fullname, const char *classname, const char *cmd=0)
Int_t GetNumberOfAnalysisSteps()
void PrintHistograms(const char *expression=0)
const char * GetStepName()
TGo4EventElement * GetEventStructure(const char *name)
static const char * fgcDEFAULTFILESUF
Bool_t RemoveEventSource(TGo4EventSource *source)
TH1 * GetHistogram(const char *name)
Int_t RunImplicitLoop(Int_t times, Bool_t showrate=kFALSE, Double_t process_event_interval=-1., Bool_t iswebserver=kFALSE)
TGo4EventElement * GetInputEvent(const char *stepname)
Int_t IsAutoSaveOverwrite() const
TCanvas * GetCanvas(const char *name)
TStopwatch * fxAutoSaveClock
void SetAutoSave(Bool_t on=kTRUE)
Bool_t AddObject(TNamed *anything, const char *subfolder=0, Bool_t replace=kTRUE)
Bool_t RemoveEventStore(TGo4EventStore *store)
Int_t GetPriority() const
void SendObjectToGUI(TObject *ob)
TString fServerObserverPass
static TGo4CommandInvoker * Instance()
Bool_t RemoveCanvas(const char *name)
Bool_t AddEventStructure(TGo4EventElement *ev)
Bool_t AddEventStore(TGo4EventStore *store)
void Message(Int_t prio, const char *text,...)
Bool_t AddEventSource(TGo4EventSource *source)
const char * GetSourceName() const
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=0)
void OpenAutoSaveFile(bool for_writing=false)
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
TFolder * FindSubFolder(TFolder *parent, const char *subfolder, Bool_t create=kTRUE)
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
Int_t StoreCondition(const char *name, TGo4Condition *con)
Bool_t AddEventProcessor(TGo4EventProcessor *pro)
Bool_t RemoveTree(TTree *tree, const char *stepname=0)
TGo4Parameter * GetParameter(const char *name, const char *parameter_class=0)
void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints=0)
Bool_t ResetBackStores(Bool_t clearflag=kFALSE)
Int_t IsAutoSaveOn() const
Long_t ExecuteScript(const char *script_name)
void SetHistogram(const char *name)
void SendObject(TObject *obj, const char *receiver=0)
TTree * GetTree(const char *name)
virtual Bool_t InitEventClasses()
Bool_t NewStepStore(const char *name, TGo4EventStoreParameter *par)
static Bool_t IsBatchMode()
Bool_t DeleteObjects(const char *name)
Bool_t RemoveCanvas(const char *name)
Bool_t AddTree(TTree *tree, const char *subfolder=0)
Bool_t RemoveEventProcessor(TGo4EventProcessor *pro)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
static const char * Message(Int_t prio, const char *text,...)
TGo4EventElement * GetInputEvent(const char *stepname)
TGo4Parameter * GetParameter(const char *name, const char *parameter_class=0)
const char * GetEntryName() const
virtual Int_t UserPostLoop()
void StartObjectServer(const char *basename, const char *passwd)
TGo4AnalysisObjectNames * CreateNamesList()
TGo4EventElement * GetOutputEvent(const char *stepname)
TObject * NextMatchingObject(const char *expr, const char *folder, Bool_t reset)
Bool_t ClearObjects(const char *name)
TGo4Picture * GetPicture(const char *name)
#define __GO4BUILDVERSION__
Int_t fiAutoSaveCompression
virtual void SetValues(Double_t low1, Double_t up1)
virtual const char * GetName() const
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=0)
const char * GetStatusMessage() const
static TGo4Version * Instance()
static TGo4Analysis * fxInstance
Bool_t AddTree(TTree *tree, const char *subfolder=0)
Int_t GetDynListInterval() const
TGo4AnalysisObjectManager * ObjectManager() const
Bool_t RemoveTree(TTree *tree, const char *stepname=0)
virtual void ProcessSnifferEvents()
TGo4ShapedCond * MakeBoxCond(const char *fullname, Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta, const char *HistoName=0)
Bool_t RemoveAnalysisCondition(const char *name)
TGo4AnalysisSniffer * fSniffer
TGo4ObjectStatus * CreateObjectStatus(const char *name, const char *folder=0)
Bool_t Update(Int_t increment=1)
TGo4RollingGraph * MakeRollingGraph(const char *fullname, const char *title, Int_t points=0, Int_t average=1)
virtual Bool_t InitEventClasses()
virtual void Print(Option_t *opt="") const
Bool_t NewStepStore(const char *name, TGo4EventStoreParameter *par)
TFolder * GetObjectFolder()
static void PrintRate(ULong64_t cnt, double rate)
TObject * NextMatchingObject(const char *expr=0, const char *folder=0, Bool_t reset=kFALSE)
static Int_t fiRunningMode
TGo4AnalysisStep * GetAnalysisStep(const char *name)
Bool_t RemoveObject(const char *name, Bool_t del=kTRUE)
static Int_t GetIgnoreLevel()
Bool_t RemoveHistogram(const char *name, Bool_t del=kTRUE)
void PrintParameters(const char *expression=0)
Int_t IsErrorStopEnabled()
void SetAutoSaveOverwrite(Bool_t over=kTRUE)
Bool_t IsAutoSaveFileName() const
TGo4ObjectStatus * CreateObjectStatus(const char *name, const char *folder=0)
Bool_t IsSortedOrder() const
Long_t ExecuteLine(const char *command, Int_t *errcode=0)
void SetAutoSaveFile(const char *filename=0, Bool_t overwrite=kFALSE, Int_t compression=5)
TGo4AnalysisStep * GetAnalysisStepNum(Int_t number)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
void ProcessDynamicList()
Bool_t ProtectObjects(const char *name, const Option_t *flags)
static TString subGO4SYS(const char *subdir)
Bool_t ProtectObjects(const char *name, const Option_t *flags)
Bool_t SetPicture(const char *name, TGo4Picture *pic)
Bool_t SaveStatus(const char *filename=0)
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
void SetConfigFileName(const char *name)
Bool_t SetPicture(const char *name, TGo4Picture *pic, TFolder *parent=0)
TGo4AnalysisStep * GetAnalysisStepNum(Int_t number)
TNamed * GetObject(const char *name, const char *folder=0)
Bool_t RemoveDynamicEntry(const char *entryname, const char *listname=0)
ULong64_t GetCurrentCount() const
Bool_t RemoveParameter(const char *name)
void UpdateStatusBuffer()
Bool_t SetParameterStatus(const char *name, TGo4ParameterStatus *par, TFolder *parent=0)
Bool_t fbAutoSaveOverwrite
Bool_t TestBufferUpdateConditions()
void SetAutoSaveInterval(Int_t i)
Bool_t AddDynamicHistogram(const char *name, const char *histo, const char *hevx, const char *hmemx, const char *hevy=0, const char *hmemy=0, const char *hevz=0, const char *hmemz=0, const char *condition=0, const char *cevx=0, const char *cmemx=0, const char *cevy=0, const char *cmemy=0)
TNamed * GetObject(const char *name, const char *folder=0)
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
TGo4AnalysisStatus * CreateStatus()
void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0)
Bool_t AddEventStructure(TGo4EventElement *ev)
void UpdateRate(Int_t counts=1)
static const char * GO4SYS()
Bool_t RemoveHistogram(const char *name, Bool_t del=kTRUE)
Bool_t LoadObjects(TFile *statusfile)
Int_t ProcessAnalysisSteps()
void SaveObjects(TFile *file)
enum TGo4Analysis::@0 fxDoWorkingFlag
Bool_t AddEventStore(TGo4EventStore *store)
const char * GetSourceClass() const
void SetDynListInterval(Int_t val)
static const Int_t fgiDYNLISTINTERVAL
static void SetRunningMode(int mode)
static TGo4Analysis * Instance()
TGo4EventElement * fxSampleEvent
static const Int_t fgiAUTOSAVECOUNTS
TTree * GetTree(const char *name)
Bool_t SetFirstStep(const char *name)
const char * GetMessage() const
const char * GetEventSourceName()
Int_t GetDynListInterval()
TGo4EventProcessor * GetEventProcessor() const
TGo4AnalysisWebStatus * CreateWebStatus()
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=0, Bool_t shapedcond=kFALSE)
static void Error(const char *text,...)
Bool_t NewStepSource(const char *name, TGo4EventSourceParameter *par)
void PrintConditions(const char *expression=0)
void SetAutoSaveCompression(Int_t i=5)
TGo4TreeStructure * CreateTreeStructure(TTree *thetree)
TGraph * MakeGraph(const char *fullname, const char *title, Int_t points=0, Double_t *xvalues=0, Double_t *yvalues=0)
static void Info(const char *text,...)
TFolder * GetObjectFolder()
Bool_t SetLastStep(const char *name)
Int_t GetAutoSaveInterval() const
Bool_t RemovePicture(const char *name)
TCanvas * GetCanvas(const char *name)
Bool_t SetLastStep(const char *name)
void SetAutoSaveInterval(Int_t interval=0)
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=0)
static void Debug(const char *text,...)
void SetStatus(TGo4AnalysisStatus *state)