Changeset 6078 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
01/28/05 11:18:44 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r6077 r6078  
    3232       the loop.
    3333
     34
     35
    3436 2005/01/28 Thomas Bretz
    3537
     
    4446     - added comment for obsolete resources as discussed yesterday
    4547       evening: TimeUpperLimit
     48
     49   * mbase/MMath.[h,cc], manalysis/MCerPhotPix.[h,cc],
     50     mpedestal/MPedPhotPix.h:
     51     - replaced TruncatePrecision by ReducePrecision (its simply a better
     52       name)
     53
     54   * mbase/MParList.cc:
     55     - added a check to make 200%(!) sure that the container added
     56       to the list is a MParContainer (everything else could crash
     57       almost everything in Mars!)
     58
     59   * mjobs/MJCalibrateSignal.cc, mjobs/MJCalibration.[h,cc],
     60     mjobs/MJPedestal.cc:
     61     - simplified the code in the WriteResult functions by using
     62       the new WriteContainer in MJob
     63     - removed the TObjArray from the MParList! It is NOT a MParContainer
     64       there are a lot of circumstance how this can crash Mars. I don't
     65       know why the compiler allowed for this.
     66     - unified WriteResult and WriteHists
     67     - split GetOutputFile into two functions for simplification
     68
     69   * mjobs/MJCalibration.h:
     70     - copy the extractorcam name when copying the contents
     71
     72   * mjobs/MJob.[h,cc]:
     73     - new member function WriteContainer to simplify code in derived
     74       classes
    4675
    4776
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.cc

    r6034 r6078  
    7878    fIsSaturated(kFALSE), fIsHGSaturated(kFALSE)
    7979{
    80     MMath::TruncatePrecision(fPhot);
    81     MMath::TruncatePrecision(fErrPhot);
     80    MMath::ReducePrecision(fPhot);
     81    MMath::ReducePrecision(fErrPhot);
    8282}
    8383
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h

    r6034 r6078  
    4848    Bool_t  IsPixelCore() const         { return fIsCore;  }
    4949
    50     void    SetNumPhotons(Float_t f)    { MMath::TruncatePrecision(f); fPhot     = f; }
    51     void    SetErrorPhot(Float_t f)     { MMath::TruncatePrecision(f); fErrPhot = f; }
    52     void    Set(Float_t np, Float_t ep) { MMath::TruncatePrecision(np); MMath::TruncatePrecision(ep);  fPhot = np; fErrPhot = ep; }
     50    void    SetNumPhotons(Float_t f)    { MMath::ReducePrecision(f); fPhot     = f; }
     51    void    SetErrorPhot(Float_t f)     { MMath::ReducePrecision(f); fErrPhot = f; }
     52    void    Set(Float_t np, Float_t ep) { MMath::ReducePrecision(np); MMath::ReducePrecision(ep);  fPhot = np; fErrPhot = ep; }
    5353
    5454    void    SetPixelSaturated()         { fIsSaturated = kTRUE; }
  • trunk/MagicSoft/Mars/mbase/MMath.cc

    r5956 r6078  
    137137// --------------------------------------------------------------------------
    138138//
    139 // This function truncates the precision to roughly 0.5% of a Float_t by
     139// This function reduces the precision to roughly 0.5% of a Float_t by
    140140// changing its bit-pattern (Be carefull, in rare cases this function must
    141141// be adapted to different machines!). This is usefull to enforce better
    142142// compression by eg. gzip.
    143143//
    144 void MMath::TruncatePrecision(Float_t &val)
     144void MMath::ReducePrecision(Float_t &val)
    145145{
    146146    UInt_t &f = (UInt_t&)val;
  • trunk/MagicSoft/Mars/mbase/MMath.h

    r5956 r6078  
    1818    Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1);
    1919
    20     void TruncatePrecision(Float_t &val);
     20    void ReducePrecision(Float_t &val);
    2121
    2222    TVector3 GetParab(const TVector3 &x, const TVector3 &y);
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r5911 r6078  
    216216    }
    217217
     218    if (!cont->InheritsFrom(MParContainer::Class()))
     219    {
     220        *fLog << dbginf << "Error: Cantainer MUST derive from MParContainer!" << endl;
     221        return kFALSE;
     222    }
     223
    218224    *fLog << inf << "Adding " << name << " to " << GetName() << "... " << flush;
    219225
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r6077 r6078  
    126126Bool_t MJCalibrateSignal::WriteResult(TObjArray &cont)
    127127{
    128     if (fPathOut.IsNull())
    129     {
    130         *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
    131         return kTRUE;
    132     }
    133 
    134     const TString oname = Form("%s/signal%08d.root", (const char*)fPathOut, fSequence.GetSequence());
    135 
    136     *fLog << inf << "Writing to file: " << oname << endl;
    137 
    138     TFile file(oname, "RECREATE");
    139 
    140     *fLog << inf << " - MStatusDisplay..." << flush;
    141     if (fDisplay && fDisplay->Write()<=0)
    142     {
    143         *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
    144         return kFALSE;
    145     }
    146     *fLog << inf << "ok." << endl;
    147 
    148     return fIsInterlaced ? WriteContainer(cont) : kTRUE;
     128    const TString name(Form("signal%08d.root", fSequence.GetSequence()));
     129    return WriteContainer(cont, name);
    149130}
    150131
     
    272253    MBadPixelsIntensityCam              ibdcam;
    273254
    274     TObjArray interlacedcont;
    275     interlacedcont.Add(&ichcam);
    276     interlacedcont.Add(&iqecam);
    277     interlacedcont.Add(&iblcam);
    278     interlacedcont.Add(&itmcam);
    279     interlacedcont.Add(&ibdcam);
    280 
    281255    MHCalibrationChargeCam      hchacam;
    282256    MHCalibrationChargeBlindCam hbndcam;
    283257    MHCalibrationChargePINDiode hpndiod;
    284258    MHCalibrationRelTimeCam     hrelcam;
    285 
    286     interlacedcont.Add(&hchacam);
    287     interlacedcont.Add(&hbndcam);
    288     interlacedcont.Add(&hpndiod);
    289     if (fIsRelTimesUpdate)
    290       interlacedcont.Add(&hrelcam);
    291259
    292260    MCalibrationChargeCam      calcam;
     
    297265    MCalibrationHiLoCam        hilcam;
    298266
    299     if (fIsHiLoCalibration)
    300       interlacedcont.Add(&hilcam);     
    301 
    302267    MBadPixelsCam              badpix;
    303268
     
    351316    plist.AddToList(&calibcont);
    352317    plist.AddToList(&hilcam);
    353 
    354     if (fIsInterlaced)
    355       plist.AddToList(&interlacedcont);
    356318
    357319    // Setup Tasklist
     
    739701    DisplayResult(plist);
    740702
     703    TObjArray interlacedcont;
     704    if (fIsInterlaced)
     705    {
     706        interlacedcont.Add(&ichcam);
     707        interlacedcont.Add(&iqecam);
     708        interlacedcont.Add(&iblcam);
     709        interlacedcont.Add(&itmcam);
     710        interlacedcont.Add(&ibdcam);
     711        interlacedcont.Add(&hchacam);
     712        interlacedcont.Add(&hbndcam);
     713        interlacedcont.Add(&hpndiod);
     714        if (fIsRelTimesUpdate)
     715            interlacedcont.Add(&hrelcam);
     716        if (fIsHiLoCalibration)
     717            interlacedcont.Add(&hilcam);
     718    }
     719
    741720    if (!WriteResult(interlacedcont))
    742721        return kFALSE;
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r6065 r6078  
    13461346const char* MJCalibration::GetOutputFile() const
    13471347{
     1348    const TString name(GetOutputFileName());
     1349    if (name.IsNull())
     1350        return "";
     1351
     1352    return Form("%s/%s", fPathOut.Data(), name.Data());
     1353}
     1354
     1355const char* MJCalibration::GetOutputFileName() const
     1356{
    13481357    if (fSequence.IsValid())
    1349         return Form("%s/calib%08d.root", (const char*)fPathOut, fSequence.GetSequence());
     1358        return Form("calib%08d.root", fSequence.GetSequence());
    13501359    if (!fRuns)
    13511360        return "";
    13521361
    1353     return Form("%s/%s-F1.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
     1362    return Form("%s-F1.root", (const char*)fRuns->GetRunsAsFileName());
    13541363}
    13551364
     
    18141823    DisplayResult(plist);
    18151824
    1816     if (!IsNoStorage())
    1817       if (!WriteResult(plist.FindObject("MGeomCam")))
     1825    if (!WriteResult(plist))
    18181826        return kFALSE;
    18191827
    1820     if (IsHistsStorage())
    1821       {
    1822         if (!WriteHists(plist))
    1823           return kFALSE;
    1824       }
    1825    
    18261828    *fLog << all << GetDescriptor() << ": Done." << endl;
    18271829
     
    19091911}
    19101912
     1913/*
    19111914Bool_t MJCalibration::WriteEventloop(MEvtLoop &evtloop) const
    19121915{
    1913 
    1914   if (IsNoStorage())
    1915     return kTRUE;
     1916    if (IsNoStorage())
     1917        return kTRUE;
    19161918
    19171919  if (fPathOut.IsNull())
     
    19241926  TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
    19251927  if (!file.IsOpen())
    1926     {
     1928  {
    19271929      *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    19281930      return kFALSE;
    1929     }
    1930  
     1931  }
     1932
    19311933  if (evtloop.Write(fName)<=0)
    1932     {
     1934  {
    19331935      *fLog << err << "Unable to write MEvtloop to " << oname << endl;
    1934         return kFALSE;
    1935     }
     1936      return kFALSE;
     1937  }
    19361938 
    19371939  return kTRUE;
    19381940}
     1941*/
    19391942
    19401943Bool_t MJCalibration::WriteTasks(MTask *t1, MTask *t2) const
     
    19431946        return kTRUE;
    19441947
    1945     if (fPathOut.IsNull())
    1946         return kTRUE;
    1947 
    1948     const TString oname(GetOutputFile());
    1949 
    1950     *fLog << inf << "Writing to file: " << oname << endl;
    1951 
    1952     TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
    1953     if (!file.IsOpen())
    1954     {
    1955         *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    1956         return kFALSE;
    1957     }
    1958 
     1948    TObjArray cont;
    19591949    if (t1)
    1960     {
    1961         *fLog << inf << " - Writing Task " << t1->GetName() << " [" << t1->ClassName() << "]..." << flush;
    1962         if (t1->Write()<=0)
    1963         {
    1964             *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
    1965             return kFALSE;
    1966         }
    1967         *fLog << "ok." << endl;
    1968     }
    1969 
     1950        cont.Add(t1);
    19701951    if (t2)
    1971     {
    1972         *fLog << inf << " - Writing Task " << t2->GetName() << " [" << t2->ClassName() << "]..." << flush;
    1973         if (t2->Write()<=0)
    1974         {
    1975             *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
    1976             return kFALSE;
    1977         }
    1978         *fLog << "ok." << endl;
    1979     }
    1980 
    1981     return kTRUE;
     1952        cont.Add(t2);
     1953
     1954    return WriteContainer(cont, GetOutputFileName(), fOverwrite?"RECREATE":"NEW");
    19821955}
    19831956
     
    19961969// - MCalibrationRelTimeCam or MCalibrationIntensityRelTimeCam     
    19971970//
    1998 Bool_t MJCalibration::WriteResult(TObject *geom)
     1971Bool_t MJCalibration::WriteResult(MParList &plist)
    19991972{
    2000     if (fPathOut.IsNull())
    2001     {
    2002         *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
    2003         return kTRUE;
    2004     }
    2005 
    2006     const TString oname(GetOutputFile());
    2007 
    2008     *fLog << inf << "Writing to file: " << oname << endl;
    2009 
    2010     TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
    2011     if (!file.IsOpen())
    2012     {
    2013         *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    2014         return kFALSE;
    2015     }
    2016 
    20171973    TObjArray cont;
    2018     if (fDisplay)
    2019         cont.Add(fDisplay);
    2020 
    2021     if (IsIntensity())
    2022     {
    2023         cont.Add(&fIntensBadCam);
    2024         cont.Add(&fIntensCalibCam);
    2025         cont.Add(&fIntensQECam);
    2026         cont.Add(&fIntensBlindCam);
    2027     }
    2028     else
    2029     {
    2030         cont.Add(&fBadPixels);
    2031         cont.Add(&fCalibrationCam);
    2032         cont.Add(&fQECam);
    2033         cont.Add(&fCalibrationBlindCam);
    2034     }
    2035     cont.Add(&fCalibrationPINDiode);
    2036 
    2037     //if (IsRelTimes())
    2038     cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
    2039 
    2040     if (!geom)
    2041         *fLog << warn << " - WARNING - MGeomCam... not found!" << endl;
    2042     else
    2043         cont.Add(geom);
    2044 
    2045     return WriteContainer(cont);
    2046 }
    2047 
    2048 // --------------------------------------------------------------------------
    2049 //
    2050 // Write the calibration histograms into the output file GetOutputFile(),
    2051 // if fOutputPath exists.
    2052 //
    2053 // The following containers are written:
    2054 // - MHCalibrationChargeCam
    2055 // - MHCalibrationChargeBlindCam
    2056 // - MHCalibrationChargePINDiode
    2057 // If the flag kRelTimes is set, then also:
    2058 // - MHCalibrationRelTimeBlindCam
    2059 //
    2060 Bool_t MJCalibration::WriteHists(MParList &plist)
    2061 {
    2062     if (fPathOut.IsNull())
    2063         return kTRUE;
    2064 
    2065     const TString oname(GetOutputFile());
    2066 
    2067     *fLog << inf << "Writing to file: " << oname << endl;
    2068 
    2069     TFile file(oname, "UPDATE", "File created by MJCalibration", 9);
    2070     if (!file.IsOpen())
    2071     {
    2072         *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    2073         return kFALSE;
    2074     }
    2075 
    2076     TObjArray cont;
    2077     cont.Add(plist.FindObject("MHCalibrationChargeCam"));
    2078     cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
    2079     cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
    2080     if (IsRelTimes())
    2081         cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
    2082 
    2083     return WriteContainer(cont);
     1974
     1975    if (!IsNoStorage())
     1976    {
     1977        if (IsIntensity())
     1978        {
     1979            cont.Add(&fIntensBadCam);
     1980            cont.Add(&fIntensCalibCam);
     1981            cont.Add(&fIntensQECam);
     1982            cont.Add(&fIntensBlindCam);
     1983        }
     1984        else
     1985        {
     1986            cont.Add(&fBadPixels);
     1987            cont.Add(&fCalibrationCam);
     1988            cont.Add(&fQECam);
     1989            cont.Add(&fCalibrationBlindCam);
     1990        }
     1991        cont.Add(&fCalibrationPINDiode);
     1992
     1993        //if (IsRelTimes())
     1994        cont.Add(IsIntensity() ? (TObject*)&fIntensRelTimeCam : (TObject*)&fRelTimeCam);
     1995
     1996        TObject *geom = plist.FindObject("MGeomCam");
     1997        if (!geom)
     1998            *fLog << warn << " - WARNING - MGeomCam... not found for writing!" << endl;
     1999        else
     2000            cont.Add(geom);
     2001    }
     2002
     2003    if (IsHistsStorage())
     2004    {
     2005        cont.Add(plist.FindObject("MHCalibrationChargeCam"));
     2006        cont.Add(plist.FindObject("MHCalibrationChargeBlindCam"));
     2007        cont.Add(plist.FindObject("MHCalibrationChargePINDiode"));
     2008        if (IsRelTimes())
     2009            cont.Add(plist.FindObject("MHCalibrationRelTimeCam"));
     2010    }
     2011
     2012    return WriteContainer(cont, GetOutputFileName(), "UPDATE");
    20842013}
    20852014
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.h

    r6065 r6078  
    160160  void   FixDataCheckHist     ( TH1D     *hist  ) const;
    161161 
    162   Bool_t WriteResult   ( TObject *geom );
    163   Bool_t WriteHists    ( MParList &plist );
    164   Bool_t WriteEventloop( MEvtLoop &evtloop   ) const;
     162  Bool_t WriteResult   (MParList &plist);
     163  //Bool_t WriteEventloop( MEvtLoop &evtloop   ) const;
    165164  Bool_t WriteTasks    ( MTask *t1, MTask *t2) const;
    166165  Bool_t CheckEnvLocal ();
     
    169168  void   InitBlindPixel(MExtractBlindPixel &blindext,
    170169                        MHCalibrationChargeBlindCam &blindcam);
     170
     171  const char* GetOutputFileName() const;
    171172 
    172173public:
     
    189190  void SetColor        ( const MCalibrationCam::PulserColor_t color) { fColor = color;       }
    190191  void SetExtractor    ( MExtractor* ext)                            { fExtractor = ext;     }
    191   void SetExtractorCam ( const MPedestalCam  &ped)                   { ped.Copy(fExtractorCam);
     192  void SetExtractorCam ( const MPedestalCam  &ped)                   { ped.Copy(fExtractorCam); fExtractorCam.SetName(ped.GetName()); }
    192193  void SetInput        ( MRunIter *iter)                             { fRuns = iter;         }
    193194  void SetQECam        ( const MCalibrationQECam &qe)                { qe.Copy(fQECam);      }
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r6063 r6078  
    141141const char* MJPedestal::GetOutputFile() const
    142142{
     143    const TString name(GetOutputFileName());
     144    if (name.IsNull())
     145        return "";
     146
     147    return Form("%s/%s", fPathOut.Data(), name.Data());
     148}
     149
     150const char* MJPedestal::GetOutputFileName() const
     151{
    143152    if (fSequence.IsValid())
    144         return Form("%s/pedest%08d.root", (const char*)fPathOut, fSequence.GetSequence());
     153        return Form("pedest%08d.root", fSequence.GetSequence());
    145154
    146155    if (!fRuns)
    147156        return "";
    148157
    149     return Form("%s/%s-F0.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
     158    return Form("%s-F0.root", (const char*)fRuns->GetRunsAsFileName());
    150159}
    151160
     
    785794        return kTRUE;
    786795
    787     if (fPathOut.IsNull())
    788     {
    789         *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
    790         return kTRUE;
    791     }
    792 
    793     const TString oname(GetOutputFile());
    794 
    795     *fLog << inf << "Writing to file: " << oname << endl;
    796 
    797     TFile file(oname, "UPDATE", "File created by MJPedestal", 9);
    798     if (!file.IsOpen())
    799     {
    800         *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    801         return kFALSE;
    802     }
    803 
    804796    TObjArray cont;
    805 
    806     if (fDisplay)
    807         cont.Add(fDisplay);
    808797
    809798    cont.Add(&fPedestalCamOut);
    810799    cont.Add(&fBadPixels);
    811800
    812     return WriteContainer(cont);
     801    return WriteContainer(cont, GetOutputFileName(), fOverwrite?"RECREATE":"NEW");
    813802}
    814803
  • trunk/MagicSoft/Mars/mjobs/MJob.cc

    r5557 r6078  
    3535#include <TFile.h>
    3636#include <TSystem.h>
     37#include <TObjArray.h>
    3738
    3839#include "MIter.h"
     
    173174}
    174175
     176//------------------------------------------------------------------------
     177//
     178// Write containers in list to gFile. Returns kFALSE if no gFile or any
     179// container couldn't be written. kTRUE otherwise.
     180//
    175181Bool_t MJob::WriteContainer(TCollection &list) const
    176182{
     
    196202}
    197203
     204//------------------------------------------------------------------------
     205//
     206// Read containers in list into list from gFile
     207// Returns kFALSE if no gFile or any container couldn't be read.
     208//
    198209Bool_t MJob::ReadContainer(TCollection &list) const
    199210{
     
    218229    return kTRUE;
    219230}
     231
     232//------------------------------------------------------------------------
     233//
     234// Write containers in cont (and - if available) the status display to
     235// fPathOut+"/"+name
     236//
     237Bool_t MJob::WriteContainer(TCollection &cont, const char *name, const char *option, const int compr) const
     238{
     239    if (fPathOut.IsNull())
     240    {
     241        *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
     242        return kTRUE;
     243    }
     244
     245    TString oname(fPathOut);
     246    oname += "/";
     247    oname += name;
     248
     249    *fLog << inf << "Writing to file: " << oname << endl;
     250
     251    TString title("File Written by ");
     252    title += fName;
     253
     254    TFile file(oname, option, title, compr);
     255    if (!file.IsOpen())
     256    {
     257        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
     258        return kFALSE;
     259    }
     260
     261    if (fDisplay)
     262        cont.Add((TObject*)(fDisplay));
     263
     264    return WriteContainer(cont);
     265}
  • trunk/MagicSoft/Mars/mjobs/MJob.h

    r5957 r6078  
    4444    Bool_t WriteContainer(TCollection &list) const;
    4545    Bool_t ReadContainer(TCollection &list) const;
     46    Bool_t WriteContainer(TCollection &cont, const char *name, const char *option="RECREATE", const int compr=2) const;
    4647
    4748public:
Note: See TracChangeset for help on using the changeset viewer.