Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4973)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4974)
@@ -33,6 +33,11 @@
  
    * mhcalib/MHCalibrationCam.h
+     - took out the "->" for all pointers
+     - introduce new steering flags: 
+       kLoGain, kOscillations, kAverageing, kSizeCheck
+
    * mhcalib/MHCalibrationBlindCam.h
      - took out the "->" for all pointers
+	     
 
  2004/09/13: Thomas Bretz
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 4973)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.cc	(revision 4974)
@@ -42,7 +42,8 @@
 //
 // The following flag can be set:
-// - SetDebug() for debug output.
-// - SetLoGain() for the case that low-gain slices are available, but 
-//               MRawRunHeader::GetNumLoGainSlices() gives still 0.
+// - SetAverageging() for calculating the event-by-event averages.
+// - SetDebug()       for debug output.
+// - SetLoGain()      for the case that low-gain slices are available, but 
+//                        MRawRunHeader::GetNumLoGainSlices() gives still 0.
 // 
 // The flag fLoGain steers if low-gain signal is treated at all or not.
@@ -99,4 +100,10 @@
 // - fPulserFrequency to fgPulserFrequency
 //
+// - SetAveregeing  (kTRUE);
+// - SetDebug       (kFALSE);
+// - SetLoGain      (kTRUE);
+//-  SetOscillations(kTRUE);
+//-  SetSizeCheck   (kTRUE);
+//
 MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
     :  fHistName(gsHistName),fHistTitle(gsHistTitle),
@@ -126,7 +133,9 @@
     SetPulserFrequency();
 
+    SetAverageing  (kTRUE);
     SetDebug       (kFALSE);
     SetLoGain      (kTRUE);
     SetOscillations(kTRUE);
+    SetSizeCheck   (kTRUE);
 }
 
@@ -172,9 +181,12 @@
   if (fHiGainArray)
     { fHiGainArray->ForEach(MHCalibrationPix,Reset)();  }
-  if (fAverageHiGainAreas)
-    { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)();  }
-  if (fAverageHiGainSectors)
-    { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)();  }
-
+  if (IsAverageing())
+    {
+      if (fAverageHiGainAreas)
+        { fAverageHiGainAreas->ForEach(MHCalibrationPix,Reset)();  }
+      if (fAverageHiGainSectors)
+        { fAverageHiGainSectors->ForEach(MHCalibrationPix,Reset)();  }
+    }
+  
   if (!IsLoGain())
     return;
@@ -182,9 +194,11 @@
   if (fLoGainArray)
     { fLoGainArray->ForEach(MHCalibrationPix,Reset)();  }
-  if (fAverageLoGainAreas)
-    { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)();  }
-  if (fAverageLoGainSectors)
-    { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)();  }
-  
+  if (IsAverageing())
+    {
+      if (fAverageLoGainAreas)
+        { fAverageLoGainAreas->ForEach(MHCalibrationPix,Reset)();  }
+      if (fAverageLoGainSectors)
+        { fAverageLoGainSectors->ForEach(MHCalibrationPix,Reset)();  }
+    }
 }
 
@@ -329,4 +343,16 @@
 {
 
+  //
+  // FIXME, this might be done faster and more elegant, by direct copy.
+  //
+  MHCalibrationCam *cam = new MHCalibrationCam();
+
+  cam->fRunNumbers             = fRunNumbers;
+  cam->fPulserFrequency        = fPulserFrequency;
+  cam->fFlags                  = fFlags;
+
+  if (!IsAverageing())
+    return cam;
+
   //  const Int_t nhi   = fHiGainArray->GetEntries();
   //  const Int_t nlo   = fLoGainArray->GetEntries();
@@ -334,9 +360,4 @@
   //  const Int_t nsehi = fAverageHiGainSectors->GetEntries();
   
-  //
-  // FIXME, this might be done faster and more elegant, by direct copy.
-  //
-  MHCalibrationCam *cam = new MHCalibrationCam();
-
   //  cam->fHiGainArray->Expand(nhi);
   //  cam->fLoGainArray->Expand(nlo);
@@ -387,7 +408,4 @@
   cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;   
   cam->fAverageSectorNum       = fAverageSectorNum;      
-  cam->fRunNumbers             = fRunNumbers;
-
-  cam->fPulserFrequency        = fPulserFrequency;
 
   return cam;
@@ -424,4 +442,5 @@
   }
 
+  /* not needed -> Class is never used twice
   fHiGainArray->Delete();
   fLoGainArray->Delete();
@@ -432,4 +451,5 @@
   fAverageHiGainSectors->Delete();
   fAverageLoGainSectors->Delete();
+  */
 
   return SetupHists(pList);
@@ -491,30 +511,32 @@
     }
 
-  //
-  // The function TArrayF::Set() already sets all entries to 0.
-  //
-  fAverageAreaNum.        Set(nareas);
-  fAverageAreaSat.        Set(nareas);           
-  fAverageAreaSigma.      Set(nareas);      
-  fAverageAreaSigmaVar.   Set(nareas);   
-  fAverageAreaRelSigma.   Set(nareas);   
-  fAverageAreaRelSigmaVar.Set(nareas);
-  fAverageSectorNum.      Set(nsectors);
-  fRunNumbers.            Set(fRunNumbers.GetSize()+1);
-
-  for (Int_t aidx=0; aidx<nareas; aidx++)
-      fAverageAreaNum[aidx] = 0;
-
-  for (Int_t sector=0; sector<nsectors; sector++)
-      fAverageSectorNum[sector] = 0;
-
-  for (Int_t i=0; i<npixels; i++)
-    {
-
-      if ((*fBadPixels)[i].IsBad())
-        continue;
-
-      fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
-      fAverageSectorNum[(*fGeom)[i].GetSector()]++;
+  if (IsAverageing())
+    {
+      //
+      // The function TArrayF::Set() already sets all entries to 0.
+      //
+      fAverageAreaNum.        Set(nareas);
+      fAverageAreaSat.        Set(nareas);           
+      fAverageAreaSigma.      Set(nareas);      
+      fAverageAreaSigmaVar.   Set(nareas);   
+      fAverageAreaRelSigma.   Set(nareas);   
+      fAverageAreaRelSigmaVar.Set(nareas);
+      fAverageSectorNum.      Set(nsectors);
+      fRunNumbers.            Set(fRunNumbers.GetSize()+1);
+      
+      for (Int_t aidx=0; aidx<nareas; aidx++)
+        fAverageAreaNum[aidx] = 0;
+      
+      for (Int_t sector=0; sector<nsectors; sector++)
+        fAverageSectorNum[sector] = 0;
+  
+      for (Int_t i=0; i<npixels; i++)
+        {
+          if ((*fBadPixels)[i].IsBad())
+            continue;
+          
+          fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
+          fAverageSectorNum[(*fGeom)[i].GetSector()]++;
+        }
     }
 
@@ -544,4 +566,7 @@
         h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
       }
+  
+  if (!IsAverageing())
+    return kTRUE;
   
   for (Int_t j=0; j<nareas; j++)
@@ -616,4 +641,7 @@
   }
 
+  if (!IsAverageing())
+    return;
+
   if (fAverageHiGainAreas->GetEntries()==0)
   {
@@ -725,4 +753,7 @@
   }
 
+  if (!IsAverageing())
+    return;
+
   if (fAverageLoGainAreas->GetEntries()==0)
   {
@@ -801,4 +832,7 @@
 {
 
+  if (!IsSizeCheck())
+    return FillHists(par,w);
+
   const Int_t npixels  = fGeom->GetNumPixels();
   const Int_t nareas   = fGeom->GetNumAreas();
@@ -814,16 +848,4 @@
     }
   
-  if (fAverageHiGainAreas->GetEntries() != nareas)
-    {
-      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
-      return kFALSE;
-    }
-
-  if (fAverageHiGainSectors->GetEntries() != nsectors)
-    {
-      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
-      return kFALSE;
-    }
-
   if (IsLoGain())
     {
@@ -833,4 +855,23 @@
           return kFALSE;
         }
+    }
+  
+  if (!IsAverageing())
+    return FillHists(par,w);
+
+  if (fAverageHiGainAreas->GetEntries() != nareas)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
+      return kFALSE;
+    }
+  
+  if (fAverageHiGainSectors->GetEntries() != nsectors)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
+      return kFALSE;
+    }
+  
+  if (IsLoGain())
+    {
       
       if (fAverageLoGainAreas->GetEntries() != nareas)
@@ -928,4 +969,7 @@
     }
 
+  if (!IsAverageing())
+    return;
+  
   for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
     {
@@ -981,4 +1025,7 @@
     }
 
+  if (!IsAverageing())
+    return;
+  
   for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
     {
@@ -1012,4 +1059,7 @@
 
   if (!fCam)
+    return;
+  
+  if (!IsAverageing())
     return;
   
@@ -1197,21 +1247,4 @@
 
 
-// --------------------------------------------------------------------------
-//
-// Dummy, needed by MCamEvent
-//
-Bool_t MHCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
-{
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// What MHCamera needs in order to draw an individual pixel in the camera
-//
-void MHCalibrationCam::DrawPixelContent(Int_t idx) const
-{
-}
-
 // -----------------------------------------------------------------------------
 // 
@@ -1224,4 +1257,7 @@
 void MHCalibrationCam::Draw(const Option_t *opt)
 {
+
+  if (!IsAverageing())
+    return;
 
   const Int_t nareas = fAverageHiGainAreas->GetEntries();
@@ -1316,4 +1352,14 @@
       rc = kTRUE;
     }
+  if (IsEnvDefined(env, prefix, "SizeCheck", print))
+    {
+      SetSizeCheck(GetEnvValue(env, prefix, "SizeCheck", IsSizeCheck()));
+      rc = kTRUE;
+    }
+  if (IsEnvDefined(env, prefix, "Averageing", print))
+    {
+      SetAverageing(GetEnvValue(env, prefix, "Averageing", IsAverageing()));
+      rc = kTRUE;
+    }
   
   if (IsEnvDefined(env, prefix, "Nbins", print))
Index: trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h
===================================================================
--- trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 4973)
+++ trunk/MagicSoft/Mars/mhcalib/MHCalibrationCam.h	(revision 4974)
@@ -90,5 +90,6 @@
   Int_t      fPulserFrequency;           // Light pulser frequency
 
-  enum { kDebug, kLoGain, kOscillations }; // Possible flags
+  enum { kDebug, kLoGain, kAverageing,
+         kOscillations, kSizeCheck };     // Possible flags
   
   Byte_t     fFlags;                     // Bit-field to hold the flags
@@ -132,7 +133,9 @@
   void InitHists       ( MHCalibrationPix &hist, MBadPixelsPix &bad, const Int_t i);
 
-  Bool_t IsDebug       () const  { return TESTBIT(fFlags,kDebug);        }
+  Bool_t IsAverageing  () const  { return TESTBIT(fFlags,kAverageing);   }
+  Bool_t IsDebug       () const  { return TESTBIT(fFlags,kDebug);        }  
+  Bool_t IsLoGain      () const  { return TESTBIT(fFlags,kLoGain);       }
   Bool_t IsOscillations() const  { return TESTBIT(fFlags,kOscillations); }
-  Bool_t IsLoGain      () const  { return TESTBIT(fFlags,kLoGain);       }
+  Bool_t IsSizeCheck   () const  { return TESTBIT(fFlags,kSizeCheck);    }
   
   Int_t ReadEnv        ( const TEnv &env, TString prefix, Bool_t print);
@@ -156,6 +159,6 @@
   void   Draw(const Option_t *opt);
 
-  Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
-  void   DrawPixelContent( Int_t num )  const;    
+  Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const { return kTRUE; }
+  void   DrawPixelContent( Int_t num )  const  {}
 
   const Int_t              GetAverageAreas       ()          const;	 
@@ -181,4 +184,7 @@
  
   void SetColor                   ( const MCalibrationCam::PulserColor_t color) { fColor = color; }
+  void SetAverageing              ( const Bool_t b=kTRUE ) { b 
+								? SETBIT(fFlags,kAverageing) 
+								: CLRBIT(fFlags,kAverageing); }
   void SetDebug                   ( const Bool_t b=kTRUE ) { b 
 								? SETBIT(fFlags,kDebug) 
@@ -190,4 +196,7 @@
 								? SETBIT(fFlags,kOscillations) 
 								: CLRBIT(fFlags,kOscillations); }
+  void SetSizeCheck               ( const Bool_t b=kTRUE ) { b 
+								? SETBIT(fFlags,kSizeCheck) 
+								: CLRBIT(fFlags,kSizeCheck); }
   void SetHistName  ( const char *name )  { fHistName  = name;  }
   void SetHistTitle ( const char *name )  { fHistTitle = name;  }
