Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 3236)
+++ trunk/MagicSoft/Mars/Changelog	(revision 3237)
@@ -4,4 +4,25 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2004/01/19: Thomas Bretz
+
+   * manalysis/MCerPhotEvt.h:
+     - added operator= to MCerPhotEvtIter -- is this correct?
+
+   * mhist/MHCamera.[h,cc]:
+     - added member function to calculate minimum content and 
+       maximum content for a single sector
+     - Added possibility to get a projection for a single sector.
+     - GetMinimum/GetMaximum now only takes used pixels into account
+       (you can request all pixels using a different member function)
+     - fixed projection (projection only took pixels with contents!=0
+       instead of 'used' pixels
+     - Don't call Sumw2() anymore for projection
+
+   * mjobs/MJExtractSignal.cc:
+     - added MPedestalCam to output again - MPedestalCam was fixed
+       yesterday
+     - Added Histograms for the two camera halves
+
+
 
  2004/01/18: Markus Gaug
@@ -15,5 +36,6 @@
     * mcalib/MCalibrationPix.h
       - move CalcFFactorMethod to public
- 
+
+
 
  2004/01/18: Abelardo Moralejo
Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 3236)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 3237)
@@ -96,4 +96,5 @@
     MCerPhotEvtIter(const MCerPhotEvt *evt, Bool_t usedonly=kTRUE, Bool_t dir=kIterForward) : TObjArrayIter(evt->fPixels, dir), fUsedOnly(usedonly) { }
     TObject *Next();
+    TIterator &operator=(const TIterator &) { return *this; }
     ClassDef(MCerPhotEvtIter, 0)
 };
Index: trunk/MagicSoft/Mars/mhist/MHCamera.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3236)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.cc	(revision 3237)
@@ -162,4 +162,14 @@
 // ------------------------------------------------------------------------
 //
+// Return kTRUE for sector<0. Otherwise return kTRUE only if the specified
+// sector idx matches the sector of the pixel with index idx.
+//
+Bool_t MHCamera::MatchSector(Int_t idx, Int_t sector) const
+{
+    return sector<0 ? kTRUE : (*fGeomCam)[idx].GetSector()==(UInt_t)sector;
+}
+
+// ------------------------------------------------------------------------
+//
 // Taken from TH1D::Fill(). Uses the argument directly as bin index.
 // Doesn't increment the number of entries.
@@ -255,29 +265,53 @@
 }
 
-Stat_t MHCamera::GetMean(Int_t axis) const
+// ------------------------------------------------------------------------
+//
+// Return the mean value of all entries which are used if all=kFALSE and
+// of all entries if all=kTRUE if sector<0. If sector>=0 only
+// entries with match the given sector are taken into account.
+//
+Stat_t MHCamera::GetMeanSector(Int_t sector, Bool_t all) const
 {
     if (fNcells<=1)
         return 0;
 
+    Int_t n=0;
+
     Stat_t mean = 0;
-    for (int i=1; i<fNcells-1; i++)
-        mean += fArray[i];
-
-    return Profile(mean/(fNcells-2));
-}
-
-Stat_t MHCamera::GetRMS(Int_t axis) const
+    for (int i=0; i<fNcells-2; i++)
+    {
+        if ((all || IsUsed(i)) && MatchSector(i, sector))
+        {
+            mean += fArray[i+1];
+            n++;
+        }
+    }
+
+    return Profile(mean/n);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the rms value of all entries which are used if all=kFALSE and
+// of all entries if all=kTRUE if sector<0. If sector>=0 only
+// entries with match the given sector are taken into account.
+//
+Stat_t MHCamera::GetRmsSector(Int_t sector, Bool_t all) const
 {
     if (fNcells<=1)
         return -1;
 
-    const Int_t n = fNcells-2;
+    Int_t n=0;
 
     Stat_t sum = 0;
     Stat_t sq  = 0;
-    for (int i=1; i<n+1; i++)
-    {
-        sum += fArray[i];
-        sq  += fArray[i]*fArray[i];
+    for (int i=0; i<fNcells-2; i++)
+    {
+        if ((all || IsUsed(i)) && MatchSector(i, sector))
+        {
+            sum += fArray[i+1];
+            sq  += fArray[i+1]*fArray[i+1];
+            n++;
+        }
     }
 
@@ -291,7 +325,8 @@
 //
 // Return the minimum contents of all pixels (if all is set, otherwise
-// only of all 'used' pixels), fMinimum if fMinimum set
-//
-Double_t MHCamera::GetMinimum(Bool_t all) const
+// only of all 'used' pixels), fMinimum if fMinimum set. If sector>=0
+// only pixels with matching sector number are taken into account.
+//
+Double_t MHCamera::GetMinimumSector(Int_t sector, Bool_t all) const
 {
     if (fMinimum != -1111)
@@ -303,16 +338,8 @@
     Double_t minimum=FLT_MAX;
 
-    if (all)
-    {
-        for (Int_t idx=0; idx<fNcells-2; idx++)
-            if (fArray[idx+1] < minimum)
-                minimum = fArray[idx+1];
-    }
-    else
-    {
-        for (Int_t idx=0; idx<fNcells-2; idx++)
-            if (IsUsed(idx) && fArray[idx+1] < minimum)
-                minimum = fArray[idx+1];
-    }
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (MatchSector(idx, sector) && (all || IsUsed(idx)) && fArray[idx+1]<minimum)
+            minimum = fArray[idx+1];
+
     return Profile(minimum);
 }
@@ -321,7 +348,8 @@
 //
 // Return the maximum contents of all pixels (if all is set, otherwise
-// only of all 'used' pixels), fMaximum if fMaximum set
-//
-Double_t MHCamera::GetMaximum(Bool_t all) const
+// only of all 'used' pixels), fMaximum if fMaximum set. If sector>=0
+// only pixels with matching sector number are taken into account.
+//
+Double_t MHCamera::GetMaximumSector(Int_t sector, Bool_t all) const
 {
     if (fMaximum!=-1111)
@@ -332,16 +360,8 @@
 
     Double_t maximum=-FLT_MAX;
-    if (all)
-    {
-        for (Int_t idx=0; idx<fNcells-2; idx++)
-            if (fArray[idx+1] > maximum)
-                maximum = fArray[idx+1];
-    }
-    else
-    {
-        for (Int_t idx=0; idx<fNcells-2; idx++)
-            if (IsUsed(idx) && fArray[idx+1] > maximum)
-                maximum = fArray[idx+1];
-    }
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (MatchSector(idx, sector) && (all || IsUsed(idx)) && fArray[idx+1]>maximum)
+            maximum = fArray[idx+1];
+
     return Profile(maximum);
 }
@@ -474,5 +494,8 @@
 // is more or less the same than to TH2-projections.
 //
-TH1D *MHCamera::Projection(const char *name) const
+// If sector>=0 only entries with matching sector index are taken
+// into account.
+//
+TH1D *MHCamera::ProjectionS(Int_t sector, const char *name) const
 {
     Int_t nbins = 50;
@@ -481,5 +504,9 @@
     TString pname(name);
     if (name=="_py")
+    {
         pname.Prepend(GetName());
+        if (sector>=0)
+            pname += sector;
+    }
 
     TH1D *h1=0;
@@ -494,6 +521,6 @@
     if (!h1)
     {
-        Double_t min = GetMinimum();
-        Double_t max = GetMaximum();
+        Double_t min = GetMinimumSector(sector);
+        Double_t max = GetMaximumSector(sector);
 
         Int_t newbins=0;
@@ -505,15 +532,11 @@
         h1->SetXTitle(GetYaxis()->GetTitle());
         h1->SetYTitle("Counts");
-        h1->Sumw2();
+        //h1->Sumw2();
     }
 
     // Fill the projected histogram
-    for (Int_t binx =0;binx<=GetNbinsX()+1;binx++) {
-        const Double_t cont = GetBinContent(binx);
-        if (cont!=0)
-            h1->Fill(cont);
-    }
-
-    h1->SetEntries(GetXaxis()->GetNbins());
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (IsUsed(idx) && MatchSector(idx, sector))
+            h1->Fill(GetBinContent(idx+1));
 
     return h1;
Index: trunk/MagicSoft/Mars/mhist/MHCamera.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3236)
+++ trunk/MagicSoft/Mars/mhist/MHCamera.h	(revision 3237)
@@ -78,4 +78,6 @@
     void   ResetUsed(Int_t idx)    { CLRBIT(fUsed[idx], kIsUsed); }
 
+    Bool_t MatchSector(Int_t idx, Int_t sector) const;
+
     // This is a trick to remove TH1 entries from the context menu
     TH1 *Rebin(Int_t ngroup=2, const char*newname="") { return this; }
@@ -138,9 +140,12 @@
     Stat_t   GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
 
-    Double_t GetMinimum(Bool_t all) const;
-    Double_t GetMaximum(Bool_t all) const;
-
-    Double_t GetMinimum() const { return GetMinimum(0/*kTRUE*/); }
-    Double_t GetMaximum() const { return GetMaximum(0/*kTRUE*/); }
+    Double_t GetMinimum(Bool_t all) const { return GetMinimumSector(-1, all); }
+    Double_t GetMaximum(Bool_t all) const { return GetMaximumSector(-1, all); }
+
+    Double_t GetMinimum() const { return GetMinimumSector(-1, kFALSE); }
+    Double_t GetMaximum() const { return GetMaximumSector(-1, kFALSE); }
+
+    Double_t GetMinimumSector(Int_t sector, Bool_t all=kFALSE) const;
+    Double_t GetMaximumSector(Int_t sector, Bool_t all=kFALSE) const;
 
     void     SetLevels(const TArrayF &arr);
@@ -181,10 +186,17 @@
     void     AddNotify(TObject *event);
 
-    Stat_t   GetMean(Int_t axis=-1) const;
-    Stat_t   GetRMS(Int_t axis=-1) const;
+    Stat_t   GetMean(Bool_t all) const { return GetMeanSector(-1, all); }
+    Stat_t   GetRMS(Bool_t all)  const { return GetRmsSector(-1, all); }
+
+    Stat_t   GetMean(Int_t sector=-1) const { return GetMeanSector(-1, kFALSE); }
+    Stat_t   GetRMS(Int_t sector=-1)  const { return GetRmsSector(-1, kFALSE); }
+
+    Stat_t   GetMeanSector(Int_t sector, Bool_t all=kFALSE) const;
+    Stat_t   GetRmsSector(Int_t sector, Bool_t all=kFALSE) const;
 
     UInt_t   GetNumPixels() const;
 
-    TH1D    *Projection(const char *name="_py") const;
+    TH1D    *Projection(const char *name="_py") const { return ProjectionS(-1, name); }
+    TH1D    *ProjectionS(Int_t sector, const char *name="_py") const;
 
     const MGeomCam &GetGeomCam() const { return *fGeomCam; }
Index: trunk/MagicSoft/Mars/mjobs/MJExtractSignal.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJExtractSignal.cc	(revision 3236)
+++ trunk/MagicSoft/Mars/mjobs/MJExtractSignal.cc	(revision 3237)
@@ -328,5 +328,5 @@
     write.AddContainer("MExtractedSignalCam", "Events");
     write.AddContainer("MTime",               "Events");
-    // FIXME: CRAHSES! write.AddContainer("MPedestalCam",        "RunHeaders");
+    write.AddContainer("MPedestalCam",        "RunHeaders");
     write.AddContainer("MRawRunHeader",       "RunHeaders");
     write.AddContainer("MBadPixelsCam",       "RunHeaders");
