Ignore:
Timestamp:
10/12/04 11:11:50 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r5161 r5233  
    8888// Default constructor.
    8989//
    90 // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
     90// Sets:
     91// - fRuns to 0,
     92// - fExtractor to NULL,
     93// - fDataCheck to kFALSE,
     94// - fUseData to kFALSE
     95// - fStorage to kNormalStorage
    9196//
    9297MJPedestal::MJPedestal(const char *name, const char *title)
     
    9499      fDataCheck(kFALSE), fUseData(kFALSE)
    95100{
    96     fName  = name  ? name  : "MJPedestal";
    97     fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
     101
     102  fName  = name  ? name  : "MJPedestal";
     103  fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
     104 
     105  SetNormalStorage();
    98106}
    99107
     
    109117}
    110118
     119//---------------------------------------------------------------------------------
     120//
     121// Try to read an existing MPedestalCam from a previously created output file.
     122// If found, also an MBadPixelsCam and the corresponding display is read.
     123//
     124// In case of Storage type "kNoStorage" or if the file is not found or the
     125// MPedestalCam cannot be read, return kFALSE, otherwise kTRUE.
     126//
    111127Bool_t MJPedestal::ReadPedestalCam()
    112128{
    113     const TString fname = GetOutputFile();
    114 
    115     if (gSystem->AccessPathName(fname, kFileExists))
    116     {
    117         *fLog << warn << "Input file " << fname << " doesn't exist, will create it." << endl;
    118         return kFALSE;
    119     }
    120 
    121     *fLog << inf << "Reading from file: " << fname << endl;
    122 
    123     TFile file(fname, "READ");
    124     if (fPedestalCam.Read()<=0)
    125     {
    126         *fLog << err << "Unable to read MPedestalCam from " << fname << endl;
    127         return kFALSE;
    128     }
    129 
    130     if (file.FindKey("MBadPixelsCam"))
    131     {
    132         MBadPixelsCam bad;
     129
     130  if (IsNoStorage())
     131    return kFALSE;
     132 
     133  const TString fname = GetOutputFile();
     134 
     135  if (gSystem->AccessPathName(fname, kFileExists))
     136    {
     137      *fLog << warn << "Input file " << fname << " doesn't exist, will create it." << endl;
     138      return kFALSE;
     139    }
     140 
     141  *fLog << inf << "Reading from file: " << fname << endl;
     142 
     143  TFile file(fname, "READ");
     144  if (fPedestalCam.Read()<=0)
     145    {
     146      *fLog << err << "Unable to read MPedestalCam from " << fname << endl;
     147      return kFALSE;
     148    }
     149 
     150  if (file.FindKey("MBadPixelsCam"))
     151    {
     152      MBadPixelsCam bad;
    133153        if (bad.Read()<=0)
    134         {
     154          {
    135155            *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
    136156            return kFALSE;
    137         }
     157          }
    138158        fBadPixels.Merge(bad);
    139159    }
    140160
    141     if (fDisplay && !fDisplay->GetCanvas("Pedestals"))
    142         fDisplay->Read();
    143 
    144     return kTRUE;
    145 }
    146 
     161  if (fDisplay && !fDisplay->GetCanvas("Pedestals"))
     162    fDisplay->Read();
     163 
     164  return kTRUE;
     165}
     166
     167//---------------------------------------------------------------------------------
     168//
     169// Display the results.
     170// If Display type "kDataCheck" was chosen, also the reference lines are displayed.
     171//
    147172void MJPedestal::DisplayResult(MParList &plist)
    148173{
     
    480505}
    481506
     507//---------------------------------------------------------------------------------
     508//
     509// Try to write the created MPedestalCam in the output file.
     510// If possible, also an MBadPixelsCam and the corresponding display is written.
     511//
     512// In case of Storage type "kNoStorage" or if any of the containers
     513// cannot be written, return kFALSE, otherwise kTRUE.
     514//
    482515Bool_t MJPedestal::WriteResult()
    483516{
    484     if (fPathOut.IsNull())
    485         return kTRUE;
    486 
    487     const TString oname(GetOutputFile());
    488 
    489     *fLog << inf << "Writing to file: " << oname << endl;
    490 
    491     TFile file(oname, "UPDATE", "File created by MJPedestal", 9);
    492     if (!file.IsOpen())
    493     {
    494         *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
    495         return kFALSE;
    496     }
    497 
    498     if (fDisplay && fDisplay->Write()<=0)
    499     {
    500         *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
    501         return kFALSE;
    502     }
    503 
    504     if (fPedestalCam.Write()<=0)
    505     {
    506         *fLog << err << "Unable to write MPedestalCam to " << oname << endl;
    507         return kFALSE;
    508     }
    509 
    510     if (fBadPixels.Write()<=0)
    511     {
    512         *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
    513         return kFALSE;
    514     }
    515 
     517 
     518  if (IsNoStorage())
    516519    return kTRUE;
     520
     521  if (fPathOut.IsNull())
     522    return kTRUE;
     523 
     524  const TString oname(GetOutputFile());
     525 
     526  *fLog << inf << "Writing to file: " << oname << endl;
     527
     528  TFile file(oname, "UPDATE", "File created by MJPedestal", 9);
     529  if (!file.IsOpen())
     530    {
     531      *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
     532      return kFALSE;
     533    }
     534 
     535  if (fDisplay && fDisplay->Write()<=0)
     536    {
     537      *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
     538      return kFALSE;
     539    }
     540
     541  if (fPedestalCam.Write()<=0)
     542    {
     543      *fLog << err << "Unable to write MPedestalCam to " << oname << endl;
     544      return kFALSE;
     545    }
     546
     547  if (fBadPixels.Write()<=0)
     548    {
     549      *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
     550      return kFALSE;
     551    }
     552
     553  return kTRUE;
    517554}
    518555
Note: See TracChangeset for help on using the changeset viewer.