Changeset 2564


Ignore:
Timestamp:
11/24/03 01:16:39 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2563 r2564  
    4646     - changed 'MRawEvtTime' to 'MTime'
    4747     - added some debugging output in case of kContinue
     48
     49   * mmain/MOnlineDump.[h,cc], mmain/MOnlineDisplay.[h,cc]:
     50     - added
     51
     52   * mmain/MainLinkDef.h, mmain/Makefile:
     53     - added MOnlineDump
     54     - added MOnlineDisplay
     55
     56   * mona.cc:
     57     - updated
    4858
    4959
  • trunk/MagicSoft/Mars/mmain/MainLinkDef.h

    r2505 r2564  
    1414#pragma link C++ class MCameraDisplay+;
    1515#pragma link C++ class MEventDisplay+;
     16#pragma link C++ class MOnlineDisplay+;
     17#pragma link C++ class MOnlineDump+;
    1618
    1719#pragma link C++ class MGDisplayAdc+;
  • trunk/MagicSoft/Mars/mmain/Makefile

    r2521 r2564  
    3737           MGDisplayAdc.cc \
    3838           MEventDisplay.cc \
     39           MOnlineDisplay.cc \
     40           MOnlineDump.cc \
    3941           MCameraDisplay.cc
    4042
  • trunk/MagicSoft/Mars/mona.cc

    r2531 r2564  
    22
    33#include <TThread.h>
     4#include <TCanvas.h>
    45#include <TMethod.h>          // GetMenuItems
     6
     7#include <TGButton.h>
    58
    69#include "MParList.h"
     
    1619#include "MFRealTimePeriod.h"
    1720#include "MHTriggerLvl0.h"
    18 #include "MHCamera.h"         // ::Class()
    19 
    20 #include "MStatusDisplay.h"
     21#include "MHCamera.h"         // ::Class(), SetFreezed
     22#include "MHCamEvent.h"       // MHCamEvent
     23#include "MHEvent.h"          // MHEvent::GetHist()
     24
     25#include "MOnlineDump.h"
     26#include "MOnlineDisplay.h"
    2127
    2228#include "MImgCleanStd.h"
    2329#include "MHillasCalc.h"
    2430#include "MHillasSrcCalc.h"
     31#include "MEventRateCalc.h"
    2532
    2633#include "MArgs.h"
     
    3239#include "MRawRunHeader.h"       // MRawRunHeader
    3340
    34 class MOnlineDump : public MTask
    35 {
    36 private:
    37     MFillH *fFill1;
    38     MFillH *fFill2;
    39     MFillH *fFill3;
    40     MFRealTimePeriod *fFilter;
    41 
    42     UInt_t fRunNumber;
    43     UInt_t fEvtNumber;
    44 
    45     MRawEvtHeader *fRawEvtHeader;
    46     MRawRunHeader *fRawRunHeader;
    47 
    48     MTime *fEvtTime;
    49     Double_t fTime;
    50 
    51     void SetNoContextMenu(TObject *c)
    52     {
    53         if (fDisplay->HasCanvas((TCanvas*)c))
    54             c->ResetBit(kNoContextMenu);
    55     }
    56     void DisplayTriggerRate()
    57     {
    58         if (*fEvtTime==0)
    59             fEvtTime->SetTime(gSystem->Now());
    60    
    61         if (fEvtNumber==0 || fRawRunHeader->GetRunNumber()!=fRunNumber)
    62         {
    63             fEvtNumber = fRawEvtHeader->GetDAQEvtNumber();
    64             fRunNumber = fRawRunHeader->GetRunNumber();
    65             fTime      = *fEvtTime;
    66             return;
    67         }
    68    
    69         const UInt_t  evts = fRawEvtHeader->GetDAQEvtNumber() - fEvtNumber;
    70         const Double_t sec = *fEvtTime-fTime;
    71    
    72         if (evts>0 && sec>0 && fDisplay)
    73             fDisplay->SetStatusLine2(Form("Trigger Rate: %.1fHz", evts/sec));
    74     }
    75 
    76 public:
    77     MOnlineDump() { fName = "MOnlineDump"; }
    78     Int_t PreProcess(MParList *pList)
    79     {
    80         if (gROOT->IsBatch())
    81         {
    82             *fLog << err << "We are in batch mode!" << endl;
    83             return kFALSE;
    84         }
    85         if (!fDisplay)
    86         {
    87             *fLog << err << "fDisplay not set." << endl;
    88             return kFALSE;
    89         }
    90    
    91         MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
    92         if (!tasks)
    93         {
    94             *fLog << err << "MTaskList not found... abort." << endl;
    95             return kFALSE;
    96         }
    97    
    98         fFill1 = (MFillH*)tasks->FindObject("MFillCamEvent");
    99         if (!fFill1)
    100         {
    101             *fLog << err << "MFillCamEvent not found... abort." << endl;
    102             return kFALSE;
    103         }
    104         fFill2 = (MFillH*)tasks->FindObject("MFillEvent");
    105         if (!fFill2)
    106         {
    107             *fLog << err << "MFillEvent not found... abort." << endl;
    108             return kFALSE;
    109         }
    110         fFill3 = (MFillH*)tasks->FindObject("MFillTriggerLvl0");
    111         if (!fFill3)
    112         {
    113             *fLog << err << "MFillTriggerLvl0 not found... abort." << endl;
    114             return kFALSE;
    115         }
    116         fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
    117         if (!fRawEvtHeader)
    118         {
    119             *fLog << err << "MRawEvtHeader not found... abort." << endl;
    120             return kFALSE;
    121         }
    122    
    123         fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
    124         if (!fRawRunHeader)
    125         {
    126             *fLog << err << "MRawRunHeader not found... abort." << endl;
    127             return kFALSE;;
    128         }
    129    
    130         fEvtTime = (MTime*)pList->FindObject("MRawEvtTime");
    131         if (!fEvtTime)
    132         {
    133             *fLog << err << "MRawEvtTime not found... abort." << endl;
    134             return kFALSE;
    135         }
    136    
    137         fRunNumber = 0xffffffff;
    138         fEvtNumber = 0;
    139    
    140         SetNoContextMenu((TObject*)fFill1->GetCanvas());
    141         SetNoContextMenu((TObject*)fFill2->GetCanvas());
    142         SetNoContextMenu((TObject*)fFill3->GetCanvas());
    143    
    144         return kTRUE;
    145     }
    146     Int_t Process()
    147     {
    148         DisplayTriggerRate();
    149    
    150         if (fDisplay)
    151             fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
    152    
    153         return kTRUE;
    154     }
    155     Int_t PostProcess()
    156     {
    157         if (fDisplay)
    158             fDisplay->SetProgressBarPosition(1);
    159    
    160         return kTRUE;
    161     }
    162 //    ClassDef(MOnlineDump, 0) // Task to fill a histogram with data from a parameter container
    163 };
    164 //ClassImp(MOnlineDump);
    165 // --------------------------------------------------------------------
     41using namespace std;
    16642
    16743void StartUpMessage()
     
    21389}
    21490
    215 Bool_t Loop(MStatusDisplay *display, Int_t port)
    216 {
     91Bool_t Loop(MOnlineDisplay *display, Int_t port)
     92{
     93    display->Reset();
     94
    21795    //
    21896    // create the tasks which should be executed and add them to the list
     
    238116    tasks.AddToList(&ncalc);
    239117
     118    MEventRateCalc tcalc;
     119    tcalc.SetNumEvents(100);
     120    tasks.AddToList(&tcalc);
     121
    240122    MFillH fill1("MHEvent",    "MCerPhotEvt", "MFillEvent");
    241123    MFillH fill2("MHCamEvent", "MCerPhotEvt", "MFillCamEvent");
     
    248130
    249131    tasks.AddToList(&filter);
     132
    250133    tasks.AddToList(&fill1);
    251134    tasks.AddToList(&fill2);
     
    254137    MOnlineDump dump;
    255138    dump.SetFilter(&filter);
     139    display->SetTask(&dump);
    256140    tasks.AddToList(&dump);
     141
     142    MHCamEvent hist("PedestalRms");
     143    hist.SetType(1);
     144    plist.AddToList(&hist);
     145
     146    // -------------------------------------------
     147
     148    MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
     149    MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
     150    maxhi.SetType(3);
     151    maxlo.SetType(4);
     152    plist.AddToList(&maxhi);
     153    plist.AddToList(&maxlo);
     154
     155    // -------------------------------------------
     156
     157    MFillH hfilla("MaxIdxHi", "MRawEvtData");
     158    MFillH hfillb("MaxIdxLo", "MRawEvtData");
     159    MFillH hfillc("Pedestals [MHCamEvent]", "MPedestalCam");
     160    MFillH hfilld("PedestalRms", "MPedestalCam");
     161    tasks.AddToList(&hfilla);
     162    tasks.AddToList(&hfillb);
     163    tasks.AddToList(&hfillc);
     164    tasks.AddToList(&hfilld);
    257165
    258166    MImgCleanStd      clean;
     
    291199void *thread(void *ptr)
    292200{
    293     const Int_t port = *(Int_t*)ptr;
    294 
    295     MStatusDisplay d;
    296     d.Resize(740, 600);
     201    const Int_t port = *((Int_t**)ptr)[0];
     202    MOnlineDisplay &d = *((MOnlineDisplay**)ptr)[1];
    297203
    298204    //
     
    303209        Loop(&d, port);
    304210
    305     gLog << dbg << "Exit System Loop... " << flush;
    306     gSystem->ExitLoop();
    307     gLog << "done." << endl;
    308 
    309     TThread::Self()->Exit();
     211
     212    gLog << dbg << "Loop stopped... exit thread()" << endl;
     213
    310214    return 0;
    311215}
     
    403307    // if the thread is terminated (by return)
    404308    //
    405     gLog << dbg << "Starting Thread..." << endl;
    406     TThread t(thread, (void*)&port);
     309    gLog << dbg << "Starting Display..." << flush;
     310    MOnlineDisplay d;
     311    d.SetBit(MStatusDisplay::kExitLoopOnExit);
     312    gLog << "done." << endl;
     313
     314    // gDebug=1;
     315
     316    gLog << dbg << "Starting Thread..." << flush;
     317    const void *ptr[2] = { &port, &d };
     318    TThread t(thread, ptr);
    407319    t.Run();
     320    gLog << "done." << endl;
    408321
    409322    gLog << dbg << "Starting System loop... " << endl;
     
    411324    gLog << dbg << "System loop stopped." << endl;
    412325
     326    d.UnmapWindow();
     327
     328    gLog << dbg << "Waiting for termination of thread... (be patient)" << endl;
     329    while (t.GetState()!=TThread::kCanceledState)
     330        gSystem->ProcessEvents();
     331
     332    gLog << dbg << "Thread terminated... joining." << endl;
     333
     334    TThread::Join(t.GetId()); //- seems that it is implicitly done... why?
     335
     336    gLog << dbg << "Exit MONA." << endl;
     337
    413338    return 0;
    414339}
Note: See TracChangeset for help on using the changeset viewer.