Index: trunk/MagicSoft/Mars/mimage/ImageLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/ImageLinkDef.h	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/ImageLinkDef.h	(revision 3526)
@@ -16,4 +16,5 @@
 
 #pragma link C++ class MNewImagePar+;
+#pragma link C++ class MConcentration+;
 
 #pragma link C++ class MHHillas+;
Index: trunk/MagicSoft/Mars/mimage/MConcentration.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MConcentration.cc	(revision 3526)
+++ trunk/MagicSoft/Mars/mimage/MConcentration.cc	(revision 3526)
@@ -0,0 +1,201 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek  6/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MConcentration
+//
+// Storage Container for image parameters
+//
+//    basic image parameters
+//
+// Version 1:
+// ----------
+// fLength   [mm]       major axis of ellipse
+// fWidth    [mm]       minor axis
+// fDelta    [rad]      angle of major axis with x-axis
+//                      by definition the major axis is pointing into
+//                      the hemisphere x>0, thus -pi/2 < delta < pi/2
+// fSize     [#CerPhot] total sum of pixels
+// fMeanX    [mm]       x of center of ellipse
+// fMeanY    [mm]       y of center of ellipse
+//
+// Version 2:
+// ----------
+// fNumCorePixels  number of pixels called core
+// fNumUsedPixels  number of pixels which survived the cleaning
+//
+// Version 3:
+// ----------
+// fNumCorePixels  moved to MNewImagePar
+// fNumUsedPixels  moved to MNewImagePar
+// fCosDelta       added
+// fSinDelte       added
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MConcentration.h"
+
+//#include <fstream>
+
+#include <TArrayF.h>
+#include <TArrayI.h>
+//#include <TEllipse.h>
+
+#include "MHillas.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MConcentration);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MConcentration::MConcentration(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MConcentration";
+    fTitle = title ? title : "Storage container for concentrations";
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the TEllipse if one exists.
+//
+MConcentration::~MConcentration()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes the values with defaults. For the default values see the
+// source code.
+//
+void MConcentration::Reset()
+{
+    for (int i=0; i<9; i++)
+        fConc[i] = -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog
+//
+void MConcentration::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Concentrations (" << GetName() << ")" << endl;
+    //*fLog << " - Length      [mm]  = " << fLength << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the image parameters from a Cherenkov photon event
+// assuming Cher.photons/pixel and pixel coordinates are given
+// In case you don't call Calc from within an eventloop make sure, that
+// you call the Reset member function before.
+// Returns:
+//   0  no error
+//   1  number of pixels < 3
+//   2  size==0
+//   3  number of used pixel < 3
+//   4  CorrXY == 0
+//
+Int_t MConcentration::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hillas)
+{
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0};             // [#phot]
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        // skip unused pixels
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const Int_t pixid = pix.GetPixId();
+
+        const MGeomPix &gpix = geom[pixid];
+
+        Double_t nphot = pix.GetNumPhotons();
+
+        //
+        // Now we are working on absolute values of nphot, which
+        // must take pixel size into account
+        //
+        nphot *= geom.GetPixRatio(pixid);
+
+	// Compute Concentrations 1-8	
+
+	if(maxpix[0]<=nphot) {
+	  for(int i=0;i<8;i++)
+	    maxpix[8-i]=maxpix[7-i];
+	  maxpix[0]=nphot;
+	}
+	else 
+	  for(int i=0;i<8;i++){
+	    if (nphot<maxpix[7-i]){
+	      for(int j=0;j<i-1;j++){  
+		maxpix[7-j]=maxpix[6-j];                    // [1]
+	      }
+	      maxpix[8-i]=nphot;
+	      break;
+	    }
+	  }
+
+    }
+
+    // Compute concentrations from the 8 pixels with higher signal
+   
+    fConc[0]=maxpix[0];
+    for(int i=1;i<8;i++)
+      {
+	fConc[i]=fConc[i-1]+maxpix[i];
+      }
+    
+    for(int i=0;i<8;i++)
+      {
+	fConc[i]/=hillas.GetSize();                       // [ratio]
+      }
+
+    SetReadyToSave();
+
+}
+
+
Index: trunk/MagicSoft/Mars/mimage/MConcentration.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MConcentration.h	(revision 3526)
+++ trunk/MagicSoft/Mars/mimage/MConcentration.h	(revision 3526)
@@ -0,0 +1,40 @@
+#ifndef MARS_MConcentration
+#define MARS_MConcentration
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHillas;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MConcentration : public MParContainer
+{
+private:
+    Float_t fConc[9];       // [%] major axis of ellipse
+
+public:
+    MConcentration(const char *name=NULL, const char *title=NULL);
+    ~MConcentration();
+
+    void Reset();
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix, const MHillas &hil);
+
+    void Print(Option_t *opt=NULL) const;
+
+    Float_t GetConc1() const { return fConc[0]; }
+    Float_t GetConc2() const { return fConc[1]; }
+    Float_t GetConc3() const { return fConc[2]; }
+    Float_t GetConc4() const { return fConc[3]; }
+    Float_t GetConc5() const { return fConc[4]; }
+    Float_t GetConc6() const { return fConc[5]; }
+    Float_t GetConc7() const { return fConc[6]; }
+    Float_t GetConc8() const { return fConc[7]; }
+    Float_t GetConc9() const { return fConc[8]; }
+
+    ClassDef(MConcentration, 1) // Storage Container for Concentration Parameter
+};
+
+#endif
Index: trunk/MagicSoft/Mars/mimage/MHillasCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasCalc.cc	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/MHillasCalc.cc	(revision 3526)
@@ -65,5 +65,5 @@
 #include "MHillasExt.h"
 #include "MNewImagePar.h"
-
+#include "MConcentration.h"
 #include "MCerPhotEvt.h"
 
@@ -81,5 +81,6 @@
 MHillasCalc::MHillasCalc(const char *name, const char *title)
     : fHilName("MHillas"), fHilExtName("MHillasExt"),
-    fImgParName("MNewImagePar"), fFlags(0xff), fErrors(5)
+    fImgParName("MNewImagePar"), fConcName("MConcentration"),
+    fFlags(0xff), fErrors(5)
 {
     fName  = name  ? name  : "MHillasCalc";
@@ -139,5 +140,13 @@
     }
 
-    memset(fErrors.GetArray(), 0, sizeof(Char_t)*fErrors.GetSize());
+     // if enabled
+    if (TestFlag(kCalcConc))
+    {
+        fConc = (MConcentration*)pList->FindCreateObj("MConcentration", fConcName);
+        if (!fConc)
+            return kFALSE;
+    }
+
+   memset(fErrors.GetArray(), 0, sizeof(Char_t)*fErrors.GetSize());
 
     return kTRUE;
@@ -171,4 +180,7 @@
     if (TestFlag(kCalcNewImagePar))
         fNewImgPar->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+
+    if (TestFlag(kCalcConc))
+        fConc->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
 
     return kTRUE;
Index: trunk/MagicSoft/Mars/mimage/MHillasCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MHillasCalc.h	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/MHillasCalc.h	(revision 3526)
@@ -22,4 +22,5 @@
 class MHillasExt;
 class MNewImagePar;
+class MConcentration;
 
 class MHillasCalc : public MTask
@@ -31,8 +32,10 @@
     MHillasExt   *fHillasExt;       //! output container to store result
     MNewImagePar *fNewImgPar;       //! output container to store result
+    MConcentration *fConc;          //! output container to store result
 
     TString      fHilName;          // name of the 'MHillas' container
     TString      fHilExtName;       // name of the 'MHillasExt' container
     TString      fImgParName;       // name of the 'MNewImagePar' container
+    TString      fConcName;         // name of the 'MConcentration' container
 
     Int_t        fFlags;            // Flags defining the behaviour of MHillasCalc
@@ -51,5 +54,6 @@
         kCalcHillasExt   = BIT(1),
         //kCalcHillasSrc   = BIT(2),
-        kCalcNewImagePar = BIT(3)
+        kCalcNewImagePar = BIT(3),
+        kCalcConc        = BIT(4)
     };
 
@@ -59,4 +63,5 @@
     void SetNameHillasExt(const char *name) { fHilExtName = name; }
     void SetNameNewImgPar(const char *name) { fImgParName = name; }
+    void SetNameConc(const char *name) { fConcName = name; }
 
     void SetFlags(Int_t f) { fFlags  =  f; }
Index: trunk/MagicSoft/Mars/mimage/MNewImagePar.cc
===================================================================
--- trunk/MagicSoft/Mars/mimage/MNewImagePar.cc	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/MNewImagePar.cc	(revision 3526)
@@ -116,5 +116,4 @@
     Double_t edgepixin2 = 0;
 
-    Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0};             // [#phot]
     Float_t maxpix1 = 0;                                 // [#phot]
     Float_t maxpix2 = 0;                                 // [#phot]
@@ -171,22 +170,4 @@
 	  }
 	}
-
-	// Compute Concentrations 1-8	
-
-	if(maxpix[0]<=nphot) {
-	  for(int i=0;i<8;i++)
-	    maxpix[8-i]=maxpix[7-i];
-	  maxpix[0]=nphot;
-	}
-	else 
-	  for(int i=0;i<8;i++){
-	    if (nphot<maxpix[7-i]){
-	      for(int j=0;j<i-1;j++){  
-		maxpix[7-j]=maxpix[6-j];                    // [1]
-	      }
-	      maxpix[8-i]=nphot;
-	      break;
-	    }
-	  }
 
 	// Compute Concetration 1 -2 
@@ -211,18 +192,4 @@
     fConc1 = maxpix1/hillas.GetSize();                   // [ratio]
 
-    fConc3 = (maxpix[0]+maxpix[1]+maxpix[2]);
-    fConc4 = (fConc3+maxpix[3]);
-    fConc5 = (fConc4+maxpix[4]);
-    fConc6 = (fConc5+maxpix[5]);
-    fConc7 = (fConc6+maxpix[6]);
-    fConc8 = (fConc7+maxpix[7]);
-
-    fConc3/=hillas.GetSize();                           // [ratio]
-    fConc4/=hillas.GetSize();                           // [ratio]
-    fConc5/=hillas.GetSize();                           // [ratio]
-    fConc6/=hillas.GetSize();                           // [ratio]
-    fConc7/=hillas.GetSize();                           // [ratio]
-    fConc8/=hillas.GetSize();                           // [ratio]
-
     SetReadyToSave();
 } 
Index: trunk/MagicSoft/Mars/mimage/MNewImagePar.h
===================================================================
--- trunk/MagicSoft/Mars/mimage/MNewImagePar.h	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/MNewImagePar.h	(revision 3526)
@@ -21,10 +21,4 @@
     Float_t fConc;               // [ratio] concentration ratio: sum of the two highest pixels / fSize
     Float_t fConc1;              // [ratio] concentration ratio: sum of the highest pixel / fSize
-    Float_t fConc3;              // [ratio] concentration ratio: sum of the 3 highest pixel / fSize
-    Float_t fConc4;              // [ratio] concentration ratio: sum of the 4 highest pixel / fSize
-    Float_t fConc5;              // [ratio] concentration ratio: sum of the 5 highest pixel / fSize
-    Float_t fConc6;              // [ratio] concentration ratio: sum of the 6 highest pixel / fSize
-    Float_t fConc7;              // [ratio] concentration ratio: sum of the 7 highest pixel / fSize
-    Float_t fConc8;              // [ratio] concentration ratio: sum of the 8 highest pixel / fSize
 
     Short_t fNumUsedPixels;      // Number of pixels which survived the image cleaning
Index: trunk/MagicSoft/Mars/mimage/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mimage/Makefile	(revision 3520)
+++ trunk/MagicSoft/Mars/mimage/Makefile	(revision 3526)
@@ -37,4 +37,5 @@
            MHillasSrcCalc.cc \
 	   MNewImagePar.cc \
+	   MConcentration.cc \
            MHHillas.cc \
            MHHillasSrc.cc \
