Commit e3a7a0a3 authored by Daniel Hynds's avatar Daniel Hynds
Browse files

First threading capability added to allow continuous monitoring.


Former-commit-id: 814d5865324b09e47e439d4f14cc09412dc877ad
parent b659c718
#include "BasicTracking.h"
#include "TCanvas.h"
BasicTracking::BasicTracking(bool debugging)
: Algorithm("BasicTracking"){
......@@ -108,7 +109,9 @@ int BasicTracking::run(Clipboard* clipboard){
tcout<<"Made "<<tracks->size()<<" tracks"<<endl;
clipboard->put("Timepix3","tracks",(TestBeamObjects*)tracks);
// cout<<gPad<<endl;
// trackChi2->Draw();
// cout<<gPad<<endl;
return 1;
}
......
......@@ -13,7 +13,7 @@ void EventDisplay::initialise(Parameters* par){
parameters = par;
// Set up histograms
eventMap = new TH3F("eventMap","eventMap",100,-5,5,100,-5,5,105,-10,200);
eventMap = new TH3F("eventMap","eventMap",100,-10,10,100,-10,10,105,-10,200);
}
......
#include "GUI.h"
#include "TApplication.h"
#include "TPolyLine3D.h"
#include "TSystem.h"
GUI::GUI(bool debugging)
: Algorithm("GUI"){
debug = debugging;
}
void startBrowser(void* gui){
cout<<"I still run"<<endl;
// TApplication* testApp = new TApplication("example",0, 0);
// TBrowser* test = new TBrowser();
// testApp->Run();
((GUI*)gui)->rootapp = new TApplication("example",0, 0);
((GUI*)gui)->browser = new TBrowser();
// gSystem->Sleep(1);
((GUI*)gui)->rootapp->Run(true);
}
void update(void*){
while(1){
gSystem->ProcessEvents();
gSystem->Sleep(1);
}
}
void GUI::initialise(Parameters* par){
parameters = par;
// Set up histograms
eventMap = new TH3F("eventMap","eventMap",100,-10,10,100,-10,10,105,-10,200);
// TApplication* rootapp = new TApplication("example",0, 0);
// browser = new TBrowser();
// rootapp->Run();
// rootapp = new TApplication("example",0, 0);
// browser = new TBrowser();
browserThread = new TThread("browserThread", startBrowser, (void*) this);
// browserThread->Run();
updateThread = new TThread("updateThread", update, (void*) 0);
// updateThread->Run();
}
int GUI::run(Clipboard* clipboard){
// updateThread->Run();
// Get the tracks
// Timepix3Tracks* tracks = (Timepix3Tracks*)clipboard->get("Timepix3","tracks");
// if(tracks == NULL){
// return 1;
// }
// rootapp = new TApplication("example",0, 0);
// browser = new TBrowser();
// rootapp->Run(false);
// browser->Refresh();
/* TCanvas* canv = new TCanvas();
eventMap->DrawCopy("");
// Loop over all tracks. Add the cluster points to the histogram and draw a line for the tracks
for(int iTrack=0; iTrack<tracks->size(); iTrack++){
// Get the track
Timepix3Track* track = (*tracks)[iTrack];
// Get all clusters on the track
Timepix3Clusters trackClusters = track->clusters();
// Fill the event map
for(int iTrackCluster=0; iTrackCluster<trackClusters.size(); iTrackCluster++){
Timepix3Cluster* trackCluster = trackClusters[iTrackCluster];
eventMap->Fill(trackCluster->globalX(), trackCluster->globalY(), trackCluster->globalZ());
}
ROOT::Math::XYZPoint linestart = track->intercept(0);
ROOT::Math::XYZPoint linestop = track->intercept(200);
TPolyLine3D *line = new TPolyLine3D(2);
line->SetPoint(0,linestart.X(),linestart.Y(),linestart.Z());
line->SetPoint(1,linestop.X(),linestop.Y(),linestop.Z());
line->SetLineColor(2);
line->Draw("same");
}
eventMap->DrawCopy("same,box");
canv->Update();
rootapp->Run();
return 1;
*/
return 1;
}
void GUI::finalise(){
}
#ifndef GUI_H
#define GUI_H 1
#include "Algorithm.h"
#include <iostream>
#include "TH1F.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TCanvas.h"
#include "TBrowser.h"
#include "TThread.h"
#include "TApplication.h"
#include "Timepix3Pixel.h"
#include "Timepix3Cluster.h"
#include "Timepix3Track.h"
class GUI : public Algorithm {
public:
// Constructors and destructors
GUI(bool);
~GUI(){}
// Functions
void initialise(Parameters*);
int run(Clipboard*);
void finalise();
// void startBrowser();
TApplication* rootapp;
TThread* browserThread;
TThread* updateThread;
TBrowser* browser;
TH3F* eventMap;
};
#endif // GUI_H
......@@ -2,6 +2,11 @@
#include "TFile.h"
#include "TChain.h"
#include <signal.h>
#include "TSystem.h"
#include "TPad.h"
#include "TCanvas.h"
#include "TObjectTable.h"
#include "TROOT.h"
// Local include files
#include "Analysis.h"
......@@ -43,9 +48,41 @@ void Analysis::run(){
int check = m_algorithms[algorithmNumber]->run(m_clipboard);
m_algorithms[algorithmNumber]->getStopwatch()->Stop();
if(check == 0) run = false;
// browser->Refresh();
}
// Clear objects from this iteration from the clipboard
m_clipboard->clear();
// TCanvas* canv = (TCanvas*)gDirectory->Get("c1");
// canv->Update();
browser->SetRefreshFlag(true);
browser->Refresh();
// browser->Dump();
// gDirectory->ls();
cout<<gROOT->GetListOfCanvases()->GetSize()<<endl;
// ((TCanvas*)gROOT->GetListOfCanvases()->At(0))->GetListOfPrimitives()->Print();
((TCanvas*)gROOT->GetListOfCanvases()->At(0))->Paint();
// ((TCanvas*)gROOT->GetListOfCanvases()->At(0))->Modified();
((TCanvas*)gROOT->GetListOfCanvases()->At(0))->Update();
// ((TPad*)(((TCanvas*)gROOT->GetListOfCanvases()->At(0))->GetPad(0)))->Modified();
gSystem->ProcessEvents();
// gPad->Dump();
// cout<<"Sleeping"<<endl;
// gSystem->Sleep(10000);
// cout<<"Woken up"<<endl;
// Check if any of the algorithms return a value saying it should stop
if(!run) break;
// Check if we have reached the maximum number of events
......
......@@ -6,6 +6,7 @@
#include "TFile.h"
#include "TDirectory.h"
#include "TBrowser.h"
#include "Algorithm.h"
#include "Clipboard.h"
......@@ -35,6 +36,8 @@ public:
void initialiseAll();
void finaliseAll();
TBrowser* browser;
protected:
// Member variables
......
......@@ -30,12 +30,20 @@ void Parameters::readCommandLineOptions(int argc, char *argv[]){
cout<<endl;
cout<<"===================| Reading Parameters |===================="<<endl<<endl;
int option; char temp[256];
while ( (option = getopt(argc, argv, "amd:c:n:h:")) != -1) {
while ( (option = getopt(argc, argv, "agemd:c:n:h:")) != -1) {
switch (option) {
case 'a':
align = true;
cout<<"Alignment flagged to be run"<<endl;
break;
case 'e':
eventDisplay = true;
cout<<"Event display flagged to be run"<<endl;
break;
case 'g':
gui = true;
cout<<"GUI flagged to be run"<<endl;
break;
case 'm':
produceMask = true;
cout<<"Will update masked pixel files"<<endl;
......
......@@ -166,6 +166,8 @@ public:
string dut;
int nEvents;
bool align;
bool eventDisplay;
bool gui;
bool produceMask;
// Parameters for each detector (stored by detector ID)
......
......@@ -6,6 +6,7 @@
// ROOT includes
#include "TROOT.h"
#include "TApplication.h"
//#include "TPad.h"
// Local includes
#include "Parameters.h"
......@@ -19,6 +20,7 @@
#include "BasicTracking.h"
#include "Alignment.h"
#include "EventDisplay.h"
#include "GUI.h"
//-------------------------------------------------------------------------------
// The Steering is effectively the executable. It reads command line
......@@ -26,6 +28,12 @@
// added. Algorithms have 3 steps: initialise, run and finalise.
//-------------------------------------------------------------------------------
void runAnalysis(void* analysis){
((Analysis*)analysis)->run();
}
// The analysis object to be used
Analysis* analysis;
......@@ -63,6 +71,7 @@ int main(int argc, char *argv[]) {
BasicTracking* basicTracking = new BasicTracking(debug);
Alignment* alignment = new Alignment(debug);
EventDisplay* eventDisplay = new EventDisplay(debug);
GUI* gui = new GUI(debug);
// =========================================================================
// Steering file ends
......@@ -83,7 +92,31 @@ int main(int argc, char *argv[]) {
if(parameters->align) analysis->add(alignment);
if(parameters->produceMask) analysis->add(tpix3MaskCreator);
analysis->run();
if(parameters->eventDisplay) analysis->add(eventDisplay);
if(parameters->gui) analysis->add(gui);
TApplication* app = new TApplication("example",0, 0);
analysis->browser = new TBrowser();
// gPad = ((TPad*)(((TCanvas*)gROOT->GetListOfCanvases()->At(0))->GetPad(0)));
// TCanvas* canv = new TCanvas();
// canv->Draw();
// cout<<gPad<<endl;
TThread* anaThread = new TThread("anaThread", runAnalysis, (void*) analysis);
anaThread->Run();
app->Run(true);
cout<<"Still running"<<endl;
while(1){
gSystem->Sleep(5);
((TCanvas*)gROOT->GetListOfCanvases()->At(0))->Modified();
((TCanvas*)gROOT->GetListOfCanvases()->At(0))->Update();
}
// analysis->run();
return 0;
......
#!/bin/bash
TBCODE=${PWD}/..
TBCODE=..
RUN=25
DATADIR=${TBCODE}/example/Run${RUN}
......@@ -8,4 +8,4 @@ CONDFILE=${TBCODE}/cond/cond.dat
HISTOFILE=${TBCODE}/histos/histogramsRun${RUN}.root
NEVENTS=20
${TBCODE}/bin/tbAnalysis -d ${DATADIR} -c ${CONDFILE} -n ${NEVENTS} -h ${HISTOFILE}
${TBCODE}/bin/tbAnalysis -d ${DATADIR} -c ${CONDFILE} -n ${NEVENTS} -h ${HISTOFILE} -g
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment