Ignore:
Timestamp:
10/12/04 11:11:50 (20 years ago)
Author:
gaug
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
2 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
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.h

    r5168 r5233  
    2323{
    2424private:
    25     static const Double_t fgPedestalMin;
    26     static const Double_t fgPedestalMax;
    27     static const Double_t fgPedRmsMin;
    28     static const Double_t fgPedRmsMax;
    2925
    30     static const Float_t  fgRefPedClosedLids;
    31     static const Float_t  fgRefPedExtraGalactic;
    32     static const Float_t  fgRefPedGalactic;
     26  static const Double_t fgPedestalMin;                 //! Minimum Axis value for pedestal datacheck display
     27  static const Double_t fgPedestalMax;                 //! Maximum Axis value for pedestal datacheck display
     28  static const Double_t fgPedRmsMin;                   //! Minimum Axis value for ped. RMS datacheck display
     29  static const Double_t fgPedRmsMax;                   //! Maximum Axis value for ped. RMS datacheck display
     30 
     31  static const Float_t  fgRefPedClosedLids;            //! Reference line pedestal for closed lids run
     32  static const Float_t  fgRefPedExtraGalactic;         //! Reference line pedestal for extragalactic source
     33  static const Float_t  fgRefPedGalactic;              //! Reference line pedestal for galactic source     
     34 
     35  static const Float_t  fgRefPedRmsClosedLidsInner;    //! Ref. line ped. RMS for closed lids run - inner pixels     
     36  static const Float_t  fgRefPedRmsExtraGalacticInner; //! Ref. line ped. RMS for extragalactic source - inner pixels
     37  static const Float_t  fgRefPedRmsGalacticInner;      //! Ref. line ped. RMS for galactic source - inner pixels     
     38 
     39  static const Float_t  fgRefPedRmsClosedLidsOuter;    //! Ref. line ped. RMS for closed lids run - outer pixels     
     40  static const Float_t  fgRefPedRmsExtraGalacticOuter; //! Ref. line ped. RMS for extragalactic source - outer pixels
     41  static const Float_t  fgRefPedRmsGalacticOuter;      //! Ref. line ped. RMS for galactic source - outer pixels     
     42   
     43  MRunIter   *fRuns;                                  // Used pedestal runs
     44  MExtractor *fExtractor;                             // Signal extractor, used to find the nr. of used FADC slices
     45 
     46  MPedestalCam  fPedestalCam;                         // Created pedestal results
     47  MBadPixelsCam fBadPixels;                           // Bad Pixels
     48 
     49  enum Display_t {kDataCheckDisplay, kNormalDisplay}; // Possible Display types
    3350
    34     static const Float_t  fgRefPedRmsClosedLidsInner;
    35     static const Float_t  fgRefPedRmsExtraGalacticInner;
    36     static const Float_t  fgRefPedRmsGalacticInner;
     51  Display_t fDisplayType;                             // Chosen Display type   
     52 
     53  enum Storage_t { kNoStorage };                      // Possible flags for the storage of results
     54 
     55  Byte_t fStorage;                                    // Bit-field for chosen storage type
     56   
     57  Bool_t fDataCheck;                                  // Flag if the data check is run on raw data
     58  Bool_t fUseData;                                    // Use data-runs from sequence instead of pedestal runs
     59 
     60  Bool_t ReadPedestalCam();
     61  Bool_t WriteResult();
     62  //Bool_t WriteEventloop(MEvtLoop &evtloop) const;
    3763
    38     static const Float_t  fgRefPedRmsClosedLidsOuter;
    39     static const Float_t  fgRefPedRmsExtraGalacticOuter;
    40     static const Float_t  fgRefPedRmsGalacticOuter;
    41    
    42     MRunIter   *fRuns;          // Used pedestal runs
    43     MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
    44 
    45     MPedestalCam  fPedestalCam; // Created pedestal results
    46     MBadPixelsCam fBadPixels;   // Bad Pixels
    47 
    48     enum  Display_t { kDataCheckDisplay, kNormalDisplay }; // Possible Display types
    49 
    50     Display_t fDisplayType;     // Chosen Display type   
    51    
    52     Bool_t fDataCheck;          // Flag if the data check is run on raw data
    53     Bool_t fUseData;            // Use data-runs from sequence instead of pedestal runs
    54 
    55     Bool_t ReadPedestalCam();
    56     Bool_t WriteResult();
    57     //Bool_t WriteEventloop(MEvtLoop &evtloop) const;
    58 
    59     void   DisplayResult(MParList &plist);
    60     void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
    61     void   DisplayOutliers(TH1D *hist) const;
    62     void   FixDataCheckHist(TH1D *hist) const;
    63 
    64     Bool_t CheckEnvLocal();
     64  void   DisplayResult(MParList &plist);
     65  void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
     66  void   DisplayOutliers(TH1D *hist) const;
     67  void   FixDataCheckHist(TH1D *hist) const;
     68 
     69  Bool_t IsNoStorage    () const { return TESTBIT(fStorage,kNoStorage);     }
     70 
     71  Bool_t CheckEnvLocal();
    6572   
    6673public:
    67     MJPedestal(const char *name=NULL, const char *title=NULL);
    6874
    69     MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
    70     const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
     75  MJPedestal(const char *name=NULL, const char *title=NULL);
    7176
    72     const char*  GetOutputFile() const;
    73     const Bool_t IsDataCheck  () const    { return fDataCheck; }
    74     const Bool_t IsUseData    () const    { return fUseData;   }   
    75 
    76     Bool_t Process    ();
    77     Bool_t ProcessFile();
    78 
    79     void SetBadPixels ( const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
    80     void SetExtractor (       MExtractor* ext   ) { fExtractor = ext;     }
    81     void SetInput     (       MRunIter  *iter   ) { fRuns      = iter;    }
    82     void SetUseData   ( const Bool_t b=kTRUE    ) { fUseData   = b;       }
    83     void SetDataCheck ( const Bool_t b=kTRUE    ) { fDataCheck = b;
    84                         b ? SetDataCheckDisplay() : SetNormalDisplay(); }
    85     void SetDataCheckDisplay()                    { fDisplayType = kDataCheckDisplay; }
    86     void SetNormalDisplay   ()                    { fDisplayType = kNormalDisplay;    }
    87    
    88     void SetPedContainerName(const char *name) { fPedestalCam.SetName(name); }
    89 
    90     ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
     77  MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
     78  const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
     79 
     80  const char*  GetOutputFile() const;
     81  const Bool_t IsDataCheck  () const    { return fDataCheck; }
     82  const Bool_t IsUseData    () const    { return fUseData;   }   
     83 
     84  Bool_t Process    ();
     85  Bool_t ProcessFile();
     86 
     87  void SetBadPixels ( const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
     88  void SetExtractor (       MExtractor* ext   ) { fExtractor = ext;     }
     89  void SetInput     (       MRunIter  *iter   ) { fRuns      = iter;    }
     90  void SetUseData   ( const Bool_t b=kTRUE    ) { fUseData   = b;       }
     91  void SetDataCheck ( const Bool_t b=kTRUE    ) { fDataCheck = b;
     92                                                  b ? SetDataCheckDisplay() : SetNormalDisplay(); }
     93  void SetDataCheckDisplay()                    { fDisplayType = kDataCheckDisplay; }
     94  void SetNormalDisplay   ()                    { fDisplayType = kNormalDisplay;    }
     95 
     96  void SetPedContainerName(const char *name)    { fPedestalCam.SetName(name); }
     97 
     98  // Storage
     99  void SetNoStorage    ( const Bool_t b ) { b ? SETBIT(fStorage,kNoStorage) : CLRBIT(fStorage,kNoStorage); }
     100  void SetNormalStorage()                 {                                   CLRBIT(fStorage,kNoStorage); }
     101 
     102  ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
    91103};
    92104
Note: See TracChangeset for help on using the changeset viewer.