trid.cxx File Reference

#include <cassert>
#include "TROOT.h"
#include "TRint.h"
#include "TString.h"
#include "TSystem.h"
#include "TStyle.h"
#include "sigc++/sigc++.h"
#include "sigc++/class_slot.h"
#include "sigc++/slot.h"
#include "Calibrator/Calibrator.h"
#include "MessageService/MsgService.h"
#include "JobControl/JobC.h"
#include "JobControl/JobCModule.h"
#include "JobControl/JobCModuleRegistry.h"
#include "Algorithm/AlgFactory.h"
#include "Algorithm/AlgConfig.h"
#include "Midad/Base/Mint.h"
#include "Midad/Base/PageDisplay.h"
#include "TriD/TridControl.h"
#include "TriD/TridPageDisplay.h"
#include "TriD/TridSetup.h"
#include "TriD/stat/ReadDispatcherModule.h"
#include "Plex/PlexLoanPool.h"
#include "DatabaseInterface/DbiTableProxyRegistry.h"

Go to the source code of this file.

Classes

class  AutoEventTimer

Typedefs

typedef enum EInputMode InputMode_t

Enumerations

enum  EInputMode { kFromFile = 0, kFromDispatcher = 1 }

Functions

void InitGui ()
 CVSID ("$Id: trid.cxx,v 1.16 2007/03/01 16:59:43 rhatcher Exp $")
TROOT root ("trid","TriD Static Viewer Program", initfuncs)
int SetupInput ()
int SetupAuto ()
int SetupAnimation ()
void setup_paths (void)
int main (int argc, char **argv)
void DoNext (void)
void DoPrev (void)

Variables

VoidFuncPtr_t initfuncs [] = { InitGui, 0 }
InputMode_t gInputMode = kFromFile
JobCjc
SigC::Ptr< TridControltc
string hostname = "localhost"
int port = 9090
float timeout = 1
bool autoNext = false
float autoNextDelay = 30.0
vector< string > filenames
bool animate = false
float animateSpeed = 0.1
int nhitThresh = 30
int nhitMax = 2000
string plexfile = "~/cache/plex_cache.dat"

Typedef Documentation

typedef enum EInputMode InputMode_t

Enumeration Type Documentation

enum EInputMode
Enumerator:
kFromFile 
kFromDispatcher 

Definition at line 48 of file stat/trid.cxx.

00048                         {
00049   kFromFile = 0,
00050   kFromDispatcher = 1
00051 } InputMode_t;


Function Documentation

CVSID ( "$Id: trid.  cxx,
v 1.16 2007/03/01 16:59:43 rhatcher Exp $"   
)
void DoNext ( void   ) 

Definition at line 157 of file stat/trid.cxx.

References gInputMode, gMint, ReadDispatcherModule::IsNewEventReady(), kFromDispatcher, Msg::kInfo, MSG, Mint::Next(), and JobC::Path.

Referenced by main().

00158 {
00159   // Called when the user hits the 'next' button.
00160   cout << "DoNext()" << endl;
00161 
00162   
00163   if(gInputMode==kFromDispatcher) {
00164     // Get the module.
00165     ReadDispatcherModule* rdm = dynamic_cast<ReadDispatcherModule*>  
00166       (&(jc->Path("default").Mod("ReadDispatcherModule")));
00167 
00168     assert(rdm);
00169             
00170     if(rdm->IsNewEventReady()) gMint->Next();
00171     else {
00172       MSG("TriD",Msg::kInfo) << "No event ready from dispatcher." << endl;
00173     }
00174   } else 
00175   
00176   {
00177     // Regualar old file
00178     gMint->Next();
00179   }
00180 }

void DoPrev ( void   ) 

Definition at line 182 of file stat/trid.cxx.

References gInputMode, gMint, kFromDispatcher, and Mint::Prev().

Referenced by main().

00183 {
00184   cout << "DoPrev()" << endl;
00185   if(gInputMode==kFromDispatcher) {
00186   } else {
00187     gMint->Prev();
00188   }
00189 }

void InitGui (  ) 
int main ( int  argc,
char **  argv 
)

Definition at line 240 of file stat/trid.cxx.

References JobCPathModule::Add(), animate, animateSpeed, JobCPathModule::Attach(), autoNext, autoNextDelay, PageDisplay::AutoZoom(), JobCPathModule::Create(), DoNext(), DoPrev(), filenames, MsgService::GetStream(), gInputMode, gMint, gPageDisplay, hostname, TridControl::Instance(), Calibrator::Instance(), DbiTableProxyRegistry::Instance(), MsgService::Instance(), Msg::kDebug, kFromDispatcher, Msg::kInfo, JobC::Msg, MSG, Mint::Next(), nhitMax, nhitThresh, JobC::Path, plexfile, port, PlexLoanPool::ReadFromFile(), JobCPathModule::Report(), CfgPromptConfigurable::Set(), CfgConfigurable::Set(), JobCMsgModule::SetLevel(), MsgStream::SetLogLevel(), setup_paths(), SetupAnimation(), SetupAuto(), SetupInput(), tc, timeout, TridSetup(), and CfgConfigurable::Update().

00241 {
00242   //
00243   // MAIN PROGRAM.
00244   //
00245   MsgService::Instance()->GetStream("TriD")->SetLogLevel(Msg::kInfo);
00246 
00248   // Configuration: read the command line.
00249   
00250   int iarg = 0;
00251   while(++iarg<argc) {
00252     // Switches.
00253     if(argv[iarg][0] == '-') {
00254       
00255       if((strcmp(argv[iarg],"-d")==0) || (strncmp(argv[iarg],"--disp",6)==0) ) {
00256         gInputMode = kFromDispatcher;   
00257         
00258         if( (iarg+1<argc) && (argv[iarg+1][0]!='-'))   hostname = argv[++iarg];
00259         if( (iarg+1<argc) && (argv[iarg+1][0]!='-')) {
00260           int tmp = 0;
00261           if(sscanf(argv[++iarg],"%d",&tmp)>0) port = tmp;
00262         }
00263         if( (iarg+1<argc) && (argv[iarg+1][0]!='-')) {
00264           float tmp = 0;
00265           if(sscanf(argv[++iarg],"%f",&tmp)>0) timeout = tmp;
00266         }
00267         cout << "Config: Using dispatcher: " << hostname << ":" << port 
00268              << " timeout: " << timeout << endl;
00269         continue;
00270       }
00271 
00272       
00273       if( (strcmp(argv[iarg],"-a")==0) || (strncmp(argv[iarg],"--auto",6)==0)) {
00274         autoNext = true;
00275         if( (iarg+1<argc) && (argv[iarg+1][0]!='-'))  {
00276           float tmp;
00277           if(sscanf(argv[++iarg],"%f",&tmp)>0) autoNextDelay = tmp;
00278         }
00279         cout << "Config: Using Auto Timer: " << autoNextDelay << " s" << endl;
00280         continue;
00281       }
00282 
00283       if( (strcmp(argv[iarg],"-n")==0) || (strncmp(argv[iarg],"--nhits",6)==0)) {
00284 
00285         if( (iarg+1<argc) && (argv[iarg+1][0]!='-'))  
00286           sscanf(argv[++iarg],"%d",&nhitThresh);
00287 
00288         if( (iarg+1<argc) && (argv[iarg+1][0]!='-'))  
00289           sscanf(argv[++iarg],"%d",&nhitMax);
00290         cout << "Using NHIT threshold of : " << nhitThresh 
00291              << " maximum NHIT " << nhitMax << endl;
00292         continue;
00293       }
00294 
00295       if( (strcmp(argv[iarg],"-r")==0) || (strncmp(argv[iarg],"--rot",5)==0)) {
00296         animate = true;
00297         if( (iarg+1<argc) && (argv[iarg+1][0]!='-'))  {
00298           float tmp;
00299           if(sscanf(argv[++iarg],"%f",&tmp)>0) animateSpeed = tmp;
00300         }
00301         cout << "Config: Turning on animation " << animateSpeed << " s" << endl;
00302         continue;
00303       }
00304 
00305       if( (strcmp(argv[iarg],"-D")==0) || (strncmp(argv[iarg],"--debug",7)==0)) {
00306         cout << "Config: Turning on debugging output." << endl;
00307         MsgService::Instance()->GetStream("TriD")->SetLogLevel(Msg::kDebug);
00308         continue;
00309       }
00310 
00311       if( (strcmp(argv[iarg],"-h")==0) || (strncmp(argv[iarg],"--help",6)==0)) {
00312         cout << "--- TriD Help ----- " << endl;
00313         cout << "Options: " << endl;
00314         cout << "  -d <host> <port>    Open dispatcher for input from host:port" << endl;
00315         cout << "  -n <nhits>          NHit threshold for dispatcher." << endl;
00316         cout << "  -a <time>           Auto-next-event every <time> seconds" << endl;
00317         cout << "  -r <speed>          Rotate view at <speed> rotations/second" << endl;
00318         cout << "  -D --debug          Turn on debugging output." << endl;
00319 
00320       }
00321 
00322     }
00323     // No switch, it's a filename.
00324     filenames.push_back(argv[iarg]);
00325   }
00326 
00327 
00328 
00329   int dummy =1;
00330   //TRint *theApp = new TRint("trid", &dummy, argv, NULL, 0);
00331   TApplication* theApp = new TApplication("PMT App",&dummy,argv);
00332 
00333   setup_paths(); // Needed to find the stupid Algorithm macros.
00334 
00335 
00336   MSG("TriD",Msg::kDebug) << "Creating job path.\n";
00337  
00338   jc = new JobC;
00339  
00340   MSG("TriD",Msg::kDebug) << "Loading plex cache from filename: " << plexfile << "\n";
00341   PlexLoanPool::ReadFromFile(plexfile.c_str());
00342 
00343   MSG("TriD",Msg::kDebug) << "Setting up DBI cache:\n";
00344   CfgConfigurable& dbiCfg = DbiTableProxyRegistry::Instance();
00345   dbiCfg.Set("Level2Cache = '~/cache/'");
00346   dbiCfg.Update();
00347 
00348 
00349   MSG("TriD",Msg::kDebug) << "Setting up job path\n";
00350  
00351   // Create the job paths.
00352   // Three paths, set up so demux gets done only if neccessary,
00353   // and digits get made only if neccessary.
00354   //
00355   // default -> getdigits -> demux -> <display>
00356   //     |                     |
00357   //     +---------------------+
00358   jc->Path.Create("default","");  
00359  // Find out our input source.
00360   SetupInput();
00361   jc->Path.Add("default","FilterEvent::Ana ");
00362 
00363   jc->Path.Create("getdigits",
00364                  "TestDigitsModule::Ana "
00365                  "DigitListModule::Get "
00366                  "DigitListModule::Reco "
00367                   "DumpMomModule::Ana "
00368                  );
00369   jc->Path("getdigits").Node("TestDigitsModule::Ana ").ReverseFilter(); // pass events with no digits, so digits get built.
00370 
00371 
00372   jc->Path.Create("demux",
00373                  "TestDemuxModule::Ana "
00374                  "DeMuxDigitListModule::Reco "
00375                   //"DemuxFast::Reco " 
00376                   "DumpMomModule::Ana "
00377                  );
00378   jc->Path("demux").Node("TestDemuxModule::Ana ").ReverseFilter(); // pass events with no digits, so digits get built.
00379   
00380   jc->Msg.SetLevel("AltDeMuxModule","Error");
00381   jc->Msg.SetLevel("AlgAltDeMux","Error");
00382   jc->Msg.SetLevel("AlgAltDeMuxDevel","Error");
00383 
00384   // Configuration:
00385   // Turn off calibration.
00386   Calibrator::Instance().Set("TimeCalibrator=SimpleCalScheme "
00387                              "PeCalibrator=SimpleCalScheme "
00388                              "DriftCalibrator=SimpleCalScheme "
00389                              "LinCalibrator=SimpleCalScheme "
00390                              "StripCalibrator=SimpleCalScheme "
00391                              "AttenCalibrator=SimpleCalScheme "
00392                              "MIPCalibrator=SimpleCalScheme "
00393                              "Thermometer=SimpleCalScheme " );
00394 
00395 
00396   jc->Path.Attach("default","getdigits");
00397   jc->Path.Attach("getdigits","demux");
00398    
00399 
00400   // Make it look pretty.
00401   gStyle->SetPalette(1,0);
00402 
00403   TridSetup(*jc);
00404   
00405   // Insert custom hooks
00406   // This allows the next and back buttons to be 'smart' and
00407   // not attempt to do things the dispatcher can't do.
00408   dynamic_cast<TridPageDisplay*>(gPageDisplay)->fNextSignal.clear();
00409   dynamic_cast<TridPageDisplay*>(gPageDisplay)->fPrevSignal.clear();
00410   dynamic_cast<TridPageDisplay*>(gPageDisplay)->fNextSignal.connect(SigC::slot(&DoNext));
00411   dynamic_cast<TridPageDisplay*>(gPageDisplay)->fPrevSignal.connect(SigC::slot(&DoPrev));
00412 
00413   // Get a sigC ptr to make sure that the TC object doesn't disappear.
00414   tc = TridControl::Instance(gPageDisplay);
00415 
00416   MSG("TriD",Msg::kDebug) << "Running job.\n";
00417 
00418  
00419   jc->Path("default").Report();
00420 
00421   // Set up auto display timer
00422   if(autoNext) {
00423     MSG("TriD",Msg::kDebug) << "Starting Auto-timer\n";
00424     SetupAuto();
00425   }
00426 
00427   if(animate) {  
00428     MSG("TriD",Msg::kDebug) << "Starting Animation\n";
00429     SetupAnimation();
00430   }
00431    gMint->Next();
00432 
00433   // Manually do an autozoom to make it look right.
00434   gPageDisplay->AutoZoom();
00435 
00436   // Run interactive interface
00437   theApp->Run();
00438 
00439   return 0;
00440 
00441 }

TROOT root ( "trid"  ,
"TriD Static Viewer Program"  ,
initfuncs   
)
void setup_paths ( void   ) 

Definition at line 191 of file stat/trid.cxx.

References gSystem(), Msg::kDebug, and MSG.

Referenced by main().

00192 {
00193   // Only need this for interactive jobs.
00194   MSG("TriD",Msg::kDebug) << "Setting up macro paths.\n";  cout.flush();
00195 
00196   TString mp = gROOT->GetMacroPath();
00197   TString ip;
00198   const char* p = gSystem->Getenv("SRT_PRIVATE_CONTEXT");
00199   if (p) {
00200     mp += ":";
00201     mp += p;
00202     mp += ":";
00203     mp += p;
00204     mp += "/macros";
00205     ip += " -I";
00206     ip += p;
00207   }
00208   
00209   const char* p2 = gSystem->Getenv("SRT_PUBLIC_CONTEXT");
00210   if (p2) {
00211     mp += ":";
00212     mp += p2;
00213     mp += ":";
00214     mp += p2;
00215     mp += "/macros";
00216     ip += " -I";
00217     ip += p2;
00218   }
00219   
00220   gROOT->SetMacroPath(mp.Data());
00221   gSystem->SetIncludePath(ip);
00222   
00223    MSG("TriD",Msg::kDebug) << "Setting up include paths.\n";  cout.flush();  
00224 
00225   if(p) {
00226     TString dip = ".include ";
00227     dip += p;
00228     gROOT->ProcessLine(dip.Data());
00229   }
00230 
00231   if(p2) {
00232     TString dip = ".include ";
00233     dip += p2;
00234     gROOT->ProcessLine(dip.Data());
00235   }
00236 }

int SetupAnimation ( void   ) 

Definition at line 146 of file stat/trid.cxx.

References animateSpeed, and tc.

Referenced by main().

00147 {
00148   assert(tc);
00149   tc->GetAnimator().SetAnimateViews(true);
00150   tc->GetAnimator().SetAnimateModels(false);
00151   tc->GetAnimator().SetViewAnimSpeed( animateSpeed );
00152   tc->GetAnimator().StartAnimation();
00153   return 0;
00154 }

int SetupAuto ( void   ) 

Definition at line 137 of file stat/trid.cxx.

References autoNextDelay, and timer().

Referenced by main().

00138 {
00139   AutoEventTimer* timer = new AutoEventTimer();
00140   timer->Start((Long_t)(autoNextDelay*1000.),true);
00141   timer->TurnOn();
00142   return 0;
00143 }

int SetupInput (  ) 

Definition at line 71 of file stat/trid.cxx.

References JobCPathModule::Add(), JobCInput::AddFile(), filenames, Form(), gInputMode, hostname, JobC::Input, Msg::kDebug, kFromDispatcher, MSG, nhitMax, nhitThresh, JobC::Path, port, JobCModule::Set(), timeout, and JobCInput::Use().

Referenced by main().

00072 {
00073   assert(jc);
00074   
00075   if(gInputMode==kFromDispatcher) {
00076     cout << "Setting up dispatcher client connected to " 
00077          << hostname << " :" << port << endl;
00078 
00079     /*
00080     jc->Input.Set("Format=DDS");
00081         jc->Input.Set(Form("DDSServer=%s",hostname.c_str())); // dispatcher server host
00082     jc->Input.Set(Form("DDSPort=%d",port));  // default dispatcher server port is 9090
00083     jc->Input.Set("Streams=DaqSnarl"); //default is DS,DM,LightInjection
00084     jc->Input.Set("DDSKeepUpMode=RecordKeepUp");  // default is FileKeepUp
00085     jc->Input.Set("DDSDataSource=Daq");  // default is Daq
00086     jc->Input.Set(Form("DDSTimeOut=%d",(int)timeout));      // (seconds) default is 120
00087     jc->Input.Set("DDSMaxSyncDelay=1");      // (seconds) default is 15    
00088     jc->Input.Select("DaqSnarl",
00089                      Form("(((RawDaqSnarlHeader*)fHeader)->GetNumRawDigits()>%d)"
00090                           "&&(((RawDaqSnarlHeader*)fHeader)->GetNumRawDigits()<%d)",
00091                           nhitThresh,nhitMax));
00092     
00093     */
00094     // Add a dummy input method to save on warnings.
00095     jc->Input.Use("DummyInput");
00096 
00097     // Add my own input
00098     jc->Path.Add("default","ReadDispatcherModule::Get ");
00099     JobCModule& mod = jc->Path("default").Mod("ReadDispatcherModule");
00100     mod.Set(Form("DDSServer=%s",hostname.c_str())); // dispatcher server host
00101     mod.Set(Form("DDSPort=%d",port));  // default dispatcher server port is 9090
00102     mod.Set("Streams=DaqSnarl"); //default is DS,DM,LightInjection
00103     mod.Set("DDSKeepUpMode=RecordKeepUp");  // default is FileKeepUp
00104     mod.Set("DDSDataSource=Daq");  // default is Daq
00105     mod.Set(Form("DDSTimeOut=%d",(int)timeout));      // (seconds) default is 120
00106     mod.Set("DDSMaxSyncDelay=1");      // (seconds) default is 15    
00107     mod.Set(Form("SelectRule=(((RawDaqSnarlHeader*)fHeader)->GetNumRawDigits()>%d)"
00108                  "&&(((RawDaqSnarlHeader*)fHeader)->GetNumRawDigits()<%d)",
00109                  nhitThresh,nhitMax));
00110     
00111 
00112   } else {
00113    jc->Input.Set("Streams=DaqSnarl,Cand");
00114         
00115     MSG("TriD",Msg::kDebug) << "Adding files..\n";
00116     for(UInt_t i=0;i<filenames.size();i++) {
00117       jc->Input.AddFile(filenames[i].c_str());
00118       MSG("TriD",Msg::kDebug) << "  Adding file " << filenames[i] << endl;
00119     }
00120     
00121   }
00122 
00123   return 1;
00124 }


Variable Documentation

bool animate = false

Definition at line 65 of file stat/trid.cxx.

Referenced by main().

float animateSpeed = 0.1

Definition at line 66 of file stat/trid.cxx.

Referenced by main(), and SetupAnimation().

bool autoNext = false

Definition at line 62 of file stat/trid.cxx.

Referenced by main().

float autoNextDelay = 30.0

Definition at line 63 of file stat/trid.cxx.

Referenced by main(), AutoEventTimer::Notify(), and SetupAuto().

vector<string> filenames

Definition at line 64 of file stat/trid.cxx.

Referenced by main(), and SetupInput().

InputMode_t gInputMode = kFromFile

Definition at line 55 of file stat/trid.cxx.

Referenced by DoNext(), DoPrev(), main(), and SetupInput().

string hostname = "localhost"
VoidFuncPtr_t initfuncs[] = { InitGui, 0 }

Definition at line 33 of file stat/trid.cxx.

JobC* jc
int nhitMax = 2000

Definition at line 68 of file stat/trid.cxx.

Referenced by main(), and SetupInput().

int nhitThresh = 30

Definition at line 67 of file stat/trid.cxx.

Referenced by main(), and SetupInput().

string plexfile = "~/cache/plex_cache.dat"

Definition at line 69 of file stat/trid.cxx.

Referenced by main().

int port = 9090
SigC::Ptr<TridControl> tc
float timeout = 1

Definition at line 61 of file stat/trid.cxx.

Referenced by main(), and SetupInput().


Generated on 20 Feb 2018 for loon by  doxygen 1.6.1