//#define USE_ROOT_HTTP 1 #include "hades.h" #include "hruntimedb.h" #include "honlineclientservercom.h" #include "honlinemonhist.h" #include "honlinemonstack.h" #include "TApplication.h" #include "TString.h" #include "TList.h" #ifdef USE_ROOT_HTTP #include "THttpServer.h" #endif #include "helpers.h" #include "createHades.C" #include "Mdc.C" #include "Rich.C" #include "Tof.C" #include "Emc.C" #include "Wall.C" //#include "Sts.C" //#include "FRpc.C" //#include "PionTracker.C" #include "Hodo.C" //#include "InnerTof.C" #include "Rpc.C" #include "Start.C" #include "Physics.C" //#include "ForwardPhysics.C" #include #include #include #include #include #include using namespace std; map < TString , HOnlineMonHistAddon* > currentMap; void usage() { cout << "usage: OnlineServer servername serverhostname connectorport parameterfile"< setDebug(kFALSE); clientservercom ->setEvtCounterInterval(-1); // do not print from HOnlineClientServerCom, use print from gHades gHades->makeCounter(evtCtInterval); gHades->setQuietMode(4); // 0:all prints, 1: Eventwise, 2: Summary at end, 3: Event+Summary, 4: Online eventwise (eventLoop called with one event only) if (!clientservercom->init()) { cout<<"Error: Hades Monitoring Server could not be initialised."<eventLoop(2); //gHades->getRuntimeDb()->saveOutput(); cout<<"Hades Monitoring Server: ADD Histograms"< fillfunctions; fillfunctions.push_back(&fillHistMdc); fillfunctions.push_back(&fillHistRich); fillfunctions.push_back(&fillHistEmc); fillfunctions.push_back(&fillHistRpc); fillfunctions.push_back(&fillHistTof); fillfunctions.push_back(&fillHistWall); // fillfunctions.push_back(&fillHistPionTracker); // fillfunctions.push_back(&fillHistSts); // fillfunctions.push_back(&fillHistFRpc); // fillfunctions.push_back(&fillHistFPhysics); fillfunctions.push_back(&fillHistHodo); // fillfunctions.push_back(&fillHistInnerTof); fillfunctions.push_back(&fillHistStart); fillfunctions.push_back(&fillHistPhysics); #ifdef USE_ROOT_HTTP // JAM2020 - export all histograms to webserver - may disable this to test lock? cout<<"Hades Monitoring Server: create HTTP server"<Unregister(gROOT); //suppress showing open calib file ? does not work TIterator* it = histpool.MakeIterator(); HOnlineMonHistAddon* addon; while( ((addon = (HOnlineMonHistAddon*) it->Next()) != 0) ) { // JAM20202- poor mans solution to divide into subsystems. the addon has no property for that. TString component="general"; TString path; if(strstr(addon->GetName(),"Mdc")) { component="MDC"; } else if(strstr(addon->GetName(),"Rich")) { component="RICH"; } else if(strstr(addon->GetName(),"Emc")) { component="EMC"; } else if(strstr(addon->GetName(),"Start")) { component="START"; } else if(strstr(addon->GetName(),"Rpc")) { component="RPC"; } else if(strstr(addon->GetName(),"InnerTof")) { component="INNERTOF"; } else if(strstr(addon->GetName(),"Tof")) { component="TOF"; } else if(strstr(addon->GetName(),"Hodo")) { component="HODO"; } else if(strstr(addon->GetName(),"Wall")) { component="WALL"; } else if(strstr(addon->GetName(),"Sts")) { component="STS"; } else if(strstr(addon->GetName(),"FRpc")) { component="FRPC"; } else if(strstr(addon->GetName(),"Forward")) { component="FPHY"; } /////////// JAM2021 todo: handle all these variants of the addon // if(type.Contains("1") ) { addon = new HOnlineHistArray (*this); } // else { addon = new HOnlineHistArray2(*this); } // } // else if(format == "trend") { addon = new HOnlineTrendHist (*this); } // else if(format == "trendarray") { addon = new HOnlineTrendArray(*this); } // else if(format == "mon") { // if(type.Contains("1") ) { addon = new HOnlineMonHist (*this); } // else { addon = new HOnlineMonHist2(*this); } // HOnlineMonStack* stack=dynamic_cast(addon); HOnlineHistArray* array=dynamic_cast(addon); HOnlineHistArray2* array2=dynamic_cast(addon); HOnlineTrendHist* trend=dynamic_cast(addon); HOnlineTrendArray* trendarray=dynamic_cast(addon); TObject* ob=0; if(stack) { TObjArray* stackarray=stack->getStack(); // TODO iterate over all members of stack TIterator* stit = stackarray->MakeIterator(); TH1* shis; while( ((shis = (TH1*) stit->Next()) != 0) ) { TH1* his= dynamic_cast(shis); if(his) { cout <<"Register stack to http server:"<GetName() << endl; path.Form("/HadesQA/%s/stacks/%s",component.Data(), addon->GetName()); httpserv->Register(path.Data(), his); } } } else if(array) { Int_t mx=0, my=0; array->getDim(&mx, &my); for(Int_t x=0; x(array->getP(x,y)); path.Form("/HadesQA/%s/%s",component.Data(), array->GetName()); cout <<"Register to http server for array:"<GetName()<<" - "<GetName() << endl; httpserv->Register(path.Data(), his); } } } else if (array2) { Int_t mx=0, my=0; array2->getDim(&mx, &my); for(Int_t x=0; x(array2->getP(x,y)); path.Form("/HadesQA/%s/%s",component.Data(), array2->GetName()); cout <<"Register to http server for array 2:"<GetName()<<" - "<GetName() << endl; httpserv->Register(path.Data(), his); } } } else if(trend) { TH1* his= dynamic_cast(trend->getP()); path.Form("/HadesQA/%s/trending",component.Data()); cout <<"Register to http server - trending:"<GetName() << endl; httpserv->Register(path.Data(), his); } else if (trendarray) { Int_t mx=0, my=0; trendarray->getDim(&mx, &my); for(Int_t x=0; x(trendarray->getP(x,y)); path.Form("/HadesQA/%s/trending/%s",component.Data(), trendarray->GetName()); cout <<"Register to http server for array:"<GetName()<<" - "<GetName() << endl; httpserv->Register(path.Data(), his); } } } else { TH1* his= dynamic_cast(addon->getP()); path.Form("/HadesQA/%s",component.Data()); cout <<"Register to http server:"<GetName() << endl; httpserv->Register(path.Data(), his); } } httpserv->SetTimer(100,kFALSE); #endif // ROOT_HTTP_SERVER cout<<"Hades Monitoring Server: START eventloop"<eventLoop(&fillfunctions); // start eventLoop thread clientservercom->processClients(histpool); // start communication loop cout<<"DELETING HADES!"<