Changeset 1600


Ignore:
Timestamp:
11/13/02 17:03:19 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
2 added
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1599 r1600  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/11/13: Thomas Bretz
     4
     5   * mfilter/MFEventSelector.[h,cc]:
     6     - if total number of events read from file the selector worked only for
     7       one eventloop - fixed.
     8     - changed MReadMarsFile to MRead
     9
     10   * mbase/MContinue.cc:
     11     - fixed a typo
     12
     13   * mbase/MEvtLoop.cc, meventdisp/MGEvtDisplay.cc:
     14     - renamed MReadMarsFile/MReadTree to MRead
     15
     16   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
     17     - added MRead
     18
     19   * mfileio/MRead.[h,cc]:
     20     - added
     21
     22   * mfileio/MReadMarsFile.[h,cc], mfileio/MReadTree.[h,cc]:
     23     - renamed from MReadMarsFile to MRead
     24     - derived from MRead
     25     - removed progressbar support from MReadTree
     26
     27   * mfileio/MWriteRootFile.cc:
     28     - added a info output
     29
     30   * mfileio/MCT1ReadPreProc.[h,cc]:
     31     - changed to work much much better :)
     32
     33   * mgeom/GeomLinkDef.h, mmc/McLinkDef.h:
     34     - added missing LinkDefs (helllo Oscar!)
     35
     36   * mgeom/MGeomCamCT1.cc:
     37     - mirrored the CT1 camera in x (CT1 default)
     38
     39   * mgeom/MGeomMirror.[h,cc]:
     40     - some small changes
     41   
     42   * mgeom/MGeomPMT.[h,cc]:
     43     - changed usage of TArrayF from pointer to reference
     44
     45   * mgui/MCamDisplay.cc:
     46     - fixed a crash at delete when the user closed a automatically
     47       created canvas
     48
     49   * mhist/MHFadcCam.[h,cc]:
     50     - implemented ResetHistograms
     51
     52   * mhist/MHMatrix.[h,cc]:
     53     - implemented ReduceNumberOfRows (preliminary, untested)
     54
     55   * mmc/MMcConfigRunHeader.[h,cc]:
     56     - some small changes
     57     - changed usage of TArrayF from pointer to reference
     58
     59
    260
    361 2002/11/11: Thomas Bretz
  • trunk/MagicSoft/Mars/mbase/MContinue.cc

    r1538 r1600  
    2727// MContinue                                                               //
    2828//                                                                         //
    29 // Does nothing than return kCONTINUE in the Process-fucntion              //
     29// Does nothing than return kCONTINUE in the Process-function              //
    3030// (use with filters)                                                      //
    3131//                                                                         //
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r1540 r1600  
    8585#include "MTaskList.h"
    8686#ifdef __MARS__
    87 #include "MReadTree.h"       // for setting progress bar
     87#include "MRead.h"           // for setting progress bar
    8888#include "MProgressBar.h"    // MProgressBar::GetBar
    8989#endif
     
    213213        else
    214214        {
    215             MReadTree *read = (MReadTree*)fTaskList->FindObject("MReadTree");
    216             if (!read)
    217                 read = (MReadTree*)fTaskList->FindObject("MReadMarsFile");
    218             if (read)
     215            MRead *read = (MRead*)fTaskList->FindObject("MRead");
     216            if (read && read->GetEntries()>0)
    219217                fProgress->SetRange(0, read->GetEntries());
    220218        }
  • trunk/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc

    r1542 r1600  
    9292MReadTree *MGEvtDisplay::GetReader() const
    9393{
    94     return (MReadTree*)GetTaskList()->FindObject("MReadMarsFile");
     94    return (MReadTree*)GetTaskList()->FindObject("MRead");
    9595}
    9696
  • trunk/MagicSoft/Mars/mfileio/FileIOLinkDef.h

    r1574 r1600  
    66
    77#pragma link C++ class MChain+;
     8#pragma link C++ class MRead+;
    89#pragma link C++ class MReadTree+;
    910#pragma link C++ class MReadMarsFile+;
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc

    r1599 r1600  
    4242//
    4343/////////////////////////////////////////////////////////////////////////////
    44 
    4544#include "MCT1ReadPreProc.h"
    4645
     
    8180//
    8281MCT1ReadPreProc::MCT1ReadPreProc(const char *fname, const char *name,
    83                                  const char *title) : fIn(NULL)
    84 {
    85     fName  = name  ? name  : "MCT1ReadPreProc";
     82                                 const char *title) : fIn(NULL), fEntries(0)
     83{
     84    fName  = name  ? name  : "MRead";
    8685    fTitle = title ? title : "Task to loop over events in CT1 ascii file";
    8786
     
    113112void MCT1ReadPreProc::AddFile(const char *txt)
    114113{
    115     TNamed *name = new TNamed(txt, "");
    116     fFileNames->AddLast(name);
     114    ifstream *store = fIn;
     115
     116    fIn = new ifstream(gSystem->ExpandPathName(txt));
     117
     118    if (!(*fIn))
     119    {
     120        *fLog << warn << "Cannot open file '" << txt << "'... ignored." << endl;
     121        fIn = store;
     122        return;
     123    }
     124
     125    fEntries += GetNumEvents();
     126
     127    delete fIn;
     128
     129    fIn = store;
     130
     131    fFileNames->AddLast(new TNamed(txt, ""));
    117132}
    118133
     
    123138// data members
    124139//
    125 void MCT1ReadPreProc::ProcessHeader(const struct outputpars &outpars)
    126 {
    127     fNumPixels = outpars.inumpixels; // number of pixels in the camera
    128 
    129     if (fNumPixels>iMAXNUMPIX || fNumPixels==0)
    130         fNumPixels=iMAXNUMPIX;
     140void MCT1ReadPreProc::ProcessRunHeader(const struct outputpars &outpars)
     141{
     142    if (outpars.inumpixels != iMAXNUMPIX)
     143        *fLog << warn << "WARNING! File doesn't contain " << iMAXNUMPIX << " Pixels... maybe corrupt." << endl;
     144
     145    fNumEventsInRun = 0;
    131146
    132147    //
     
    166181    *fLog << "Source:    RA=" << outpars.dsourcera_hours << "h  DEC=";
    167182    *fLog << outpars.dsourcedec_deg << "deg" << endl;
    168 
    169     *fLog << "Pixels:    " << fNumPixels << endl;
    170183
    171184    //int     inummuonpixels;   // number of pixels in the muon shield
     
    262275
    263276    // FIXME? Is x-y echanged between Mars CT1 geometry and CT1 definition?
    264     fSrcPos->SetXY(outpars.fypointcorr_deg/fGeom->GetConvMm2Deg(),
    265                    outpars.fxpointcorr_deg/fGeom->GetConvMm2Deg());
     277    fSrcPos->SetXY(-outpars.fypointcorr_deg/fGeom->GetConvMm2Deg(),
     278                   -outpars.fxpointcorr_deg/fGeom->GetConvMm2Deg());
     279    fSrcPos->SetReadyToSave();
    266280
    267281    /*
     
    342356
    343357    fIsMcFile = outpars.bmontecarlo==TRUE;
     358
     359    fPedest->SetReadyToSave();
    344360}
    345361
     
    348364// Read CT1 PreProc File Header:
    349365//
    350 Bool_t MCT1ReadPreProc::ReadHeader()
     366Bool_t MCT1ReadPreProc::ReadRunHeader()
    351367{
    352368    char cheadertitle[iHEADERTITLELENGTH];
     
    381397    fIn->read((Byte_t*)&outpars, sizeof(struct outputpars));
    382398
    383     ProcessHeader(outpars);
     399    ProcessRunHeader(outpars);
    384400
    385401    return kTRUE;
    386402}
    387403
    388 Bool_t MCT1ReadPreProc::ReadFooter()
     404Bool_t MCT1ReadPreProc::ReadRunFooter()
    389405{
    390406    char cheadertitle[iHEADERTITLELENGTH];
     
    400416
    401417    if (!s.BeginsWith(m(0,p)))
    402         return kFALSE;
     418    {
     419        fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
     420        return kFALSE;
     421    }
    403422
    404423    *fLog << inf << cheadertitle << flush;
     
    423442     */
    424443
     444    fNumFilterEvts += filterres.ifilter_passed_evts;
     445    fNumRuns++;
     446
     447    *fLog << inf << "Read " << fNumEventsInRun << " events from run." << endl;
     448
     449    if (fNumEventsInRun!=(UInt_t)filterres.ifilter_passed_evts)
     450    {
     451        *fLog << warn << "WARNING! Number of events in run doesn't match number of read events." << endl;
     452        *fLog << "         File might be corrupt." << endl;
     453    }
     454
    425455    return kTRUE;
    426456}
     
    468498    *fLog << inf << "-----------------------------------------------------------------------" << endl;
    469499
    470     //*fLog << "File contains " << GetNumEvents() << " events." << endl;
    471 
    472     Bool_t rc = ReadHeader();
     500    *fLog << "File contains " << GetNumEvents() << " events." << endl;
     501
     502    // WORKAROUND for not working seekg(0) in GetNumEvents
     503    fIn->close();
     504    fIn->open(gSystem->ExpandPathName(name));
     505
     506    Bool_t rc = ReadRunHeader();
    473507
    474508    if (!rc)
    475         *fLog << warn << "Unable to read header... skipping file." << endl;
     509        *fLog << warn << "Unable to read first run header... skipping file." << endl;
    476510
    477511    return rc;
     
    480514Int_t MCT1ReadPreProc::GetNumEvents()
    481515{
    482     Int_t n = 0;
     516    *fLog << inf << "Scanning file for size" << flush;
     517
     518    const TString m(cEND_EVENTS_TEMPLATE);
     519    const Int_t p = m.First('%');
     520    const TString test = m(0, p);
     521
     522    Int_t nevts = 0;
     523    Int_t nruns = 0;
    483524
    484525    while (!fIn->eof())
    485526    {
    486         if (fIn->get()!=cEND_EVENTS_TEMPLATE[0])
    487             continue;
    488 
    489         char cheadertitle[iHEADERTITLELENGTH];
    490         fIn->read(cheadertitle, iHEADERTITLELENGTH-1);
    491 
    492         TString s = cheadertitle;
    493         TString m = cEND_EVENTS_TEMPLATE;
    494         Int_t p = m.First('%');
    495 
    496         if (!s.BeginsWith(m(1,p-1)))
    497             continue;
    498 
    499         int num;
    500 
    501         sscanf(cheadertitle, &cEND_EVENTS_TEMPLATE[1], &num);
    502 
    503         n += num;
    504     }
    505 
    506     fIn->seekg(0);
    507 
    508     return n;
     527        fIn->seekg(iHEADERTITLELENGTH, ios::cur);
     528        fIn->seekg(sizeof(struct outputpars), ios::cur);
     529
     530        while (1)
     531        {
     532            if (fIn->peek()==cEND_EVENTS_TEMPLATE[0])
     533            {
     534                char cheadertitle[iHEADERTITLELENGTH];
     535                fIn->read(cheadertitle, iHEADERTITLELENGTH);
     536
     537                const TString s = cheadertitle;
     538                if (s.BeginsWith(test))
     539                {
     540                    fIn->seekg(sizeof(struct filterresults), ios::cur);
     541                    nruns++;
     542                    break;
     543                }
     544
     545                fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
     546            }
     547
     548            fIn->seekg(sizeof(struct eventrecord), ios::cur);
     549            if (fIn->eof())
     550                break;
     551            nevts++;
     552        }
     553        *fLog << "." << flush;
     554    }
     555
     556    *fLog << "done." << endl;
     557    *fLog << "Found " << nevts << " events in " << nruns << " runs." << endl;
     558
     559    return nevts;
    509560}
    510561
     
    542593    //  look for the source position in the camera
    543594    //
    544     fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
     595    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "Source");
    545596    if (!fSrcPos)
    546597        return kFALSE;
     
    566617    if (!fMcTrig)
    567618        return kFALSE;
     619
     620    fNumFilterEvts = 0;
     621    fNumRuns       = 0;
    568622
    569623    return kTRUE;
     
    582636     int   isecfrac_200ns;     // fractional part of isecs_since_midday
    583637     short snot_ok_flags;      // the bits in these two bytes are flags for additional information on the event: Everything OK =: all Bits = 0
    584      int   ipreproc_alt_arcs;  // "should be" alt according to preproc (arcseconds)
    585      int   ipreproc_az_arcs;   // "should be" az according to preproc (arcseconds)
    586638
    587639     // for ALT-AZ mount telescopes: rotation angle of the field of
     
    602654     float fhourangle;
    603655     */
    604     /*
    605      *fLog << event.isecs_since_midday << "s ";
    606      *fLog << event.ipreproc_alt_arcs << "s ";
    607      *fLog << event.ipreproc_az_arcs << "s ";
    608      *fLog << event.ifieldrot_arcs << "s ";
    609      *fLog << event.fhourangle << endl;
    610      */
    611656
    612657    //
     
    614659    // too the list with it's id, number of photons and error
    615660    //
    616     fNphot->InitSize(fNumPixels);
     661    fNphot->InitSize(iMAXNUMPIX);
    617662
    618663    // number of photoelectrons measured in each pixel only the
    619664    // actual number of pixels (outputpars.inumpixels) is written out
    620665    // short spixsig_10thphot[iMAXNUMPIX];
    621     for (Int_t i=0; i<fNumPixels; i++)
    622     {
    623         if (event.spixsig_10thphot[i]>0)
    624             fNphot->AddPixel(i, 0.1*event.spixsig_10thphot[i],
    625                              (*fPedest)[i].GetMeanRms());
    626     }
     666    for (Int_t i=0; i<iMAXNUMPIX; i++)
     667    {
     668        if (event.spixsig_10thphot[i]==0)
     669            continue;
     670
     671        fNphot->AddPixel(i, 0.1*event.spixsig_10thphot[i],
     672                         (*fPedest)[i].GetMeanRms());
     673    }
     674    fNphot->SetReadyToSave();
     675
     676    // int ipreproc_alt_arcs; // "should be" alt according to preproc (arcseconds)
     677    // int ipreproc_az_arcs;  // "should be" az according to preproc (arcseconds)
    627678
    628679    fMcEvt->SetTheta(TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600));   // altitude (arcseconds)
    629680    fMcEvt->SetPhi(TMath::Pi()/180*event.iaz_arcs/3600);               // azimuth (arcseconds)
     681
     682    fMcEvt->SetReadyToSave();
    630683
    631684    if (!fIsMcFile)
     
    636689    fMcEvt->SetImpact(event.imcimpact_m*100);    // simulated impact
    637690
    638     fMcTrig->SetFirstLevel(event.imctriggerflag); // MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
     691    fMcTrig->SetFirstLevel(event.imctriggerflag);    // MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
     692    fMcTrig->SetReadyToSave();
    639693
    640694    //float fmcsize_phel;   // Simulated SIZE
     
    655709
    656710    //
    657     // If the first character isn't the first of the footer it must be
    658     // an event
    659     //
    660     if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
    661         return kTRUE;
    662 
    663     //
    664     // Remember the current position if the first character faked a
    665     // footer
    666     //
    667     const Int_t pos = fIn->tellg();
    668 
    669     //
    670     // Try reading the footer. If it isn't succefull jump back...
    671     // must be an event
    672     //
    673     if (!ReadFooter())
    674     {
    675         fIn->seekg(pos, ios::beg);
    676         return kTRUE;
    677     }
    678 
    679     *fLog << inf << "Footer found." << endl;
    680 
    681     //
    682     // No after reading the footer check if we reached the end of the file
    683     //
    684     if (fIn->eof())
    685     {
    686         *fLog << "End of file." << endl;
    687         return kFALSE;
    688     }
    689 
    690     //
    691     // If the eof isn't reached a new header must follow. Check for it.
    692     //
    693     if (fIn->peek()!=cTITLE_TEMPLATE[0])
    694     {
    695         *fLog << inf << "Error finding new run header in file (possible EOF)... skipping rest of file." << endl;
    696         return kFALSE;
    697     }
    698 
    699     *fLog << "-----------------------------------------------------------------------" << endl;
    700     if (ReadHeader())
    701         return kTRUE;
    702 
    703     *fLog << inf << "Error reading run header in file... skipping rest of file." << endl;
    704     return kFALSE;
     711    // Because we can have 0-event runs in the file we loop as often
     712    // as we don't find a new footer-header combination.
     713    //
     714    while (1)
     715    {
     716        //
     717        // If the first character isn't the first of the footer it must be
     718        // an event
     719        //
     720        if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
     721            return kTRUE;
     722
     723        //
     724        // Try reading the footer. If it isn't succefull...
     725        // must be an event
     726        //
     727        if (!ReadRunFooter())
     728            return kTRUE;
     729
     730        *fLog << inf << "Footer found." << endl;
     731
     732        //
     733        // No after reading the footer check if we reached the end of the file
     734        //
     735        if (fIn->eof())
     736        {
     737            *fLog << "End of file." << endl;
     738            return kFALSE;
     739        }
     740
     741        //
     742        // If the eof isn't reached a new header must follow. Check for it.
     743        //
     744        if (fIn->peek()!=cTITLE_TEMPLATE[0])
     745        {
     746            *fLog << inf << "Error finding new run header in file (possible EOF)... skipping rest of file." << endl;
     747            return kFALSE;
     748        }
     749
     750        *fLog << "-----------------------------------------------------------------------" << endl;
     751        if (!ReadRunHeader())
     752            return kTRUE;
     753    }
    705754}
    706755
     
    726775    struct eventrecord event;
    727776
    728     const int size1 = sizeof(event)-sizeof(event.spixsig_10thphot);
    729     const int size2 = sizeof(event.spixsig_10thphot[0])*fNumPixels;
    730 
    731     // read the eventrecord with the recorded number of stored pixels
    732     fIn->read((Byte_t*)&event, size1+size2);
    733 
    734     if (fIn->eof())
    735         return kFALSE;
     777    // read the eventrecord from the file
     778    fIn->read((Byte_t*)&event, sizeof(struct eventrecord));
    736779
    737780    ProcessEvent(event);
    738781
    739     fNumEvent++;
     782    fNumEvents++;
     783    fNumEventsInRun++;
    740784
    741785    return kTRUE;
    742786}
    743787
     788Bool_t MCT1ReadPreProc::PostProcess()
     789{
     790    *fLog << all;
     791    *fLog << "Number events passed the filter: " << fNumFilterEvts << endl;
     792    *fLog << "Number of Events read from file: " << fNumEvents << endl;
     793    *fLog << "Number of Runs read from file:   " << fNumRuns << endl;
     794
     795    if (fNumEvents!=fNumFilterEvts)
     796    {
     797        *fLog << warn << "WARNING! Number of events in file doesn't match number of read events..." << endl;
     798        *fLog << "         File might be corrupt." << endl;
     799    }
     800
     801    return kTRUE;
     802}
  • trunk/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h

    r1583 r1600  
    22#define MARS_MCT1ReadPreProc
    33
    4 #ifndef MARS_MTask
    5 #include "MTask.h"
     4#ifndef MARS_MRead
     5#include "MRead.h"
    66#endif
    77
     
    1818struct eventrecord;
    1919
    20 class MCT1ReadPreProc : public MTask
     20class MCT1ReadPreProc : public MRead
    2121{
    2222private:
    23     ifstream     *fIn;          // the inputfile
    24     MGeomCam     *fGeom;        // camera geometry
    25     MCerPhotEvt  *fNphot;       // the data container for all data.
    26     MPedestalCam *fPedest;      // ct1 pedestals
    27     MMcEvt       *fMcEvt;       // monte carlo data container for MC files
    28     MMcTrig      *fMcTrig;      // mc data container for trigger information
    29     MSrcPosCam   *fSrcPos;      // source position in the camera
    30     TList        *fFileNames;   // Array which stores the \0-terminated filenames
    31     MBlindPixels *fBlinds;      // Array holding blind pixels
     23    ifstream *fIn;          // the inputfile
     24    TList    *fFileNames;   // Array which stores the \0-terminated filenames
    3225
    33     Int_t fNumPixels;
    34     Bool_t fIsMcFile;
     26    MGeomCam     *fGeom;    // camera geometry
     27    MCerPhotEvt  *fNphot;   // the data container for all data.
     28    MPedestalCam *fPedest;  // ct1 pedestals
     29    MMcEvt       *fMcEvt;   // monte carlo data container for MC files
     30    MMcTrig      *fMcTrig;  // mc data container for trigger information
     31    MSrcPosCam   *fSrcPos;  // source position in the camera
     32    MBlindPixels *fBlinds;  // Array holding blind pixels
    3533
    36     UInt_t fNumEvents;
    37     UInt_t fNumEvent;
     34    Bool_t fIsMcFile;       // Flag whether current run is a MC run
     35
     36    UInt_t fNumEvents;      // number of events counted in all runs in all files
     37    UInt_t fNumEventsInRun; // number of events in the counted in th ecurrent run
     38    UInt_t fNumRuns;        // number of processed runs of all files
     39    UInt_t fEntries;        // entries of all files succesfully added
     40    UInt_t fNumFilterEvts;  // number of events mentioned in the runs footers
    3841
    3942    Bool_t OpenNextFile();
     
    4245
    4346    void   ReadPedestals();
    44     Bool_t ReadHeader();
    45     Bool_t ReadFooter();
     47    Bool_t ReadRunHeader();
     48    Bool_t ReadRunFooter();
    4649    Bool_t CheckFilePosition();
    47     void   ProcessHeader(const struct outputpars &outpars);
     50    void   ProcessRunHeader(const struct outputpars &outpars);
    4851    void   ProcessEvent(const struct eventrecord &event);
    4952
    5053public:
    5154    MCT1ReadPreProc(const char *filename=NULL,
    52                   const char *name=NULL,
    53                   const char *title=NULL);
     55                    const char *name=NULL,
     56                    const char *title=NULL);
    5457
    5558    ~MCT1ReadPreProc();
     
    5962    Bool_t PreProcess(MParList *pList);
    6063    Bool_t Process();
     64    Bool_t PostProcess();
     65
     66    UInt_t GetEntries() { return fEntries; }
    6167
    6268    ClassDef(MCT1ReadPreProc, 0)        // Reads the CT1 data file
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r1583 r1600  
    5454MReadMarsFile::MReadMarsFile() : fRun(NULL)
    5555{
    56     fName  = "MReadMarsFile";
     56    fName  = "MRead";
    5757    fTitle = "Task to loop over all events in a tree of a Mars file.";
    5858}
     
    6767    : MReadTree(tname, fname)
    6868{
    69     fName  = name  ? name  : "MReadMarsFile";
     69    fName  = name  ? name  : "MRead";
    7070    fTitle = title ? title : "Task to loop over all events in a tree of a Mars file.";
    7171
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r1583 r1600  
    5555#include <TFile.h>           // TFile::GetName
    5656#include <TSystem.h>         // gSystem->ExpandPath
    57 #include <TGProgressBar.h>
     57//#include <TGProgressBar.h>
    5858#include <TChainElement.h>
    5959#include <TOrdCollection.h>
     
    7575//
    7676MReadTree::MReadTree()
    77     : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
    78 {
    79     fName  = "MReadTree";
     77    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
     78{
     79    fName  = "MRead";
    8080    fTitle = "Task to loop over all events in one single tree";
    8181
     
    9999MReadTree::MReadTree(const char *tname, const char *fname,
    100100                     const char *name, const char *title)
    101     : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
    102 {
    103     fName  = name  ? name  : "MReadTree";
     101    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
     102{
     103    fName  = name  ? name  : "MRead";
    104104    fTitle = title ? title : "Task to loop over all events in one single tree";
    105105
     
    415415    if (TestBit(kChainWasChanged))
    416416    {
     417        *fLog << inf << "Scanning chain... " << flush;
    417418        fNumEntries = (UInt_t)fChain->GetEntries();
     419        *fLog << fNumEntries << " events found." << endl;
    418420        ResetBit(kChainWasChanged);
    419421    }
     
    566568
    567569    //
    568     // If a progress bar is given set its range.
    569     //
    570     if (fProgress)
    571         fProgress->SetRange(0, fNumEntries);
    572 
    573     //
    574570    // Now we can start notifying. Reset tree makes sure, that TChain thinks
    575571    // that the correct file is not yet initialized and reinitilizes it
  • trunk/MagicSoft/Mars/mfileio/MReadTree.h

    r1572 r1600  
    22#define MARS_MReadTree
    33
    4 #ifndef MARS_MTask
    5 #include "MTask.h"
     4#ifndef MARS_MRead
     5#include "MRead.h"
    66#endif
    77
    88class MChain;
    99class TBranch;
    10 class TGProgressBar;
    1110
    12 class MReadTree : public MTask
     11class MReadTree : public MRead
    1312{
    1413private:
     
    2726
    2827private:
    29     TGProgressBar  *fProgress; //! Possible display of status
    30 
    3128    void SetBranchStatus(const TList *list, Bool_t status);
    3229    void SetBranchStatus(TObject *branch, Bool_t status);
     
    5047    void   EnableBranch(const char *name);
    5148    void   VetoBranch(const char *name);
    52 
    53     void   SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
    5449
    5550    Bool_t GetEvent();
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r1583 r1600  
    130130    // - Branches are automatically deleted by the tree destructor
    131131    //
     132
     133    *fLog << inf << "Output File closed and deleted." << endl;
    132134}
    133135
  • trunk/MagicSoft/Mars/mfileio/Makefile

    r1574 r1600  
    3232
    3333SRCFILES = MChain.cc \
     34           MRead.cc \
    3435           MReadTree.cc \
    3536           MReadMarsFile.cc \
  • trunk/MagicSoft/Mars/mfilter/MFEventSelector.cc

    r1589 r1600  
    4040// To get around 2000 events from all events use (Remark: This will only
    4141// work if the parlist has an entry called MTaskList which has a task
    42 // MRTeadTree inheriting from MReadTree):
     42// MRead inheriting from MRead):
    4343//   MFEventSelector sel;
    44 //   sel.SetNumSelectEvents(2000);
     44//   sel.SetNumSelectEvts(2000);
    4545//   MFillH filler(...);
    4646//   filler.SetFilter(&sel);
     
    4848//   tlist.AddToList(&filler);
    4949//
    50 // If you don't have MReadTree available you have to set the number of
     50// If you don't have MRead available you have to set the number of
    5151// total events manually, using sel.SetNumTotalEvts(10732);
    5252//
     
    6767#include "MParList.h"
    6868#include "MTaskList.h"
    69 #include "MReadTree.h"
     69#include "MRead.h"
    7070
    7171#include "MLog.h"
     
    127127            return kFALSE;
    128128        }
    129         MReadTree *read = (MReadTree*)tlist->FindObject("MReadTree");
    130         if (!read)
    131             read = (MReadTree*)tlist->FindObject("MReadMarsFile");
     129        MRead *read = (MRead*)tlist->FindObject("MRead");
    132130        if (!read)
    133131        {
    134             *fLog << err << dbginf << "Sorry can't determin total number of events from 'MReadTree/MReadMarsFile'." << endl;
     132            *fLog << err << dbginf << "Sorry can't determin total number of events from 'MRead'." << endl;
    135133            return kFALSE;
    136134        }
    137135        fNumTotalEvts = read->GetEntries();
     136
     137        SetBit(kNumTotalFromFile);
    138138    }
    139139
     
    166166Bool_t MFEventSelector::PostProcess()
    167167{
     168    if (TestBit(kNumTotalFromFile))
     169        fNumTotalEvts = -1;
    168170    return kTRUE;
    169171}
  • trunk/MagicSoft/Mars/mfilter/MFEventSelector.h

    r1588 r1600  
    2727    void StreamPrimitive(ofstream &out) const;
    2828
     29    enum { kNumTotalFromFile = BIT(14) };
    2930    /*
    3031     enum { kUseFixedRatio=BIT(14) }
     
    3839    Bool_t IsExpressionTrue() const { return fResult; }
    3940
    40     void SetNumTotalEvts(Int_t n) { fNumTotalEvts = n; }
     41    void SetNumTotalEvts(Int_t n) { fNumTotalEvts = n; ResetBit(kNumTotalFromFile); }
    4142    void SetNumSelectEvts(Int_t n) { fNumSelectEvts = n; }
    4243    void SetSelectionRatio(Float_t f) { fSelRatio = f; }
  • trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h

    r1436 r1600  
    55#pragma link off all functions;
    66
     7#pragma link C++ class MGeomPMT+;
     8#pragma link C++ class MGeomMirror+;
    79#pragma link C++ class MGeomPix+;
    810#pragma link C++ class MGeomCam+;
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc

    r1458 r1600  
    237237        //
    238238        for (int i=0; i<ring; i++)
    239             (*this)[pixnum++].Set((-ring+i*0.5)*diameter,
     239            (*this)[pixnum++].Set((ring-i*0.5)*diameter,
    240240                                  i*kS32*diameter,
    241241                                  diameter);
    242242
    243243        for (int i=0; i<ring; i++)
    244             (*this)[pixnum++].Set((-ring*0.5+i)*diameter,
     244            (*this)[pixnum++].Set((ring*0.5-i)*diameter,
    245245                                  ring*kS32 * diameter,
    246246                                  diameter);
    247247
    248248        for (int i=0; i<ring; i++)
     249            (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
     250                                  (ring-i)*kS32*diameter,
     251                                  diameter);
     252
     253        for (int i=0; i<ring; i++)
     254            (*this)[pixnum++].Set((0.5*i-ring)*diameter,
     255                                  -i*kS32*diameter,
     256                                  diameter);
     257
     258        for (int i=0; i<ring; i++)
     259            (*this)[pixnum++].Set((i-ring*0.5)*diameter,
     260                                  -ring*kS32 * diameter,
     261                                  diameter);
     262
     263        for (int i=0; i<ring; i++)
    249264            (*this)[pixnum++].Set((ring+i)*0.5*diameter,
    250                                   (ring-i)*kS32*diameter,
    251                                   diameter);
    252 
    253         for (int i=0; i<ring; i++)
    254             (*this)[pixnum++].Set((ring-0.5*i)*diameter,
    255                                   -i*kS32*diameter,
    256                                   diameter);
    257 
    258         for (int i=0; i<ring; i++)
    259             (*this)[pixnum++].Set((ring*0.5-i)*diameter,
    260                                   -ring*kS32 * diameter,
    261                                   diameter);
    262 
    263         for (int i=0; i<ring; i++)
    264             (*this)[pixnum++].Set((-ring-i)*0.5*diameter,
    265265                                  (-ring+i)*kS32*diameter,
    266266                                  diameter);
  • trunk/MagicSoft/Mars/mgeom/MGeomMirror.cc

    r1596 r1600  
    6969}
    7070
     71// --------------------------------------------------------------------------
     72//
     73// DESCRIPTION MISSING
     74//
    7175void MGeomMirror::SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
    7276                                   Float_t curv_y, Float_t lin_x, Float_t lin_y,
  • trunk/MagicSoft/Mars/mgeom/MGeomMirror.h

    r1596 r1600  
    99{
    1010private:
    11 
    12     Int_t   fMirrorId;       // the Mirror Id
     11    Int_t   fMirrorId;    // the Mirror Id
    1312
    1413    Float_t fFocalDist;   //  focal distance of that mirror [cm]
     
    3332                          // of the spot of a single mirror on the camera plane
    3433public:
    35 
    3634    MGeomMirror(Int_t mir=-1, const char *name=NULL, const char *title=NULL);
    3735
    38     Int_t   GetMirrorId() const         { return fMirrorId;   }
     36    Int_t GetMirrorId() const         { return fMirrorId;   }
    3937
    40     void    SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
    41                           Float_t curv_y, Float_t lin_x, Float_t lin_y,
    42                           Float_t lin_z, Float_t theta, Float_t phi,
    43                           Float_t x_n, Float_t y_n, Float_t z_n,
    44                           Float_t dev_x, Float_t dev_y);
     38    void  SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
     39                           Float_t curv_y, Float_t lin_x, Float_t lin_y,
     40                           Float_t lin_z, Float_t theta, Float_t phi,
     41                           Float_t x_n, Float_t y_n, Float_t z_n,
     42                           Float_t dev_x, Float_t dev_y);
    4543
    4644    ClassDef(MGeomMirror, 1)  // class containing information about the Cerenkov Photons in a pixel
  • trunk/MagicSoft/Mars/mgeom/MGeomPMT.cc

    r1596 r1600  
    3030//
    3131///////////////////////////////////////////////////////////////////////
     32#include "MGeomPMT.h"
    3233
    3334#include "MLog.h"
    3435#include "MLogManip.h"
    35 
    36 #include "MGeomPMT.h"
    3736
    3837ClassImp(MGeomPMT);
     
    4342//
    4443MGeomPMT::MGeomPMT(Int_t pmt, const char *name=NULL, const char *title=NULL)
     44    : fPMTId(pmt), fWavelength(0), fQE(0)
    4545{
    4646    fName  = name  ? name  : "MGeomPMT";
    4747    fTitle = title ? title : "Storage container for  a PMT characteristics";
     48}
     49
     50// --------------------------------------------------------------------------
     51//
     52// DESCRIPTION MISSING
     53//
     54void MGeomPMT::SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe)
     55{
     56    if (fWavelength.GetSize()!=wav.GetSize() ||
     57        fQE.GetSize()!=qe.GetSize())
     58    {
     59        *fLog << err << dbginf << " fWavelength or fQE do not have ";
     60        *fLog << "size of setting arrays" << endl;
     61        return;
     62    }
    4863
    4964    fPMTId = pmt;
    50     fWavelength->Set(0);
    51     fQE->Set(0);
    5265
    53 }
    54 
    55 void MGeomPMT::SetPMTContent(Int_t pmt, TArrayF *wav, TArrayF *qe)
    56 {
    57     fPMTId = pmt;
    58 
    59   if(fWavelength->GetSize()==wav->GetSize() &&
    60      fQE->GetSize()==qe->GetSize()){
    61     wav->Copy(*fWavelength);
    62     qe->Copy(*fQE);
    63   }
    64   else
    65      *fLog<<err << "MGeomPMT::SetPMTContent fWavelength "
    66           <<"and fQE do not have "
    67           <<"size of setting arrays"<<endl;
    68 
     66    fWavelength = wav;
     67    fQE = qe;
    6968}
    7069
  • trunk/MagicSoft/Mars/mgeom/MGeomPMT.h

    r1596 r1600  
    1212{
    1313private:
     14    Int_t   fPMTId;        // the PMT Id
    1415
    15     Int_t   fPMTId;       // the PMT Id
    16 
    17     TArrayF *fWavelength;  // List of wavelength
    18     TArrayF *fQE;          // QE values
     16    TArrayF fWavelength;  // List of wavelength
     17    TArrayF fQE;          // QE values
    1918
    2019public:
     
    2423    Int_t   GetPMTId() const         { return fPMTId;   }
    2524
    26     void    SetArrays(Int_t dim) {fWavelength->Set(dim);fQE->Set(dim);}
     25    void    SetArraySize(Int_t dim) { fWavelength.Set(dim); fQE.Set(dim); }
    2726
    28     void    SetPMTContent(Int_t pmt, TArrayF *wav, TArrayF *qe);
     27    void    SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe);
    2928
    3029    ClassDef(MGeomPMT, 1)  // class containing information about PMTs
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.cc

    r1554 r1600  
    154154    // delete fGeomCam;
    155155
    156     // Maybe harmfull! Don't exchange the order!
    157     if (fIsAllocated && fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    158     {
    159         fDrawingPad->RecursiveRemove(this);
    160         delete fDrawingPad;
    161     }
     156    // Not allocated by MCamDisplay or already deleted by the user
     157    if (!fIsAllocated || !gROOT->GetListOfCanvases()->FindObject(fDrawingPad))
     158        return;
     159
     160    // If it is not already removed make sure that nothing of this object
     161    // maybe be deleted automatically by the canvas destructor
     162    if (!fDrawingPad->GetListOfPrimitives()->FindObject(this))
     163        return;
     164
     165    fDrawingPad->RecursiveRemove(this);
     166    delete fDrawingPad;
    162167}
    163168
  • trunk/MagicSoft/Mars/mhist/MHFadcCam.cc

    r1303 r1600  
    112112    return kTRUE;
    113113}
     114
     115void MHFadcCam::ResetHistograms()
     116{
     117    for (Int_t i=0; i<577; i++)
     118    {
     119        GetHistHi(i)->Reset();
     120        GetHistLo(i)->Reset();
     121    }
     122}
  • trunk/MagicSoft/Mars/mhist/MHFadcCam.h

    r1208 r1600  
    3636    Bool_t Fill(const MParContainer *par);
    3737
     38    void ResetHistograms();
     39
    3840    //
    3941    // FIXME! This should be replaced by a Draw(Option_t)-function
  • trunk/MagicSoft/Mars/mhist/MHMatrix.cc

    r1593 r1600  
    614614    return fData ? fData->GetDataMember() : TString("");
    615615}
     616
     617// --------------------------------------------------------------------------
     618//
     619// Return a comma seperated list of all data members used in the matrix.
     620// This is mainly used in MTask::AddToBranchList
     621//
     622void MHMatrix::ReduceNumberOfRows(UInt_t numrows, const TString opt)
     623{
     624    UInt_t rows = fM.GetNrows();
     625
     626    if (rows==numrows)
     627    {
     628        *fLog << warn << "Matrix has already the correct number of rows..." << endl;
     629        return;
     630    }
     631
     632    Float_t ratio = (Float_t)numrows/fM.GetNrows();
     633
     634    if (ratio>=1)
     635    {
     636        *fLog << warn << "Matrix cannot be enlarged..." << endl;
     637        return;
     638    }
     639
     640    Double_t sum = 0;
     641
     642    UInt_t oldrow = 0;
     643    UInt_t newrow = 0;
     644
     645    while (oldrow<rows)
     646    {
     647        sum += ratio;
     648
     649        if (newrow<=(unsigned int)sum)
     650        {
     651            TVector vold(fM.GetNcols());
     652            vold = TMatrixRow(fM, oldrow);
     653
     654            TMatrixRow rownew(fM, newrow);
     655            rownew = vold;
     656            newrow++;
     657        }
     658
     659        oldrow++;
     660    }
     661
     662/*
     663
     664    TMatrix m(n, fM.GetNcols());
     665    for (int i=0; i<n; i++)
     666    {
     667        TVector vold(n);
     668        vold = TMatrixRow(fM, idx[i]);
     669
     670        TMatrixRow rownew(m, i);
     671        rownew = vold;
     672    }
     673*/
     674
     675}
  • trunk/MagicSoft/Mars/mhist/MHMatrix.h

    r1574 r1600  
    2929    TMatrix fM;         // Matrix to be filled
    3030
    31     TMatrix fM2;        //!
     31    TMatrix fM2;        //! Covariance Matrix
    3232
    3333    MDataArray *fData;  // List of data members (columns)
     
    8989    TString GetDataMember() const;
    9090
     91    void ReduceNumberOfRows(UInt_t numrows, const TString opt);
     92
    9193    ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
    9294};
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.cc

    r1597 r1600  
    3535//
    3636////////////////////////////////////////////////////////////////////////////
    37 
    38 #ifndef MARS_MMcConfigRunHeader
    3937#include "MMcConfigRunHeader.h"
    40 #endif
    4138
    4239#include <fstream.h>
    4340#include <iomanip.h>
    4441
     42#include <TArrayF.h>
     43
    4544#include "MLog.h"
    4645#include "MLogManip.h"
     46
    4747ClassImp(MMcConfigRunHeader);
    4848
     
    5353//
    5454MMcConfigRunHeader::MMcConfigRunHeader(const char *name, const char *title)
     55    : fNumMirrors(0), fNumPMTs(0), fIncidentTheta(181), fLightGuidesFactor(181)
    5556{
    5657    fName  = name  ? name  : "MMcConfigRunHeader";
    5758    fTitle = title ? title : "Mc Configuration Information";
    5859
    59     fNumMirrors=0;
    60     fNumPMTs=0;
    61 
    62     fRadiusMirror=-10.0;
    63     fFocalDist=-10.0;
    64     fFocalStdev=-10.0;
    65     fPointSpread=-10.0;
    66     fPointStdev=-10.0;
    67     fDevAdjust=-10.0;
    68     fBlackSpot=-10.0;
    69     fCameraWidth=-10.0;
    70 
    71     fIncidentTheta->Set(181);
    72     fLightGuidesFactor->Set(181);
     60    fRadiusMirror=-1;
     61    fFocalDist   =-1;
     62    fFocalStdev  =-1;
     63    fPointSpread =-1;
     64    fPointStdev  =-1;
     65    fDevAdjust   =-1;
     66    fBlackSpot   =-1;
     67    fCameraWidth =-1;
    7368
    7469    fMirrors = new TClonesArray("MGeomMirror", 0);
     
    7772}
    7873
    79 // -------------------------------------------------------------------------
     74// --------------------------------------------------------------------------
    8075//
    81 // SetMagicDef
     76// DESCRIPTION MISSING
    8277//
    8378void MMcConfigRunHeader::SetMagicDef(const Float_t  radius,
     
    10196}
    10297
    103 void  MMcConfigRunHeader::SetLightGuides(TArrayF *theta, TArrayF *factor){
    104  
    105   if(fIncidentTheta->GetSize()==theta->GetSize() &&
    106      fLightGuidesFactor->GetSize()==factor->GetSize()){
    107     theta->Copy(*fIncidentTheta);
    108     factor->Copy(*fLightGuidesFactor);
    109   }
    110   else
    111     *fLog<<err << "MMcConfigRunHeader::SetLightGuides: fIncidentTheta "
    112         <<"and fLightGuidesFactor do not have "
    113         <<"size of setting arrays"<<endl;
     98// --------------------------------------------------------------------------
     99//
     100// DESCRIPTION MISSING
     101//
     102void  MMcConfigRunHeader::SetLightGuides(const TArrayF &theta, const TArrayF &factor)
     103{
     104    if (fIncidentTheta.GetSize()    !=theta.GetSize() ||
     105        fLightGuidesFactor.GetSize()!=factor.GetSize())
     106    {
     107        *fLog<< err << dbginf << "fIncidentTheta or fLightGuidesFactor ";
     108        *fLog << "do not have size of setting arrays" << endl;
     109        return;
     110    }
    114111
     112    fIncidentTheta = theta;
     113    fLightGuidesFactor = factor;
    115114}
    116 
    117 
    118 
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.h

    r1596 r1600  
    55#include <TClonesArray.h>
    66#endif
    7 #ifndef ROOT_TArrayF
    8 #include <TArrayF.h>
    9 #endif
     7
    108#ifndef MARS_MGeomMirror
    119#include "MGeomMirror.h"
    1210#endif
    13 
    1411#ifndef MARS_MGeomPMT
    1512#include "MGeomPMT.h"
     
    2320private:
    2421    // Mirror Information
    25     UShort_t        fNumMirrors;
     22    UShort_t      fNumMirrors;
    2623    Float_t       fRadiusMirror;// [cm] Radius of a single mirror
    2724    TClonesArray *fMirrors;     // FIXME: Change TClonesArray away from a pointer?
     
    4239
    4340    // Light Guides Information
    44     TArrayF *fIncidentTheta;    // [deg]
    45     TArrayF *fLightGuidesFactor;// []
     41    TArrayF fIncidentTheta;    // [deg]
     42    TArrayF fLightGuidesFactor;// []
    4643
    4744public:
     
    5148    void SetMagicDef(Float_t radius, Float_t focal, Float_t stdfocal, Float_t point,
    5249                     Float_t stdpoint, Float_t adjust, Float_t spot, Float_t camwidth);
    53     void SetLightGuides(TArrayF *theta, TArrayF *factor);
     50    void SetLightGuides(const TArrayF &theta, const TArrayF &factor);
    5451
    5552    UInt_t GetNumMirror() const { return fNumMirrors; }
  • trunk/MagicSoft/include-Classes/MMcFormat/McLinkDef.h

    r1243 r1600  
    1010#pragma link C++ class MMcTrigHeader+;
    1111#pragma link C++ class MMcFadcHeader+;
     12#pragma link C++ class MMcConfigRunHeader+;
    1213
    1314#endif
Note: See TracChangeset for help on using the changeset viewer.