Index: trunk/MagicSoft/Mars/mtemp/Changelog
===================================================================
--- trunk/MagicSoft/Mars/mtemp/Changelog	(revision 7136)
+++ 	(revision )
@@ -1,371 +1,0 @@
-Please  do  not write behind the end of line tag so that it is  possible
-to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
-
-For your entries please follow this style:
-
-_yyyy/mm/dd:_[Your Name]
-_
-___*_filename:
-_____-_description
-_
-___*_filename2, filename3:
-_____-_description
-_
-_
-_
-
-While an underscore is a placeholder for a white-space or an empty line.
-
-                                                 -*-*- END OF LINE -*-*-
-
-
-2005/02/14: Hendrik Bartko
-   * mtemp/mmpi/macros/noise_autocorrelation_AB_all.C
-     - add new macro to calculate the noise autocorrelation for all
-       inner pixels
-
-
-
-2005/02/14: Robert Wagner
-   * mtemp/mmpi/FluxCalcAndUnfold.C
-     - Example macro for calculating a flux and unfolding it using
-       MUnfoldSpectrum and MUnfold
-
-
-
-
-2005/02/11: Robert Wagner
-   * mtemp/mmpi/MUnfoldSpectrum.[cc,h]
-     - A wrapper class which applies the general unfolding algorithms
-       of MUnfold to a gamma spectrum
-
-
-
-2005/01/07: Hendrik Bartko
-   * mtemp/mmpi/macros/noise_autocorrelation_AB.C
-     - corrected bug in AB noise correction
-
-
-
-2004/12/09: Hendrik Bartko
-   * mtemp/mmpi/macros/calculate_of_weights.C
-     - included the theoretical error calculation of the reconstructed
-       signal and arrival time in the weights computation
-
-
-
-2004/12/03: Robert Wagner
-   * mtemp/mmpi/MUnfold.[cc,h]
-     - add new class MUnfold for unfolding 
-
-   * mtemp/mmpi/macros/fluxMUnfold.C
-     - example macro based on macros/fluxUnfold.C, but using the 
-       MUnfold class
-
-
-
-2004/11/22: Marcos Lopez
-   * mtemp/mucm/classes
-     - add new classes MHFlux.{h,cc} and MHExcessEnergyTheta.{h,cc} for the
-       flux calculation.
-
-
-
-2004/10/05: Javier Rico
-   * mtemp/Makefile, TempLinkDef.h
-     - add missing MStarLocalCam
-
-
-
-2004/10/03: Hendrik Bartko
-   * mtemp/mmpi/macros/calculate_of_weights.C
-     - fixed a bug in the histogram naming
-
-
-
-2004/09/24: Hendrik Bartko
-   * mtemp/mmpi/macros/calibration_shape.C
-     - fine tuning of the plots
-   * mtemp/mmpi/macros/data_shape.C
-     - added new macro to compute the signal shape for cosmics runs
-   * mtemp/mmpi/macros/calculate_of_weights.C
-     - added new macro to compute the weights for the optimal filter
-
-
-
-2004/09/19: Hendrik Bartko
-   * mtemp/mmpi/macros/noise_autocorrelation_AB.C
-     - added new macro to compute the noise auto correlation matrix from 
-       a pedestal run
-   * mtemp/mmpi/macros/calibration_shape.C
-     - added new macro to compute the signal shape for calibration runs
-
-
-2004/09/14: Hendrik Bartko
-   * mtemp/mmpi/macros/calibrate_data_ped_standard.C
-     - added new macro to calibrate the data. The pedestals are deter-
-       mined from the cosmics events and the source position is deter-
-       mined from the an analysis of the DC current information.
-
-
-2004/09/10: Nicola Galante
-   * mtemp/mpisa/triggerdisplay/MagicTriggerDisplay.[h,cc]
-     - added the trigger display
-   * mtemp/mpisa/triggerdisplay/MagicTriggerButton.[h,cc]
-     - added custom buttons
-   * mtemp/mpisa/triggerdisplay/MMcTriggerLvl2.[h,cc]
-     - added the last modified MMcTriggerLvl2 with the new
-       changes for the trigger display
-
-
- 2004/08/23: Robert Wagner
-   * mtemp/MLocalStarPos.[h,cc], mtemp/MLocalStarCam.[h,cc],
-     - removed (have been moved to /mstarcam)
-
-   * mtemp/Makefile, mtemp/TempLinkDef.h
-     - removed entries for mtemp/MLocalStarPos.cc
-       mtemp/MLocalStarCam.cc
-
-   * mtemp/MSourceDirections.[h,cc]
-     - report names of directions already before first
-       Process() call, containers are empty apart from that,
-       though  
-
-
-
-2004/08/19: Marcos Lopez
-   * mtemp/Makefile
-     - added the mstarcam directory in the includes list.
- 
-
-
- 2004/08/18: Marcos Lopez
-   * mtemp/mucm
-     - new directory for containing classes of the Madrid group.
-
-
-
- 2004/08/17: Robert Wagner
-   * mtemp/mmpi/MAstroCamera.[h,cc]
-     - removed (merged with mastro/MAstroCamera.[h,cc])
-
-
-
- 2004/08/16: Robert Wagner
-   * mtemp/MStarLocalPos.[h,cc]
-     - added member variables, setters and getters for ideal position,
-       i.e. position without aberration effects
-
-   * mtemp/mmpi/MAstroCamera.cc
-     - Ideal position of star is filled in MLocalStarPos container  
-
-
-
- 2004/08/09: Robert Wagner
-   * mtemp/MSourceDirections.[h,cc]
-     - move from mtemp/mmpi to mtemp
-
-
-
- 2004/08/05: Robert Wagner
-
-   * mtemp/mmpi/MSourceDirections.[h,cc]
-     - Converts objects given by their sky coordinates into 
-       camera coordinates by using MAstroCamera the same way
-       as MFindStars does.
-
-
-
- 2004/08/02: Robert Wagner
-
-   * mtemp/mmpi/MFindStars.[h,cc]
-     - Functionality for finding stars by using stars from star catalog
-   
-   * mtemp/mmpi/MAstroCamera.[h,cc]
-     - Filling stars into a MStarLocalCam instead of painting them
-       (Functionality also in mastro/MAsstroCamera.[h,cc], but 
-       commented out there since MStarLocalCam not part of standard
-       MARS)
-
-   * mtemp/mmpi/macros/findstars.C
-     - sample macro for determining star positions (both with and 
-       without using a star catalog)
-
-   * mtemp/mmpi/macros/bsc5.dat
-     - Bright star catalog as used by findstars.C
-
-
-
- 2004/07/30: Nicola Galante
-
-   * mtemp/mpisa/macros/AnalCurrents.C
-      - Added new macros AnalCurrents.C which reads DC files
-        and looks for DC clusters. Still preliminary! 
-        It currently just looks for starting pixels of clusters.
-
-
-
- 2004/07/22: Sabrina Stark
-
-   * /mtemp/meth/MFindStars.[h,cc]
-      - new fit function, incl. constant background and rotation of 
-	2d gauss
-      - initialization of MAstroCamera
-      - new functions: 
-	     - CorrSourcePos -> calculates a corrected
-	       source position using the images of two stars
-	     - DistBetweenStars -> calculates the distances between
-	       two stars and the source
-	
-   * /mtemp/meth/MAstroCamera.[h,cc]
-      - TList *fCatList: list with star positions from catalog
-      - new functions: 
-	     - StarPosInCamera (similar to FillStarList, but
-               incl. aberration)
-      - GetCatList -> Access function to fCatList
-
-   * /mtemp/meth/MStarLocalPos.[h,cc]
-      - in function SetFitValue -> background included
-	
-
-   * /mtemp/meth/macros/CorrectSrcPos.C
-      - macro to calculate a corrected source position using
-	the images of two stars, these positions are written
-	to an output file
-
-
-	
- 2004/07/20: David Paneque
-
-   * /mtemp/mmpi/SupercutsONOFFClasses directory containing the 
-   classes needed to optimize supercuts (and extract gamma signal) 
-   using the ON and OFF data. These classes are listed below:
-
-   MFRandomSplit.cc     
-   MSupercutsCalcONOFF.cc 
-   MTSupercutsApplied.cc
-   MHFindSignificanceONOFF.cc       
-   MFindSupercutsONOFFThetaLoop.cc 
-   MFindSupercutsONOFF.cc 
-
-   In order to add (to the compiled mars version) these classes you must add the 
-   following line to the SUBDIRS field of the general Makefile
-
-   mtemp/mmpi/SupercutsONOFFClasses
-
-
-   And that's it. It should compile without problems... there is no interference 
-   with the other classes.
-
-   I also add few macros (in the directory /mtemp/mmpi/macros/) which should help 
-   the user to use (correctly) the mentioned classes. 
-
-   SuperCutsONOFFMacro.C
-   SCDynamicalSupercutsApplied.C
-   SCNexSignificanceVSAlphaCut.C
-   
-   
-   The whole analysis is set and executed by running the macro  SuperCutsONOFFMacro.C.
-   I wrote quite some comments on it; it should be self-explanatory. 
-   The macro SCDynamicalSupercutsApplied.C can be used to make a quick 
-   inspection to the cuts applied to the events that survived the cuts, and the 
-   macro    SCNexSignificanceVSAlphaCut.C plots the significance and the excess events 
-   vs the cut in the ALPHA parameter.
-
-   I also included the directory mtemp/mmpi/asciifiles containing ascii files with 
-   some initial supercuts values and the optimized supercuts for Mkn421 Feb 15, 
-   that are used as input for the supercuts ON-OFF analysis.
-						 
-
- 2004/06/29: Javier Rico
-
-   * MIslands.[h,cc], MIslandCalc.[h,cc]
-      - Remove obsolete versions of these classes whose up-to-date ver-
-	sions are available at mifae/library
-
-
- 2004/06/26: Eva Domingo - Pepe Flix
-
-   * mifae/library/MDisp.[h,cc]
-   * mifae/library/MDispCalc.[h,cc]
-      - Added classes for evaluation of DISP method.
-
- 2004/06/25: Sebastian Commichau
-
-   * meth/macros/analysis.C 
-      -Added macro to analyze data
-
-   * meth/macros/analysis_read.C 
-      -Added macro that reads the output of analysis.C	
-
- 2004/06/24: Nicola Galante
-
-   * mpisa/macros/AlphaPlot.C
-     -Added a new macro to plot eccess in alpha
-
- 2004/05/26: Nicola Galante
-
-   * mpisa/macros/timedist3.C
-     - Added a new macro to plot signal time distributions
-
- 2004/05/26: Nicola Galante
-
-   * mpisa/macros/production3.C
-     - Added a new production macro. It is based on 
-       bootcampstandardanalisys.C
-
- 2004/05/23: Thomas Hengstebeck
-   * mberlin/macros/ScaleHillas.C , SrcCorrect.C , Convert2Matrix.C , 
-     CutOptim.C , AlphaPlot.C , IOMkn421.h
-     - Added analysis macros
-
-
- 2004/05/18: Daniel Mazin
-   * mmpi/macros/hillasread.C  
-     - Removed a small bug
-
-   * mmpi/macros/callalphaplot.C
-     - Added. macro to produce an alpha plot for a chosen position in the sky map
-     - Derotation is possible if theta and phi for each event are available 
-     - Using OFF data to estimate significance is optional 
-
- 2004/05/18: Sebastian Commichau
-   * meth/MHillasSrc.cc/h
-     - Added. This is a modified version, containing now
-       the DCA parameter.
-
-   * meth/MDCACalc.cc/h, MDCA.cc/h
-     - Added. Based on MHillasCalc/MHillas, it calculates
-       the DCA parameter and provides a nice draw function
-
- 2004/05/17: Daniel Mazin
-   * mmpi/macros 
-     - Added to put analysis macros there
-
-   * mmpi/macros/callcleaning.C , cleaninghillas.C
-     - Added. macros to make cleaning and calculate Hillas parameters
-	
-   * mmpi/macros/mtools.C
-     -Added. some simple mathematical functions 
-
-   * mmpi/macros/falsesourcemethod.C, skyplot.h, hillasread.C, gridloop.C
-     -Added. macros to produce 2D plots of False Source Method 
-
- 2004/04/28: Javier Rico
-   * mifae/Changelog
-     - Added. Next changes in directory mifae will be reported 
-       exclusively in there
-
-	
- 2004/04/27: Javier Rico
-   * mifae
-     - Add new directory for IFAE temporal stuff
-	
-   * mifae/Makefile,IFAEIncl.h,IFAELinkDef.h
-     - Add basic stuff to run the directory
-	
-   * mifae/MDCA.[h,cc]
-     - Add Commichau & Starks's MDCA (provisional)
-
-   * mifae/makeHillas.cc,makehillas.datacard
-     - Add program to generate hillas parameters' file
Index: trunk/MagicSoft/Mars/mtemp/MFindStars.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MFindStars.cc	(revision 7136)
+++ 	(revision )
@@ -1,1278 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Robert Wagner,   2/2004 <mailto:rwagner@mppmu.mpg.de>
-!              Javier López ,   4/2004 <mailto:jlopez@ifae.es>
-!              Wolfgang Wittek, 8/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MFindStars
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MFindStars.h"
-
-#include <TMinuit.h>
-#include <TStopwatch.h>
-#include <TTimer.h>
-#include <TString.h>
-#include <TFile.h>
-#include <TTree.h>
-#include <TCanvas.h>
-#include <TH1F.h>
-#include <TF1.h>
-#include <TEllipse.h>
-
-
-#include "MObservatory.h"
-#include "MAstroCamera.h"
-#include "MMcConfigRunHeader.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MHCamera.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-#include "MCameraDC.h"
-#include "MTime.h"
-#include "MReportDrive.h"
-#include "MStarCam.h"
-#include "MStarPos.h"
-
-#include "MParList.h"
-#include "MTaskList.h"
-
-ClassImp(MFindStars);
-using namespace std;
-
-const Float_t sqrt2 = sqrt(2.);
-const Float_t sqrt3 = sqrt(3.);
-const UInt_t  lastInnerPixel = 396;
-    
-
-//______________________________________________________________________________
-//
-// The 2D uncorrelated gaussian function used to fit the spot of the star
-//
-static Double_t func(float x,float y,Double_t *par)
-{
-    Double_t value=par[0]*exp( -(x-par[1])*(x-par[1])/(2*par[2]*par[2]) )
-                         *exp( -(y-par[3])*(y-par[3])/(2*par[4]*par[4]) );
-    return value;
-}
-
-//______________________________________________________________________________
-//
-// The 2D correlated gaussian function used to fit the spot of the star
-//
-static Double_t funcCG(float x,float y,Double_t *par)
-{
-  Double_t temp  = 1.0-par[5]*par[5];
-  //  Double_t value = par[0] / (2.0*TMath::Pi()*par[2]*par[4]*sqrt(temp))
-  Double_t value = par[0] 
-    * exp( -0.5/temp * (   (x-par[1])*(x-par[1])/(par[2]*par[2])
-	     -2.0*par[5] * (x-par[1])*(y-par[3])/(par[2]*par[4])
-			 + (y-par[3])*(y-par[3])/(par[4]*par[4]) ) );
-    return value;
-}
-
-//______________________________________________________________________________
-//
-// Function used by Minuit to do the fit
-//
-static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
-{
-
-  MParList*      plist = (MParList*)gMinuit->GetObjectFit();
-  MTaskList*     tlist = (MTaskList*)plist->FindObject("MTaskList");
-  MFindStars*    find  = (MFindStars*)tlist->FindObject("MFindStars");
-  MStarCam* stars = 
-          (MStarCam*)plist->FindObject("MStarCam","MStarCam");
-  MGeomCam*      geom  = (MGeomCam*)plist->FindObject("MGeomCam");
-
-  MHCamera& display = (MHCamera&)find->GetDisplay();
-  
-  Float_t innerped = stars->GetInnerPedestalDC();
-  Float_t innerrms = stars->GetInnerPedestalRMSDC();
-  Float_t outerped = stars->GetOuterPedestalDC();
-  Float_t outerrms = stars->GetOuterPedestalRMSDC();
-
-  UInt_t numPixels = geom->GetNumPixels();
-  
-
-//calculate chisquare
-    Double_t chisq = 0;
-    Double_t delta;
-    Double_t x,y,z;
-    Double_t errorz=0;
-
-    UInt_t usedPx=0;
-    for (UInt_t pixid=1; pixid<numPixels; pixid++) 
-    {
-
-
-	if (display.IsUsed(pixid))
-	{
-	    x = (*geom)[pixid].GetX();
-	    y = (*geom)[pixid].GetY();
-
-            z = display.GetBinContent(pixid+1)
-                -  (pixid>lastInnerPixel?outerped:innerped);
-            errorz=(pixid>lastInnerPixel?outerrms:innerrms);
-
-
-	    if (errorz > 0.0)
-	    {
-              usedPx++;
-
-              Double_t fu;
-              if (find->GetUseCorrelatedGauss())
-                fu = funcCG(x,y,par);
-              else
-                fu = func(x,y,par);
-
-              delta  = (z-fu) / errorz;
-              chisq += delta*delta; 
-
-              if (iflag == 3)
-	      {
-                gLog  << "fcn : usedPx, pixid, content, pedestal,z, fu, errorz, delta = "
-                      << usedPx << ",  " << pixid << ",  "
-                      << display.GetBinContent(pixid+1) << ",  "
-                      << (pixid>lastInnerPixel?outerped:innerped)
-                      << ",  " << z << ",  " << fu << ",  " << errorz 
-                      << ",  " << delta << endl;
-	      }
-	    }
-	    else
-		cerr << " TMinuit::fcn errorz[" << pixid << "] " << errorz << endl;
-	}
-    }
-    f = chisq;
-
-    find->SetChisquare(chisq);
-    find->SetDegreesofFreedom(usedPx);
-
-    //gLog << "fcn : chisq, usedPx = " << chisq << ",  " << usedPx << endl;
-}
-
-//-------------------------------------------------------------------------
-//
-// Constructor
-//
-
-MFindStars::MFindStars(const char *name, const char *title): 
-  fGeomCam(NULL), fCurr(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL), 
-  fNumVar(6)
-{
-  fName  = name  ? name  : "MFindStars";
-  fTitle = title ? title : "Tool to find stars from DC Currents";
-
-  // the correlated Gauss function  
-  // is fitted by default
-  fNumVar = 6;
-  fUseCorrelatedGauss = kTRUE;
-
-  fNumIntegratedEvents=0;
-  fMaxNumIntegratedEvents = 10;
-  fRingInterest = 125.; //[mm] ~ 0.4 deg
-  fDCTailCut = 4;
-  
-  fPixelsUsed.Set(577);
-  fPixelsUsed.Reset((Char_t)kTRUE);
-  
-  //Fitting(Minuit) initialitation
-  const Float_t pixelSize = 31.5; //[mm]
-  fMinuitPrintOutLevel = -1;
-  //fMinuitPrintOutLevel = 3;
-  
-  fVname = new TString[fNumVar];
-  fVinit.Set(fNumVar); 
-  fStep.Set(fNumVar); 
-  fLimlo.Set(fNumVar); 
-  fLimup.Set(fNumVar); 
-  fFix.Set(fNumVar);
-
-  fVname[0] = "max";
-  fVinit[0] = 10.*fMaxNumIntegratedEvents;
-  fStep[0]  = fVinit[0]/sqrt2;
-  fLimlo[0] = fMinDCForStars;
-  fLimup[0] = 30.*fMaxNumIntegratedEvents;
-  fFix[0]   = 0;
-
-  fVname[1] = "meanx";
-  fVinit[1] = 0.;
-  fStep[1]  = fVinit[1]/sqrt2;
-  fLimlo[1] = -600.;
-  fLimup[1] = 600.;
-  fFix[1]   = 0;
-
-  fVname[2] = "sigmax";
-  fVinit[2] = pixelSize;
-  fStep[2]  = fVinit[2]/sqrt2;
-  fLimlo[2] = pixelSize/(2*sqrt3);
-  fLimup[2] = 500.;
-  fFix[2]   = 0;
-
-  fVname[3] = "meany";
-  fVinit[3] = 0.;
-  fStep[3]  = fVinit[3]/sqrt2;
-  fLimlo[3] = -600.;
-  fLimup[3] = 600.;
-  fFix[3]   = 0;
-
-  fVname[4] = "sigmay";
-  fVinit[4] = pixelSize;
-  fStep[4]  = fVinit[4]/sqrt2;
-  fLimlo[4] = pixelSize/(2*sqrt3);
-  fLimup[4] = 500.;
-  fFix[4]   = 0;
-
-  if (fUseCorrelatedGauss)
-  {
-    fVname[5] = "xycorr";
-    fVinit[5] = 0.0;
-    fStep[5]  = 0.1;
-    fLimlo[5] = -1.0;
-    fLimup[5] =  1.0;
-    fFix[5]   = 0;
-  }
-
-  fObjectFit  = NULL;
-  //  fMethod     = "SIMPLEX";
-  fMethod     = "MIGRAD";
-  //  fMethod     = "MINIMIZE";
-  fNulloutput = kFALSE;
-
-  // Set output level
-  //  fLog->SetOutputLevel(3); // No dbg messages
-
-  fGeometryFile="";
-  fBSCFile="";
-}
-
-//-------------------------------------------------------------------------
-//
-// Set 'fUseCorrelatedGauss' flag
-//
-//     if 'fUseCorrelatedGauss' is TRUE a 2dim Gaussian with correlation
-//                                 will be fitted
-//
-
-void MFindStars::SetUseCorrelatedGauss(Bool_t usecorrgauss)
-{
-  fUseCorrelatedGauss = usecorrgauss;
-
-  if (usecorrgauss)
-    fNumVar = 6;
-  else
-    fNumVar = 5;
-}
-
-//-------------------------------------------------------------------------
-//
-// PreProcess
-//
-
-Int_t MFindStars::PreProcess(MParList *pList)
-{
-
-    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-
-    if (!fGeomCam)
-    {
-      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-
-    // Initialize camera display with the MGeomCam information
-    fDisplay.SetGeometry(*fGeomCam,"FindStarsDisplay","FindStarsDisplay");
-    fDisplay.SetUsed(fPixelsUsed);
-
-    fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
-
-    if (!fCurr)
-    {
-      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-
-    fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
-
-    if (!fTimeCurr)
-    {
-      *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-
-    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
-
-    if (!fDrive)
-      {
-
-        *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... ignored." << endl;
-
-      }
-    else
-      {
-	
-	MObservatory magic1;
-
-	MMcConfigRunHeader *config=0;
-	MGeomCam           *geom=0;
-
-	TFile file(fGeometryFile);
-	TTree *tree = (TTree*)file.Get("RunHeaders");
-	tree->SetBranchAddress("MMcConfigRunHeader", &config);
-	if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
-	tree->GetEntry(0);
-	
-	fAstro.SetMirrors(*config->GetMirrors());
-	fAstro.SetGeom(*geom);	
-	fAstro.ReadBSC(fBSCFile);
-	
-	fAstro.SetObservatory(magic1);
-	
-      }
-    
-
-    fStars = (MStarCam*)pList->FindCreateObj(AddSerialNumber("MStarCam"),"MStarCam");
-    if (!fStars)
-    {
-      *fLog << err << AddSerialNumber("MStarCam") << " cannot be created ... aborting" << endl;
-      return kFALSE;
-    }
-
-    fMinDCForStars = 1.*fMaxNumIntegratedEvents; //[uA]
-
-    // Initialize the TMinuit object
-
-    TMinuit *gMinuit = new TMinuit(fNumVar);  //initialize TMinuit with a maximum of params
-    gMinuit->SetFCN(fcn);
-
-    Double_t arglist[10];
-    Int_t ierflg = 0;
-
-    arglist[0] = 1;
-    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
-    arglist[0] = fMinuitPrintOutLevel;
-    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
-
-    // suppress warnings
-    Int_t errWarn;
-    Double_t tmpwar = 0;
-    gMinuit->mnexcm("SET NOW", &tmpwar, 0, errWarn);
-
-
-    // Set MParList object pointer to allow mimuit to access internally
-    gMinuit->SetObjectFit(pList);
-
-    return kTRUE;
-}
-
-//------------------------------------------------------------------------
-//
-// Process :
-//              
-//
-//
-//
-
-Int_t MFindStars::Process()
-{
-
-  UInt_t numPixels = fGeomCam->GetNumPixels();
-  TArrayC origPixelsUsed;
-  origPixelsUsed.Set(numPixels);
-
-  if (fNumIntegratedEvents >= fMaxNumIntegratedEvents) {
-
-    //Fist delete the previous stars in the list
-    fStars->GetList()->Delete();
-
-    if (fDrive) {
-
-      //If drive information is provided we take RaDec info
-      //from the drive and let the star list fill by the astrocamera.
-
-      //FIXME: rwagner: Doesn't work as expected
-      //FIXME: rwagner: For the time being set manually.
-      //fAstro.SetRaDec(fDrive->GetRa(), fDrive->GetDec());              
-
-      fAstro.SetTime(*fTimeCurr);
-      fAstro.SetGuiActive();
-      fAstro.FillStarList(fStars->GetList());      
-
-      //cout << "Number of Stars added by astrocamera is " 
-      //     <<fStars->GetList()->GetSize() << endl;
-      
-      MStarPos* starpos;
-      TIter Next(fStars->GetList());
-      while ((starpos=(MStarPos*)Next())) {
-	//starpos->SetCalcValues(40,40,starpos->GetXExp(), starpos->GetYExp(),
-        //                       fRingInterest/2,          fRingInterest/2,
-        //                       0.,   0., 0., 0.);
-	//starpos->SetFitValues (40,40,starpos->GetXExp(), starpos->GetYExp(),
-        //                       fRingInterest/2,          fRingInterest/2, 0.,
-        //                       0., 0., 0.,   0., -1);
-      }
-
-      for (UInt_t pix=1; pix<numPixels; pix++) {
-	if (fDisplay.IsUsed(pix))
-	  origPixelsUsed[pix]=(Char_t)kTRUE;
-	else
-	  origPixelsUsed[pix]=(Char_t)kFALSE;
-      }
-      
-      DCPedestalCalc();
-
-    } 
-    else 
-    {
-      
-      cout << "No drive information available: Will not use a star catalog to identify stars."<< endl;
-      
-      for (UInt_t pix=1; pix<numPixels; pix++) {
-	if (fDisplay.IsUsed(pix))
-	  origPixelsUsed[pix]=(Char_t)kTRUE;
-	else
-	  origPixelsUsed[pix]=(Char_t)kFALSE;
-      }
-          
-      if (DCPedestalCalc()) {
-
-	Float_t innermin = fStars->GetInnerPedestalDC()+fDCTailCut*fStars->GetInnerPedestalRMSDC();
-	Float_t outermin = fStars->GetOuterPedestalDC()+fDCTailCut*fStars->GetOuterPedestalRMSDC();
-	fMinDCForStars = innermin>outermin?innermin:outermin;
-	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars = " << fMinDCForStars << endl;
-              
-	// Find the star candidates searching the most brights pairs of pixels
-	Float_t maxPixelDC;
-	MGeomPix maxPixel;
-	
-	while(FindPixelWithMaxDC(maxPixelDC, maxPixel)) {
-	  MStarPos *starpos = new MStarPos;
-
-  	  starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY());
-
-	  //starpos->SetCalcValues(maxPixelDC,      maxPixelDC,
-          //                       maxPixel.GetX(), maxPixel.GetY(),
-          //                       fRingInterest/2, fRingInterest/2,
-          //                       0.,   0., 0., 0.);
-
-	  //starpos->SetFitValues(maxPixelDC,      maxPixelDC,
-          //                      maxPixel.GetX(), maxPixel.GetY(),
-          //                      fRingInterest/2, fRingInterest/2, 0.,
-          //                      0., 0., 0.,      0., -1);
-
-	  fStars->GetList()->Add(starpos);
-	  ShadowStar(starpos);
-	}	
-	fDisplay.SetUsed(origPixelsUsed);
-      }      
-    }
-
-    //Show the stars found
-    //fStars->Print("namepossizechierr");
-   
-    //loop to extract position of stars on the camera
-    if (fStars->GetList()->GetSize() == 0) {
-      *fLog << err << GetName() << "No stars candidates in the camera." << endl;
-      return kCONTINUE;
-    } else
-    {
-      //*fLog << inf << GetName() << " found " << fStars->GetList()->GetSize() 
-      //	    << " star candidates in the camera." << endl;
-    }    
-
-    for (UInt_t pix=1; pix<numPixels; pix++) {
-      if (fDisplay.IsUsed(pix))
-	origPixelsUsed[pix]=(Char_t)kTRUE;
-      else
-	origPixelsUsed[pix]=(Char_t)kFALSE;
-    }
-
-    TIter Next(fStars->GetList());
-    MStarPos* star;
-    while ((star=(MStarPos*)Next())) {
-       FindStar(star);
-       ShadowStar(star);
-    }
-
-    //Show the stars found: Here it is interesting to see what FindStars
-    //made out of the positions we gave to it.
-    if (fMinuitPrintOutLevel>=0)
-      fStars->Print("namepossizchierr");
-
-    //After finding stars reset all variables
-    fDisplay.Reset();
-    fStars->GetDisplay().Reset(); //FIXME: Put this display just in the container
-    fDisplay.SetUsed(origPixelsUsed);
-    fNumIntegratedEvents=0;
-  }
-
-  for (UInt_t pix=1; pix<numPixels; pix++) {
-    if (fDisplay.IsUsed(pix))
-      origPixelsUsed[pix]=(Char_t)kTRUE;
-    else
-      origPixelsUsed[pix]=(Char_t)kFALSE;
-    
-  }
-  
-  fDisplay.AddCamContent(*fCurr);
-  fNumIntegratedEvents++;
-  fDisplay.SetUsed(origPixelsUsed);
-  
-  return kTRUE;
-}
-
-Int_t MFindStars::PostProcess()
-{
-  return kTRUE;
-}
-
-void MFindStars::SetBlindPixels(TArrayS blindpixels)
-{
-    Int_t npix = blindpixels.GetSize();
-
-    for (Int_t idx=0; idx<npix; idx++)
-      {
-	fPixelsUsed[blindpixels[idx]]=(Char_t)kFALSE;
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx]  << ") kFALSE" << endl;
-      }
-    
-    fDisplay.SetUsed(fPixelsUsed);
-}
-
-//-------------------------------------------------------------------------
-//
-// DCPedestalCalc :
-//
-//  
-//
-//
-
-Bool_t MFindStars::DCPedestalCalc()
-{
-    //-------------------------------------------------------------
-    // save pointer to the MINUIT object for optimizing the supercuts
-    // because it will be overwritten 
-    // when fitting the alpha distribution in MHFindSignificance
-    TMinuit *savePointer = gMinuit;
-    //-------------------------------------------------------------
-
-   UInt_t numPixels = fGeomCam->GetNumPixels();
-   Float_t ped;
-   Float_t rms;
-
-   //TH1F **dchist = new TH1F*[2];
-   TH1F *dchist[2];
-   TString tit;
-   TString nam;
-   for (UInt_t i=0; i<2; i++)
-   {
-      nam = i;
-      tit = "dchist[";
-      tit += i;
-      tit += "]";
-      dchist[i] = new TH1F(nam, tit,
-                  26,0.4*fMaxNumIntegratedEvents,3.*fMaxNumIntegratedEvents);
-   }   
-
-   for (UInt_t pix=1; pix<=lastInnerPixel; pix++)
-       dchist[0]->Fill(fDisplay.GetBinContent(pix+1));
-   for (UInt_t pix=lastInnerPixel+1; pix<numPixels; pix++)
-       dchist[1]->Fill(fDisplay.GetBinContent(pix+1));
-
-   // inner/outer pixels
-   for (UInt_t i=0; i<2; i++)
-   {
-      Float_t nummaxprobdc = dchist[i]->GetBinContent(dchist[i]->GetMaximumBin());
-      Float_t maxprobdc = dchist[i]->GetBinCenter(dchist[i]->GetMaximumBin());
-      UInt_t bin = dchist[i]->GetMaximumBin();
-      do
-        {
-          bin++;
-        }
-      while(dchist[i]->GetBinContent(bin)/nummaxprobdc > 0.5);
-      Float_t halfmaxprobdc = dchist[i]->GetBinCenter(bin);
-      
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] ";
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist[i]->GetBinContent(bin) << "]" << endl;
-      
-      Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc);
-      Float_t min = maxprobdc-3*rmsguess;
-      min = (min<0.?0.:min);
-      Float_t max = maxprobdc+3*rmsguess;
-      
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
-      
-      TF1 func("func","gaus",min,max);
-      func.SetParameters(nummaxprobdc, maxprobdc, rmsguess);
-      
-      dchist[i]->Fit("func","QR0");
-      
-      UInt_t aproxnumdegrees = 6*(bin-dchist[i]->GetMaximumBin());
-      Float_t chiq = func.GetChisquare();
-      ped = func.GetParameter(1);
-      rms = func.GetParameter(2);
-      
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
-      
-      Int_t numsigmas = 5;
-      Axis_t minbin = ped-numsigmas*rms/dchist[i]->GetBinWidth(1);
-      minbin=minbin<1?1:minbin;
-      Axis_t maxbin = ped+numsigmas*rms/dchist[i]->GetBinWidth(1);
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist[i]->Integral((int)minbin,(int)maxbin) << endl;
-      
-      //Check results from the fit are consistent
-      if (ped < 0. || rms < 0.)
-        {
-          *fLog << dbg << "dchist[i]->GetEntries()" << dchist[i]->GetEntries();
-//            TCanvas *c1 = new TCanvas("c2","c2",500,800);
-//            dchist[i]->Draw();
-//            c1->Print("dchist.ps");
-//            delete c1;
-//            exit(1);
-        }
-      else if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess)
-        {
-          *fLog << warn << GetName() << " Pedestal DC fit give non consistent results for " << (i==0?"Inner":"Outer") << "pixels." << endl;
-          *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
-          *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
-          ped = maxprobdc;
-          rms = rmsguess/1.175; // FWHM=2.35*rms
-        }
-   
-      if (i == 0)
-        {
-          fStars->SetInnerPedestalDC(ped);
-          fStars->SetInnerPedestalRMSDC(rms);
-        }
-      else
-        {
-          fStars->SetOuterPedestalDC(ped);
-          fStars->SetOuterPedestalRMSDC(rms);
-        }
-   }
-   
-
-
-   for (UInt_t i=0; i<2; i++)
-   {
-      delete dchist[i];
-   }
-   //delete [] dchist;
-
-   //=================================================================
-
-   // reset gMinuit to the MINUIT object for optimizing the supercuts 
-   gMinuit = savePointer;
-   //-------------------------------------------
-   
-   if (fStars->GetInnerPedestalDC() < 0. ||  fStars->GetInnerPedestalRMSDC() < 0. || fStars->GetOuterPedestalDC() < 0. ||  fStars->GetOuterPedestalRMSDC() < 0.)
-     return kFALSE;
-  
-   return kTRUE;
-}
-    
-Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix)
-{
-    UInt_t numPixels = fGeomCam->GetNumPixels();
-
-// Find the two close pixels with the maximun dc
-    UInt_t maxPixIdx[2];
-
-    maxDC = 0;
-
-    for (UInt_t pix=1; pix<numPixels; pix++)
-    {
-	if(fDisplay.IsUsed(pix))
-	{
-	    Float_t dc[2];
-	    dc[0] = fDisplay.GetBinContent(pix+1);
-	    if (dc[0] < fMinDCForStars)
-		continue;
-
-	    MGeomPix &g = (*fGeomCam)[pix];
-	    Int_t numNextNeighbors = g.GetNumNeighbors();
-	    
-	    Float_t dcsum;
-	    for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
-	    {
-              UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
-              if(fDisplay.IsUsed(swneighbor))
-                {
-                  dc[1] = fDisplay.GetBinContent(swneighbor+1);
-                  if (dc[1] < fMinDCForStars)
-                    continue;
-                  
-                  dcsum = dc[0] + dc[1];
-                  
-                  if(dcsum > maxDC*2)
-                    {
-                      if(dc[0]>=dc[1])
-                        {
-                          maxPixIdx[0] = pix;
-                          maxPixIdx[1] = swneighbor;
-                          maxDC = dc[0];
-                        }
-                      else
-                        {
-                          maxPixIdx[1] = pix;
-                          maxPixIdx[0] = swneighbor;
-                          maxDC = dc[1];
-                        }
-                    }	
-                }
-            }
-        }
-    }
-
-    if (maxDC == 0)
-      {
-        *fLog << warn << " No found pixels with maximum dc" << endl;
-	return kFALSE;
-      }
-    
-    maxPix = (*fGeomCam)[maxPixIdx[0]];
-
-    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() <<  " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl;
-
-    return kTRUE;
-}
-
-
-//----------------------------------------------------------------------------
-//
-// FindStar
-//
-//
-//
-
-Bool_t MFindStars::FindStar(MStarPos* star)
-{    
-  UInt_t numPixels = fGeomCam->GetNumPixels();
-  Float_t innerped = fStars->GetInnerPedestalDC();
-  Float_t outerped = fStars->GetOuterPedestalDC();
-
-  TArrayC origPixelsUsed;
-  origPixelsUsed.Set(numPixels);
-  
-  for (UInt_t pix=1; pix<numPixels; pix++)
-    {
-      if (fDisplay.IsUsed(pix))
-        origPixelsUsed[pix]=(Char_t)kTRUE;
-      else
-        origPixelsUsed[pix]=(Char_t)kFALSE;
-    }
-  
-  Float_t expX = star->GetXExp();
-  Float_t expY = star->GetYExp();
-
-  Float_t max         =0;
-  UInt_t  pixmax      =0;
-  Float_t meanX       =0;
-  Float_t meanY       =0;
-  Float_t meanSqX     =0;
-  Float_t meanSqY     =0;
-  Float_t sumCharge   =0;
-  Float_t sumSqCharge =0;
-  UInt_t  usedInnerPx =0;	
-  UInt_t  usedOuterPx =0;	
-  Float_t factor = 1.0;
-
-  Float_t meanXold = 1.e10;
-  Float_t meanYold = 1.e10;
-
-  const Float_t meanPresition = 3.; //[mm]
-  const UInt_t maxNumIterations = 10;
-  UInt_t numIterations = 0;
-
-  //--------------------   start of iteration loop   -----------------------
-  for (UInt_t it=0; it<maxNumIterations; it++)
-  {
-      //rwagner: Need to find px with highest dc and need to assume it is
-      // somewhere near the center of the star
-      //after that we need to REDEFINE our roi! because expected pos could be
-      // quite off that px!
-      
-      // 1.) Initial roi around expected position
-
-      for (UInt_t pix=1; pix<numPixels; pix++)
-	{
-	  
-	  Float_t pixXpos=(*fGeomCam)[pix].GetX();
-	  Float_t pixYpos=(*fGeomCam)[pix].GetY();
-	  Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
-			      (pixYpos-expY)*(pixYpos-expY));
-	  
-	  if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
-	    fPixelsUsed[pix]=(Char_t)kTRUE;
-	  else
-	    fPixelsUsed[pix]=(Char_t)kFALSE;
-	}
-      fDisplay.SetUsed(fPixelsUsed);
-
-      // 2.) Find px with highest dc in that region
-
-      max    = 0.0;
-      pixmax =   0;
-      for(UInt_t pix=0; pix<numPixels; pix++)	
-	if(fDisplay.IsUsed(pix))
-	  {
-	    Float_t charge  = fDisplay.GetBinContent(pix+1);	      
-	    if (charge>max)
-	      {
-		max=charge;
-		pixmax=pix;
-	      }
-	  }         
-
-      // 3.) make it new center
-
-      expX = (*fGeomCam)[pixmax].GetX();
-      expY = (*fGeomCam)[pixmax].GetY();
-
-      for (UInt_t pix=1; pix<numPixels; pix++)
-	fPixelsUsed[pix]=(Char_t)kTRUE;       
-      fDisplay.SetUsed(fPixelsUsed);
-
-      // First define a area of interest around the expected position of the star
-      for (UInt_t pix=1; pix<numPixels; pix++)
-	{
-	  Float_t pixXpos=(*fGeomCam)[pix].GetX();
-	  Float_t pixYpos=(*fGeomCam)[pix].GetY();
-	  Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
-			      (pixYpos-expY)*(pixYpos-expY));
-	  
-	  if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
-	    fPixelsUsed[pix]=(Char_t)kTRUE;
-	  else
-	    fPixelsUsed[pix]=(Char_t)kFALSE;
-	}
-  
-      fDisplay.SetUsed(fPixelsUsed);
-    
-      // determine mean x and mean y
-      max         = 0.0;
-      pixmax      =   0;
-      meanX       = 0.0;
-      meanY       = 0.0;
-      meanSqX     = 0.0;
-      meanSqY     = 0.0;
-      sumCharge   = 0.0;
-      sumSqCharge = 0.0;
-      usedInnerPx =   0;	
-      usedOuterPx =   0;	
-
-      for(UInt_t pix=0; pix<numPixels; pix++)
-	{
-	  if(fDisplay.IsUsed(pix))
-	    {
-	      pix>lastInnerPixel?usedOuterPx++:usedInnerPx++;
-	      
-	      Float_t charge  = fDisplay.GetBinContent(pix+1);
-	      Float_t pixXpos = (*fGeomCam)[pix].GetX();
-	      Float_t pixYpos = (*fGeomCam)[pix].GetY();
-	      
-	      if (charge>max)
-		{
-		  max=charge;
-		  pixmax=pix;
-		}
-	      
-	      meanX     += charge*pixXpos;
-	      meanY     += charge*pixYpos;
-	      meanSqX   += charge*pixXpos*pixXpos;
-	      meanSqY   += charge*pixYpos*pixYpos;
-	      sumCharge   += charge;
-	      sumSqCharge += charge*charge;
-	    }
-	} 
-      
-      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " usedInnerPx " << usedInnerPx << " usedOuterPx " << usedOuterPx << endl;
-      
-      meanX   /= sumCharge;
-      meanY   /= sumCharge;
-      meanSqX /= sumCharge;
-      meanSqY /= sumCharge;
-      factor = sqrt( sumSqCharge/(sumCharge*sumCharge) );
-
-      // stop iteration when (meanX, meanY) becomes stable
-      if ( TMath::Abs(meanX-meanXold) < meanPresition  && 
-           TMath::Abs(meanY-meanYold) < meanPresition    )
-        break;
-
-      meanXold = meanX;
-      meanYold = meanY;
-      numIterations++;
-  }
-  // this statement was commented out because the condition 
-  // was never fulfilled :
-  //while(TMath::Abs(meanX-expX) > meanPresition || 
-  //      TMath::Abs(meanY-expY) > meanPresition);
-  //--------------------   end of iteration loop   -----------------------
-
-  if (numIterations >=  maxNumIterations)
-  {
-     *fLog << warn << GetName() << "Mean calculation not converged after " 
-           << maxNumIterations << " iterations" << endl;
-  }
-  
-
-  //Float_t rmsX = (meanSqX - meanX*meanX) - fRingInterest*fRingInterest/12;
-  //Float_t rmsY = (meanSqY - meanY*meanY) - fRingInterest*fRingInterest/12;
-
-  Float_t rmsX = (meanSqX - meanX*meanX);
-  Float_t rmsY = (meanSqY - meanY*meanY);
-  
-  if ( rmsX > 0)
-    rmsX =  TMath::Sqrt(rmsX);
-  else
-    {
-      *fLog << warn << " MFindStars::FindStar negative rmsX² " << rmsX << endl;
-      *fLog << warn << " meanSqX " << meanSqX << " meanX " << meanX << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge << endl;
-      rmsX = 0.;
-    }
-  
-  if ( rmsY > 0)
-    rmsY =  TMath::Sqrt(rmsY);
-  else
-    {
-      *fLog << warn << " MFindStars::FindStar negative rmsY² " << rmsY << endl;
-      *fLog << warn << " meanSqY " << meanSqY << " meanY " << meanY << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge<< endl;
-      rmsY = 0.;
-    }
-  
-  Float_t deltameanX = factor * rmsX;
-  Float_t deltameanY = factor * rmsY;
-
-
-  // Substrack pedestal DC
-  sumCharge-= (usedInnerPx*innerped+usedOuterPx*outerped)/(usedInnerPx+usedOuterPx);
-  max-=pixmax>lastInnerPixel?outerped:innerped;
-  
-  
-  star->SetCalcValues( sumCharge, max, meanX, meanY, rmsX, rmsY,
-                       0.,   deltameanX*deltameanX, 0., deltameanY*deltameanY);
-  
-  if (rmsX <= 0. || rmsY <= 0.)
-    return kFALSE;
-    
-    
-// fit the star spot using TMinuit
-
-    
-    for (UInt_t pix=1; pix<numPixels; pix++)
-      if (fDisplay.IsUsed(pix))
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl;
-  
-    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars " << fMinDCForStars << " pixmax>lastInnerPixel?outerped:innerped " << (pixmax>lastInnerPixel?outerped:innerped) << " fMaxNumIntegratedEvents " << fMaxNumIntegratedEvents << endl;
-
-  //Initialize variables for fit
-    fVinit[0] = max;
-    fLimlo[0] = fMinDCForStars-(pixmax>lastInnerPixel?outerped:innerped);
-    fLimup[0] = 30*fMaxNumIntegratedEvents-(pixmax>lastInnerPixel?outerped:innerped);
-    fVinit[1] = meanX;
-    fVinit[2] = rmsX;
-    fVinit[3] = meanY;
-    fVinit[4] = rmsY;
-    //Init steps
-    for(Int_t i=0; i<fNumVar; i++)
-    {
-	if (fVinit[i] != 0)
-	  fStep[i] = TMath::Abs(fVinit[i]/sqrt2);
-        else
-          fStep[i] = 0.1;
-
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fVinit[" << i << "] " << fVinit[i];
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fStep[" << i << "] " << fStep[i];
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimlo[" << i << "] " << fLimlo[i];
-        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimup[" << i << "] " << fLimup[i] << endl;
-    }
-
-
-    // -------------------------------------------
-    // call MINUIT
-
-    Double_t arglist[10];
-    Int_t ierflg = 0;
-
-    for (Int_t i=0; i<fNumVar; i++)
-      gMinuit->mnparm(i, fVname[i], fVinit[i], fStep[i], fLimlo[i], fLimup[i], ierflg);
-
-    TStopwatch clock;
-    clock.Start();
-
-// Now ready for minimization step
-    arglist[0] = 500;
-    arglist[1] = 1.;
-    gMinuit->mnexcm(fMethod, arglist ,2,ierflg);
-
-    // call fcn with iflag = 3 
-    //arglist[0] = 3;
-    //Int_t ierflg3;
-    //gMinuit->mnexcm("CALL", arglist, 1, ierflg3);     
-
-    clock.Stop();
-
-    if(fMinuitPrintOutLevel>=0)
-      {
-	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Time spent for the minimization in MINUIT :   " << endl;;
-	clock.Print();
-      }
-
-
-    //----------  for the uncorrelated Gauss fit (start)   ---------
-    if (!fUseCorrelatedGauss)
-    {
-      Double_t integratedCharge;
-      Double_t maxFit,   maxFitError;
-      Double_t meanXFit, meanXFitError;
-      Double_t sigmaX,   sigmaXError;
-      Double_t meanYFit, meanYFitError;
-      Double_t sigmaY,   sigmaYError;
-      Float_t  chisquare = GetChisquare();
-      Int_t    degrees  = GetDegreesofFreedom()-fNumVar;
-
-      if (!ierflg)
-      {
-        gMinuit->GetParameter(0, maxFit,   maxFitError);
-        gMinuit->GetParameter(1, meanXFit, meanXFitError);
-        gMinuit->GetParameter(2, sigmaX,   sigmaXError);
-        gMinuit->GetParameter(3, meanYFit, meanYFitError);
-        gMinuit->GetParameter(4, sigmaY,   sigmaYError);
-        
-        //FIXME: Do the integral properlly
-        integratedCharge = 0.;
-      }
-      else
-      {
-        maxFit = 0.;
-        meanXFit = 0.;
-        sigmaX = 0.;
-        meanYFit = 0.;
-        sigmaY = 0.;
-        integratedCharge = 0.;
-
-	*fLog << err << "TMinuit::Call error " << ierflg << endl;
-      }
-
-      // get error matrix
-      Double_t matrix[5][5];
-      gMinuit->mnemat(&matrix[0][0],5);
-
-      star->SetFitValues(integratedCharge,maxFit,       meanXFit,    meanYFit,
-                         sigmaX,          sigmaY,       0.0,
-      	          	 matrix[1][1],    matrix[1][3], matrix[3][3],
-                         chisquare,   degrees);
-    }
-    //----------  for the uncorrelated Gauss fit (end)   ---------    
-
-    //----------  for the correlated Gauss fit (start)   ---------
-    if (fUseCorrelatedGauss)
-    {
-      TArrayD fValues(fNumVar);
-      TArrayD fErrors(fNumVar);
-
-      const static Int_t fNdim = 6;
-      Double_t matrix[fNdim][fNdim];
-
-      Double_t fmin   = 0.0;
-      Double_t fedm   = 0.0;
-      Double_t errdef = 0.0;
-      Int_t npari     =   0;
-      Int_t nparx     =   0;
-      Int_t istat     =   0;
-      gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, istat);
-      if (fMinuitPrintOutLevel>=0)
-      { 
-            *fLog << dbg  
-            << "Status of Correlated Gauss fit to the DC currents : " << endl;
-      }
-      if (fMinuitPrintOutLevel>=0) 
-      {
-            *fLog << dbg 
-            << "       fmin, fedm, errdef, npari, nparx, istat = "
-            << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
-            << ",  " << nparx << ",  " << istat << endl;
-      }
-
-      if (!ierflg)
-      {
-        for (Int_t k=0; k<fNumVar; k++)
-          gMinuit->GetParameter( k, fValues[k], fErrors[k] );
-      }
-      else
-      {
-	*fLog << err << "Correlated Gauss fit failed : ierflg, istat = " 
-              << ierflg << ",  " << istat << endl;
-      }
-
-      Float_t  charge = 0.0;
-      Float_t  chi2   = fmin;
-      Int_t    ndof   = GetDegreesofFreedom()-fNumVar;
-
-      //get error matrix
-      if (istat >= 1)
-      {
-        gMinuit->mnemat( &matrix[0][0], fNdim);
-
-        // copy covariance matrix into a matrix which includes also the fixed
-        // parameters
-        TString  name;
-        Double_t bnd1, bnd2, val, err;
-        Int_t    jvarbl;
-        Int_t    kvarbl;
-        for (Int_t j=0; j<fNumVar; j++)
-        {
-            if (gMinuit)
-                gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
-
-            for (Int_t k=0; k<fNumVar; k++)
-            {
-              if (gMinuit)
-                  gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
-
-              matrix[j][k] = jvarbl==0 || kvarbl==0 ? 0 : matrix[jvarbl-1][kvarbl-1];
-            }
-        }
-      }
-      else
-      {
-        // error matrix was not calculated, construct it
-        if (fMinuitPrintOutLevel>=0)
-	{
-        *fLog << warn 
-              << "error matrix is not defined, construct it" << endl;
-	}
-        for (Int_t j=0; j<fNumVar; j++)
-        {
-          for (Int_t k=0; k<fNumVar; k++)
-              matrix[j][k] = 0;
-
-          matrix[j][j] = fErrors[j]*fErrors[j];
-        }
-      }
-
-      if (fMinuitPrintOutLevel>=0)
-      {
-        *fLog << "Before calling SetFitValues : " << endl; 
-        *fLog << "fValues = " << fValues[0] << ",  " << fValues[1] << ",  "
-              << fValues[2] << ",  " << fValues[3] << ",  " << fValues[4]
-              << ",  " << fValues[5] << endl;
-
-        *fLog << "fErrors = " << fErrors[0] << ",  " << fErrors[1] << ",  "
-              << fErrors[2] << ",  " << fErrors[3] << ",  " << fErrors[4]
-              << ",  " << fErrors[5] << endl;
-
-        *fLog << "error matrix = " << matrix[0][0] << "   " << matrix[0][1]
-                          << "   " << matrix[0][2] << "   " << matrix[0][3]
-                          << "   " << matrix[0][4] << "   " << matrix[0][5]
-              << endl;
-        *fLog << "               " << matrix[1][0] << "   " << matrix[1][1]
-                          << "   " << matrix[1][2] << "   " << matrix[1][3]
-                          << "   " << matrix[1][4] << "   " << matrix[1][5]
-              << endl;
-        *fLog << "               " << matrix[2][0] << "   " << matrix[2][1]
-                          << "   " << matrix[2][2] << "   " << matrix[2][3]
-                          << "   " << matrix[2][4] << "   " << matrix[2][5]
-              << endl;
-        *fLog << "               " << matrix[3][0] << "   " << matrix[3][1]
-                          << "   " << matrix[3][2] << "   " << matrix[3][3]
-                          << "   " << matrix[3][4] << "   " << matrix[3][5]
-              << endl;
-        *fLog << "               " << matrix[4][0] << "   " << matrix[4][1]
-                          << "   " << matrix[4][2] << "   " << matrix[4][3]
-                          << "   " << matrix[4][4] << "   " << matrix[4][5]
-              << endl;
-        *fLog << "               " << matrix[5][0] << "   " << matrix[5][1]
-                          << "   " << matrix[5][2] << "   " << matrix[5][3]
-                          << "   " << matrix[5][4] << "   " << matrix[5][5]
-              << endl;
-      }
-
-      star->SetFitValues(charge,       fValues[0],  fValues[1], fValues[3],
-                         fValues[2],   fValues[4],  fValues[5],
-  	       	         matrix[1][1], matrix[1][3],matrix[3][3],
-                         chi2,         ndof);
-    }
-
-    //----------  for the correlated Gauss fit (end)   ---------    
-
-
-    // reset the display to the starting values
-    fDisplay.SetUsed(origPixelsUsed);
-
-    if (ierflg)
-      return kCONTINUE;
-    return kTRUE;
-}
-
-Bool_t MFindStars::ShadowStar(MStarPos* star)
-{
-    UInt_t numPixels = fGeomCam->GetNumPixels();
-
-// Define an area around the star which will be set unused.
-    UInt_t shadowPx=0;	
-    for (UInt_t pix=1; pix<numPixels; pix++)
-    {
-	Float_t pixXpos  = (*fGeomCam)[pix].GetX();
-	Float_t pixYpos  = (*fGeomCam)[pix].GetY();
-        Float_t starXpos = star->GetMeanX();
-        Float_t starYpos = star->GetMeanY();
-
-        Float_t starSize = 3*sqrt(   star->GetSigmaX()*star->GetSigmaX()
-				   + star->GetSigmaY()*star->GetSigmaY() );
-        
-	Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+
-			    (pixYpos-starYpos)*(pixYpos-starYpos));
-
-        if (dist > starSize && fDisplay.IsUsed(pix))
-	  fPixelsUsed[pix]=(Char_t)kTRUE;
-        else
-          {
-            fPixelsUsed[pix]=(Char_t)kFALSE;
-            shadowPx++;
-          }
-    }
-
-    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " shadowPx " << shadowPx << endl;
-
-    fDisplay.SetUsed(fPixelsUsed);
-
-    return kTRUE;
-}
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MFindStars.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MFindStars.h	(revision 7136)
+++ 	(revision )
@@ -1,123 +1,0 @@
-#ifndef MARS_MFindStars
-#define MARS_MFindStars
-
-#ifndef ROOT_TArrayS
-#include <TArrayS.h>
-#endif
-
-#ifndef ROOT_TArrayC
-#include <TArrayC.h>
-#endif
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef MARS_MHCamera
-#include "MHCamera.h"
-#endif
-
-#ifndef MARS_MAstroCamera
-#include "MAstroCamera.h"
-#endif
-
-class MGeomCam;
-class MGeomPix;
-class MCameraDC;
-class MTime;
-class MReportDrive;
-class MStarCam;
-class MStarPos;
-
-class MFindStars : public MTask
-{
-
-private:
-
-    MGeomCam      *fGeomCam;
-    MCameraDC     *fCurr;
-    MTime         *fTimeCurr;
-    MReportDrive  *fDrive;
-    MStarCam      *fStars;
-
-    MAstroCamera fAstro;
-    TArrayC      fPixelsUsed;
-    MHCamera     fDisplay;
-
-    UInt_t fMaxNumIntegratedEvents;
-    UInt_t fNumIntegratedEvents;
-
-    Float_t fRingInterest; //[mm]
-    Float_t fMinDCForStars; //[uA]
-
-    Float_t fDCTailCut;
-
-    //Fitting(Minuit) variables
-    Int_t fNumVar;
-    Float_t fTempChisquare;
-    Int_t fTempDegreesofFreedom;
-    Int_t fMinuitPrintOutLevel;
-    
-    Bool_t fUseCorrelatedGauss;
-
-    TString *fVname;
-    TArrayD fVinit; 
-    TArrayD fStep; 
-    TArrayD fLimlo; 
-    TArrayD fLimup; 
-    TArrayI fFix;
-    TObject *fObjectFit;
-    TString fMethod;
-    Bool_t fNulloutput;
-    
-    Bool_t DCPedestalCalc();
-    Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix);
-    Bool_t FindStar(MStarPos* star);
-    Bool_t ShadowStar(MStarPos* star);
-
-    TString fGeometryFile;
-    TString fBSCFile;
-
-  public:
-    
-    MFindStars(const char *name=NULL, const char *title=NULL);
-    
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess();
-
-    void SetUseCorrelatedGauss(Bool_t usecorrgauss = kTRUE);
-    Bool_t  GetUseCorrelatedGauss()          {return fUseCorrelatedGauss;}
-
-    // setters
-    void SetNumIntegratedEvents(UInt_t max)  {fMaxNumIntegratedEvents=max;}
-    void SetRingInterest(Float_t ring)       {fRingInterest=ring;}
-    void SetBlindPixels(TArrayS blindpixels);
-    void SetMinuitPrintOutLevel(Int_t level) {fMinuitPrintOutLevel=level;}
-    void SetDCTailCut(Float_t cut)           {fDCTailCut=cut;}
-
-    void SetChisquare(Float_t chi)           {fTempChisquare=chi;}
-    void SetDegreesofFreedom(Int_t free)     {fTempDegreesofFreedom=free;}
-
-    void SetGeometryFile(TString f)          {fGeometryFile=f;}
-    void SetBSCFile(TString f)               {fBSCFile=f;}
-    void SetRaDec(Double_t ra, Double_t dec) {fAstro.SetRaDec(ra,dec);}
-    void SetRaDec(TVector3 &v)               { fAstro.SetRaDec(v); }
-    void SetLimMag(Double_t mag)             { fAstro.SetLimMag(mag); } 
-    void SetRadiusFOV(Double_t deg)          { fAstro.SetRadiusFOV(deg); }
-
-
-    //Getters
-    MHCamera& GetDisplay()           { return fDisplay; }
-    
-    Float_t GetChisquare()           {return fTempChisquare;}
-    Int_t   GetDegreesofFreedom()    {return fTempDegreesofFreedom;}
-    UInt_t  GetNumIntegratedEvents() {return fMaxNumIntegratedEvents;}
-    Float_t GetRingInterest()        {return fRingInterest;}
-    
-  ClassDef(MFindStars, 0) // Tool to find stars from DC Currents
-};
-
-#endif
-
-
Index: trunk/MagicSoft/Mars/mtemp/MHTelAxisFromStars.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MHTelAxisFromStars.cc	(revision 7136)
+++ 	(revision )
@@ -1,638 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Wolfgang Wittek  07/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MHTelAxisFromStars
-//
-// This class contains histograms for MTelAxisFromStars
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MHTelAxisFromStars.h"
-
-#include <math.h>
-
-#include <TH1.h>
-#include <TH2.h>
-#include <TPad.h>
-#include <TStyle.h>
-#include <TCanvas.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-
-#include "MGeomCam.h"
-#include "MBinning.h"
-
-#include "MStarCam.h"
-#include "MStarPos.h"
-#include "MSkyCamTrans.h"
-#include "MSrcPosCam.h"
-
-
-ClassImp(MHTelAxisFromStars);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Setup the histograms 
-//
-MHTelAxisFromStars::MHTelAxisFromStars(const char *name, const char *title)
-    : fMm2Deg(1), fUseMmScale(kFALSE)
-{
-    fName  = name  ? name  : "MHTelAxisFromStars";
-    fTitle = title ? title : "Plots for MTelAxisFromStars";
-
-    fNStars     = new TH1D("NStars", "No. of stars", 10, -0.5, 9.5);
-    fNStars->SetDirectory(NULL);
-    fNStars->SetXTitle("Numder of stars");    
-    fNStars->SetYTitle("Counts");
-
-    fNdoF     = new TH1D("NdoF", "No. of degrees of freedom", 20, -0.5, 19.5);
-    fNdoF->SetDirectory(NULL);
-    fNdoF->SetXTitle("Numder of degrees of freedom");    
-    fNdoF->SetYTitle("Counts");
-
-    fLog10Chi2 = new TH1D("log10Chi2", "log10Chi2", 60, -10, 5);
-    fLog10Chi2->SetDirectory(NULL);
-    fLog10Chi2->SetXTitle("log10(Chi2)");
-    fLog10Chi2->SetYTitle("Counts");
-
-    fChi2Prob = new TH1D("Chi2-Prob", "Chi2 probability",     40,  0.0,  1.0);
-    fChi2Prob->SetDirectory(NULL);
-    fChi2Prob->SetXTitle("Chi2 probability");
-    fChi2Prob->SetYTitle("Counts");
-
-
-    fNumIter  = new TH1D("NumIter", "Number of iterations",   50, -0.5, 49.5);
-    fNumIter->SetDirectory(NULL);
-    fNumIter->SetXTitle("Number of iterations");
-    fNumIter->SetYTitle("Counts");
-
-
-    fLambda   = new TH1D("Lambda", "Scale factor lambda",     80, 0.90, 1.10);
-    fLambda->SetDirectory(NULL);
-    fLambda->SetXTitle("Scale factor lambda");
-    fLambda->SetYTitle("Counts");
-
-
-    fAlfa     = new TH1D("Alfa", "Rotation angle alfa",      100, -2.5,  2.5);
-    fAlfa->SetDirectory(NULL);
-    fAlfa->SetXTitle("Rotation angle alfa [\\circ]");
-    fAlfa->SetYTitle("Counts");
-
-
-    fShift = new TH2D("Shift", "Sky-Cam transformnation : (x,y) shift", 
-                      72, -534.0707, 534.0707, 72, -534.0707, 534.0707);
-    fShift->SetDirectory(NULL);
-    fShift->SetZTitle("Counts");
-    fShift->SetXTitle("x-shift [\\circ]");
-    fShift->SetYTitle("y-shift [\\circ]");
-
-
-    fEstPos1 = new TH2D("EstPos1", "Estimated position1", 
-                      72, -534.0707, 534.0707, 72, -534.0707, 534.0707);
-    fEstPos1->SetDirectory(NULL);
-    fEstPos1->SetZTitle("Counts");
-    fEstPos1->SetXTitle("Estimated position1    x [\\circ]");
-    fEstPos1->SetYTitle("Estimated position1    y [\\circ]");
-
-    fEstPos2 = new TH2D("EstPos2", "Estimated position2", 
-                      72, -534.0707, 534.0707, 72, -534.0707, 534.0707);
-    fEstPos2->SetDirectory(NULL);
-    fEstPos2->SetZTitle("Counts");
-    fEstPos2->SetXTitle("Estimated position2    x [\\circ]");
-    fEstPos2->SetYTitle("Estimated position2    y [\\circ]");
-
-    fEstPos3 = new TH2D("EstPos3", "Estimated position3", 
-                      72, -534.0707, 534.0707, 72, -534.0707, 534.0707);
-    fEstPos3->SetDirectory(NULL);
-    fEstPos3->SetZTitle("Counts");
-    fEstPos3->SetXTitle("Estimated position3    x [\\circ]");
-    fEstPos3->SetYTitle("Estimated position3    y [\\circ]");
-
-
-    // default input type : results from Gauss fit
-    fInputType = 1;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the type of the input
-//
-//     type = 0        calculated star positions (by averaging)
-//     type = 1        fitted star positions (by Gauss fit)
-//
-void MHTelAxisFromStars::SetInputType(Int_t type)
-{
-  *fLog << all << "MHTelAxisFromStars::SetInputType; input type is set equal to : " 
-        << type ;
-
-  if (type == 0)
-    *fLog << " (calculated star positions)" << endl;
-  else
-    *fLog << " (fitted star positions)" << endl;
-
-
-  fInputType = type;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Delete the histograms
-//
-MHTelAxisFromStars::~MHTelAxisFromStars()
-{
-  //*fLog << "MHTelAxisFromStars::Destructor" << endl;
-
-    delete fNStars;
-    delete fNdoF;
-    delete fLog10Chi2;
-    delete fChi2Prob;
-    delete fNumIter;
-    delete fLambda;
-    delete fAlfa;
-
-    delete fShift;
-    delete fEstPos1;
-    delete fEstPos2;
-    delete fEstPos3;
-}
-
-// --------------------------------------------------------------------------
-//
-// Setup the Binning for the histograms. 
-//
-// Find the pointers to the containers.
-//
-// Use this function if you want to set the conversion factor which
-// is used to convert the mm-scale in the camera plane into the deg-scale.
-// The conversion factor is part of the camera geometry. Please create a 
-// corresponding MGeomCam container.
-//
-Bool_t MHTelAxisFromStars::SetupFill(const MParList *plist)
-{
-
-   fStarCam = (MStarCam*)plist->FindObject("MStarCam", "MStarCam");
-   if (!fStarCam)
-   {
-       *fLog << err << "MHTelAxisFromStars::SetupFill; container 'MStarCam' not found... aborting." << endl;
-       return kFALSE;
-   }
-
-   
-   fSourceCam = (MStarCam*)plist->FindObject("MSourceCam", "MStarCam");
-   if (!fSourceCam)
-   {
-       *fLog << err << "MHTelAxisFromStars::SetupFill; container 'MSourceCam' not found... " << endl;
-   }
-   
-
-
-    fSrcPos = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MSrcPosCam"));
-    if (!fSrcPos)
-    {
-        *fLog << err << "MHTelAxisFromStars::SetupFill;  MSrcPosCam not found...  aborting" << endl;
-        return kFALSE;
-    }
-
-    fSkyCamTrans = (MSkyCamTrans*)plist->FindObject(AddSerialNumber("MSkyCamTrans"));
-    if (!fSkyCamTrans)
-    {
-        *fLog << err << "MHTelAxisFromStars::SetupFill;  MSkyCamTrans not found...  aborting" << endl;
-        return kFALSE;
-    }
-
-
-   //------------------------------------------------------------------
-    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
-    if (!geom)
-    {
-        *fLog << warn << GetDescriptor() 
-          << ": No Camera Geometry available. Using mm-scale for histograms." 
-          << endl;
-        SetMmScale(kTRUE);
-    }
-    else
-    {
-        fMm2Deg = geom->GetConvMm2Deg();
-        SetMmScale(kFALSE);
-    }
-
-    ApplyBinning(*plist, "NStars",   fNStars);
-    ApplyBinning(*plist, "NdoF",     fNdoF);
-    ApplyBinning(*plist, "Log10Chi2",fLog10Chi2);
-    ApplyBinning(*plist, "Chi2Prob", fChi2Prob);
-    ApplyBinning(*plist, "NumIter",  fNumIter);
-    ApplyBinning(*plist, "Lambda",   fLambda);
-    ApplyBinning(*plist, "Alfa",     fAlfa);
-
-    const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera");
-    if (!bins)
-    {
-        float r = geom ? geom->GetMaxRadius() : 600;
-        r *= 0.9;
-        if (!fUseMmScale)
-            r *= fMm2Deg;
-
-        MBinning b;
-        b.SetEdges(61, -r, r);
-        SetBinning(fShift,   &b, &b);
-        SetBinning(fEstPos1, &b, &b);
-        SetBinning(fEstPos2, &b, &b);
-        SetBinning(fEstPos3, &b, &b);
-    }
-    else
-    {
-        SetBinning(fShift,   bins, bins);
-        SetBinning(fEstPos1, bins, bins);
-        SetBinning(fEstPos2, bins, bins);
-        SetBinning(fEstPos3, bins, bins);
-    }
-
-    //-------------------------------------------    
-    // copy names from MStarCam to the histograms
-    MStarPos* starpos;
-    Int_t istar = 0;
-    TIter Next(fSourceCam->GetList());
-
-    while ((starpos=(MStarPos*)Next())) {
-      fStarnames[istar] =  starpos->GetName();
-      //*fLog << "istar, star name = " << istar << ",  " 
-      //      << fStarnames[istar] << endl;
-      istar++;
-      if (istar >= fNstarnames) break;
-    }
-
-    if (fSourceCam)
-    {
-      MStarPos *starSource = 0;
-      TIter nextSource(fSourceCam->GetList());
-      while ( (starSource = (MStarPos*)nextSource()) )
-      {
-         if     ( fNstarnames > 0  &&  starSource->GetName() == fStarnames[0] )
-           fEstPos1->SetName(starSource->GetName());
-
-         else if( fNstarnames > 1  &&  starSource->GetName() == fStarnames[1] )
-           fEstPos2->SetName(starSource->GetName());
-
-         else if( fNstarnames > 2  &&  starSource->GetName() == fStarnames[2] )
-           fEstPos3->SetName(starSource->GetName());
-      }
-    }
-    
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Use this function to setup your own conversion factor between degrees
-// and millimeters. The conversion factor should be the one calculated in
-// MGeomCam. Use this function with Caution: You could create wrong values
-// by setting up your own scale factor.
-//
-void MHTelAxisFromStars::SetMm2Deg(Float_t mmdeg)
-{
-    if (mmdeg<0)
-    {
-        *fLog << warn << dbginf 
-              << "Warning - Conversion factor < 0 - nonsense. Ignored." 
-              << endl;
-        return;
-    }
-
-    if (fMm2Deg>=0)
-        *fLog << warn << dbginf 
-              << "Warning - Conversion factor already set. Overwriting" 
-              << endl;
-
-    fMm2Deg = mmdeg;
-}
-
-// --------------------------------------------------------------------------
-//
-// With this function you can convert the histogram ('on the fly') between
-// degrees and millimeters.
-//
-void MHTelAxisFromStars::SetMmScale(Bool_t mmscale)
-{
-    if (fUseMmScale == mmscale)
-        return;
-
-    if (fMm2Deg<0)
-    {
-        *fLog << warn << dbginf 
-         << "Warning - Sorry, no conversion factor for conversion available." 
-         << endl;
-        return;
-    }
-
-    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
-    MH::ScaleAxis(fShift,   scale, scale);
-    MH::ScaleAxis(fEstPos1, scale, scale);
-    MH::ScaleAxis(fEstPos2, scale, scale);
-    MH::ScaleAxis(fEstPos3, scale, scale);
-
-    if (mmscale)
-    {
-        fShift->SetXTitle("x-shift [mm]");
-        fShift->SetYTitle("y-shift [mm]");
-
-        fEstPos1->SetXTitle("Estimated position1 x [mm]");
-        fEstPos1->SetYTitle("Estimated position1 y [mm]");
-
-        fEstPos2->SetXTitle("Estimated position2 x [mm]");
-        fEstPos2->SetYTitle("Estimated position2 y [mm]");
-
-        fEstPos3->SetXTitle("Estimated position3 x [mm]");
-        fEstPos3->SetYTitle("Estimated position3 y [mm]");
-    }
-    else
-    {
-        fShift->SetXTitle("x-shift [\\circ]");
-        fShift->SetYTitle("y-shift [\\circ]");
-
-        fEstPos1->SetXTitle("Estimated position1 x [\\circ]");
-        fEstPos1->SetYTitle("Estimated position1 y [\\circ]");
-
-        fEstPos2->SetXTitle("Estimated position2 x [\\circ]");
-        fEstPos2->SetYTitle("Estimated position2 y [\\circ]");
-
-        fEstPos3->SetXTitle("Estimated position3 x [\\circ]");
-        fEstPos3->SetYTitle("Estimated position3 y [\\circ]");
-    }
-
-    fUseMmScale = mmscale;
-}
-
-// --------------------------------------------------------------------------
-//
-// Fill the histograms 
-// 
-//
-Bool_t MHTelAxisFromStars::Fill(const MParContainer *par, const Stat_t w)
-{
-    Int_t Ndof = fSkyCamTrans->GetNdof();
-    if (Ndof < 0)
-      return kTRUE;
-
-    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
-
-
-    fNStars   ->Fill(fSkyCamTrans->GetNStars(),               w);
-    fNdoF     ->Fill(fSkyCamTrans->GetNdof(),                 w);
-    if (fSkyCamTrans->GetChiSquare() > 0.0)
-      fLog10Chi2->Fill( log10(fSkyCamTrans->GetChiSquare() ), w);
-    fChi2Prob ->Fill(fSkyCamTrans->GetChiSquareProb(),        w);
-    fNumIter  ->Fill(fSkyCamTrans->GetNumIter(),              w);
-    fLambda   ->Fill(fSkyCamTrans->GetLambda(),               w);
-    fAlfa     ->Fill(fSkyCamTrans->GetAlfa(),                 w);
-
-
-    Double_t lowx;
-    Double_t higx;
-    Double_t lowy;
-    Double_t higy;
-    Double_t x;
-    Double_t y;
-    Int_t    nbix;
-    Int_t    nbiy;
-
-    nbix = fShift->GetXaxis()->GetNbins();
-    lowx = fShift->GetXaxis()->GetBinLowEdge(1);
-    higx = fShift->GetXaxis()->GetBinLowEdge(nbix+1);
-
-    nbiy = fShift->GetYaxis()->GetNbins();
-    lowy = fShift->GetYaxis()->GetBinLowEdge(1);
-    higy = fShift->GetYaxis()->GetBinLowEdge(nbiy+1);
-
-    x = scale * (fSkyCamTrans->GetShiftD())[0];
-    y = scale * (fSkyCamTrans->GetShiftD())[1];
-    if (x>lowx  && x<higx  && y>lowy  && y<higy)
-    {
-      fShift    ->Fill(x, y, w);
-    }
-
-    if (fSourceCam)
-    {
-      MStarPos *starSource = 0;
-      TIter nextSource(fSourceCam->GetList());
-
-      while( (starSource = (MStarPos*)nextSource()) )
-      {
-        if (fInputType == 1)
-        {
-          x = scale * starSource->GetMeanXFit(); 
-          y = scale * starSource->GetMeanYFit(); 
-        }
-        else 
-        {
-          x = scale * starSource->GetMeanXCalc(); 
-          y = scale * starSource->GetMeanYCalc(); 
-        }
-
-	if (x>lowx  && x<higx  && y>lowy  && y<higy)
-        {
-         if     ( fNstarnames > 0  &&  starSource->GetName() == fStarnames[0] )
-           fEstPos1->Fill(x, y, w);
-
-         else if( fNstarnames > 1  &&  starSource->GetName() == fStarnames[1] )
-           fEstPos2->Fill(x, y, w);
-
-         else if( fNstarnames > 2  &&  starSource->GetName() == fStarnames[2] )
-           fEstPos3->Fill(x, y, w);
-	}
-      }
-    }
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Finalize :
-//
-//    it is called in the postprocessing
-//    reset pointers in order to allow cloning of the object
-//
-Bool_t MHTelAxisFromStars::Finalize()
-{
-  //*fLog << "MHTelAxisFromStars::Finalize;  fSourceCam = " 
-  //      << fSourceCam  << endl; 
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Creates a new canvas and draws the histograms.
-// Be careful: The histograms belongs to this object and won't get deleted
-// together with the canvas.
-//
-
-void MHTelAxisFromStars::Draw(Option_t *opt)
-{
-  TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
-  pad->SetBorderMode(0);
-
-  AppendPad("");
-  
-  //TCanvas *pad = new TCanvas("TelAxisFromStars", "TelAxis plots", 1200, 900);
-  //gROOT->SetSelectedPad(NULL);
-
-    pad->Divide(4,3);
-
-    pad->cd(1);
-    gPad->SetBorderMode(0);
-    fNStars->Draw(opt); 
-
-    pad->cd(2);
-    gPad->SetBorderMode(0);
-    fNdoF->Draw(opt); 
-
-    pad->cd(3);
-    gPad->SetBorderMode(0);
-    fLog10Chi2->Draw(opt); 
-
-    pad->cd(4);
-    gPad->SetBorderMode(0);
-    fChi2Prob->Draw(opt); 
-
-    pad->cd(5);
-    gPad->SetBorderMode(0);
-    fNumIter->Draw(opt);
-
-    pad->cd(6);
-    gPad->SetBorderMode(0);
-    fLambda->Draw(opt);
-
-    pad->cd(7);
-    gPad->SetBorderMode(0);
-    fAlfa->Draw(opt);
-
-    pad->cd(8);
-    gPad->SetBorderMode(0);
-    //SetColors();
-    //fShift->Draw("colz");
-    fShift->Draw("");
-
-
-    //-----------------------------------------------
-    // plot the expected positions of some sources
-    //*fLog << "fSourcsCam = " << fSourceCam << endl;
-
-    if (fSourceCam)
-    {
-      *fLog << "MHTelAxisFromSrars::Draw; plotting" << endl;
-
-      pad->cd(9);
-      gPad->SetBorderMode(0);
-      //SetColors();
-      fEstPos1->Draw("");
-
-      pad->cd(10);
-      gPad->SetBorderMode(0);
-      //SetColors();
-      fEstPos2->Draw("");
-
-      pad->cd(11);
-      gPad->SetBorderMode(0);
-      //SetColors();
-      fEstPos3->Draw("");
-    }
-
-    pad->Modified();
-    pad->Update();
-}
-
-//---------------------------------------------------------------------
-//
-
-TH1 *MHTelAxisFromStars::GetHistByName(const TString name)
-{
-    if (name.Contains("NStars", TString::kIgnoreCase))
-        return fNStars;
-    if (name.Contains("NdoF", TString::kIgnoreCase))
-        return fNdoF;
-    if (name.Contains("Log10Chi2", TString::kIgnoreCase))
-        return fLog10Chi2;
-    if (name.Contains("Chi2Prob", TString::kIgnoreCase))
-        return fChi2Prob;
-    if (name.Contains("NumIter", TString::kIgnoreCase))
-        return fNumIter;
-    if (name.Contains("Lambda", TString::kIgnoreCase))
-        return fLambda;
-    if (name.Contains("Alfa", TString::kIgnoreCase))
-        return fAlfa;
-
-    if (name.Contains("Shift", TString::kIgnoreCase))
-        return fShift;
-    if (name.Contains("EstPos1", TString::kIgnoreCase))
-        return fEstPos1;
-    if (name.Contains("EstPos2", TString::kIgnoreCase))
-        return fEstPos2;
-    if (name.Contains("EstPos3", TString::kIgnoreCase))
-        return fEstPos3;
-
-    return NULL;
-}
-
-// --------------------------------------------------------------------------
-//
-// Setup an inversed deep blue sea palette.
-//
-
-void MHTelAxisFromStars::SetColors() const
-{
-    gStyle->SetPalette(51, NULL);
-    Int_t c[50];
-    for (int i=0; i<50; i++)
-        c[49-i] = gStyle->GetColorPalette(i);
-    gStyle->SetPalette(50, c);
-}
-
-
-//---------------------------------------------------------------------
-//
-
-void MHTelAxisFromStars::Paint(Option_t *opt)
-{
-    SetColors();
-    MH::Paint();
-}
-
-//==========================================================================
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MHTelAxisFromStars.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MHTelAxisFromStars.h	(revision 7136)
+++ 	(revision )
@@ -1,86 +1,0 @@
-#ifndef MARS_MHTelAxisFromStars
-#define MARS_MHTelAxisFromStars
-
-#ifndef MARS_MH
-#include "MH.h"
-#endif
-
-class TH1D;
-class TH2D;
-class MTelAxisFromStars;
-class MSrcPosCam;
-class MSkyCamTrans;
-class MStarCam;
-
-class MHTelAxisFromStars : public MH
-{
-private:
-
-    TH1D *fNStars;     //-> Number of stars
-    TH1D *fNdoF;       //-> Number of degrees of freedom
-    TH1D *fLog10Chi2;  //-> log10(Chi2) 
-    TH1D *fChi2Prob;   //-> Chi2 probability
-    TH1D *fNumIter;    //-> Number of iterations
-    TH1D *fLambda;     //-> Scale factor lambda
-    TH1D *fAlfa;       //-> Rotation angle alfa
-
-    TH2D *fShift;      //-> Shift between Sky and Camera system
-    TH2D *fEstPos1;    //-> Estimated position 1
-    TH2D *fEstPos2;    //-> Estimated position 2
-    TH2D *fEstPos3;    //-> Estimated position 3
-
-    MStarCam        *fStarCam;     //!
-    MStarCam        *fSourceCam;   
-    MSrcPosCam      *fSrcPos;      //!
-    MSkyCamTrans    *fSkyCamTrans; //!
-
-    Float_t fMm2Deg;                    //!
-    Bool_t  fUseMmScale;                //!
-    Int_t   fInputType;                 //!
-
-    const static Int_t fNstarnames = 3;        //!
-    TString fStarnames[fNstarnames];    //!
-
-    void SetColors() const;
-    void Paint(Option_t *opt="");
-
-public:
-    MHTelAxisFromStars(const char *name=NULL, const char *title=NULL);
-    ~MHTelAxisFromStars();
-
-    void SetInputType(Int_t type=1);
-    void SetMmScale(Bool_t mmscale=kTRUE);
-    virtual void SetMm2Deg(Float_t mmdeg);
-
-    Bool_t SetupFill(const MParList *pList);
-    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
-    Bool_t Finalize();
-
-    TH1 *GetHistByName(const TString name);
-
-    TH1D *GetHistNStars()    { return fNStars;    }
-    TH1D *GetHistNdoF()      { return fNdoF;      }
-    TH1D *GetHistLog10Chi2() { return fLog10Chi2; }
-    TH1D *GetHistChi2Prob()  { return fChi2Prob;  }
-
-    TH1D *GetHistNumIter()   { return fNumIter;   }
-    TH1D *GetHistLambda()    { return fLambda;    } 
-
-    TH1D *GetHistAlfa()      { return fAlfa;      }
-
-    TH2D *GetHistShift()     { return fShift;     }
-    TH2D *GetHistEstPos1()   { return fEstPos1;   }
-    TH2D *GetHistEstPos2()   { return fEstPos2;   }
-    TH2D *GetHistEstPos3()   { return fEstPos3;   }
-
-    void Draw(Option_t *opt=NULL);
-
-    ClassDef(MHTelAxisFromStars, 1) // Container which holds histograms for MTelAxisFromStars
-};
-
-#endif
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MSkyCamTrans.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MSkyCamTrans.cc	(revision 7136)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Wolfgang Wittek , 7/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////
-//
-// MSkyCamTrans
-//
-//     container holding the parameters of the transformation from
-//     sky directions 'a' (projected onto the camera) 
-//     to positions 'b' in the camera
-//
-//                                          ( cos(fAlfa)   -sin(fAlfa) )
-//      b = fLambda * fA * a + fD      fA = (                        )
-//             ^       ^        ^           ( sin(fAlfa)    cos(fAlfa) )
-//             |       |        |
-//           scale  rotation  shift 
-//          factor  matrix
-//
-//     fNumIter             number of iterations
-//     fNdof                number of degrees of freedom
-//     fChiSquare           chi-square value
-//     fChiSquareProb       chi-square probability
-//
-// The units are assumed to be 
-//     [degrees]  for  fAlfa
-//     [mm]       for  a, b, fD
-//     [1]        for  fLambda                       
-//
-//
-// The container is filled by  the task 'MTelAxisFromStars' 
-//
-///////////////////////////////////////////////////////////////////////////
-
-
-#include "MSkyCamTrans.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MSkyCamTrans);
-
-using namespace std;
-
-// ---------------------------------------------------------------------
-//
-//
-//
-MSkyCamTrans::MSkyCamTrans(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MSkyCamTrans";
-    fTitle = title ? title : "Sky-Cam transformation parameters";
-}
-
-// ---------------------------------------------------------------------
-//
-//
-//
-void MSkyCamTrans::SetParameters(Double_t &lambda, Double_t &alfa, 
-     Double_t a[2][2], Double_t d[2],  Double_t errd[2][2], 
-     Int_t &nstars,    Int_t &numiter,  
-     Int_t &ndof,      Double_t &chisquare,        Double_t &chisquareprob)
-{
-  fLambda = lambda;
-  fAlfa   = alfa;
-    
-  fA[0][0] = a[0][0];
-  fA[0][1] = a[0][1];
-  fA[1][0] = a[1][0];
-  fA[1][1] = a[1][1];
-
-  fD[0] = d[0];
-  fD[1] = d[1];
-
-  fErrD[0][0] = errd[0][0];
-  fErrD[0][1] = errd[0][1];
-  fErrD[1][0] = errd[1][0];
-  fErrD[1][1] = errd[1][1];
-
-  fNStars        = nstars;
-  fNumIter       = numiter;
-  fNdof          = ndof;
-  fChiSquare     = chisquare;
-  fChiSquareProb = chisquareprob;
-}
-// ---------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MSkyCamTrans.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MSkyCamTrans.h	(revision 7136)
+++ 	(revision )
@@ -1,55 +1,0 @@
-#ifndef MARS_MSkyCamTrans
-#define MARS_MSkyCamTrans
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MSkyCamTrans : public MParContainer
-{
-private:
-
-    //Parameters of transformation from sky to camera
-    
-    Double_t fLambda;         // scale factor lambda
-    Double_t fAlfa;           // rotation angle alfa [degrees]
-    Double_t fA[2][2];        // rotation matrix A
-    Double_t fD[2];           // shift D [mm]
-    Double_t fErrD[2][2];     // error matrix of shift D   [mm*mm]
-
-    Int_t    fNStars;
-    Int_t    fNumIter;
-    Int_t    fNdof;
-    Double_t fChiSquare;
-    Double_t fChiSquareProb;
-
-public:
-
-    MSkyCamTrans(const char *name=NULL, const char *title=NULL);
-
-    void SetParameters(Double_t &,       Double_t &,
-		       Double_t[2][2],   Double_t[2], Double_t[2][2], 
-              Int_t &, Int_t &, Int_t &, Double_t &,  Double_t &);
- 
-    Int_t    GetNStars()             { return fNStars;       }
-    Int_t    GetNumIter()            { return fNumIter;       }
-    Int_t    GetNdof()               { return fNdof;          }
-    Double_t GetChiSquare()          { return fChiSquare;     }
-    Double_t GetChiSquareProb()      { return fChiSquareProb; }
-    Double_t GetLambda()             { return fLambda;        }
-    Double_t GetAlfa()               { return fAlfa;          }
-
-    Double_t *GetRotationMatrix()    { return &fA[0][0];      }  
-    Double_t *GetShiftD()            { return &fD[0];         }  
-    Double_t *GetErrMatrixShiftD()   { return &fErrD[0][0];   }  
-
-    ClassDef(MSkyCamTrans, 1) // Container holding the sky-camera transformation parameters
-};
-
-#endif
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MSourceDirections.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MSourceDirections.cc	(revision 7136)
+++ 	(revision )
@@ -1,188 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 expressed
-! * or implied warranty.
-! *
-!
-!   Author(s): Robert Wagner, 8/2004 <mailto:rwagner@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MSourceDirections
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MSourceDirections.h"
-
-#include <TTimer.h>
-#include <TString.h>
-#include <TFile.h>
-#include <TTree.h>
-#include <TCanvas.h>
-#include <TH1F.h>
-#include <TF1.h>
-#include <TEllipse.h>
-
-
-#include "MObservatory.h"
-#include "MAstroCamera.h"
-#include "MMcConfigRunHeader.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MHCamera.h"
-
-#include "MGeomCam.h"
-#include "MGeomPix.h"
-#include "MCameraDC.h"
-#include "MTime.h"
-#include "MReportDrive.h"
-#include "MStarCam.h"
-#include "MStarPos.h"
-
-#include "MParList.h"
-#include "MTaskList.h"
-
-ClassImp(MSourceDirections);
-using namespace std;
-
-MSourceDirections::MSourceDirections(const char *name, const char *title): 
-  fGeomCam(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL)
-{
-  fName  = name  ? name  : "MSourceDirections";
-  fTitle = title ? title : "Convert Ra-Dec source positions into camera coordinates";
-  fGeometryFile="";
-}
-
-Int_t MSourceDirections::PreProcess(MParList *pList)
-{
-  fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-  if (!fGeomCam) {
-    *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
-    return kFALSE;
-  }
-  
-  fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
-  if (!fTimeCurr) {
-    *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
-    return kFALSE;
-  }
-
-  fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
-  if (!fDrive) {
-    *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... aborting" << endl;
-    return kFALSE;
-  } 
-
-
-  fStars = (MStarCam*)pList->FindCreateObj(AddSerialNumber("MStarCam"),"MSourceCam");
-  if (!fStars) {
-    *fLog << err << AddSerialNumber("MStarCam") << " with name '"
-          << "MSourceCam" << " cannot be created ... aborting" << endl;
-    return kFALSE;
-  }
-  
-
-
-  MObservatory magic1;
-  
-  MMcConfigRunHeader *config=0;
-  MGeomCam           *geom=0;
-  
-  TFile file(fGeometryFile);
-  TTree *tree = (TTree*)file.Get("RunHeaders");
-  tree->SetBranchAddress("MMcConfigRunHeader", &config);
-  if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
-  tree->GetEntry(0);
-  
-  fAstro.SetMirrors(*config->GetMirrors());
-  fAstro.SetGeom(*geom);	
-  fAstro.SetObservatory(magic1);  
-
-
-  // make the starlist available already in the preprocessing
-  fStars->GetList()->Delete();
-  fAstro.SetTime(*fTimeCurr);
-  fAstro.SetGuiActive();
-  fAstro.FillStarList(fStars->GetList());      
-  //*fLog << inf << "in preprocessing " << GetName() << " found " 
-  //      << fStars->GetList()->GetSize() 
-  //	  << " directions inside the chosen FOV." << endl;          
-
-
-  return kTRUE;
-}
-
-Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name) 
-{
-  *fLog << "MSourceDirections::AddDirection; add the direction : ra, dec, mag, name = " 
-        << ra << ",  " << dec << ",  " << mag << ",  " << name << endl;
-
-  Int_t rc = fAstro.AddObject(ra,dec,1,name);
-//   if (rc) {
-//     MStarPos *starpos = new MStarPos;
-//     starpos->SetName(name);
-//     fStars->GetList()->Add(starpos);
-//   }
-  return rc;
-}
-
-Int_t MSourceDirections::Process()
-{
-  //First delete the previous directions in the list
-  fStars->GetList()->Delete();
-
-  fAstro.SetTime(*fTimeCurr);
-  fAstro.SetGuiActive();
-  fAstro.FillStarList(fStars->GetList());      
-      
-  MStarPos* starpos;
-  TIter Next(fStars->GetList());
-  while ((starpos=(MStarPos*)Next())) {
-    //starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),
-    //                       0.,0.,0.,    0.,0.,0.);
-    //starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),
-    //                       0.,0.,0.,    0.,0.,0.,  0., -1);
-  }
-
-  if (fStars->GetList()->GetSize() == 0) {
-    *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
-  } else {
-    //*fLog << inf << GetName() << " found " << fStars->GetList()->GetSize() 
-    //	  << " directions inside the chosen FOV." << endl;          
-  }
-  return kTRUE;
-}
-
-Int_t MSourceDirections::PostProcess()
-{
-  return kTRUE;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MSourceDirections.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MSourceDirections.h	(revision 7136)
+++ 	(revision )
@@ -1,49 +1,0 @@
-#ifndef MARS_MSourceDirections
-#define MARS_MSourceDirections
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef MARS_MAstroCamera
-#include "MAstroCamera.h"
-#endif
-
-class MTime;
-class MReportDrive;
-class MStarCam;
-class MStarPos;
-
-class MSourceDirections : public MTask
-{
-
-private:
-
-    MGeomCam      *fGeomCam;
-    MTime         *fTimeCurr;
-    MReportDrive  *fDrive;
-    MStarCam *fStars;
-
-    MAstroCamera fAstro;
-  
-    TString fGeometryFile;
-
-  public:
-    
-    MSourceDirections(const char *name=NULL, const char *title=NULL);
-    
-    Int_t AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name="");
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess();
-
-    // setters
-    void SetGeometryFile(TString f) {fGeometryFile=f;}
-    void SetRaDec(Double_t ra, Double_t dec) {fAstro.SetRaDec(ra,dec);}
-    void SetRaDec(TVector3 &v) { fAstro.SetRaDec(v); }
-    void SetRadiusFOV(Double_t deg) { fAstro.SetRadiusFOV(deg); }
-    
-  ClassDef(MSourceDirections, 0) // Tool to translate RaDec Source Directions into camera coordinates
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/MStarLocalCam.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MStarLocalCam.cc	(revision 7136)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier Lopez 04/2004 <mailto:jlopez@ifae.es>
-!   Author(s): Jordi Albert 04/2004 <mailto:albert@astro.uni-wuerzburg.de>
-!                 
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MStarLocalCam
-//                                                                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#include "MStarLocalCam.h"
-
-#include <TList.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MStarLocalPos.h"
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-// Default constructor. 
-//
-//
-MStarLocalCam::MStarLocalCam(const char *name, const char *title) 
-{
-  fName  = name  ? name  : "MStarLocalCam";
-  fTitle = title ? title : "";
-  
-  fStars = new TList;
-
-  fInnerPedestalDC = 0.;
-  fOuterPedestalDC = 0.;
-  fInnerPedestalRMSDC = 0.;
-  fOuterPedestalRMSDC = 0.;
-  
-}
-
-MStarLocalCam::~MStarLocalCam()
-{
-    fStars->SetOwner();
-    fStars->Delete();
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th
-//
-MStarLocalPos &MStarLocalCam::operator[] (Int_t i)
-{
-  MStarLocalPos& star = *static_cast<MStarLocalPos*>(fStars->At(i));
-  return star;
-}
-
-// --------------------------------------------------------------------------
-//
-// Get i-th
-//
-const MStarLocalPos &MStarLocalCam::operator[] (Int_t i) const
-{
-    return *static_cast<MStarLocalPos*>(fStars->At(i));
-}
-
-void MStarLocalCam::Paint(Option_t *o)
-{
-	TIter Next(fStars);
-	MStarLocalPos* star;
-	while ((star=(MStarLocalPos*)Next())) 
-	    star->Paint(o);
-}
-
-void MStarLocalCam::Print(Option_t *o) const
-{
-      *fLog << inf << "DCs baseline:" << endl;
-      *fLog << inf << " Inner Pixels Mean pedestal \t" << setw(4) << fInnerPedestalDC << " uA  and RMS " << setw(4) << fInnerPedestalRMSDC << " uA for DCs" << endl;
-      *fLog << inf << " Outer Pixels Mean pedestal \t" << setw(4) << fOuterPedestalDC << " uA  and RMS " << setw(4) << fOuterPedestalRMSDC << " uA for DCs" << endl;
-      
-      TIter Next(fStars);
-      MStarLocalPos* star;
-      UInt_t starnum = 0;
-      while ((star=(MStarLocalPos*)Next())) 
-        {
-          *fLog << inf << "Star[" << starnum << "] info:" << endl;
-          star->Print(o);
-          starnum++;
-        }
-}
Index: trunk/MagicSoft/Mars/mtemp/MStarLocalCam.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MStarLocalCam.h	(revision 7136)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#ifndef MARS_MStarLocalCam
-#define MARS_MStarLocalCam
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef MARS_MHCamera
-#include "MHCamera.h"
-#endif
-
-class TList;
-
-class MGeomCam;
-class MStarLocalPos;
-
-class MStarLocalCam : public MParContainer
-{
-private:
-
-  TList  *fStars;  //-> FIXME: Change TClonesArray away from a pointer?
-
-  // BaseLine DCs info
-  Float_t fInnerPedestalDC;         //[ua]
-  Float_t fOuterPedestalDC;         //[ua]
-
-  Float_t fInnerPedestalRMSDC;      //[ua]
-  Float_t fOuterPedestalRMSDC;      //[ua]
-
-  MHCamera fDisplay;
-
- public:
-
-  MStarLocalCam(const char *name=NULL, const char *title=NULL);
-  ~MStarLocalCam();
-
-  MStarLocalPos &operator[] (Int_t i);
-  const MStarLocalPos &operator[] (Int_t i) const;
-
-  TList *GetList() const { return fStars; }
-  UInt_t GetNumStars() const { return fStars->GetSize(); }
-
-  //Getters
-
-  Float_t GetInnerPedestalDC() {return fInnerPedestalDC;}
-  Float_t GetOuterPedestalDC() {return fOuterPedestalDC;}
-  Float_t GetInnerPedestalRMSDC() { return fInnerPedestalRMSDC;}
-  Float_t GetOuterPedestalRMSDC() { return fOuterPedestalRMSDC;}
-
-  MHCamera& GetDisplay() { return fDisplay; }
-
-    //Setters
-  void SetInnerPedestalDC(Float_t ped) {fInnerPedestalDC = ped;}
-  void SetOuterPedestalDC(Float_t ped) {fOuterPedestalDC = ped;}
-  void SetInnerPedestalRMSDC(Float_t rms){fInnerPedestalRMSDC = rms;}
-  void SetOuterPedestalRMSDC(Float_t rms){fOuterPedestalRMSDC = rms;}
-
-  void Paint(Option_t *o=NULL);
-  void Print(Option_t *o=NULL) const;
-
-  ClassDef(MStarLocalCam, 1)	// Storage Container for star positions in the camera
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/MStarLocalPos.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MStarLocalPos.cc	(revision 7136)
+++ 	(revision )
@@ -1,309 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 expressed
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Javier López ,   4/2004 <mailto:jlopez@ifae.es>
-!              Robert Wagner,   7/2004 <mailto:rwagner@mppmu.mpg.de>
-!              Wolfgang Wittek, 8/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-#include "MStarLocalPos.h"
-
-#include <TEllipse.h>
-#include <TMarker.h>
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MStarLocalPos);
-
-using namespace std;
-
-MStarLocalPos::MStarLocalPos(const char *name, const char *title)
-{
-
-    fName  = name  ? name  : "MStarLocalPos";
-    fTitle = title ? title : "";
-    
-    Reset();
-}
-
-void MStarLocalPos::Reset()
-{
-
-    //Expected position on camera
-     fMagExp = 0.;
-     fXExp = 0.;
-     fYExp = 0.;
-
-    //Info from calculation
-     fMagCalc = 0.;
-     fMaxCalc = 0.;
-     fMeanXCalc = 0.;
-     fMeanYCalc = 0.;
-     fSigmaMinorAxisCalc = 0.;
-     fSigmaMajorAxisCalc = 0.;
-
-    //Info from uncorrelated Gauss fit
-     fMagFit = 0.;
-     fMaxFit = 0.;
-     fMeanXFit = 0.;
-     fMeanYFit = 0.;
-     fSigmaMinorAxisFit = 0.;
-     fSigmaMajorAxisFit = 0.;
-
-     fChiSquare = 0.;
-     fNdof = 1;
-
-    //Info from correlated Gauss fit
-     fMagCGFit    = 0.;
-     fMaxCGFit    = 0.;
-     fMeanXCGFit  = 0.;
-     fMeanYCGFit  = 0.;
-     fSigmaXCGFit = 0.;
-     fSigmaYCGFit = 0.;
-     fCorrXYCGFit = 0.;
-     fXXErrCGFit  = 0.;
-     fXYErrCGFit  = 0.;
-     fYYErrCGFit  = 0.;
-
-     fChiSquareCGFit = 0.;
-     fNdofCGFit      = 1;
-
-}
-
-void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
-{
-     fMagExp = mag;
-     fXExp = x;
-     fYExp = y;
-}
-
-void MStarLocalPos::SetIdealValues(Float_t mag, Float_t x, Float_t y)
-{
-     fMagIdeal = mag;
-     fXIdeal = x;
-     fYIdeal = y;
-}
-
-void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max, 
-        Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
-{
-     fMagCalc = mag;
-     fMaxCalc = max;
-     fMeanXCalc = x;
-     fMeanYCalc = y;
-     fSigmaMinorAxisCalc = sigmaMinorAxis;
-     fSigmaMajorAxisCalc = sigmaMajorAxis;
-}
-
-void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, 
-        Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, 
-        Float_t chiSquare, Int_t ndof)
-{
-     fMagFit = mag;
-     fMaxFit = max;
-     fMeanXFit = x;
-     fMeanYFit = y;
-     fSigmaMinorAxisFit = sigmaMinorAxis;
-     fSigmaMajorAxisFit = sigmaMajorAxis;
-     fChiSquare = chiSquare;
-     fNdof = ndof;
-}
-
-void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, 
-        Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, 
-        Float_t chiSquare, Int_t ndof, 
-        Float_t xx, Float_t xy, Float_t yy)
-{
-  SetFitValues(mag, max, x, y, sigmaMinorAxis, sigmaMajorAxis, chiSquare, ndof);
-  fXXErr = xx;
-  fYYErr = yy;
-  fXYErr = xy;
-}
-
-void MStarLocalPos::SetCGFitValues(
-               Float_t mag,       Float_t max,    Float_t x,    Float_t y, 
-               Float_t sigmaX,    Float_t sigmaY, Float_t correlation, 
-               Float_t xx,        Float_t xy,     Float_t yy,
-               Float_t chiSquare, Int_t ndof)
-{
-     fMagCGFit    = mag;
-     fMaxCGFit    = max;
-     fMeanXCGFit  = x;
-     fMeanYCGFit  = y;
-     fSigmaXCGFit = sigmaX;
-     fSigmaYCGFit = sigmaY;
-     fCorrXYCGFit = correlation;
-     fXXErrCGFit  = xx;
-     fXYErrCGFit  = xy;
-     fYYErrCGFit  = yy;
-
-     fChiSquareCGFit = chiSquare;
-     fNdofCGFit      = ndof;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Paint the ellipse corresponding to the parameters
-//
-void MStarLocalPos::Paint(Option_t *opt)
-{
-  //Print a cross in the expected position
-  TMarker mexp(fXExp, fYExp, 29);
-  mexp.SetMarkerSize(3);
-  mexp.SetMarkerColor(94);
-  mexp.Paint(); 
-
-  if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
-    {
-      TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
-      ecalc.SetLineWidth(3);
-      ecalc.SetLineColor(kBlue);
-      ecalc.Paint();
-    }
-
-  if (fSigmaMinorAxisFit>0. && fSigmaMajorAxisFit>0.)
-    {
-      TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, 0);
-      efit.SetLineWidth(3);
-      efit.SetLineColor(kBlack);
-      efit.Paint();
-    }
-
-  if (fSigmaXCGFit>0. && fSigmaYCGFit>0.)
-    {
-      //Print a cross in the fitted position
-      //TMarker mCGFit(fMeanXCGFit, fMeanYCGFit, 3);
-      //mCGFit.SetMarkerSize(3);
-      //mCGFit.SetMarkerColor(1);
-      //mCGFit.Paint(); 
-
-      Double_t cxx = fSigmaXCGFit*fSigmaXCGFit;
-      Double_t cyy = fSigmaYCGFit*fSigmaYCGFit;
-      Double_t d   = cyy - cxx;
-      Double_t cxy = fCorrXYCGFit * fSigmaXCGFit * fSigmaYCGFit;
-      Double_t tandel;
-      if (cxy != 0.0)
-        tandel = ( d + sqrt(d*d + 4.0*cxy*cxy) ) / (2.0*cxy); 
-      else
-        tandel = 0.0;
-
-      Double_t sindel = tandel / sqrt(1.0 + tandel*tandel);
-      Double_t delta = TMath::ASin(sindel);
-
-      Double_t major =   (cxx + 2.0*tandel*cxy + tandel*tandel*cyy)
-	                / (1.0 + tandel*tandel);  
-
-      Double_t minor =   (tandel*tandel*cxx - 2.0*tandel*cxy + cyy)
-	                / (1.0 + tandel*tandel);  
-
-      TEllipse efit(fMeanXCGFit, fMeanYCGFit, sqrt(major), sqrt(minor), 
-                    0, 360,      delta*kRad2Deg);
-      efit.SetLineWidth(3);
-      efit.SetLineColor(kMagenta);
-      efit.Paint();
-    }
-}
-  
-void MStarLocalPos::Print(Option_t *opt) const
-{
-  TString o = opt;
-
-  if (o.Contains("name", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "Star Name: \"" << this->GetName() << "\"" << endl;
-    }
-      
-  if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
-    {
-  
-      *fLog << inf << "Star magnitude:" << endl;
-      *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
-      *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
-      *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
-      *fLog << inf << " CGFitted \t " << setw(4) << fMagCGFit << endl;
-    }
-  
-  if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "Star Maximum:" << endl;
-      *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA" 
-            << endl;
-      *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
-      *fLog << inf << " CGFitted \t " << setw(4) << fMaxCGFit << " uA" << endl;
-    }
-  
-  if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "Star position:" << endl;
-      *fLog << inf << " Expected \t X " << setw(4) << fXExp 
-            << " mm \tY " << setw(4) << fYExp << " mm" << endl;
-      *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc 
-            << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
-      *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit 
-            << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
-      *fLog << inf << " CGFitted \t X " << setw(4) << fMeanXCGFit 
-            << " mm \tY " << setw(4) << fMeanYCGFit << " mm" << endl;
-    }
-
-  if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "Star size:" << endl;
-      *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc 
-            << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
-      *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit 
-            << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
-      *fLog << inf << " CGFitted \t X " << setw(4) << fSigmaXCGFit 
-            << " mm \tY " << setw(4) << fSigmaYCGFit << " mm \t correlation" 
-            << setw(4) << fCorrXYCGFit << endl;
-    }
-
-  if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "Star Fit Quality:" << endl;
-      *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare 
-            << "/" << fNdof << endl;
-
-      *fLog << inf << "Star CGFit Quality:" << endl;
-      *fLog << inf << " ChiSquareCGFit/NdofCGFit \t " << setw(3) 
-            << fChiSquareCGFit << "/" << fNdofCGFit << endl;
-    }
-
-  if (o.Contains("err", TString::kIgnoreCase) || opt == NULL)
-    {
-      *fLog << inf << "CGFit Error Matrix of (fMeanXCGFit,fMeanYCGFit) :" 
-            << endl;
-      *fLog << inf << " xx,xy,yy \t " << setw(3) << fXXErrCGFit << ", " 
-            << fXYErrCGFit << ", " << fYYErrCGFit << endl;
-    }
-
-
-}
-//--------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MStarLocalPos.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MStarLocalPos.h	(revision 7136)
+++ 	(revision )
@@ -1,142 +1,0 @@
-#ifndef MARS_MStarLocalPos
-#define MARS_MStarLocalPos
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MStarLocalPos : public MParContainer
-{
-private:
-
-    //Expected position on camera
-    Float_t fMagExp;
-    Float_t fXExp;    //[mm]
-    Float_t fYExp;    //[mm]
-
-    //Ideal position on camera
-    Float_t fMagIdeal;
-    Float_t fXIdeal;    //[mm]
-    Float_t fYIdeal;    //[mm]
-
-    //Info from calculation
-    Float_t fMagCalc;
-    Float_t fMaxCalc;            //[uA]
-    Float_t fMeanXCalc;          //[mm]
-    Float_t fMeanYCalc;          //[mm]
-    Float_t fSigmaMinorAxisCalc; //[mm]
-    Float_t fSigmaMajorAxisCalc; //[mm]
-
-    //Info from uncorrelated Gauss fit
-    Float_t fMagFit;
-    Float_t fMaxFit;             //[uA]
-    Float_t fMeanXFit;           //[mm]
-    Float_t fMeanYFit;           //[mm]
-    Float_t fSigmaMinorAxisFit;  //[mm]
-    Float_t fSigmaMajorAxisFit;  //[mm]
-    Float_t fXXErr;          
-    Float_t fXYErr;
-    Float_t fYYErr;
-
-    Float_t fChiSquare;
-    Int_t   fNdof;
-
-    //Info from correlated Gauss fit
-    Float_t fMagCGFit;
-    Float_t fMaxCGFit;             //[uA]
-    Float_t fMeanXCGFit;           //[mm]
-    Float_t fMeanYCGFit;           //[mm]
-    Float_t fSigmaXCGFit;          //[mm]
-    Float_t fSigmaYCGFit;          //[mm]
-    Float_t fCorrXYCGFit;          // correlation coefficient
-    Float_t fXXErrCGFit;           // error matrix of (fMeanXCGFit,fMeanYCGFit)
-    Float_t fXYErrCGFit;
-    Float_t fYYErrCGFit;
-
-    Float_t fChiSquareCGFit;
-    Int_t   fNdofCGFit;
-
-
-public:
-
-    MStarLocalPos(const char *name=NULL, const char *title=NULL);
-    //~MStarLocalPos();
-
-    Float_t GetMagExp() {return fMagExp;}
-    Float_t GetXExp() {return fXExp;}
-    Float_t GetYExp() {return fYExp;}
-
-    Float_t GetMagIdeal() {return fMagIdeal;}
-    Float_t GetXIdeal() {return fXIdeal;}
-    Float_t GetYIdeal() {return fYIdeal;}
-
-    Float_t GetMagCalc() {return fMagCalc;}
-    Float_t GetMaxCalc() {return fMaxCalc;}
-    Float_t GetMeanXCalc() {return fMeanXCalc;}
-    Float_t GetMeanYCalc() {return fMeanYCalc;}
-    Float_t GetSigmaMinorAxisCalc() {return fSigmaMinorAxisCalc;}
-    Float_t GetSigmaMajorAxisCalc() {return fSigmaMajorAxisCalc;}
-
-    Float_t GetMagFit() {return fMagFit;}
-    Float_t GetMaxFit() {return fMaxFit;}
-    Float_t GetMeanXFit() {return fMeanXFit;}
-    Float_t GetMeanYFit() {return fMeanYFit;}
-    Float_t GetSigmaMinorAxisFit() {return fSigmaMinorAxisFit;}
-    Float_t GetSigmaMajorAxisFit() {return fSigmaMajorAxisFit;}
-    Float_t GetChiSquare() {return fChiSquare;}
-    UInt_t GetNdof() {return fNdof;}
-    Float_t GetChiSquareNdof() {return fChiSquare/fNdof;}
-
-    Float_t GetMeanX() {return fMeanXFit!=0?fMeanXFit:fMeanXCalc;}
-    Float_t GetMeanY() {return fMeanXFit!=0?fMeanYFit:fMeanYCalc;}
-    Float_t GetSigmaMinorAxis() {return fSigmaMinorAxisFit!=0?fSigmaMinorAxisFit:fSigmaMinorAxisCalc;}
-    Float_t GetSigmaMajorAxis() {return fSigmaMajorAxisFit!=0?fSigmaMajorAxisFit:fSigmaMajorAxisCalc;}
-    
-    // getters for the correlated Gauss fit
-    Float_t GetMagCGFit()           {return fMagCGFit;}
-    Float_t GetMaxCGFit()           {return fMaxCGFit;}
-    Float_t GetMeanXCGFit()         {return fMeanXCGFit;}
-    Float_t GetMeanYCGFit()         {return fMeanYCGFit;}
-    Float_t GetSigmaXCGFit()        {return fSigmaXCGFit;}
-    Float_t GetSigmaYCGFit()        {return fSigmaYCGFit;}
-    Float_t GetCorrXYCGFit()        {return fCorrXYCGFit;}
-    Float_t GetXXErrCGFit()         {return fXXErrCGFit;}
-    Float_t GetXYErrCGFit()         {return fXYErrCGFit;}
-    Float_t GetYYErrCGFit()         {return fYYErrCGFit;}
-    Float_t GetChiSquareCGFit()     {return fChiSquareCGFit;}
-    UInt_t GetNdofCGFit()           {return fNdofCGFit;}
-    Float_t GetChiSquareNdofCGFit() {return fChiSquareCGFit/fNdofCGFit;}
-
-
-    void Reset();
-
-    void SetExpValues(Float_t mag, Float_t x, Float_t y);
-
-    void SetIdealValues(Float_t mag, Float_t x, Float_t y);
-
-    void SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, 
-                       Float_t sigmaMinorAxis, Float_t sigmaMajorAxis);
-
-    void SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, 
-                      Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, 
-                      Float_t chi, Int_t ndof);
-
-    void SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, 
-                      Float_t sigmaX, Float_t sigmaY, 
-                      Float_t chi, Int_t ndof, 
-                      Float_t xx, Float_t xy, Float_t yy);
-
-    void SetCGFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, 
-                        Float_t sigmaX, Float_t sigmaY, Float_t correlation, 
-                        Float_t xx, Float_t xy, Float_t yy,
-                        Float_t chi, Int_t ndof);
-
-    void Paint(Option_t *opt=NULL);
-    void Print(Option_t *opt=NULL) const;
-
-    ClassDef(MStarLocalPos, 1) // Container that holds the star information in the PMT camera
-};
-
-#endif
-
-
Index: trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.cc	(revision 7136)
+++ 	(revision )
@@ -1,1266 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Wolfgang Wittek 07/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MTelAxisFromStars
-//
-//  This task 
-//  - determines the transformation from expected positions of stars
-//    in the camera to measured positions of these stars in the camera
-//  - applies this transformation to expected positions of other objects 
-//    to obtain the estimated positions of these objects in the camera
-//  - puts the estimated positions into the relevant containers
-//
-//  Input Containers :
-//   MStarCam[MStarCam], MStarCamSource[MStarCam]
-//
-//  Output Containers :
-//   MSkyCamTrans, MSrcPosCam 
-//
-/////////////////////////////////////////////////////////////////////////////
-#include <TMath.h>
-#include <TList.h>
-#include <TSystem.h>
-
-#include <fstream>
-
-#include "MTelAxisFromStars.h"
-
-#include "MParList.h"
-
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MReportDrive.h"
-#include "MPointingPos.h"
-#include "MSrcPosCam.h"
-
-#include "MStarCam.h"
-#include "MStarPos.h"
-#include "MSkyCamTrans.h"
-#include "MStarCamTrans.h"
-
-ClassImp(MTelAxisFromStars);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Constructor
-//
-MTelAxisFromStars::MTelAxisFromStars(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MTelAxisFromStars";
-    fTitle = title ? title : "Calculate source position from star positions";
-
-    // if scale factor fLambda should NOT be fixed set fFixdScaleFactor to 
-    // -1.0; otherwise set it to the value requested
-    fFixedScaleFactor   = 1.0;
-
-    // if rotation angle fAlfa should NOT be fixed set fFixdRotationAngle to 
-    // -1.0; otherwise set it to the requested value
-    fFixedRotationAngle = 0.0;
-
-    // default type of input is :    the result of the Gauss fit
-    // type 0 : result from the weighted average
-    // type 1 : result from the Gauss fit
-    fInputType = 1;
-
-    // default value of fAberr
-    // the value 1.07 is valid if the expected position (with aberration)
-    // in the camera is calculated as the average of the positions obtained
-    // from the reflections at the individual mirrors
-    fAberr = 1.07;
-
-}
-
-// --------------------------------------------------------------------------
-//
-// Destructor
-//
-MTelAxisFromStars::~MTelAxisFromStars()
-{
-  delete fStarCamTrans;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set links to containers
-//
-
-Int_t MTelAxisFromStars::PreProcess(MParList *pList)
-{
-   fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
-   if (!fDrive)
-   {
-       *fLog << err << AddSerialNumber("MReportDrive") 
-             << " not found... aborting." << endl;
-       return kFALSE;
-   }
- 
-  
-   fStarCam = (MStarCam*)pList->FindObject("MStarCam", "MStarCam");
-   if (!fStarCam)
-   {
-       *fLog << err << "MStarCam not found... aborting." << endl;
-       return kFALSE;
-   }
-
-   
-   fSourceCam = (MStarCam*)pList->FindObject("MSourceCam", "MStarCam");
-   if (!fSourceCam)
-   {
-       *fLog << warn << "MSourceCam[MStarCam] not found... continue  " << endl;
-   }
-
-
-   //-----------------------------------------------------------------
-    fSrcPos = (MSrcPosCam*)pList->FindCreateObj(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
-    if (!fSrcPos)
-        return kFALSE;
-
-    fPntPos = (MSrcPosCam*)pList->FindCreateObj(AddSerialNumber("MSrcPosCam"), "MPntPosCam");
-    if (!fPntPos)
-        return kFALSE;
-
-    fPointPos = (MPointingPos*)pList->FindCreateObj(AddSerialNumber("MPointingPos"), "MPointingPos");
-    if (!fPointPos)
-        return kFALSE;
-
-    fSourcePos = (MPointingPos*)pList->FindCreateObj(AddSerialNumber("MPointingPos"), "MSourcePos");
-    if (!fSourcePos)
-        return kFALSE;
-
-    fSkyCamTrans = (MSkyCamTrans*)pList->FindCreateObj(AddSerialNumber("MSkyCamTrans"));
-    if (!fSkyCamTrans)
-        return kFALSE;
-
-
-   //-----------------------------------------------------------------
-   // book an MStarCamTrans object
-   // this is needed when calling one of the member functions of MStarCamTrans
-
-   MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
-   if (!geom)
-   {
-       *fLog << err << AddSerialNumber("MGeomCam") 
-             << " not found... aborting." << endl;
-       return kFALSE;
-   }
-
-   MObservatory *obs = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
-   if (!obs)
-   {
-       *fLog << err << AddSerialNumber("MObservatory") 
-             << " not found... aborting." << endl;
-       return kFALSE;
-   }
-
-   //-----------------------------------------------------------------
-    fStarCamTrans = new MStarCamTrans(*geom, *obs);
-
-   *fLog << all   << "MTelAxisFromStars::Preprocess; the optical aberration factor is set equal to : " 
-         << fAberr ;
-
-   *fLog << all   << "MTelAxisFromStars::Preprocess; input type is set equal to : " 
-         << fInputType ;
-   if (fInputType == 0)
-     *fLog << " (calculated star positions)" << endl;
-   else
-     *fLog << " (fitted star positions)" << endl;
-
-   *fLog << all << "MTelAxisFromStars::Preprocess; scale factor will be fixed at : " 
-         << fFixedScaleFactor << endl;
-
-   *fLog << all << "MTelAxisFromStars::Preprocess; rotation angle will be fixed at : " 
-         << fFixedRotationAngle << endl;
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set optical aberration factor
-//
-//   fAberr   is the ratio between 
-//            the distance from the camera center with optical aberration and
-//            the distance from the camera center with an ideal imaging
-//
-//   fAberr = r_real/r_ideal 
-//
-void MTelAxisFromStars::SetOpticalAberr(Double_t aberr)
-{
-  fAberr = aberr;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the type of the input
-//
-//     type = 0        calculated star positions (by averaging)
-//     type = 1        fitted star positions (by Gauss fit)
-//
-void MTelAxisFromStars::SetInputType(Int_t type)
-{
-  fInputType = type;
-}
-
-// --------------------------------------------------------------------------
-//
-// Fix the scale factor fLambda
-//
-//
-void MTelAxisFromStars::FixScaleFactorAt(Double_t lambda)
-{
-  fFixedScaleFactor = lambda;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Fix rotation angle fAlfa
-//
-//
-void MTelAxisFromStars::FixRotationAngleAt(Double_t alfa)
-{
-  fFixedRotationAngle = alfa;    // [degrees]
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Process
-//
-//           call FindSkyCamTrans    to find the Sky-Camera transformation
-//           call TransSkyCam        to transform some sky directions
-//                                   into the camera system
-//           put the estimated source position into MSrcPosCam
-//
-
-Int_t MTelAxisFromStars::Process()
-{
-  //Int_t run = fRun->GetRunNumber();
-  //*fLog << "MTelAxisFromStars::Process; run = " << run << endl;
-
-  //--------------------------------------
-  // Define the input for FindSkyCamTrans
-  //
-
-  // get the expected (axy[0], axy[1]) and the measured positions 
-  // (bxy[0], bxy[1]) of stars in the camera from MStarCam 
-  Int_t fNumStars = fStarCam->GetNumStars();
-
-  if (fNumStars <= 0)
-    return kTRUE;
-
-  TArrayD  axy[2];
-  axy[0].Set(fNumStars);
-  axy[1].Set(fNumStars);
-
-  TArrayD  bxy[2];
-  bxy[0].Set(fNumStars);
-  bxy[1].Set(fNumStars);
-
-  // error matrix of bxy
-  TArrayD  exy[2][2];
-  exy[0][0].Set(fNumStars);
-  exy[0][1].Set(fNumStars);
-  exy[1][0].Set(fNumStars);
-  exy[1][1].Set(fNumStars);
-
-  // transformation parameters
-  Double_t fLambda;
-  Double_t fAlfa;
-  Double_t fA[2][2];
-  Double_t fD[2];
-  Double_t fErrD[2][2];
-  Int_t    fNumIter;
-  Int_t    fNdof;
-  Double_t fChi2;
-  Double_t fChi2Prob;
-
-  MStarPos *star = 0;
-  TIter next(fStarCam->GetList());
-  Int_t ix = 0;
-
-  // loop over all stars
-  while ( (star = (MStarPos*)next()) )
-  {
-    axy[0][ix]   = star->GetXExp(); 
-    axy[1][ix]   = star->GetYExp(); 
-
-    if (fInputType == 0)
-    {
-      // values from averaging
-      bxy[0][ix]     = star->GetMeanXCalc(); 
-      bxy[1][ix]     = star->GetMeanYCalc(); 
-
-      // this is the error matrix for (MeanXCalc, MeanYCalc);
-      // this is the error matrix which should be used
-      exy[0][0][ix]  =  star->GetXXErrCalc(); 
-      exy[0][1][ix]  =  star->GetXYErrCalc();
-      exy[1][0][ix]  =  star->GetXYErrCalc();
-      exy[1][1][ix]  =  star->GetYYErrCalc();
-
-      //exy[0][0][ix]  = star->GetSigmaXCalc()*star->GetSigmaXCalc(); 
-      //exy[0][1][ix]  =  0.0;
-      //exy[1][0][ix]  =  0.0;
-      //exy[1][1][ix]  = star->GetSigmaYCalc()*star->GetSigmaYCalc(); 
-    }
-
-    else if (fInputType == 1)
-    {
-      // values from Gauss fit
-      bxy[0][ix]   = star->GetMeanXFit(); 
-      bxy[1][ix]   = star->GetMeanYFit(); 
-
-      // this is the error matrix for (MeanXFit, MeanYFit);
-      // this is the error matrix which should be used
-      exy[0][0][ix]  =  star->GetXXErrFit(); 
-      exy[0][1][ix]  =  star->GetXYErrFit();
-      exy[1][0][ix]  =  star->GetXYErrFit();
-      exy[1][1][ix]  =  star->GetYYErrFit();
-
-      // this is the error matrix constructed from SigmaXFit and SigmaYFit;
-      // it is used because the errors above are too small, at present
-      //exy[0][0][ix]  =  star->GetSigmaXFit() * star->GetSigmaXFit(); 
-      //exy[0][1][ix]  =  star->GetCorrXYFit() * 
-      //                  star->GetSigmaXFit() * star->GetSigmaYFit();
-      //exy[1][0][ix]  =  exy[0][1][ix];
-      //exy[1][1][ix]  =  star->GetSigmaYFit() * star->GetSigmaYFit();
-    }
-
-    else
-    {
-      *fLog << err << "MTelAxisFromStars::Process;  type of input is not defined" 
-            << endl;
-      return kFALSE;
-    }   
-
-    // don't include stars with undefined error
-    Double_t deter =   exy[0][0][ix]*exy[1][1][ix]
-                     - exy[0][1][ix]*exy[1][0][ix];
-
-    //*fLog << "ix ,deter, xx, xy, yy = " << ix << ":    "
-    //      << deter << ",  " << exy[0][0][ix] << ",  "
-    //      << exy[0][1][ix] << ",  " << exy[1][1][ix] << endl;
-    if (deter <= 0.0)
-      continue;
-
-    //*fLog << "MTelAxisFromStars : " << endl;
-    //*fLog << "      ix, XExp, YExp, XFit, YFit, SigmaX2, SigmaXY, SigmaY2 = " 
-    //      << ix << " :  " 
-    //      << axy[0][ix] << ",  " << axy[1][ix] << ",  "
-    //      << bxy[0][ix] << ",  " << bxy[1][ix] << ",  "
-    //      << exy[0][0][ix] << ",  " << exy[0][1][ix] << ",  " 
-    //      << exy[1][1][ix] << endl;
-
-    ix++;
-  }
-
-  //--------------------------------------
-  // Find the transformation from expected positions (axy[1], axy[2]) 
-  // to measured positions (bxy[1], bxy[2]) in the camera
-
-  Int_t fNStars = ix;
-
-  if (ix < fNumStars)
-  {
-    // reset the sizes of the arrays
-    Int_t fNStars = ix;
-    axy[0].Set(fNStars);
-    axy[1].Set(fNStars);
-
-    bxy[0].Set(fNStars);
-    bxy[1].Set(fNStars);
-
-    exy[0][0].Set(fNStars);
-    exy[0][1].Set(fNStars);
-    exy[1][0].Set(fNStars);
-    exy[1][1].Set(fNStars);
-  }
-
-  Bool_t fitOK;
-  if (fNStars < 1)
-  {
-    //*fLog << "MTelAxisFromStars::Process; no star for MTelAxisFromStars"
-    //      << endl;
-    fitOK = kFALSE;
-  }
-  else
-  {
-    fitOK =  FindSkyCamTrans(axy,      bxy,   exy,   
-               fFixedRotationAngle,    fFixedScaleFactor, fLambda,
-               fAlfa  ,  fA,    fD,    fErrD,
-               fNumIter, fNdof, fChi2, fChi2Prob);
-  }
-
-  if (!fitOK  &&  fNStars >= 1)
-  {
-    *fLog << err 
-          << "MTelAxisFromStars::Process;  Fit to find transformation from star to camera system failed" 
-          << endl;
-    
-    //if (fNStars > 0)
-    //{
-    //  *fLog << err 
-    //        << "    fNumIter, fNdof, fChi2, fChi2Prob = " << fNumIter
-    //        << ",  " << fNdof << ",  " << fChi2 << ",  " << fChi2Prob << endl;
-    //}
-
-    return kTRUE;
-  }
-
-
-  //--------------------------------------
-  // Put the transformation parameters into the MSkyCamTrans container
-
-  fSkyCamTrans->SetParameters(fLambda,   fAlfa,    fA,    fD,    fErrD,
-                              fNumStars, fNumIter, fNdof, fChi2, fChi2Prob);
-  fSkyCamTrans->SetReadyToSave();
-
-  //--------------------------------------
-  // Put the camera position (X, Y) 
-  //         obtained by transforming the camera center (0, 0)
-  // into MPntPosCam[MSrcPosCam]
-
-  fPntPos->SetXY(fD[0], fD[1]);
-  fPntPos->SetReadyToSave();       
-
-
-  //--------------------------------------
-  // Put the corrected pointing position into MPointingPos 
-  //
-  SetPointingPosition(fStarCamTrans, fDrive, fSkyCamTrans, fPointPos);
-
-
-  //--------------------------------------
-  // Put the estimated position of the source into SrcPosCam
-  //
-  // get the source direction from MReportDrive
-  // Note : this has to be changed for the wobble mode, where the source 
-  //        isn't in the center of the camera
-  Double_t decsource = fDrive->GetDec();
-  Double_t rasource  = fDrive->GetRa();
-  //
-  Double_t radrive = fDrive->GetRa();
-  Double_t hdrive  = fDrive->GetHa();
-  Double_t hsource = hdrive + radrive - rasource;
-  fSourcePos->SetSkyPosition(rasource, decsource, hsource);
-
-  SetSourcePosition(fStarCamTrans, fPointPos, fSourcePos, fSrcPos);
-
-  //*fLog << "after calling SetSourcePosition : , X, Y ,fD = " 
-  //      << fSrcPos->GetX() << ",  " << fSrcPos->GetY() << ",  "
-  //      << fD[0] << ",  " << fD[1] << endl;
-
-  //--------------------------------------
-  // Apply the transformation to some expected positions (asxy[1], asxy[2]) 
-  // to obtain estimated positions (bsxy[1], bsxy[2]) in the camera 
-  //      and their error matrices esxy[2][2]
-
-  // get the expected positions (asxy[1], asxy[2]) from another MStarCam 
-  // container (with the name "MSourceCam") 
-  Int_t fNumStarsSource = 0; 
-
-  if (fSourceCam)
-    fNumStarsSource = fSourceCam->GetNumStars();
-
-  //*fLog << "MTelAxisFromStars::Process;  fNumStarsSource = " 
-  //      << fNumStarsSource << endl;
-
-  if (fNumStarsSource > 0)
-  {
-    TArrayD  asxy[2];
-    asxy[0].Set(fNumStarsSource);
-    asxy[1].Set(fNumStarsSource);
-
-    TArrayD  bsxy[2];
-    bsxy[0].Set(fNumStarsSource);
-    bsxy[1].Set(fNumStarsSource);
-
-    TArrayD  esxy[2][2];
-    esxy[0][0].Set(fNumStarsSource);
-    esxy[0][1].Set(fNumStarsSource);
-    esxy[1][0].Set(fNumStarsSource);
-    esxy[1][1].Set(fNumStarsSource);
-
-    MStarPos *starSource = 0;
-    TIter nextSource(fSourceCam->GetList());
-    ix = 0;
-    while ( (starSource = (MStarPos*)nextSource()) )
-    {
-      asxy[0][ix]  = starSource->GetXExp(); 
-      asxy[1][ix]  = starSource->GetYExp(); 
-
-      ix++;
-    }
-
-    TransSkyCam(fLambda, fA, fD, fErrD, asxy, bsxy,  esxy);   
-
-    // put the estimated positions into the MStarCam container
-    // with name "MSourceCam"
-    TIter setnextSource(fSourceCam->GetList());
-    ix = 0;
-    while ( (starSource = (MStarPos*)setnextSource()) )
-    {
-       Double_t corr = esxy[0][1][ix] / 
-                       TMath::Sqrt( esxy[0][0][ix] * esxy[1][1][ix] );
-       if (fInputType == 1)
-       {
-         starSource->SetFitValues(100.0, 100.0, bsxy[0][ix], bsxy[1][ix],
-	       TMath::Sqrt(esxy[0][0][ix]), TMath::Sqrt(esxy[1][1][ix]), corr,
-               esxy[0][0][ix],       esxy[0][1][ix],       esxy[1][1][ix], 
-               fChi2, fNdof); 
-       }
-       else
-       {
-         starSource->SetCalcValues(100.0, 100.0, bsxy[0][ix], bsxy[1][ix],
-	       TMath::Sqrt(esxy[0][0][ix]), TMath::Sqrt(esxy[1][1][ix]), corr,
-               esxy[0][0][ix],       esxy[0][1][ix],       esxy[1][1][ix]); 
-       }
-
-      ix++;
-    }
-
-  }
-
-  //--------------------------------------
-
-  return kTRUE;
-}
-
-
-
-//---------------------------------------------------------------------------
-//
-// FindSkyCamTrans
-//
-// This routine determines the transformation 
-//
-//                                      ( cos(alfa)   -sin(alfa) )
-//      b = lambda * A * a + d      A = (                        )
-//             ^     ^       ^          ( sin(alfa)    cos(alfa) )
-//             |     |       |
-//           scale rotation shift 
-//          factor matrix
-//
-// from sky coordinates 'a' (projected onto the camera) to camera 
-// coordinates 'b', using the positions of known stars in the camera. 
-// The latter positions may have been determined by analysing the 
-// DC currents in the different pixels.
-//
-// Input  : a[2]    x and y coordinates of stars projected onto the camera;
-//                  they were obtained from (RA, dec) of the stars and
-//                  (ThetaTel, PhiTel) and the time of observation;
-//                  these are the 'expected positions' of stars in the camera
-//          b[2]    'measured positions' of these stars in the camera;
-//                  they may have been obtained from the DC currents
-//          e[2][2] error matrix of b[2]
-//          fixedrotationangle  value [in degrees] at which rotation angle 
-//                              alfa should be fixed; -1 means don't fix
-//          fixedscalefactor    value at which scale factor lambda  
-//                              should be fixed; -1 means don't fix
-//
-// Output : lambda, alfadeg, A[2][2], d[2]   fit results;
-//                               parameters describing the transformation 
-//                               from 'expected positions' to the 'measured 
-//                               positions' in the camera
-//          errd[2][2]           error matrix of d[2]
-//          fNumIter             number of iterations
-//          fNdoF                number of degrees of freedom
-//          fChi2                chi-square value
-//          fChi2Prob            chi-square probability
-//
-// The units are assumed to be 
-//     [degrees]  for  alfadeg
-//     [mm]       for  a, b, d
-//     [1]        for  lambda                       
-
-Bool_t MTelAxisFromStars::FindSkyCamTrans(
-   TArrayD a[2],      TArrayD b[2],     TArrayD e[2][2], 
-   Double_t &fixedrotationang, Double_t &fixedscalefac,  Double_t &lambda,  
-   Double_t &alfadeg, Double_t A[2][2], Double_t d[2],   Double_t errd[2][2],
-   Int_t &fNumIter,   Int_t &fNdof,     Double_t &fChi2, Double_t &fChi2Prob)
-{
-  Int_t fNumStars = a[0].GetSize();
-
-  //*fLog << "MTelAxisFromStars::FindSkyCamTrans; expected and measured positions :"
-  //        << endl;
-  for (Int_t ix=0; ix<fNumStars; ix++)
-  {
-    //*fLog << "    ix, a[0], a[1], b[0], b[1], errxx, errxy, erryy = " 
-    //        << ix << " :   " 
-    //        << a[0][ix] << ",  " << a[1][ix] << ";    " 
-    //        << b[0][ix] << ",  " << b[1][ix] << ";    " 
-    //        << e[0][0][ix] << ",  " << e[0][1][ix] << ",  "
-    //        << e[1][1][ix] << endl;
-  }
-
-
-  //-------------------------------------------
-  // fix some parameters if the number of degrees of freedom is too low
-  // (<= 0.0)
-
-  Double_t fixedscalefactor   = fixedscalefac;
-  Double_t fixedrotationangle = fixedrotationang;
-
-  // calculate number of degrees of freedom
-  fNdof = 2 * fNumStars - 4;
-  if (fixedscalefactor != -1.0)
-     fNdof += 1;
-  if (fixedrotationangle != -1.0)
-     fNdof += 1;
-
-  // if there is only 1 star fix both rotation angle and scale factor
-  if (fNumStars == 1)
-  {
-     if (fixedscalefactor == -1.0)
-     {  
-       fixedscalefactor = 1.0;
-       *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; scale factor is fixed at "
-	     << fixedscalefactor << endl;
-     }
-     if (fixedrotationangle == -1.0)
-     {
-       fixedrotationangle = 0.0;
-       *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; rotation angle is fixed at "
-	     << fixedrotationangle << endl;
-     }
-  }
-  // otherwise fix only 1 parameter if possible
-  else if (fNdof < 0)
-  {
-    if (fNdof < -2)
-    {
-      *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; number of degrees of freedom is too low : " 
-            << fNdof << ";  fNumStars = " << fNumStars << endl;
-      return kFALSE;
-    }
-    else if (fNdof == -2)
-    {
-      if (fixedscalefactor == -1.0  &&  fixedrotationangle == -1.0)
-      {
-        fixedscalefactor   = 1.0;
-        fixedrotationangle = 0.0;
-        *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; scale factor and rotation angle are fixed at " 
-              << fixedscalefactor << "  and  " << fixedrotationangle 
-              << " respectively" << endl;
-      }
-      else
-      {
-        *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; number of degrees of freedom is too low : " 
-              << fNdof << ";  fNumStars = " << fNumStars << endl;
-        return kFALSE;
-      }
-    }
-    else if (fNdof == -1)
-    {
-      if (fixedrotationangle == -1.0)
-      {
-        fixedrotationangle = 0.0;
-        *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; rotation angle is fixed at "
-	      << fixedrotationangle << endl;
-      }
-      else if (fixedscalefactor == -1.0)
-      {
-        fixedscalefactor = 1.0;
-        *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; scale factor is fixed at "
-	      << fixedscalefactor << endl;
-      }
-      else
-      {
-        *fLog << warn << "MTelAxisFromStars::FindSkyCamTrans; number of degrees of freedom is too low : " 
-              << fNdof << ";  fNumStars = " << fNumStars<< endl;
-        return kFALSE;
-      }
-    }
-  }
-
-  // recalculate number of degrees of freedom
-  fNdof = 2 * fNumStars - 4;
-  if (fixedscalefactor != -1.0)
-     fNdof += 1;
-  if (fixedrotationangle != -1.0)
-     fNdof += 1;
-
-  if (fNdof < 0)
-    return kFALSE;
-  //-------------------------------------------
-
-
-  // get first approximation of scaling factor
-  if (fixedscalefactor != -1.0)
-    lambda = fixedscalefactor;
-  else
-    lambda = 1.0;
-
-  Double_t lambdaold = lambda;
-  Double_t dlambda = 0.0;
-
-  // get first approximation of rotation angle
-  Double_t alfa = 0.0;
-  if (fixedrotationangle != -1.0)
-    alfa = fixedrotationangle / TMath::RadToDeg();
-
-  Double_t alfaold   = alfa;
-  // maximum allowed change of alfa in 1 iteration step (5 degrees)
-  Double_t dalfamax = 5.0 / TMath::RadToDeg();
-  Double_t dalfa = 0.0;
-
-  Double_t cosal = TMath::Cos(alfa);
-  Double_t sinal = TMath::Sin(alfa);
-
-  A[0][0] =  cosal;
-  A[0][1] = -sinal;
-  A[1][0] =  sinal;
-  A[1][1] =  cosal;
-
-
-  Double_t absdold2    = 10000.0;
-  Double_t fChangeofd2 = 10000.0;
-
-
-  TArrayD Aa[2];
-  Aa[0].Set(fNumStars);
-  Aa[1].Set(fNumStars);
-
-
-  Double_t sumEbminlamAa[2];
-
-  TArrayD Ebminlambracd[2];
-  Ebminlambracd[0].Set(fNumStars);
-  Ebminlambracd[1].Set(fNumStars);
-
-  TArrayD EAa[2];
-  EAa[0].Set(fNumStars);
-  EAa[1].Set(fNumStars);
-
-  // invert the error matrices
-  TArrayD  c[2][2];
-  c[0][0].Set(fNumStars);
-  c[0][1].Set(fNumStars);
-  c[1][0].Set(fNumStars);
-  c[1][1].Set(fNumStars);
-
-  for (Int_t ix=0; ix<fNumStars; ix++)
-  {
-    Double_t XX = e[0][0][ix]; 
-    Double_t XY = e[0][1][ix]; 
-    Double_t YY = e[1][1][ix]; 
-
-    // get inverse of error matrix
-    Double_t determ = XX*YY - XY*XY;
-    c[0][0][ix]  =  YY / determ; 
-    c[0][1][ix]  = -XY / determ; 
-    c[1][0][ix]  = -XY / determ;
-    c[1][1][ix]  =  XX / determ; 
-  }
-
-
-
-  // calculate sum of inverted error matrices
-  Double_t determsumc;
-  Double_t sumc[2][2];
-  sumc[0][0] = 0.0;
-  sumc[0][1] = 0.0;
-  sumc[1][0] = 0.0;
-  sumc[1][1] = 0.0;
-
-  for (Int_t ix=0; ix<fNumStars; ix++)
-  {
-       sumc[0][0]  += c[0][0][ix]; 
-       sumc[0][1]  += c[0][1][ix]; 
-       sumc[1][0]  += c[1][0][ix]; 
-       sumc[1][1]  += c[1][1][ix]; 
-  }
-  determsumc = sumc[0][0]*sumc[1][1] - sumc[0][1]*sumc[1][0];
-
-  // calculate inverse of sum of inverted error matrices
-  Double_t sumcinv[2][2];
-  sumcinv[0][0]  =  sumc[1][1] / determsumc; 
-  sumcinv[0][1]  = -sumc[0][1] / determsumc; 
-  sumcinv[1][0]  = -sumc[1][0] / determsumc;
-  sumcinv[1][1]  =  sumc[0][0] / determsumc; 
-
-  //*fLog << "sumcinv = " << sumcinv[0][0] << ",  " << sumcinv[0][1] 
-  //      << ",  " << sumcinv[1][1] << endl;
-
-
-  // minimize chi2 by iteration *****   start   **********************
-  
-  // stop iteration when change in |d|*|d| is less than 'told2'
-  //                and  change in alfa    is less than 'toldalfa'
-  //                and  change in lambda  is less than 'toldlambda'
-  //                 or  chi2              is less than 'tolchi2'
-  Double_t told2 = 0.3*0.3;  // [mm*mm]; 1/100 of an inner pixel diameter
-  Double_t toldalfa = 0.01 / TMath::RadToDeg();  // 0.01 degrees 
-  Double_t toldlambda = 0.00006;   // uncertainty of 1 mm of distance 
-                                   // between camera and reflector
-  Double_t tolchi2 = 1.e-5;
-
-  Int_t fNumIterMax  = 100;
-  fNumIter           =   0;
-
-  for (Int_t i=0; i<fNumIterMax; i++)
-  {
-    fNumIter++;
-
-    // get next approximation of d  ------------------
-    for (Int_t ix=0; ix<fNumStars; ix++)
-    {
-        Aa[0][ix] = A[0][0] * a[0][ix]  +  A[0][1]*a[1][ix];
-        Aa[1][ix] = A[1][0] * a[0][ix]  +  A[1][1]*a[1][ix];
-
-        //*fLog << "ix, Aa = " << ix << " :  " << Aa[0][ix] << ",  "
-        //      << Aa[1][ix] << endl;
-    }
-
-    sumEbminlamAa[0] = 0.0;
-    sumEbminlamAa[1] = 0.0;
-
-    for (Int_t ix=0; ix<fNumStars; ix++)
-    {
-      sumEbminlamAa[0] +=   c[0][0][ix] * (b[0][ix] - lambda*Aa[0][ix])
-                          + c[0][1][ix] * (b[1][ix] - lambda*Aa[1][ix]);
-
-      sumEbminlamAa[1] +=   c[1][0][ix] * (b[0][ix] - lambda*Aa[0][ix])
-                          + c[1][1][ix] * (b[1][ix] - lambda*Aa[1][ix]);
-    }
-
-    //*fLog << "sumEbminlamAa = " << sumEbminlamAa[0] << ",  "
-    //      << sumEbminlamAa[1] << endl;
-
-    d[0] =      sumcinv[0][0] * sumEbminlamAa[0]
-	      + sumcinv[0][1] * sumEbminlamAa[1] ;
-
-    d[1] =      sumcinv[1][0] * sumEbminlamAa[0] 
-              + sumcinv[1][1] * sumEbminlamAa[1] ;
-
-    Double_t absdnew2 = d[0]*d[0] + d[1]*d[1]; 
-    fChangeofd2 = absdnew2 - absdold2;
-
-    //*fLog << "fNumIter : " << fNumIter 
-    //      << "; alfa, lambda, d[0], d[1], absdold2, absdnew2 = " << endl; 
-    //*fLog << alfa << ",  " << lambda << ",  " << d[0] << ",  " << d[1] 
-    //      << ",  " << absdold2 << ",  " << absdnew2 << endl;
-     
-
-    if ( fabs(fChangeofd2) < told2   &&  fabs(dalfa) < toldalfa  &&
-         fabs(dlambda)     < toldlambda ) 
-    {
-      //*fLog << "Iteration stopped because of small changes : fChangeofd2, dalfa, dlambda = "
-      //      << fChangeofd2 << ",  " << dalfa << ",  "  << dlambda << endl;
-      break;
-    }
-    absdold2 = absdnew2;
-
-    // get next approximation of matrix A  ----------------
-    if (fFixedRotationAngle == -1.0)
-    {     
-        for (Int_t ix=0; ix<fNumStars; ix++)
-        {
-          Ebminlambracd[0][ix] =   
-             c[0][0][ix] * ( b[0][ix] - lambda*Aa[0][ix] - d[0] )
-           + c[0][1][ix] * ( b[1][ix] - lambda*Aa[1][ix] - d[1] );
-
-          Ebminlambracd[1][ix] =   
-             c[1][0][ix] * ( b[0][ix] - lambda*Aa[0][ix] - d[0] )
-           + c[1][1][ix] * ( b[1][ix] - lambda*Aa[1][ix] - d[1] );
-
-          //*fLog << "ix, Ebminlambracd = " << ix << " :  "
-          //      << Ebminlambracd[0][ix] << ",  "
-          //      << Ebminlambracd[1][ix] << endl;
-        }
-
-        // stop iteration if fChi2 is small enough
-        fChi2 = 0.0;
-        for (Int_t ix=0; ix<fNumStars; ix++)
-        {
-          fChi2 +=  (b[0][ix]-lambda*Aa[0][ix]-d[0] ) * Ebminlambracd[0][ix]
-                  + (b[1][ix]-lambda*Aa[1][ix]-d[1] ) * Ebminlambracd[1][ix];
-        }
-        if ( fChi2 < tolchi2 ) 
-        {
-          //*fLog << "iteration stopped because of small fChi2 :  "
-          //      << fChi2 << endl;
-          break;
-        }
-
-
-        Double_t dchi2dA[2][2];
-        dchi2dA[0][0] = 0.0; 
-        dchi2dA[0][1] = 0.0;
-        dchi2dA[1][0] = 0.0;
-        dchi2dA[1][1] = 0.0;
-		
-        for (Int_t ix=0; ix<fNumStars; ix++)
-        {
-          dchi2dA[0][0] += Ebminlambracd[0][ix] * a[0][ix];
-          dchi2dA[0][1] += Ebminlambracd[0][ix] * a[1][ix];
-          dchi2dA[1][0] += Ebminlambracd[1][ix] * a[0][ix];
-          dchi2dA[1][1] += Ebminlambracd[1][ix] * a[1][ix];
-        }
-
-        //*fLog << "dchi2dA = " << dchi2dA[0][0] << ",  " << dchi2dA[0][1]
-        //      << ",  " << dchi2dA[1][0] << ",  " << dchi2dA[1][1] << endl;
-
-        // *********  1st derivative (d chi2) / (d alfa) ************
-        Double_t dchi2dalfa =   -2.0*lambda * 
-                              ( - sinal*(dchi2dA[0][0]+dchi2dA[1][1])
-                                + cosal*(dchi2dA[1][0]-dchi2dA[0][1]) );
-        
-
-        //Double_t dalfa1st = - fChi2 / dchi2dalfa;
-
-        //*fLog << "fChi2, dchi2dalfa = " << fChi2 << ",  " 
-        //      << dchi2dalfa << endl;
-        //*fLog << "proposed change of alfa using 1st derivative = " 
-        //      << dalfa1st << endl;
-
-        // *********  2nd derivative (d2 chi2) / (d alfa2) ******
-        Double_t term1 = 0.0;
-        Double_t term2 = 0.0;
-        Double_t term3 = 0.0;
-        Double_t term4 = 0.0;
-
-        for (Int_t ix=0; ix<fNumStars; ix++)
-        {
-          term1 += a[0][ix]*c[0][0][ix]*a[0][ix] + a[1][ix]*c[1][0][ix]*a[0][ix]
-	         + a[0][ix]*c[0][1][ix]*a[1][ix] + a[1][ix]*c[1][1][ix]*a[1][ix];
-
-          term2 += a[0][ix]*c[1][0][ix]*a[0][ix] - a[1][ix]*c[0][0][ix]*a[0][ix]
-	         + a[0][ix]*c[1][1][ix]*a[1][ix] - a[1][ix]*c[0][1][ix]*a[1][ix];
-
-          term3 = a[0][ix]*c[0][0][ix]*a[1][ix] + a[1][ix]*c[1][0][ix]*a[1][ix]
-	         - a[0][ix]*c[0][1][ix]*a[0][ix] - a[1][ix]*c[1][1][ix]*a[0][ix];
-
-          term4 += a[0][ix]*c[1][0][ix]*a[1][ix] - a[1][ix]*c[0][0][ix]*a[1][ix]
-	         - a[0][ix]*c[1][1][ix]*a[0][ix] + a[1][ix]*c[0][1][ix]*a[0][ix];
-        }
-
-        Double_t d2chi2dalfa2 = 
-                  - 2.0*lambda * ( - cosal*(dchi2dA[0][0]+dchi2dA[1][1])
-                                   - sinal*(dchi2dA[1][0]-dchi2dA[0][1]) )
-	   + 2.0*lambda*lambda * ( sinal*sinal * term1 - sinal*cosal * term2
-		  	         + sinal*cosal * term3 - cosal*cosal * term4);
-
-        // Gauss-Newton step
-        Double_t dalfa2nd = - dchi2dalfa / d2chi2dalfa2;
-
-        //*fLog << "proposed change of alfa using 2st derivative = " 
-        //    << dalfa2nd << endl;
-
-        //dalfa = dalfa1st;
-        dalfa = dalfa2nd;
-
-        // ******************************************
-
-
-        // restrict change of alfa
-        if ( fabs(dalfa) > dalfamax )
-        {
-          dalfa = TMath::Sign( dalfamax, dalfa ); 
-        }
-        alfa = alfaold + dalfa;
-
-        if ( alfa < -5.0/TMath::RadToDeg() )
-          alfa = -5.0/TMath::RadToDeg();
-        else if ( alfa > 5.0/TMath::RadToDeg() )
-          alfa = 5.0/TMath::RadToDeg();
-        
-        dalfa = alfa - alfaold;
-
-        alfaold = alfa;
-
-        sinal = TMath::Sin(alfa);
-        cosal = TMath::Cos(alfa);
-
-        A[0][0] =  cosal;
-        A[0][1] = -sinal;
-        A[1][0] =  sinal;
-        A[1][1] =  cosal;
-
-        //*fLog << "alfa-alfaold = " << dalfa << endl;
-        //*fLog << "new alfa = " << alfa << endl;
-    }
-
-
-    // get next approximation of lambda  ----------------
-    if (fFixedScaleFactor == -1.0)
-    {
-      for (Int_t ix=0; ix<fNumStars; ix++)
-      {
-        Aa[0][ix] = A[0][0]*a[0][ix] + A[0][1]*a[1][ix];
-        Aa[1][ix] = A[1][0]*a[0][ix] + A[1][1]*a[1][ix];
-
-        EAa[0][ix] =   
-           c[0][0][ix] * Aa[0][ix]  +  c[0][1][ix] * Aa[1][ix];
-        EAa[1][ix] =   
-           c[1][0][ix] * Aa[0][ix]  +  c[1][1][ix] * Aa[1][ix];
-
-        //*fLog << "ix, Aa = " << ix << " :  " << Aa[0][ix] << ",  "
-        //      << Aa[1][ix] << endl;
-
-        //*fLog << "ix, EAa = " << ix << " :  " << EAa[0][ix] << ",  "
-        //      << EAa[1][ix] << endl;
-      }
-
-      Double_t num   = 0.0;
-      Double_t denom = 0.0;
-      for (Int_t ix=0; ix<fNumStars; ix++)
-      {
-        num    +=   (b[0][ix]-d[0]) * EAa[0][ix] 
-                  + (b[1][ix]-d[1]) * EAa[1][ix];
-
-        denom  +=    Aa[0][ix]      * EAa[0][ix]  
-                  +  Aa[1][ix]      * EAa[1][ix]; 
-
-        //*fLog << "ix : b-d = " << ix << " :  " << b[0][ix]-d[0]
-	//      << ",  " << b[1][ix]-d[1] << endl;
-
-        //*fLog << "ix : Aa = " << ix << " :  " << Aa[0][ix]
-	//      << ",  " << Aa[1][ix] << endl;
-      }
-
-      lambda = num / denom;
-
-      if ( lambda < 0.9 )
-        lambda = 0.9;
-      else if ( lambda > 1.1 )
-        lambda = 1.1;
-
-      dlambda = lambda - lambdaold;
-      lambdaold = lambda;
-
-      //*fLog << "num, denom, lambda, dlambda = " << num
-      //      << ",  " << denom << ",  " << lambda << ",  "
-      //      << dlambda << endl;
-    }
-
-  }
-  //-------   end of iteration *****************************************
-
-  alfadeg = alfa * TMath::RadToDeg();
-
-  // calculate error matrix of d[2]
-  errd[0][0] = sumcinv[0][0];
-  errd[0][1] = sumcinv[0][1];
-  errd[1][0] = sumcinv[1][0];
-  errd[1][1] = sumcinv[1][1];
-
-  // evaluate quality of fit
-
-  // calculate chi2
-  for (Int_t ix=0; ix<fNumStars; ix++)
-  {
-    Ebminlambracd[0][ix] =   
-       c[0][0][ix] * ( b[0][ix] - lambda*Aa[0][ix] - d[0] )
-     + c[0][1][ix] * ( b[1][ix] - lambda*Aa[1][ix] - d[1] );
-
-    Ebminlambracd[1][ix] =   
-       c[1][0][ix] * (b[0][ix] - lambda*Aa[0][ix] - d[0] )
-     + c[1][1][ix] * (b[1][ix] - lambda*Aa[1][ix] - d[1] );
-  }
-
-  fChi2 = 0.0;
-  for (Int_t ix=0; ix<fNumStars; ix++)
-  {
-    fChi2 +=  (b[0][ix] - lambda*Aa[0][ix] - d[0] ) * Ebminlambracd[0][ix]
-            + (b[1][ix] - lambda*Aa[1][ix] - d[1] ) * Ebminlambracd[1][ix];
-  }
-
-  fChi2Prob = TMath::Prob(fChi2, fNdof);
-
-  //*fLog << "MTelAxisFromStars::FindSkyCamTrans :" << endl;
-  //*fLog <<  "   fNumStars, fChi2, fNdof, fChi2Prob, fNumIter, fChangeofd2, dalfa, dlambda = "
-  //      << fNumStars << ",  " << fChi2 << ",  " << fNdof << ",  " 
-  //      << fChi2Prob << ",  " 
-  //      << fNumIter << ",  "  << fChangeofd2 << ",  " << dalfa << ",  "
-  //      << dlambda << endl;
-  //*fLog << "    lambda, alfadeg, d[0], d[1] = " << lambda << ",  " 
-  //      << alfadeg   << ",  " << d[0] << ",  " << d[1] << endl;
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// Apply transformation (lambda, A, d)
-//       to the        expected  positions (a[1], a[2]) 
-//       to obtain the estimated positions (b[1], b[2])
-//
-//       e[2][2]       is the error matrix of b[2]
-
-void MTelAxisFromStars::TransSkyCam(
-    Double_t &lambda, Double_t A[2][2], Double_t d[2], Double_t errd[2][2],
-    TArrayD a[2],     TArrayD b[2],     TArrayD e[2][2])   
-{
-  Int_t numpos = a[0].GetSize();
-  if (numpos <= 0)
-    return;
-
-  //*fLog << "MTelAxisFromStars::TransSkyCam; lambda, A, d = " 
-  //      << lambda << ";    " << A[0][0] << ",  " << A[0][1] << ",  "
-  //      << A[1][1] << ";   " << d[0] << ",  " << d[1] << endl;   
-
-  //*fLog << "MTelAxisFromStars::TransSkyCam; expected and estimated positions :"
-  //      << endl;
-
-  for (Int_t ix=0; ix<numpos; ix++)
-  {
-    //    *fLog << "MTelAxisFromStars;  ix = " << ix << endl;
-
-      b[0][ix] = lambda * (A[0][0]*a[0][ix] + A[0][1]*a[1][ix]) + d[0];
-      b[1][ix] = lambda * (A[1][0]*a[0][ix] + A[1][1]*a[1][ix]) + d[1];
-
-      e[0][0][ix] = errd[0][0];
-      e[0][1][ix] = errd[0][1];
-      e[1][0][ix] = errd[1][0];
-      e[1][1][ix] = errd[1][1];
-
-      // *fLog << "    ix, a[0], a[1], b[0], b[1], errxx, errxy, erryy = " 
-      //      << ix << " :   " 
-      //      << a[0][ix] << ",  " << a[1][ix] << ";    " 
-      //      << b[0][ix] << ",  " << b[1][ix] << ";    " 
-      //      << e[0][0][ix] << ",  " << e[0][1][ix] << ",  "
-      //      << e[1][1][ix] << endl;
-  }
-}
-
-// --------------------------------------------------------------------------
-//
-// SetPointingPosition
-//
-//    put the corrected pointing direction into MPointingPos[MPointingPos];
-//    this direction corresponds to the position (0,0) in the camera
-//
-
-Bool_t MTelAxisFromStars::SetPointingPosition(MStarCamTrans *fstarcamtrans,
-       MReportDrive *fdrive, MSkyCamTrans *ftrans, MPointingPos *fpointpos)
-{
-  Double_t decdrive = fdrive->GetDec();
-  Double_t hdrive   = fdrive->GetHa();
-  Double_t radrive  = fdrive->GetRa();
-
-  // this is the estimated position (with optical aberration) in the camera 
-  // corresponding to the direction in MReportDrive
-  Double_t Xpoint = (ftrans->GetShiftD())[0];    
-  Double_t Ypoint = (ftrans->GetShiftD())[1];    
-
-  // get the sky direction corresponding to the position (0,0) in the camera
-  Double_t decpoint = 0.0;
-  Double_t hpoint   = 0.0;
-  fstarcamtrans->CelCamToCel0(decdrive, hdrive, 
-                         Xpoint/fAberr, Ypoint/fAberr, decpoint, hpoint);
-  Double_t rapoint = radrive - hpoint + hdrive;
-  fpointpos->SetSkyPosition(rapoint, decpoint, hpoint);
-
-  // get the local direction corresponding to the position (0,0) in the camera
-  Double_t thetadrive = fdrive->GetNominalZd();
-  Double_t phidrive   = fdrive->GetNominalAz();
-  Double_t thetapoint = 0.0;
-  Double_t phipoint   = 0.0;
-  fstarcamtrans->LocCamToLoc0(thetadrive, phidrive, 
-               Xpoint/fAberr, Ypoint/fAberr, thetapoint, phipoint); 
-  fpointpos->SetLocalPosition(thetapoint, phipoint);
-  fpointpos->SetReadyToSave();
-
-  //*fLog << "SetPointingPosition : decdrive, hdrive, radrive Xpoint, Ypoint = "
-  //      << decdrive << ",  " << hdrive << ",  " << radrive << ",  "
-  //      << Xpoint << ",  " << Ypoint << endl;
-
-  //*fLog << "SetPointingPosition : thetadrive, phidrive, thetapoint, phipoint = "       
-  //      << thetadrive << ",  " << phidrive << ",  " << thetapoint << ",  "
-  //      << phipoint << endl;
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-// SetSourcePosition
-//
-//    put the estimated position of the source in the camera into 
-//    MSrcPosCam[MSrcPosCam]
-//
-//    and the estimated local direction of the source into
-//    MSourcePos[MPointingPos]
-//
-
-Bool_t MTelAxisFromStars::SetSourcePosition(MStarCamTrans *fstarcamtrans,
-       MPointingPos *fpointpos, MPointingPos *fsourcepos, MSrcPosCam *fsrcpos)
-{
-  // get the corrected pointing direction
-  // corresponding to the position (0,0) in the camera
-  Double_t decpoint = fpointpos->GetDec();
-  Double_t hpoint   = fpointpos->GetHa();
-
-  // get the sky direction of the source
-  Double_t decsource = fsourcepos->GetDec();
-  Double_t hsource   = fsourcepos->GetHa();
-
-  // get the estimated position (Xsource, Ysource) of the source in the camera;
-  // this is a position for an ideal imaging, without optical aberration
-  Double_t Xsource = 0.0;
-  Double_t Ysource = 0.0;
-  fstarcamtrans->Cel0CelToCam(decpoint,  hpoint, 
-                              decsource, hsource, Xsource, Ysource);
-  fsrcpos->SetXY(Xsource*fAberr, Ysource*fAberr);
-  fsrcpos->SetReadyToSave();
-
-  // get the estimated local direction of the source
-  Double_t thetapoint = fpointpos->GetZd();
-  Double_t phipoint   = fpointpos->GetAz();
-  Double_t thetasource = 0.0;
-  Double_t phisource   = 0.0;
-  fstarcamtrans->Loc0CamToLoc(thetapoint, phipoint, 
-                              Xsource, Ysource, thetasource, phisource);
-  fsourcepos->SetLocalPosition(thetasource, phisource);
-  fsourcepos->SetReadyToSave();
-
-  //*fLog << "SetSourcePosition : decpoint, hpoint, decsource, hsource, Xsource, Ysource = "
-  //      << decpoint << ",  " << hpoint << ",  " << decsource << ",  "
-  //      << hsource  << ",  " << Xsource << ",  " << Ysource << endl;
-  //*fLog << "SetSourcePosition : thetapoint, phipoint, thetasource, phisource = "
-  //      << thetapoint << ",  " << phipoint << ",  " << thetasource << ",  "
-  //      << phisource << endl;
-
-  return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/MTelAxisFromStars.h	(revision 7136)
+++ 	(revision )
@@ -1,88 +1,0 @@
-#ifndef MARS_MTelAxisFromStars
-#define MARS_MTelAxisFromStars
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MTelAxisFromStars                                                       //
-//                                                                         //
-// Task to calculate the position (in the camera) 
-//      of certain sky directions (source position, tracking direction, ...) 
-//      from the positions (in the camera) of known stars 
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef ROOT_TArrayD
-#include <TArrayD.h>
-#endif
-
-class MReportDrive;
-class MPointingPos;
-class MSrcPosCam;
-class MStarCam;
-class MSkyCamTrans;
-class MStarCamTrans;
-
-class MTelAxisFromStars : public MTask
-{
- private:
-
-    const MStarCam *fStarCam;          //!
-    const MStarCam *fSourceCam;        //!
-
-    MReportDrive        *fDrive;          //!
-    MPointingPos        *fPointPos;       //!
-    MPointingPos        *fSourcePos;      //!
-    MSrcPosCam          *fSrcPos;         //!
-    MSrcPosCam          *fPntPos;         //!
-    MSkyCamTrans        *fSkyCamTrans;    //!
-    MStarCamTrans       *fStarCamTrans;   //!
-
-    Double_t fFixedScaleFactor;           //!
-    Double_t fFixedRotationAngle;         //! [degrees]
-    Double_t fAberr;                      //! optical aberration factor
-
-    Int_t fInputType;                     //! type of input
-
-    Int_t  PreProcess(MParList *pList);
-    Int_t  Process();
-
- public:
-
-    MTelAxisFromStars(const char *name=NULL, const char *title=NULL);
-    ~MTelAxisFromStars();
-
-    void FixScaleFactorAt(Double_t lambda = 1.0);
-    void FixRotationAngleAt(Double_t alfa = 0.0);  // alfa in [degrees]
-
-    void SetOpticalAberr(Double_t aberr);   
-    void SetInputType(Int_t type = 1);
-
-    Bool_t FindSkyCamTrans(TArrayD[2],      TArrayD[2],  TArrayD[2][2], 
-		  	   Double_t &,      Double_t &,  Double_t &,
-	       Double_t &, Double_t[2][2] , Double_t[2], Double_t[2][2],
-               Int_t &,    Int_t &,         Double_t &,  Double_t &); 
-
-    void TransSkyCam(Double_t &,  Double_t[2][2], Double_t[2], Double_t[2][2],
-                     TArrayD[2],  TArrayD[2],     TArrayD[2][2]);   
-
-    Bool_t SetPointingPosition(MStarCamTrans *fstarcamtrans,
-       MReportDrive *fdrive, MSkyCamTrans *ftrans, MPointingPos *fpointpos);
-    Bool_t SetSourcePosition(MStarCamTrans *fstarcamtrans,
-       MPointingPos *fpointpos, MPointingPos *fsourcepos, MSrcPosCam *fsrcpos);
-
-    ClassDef(MTelAxisFromStars, 0) // Task to calculate the source position from star positions
-};
-
-#endif
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/findTelAxisFromStars.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/findTelAxisFromStars.C	(revision 7136)
+++ 	(revision )
@@ -1,413 +1,0 @@
-void ReadSetup(TString fname, MAstroCamera &cam)
-{
-    MMcConfigRunHeader *config=0;
-    MGeomCam           *geom=0;
-
-    TFile file(fname);
-    TTree *tree = (TTree*)file.Get("RunHeaders");
-    tree->SetBranchAddress("MMcConfigRunHeader", &config);
-    if (tree->GetBranch("MGeomCam"))
-        tree->SetBranchAddress("MGeomCam", &geom);
-    tree->GetEntry(0);
-
-    cam.SetMirrors(*config->GetMirrors());
-    cam.SetGeom(*geom);
-}
-
-//--------------------------------------------------------------------------
-//
-//  findTelAxisFromStars
-//
-//  macro to 
-//    - determine the positions of stars in the camera from the DC currents 
-//    - and to find the expected position of the source in the camera
-//
-
-void findTelAxisFromStars(const TString filename="20040422_23213_D_Mrk421_E.root", const TString directory="/.magic/magicserv01/MAGIC/rootdata/2004_04_22/", const UInt_t numEvents = 0)
-{
-  gLog.SetNoColors();
-
-  //-------------------------------------------------------------------
-  // book some histograms which are to be filled in the event loop
-  //
-
-  TH2D *aberr = new TH2D("OpticalAberr", "Opt_Aberr",
-                         100, 0.0, 650.0,  100, 0.0, 650.0);
-  aberr->SetXTitle("Ideal distance from center [mm]");
-  aberr->SetYTitle("Expected distance from center [mm]");
-
-  TProfile *reldiff = new TProfile("RelativeDiff", "Rel_Diff",
-				   100, 0.0, 650.0, -0.2, 0.2, "S");
-  reldiff->SetXTitle("Ideal distance from center [mm]");
-  reldiff->SetYTitle("(R - R0)/R0");
-
-  //-------------------------------------------------------------------
-
-
-  MParList  plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  MGeomCamMagic geomcam;
-  MCameraDC     dccam;
-  MStarCam      starcam;
-
-  //$$$$$$$$$$$$$$$$ ww
-  MObservatory  obs;
-  MStarCam      sourcecam;
-  sourcecam.SetName("MSourceCam");
-
-  MHTelAxisFromStars htelaxis;
-
-  plist.AddToList(&obs);
-  plist.AddToList(&htelaxis);
-  //$$$$$$$$$$$$$$$$ ww
-
-
-  plist.AddToList(&geomcam);
-  plist.AddToList(&dccam);
-  plist.AddToList(&starcam);
-  plist.AddToList(&sourcecam);
-
-  // Reads the trees of the root file and the analysed branches
-  MReadReports read;
-  read.AddTree("Currents"); 
-  read.AddTree("Drive"); // If you do not include Drive info, the MFindStars class
-                         // will not use the star catalog method
-  read.AddFile(directory+filename); // after the reading of the trees!!!
-  read.AddToBranchList("MReportCurrents.*");
-  read.AddToBranchList("MReportDrive.*");
-
-  MGeomApply geomapl;
-  //  TString continuoslightfile =   
-  //   "/data/MAGIC/Period016/rootdata/2004_04_16/20040416_22368_P_Off3c279-2CL100_E.root";
-
-  TString continuoslightfile =
-"/.magic/magicserv01/MAGIC/rootdata/2004_04_16/20040416_22368_P_Off3c279-2CL100_E.root";
-
-
-  Float_t mindc = 0.9; //[uA]
-
-  MCalibrateDC dccal;
-  dccal.SetFileName(continuoslightfile);
-  dccal.SetMinDCAllowed(mindc);
-
-  const Int_t numblind = 5;
-  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
-  const TArrayS blindpixels(numblind,(Short_t*)x);
-  Float_t ringinterest = 100; //[mm]
-  Float_t tailcut = 2.5;
-  UInt_t integratedevents = 1;
-
-  // We need the MAGIC mirror geometry from a MC header:
-  //TString geometryfile = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
-  TString geometryfile =
-"/.magic/magicserv01/MAGIC/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
-
-
-
-
-  // We need the Bright Star Catalog:
-  //TString catalogfile = "/home/rwagner/bsc5.dat";
-  TString catalogfile = "mtemp/mmpi/macros/bsc5.dat";
-
-  //$$$$$$$$$$$$$$$$ ww
-  MSourceDirections sdirs;
-  sdirs.SetGeometryFile(geometryfile);
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 26);
-  const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
-  sdirs.SetRaDec(ra,dec);
-  sdirs.AddDirection(ra,dec,1,"Mkn 421");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  0, 50);
-  const Double_t dec = MAstro::Dms2Rad(39, 12, 44);
-  sdirs.AddDirection(ra,dec,1,"My_UMa 49");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 14, 29);
-  sdirs.AddDirection(ra,dec,1,"My_UMa 51");
-
-  // dummy source dirtections
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 20,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy1");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 20,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy2");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 30,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy3");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 40,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy4");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(38, 50,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy5");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39,  0,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy6");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39, 10,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy7");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39, 20,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy8");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39, 30,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy9");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39, 40,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy10");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(39, 50,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy11");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(40,  0,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy12");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(40, 10,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy13");
-
-  const Double_t ra  = MAstro::Hms2Rad(11,  4, 31);
-  const Double_t dec = MAstro::Dms2Rad(40, 20,  0);
-  sdirs.AddDirection(ra,dec,1,"Dummy14");
-
-
-  sdirs.SetRadiusFOV(3);
-  //$$$$$$$$$$$$$$$$ ww
-
-  MFindStars findstars;
-  findstars.SetBlindPixels(blindpixels);
-  findstars.SetRingInterest(ringinterest);
-  findstars.SetDCTailCut(tailcut);
-  findstars.SetNumIntegratedEvents(integratedevents);
-  findstars.SetMinuitPrintOutLevel(-1);
-  findstars.SetGeometryFile(geometryfile);
-  findstars.SetBSCFile(catalogfile);
-  const Double_t ra  = MAstro::Hms2Rad(11, 4, 26);
-  const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
-  findstars.SetRaDec(ra,dec);
-  findstars.SetLimMag(8);
-  findstars.SetRadiusFOV(1.5);
-
-
-
-  //$$$$$$$$$$$$$$$$ ww
-  Int_t InputType = 0;
-  //findstars.SetUseCorrelatedGauss(kFALSE);
-
-  MTelAxisFromStars telaxis;
-  //telaxis.FixRotationAngleAt(-1.0);
-  //telaxis.FixScaleFactorAt(-1.0);
-  telaxis.SetInputType(InputType);
-
-  MFillH fillhisto("MHTelAxisFromStars[MHTelAxisFromStars]","");
-  htelaxis.SetInputType(InputType);
-  //$$$$$$$$$$$$$$$$ ww
-
-
-  tlist.AddToList(&geomapl);
-  tlist.AddToList(&read);
-  tlist.AddToList(&dccal);
-  tlist.AddToList(&findstars, "Currents");
-
-  //$$$$$$$$$$$$$$$$ ww
-  tlist.AddToList(&sdirs);
-  tlist.AddToList(&telaxis);
-  tlist.AddToList(&fillhisto);
-  //$$$$$$$$$$$$$$$$ ww
-
-
-  
-  // The following lines you only need if in addition you want to display
-  // independent MAstroCamera output
-  //
-  //  TString fname = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
-  //  MObservatory magic1;      
-  //  const Double_t ra  = MAstro::Hms2Rad(11, 4, 26); //Mkn421
-  //  const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
-  //
-  //  MAstroCamera stars;        
-  //  ReadSetup(fname, stars); 
-  //  stars.SetLimMag(9);
-  //  stars.SetRadiusFOV(3);
-  //  stars.SetRaDec(ra, dec);
-  //  stars.ReadBSC("/home/rwagner/bsc5.dat");
-  //  stars.SetObservatory(magic1);
-
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-     
-  if (!evtloop.PreProcess())
-    return;
-  
-  MHCamera display(geomcam);
-  display.SetPrettyPalette();
-  display.Draw();
-  gPad->cd(1);
-  starcam.Draw();
-  
-  UInt_t numevents=0;
-  
-  while (tlist.Process())
-    {
-      //gLog << "---------------------------------------------" << endl;
-      //gLog << "Macro : MStarPos content = " << endl;
-      //starcam.Print("namepossizchierr");
-      //gLog << "---------------------------------------------" << endl;
-      //gLog << "Macro : MSourcePos content = " << endl;
-      //sourcecam.Print("namepossizchierr");
-      //gLog << "---------------------------------------------" << endl;
-
-      numevents++;
-      if (numevents%integratedevents==0)
-	{
-	  display.SetCamContent(findstars.GetDisplay());
-	  gPad->Modified();
-	  gPad->Update();	      
-        // This line prints the results:
-	// 	  starcam.Print();
-
-	// This is how to access the TList of stars:
-	//	  TList* starlist = starcam.GetList();
-
-	// This is how to iterate over stars found:
-	//	  TIter Next(starlist);
-	// 	  MStarPos* star;
-	// 	  UInt_t starnum = 0;
-	//        cout << filename << " ";
-	//        cout << "Iterating over list" << endl;
-	// 	  while ( (star=(MStarPos*)Next()) ) 
-	// 	  {
-	//          cout << "star[" << starnum << "] ";
-	//          cout << star->GetMeanX() << " " 
-	//               << star->GetMeanY() << " ";
-	//	    starnum++;
-	//	  }
-	//        cout << endl;
-	}
-
-      // fill the histograms
-      // loop over stars in "MSourceCam"
-      TList* sourcelist = sourcecam.GetList();
-      TIter Nextsource(sourcelist);
-      MStarPos* source;
-      while ( (source=(MStarPos*)Nextsource()) ) 
-      {
-        Double_t R = sqrt( source->GetXExp()*source->GetXExp()
-      		   + source->GetYExp()*source->GetYExp() );
-
-        Double_t R0= sqrt( source->GetXIdeal()*source->GetXIdeal()
-      		   + source->GetYIdeal()*source->GetYIdeal() );
-
-        //cout << "R0, R = " << R0 << ",  " << R << endl;
-
-	aberr->Fill(R0, R, 1.0);
-        reldiff->Fill(R0, (R-R0)/R0), 1.0);
-      }
-	
-      //--------------------------------------
-      MTime time;
-      time.Set(2004, 4, 22, 21, 51, 15);
-      
-      //superimpose star picture
-      //       stars.SetTime(time);
-      //       TObject *o = stars.Clone();
-      //       o->SetBit(kCanDelete);
-      //       o->Draw();
-      
-      // wait after each event
-      //if (!HandleInput())
-      //  break;
-
-    }
-
-
-
-  evtloop.PostProcess();
-  tlist.PrintStatistics();
-    
-  plist.Print();
-
-  //$$$$$$$$$$$$$$$$ ww
-  
-  //gLog << "Event loop finished; call DrawClone of MHTelAxisFromStars" << endl;
-
-  //TObject *srccam = plist.FindObject("MSourceCam");
-  //gLog << "srccam = " << srccam << endl;
-
-  TObject *obj = plist.FindObject("MHTelAxisFromStars");
-  if (obj)
-  {
-    //obj->Print();
-    //obj->Dump();
-    obj->DrawClone();
-  }
-  else
-    gLog << "address of MHTelAxisFromStars container is zero" << endl;
-  
-  //$$$$$$$$$$$$$$$$ ww
-
-  // plot the histograms
-  TCanvas *canv = new TCanvas("Optical_Aberration", "Optical aberration",
-			      0, 0, 600, 300);
-  canv->Divide(2,1);
-  canv->SetBorderMode(0); 
-  
-  canv->cd(1);
-  aberr->Draw();
-
-  canv->cd(2);
-  reldiff->Draw();
-
-}
-
-//----------------------------------------------------------------------
-//
-//
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-//=========================================================================
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/Changelog
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 7136)
+++ 	(revision )
@@ -1,738 +1,0 @@
-Please  do  not write behind the end of line tag so that it is  possible
-to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
-
-For your entries please follow this style:
-
-_yyyy/mm/dd:_[Your Name]
-_
-___*_filename:
-_____-_description
-_
-___*_filename2, filename3:
-_____-_description
-_
-_
-_
-
-While an underscore is a placeholder for a white-space or an empty line.
-
-                                                 -*-*- END OF LINE -*-*-
- 2005/03/03 Javier Rico
-    * programs/makeHillas.cc programs/makehillas.datacard
-      - read initial list of bad pixels from ascii file
-      - include MImagePar as output container
-
- 2005/02/15 Javier Rico
-    * library/MEffAreaAndCoeffCalc.[h,cc]
-    * macros/computeCoeff.C
-      - extend the energy bounds to compute weights
-      - add possibility to set the zenith angle binning from outside
-
- 2005/02/14 Javier Rico
-    * library/MEffAreaAndCoeffCalc.[h,cc]
-    * macros/computeCoeff.C
-      - compute the coefficients in the big bins
-      - migrate to new data format
-      
-	
- 2005/02/10 Javier Rico
-    * library/MEffAreaAndCoeffCalc.[h,cc]
-      - added class to compute Effective areas and unfolding coefficients
-    * library/Makefile, IFAELinkDef.h
-      - add MEffAreaAndCoeffCalc
-    * macros/computeCoeff.C
-      - add macro example to use MEffAreaAndCoeffCalc	
-	
- 2005/02/02 Oscar Blanch Bigas
-    * library/MGainFluctuationPix.[h,cc],MGainFluctuationCam.[h,cc]
-      - added parameter containers to handle gain fluctuaions
-    * library/MAddGainFluctuation.[h,cc]
-      - added task to add gain fluctuaions
-    * library/Makefile,IFAELinkDef.h
-      - modified to compile new classes
-    * macros/makeHillasMC.C
-      - modified to compute also Mhadronness and MDisp
-      - modified adding class to introduce gain fluctuations
-      - modified adding display hillas
-
- 2005/01/27 Javier Rico
-    * programs/DISPstd.root, programs/RF*.root
-     - removed, will be available at 
-       http://atlas.ifae.es/~jrico/Mars_Standard06/mtemp/mifae/bin/
-
- 2005/01/27 Eva Domingo
-    * programs/DISPstd.root
-     - updated optimal DISP parameters, running over the MC treated
-       with the Spline signal extractor
-    * macros/DispSkymap.C
-     - added first version of a macro that creates the On, Off and
-       On-Off skymaps from the makeHillas program output files
-    * macros/makeHillasMC.C
-     - added macro equivalent to current makeHillas program 
-       for MC files (it is in fact a version of several already 
-       existing macros)
-
- 2005/01/25 Javier Rico
-    * macros/mmcCleaning.C
-     - added extractor spline and input arguments
-	
- 2005/01/24 Javier Rico
-    * programs/RFstd.root, programs/RFdist.root, programs/RFalpha.root
-     - added default forest files for standard analysis, for 
-       off-axis or exteded sources (disp analysis), and analysis 
-       on hadronness including alpha.
-	
- 2005/01/24 Eva Domingo
-    * library/MFDisp.[cc,h] 
-     - Number of islands read from MImagePar container
-       to be used as cut parameter if wanted
-    * library/MHDisp.cc 
-     - corrected to be able to run Disp method also over
-       data (MMcEvt container info just used if available)
-    * library/MDispCalc.cc
-     - introduced DISP = Xi*(1/(1+width/length)) as default
-       Disp parameterization for the moment
-
- 2005/01/24 Eva Domingo
-    * programs/makeHillas.cc 
-      programs/makehillas.datacard
-      programs/DISPstd.root, default DISP parameters values
-     - Add Disp computation
-
- 2005/01/21 Javier Rico
-    * programs/makeHillas.cc, programs/Makefile, 
-      programs/makehillas.datacard
-     - Add Random Forest computation
-	
- 2005/01/20 Eva Domingo
-    * library/MDispParameters.[cc,h]
-     - Added substituting previous MDisp.[cc,h] classes.
-       Old MDisp::Calc function moved to MDispCalc task.
-    * library/MDispCalc.[cc,h]
-     - Now includes the DISP parameterization, defined in 
-       MDispCalc::Calc. MDispCalc::InitMapping now defines 
-       training and test matrices with only the columns of 
-       variables needed in the DISP expression.
-    * library/MHDisp.[cc,h]
-     - Changed the Chi2 name by MinPar (to clarify it accounts for 
-       the parameter asked to be minimized in the Disp optimization).
-       Added MHDisp::InitMapping, defines matrices with only the columns
-       of variables needed for computing the minimization parameter 
-       and for filling the DISP histograms.
-
- 2005/01/18 Javier Rico & Markus Gaug
-    * programs/controlPlot.cc, programs/controlplot.datacard,
-      programs/Makefile
-     - correct bugs: cuts in the proper units; separate ON and OFF 
-       task lists since before it was reading who knows what
-    * library/MControlPlots.[h,cc]
-     - add Clear() method and remove some (minor) memory leaks
-    * library/MIslands.cc
-     - place call to SetOwner() in the correct place
-	
- 2005/01/10 Javier Rico
-    * programs/makeHillas, programs/makehillas.datacard
-     - adapt to new mars version
-	
- 2004/12/22 Eva Domingo
-    * library/MImageParDisp.[cc,h]
-     - Container for the estimated distance to source position DISP.
-    * library/MDisp.[cc,h]
-     - Container holding the parameters used for the DISP expression.
-       The current DISP parameterization is defined in MDisp::Calc.
-    * library/MDispCalc.[cc,h]
-     - Task calculating DISP with the expression and parameter values
-       stored in MDisp. Training and test matrix of variables to be 
-       used in the DISP optimization are also defined within 
-       MDispCalc::InitMapping.
-    * library/MHDisp.[cc,h]
-     - Container for the histograms to judge the quality of the DISP 
-       estimate. MHDisp::GetChi2 returns the value of the quantity 
-       requested to be minimized by Minuit, which is defined and 
-       computed in MHDisp::Fill and MHDisp::Finalize. 
-       MHDisp::GetSkymapXY returns the reconstructed map of source 
-       positions. MHDisp::SetSelectedPos function to choose the 
-       selection method of the DISP source position solution.
-    * library/MFDisp.[cc,h]
-     - Filter to select a sample of events to do the DISP optimization.
-       Use MFDisp::SetCuts function.
-    * library/MFindDisp.[cc,h]
-     - Main class for DISP optimization:
-        ::DefineTrainMatrix, ::DefineTestMatrix, ::DefineTrainTestMatrix
-       generate the training and test samples (in the form of matrices)
-       from the input file.
-	::FindParams is the function steering the optimization (over the
-       training sample), calling Minuit, passing the fcn function to be 
-       minimize and defining the event loop to be executed in each step.
-	::TestParams tests the quality of the DISP estimate using the 
-       test matrix sample
-    * macros/OptimizeDisp.C
-     - macro for estimating the DISP parameter: create training and test
-       matrix; optimize DISP; test quality optimization; calculate DISP
-       and construct skymap for an input file.
-    * library/Makefile, library/IFAELinkDef.h
-     - include Disp classes.
-
- 2004/12/21 Pepe Flix (represented by jrico)
-    * library/MTopology.[cc,h], library/MTopologyCalc.[cc,h], 
-      library/Makefile, library/IFAELinkDef.h
-     - include topology classes
-	
- 2004/12/21 Javier Rico
-    * programs/makeHillas.cc, programs/makehillas.datacard
-     - Include spline extractor and remove possibility of computing 
-       pedestals from pedestal runs instead of from low gains
-
- 2004/11/24  Ester Aliu
-    * library/MIslandsCalc.h
-     - Remove a memmory leak, and add a sort function to order the 
-     pixels by index after their interpolation
-     - Other minor changes 
-    * library/MImgIsland.[h,cc]
-     - Reset some variables
-
- 2004/11/11  Ester Aliu
-    * library/MIslands.h
-     - Add the variable AlphaW
-    * library/MImgIsland.[h,cc]
-     - Add alpha for each island
-    * library/MIslandsCalc.cc
-     - Bug solved
-    * library/MIslandsClean.cc
-     - More different island cleanings added	
-
-  2004/10/20  Javier Rico
-    * programs/makeHillas.cc
-     - Correct reading in MReportDrive
-	
-  2004/10/15  Javier Rico
-    * programs/makeHillas.cc, programs/Makefile
-     - Write out MReportDrive
-	
-  2004/10/15  Javier Rico
-    * macros/mmcCleaning.C
-     - Include islands
-     - Do not save uncalibrated nonoise file
-
-  2004/10/08  Javier Rico
-    * programs/makeHillas.cc, programs/makehillas.datacard
-     - Include possibility to select signal extractor in datacard
-     - Include possitility to compute pedestals from data themselves, 
-       by selecting word PRUNS 0. For the time being, the old option
-       of computing them from a pedestal run is still available
-	
-  2004/10/05  Javier Rico
-    * programs/srcPos.cc
-     - Change kRotate by kRotating since the former is a used name
-    * programs/makeHillas.cc
-     - Change SetProcessRMS by SetProcessPedestal since name has changed
-    * programs/Makefile
-     - add mhcalib to the list of include dirs since it is now needed
-
-  2004/10/05  Ester Aliu
-    * library/Makefile ,library/IFAELinkDef
-     - modified according to the new classes implemented
-    * programs/makeHillas.cc
-     - modified according to the new classes implemented 
-
-  2004/10/05  Ester Aliu
-    * library MIslands.[h,cc] ,library/MIslandCalc.[h,cc],
-      MIslandClean.[h,cc]
-     - removed
-    * library MIslands.[h,cc],library/MIslandsCalc.[h,cc], 
-     MIslandsClean.[h,cc] , MImgIsland.[h,cc]
-     - added
-    * library/MControlPlots.[h,cc], MIslands.[h,cc]
-     - changed. A bug in the islands has been solved and a new structure
-     for the islands classes similar to the MStarPos and MStarCam classes
-     is proposed
-
-  2004/09/16 Javier Rico
-    * macros/pedrmsonoff.C
-     - Added
-
-  2004/09/02 Javier Rico
-    * programs/srcPos.cc
-     - Add include MArgs.h to cope with changes in Mars
-
-  2004/08/31 Javier Rico
-    * macros/mergeClean.C, mmcCleaning, cleanComp.C
-     - Added macros for the cleaning comparison analysis
-
-  2004/08/27 Javier Rico
-    * library/MDisplay.[cc,h]
-     - Dump run and event numbers
-     - Add possibility to produce ps file of the image
-
-  2004/08/10 Javier Rico
-    * programs/makeHillas.cc
-     - include recomendations of Nadia to interpolate bad pixels
-
-  2004/08/10 Ester Aliu
-    * library/MIslands.[h,cc], MIslandCalc.[h,cc]
-     - remove som bugs
-    * programs/makeHillas.[cc]
-     - fixed window(14 slices) by default 
-  
-  2004/08/04 Javier Rico
-    * programs/makeHillas.cc
-     - remove "#include" of obsolete MBlindPixel.h
-     - do not interpolate "unreliable" pixels
-	
-    * library/MIslands.[cc]
-     - Correct tiny compilation error
-    
-    * library/MDisplay.cc, library/MHillasDisplay.[h,cc]
-     - Print hillas source position dependent stuff
-
-  2004/08/03 Ester Aliu Fusté
-    * library/MIslands.[h, cc], MIslandCalc.[h,cc]
-     - Add the delete for the pointers  
-
-  2004/08/02 Ester Aliu Fusté
-    * library/MIslands.[h, cc], MIslandCalc.[h,cc]
-     - Added the variables: distance (Dist) between the larger island and 
-       the other ones, width and lenght of the larger island. 
-     
-     - Written pointers instead of vectors 
-     
-  2004/07/28 Javi Lopez
-    * script/
-     - Created directory call scripts
-     - Added srcPosRun.sh script to create the *.pos file for the MSrcPosFromFile
-       task.
-     - Added makeHillas.sh script that run several makeHillas making groups of
-       data runs with preavius pedestal run.
-  
-  2004/07/28 Ester Aliu Fuste
-    * programa/makeHillas.cc
-     - Add a flag for the time calibration
- 
-  2004/07/26 Ester Aliu Fuste
-    * library/MIslandCalc.cc
-     - Add the initialization of Dist(to -1) and MeanX/MeanY (to -10000) vectors
-
-  2004/07/22 Oscar Blanch Bigas
-    * programs/makeHillas.cc
-     - Solved backwards compatibility on the CLEANLEVEL
-       options.
-
-  2004/07/22 Ester Aliu 
-    * library/MIslands.[h,cc],MIslandCalc.cc
-     - Add meanX, meanY and dist of each of the islands
-     - Now the island with id 0 is the larger one
-
-  2004/07/21  Javier Rico
-    * programs/makeHillas.cc, srcPos.cc
-      - Add time information
-
-    * programs/makehillas.datacard
-      - Add comment
-
-  2004/07/20  Javier Lopez
-    * library/MLiveTime.[h,cc]
-      - Containers to hold the live time. It has the option to
-      have several time bins.
-    * library/MLiveTimeCalc.[h,cc]
-      - Task to compute the live time from the data. 
-    * macros/runlivetime.C
-      - Macro to use the MLiveTime+ stuff.
-
-  2004/07/15  Javier Lopez
-    * macros/ligthcurve.C
-      - Macro to compute a light curve from hillas files.
-
-  2004/07/04  Oscar Blanch Bigas
-    * library/MControlPlots.cc
-      - Off MHCamera normalised to On
-
-    * programs/makeHillas.cc
-      - Added clean flags to chose: number of rings and kDemocratic.
-      - Using different Pedestal run for the calibration.
-
-    * programs/optimizeCuts.cc
-      - Added alias for MNewImageParameters.fInnerLeakage
-
-    * calib.[cc,datacard]
-      - Added : produces ascci file with relevant factors of
-                Calibration
-
-    * controlPlot.cc, controlplot.datacard
-      - Added : It makes Number of hits plot.
-
-  2004/06/30: Javier Rico
-
-    * mifae/library/MDisp.cc
-      - Remove include of deprecated library
-      - Define namespace
-
-    * mifae/library/MControlPlots.cc
-      - Define style
-      - Add projection
-      - Plot 3rd plot correctly
-      - Search for "MIsland" instead of "MIsland1" container
-
-  2004/06/26: Eva Domingo - Pepe Flix
-
-    * mifae/library/MDisp.[h,cc]
-    * mifae/library/MDispCalc.[h,cc]
-      - Added classes for evaluation of DISP method.
-
-  2004/06/22  Javier Rico
-    * library/MControlPlots.[h,cc]
-      - Added
-
-    * library/Makefile, IFAELinkDef.h
-      - Add MControlPlots. So far, it produces plots with the number
-        of times each pixel survives the cleaning. It needs a MIsland
-        object to be included on the parameter list
-
-    * programs/makeHillas.cc
-      - Change pointer to MWriteRootFile object for MWriteRootFile 
-	object (otherwise the tree "Parameters" is not saved)
-      - Islands are always computed since are needed for some control
-        plots
-
-    * programs/srcPos.cc
-      - Add MControlPlots to the task list
-
-    * library/MSrcPosFromFile.cc
-      - Cope with case where first analyzed run is not in input file
-
-  2004/06/15  Javier Lopez
-    * library/MSrcPosFromStars.[h,cc]
-      - Task to compute the position of a source from
-        the positions of several stars.
-
-    * library/MHPSFFromStars.[h,cc]
-      - Histogram task that holds and fills the histograms of 
-        positioning and point spread function of an star.
-
-    * macros/distancebetweenstars.C
-      - Add macros that show in an histogram the distance between
-        the stars in a field of view. 
-
-    * macros/psffromstars.C
-      - Add task that show the point spread funtion and positon of
-        the most central star in the field of view. This information
-        is compute using the MFindStars tool.
-
- 2004/06/11 Ester Aliu 
-   * programs/makeHillas.cc
-     - add the possibility of using more than one algorithm to 
-      calculate the islands and use different algorithms for counting
-      islands
-
-   * library/MIslands.[h,cc],MIslandCalc.[h,cc], MIslandCleaning.[h,cc]
-     - add a new island cleaning which consists in removing all the
-      islands except the larger one
-     - add a new algorithm of counting islands consisting in consider
-      as the same islands those islands separated by 2 or less pixels
-
- 2004/06/02 Javier Rico
-   * srcpositions, srcpositions/Mrk421_220404_pos.txt
-     - add directory to store files with source positions and a first
-       sample file (with real data)
-
- 2004/06/01 Javier Rico
-   * macros/observationTime.C
-     - add macro to compute observation time
-
- 2004/05/28 Javier Rico
-   * programs/optimizeCuts.cc programs/optimizecuts.datacard
-     - Include loop on size
-
- 2004/05/27 Ester Aliu 
-   * programs/makeHillas.cc
-     - Add the name of the MIslands container
-
-   * library/MHillasDisplay.[h,cc]
-     - Add a function which retuns the name of the MIslands container
-
-   * library/MIslands.[h,cc],MIslandCalc.cc
-     - Add MIslands::Print() function wich prints the island parameters
-     - Change some part of the code to take into account that some 
-     times there are bad pixels
-
- 2004/05/27 Javier Rico
-   * programs/makeHillas.cc, programs/makehillas.datacard
-     - Remove unneeded MCalibrationQECam and MBadPixelsCam objects, 
-       trying to trace back a bug in the calibration
-     - Add possibility to interpolate bad pixels
-
-   * library/MHillasDisplay.cc
-     - Initialize MIslands object in constructor
-	
- 2004/05/26 Javier Rico
-   * library/MHillasDisplay.[h,cc]
-     - Call for MIslands::Print() in the process if any MIslands is 
-       found
-	
- 2004/05/24 Javier Rico
-   * library/MDisplay.[h,cc], programs/makeHillas.cc, 
-     programs/makehillas.datacard
-     - Add possibility to save a ps file
-     - Update documentation
-     - Cope with the case when no cut is provided
-	
-   * library/MHillasDisplay[h.cc]
-     - correct minor axis paint
-     - include MNewImagePar dumping
-     - update documentation
-	
- 2004/05/21 Oscar Blanch
-   * makeHillas.cc
-     - Adde a couple of conditionals to allow makeHillas in 
-       NON calibration mode without giving a Cailbration file,
-	
- 2004/05/21  Javier Rico
-   * library/MDCA.[cc.h]
-     - removed
-
-   * library/MDisplay.[h,cc], library/MHillasDisplay.[h,cc]
-     - added
-
-   * library/Makefile, library/IFAELinkDef.h
-     - remove MDCA
-     - add MDisplay and MHillasDisplay
-
-   * library/MSrcPlace.[h,cc], library/MSrcRotate.[h,cc],
-     library/MSrcTranslate.[h,cc], library/MSrcPosFromFile.cc
-     - remove MDCA dependences
-
-   * programs/makeHillas.cc, programs/makehillas.datacard
-     - include display and selection cuts options
-	
-   * programs/Makefile
-     - include mfbase in the list of includes directory
-
- 2004/05/18  Javier Rico
-   * macros/plotOptimal.C
-     - dump value of maximal significance and cuts
-
- 2004/05/18  Javier Rico
-   * library/MSrcPlace.[cc,h], library/MSrcRotate.[cc,h], 
-     library/MSrcTranslate.[cc,h], library/MSrcPosFromFile.[cc,h]
-     - Add the possibility of having different input and output 
-       MSrcPosCam containers (CONSTRUCTORS HAVE CHANGED!)
-     - Move the creation of internal histogram to PreProcess, so that
-       it can be configured before creation. Now configurable: whether
-       histo must be created or not (fCreateHisto), histo bin size 
-       (fHistoBinPrec), histogram name (fHistoName), with corresponding
-       getters and setters
-     - Update documentation
-
-   * library/MSrcPosFromFile.cc	
-     - If no position has been measured for the first analyzed run, use
-       the one of the first run in file instead.
-
-   * programs/falseSource.cc
-     - Change obsolete MSrcPosCam predefinitions for modern 
-       MSrcTranslate objects, which allow relative displacement of the
-       source position from a previously assigned one. 
-     - Add flag for relative translation
-     - Include control histograms (hOn[Off]SrcPos) for the source 
-       position
-
-   * programs/falsesource.datacard
-     - Add datacard SRCABS for relative/absolute source translation
-
-   * programs/srcPos.cc
-     - Avoid creation of internal histograms for the translation
-
-   * programs/optimizeCuts.cc
-     - Correct bug on width initial value
-
-   * programs/makeHillas.cc
-     - Pass MCalibrationQECam from the MJCalibration to the following
-       loops (to be able to perform calibration of data)
-	
-	
- 2004/05/17  Javier Rico
-   * library/MSrcPlace.[cc,h], library/MSrcRotate.cc, 
-     library/MSrcTranslate.cc
-     - Assign the internal histogram a class-dependent name
-     - Add some log lines to trace the classes behaviour
-     - Remove function SearchForSrcPos
-
-   * library/MSrcPosFromFile.[cc,h]
-     - Correct behaviour for not found runs
-     - Keep latest good MSrcPosCam to fill for next events
-     - Initialize pointers to NULL
-     - Fill also MDCA
-
-	
- 2004/05/14  Javier Rico
-   * library/MSrcPlace.[cc,h]
-     - added
-
-   * library/MSrcPosFromFile.[cc,h], library/MSrcRotate.[cc,h],
-     library/MSrcTranslate.[cc,h]
-     - inherit from MSrcPlace
-
-   * programs/srcPos.cc programs/srcpos.datacard
-     - adapt to new MSrcPlace class
-	
-   * library/Makefile, library/IFAELinkDef.h
-     - include MSrcPlace
-
- 2004/05/13  Javier Rico
-   * macros/rotation.C
-     - added
-
-
- 2004/05/13  Javier Lopez
-   * library/MCalibrateDC.[h,cc]
-     - Task to intercalibrate the dc response of the dc
-       current for all the pmts from a continuos light
-       run.
-
- 2004/05/12: Javier Rico
-   * macros/alpha.C, macros/plotOptimal.C
-     - added
-
-   * library/MSrcRotate.[cc.h]
-     - correct bug in computation of run time for rotation
-	
-   * programs/srcPos.cc
-     - change mjdpos type to Double_t
-	
-	
-	
- 2004/05/11: Javier Rico
-   * programs/optimizeCuts.cc, programs/optimizecuts.datacard
-     - added
-
-   * programs/Makefile
-     - include optimizeCuts
-
-   * programs/srcPos.cc, programs/srcpos.datacard
-     - add reference rotation angle
-
-	
- 2004/05/11: Ester Aliu
-   *  macros/signal.cc 
-     - change some things
-   *  programs/falseSource.cc 
-     - change some mathematical functions to root equivalents 
-   *  programs/psffit.cc
-     - add <stdlib.h> library 
-
- 2004/05/11: Ester Aliu 
-   * programs/makeHillas.cc, programs/makehillas.datacard
-     - add island calculations
- 
- 2004/05/11: Javier Rico
-   * programs/makeHillas.cc
-     - prevent it from bombing because of the mjobs
-
-
- 2004/05/10: Javier Rico
-   * programs/Makefile
-     - specify libmars.so with absolute path
-
-	
- 2004/05/07: Javier Rico
-   * programs/pedvsslices.cc
-     - added
-
-	
- 2004/05/05: Ester Aliu
-   * library/MPSFFitCalc.cc library/MSrcRotate.cc
-     - change some mathematical functions to root equivalents 
-
-   * library/MIslands.[h,cc], library/MIslandCalc.[h,cc],
-    library/MIslandClean.[h,cc]
-     - added
-
-   * library/Makefile, library/IFAELinkDef.h
-     - add MIslands, MIslandCalc, MIslandClean
- 
- 2004/05/05: Javier Lopez
-   * library/MFHVNotNominal.[h,cc]
-     - filter to flag events(pixels) with non nominal hv
- 
-   * macros/hvnotnominal.C
-     - macro to test MFHVNotNominal filter
-
- 2004/05/05: Javier Rico
-   * library/MSrcTranslate.[h,cc]
-     - added
-
-   * library/Makefile, library/IFAELinkDef.h
-     - add MSrcTranslate
-
-   * library/MSrcRotate.[h.cc]
-     - adapted to changes in MObservatory and MAstro
-   
-   * programs/falseSource.cc programs/falsesource.datacard 
-     programs/srcPos.cc programs/srcpos.datacard
-     - added
-
-   * programs/Makefile
-     - add falseSource and srcPos
-
-   * macros/signal.C macros/signalPoint.C
-     - added
-	
- 2004/05/03: Javier Rico
-   * makeHillas.cc
-     - put back Jobs for pedestal and calibration parts
-
-   * .rootrc
-     - added
-
- 2004/05/03: Javier Rico
-   * library,programs,macros,*:
-     - new directories added
-     - directory macros contains macros (.C) and scripts (.sh)
-     - directory programs contains root compilables and associated
-       [input] files
-     - directory library contains routines to be linked with libmars.so
-	
- 2004/04/30: Javier López
-   * alpha_plot.C
-     - macro to display hillas disttributions with corrected 
-       miss pointing
-
-   * srcPosRun.sh
-     - Script to produce the file with the positions of UMa51 using 
-       psffit executable
-
-   * MSrcPosFromFile.[h,cc]
-     - Tool to correct the position of the source for on and off data 
-       from a file
- 
-   * psffit.C & psffit.cc
-     - Macro and executable to calculate the mean position of a star.
-
-   * MPSFFit.[h,cc] & MPSFFitCalc.[h,cc]
-     - Container and taks to do calculation of the psf and position of 
-       stars.
-
- 2004/04/28: Javier Rico
-   * makeHillas.cc, makehillas.datacard
-     - Use MJPedestal and MJCalibration and simplified datacard
-
-   * Makefile
-     - include mjobs
-
-	
- 2004/04/28: Javier Rico
-   * mifae/Changelog
-     - Added. Next changes in directory mifae will be reported 
-       exclusively in here
-
-	
- 2004/04/27: Javier Rico
-   * mifae
-     - Add new directory for IFAE temporal stuff
-	
-   * mifae/Makefile,IFAEIncl.h,IFAELinkDef.h
-     - Add basic stuff to run the directory
-	
-   * mifae/MDCA.[h,cc]
-     - Add Commichau & Starks's MDCA (provisional)
-
-   * mifae/makeHillas.cc,makehillas.datacard
-     - Add program to generate hillas parameters' file
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDispParameters.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDispParameters.cc	(revision 7136)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Eva Domingo,     12/2004 <mailto:domingo@ifae.es>
-!              Wolfgang Wittek, 12/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2005
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//   MDispParameters                                                       //
-//                                                                         //
-//   this is the container for the Disp parameters                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MDispParameters.h"
-
-#include <math.h>
-#include <fstream>
-
-#include <TArrayD.h>
-
-#include "MImageParDisp.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-
-ClassImp(MDispParameters);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// constructor
-//
-MDispParameters::MDispParameters(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MDispParameters";
-    fTitle = title ? title : "Container for the Disp parameters";
-}
-
-
-// --------------------------------------------------------------------------
-//
-// set default values for the Disp parameters
-//
-void MDispParameters::InitParameters()
-{
-    //---------------------------------------------------
-    //  these are the default values
-
-    fParameters[0] =  0.93227;
-    fParameters[1] =  0.187132;
-    fParameters[2] = -0.192808;
-    fParameters[3] =  0.0350143;
-    fParameters[4] = -0.0110078;
-
-
-    //---------------------------------------------------
-    // fStepsizes 
-    // if == 0.0    the parameter will be fixed in the minimization
-    //    != 0.0    initial step sizes for the parameters
-
-    fStepsizes[0] = 0.010;
-    fStepsizes[1] = 0.002;
-    fStepsizes[2] = 0.002;
-    fStepsizes[3] = 0.0004;
-    fStepsizes[4] = 0.0001;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Set the parameter values from the array 'd'
-//
-//
-Bool_t MDispParameters::SetParameters(const TArrayD &d)
-{
-    if (d.GetSize() != fParameters.GetSize())
-    {
-        *fLog << err << "Sizes of d and of fParameters are different : "
-              << d.GetSize() << ",  " << fParameters.GetSize() << endl;
-        return kFALSE;
-    }
-
-    fParameters = d;
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Set the step sizes from the array 'd'
-//
-//
-Bool_t MDispParameters::SetStepsizes(const TArrayD &d)
-{
-    if (d.GetSize() != fStepsizes.GetSize())
-    {
-        *fLog << err << "Sizes of d and of fStepsizes are different : "
-              << d.GetSize() << ",  " << fStepsizes.GetSize() << endl;
-        return kFALSE;
-    }
-
-    fStepsizes = d;
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDispParameters.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDispParameters.h	(revision 7136)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#ifndef MARS_MDispParameters
-#define MARS_MDispParameters
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef ROOT_TArrayD
-#include <TArrayD.h>
-#endif
-
-class MDispParameters : public MParContainer
-{
-private:
-
-    TArrayD fParameters;      // Disp parameters
-    TArrayD fStepsizes;       //! step sizes of Disp parameters
-
-
-public:
-
-    MDispParameters(const char *name=NULL, const char *title=NULL);
-
-    void InitParameters();
-
-    Bool_t SetParameters(const TArrayD &d);
-    Bool_t SetStepsizes(const TArrayD &d);
-
-    void SetVariables(const TArrayD &d)    { SetParameters(d); }
- 
-    TArrayD &GetParameters() { return fParameters; }
-    TArrayD &GetStepsizes()  { return fStepsizes;  }
-
-    ClassDef(MDispParameters, 1) // Container for the Disp parameters
-};
-
-#endif
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.cc	(revision 7136)
+++ 	(revision )
@@ -1,176 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier Rico     05/2004 <mailto:jrico@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// MDisplay
-//
-// Class to display camera events (MCamEvent)
-// You can set an event-by-event display with pause between two consecutive 
-// events. You can set an output PS file.
-//
-// Input containers (to be provided to the constructor):
-//
-//  MCamEvent
-//  MGeomCam
-//
-// Output containers:
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <fstream>
-#include <math.h>
-
-#include "TCanvas.h"
-#include "TPostScript.h"
-
-#include "MParList.h"
-#include "MDisplay.h"
-#include "MCamEvent.h"
-#include "MGeomCam.h"
-#include "MHCamera.h"
-#include "MRawRunHeader.h"
-#include "MRawEvtHeader.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MDisplay);
-
-using namespace std;
-
-static const TString gsDefName       = "MDisplay";
-static const TString gsDefTitle      = "Camera display task";
-static const TString gsDefPSFileName = "display.ps";
-
-// -------------------------------------------------------------------------
-//
-// Constructor. Need to provide the MCamEvent container to be displayed <event>
-// and camera geometry <geom>. Also the display type <type> can be specified
-// (see the MHCamera documentation for more details)
-//
-MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
-  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fPSFile(NULL), fDisplayType(type), fCreatePSFile(kFALSE), fPause(kTRUE)
-{
-  fName  = name  ? name  : gsDefName.Data();
-  fTitle = title ? title : gsDefTitle.Data();
-
-  fDisplay = new MHCamera(*geom);
-  fDisplay->SetPrettyPalette();
-  
-  fPSFileName = gsDefPSFileName;
-}
-// -------------------------------------------------------------------------
-//
-// Destructor
-//
-MDisplay::~MDisplay()
-{
-  delete fDisplay;
-  if(fCanvas)
-    delete fCanvas;
-  if(fPSFile)
-    delete fPSFile;
-}
-
-// -------------------------------------------------------------------------
-//
-// Create the canvas, eventually set the batch mode and open ps file
-//
-Int_t MDisplay::PreProcess(MParList* pList)
-{ 
-  fCanvas = new TCanvas("myCanvas","Event Display",600,600);
-  if(fCreatePSFile) 
-    fPSFile = new TPostScript(fPSFileName,111);
-  if(!fPause)
-    fCanvas->SetBatch();
-  fCanvas->cd(1);
-  fDisplay->Draw();
-
-  //look for the run and event headers
-  fEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
-  if (!fEvtHeader)
-    {
-      *fLog << err << "MRawEvtHeader not found... aborting." << endl;
-      return kFALSE;
-    }
-  
-  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
-  if (!fRunHeader)
-    {
-      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
-      return kFALSE;
-    }
-
-  return kTRUE;
-}
-
-// -------------------------------------------------------------------------
-//
-// Set the new containt of the camera event and update the display.
-// Set new page if ps file is requested
-// Pause execution if event-by-event display is chosen
-//
-Int_t MDisplay::Process()
-{  
-  // new page in ps file
-  if(fPSFile)
-    fPSFile->NewPage();
-
-  // update the display contents
-  fDisplay->SetCamContent(*fCamEvent,fDisplayType);
-  fCanvas->GetPad(1)->Modified();
-  fCanvas->GetPad(1)->Update();
-  
-  *fLog << all << "Run: " << fRunHeader->GetRunNumber() << ", Event: " << fEvtHeader->GetDAQEvtNumber() << endl;
-
-  // pause execution
-  if(fPause)
-    {
-      cout << "Type 'q' to exit, 'p' to print event into ps file, <return> to go on: ";      
-      TString input;
-      input =cin.get(); 
-      
-      if (input=='q')
-	return kFALSE;
-      if(input=='p')
-	{
-	  Char_t psfile[200];
-	  sprintf(psfile,"Run%06dEvent%07d.ps", fRunHeader->GetRunNumber(), fEvtHeader->GetDAQEvtNumber());
-	  fCanvas->Print(psfile);
-	}
-    }
-
-  return kTRUE;
-}
-
-// -------------------------------------------------------------------------
-//
-// Close ps file if it was open
-//
-Int_t MDisplay::PostProcess()
-{
-  if(fPSFile) fPSFile->Close();
-  return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MDisplay.h	(revision 7136)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#ifndef MARS_MDisplay
-#define MARS_MDisplay
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MRawRunHeader;
-class MRawEvtHeader;
-class MHCamera;
-class MCamEvent;
-class MGeomCam;
-class TCanvas;
-class TPostScript;
-
-class MDisplay : public MTask
-{
- private:
-  MRawEvtHeader*  fEvtHeader;    // event header
-  MRawRunHeader*  fRunHeader;    // run header
-  MHCamera*       fDisplay;      // pointer to the camera display
-  MGeomCam*       fGeomCam;      // pointer to the camera geometry
-  MCamEvent*      fCamEvent;     // pointer to camera event
-  TCanvas*        fCanvas;       // pointer to the canvas
-  TPostScript*    fPSFile;       // pointer to ps file
-  TString         fPSFileName;   // name for ps file
-  Int_t           fDisplayType;  // display type (see MHCamera)
-  Bool_t          fCreatePSFile; // flag to produce a ps file with events
-  Bool_t          fPause;        // flag to pause execution between events
-  
-
-  virtual Int_t PostProcess();
-
- protected:
-  virtual Int_t PreProcess(MParList *plist);  
-  virtual Int_t Process();
-
- public:
-  MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type=0, const char* name=NULL, const char* title=NULL);
-  virtual ~MDisplay();
-
-  virtual void Paint(Option_t* option)     {};
-
-  MGeomCam*    GetGeomCam()                {return fGeomCam;}
-  Bool_t       GetPauseMode()              {return fPause;}
-  Bool_t       GetCreatePSFile()           {return fCreatePSFile;}
-
-  void         SetDisplayType(Int_t type)  {fDisplayType=type;}
-  void         SetPSFile(Bool_t set=kTRUE) {fCreatePSFile=set;}
-  void         SetPSFileName(TString name) {fPSFileName=name;}
-  void         SetPause(Bool_t set=kTRUE)  {fPause=set;}
-
-  ClassDef(MDisplay, 0) // Task to display camera containers
-};
-
-#endif
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MFDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MFDisp.cc	(revision 7136)
+++ 	(revision )
@@ -1,299 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Eva Domingo,     12/2004 <mailto:domingo@ifae.es> 
-!              Wolfgang Wittek, 12/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!
-!   Copyright: MAGIC Software Development, 2000-2005
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//  MFDisp                                                                  //
-//                                                                          //
-//  This is a class to set cuts to select an event sample                   //
-//  for the Disp optimization                                               //
-//                                                                          //
-//                                                                          //
-//////////////////////////////////////////////////////////////////////////////
-
-#include "MFDisp.h"
-
-#include "MGeomCam.h"
-#include "MHillas.h"
-#include "MHillasSrc.h"
-#include "MImagePar.h"
-#include "MNewImagePar.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-
-ClassImp(MFDisp);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MFDisp::MFDisp(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MFDisp";
-    fTitle = title ? title : "Cuts for Disp optimization";
-
-    // default values of cuts
-    SetCuts(0, 1000,   0, 1000,   0, 1000, 
-            0.0, 1.e10,  0.0, 1.0,  0.0, 1.0,   0.0, 0.0);
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Set the values for the cuts 
-// 
-void MFDisp::SetCuts(Int_t islandsmin,      Int_t islandsmax,
-                     Int_t usedpixelsmin,   Int_t usedpixelsmax, 
-                     Int_t corepixelsmin,   Int_t corepixelsmax,
-                     Float_t sizemin,       Float_t sizemax,
-                     Float_t leakage1min,   Float_t leakage1max,
-                     Float_t leakage2min,   Float_t leakage2max,
-                     Float_t lengthmin,     Float_t widthmin)
-{ 
-  fIslandsMin    = islandsmin;
-  fIslandsMax    = islandsmax;
-
-  fUsedPixelsMin = usedpixelsmin;
-  fUsedPixelsMax = usedpixelsmax;
-
-  fCorePixelsMin = corepixelsmin;
-  fCorePixelsMax = corepixelsmax;
-
-  fSizeMin       = sizemin;
-  fSizeMax       = sizemax;
-
-  fLeakage1Min   = leakage1min;
-  fLeakage1Max   = leakage1max;
-
-  fLeakage2Min   = leakage2min;
-  fLeakage2Max   = leakage2max;
-
-  fLengthMin     = lengthmin;
-  fWidthMin      = widthmin;
-}
-
-
-// --------------------------------------------------------------------------
-//
-Int_t MFDisp::PreProcess(MParList *pList)
-{
-    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
-    if (!cam)
-    {
-        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fMm2Deg = cam->GetConvMm2Deg();
-
-
-    fHil = (MHillas*)pList->FindObject("MHillas");
-    if (!fHil)
-    {
-        *fLog << err << "MHillas not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fHilSrc = (MHillasSrc*)pList->FindObject("MHillasSrc");
-    if (!fHilSrc)
-    {
-        *fLog << err << "MHillasSrc not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fImgPar = (MImagePar*)pList->FindObject("MImagePar");
-    if (!fImgPar)
-    {
-        *fLog << err << "MImagePar not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fNewImgPar = (MNewImagePar*)pList->FindObject("MNewImagePar");
-    if (!fNewImgPar)
-    {
-        *fLog << err << "MNewImagePar not found... aborting." << endl;
-        return kFALSE;
-    }
-
-
-    memset(fCut, 0, sizeof(fCut));
-
-
-    //--------------------
-    *fLog << inf << "MFDisp cut values :" << endl; 
-
-    *fLog << inf << "     fIslandsMin, fIslandsMax = "
-          << fIslandsMin << ",  " << fIslandsMax << endl;
-
-    *fLog << inf << "     fUsedPixelsMin, fUsedPixelsMax = "
-          << fUsedPixelsMin << ",  " << fUsedPixelsMax << endl;
-
-    *fLog << inf << "     fCorePixelsMin, fCorePixelsMax = "
-          << fCorePixelsMin << ",  " << fCorePixelsMax << endl;
-
-    *fLog << inf << "     fSizeMin, fSizeMax = " 
-          << fSizeMin << ",  " << fSizeMax << endl;
-
-    *fLog << inf << "     fLeakage1Min, fLeakage1Max = " 
-          << fLeakage1Min << ",  " << fLeakage1Max << endl;
-
-    *fLog << inf << "     fLeakage2Min, fLeakage2Max = " 
-          << fLeakage2Min << ",  " << fLeakage2Max << endl;
-
-    *fLog << inf << "     fLengthMin, fWidthMin = " 
-          << fLengthMin << ",  " << fWidthMin << endl;
-    //--------------------
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Sum up the number of events passing each cut
-//
-Bool_t MFDisp::Set(Int_t rc)
-{
-    fResult = kTRUE;
-    fCut[rc]++;
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Evaluate cuts for Disp optimization
-// if selections are fulfilled set fResult = kTRUE;
-// 
-Int_t MFDisp::Process()
-{
-    const Double_t length     = fHil->GetLength() * fMm2Deg;
-    const Double_t width      = fHil->GetWidth()  * fMm2Deg;
-    //const Double_t dist       = fHilSrc->GetDist()* fMm2Deg;
-    //const Double_t delta      = fHil->GetDelta()  * kRad2Deg;
-    const Double_t size       = fHil->GetSize();
-
-    const Double_t leakage1   = fNewImgPar->GetLeakage1();
-    const Double_t leakage2   = fNewImgPar->GetLeakage2();
-
-    const Int_t numusedpixels = fNewImgPar->GetNumUsedPixels();
-    const Int_t numcorepixels = fNewImgPar->GetNumCorePixels();
-    const Int_t numislands    = fImgPar->GetNumIslands();
-
-    fResult = kFALSE;
-
-    if  (numislands<fIslandsMin  || numislands>fIslandsMax )
-        return Set(1);
-
-    if  (numusedpixels<fUsedPixelsMin  || numusedpixels>fUsedPixelsMax )
-        return Set(2);
-
-    if  (numcorepixels<fCorePixelsMin  || numcorepixels>fCorePixelsMax )
-        return Set(3);
-
-    if (size<fSizeMin  ||  size>fSizeMax)
-        return Set(4);
-
-    if (leakage1<fLeakage1Min || leakage1>fLeakage1Max)
-        return Set(5);
-
-    if (leakage2<fLeakage2Min || leakage2>fLeakage2Max)
-        return Set(6);
-
-    if (length<fLengthMin || width<fWidthMin)
-        return Set(7);
-
-    fCut[0]++;
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-//  Prints some statistics about the cuts selections
-//
-Int_t MFDisp::PostProcess()
-{
-    if (GetNumExecutions()==0)
-        return kTRUE;
-
-    *fLog << inf << endl;
-    *fLog << GetDescriptor() << " execution statistics:" << endl;
-
-    *fLog << dec << setfill(' ');
-    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3);
-    *fLog << (int)(fCut[1]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: No.of islands < " << fIslandsMin ;
-    *fLog << " or > " << fIslandsMax << endl;
-
-    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3);
-    *fLog << (int)(fCut[2]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: No.of used pixels < " << fUsedPixelsMin ;
-    *fLog << " or > " << fUsedPixelsMax << endl;
-
-    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3);
-    *fLog << (int)(fCut[3]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: No.of core pixels < " << fCorePixelsMin ;
-    *fLog << " or > " << fCorePixelsMax << endl;
-
-    *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
-    *fLog << (int)(fCut[4]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: SIZE < " << fSizeMin;
-    *fLog << " or > " << fSizeMax << endl;
-
-    *fLog << " " << setw(7) << fCut[5] << " (" << setw(3) ;
-    *fLog << (int)(fCut[5]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: Leakage1 < " << fLeakage1Min;
-    *fLog << " or > " << fLeakage1Max << endl;
-
-    *fLog << " " << setw(7) << fCut[6] << " (" << setw(3) ;
-    *fLog << (int)(fCut[6]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: Leakage2 < " << fLeakage2Min;
-    *fLog << " or > " << fLeakage2Max << endl;
-
-    *fLog << " " << setw(7) << fCut[7] << " (" << setw(3) ;
-    *fLog << (int)(fCut[7]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts skipped due to: LENGTH <= " << fLengthMin;
-    *fLog << " or WIDTH <= " << fWidthMin << endl;
-
-    *fLog << " " << fCut[0] << " (" ;
-    *fLog << (int)(fCut[0]*100/GetNumExecutions()+0.5) ;
-    *fLog << "%) Evts survived the Disp cuts!" << endl;
-    *fLog << endl;
-
-    return kTRUE;
-}
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MFDisp.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MFDisp.h	(revision 7136)
+++ 	(revision )
@@ -1,90 +1,0 @@
-#ifndef MARS_MFDisp
-#define MARS_MFDisp
-
-#ifndef MARS_MFilter
-#include "MFilter.h"
-#endif
-
-class MHillas;
-class MHillasSrc;
-class MImagePar;
-class MNewImagePar;
-
-class MFDisp : public MFilter
-{
-private:
-
-    MHillas      *fHil;
-    MHillasSrc   *fHilSrc;
-    MImagePar    *fImgPar;
-    MNewImagePar *fNewImgPar;
-
-    //--------------------------    
-
-    // cutting variables to select the sample
-    // for the Disp optimization
-
-    Int_t      fIslandsMin;
-    Int_t      fIslandsMax;
-
-    Int_t      fUsedPixelsMin;
-    Int_t      fUsedPixelsMax;
-
-    Int_t      fCorePixelsMin;
-    Int_t      fCorePixelsMax;
-
-    Float_t      fSizeMin;
-    Float_t      fSizeMax;
-
-    Float_t      fLeakage1Min;
-    Float_t      fLeakage1Max;
-
-    Float_t      fLeakage2Min;
-    Float_t      fLeakage2Max;
-
-    Float_t      fLengthMin;
-    Float_t      fWidthMin;
-
-    //--------------------------    
-
-    Double_t     fMm2Deg;     // conversion mm to degrees in camera
-
-    Int_t        fCut[8];     // array to save cuts statistics
-
-    Bool_t       fResult;
-
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-    Int_t PostProcess();
-
-    Bool_t IsExpressionTrue() const  { return fResult; }
-
-    Bool_t Set(Int_t rc);
-
-public:
-
-    MFDisp(const char *name=NULL, const char *title=NULL);
-
-    void SetCuts(Int_t islandsmin,      Int_t islandsmax,
-                 Int_t usedpixelsmin,   Int_t usedpixelsmax,
-                 Int_t corepixelsmin,   Int_t corepixelsmax,
-                 Float_t sizemin,       Float_t sizemax, 
-                 Float_t leakage1min,   Float_t leakage1max,
-                 Float_t leakage2min,   Float_t leakage2max,
-                 Float_t lengthmin,     Float_t widthmin);
-
-    ClassDef(MFDisp, 0)   // Class to set cuts for Disp optimization
-};
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MFindDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MFindDisp.cc	(revision 7136)
+++ 	(revision )
@@ -1,1158 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Eva Domingo,     12/2004 <mailto:domingo@ifae.es>
-!              Wolfgang Wittek, 12/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2005
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-// MFindDisp                                                               //
-//                                                                         //
-// Class for otimizing the estimation of Disp                              //
-//                                                                         //
-//                                                                         //
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MFindDisp.h"
-
-#include <math.h>            // fabs 
-
-#include <TArrayD.h>
-#include <TCanvas.h>
-#include <TFile.h>
-#include <TH1.h>
-#include <TH2.h>
-#include <TMinuit.h>
-#include <TStopwatch.h>
-#include <TVirtualFitter.h>
-
-#include "MBinning.h"
-#include "MContinue.h"
-#include "MDispParameters.h"
-#include "MDispCalc.h"
-#include "MDataElement.h"
-#include "MDataMember.h"
-
-#include "MEvtLoop.h"
-#include "MFSelFinal.h"
-#include "MF.h"
-#include "MFDisp.h"
-#include "MFEventSelector.h"
-#include "MFEventSelector2.h"
-#include "MFillH.h"
-#include "MFEventSelector.h"
-#include "MGeomCamMagic.h"
-#include "MH3.h"
-#include "MHDisp.h"
-#include "MHFindSignificance.h"
-#include "MHMatrix.h"
-#include "MHOnSubtraction.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MMatrixLoop.h"
-#include "MMinuitInterface.h"
-#include "MParameters.h"
-#include "MParList.h"
-#include "MProgressBar.h"
-#include "MReadMarsFile.h"
-#include "MReadTree.h"
-#include "MStatusDisplay.h"
-#include "MTaskList.h"
-
-
-ClassImp(MFindDisp);
-
-using namespace std;
-
-
-//------------------------------------------------------------------------
-// fcnDisp 
-//------------------------------------------------------------------------
-//
-// - calculates the quantity to be minimized (by TMinuit)
-//
-// - the quantity to be minimized is defined in 
-//   MHDisp::Fill() and MHDisp::Finalize()
-//
-// - the parameters to be varied in the minimization are the parameters
-//   appearing in the parametrization of Disp (MDispCalc::Calc())
-//
-//------------------------------------------------------------------------
-
-static void fcnDisp(Int_t &npar, Double_t *gin, Double_t &f, 
-                    Double_t *par, Int_t iflag)
-{
-    cout <<  "entry fcnDisp" << endl;
-
-    // save pointer to the MINUIT object (for optimizing Disp) for the case
-    // that it is overwritten by the pointer to another Minuit object
-    //    TMinuit *savePointer = gMinuit;
-    //-------------------------------------------------------------
-
-
-    MEvtLoop *evtloopfcn = (MEvtLoop*)gMinuit->GetObjectFit();
-
-    MParList *plistfcn   = (MParList*)evtloopfcn->GetParList();
-    MTaskList *tasklistfcn   = (MTaskList*)plistfcn->FindObject("MTaskList");
-
-    // get needed Disp containers from the existing parList
-    MDispParameters *dispparams = (MDispParameters*)plistfcn->FindObject("MDispParameters");
-    if (!dispparams)
-    {
-        gLog << "fcnDisp : MDispParameters object '" << "MDispParameters"
-            << "' not found... aborting" << endl;
-        return;
-    }
-
-    MHDisp *hdisp = (MHDisp*)plistfcn->FindObject("MHDisp");
-    if (!hdisp)
-    {
-        gLog << "fcnDisp : MHDisp object '" << "MHDisp"
-            << "' not found... aborting" << endl;
-        return;
-    }
-
-    MParameterD *minpar = (MParameterD*)plistfcn->FindObject("MinimizationParameter");
-
-    //
-    // transfer current parameter values to MDispParameters
-    //
-    // Attention : npar is the number of variable parameters
-    //                  not the total number of parameters
-    //
-    Double_t fMin,   fEdm,   fErrdef;
-    Int_t    fNpari, fNparx, fIstat;
-    gMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
-
-    dispparams->SetParameters(TArrayD(fNparx, par));
-
-    // checking that parameters have been properly set
-    TArrayD checkparameters = dispparams->GetParameters();
-    gLog << "fcnDisp : fNpari, fNparx =" << fNpari << ",  " 
-         << fNparx  << endl;
-    gLog << "fcnDisp : i, par, checkparameters =" << endl;
-    for (Int_t i=0; i<fNparx; i++)
-    {
-      gLog << i << ",  " << par[i] << ",  " << checkparameters[i] << endl;
-    }
-
-    //
-    // loop over the events in the training matrices to compute the parameter 
-    // to minimize for the current Disp parameter values
-    evtloopfcn->Eventloop();
-
-    tasklistfcn->PrintStatistics(0, kTRUE);
-
-    //-------------------------------------------
-    // get the Minimization parameter value for the current values 
-    // of the Disp parameters
-    if (minpar)
-      f = minpar->GetVal();
-    else
-    {
-      gLog << "fcnDisp : MParameterD object '" << "MinimizationParameter"
-	   << "' not found... aborting" << endl;
-      return;
-    }
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MFindDisp::MFindDisp(MFDisp *fdisp, const char *name, const char *title)
-  : fHowManyTrain(10000), fHowManyTest(10000)
-{
-    fName  = name  ? name  : "MFindDisp";
-    fTitle = title ? title : "Optimizer of Disp";
-
-    //---------------------------
-    // camera geometry is needed for conversion mm ==> degree
-    fCam = new MGeomCamMagic; 
-
-    // initialize MFDisp filter cuts to default (no cutting) values
-    // (done at MFDisp constructor)
-    fDispFilter = fdisp;
-
-    // matrices to contain the training/test samples
-    fMatrixTrainCalc  = new MHMatrix("MatrixTrainCalc");
-    fMatrixTrainHists = new MHMatrix("MatrixTrainHists");
-    fMatrixTestCalc   = new MHMatrix("MatrixTestCalc");
-    fMatrixTestHists  = new MHMatrix("MatrixTestHists");
-
-    // objects of MDispCalc where the first part of the matrices mapping is defined
-    fDispCalcTrain = new MDispCalc("DispTrain","MDispParameters");
-    fDispCalcTest  = new MDispCalc("DispTest","MDispParametersTest");
-
-    // objects of MHDisp where the second part of the matrices mapping is defined
-    fHDispTrain = new MHDisp("DispTrain");
-    fHDispTest  = new MHDisp("DispTest");
-
-    // define columns of matrices
-    // Train matrix
-    fDispCalcTrain->InitMapping(fMatrixTrainCalc);
-    fHDispTrain->InitMapping(fMatrixTrainHists);
-    // Test matrix
-    fDispCalcTest->InitMapping(fMatrixTestCalc);
-    fHDispTest->InitMapping(fMatrixTestHists);
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Default destructor.
-//
-MFindDisp::~MFindDisp()
-{
-    delete fCam;
-    delete fMatrixTrainCalc;
-    delete fMatrixTrainHists;
-    delete fMatrixTestCalc;
-    delete fMatrixTestHists;
-    delete fDispCalcTrain;
-    delete fDispCalcTest;
-    delete fHDispTrain;
-    delete fHDispTest;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Define the matrices 'fMatrixTrainCalc' and 'fMatrixTrainHists' 
-// for the TRAINING sample
-//
-// alltogether 'howmanytrain' events are read from file 'nametrain';
-// the events are selected according to a target distribution 'hreftrain'
-//
-//
-Bool_t MFindDisp::DefineTrainMatrix(
-			  const TString &nametrain, MH3 &hreftrain, 
-			  const Int_t howmanytrain, const TString &filetrain, 
-			  Int_t iflag)
-{
-    if (nametrain.IsNull() || howmanytrain <= 0)
-        return kFALSE;
-
-    *fLog   << "=============================================" << endl;
-    *fLog   << "Fill TRAINING Matrices from file '" << nametrain << endl;
-    *fLog   << "     select " << howmanytrain << " events " << endl;
-    if (!hreftrain.GetHist().GetEntries()==0)
-    {
-      *fLog << "     according to a distribution given by the MH3 object '"
-            << hreftrain.GetName() << "'" << endl;
-    }
-    else
-    {
-      *fLog << "     randomly" << endl;
-    }
-    *fLog   << "=============================================" << endl;
-
-
-    MParList  plist;
-    MTaskList tlist;
-
-    // initialize display to check the reference distribution
-    // for the event selection (just if iflag==1)
-    MStatusDisplay *display = NULL;
-    if (iflag)
-      display = new MStatusDisplay;
-
-    MReadMarsFile read("Events", nametrain);
-    read.DisableAutoScheme();
-
-    // apply cuts for event selection
-    MContinue contdisp(fDispFilter);
-    contdisp.SetName("ContFilterSelector2");
-
-    // choose a reference distribution
-    MFEventSelector2 seltrain(hreftrain);
-    seltrain.SetNumMax(howmanytrain);
-    seltrain.SetName("selectTrain");
-
-    MFillH filltraincalc(fMatrixTrainCalc);
-    filltraincalc.SetFilter(&seltrain);
-    filltraincalc.SetName("fillMatrixTrainCalc");
-
-    MFillH filltrainhists(fMatrixTrainHists);
-    filltrainhists.SetFilter(&seltrain);
-    filltrainhists.SetName("fillMatrixTrainHists");
-
-    //******************************
-    // entries in MParList 
-    
-    plist.AddToList(&tlist);
-    plist.AddToList(fCam);
-    plist.AddToList(fMatrixTrainCalc);
-    plist.AddToList(fMatrixTrainHists);
-
-    //******************************
-    // entries in MTaskList 
-
-    tlist.AddToList(&read);
-    if (fDispFilter != NULL)
-      tlist.AddToList(&contdisp);
-    tlist.AddToList(&seltrain);
-    tlist.AddToList(&filltraincalc);
-    tlist.AddToList(&filltrainhists);
-
-    //******************************
-
-    MProgressBar bar;
-    MEvtLoop evtloop;
-    if (display != NULL)
-      evtloop.SetDisplay(display);
-    evtloop.SetParList(&plist);
-    evtloop.SetName("EvtLoopMatrixTrain");
-    evtloop.SetProgressBar(&bar);
-
-    if (!evtloop.Eventloop())
-      return kFALSE;
-
-    tlist.PrintStatistics(0, kTRUE);
-
-
-    // print the filled Training Matrices
-    fMatrixTrainCalc->Print("SizeCols");
-    fMatrixTrainHists->Print("SizeCols");
-
-    // check that number of generated events is compatible with the resquested
-    Int_t howmanygeneratedcalc = fMatrixTrainCalc->GetM().GetNrows();
-    if (TMath::Abs(howmanygeneratedcalc-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
-    {
-      *fLog << "MFindDisp::DefineTrainMatrix; no.of generated events ("
-	    << howmanygeneratedcalc 
-            << ") is incompatible with the no.of requested events ("
-            << howmanytrain << ")" << endl;
-    }
-
-    Int_t howmanygeneratedhists = fMatrixTrainHists->GetM().GetNrows();
-    if (TMath::Abs(howmanygeneratedhists-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
-    {
-      *fLog << "MFindDisp::DefineTrainMatrix; no.of generated events ("
-	    << howmanygeneratedhists 
-            << ") is incompatible with the no.of requested events ("
-            << howmanytrain << ")" << endl;
-    }
-
-
-    *fLog << "TRAINING Matrices were filled" << endl;
-    *fLog << "=============================================" << endl;
-
-
-    //--------------------------
-    // write out training matrices
-
-    if (filetrain != "")
-    {
-      TFile filetr(filetrain, "RECREATE");
-      fMatrixTrainCalc->Write();
-      fMatrixTrainHists->Write();
-      filetr.Close();
-
-      *fLog << "MFindDisp::DefineTrainMatrix; Training matrices were written onto file '"
-            << filetrain << "'" << endl;
-    }
-
-
-    if (display != NULL)
-      delete display;
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Define the matrices 'fMatrixTestCalc' and 'fMatrixTestHists' 
-// for the TEST sample
-//
-// alltogether 'howmanytest' events are read from file 'nametest'
-// the events are selected according to a target distribution 'hreftest'
-//
-//
-Bool_t MFindDisp::DefineTestMatrix(
-			  const TString &nametest, MH3 &hreftest,
-	                  const Int_t howmanytest, const TString &filetest,
-			  Int_t iflag)
-{
-    if (nametest.IsNull() || howmanytest<=0)
-        return kFALSE;
-
-    *fLog   << "=============================================" << endl;
-    *fLog   << "Fill TEST Matrices from file '" << nametest << endl;
-    *fLog   << "     select " << howmanytest << " events " << endl;
-    if (!hreftest.GetHist().GetEntries()==0)
-    {
-      *fLog << "     according to a distribution given by the MH3 object '"
-            << hreftest.GetName() << "'" << endl;
-    }
-    else
-    {
-      *fLog << "     randomly" << endl;
-    }
-
-
-    MParList  plist;
-    MTaskList tlist;
-
-    // initialize display to check the reference distribution
-    // for the event selection (just if iflag==1)
-    MStatusDisplay *display = NULL;
-    if (iflag)
-      display = new MStatusDisplay;
-
-    MReadMarsFile read("Events", nametest);
-    read.DisableAutoScheme();
-
-    // apply cuts for event selection
-    MContinue contdisp(fDispFilter);
-    contdisp.SetName("ContFilterSelector2");
- 
-    // choose a reference distribution 
-    MFEventSelector2 seltest(hreftest);
-    seltest.SetNumMax(howmanytest);
-    seltest.SetName("selectTest");
- 
-    MFillH filltestcalc(fMatrixTestCalc);
-    filltestcalc.SetFilter(&seltest);
-    filltestcalc.SetName("fillMatrixTestCalc");
-
-    MFillH filltesthists(fMatrixTestHists);
-    filltesthists.SetFilter(&seltest);
-    filltesthists.SetName("fillMatrixTestHists");
-
-    //******************************
-    // entries in MParList 
-    
-    plist.AddToList(&tlist);
-    plist.AddToList(fCam);
-    plist.AddToList(fMatrixTestCalc);
-    plist.AddToList(fMatrixTestHists);
-
-    //******************************
-    // entries in MTaskList 
-
-    tlist.AddToList(&read);
-    if (fDispFilter != NULL)
-      tlist.AddToList(&contdisp);
-    tlist.AddToList(&seltest);
-    tlist.AddToList(&filltestcalc);
-    tlist.AddToList(&filltesthists);
-
-    //******************************
-
-    MProgressBar bar;
-    MEvtLoop evtloop;
-    if (display != NULL)
-      evtloop.SetDisplay(display);
-    evtloop.SetParList(&plist);
-    evtloop.SetName("EvtLoopMatrixTest");
-    evtloop.SetProgressBar(&bar);
-
-    if (!evtloop.Eventloop())
-      return kFALSE;
-
-    tlist.PrintStatistics(0, kTRUE);
-
-
-    // print the filled Test Matrices
-    fMatrixTestCalc->Print("SizeCols");
-    fMatrixTestHists->Print("SizeCols");
-
-    // check that number of generated events is compatible with the resquested
-    const Int_t howmanygeneratedcalc = fMatrixTestCalc->GetM().GetNrows();
-    if (TMath::Abs(howmanygeneratedcalc-howmanytest) > TMath::Sqrt(9.*howmanytest))
-    {
-      *fLog << "MFindDisp::DefineTestMatrix; no.of generated events ("
-	    << howmanygeneratedcalc
-            << ") is incompatible with the no.of requested events ("
-            << howmanytest << ")" << endl;
-    }
-
-    const Int_t howmanygeneratedhists = fMatrixTestHists->GetM().GetNrows();
-    if (TMath::Abs(howmanygeneratedhists-howmanytest) > TMath::Sqrt(9.*howmanytest))
-    {
-      *fLog << "MFindDisp::DefineTestMatrix; no.of generated events ("
-	    << howmanygeneratedhists
-            << ") is incompatible with the no.of requested events ("
-            << howmanytest << ")" << endl;
-    }
-
-    *fLog << "TEST Matrices were filled" << endl;
-    *fLog << "=============================================" << endl;
-
-
-    //--------------------------
-    // write out test matrices
-
-    if (filetest != "")
-    {
-      TFile filete(filetest, "RECREATE");
-      fMatrixTestCalc->Write();
-      fMatrixTestHists->Write();
-      filete.Close();
-
-      *fLog << "MFindDisp::DefineTestMatrix; Test matrices were written onto file '"
-            << filetest << "'" << endl;
-    }
-
-
-    if (display != NULL)
-      delete display;
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Define the matrices for the TRAINING and TEST sample respectively
-//
-//   - this is for the case that training and test samples are generated
-//     from the same input file (which has the name 'name')
-//
-Bool_t MFindDisp::DefineTrainTestMatrix(
-			  const TString &name, MH3 &href,
-	                  const Int_t howmanytrain, const Int_t howmanytest,
-                          const TString &filetrain, const TString &filetest,
-			  Int_t iflag)
-{
-    *fLog   << "=============================================" << endl;
-    *fLog   << "Fill TRAINING and TEST Matrices from file '" << name << endl;
-    *fLog   << "     select "   << howmanytrain 
-	    << " training and " << howmanytest << " test events " << endl;
-    if (!href.GetHist().GetEntries()==0)
-    {
-      *fLog << "     according to a distribution given by the MH3 object '"
-            << href.GetName() << "'" << endl;
-    }
-    else
-    {
-      *fLog << "     randomly" << endl;
-    }
-
-
-    MParList  plist;
-    MTaskList tlist;
-
-    // initialize display to check the reference distribution
-    // for the event selection (just if iflag==1)
-    MStatusDisplay *display = NULL;
-    if (iflag)
-      display = new MStatusDisplay;
-
-    MReadMarsFile read("Events", name);
-    read.DisableAutoScheme();
-
-    // apply cuts for event selection
-    MContinue contdisp(fDispFilter);
-    contdisp.SetName("ContFilterSelector2");
-
-    // choose a reference distribution 
-    MFEventSelector2 selector(href);
-    selector.SetNumMax(howmanytrain+howmanytest);
-    selector.SetName("selectTrainTest");
-    selector.SetInverted();
-    MContinue cont(&selector);
-    cont.SetName("ContTrainTest");
-
-    // choose randomly the events to fill the Training Matrix
-    Double_t prob =  ( (Double_t) howmanytrain )
-                   / ( (Double_t)(howmanytrain+howmanytest) );
-    MFEventSelector split;
-    split.SetSelectionRatio(prob);
-
-    MFillH filltraincalc(fMatrixTrainCalc);
-    filltraincalc.SetFilter(&split);
-    filltraincalc.SetName("fillMatrixTrainCalc");
-
-    MFillH filltrainhists(fMatrixTrainHists);
-    filltrainhists.SetFilter(&split);
-    filltrainhists.SetName("fillMatrixTrainHists");
-
-    // consider this event as candidate for a test event 
-    // only if event was not accepted as a training event
-    MContinue conttrain(&split);
-    conttrain.SetName("ContTrain");
-
-    MFillH filltestcalc(fMatrixTestCalc);
-    filltestcalc.SetName("fillMatrixTestCalc");
-
-    MFillH filltesthists(fMatrixTestHists);
-    filltesthists.SetName("fillMatrixTestHists");
-
-
-    //******************************
-    // entries in MParList 
-    
-    plist.AddToList(&tlist);
-    plist.AddToList(fCam);
-    plist.AddToList(fMatrixTrainCalc);
-    plist.AddToList(fMatrixTrainHists);
-    plist.AddToList(fMatrixTestCalc);
-    plist.AddToList(fMatrixTestHists);
-
-    //******************************
-    // entries in MTaskList 
-
-    tlist.AddToList(&read);
-    if (fDispFilter != NULL)
-      tlist.AddToList(&contdisp);
-    tlist.AddToList(&cont);
-    tlist.AddToList(&filltraincalc);
-    tlist.AddToList(&filltrainhists);
-    tlist.AddToList(&conttrain);
-    tlist.AddToList(&filltestcalc);
-    tlist.AddToList(&filltesthists);
-
-    //******************************
-
-    MProgressBar bar;
-    MEvtLoop evtloop;
-    if (display != NULL)
-      evtloop.SetDisplay(display);
-    evtloop.SetParList(&plist);
-    evtloop.SetName("EvtLoopMatrixTrainTest");
-    evtloop.SetProgressBar(&bar);
-
-    Int_t maxev = -1;
-    if (!evtloop.Eventloop(maxev))
-      return kFALSE;
-
-    tlist.PrintStatistics(0, kTRUE);
-
-
-    // print the filled Train Matrices
-    fMatrixTrainCalc->Print("SizeCols");
-    fMatrixTrainHists->Print("SizeCols");
-
-    // check that number of generated events is compatible with the resquested
-    const Int_t generatedtraincalc = fMatrixTrainCalc->GetM().GetNrows();
-    if (TMath::Abs(generatedtraincalc-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
-    {
-      *fLog << "MFindDisp::DefineTrainTestMatrix; no.of generated events ("
-	    << generatedtraincalc
-            << ") is incompatible with the no.of requested events ("
-            << howmanytrain << ")" << endl;
-    }
-    const Int_t generatedtrainhists = fMatrixTrainHists->GetM().GetNrows();
-    if (TMath::Abs(generatedtrainhists-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
-    {
-      *fLog << "MFindDisp::DefineTrainTestMatrix; no.of generated events ("
-	    << generatedtrainhists
-            << ") is incompatible with the no.of requested events ("
-            << howmanytrain << ")" << endl;
-    }
-
-
-    // print the filled Test Matrices
-    fMatrixTestCalc->Print("SizeCols");
-    fMatrixTestHists->Print("SizeCols");
-
-    // check that number of generated events is compatible with the resquested
-    const Int_t generatedtestcalc = fMatrixTestCalc->GetM().GetNrows();
-    if (TMath::Abs(generatedtestcalc-howmanytest) > TMath::Sqrt(9.*howmanytest))
-    {
-      *fLog << "MFindDisp::DefineTrainTestMatrix; no.of generated events ("
-	    << generatedtestcalc
-            << ") is incompatible with the no.of requested events ("
-            << howmanytest << ")" << endl;
-    }
-    const Int_t generatedtesthists = fMatrixTestHists->GetM().GetNrows();
-    if (TMath::Abs(generatedtesthists-howmanytest) > TMath::Sqrt(9.*howmanytest))
-    {
-      *fLog << "MFindDisp::DefineTrainTestMatrix; no.of generated events ("
-	    << generatedtesthists
-            << ") is incompatible with the no.of requested events ("
-            << howmanytest << ")" << endl;
-    }
-
-
-    *fLog << "TRAINING and TEST Matrices were filled" << endl;
-    *fLog << "=============================================" << endl;
-
-
-    //----------------------------
-    // write out training matrices
-
-    if (filetrain != "")
-    {
-      TFile filetr(filetrain, "RECREATE");
-      fMatrixTrainCalc->Write();
-      fMatrixTrainHists->Write();
-      filetr.Close();
-
-      *fLog << "MFindDisp::DefineTrainTestMatrix; Training matrices were written onto file '"
-            << filetrain << "'" << endl;
-    }
-
-    //--------------------------
-    // write out test matrices
-
-    if (filetest != "")
-    {
-      TFile filete(filetest, "RECREATE");
-      fMatrixTestCalc->Write();
-      fMatrixTestHists->Write();
-      filete.Close();
-
-      *fLog << "MFindDisp::DefineTrainTestMatrix; Test matrices were written onto file '"
-            << filetest << "'" << endl;
-    }
-
-    if (display != NULL)
-      delete display;
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Read training and test matrices from files
-//
-//
-Bool_t MFindDisp::ReadMatrix(const TString &filetrain, const TString &filetest)
-{
-  //--------------------------
-  // read in training matrices
-
-  TFile filetr(filetrain);
-  fMatrixTrainCalc->Read("MatrixTrainCalc");
-  fMatrixTrainHists->Read("MatrixTrainHists");
-  fMatrixTrainCalc->Print("SizeCols");
-  fMatrixTrainHists->Print("SizeCols");
-
-  *fLog << "MFindDisp::ReadMatrix; Training matrices were read in from file '"
-        << filetrain << "'" << endl;
-  filetr.Close();
-
-
-  //--------------------------
-  // read in test matrices
-
-  TFile filete(filetest);
-  fMatrixTestCalc->Read("MatrixTestCalc");
-  fMatrixTestHists->Read("MatrixTestHists");
-  fMatrixTestCalc->Print("SizeCols");
-  fMatrixTestHists->Print("SizeCols");
-
-  *fLog << "MFindDisp::ReadMatrix; Test matrices were read in from file '"
-        << filetest << "'" << endl;
-  filete.Close();
-
-  return kTRUE;  
-}
-
-
-//------------------------------------------------------------------------
-//
-// Steering program for optimizing Disp
-// ------------------------------------
-//
-//      the criterion for the 'optimum' is defined in 
-//      MHDisp::Fill()  and  MHDisp::Finalize(); 
-//      for example : smallest sum (over all events) of d^2, where d is the 
-//                    distance between the estimated source position 
-//                    (calculated using the current value of Disp) and
-//                    the true source position     
-//
-// The various steps are :
-//
-// - setup the event loop to be executed for each call to fcnDisp 
-//
-// - call TMinuit to do the minimization :
-//        the fcnDisp function calculates the parameter to minimize 
-//                            for the current Disp parameter values;
-//        for this - Disp is calculated in the event loop by calling 
-//                   MDispCalc::Process() ==> MDispCalc::Calc() 
-//                 - the Minimization parameter contributions are summed up 
-//                   in the event loop by calling MHDisp::Fill()
-//                 - after the event loop the final value of the Minimization
-//                   parameter is calculated by calling MHDisp::Finalize()
-//
-// Needed as input : (to be set by the Set functions)
-//
-// - fFilenameParam      name of file to which optimum values of the 
-//                       parameters are written
-//
-// - for the minimization, the starting values of the parameters are taken  
-//     - from the file parDispInit (if it is != "")
-//     - or from the arrays params and/or steps 
-//     - or from the DispParameters constructor
-//
-//----------------------------------------------------------------------
-Bool_t MFindDisp::FindParams(TString parDispInit,
-                             TArrayD &params, TArrayD &steps)
-{
-    // Setup the event loop which will be executed in the 
-    //                 fcnDisp function  of MINUIT
-    //
-    // parDispInit is the name of the file containing the initial values 
-    // of the parameters; 
-    // if parDispInit = ""   'params' and 'steps' are taken as initial values
-    //
-
-    *fLog << "=============================================" << endl;
-    *fLog << "Setup event loop for fcnDisp" << endl;
-
-
-    if (fMatrixTrainCalc == NULL || fMatrixTrainHists == NULL)
-    {
-      *fLog << "MFindDisp::FindParams; training matrices are not defined... aborting"
-            << endl;
-      return kFALSE;
-    }
-
-    if (fMatrixTrainCalc->GetM().GetNrows() <= 0  ||  fMatrixTrainHists->GetM().GetNrows() <= 0)
-    {
-      *fLog << "MFindDisp::FindParams; training matrices have no entries"
-            << endl;
-      return kFALSE;
-    }
-
-    //---------------------------------------------------------
-    MParList  parlistfcn;
-    MTaskList tasklistfcn;
-
-    // loop over rows of matrix
-    MMatrixLoop loopcalc(fMatrixTrainCalc);
-    MMatrixLoop loophists(fMatrixTrainHists);
-
-    //--------------------------------
-    // create container for the Disp parameters
-    // and set them to their initial values
-    MDispParameters *dispparams = fDispCalcTrain->GetDispParameters();
-
-    // take initial values from file parDispInit
-    if (parDispInit != "")
-    {
-      TFile inparam(parDispInit);
-      dispparams->Read("MDispParameters");
-      inparam.Close();
-      *fLog << "MFindDisp::FindParams; initial values of parameters are taken from file "
-            << parDispInit << endl;
-    }
-
-    // take initial values from 'params' and/or 'steps'
-    else if (params.GetSize() != 0  || steps.GetSize()  != 0 )
-    {
-      if (params.GetSize()  != 0)
-      {
-        *fLog << "MFindDisp::FindParams; initial values of parameters are taken from 'params'"
-              << endl;
-        dispparams->SetParameters(params);
-      }
-      if (steps.GetSize()  != 0)
-      {
-        *fLog << "MFindDisp::FindParams; initial step sizes are taken from 'steps'"
-              << endl;
-        dispparams->SetStepsizes(steps);
-      }
-    }
-    else
-    {
-        *fLog << "MFindDisp::FindParams; initial values and step sizes are taken "
-	      << "from the MDispParameters constructor" << endl;
-    }
-
-    // fill the plots for Disp and sum up the Minimization parameter contributions
-    MFillH filldispplots("MHDisp", "");
-
-    //******************************
-    // entries in MParList
-    
-    parlistfcn.AddToList(&tasklistfcn);
-    parlistfcn.AddToList(dispparams);
-    parlistfcn.AddToList(fHDispTrain);
-    parlistfcn.AddToList(fCam);
-    parlistfcn.AddToList(fMatrixTrainCalc);
-    parlistfcn.AddToList(fMatrixTrainHists);
-
-    //******************************
-    // entries in MTaskList
-
-    tasklistfcn.AddToList(&loopcalc);
-    tasklistfcn.AddToList(&loophists);
-    tasklistfcn.AddToList(fDispCalcTrain);
-    tasklistfcn.AddToList(&filldispplots);
-
-    //******************************
-
-    MEvtLoop evtloopfcn("EvtLoopFCN");
-    evtloopfcn.SetParList(&parlistfcn);
-    *fLog << "Event loop for fcnDisp has been setup" << endl;
-
-    // address of evtloopfcn is used in CallMinuit()
-
-
-    //-----------------------------------------------------------------------
-    //
-    //----------   Start of minimization part   --------------------
-    //
-    // Do the minimization with MINUIT
-    //
-    // Be careful: This is not thread safe
-    //
-    *fLog << "========================================================" << endl;
-    *fLog << "Start minimization for Disp" << endl;
-
-
-    // -------------------------------------------
-    // prepare call to MINUIT
-    //
-
-    // get initial values of parameters 
-    fVinit = dispparams->GetParameters();
-    fStep  = dispparams->GetStepsizes();
-
-    TString name[fVinit.GetSize()];
-    fStep.Set(fVinit.GetSize());
-    fLimlo.Set(fVinit.GetSize());
-    fLimup.Set(fVinit.GetSize());
-    fFix.Set(fVinit.GetSize());
-
-    fNpar = fVinit.GetSize();
-
-    // define names, step sizes, lower and upper limits of the parameters
-    // fFix[] = 0;  means the parameter is not fixed
-    for (UInt_t i=0; i<fNpar; i++)
-    {
-        name[i]   = "p";
-        name[i]  += i+1;
-        //fStep[i]  = TMath::Abs(fVinit[i]/10.0);
-        fLimlo[i] = -100.0;
-        fLimup[i] =  100.0;
-        fFix[i]   =     0;
-    }
-
-    // fix some parameters
-    //for (UInt_t i=0; i<fNpar; i++)
-    //{
-    //  if (i == 1  ||  i==3)
-    //	{
-    //      fStep[i] = 0.0;
-    //      fFix[i]  =   1;
-    //	}
-    //}
- 
-
-    // -------------------------------------------
-    // call MINUIT
-
-    TStopwatch clock;
-    clock.Start();
-
-    *fLog << "before calling CallMinuit" << endl;
-
-    MMinuitInterface inter;               
-    Bool_t rc = inter.CallMinuit(fcnDisp, name,
-                                 fVinit, fStep, fLimlo, fLimup, fFix,
-                                 &evtloopfcn, "MIGRAD", kFALSE);
- 
-    *fLog << "after calling CallMinuit" << endl;
-
-    *fLog << "Time spent for the minimization in MINUIT :   " << endl;;
-    clock.Stop();
-    clock.Print();
-
-
-    if (!rc)
-        return kFALSE;
-
-    *fLog << "Minimization for Disp finished" << endl;
-    *fLog << "========================================================" << endl;
-
-
-    // -----------------------------------------------------------------
-    // in 'fcnDisp' the optimum parameter values were put into MDisp
-
-    // write optimum parameter values onto file fFilenameParam
-    
-    TFile outparam(fFilenameParam, "RECREATE"); 
-    dispparams->Write();
-    outparam.Close();
-
-    *fLog << "Optimum parameter values for Disp were written onto file '"
-              << fFilenameParam << "' :" << endl;
-
-    const TArrayD &check = dispparams->GetParameters();
-    for (Int_t i=0; i<check.GetSize(); i++)
-        *fLog << check[i] << ",  ";
-    *fLog << endl;
-
-
-
-    //-------------------------------------------
-    // draw the plots
-    fHDispTrain->Draw();
-
-    *fLog << "End of Disp optimization part" << endl;
-    *fLog << "======================================================" << endl;
-
-    return kTRUE;
-}
-
-
-// -----------------------------------------------------------------------
-//
-// Test the result of the Disp optimization on the test sample
-//
-
-Bool_t MFindDisp::TestParams()
-{
-    if (fMatrixTestCalc == NULL || fMatrixTestHists == NULL)
-    {
-      *fLog << "MFindDisp::TestParams; test matrices are not defined... aborting"
-            << endl;
-      return kFALSE;
-    }
-
-    if (fMatrixTestCalc->GetM().GetNrows() <= 0  ||  fMatrixTestHists->GetM().GetNrows() <= 0)
-    {
-        *fLog << "MFindDisp::TestParams; test matrices have no entries" 
-              << endl;
-        return kFALSE;
-    }
-
-    // -------------   TEST the Disp optimization    -------------------
-    //
-    *fLog << "Test the Disp optimization on the test sample" << endl;
-
-    // -----------------------------------------------------------------
-    // read optimum parameter values from file fFilenameParam
-    // into array 'dispPar'
-
-    TFile inparam(fFilenameParam);
-    MDispParameters dispin; 
-    dispin.Read("MDispParameters");
-    inparam.Close();
-
-    *fLog << "Optimum parameter values for Disp were read from file '";
-    *fLog << fFilenameParam << "' :" << endl;
-
-    const TArrayD &dispPar = dispin.GetParameters();
-    for (Int_t i=0; i<dispPar.GetSize(); i++)
-        *fLog << dispPar[i] << ",  ";
-    *fLog << endl;
-    //---------------------------
-
-
-    // -----------------------------------------------------------------
-    MParList  parlist2;
-    MTaskList tasklist2;
-
-    MDispParameters *dispparams = fDispCalcTest->GetDispParameters();
-    dispparams->SetParameters(dispPar);
-
-    MMatrixLoop loopcalc(fMatrixTestCalc);
-    MMatrixLoop loophists(fMatrixTestHists);
-
-    MHMatrix *imatrix = NULL;
-    TArrayI  imap;
-    fHDispTest->GetMatrixMap(imatrix,imap);
-
-    // attention: argument of MHDisp is the name of MImageParDisp container, that should
-    // be the same than the name given to it when creating MDispCalc object at the MFindDisp
-    // constructor:  fDispCalcTrain = new MDispCalc("DispTest");
-    // fill the plots for Disp and sum up the Minimization parameter contributions
-    MHDisp hdisp1("DispTest");
-    hdisp1.SetName("MHDispCorr");
-    hdisp1.SetSelectedPos(1);
-    hdisp1.SetMatrixMap(imatrix,imap);
-    MFillH filldispplots1("MHDispCorr[MHDisp]", "");
-    
-    MHDisp hdisp2("DispTest");
-    hdisp2.SetName("MHDispWrong");
-    hdisp2.SetSelectedPos(2);
-    hdisp2.SetMatrixMap(imatrix,imap);
-    MFillH filldispplots2("MHDispWrong[MHDisp]", "");
-    
-    MHDisp hdisp3("DispTest");
-    hdisp3.SetName("MHDispM3Long");
-    hdisp3.SetSelectedPos(3);
-    hdisp3.SetMatrixMap(imatrix,imap);
-    MFillH filldispplots3("MHDispM3Long[MHDisp]", "");
-    
-    MHDisp hdisp4("DispTest");
-    hdisp4.SetName("MHDispAsym");
-    hdisp4.SetSelectedPos(4);
-    hdisp4.SetMatrixMap(imatrix,imap);
-    MFillH filldispplots4("MHDispAsym[MHDisp]", "");
-    
-
-    //******************************
-    // entries in MParList
-
-    parlist2.AddToList(&tasklist2);
-    parlist2.AddToList(dispparams);
-    parlist2.AddToList(&hdisp1);
-    parlist2.AddToList(&hdisp2);
-    parlist2.AddToList(&hdisp3);
-    parlist2.AddToList(&hdisp4);
-    parlist2.AddToList(fCam);
-    parlist2.AddToList(fMatrixTestCalc);
-    parlist2.AddToList(fMatrixTestHists);
-
-    //******************************
-    // entries in MTaskList
-
-    tasklist2.AddToList(&loopcalc);
-    tasklist2.AddToList(&loophists);
-    tasklist2.AddToList(fDispCalcTest);
-    tasklist2.AddToList(&filldispplots1);
-    tasklist2.AddToList(&filldispplots2);
-    tasklist2.AddToList(&filldispplots3);
-    tasklist2.AddToList(&filldispplots4);
-
-    //******************************
-
-    MProgressBar bar2;
-    MEvtLoop evtloop2;
-    evtloop2.SetParList(&parlist2);
-    evtloop2.SetName("EvtLoopTestParams");
-    evtloop2.SetProgressBar(&bar2);
-    Int_t maxevents2 = -1;
-    if (!evtloop2.Eventloop(maxevents2))
-        return kFALSE;
-
-    tasklist2.PrintStatistics(0, kTRUE);
-
-
-    //-------------------------------------------
-    // draw the plots
-
-    hdisp1.Draw();
-    hdisp2.Draw();
-    hdisp3.Draw();
-    hdisp4.Draw();
-
-    //-------------------------------------------
-
-
-    *fLog << "Test of Disp otimization finished" << endl;
-    *fLog << "======================================================" << endl;
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MFindDisp.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MFindDisp.h	(revision 7136)
+++ 	(revision )
@@ -1,134 +1,0 @@
-#ifndef MARS_MFindDisp
-#define MARS_MFindDisp
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef ROOT_TArrayD
-#include <TArrayD.h>
-#endif
-
-#ifndef ROOT_TArrayI
-#include <TArrayI.h>
-#endif
-
-class MHMatrix;
-class MDispCalc;
-class MHDisp;
-class MFDisp;
-class MFilter;
-class MH3;
-class MGeomCam;
-class MEvtLoop;
-
-class MFindDisp : public MParContainer
-{
-private:
-
-  TString   fFilenameParam;  // filename to store optimum Disp parameters
-
-  TString   fFilenameTrain;
-  TString   fFilenameTest;
-
-  Int_t     fHowManyTrain;   // number of events for training
-  Int_t     fHowManyTest;    // number of events for testing
-
-  MHMatrix  *fMatrixTrainCalc;    // training matrix with variables needed in MDispCalc
-  MHMatrix  *fMatrixTrainHists;   // training matrix with variables needed in MHDisp
-  MHMatrix  *fMatrixTestCalc;     // testing matrix with variables needed in MDispCalc
-  MHMatrix  *fMatrixTestHists;    // testing matrix with variables needed in MHDisp
-
-  MDispCalc *fDispCalcTrain;
-  MDispCalc *fDispCalcTest;
-
-  MHDisp    *fHDispTrain;
-  MHDisp    *fHDispTest;
-
-  MFDisp    *fDispFilter;    // filter to select an events sample
-
-  MGeomCam  *fCam;
-
-  MEvtLoop  *fObjectFit;
-
-  //--------------------------------------------
-  // To comunicate with MINUIT
-  //--------------------------------------------
-  // attention : dimensions must agree with those in 
-  //             MMinuitInterface::CallMinuit()
-  //char  fParName [80][100];
-  TArrayD   fVinit;
-  TArrayD   fStep;
-  TArrayD   fLimlo;
-  TArrayD   fLimup;
-  TArrayI   fFix;
-
-  UInt_t    fNpar;
-
-  TString   fMethod;
-
-  Double_t  fMin,   fEdm,   fErrdef;
-  Int_t     fNpari, fNparx, fIstat;
-  Int_t     fErrMinimize;
-  //--------------------------------------------
-
-public:
-
-  MFindDisp(MFDisp *fdisp=NULL, const char *name=NULL, const char *title=NULL);
-  ~MFindDisp();
-
-  void SetFilenameParam(const TString &name)    {fFilenameParam  = name;}
-
-  void SetFilenameTraining(const TString &name, const Int_t howmany) 
-      {fFilenameTrain = name;  fHowManyTrain = howmany; }
-
-  void SetFilenameTest(const TString &name, const Int_t howmany)     
-      {fFilenameTest     = name;  fHowManyTest  = howmany; }
-
-  Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
-                           const Int_t howmany, const TString &filetrain,
-			   Int_t iflag=0); 
-
-  Bool_t DefineTestMatrix(const TString &name, MH3 &href,
-                          const Int_t howmany, const TString &filetest,
-			  Int_t iflag=0); 
-
-  Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
-			       const Int_t howmanytrain, const Int_t howmanytest, 
-			       const TString &filetrain, const TString &filetest,
-			       Int_t iflag=0); 
-
-  MHMatrix *GetMatrixTrainCalc()  { return fMatrixTrainCalc;  }
-  MHMatrix *GetMatrixTrainHists() { return fMatrixTrainHists; }
-  MHMatrix *GetMatrixTestCalc()   { return fMatrixTestCalc;   }
-  MHMatrix *GetMatrixTestHists()  { return fMatrixTestHists;  }
-
-  Bool_t ReadMatrix( const TString &filetrain, const TString &filetest);
-
-  Bool_t FindParams(TString parSCinit, TArrayD &params, TArrayD &steps);
-
-  Bool_t TestParams();
-
-  ClassDef(MFindDisp, 1) // Class for optimizing Disp
-};
-
-#endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MHDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MHDisp.cc	(revision 7136)
+++ 	(revision )
@@ -1,717 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Eva Domingo,     12/2004 <mailto:domingo@ifae.es>
-!              Wolfgang Wittek, 12/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2005
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//                                                                         //
-//   MHDisp                                                                //
-//                                                                         //
-//   container holding the histograms for Disp                             //
-//   also computes the minimization parameter of the Disp optimization     // 
-//                                                                         //
-/////////////////////////////////////////////////////////////////////////////
-#include "MHDisp.h"
-
-#include <math.h>
-
-#include <TH1.h>
-#include <TH2.h>
-#include <TProfile.h>
-#include <TArrayI.h>
-#include <TPad.h>
-#include <TCanvas.h>
-#include <TStyle.h>
-
-#include "MGeomCam.h"
-#include "MSrcPosCam.h"
-#include "MHillas.h"
-#include "MHillasExt.h"
-#include "MNewImagePar.h"
-#include "MMcEvt.hxx"
-#include "MPointingPos.h"
-#include "MImageParDisp.h"
-
-#include "MHMatrix.h"
-#include "MParameters.h"
-
-#include "MParList.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MHDisp);
-
-using namespace std;
-
-enum dispVar_t {kX,kY,kMeanX,kMeanY,kDelta,kSize,kM3Long,kAsym,
-		kEnergy,kImpact,kLongitmax,kZd,kAz,kTotVar};    // enum variables for the
-                                                                // matrix columns mapping
-
-// --------------------------------------------------------------------------
-//
-// Constructor 
-//
-MHDisp::MHDisp(const char *imagepardispname,
-	       const char *name, const char *title)
-  : fImageParDispName(imagepardispname)
-{
-    fName  = name  ? name  : "MHDisp";
-    fTitle = title ? title : "Histograms for Disp";
-
-    fSelectedPos = 1;  // default MHDisp flag (selects Correct Disp source position solution)
-
-    fMatrix = NULL;
-
-    // initialize mapping array dimension to the number of columns of fMatrix
-    fMap.Set(kTotVar);
-
-    //--------------------------------------------------
-    // creating the Disp related histograms
-
-    fHistEnergy   = new TH1F("fHistEnergy", 
-	 "log10(Energy)", 50, 1., 3.);
-    fHistEnergy->SetDirectory(NULL);
-    fHistEnergy->UseCurrentStyle();
-    fHistEnergy->SetXTitle("log10(Energy) [GeV]");
-    fHistEnergy->SetYTitle("# events");
-
-    fHistSize   = new TH1F("fHistSize", 
-	 "log10(Size)", 50, 2., 4.);
-    fHistSize->SetDirectory(NULL);
-    fHistSize->UseCurrentStyle();
-    fHistSize->SetXTitle("log10(Size) [#phot]");
-    fHistSize->SetYTitle("# events");
-
-    fHistcosZA   = new TH1F("fHistcosZA", 
-	 "cos(Zenith Angle)", 10, 0., 1.);
-    fHistcosZA->SetDirectory(NULL);
-    fHistcosZA->UseCurrentStyle();
-    fHistcosZA->SetXTitle("cos(Theta)");
-    fHistcosZA->SetYTitle("# events");
-
-    fSkymapXY = new TH2F("fSkymapXY", 
-         "Disp estimated source positions Skymap", 71, -2., 2., 71, -2., 2.);
-    fSkymapXY->SetDirectory(NULL);
-    fSkymapXY->UseCurrentStyle();
-    fSkymapXY->SetXTitle("X Disp source position [deg]");
-    fSkymapXY->SetYTitle("Y Disp source position [deg]");
-
-    fHistMinPar   = new TH1F("fHistMinPar"  , 
-         "Distance^2 between Disp and real srcpos", 100, 0., 2.);
-    fHistMinPar->SetDirectory(NULL);
-    fHistMinPar->UseCurrentStyle();
-    fHistMinPar->SetXTitle("Minimization parameter = d^2 Disp to real srcpos [deg^2]");
-    fHistMinPar->SetYTitle("# events");
-    
-    fHistDuDv   = new TH2F("fHistDuDv", 
-	 "Du vs. Dv (distances between Disp and real srcpos)", 
-	 100, -2., 2., 100, -2., 2.);
-    fHistDuDv->SetDirectory(NULL);
-    fHistDuDv->UseCurrentStyle();
-    fHistDuDv->SetXTitle("Dv = transveral distance [deg]");
-    fHistDuDv->SetYTitle("Du = longitudinal distance [deg]");
-
-    fHistMinParEnergy   = new TH2F("fHistMinParEnergy", 
-	 "Minimization parameter vs. Energy", 50, 1., 3., 100, 0., 2.);
-    fHistMinParEnergy->SetDirectory(NULL);
-    fHistMinParEnergy->UseCurrentStyle();
-    fHistMinParEnergy->SetXTitle("log10(Energy) [GeV]");
-    fHistMinParEnergy->SetYTitle("Minimization parameter = d^2 Disp to real srcpos [deg^2]");
-
-    fHistMinParSize   = new TH2F("fHistMinParSize", 
-	 "Minimization parameter vs. Size", 50, 2., 4., 100, 0., 2.);
-    fHistMinParSize->SetDirectory(NULL);
-    fHistMinParSize->UseCurrentStyle();
-    fHistMinParSize->SetXTitle("log10(Size) [#phot]");
-    fHistMinParSize->SetYTitle("Minimization parameter = d^2 Disp to real srcpos [deg^2]");
-
-    fHistDuEnergy   = new TH2F("fHistDuEnergy", 
-	 "Du vs. Energy", 50, 1., 3., 100, -2., 2.);
-    fHistDuEnergy->SetDirectory(NULL);
-    fHistDuEnergy->UseCurrentStyle();
-    fHistDuEnergy->SetXTitle("log10(Energy) [GeV]");
-    fHistDuEnergy->SetYTitle("Du = longitudinal distance Disp to real srcpos [deg]");
-
-    fHistDuSize   = new TH2F("fHistDuSize", 
-	 "Du vs. Size", 50, 2., 4., 100, -2., 2.);
-    fHistDuSize->SetDirectory(NULL);
-    fHistDuSize->UseCurrentStyle();
-    fHistDuSize->SetXTitle("log10(Size) [#phot]");
-    fHistDuSize->SetYTitle("Du = longitudinal distance Disp to real srcpos [deg]");
-
-    fHistDvEnergy   = new TH2F("fHistDvEnergy", 
-	 "Dv vs. Energy", 50, 1., 3., 100, -2., 2.);
-    fHistDvEnergy->SetDirectory(NULL);
-    fHistDvEnergy->UseCurrentStyle();
-    fHistDvEnergy->SetXTitle("log10(Energy) [GeV]");
-    fHistDvEnergy->SetYTitle("Dv = transveral distance Disp to real srcpos [deg]");
-
-    fHistDvSize   = new TH2F("fHistDvSize", 
-	 "Dv vs. Size", 50, 2., 4., 100, -2., 2.);
-    fHistDvSize->SetDirectory(NULL);
-    fHistDvSize->UseCurrentStyle();
-    fHistDvSize->SetXTitle("log10(Size) [#phot]");
-    fHistDvSize->SetYTitle("Dv = transveral distance Disp to real srcpos [deg]");
-
-    fEvCorrAssign   = new TProfile("fEvCorrAssign", 
-	 "Fraction events srcpos well assign vs. Size", 50, 2., 4., 0., 1.);
-    fEvCorrAssign->SetDirectory(NULL);
-    fEvCorrAssign->SetStats(0);
-    fEvCorrAssign->SetXTitle("log10(Size) [#phot]");
-    fEvCorrAssign->SetYTitle("Fraction of events with srcpos well assign");
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Destructor 
-//
-MHDisp::~MHDisp()
-{
-  delete fHistEnergy;
-  delete fHistSize;
-  delete fHistcosZA;
-  delete fSkymapXY;
-  delete fHistMinPar;
-  delete fHistDuDv;
-  delete fHistMinParEnergy;
-  delete fHistMinParSize;
-  delete fHistDuEnergy;
-  delete fHistDuSize;
-  delete fHistDvEnergy;
-  delete fHistDvSize;
-  delete fEvCorrAssign;
-}
-
-// --------------------------------------------------------------------------
-//
-// Set the pointers to the containers 
-// 
-//
-Bool_t MHDisp::SetupFill(const MParList *pList)
-{
-    // reset all histograms and Minimization parameter computing variables
-    // before each new eventloop
-    fNumEv = 0;
-    fSumMinPar  = 0.;
-    fMinPar = (MParameterD*)const_cast<MParList*>(pList)->FindCreateObj("MParameterD", "MinimizationParameter");
-    if (!fMinPar)
-    {
-      *fLog << err << "MParameterD (MinimizationParameter) not found and could not be created... aborting." 
-	    << endl;
-      return kFALSE;
-    }
-    fMinPar->SetVal(0);
-
-    fHistEnergy->Reset();
-    fHistSize->Reset();
-    fHistcosZA->Reset();
-    fSkymapXY->Reset();
-    fHistMinPar->Reset();
-    fHistDuDv->Reset();
-    fHistMinParEnergy->Reset();
-    fHistMinParSize->Reset();
-    fHistDuEnergy->Reset();
-    fHistDuSize->Reset();
-    fHistDvEnergy->Reset();
-    fHistDvSize->Reset();
-    fEvCorrAssign->Reset();
-
-
-    // look for the defined camera geometry to get mm to deg conversion factor
-    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
-    if (!cam)
-    {
-        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." 
-              << endl;
-        return kFALSE;
-    }
-    fMm2Deg = cam->GetConvMm2Deg();
-
-
-    // look for Disp related containers
-    fImageParDisp = (MImageParDisp*)pList->FindObject(fImageParDispName,
-						      "MImageParDisp");
-    if (!fImageParDisp)
-    {
-        *fLog << err << fImageParDispName 
-              << " [MImageParDisp] not found... aborting." << endl;
-        return kFALSE;
-    }
-
-
-    //-----------------------------------------------------------
-    // if fMatrix exists, skip preprocessing and just read events from matrix;
-    // if doesn't exist, read variables values from containers, so look for them
-    if (fMatrix)
-      return kTRUE;
-    
-    fSrcPos = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
-    if (!fSrcPos)
-    {
-        *fLog << err << "MSrcPosCam not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fHil = (MHillas*)pList->FindObject("MHillas");
-    if (!fHil)
-    {
-        *fLog << err << "MHillas not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fHilExt = (MHillasExt*)pList->FindObject("MHillasExt");
-    if (!fHilExt)
-    {
-        *fLog << err << "MHillasExt not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fNewPar = (MNewImagePar*)pList->FindObject("MNewImagePar");
-    if (!fNewPar)
-    {
-        *fLog << err << "MNewImagePar not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
-    if (!fMcEvt)
-    {
-        *fLog << err << "MMcEvt not found... This is not a MC file,"
-	      << " you are not trying to optimize Disp, just calculating it."
-	      << endl;
-	//        return kFALSE;
-    }
-
-    fPointing = (MPointingPos*)pList->FindObject("MPointingPos");
-    if (!fPointing)
-    {
-        *fLog << err << "MPointingPos not found... aborting." << endl;
-	return kFALSE;
-    }
-
-    //------------------------------------------
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Set which selection algorithm for the Disp estimated source position 
-// solutions we want to follow when filling the histograms:
-//  * iflag == 1 --> Correct source position, the closest to the real srcpos
-//                   (only applicable to MC or well known source real data)
-//  * iflag == 2 --> Wrong source position, the furthest to the real srcpos
-//                   (same applicability than case 1)
-//  * iflag == 3 --> Source position assigned as M3Long sign indicates
-//  * iflag == 4 --> Source position assigned as Asym sign indicates
-//
-void MHDisp::SetSelectedPos(Int_t iflag)
-{ 
-    fSelectedPos = iflag; 
-}    
-
-
-// --------------------------------------------------------------------------
-//
-// Sets the Matrix and the array of mapped values for each Matrix column
-//
-void MHDisp::SetMatrixMap(MHMatrix *matrix, TArrayI &map)
-{
-    fMatrix = matrix;
-    fMap = map;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Returns the Matrix and the mapped value for each Matrix column
-//
-void MHDisp::GetMatrixMap(MHMatrix* &matrix, TArrayI &map)
-{
-    map = fMap;
-    matrix = fMatrix;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// You can use this function if you want to use a MHMatrix instead of the
-// given containers for the Disp optimization. This function adds all 
-// necessary columns to the given matrix. Afterwards, you should fill 
-// the matrix with the corresponding data (eg from a file by using 
-// MHMatrix::Fill). Then, if you loop through the matrix (eg using 
-// MMatrixLoop), MHDisp::Fill will take the values from the matrix 
-// instead of the containers.
-//
-void MHDisp::InitMapping(MHMatrix *mat)
-{
-    if (fMatrix)
-      return;
-
-    fMatrix = mat;
-
-    fMap[kX]          = fMatrix->AddColumn("MSrcPosCam.fX");
-    fMap[kY]          = fMatrix->AddColumn("MSrcPosCam.fY");
-    fMap[kMeanX]      = fMatrix->AddColumn("MHillas.fMeanX");
-    fMap[kMeanY]      = fMatrix->AddColumn("MHillas.fMeanY");
-    fMap[kDelta]      = fMatrix->AddColumn("MHillas.fDelta");
-
-    fMap[kSize]       = fMatrix->AddColumn("MHillas.fSize");
-    
-    fMap[kM3Long]     = fMatrix->AddColumn("MHillasExt.fM3Long");
-    fMap[kAsym]       = fMatrix->AddColumn("MHillasExt.fAsym");
-    
-    fMap[kEnergy]     = fMatrix->AddColumn("MMcEvt.fEnergy");
-    fMap[kImpact]     = fMatrix->AddColumn("MMcEvt.fImpact");
-    fMap[kLongitmax]  = fMatrix->AddColumn("MMcEvt.fLongitmax");
-    
-    fMap[kZd]         = fMatrix->AddColumn("MPointingPos.fZd");
-    fMap[kAz]         = fMatrix->AddColumn("MPointingPos.fAz");
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Returns a mapped value from the Matrix
-//
-Double_t MHDisp::GetVal(Int_t i) const
-{
-    Double_t val = (*fMatrix)[fMap[i]];
-
-    //*fLog << "MHDisp::GetVal; i, fMatrix, fMap, val = "
-    //    << i << ",  " << fMatrix << ",  " << fMap[i] << ",  " << val << endl;
-
-    return val;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Fill the histograms and sum up the Minimization paramter outcome 
-// of each processed event
-//
-Bool_t MHDisp::Fill(const MParContainer *par, const Stat_t w)
-{
-    Double_t energy = 0.;
-    Double_t impact = 0.;
-    Double_t xmax = 0.;
-
-    if ( fMatrix || (!fMatrix && fMcEvt) )
-    {  
-      energy   = fMatrix ? GetVal(kEnergy)     : fMcEvt->GetEnergy();
-      impact   = fMatrix ? GetVal(kImpact)     : fMcEvt->GetImpact();
-      xmax     = fMatrix ? GetVal(kLongitmax)  : fMcEvt->GetLongitmax();      
-    }
-
-    Double_t theta      = fMatrix ? GetVal(kZd)  : fPointing->GetZd();
-    //    Double_t phi        = fMatrix ? GetVal(kAz)  : fPointing->GetAz();
-
-    Double_t xsrcpos0   = fMatrix ? GetVal(kX)       : fSrcPos->GetX();
-    Double_t ysrcpos0   = fMatrix ? GetVal(kY)       : fSrcPos->GetY();
-    Double_t xmean0     = fMatrix ? GetVal(kMeanX)   : fHil->GetMeanX();  
-    Double_t ymean0     = fMatrix ? GetVal(kMeanY)   : fHil->GetMeanY();
-    Double_t delta      = fMatrix ? GetVal(kDelta)   : fHil->GetDelta();
-    
-    Double_t size       = fMatrix ? GetVal(kSize)    : fHil->GetSize();
-    
-    Double_t m3long     = fMatrix ? GetVal(kM3Long)  : fHilExt->GetM3Long();
-    Double_t asym       = fMatrix ? GetVal(kAsym)    : fHilExt->GetAsym();
-
-    //------------------------------------------
-    // convert to deg
-    Double_t xsrcpos  = xsrcpos0 * fMm2Deg;
-    Double_t ysrcpos  = ysrcpos0 * fMm2Deg;
-    Double_t xmean    = xmean0 * fMm2Deg;
-    Double_t ymean    = ymean0 * fMm2Deg;
-    
-    // calculate cosinus of the angle between d and a vectors
-    Double_t a = (xmean-xsrcpos)*cos(delta) + (ymean-ysrcpos)*sin(delta);
-    Double_t b = sqrt( (xmean-xsrcpos)*(xmean-xsrcpos) + (ymean-ysrcpos)*(ymean-ysrcpos) );
-    Double_t cosda = a/b;
-    
-    // sign of cosda
-    Int_t s0 = cosda>0 ? 1 : -1;   
-    
-    // get the sign of M3Long and Asym variables
-    Int_t sm3 = m3long>0 ? 1 : -1;
-    Int_t sa  =   asym>0 ? 1 : -1;
-    
-    // set the sign "s" that will select one Disp source position for each
-    // shower, according to each of the possible algorithms for solution selection:
-    //   SelectedPos = 1  means choose the right source position
-    //                 2                   wrong
-    //                 3               the position according to M3Long
-    //                 4               the position according to Asym
-    Int_t s = s0;
-    if (fSelectedPos == 1)    
-      s = s0;  
-    else if (fSelectedPos == 2)
-      s = -s0;
-    else if (fSelectedPos == 3)
-      s = sm3;
-    else if (fSelectedPos == 4)
-      s = sa;
-    else
-      *fLog << "Illegal value for Disp srcpos selection algorithm: " 
-	    << " fSelectedPos = " << fSelectedPos << endl;
-    
-    // count the number of events where source position has been correctly assigned
-    if (s == s0)
-      fEvCorrAssign->Fill(log10(size), 1.);
-    else
-      fEvCorrAssign->Fill(log10(size), 0.);
-    
-    // get estimated Disp value
-    Double_t disp = fImageParDisp->GetDisp();
-    
-    //------------------------------------------
-    // Disp estimated source position
-    Double_t xdisp = xmean - s*cos(delta)*disp;
-    Double_t ydisp = ymean - s*sin(delta)*disp;
-    fSkymapXY->Fill(xdisp,ydisp);
-    
-    // Distance between estimated Disp and real source position
-    Double_t d2 = (xdisp-xsrcpos)*(xdisp-xsrcpos) +  (ydisp-ysrcpos)*(ydisp-ysrcpos); 
-    fHistMinPar->Fill(d2);
-    
-    // Longitudinal and transversal distances between Disp and real source positon
-    Double_t Du = -s*( (xdisp-xsrcpos)*cos(delta) + (ydisp-ysrcpos)*sin(delta));
-    Double_t Dv = -s*(-(xdisp-xsrcpos)*sin(delta) + (ydisp-ysrcpos)*cos(delta));
-    fHistDuDv->Fill(Dv,Du);
-    
-    // Fill Energy, Size and ZA distributions
-    if (fMatrix || (!fMatrix && fMcEvt))
-      fHistEnergy->Fill(log10(energy));
-    fHistSize->Fill(log10(size));
-    fHistcosZA->Fill(cos(theta/kRad2Deg));
-    
-    // to check the size and energy dependence of the optimization
-    if (fMatrix || (!fMatrix && fMcEvt))
-    {
-      fHistMinParEnergy->Fill(log10(energy),d2);
-      fHistDuEnergy->Fill(log10(energy),Du);
-      fHistDvEnergy->Fill(log10(energy),Dv);
-    }
-    fHistMinParSize->Fill(log10(size),d2);
-    fHistDuSize->Fill(log10(size),Du);
-    fHistDvSize->Fill(log10(size),Dv);
-    
-    // variables for the Minimization parameter calculation (= d^2)
-    fNumEv += 1;
-    fSumMinPar += d2;  
-    
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Calculates the final Minimization parameter of the Disp optimization
-//
-Bool_t MHDisp::Finalize()
-{
-    fMinPar->SetVal(fSumMinPar/fNumEv);
-    *fLog << endl;
-    *fLog << "MHDisp::Finalize: SumMinPar, NumEv = " << fSumMinPar << ", " << fNumEv << endl;
-    *fLog << "MHDisp::Finalize: Final MinPar = " << fMinPar->GetVal() << endl;
-    
-    fMinPar->SetVal(fHistMinPar->GetMean());
-    *fLog << "MHDisp::Finalize: Final MinPar = " << fMinPar->GetVal() << endl;
-
-    SetReadyToSave();
-
-    return kTRUE;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Creates a new canvas and draws the Disp related histograms into it.
-// Be careful: The histograms belongs to this object and won't get deleted
-// together with the canvas.
-//
-void MHDisp::Draw(Option_t *opt)
-{
-    gStyle->SetPalette(1);
-
-    TString title = GetName();
-    title += ": ";
-    title += GetTitle();
-
-    TCanvas *pad = new TCanvas(GetName(),title,0,0,900,1500);    
-    pad->SetBorderMode(0);
-    pad->Divide(3,5);
-
-    pad->cd(1);
-    gPad->SetBorderMode(0);
-    fHistcosZA->SetTitleOffset(1.2,"Y");
-    fHistcosZA->DrawClone(opt);
-    fHistcosZA->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(2);
-    gPad->SetBorderMode(0);
-    fHistEnergy->SetTitleOffset(1.2,"Y");
-    fHistEnergy->DrawClone(opt);
-    fHistEnergy->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(3);
-    gPad->SetBorderMode(0);
-    fHistSize->SetTitleOffset(1.2,"Y");
-    fHistSize->DrawClone(opt);
-    fHistSize->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(4);
-    gPad->SetBorderMode(0);
-    fHistMinPar->SetTitleOffset(1.2,"Y");
-    fHistMinPar->DrawClone(opt);
-    fHistMinPar->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profMinParEnergy = fHistMinParEnergy->ProfileX("Minimization parameter vs. Energy",0,99999,"s");
-    profMinParEnergy->SetXTitle("log10(Energy) [GeV]");
-    profMinParEnergy->SetYTitle("Minimization parameter = d^2 Disp to real srcpos [deg^2]");
-    pad->cd(5);
-    gPad->SetBorderMode(0);
-    profMinParEnergy->SetTitleOffset(1.2,"Y");
-    profMinParEnergy->SetStats(0);
-    profMinParEnergy->DrawClone(opt);
-    profMinParEnergy->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profMinParSize = fHistMinParSize->ProfileX("Minimization parameter vs. Size",0,99999,"s");
-    profMinParSize->SetXTitle("log10(Size) [#phot]");
-    profMinParSize->SetYTitle("Minimization parameter = d^2 Disp to real srcpos [deg^2]");
-    pad->cd(6);
-    gPad->SetBorderMode(0);
-    profMinParSize->SetTitleOffset(1.2,"Y");
-    profMinParSize->SetStats(0);
-    profMinParSize->DrawClone(opt);
-    profMinParSize->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(7);
-    gPad->SetBorderMode(0);
-    fSkymapXY->SetTitleOffset(1.2,"Y");
-    fSkymapXY->DrawClone("COLZ");
-    fSkymapXY->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(8);
-    gPad->SetBorderMode(0);
-    fEvCorrAssign->SetTitleOffset(1.2,"Y");
-    fEvCorrAssign->DrawClone(opt);
-    fEvCorrAssign->SetBit(kCanDelete);
-    gPad->Modified();
-
-    pad->cd(9);
-    gPad->SetBorderMode(0);
-    fHistDuDv->SetTitleOffset(1.2,"Y");
-    fHistDuDv->DrawClone("COLZ");
-    fHistDuDv->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TH1F *histDu = (TH1F*)fHistDuDv->ProjectionY("histDu");
-    histDu->SetTitle("Longitudinal distance Du");
-    histDu->SetXTitle("Du = longitudinal distance [deg]");
-    pad->cd(10);
-    gPad->SetBorderMode(0);
-    histDu->SetTitleOffset(1.2,"Y");
-    histDu->DrawClone(opt);
-    histDu->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profDuEnergy = fHistDuEnergy->ProfileX("Du vs. Energy",0,99999,"s");
-    profDuEnergy->SetXTitle("log10(Energy) [GeV]");
-    profDuEnergy->SetYTitle("Du = longitudinal distance [deg]");
-    pad->cd(11);
-    gPad->SetBorderMode(0);
-    profDuEnergy->SetTitleOffset(1.2,"Y");
-    profDuEnergy->SetStats(0);
-    profDuEnergy->DrawClone(opt);
-    profDuEnergy->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profDuSize = fHistDuSize->ProfileX("Du vs. Size",0,99999,"s");
-    profDuSize->SetXTitle("log10(Size) [#phot]");
-    profDuSize->SetYTitle("Du = longitudinal distance [deg]");
-    pad->cd(12);
-    gPad->SetBorderMode(0);
-    profDuSize->SetTitleOffset(1.2,"Y");
-    profDuSize->SetStats(0);
-    profDuSize->DrawClone(opt);
-    profDuSize->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TH1F *histDv = (TH1F*)fHistDuDv->ProjectionX("histDv");
-    histDv->SetTitle("Transversal distance Dv");
-    histDv->SetXTitle("Dv = transversal distance [deg]");
-    pad->cd(13);
-    gPad->SetBorderMode(0);
-    histDv->SetTitleOffset(1.2,"Y");
-    histDv->DrawClone(opt);
-    histDv->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profDvEnergy = fHistDvEnergy->ProfileX("Dv vs. Energy",0,99999,"s");
-    profDvEnergy->SetXTitle("log10(Energy) [GeV]");
-    profDvEnergy->SetYTitle("Dv = transversal distance [deg]");
-    pad->cd(14);
-    gPad->SetBorderMode(0);
-    profDvEnergy->SetTitleOffset(1.2,"Y");
-    profDvEnergy->SetStats(0);
-    profDvEnergy->DrawClone(opt);
-    profDvEnergy->SetBit(kCanDelete);
-    gPad->Modified();
-
-    TProfile *profDvSize = fHistDvSize->ProfileX("Dv vs. Size",0,99999,"s");
-    profDvSize->SetXTitle("log10(Size) [#phot]");
-    profDvSize->SetYTitle("Dv = transversal distance [deg]");
-    pad->cd(15);
-    gPad->SetBorderMode(0);
-    profDvSize->SetTitleOffset(1.2,"Y");
-    profDvSize->SetStats(0);
-    profDvSize->DrawClone(opt);
-    profDvSize->SetBit(kCanDelete);
-    gPad->Modified();
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MHDisp.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MHDisp.h	(revision 7136)
+++ 	(revision )
@@ -1,111 +1,0 @@
-#ifndef MARS_MHDisp
-#define MARS_MHDisp
-
-#ifndef MARS_MH
-#include "MH.h"
-#endif
-
-#ifndef ROOT_TArrayI
-#include <TArrayI.h>
-#endif
-
-class TH1F;
-class TH2F;
-class TProfile;
-class MImageParDisp;
-class MSrcPosCam;
-class MHillas;
-class MHillasExt;
-class MNewImagePar;
-class MMcEvt;
-class MPointingPos;
-class MHMatrix;
-class MParameterD;
-
-class MHDisp : public MH
-{
-private:
-
-    MImageParDisp *fImageParDisp;  // container with the estimated Disp
-    MSrcPosCam    *fSrcPos;
-    MHillas       *fHil;
-    MHillasExt    *fHilExt;
-    MNewImagePar  *fNewPar;
-    MMcEvt        *fMcEvt;
-    MPointingPos  *fPointing;
-
-    TString fImageParDispName;
-
-    Int_t fSelectedPos;      // flag to select which of the two Disp source position
-                             // solutions we want to fill the histograms (see Set function)
-
-    TH1F *fHistEnergy;       // Energy distribution of events
-    TH1F *fHistSize;         // Size distribution of events
-    TH1F *fHistcosZA;        // cosinus Zenith angle distribution of events
-    TH2F *fSkymapXY;         // 2D histogram for Disp estimated source positions
-    TH1F *fHistMinPar;       // Histogram of the event Minimization Parameter (= d^2 = 
-                             // = distance^2 between Disp estimated and true source position)
-    TH2F *fHistDuDv;         // Distribution of longitudinal (Du) and transversal 
-                             // (Dv) distances between Disp and true source position    
-    TH2F *fHistMinParEnergy; // Minimization Parameter (= d^2) vs. Energy
-    TH2F *fHistMinParSize;   // Minimization Parameter (= d^2) vs. Size
-    TH2F *fHistDuEnergy;     // Du vs. Energy
-    TH2F *fHistDuSize;       // Du vs. Size
-    TH2F *fHistDvEnergy;     // Dv vs. Energy
-    TH2F *fHistDvSize;       // Dv vs. Size
-    TProfile *fEvCorrAssign; // % events with source position well assign vs. Size 
-
-
-    Double_t fMm2Deg;        // conversion factor from mm to deg
-
-    MHMatrix *fMatrix;       // matrix storing variables needed for the Disp optimization
-    TArrayI fMap;            // array storing the matrix mapping column numbers corresponding
-                             // to each variable added to fMatrix
-
-    Double_t GetVal(Int_t i) const;
-
-    Int_t fNumEv;            // total number of events
-    Double_t fSumMinPar;     // current sum of the minimization parameter   
-    MParameterD *fMinPar;    // final minimization parameters of the Disp optimization
-
-public:
-
-    MHDisp(const char *imagepardispname = "MImageParDisp",
-	   const char *name=NULL, const char *title=NULL);
-    ~MHDisp();
-
-    Bool_t SetupFill(const MParList *plist);
-    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
-    Bool_t Finalize();  
-
-    void SetSelectedPos(Int_t iflag);
-
-    void SetMatrixMap(MHMatrix *matrix, TArrayI &map);    
-    void GetMatrixMap(MHMatrix* &matrix, TArrayI &map);  // get matrix and its mapping array
-
-    void InitMapping(MHMatrix *mat);       // define the matrix of variables
-                                           // needed for the Disp optimization
-
-    TH1F *GetHistEnergy()       { return fHistEnergy; } 
-    TH1F *GetHistSize()         { return fHistSize; } 
-    TH1F *GetHistcosZA()        { return fHistcosZA; } 
-    TH2F *GetSkymapXY()         { return fSkymapXY; }
-    TH1F *GetHistMinPar()       { return fHistMinPar; }
-    TH2F *GetHistDuDv()         { return fHistDuDv; }
-    TH2F *GetHistMinParEnergy() { return fHistMinParEnergy; }
-    TH2F *GetHistMinParSize()   { return fHistMinParSize; }
-    TH2F *GetHistDuEnergy()     { return fHistDuEnergy; }
-    TH2F *GetHistDuSize()       { return fHistDuSize; }
-    TH2F *GetHistDvEnergy()     { return fHistDvEnergy; }
-    TH2F *GetHistDvSize()       { return fHistDvSize; }
-    TProfile *GetEvCorrAssign() { return fEvCorrAssign; }
-
-    void Draw(Option_t *opt="");
-
-    ClassDef(MHDisp, 1) // Container holding the Histograms for Disp and
-                        // the parameter to minimize in the Disp optimization
-};
-
-#endif
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MImageParDisp.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MImageParDisp.cc	(revision 7136)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Eva Domingo    , 12/2004 <mailto:domingo@ifae.es>
-!              Wolfgang Wittek, 12/2004 <mailto:wittek@mppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2005
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MImageParDisp
-//
-// Storage Container for estimated distance to source position (Disp)
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MImageParDisp.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-
-ClassImp(MImageParDisp);
-
-using namespace std;
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MImageParDisp::MImageParDisp(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MImageParDisp";
-    fTitle = title ? title : "Estimated distance to source position (Disp)";
-
-    Reset();
-}
-
-// --------------------------------------------------------------------------
-//
-void MImageParDisp::Reset()
-{
-    fDisp = -1;
-}
-
-// --------------------------------------------------------------------------
-//
-void MImageParDisp::Print(Option_t *) const
-{
-    *fLog << all;
-    *fLog << "Estimated distance to source position (" << GetName() << ")" << endl;
-    *fLog << " - Disp [deg] = " << fDisp << endl;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MImageParDisp.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MImageParDisp.h	(revision 7136)
+++ 	(revision )
@@ -1,30 +1,0 @@
-#ifndef MARS_MImageParDisp
-#define MARS_MImageParDisp
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-class MImageParDisp : public MParContainer
-{
-private:
-
-    Float_t fDisp;     // [deg] distance between the image center
-                       //       and the estimated source position,
-                       //       along the major axis of the image
-
-public:
-
-    MImageParDisp(const char *name=NULL, const char *title=NULL);
-
-    void Reset();
-
-    void SetDisp(Float_t disp)  { fDisp = disp; }
-    Float_t GetDisp() const     { return fDisp; }
-
-    void Print(Option_t *opt=NULL) const;
-
-    ClassDef(MImageParDisp, 1) // Container to hold estimated distance to source position (Disp)
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTime.cc	(revision 7136)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López , 7/2004 <mailto:jlopez@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-#include "MLiveTime.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MLiveTime);
-
-using namespace std;
-
-MLiveTime::MLiveTime(UInt_t numberbins, const char *name, const char *title)
-{
-
-    fName  = name  ? name  : "MLiveTime";
-    fTitle = title ? title : "Container to hold the live time for a certain time bin";
-    
-    Set(numberbins);
-}
-
-void MLiveTime::Set(UInt_t numberbins)
-{
-  fNumberTimeBins = numberbins;
-  fLiveTimeBin.Set(numberbins);
-  fMeanRealTimeBin.Set(numberbins);
-  fWidthRealTimeBin.Set(numberbins);
-}
-
-void MLiveTime::Print(const Option_t* o) const
-{
-    TString opt = o;
-
-    Double_t totalLiveTime = 0;
-
-    if (opt.Contains("last", TString::kIgnoreCase))
-    {
-	*fLog << GetName() << ": Present real time bin " << setprecision(10) << fMeanRealTimeBin[fNumberTimeBins-1] << " +- " << setprecision(5) << fWidthRealTimeBin[fNumberTimeBins-1] << " [" <<  2*fWidthRealTimeBin[fNumberTimeBins-1]*24*60*60 << " sec] MJD" << endl;
-	*fLog << GetName() << ": Present live time " << fLiveTimeBin[fNumberTimeBins-1] << " sec" << endl;
-    }
-    else if (opt.Contains("all", TString::kIgnoreCase))
-    {
-	*fLog << GetName() << ": " << fNumberTimeBins << " time bins" << endl;
-	for (UInt_t bin = 0; bin<fNumberTimeBins; bin++)
-	{
-	    *fLog << GetName() << ": Present real time bin " << setprecision(10) << fMeanRealTimeBin[bin] << " +- " << setprecision(5) <<  fWidthRealTimeBin[bin] << " [" <<  2*fWidthRealTimeBin[bin]*24*60*60 << " sec] MJD" << endl;
-	    *fLog << GetName() << ": Present live time " << fLiveTimeBin[bin] << " sec" << endl;
-	    totalLiveTime += fLiveTimeBin[bin];
-	}		
-	*fLog << GetName() << ": Total live time " << totalLiveTime << " sec" << endl;
-    }
-    else
-	*fLog << GetName() << warn << "::Print() Bad argument " << opt << endl; 
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTime.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTime.h	(revision 7136)
+++ 	(revision )
@@ -1,51 +1,0 @@
-#ifndef MARS_MLiveTime
-#define MARS_MLiveTime
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef ROOT_TArrayD
-#include <TArrayD.h>
-#endif
-
-class MLiveTime : public MParContainer
-{
- private:
-  
-  UInt_t fNumberTimeBins;
-  TArrayD fLiveTimeBin;
-  TArrayD fMeanRealTimeBin;
-  TArrayD fWidthRealTimeBin;
-  
-  void Set(UInt_t numberbins);
-
- public:
-
-  MLiveTime(UInt_t numberbins = 1, const char *name=NULL, const char *title=NULL);
-  //~MLiveTime;
-
-  void AddBin() { Set(fNumberTimeBins+1); }
-  void AddTime(Double_t time) { fLiveTimeBin[fNumberTimeBins-1]+=time; }
-  void SetRealTime (Double_t mean, Double_t width)
-      {
-	  fMeanRealTimeBin[fNumberTimeBins-1]=mean;
-	  fWidthRealTimeBin[fNumberTimeBins-1]=width;
-      }
-
-  UInt_t GetNumberTimeBins() { return fNumberTimeBins;}
-  Double_t GetLiveTime() { return fLiveTimeBin[fNumberTimeBins-1]; }
-  Double_t GetMeanRealTime() { return fMeanRealTimeBin[fNumberTimeBins-1]; }
-  Double_t GetWidthRealTime() { return fWidthRealTimeBin[fNumberTimeBins-1]; }
-
-  TArrayD& GetLiveTimeTArray()      { return fLiveTimeBin; }
-  TArrayD& GetMeanRealTimeTArray()  { return fMeanRealTimeBin; }
-  TArrayD& GetWidthRealTimeTArray() { return fWidthRealTimeBin; }
-
-  void Print(const Option_t*) const;
-
- ClassDef(MLiveTime, 1)    // Storage for the live time extracted from real data
-
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTimeCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTimeCalc.cc	(revision 7136)
+++ 	(revision )
@@ -1,360 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López , 7/2004 <mailto:jlopez@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  MLiveTimeCalc
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MLiveTimeCalc.h"
-
-#include "MRawRunHeader.h"
-#include "MRawEvtHeader.h"
-#include "MLiveTime.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-#include "MTaskList.h"
-
-ClassImp(MLiveTimeCalc)
-using namespace std;
-
-Bool_t Debug = kFALSE;
-Bool_t PrintNewRun = kTRUE;
-
-MLiveTimeCalc::MLiveTimeCalc(const char *name, const char *title) : kSecTomSec(1e3), kDayToSec(24.*60.*60.), fRunHeader(NULL), fEvtHeader(NULL), fPresentEventTime(NULL), fLiveTime(NULL)
-{
-
-  fName  = name  ? name  : "MLiveTimeCalc";
-  fTitle = title ? title : "Task to compute the live time from real data.";
-
-  for (Int_t i=0; i<10; i++)
-    fNumberLostEvents[i] = 0;
-  
-  fFirstEventMjd = 0.;
-  fPresentEventMjd = 0.;
-  fLastEventMjd = 0.;
-
-  fPresentEventNumber = 0;
-  fLastEventNumber = 0;
-
-  fPresentEventRunNumber = 0;
-  fLastEventRunNumber = 0;
-
-  fRealTimeBinSize = 0.;
-
-  fPrintNextEvent = kFALSE;
-}
-
-Int_t MLiveTimeCalc::PreProcess(MParList *pList)
-{
-  
-  fEvtHeader = (MRawEvtHeader*)pList->FindObject(AddSerialNumber("MRawEvtHeader"));
-  if (!fEvtHeader)
-    {
-      *fLog << err << AddSerialNumber("MRawEvtHeader") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-  
-  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
-  if (!fRunHeader)
-    {
-      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-  
-  fPresentEventTime = (MTime*)pList->FindObject(AddSerialNumber("MTime"));
-  if (!fPresentEventTime)
-    {
-      *fLog << err << AddSerialNumber("MTime") << " not found ... aborting" << endl;
-      return kFALSE;
-    }
-  
-  
-  fLiveTime = (MLiveTime*)pList->FindCreateObj(AddSerialNumber("MLiveTime"));
-  if (!fLiveTime)
-    {
-      *fLog << err << AddSerialNumber("MLiveTime") << " cannot be created ... aborting" << endl;
-      return kFALSE;
-    }
-  
-  return kTRUE;
-}
-
-Int_t MLiveTimeCalc::Process()
-{
-
-  fPresentEventMjd       = fPresentEventTime->GetMjd(); 
-  fLastEventMjd          = fLastEventTime.GetMjd();
-  fPreaviusLastEventMjd  = fPreaviusLastEventTime.GetMjd();
-
-  fPresentEventNumber    = fEvtHeader->GetDAQEvtNumber();
-  fPresentEventRunNumber = fRunHeader->GetRunNumber();;
-  
-  if (fPrintNextEvent && Debug)
-  {
-      *fLog << dbg << GetName() << ": Printing next event" << endl;
-      Print("all");
-      fLiveTime->Print("last");
-      *fLog << inf << endl; 
-      fPrintNextEvent = kFALSE;
-  }
-	  
-  if (fFirstEventMjd == 0)
-  {
-      fFirstEventMjd = fPresentEventMjd;
-
-      fPreaviusLastEventTime = fLastEventTime;
-      fLastEventTime = *fPresentEventTime;
-
-      fPreaviusLastEventRunNumber = fLastEventRunNumber;
-      fLastEventRunNumber = fPresentEventRunNumber;
-
-      fPreaviusLastEventNumber = fLastEventNumber;
-      fLastEventNumber = fPresentEventNumber;
-  }
-  else
-  {
-      if (isTimeStampOk())
-      {
-	  if (fRealTimeBinSize > 0 &&
-	      (fPresentEventMjd - fFirstEventMjd)*kDayToSec > fRealTimeBinSize)
-	  {
-
-	      Double_t width = (fLastEventMjd - fFirstEventMjd)/2;
-	      Double_t mean  = fFirstEventMjd + width;
-	      
-	      fLiveTime->SetRealTime(mean,width);
-	      
-	      if (Debug)
-		{
-		  *fLog << inf << GetName() << ": New time bin" << endl;
-		  Print("all");
-		  *fLog << GetName() << ": First event time " << setprecision(10) << fFirstEventMjd << setprecision(5) << endl;
-		  fLiveTime->Print("last");
-		}
-	      
-	      fLiveTime->AddBin();
-	      fFirstEventMjd = fPresentEventMjd;
-	  }      
-
-	  if (fPresentEventRunNumber!=fLastEventRunNumber)
-	  {
-	      if (fLastEventRunNumber != 0 && PrintNewRun)
-	      {
-		  *fLog << dbg << GetName() << ": New run" << endl;
-		  Print("all");
-		  fLiveTime->Print("last");
-		  *fLog << inf << endl;
-	      }
-	      fLastEventRunNumber = fPresentEventRunNumber;
-	  }
-	  else
-	      fLiveTime->AddTime((fPresentEventMjd-fLastEventMjd)*kDayToSec);
-	  
-
-      
-      fPreaviusLastEventTime = fLastEventTime;
-      fLastEventTime = *fPresentEventTime;
-
-      fPreaviusLastEventRunNumber = fLastEventRunNumber;
-      fLastEventRunNumber = fPresentEventRunNumber;
-
-      fPreaviusLastEventNumber = fLastEventNumber;      
-      fLastEventNumber = fPresentEventNumber;
-
-      }
-  }
-
-  return kTRUE;
-}
-  
-Int_t MLiveTimeCalc::PostProcess()
-{
-  Double_t width = (fLastEventMjd - fFirstEventMjd)/2;
-  Double_t mean  = fFirstEventMjd + width;
- 
-  fLiveTime->SetRealTime(mean,width);
-
-  *fLog << dbg << endl;
-  *fLog << dbg << GetName() << ": PostProcess" << endl;
-  fLiveTime->Print("all");
-  *fLog << inf << endl;
-
-  *fLog << GetName() << " execution statistics:" << endl;
-  *fLog << dec << setfill(' ');
-
-  ULong_t fTotalNumberLostEvents = 0;
-  for (Int_t i=0; i<6; i++)
-    fTotalNumberLostEvents += fNumberLostEvents[i];
-
-  *fLog << " " << setw(7) << fTotalNumberLostEvents << " (" << setw(3) ;
-  *fLog << (Int_t)(fTotalNumberLostEvents*100/GetNumExecutions()) ;
-  *fLog << "%) bad time stamp events" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[0]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) time stamp == 0" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[1]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) last time stamp  == 0" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[2]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) time stamp in the past" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[3]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) time stamp == last one" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[4]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) time stamp just with integer part" << endl;
-
-  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[5]*100/fTotalNumberLostEvents) ;
-  *fLog << "%) run number < last one" << endl;
-
-  return kTRUE;
-}
-
-Bool_t MLiveTimeCalc::isTimeStampOk()
-{
-
-  Bool_t result = kTRUE;
-  
-
-  if (fPresentEventMjd == 0)
-    {
-	
-      if (Debug)
-	{
-	    *fLog << err << GetName() << ": Present event time stamp equal to 0" << endl;
-	    Print("all");
-	}
-
-      fNumberLostEvents[0]++;
-      result = kFALSE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if (fLastEventMjd == 0)
-    {
-	
-      if (Debug)
-	{
-	    *fLog << err << GetName() << ": Last event time stamp equal to 0" << endl;
-	    Print("all");
-	}
-
-      fNumberLostEvents[1]++;
-      result = kFALSE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if (fPresentEventMjd-fLastEventMjd < 0)
-    {
-      
-      if (Debug)
-	{
-	    *fLog << err << GetName() << ": Present event with time stamp in the past" << endl;
-	    Print("all");
-	}
-	  
-      fNumberLostEvents[2]++;
-      result = kFALSE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if (fPresentEventMjd-fLastEventMjd == 0)
-    {
-      
-      if (Debug)
-	{
-	    *fLog << err << GetName() << ": Present event time stamp equal than last event" << endl;
-	    Print("all");
-	}
-      
-      fNumberLostEvents[3]++;
-      result = kFALSE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if (fPresentEventNumber- fLastEventNumber<= 0 && fPresentEventRunNumber == fLastEventRunNumber)
-    {
-      
-      if (Debug)
-	{
-	    *fLog << warn << GetName() << ": Present event number equal or smaller than last event" << endl;
-	  Print("all");
-	}
-
-      result = kTRUE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if ((Int_t)fPresentEventMjd == fPresentEventMjd)
-    {
-      
-      if (Debug)
-	{
-	    *fLog << err << GetName() << ": Present event time stamp idetical to midnight" << endl;
-	    Print("all");
-	}
-      
-      fNumberLostEvents[4]++;
-      result = kFALSE;
-      fPrintNextEvent = kTRUE;
-    }
-  else if  ((fPresentEventMjd-fLastEventMjd)*kDayToSec > 1.)
-  {
-      
-      if (Debug)
-      {
-	  *fLog << warn << GetName() << ": Time from last event bigger than 1 sec" << endl;
-	  Print("all");
-      }
-      
-      result = kTRUE;
-      fPrintNextEvent = kTRUE;
-  }
-  else if  (fPresentEventRunNumber-fLastEventRunNumber < 0)
-  {
-      
-      if (Debug)
-      {
-	  *fLog << warn << GetName() << ": Present run number previuos than last one" << endl;
-	  Print("all");
-      }
-      
-      fNumberLostEvents[5]++;
-      result = kTRUE;
-      fPrintNextEvent = kTRUE;
-  }
-
-  return result;
-}
-
-void MLiveTimeCalc::Print(const Option_t *o) const
-{
-
-  *fLog << "Present event run number       ["  << fPresentEventRunNumber << "] event number [" << fPresentEventNumber << ']' << endl;
-  *fLog << "Last event run number          ["  << fLastEventRunNumber << "] event number [" << fLastEventNumber << ']' << endl;
-  *fLog << "Preavius last event run number ["  << fPreaviusLastEventRunNumber << "] event number [" << fPreaviusLastEventNumber << ']' << endl;
-  *fLog << "Present, last and preavius to last event times:"  << endl;
-  fPresentEventTime->Print();
-  fLastEventTime.Print();
-  fPreaviusLastEventTime.Print();
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTimeCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MLiveTimeCalc.h	(revision 7136)
+++ 	(revision )
@@ -1,71 +1,0 @@
-#ifndef MARS_MLiveTimeCalc
-#define MARS_MLiveTimeCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-#ifndef MARS_MTime
-#include "MTime.h"
-#endif
-
-class MRawRunHeader;
-class MRawEvtHeader;
-class MLiveTime;
-
-class MLiveTimeCalc : public MTask
-{
- public:
-  
-  const Double_t kSecTomSec;
-  const Double_t kDayToSec;
-  
- private:
-  
-  MRawRunHeader* fRunHeader;
-  MRawEvtHeader* fEvtHeader;
-
-  MTime*         fPresentEventTime;
-  MTime          fLastEventTime;
-  MTime          fPreaviusLastEventTime;
-
-  MLiveTime*     fLiveTime;
-
-  
-  UInt_t   fNumberLostEvents[10];
-
-  Double_t fFirstEventMjd;
-  Double_t fPresentEventMjd;
-  Double_t fLastEventMjd;
-  Double_t fPreaviusLastEventMjd;
-
-  Int_t    fPresentEventNumber;
-  Int_t    fLastEventNumber;
-  Double_t fPreaviusLastEventNumber;
-
-  Int_t    fPresentEventRunNumber;
-  Int_t    fLastEventRunNumber;
-  Double_t fPreaviusLastEventRunNumber;
-
-  Double_t fRealTimeBinSize;
-  
-  Bool_t fPrintNextEvent;
-
- public:
-
-  MLiveTimeCalc(const char *name=NULL, const char *title=NULL);
-  //~MLiveTimeCalc;
-
-  Int_t PreProcess(MParList *pList);
-  Int_t Process();
-  Int_t PostProcess();
-
-  void SetRealTimeBinSize(Double_t time) { fRealTimeBinSize=time; }
-
-  Bool_t isTimeStampOk();
-  void Print(const Option_t *o) const;
-
- ClassDef(MLiveTimeCalc, 0)    // Task to compute the live time from real data
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MTopologyCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MTopologyCalc.cc	(revision 7136)
+++ 	(revision )
@@ -1,133 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Josep Flix   09/2004 <mailto:jflix@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2004
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MTopologyCalc
-//
-// Taks that evaluates the Topological Parameters of images after image cleaning
-//
-// fDistance = SUM_(i,j) D_ij , where i,j<UsedPixels and d_ij are distances
-//                              between pixels. This characterizes topology.
-//
-// fUsed = Used Pixels after image cleaning.
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#include "MTopologyCalc.h"
-
-#include "MParList.h"
-
-#include "MTopology.h"
-
-#include "MCerPhotEvt.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-ClassImp(MTopologyCalc);
-
-using namespace std;
-
-static const TString gsDefName  = "MTopologyCalc";
-static const TString gsDefTitle = "Calculate Topology related parameters";
-
-// -------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MTopologyCalc::MTopologyCalc(const char *name, const char *title)
-    : fTopology(NULL)
-{
-    fName  = name  ? name  : gsDefName.Data();
-    fTitle = title ? title : gsDefTitle.Data();
-
-}
-
-// -------------------------------------------------------------------------
-//
-Int_t MTopologyCalc::PreProcess(MParList *pList)
-{
-
-    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
-    if (!fCerPhotEvt)
-    {
-        *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
-    if (!fGeomCam)
-    {
-        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
-        return kFALSE;
-    }
-
-    fTopology = (MTopology*)pList->FindCreateObj("MTopology");
-    if (!fTopology)
-        return kFALSE;
- 
-    return kTRUE;
-
-}
-
-// -------------------------------------------------------------------------
-//
-Int_t MTopologyCalc::Process()
-{
-
-    Int_t rc = fTopology->Calc(*fGeomCam, *fCerPhotEvt);
-    
-    if (rc == 1)
-	fErrors++;
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-//  Prints some statistics about the Topology calculation. The percentage
-//  is calculated with respect to the number of executions of this task.
-//
-Int_t MTopologyCalc::PostProcess()
-{
-    if (GetNumExecutions()==0)
-        return kTRUE;
-
-    *fLog << inf << endl;
-    *fLog << GetDescriptor() << " execution statistics:" << endl;
-    *fLog << dec << setfill(' ');
-    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) 
-	  << "%) Evts skipped due to UsedPixels == -1" << endl;
-    *fLog << endl;
-
-    /*
-    delete fHillas;
-    delete fHillasSrc;
-    delete fSrcPos;
-    delete fTopology;
-    */
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MTopologyCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MTopologyCalc.h	(revision 7136)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#ifndef MARS_MTopologyCalc
-#define MARS_MTopologyCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-class MGeomCam;
-class MCerPhotEvt;
-class MTopology;
-
-class MTopologyCalc : public MTask
-{
-private:
-
-    const MGeomCam     *fGeomCam;
-    const MCerPhotEvt  *fCerPhotEvt;
-
-    MTopology      *fTopology;
-
-    Int_t       fErrors;
-   
-    Int_t PreProcess(MParList *plist);
-    Int_t Process();
-    Int_t PostProcess();
-
-public:
-
-    MTopologyCalc(const char *name=NULL, const char *title=NULL);
-    
-    ClassDef(MTopologyCalc, 0) // task to calculate....
-};
-
-#endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/DispSkymap.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/DispSkymap.C	(revision 7136)
+++ 	(revision )
@@ -1,223 +1,0 @@
-//************************************************************************
-//
-// Authors : Eva Domingo,     1/2005 <mailto:domingo@ifae.es>
-//
-//
-// Macro for generating DISP Skymap of the FoV
-// -------------------------------------------
-//
-//************************************************************************
-
-void DispSkymap(TString onfilename  = "ONhillasfile.root",
-		TString offfilename = "OFFhillasfile.root",
-		TString outfilename = "skymaps.root",
-		Float_t HadronnessCut = 0.06, 
-		Float_t SizeCut = 1000.)
-{
-  //======================================================================
-  // Make Disp plots
-  //======================================================================
-  
-  gLog << "-----------------------------------------------------" << endl; 
-  gLog << "Make Disp related plots" << endl;
-  gLog << "-----------------------------------------------------" << endl; 
-  
-  // Input root file/s storing the computed Hillas and Disp parameters
-  gLog << "Input ON file/s: "  <<  onfilename  << endl;
-  gLog << "Input OFF file/s: " <<  offfilename << endl;
-  
-
-  //----------------------------------------------------
-  MTaskList tliston;
-  MParList  pliston;
-
-  MTaskList tlistoff;
-  MParList  plistoff;
-  
-  // MReadMarsFile readon("Events", onfilename);
-  MReadTree readon("Parameters", onfilename);
-  readon.DisableAutoScheme();
-
-  // MReadMarsFile readoff("Events", offfilename);
-  MReadTree readoff("Parameters", offfilename);
-  readoff.DisableAutoScheme();
-  
-  MGeomCamMagic geomcam;
-
-  // set cuts to select an event sample to apply Disp
-  MFDisp *fdisp = NULL;
-  //      fdisp = new MFDisp;
-  //      fdisp->SetCuts(0,1,7,600,0,600,0.,3000000.,0.,0.,0.,0.,0.,0.);
-  //      MContinue contdisp(fdisp);
-
-  // Hadroness cut
-  TString hadrcut = "MHadronness.fHadronness<";
-  hadrcut += HadronnessCut;
-  gLog << "Hadronness Cut applied = " << hadrcut << endl;
-  MF hadrfilter(hadrcut);  
-  MContinue conthadr(&hadrfilter);
-  conthadr.SetInverted(kTRUE);
-
-  // Size cut
-  TString sizecut = "MHillas.fSize>";
-  sizecut += SizeCut;
-  gLog << "Size Cut applied = " << sizecut << endl;
-  MF sizefilter(sizecut);  
-  MContinue contsize(&sizefilter);
-  contsize.SetInverted(kTRUE);
-
-  // make Disp plots
-  // SelectedPos = 1  means choose the right source position
-  //               2                   wrong
-  //               3               the position according to M3Long
-  //               4               the position according to Asym
-  MHDisp hdispon;
-  hdispon.SetName("MHDispAsymOn");
-  hdispon.SetSelectedPos(4);
-  MFillH filldispon("MHDispAsymOn[MHDisp]", "");
-
-  MHDisp hdispoff;
-  hdispoff.SetName("MHDispAsymOff");
-  hdispoff.SetSelectedPos(4);
-  MFillH filldispoff("MHDispAsymOff[MHDisp]", "");
-  
-  
-  //*****************************
-  // entries in MParList On
-  pliston.AddToList(&tliston);
-  pliston.AddToList(&geomcam);
-  pliston.AddToList(&hdispon);
-
-  // entries in MParList Off
-  plistoff.AddToList(&tlistoff);
-  plistoff.AddToList(&geomcam);
-  plistoff.AddToList(&hdispoff);
-
-  
-  //*****************************
-  // entries in MTaskList On
-  tliston.AddToList(&readon);
-  if (fdisp != NULL)
-    tliston.AddToList(&contdisp);
-  tliston.AddToList(&conthadr);
-  tliston.AddToList(&contsize);
-  tliston.AddToList(&filldispon);
-
-  // entries in MTaskList Off
-  tlistoff.AddToList(&readoff);
-  if (fdisp != NULL)
-    tlist.AddToList(&contdisp);
-  tlistoff.AddToList(&conthadr);
-  tlistoff.AddToList(&contsize);
-  tlistoff.AddToList(&filldispoff);
-  
-  //*****************************
-  
-  //-------------------------------------------
-  // Execute event loop On
-  MProgressBar barOn;
-  MEvtLoop evtloopOn;
-  evtloopOn.SetParList(&pliston);
-  evtloopOn.SetProgressBar(&barOn);
-  
-  Int_t maxeventsOn = -1;
-  if ( !evtloopOn.Eventloop(maxeventsOn) )
-    return;
-  
-  tliston.PrintStatistics(0, kTRUE);
-
-  //-------------------------------------------
-  // Execute event loop Off
-  MProgressBar barOff;
-  MEvtLoop evtloopOff;
-  evtloopOff.SetParList(&plistoff);
-  evtloopOff.SetProgressBar(&barOff);
-  
-  Int_t maxeventsOff = -1;
-  if ( !evtloopOff.Eventloop(maxeventsOff) )
-    return;
-  
-  tlistoff.PrintStatistics(0, kTRUE);
-  
-
-  //-------------------------------------------
-  // Get the skymaps
-  TH2F *skymapOn  = hdispon.GetSkymapXY();
-  skymapOn->SetName("fSkymapXYOn");
-  skymapOn->SetTitle("ON DATA: Disp estimated source positions Skymap");
-  skymapOn->SetTitleOffset(1.2,"Y");
-  TH2F *skymapOff = hdispoff.GetSkymapXY();
-  skymapOff->SetName("fSkymapXYOff");
-  skymapOff->SetTitle("OFF DATA: Disp estimated source positions Skymap");
-  skymapOff->SetTitleOffset(1.2,"Y");
-
-  // Normalize to the number of events and subtract Off to On skymap
-  Double_t onentries  = skymapOn->GetEntries();
-  Double_t offentries = skymapOff->GetEntries();
-  Double_t norm = onentries/offentries;
-  cout << "Number of ON events after cuts = "  << onentries  << endl;
-  cout << "Number of OFF events after cuts = " << offentries << endl;
-  cout << "Normalization factor = " << norm << endl;
-
-  TH2F *skymap = new TH2F("fSkymapXY", 
-         "ON-OFF: Disp estimated source positions Skymap", 71, -2., 2., 71, -2., 2.);
-  skymap->Add(skymapOn,skymapOff,1.,-norm);
-  skymap->SetTitleOffset(1.2,"Y");
-  
-  //-------------------------------------------
-  // Display the skymaps
-  gLog << endl;
-  gLog << "Drawing DISP Skymaps for the FoV ...... "   << endl;
-  gLog << "(srcpos solution selected according Asym sign)" << endl; 
-
-  gStyle->SetPalette(1);
-  gStyle->SetOptStat(11);
-
-  TCanvas *c = new TCanvas("c","Disp Skymaps",0,0,900,900);    
-  c->SetBorderMode(0);
-  c->Divide(2,2);
-
-  c->cd(1);
-  gPad->SetBorderMode(0);
-  skymapOn->DrawClone("COLZ");
-  skymapOn->SetBit(kCanDelete);
-  gPad->Modified();
-
-  c->cd(2);
-  gPad->SetBorderMode(0);
-  skymapOff->DrawClone("COLZ");
-  skymapOff->SetBit(kCanDelete);
-  gPad->Modified();
-
-  c->cd(3);
-  gPad->SetBorderMode(0);
-  skymap->DrawClone("COLZ");
-  skymap->SetBit(kCanDelete);
-  gPad->Modified();
-
-  //-------------------------------------------
-  // Save the skymaps in a .root file
-  TFile outfile(outfilename,"RECREATE");
-  skymapOn->Write();
-  skymapOff->Write();
-  skymap->Write();
-  outfile.Close();
-  gLog << endl << "Skymaps stored in file: " << outfilename <<endl;
-
-  //-------------------------------------------
-  gLog << endl << "Disp plots were made for files: " << endl;
-  gLog << "ON data:  " << onfilename  << endl; 
-  gLog << "OFF data: " << offfilename << endl; 
-  gLog << "-----------------------------------------------------" << endl; 
-
-}
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha.C	(revision 7136)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/* ======================================================================== *\!
-!   Author(s): Oscar Blanch & Javier Rico
-\* ======================================================================== */
-
-void alpha(
-    Float_t cutsize=2000,
-    Float_t upcutsize=9999999,
-    Float_t lengthlowcut=0.,
-    Float_t lengthcut=0.26,
-    Float_t widthlowcut=0.,
-    Float_t widthcut=0.12
-)
-{    
-    // constants
-    const Int_t nbins = 9;
-    TString psname("alphaMrk.gif");
-    // general settings
-    gROOT->Reset();
-    gStyle->SetCanvasColor(0);
-    gStyle->SetCanvasBorderMode(0);
-    gStyle->SetPadBorderMode(0);
-    gStyle->SetFrameBorderMode(0);
-    gStyle->SetOptTitle(0);
-    gStyle->SetTitleOffset(1.7,"y");
-    gStyle->SetPadLeftMargin(0.15);
-    gStyle->SetOptStat(111110);
-    gStyle->SetStatColor(0);
-    gStyle->SetStatBorderSize(1);
-    gStyle->SetStatW(0.2);
-    gStyle->SetStatH(0.1);
-    gStyle->SetStatX(0.9);
-    gStyle->SetStatY(0.9);
-    
-    // define files, chain, trees, canvas...
-    TChain* ton= new TChain("Parameters");
-    
-    // ON data
-    ton->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root");
-
-    TChain* toff= new TChain("Parameters");
-
-    // OFF data
-    toff->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root");
-    
-    TCanvas *c1 = new TCanvas("c1","c1",800,500);
-    c1->cd(1);
-
-    // define aliases
-    ton->SetAlias("length","MHillas.fLength*0.6/189");
-    ton->SetAlias("width","MHillas.fWidth*0.6/189");
-    ton->SetAlias("dist","MHillasSrc.fDist*0.6/189");
-    ton->SetAlias("conc","MNewImagePar.fConc");
-    ton->SetAlias("size","MHillas.fSize");
-    ton->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
-    ton->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
-    ton->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
-    
-    toff->SetAlias("length","MHillas.fLength*0.6/189");
-    toff->SetAlias("width","MHillas.fWidth*0.6/189");
-    toff->SetAlias("dist","MHillasSrc.fDist*0.6/189");
-    toff->SetAlias("conc","MNewImagePar.fConc");
-    toff->SetAlias("size","MHillas.fSize");
-    toff->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
-    toff->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
-    toff->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
-
-    // define  cut(s)
-//    const char* eventcut="event%4==0 &&";
-    const char* eventcut="";
-    const char varcut[512];
-    //    sprintf(varcut,"size>%f && size<%f && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
-    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<1.1 && leakage==0 && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
-//    sprintf(varcut,"size>%f && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize,lengthcut,widthcut);
-//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize);
-//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8 && length<0.21",cutsize,upcutsize);
-//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8",cutsize,upcutsize);
-//    sprintf(varcut,"size>%f && size<%f",cutsize,upcutsize)
-//    sprintf(varcut,"");
-    Char_t cut[256];
-    Char_t cutoff[256];
-    strcat(cut,eventcut);
-    strcat(cut,varcut);
-    strcat(cutoff,varcut);
-
-    // fill on/off histos
-    TH1F* onhisto       = new TH1F("OnHist" ,"Alpha Plot",nbins,0,90);
-    TH1F* offhisto      = new TH1F("OffHist","Alpha Plot",nbins,0,90);    
-    ton->Draw("alpha>>OnHist",cut);
-    toff->Draw("alpha>>OffHist",cutoff);
-    cout << "Applied cut: " << cut << endl;
-    
-    // line/normalization
-    const Int_t inibin = 20./90.*nbins+1;
-    Float_t level=0;
-    Float_t leveloff=0;
-    Float_t levelofferror=0;
-    for(Int_t ibin = inibin; ibin<=nbins;ibin++)
-    {
-	level+=onhisto->GetBinContent(ibin);
-	leveloff+=offhisto->GetBinContent(ibin);
-    }
-    level/=(nbins-inibin+1);
-    leveloff/=(nbins-inibin+1);
-    
-    // normalize on/off
-    offhisto->Sumw2(); // needed to compute correct errors after normalization
-    const Float_t norm = level/leveloff;
-    cout << "Normalizing by factor " << norm <<endl;
-    offhisto->Scale(norm);    
-
-    // significance:
-    Float_t sig=0,bg=0,esig=0,ebg=0;
-    Float_t significance=0;
-    const Int_t signbins = inibin-1;
-    for(Int_t ibin = 1; ibin<=signbins;ibin++)
-    {
-//	Float_t sigma = (onhisto->GetBinContent(ibin)-level)/onhisto->GetBinError(ibin);
-//	significance+=sigma*sigma;
-	sig  += onhisto->GetBinContent(ibin);
-	esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
-	bg   += offhisto->GetBinContent(ibin);
-	ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
-    }
-    Float_t error= TMath::Sqrt(esig+ebg);
-    significance = (sig-bg)/error;
-    
-    cout << "Excess: " << sig-bg << endl;
-    cout << "N bkg: "  << bg << endl; 
-    cout << "Significance: " << significance << endl;
-
-    // plot
-    onhisto->SetXTitle("alpha (deg)");
-    onhisto->SetYTitle("Entries");
-    onhisto->SetMarkerColor(4);
-    onhisto->SetMarkerStyle(20);
-    onhisto->SetMarkerSize(.7);
-    onhisto->SetLineColor(4);
-    onhisto->SetMaximum(onhisto->GetBinContent(nbins)*1.5);
-
-    offhisto->SetFillColor(2);
-    offhisto->SetMaximum(offhisto->GetBinContent(nbins)*1.5);
-    offhisto->SetXTitle("alpha (deg)");
-    offhisto->SetYTitle("Entries");
-
-    offhisto->Draw("HIST");
-    offhisto->Draw("ESAME");
-    onhisto->Draw("ESAMES");
-    //    onhisto->Draw("E");
-
-    // move stat box to make them all visible
-    gPad->Update();
-    TPaveStats* offpavstat = (TPaveStats*) offhisto->GetListOfFunctions()->FindObject("stats");
-    if(offpavstat)
-    {
-	Float_t shiftx = offpavstat->GetX2NDC()-offpavstat->GetX1NDC();
-	offpavstat->SetX1NDC(offpavstat->GetX1NDC()-shiftx);
-	offpavstat->SetX2NDC(offpavstat->GetX2NDC()-shiftx);
-    }
-
-    // draw line
-    TLine* line = new TLine(0.,level,90.,level);
-    line->SetLineColor(2);
-    line->SetLineStyle(2);
-//    line->Draw();
-
-    gPad->Modified();
-    gPad->Update();
-
-    // produce ps
-    //  char psname[50];
-    //  sprintf(psname,"%s.ps",var);
-    c1->Print(psname);
-}
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha_plot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/alpha_plot.C	(revision 7136)
+++ 	(revision )
@@ -1,835 +1,0 @@
-Double_t ChiSquareNDof(TH1D *h1, TH1D *h2)
-{
-    Double_t chiq = 0.;
-    Double_t chi;
-    Double_t error;
-    Int_t nbinsnozero = 0;
-
-    Int_t nbins = h1->GetNbinsX();
-    if (nbins != h2->GetNbinsX() || nbins == 0)
-	return -1;
-
-    for (UInt_t bin=1; bin<=nbins; bin++)
-    {
-	error = sqrt(h1->GetBinError(bin)*h1->GetBinError(bin) +
-			   h2->GetBinError(bin)*h2->GetBinError(bin));
-	if (error != 0)
-	{
-	    chi = (h1->GetBinContent(bin)-h2->GetBinContent(bin))/error;
-	    chiq += chi*chi;
-	    nbinsnozero++;
-	}
-    }
-
-    return chiq/nbinsnozero;
-}
-
-void alpha_plot(TString f_on_name  = "../HillasFiles/Mrk421/*_H.root",
-		TString f_off_name = "../HillasFiles/OffMrk421/*_H.root",
-		TString f_src_name = "../HillasFiles/20040319_OffMrk421.fake.pos")	     
-{
-
-    const UInt_t numEntries = 100000000;
-    
-    //cuts
-    Float_t sizemin   = 2000.; //[ADC]
-    Float_t sizemax   = 10000000000.; //[ADC]
-    Float_t widthmin  = 0.06; 
-    Float_t widthmax  = 0.12;
-    Float_t lengthmin = 0.10; 
-    Float_t lengthmax = 0.26;
-    Float_t distmin   = 0.3; 
-    Float_t distmax   = 1.2;
-    Float_t alphamin   = 0.; 
-    Float_t alphamax   = 90.;
-
-    //integration
-    Float_t sigexccmin = 0.;
-    Float_t sigexccmax = 30.;
-    Float_t bkgnormmin = 30.;
-    Float_t bkgnormmax = 90.;
-    
-    gStyle->SetOptStat(111111);
-    gStyle->SetOptFit();
-    
-    //
-    // Make a loop only for the ON data:
-    //
-    
-    MParList plist_on;
-    MTaskList tlist_on;
-    plist_on.AddToList(&tlist_on);
-  
-    // ON containers
-    MGeomCamMagic geomcam;
-    MSrcPosCam source_on;
-    MHillas hillas;
-    MHillasSrc hillasscr;
-    
-    plist_on.AddToList(&geomcam);
-    plist_on.AddToList(&source_on);
-    plist_on.AddToList(&hillas);
-    plist_on.AddToList(&hillasscr);
-    
-    //create some 1-dim histo to test only for the ON distribution of dist, width , length, size...
-    MH3 hDist_on("MHillasSrc.fDist/315.");
-    hDist_on.SetName("Dist_on");
-    plist_on.AddToList(&hDist_on);
-    MBinning binsDist_on("BinningDist_on");
-    Int_t nbins_Dist = 20;
-    Float_t min_Dist = 0.;
-    Float_t max_Dist = distmax*1.2;
-    binsDist_on.SetEdges(nbins_Dist, min_Dist, max_Dist);
-    plist_on.AddToList(&binsDist_on);
-    
-    MH3 hWidth_on("MHillas.fWidth/315.");
-    hWidth_on.SetName("Width_on");
-    plist_on.AddToList(&hWidth_on);
-    MBinning binsWidth_on("BinningWidth_on");
-    Int_t nbins_Width = 20;
-    Float_t min_Width = 0.;
-    Float_t max_Width = widthmax*1.2;
-    binsWidth_on.SetEdges(nbins_Width, min_Width, max_Width);
-    plist_on.AddToList(&binsWidth_on);
-    
-    MH3 hLength_on("MHillas.fLength/315.");
-    hLength_on.SetName("Length_on");
-    plist_on.AddToList(&hLength_on);
-    MBinning binsLength_on("BinningLength_on");
-    Int_t nbins_Length = 20;
-    Float_t min_Length = 0.;
-    Float_t max_Length =  lengthmax*1.2;
-    binsLength_on.SetEdges(nbins_Length, min_Length, max_Length);
-    plist_on.AddToList(&binsLength_on);
-    
-    MH3 hSize_on("log10(MHillas.fSize)");
-    hSize_on.SetName("Size_on");
-    plist_on.AddToList(&hSize_on);
-    MBinning binsSize_on("BinningSize_on");
-    Int_t nbins_Size = 60;
-    Float_t min_Size = log10(sizemin)*0.8;
-    Float_t max_Size = log10(1000000)*1.2;
-    binsSize_on.SetEdges(nbins_Size, min_Size, max_Size);
-    plist_on.AddToList(&binsSize_on);
-    
-    //create a histo to fill the alpha values: one alpha plot form 0 to +90 deg in abs value
-    MH3 hAlpha_on_abs("abs(MHillasSrc.fAlpha)");
-    hAlpha_on_abs.SetName("Alpha_on_abs");
-    plist_on.AddToList(&hAlpha_on_abs);
-    MBinning binsAlpha_on_abs("BinningAlpha_on_abs");
-    Int_t nbins_abs = 9;
-    Float_t minalpha_abs = 0.;
-    Float_t maxalpha_abs =90.;
-    binsAlpha_on_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
-    plist_on.AddToList(&binsAlpha_on_abs);
-    
-    //create a histo to fill the alpha values: one alpha plot form -90 to +90 deg.
-    MH3 hAlpha_on("MHillasSrc.fAlpha");
-    hAlpha_on.SetName("Alpha_on");
-    plist_on.AddToList(&hAlpha_on);
-    MBinning binsAlpha_on("BinningAlpha_on");
-    Int_t nbins = nbins_abs*2;
-    Float_t minalpha = -90.;
-    Float_t maxalpha =  90.;
-    binsAlpha_on.SetEdges(nbins, minalpha, maxalpha);
-    plist_on.AddToList(&binsAlpha_on);
-    
-
-    MH3 hSrcPos_on("MSrcPosCam.fX","MSrcPosCam.fY");
-    hSrcPos_on.SetName("SrcPos_on");
-    plist_on.AddToList(&hSrcPos_on);
-    MBinning binsSrcPos_onX("BinningSrcPos_onX");
-    MBinning binsSrcPos_onY("BinningSrcPos_onY");
-    Int_t nbins_srcpos = 400;
-    Float_t minsrcpos = -600.;
-    Float_t maxsrcpos =  600.;
-    binsSrcPos_onX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
-    binsSrcPos_onY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
-    plist_on.AddToList(&binsSrcPos_onX);
-    plist_on.AddToList(&binsSrcPos_onY);
-
-    MH3 hDAQEvtNumber_on("MRawEvtHeader.fDAQEvtNumber");
-    hDAQEvtNumber_on.SetName("DAQEvtNumber_on");
-    plist_on.AddToList(&hDAQEvtNumber_on);
-    MBinning binsDAQEvtNumber_onX("BinningDAQEvtNumber_onX");
-    Int_t nbins_evtnum = 1000;
-    Float_t minevtnum =  0.;
-    Float_t maxevtnum =  1000.;
-    binsDAQEvtNumber_onX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
-    plist_on.AddToList(&binsDAQEvtNumber_onX);
-
-    //
-    //tasks
-    //
-    
-    MReadTree read_on("Parameters", f_on_name);
-    read_on.DisableAutoScheme();
- 
-
-    //cuts
-    TString sizestr = "(MHillas.fSize < ";
-    sizestr += sizemin;
-    sizestr += ") || (";
-    sizestr += "MHillas.fSize > ";
-    sizestr += sizemax;
-    sizestr += ")";
-    MF sizefilter(sizestr);
-    
-    TString widthstr = "({MHillas.fWidth/315.} < ";
-    widthstr += widthmin;
-    widthstr += ") || (";
-    widthstr += "{MHillas.fWidth/315.} > ";
-    widthstr += widthmax;
-    widthstr += ")";
-    MF widthfilter(widthstr);
-    
-    TString lengthstr = "({MHillas.fLength/315.} < ";
-    lengthstr += lengthmin;
-    lengthstr += ") || (";
-    lengthstr += "{MHillas.fLength/315.} > ";
-    lengthstr += lengthmax;
-    lengthstr += ")";
-    MF lengthfilter(lengthstr);
-    
-    TString diststr = "({MHillasSrc.fDist/315.} < ";
-    diststr += distmin;
-    diststr += ") || (";
-    diststr += "{MHillasSrc.fDist/315.} > ";
-    diststr += distmax;
-    diststr += ")";
-    MF distfilter(diststr);
-    
-    TString alphastr = "({abs(MHillasSrc.fAlpha)} < ";
-    alphastr += alphamin;
-    alphastr += ") || (";
-    alphastr += "{abs(MHillasSrc.fAlpha)} > ";
-    alphastr += alphamax;
-    alphastr += ")";
-    MF alphafilter(alphastr);
-    
-    MF evenfilter("{MRawEvtHeader.fDAQEvtNumber%3}<0.5");
-    MF oddfilter("{MRawEvtHeader.fDAQEvtNumber%3}>0.5");
-
-    MContinue cont_size(&sizefilter);
-    MContinue cont_width(&widthfilter);
-    MContinue cont_length(&lengthfilter);
-    MContinue cont_dist(&distfilter);
-    MContinue cont_alpha(&alphafilter);
-    MContinue cont_even(&evenfilter);
-    MContinue cont_odd(&oddfilter);
-    
-    //    MSrcPosFromFile srccalc(f_src_name);
-    MSrcPlace srccalc;
-    
-    MHillasSrcCalc csrc_on;
-
-    // fill all histograms
-    MFillH falpha_on_abs(&hAlpha_on_abs);
-    MFillH falpha_on(&hAlpha_on);
-    MFillH fdist_on(&hDist_on);
-    MFillH fwidth_on(&hWidth_on);
-    MFillH flength_on(&hLength_on);
-    MFillH fsize_on(&hSize_on);
-    MFillH fsrcpos_on(&hSrcPos_on);
-    MFillH fevtnum_on(&hDAQEvtNumber_on);
-    
-
-    // prints
-    MPrint pevent("MRawEvtHeader");
-    MPrint phillas("MHillas");
-    MPrint phillassrc("MHillasSrc");
-    MPrint psrcpos("MSrcPosCam");
-
-    //tasklist
-    tlist_on.AddToList(&read_on);
-    tlist_on.AddToList(&srccalc);
-    tlist_on.AddToList(&csrc_on);
-    tlist_on.AddToList(&fsrcpos_on);
-//    tlist_on.AddToList(&cont_odd);
-    tlist_on.AddToList(&cont_size);
-    tlist_on.AddToList(&cont_width);
-    tlist_on.AddToList(&cont_length);
-    tlist_on.AddToList(&cont_dist);
-    tlist_on.AddToList(&cont_alpha);
-    tlist_on.AddToList(&falpha_on_abs);
-    tlist_on.AddToList(&falpha_on);
-    tlist_on.AddToList(&fdist_on);
-    tlist_on.AddToList(&fwidth_on);
-    tlist_on.AddToList(&flength_on);
-    tlist_on.AddToList(&fsize_on);
-    tlist_on.AddToList(&fevtnum_on);
-    
-    // Create and setup the eventloop
-    MEvtLoop loop_on;
-    loop_on.SetParList(&plist_on);
-  //loop_on.SetDisplay(display);
-    
-    MProgressBar bar;
-    loop_on.SetProgressBar(&bar);
-    
-    if (!loop_on.Eventloop(numEntries))
-	return;
-
-    tlist_on.PrintStatistics();
-    
-    // 
-    // Make a loop only for the OFF data:
-    //
-    
-    MParList plist_off;
-    MTaskList tlist_off;
-    plist_off.AddToList(&tlist_off);
-    
-    MSrcPosCam source_off;
-
-    plist_off.AddToList(&geomcam);
-    plist_off.AddToList(&source_off);
-    plist_off.AddToList(&hillas);
-    plist_off.AddToList(&hillasscr);
-
-    //create some 1-dim histo to test only for the OFF distribution of dist, width , length, size...
-    MH3 hDist_off("MHillasSrc.fDist/315.");
-    hDist_off.SetName("Dist_off");
-    plist_off.AddToList(&hDist_off);
-    MBinning binsDist_off("BinningDist_off");
-    binsDist_off.SetEdges(nbins_Dist, min_Dist, max_Dist);
-    plist_off.AddToList(&binsDist_off);
-    
-    MH3 hWidth_off("MHillas.fWidth/315.");
-    hWidth_off.SetName("Width_off");
-    plist_off.AddToList(&hWidth_off);
-    MBinning binsWidth_off("BinningWidth_off");
-    binsWidth_off.SetEdges(nbins_Width, min_Width, max_Width);
-    plist_off.AddToList(&binsWidth_off);
-
-    MH3 hLength_off("MHillas.fLength/315.");
-    hLength_off.SetName("Length_off");
-    plist_off.AddToList(&hLength_off);
-    MBinning binsLength_off("BinningLength_off");
-    binsLength_off.SetEdges(nbins_Length, min_Length, max_Length);
-    plist_off.AddToList(&binsLength_off);
-    
-    MH3 hSize_off("log10(MHillas.fSize)");
-    hSize_off.SetName("Size_off");
-    plist_off.AddToList(&hSize_off);
-    MBinning binsSize_off("BinningSize_off");
-    binsSize_off.SetEdges(nbins_Size, min_Size, max_Size);
-    plist_off.AddToList(&binsSize_off);
-    
-    //create a histo to fill the alpha values: from 0 to 90 deg -> abs value
-    MH3 hAlpha_off_abs("abs(MHillasSrc.fAlpha)");
-    hAlpha_off_abs.SetName("Alpha_off_abs");
-    plist_off.AddToList(&hAlpha_off_abs);
-    MBinning binsAlpha_off_abs("BinningAlpha_off_abs");
-    binsAlpha_off_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
-    plist_off.AddToList(&binsAlpha_off_abs);
-    
-    //create a histo to fill the alpha values: from -90 to 90 deg
-    MH3 hAlpha_off("MHillasSrc.fAlpha");
-    hAlpha_off.SetName("Alpha_off");
-    plist_off.AddToList(&hAlpha_off);
-    MBinning binsAlpha_off("BinningAlpha_off");
-    binsAlpha_off.SetEdges(nbins, minalpha, maxalpha);
-    plist_off.AddToList(&binsAlpha_off);
-    
-    
-    MH3 hSrcPos_off("MSrcPosCam.fX","MSrcPosCam.fY");
-    hSrcPos_off.SetName("SrcPos_off");
-    plist_off.AddToList(&hSrcPos_off);
-    MBinning binsSrcPos_offX("BinningSrcPos_offX");
-    MBinning binsSrcPos_offY("BinningSrcPos_offY");
-    binsSrcPos_offX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
-    binsSrcPos_offY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
-    plist_off.AddToList(&binsSrcPos_offX);
-    plist_off.AddToList(&binsSrcPos_offY);
-
-    MH3 hDAQEvtNumber_off("MRawEvtHeader.fDAQEvtNumber");
-    hDAQEvtNumber_off.SetName("DAQEvtNumber_off");
-    plist_off.AddToList(&hDAQEvtNumber_off);
-    MBinning binsDAQEvtNumber_offX("BinningDAQEvtNumber_offX");
-    Int_t nbins_evtnum = 100;
-    Float_t minevtnum =  0.;
-    Float_t maxevtnum =  100.;
-    binsDAQEvtNumber_offX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
-    plist_off.AddToList(&binsDAQEvtNumber_offX);
-
-   //tasks
-    MReadTree read_off("Parameters", f_off_name);
-    read_off.DisableAutoScheme();
-    
-    srccalc.SetMode(MSrcPlace::kOff);
-
-    MHillasSrcCalc csrc_off;
-
-    // fill all histograms
-    MFillH falpha_off_abs(&hAlpha_off_abs);
-    MFillH falpha_off(&hAlpha_off);
-    MFillH fdist_off(&hDist_off);
-    MFillH fwidth_off(&hWidth_off);
-    MFillH flength_off(&hLength_off);
-    MFillH fsize_off(&hSize_off);
-    MFillH fsrcpos_off(&hSrcPos_off);
-    MFillH fevtnum_off(&hDAQEvtNumber_off);
-   
-    //tasklist
-    tlist_off.AddToList(&read_off);
-    tlist_off.AddToList(&srccalc);
-    tlist_off.AddToList(&csrc_off);
-    tlist_off.AddToList(&fsrcpos_off);
-//    tlist_off.AddToList(&cont_even);
-    tlist_off.AddToList(&cont_size);
-    tlist_off.AddToList(&cont_width);
-    tlist_off.AddToList(&cont_length);
-    tlist_off.AddToList(&cont_dist);
-    tlist_off.AddToList(&cont_alpha);
-    tlist_off.AddToList(&falpha_off_abs);
-    tlist_off.AddToList(&falpha_off);
-    tlist_off.AddToList(&fdist_off);
-    tlist_off.AddToList(&fwidth_off);
-    tlist_off.AddToList(&flength_off);
-    tlist_off.AddToList(&fsize_off);
-    tlist_off.AddToList(&fevtnum_off);
-     
-    // Create and setup the eventloop
-    MEvtLoop loop_off;
-    loop_off.SetParList(&plist_off);
-    //loop_off.SetDisplay(display);
-    
-    MProgressBar bar_off;
-    loop_off.SetProgressBar(&bar_off);
-    
-    if (!loop_off.Eventloop(numEntries))
-	return;
-    
-    tlist_off.PrintStatistics();
-    
-  // ############################################################################
-  //  look for the histograms
-  // ############################################################################
-
-  TH1F *hist_size_on = (TH1F*)hSize_on.GetHist();
-  TH1F *hist_size_off = (TH1F*)hSize_off.GetHist();
-
-  TH1F *hist_dist_on = (TH1F*)hDist_on.GetHist();
-  TH1F *hist_dist_off = (TH1F*)hDist_off.GetHist();
-
-  TH1F *hist_width_on = (TH1F*)hWidth_on.GetHist();
-  TH1F *hist_width_off = (TH1F*)hWidth_off.GetHist();
-
-  TH1F *hist_length_on = (TH1F*)hLength_on.GetHist();
-  TH1F *hist_length_off = (TH1F*)hLength_off.GetHist();
-
-  TH1F *hist_on_abs = (TH1F*)hAlpha_on_abs.GetHist();
-  TH1F *hist_off_abs = (TH1F*)hAlpha_off_abs.GetHist();
-
-  TH1F *hist_on = (TH1F*)hAlpha_on.GetHist();
-  TH1F *hist_off = (TH1F*)hAlpha_off.GetHist();
-
-
-  // ############################################################################
-  // Calculate significance and excess: 
-  // ############################################################################
-
-  Double_t norm_on_abs  = (Double_t) hist_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
-  Double_t exces_on_abs = (Double_t) hist_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
-  Double_t norm_off_abs  = (Double_t) hist_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
-  Double_t exces_off_abs = (Double_t) hist_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
-  Double_t norm = norm_on_abs/norm_off_abs;
-
-  char text_tit_alpha[256];
-  sprintf(text_tit_alpha, " Alpha Plot On and Off ");
-  hist_off_abs->SetTitle(text_tit_alpha);
-  hist_on_abs->SetTitle(text_tit_alpha);
-
-  Double_t excess  = exces_on_abs - exces_off_abs*norm;
-  Double_t sign    = excess / sqrt( exces_on_abs + norm*norm*exces_off_abs );
-  Double_t int_off = (Double_t) hist_off_abs->Integral(1, 18);
-  int hist_on_entries  = (int) hist_on_abs->GetEntries();
-  int hist_off_entries = (int) hist_off_abs->GetEntries();
-    
-  cout << "---> Normalization F factor =\t" << norm <<endl;
-  cout << "---> Excess =\t\t\t" << excess <<endl;
-  cout << "---> Significancia =\t\t" << sign <<endl;    
-  cout << "---> entries on   =\t\t" << hist_on_entries  <<endl;
-  cout << "---> entries off  =\t\t" << hist_off_entries <<endl;
-  cout << "---> integral off =\t\t" << int_off <<endl;
-
-  Float_t shiftx;
-
-  //
-  //Create the display -> from now on, all histos are plotted
-  MStatusDisplay *display = new MStatusDisplay;
-  display->SetUpdateTime(3000);
-  display->Resize(850,700);
-  
-  // ############################################################################
-  // Draw SIZE
-  // ############################################################################
-  display->AddTab("SIZE");
-
-  gPad->cd();
-
-  gPad->SetLogy();
-  hist_size_on->Sumw2();
-  hist_size_off->Sumw2();
-  hist_size_off->Scale(norm); 
-  hist_size_on->SetLineColor(kBlack);
-  hist_size_on->SetMarkerStyle(21);
-  hist_size_on->SetMarkerSize(0.7);
-  hist_size_on->SetMarkerColor(kBlack);
-  hist_size_off->SetFillColor(46);
-  hist_size_off->SetLineColor(46);
-  hist_size_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_size_off->SetMinimum(0.1);
-  hist_size_on->SetMinimum(0.1);
-  hist_size_on->SetTitle("SIZE distribution");
-  hist_size_off->SetTitle("SIZE distribution");
-
-  hist_size_on->DrawCopy("E1P");
-
-  // move stat box to make them all visible
-  gPad->Update();
-  TPaveStats* pavs_on_size = (TPaveStats*) hist_size_on->GetListOfFunctions()->FindObject("stats");
-  if(pavs_on_size){
-    shiftx = pavs_on_size->GetX2NDC() - pavs_on_size->GetX1NDC();
-    pavs_on_size->SetX1NDC(pavs_on_size->GetX1NDC() - shiftx);
-    pavs_on_size->SetX2NDC(pavs_on_size->GetX2NDC() - shiftx);  
-  }
-  gPad->Modified();
-  gPad->Update();
-
-  hist_size_off->DrawCopy("HISTSAME");
-  hist_size_off->DrawCopy("ESAME");
-
-  gPad->Modified();
-  gPad->Update();
-
-  Double_t chisize = ChiSquareNDof((TH1D*)hist_size_on,(TH1D*)hist_size_off);
-
-  Double_t x_label_pos  = log10(1000000)*0.7;
-  Double_t y_label_pos  = log10((hist_size_on->GetBinContent(hist_size_on->GetMaximumBin()))/2.);
-  Double_t textsize = 0.03;
-
-  char text_size[256];
-  sprintf(text_size,"ChiSquare/NDof = %4.2f",chisize);
-
-  TLatex *tsize = new TLatex(x_label_pos, y_label_pos, text_size);
-  tsize->SetTextSize(textsize);
-//  tsize->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-
-  // ############################################################################
-  // DrawCopy DIST
-  // ############################################################################
-  display->AddTab("DIST");
-
-  gPad->cd();
-
-  hist_dist_on->Sumw2();
-  hist_dist_off->Sumw2();
-  hist_dist_off->Scale(norm); 
-  hist_dist_on->SetLineColor(kBlack);
-  hist_dist_on->SetMarkerStyle(21);
-  hist_dist_on->SetMarkerSize(0.7);
-  hist_dist_on->SetMarkerColor(kBlack);
-  hist_dist_off->SetFillColor(46);
-  hist_dist_off->SetLineColor(46);
-  hist_dist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_dist_off->SetMinimum(0.);
-  hist_dist_on->SetTitle("DIST distribution");
-  hist_dist_off->SetTitle("DIST distribution");
-
-  hist_dist_on->DrawCopy("E1P");
-
-  // move stat box to make them all visible
-  gPad->Update();
-  TPaveStats* pavs_on_dist = (TPaveStats*) hist_dist_on->GetListOfFunctions()->FindObject("stats");
-  if(pavs_on_dist){
-    shiftx = pavs_on_dist->GetX2NDC() - pavs_on_dist->GetX1NDC();
-    pavs_on_dist->SetX1NDC(pavs_on_dist->GetX1NDC() - shiftx);
-    pavs_on_dist->SetX2NDC(pavs_on_dist->GetX2NDC() - shiftx);  
-  }
-  gPad->Modified();
-  gPad->Update();
-
-  hist_dist_off->DrawCopy("HISTSAME");
-  hist_dist_off->DrawCopy("ESAME");
-  hist_dist_on->DrawCopy("E1PSAME");
-
-  Double_t chidist = ChiSquareNDof((TH1D*)hist_dist_on,(TH1D*)hist_dist_off);
-
-  x_label_pos  = distmax*0.7;
-  y_label_pos  = hist_dist_on->GetBinContent(hist_dist_on->GetMaximumBin())/2.;
-
-  char text_dist[256];
-  sprintf(text_size,"ChiSquare/NDof = %4.2f",chidist);
-
-  TLatex *tdist = new TLatex(x_label_pos, y_label_pos, text_dist);
-  tdist->SetTextSize(textsize);
-//  tdist->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-
-   // ############################################################################
-  // DrawCopy WIDTH
-  // ############################################################################
-  display->AddTab("WIDTH");
-
-  gPad->cd();
-
-  hist_width_off->Sumw2();
-  hist_width_off->Scale(norm); 
-  hist_width_on->SetLineColor(kBlack);
-  hist_width_on->SetMarkerStyle(21);
-  hist_width_on->SetMarkerSize(0.7);
-  hist_width_on->SetMarkerColor(kBlack);
-  hist_width_off->SetFillColor(46);
-  hist_width_off->SetLineColor(46);
-  hist_width_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_width_off->SetMinimum(0.);
-  hist_width_on->SetTitle("WIDTH distribution");
-  hist_width_off->SetTitle("WIDTH distribution");
-
-  hist_width_on->DrawCopy("E1P");
-
-  // move stat box to make them all visible
-  gPad->Update();
-  TPaveStats* pavs_on_width = (TPaveStats*) hist_width_on->GetListOfFunctions()->FindObject("stats");
-  if(pavs_on_width){
-    shiftx = pavs_on_width->GetX2NDC() - pavs_on_width->GetX1NDC();
-    pavs_on_width->SetX1NDC(pavs_on_width->GetX1NDC() - shiftx);
-    pavs_on_width->SetX2NDC(pavs_on_width->GetX2NDC() - shiftx);  
-  }
-  gPad->Modified();
-  gPad->Update();
-
-  hist_width_off->DrawCopy("HISTSAME");
-  hist_width_off->DrawCopy("ESAME");
-  hist_width_on->DrawCopy("E1PSAME");
-
-  Double_t chiwidth = ChiSquareNDof((TH1D*)hist_width_on,(TH1D*)hist_width_off);
-
-  x_label_pos  = widthmax*0.7;
-  y_label_pos  = hist_width_on->GetBinContent(hist_width_on->GetMaximumBin())/2.;
-
-  char text_width[256];
-  sprintf(text_size,"ChiSquare/NDof = %4.2f",chiwidth);
-
-  TLatex *twidth = new TLatex(x_label_pos, y_label_pos, text_width);
-  twidth->SetTextSize(textsize);
-//  twidth->Draw();
-
-  gPad->Modified();
-  gPad->Update();
- 
-  // ############################################################################
-  // DrawCopy LENGTH
-  // ############################################################################
-  display->AddTab("LENGTH");
- 
-  gPad->cd();
-
-  hist_length_on->Sumw2();
-  hist_length_off->Sumw2();
-  hist_length_off->Scale(norm); 
-  hist_length_on->SetLineColor(kBlack);
-  hist_length_on->SetMarkerStyle(21);
-  hist_length_on->SetMarkerSize(0.7);
-  hist_length_on->SetMarkerColor(kBlack);
-  hist_length_off->SetFillColor(46);
-  hist_length_off->SetLineColor(46);
-  hist_length_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_length_off->SetMinimum(0.);
-  hist_length_on->SetTitle("LENGTH distribution");
-  hist_length_off->SetTitle("LENGTH distribution");
-
-  hist_length_on->DrawCopy("E1P");
-
-  // move stat box to make them all visible
-  gPad->Update();
-  TPaveStats* pavs_on_length = (TPaveStats*) hist_length_on->GetListOfFunctions()->FindObject("stats");
-  if(pavs_on_length){
-    shiftx = pavs_on_length->GetX2NDC() - pavs_on_length->GetX1NDC();
-    pavs_on_length->SetX1NDC(pavs_on_length->GetX1NDC() - shiftx);
-    pavs_on_length->SetX2NDC(pavs_on_length->GetX2NDC() - shiftx);  
-  }
-  gPad->Modified();
-  gPad->Update();
-
-  hist_length_off->DrawCopy("HISTSAME");
-  hist_length_off->DrawCopy("ESAME");
-  hist_length_on->DrawCopy("E1PSAME");
-
-  Double_t chilength = ChiSquareNDof((TH1D*)hist_length_on,(TH1D*)hist_length_off);
-
-  x_label_pos  = lengthmax*0.7;
-  y_label_pos  = hist_length_on->GetBinContent(hist_length_on->GetMaximumBin())/2.;
-
-  char text_length[256];
-  sprintf(text_size,"ChiSquare/NDof = %4.2f",chilength);
-
-  TLatex *tlength = new TLatex(x_label_pos, y_label_pos, text_length);
-  tlength->SetTextSize(textsize);
-//  tlength->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-
-  // ############################################################################
-  // DrawCopy normalized ALPHA plot
-  // ############################################################################
-  display->AddTab("ALPHA");
-  
-  gPad->cd();
-
-  hist_on_abs->Sumw2();
-  hist_off_abs->SetStats(0);
-  hist_off_abs->Sumw2();
-  hist_off_abs->Scale(norm); 
-  hist_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
-  hist_on_abs->SetLineColor(kBlack);
-  hist_on_abs->SetMarkerStyle(21);
-  //hist_on_abs->SetMarkerSize();
-  hist_on_abs->SetMarkerColor(kBlack);
-  hist_on_abs->SetMarkerSize(0.7);
-  hist_off_abs->SetFillColor(46);
-  hist_off_abs->SetLineColor(46);
-  hist_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_off_abs->SetMinimum(0.);
-  hist_on_abs->SetTitle("Alpha plot");
-  hist_off_abs->SetTitle("Alpha plot");
-
-  
-  hist_on_abs->DrawCopy("E1P");
-  hist_off_abs->DrawCopy("HISTSAME");
-  hist_off_abs->DrawCopy("ESAME");
-  hist_on_abs->DrawCopy("E1PSAME");
-
-
-   //draw the LEGEND with excess and significance values in the alpha plot:
-  char text_Fnorm[256], text_excess[256], text_sign[256];
-  char text_entries_on[256], text_entries_off[256], text_integral_off[256];
-  int hist_on_entries  = (int) hist_on_abs->GetEntries();
-  int hist_off_entries = (int) hist_off_abs->GetEntries();
-  sprintf(text_Fnorm,       " F norm =       %.3f", norm);
-  sprintf(text_excess,      " Excess =       %.3f", excess);
-  sprintf(text_sign,        " Significance = %.3f", sign);
-  sprintf(text_entries_on,  " Entries ON   = %d",  hist_on_entries);
-  sprintf(text_entries_off, " Entries OFF  = %d",  hist_off_entries);
-  sprintf(text_integral_off," Integral OFF = %d",  int_off);
-  
-  x_label_pos  = alphamax*0.7;
-  y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/1.6; //2.;
-  Double_t y_label_step = y_label_pos / 8.;
-
-  TLatex *t0 = new TLatex(x_label_pos, y_label_pos - y_label_step*0, text_Fnorm);
-  t0->SetTextSize(textsize);
-  t0->Draw();
-  TLatex *t1 = new TLatex(x_label_pos, y_label_pos - y_label_step*1, text_excess);
-  t1->SetTextSize(textsize);
-  t1->Draw();
-  TLatex *t2 = new TLatex(x_label_pos, y_label_pos - y_label_step*2, text_sign);
-  t2->SetTextSize(textsize);
-  t2->Draw();
-  TLatex *t3 = new TLatex(x_label_pos, y_label_pos - y_label_step*3, text_entries_on);
-  t3->SetTextSize(textsize);
-  t3->Draw();
-  TLatex *t4 = new TLatex(x_label_pos, y_label_pos - y_label_step*4, text_entries_off);
-  t4->SetTextSize(textsize);
-  t4->Draw();
-  TLatex *t5 = new TLatex(x_label_pos, y_label_pos - y_label_step*5, text_integral_off);
-  t5->SetTextSize(textsize);
-  t5->Draw();
-  
-
-  Double_t chialpha = ChiSquareNDof((TH1D*)hist_on_abs,(TH1D*)hist_off_abs);
-
-  y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/2.;
-
-  char text_alpha[256];
-  sprintf(text_size,"ChiSquare/NDof = %4.2f",chialpha);
-
-  TLatex *talpha = new TLatex(x_label_pos, y_label_pos, text_alpha);
-  talpha->SetTextSize(textsize);
-//  talpha->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-
-  // ############################################################################
-  // DrawCopy normalized alpha histos for alpha form -90 to 90 deg.
-  // ############################################################################
-  display->AddTab("ALPHA +-90");
-
-  gPad->cd();
-
-  hist_on->Sumw2();
-  hist_off->SetStats(0);
-  hist_off->Sumw2();
-  hist_off->Scale(norm); 
-  hist_off->SetFillColor(46);
-  hist_off->SetLineColor(46);
-  hist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
-  hist_off->SetMinimum(0.); 
-  hist_on->SetStats(0); //-> Do NOT show the legend with statistics
-  hist_on->SetLineColor(kBlack);
-  hist_on->SetMarkerStyle(21);
-  hist_on->SetMarkerSize(0.7);
-  hist_on->SetMarkerColor(kBlack);
-  hist_on->SetTitle("Alpha plot form -90 to 90 deg");
-  hist_off->SetTitle("Alpha plot form -90 to 90 deg");
-
-  hist_on->DrawCopy("E1P");
-  hist_off->DrawCopy("HISTSAME");
-  hist_off->DrawCopy("ESAME");
-  hist_on->DrawCopy("E1PSAME");
-
-  Double_t chialpha90 = ChiSquareNDof((TH1D*)hist_on,(TH1D*)hist_off);
-
-  x_label_pos  = alphamax*0.5;
-  y_label_pos  = hist_on->GetBinContent(hist_on->GetMaximumBin())/2.;
-
-  char text_alpha90[256];
-  sprintf(text_alpha90,"ChiSquare/NDof = %4.2f",chialpha90);
-
-  TLatex *talpha90 = new TLatex(x_label_pos, y_label_pos, text_alpha90);
-  talpha90->SetTextSize(textsize);
-//  talpha90->Draw();
-
-  gPad->Update();
-  gPad->Modified();
-
-
-  cout << "---> ChiSquare/NDof [Size] =\t\t" << chisize << endl;
-  cout << "---> ChiSquare/NDof [Dist] =\t\t" << chidist << endl;
-  cout << "---> ChiSquare/NDof [Width] =\t\t" << chiwidth << endl;
-  cout << "---> ChiSquare/NDof [Length] =\t\t" << chilength << endl;
-  cout << "---> ChiSquare/NDof [Abs(Alpha)] =\t" << chialpha << endl;
-  cout << "---> ChiSquare/NDof [Alpha] =\t\t" << chialpha90 << endl;
-
-
-  display->AddTab("SRCPOS ON");
-  TH2F *hist_srcpos_on = (TH2F*)hSrcPos_on.GetHist();
-  hist_srcpos_on->DrawCopy("BOX");
-
-  display->AddTab("SRCPOS OFF");
-  TH2F *hist_srcpos_off = (TH2F*)hSrcPos_off.GetHist();
-  hist_srcpos_off->DrawCopy("BOX");
-
-  display->AddTab("EVTNUM ON");
-  TH1F *hist_evtnum_on = (TH1F*)hDAQEvtNumber_on.GetHist();
-  hist_evtnum_on->DrawCopy();
-
-  display->AddTab("EVTNUM OFF");
-  TH1F *hist_evtnum_off = (TH1F*)hDAQEvtNumber_off.GetHist();
-  hist_evtnum_off->DrawCopy();
-
-  cout << "Done!!" <<endl;
-
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/cleanComp.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/cleanComp.C	(revision 7136)
+++ 	(revision )
@@ -1,445 +1,0 @@
-/* ======================================================================== *\!
-!   Author(s): Javier Rico
-\* ======================================================================== */
-
-void cleanComp()
-{    
-  // general settings
-  gROOT->Reset();
-  gStyle->SetCanvasColor(0);
-  gStyle->SetCanvasBorderMode(0);
-  gStyle->SetPadBorderMode(0);
-  gStyle->SetFrameBorderMode(0);
-  gStyle->SetOptTitle(1);
-  //  gStyle->SetTitleOffset(1.7,"y");
-  //  gStyle->SetPadLeftMargin(0.15);
-  gStyle->SetOptStat(111110);
-  gStyle->SetStatColor(0);
-  gStyle->SetStatBorderSize(1);
-  gStyle->SetStatW(0.2);
-  gStyle->SetStatH(0.1);
-  gStyle->SetStatX(0.9);
-  gStyle->SetStatY(0.9);
-  
-  // define files, chain, trees, canvas...
-  TChain* ton;
-  ton= new TChain("Events");
-  
-  // data file(s)
-  ton->Add("/local_disk/jrico/mc/cleanComp0-3.root");
-  
-  // define aliases
-  ton->SetAlias("run","MRawRunHeader.fRunNumber");
-  ton->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
-  ton->SetAlias("energy","MMcEvt.fEnergy");
-
-  // alpha0 is for the file without noise
-  // alphaNOCL is for the file with noise and no cleaning
-  ton->SetAlias("alpha0","MHillasSrc0.fAlpha");
-  ton->SetAlias("alphaNOCL","MHillasSrcnoclean.fAlpha");
-  ton->SetAlias("alpha3015","MHillasSrc3015.fAlpha");
-  ton->SetAlias("alpha4025","MHillasSrc4025.fAlpha");
-  ton->SetAlias("alpha5035","MHillasSrc5035.fAlpha");
-  ton->SetAlias("alpha6045","MHillasSrc6045.fAlpha");
-  
-  //  ton->Scan("run:event","alpha0<-30 && energy>2500 && energy<5000");
-  
-  //  plotAlphaWidth(ton);
-   plotAlphaWidthVsEnergy(ton);
-  // plotEfficiencies(ton);
-}
-
-void plotAlphaWidth(TChain* ton)
-{
-  // define and fill histos
-  const Int_t nbins=90;
-  TH1F* halpha3015 = new TH1F("Alpha3015" ,"Alpha3015",nbins,-180,180);
-  TH1F* halpha4025 = new TH1F("Alpha4025" ,"Alpha4025",nbins,-180,180);
-  TH1F* halpha5035 = new TH1F("Alpha5035" ,"Alpha5035",nbins,-180,180);
-  TH1F* halpha6045 = new TH1F("Alpha6045" ,"Alpha6045",nbins,-180,180);
-  
-  halpha3015->SetXTitle("alpha-alpha0 (deg)");
-  halpha3015->SetYTitle("Entries");
-  
-  halpha3015->SetLineColor(1);
-  halpha4025->SetLineColor(2);
-  halpha5035->SetLineColor(3);
-  halpha6045->SetLineColor(4);
-  
-  ton->Draw("alpha3015-alpha0>>Alpha3015","alpha3015!=0");
-  ton->Draw("alpha4025-alpha0>>Alpha4025","alpha4025!=0");
-  ton->Draw("alpha5035-alpha0>>Alpha5035","alpha5035!=0");
-  ton->Draw("alpha6045-alpha0>>Alpha6045","alpha6045!=0");
-  
-  // plot
-  TCanvas *c1 = new TCanvas("c1","c1",800,500);
-  c1->cd(1);
-  
-  halpha3015->Draw("HIST");
-  halpha4025->Draw("HISTSAMES");
-  halpha5035->Draw("HISTSAMES");
-  halpha6045->Draw("HISTSAMES");
-  
-  gPad->Update();
-  TPaveStats* pvstat4025  = (TPaveStats*) halpha4025->GetListOfFunctions()->FindObject("stats");
-  TPaveStats* pvstat5035  = (TPaveStats*) halpha5035->GetListOfFunctions()->FindObject("stats");
-  TPaveStats* pvstat6045  = (TPaveStats*) halpha6045->GetListOfFunctions()->FindObject("stats");
-  
-  Float_t shifty = pvstat4025->GetY2NDC()-pvstat4025->GetY1NDC();
-  
-  pvstat4025->SetY1NDC(pvstat4025->GetY1NDC()-shifty);
-  pvstat4025->SetY2NDC(pvstat4025->GetY2NDC()-shifty);
-  pvstat5035->SetY1NDC(pvstat5035->GetY1NDC()-2*shifty);
-  pvstat5035->SetY2NDC(pvstat5035->GetY2NDC()-2*shifty);
-  pvstat6045->SetY1NDC(pvstat6045->GetY1NDC()-3*shifty);
-  pvstat6045->SetY2NDC(pvstat6045->GetY2NDC()-3*shifty);
-  
-  gPad->Modified();
-  gPad->Update();
-  
-  c1->Print("cleanComp.ps");
-}
-
-/*******************************************************************************/
-void plotAlphaWidthVsEnergy(TChain* ton)
-{
-  const Int_t nbins = 8;
-  Float_t bound[nbins+1] ={0,30,50,80,150,300,600,1200,3000}; // boundary of considered size bins
-  
-  // define the arrays that will feed the graphs
-  // value of rms of the alpha-alpha0 distribution, and errors
-  Float_t alpha0[nbins];
-  Float_t alpha3015[nbins];
-  Float_t alpha4025[nbins];
-  Float_t alpha5035[nbins];
-  Float_t alpha6045[nbins];
-
-  Float_t ealpha0[nbins];
-  Float_t ealpha3015[nbins];
-  Float_t ealpha4025[nbins];
-  Float_t ealpha5035[nbins];
-  Float_t ealpha6045[nbins];
-
-  // x axis and error
-  Float_t x[nbins];
-  Float_t ex[nbins];
-
-  TH1F* hp[nbins];
-
-  // define the function that will be used to fit the histograms
-  TF1 f2("f2","[0]+[1]/[3]*exp(-(x-[2])*(x-[2])/(2*[3]*[3]))",-180.,180.);
-  f2.SetParameters(0,100,0,02);
-  f2.FixParameter(0,0);
-  f2.SetLineWidth(1);
-
-  // fill the arrays
-  for(Int_t i=0;i<nbins;i++)
-    {
-      //      cout << "Bin " << i << endl;
-      TH1F dummy0("dummy0" ,"dummy0",100,-90,90);
-      TH1F dummy3015("dummy3015" ,"dummy3015",100,-180,180);
-      TH1F dummy4025("dummy4025" ,"dummy4025",100,-180,180);
-      TH1F dummy5035("dummy5035" ,"dummy5035",100,-180,180);
-      TH1F dummy6045("dummy6045" ,"dummy6045",100,-180,180);
-
-      TH1F xdummy("xdummy" ,"xdummy",100,bound[i],bound[i+1]);
-
-      // define the cuts for each of the cleaning levels
-      char cut[100];
-      sprintf(cut,"energy>%f && energy<%f && alpha0!=0",bound[i],bound[i+1]);
-      char cut3015[200];
-      sprintf(cut3015,"%s && alpha3015!=0",cut);
-      char cut4025[200];
-      sprintf(cut4025,"%s && alpha4025!=0",cut);
-      char cut5035[200];
-      sprintf(cut5035,"%s && alpha5035!=0",cut);
-      char cut6045[200];
-      sprintf(cut6045,"%s && alpha6045!=0",cut);
-
-      TF1 f1("f1","[0]+[1]/[3]*exp(-(x-[2])*(x-[2])/(2*[3]*[3]))",-180.,180.);
-      f1.SetParameters(0,100,0,02);
-      f1.FixParameter(0,0);
-
-
-      // fill the histograms to extract later the information from rms, entries, means, etc
-      ton->Draw("alpha0>>dummy0",cut);
-      ton->Draw("alpha3015-alpha0>>dummy3015",cut3015);
-      ton->Draw("alpha4025-alpha0>>dummy4025",cut4025);
-      ton->Draw("alpha5035-alpha0>>dummy5035",cut5035);
-      ton->Draw("alpha6045-alpha0>>dummy6045",cut6045);
-
-      ton->Draw("energy>>xdummy",cut);
-
-      // fit to a gaussian and get the sigma to be plotted later
-      dummy0.Fit("f1");
-      alpha0[i]   =f1.GetParameter(3);
-      dummy3015.Fit("f1");
-      alpha3015[i]=f1.GetParameter(3);
-      dummy4025.Fit("f1");
-      alpha4025[i]=f1.GetParameter(3);
-      dummy5035.Fit("f1");
-      alpha5035[i]=f1.GetParameter(3);
-      dummy6045.Fit("f1");
-      alpha6045[i]=f1.GetParameter(3);
-
-      Float_t nevt0    = dummy0.GetEntries();
-      Float_t nevt3015 = dummy3015.GetEntries();
-      Float_t nevt4025 = dummy4025.GetEntries();
-      Float_t nevt5035 = dummy5035.GetEntries();
-      Float_t nevt6045 = dummy6045.GetEntries();
-
-      // since gaussian is not so good aproximation, compute error like follows
-      ealpha0[i]   = alpha0[i]/TMath::Sqrt(2*nevt0);
-      ealpha3015[i]= alpha3015[i]/TMath::Sqrt(2*nevt3015);
-      ealpha4025[i]= alpha4025[i]/TMath::Sqrt(2*nevt4025);
-      ealpha5035[i]= alpha5035[i]/TMath::Sqrt(2*nevt5035);
-      ealpha6045[i]= alpha6045[i]/TMath::Sqrt(2*nevt6045);
-
-      // copy some histos to be plotted later
-      Char_t nom[10];
-      sprintf(nom,"hp[%02d]",i);
-      hp[i] = new TH1F(nom,nom,100,-180,180);
-      hp[i]->GetXaxis()->SetTitle("alpha (deg)");
-      hp[i]->Add(&dummy6045);
-      hp[i]->Fit("f2");
-
-      //      cout << xdummy.GetMean() << " " << xdummy.GetRMS()<< " " << xdummy.GetEntries() << endl;
-      x[i]  = xdummy.GetMean();            
-      //      Float_t rms = xdummy.GetRMS();
-      ex[i] = 0;//rms*rms/xdummy.GetEntries();
-    }
-
-  //#if 0
-  TCanvas* cdum = new TCanvas("cdum","cdum",600,900);
-  cdum->Divide(2,nbins/2+1);
-  for(Int_t i=0;i<nbins;i++)
-    {
-      cdum->cd(i+1);
-      hp[i]->Draw();
-      gPad->Modified();
-      gPad->Update();
-    }
-  //#endif
-  
-  // create the graphs
-  TGraphErrors* gr0    = new TGraphErrors(nbins,x,alpha0,ex,ealpha0);
-  TGraphErrors* gr3015 = new TGraphErrors(nbins,x,alpha3015,ex,ealpha3015);
-  TGraphErrors* gr4025 = new TGraphErrors(nbins,x,alpha4025,ex,ealpha4025);
-  TGraphErrors* gr5035 = new TGraphErrors(nbins,x,alpha5035,ex,ealpha5035);
-  TGraphErrors* gr6045 = new TGraphErrors(nbins,x,alpha6045,ex,ealpha6045);  
-
-  // marker/line colors
-  gr0->SetMarkerStyle(20);
-  gr3015->SetMarkerStyle(24);
-  gr4025->SetMarkerStyle(21);
-  gr5035->SetMarkerStyle(25);
-  gr6045->SetMarkerStyle(22);
-
-  gr0->SetMarkerColor(1);
-  gr3015->SetMarkerColor(2);
-  gr4025->SetMarkerColor(3);
-  gr5035->SetMarkerColor(4);
-  gr6045->SetMarkerColor(6);
-
-  gr0->SetLineColor(1);
-  gr3015->SetLineColor(2);
-  gr4025->SetLineColor(3);
-  gr5035->SetLineColor(4);
-  gr6045->SetLineColor(6);
-
-  //////////////////////
-  // plot alpha width //
-  //////////////////////
-  TCanvas *c1 = new TCanvas("c1","c1",800,500);
-  c1->cd(1);
-  gPad->SetGridx();  
-  gPad->SetGridy();  
-  gPad->SetLogx();
-
-  TGraphErrors* grfirst = gr4025;
-  grfirst->Draw("APL");
-  gr0->Draw("PL");
-  gr3015->Draw("PL");
-  gr4025->Draw("PL");
-  gr5035->Draw("PL");
-  gr6045->Draw("PL");
-
-  grfirst->GetHistogram()->SetTitle("Cleaning comparison (alpha)");
-  grfirst->GetHistogram()->GetXaxis()->SetTitle("E_{MC} [GeV]");
-  grfirst->GetHistogram()->GetYaxis()->SetTitle("#sigma (alpha-alpha_{0}) [deg]");
-  grfirst->GetHistogram()->SetMaximum(80);
-
-  TPaveLabel* label = new TPaveLabel(0.25,0.75,0.6,0.85,"MC Gammas - zbins 0-3","NDC");
-  label->SetBorderSize(0);
-  label->SetFillColor(0);
-  label->Draw();
-
-  // legend
-  TLegend* leg = new TLegend(.6,.5,.8,.8);
-  leg->SetHeader("");
-  leg->SetFillColor(0);
-  leg->SetLineColor(0);
-  leg->SetBorderSize(0);
-  leg->AddEntry(gr0,"No noise","p");
-  leg->AddEntry(gr3015,"(3.0,1.5)","p");
-  leg->AddEntry(gr4025,"(4.0,2.5)","p");
-  leg->AddEntry(gr5035,"(5.0,3.5)","p");
-  leg->AddEntry(gr6045,"(6.0,4.5)","p");
-  leg->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-  // print to file
-  c1->Print("cleanAlphaWidthVSEnergy.ps");
-}
-
-/*******************************************************************************/
-void plotEfficiencies(TChain* ton)
-{
-  const Int_t nbins = 8;
-  Float_t bound[nbins+1] ={0,30,50,80,150,300,600,1200,3000}; // boundary of considered size bins
-  
-  // define the arrays that will feed the graphs
-  // gamma detection efficiency, and errors  
-  Float_t effNOCL[nbins];
-  Float_t eff3015[nbins];
-  Float_t eff4025[nbins];
-  Float_t eff5035[nbins];
-  Float_t eff6045[nbins];
-
-  Float_t eeffNOCL[nbins];
-  Float_t eeff3015[nbins];
-  Float_t eeff4025[nbins];
-  Float_t eeff5035[nbins];
-  Float_t eeff6045[nbins];
-
-  // x axis and error
-  Float_t x[nbins];
-  Float_t ex[nbins];
-
-  // fill the arrays
-  for(Int_t i=0;i<nbins;i++)
-    {
-      //      cout << "Bin " << i << endl;
-      TH1F dummyNOCL("dummyNOCL" ,"dummyNOCL",100,-90,90);
-      TH1F dummy3015("dummy3015" ,"dummy3015",100,-90,90);
-      TH1F dummy4025("dummy4025" ,"dummy4025",100,-90,90);
-      TH1F dummy5035("dummy5035" ,"dummy5035",100,-90,90);
-      TH1F dummy6045("dummy6045" ,"dummy6045",100,-90,90);
-
-      TH1F xdummy("xdummy" ,"xdummy",100,bound[i],bound[i+1]);
-
-      // define the cuts for each of the cleaning levels
-      char cut[100];
-      sprintf(cut,"energy>%f && energy<%f && alpha0!=0",bound[i],bound[i+1]);
-      char cutNOCL[200];
-      sprintf(cutNOCL,"%s && alphaNOCL!=0",cut);
-      char cut3015[200];
-      sprintf(cut3015,"%s && alpha3015!=0",cut);
-      char cut4025[200];
-      sprintf(cut4025,"%s && alpha4025!=0",cut);
-      char cut5035[200];
-      sprintf(cut5035,"%s && alpha5035!=0",cut);
-      char cut6045[200];
-      sprintf(cut6045,"%s && alpha6045!=0",cut);
-
-
-      // fill the histograms to extract later the information from rms, entries, means, etc
-      ton->Draw("alpha0>>dummyNOCL",cutNOCL);
-      ton->Draw("alpha0>>dummy3015",cut3015);
-      ton->Draw("alpha0>>dummy4025",cut4025);
-      ton->Draw("alpha0>>dummy5035",cut5035);
-      ton->Draw("alpha0>>dummy6045",cut6045);
-
-      ton->Draw("energy>>xdummy",cut);
-
-      Float_t nevt0    = dummyNOCL.GetEntries();
-      Float_t nevt3015 = dummy3015.GetEntries();
-      Float_t nevt4025 = dummy4025.GetEntries();
-      Float_t nevt5035 = dummy5035.GetEntries();
-      Float_t nevt6045 = dummy6045.GetEntries();
-
-      // fill the array of efficiencies
-      eff3015[i] = nevt3015/nevt0*100;
-      eff4025[i] = nevt4025/nevt0*100;
-      eff5035[i] = nevt5035/nevt0*100;
-      eff6045[i] = nevt6045/nevt0*100;
-
-      eeff3015[i] = TMath::Sqrt(nevt3015)/nevt0*100;
-      eeff4025[i] = TMath::Sqrt(nevt4025)/nevt0*100;
-      eeff5035[i] = TMath::Sqrt(nevt5035)/nevt0*100;
-      eeff6045[i] = TMath::Sqrt(nevt6045)/nevt0*100;
-
-      //      cout << xdummy.GetMean() << " " << xdummy.GetRMS()<< " " << xdummy.GetEntries() << endl;
-      x[i]  = xdummy.GetMean();            
-      //      Float_t rms = xdummy.GetRMS();
-      ex[i] = 0;//rms*rms/xdummy.GetEntries();
-    }
-
-  // create the graphs
-  TGraphErrors* efgr3015 = new TGraphErrors(nbins,x,eff3015,ex,eeff3015);
-  TGraphErrors* efgr4025 = new TGraphErrors(nbins,x,eff4025,ex,eeff4025);
-  TGraphErrors* efgr5035 = new TGraphErrors(nbins,x,eff5035,ex,eeff5035);
-  TGraphErrors* efgr6045 = new TGraphErrors(nbins,x,eff6045,ex,eeff6045);  
-
-  // marker/line colors
-  efgr3015->SetMarkerStyle(24);
-  efgr4025->SetMarkerStyle(21);
-  efgr5035->SetMarkerStyle(25);
-  efgr6045->SetMarkerStyle(22);
-
-  efgr3015->SetMarkerColor(2);
-  efgr4025->SetMarkerColor(3);
-  efgr5035->SetMarkerColor(4);
-  efgr6045->SetMarkerColor(6);
-
-  efgr3015->SetLineColor(2);
-  efgr4025->SetLineColor(3);
-  efgr5035->SetLineColor(4);
-  efgr6045->SetLineColor(6);
-
-  ///////////////////////
-  // plot efficiencies //
-  ///////////////////////
-  TCanvas *c1 = new TCanvas("c1","c1",800,500);
-  c1->cd(1);
-  gPad->SetGridx();  
-  gPad->SetGridy();  
-  gPad->SetLogx();
-
-  TGraphErrors* efgrfirst = efgr6045;
-  efgrfirst->Draw("APL");
-  efgr3015->Draw("PL");
-  efgr4025->Draw("PL");
-  efgr5035->Draw("PL");
-  efgr6045->Draw("PL");
-
-  efgrfirst->GetHistogram()->SetTitle("Cleaning comparison (efficiency)");
-  efgrfirst->GetHistogram()->GetXaxis()->SetTitle("E_{MC} [GeV]");
-  efgrfirst->GetHistogram()->GetYaxis()->SetTitle("Detection efficiency (%)");
-
-  // label
-  TPaveLabel* eflabel = new TPaveLabel(0.5,0.49,0.85,0.59,"MC Gammas - zbins 0-3","NDC");
-  eflabel->SetBorderSize(0);
-  eflabel->SetFillColor(0);
-  eflabel->Draw();
- 
-  // legend
-  TLegend* efleg = new TLegend(.6,.2,.8,.5);
-  efleg->SetHeader("");
-  efleg->SetFillColor(0);
-  efleg->SetLineColor(0);
-  efleg->SetBorderSize(0);
-  efleg->AddEntry(efgr3015,"(3.0,1.5)","p");
-  efleg->AddEntry(efgr4025,"(4.0,2.5)","p");
-  efleg->AddEntry(efgr5035,"(5.0,3.5)","p");
-  efleg->AddEntry(efgr6045,"(6.0,4.5)","p");
-  efleg->Draw();
-
-  gPad->Modified();
-  gPad->Update();
-
-  // print to file
-  c1->Print("cleanEfficiency.ps");
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/computeCoeff.C	(revision 7136)
+++ 	(revision )
@@ -1,61 +1,0 @@
-
-
-void computeCoeff()
-{    
-  MEffAreaAndCoeffCalc calc;
-  calc.AddFile("/data/star_gamma_test.root");
-
-  /************************************************/
-  /* Build spectrum                               */
-  /* now it's just a cross check with the same MC */
-  /************************************************/
-  const Int_t ebins = 20;              // number of bins to build spectrum
-  const Double_t emin=10;
-  const Double_t emax=200;
-  const Int_t tbins = 2;
-  const Double_t thetab[tbins+1] = {0,10,20};
-  calc.SetEbins(ebins);
-  calc.SetEmin(emin);
-  calc.SetEmax(emax);
-  calc.SetThetaBinning(tbins,thetab);
-  
-  // define the funtion of the desired spectrum
-  calc.SetFunction("4.e9*pow(x,-2.6+1)");
-  calc.ComputeAllFactors();
-  
-  const UInt_t ncutfiles=1;
-  Char_t* cutName[ncutfiles]={"/data/star_gamma_test.root"};
-
-  TChain* ccut = new TChain("Events");
-  for(Int_t i = 0; i < ncutfiles; i++)
-    ccut->Add(cutName[i]);
-  ccut->SetAlias("logestenergy","log10(MHillas.fSize/0.18/15.)");
-  ccut->SetAlias("theta","MMcEvt.fTelescopeTheta*180./3.14159");
-
-
-  const Double_t logemin = TMath::Log10(emin);
-  const Double_t logemax = TMath::Log10(emax);
-  TH1D* hspec = new TH1D("hspec","Spectrum",ebins,logemin,logemax);
-  hspec->Sumw2();
-  ccut->Draw("logestenergy>>hspec","theta<10","goff");
-
-  for(Int_t i=0;i<ebins;i++)
-    {
-      const Float_t uncorrval = hspec->GetBinContent(i+1);
-      const Float_t effa  =  calc.GetEffectiveAreaHisto()->GetBinContent(i+1,1);
-      const Float_t unfold = calc.GetCoefficientHisto()->GetBinContent(i+1,1);
-      Float_t corrval;
-      if(effa)
-	corrval = uncorrval*unfold/effa*1e9;
-      else
-	corrval = 0;
-      hspec->SetBinContent(i+1,corrval);
-    }
-
-  // SAVE RESULTS
-  TFile file("prueba.root","RECREATE");
-  hspec->Write();
-  calc.GetEffectiveAreaHisto()->Write();
-  calc.GetCoefficientHisto()->Write();
-  return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/distancebetweenstars.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/distancebetweenstars.C	(revision 7136)
+++ 	(revision )
@@ -1,249 +1,0 @@
- /* ======================================================================== *\
-!
-! *
-! * 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): Javier López, 05/2004 <mailto:jlopez@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
-Double_t fitfunc(Double_t *x, Double_t *par);
-
-void distancebetweenstars(const TString filename="dc_2004_03_17_01_16_51_20440_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_17/", const UInt_t numEvents = 100000000)
-{
-
-    // general settings
-    gROOT->Reset();
-    gStyle->SetCanvasColor(0);
-    gStyle->SetCanvasBorderMode(0);
-    gStyle->SetPadBorderMode(0);
-    gStyle->SetFrameBorderMode(0);
-    gStyle->SetOptTitle(0);
-    gStyle->SetTitleOffset(1.7,"y");
-    gStyle->SetPadLeftMargin(0.15);
-    gStyle->SetOptStat(111110);
-    gStyle->SetOptFit(1);
-    gStyle->SetStatColor(0);
-    gStyle->SetStatBorderSize(1);
-    gStyle->SetStatW(0.2);
-    gStyle->SetStatH(0.1);
-    gStyle->SetStatX(0.9);
-    gStyle->SetStatY(0.9);
-
-  Int_t nbins  = 100;
-  Float_t mindist = 0.0;
-  Float_t maxdist = 400.0;
-  
-  TH1F* histStarsDintances = new TH1F("StarsDintances","Distance between stars",nbins,mindist,maxdist);
-  histStarsDintances->SetXTitle("Distance [mm]");
-  histStarsDintances->SetYTitle("Counts [#]");
-  TH1F* histStarsDintances1 = new TH1F("StarsDintances1","Distance between stars",nbins,mindist,maxdist);
-  TH1F* histStarsDintances2 = new TH1F("StarsDintances2","Distance between stars [1]-[3]",nbins,mindist,maxdist);
-  TH1F* histStarsDintances3 = new TH1F("StarsDintances3","Distance between stars [2]-[3]",nbins,mindist,maxdist);
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  MGeomCamMagic geomcam;
-  MCameraDC     dccam;
-  MStarLocalCam starcam;
-
-  plist.AddToList(&geomcam);
-  plist.AddToList(&dccam);
-  plist.AddToList(&starcam);
-
-  //
-  // Now setup the tasks and tasklist:
-  // ---------------------------------
-  //
-
-  // Reads the trees of the root file and the analysed branches
-  MReadReports read;
-  read.AddTree("Currents"); 
-  read.AddFile(directory+filename);     // after the reading of the trees!!!
-  read.AddToBranchList("MReportCurrents.*");
-
-  MGeomApply geomapl;
-  TString continuoslightfile = 
-    //    "/home/Javi/mnt_magic_data/CaCo/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
-        "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
-
-  Float_t mindc = 0.7;
-  MCalibrateDC dccal;
-  dccal.SetFileName(continuoslightfile);
-  dccal.SetMinDCAllowed(mindc);
-
-  const Int_t numblind = 5;
-  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
-  const TArrayS blindpixels(numblind,(Short_t*)x);
-  Float_t ringinterest = 100; //[mm]
-  Float_t tailcut = 4.0;
-  UInt_t integratedevents = 1;
-
-  MFindStars findstars;
-  findstars.SetBlindPixels(blindpixels);
-  findstars.SetRingInterest(ringinterest);
-  findstars.SetDCTailCut(tailcut);
-  findstars.SetNumIntegratedEvents(integratedevents);
-  findstars.SetMinuitPrintOutLevel(-1);
-
-  tlist.AddToList(&geomapl);
-  tlist.AddToList(&read);
-  tlist.AddToList(&dccal);
-  tlist.AddToList(&findstars, "Currents");
-
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-  
-//   MProgressBar bar;
-//   evtloop.SetProgressBar(&bar);
-  
-  //
-  // Execute your analysis
-  //
-  
-//   if (!evtloop.Eventloop(numEvents))
-//     return;
-
-  if (!evtloop.PreProcess())
-    return;
-
-  Float_t maxchindof = 4.;
-  
-  while (tlist.Process())
-    {
-  
-      Int_t numStars = starcam.GetNumStars();
-      if ( numStars == 3)
-        {
-          
-          for (Int_t first=0; first<numStars; first++)
-            {
-              if (starcam[first].GetChiSquareNdof()>0. && starcam[first].GetChiSquareNdof()<maxchindof)
-                {
-                  for (Int_t second=first+1; second<numStars; second++)
-                    {
-                      if (starcam[second].GetChiSquareNdof()>0. && starcam[second].GetChiSquareNdof()<maxchindof)
-                        {
-                          Float_t dist = TMath::Sqrt((starcam[first].GetMeanX()-starcam[second].GetMeanX())*
-                                                     (starcam[first].GetMeanX()-starcam[second].GetMeanX()) +
-                                                     (starcam[first].GetMeanY()-starcam[second].GetMeanY())*
-                                                     (starcam[first].GetMeanY()-starcam[second].GetMeanY()));
-
-                            histStarsDintances->Fill(dist);
-                          if (first == 0 && second == 1)
-                            histStarsDintances1->Fill(dist);
-                          else if (first == 0 && second == 2)
-                            histStarsDintances2->Fill(dist);
-                          else if (first == 1 && second == 2)
-                            histStarsDintances3->Fill(dist);
-
-                        }
-                    }
-                }
-            }
-        }
-    }
-  
-  
-
-  evtloop.PostProcess();
-
-  tlist.PrintStatistics();
-
-  //Draw results
-
-  //   histStarsDintances->Draw();
-
-// Creates a Root function based on function fitf above
-   TF1 *func = new TF1("fitfunc",fitfunc,mindist,maxdist,7);
-
-// Sets initial values and parameter names
-   func->SetParNames("ConvF","Max0","Sig0","Max1","Sig1","Max2","Sig2");
-   func->SetParameters(300.,500.,5.,500.,5.,500.,5.);
-
-// Fit histogram in range defined by function
-   histStarsDintances->Fit("fitfunc","R");
-
-//   histStarsDintances1->Draw();
-//   histStarsDintances2->Fit("gaus","0");
-//   histStarsDintances2->Draw("same");
-//   histStarsDintances2->Fit("gaus","0");
-//   histStarsDintances3->Draw("same");
-//   histStarsDintances3->Fit("gaus","0");
-
-  if (!HandleInput())
-
-  delete histStarsDintances;
-  delete histStarsDintances1;
-  delete histStarsDintances2;
-  delete histStarsDintances3;
-  
-}
-
-Double_t fitfunc(Double_t *x, Double_t *par)
-{
-  Double_t dist[3] = 
-    {
-      0.64,0.750,1.203
-    };
-  
-  
-   Double_t fitval = 
-     par[1]*TMath::Exp(-0.5*(x[0]-par[0]*dist[0])*(x[0]-par[0]*dist[0])/(par[2]*par[2])) +
-     par[3]*TMath::Exp(-0.5*(x[0]-par[0]*dist[1])*(x[0]-par[0]*dist[1])/(par[4]*par[4])) +
-     par[5]*TMath::Exp(-0.5*(x[0]-par[0]*dist[2])*(x[0]-par[0]*dist[2])/(par[6]*par[6]));
-
-   //   cout << "x "  << x[0] << " fitval " << fitval << endl;
-   
-
-   return fitval;
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/findstars.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/findstars.C	(revision 7136)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López, 05/2004 <mailto:jlopez@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
-
-void findstars(const TString filename="20040422_*_D_Mrk421_E.root", const TString directory="/local_disk/Data/rootdata/Mrk421/Period016/2004_04_22/", const UInt_t numEvents = 0)
-{
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-
-  MGeomCamMagic geomcam;
-  MCameraDC     dccam;
-  MStarLocalCam starcam;
-
-  plist.AddToList(&geomcam);
-  plist.AddToList(&dccam);
-  plist.AddToList(&starcam);
-
-  //
-  // Now setup the tasks and tasklist:
-  // ---------------------------------
-  //
-
-  // Reads the trees of the root file and the analysed branches
-  MReadReports read;
-  read.AddTree("Currents"); 
-  read.AddFile(directory+filename);     // after the reading of the trees!!!
-  read.AddToBranchList("MReportCurrents.*");
-
-  MGeomApply geomapl;
-  TString continuoslightfile = 
-    "/local_disk/CaCoData/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
-
-  Float_t mindc = 0.9; //[uA]
-  MCalibrateDC dccal;
-  dccal.SetFileName(continuoslightfile);
-  dccal.SetMinDCAllowed(mindc);
-
-  const Int_t numblind = 5;
-  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
-  const TArrayS blindpixels(numblind,(Short_t*)x);
-  Float_t ringinterest = 100; //[mm]
-  Float_t tailcut = 3.5;
-  UInt_t integratedevents = 4;
-
-  MFindStars findstars;
-  findstars.SetBlindPixels(blindpixels);
-  findstars.SetRingInterest(ringinterest);
-  findstars.SetDCTailCut(tailcut);
-  findstars.SetNumIntegratedEvents(integratedevents);
-  findstars.SetMinuitPrintOutLevel(-1);
-
-  
-  tlist.AddToList(&geomapl);
-  tlist.AddToList(&read);
-  tlist.AddToList(&dccal);
-  tlist.AddToList(&findstars, "Currents");
-
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-     
-  //
-  // Execute your analysis
-  //
-
-  if (numEvents > 0)
-  {
-      if (!evtloop.Eventloop(numEvents))
-	  return;
-  }
-  else
-  {
-      if (!evtloop.PreProcess())
-	  return;
-      
-//        MHCamera display0(geomcam);
-//        display0.SetPrettyPalette();
-//        display0.Draw();
-//        //       display0.SetCamContent(dccal.GetDisplay());
-//        display0.SetCamContent(dccal.GetDCCalibrationFactor());
-//        gPad->Modified();
-//        gPad->Update();
-
-//        // Remove the comments if you want to go through the file
-//        // event-by-event:
-//        if (!HandleInput())
-//          break;
-
-       MHCamera display(geomcam);
-       display.SetPrettyPalette();
-       display.Draw();
-       gPad->cd(1);
-       starcam.Draw();
-      
-       UInt_t numevents=0;
-       
-       while (tlist.Process())
-         {
-           numevents++;
-           if (numevents%integratedevents==0)
-             {
-               //               display.SetCamContent(dccam);
-               display.SetCamContent(findstars.GetDisplay());
-               gPad->Modified();
-               gPad->Update();
-               starcam.Print("maxpossizechi");
-               // Remove the comments if you want to go through the file
-               // event-by-event:
-               if (!HandleInput())
-                 break;
-             }
-      } 
-
-      evtloop.PostProcess();
-  }
-
-  tlist.PrintStatistics();
-
-}
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/hillasONOFF.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/hillasONOFF.C	(revision 7136)
+++ 	(revision )
@@ -1,1339 +1,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-//           _____Macro for checking the hillas parameters_____
-//
-//                       Ester Aliu  <aliu@ifae.es>
-////////////////////////////////////////////////////////////////////////////
-void hillasONOFF()
-{    
-    // general settings
-    gROOT->Reset();
-    gStyle->SetCanvasColor(0);
-    gStyle->SetCanvasBorderMode(0);
-    gStyle->SetPadBorderMode(0);
-    gStyle->SetFrameBorderMode(0);
-    gStyle->SetOptStat(kFALSE);
-    // gStyle->SetTitleSize(0);
-    gStyle->SetStatColor(0);
-    gStyle->SetStatBorderSize(1);
-    gStyle->SetStatW(0.2);
-    gStyle->SetStatH(0.1);
-    gStyle->SetStatX(0.9);
-    gStyle->SetStatY(0.9);
- 
-       
-    // define file, tree, canvas
-    TChain* t= new TChain("Parameters");
-    //    t->AddFile("/local_disk/jrico/hillas/hillasOn21.root");
-    //    t->AddFile("/local_disk/jrico/hillas/hillasOn22.root");
-    t->AddFile("/local_disk/jrico/hillas/RFOnnoAlpha.root");
-    
-    // define file, tree, canvas
-    TChain *t2 = new TChain("Parameters");
-    //    t2->AddFile("/local_disk/jrico/hillas/hillasOff09.root");
-    //    t2->AddFile("/local_disk/jrico/hillas/hillasOff18.root");
-    //    t2->AddFile("/local_disk/jrico/hillas/hillasOff21.root");
-    t2->AddFile("/local_disk/jrico/hillas/RFOffnoAlpha.root");
-
-   
-    TString psname="hillasonoff.ps";
-    TString title;
-
-    TH1F* hLength; 
-    TH1F* hWidth; 
-    TH1F* hDist;
-    TH1F* hConc;
-    TH1F* hConc1;
-    TH1F* hConc6;
-    TH1F* hAlpha; 
-    TH1F* hSize; 
-
-    TH2F *hXY;
-
-    // define aliases
-    t->SetAlias("length","MHillas.fLength*0.6/189");
-    t->SetAlias("width","MHillas.fWidth*0.6/189");
-    t->SetAlias("dist","MHillasSrc.fDist*0.6/189");
-    t->SetAlias("conc","MNewImagePar.fConc");
-    t->SetAlias("conc1","MNewImagePar.fConc1");
-    t->SetAlias("conc6","MConcentration.fConc[6]");
-    t->SetAlias("size","MHillas.fSize");
-    t->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
-    t->SetAlias("meanx","MHillas.fMeanX");
-    t->SetAlias("meany","MHillas.fMeanY");
-
-    // define aliases
-    t2->SetAlias("length","MHillas.fLength*0.6/189");
-    t2->SetAlias("width","MHillas.fWidth*0.6/189");
-    t2->SetAlias("dist","MHillasSrc.fDist*0.6/189");
-    t2->SetAlias("conc","MNewImagePar.fConc");
-    t2->SetAlias("conc1","MNewImagePar.fConc1");
-    t2->SetAlias("conc6","MConcentration.fConc[6]");
-    t2->SetAlias("size","MHillas.fSize");
-    t2->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
-    t2->SetAlias("meanx","MHillas.fMeanX");
-    t2->SetAlias("meany","MHillas.fMeanY");
-
-      
-    // define  cuts
-    const char* cut1 = "size>500 && MHadronness.fHadronness<0.1";
-    const char* cut2 = "size>1000";
-    const char* cut3 = "size>2000";
-    const char* cut4 = "size>5000";
-    const char* cut5 = "size>10000";
-
-    const char* cutDist = "MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189.<0.8";
-
-
-    /*****************************************************************
-    ****                         PLOTS                            ****
-    *****************************************************************/
-    
-    Int_t nbin;
-    Float_t min;
-    Float_t max;
-
-
-    TString openpsname;
-    openpsname = psname + "(";
-
-    TString closepsname;
-    closepsname = psname  + ")";
-
-
-    //////////////////////////////////////////////////////////////
-    //                    Cuts in Size
-    //////////////////////////////////////////////////////////////
-    TCanvas *c1 = new TCanvas("c1","c1",500,800);
-    c1->Divide(2,3);
-    /////////////////////////////////////////////////////////////////
-
-    char* var="length>>hLength";    
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c1->cd(1);
-    c1->GetPad(1)->SetGrid();    
-    title = "length " ;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var, "","goff");  
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-    
-    c1->cd(2);
-    c1->GetPad(2)->SetGrid();    
-    title = "length ";  
-    title = title + cut1;
-    hLength = new TH1F("hLength",title, nbin, min, max);
-    t->Draw(var,cut1,"goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");    
-    c1->GetPad(2)->Update();
-  
-    c1->cd(3);
-    c1->GetPad(3)->SetGrid();    
-    title = "length ";  
-    title = title + cut2;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var,cut2,"goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");
-    c1->GetPad(3)->Update();
-  
-    c1->cd(4);
-    c1->GetPad(4)->SetGrid();    
-    title = "length ";  
-    title = title + cut3;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var,cut3, "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");
-    c1->GetPad(4)->Update();
-        
-    c1->cd(5);
-    c1->GetPad(5)->SetGrid();    
-    title = "length ";  
-    title = title + cut4;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var,cut4, "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");
-    c1->GetPad(5)->Update();
-        
-    c1->cd(6);
-    c1->GetPad(6)->SetGrid();    
-    title = "length ";  
-    title = title + cut5;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var,cut5, "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1.);
-    hLength->Draw("Ehist");
-    c1->GetPad(6)->Update();
-   
-    //off data
-
-    c1->cd(1);
-    title = "length " ;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var, "","goff");  
-    hLength->SetXTitle("degrees");
-    //hLength->SetLineStyle(2);
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-    
-    c1->cd(2);
-    title = "length ";  
-    title = title + cut1;
-    hLength = new TH1F("hLength",title, nbin, min, max);
-    t2->Draw(var,cut1,"goff");
-    hLength->SetXTitle("degrees");
-    //hLength->SetLineStyle(2);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetMarkerStyle(20);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");    
-    c1->GetPad(2)->Modified();    
-    c1->GetPad(2)->Update();
-  
-    c1->cd(3);
-    title = "length ";  
-    title = title + cut2;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var,cut2,"goff");
-    //hLength->SetXTitle("degrees");
-    hLength->SetMarkerSize(0.4);
-    hLength->SetMarkerStyle(20);
-    //hLength->SetLineStyle(2);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-  
-    c1->cd(4);
-    title = "length ";  
-    title = title + cut3;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var,cut3, "goff");
-    hLength->SetXTitle("degrees");
-    //    hLength->SetLineStyle(2);
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-        
-    c1->cd(5);
-    title = "length ";  
-    title = title + cut4;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var,cut4, "goff");
-    hLength->SetXTitle("degrees");
-    //hLength->SetLineStyle(2);
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-        
-    c1->cd(6);
-    title = "length ";  
-    title = title + cut5;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var,cut5, "goff");
-    hLength->SetXTitle("degrees");
-    // hLength->SetLineStyle(2);
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-    
-    c1->Print(openpsname); 
-
-    /////////////////////////////////////////////////////////////////
-    char* var="width>>hWidth";
-
-    nbin = 40; min = 0.; max = 0.8;
-
-    c1->cd(1);
-    title = "width ";  
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var, "", "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "width ";  
-    title = title + cut1;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cut1, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "width ";  
-    title = title + cut2;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cut2, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "width ";  
-    title = title + cut3;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cut3, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "width ";  
-    title = title + cut4;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cut4, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "width ";  
-    title = title + cut5;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cut5, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1.);
-    hWidth->Draw("Ehist");
-    c1->GetPad(6)->Update();
-
-    // offdata
-   
-    c1->cd(1);
-    title = "width ";  
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var, "", "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "width ";  
-    title = title + cut1;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cut1, "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");    
-    c1->GetPad(2)->Modified();    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "width ";  
-    title = title + cut2;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cut2, "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "width ";  
-    title = title + cut3;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cut3, "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "width ";  
-    title = title + cut4;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cut4, "goff");
-    hWidth->SetXTitle("degrees");
-    // hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "width ";  
-    title = title + cut5;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cut5, "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-
-   
-    c1->Print(psname); 
- 
-    /////////////////////////////////////////////////////////////////
-
-    char* var="dist>>hDist";
-      
-    nbin = 40; min = 0.; max = 1.6;
-
-    c1->cd(1);
-    title = "dist ";  
-    hDist = new TH1F("hDist",title,nbin, min, max);   
-    t->Draw(var, "", "goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "dist ";  
-    title = title + cut1;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t->Draw(var,cut1, "goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "dist ";  
-    title = title + cut2;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t->Draw(var,cut2, "goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "dist ";  
-    title = title + cut3;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t->Draw(var,cut3, "goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "dist ";  
-    title = title + cut4;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t->Draw(var,cut4, "goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "dist ";  
-    title = title + cut5;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t->Draw(var,cut5,"goff");
-    hDist->SetXTitle("degrees");
-    hDist->SetNormFactor(1.);
-    hDist->Draw("Ehist");
-    c1->GetPad(6)->Update();
-
-    //offdata
-
-    c1->cd(1);
-    title = "dist ";  
-    hDist = new TH1F("hDist",title,nbin, min, max);   
-    t2->Draw(var, "", "goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "dist ";  
-    title = title + cut1;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t2->Draw(var,cut1, "goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");    
-    c1->GetPad(2)->Modified();    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "dist ";  
-    title = title + cut2;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t2->Draw(var,cut2, "goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);   
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "dist ";  
-    title = title + cut3;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t2->Draw(var,cut3, "goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "dist ";  
-    title = title + cut4;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t2->Draw(var,cut4, "goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "dist ";  
-    title = title + cut5;
-    hDist = new TH1F("hDist",title,nbin, min, max);
-    t2->Draw(var,cut5,"goff");
-    hDist->SetXTitle("degrees");
-    //hDist->SetLineStyle(2);
-    hDist->SetMarkerStyle(20);
-    hDist->SetMarkerSize(0.4);
-    hDist->SetNormFactor(1);
-    hDist->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-
-    c1->Print(psname); 
-
-    /////////////////////////////////////////////////////////////////
-    char* var="conc>>hConc";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c1->cd(1);
-    title = "conc ";  
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,"","goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "conc ";  
-    title = title + cut1;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cut1,"goff");    
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "conc ";  
-    title = title + cut2;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cut2,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "conc ";  
-    title = title + cut3;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cut3,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "conc ";  
-    title = title + cut4;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cut4,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "conc ";  
-    title = title + cut5;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cut5,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c1->GetPad(6)->Update();
-  
-    //offdata 
-
-    c1->cd(1);
-    title = "conc ";  
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var, "","goff");
-    hConc->SetNormFactor(1.);
-    //hConc->SetLineStyle(2);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    hConc->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "conc ";  
-    title = title + cut1;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cut1,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    // hConc->SetLineStyle(2);
-    hConc->Draw("samePE");
-    c1->GetPad(2)->Modified();        
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "conc ";  
-    title = title + cut2;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cut2,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    //hConc->SetLineStyle(2);
-    hConc->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "conc ";  
-    title = title + cut3;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cut3,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    //hConc->SetLineStyle(2);
-    hConc->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "conc ";  
-    title = title + cut4;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cut4,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    //hConc->SetLineStyle(2);
-    hConc->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "conc ";  
-    title = title + cut5;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cut5,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    //hConc->SetLineStyle(2);
-    hConc->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-  
-    c1->Print(psname); 
-
-    /////////////////////////////////////////////////////////////////
-    char* var="conc6>>hConc6";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c1->cd(1);
-    title = "conc6 ";  
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,"","goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "conc6 ";  
-    title = title + cut1;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cut1,"goff");  
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");  
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "conc6 ";  
-    title = title + cut2;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cut2,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "conc6 ";  
-    title = title + cut3;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cut3,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "conc6 ";  
-    title = title + cut4;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cut4,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "conc6 ";  
-    title = title + cut5;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cut5,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c1->GetPad(6)->Update();
-
-    //offdata
-
-    c1->cd(1);
-    title = "conc6 ";  
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,"","goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    //hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "conc6 ";  
-    title = title + cut1;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cut1,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    //hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(2)->Modified();        
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "conc6 ";  
-    title = title + cut2;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cut2,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    //hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "conc6 ";  
-    title = title + cut3;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cut3,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    //hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "conc6 ";  
-    title = title + cut4;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cut4,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    // hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "conc6 ";  
-    title = title + cut5;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cut5,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    //hConc6->SetLineStyle(2);
-    hConc6->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-
-    c1->Print(psname); 
-
-    /////////////////////////////////////////////////////////////////
-    char* var="alpha>>hAlpha";
-
-    nbin = 18; min = 0.; max = 90.;
-    
-    c1->cd(1);
-    title = "alpha ";  
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var, "", "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "alpha ";  
-    title = title + cut1;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cut1, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "alpha ";  
-    title = title + cut2;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cut2, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "alpha ";  
-    title = title + cut3;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cut3, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "alpha ";  
-    title = title + cut4;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cut4, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "alpha ";  
-    title = title + cut5;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cut5, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c1->GetPad(6)->Update();
-
-    //offdata
-
-    c1->cd(1);
-    title = "alpha ";  
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var, "", "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetNormFactor(1);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->Draw("samePE");
-    c1->GetPad(1)->Modified();    
-    c1->GetPad(1)->Update();    
-
-    c1->cd(2);
-    title = "alpha ";  
-    title = title + cut1;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cut1, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");    
-    c1->GetPad(2)->Modified();    
-    c1->GetPad(2)->Update();
-    
-    c1->cd(3);
-    title = "alpha ";  
-    title = title + cut2;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cut2, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetNormFactor(1);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->Draw("samePE");
-    c1->GetPad(3)->Modified();    
-    c1->GetPad(3)->Update();
-    
-    c1->cd(4);
-    title = "alpha ";  
-    title = title + cut3;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cut3, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");
-    c1->GetPad(4)->Modified();    
-    c1->GetPad(4)->Update();
-    
-    c1->cd(5);
-    title = "alpha ";  
-    title = title + cut4;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cut4, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");
-    c1->GetPad(5)->Modified();    
-    c1->GetPad(5)->Update();
-    
-    c1->cd(6);
-    title = "alpha ";  
-    title = title + cut5;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cut5, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");
-    c1->GetPad(6)->Modified();    
-    c1->GetPad(6)->Update();
-
-    c1->Print(psname); 
-
-    /////////////////////////////////////////////////////////////////
-    //                     Cuts in Dist
-    /////////////////////////////////////////////////////////////////
-
-    TCanvas *c2 = new TCanvas("c2","Cuts in Dist",500,800);
-    c2->Divide(2,3);
-    /////////////////////////////////////////////////////////////////
-    char* var="length>>hLength";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c2->cd(1);
-    //    c2->GetPad(1)->SetGrid();    
-    title = "length "; 
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var, "", "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1);
-    hLength->Draw("Ehist");
-    c2->GetPad(1)->Update();
- 
-    c2->cd(2);
-    //c2->GetPad(2)->SetGrid();    
-    title = "length ";  
-    title = title + cutDist;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t->Draw(var,cutDist, "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetNormFactor(1);
-    hLength->Draw("Ehist");
-    c2->GetPad(2)->Update();
-
-    //offdata
-        
-    c2->cd(1);
-    c2->GetPad(1)->SetGrid();    
-    title = "length "; 
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var, "", "goff");
-    hLength->SetXTitle("degrees");
-    //   hLength->SetLineStyle(2);
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c2->GetPad(1)->Modified();    
-    c2->GetPad(1)->Update();
- 
-    c2->cd(2);
-    c2->GetPad(2)->SetGrid();    
-    title = "length ";  
-    title = title + cutDist;
-    hLength = new TH1F("hLength",title,nbin, min, max);
-    t2->Draw(var,cutDist, "goff");
-    hLength->SetXTitle("degrees");
-    hLength->SetMarkerStyle(20);
-    hLength->SetMarkerSize(0.4);
-    //hLength->SetLineStyle(2);
-    hLength->SetNormFactor(1);
-    hLength->Draw("samePE");
-    c2->GetPad(1)->Modified();    
-    c2->GetPad(2)->Update();
-
-    /////////////////////////////////////////////////////////////////
-    char* var="width>>hWidth";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c2->cd(3);
-    c2->GetPad(3)->SetGrid();    
-    title = "width ";  
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var, "", "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("Ehist");
-    c2->GetPad(3)->Update();
-    
-    c2->cd(4);
-    c2->GetPad(4)->SetGrid();    
-    title = "width ";  
-    title = title + cutDist;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t->Draw(var,cutDist, "goff");
-    hWidth->SetXTitle("degrees");
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("Ehist");
-    c2->GetPad(4)->Update();
-    
-    //offdata
-
-    c2->cd(3);
-    c2->GetPad(3)->SetGrid();    
-    title = "width ";  
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var, "", "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c2->GetPad(3)->Modified();    
-    c2->GetPad(3)->Update();
-    
-    c2->cd(4);
-    c2->GetPad(4)->SetGrid();    
-    title = "width ";  
-    title = title + cutDist;
-    hWidth = new TH1F("hWidth",title,nbin, min, max);
-    t2->Draw(var,cutDist, "goff");
-    hWidth->SetXTitle("degrees");
-    //hWidth->SetLineStyle(2);
-    hWidth->SetMarkerStyle(20);
-    hWidth->SetMarkerSize(0.4);
-    hWidth->SetNormFactor(1);
-    hWidth->Draw("samePE");
-    c2->GetPad(4)->Modified();    
-    c2->GetPad(4)->Update();
-
-    /////////////////////////////////////////////////////////////////
-    char* var="conc>>hConc";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c2->cd(5);
-    c2->GetPad(5)->SetGrid();    
-    title = "conc ";  
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,"","goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c2->GetPad(5)->Update();
-    
-    c2->cd(6);
-    c2->GetPad(6)->SetGrid();    
-    title = "conc ";  
-    title = title + cutDist;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t->Draw(var,cutDist,"goff");
-    hConc->SetNormFactor(1.);
-    hConc->Draw("Ehist");
-    c2->GetPad(6)->Update();
-    
-    //offdata
-
-    c2->cd(5);
-    c2->GetPad(5)->SetGrid();    
-    title = "conc ";  
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,"", "goff");
-    //  hConc->SetLineStyle(2);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    hConc->SetNormFactor(1.);
-    hConc->Draw("samePE");
-    c2->GetPad(5)->Modified();    
-    c2->GetPad(5)->Update();
-    
-    c2->cd(6);
-    c2->GetPad(6)->SetGrid();    
-    title = "conc ";  
-    title = title + cutDist;
-    hConc = new TH1F("hConc",title,nbin, min, max);
-    t2->Draw(var,cutDist,"goff");
-    //hConc->SetLineStyle(2);
-    hConc->SetMarkerStyle(20);
-    hConc->SetMarkerSize(0.4);
-    hConc->SetNormFactor(1.);
-    hConc->Draw("samePE");
-    c2->GetPad(6)->Modified();    
-    c2->GetPad(6)->Update();
-    
-    c2->Print(psname); 
-
-    /////////////////////////////////////////////////////////////////
-    char* var="conc6>>hConc6";
-
-    nbin = 40; min = 0.; max = 1.;
-
-    c2->cd(1);
-    title = "conc6 ";  
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,"","goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c2->GetPad(1)->Update();
-    
-    c2->cd(2);
-    title = "conc6 ";  
-    title = title + cutDist;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t->Draw(var,cutDist,"goff");
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("Ehist");
-    c2->GetPad(2)->Update();
-
-    //offdata
-
-    c2->cd(1);
-    title = "conc6 ";  
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,"","goff");
-    //hConc6->SetLineStyle(2);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("samePE");
-    c2->GetPad(1)->Modified();    
-    c2->GetPad(1)->Update();
-    
-    c2->cd(2);
-    title = "conc6 ";  
-    title = title + cutDist;
-    hConc6 = new TH1F("hConc6",title,nbin, min, max);
-    t2->Draw(var,cutDist,"goff");
-    // hConc6->SetLineStyle(2);
-    hConc6->SetMarkerStyle(20);
-    hConc6->SetMarkerSize(0.4);
-    hConc6->SetNormFactor(1.);
-    hConc6->Draw("samePE");
-    c2->GetPad(2)->Modified();    
-    c2->GetPad(2)->Update(); 
-  
-    /////////////////////////////////////////////////////////////////
-    char* var="alpha>>hAlpha";
-
-    nbin = 18; min = 0.; max = 90.;
-
-    c2->cd(3);
-    title = "alpha ";  
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var, "", "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c2->GetPad(3)->Update();
-    
-    c2->cd(4);
-    title = "alpha ";  
-    title = title + cutDist;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t->Draw(var,cutDist, "goff");
-    hAlpha->SetXTitle("degrees");
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("Ehist");
-    c2->GetPad(4)->Update();
-   
-    //offdata
-
-    c2->cd(3);
-    title = "alpha ";  
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var, "", "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");
-    c2->GetPad(3)->Modified();    
-    c2->GetPad(3)->Update();
-    
-    c2->cd(4);
-    title = "alpha ";  
-    title = title + cutDist;
-    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
-    t2->Draw(var,cutDist, "goff");
-    hAlpha->SetXTitle("degrees");
-    //hAlpha->SetLineStyle(2);
-    hAlpha->SetMarkerStyle(20);
-    hAlpha->SetMarkerSize(0.4);
-    hAlpha->SetNormFactor(1);
-    hAlpha->Draw("samePE");
-    c2->GetPad(4)->Modified();    
-    c2->GetPad(4)->Update();
-
-
-    /////////////////////////////////////////////////////////////////
-    char* var="log10(size)>>hSize";
-
-    nbin = 40; min = 0.5; max = 4.5;
-
-    c2->cd(5);
-    c2->GetPad(5)->SetLogy(); 
-    title = "size ";  
-    hSize = new TH1F("hSize",title,nbin, min, max);
-    t->Draw(var, "1/MHillas.fSize", "goff");
-    hSize->SetNormFactor(1.);
-    hSize->SetXTitle("log10(ADC counts)");
-    hSize->Draw("Ehist");
-    c2->GetPad(5)->Update();
-    
-    c2->cd(6);
-    c2->GetPad(6)->SetLogy(); 
-    title = "size ";  
-    title = title + cutDist;
-    hSize = new TH1F("hSize",title,nbin, min, max);
-    t->Draw(var,"1/MHillas.fSize*(MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189<0.8)", "goff");
-    hSize->SetXTitle("log10(ADC counts)");
-    hSize->SetNormFactor(1.);
-    hSize->Draw("Ehist");
-    c2->GetPad(6)->Update(); 
-
-    //offdata
-    c2->cd(5);
-    c2->GetPad(5)->SetLogy(); 
-    title = "size ";  
-    hSize = new TH1F("hSize",title,nbin, min, max);
-    t2->Draw(var, "1/MHillas.fSize", "goff");
-    hSize->SetXTitle("log10(ADC counts)");
-    hSize->SetNormFactor(1.);
-    hSize->SetMarkerStyle(20);
-    hSize->SetMarkerSize(0.4);
-    //hSize->SetLineStyle(2);
-    hSize->Draw("samePE");
-    c2->GetPad(5)->Modified();    
-    c2->GetPad(5)->Update();
-    
-    c2->cd(6);
-    c2->GetPad(6)->SetLogy(); 
-    title = "size ";  
-    title = title + cutDist;
-    hSize = new TH1F("hSize",title,nbin, min, max);
-    t2->Draw(var,"1/MHillas.fSize*(MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189<0.8)", "goff");
-    hSize->SetXTitle("log10(ADC counts)");
-    //hSize->SetLineStyle(2);
-    hSize->SetNormFactor(1.);
-    hSize->SetMarkerStyle(20);
-    hSize->SetMarkerSize(0.4);
-    hSize->Draw("samePE");
-    c2->GetPad(6)->Modified();    
-    c2->GetPad(6)->Update(); 
-       
-    c2->Print(closepsname);                                                    
-  
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/hvnotnominal.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/hvnotnominal.C	(revision 7136)
+++ 	(revision )
@@ -1,167 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López, 04/2004 <mailto:jlopez@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
-
-void hvnotnominal(const TString filename="20040319_20821_D_Mrk421_S.root", const TString directory="/nfs/magic/CaCodata/2004_03_19/", Float_t percent = 0.01)
-{
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-
-  MGeomCamMagic geomcam;
-  MBadPixelsCam badcam;
-  MCameraHV     hvcam;
-
-  // this line is needed because the CC rep rootified file don't have run header,
-  // then the MGeomApply can not initialitaze the containers with the number of 
-  // pixels because this is done in the reinit().
-  badcam.InitSize(geomcam.GetNumPixels());
-  
-  plist.AddToList(&geomcam);
-  plist.AddToList(&badcam);
-  plist.AddToList(&hvcam);
-
-  //
-  // Now setup the tasks and tasklist:
-  // ---------------------------------
-  //
-
-  // Reads the trees of the root file and the analysed branches
-  MReadReports read;
-  read.AddTree("Camera"); 
-  read.AddFile(directory+filename);     // after the reading of the trees!!!
-  read.AddToBranchList("MReportCamera.*");
-
-  MGeomApply geomapl;
-  MFHVNotNominal fHVNominal;
-  TString hvnominal = "/mnt/users/jlopez/Mars/Files4Mars/Config/HVSettings_FF35q.conf";
-  fHVNominal.SetHVNominalValues(hvnominal);
-  //  fHVNominal.SetMaxNumPixelsDeviated(10);
-  MContinue cont_hv(&fHVNominal);
-
-  tlist.AddToList(&read);
-  tlist.AddToList(&geomapl);
-  tlist.AddToList(&cont_hv);
-
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-     
-  //
-  // Execute your analysis
-  //
-
-  MHCamera hvnotnominal(geomcam);
-  MHCamera lowhvnotnominal(geomcam);
-  MHCamera uphvnotnominal(geomcam);
-
-  if (!evtloop.PreProcess())
-    return;
-
-  TArrayD nominal = fHVNominal.GetHVNominal();
-  TArrayD lownominal = nominal;
-  TArrayD upnominal = nominal;
-  
-  for (UInt_t pix=0; pix<nominal.GetSize(); pix++)
-    {
-      lownominal[pix] *= (1-percent);
-      upnominal[pix]  *= (1+percent);
-    }
-  
-  
-  while(tlist.Process())
-    {
-      
-      hvnotnominal.CntCamContent(hvcam,lownominal,0,kFALSE);
-      hvnotnominal.CntCamContent(hvcam,upnominal,0,kTRUE);
-      
-      lowhvnotnominal.CntCamContent(hvcam,lownominal,0,kFALSE);
-      uphvnotnominal.CntCamContent(hvcam,upnominal,0,kTRUE);
-    }
-  
-
-  evtloop.PostProcess();
-  
-  tlist.PrintStatistics();
-  
-  TCanvas c1;
-  c1.Divide(2,1);
-  c1.cd(1);
-  lowhvnotnominal.SetPrettyPalette();
-  lowhvnotnominal.Draw();
-  gPad->cd(1);
-  gPad->Modified();
-  gPad->Update();
-  c1.cd(2);
-  uphvnotnominal.SetPrettyPalette();
-  uphvnotnominal.Draw();
-  gPad->cd(2);
-  gPad->Modified();
-  gPad->Update();
-
-  TCanvas c2;
-  hvnotnominal.SetPrettyPalette();
-  hvnotnominal.Draw();
-  gPad->cd(1);
-  gPad->Modified();
-  gPad->Update();
-
-  if (!HandleInput())
-    break;
-
-}
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/makeHillas.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/makeHillas.C	(revision 7136)
+++ 	(revision )
@@ -1,558 +1,0 @@
-/*********************************/
-/* Compute the hillas parameters */
-/*********************************/
-
-Bool_t readDatacards(TString& filename);
-
-// initial and final time slices to be used in signal extraction
-const Byte_t hifirst = 0;
-const Byte_t hilast  = 13;
-const Byte_t lofirst = 3;
-const Byte_t lolast  = 12;
-
-// declaration of variables read from datacards
-TString  outname;
-TString  idirname;
-MRunIter pedcaliter;
-MRunIter caliter;
-MRunIter pediter;
-MRunIter datiter;
-ULong_t  nmaxevents=999999999;
-Short_t  calflag=1;
-Float_t  lcore = 3.0;
-Float_t  ltail = 1.5;
-Int_t islflag = 0;
-Float_t  lnew  = 40;
-Int_t  kmethod = 1;
-Int_t    nfiles = 0;
-
-const TString defaultcard="input.datacard";
-
-//Slow control varialbles
-Short_t slowflag=0;
-Bool_t  isSlowControlAvailable = kFALSE;
-TString hvConfigFile="/mnt/users/jlopez/Mars/Files4Mars/Config/HVSettings_FF35q.conf";
-TString continuosLightFile="/local_disk/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
-
-
-/*************************************************************/
-int makeHillas(TString datacard = defaultcard)
-{
-
-  if(!datacard.Length())
-    datacard = defaultcard;
-
-  if(!readDatacards(datacard))
-    {
-      cout << "Error reading datacards. Stoping" << endl;
-      return -1;
-    }
-
-  // Set the general tasks/containers
-  MExtractFixedWindow    extractor;
-  extractor.SetRange(hifirst,hilast,lofirst,lolast);
-
-  MCalibrationQECam   qecam;
-  MBadPixelsCam       badcam;
-  MGeomCamMagic       geomcam;
-  MGeomApply          geomapl;
-
-  cout << endl;
-  cout << "/****************************************************/" << endl;
-  cout << "/* FIRST LOOP: PEDESTAL FOR CALIBRATION COMPUTATION */" << endl;
-  cout << "/****************************************************/" << endl;
-  cout << endl;
-
-  // If you want to exclude pixels from the beginning, read 
-  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)  
-  ifstream fin("badpixels.dat");
-  badcam.AsciiRead(fin);
-  fin.close();
-
-  MJPedestal pedloop0;
-  pedloop0.SetOutputPath("./");
-  pedloop0.SetInput(&pedcaliter);
-  pedloop0.SetExtractor(&extractor);
-  pedloop0.SetBadPixels(badcam);
-
-  if (!pedloop0.Process())
-    return;
-
-  cout << endl;
-  cout << "/*****************************/" << endl;
-  cout << "/* SECOND LOOP: CALIBRATION  */" << endl;
-  cout << "/*****************************/" << endl;        
-  cout << endl;
-
-  MJCalibration calloop;
-
-  calloop.SetOutputPath("./");
-  calloop.SetExtractor(&extractor);
-  calloop.SetInput(&caliter);
-  calloop.SetQECam(qecam);
-  calloop.SetBadPixels(pedloop0.GetBadPixels());
-  if (!calloop.Process(pedloop0.GetPedestalCam()))
-    return;
-
-  cout << endl;
-  cout << "/*************************************************/" << endl;
-  cout << "/* THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS */" << endl;
-  cout << "/*************************************************/" << endl;
-  cout << endl;
-
-  // First Compute the pedestals
-  MJPedestal pedloop;
-  pedloop.SetOutputPath("./");
-  pedloop.SetInput(&pediter);
-
-  if (!pedloop.Process())
-    return;
-
-  MPedestalCam pedcam = pedloop.GetPedestalCam();
-
-  // Now convert this pedestals in photons
-  MParList  plist3;
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
-  
-  // containers
-  MCerPhotEvt         nphot;
-  MPedPhotCam         nphotrms;
-  MExtractedSignalCam sigcam;
-
-  plist3.AddToList(&geomcam);
-  plist3.AddToList(&pedcam);
-  plist3.AddToList(&calloop.GetCalibrationCam());
-  plist3.AddToList(&qecam);
-  plist3.AddToList(&badcam);
-  plist3.AddToList(&sigcam);
-  plist3.AddToList(&nphot);
-  plist3.AddToList(&nphotrms);
-
-  
-  MCalibrate::CalibrationMode_t calMode=MCalibrate::kDefault;  
-  if(calflag==0)
-    calMode=MCalibrate::kNone;
-  if(calflag==-1)
-    calMode=MCalibrate::kDummy;
-
-  //tasks
-  MReadMarsFile read3("Events");
-  static_cast<MRead&>(read3).AddFiles(pediter); 
-  read3.DisableAutoScheme();
- 
-//   MReadReports read3;
-//   read3.AddTree("Events","MTime.",kFALSE);
-//   static_cast<MRead&>(read3).AddFiles(pediter); 
-
-   //  MExtractSignal  extsig;
-  //  extsig.SetRange(hifirst,hilast,lofirst,lolast);
-  MCalibrate      photcalc(calMode);
-  MPedPhotCalc    photrmscalc; 
-  
-  tlist3.AddToList(&read3);
-  tlist3.AddToList(&geomapl);
-  tlist3.AddToList(&extractor);
-  tlist3.AddToList(&photcalc);
-  tlist3.AddToList(&photrmscalc);
-
-  // Create and setup the eventloop
-  MEvtLoop evtloop3;
-  evtloop3.SetParList(&plist3);
-  if (!evtloop3.Eventloop())
-    return;
-  
-  tlist3.PrintStatistics();
-
-  cout << "/**********************************************/" << endl;
-  cout << "/* FOURTH LOOP: DATA CALIBRATION INTO PHOTONS */" << endl;
-  cout << "/**********************************************/" << endl;
-
-  MParList  plist4;
-  MTaskList tlist4;
-  plist4.AddToList(&tlist4);
-  
-  // containers 
-  MHillas       hillas;
-  MSrcPosCam    source;
-  MRawRunHeader runhead;
-
-  MArrivalTimeCam   timecam;
-     
-  MIslands      isl;
-  isl.SetName("MIslands1");
-  
-  MIslands      isl2;
-  isl2.SetName("MIslands2");
-
-  MReportDrive  drive;
-  MStarLocalCam starcam;
-
-  if (islflag == 1 || islflag == 2)
-    {
-      plist4.AddToList(&timecam);
-      plist4.AddToList(&isl);
-    }
-  
-  if (islflag == 2)
-    {
-      plist4.AddToList(&isl2);
-    }
-
-  if (isSlowControlAvailable)
-    {
-      plist4.AddToList(&starcam);
-    }
-  
-  
-  plist4.AddToList(&geomcam);
-  plist4.AddToList(&pedcam);
-  plist4.AddToList(&calloop.GetCalibrationCam());
-  plist4.AddToList(&qecam);
-  plist4.AddToList(&badcam);
-  plist4.AddToList(&nphot);
-  plist4.AddToList(&nphotrms);
-  plist4.AddToList(&source);
-  plist4.AddToList(&hillas);
-  plist4.AddToList(&runhead);
-  
-  //tasks
-//   MReadMarsFile read4("Events");
-//   static_cast<MRead&>(read4).AddFiles(datiter); 
-//   read4.DisableAutoScheme();
-
-  MReadReports read4;
-  read4.AddTree("Events","MTime.",kTRUE);
-  read4.AddTree("Currents");
-  read4.AddTree("Camera");
-  read4.AddTree("Drive");
-  static_cast<MRead&>(read4).AddFiles(datiter); 
-  read4.AddToBranchList("MReportCurrents.*");
-
-  // Task that use Slow control information 
-  MFHVNotNominal fhvnotnominal;
-  fhvnotnominal.SetHVNominalValues(hvConfigFile);
-  fhvnotnominal.SetMaxNumPixelsDeviated(40);
- 
-  MContinue hvnotnominal(&fhvnotnominal);
-
-  MCalibrateDC dccalib;
-  dccalib.SetFileName(continuosLightFile);
-
-  const Int_t numblind = 5;
-  const Short_t w[numblind] = { 47, 124, 470, 475, 571};
-  const TArrayS blindpixels(numblind,(Short_t*)w);
-  Float_t ringinterest = 100; //[mm]
-  Float_t tailcut = 3.5;
-  UInt_t integratedevents = 4;
-
-  MFindStars findstars;
-  findstars.SetBlindPixels(blindpixels);
-  findstars.SetRingInterest(ringinterest);
-  findstars.SetDCTailCut(tailcut);
-  findstars.SetNumIntegratedEvents(integratedevents);
-  findstars.SetMinuitPrintOutLevel(-1);
-
-  MSrcPosFromStars srcposfromstar;
-    
-  MBadPixelsTreat   interpolatebadpixels;
-  interpolatebadpixels.SetUseInterpolation();
-  
-  MImgCleanStd      clean(lcore,ltail);
-
-  MArrivalTimeCalc2 timecalc;
-  
-  MIslandCalc       island;
-  island.SetOutputName("MIslands1");
-
-  MIslandClean      islclean(lnew);
-  islclean.SetInputName("MIslands1");
-  islclean.SetMethod(kmethod);
-      
-  MIslandCalc       island2;
-  island2.SetOutputName("MIslands2");  
-  
-  
-  MHillasCalc       hcalc;
-  MHillasSrcCalc    csrc1;
-  
-  MWriteRootFile write(outname,"RECREATE");
-  
-  write.AddContainer("MTime"          , "Parameters");
-  write.AddContainer("MHillas"        , "Parameters");
-  write.AddContainer("MHillasSrc"     , "Parameters");
-  write.AddContainer("MHillasExt"     , "Parameters");
-  write.AddContainer("MNewImagePar"   , "Parameters");
-  write.AddContainer("MRawEvtHeader"  , "Parameters");
-  write.AddContainer("MRawRunHeader"  , "Parameters");
-  write.AddContainer("MConcentration" , "Parameters");
-  write.AddContainer("MSrcPosCam"     , "Parameters");
-
-  if (islflag == 1 || islflag == 2)
-    write.AddContainer("MIslands1" , "Parameters");
-  if (islflag == 2) 
-    write.AddContainer("MIslands2" , "Parameters");
-  if (isSlowControlAvailable)
-    {
-      write.AddContainer("MStarLocalCam" , "Parameters");
-      write.AddContainer("MReportDrive" , "Parameters");
-    }
-  
-  tlist4.AddToList(&read4);
-  tlist4.AddToList(&geomapl);
-  if (isSlowControlAvailable)
-    {
-      tlist4.AddToList(&hvnotnominal,"Events");
-      tlist4.AddToList(&dccalib,"Currents");
-      tlist4.AddToList(&findstars,"Currents");
-      tlist4.AddToList(&srcposfromstar,"Events");
-    }
-                       
-  tlist4.AddToList(&extractor,"Events");
-  tlist4.AddToList(&photcalc,"Events");
-  if(calflag==11)
-    tlist4.AddToList(&interpolatebadpixels);
-  tlist4.AddToList(&clean,"Events");
-
-  if (islflag == 1 || islflag == 2)
-    {
-      tlist4.AddToList(&timecalc,"Events");
-      tlist4.AddToList(&island,"Events");
-    }
-
-  if (islflag == 2)
-    {
-      tlist4.AddToList(&islclean,"Events");
-      tlist4.AddToList(&island2,"Events");
-    }
-  
-  //tlist4.AddToList(&blind2,"Events");
-  tlist4.AddToList(&hcalc,"Events");
-  tlist4.AddToList(&csrc1,"Events");
-  tlist4.AddToList(&write,"Events");
-
-  // Create and setup the eventloop
-  MEvtLoop datloop;
-  datloop.SetParList(&plist4);
-
-  cout << endl;
-  cout << "******************************************************" << endl;
-  cout << "* COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS) *" << endl;
-  cout << "******************************************************" << endl;
-  cout << endl;
-
-  if (!datloop.Eventloop(nmaxevents))
-    return;
-
-  tlist4.PrintStatistics();    
-
-}
-//-------------------------------------------------------------------------------
-
-Bool_t readDatacards(TString& filename)
-{
-  ifstream ifun(filename.Data());
-  if(!ifun)
-    {
-      cout << "File " << filename << " not found" << endl;
-      return kFALSE;
-    }
-
-  TString word;
-  
-  while(ifun >> word)
-    {
-
-      // skip comments
-      if(word[0]=='/' && word[1]=='/')
-	{
-	  while(ifun.get()!='\n'); // skip line
-	  continue;
-	}
-
-      // number of events
-      if(strcmp(word.Data(),"NEVENTS")==0)
-	ifun >> nmaxevents;
-
-
-      // input file directory
-      if(strcmp(word.Data(),"IDIR")==0)
-	{
-	  if(idirname.Length())
-	    cout << "readDataCards Warning: overriding input directory file name" << endl;
-	  ifun >> idirname;
-	}
-
-       // pedestal runs for calibration
-      if(strcmp(word.Data(),"PCRUNS")==0)
-	{
-	  if(pedcaliter.GetNumRuns())
-	    cout << "readDataCards Warning: adding pedestal runs for calibration to the existing list" << endl;
-	  ifun >> word;
-	  pedcaliter.AddRuns(word.Data(),idirname.Data());
-	}
-
-      // calibration runs
-      if(strcmp(word.Data(),"CRUNS")==0)
-	{
-	  if(caliter.GetNumRuns())
-	    cout << "readDataCards Warning: adding calibration runs to the existing list" << endl;
-	  ifun >> word;
-	  caliter.AddRuns(word.Data(),idirname.Data());
-	}
-
-     // pedestal runs for data
-      if(strcmp(word.Data(),"PRUNS")==0)
-	{
-	  if(pediter.GetNumRuns())
-	    cout << "readDataCards Warning: adding pedestal runs for data to the existing list" << endl;
-	  ifun >> word;
-	  pediter.AddRuns(word.Data(),idirname.Data());
-	}
-
-      // data runs
-      if(strcmp(word.Data(),"DRUNS")==0)
-	{
-	  if(datiter.GetNumRuns())
-	    cout << "readDataCards Warning: adding data runs to the existing list" << endl;
-	  ifun >> word;
-	  datiter.AddRuns(word.Data(),idirname.Data());
-	}
-      
-      // output file name
-      if(strcmp(word.Data(),"OUTFILE")==0)
-	{
-	  if(outname.Length())
-	    cout << "readDataCards Warning: overriding output file name" << endl;
-	  ifun >> outname;
-	}
-
-      // calibration flag
-      if(strcmp(word.Data(),"CALFLAG")==0)
-	ifun >> calflag;
-
-      // cleaning level
-      if(strcmp(word.Data(),"CLEANLEVEL")==0)
-	{
-	  ifun >> lcore;
-	  ifun >> ltail;
-	}
-
-      if(strcmp(word.Data(),"ISLFLAG")==0)
-	{
-	  ifun >> islflag;
-	}
-
-      // island cleaning 
-      if (islflag == 2){
-	if(strcmp(word.Data(),"ISLANDCLEAN")==0)
-	  {
-	    ifun >> kmethod;
-	    ifun >> lnew;
-	  }
-      }
-
-      // slow control data available
-      if(strcmp(word.Data(),"SLOWCRT")==0)
-	{
-	  ifun >> slowflag;
-          if (slowflag == 1) isSlowControlAvailable = kTRUE;
-	}
-
-      // hv configuration file
-      if(strcmp(word.Data(),"HVCONFFILE")==0)
-	{
-	  ifun >> hvConfigFile;
-	}
-
-      // countinous light file to calibrate the dc data
-      if(strcmp(word.Data(),"CLFILE")==0)
-	{
-	  ifun >> continuosLightFile;
-	}
-    }
-
-  pedcaliter.Reset();
-  pediter.Reset();
-  caliter.Reset();
-  datiter.Reset();
-  TString pfile;
-
-  // Dump read values
-  cout << "************************************************" << endl;
-  cout << "* Datacards read from file " << filename << endl;
-  cout << "************************************************" << endl;
-  cout << "Pedestal file (s) for calibration: "  << endl;
-  while(kTRUE)
-  {
-      pfile=pedcaliter.Next();
-      if (pfile.IsNull())
-	  break;
-      cout << pfile << endl;
-  }
-  cout << "Calibration file (s): "  << endl;
-  while(kTRUE)
-  {
-      pfile=caliter.Next();
-      if (pfile.IsNull())
-	  break;
-      cout << pfile << endl;
-  }
-  cout << "Pedestal file (s) for data: "  << endl;
-  while(kTRUE)
-  {
-      pfile=pediter.Next();
-      if (pfile.IsNull())
-	  break;
-      cout << pfile << endl;
-  }
-  cout << "Data file (s): "  << endl;
-  while(kTRUE)
-  {
-      pfile=datiter.Next();
-      if (pfile.IsNull())
-	  break;
-      cout << pfile << endl;
-  }
-  cout << "Maximum number of events: " << nmaxevents << endl;
-  cout << "Output file name: " << outname << endl;
-  cout << "Calibration flag: " << calflag << endl;
-  cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
-  if (islflag == 1 || islflag == 2)
-    cout << "Island calcultation..." << endl;
-  if (islflag == 2)
-    {
-      cout << "Island Cleaning: "<< kmethod <<" method  "<< lnew << " new threshold" << endl;
-    }
-  cout << "***********" << endl << endl;
-  
-  if(!pediter.GetNumEntries())
-    {
-      cout << "No pedestal file name specified" << endl;
-      return kFALSE;
-    }
-  if(!caliter.GetNumEntries())
-    {
-      cout << "No calibration file name specified" << endl;
-      return kFALSE;
-    }
-  if(!datiter.GetNumEntries())
-    {
-      cout << "No data file name specified" << endl;
-      return kFALSE;
-    }
-  if(!outname.Length())
-    {
-      cout << "No output file name specified" << endl;
-      return kFALSE;
-    }
-
-  if (isSlowControlAvailable)
-    {
-      cout << "HV Configuratin file: " << hvConfigFile << endl;
-      cout << "Continous Light file: " << continuosLightFile << endl;
-    }
-  
-
-  return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/makeHillasMC.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/makeHillasMC.C	(revision 7136)
+++ 	(revision )
@@ -1,435 +1,0 @@
-/* ======================================================================== *\
-   !
-   ! *
-   ! * 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      5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
-   !              Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
-   !              Eva Domingo       1/2005 <mailto:domingo@ifae.es>
-   !             
-   !   Copyright: MAGIC Software Development, 2000-2004
-   !
-   !
-   \* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-//  STARMC - STandard Analysis and Reconstruction (MC example)
-//
-//  This macro is a version of the standard converter to convert raw data 
-//  into image parameters, made to show how to run analysis on MC files. 
-//
-//  (1/2005):: Spline extractor added and additional containers written out
-//
-/////////////////////////////////////////////////////////////////////////////
-
-#include "MImgCleanStd.h"
-
-void makeHillasMC()
-{
-  //
-  // This is a demonstration program which calculates the image 
-  // parameters from Magic Monte Carlo files (output of camera).
-
-
-  TString* CalibrationFilename;
-  TString* AnalysisFilename;
-  TString* OutFilename1;
-  TString* OutFilename2;
-
-  TString  rffilename;
-  TString  dispfilename;
-
-  // ------------- USER CHANGE -----------------
-  // Comment line starting "CalibrationFileName" to disable calibration. 
-  // In that case the units of the MHillas.fSize parameter will be ADC counts 
-  // (rather, equivalent ADC counts in inner pixels, since we correct for the 
-  // possible differences in gain of outer pixels)
-
-  // File to be used in the calibration (must be a camera file without added noise)
-  CalibrationFilename = new TString("/mnt/local_wdjrico/jrico/mc/Gammas/Gamma_zbin3_90_7_1290to1299_w0_nonoise.root");
-  // File to be analyzed
-  AnalysisFilename = new TString("/mnt/users/blanch/magic/TestSample/file*.root");
-
-  // Change output file names as desired. 
-  // If you want only one output (not dividing the events in Train and Test samples),
-  // comment the initialization of OutFilename2.
-  OutFilename1 = new TString("/mnt/users/blanch/Temp/Prova.root");
-  //  OutFilename2 = new TString("star_test.root");    // Output file name 2 (train)
-
-  // File to read RandomForest
-  rffilename="/mnt/users/blanch/magic/Mars-All/Mars_Standard06/mtemp/mifae/programs/RFstd.root";
-  // File to read Disp
-  dispfilename="/mnt/users/blanch/magic/Mars-All/Mars_Standard06/mtemp/mifae/programs/DISPstd.root";
-
-  // Fraction of events (taken at random) which one wants to process from the 
-  // file to be analyzed (useful to make smaller files if starting sample is too large).
-  Float_t accepted_fraction = 1.;
-
-
-  // ------------- USER CHANGE -----------------
-  // Cleaning levels
-  Float_t CleanLev[2] = {4.0, 3.5}; // Tail cuts for image analysis
-
-  // Signal extractor
-  // (default=Spline, other extraction methods can be used)
-  const Int_t wsize=2;
-  MExtractor* sigextract = new MExtractTimeAndChargeSpline();
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetTimeType(MExtractTimeAndChargeSpline::kHalfMaximum);
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetChargeType(MExtractTimeAndChargeSpline::kIntegral);      
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetRiseTime((Float_t)wsize*0.25); 
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetFallTime((Float_t)wsize*0.75);  
-  // Define FADC slices to be integrated in high and low gain:
-  sigextract->SetRange(1, 11, 2, 12);
-  // Defines when to switch to low gain
-  sigextract->SetSaturationLimit(240);
-
-
-  // -------------------------------------------
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  //  MGeomCamMagic geomcam;
-
-  //  MSrcPosCam src;
-  // WOBBLE MODE!!
-  //  src.SetX(120.);  // units: mm
-  //  src.SetXY(0.,0.4/geomcam.GetConvMm2Deg());
-  //  src.SetXY(0.,0.); 
-  //  src.SetReadyToSave();
-
-  MBadPixelsCam badpix;
-
-  //  plist.AddToList(&geomcam);
-  //  plist.AddToList(&src);
-  plist.AddToList(&badpix);
-
-  MCerPhotEvt     nphot;
-  // Stores number of phe
-  plist.AddToList(&nphot);
-  
-  // Now setup the tasks and tasklist:
-  // ---------------------------------
-  //
-  MReadMarsFile read("Events");
-  if (CalibrationFilename)
-    read.AddFile(CalibrationFilename->Data());
-  read.DisableAutoScheme();
-
-  MGeomApply geom; 
-  // Reads in geometry from MC file and sets the right sizes for
-  // several parameter containers.
-
-  MMcPedestalCopy   pcopy; 
-  // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
-
-  MPointingPosCalc pointcalc;
-  // Creates MPointingPos object and fill it with the telescope orientation
-  // information taken from MMcEvt.
-
-  MMcCalibrationUpdate  mccalibupdate;
-
-  MCalibrateData calib; 
-  // Transforms signals from ADC counts into photons. In the first
-  // loop it applies a "dummy" calibration supplied by MMcCalibrationUpdate, just 
-  // to equalize inner and outer pixels. At the end of the first loop, in the
-  // PostProcess of MMcCalibrationCalc (see below) the true calibration constants
-  // are calculated.
-  calib.SetCalibrationMode(MCalibrateData::kFfactor);
-
-  //    MBlindPixelCalc   blind;
-  //    blind.SetUseInterpolation();
-
-  MMcCalibrationCalc mccalibcalc; 
-  // Calculates calibration constants to convert from ADC counts to photons.
-
-  MAddGainFluctuation gainfluc;
-  //gainfluc.FillHist(1,0.5);
-  gainfluc.FillHist(0,0.1); // defaul line to not add fluctuations
-  // Adds Gain fluctuations
-
-  MImgCleanStd  clean(CleanLev[0], CleanLev[1]); 
-  // Applies tail cuts to image. Since the calibration is performed on 
-  // noiseless camera files, the precise values of the cleaning levels 
-  // are unimportant for the calibration file processing (in any case, 
-  // only pixels without any C-photon will be rejected).
-  clean.SetCleanRings(1);
-  //  clean.SetRemoveSingle(kFALSE);
-  //  clean.SetMethod(MImgCleanStd::kDemocratic);
-
-  MHillasCalc   hcalc; 
-  // Calculates Hillas parameters.
-
-  tlist.AddToList(&read);
-  tlist.AddToList(&geom);
-  tlist.AddToList(&pcopy);
-  tlist.AddToList(&pointcalc);
-  tlist.AddToList(sigextract);
-  tlist.AddToList(&mccalibupdate);
-  tlist.AddToList(&calib);
-  tlist.AddToList(&clean);
-  //  tlist.AddToList(&blind);
-  tlist.AddToList(&hcalc);
-  tlist.AddToList(&mccalibcalc);
-
-
-  //
-  // Open output files:
-  //
-
-  MWriteRootFile write1(OutFilename1->Data()); // Writes output1
-  write1.AddContainer("MRawRunHeader",       "RunHeaders");
-  write1.AddContainer("MMcRunHeader",        "RunHeaders");
-  write1.AddContainer("MSrcPosCam",          "RunHeaders");
-  write1.AddContainer("MGeomCam",            "RunHeaders");
-  write1.AddContainer("MMcConfigRunHeader",  "RunHeaders");
-  write1.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
-  write1.AddContainer("MMcFadcHeader",       "RunHeaders");
-  write1.AddContainer("MMcTrigHeader",       "RunHeaders");
-  write1.AddContainer("MGainFluctuationCam", "RunHeaders");
-
-  write1.AddContainer("MRawEvtHeader",   "Events");
-  write1.AddContainer("MMcEvt",          "Events");
-  write1.AddContainer("MHillas",         "Events");
-  write1.AddContainer("MHillasExt",      "Events");
-  write1.AddContainer("MHillasSrc",      "Events");
-  write1.AddContainer("MImagePar",       "Events");
-  write1.AddContainer("MNewImagePar",    "Events");
-  write1.AddContainer("MConcentration",  "Events");
-  write1.AddContainer("MIslands",        "Events");
-  write1.AddContainer("MTopology",       "Events");
-  write1.AddContainer("MPointingPos",    "Events");
-  write1.AddContainer("MHadronness",     "Events");
-  write1.AddContainer("MImageParDisp"  , "Events");
-  //write1.AddContainer("MArrivalTimeCam", "Events");
-  //write1.AddContainer("MCerPhotEvt",     "Events");
-
-  if (OutFilename2)
-    {
-      MWriteRootFile write2(OutFilename2->Data()); // Writes output2
-      write2.AddContainer("MRawRunHeader",       "RunHeaders");
-      write2.AddContainer("MMcRunHeader",        "RunHeaders");
-      write2.AddContainer("MSrcPosCam",          "RunHeaders");
-      write2.AddContainer("MGeomCam",            "RunHeaders");
-      write2.AddContainer("MMcConfigRunHeader",  "RunHeaders");
-      write2.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
-      write2.AddContainer("MMcFadcHeader",       "RunHeaders");
-      write2.AddContainer("MMcTrigHeader",       "RunHeaders");
-      write2.AddContainer("MGainFluctuationCam", "RunHeaders");
-
-      write2.AddContainer("MRawEvtHeader",   "Events");
-      write2.AddContainer("MMcEvt",          "Events");
-      write2.AddContainer("MHillas",         "Events");
-      write2.AddContainer("MHillasExt",      "Events");
-      write2.AddContainer("MHillasSrc",      "Events");
-      write2.AddContainer("MImagePar",       "Events");
-      write2.AddContainer("MNewImagePar",    "Events");
-      write2.AddContainer("MConcentration",  "Events");
-      write2.AddContainer("MIslands",        "Events");
-      write2.AddContainer("MTopology",       "Events");
-      write2.AddContainer("MPointingPos",    "Events");
-      write2.AddContainer("MHadronness",     "Events");
-      write2.AddContainer("MImageParDisp"  , "Events");
-      //write2.AddContainer("MArrivalTimeCam", "Events");
-      //write2.AddContainer("MCerPhotEvt",     "Events");
-
-
-      // Divide output in train and test samples, using the event number
-      // (odd/even) to achieve otherwise unbiased event samples:
-      MF filter1("{MMcEvt.fEvtNumber%2}>0.5");
-      MF filter2("{MMcEvt.fEvtNumber%2}<0.5");
-
-      write1.SetFilter(&filter1);
-      write2.SetFilter(&filter2);
-    }
-
-
-  //
-  // FIRST LOOP: Calibration loop (with no noise file)
-  //
-  MProgressBar bar;
-  bar.SetWindowName("Calibrating...");
-
-  MEvtLoop evtloop;
-  evtloop.SetProgressBar(&bar);
-  evtloop.SetParList(&plist);
-
-  if (CalibrationFilename)
-    {
-      if (!evtloop.Eventloop())
-	return;
-      mccalibcalc.GetHistADC2PhotEl()->Write();
-      mccalibcalc.GetHistPhot2PhotEl()->Write();
-      // Writes out the histograms used for calibration.
-    }
-
-  //
-  // SECOND LOOP: TO READ THE RANDOM FOREST FILE(S) 
-  //
-
-  MParList   plistrf;
-  MTaskList  tlistrf;
-  MRanForest ranforest;
-  MRanTree   rantree;
-
-  if(rffilename.Length())
-    {
-      plistrf.AddToList(&tlistrf);
-      plistrf.AddToList(&ranforest);
-      plistrf.AddToList(&rantree);
-
-      MReadTree readrf("Tree",rffilename);
-      readrf.DisableAutoScheme();
-      
-      MRanForestFill rffill;
-      rffill.SetNumTrees(100);
-      
-      tlistrf.AddToList(&readrf);
-      tlistrf.AddToList(&rffill);
-      
-      MEvtLoop evtlooprf;
-      evtlooprf.SetParList(&plistrf);
-      if (!evtlooprf.Eventloop())
-	return;
-      
-      tlistrf.PrintStatistics();
-    }
-  
-
-  //
-  // THIRD LOOP: Analysis loop (process file with noise)
-  //
-  bar.SetWindowName("Analyzing...");
-
-  MIslands         isl;
-  MArrivalTimeCam  timecam;      
-  MTopology        topology;
-  plist.AddToList(&isl);
-  plist.AddToList(&timecam);
-  plist.AddToList(&topology);
-  plist.AddToList(&rantree);
-  plist.AddToList(&ranforest);
- 
-  MArrivalTimeCalc2  timecalc;
-  // Calculates the arrival time as the mean time of the fWindowSize 
-  // time slices which have the highest integral content.
-  //  MArrivalTimeCalc timecalc;            
-  // Calculates the arrival times of photons. Returns the absolute 
-  // maximum of the spline that interpolates the FADC slices.
-
-  MIslandsCalc       islcalc;
-  islcalc.SetOutputName("MIslands");
-  islcalc.SetAlgorithm(1);
-  //  MIslandsClean      islclean(40);
-  //  islclean.SetInputName("MIslands");
-  //  islclean.SetMethod(1);
-
-  MTopologyCalc      topcalc;
-
-  // Change the read task by another one which reads the file we want to analyze:
-  MReadMarsFile read2("Events","/mnt/users/blanch/magic/TestSample/file*.root");
-  //  MReadMarsFile read2("Events","/mnt/users/blanch/magic/TestSample/file53.root");
-  //  read2.AddFile(AnalysisFilename->Data());
-  read2.DisableAutoScheme();
-  tlist.AddToListBefore(&read2, &read);
-  tlist.RemoveFromList(&read);
-
-
-  // Add new tasks (Islands and Topology calculations)
-  tlist.AddToListBefore(&timecalc,&mccalibupdate);
-  tlist.AddToListBefore(&islcalc,&hcalc);
-  //  tlist.AddToListBefore(&islclean,&hcalc);
-  tlist.AddToListBefore(&topcalc,&hcalc);
-
-  // Add Task to Add Gain Fluctuations
-  tlist.AddToListBefore(&gainfluc, &hcalc);
-
-  MGeomCamMagic geomcam;// = new MGeomCam();
-  plist.AddToList(&geomcam);
-
-
-  MHillasDisplay*  disphillas=NULL;
-  disphillas = new MHillasDisplay(&nphot,&geomcam);
-
-  // Analyze only the desired fraction of events, skip the rest:
-  MFEventSelector eventselector;
-  Float_t rejected_fraction = 1. - accepted_fraction; 
-  eventselector.SetSelectionRatio(rejected_fraction);
-  MContinue skip(&eventselector);
-  tlist.AddToListBefore(&skip, sigextract);
-
-  // Remove calibration task from list.
-  tlist.RemoveFromList(&mccalibcalc); 
-
-  // disp
-  // (read in optimum Disp parameter values)  
-  MDispParameters dispin;
-  TArrayD dispPar;
-  if(dispfilename.Length())
-    {
-      TFile inparam(dispfilename);
-      dispin.Read("MDispParameters");
-      cout << "Optimum parameter values taken for calculating Disp : " << endl;
-
-      dispPar =  dispin.GetParameters();
-      for (Int_t i=0; i<dispPar.GetSize(); i++)
-	cout << dispPar[i] << ",  ";
-      cout << endl;
-      
-      inparam.Close();
-    }
-  // Disp results container
-  MImageParDisp imagepardisp;
-  // Disp histograms
-  MHDisp hdisp;
-  hdisp.SetName("MHDispAsym");
-  hdisp.SetSelectedPos(4);
-  MFillH filldisp("MHDispAsym[MHDisp]", "");
-  
-  // Add RandomForest and Disp task computation
-  MRanForestCalc hadrcalc;
-  MDispCalc         dispcalc;  
-
-  tlist.AddToList(&dispcalc);
-  tlist.AddToList(&filldisp);
-  if(rffilename.Length())
-    tlist.AddToList(&hadrcalc);
- 
-  // Add tasks to write output:
-  if (OutFilename2)
-    {
-      tlist.AddToList(&filter1);
-      tlist.AddToList(&filter2);
-      tlist.AddToList(&write2); 
-    }
-  tlist.AddToList(&write1); 
-
-  // Add display image with hillas
-  disphillas->SetPSFile();
-  disphillas->SetPSFileName("provaGF.ps");
-  disphillas->SetPause(kFALSE);	
-  //tlist.AddToList(disphillas);
-  
-
-  if (!evtloop.Eventloop())
-    return;
-
-  tlist.PrintStatistics();
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/mergeClean.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/mergeClean.C	(revision 7136)
+++ 	(revision )
@@ -1,411 +1,0 @@
-/* ======================================================================== *\
-!   Take different MC input files and combine them into single one
-!   Author(s): Oscar Blanch & Javier Rico
-\* ======================================================================== */
-
-void mergeClean()
-{
-  const TString fileout = "/local_disk/jrico/mc/prueba.root";
-
-  const Int_t nfiles = 11;
-  const Int_t nlevels= 5;
-
-  const Char_t* levelname[nlevels]={"noclean","3015","4025","5035","6045"};
-
-  // input files -- no noise
-  const Char_t* NonoiseOutFilename[nfiles] = 
-    {"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_nonoise.root",
-     "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_nonoise.root"
-    };
-
-  // input files -- different cleaning levels
-  const Char_t* NoiseOutFilename[nlevels][nfiles]   = 
-    {{"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_noclean.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_noclean.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_noclean.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_noclean.root"},
-     {"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_3015.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_3015.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_3015.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_3015.root"},
-     {"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_4025.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_4025.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_4025.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_4025.root"},   
-     {"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_5035.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_5035.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_5035.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_5035.root"},
-     {"/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0_cleaned_6045.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_0_7_1130to1139_w0_cleaned_6045.root",   
-      "/local_disk/jrico/mc/Gamma_zbin0_90_7_1260to1269_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1010to1019_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_0_7_1140to1149_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin1_90_7_1270to1279_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1020to1029_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin2_0_7_1150to1159_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1030to1039_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_0_7_1160to1169_w0_cleaned_6045.root",
-      "/local_disk/jrico/mc/Gamma_zbin3_90_7_1290to1299_w0_cleaned_6045.root"}
-    };   
-
-
-  // Getting input braches 
-  TChain* tno  = new TChain("Events");
-  TChain* tyes[nlevels];
-  for(Int_t i=0;i<nlevels;i++)
-    tyes[i] = new TChain("Events");
-
-  for(Int_t i=0;i<nfiles;i++)
-    {
-      tno->Add(NonoiseOutFilename[i]);
-      for(Int_t j=0;j<nlevels;j++)
-	tyes[j]->Add(NoiseOutFilename[j][i]);
-    }
-
-  // input braches for no noise file
-  MCerPhotEvt*   nphotNo;
-  MHillas*       hillasNo;
-  MHillasSrc*    hillassrcNo;
-  MMcEvt*        mcevtNo;
-  MRawEvtHeader* evtheaderNo;
-  MRawRunHeader* runheaderNo;
-
-  tno->SetBranchAddress("MCerPhotEvt.",&nphotNo);
-  tno->SetBranchAddress("MHillas.",&hillasNo);
-  tno->SetBranchAddress("MHillasSrc.",&hillassrcNo);
-  tno->SetBranchAddress("MMcEvt.",&mcevtNo);
-  tno->SetBranchAddress("MRawEvtHeader.",&evtheaderNo);
-  tno->SetBranchAddress("MRawRunHeader.",&runheaderNo);
-
-  
-  // input branches for noise files
-  MCerPhotEvt*   nphotYes[nlevels];
-  MHillas*       hillasYes[nlevels];
-  MHillasSrc*    hillassrcYes[nlevels];
-  MMcEvt*        mcevtYes[nlevels];
-  MRawEvtHeader* evtheaderYes[nlevels];
-  MRawRunHeader* runheaderYes[nlevels];
-
-  for(Int_t i=0;i<nlevels;i++)
-    {      
-      tyes[i]->SetBranchAddress("MCerPhotEvt.",&nphotYes[i]);
-      tyes[i]->SetBranchAddress("MHillas.",&hillasYes[i]);
-      tyes[i]->SetBranchAddress("MHillasSrc.",&hillassrcYes[i]);
-      tyes[i]->SetBranchAddress("MMcEvt.",&mcevtYes[i]);
-      tyes[i]->SetBranchAddress("MRawEvtHeader.",&evtheaderYes[i]);
-      tyes[i]->SetBranchAddress("MRawRunHeader.",&runheaderYes[i]);
-    }
-
-  // Setting ouput branches
-  TFile* fout = new TFile(fileout,"RECREATE");
-  TTree* to   = new TTree("Events","Events");   
-
-  // common containers
-  TBranch* bmcevt        = to->Branch("MMcEvt.",       "MMcEvt",       &mcevtNo);
-  TBranch* brawevtheader = to->Branch("MRawEvtHeader.","MRawEvtHeader",&evtheaderNo);
-  TBranch* brawrunheader = to->Branch("MRawRunHeader.","MRawRunHeader",&runheaderNo);
-
-  // noise/cleaning dependent containers
-  to->Branch("MCerPhotEvt0.",  "MCerPhotEvt",  &nphotNo);
-  to->Branch("MHillas0.",      "MHillas",      &hillasNo);
-  to->Branch("MHillasSrc0.",   "MHillasSrc",   &hillassrcNo);
-
-  //  cout << "llego1" << endl;
-  for(Int_t i=0;i<nlevels;i++)
-    {
-      //      cout << "i: " << i << endl;
-      
-      char mcerphot[100];
-      char mhillas[100];
-      char mhillassrc[100];
-
-
-      sprintf(mcerphot,  "MCerPhotEvt%s.",levelname[i]);
-      sprintf(mhillas,   "MHillas%s."    ,levelname[i]);
-      sprintf(mhillassrc,"MHillasSrc%s." ,levelname[i]);
-
-      to->Branch(mcerphot,  "MCerPhotEvt",  &nphotYes[i]);
-      to->Branch(mhillas,   "MHillas",      &hillasYes[i]);
-      to->Branch(mhillassrc,"MHillasSrc",   &hillassrcYes[i]);      
-    }
-  //  cout << "llego2" << endl;
-  
-      
-  Int_t nentries1 = (Int_t)tno->GetEntries();
-  cout << "Entries: No noise file: " << nentries1 << endl;
-  Int_t nentries2[nlevels];
-  Int_t latestk[nlevels];
-  Int_t latestevt[nlevels];
-  Int_t nfound[nlevels];
-  for(Int_t i=0;i<nlevels;i++)
-    {
-      nfound[i]=0;
-      latestk[i]=0;
-      latestevt[i]=99999999;
-      nentries2[i] = (Int_t)tyes[i]->GetEntries();
-      cout << "Entries: cleaning level [" << levelname[i] << "] :" << nentries2[i] << endl;
-    }
-
-  // loop over all events in no-noise file and look for them in the other files
-  for(Int_t i=0;i<nentries1;i++)
-    //  for(Int_t i=0;i<100;i++)
-    {      
-      tno->GetEntry(i);
-      Int_t runno = runheaderNo->GetRunNumber();
-      Int_t evtno = evtheaderNo->GetDAQEvtNumber();
-
-      cout << "Checking run " << runno<< ", event " << evtno << endl;
-
-      //check if the no-noise event is present in all of the other files
-      for(Int_t j=0;j<nlevels;j++)
-	{
-	  Int_t runyes;
-	  Int_t evtyes;
-	  cout << "Level " << levelname[j] << endl;
-	  Int_t k=latestk[j];	  
-	  while(k<nentries2[j])
-	    {
-	      //	      cout << k << endl;
-	      tyes[j]->GetEntry(k++);
-	      runyes = runheaderYes[j]->GetRunNumber();
-	      evtyes = evtheaderYes[j]->GetDAQEvtNumber();
-	      if(runyes==runno && evtyes==evtno)
-		break;
-	      // next condition speeds up selection when events are grouped by runs and
-	      // in event increasing order
-	      if(runyes==runno && latestevt[j]<evtno && evtno<evtyes)
-		break;
-	      // next condition speeds up selection when events are grouped by runs
-	      // and in run increasing order
-	      //	      if(runyes>runno)
-	      //		break;
-	    }
-
-	  if(k>=nentries2[j])
-	    {
-	      k=0;
-	      while(k<latestk[j])
-		{
-		  //		  cout << k << endl;
-		  tyes[j]->GetEntry(k++);
-		  runyes = runheaderYes[j]->GetRunNumber();
-		  evtyes = evtheaderYes[j]->GetDAQEvtNumber();
-		  if(runyes==runno && evtyes==evtno)
-		    break;
-		  // next condition speeds up selection when events are grouped by runs and
-		  // in event increasing order
-		  if(runyes==runno && latestevt[j]<evtno && evtno<evtyes)
-		    break;
-		  // next condition speeds up selection when events are grouped by runs
-		  // and in run increasing order
-		  //		  if(runyes>runno)
-		  //		    break;
-		}
-	    }
-	  
-	  // the event has not been found, assign dummy containers
-	  if(runyes=!runno || evtyes!=evtno)
-	    {
-	      cout << "Not Found!" << endl;	      
-	      for(Int_t l=j;l<nlevels;l++)
-		{
-		  nphotYes[l]->Reset();
-		  hillasYes[l]->Reset();
-		  hillassrcYes[l]->Reset();		  
-		}
-	      break;
-	    }
-	  else
-	    {
-	      cout << "Found!" << endl;
-	      latestevt[j] = evtyes;
-	      latestk[j]=k;	  
-	      nfound[j]++;
-	    }
-	}
-      to->Fill();
-    }
-
-  // loop over all events in first noise file and look for them in the no-noise file in order to save also purely noisy events  
-  cout << "***************************************" << endl;
-  cout << "*** Looking for purely noisy events ***" << endl;
-  cout << "***************************************" << endl;
-  Int_t nfound2[nlevels];
-  for(Int_t i=0;i<nlevels;i++)
-    {
-      nfound2[i]=0;
-      latestk[i]=0;
-      latestevt[i]=99999999;
-    }
-  
-  // readdress the common container addresses
-  bmcevt->SetAddress(&mcevtYes[0]);
-  brawevtheader->SetAddress(&evtheaderYes[0]);
-  brawrunheader->SetAddress(&runheaderYes[0]);
-
-  for(Int_t i=0;i<nentries2[0];i++)
-  //  for(Int_t i=0;i<100;i++)
-    {      
-      tyes[0]->GetEntry(i);
-      Int_t run = runheaderYes[0]->GetRunNumber();
-      Int_t evt = evtheaderYes[0]->GetDAQEvtNumber();
-      Int_t runno;
-      Int_t evtno;
-
-      cout << "Checking run " << run << ", event " << evt << endl;
-
-      //check if the event is present in the no-noise file
-      Int_t kk=latestk[0];	  
-      while(kk<nentries1)
-	{
-	  //	  cout << kk << endl;
-	  tno->GetEntry(kk++);
-	  runno = runheaderNo->GetRunNumber();
-	  evtno = evtheaderNo->GetDAQEvtNumber();
-	  if(run==runno && evt==evtno)
-	    break;
-	  if(run==runno && latestevt[0]<evt && evt<evtno)
-	    break;
-	  //	  if(runno>run)
-	  //	    break;
-	}
-
-      if(kk>=nentries1)
-	{
-	  kk=0;
-	  while(kk<latestk[0])
-	    {
-	      //		  cout << kk << endl;
-	      tno->GetEntry(kk++);
-	      runno = runheaderNo->GetRunNumber();
-	      evtno = evtheaderNo->GetDAQEvtNumber();
-	      if(run==runno && evt==evtno)
-		break;
-	      if(run==runno && latestevt[0]<evt && evt<evtno)
-		break;
-	      //	      if(runno>run)
-	      //		break;
-	    }
-	}
-
-      // the event is already included because it is also a no-noise event, dismiss it
-      if(run==runno && evt==evtno)
-	{
-	  cout << "Found already in the no-noise sample, continuing... " << endl;
-	  latestevt[0] = evtno;
-	  latestk[0]=kk;	  
-	  continue;
-	}
-
-      nfound2[0]++;
-      nphotNo->Reset();
-      hillasNo->Reset();
-      hillassrcNo->Reset();
-
-      // look for the event in the rest of the noisy samples
-      for(Int_t j=1;j<nlevels;j++)
-	{
-	  Int_t runyes;
-	  Int_t evtyes;
-	  cout << "Level " << levelname[j] << endl;
-	  Int_t k=latestk[j];	  
-	  while(k<nentries2[j])
-	    {
-	      //	      cout << k << endl;
-	      tyes[j]->GetEntry(k++);
-	      runyes = runheaderYes[j]->GetRunNumber();
-	      evtyes = evtheaderYes[j]->GetDAQEvtNumber();
-	      if(runyes==run && evtyes==evt)
-		break;
-	      if(runyes==run && latestevt[j]<evt && evt<evtyes)
-		break;
-	      //	      if(runyes>run)
-	      //		break;
-	    }
-
-	  if(k>=nentries2[j])
-	    {
-	      k=0;
-	      while(k<latestk[j])
-		{
-		  //		  cout << k << endl;
-		  tyes[j]->GetEntry(k++);
-		  runyes = runheaderYes[j]->GetRunNumber();
-		  evtyes = evtheaderYes[j]->GetDAQEvtNumber();
-		  if(runyes==run && evtyes==evt)
-		    break;
-		  if(runyes==run && latestevt[j]<evt && evt<evtyes)
-		    break;
-		  //		  if(runyes>run)
-		  //		    break;
-		}
-	    }
-	  
-	  // the event has not been found, assign dummy containers
-	  if(runyes=!run || evtyes!=evt)
-	    {
-	      cout << "Not Found!" << endl;	      
-	      for(Int_t l=j;l<nlevels;l++)
-		{
-		  nphotYes[l]->Reset();
-		  hillasYes[l]->Reset();
-		  hillassrcYes[l]->Reset();		  
-		}
-	      break;
-	    }
-	  else
-	    {
-	      cout << "Found!" << endl;
-	      latestevt[j] = evtyes;
-	      latestk[j]=k;	  
-	      nfound2[j]++;
-	    }
-	}
-      to->Fill();    
-    }
-
-  fout->Write();
-  fout->Close();
-
-  for(Int_t i=0;i<nlevels;i++)
-    cout << "Found " << nfound[i] << "+" << nfound2[i] << " for cleaning level " << levelname[i] << endl;
-
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/mmcCleaning.C	(revision 7136)
+++ 	(revision )
@@ -1,197 +1,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-//  mmcCleaning - calibrate/clean mc events
-//
-/////////////////////////////////////////////////////////////////////////////
-
-
-void mmcCleaning(TString NoiseFilename, TString NoiseOutFilename)
-{
-  //
-  // This is a demonstration program which reads in MC camera files
-  // and produces and output with calibrated events (signal in photons
-  // for all pixels, in MCerPhotEvt containers).
-  //
-
-  // ------------- user change -----------------
-  Char_t*  NonoiseFilename = "/local_disk/jrico/mc/Gamma_zbin0_0_7_1000to1009_w0.root";
-  //  Char_t*  NoiseFilename   = "/mnt/wdflix/root_0.73mirror/wuerzburg/gammas/Gamma_zbin3_0_7_1160to1169_w0.root"; // File to be analyzed
-
-  //  Char_t* NoiseOutFilename   = "/mnt/users/jrico/prueba.root";   // Output file name
-
-  const Int_t wsize=2;
-  // Signal sigextract
-  // (other extraction methods can be used)
-  MExtractor* sigextract = new MExtractTimeAndChargeSpline();
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetTimeType(MExtractTimeAndChargeSpline::kHalfMaximum);
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetChargeType(MExtractTimeAndChargeSpline::kIntegral);      
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetRiseTime((Float_t)wsize*0.25); 
-  ((MExtractTimeAndChargeSpline*)sigextract)->SetFallTime((Float_t)wsize*0.75);
-  
-  // Define FADC slices to be integrated in high and low gain:
-  sigextract->SetRange(1, 11, 2, 12);
-
-  // Defines when to switch to low gain
-  sigextract->SetSaturationLimit(240);
-
-  // ---------------------------------------------------------------------
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  MPedestalCam  pedcam;
-  MGeomCamMagic geomcam;
-  MCerPhotEvt   nphot;
-
-  plist.AddToList(&pedcam);
-  plist.AddToList(&geomcam);
-  plist.AddToList(&nphot);
-
-  //
-  // Now setup the tasks and tasklist:
-  // ---------------------------------
-  //
-  MReadMarsFile read("Events");
-  read.AddFile(NonoiseFilename);
-  read.DisableAutoScheme();
-
-  MGeomApply geom; 
-  // Reads in geometry from MC file and sets the right sizes for
-  // several parameter containers.
-
-  MMcPedestalCopy   pcopy; 
-  // Copies pedestal data from the MC file run fadc header to the 
-  // MPedestalCam container.
-
-  MDisplay       display(&nphot,&geomcam);
-  MHillasDisplay display2(&nphot,&geomcam);
-
-  MPointingPosCalc pointcalc;
-  // Creates MPointingPos object and fill it with the telescope orientation
-  // information taken from MMcEvt.
-
-  MMcCalibrationUpdate  mccalibupdate;
-
-  MCalibrate calib; 
-  // MCalibrate transforms signals from ADC counts into photons. In the first
-  // loop it applies a "dummy" calibration supplied by MMcCalibrationUpdate, just 
-  // to equalize inner and outer pixels. At the end of the first loop, in the
-  // PostProcess of MMcCalibrationCalc (see below) the true calibration constants
-  // are calculated.
-
-  calib.SetCalibrationMode(MCalibrate::kFfactor);
-
-  MImgCleanStd clean(4.0,3.5);
-  clean.SetCleanRings(1);
-  //  clean.SetRemoveSingle(kFALSE);
-  //
-  // Applies tail cuts to image. Since the calibration is performed on 
-  // noiseless camera files, the precise values of the cleaning levels 
-  // are unimportant (in any case, only pixels without any C-photon will
-  // be rejected).
-  //
-
-  MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
-  MHillasSrcCalc hsrccalc;
-
-  MMcCalibrationCalc mccalibcalc; 
-  // Calculates calibration constants to convert from ADC counts to photons.
-
-  tlist.AddToList(&read);
-  tlist.AddToList(&geom);
-  tlist.AddToList(&pcopy);
-  tlist.AddToList(&pointcalc);
-  tlist.AddToList(sigextract);
-  tlist.AddToList(&mccalibupdate);
-  tlist.AddToList(&calib);
-  tlist.AddToList(&clean);
-  tlist.AddToList(&hcalc);
-  tlist.AddToList(&hsrccalc); 
-  tlist.AddToList(&mccalibcalc);
-  //tlist.AddToList(&display2);
-
-  //
-  // First loop: No noise
-  //
-  MProgressBar bar;
-  bar.SetWindowName("No noise...");
-
-  MEvtLoop evtloop;
-  //  evtloop.SetProgressBar(&bar);
-  evtloop.SetParList(&plist);
-
-  if (!evtloop.Eventloop())
-    return;
-  mccalibcalc.GetHistADC2PhotEl()->Write();
-  mccalibcalc.GetHistPhot2PhotEl()->Write();
-  // Writes out the histograms used for calibration.
-
-
-  //
-  // Second loop: process file with noise
-  //  
-  MIslands      isl;
-  MArrivalTimeCam timecam;      
-  MTopology     topology;
-  plist.AddToList(&isl);
-  plist.AddToList(&timecam);
-  plist.AddToList(&topology);
-
-  MArrivalTimeCalc2 timecalc;
-  MIslandsCalc      islandcalc;
-  islandcalc.SetOutputName("MIslands");
-  islandcalc.SetAlgorithm(1);
-  MIslandsClean     islclean(40);
-  islclean.SetInputName("MIslands");
-  islclean.SetMethod(1);
-  MTopologyCalc     topcalc;
-
-  MReadMarsFile read2("Events");
-  read2.AddFile(NoiseFilename);
-  read2.DisableAutoScheme();
-  tlist.AddToListBefore(&read2, &read, "All");
-  tlist.RemoveFromList(&read);
-
-  tlist.AddToListBefore(&timecalc,&mccalibupdate,"All");
-  tlist.AddToListBefore(&islandcalc,&hcalc,"All");
-  tlist.AddToListBefore(&topcalc,&hcalc,"All");
-
-  MWriteRootFile write(NoiseOutFilename); // Writes output
-  write.AddContainer("MRawRunHeader", "RunHeaders");
-  write.AddContainer("MMcRunHeader",  "RunHeaders");
-  write.AddContainer("MSrcPosCam",    "RunHeaders");
-  write.AddContainer("MGeomCam",      "RunHeaders");
-  write.AddContainer("MMcConfigRunHeader",  "RunHeaders");
-  write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
-  write.AddContainer("MMcFadcHeader",  "RunHeaders");
-  write.AddContainer("MMcTrigHeader",  "RunHeaders");
-
-  write.AddContainer("MMcEvt",        "Events");
-  write.AddContainer("MRawEvtHeader", "Events");
-  write.AddContainer("MHillas",       "Events");
-  write.AddContainer("MHillasSrc",    "Events");
-  write.AddContainer("MHillasExt",    "Events");
-  write.AddContainer("MConcentration","Events");
-  write.AddContainer("MImagePar",     "Events");
-  write.AddContainer("MNewImagePar",  "Events");
-  write.AddContainer("MIslands",      "Events");
-  write.AddContainer("MPointingPos",  "Events");
-  write.AddContainer("MTopology",      "Events");
-
-  tlist.RemoveFromList(&mccalibcalc);
-  tlist.AddToList(&write);
-  //  tlist.AddToListBefore(&display2,&write, "All");
-
-  bar.SetWindowName("Calibrating/Cleaning...");
-  //  clean.SetRemoveSingle();
-  //  clean.SetMethod(MImgCleanStd::kDemocratic);
-
-  if (!evtloop.Eventloop())
-    return;
-
-  tlist.PrintStatistics();
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/observationTime.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/observationTime.C	(revision 7136)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/* ======================================================================== *\!
-!   Author(s): Javier Rico
-\* ======================================================================== */
-
-void observationTime(
-		     Int_t iniRun=0,
-		     Int_t finRun=99999,
-		     TString filename="/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/AllCrabNebula_3015_kDefault_MispE.root"
-)
-{    
-    // define files, chains...
-    TChain* t= new TChain("Parameters");
-    t->Add(filename);
-
-    // define aliases
-    t->SetAlias("run",     "MRawRunHeader.fRunNumber");
-    t->SetAlias("runiniT", "MRawRunHeader.fRunStart.fTime.fMilliSec/1000");
-    t->SetAlias("runfinT", "MRawRunHeader.fRunStop.fTime.fMilliSec/1000");
-
-    TH1I* hrun = new TH1I("hrun","",finRun-iniRun+1,iniRun,finRun+1);
-    TH1I* hent = new TH1I("hent","",finRun-iniRun+1,iniRun,finRun+1);
-	
-    const char varcut[512];
-    const char runcut[512];
-    sprintf(runcut,"(run>=%d && run<=%d)",iniRun,finRun);
-    sprintf(varcut,"%s*(runfinT-runiniT)",runcut);
-
-    t->Draw("run>>hrun",runcut);
-    t->Draw("run>>hent",varcut);
-
-    Float_t seconds=0;
-    for(Int_t irun = 1; irun<=finRun-iniRun+1; irun++)
-      {
-	Int_t nev;
-	if(nev=hrun->GetBinContent(irun))
-	  {
-	    Float_t time = hent->GetBinContent(irun)/nev;
-	    seconds += time;	    
-	    cout << "run " << iniRun-1+irun << ", " << time <<  " seconds" << endl;
-	  }
-      }
-    
-    cout << "Total observation time = " << seconds << " seconds = " << seconds/60. << " minutes = " << seconds/3600. << " hours" << endl;
-    delete hrun;
-    delete hent;
-}
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/pedrmsonoff.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/pedrmsonoff.C	(revision 7136)
+++ 	(revision )
@@ -1,284 +1,0 @@
-// pedrmsonoff.C
-// compare pedestal rms for two different sets
-//
-
-#include "MParList.h"
-#include "MTaskList.h"
-#include "MPedestalCam.h"
-#include "MReadMarsFile.h"
-#include "MGeomApply.h"
-#include "MPedCalcPedRun.h"
-#include "MEvtLoop.h"
-#include "MPedestalPix.h"
-#include "MHCamera.h"
-
-#include "TTimer.h"
-#include "TString.h"
-#include "TCanvas.h"
-#include "TFile.h"
-#include "TGraphErrors.h"
-#include "TMultiGraph.h"
-#include "TLegend.h"
-#include "TPaveStats.h"
-#include "TH1F.h"
-#include "TStyle.h"
-#include "TROOT.h"
-
-#include <iostream>
-
-using namespace std;	     
-
-void compare(TCanvas* canvas,TString onfname, TString offfname,TString descon, TString descoff, UInt_t index=-1);
-
-void pedrmsonoff()
-//int main()
-{
-  // general settings
-  gROOT->Reset();
-  gStyle->SetCanvasColor(0);
-  gStyle->SetStatColor(0);
-  gStyle->SetStatBorderSize(1);
-  gStyle->SetOptStat(111111);
-  gStyle->SetStatW(0.2);
-  gStyle->SetStatH(0.1);
-  gStyle->SetStatX(0.9);
-  gStyle->SetStatY(0.9);
-
-  // create canvas
-  TCanvas* canvas = new TCanvas("canvas","On/Off crab pedestal rms", 0, 100, 800, 500);
-  canvas->SetBorderMode(0);    // Delete the Canvas' border line     
-  canvas->cd();
-
-#ifdef TEMPLATE
-  // define input files/parameters
-  const UInt_t ncomp = 9;
-
-  //  const TString onfile ="/mnt/disc02/Data/rootdata/CrabNebula/2004_01_26/20040125_10412_P_Crab-On_E.root";
-  TString onfile[ncomp] = {
-    "/local_disk/jrico/rootdata/20040126_12149_P_Cab-On_E.root",
-    "/local_disk/jrico/rootdata/20040125_10412_P_Crab-On_E.root", 
-    "/local_disk/jrico/rootdata/20040125_10412_P_Crab-On_E.root",
-    "/local_disk/jrico/rootdata/20040119_04642_P_Crab-On_E.root",
-    "/local_disk/jrico/rootdata/20040128_1342*_P_ClosedLidsHVoff_E.root",
-    "/local_disk/jrico/rootdata/20040128_1342*_P_ClosedLidsLVoff_E.root",
-    "/local_disk/jrico/rootdata/20040128_1343*_P_ReciversOff_E.root",
-    "/local_disk/jrico/rootdata/20040126_12386_P_Cab-On_E.root",
-    "/local_disk/jrico/rootdata/20040126_12543_P_OffCrab-1_E.root"};
-
-  
-  TString ondesc[ncomp] = {"Run 12149 Jan 27th, Crab On, #theta 28 deg",
-			   "Run 10412 Jan 26th, Crab On, #theta 12.5 deg",
-			   "Run 10412 Jan 26th, Crab On, #theta 12.5 deg",			      
-			   "Run 4642 Jan 20th, Crab On, #theta 14.1 deg",
-			   "Runs 13426-7 Jan 29th, Closed lids HV off",
-			   "Runs 13428-9 Jan 29th, Closed lids LV off",
-			   "Runs 13430-1 Jan 29th, Recivers Off",
-			   "Run 12386 Jan 27th, Crab On #theta 37.1 deg",
-			   "Run 12543 Jan 27th, Crab Off #theta 8.6 deg"};
-
-  
-  TString offfile[ncomp] = {
-    "/local_disk/jrico/rootdata/20040121_06773_P_OffCrab1_E.root",
-    "/local_disk/jrico/rootdata/20040125_11477_P_OffCrab1_E.root",
-    "/local_disk/jrico/rootdata/20040125_10415_P_Crab-On_E.root",
-    "/local_disk/jrico/rootdata/20040125_10415_P_Crab-On_E.root",
-    "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
-    "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
-    "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
-    "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root",
-    "/local_disk/jrico/rootdata/20040128_13425_P_ClosedLidsHVon_E.root"};
-
-  
-  TString offdesc[ncomp] = {"Run 6773 Jan 22nd, Crab Off #theta 28 deg",
-			    "Run 11477 Jan 26th, Crab Off #theta 9.2 deg",
-			    "Run 10415 Jan 26th, Crab On, #theta 13.8 deg",
-			    "Run 10415 Jan 26th, Crab On, #theta 13.8 deg",
-			    "Run 13425 Jan 29th, Closed lids HV on",
-			    "Run 13425 Jan 29th, Closed lids HV on",
-			    "Run 13425 Jan 29th, Closed lids HV on",
-			    "Run 13425 Jan 29th, Closed lids HV on",
-			    "Run 13425 Jan 29th, Closed lids HV on"};
-#endif
-
-  // define input files/parameters
-  const UInt_t ncomp = 1;
-
-  TString onfile[ncomp] = {"/local_disk/jrico/rootdata/pedestals/20040619_*_P_OffPSR1957-1_E.root"};  
-  TString ondesc[ncomp] = {"Off-PSR1957"};  
-  TString offfile[ncomp] = {"/local_disk/jrico/mc/empty_disc00.root"};  
-  TString offdesc[ncomp] = {"MC (Vela)"};
-
-  canvas->Print("pedrmsonoff.ps[");  
-  for(UInt_t i=0;i<ncomp;i++)    
-    compare(canvas,onfile[i],offfile[i],ondesc[i],offdesc[i],i);
-  canvas->Print("pedrmsonoff.ps]");  
-}
-
-
-void compare(TCanvas* canvas,TString onfname, TString offfname,TString descon, TString descoff,UInt_t index)
-{
-  /*************************/
-  /* FIRST LOOP: ON DATA   */
-  /*************************/
-
-  // basic lists
-  MParList plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-  
-  // containers
-  MPedestalCam   onpedcam;
-  plist.AddToList(&onpedcam);
-    
-  //tasks
-  MReadMarsFile read("Events", onfname);
-  MGeomApply     geomapl;
-  MPedCalcPedRun pedcalc;
-
-  read.DisableAutoScheme();
-
-  tlist.AddToList(&read);
-  tlist.AddToList(&geomapl);
-  tlist.AddToList(&pedcalc);
-
-  // Create and execute the event looper
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-  
-  cout << "*********************" << endl;
-  cout << "** RUNNING ON DATA **" << endl;
-  cout << "*********************" << endl;
-
-  if (!evtloop.Eventloop())
-    return;
-  
-  tlist.PrintStatistics();
-
-  /**************************/
-  /* SECOND LOOP: OFF DATA  */
-  /**************************/
-  MReadMarsFile read2("Events",offfname);
-  read2.DisableAutoScheme();
-  tlist.AddToListBefore(&read2, &read, "All");
-  tlist.RemoveFromList(&read);
-  
-  // containers
-  MPedestalCam   offpedcam;
-  plist.Remove(&onpedcam);
-  plist.AddToList(&offpedcam);
-  
-  // Execute the event looper
-  cout << "**********************" << endl;
-  cout << "** RUNNING OFF DATA **" << endl;
-  cout << "**********************" << endl;
-
-  if (!evtloop.Eventloop())
-    return;
-  
-  tlist.PrintStatistics();
-
-  /*******************/
-  /* FILL HISTOGRAMS */
-  /*******************/
-  const UInt_t npix = 577;
-  const UInt_t ninner = 397;
-  const UInt_t imin =  0;
-  const UInt_t imax = 20;
-  const UInt_t itot = 50;
-  
-  TH1F* honinpedrms  = new TH1F(descon+TString(" Inner"),"Pedestal RMS" ,itot,imin,imax);
-  TH1F* hoffinpedrms = new TH1F(descoff+TString(" Inner"),"Pedestal RMS",itot,imin,imax);
-  TH1F* honoutpedrms  = new TH1F(descon+TString(" Outer"),"Pedestal RMS" ,itot,imin,imax);
-  TH1F* hoffoutpedrms = new TH1F(descoff+TString(" Outer"),"Pedestal RMS",itot,imin,imax);
-
-  for(UInt_t i=0;i<npix;i++)
-    {
-      const Float_t onpedrms  =  onpedcam[i].GetPedestalRms();
-      const Float_t offpedrms = offpedcam[i].GetPedestalRms();
-      
-      if(i<ninner)
-	{
-	  honinpedrms->Fill(onpedrms);
-	  hoffinpedrms->Fill(offpedrms);
-	}
-      else
-	{
-	  honoutpedrms->Fill(onpedrms);
-	  hoffoutpedrms->Fill(offpedrms);
-	}
-    }
-
-  /*******************/
-  /* DRAW HISTOGRAMS */
-  /*******************/
-     
-  // draw pedestal histos
-  honinpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
-  honinpedrms->GetYaxis()->SetTitle("# pixels");
-  honinpedrms->SetFillStyle(3004);
-  honinpedrms->SetFillColor(1);
-
-  hoffinpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
-  hoffinpedrms->GetYaxis()->SetTitle("# pixels");
-  hoffinpedrms->SetFillStyle(3005);
-  hoffinpedrms->SetFillColor(2);
-  hoffinpedrms->SetLineColor(2);
-
-  honoutpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
-  honoutpedrms->GetYaxis()->SetTitle("# pixels");
-  honoutpedrms->SetFillStyle(3017);
-  honoutpedrms->SetFillColor(1);
-
-  hoffoutpedrms->GetXaxis()->SetTitle("Pedestal RMS (ADC cnts)");
-  hoffoutpedrms->GetYaxis()->SetTitle("# pixels");
-  hoffoutpedrms->SetFillStyle(3018);
-  hoffoutpedrms->SetFillColor(2);
-  hoffoutpedrms->SetLineColor(2);
-
-  hoffinpedrms->Draw();
-  hoffoutpedrms->Draw("sames");
-  honinpedrms->Draw("sames");
-  honoutpedrms->Draw("sames");
-
-  // move stat boxes to make them all visible
-  gPad->Update();
-  TPaveStats* onoutpavstat  = (TPaveStats*) honoutpedrms->GetListOfFunctions()->FindObject("stats");
-  TPaveStats* offinpavstat  = (TPaveStats*) hoffinpedrms->GetListOfFunctions()->FindObject("stats");
-  TPaveStats* offoutpavstat = (TPaveStats*) hoffoutpedrms->GetListOfFunctions()->FindObject("stats");
-  Float_t shifty = offinpavstat->GetY2NDC()-offinpavstat->GetY1NDC();
-  Float_t shiftx = onoutpavstat->GetX2NDC()-onoutpavstat->GetX1NDC();
-
-  onoutpavstat->SetX1NDC(onoutpavstat->GetX1NDC()-shiftx);
-  onoutpavstat->SetX2NDC(onoutpavstat->GetX2NDC()-shiftx);
-
-  offinpavstat->SetY1NDC(offinpavstat->GetY1NDC()-shifty);
-  offinpavstat->SetY2NDC(offinpavstat->GetY2NDC()-shifty);
-
-  offoutpavstat->SetX1NDC(offoutpavstat->GetX1NDC()-shiftx);
-  offoutpavstat->SetX2NDC(offoutpavstat->GetX2NDC()-shiftx);
-  offoutpavstat->SetY1NDC(offoutpavstat->GetY1NDC()-shifty);
-  offoutpavstat->SetY2NDC(offoutpavstat->GetY2NDC()-shifty);
-
-  // include legend
-  TLegend* leg1 = new TLegend(.52,.25,.88,.45);
-  leg1->SetHeader("");
-  leg1->AddEntry(honinpedrms,descon+TString(" (Inner)"),"f");
-  leg1->AddEntry(hoffinpedrms,descoff+TString(" (Inner)"),"f");
-  leg1->AddEntry(honoutpedrms,descon+TString(" (Outer)"),"f");
-  leg1->AddEntry(hoffoutpedrms,descoff+TString(" (Outer)"),"f");
-  leg1->SetFillColor(0);
-  leg1->SetLineColor(0);
-  leg1->SetBorderSize(0);
-  leg1->Draw();
-
-  if(index>=0)
-    {
-      char fname[100];
-      sprintf(fname,"pedrmsonoff%02d.eps",index);
-      canvas->Print(fname);        
-    }
-  canvas->Print("pedrmsonoff.ps");  
-
-  return; 
-  
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/plotOptimal.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/plotOptimal.C	(revision 7136)
+++ 	(revision )
@@ -1,124 +1,0 @@
-////////////////////////////////////////////////////////////////////////////////////
-//
-//             _____ Plot Optimized cuts _____
-//
-//  Take as input an output from programs/optimizeCuts and plot the results
-//  You only need to specify the input file name
-//
-//                 Jose Flix    <jflix@ifae.es>
-//                 Javier Rico  <jrico@ifae.es>
-////////////////////////////////////////////////////////////////////////////////////
-
-
-void plotOptimal(TString fname="optimize.out")
-{
-  gROOT->Reset();
-  gStyle->SetCanvasColor(0);
-  gStyle->SetCanvasBorderMode(0);
-  gStyle->SetPadBorderMode(0);
-  gStyle->SetFrameBorderMode(0);
-  gStyle->SetOptStat(000000);
-  gStyle->SetPalette(1);
-
-  ifstream ifun(fname.Data());
-  Float_t width,length,excess,significance;
-
-  Float_t wmin=9999999;
-  Float_t lmin=9999999;
-  Float_t wmax=-9999999;
-  Float_t lmax=-9999999;
-  Float_t emax=-9999999;
-  Float_t smax=-9999999;
-
-  Float_t dw=-1;
-  Float_t dl=-1;
-  Float_t prevw=-1;
-  Float_t prevl=-1;
-
-  // first loop to get parameters
-  Int_t i=0;
-  while(ifun >> width)
-    {
-      // read data
-      ifun >> length;
-      ifun >> excess;
-      ifun >> significance;
-      
-      // keep max/min
-      if(width<wmin)  wmin=width;
-      if(length<lmin) lmin=length;
-      if(width>wmax)  wmax=width;
-      if(length>lmax) lmax=length;
-      if(significance>smax) 
-	{
-	  smax=significance;
-	  emax=excess;
-	}
-
-      if(width!=prevw)   dw=width-prevw;
-      if(length!=prevl) dl=length-prevl;
-
-      prevw=width;
-      prevl=length;
-      i++;
-    }
-  ifun.close();
-
-  cout << "wmin: " << wmin << ", wmax: " << wmax+dw << ", lmin: " << lmin << ", lmax: " << lmax+dl << endl;
-
-  // define histos
-  Int_t nx = TMath::Nint((wmax-wmin)/dw)+1;
-  Int_t ny = TMath::Nint((lmax-lmin)/dl)+1;
-  TH2F *ex  = new TH2F("Excess","Excess",nx,wmin,wmax+dw,ny,lmin,lmax+dl);
-  TH2F *sig = new TH2F("Significance","Significance",nx,wmin,wmax+dw,ny,lmin,lmax+dl);
-
-  cout << "nx: " << nx << ", ny: " << ny << endl;
-  cout << "dw: " << dw << ", dl: " << dl << endl;
-
-  ifstream ifun2;
-  ifun2.open(fname.Data());
-  
-  // second loop to fill the histograms
-  Float_t wopt,lopt,eopt;
-  while(ifun2 >> width)
-    {
-      // read data
-      ifun2 >> length;
-      ifun2 >> excess;
-      ifun2 >> significance;
-
-      cout << "Width: " << width << '\t' << "Length: " << length << '\t' << "Excess: " << excess << '\t' << "Significance: " << significance;
-      if(significance==smax)
-	{
-	  cout << " *****";
-	  wopt=width;
-	  lopt=length;
-	  eopt=excess;
-	}
-	    
-      cout << endl;
-
-      Int_t binx = TMath::Nint(((width-wmin)/dw));
-      Int_t biny = TMath::Nint(((length-lmin)/dl));
-
-      //      cout << "binnx: " << binx+1 << ", biny: " << biny+1 << endl;
-
-      ex->SetBinContent(binx+1,biny+1,excess+.00001);
-      sig->SetBinContent(binx+1,biny+1,significance+.00001);    
-    }
-  cout << "Maximal significance: " << smax << " (excess=" << eopt << ") for width="<<wopt<<", length=" << lopt << endl;
-
-  // plot
-  TCanvas *c3 = new TCanvas("c3","c3",0,0,500,750);
-  c3->Divide(1,2);
-  
-  c3->cd(1);
-  ex->GetXaxis()->SetTitle("Width (degrees)");
-  ex->GetYaxis()->SetTitle("Length (degrees)");
-  ex->Draw("colz");
-  
-  c3->cd(2);
-  sig->GetXaxis()->SetTitle("Width (degrees)");
-  sig->GetYaxis()->SetTitle("Length (degrees)");
-  sig->Draw("colz");
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/rotation.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/rotation.C	(revision 7136)
+++ 	(revision )
@@ -1,101 +1,0 @@
-
-// Macro to compare the rotation obtained from simple FOV rotation, with 
-// measured values
-
-void rotation()
-{
-  const Int_t rmax=17427;
-  gStyle->SetMarkerStyle(20);
-  gStyle->SetMarkerSize(1);
-
-  const char* fname="/mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/macros/20040215_Mrk421.B.pos";
-  TFile* file= new TFile("/mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnRotateNoCalB.root");
-  TTree* chain = (TTree*)file->Get("Parameters");
-
-  // read position data from file
-  ifstream ifun(fname);
-
-  Int_t irun;
-  Float_t ix;
-  Float_t iy;
-
-  // first loop to evaluate number of entries
-  Int_t nentries=0;  
-  while(ifun >> irun)
-    {
-      ifun >> ix;
-      ifun >> iy;
-      nentries++;
-    }
-  ifun.close();
-  const Int_t size = nentries;
-  Float_t x[size];
-  Float_t y[size];
-  Int_t run[size];
-
-  // second loop to actually read values into arrays
-  Int_t i=0;
-  ifstream ifun2(fname);
-  while(ifun2 >> run[i])
-    {
-      ifun2 >> x[i];
-      ifun2 >> y[i];
-      x[i]/=315.;
-      y[i]/=315.;
-      i++;
-    }  
-  ifun2.close();
-  TGraph* tray = new TGraph(nentries,x,y);
-
-  // get data from tree
-  MSrcPosCam* srpos = new MSrcPosCam; 
-  MRawRunHeader* hrun = new MRawRunHeader;
-  chain->SetBranchAddress("MSrcPosCam.",&srpos);
-  chain->SetBranchAddress("MRawRunHeader.",&hrun);
-
-  Int_t ntot = chain->GetEntries();
-  const Int_t ctot =ntot;
-  Float_t xth[ctot];
-  Float_t yth[ctot];
-  Int_t rtot=0;
-  for(Int_t j=0;j<ctot;j++)
-    {
-      chain->GetEntry(j);
-      Int_t arun=hrun->GetRunNumber();
-      if(arun<=rmax)
-	{
-	  xth[j]=srpos->GetX()/315.;
-	  yth[j]=srpos->GetY()/315.;
-	  rtot++;
-	}
-    }     
-  TGraph* trayth = new TGraph(rtot,xth,yth);
-  
-
-  // Plot   
-  TPostScript myps("rotation.ps",111);
-  myps.Range(15,15);
-  TCanvas* myC = new TCanvas("myC","pedestal studies",500,500);
-  myC->cd(1);
-
-  // Null graph to adjust plot limits
-  Float_t nullx[2]={-0.4,0.4};
-  Float_t nully[2]={-0.4,0.4};
-
-  TGraph grnull(2,nullx,nully);
-  grnull.SetMarkerSize(0);
-  grnull.SetMarkerColor(0);
-  grnull.GetXaxis()->SetTitle("x (deg)");
-  grnull.GetYaxis()->SetTitle("y (deg)");
-  grnull.SetTitle("Source position in camera Mrk421 15th February");
-  grnull.DrawClone("AP");
-
-  tray->SetMarkerStyle(2);
-  tray->SetMarkerSize(2);
-  trayth->SetMarkerStyle(6);
-  trayth->SetMarkerColor(2);
-
-  tray->DrawClone("P");
-  trayth->DrawClone("P");
-  myps.Close();
-}
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/signal.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/signal.C	(revision 7136)
+++ 	(revision )
@@ -1,180 +1,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-//       This macro makes the two-dimension plot of the False Source Method:
-//        root > .x signal.C(TString name, TString psname)
-//
-//                 Ester Aliu   <aliu@ifae.es>
-//                 Oscar Blanch <blanch@ifae.es>
-//                 Javier Rico  <jrico@ifae.es>
-////////////////////////////////////////////////////////////////////////////
-void signal(
-TString fname ="hillasCrab/falseSourceCrab20040215.root",
-TString psname ="kk.ps")
-{
-  Float_t excess;
-  Float_t significance;
-  Float_t array[2];
-  
-  Int_t nbin2d = 5;
-  Int_t ntotal = 2*nbin2d+1;
-  
-  Int_t nx = 0;
-  Int_t ny = 0;
-  
-  Float_t max = -10000;
-  Int_t imax;
-  Int_t jmax;
-  Float_t A ;
-  Float_t B;
-  
-  TH2F *hsignif = new TH2F("hsignif","Significance", ntotal, -1.0, 1.0, ntotal, -1.0, 1.0);
-  TH2F *hexcess = new TH2F("hexcess","Excess", ntotal, -1.0, 1.0, ntotal, -1.0, 1.0);
-  
-  
-  // loop on the histos and compute excess and significance
-  for( Int_t i = -nbin2d; i <= nbin2d ; i++)  
-    {    
-      nx++;
-      ny = 0;
-      for( Int_t j = -nbin2d; j <= nbin2d ; j++)  
-	{	
-	  ny++;	  
-	  step_signal(i,j,&array[0], fname);
-	  
-	  excess = array[0];
-	  significance = array[1];
-
-	  hexcess->SetBinContent(nx, ny, excess);
-	  hsignif->SetBinContent(nx, ny, significance);
-
-	  if ( significance > max)
-	    {
-	      max = significance;
-	      imax = i;
-	      jmax = j;
-	      A = excess;
-	      B = significance;
-	    }
-	}
-    }
-  
-  cout << "The position of maximum significance is ( " << imax << " , " << jmax << " )" << endl;
-  cout << "Excess: " << A << endl;
-  cout << "Significance: " << B << endl;
-    
-  // Plot 
-  gROOT->Reset();
-  gStyle->SetCanvasColor(0);
-  gStyle->SetCanvasBorderMode(0);
-  gStyle->SetPadBorderMode(0);
-  gStyle->SetFrameBorderMode(0);
-  gStyle->SetOptTitle(0);
-  gStyle->SetTitleOffset(1.7,"y");
-  gStyle->SetPadLeftMargin(0.15);
-  gStyle->SetOptStat(kFALSE);
-  gStyle->SetStatColor(0);
-  gStyle->SetStatBorderSize(1);
-  gStyle->SetStatW(0.2);
-  gStyle->SetStatH(0.1);
-  gStyle->SetStatX(0.9);
-  gStyle->SetStatY(0.9);
-  
-
-  TPostScript myps(psname,111);
-  myps.Range(15,15);
-  TCanvas *c2d = new TCanvas("c2d", "Matrices", 0, 0, 800,800);  
-  c2d->Divide(2,2);
-  gStyle->SetPalette(1); 
-  
-  c2d->cd(1);
-  hexcess->Draw("colz");
-  hexcess->SetXTitle("X position (deg)");
-  hexcess->SetYTitle("Y position (deg)");
-  gPad->Update();    
-  
-  c2d->cd(2);
-  hsignif->Draw("colz");
-  hsignif->SetXTitle("X position (deg)");
-  hsignif->SetYTitle("Y position (deg)");
-  gPad->Update();
-
-  c2d->cd(3);
-  hexcess->Draw("lego2");
-  hexcess->SetXTitle("X position (deg)");
-  hexcess->SetYTitle("Y position (deg)");
-  gPad->Update();    
-  
-  c2d->cd(4);
-  hsignif->Draw("lego2");
-  hsignif->SetXTitle("X position (deg)");
-  hsignif->SetYTitle("Y position (deg)");
-  gPad->Update();    
-
-  myps.Close();
-}
-  
-  
-void step_signal(Int_t i, Int_t j, Float_t *array, TString fname) 
-{
-  cout << "Bin (" << i << "," << j << ")" << endl;
-  TH1F *onhisto;
-  TH1F *offhisto;
-
-  // open file and access to the histograms  
-  TFile *f = new TFile(fname);
-  Char_t name[20]; 
-  Char_t title[50]; 
-
-  // histo name
-  sprintf(name,"hOnAlpha[%d][%d]", i, j);
-  sprintf(title,"Alpha-Plot(On data) (%d ,%d)", i, j);
-  onhisto = (TH1F*)gDirectory->Get(name);   
-  
-  sprintf(name,"hOffAlpha[%d][%d]", i, j);
-  sprintf(title,"Alpha-Plot(Off data) (%d ,%d)", i, j);
-  offhisto = (TH1F*)gDirectory->Get(name);   
-  
-  // line/normalization
-  const Int_t nbins = 18;
-  const Int_t inibin = 20./90.*nbins+1;
-  Float_t level=0;
-  Float_t leveloff=0;
-  Float_t levelofferror=0;
-  for(Int_t ibin = inibin; ibin<=nbins;ibin++)
-    {
-      level+=onhisto->GetBinContent(ibin);
-      leveloff+=offhisto->GetBinContent(ibin);
-    }
-  level/=(nbins-inibin+1);
-  leveloff/=(nbins-inibin+1);
-  
-  // normalize on/off
-  offhisto->Sumw2(); // needed to compute correct errors after normalization
-  const Float_t norm = level/leveloff;
-  cout << "Normalizing by factor " << norm <<endl;
-  offhisto->Scale(norm);    
-  
-  // significance:
-  Float_t sig=0,bg=0,esig=0,ebg=0;
-  Float_t significance=0;
-  const Int_t signbins = inibin-1;
-  for(Int_t ibin = 1; ibin<=signbins;ibin++)
-    {
-      sig  += onhisto->GetBinContent(ibin);
-      esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
-      bg   += offhisto->GetBinContent(ibin);
-      ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
-    }
-  Float_t error= TMath::Sqrt(esig+ebg);
-  Float_t excess = sig-bg;
-  Float_t significance = excess/error;
-  
-  cout << "Excess:       " << excess << endl;
-  cout << "Significance: " << significance << endl;
-  
-  array[0] = excess;
-  array[1] = significance;
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mifae/macros/signalPoint.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/macros/signalPoint.C	(revision 7136)
+++ 	(revision )
@@ -1,131 +1,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-//       This macro makes the alpha-plot for one of the positions of the 
-//     False Source Method:
-//
-//                 Ester Aliu   <aliu@ifae.es>
-//                 Oscar Blanch <blanch@ifae.es>
-//                 Javier Rico  <jrico@ifae.es>
-////////////////////////////////////////////////////////////////////////////
-
-void signalPoint(Int_t i=0, Int_t j=0, TString fname="hillasCrab/falseSourceCrab20040215.root")
-{  
-  // constants
-  const Int_t nbins = 18;
-  
-  // general settings
-  gROOT->Reset();
-  gStyle->SetCanvasColor(0);
-  gStyle->SetCanvasBorderMode(0);
-  gStyle->SetPadBorderMode(0);
-  gStyle->SetFrameBorderMode(0);
-  gStyle->SetOptTitle(0);
-  gStyle->SetTitleOffset(1.7,"y");
-  gStyle->SetPadLeftMargin(0.15);
-  gStyle->SetOptStat(111110);
-  gStyle->SetStatColor(0);
-  gStyle->SetStatBorderSize(1);
-  gStyle->SetStatW(0.2);
-  gStyle->SetStatH(0.1);
-  gStyle->SetStatX(0.9);
-  gStyle->SetStatY(0.9);
-  
-  
-  //  open file and access to the histograms
-  TFile *f = new TFile(fname);
-  
-  Char_t name[20]; 
-  Char_t title[50]; 
-  
-  sprintf(name,"hOnAlpha[%d][%d]", i, j);
-  sprintf(title,"Alpha-Plot(On data) (%d ,%d)", i, j);
-  TH1F* onhisto = (TH1F*)gDirectory->Get(name);   
-  
-  sprintf(name,"hOffAlpha[%d][%d]", i, j);
-  sprintf(title,"Alpha-Plot(Off data) (%d ,%d)", i, j);
-  TH1F* offhisto = (TH1F*)gDirectory->Get(name);   
-
-  TPostScript myps("signalpoint.ps",111);
-  myps.Range(15,15);
-  TCanvas *c1 = new TCanvas("c1","c1",800,600);
-  c1->cd(1);
-
-  // line/normalization
-  const Int_t inibin = 20./90.*nbins+1;
-  Float_t level=0;
-  Float_t leveloff=0;
-  Float_t levelofferror=0;
-  for(Int_t ibin = inibin; ibin<=nbins;ibin++)
-    {
-      level+=onhisto->GetBinContent(ibin);
-      leveloff+=offhisto->GetBinContent(ibin);
-    }
-  level/=(nbins-inibin+1);
-  leveloff/=(nbins-inibin+1);
-  
-  // normalize on/off
-  offhisto->Sumw2(); // needed to compute correct errors after normalization
-  const Float_t norm = level/leveloff;
-  cout << "Normalizing by factor " << norm <<endl;
-  offhisto->Scale(norm);    
-  
-  // significance:
-  Float_t sig=0,bg=0,esig=0,ebg=0;
-  Float_t significance=0;
-  const Int_t signbins = inibin-1;
-  for(Int_t ibin = 1; ibin<=signbins;ibin++)
-    {
-      //	Float_t sigma = (onhisto->GetBinContent(ibin)-level)/onhisto->GetBinError(ibin);
-      //	significance+=sigma*sigma;
-      sig  += onhisto->GetBinContent(ibin);
-      esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
-      bg   += offhisto->GetBinContent(ibin);
-      ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
-    }
-  Float_t error= TMath::Sqrt(esig+ebg);
-  significance = (sig-bg)/error;
-  
-  cout << "Significance: " << significance << endl;
-  
-  // plot
-  onhisto->SetXTitle("alpha (deg)");
-  onhisto->SetYTitle("Entries");
-  onhisto->SetMarkerColor(4);
-  onhisto->SetMarkerStyle(20);
-  onhisto->SetMarkerSize(.7);
-  onhisto->SetLineColor(4);
-  onhisto->SetMaximum(onhisto->GetBinContent(nbins)*1.5);
-  
-  offhisto->SetFillColor(2);
-  offhisto->SetMaximum(offhisto->GetBinContent(nbins)*1.5);
-  offhisto->SetXTitle("alpha (deg)");
-  offhisto->SetYTitle("Entries");
-  
-  offhisto->Draw("HIST");
-  offhisto->Draw("ESAME");
-  onhisto->Draw("ESAMES");
-  //    onhisto->Draw("E");
-  
-  // move stat box to make them all visible
-  gPad->Update();
-  TPaveStats* offpavstat = (TPaveStats*) offhisto->GetListOfFunctions()->FindObject("stats");
-  if(offpavstat)
-    {
-      Float_t shiftx = offpavstat->GetX2NDC()-offpavstat->GetX1NDC();
-      offpavstat->SetX1NDC(offpavstat->GetX1NDC()-shiftx);
-      offpavstat->SetX2NDC(offpavstat->GetX2NDC()-shiftx);
-    }
-  
-  // draw line
-  TLine* line = new TLine(0.,level,90.,level);
-  line->SetLineColor(2);
-  line->SetLineStyle(2);
-  //    line->Draw();
-  
-  gPad->Modified();
-  gPad->Update();
-  
-  myps.Close();
-}
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/MySkyPlot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/MySkyPlot.C	(revision 7136)
+++ 	(revision )
@@ -1,171 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-// Daniel Mazin 26.09.2004  mazin@mppmu.mpg.de
-//**********************************************************
-// this macro :
-// 1)  take Hillas Parameters and produce a sky plot
-//**********************************************************
-
-gROOT->Reset();
-
-//************************************************************************
-void MySkyPlot(const char *onfile) 
-{
-
-    TString fileON  = onfile;
-
-    // name of input root file
-    TString filenamein(fileON);
-
-
-    //  set up the task list:
-    //-----------------------------------------------------------
-    MTaskList tlist;
-    MParList plist;
-
-
-    TString XPosMaxString ("MSrcPosCam.fX<0.1");
-    MContinue XPosMaxCut(XPosMaxString);
-    XPosMaxCut.SetInverted();
-
-    TString XPosMinString ("MSrcPosCam.fX>-0.1");
-    MContinue XPosMinCut(XPosMinString);
-    XPosMinCut.SetInverted();
-
-    TString YPosMaxString ("MSrcPosCam.fY<0.1");
-    MContinue YPosMaxCut(YPosMaxString);
-    YPosMaxCut.SetInverted();
-
-    TString YPosMinString ("MSrcPosCam.fY>-0.1");
-    MContinue YPosMinCut(YPosMinString);
-    YPosMinCut.SetInverted();
-
-
-
-    MSkyPlot skyplot; 
-    skyplot.SetMinDist(0.2);
-    //skyplot.ReadCuts("/local/supercuts/OptSCParametersONOFFThetaRange0_1570mRad.root");
-    //skyplot.ReadCuts("/remote/home/pc1/operator/mazin/supercuts/2004_09_13/Zd20_60all/Cuts.root");
-    //skyplot.ReadCuts("/local/supercuts/2004_09_13/OptDynCuts2000CrabNebula.root");
-    //skyplot.ReadCuts("/remote/home/pc17/operator/OnlineA/supercuts/OptDynCuts2000CrabNebula.root");
-    //skyplot.ReadCuts("/home/pcmagic04/pratik/crab_analysis/sept2k4/gt2000/RootFileDynCuts_crabsept_GREEN_15o30deg.root");
-    skyplot.ReadCuts("/home/pcmagic04/pratik/crab_analysis/sept2k4/gt2000/RootFileDynCuts_20to30deg_alldata.root");
-    skyplot.SetSkyPlot(-1.,1.,-1.,1.,0.05);
-    skyplot.SetSizeMin(2000.);
-    skyplot.SetSizeMax(1e6);
-    skyplot.SetOutputAlphaName("Crab21_UV.root");
-    skyplot.SetOutputSkyName("Crab21_UV.root");
-
-
-    MObservatory mobs;
-
-    plist.AddToList(&mobs);
-
-    // geometry is needed in  MHHillas... classes 
-    const MGeomCam *fGeom = 
-             (MGeomCam*)plist->FindCreateObj("MGeomCamMagic", "MGeomCam");
-
-    //-------------------------------------------
-    // create the tasks which should be executed 
-    //
-
-    MReadReports read;
-    read.AddTree("Drive");
-//    read.AddTree("CC");
-//    read.AddTree("Events");
-    read.AddTree("Events","MTime.",kTRUE);
- 
-    read.AddFile(filenamein);
- 
-    read.AddToBranchList("MReportDrive.*");
-//    read.AddToBranchList("MRawEvtHeader.*");
-
-
-    //MReadMarsFile read("Events", filenamein);
-    //MReadMarsFile read(filenamein);
-    //read.DisableAutoScheme();
-
-    MGeomApply        apply;
-
-    
-
-    //*****************************
-    // entries in MParList
-    
-    plist.AddToList(&tlist);
-
-//    pliston.AddToList(&source);
-
-    //*****************************
-    // entries in MTaskList
-    
-
-    tlist.AddToList(&read);
-    tlist.AddToList(&apply);
-
-    tlist.AddToList(&XPosMaxCut);
-    tlist.AddToList(&XPosMinCut);
-
-    tlist.AddToList(&YPosMaxCut);
-    tlist.AddToList(&YPosMinCut);
-
-    tlist.AddToList(&skyplot);
-
-    //*****************************
-
-    //-------------------------------------------
-    // Execute event loop
-    //
-    MProgressBar bar;
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-    evtloop.SetProgressBar(&bar);
-/*
-    Int_t maxevents = -1;
-    //Int_t maxevents = 1000;
-    if ( !evtloop.Eventloop(maxevents) )
-        return;
-*/
-    if (!evtloop.PreProcess())
-            return;
-
-    Int_t counter=0;
-    while(tlist.Process())
-    {
-      counter++;
-      if(counter%10000 == 0) cout << "events = " << counter << endl;
-//     MReportDrive * mrepdrive = (MReportDrive *)pliston.FindObject("MReportDrive");
-//     cout << "Ra " << mrepdrive->GetRa() << ", Dec " << mrepdrive->GetDec() << endl;
-//     MHillasSrc * mhs = (MHillasSrc*)pliston.FindObject("MHillasSrc");
-//     mhs->Print();
-    }
-
-    evtloop.PostProcess(); 
- 
-    tlist.PrintStatistics(0, kTRUE);
-
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/SCDynamicalSupercutsApplied.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/SCDynamicalSupercutsApplied.C	(revision 7136)
+++ 	(revision )
@@ -1,273 +1,0 @@
-// The aim of this macro is to show the cuts applied to the 
-// events that survive the g/h separation cuts + the alpha cut.
-// The macro can be modified easily to show other things...
-
-// This program reads a TTree (specified by the user) and 
-// stores the array containing the variables specified by 
-// the user into pointer to arrays. This is done through 
-// the member function TTree::Draw()
-
-// Selection rules (cuts) are allowed. In such case, only 
-// the variables of the events that pass the cuts specified are 
-// stored into the arrays. 
-
-
-// It  works with arrays of pointers 
-// and plot N quantities in the N pads of the same Canvas.
-// single strings that contain
-// the quantities to be plotted are used.
-
-// This program is an alternative to another (faster?) more 
-// professional way of getting info from a Tree.
-
-
-// As input, this macro needs a root file that is 
-// generated by the SupercutsONOFF programs, which is 
-// the root file containing the TTrees with the needed info.
-
-// The user must write
-
-// 1) Name of the root file with the info (Path included!!)
-
-// 2) Name of the output ps file produced by the macro (with path included!!)
-
-
-gROOT -> Reset();
-
-void SCDynamicalSupercutsApplied()
-{
-
-
-
-
-  char* RootFile = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/RootFileDynCuts.root"};
-
-  char* OutputPsFilename = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/DynamicalCutsLengthWidthDistApplied.eps"};
-  
-  
-  char* Xaxis = "log(SIZE/[photons])";
-  
-  char* YaxisVector[6] = {"LENGTH UP [\\circ]", "LENGTH LOW [\\circ]", 
-		       "WIDTH UP [\\circ]", "WIDTH LOW [\\circ]", 
-		       "DIST UP [\\circ]", "DIST LOW [\\circ]"}; 
-
-  
-  
-
-
-  
-  
- 
-
-
-// Name of the root file that contains the Tree
-    char* TreeName = {"SupercutsAppliedTrainONThetaRange0_1570mRad"}; // Name of the Tree that contains the variables that have to plotted
-   
-
-    
-    const Int_t NQuantitiesToBePlot = 6;
-
-    // Write here the quantities to be plot
-    
-    TString QuantitiesToBePlot[NQuantitiesToBePlot] = 
-    {"SupercutsApplied.LengthUp:log10(ShowerParameters.Size)", 
-     "SupercutsApplied.LengthLow:log10(ShowerParameters.Size)", 
-     "SupercutsApplied.WidthUp:log10(ShowerParameters.Size)", 
-     "SupercutsApplied.WidthLow:log10(ShowerParameters.Size)",
-     "SupercutsApplied.DistUp:log10(ShowerParameters.Size)", 
-     "SupercutsApplied.DistLow:log10(ShowerParameters.Size)"};
-
-
-    // Write here the number of rows and columns in the ps file
-
-    const Int_t Nrows = 2;
-    const Int_t Ncolumns = 3;
-
-    // Title of Canvas.. not really important...
-
-    TString CanvasTitle = ("Dynamical cuts in Length, Width and Dist");
-
-    // 0 for not using and 1 for using Selection cut
-    Int_t UseSelectionCut = 1; 
-    // Section rule to be applied in the data to be plotted
-    char* SelectionCut = {"(SupercutsApplied.Hadronness < 0.5) && ShowerParameters.Alpha < 12"}; 
-    
-    
-
-    // Vectors where variables will be stored
-    Int_t ArrayDimension[NQuantitiesToBePlot];
-    Double_t* VarYArray[NQuantitiesToBePlot];
-    Double_t* VarXArray[NQuantitiesToBePlot];
-
-
-    
-
-    // Vector  of pointers to TFile objects and TTree objects that will be used to retrieve 
-    // requested info from root file. 
-
-    TFile* FileVector[NQuantitiesToBePlot];
-    TTree* TreeVector[NQuantitiesToBePlot];
-
-    // Vector of pointers to graph objects where quantities will be plot
-
-    TGraph* GraphVector[NQuantitiesToBePlot];
-
-
-    // Options available for plotting the histo are the following ones:
-    // "prof" -->> Profile
-    // "goff" -->> No draw variables in TTree::Draw()
-    // ""     -->> No special option is set
-
-    char* DrawingOption = {"goff"};
-
-
-    TString selection = UseSelectionCut ? SelectionCut : NULL;
-
-
-
-    // Tree is read and stored in dynamic memory pointed by pointer tree.
-    
-    //  TFile file (RootFile);
-    // TTree* tree = (TTree*) file.Get(TreeName);
-
-
-  
-
-    // Loop in which arrays are retrieved from root file and 
-    // array dimensions (with events surviving the selection)
-    // are retrieved too.
-
-    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
-      {
-
-
-	FileVector[i] = new TFile(RootFile, "READ");
-
-	TreeVector[i] = (TTree*) FileVector[i] -> Get(TreeName);
-	
-	 // Array dimension of temporal vectors where the variables 
-	// that will be plotted are stored can be modify accordingly 
-	// with the nnumber of events of the Tree
-	
-	TreeVector[i] -> SetEstimate(TreeVector[i] -> GetEntries());
-
-	// Requested info is "plotted"
-
-	TreeVector[i]  -> Draw(QuantitiesToBePlot[i].Data(), selection, DrawingOption);
-
-	
-	// Let's find out the REAL length of the vectors we want 
-	// to get from the tree (Selection rules may have removed some events)
-	
-	ArrayDimension[i] = TreeVector[i] -> GetSelectedRows();
-	
-	// Vectors are retrieved
-
-	VarYArray[i] = TreeVector[i] -> GetV1();
-	VarXArray[i] = TreeVector[i] -> GetV2();
-
-      }
-
-  
-   
-    // Silly info is displayed for testing...
-
-
-   
-    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
-      {
-	cout << "Events that passed the selection for quantity " 
-	     << QuantitiesToBePlot[i] << " : " << ArrayDimension[i] << endl;
-      }
-
-   
-    // Initialization of the graphs with the info contained in the vectors
-    // Kind of default features are set for all graphs
-
-
-     TAxis* axispointer;
-      
-     
-
-    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
-      {	
-	GraphVector[i] = new TGraph (ArrayDimension[i], VarXArray[i], VarYArray[i]);
-	
-	GraphVector[i] -> SetTitle(QuantitiesToBePlot[i].Data());
-
-	
-	GraphVector[i]->SetFillColor(19);
-	GraphVector[i]->SetMarkerColor(2);
-	GraphVector[i]->SetMarkerStyle(21);
-	GraphVector[i]->SetMarkerSize(0.5);
-
-	axispointer = GraphVector[i] -> GetXaxis();
-	axispointer -> SetTitle(Xaxis);
-	axispointer -> SetTitleOffset(1.3);
-	axispointer -> SetTitleSize(0.05);
-
-
-	axispointer =  GraphVector[i] -> GetYaxis();
-	axispointer -> SetTitle(YaxisVector[i]);
-	axispointer -> SetTitleOffset(1.5);
-	axispointer -> SetTitleSize(0.05);
-	
-
-      }
-
-
-
-   
-    /*
-    // Let's output some of their components:
-    
-    for ( Int_t i = 0; i < ArrayDimension[]0; i++)
-    {
-	cout << VarXArray[0][i] << "  " <<  VarYArray[0][i] << endl;
-
-    }
-    */
-
-    
-    // TCanvas is defined with the NQuantitiesToBePlot Pads where the graphs 
-    // will be plotted
-
-    TCanvas* Canvas = new TCanvas(CanvasTitle, CanvasTitle, 600, 800);
-    Canvas -> SetBorderMode(0);
-    Canvas -> Divide(Nrows, Ncolumns);
-    
-    
-    // gStyle -> SetFrameFillColor(10);
-    gStyle -> SetPadLeftMargin (0.15);
-    gStyle -> SetPadRightMargin (0.05);
-    gStyle -> SetPadTopMargin (0.00);
-    gStyle -> SetPadBottomMargin (0.20);
-    
-    gStyle -> SetOptTitle(0);
-
-    // Graphs are plot in canvas
-    
-    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
-      {	
-	Canvas -> cd(i+1);
-	gPad -> SetBorderMode(0);
-	gPad->SetGridx();
-	gPad->SetGridy(); 
-	//gPad -> SetPadTopMargin (0.05);
-	//gPad -> SetPadBottomMargin (0.15);
-	
-	GraphVector[i] -> Draw("AP");
-      }
-    
-    
-
-    Canvas -> SaveAs(OutputPsFilename);
-
-
-}
-    
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/SCNexSignificanceVSAlphaCut.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/SCNexSignificanceVSAlphaCut.C	(revision 7136)
+++ 	(revision )
@@ -1,466 +1,0 @@
-// This program produces a ps file with 
-// two graphs in the same TPad, but 
-// with different axis. 
-
-// The aim is to plot Nex and significance vs 
-// cut in alpha parameter.
-
-// As input, this macro needs a root file that is 
-// generated by the SupercutsONOFF programs.
-
-// It will read the histograms where Nex and significance 
-// vs alpha are stored and will plot this info in a single 
-// ps file. 
-
-// The user must write
-
-// 1) Name of the root file with the info (Path included!!)
-
-// 2) Name of the output ps file (with path included!!)
-
-// Depending on the values to be plotted the axis scale
-// as well as the axis offsets for labels might have to be 
-// modified. If I have time I will modify the program to 
-// make it automatic...
-
-
-
-
-#include <string.h>
-#include <iostream.h>
-#include <fstream.h>
-#include <iomanip.h>
-#include <stdlib.h>
-#include <math.h>
-
-
-gROOT -> Reset();
-
-void SCNexSignificanceVSAlphaCut() 
-{
-
-  
-  
-  char* SCRootFile = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt/RootFileDynCuts.root"};
-
-  char* output_ps_file = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt/NexSignificanceVSCutinAlpha.ps"};
-
-  
- 
-  char* ps_title = 
-    {"Excess events (green) and significance (red) vs cut in alpha"};
-
-
-
-
-  // Name of the histograms (contained in root file) that contain the number of 
-  // excess events and significance vs alpha cut
-
-  TString ExcessEventsHistoName = ("NexVSAlphaTrainThetaRange0_1570mRad");
-  TString SignificanceHistoName = ("SignificanceVSAlphaTrainThetaRange0_1570mRad");
-
-
-  // Axis titles
-
-  char* xaxis_title = "Cut in alpha (degrees)";
-  char* yaxis_title = "Excess events";
-  char* yaxis_2_title = "Significance";
-
-  // Axis for plot
-
-  const Double_t pad_xlow = 0;
-  const Double_t pad_ylow = 0;
-  const Double_t pad_xup = 30;
-  const Double_t pad_yup = 1000;
-
-  
-  
-  
-  // Axis labels offsets for plot
- 
-  const Double_t xaxis_label_xoffset_pad = 8;
-  const Double_t xaxis_label_yoffset_pad = -300;
-  const Double_t yaxis_label_xoffset_pad = -5;
-  const Double_t yaxis_label_yoffset_pad = 1200;
-  const Double_t yaxis_2_label_xoffset_pad = 35;
-  const Double_t yaxis_2_label_yoffset_pad = 1200;
-
- 
-
-  // Vector of pointer to histograms that will be plotted
-  // Colors and marker types are also defined 
-
-
-  const Int_t n_graphs = 2; 
-  TGraph* graph_vector [n_graphs];
-  Int_t graph_colors_vector[n_graphs] = {3,2};
-  Int_t polimarker_style_vector[n_graphs] = {21,25};
-  char* additional_info_vector[n_graphs] = 
-    {"Excess events", "Significance"};
-
-
-
-  // TMP VARIABLES
-
-  Int_t tmp_int = 0;
-
-  TH1F* histo1;
-  TH1F* histo2;
-
-
- 
-  Double_t y_axis_2_min_value = 0.0;
-  Double_t y_axis_2_max_value = 0.0;
-  
-  Double_t graph_y_minmax_vector [n_graphs][2];
-  // It contains y values min and max for graphs that 
-  // are plotted.
-  
-  Double_t graph_2_scale_factor = 0.0;
-
-  // ******************************************************************
-  // Data is read from the histograms contained in the input root file 
-  // and stored in vectors 
-  // ******************************************************************
-  
-  TFile rootfile (SCRootFile, "READ");
-
-  histo1 = (TH1F*) rootfile.Get(ExcessEventsHistoName);
-  histo2 = (TH1F*) rootfile.Get(SignificanceHistoName);
-
-  
-
-  // check that dimension is the same 
-
-  if (histo1 -> GetNbinsX() != histo2 -> GetNbinsX())
-    {
-      cout << "Dimension of histogram " << ExcessEventsHistoName 
-	   << " is not equal to dimension of histogram "<< SignificanceHistoName << endl
-	   << "Aborting ..." << endl;
-      
-      Exit(1);
-    }
-
-  
-  tmp_int = histo1 -> GetNbinsX();
-  
-  const Int_t vectors_dimension = tmp_int;
-
-
-  // Vectors that will be used to plot graphs are defined and filled
-
-  Double_t alpha_cut_vector[vectors_dimension] = {0.0};
-  Double_t excess_events_vector[vectors_dimension] = {0.0};
-  Double_t significance_vector[vectors_dimension] = {0.0};
-
-
-  for (Int_t i = 0 ; i < vectors_dimension; i++)
-    {
-      alpha_cut_vector[i] =  histo1-> GetBinCenter(i+1) + ((histo1->GetBinWidth(i+1))/2);
-      excess_events_vector[i] = histo1-> GetBinContent(i+1);
-      significance_vector[i] = histo2-> GetBinContent(i+1);
-    }
-
-  
-  
-
-   // Dynamic memory from is released and root file closed 
-
-  delete histo1;
-  delete histo2;
-
-  rootfile.Close();
-
-
-    // Information retrieved from histos is displayed in terminal
-  
-  cout << endl
-       << "Cut in alpha, excess events and significance values retrieved from root file: "
-       << endl;
-
-  for (Int_t i = 0 ; i < vectors_dimension; i++)
-    {
-      cout << alpha_cut_vector[i] << "        " 
-	   << excess_events_vector[i] << "        " 
-	   << significance_vector[i] << endl;
-    }
-  
-
-
-
-
-
-  //******************************************************
-  // Graph 2 is scaled so that it can be plotted in the 
-  // same TPad... kind of a trick in root.
-
-  // First, values min and max are needed for the 
-  // graphs to be plotted.
-
-  graph_y_minmax_vector [0][0] = pad_ylow;
-  graph_y_minmax_vector [0][1] = find_max (excess_events_vector, 
-					   vectors_dimension);
-    
-cout << " min set to : " <<  graph_y_minmax_vector [0][0] << endl;
-cout << " max set to : " <<  graph_y_minmax_vector [0][1] << endl;
-
-  graph_y_minmax_vector [1][0] = 0;
-					
-  graph_y_minmax_vector [1][1] = find_max (significance_vector, 
-					   vectors_dimension);
-  //TEST
-  /*
-  cout << graph_y_minmax_vector [0][1] << "  "  
-       << graph_y_minmax_vector [0][0] << endl;
-
-   cout << graph_y_minmax_vector [1][1] << "  "  
-       << graph_y_minmax_vector [1][0] << endl;
-   */
-
-
-   
-  graph_2_scale_factor = 
-    (graph_y_minmax_vector [0][1] - 
-     graph_y_minmax_vector [0][0])/(graph_y_minmax_vector [1][1] 
-				    - graph_y_minmax_vector [1][0]);
-
-  //  cout << "scale factor :  " << graph_2_scale_factor << endl;
-
-  for (Int_t i = 0 ; i < vectors_dimension; i++)
-    { 
-      
-      significance_vector[i] = ((graph_2_scale_factor * significance_vector[i])
-			   + graph_y_minmax_vector [0][0]);
-    }
-  
-  // ***********  END OF SCALING   ********************************
-
-  // Graphs are initialized and filled with vectors
-
-   
-  // Graph i initialized and filled 
-  graph_vector[0] = new TGraph(vectors_dimension,
-			       alpha_cut_vector, 
-			       excess_events_vector);
-      
-
-  graph_vector[1] = new TGraph(vectors_dimension,
-			       alpha_cut_vector, 
-			       significance_vector);
-  
-  // Some properties of graphs are set
-
-  for (Int_t i = 0; i < n_graphs; i++)
-    {
-      graph_vector[i]->SetTitle();
-      graph_vector[i]->SetFillColor(19);
-      graph_vector[i]->SetLineColor(graph_colors_vector[i]);
-      graph_vector[i]->SetLineWidth(1);
-      graph_vector[i]->SetMarkerColor(graph_colors_vector[i]);
-      graph_vector[i]->SetMarkerStyle(polimarker_style_vector[i]);
-      graph_vector[i]->SetMarkerSize(1);
-    }
-
-
-// Graphgrams are plotted
-
-
- TCanvas *Window = new TCanvas("Plot","Plot",600,600); 
-  
- gStyle->SetOptStat(0);   
- // So that statistic information is not printed
-
-  Window -> SetFillColor(10);
-  gStyle -> SetFrameFillColor(10);
-  gStyle -> SetPadLeftMargin (0.15);
-  gStyle -> SetPadRightMargin (0.15);
-  gStyle -> SetPadTopMargin (0.05);
-  gStyle -> SetPadBottomMargin (0.15);
-
-  TPaveText *title = new TPaveText (.05,.95,.95,.99);
-  title -> SetFillColor (38);  
-  title -> AddText (ps_title);
-  title -> Draw();
-
- 
-  
-  
-  /* TPad(const char *name, const char *title, 
-     Double_t xlow, Double_t ylow, 
-     Double_t xup, Double_t yup, Color_t color, 
-     Short_t bordersize,Short_t bordermode) 
-     : TVirtualPad(name,title,xlow,ylow,xup,yup,color,
-     bordersize,bordermode) 
-  */
-
-  TPad *pad = new TPad ("plot", "plot",0.0, 0.0, 1.0, 0.92, 
-			10, 0, 0); 
-  // I do not want any border effect.
-  pad -> Draw();
-   
-   
-  // Axis and axis labels for pad1 are created and drawn.
-
-  pad -> cd();
-  pad -> SetGrid(1,1); // Grid for x axis and for y axis.
-  pad -> DrawFrame(pad_xlow,pad_ylow,pad_xup,pad_yup); 
-  // dimensions of the pad are set.
-  
-  
-   
-  // Labels of the graph are set
-
-  TText *t = new TText();
-  t->SetTextFont(62);
-  t->SetTextColor(1);
-  t->SetTextSize(0.05);
-  t->SetTextAlign(11);
-
-  // X axis
-  t->SetTextAngle(0);
-  t->DrawText(xaxis_label_xoffset_pad,
-	      xaxis_label_yoffset_pad,
-	      xaxis_title);
-  // Y axis
-  t->SetTextAngle(90); 
-  t->DrawText(yaxis_2_label_xoffset_pad,
-	      yaxis_2_label_yoffset_pad, 
-	      yaxis_2_title);
-
- 
-  
-
-  // Graphs are plotted in pad
-
-
-  for (Int_t j = 0; j < n_graphs; j++)
-    {  
-      
-      pad -> cd();
-      graph_vector[j]-> Draw("LP");
-      // "A" option is removed in order to 
-      //control de dimensionsn of the pad, 
-      // by means of the " DrawFrame()" function.
-      
-    }
-  
-  // **************************************************
-  // Second Axis is drawn with its label
-  
-  // First of all we must look for units at
-  // bottom and top of axis. This is found 
-
-  
-  y_axis_2_min_value = ((pad_ylow - graph_y_minmax_vector [0][0])/
-			graph_2_scale_factor);
-
-  y_axis_2_max_value = ((pad_yup - graph_y_minmax_vector [0][0])/
-			graph_2_scale_factor);
-
-  
-
-  TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
-			    gPad->GetUxmax(), gPad->GetUymax(),
-			    y_axis_2_min_value,
-			    y_axis_2_max_value,510,"+L");
-
-   axis->SetLineColor(1);
-   axis->SetTextColor(1);
-   axis->Draw();
-
-    // Y axis 2
-  t->SetTextAngle(90); 
-  t->DrawText(yaxis_label_xoffset_pad,
-	      yaxis_label_yoffset_pad, 
-	      yaxis_title);
-
-  // Graph information is produced and drawn.
-
-  // Spectrum names
-  /*
-  char info_string[150] = 0;
-  char info_string_tmp [20] = 0;
-  Double_t xpos = 0;
-  Double_t ypos = 0;
-  TText *tt = new TText();
-  tt->SetTextFont(62);
-  tt->SetTextSize(0.04);
-  tt->SetTextAlign(12);
-  tt->SetTextAngle(0);
-  
-  for (Int_t i = 0; i < n_graphs; i++)
-    {
-      if (i < 1)
-	{xpos = 0.15; ypos =  0.91;} 
-      else 
-	{xpos = 0.15; ypos = 0.85;}
-      
-      //xpos = 0.02 + i*0.12 + i*(i-1)*0.15; //for three curves
-      //xpos = 0.1 + i*0.4; // for two curves
-      strcpy(info_string, additional_info_vector[i]);
-      tt->SetTextColor(graph_colors_vector[i]);
-      Window -> cd();
-      tt->DrawText(xpos,ypos,info_string);
-    }
-  */
-
-
-  Window -> SaveAs(output_ps_file);
-
-}
-
-
-
-
-// FUNCTION DEFINITIONS
-
-
-
-
-
-Double_t find_value (Double_t vector[], Int_t dimension, Int_t min_max)
-{
-  Double_t value = vector[0];
-  if (min_max < 0.5) // we look for min
-    {
-      for (Int_t i = 1; i < dimension; i++)
-	{
-	  if (value > vector[i])
-	    {
-	      value = vector[i];
-	    }
-	}
-    }
-
-  else // we look for max
-    {
-      for (Int_t i = 1; i < dimension; i++)
-	{
-	  if (value < vector[i])
-	    {
-	      value = vector[i];
-	    }
-	}
-    }
-
-  return value;
-}
-  
-
-
-Double_t find_min (Double_t vector[], Int_t dimension)
-{
-  Double_t min = 0.0;
-  min = find_value (vector, dimension, 0);
-  return min;
-}
-
-
-
-Double_t find_max (Double_t vector[], Int_t dimension)
-{
-  Double_t max = 0.0;
-  max = find_value (vector, dimension, 1);
-  return max;
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacro.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacro.C	(revision 7136)
+++ 	(revision )
@@ -1,435 +1,0 @@
-// Silly macro to run the classes that optimize supercuts 
-// using ON and OFF data.
-
-// The user only needs to fill/change the variables that control 
-// the optimization procedure.
-
-
-gROOT -> Reset();
-
-void SuperCutsONOFFMacroNew()
-{
-  gLog.SetNoColors();
-
-    // File containing the data (ON/OFF DATA and path for files (root/ps))
-
-    // From magicserv01
-//    TString  ONDataFilename("/.magic/data16a/mazin/data/mcdata/2004_06_30/*HillasON.root");
-                                       
-//    TString  OFFDataFilename("/.magic/data16a/mazin/data/mcdata/2004_06_30/*HillasOFF.root");
-
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040914.root");
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040921.root");
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040922.root");
-
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_2004*.root");
-  
-   //TString  ONDataFilename("/.magic/data22a/mazin/HillasParam/Period24/2004_12_18/Crab_40_25_1_AbsHillas.root");
-   TString  ONDataFilename("/.magic/data04a/nadia/Analysis/starfiles/DF/40_25_1/CrabNebula_*_Hillas_Abs.root");
-   TString  OFFDataFilename("/.magic/data04a/nadia/Analysis/starfiles/DF/40_25_1/OffCrab1*Hillas_Abs.root");
-   //TString ONDataFilename("/.magic/data03a/mazin/results/2004_09_21/CrabNebulaNadiaHillas.root");  
-   //TString OFFDataFilename("/.magic/data03a/mazin/results/2004_09_21/CrabNebulaNadiaHillas.root");  
-
-
-    TString PathForFiles ("/.magic/data03a/mazin/results/Crab/DF/CrabNadia/SuperCuts/Size2000/");  
-
-//    TString PathForFiles ("/.magic/magicserv01/scratch/hbartko/SC/"); // was: Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC_Test/
-
-    
-
-    // Boolean variables defining the job of the 
-    // macro
- 
-    // Boolean variable that decides wether data is read from files specified above
-    // (ON/OFF) or read from already existing Matrices (which are obviously stored
-    // in a root file). The names of the files storing those matrices are produced 
-    // automatically using information provided by some of the next variables whose 
-    // values must be specified by user.
-
-    Bool_t ReadMatrixFromRootFiles = kTRUE;  
-  
-
-    // Boolean variable that controls the supercuts 
-    // optimization using the training sample
-    // The optimized cuts will be  written in root file
-    // located in directory specified before. Name of 
-    // the root files is created automatically.
-
-    Bool_t TrainParams   = kTRUE;  
-
-    // Variable that allows the user to skip the optimization on the 
-    // train sample. If optimization is skipped (value kTRUE), the
-    // previously optimized supercuts (stored in root file) are used 
-    // on the train sample.
-    
-    Bool_t SkipOptimization = kFALSE;
-
-    // Boolean variable that allows the user to write the initial parameters 
-    // into the root file that will be used to store the optimum cuts.
-    // If fUseInitialSCParams = kTRUE , parameters are written.
-    // In this way, the initial SC parameters can be applied on the data (train/test) 
-    
-    // The initial parameters are ONLY written to the root file if 
-    // there is NO SC params optimization, i.e., if variable 
-    // fSkipOptimization = kTRUE;
-  
-    // NOTE: be aware that, if there was a file with the optimized cuts 
-    // (previously computed), it will be overwritten with the initial 
-    // SC parameters. This is something that I WILL HAVE TO CHANGE IN 
-    // future. Yet for the time being...
-
-    Bool_t UseInitialSCParams = kTRUE;  // was kFALSE 
-    
-
-
-    // Variable that decides whether the optimized cuts are used 
-    // in the test sample.
-
-    Bool_t TestParams = kTRUE;  
-
-
-    // Boolean variable that controls wether to combine, OR not, the 
-    // alpha distributions computed (after cuts) for the several theta bins
-    // in which the TRAIN sample was divided.
-
-    Bool_t CombineCosThetaBinsForTrainSample = kFALSE; 
-    
-    // Boolean variable that controls wether to combine, OR not, the 
-    // alpha distribution computed (after cuts) for the several theta bins
-    // in which the TEST sample was divided.
-
-    Bool_t CombineCosThetaBinsForTestSample = kFALSE; 
-    
-
-    // Fraction of ON events used for the training/testing
-    Double_t whichfractiontrain = 0.5;
-    Double_t whichfractiontest = 0.5;
-
-    // Fraction of OFF events used for the training/testing 
-    Double_t whichfractiontrainOFF = 0.5;
-    Double_t whichfractiontestOFF = 0.5;
-
-
-    // Efficiency for gammas when using this set of dynamical cuts
-    // (i.e., fraction of initial gammas that remain after cuts)
-
-    // Current value is the first estimation of the efficiency of cuts
-    // on Mkn421 at a SIZE > 2000 photons
-
-    Double_t gammaeff = 0.6;  
-                         
-
-    // Alpha value (degrees) below which signal is expected
-    
-    Double_t alphasig = 9; 
-
-    // Definition of alpha bkg region (where no signal is expected)
-
-    Double_t alphabkgmin = 30;
-    Double_t alphabkgmax = 90;
-    
-    // Definition of the Size range
-
-    Double_t SizeLow = 2000;
-//    Double_t SizeUp =  2000;
-    Double_t SizeUp = 1000000;
-    
-    Double_t LeakageMax = 0.04;
-    Double_t DistMax    = 1.5;
-    Double_t DistMin    = 0.1;
-
-     // Definition of binning of alpha plots
-    Int_t NAlphaBins = 35;
-    Double_t AlphaBinLow = -9;
-    Double_t AlphaBinUp = 96;
-
- 
-    // Boolean variable used to determine wether the normalization factor is 
-    // computed from method 1) or 2)
-    // 1) Using total number of ON and OFF events before cuts, and tuning the factor 
-    //    correcting for "contamination" of gamma events in ON sample 
-    // 2) Using number of ON and OFF events after cuts in the background 
-    //    region determined by variables fAlphaBkgMin-fAlphaBkgMax
-    
-    Bool_t NormFactorFromAlphaBkg = kTRUE; // if kTRUE, method 2) is used
-
-
-    // Boolean variable used to disable the usage ("serious" usage) of the 
-    // quantities computed from fits. This will be useful in those cases 
-    // where there is too few events to perform a decent fit to the 
-    // alpha histograms.
-    
-    Bool_t UseFittedQuantities = kTRUE;
-
-
-    // Boolean variable used to control wether to use theta information 
-    // in the computation of teh dynamical cuts that take place within
-    // class MCT1SupercutsCalc
-    //Bool_t NotUseTheta = kFALSE; // kTRUE removes theta from the parameterization of cuts
-    Bool_t NotUseTheta = kTRUE; // kTRUE removes theta from the parameterization of cuts
-
-    // Boolean variable used to decide wether to use dynamical cuts or static cuts
-    // kTRUE means that static cuts are used.
-    Bool_t UseStaticCuts = kFALSE;
-
-
-
-
-
-    // Name of the Postscript document where all plots
-    // will be saved.
-    // STORAGE OF PSFILE IS NOT WORKING PROPERLY
-    // For the time being, several ps files are produced 
-    // and saved in the directory specified by PathForFiles
-
-    /*
-    TString PsFileName = ("PsTest23.ps");
-    TString CompletePsFileName = (PathForFiles);
-    CompletePsFileName += PsFileName;
-    TPostScript* PsFile = new TPostScript(CompletePsFileName, 111);
-    */
-
-    // Boolean variable used to decide wether initial parameters are 
-    // read from ascii file or not. If kTRUE, parameters are retrieved 
-    // from ascii file. 
-
-    Bool_t ReadInitParamsFromAsciiFile = kTRUE;
-
-    // Number of SC parameters. The aim of this variable is to cross check 
-    // that the number of parameters read from an ascii file 
-    // is teh one the user wants. 
-
-    Int_t NInitSCPar = 104;
-
-    // Name of  the ascii file containing the 2 columns, the first one 
-    // for initial parameters and the second one for the steps
-    // Name must contain also the path.
- 
-    const char* InitSCParamAsciiFile = 
-      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
-      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist.txt"};
-      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist11.txt"};
-      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsFixedPol2SizeCut3000.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynWithDistParametersFixed.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2WidthCutLowFixed.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSize.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt"};
-      //{"mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt"};
-      //{"/home/pcmagic16/mazin/mars/Mars260804/mtemp/mmpi/asciifiles/StartingValuesForSmallSizes1.txt"};
-//      {"/home/pcmagic16/mazin/mars/Mars260804/mtemp/mmpi/asciifiles/SmallSizeRFStartValues.txt"};
-      {"/home/pcmagic16/mazin/mars/Mars260804/mtemp/mmpi/asciifiles/OptimizedCrabFrom2000_a.txt"};
-      //{"mtemp/mmpi/asciifiles/VeryGoodDummyValuesWithConcCut.txt"};
-
-
-    // Name of the root file where alpha distributions, TTree objects
-    // with info about the events and cuts applied and  info support histograms 
-    // will be stored. 
-    // Write only the name of the file. The Path 
-    // is the one defined previously
-
-    TString RootFilename = ("RootFileDynCuts.root");
-
-    
-
-    
-    
-
-    // Vector containing the theta bins in which data (ON/OFF train/test)
-    // will be divided. Actually this vector contains the cosinus of 
-    // these theta bins. The dimension of the vector is N+1, where 
-    // N is the number of theta bins intended. The first component of the 
-    // vector is the low bin edge of the first bin, and the last 
-    // vector component the upper bin edge of the last bin.
-
-
-    TArrayD CosThetaRangeVector(2);
-    CosThetaRangeVector[1] = 0.866;  //30
-    //CosThetaRangeVector[1] = 0.74;  //42
-    //CosThetaRangeVector[1] = 0.82;  //35
-    //CosThetaRangeVector[1] = 0;
-    //CosThetaRangeVector[1] = 0.825;
-    //CosThetaRangeVector[2] = 0.921; 
-    //CosThetaRangeVector[3] = 0.961; 
-    CosThetaRangeVector[0] = 0.5;  // 60
-    //CosThetaRangeVector[0] = 1;
-
-
-    /*
-    TArrayD CosThetaRangeVector(2);
-    CosThetaRangeVector[0] = 0.622;
-    // CosThetaRangeVector[1] = 0.825;
-    //CosThetaRangeVector[2] = 0.921; 
-    //CosThetaRangeVector[0] = 0.961; 
-    CosThetaRangeVector[1] = 0.984;
-    
-    */
-    // Object of MCT1FindSupercutsONOFFThetaLoop created, data that was specified 
-    // above is introduced and ... and the party starts.
-     
-    MFindSupercutsONOFFThetaLoop FindSupercuts("MFindSupercutsONOFFThetaLoop", 
-					       "Optimizer for the supercuts");
-
-    
-    FindSupercuts.SetPathForFiles(PathForFiles);
-
-    FindSupercuts.SetDataONOFFRootFilenames(ONDataFilename, OFFDataFilename);
-
-    FindSupercuts.SetFractionTrainTestOnOffEvents(whichfractiontrain, 
-						  whichfractiontest, 
-						  whichfractiontrainOFF, 
-						  whichfractiontestOFF);
-
-
-    FindSupercuts.SetGammaEfficiency(gammaeff);
-
-
-    FindSupercuts.SetAlphaSig(alphasig);
-
-    // Bkg alpha region is set 
-    FindSupercuts.SetAlphaBkgMin(alphabkgmin);
-    FindSupercuts.SetAlphaBkgMax(alphabkgmax);
-
-    // alpha bkg and signal region set in object FindSupercuts
-    // are re-checked in order to be sure that make sense
-	
-    FindSupercuts.CheckAlphaSigBkg();
-
-
-    // binning for alpha plots is defined
-
-    FindSupercuts.SetAlphaPlotBinining(NAlphaBins, AlphaBinLow, 
-				       AlphaBinUp);
-
-
-
-
-    // Size range is defined
-
-    FindSupercuts.SetSizeRange(SizeLow, SizeUp);
-    FindSupercuts.SetFilters(LeakageMax, DistMax, DistMin);
-//    FindSupercuts.SetFilters(0.001, 1.5, 0.2);
-
-
-
-    FindSupercuts.SetNormFactorFromAlphaBkg(NormFactorFromAlphaBkg);
-
-    FindSupercuts.SetUseFittedQuantities(UseFittedQuantities);
-
-    FindSupercuts.SetVariableUseStaticCuts(UseStaticCuts);
-
-    FindSupercuts.SetVariableNotUseTheta(NotUseTheta);
-
-    FindSupercuts.SetReadMatricesFromFile(ReadMatrixFromRootFiles);
-
-    FindSupercuts.SetTrainParameters(TrainParams);
-    FindSupercuts.SetSkipOptimization(SkipOptimization);
-    FindSupercuts.SetUseInitialSCParams(UseInitialSCParams);
-
-    FindSupercuts.SetTestParameters(TestParams);
-
-   
-    
-    FindSupercuts.SetHadronnessName("MHadSC");
-    FindSupercuts.SetHadronnessNameOFF("MHadOFFSC");
-    
-    FindSupercuts.SetAlphaDistributionsRootFilename (RootFilename);
-    
-    // FindSupercuts.SetPostScriptFile (PsFile);
-
-    FindSupercuts.SetCosThetaRangeVector (CosThetaRangeVector);
-    
-
-    // Names for all root files (matrices, alpha distributions...)
-    // are created 
-    FindSupercuts.SetALLNames();
-
-    if(ReadInitParamsFromAsciiFile)
-    {
-	// Initial SC Parameters and steps are retrieved from 
-	// Ascii file
-	if(!FindSupercuts.ReadSCParamsFromAsciiFile(InitSCParamAsciiFile,
-						    NInitSCPar))
-	{
-	    cout << "Initial SC Parameters could not be read from Ascii file "
-		 << InitSCParamAsciiFile << endl
-		 << "Aborting execution of macro... " << endl;
-	    return;
-
-	}
-    }
- 
-   
-
-
-    // Finally loop over all theta bins defined is executed
-    
-    if (!FindSupercuts.LoopOverThetaRanges())
-      {
-	cout << "Function MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges()" << endl
-	     << "could not be performed" << endl;
-
-      }
-
-    
-
-    // Nex and Significance are computed vs alphasig
-    
-    if (!FindSupercuts.ComputeNexSignificanceVSAlphaSig())
-      {
-	cout << "Function MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" << endl
-	     << "could not be performed" << endl;
-	
-
-      }
-    
-
-
-
-    // Option to store ps files in a single ps document is still not working
-    /*
-    PsFile -> Close();
-    PsFile = NULL;
-    */
-
-    // Several theta bins are combined to produced a single alpha plot (for train and test)
-    // with single Nex and significances
-
-    if (CombineCosThetaBinsForTrainSample || CombineCosThetaBinsForTestSample)
-    {
-	if(!FindSupercuts.ComputeOverallSignificance(CombineCosThetaBinsForTrainSample, 
-						     CombineCosThetaBinsForTestSample))
-	  {
-	    cout << "Function MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance" << endl
-		 << "could not be performed" << endl;
-	  }
-       
-
-    }
-
-
-   
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacroNew.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacroNew.C	(revision 7136)
+++ 	(revision )
@@ -1,473 +1,0 @@
-// Silly macro to run the classes that optimize supercuts 
-// using ON and OFF data.
-
-// The user only needs to fill/change the variables that control 
-// the optimization procedure.
-
-
-gROOT -> Reset();
-
-void SuperCutsONOFFMacroNew()
-{
-//  gLog.SetNoColors();
-
-    // File containing the data (ON/OFF DATA and path for files (root/ps))
-
-    // From magicserv01
-//    TString  ONDataFilename("/.magic/data16a/mazin/data/mcdata/2004_06_30/*HillasON.root");
-                                       
-//    TString  OFFDataFilename("/.magic/data16a/mazin/data/mcdata/2004_06_30/*HillasOFF.root");
-
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040914.root");
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040921.root");
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_20040922.root");
-
-//   TString  ONDataFilename("/.magic/magicserv01/scratch/Period21/HillasFiles/CrabNebula_2004*.root");
-  
-   TString  ONDataFilename("/users/emc/mazin/HillasFiles/2004_12_18/55_28_1/CrabNebula*.root");
-   //TString  ONDataFilename("/.magic/data22a/mazin/HillasParam/MC_OffSep/ON/*.root");
-   //TString  ONDataFilename("/.magic/data04a/nadia/Analysis/starfiles/DF/40_25_1/1ES1959_*.root");
-   TString  OFFDataFilename("/users/emc/mazin/HillasFiles/Off/55_28_1/Off*.root");
-   //TString ONDataFilename("/.magic/data03a/mazin/results/2004_09_21/CrabNebulaNadiaHillas.root");  
-   //TString OFFDataFilename("/.magic/data03a/mazin/results/2004_09_21/CrabNebulaNadiaHillas.root");  
-
-
-    //TString PathForFiles ("/.magic/data03a/mazin/results/mcOffCrab/SuperCuts/Size1000/");  
-    //TString PathForFiles ("/.magic/data03a/mazin/results/Crab/DF/CrabNadia/SuperCuts/Size2000_cutsfrommc_all/");  
-    TString PathForFiles ("/users/emc/mazin/SuperCuts/Spline/SuperCuts/55_28_1/Size1k2k/");  
-    //TString PathForFiles ("/.magic/data03a/mazin/results/Crab/DF/CrabNadia/SuperCuts/1ES1959Size2000_cutsfrommc_all_2/");  
-    //TString PathForFiles ("/.magic/data03a/mazin/results/Crab/DF/CrabNadia/SuperCuts/1ES1959Size2000/");  
-//    TString PathForFiles ("/.magic/data03a/mazin/results/Crab/DF/CrabNadia/SuperCuts/Size2000_all/");  
-
-//    TString PathForFiles ("/.magic/magicserv01/scratch/hbartko/SC/"); // was: Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC_Test/
-
-    
-
-    // Boolean variables defining the job of the 
-    // macro
- 
-    // Boolean variable that decides wether data is read from files specified above
-    // (ON/OFF) or read from already existing Matrices (which are obviously stored
-    // in a root file). The names of the files storing those matrices are produced 
-    // automatically using information provided by some of the next variables whose 
-    // values must be specified by user.
-
-    Bool_t ReadMatrixFromRootFiles = kTRUE;  
-  
-
-    // Boolean variable that controls the supercuts 
-    // optimization using the training sample
-    // The optimized cuts will be  written in root file
-    // located in directory specified before. Name of 
-    // the root files is created automatically.
-
-    Bool_t TrainParams   = kTRUE;  
-
-    // Variable that allows the user to skip the optimization on the 
-    // train sample. If optimization is skipped (value kTRUE), the
-    // previously optimized supercuts (stored in root file) are used 
-    // on the train sample.
-    
-    Bool_t SkipOptimization = kFALSE;
-
-    // Boolean variable that allows the user to write the initial parameters 
-    // into the root file that will be used to store the optimum cuts.
-    // If fUseInitialSCParams = kTRUE , parameters are written.
-    // In this way, the initial SC parameters can be applied on the data (train/test) 
-    
-    // The initial parameters are ONLY written to the root file if 
-    // there is NO SC params optimization, i.e., if variable 
-    // fSkipOptimization = kTRUE;
-  
-    // NOTE: be aware that, if there was a file with the optimized cuts 
-    // (previously computed), it will be overwritten with the initial 
-    // SC parameters. This is something that I WILL HAVE TO CHANGE IN 
-    // future. Yet for the time being...
-
-    Bool_t UseInitialSCParams = kTRUE;  // was kFALSE 
-    
-
-
-    // Variable that decides whether the optimized cuts are used 
-    // in the test sample.
-
-    Bool_t TestParams = kTRUE;  
-
-
-    // Boolean variable that controls wether to combine, OR not, the 
-    // alpha distributions computed (after cuts) for the several theta bins
-    // in which the TRAIN sample was divided.
-
-    Bool_t CombineCosThetaBinsForTrainSample = kFALSE; 
-    
-    // Boolean variable that controls wether to combine, OR not, the 
-    // alpha distribution computed (after cuts) for the several theta bins
-    // in which the TEST sample was divided.
-
-    Bool_t CombineCosThetaBinsForTestSample = kFALSE; 
-    
-
-    // Fraction of ON events used for the training/testing
-    Double_t whichfractiontrain = 0.5;
-    Double_t whichfractiontest = 0.5;
-
-    // Fraction of OFF events used for the training/testing 
-    Double_t whichfractiontrainOFF = 0.5;
-    Double_t whichfractiontestOFF = 0.5;
-
-
-    // Efficiency for gammas when using this set of dynamical cuts
-    // (i.e., fraction of initial gammas that remain after cuts)
-
-    // Current value is the first estimation of the efficiency of cuts
-    // on Mkn421 at a SIZE > 2000 photons
-
-    Double_t gammaeff = 0.6;  
-                         
-
-    // Alpha value (degrees) below which signal is expected
-    
-    Double_t alphasig = 6; 
-
-    // Definition of alpha bkg region (where no signal is expected)
-
-    Double_t alphabkgmin = 20;
-    Double_t alphabkgmax = 80;
-
-    // Definition of the degree of the polynomials used to fit 
-    // the ON and the OFF data
-
-    Int_t degree = 2;
-
-    
-    // Definition of the Size range
-
-    Double_t SizeLow = 1000;
-    Double_t SizeUp =  2000;
-//    Double_t SizeUp = 1000000;
-    
-/*
-    Double_t LeakageMax = 0.05;
-    Double_t DistMax    = 1.5;
-    Double_t DistMin    = 0.1;
-*/
-    //Double_t LeakageMax = 1.;
-    //Double_t DistMax    = 1.0;
-    //Double_t DistMin    = 0.2;
-
-    Double_t LeakageMax = 0.25;
-    Double_t DistMax    = 1.0;
-    Double_t DistMin    = 0.2;
-
-     // Definition of binning of alpha plots
-//    Int_t NAlphaBins = 35;
-//    Double_t AlphaBinLow = -9;
-//    Double_t AlphaBinUp = 96;
-
-    Int_t NAlphaBins = 30;
-    Double_t AlphaBinLow = 0;
-    Double_t AlphaBinUp = 90;
-
-//    Int_t NAlphaBins = 20;
-//    Double_t AlphaBinLow = 0;
-//    Double_t AlphaBinUp = 90;
-
- 
-    // Boolean variable used to determine wether the normalization factor is 
-    // computed from method 1) or 2)
-    // 1) Using total number of ON and OFF events before cuts, and tuning the factor 
-    //    correcting for "contamination" of gamma events in ON sample 
-    // 2) Using number of ON and OFF events after cuts in the background 
-    //    region determined by variables fAlphaBkgMin-fAlphaBkgMax
-    
-    Bool_t NormFactorFromAlphaBkg = kTRUE; // if kTRUE, method 2) is used
-
-
-    // Boolean variable used to disable the usage ("serious" usage) of the 
-    // quantities computed from fits. This will be useful in those cases 
-    // where there is too few events to perform a decent fit to the 
-    // alpha histograms.
-    
-    Bool_t UseFittedQuantities = kTRUE;
-
-
-    // Boolean variable used to control wether to use theta information 
-    // in the computation of teh dynamical cuts that take place within
-    // class MCT1SupercutsCalc
-    //Bool_t NotUseTheta = kFALSE; // kTRUE removes theta from the parameterization of cuts
-    Bool_t NotUseTheta = kTRUE; // kTRUE removes theta from the parameterization of cuts
-
-    // Boolean variable used to decide wether to use dynamical cuts or static cuts
-    // kTRUE means that static cuts are used.
-    Bool_t UseStaticCuts = kFALSE;
-
-
-
-
-
-    // Name of the Postscript document where all plots
-    // will be saved.
-    // STORAGE OF PSFILE IS NOT WORKING PROPERLY
-    // For the time being, several ps files are produced 
-    // and saved in the directory specified by PathForFiles
-
-    /*
-    TString PsFileName = ("PsTest23.ps");
-    TString CompletePsFileName = (PathForFiles);
-    CompletePsFileName += PsFileName;
-    TPostScript* PsFile = new TPostScript(CompletePsFileName, 111);
-    */
-
-    // Boolean variable used to decide wether initial parameters are 
-    // read from ascii file or not. If kTRUE, parameters are retrieved 
-    // from ascii file. 
-
-    Bool_t ReadInitParamsFromAsciiFile = kTRUE;
-
-    // Number of SC parameters. The aim of this variable is to cross check 
-    // that the number of parameters read from an ascii file 
-    // is teh one the user wants. 
-
-    Int_t NInitSCPar = 104;
-
-    // Name of  the ascii file containing the 2 columns, the first one 
-    // for initial parameters and the second one for the steps
-    // Name must contain also the path.
- 
-    const char* InitSCParamAsciiFile = 
-      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
-      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist.txt"};
-      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist11.txt"};
-      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsFixedPol2SizeCut3000.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynWithDistParametersFixed.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2WidthCutLowFixed.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSize.txt"};
-      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt"};
-      //{"mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt"};
-        {"mtemp/mmpi/asciifiles/StartingValuesForSmallSizes1.txt"};
-      //{"mtemp/mmpi/asciifiles/SmallSizeRFStartValues.txt"};
-//      {"/home/pcmagic16/mazin/mars/Mars260804/mtemp/mmpi/asciifiles/OptimizedCrabFrom2000_a.txt"};
-      //{"mtemp/mmpi/asciifiles/VeryGoodDummyValuesWithConcCut.txt"};
-
-
-    // Name of the root file where alpha distributions, TTree objects
-    // with info about the events and cuts applied and  info support histograms 
-    // will be stored. 
-    // Write only the name of the file. The Path 
-    // is the one defined previously
-
-    TString RootFilename = ("RootFileDynCuts.root");
-
-    
-
-    
-    
-
-    // Vector containing the theta bins in which data (ON/OFF train/test)
-    // will be divided. Actually this vector contains the cosinus of 
-    // these theta bins. The dimension of the vector is N+1, where 
-    // N is the number of theta bins intended. The first component of the 
-    // vector is the low bin edge of the first bin, and the last 
-    // vector component the upper bin edge of the last bin.
-
-
-    TArrayD CosThetaRangeVector(2);
-    CosThetaRangeVector[1] = 0.866;  //30
-    //CosThetaRangeVector[1] = 0.74;  //42
-    //CosThetaRangeVector[1] = 0.82;  //35
-    //CosThetaRangeVector[1] = 0;
-    //CosThetaRangeVector[1] = 0.825;
-    //CosThetaRangeVector[2] = 0.921; 
-    //CosThetaRangeVector[3] = 0.961; 
-    CosThetaRangeVector[0] = 0.5;  // 60
-    //CosThetaRangeVector[0] = 1;
-
-
-    /*
-    TArrayD CosThetaRangeVector(2);
-    CosThetaRangeVector[0] = 0.622;
-    // CosThetaRangeVector[1] = 0.825;
-    //CosThetaRangeVector[2] = 0.921; 
-    //CosThetaRangeVector[0] = 0.961; 
-    CosThetaRangeVector[1] = 0.984;
-    
-    */
-    // Object of MCT1FindSupercutsONOFFThetaLoop created, data that was specified 
-    // above is introduced and ... and the party starts.
-     
-    MFindSupercutsONOFFThetaLoop FindSupercuts("MFindSupercutsONOFFThetaLoop", 
-					       "Optimizer for the supercuts");
-
-    
-    FindSupercuts.SetPathForFiles(PathForFiles);
-
-    FindSupercuts.SetDataONOFFRootFilenames(ONDataFilename, OFFDataFilename);
-
-    FindSupercuts.SetFractionTrainTestOnOffEvents(whichfractiontrain, 
-						  whichfractiontest, 
-						  whichfractiontrainOFF, 
-						  whichfractiontestOFF);
-
-
-    FindSupercuts.SetGammaEfficiency(gammaeff);
-
-
-    FindSupercuts.SetAlphaSig(alphasig);
-
-    // Bkg alpha region is set 
-    FindSupercuts.SetAlphaBkgMin(alphabkgmin);
-    FindSupercuts.SetAlphaBkgMax(alphabkgmax);
-
-    // alpha bkg and signal region set in object FindSupercuts
-    // are re-checked in order to be sure that make sense
-	
-    FindSupercuts.CheckAlphaSigBkg();
-
-
-    // Degree of the polynomials used to fit the ON OFF data 
-    // is set
-
-    FindSupercuts.SetDegreeON(degree);
-    FindSupercuts.SetDegreeOFF(degree);
-
-
-
-
-    // binning for alpha plots is defined
-
-    FindSupercuts.SetAlphaPlotBinining(NAlphaBins, AlphaBinLow, 
-				       AlphaBinUp);
-
-
-
-
-    // Size range is defined
-
-    FindSupercuts.SetSizeRange(SizeLow, SizeUp);
-    FindSupercuts.SetFilters(LeakageMax, DistMax, DistMin);
-//    FindSupercuts.SetFilters(0.001, 1.5, 0.2);
-
-
-
-    FindSupercuts.SetNormFactorFromAlphaBkg(NormFactorFromAlphaBkg);
-
-    FindSupercuts.SetUseFittedQuantities(UseFittedQuantities);
-
-    FindSupercuts.SetVariableUseStaticCuts(UseStaticCuts);
-
-    FindSupercuts.SetVariableNotUseTheta(NotUseTheta);
-
-    FindSupercuts.SetReadMatricesFromFile(ReadMatrixFromRootFiles);
-
-    FindSupercuts.SetTrainParameters(TrainParams);
-    FindSupercuts.SetSkipOptimization(SkipOptimization);
-    FindSupercuts.SetUseInitialSCParams(UseInitialSCParams);
-
-    FindSupercuts.SetTestParameters(TestParams);
-
-   
-    
-    FindSupercuts.SetHadronnessName("MHadSC");
-    FindSupercuts.SetHadronnessNameOFF("MHadOFFSC");
-    
-    FindSupercuts.SetAlphaDistributionsRootFilename (RootFilename);
-    
-    // FindSupercuts.SetPostScriptFile (PsFile);
-
-    FindSupercuts.SetCosThetaRangeVector (CosThetaRangeVector);
-    
-
-    // Names for all root files (matrices, alpha distributions...)
-    // are created 
-    FindSupercuts.SetALLNames();
-
-    if(ReadInitParamsFromAsciiFile)
-    {
-	// Initial SC Parameters and steps are retrieved from 
-	// Ascii file
-	if(!FindSupercuts.ReadSCParamsFromAsciiFile(InitSCParamAsciiFile,
-						    NInitSCPar))
-	{
-	    cout << "Initial SC Parameters could not be read from Ascii file "
-		 << InitSCParamAsciiFile << endl
-		 << "Aborting execution of macro... " << endl;
-	    return;
-
-	}
-    }
- 
-   
-
-
-    // Finally loop over all theta bins defined is executed
-    
-    if (!FindSupercuts.LoopOverThetaRanges())
-      {
-	cout << "Function MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges()" << endl
-	     << "could not be performed" << endl;
-
-      }
-
-    
-
-    // Nex and Significance are computed vs alphasig
-    
-    if (!FindSupercuts.ComputeNexSignificanceVSAlphaSig())
-      {
-	cout << "Function MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" << endl
-	     << "could not be performed" << endl;
-	
-
-      }
-    
-
-
-
-    // Option to store ps files in a single ps document is still not working
-    /*
-    PsFile -> Close();
-    PsFile = NULL;
-    */
-
-    // Several theta bins are combined to produced a single alpha plot (for train and test)
-    // with single Nex and significances
-
-    if (CombineCosThetaBinsForTrainSample || CombineCosThetaBinsForTestSample)
-    {
-	if(!FindSupercuts.ComputeOverallSignificance(CombineCosThetaBinsForTrainSample, 
-						     CombineCosThetaBinsForTestSample))
-	  {
-	    cout << "Function MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance" << endl
-		 << "could not be performed" << endl;
-	  }
-       
-
-    }
-
-
-   
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/callalphaplot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/callalphaplot.C	(revision 7136)
+++ 	(revision )
@@ -1,1271 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-
-// Daniel Mazin 18.05.2004  mazin@mppmu.mpg.de
-// **********************************************************************************
-// this macro is used to produce an alpha plot/plots for a chosen position in the sky map.
-// In case of several subsamples, the overall alpha plot is also produced.
-// The derotation is possible if Zd and Az are available for each event.
-// Using of OFF data to estimate Nex and Significance is optional (if such data available)
-//
-// input: hillas parameter file/files
-//      optional: a) ascii file with the estimated position of the source
-//                b) ascii file with fit parameters from the OFF sample 
-//                                  (needed for estimation of the background from OFF dada)
-// output: alpha plot for each subsample, overall alpha plot
-// **********************************************************************************
-
-
-#define XSOUR   0.05  // [deg]
-#define YSOUR   0.6  // [deg]
-#define NUM     0
-
-
-TString sourcename = "M87On";
-
-const Bool_t ROTOPTION  = kFALSE;  // kFALSE: do not derotate, use camera coordinates
-                                  // kTRUE: derotate into "quasi" sky coordinates
-
-const Bool_t USEOFFDATA = kFALSE; // kFALSE: do not use OFF data to estimate the significance
-                                  // kTRUE: use in addition OFF data to estimate the significance
-
-const char * offfile = "paramOffCrab2701.dat"; // file with parameters of the OFF sample
-                                               // needed only if USEOFFDATA = kTRUE
-
-const Bool_t USEFILE = kFALSE; // kFALSE : use XSOUR, YSOUR 
-                               // kTRUE: use "posfile" 
-                               // to specify the position for which alpha plot has to be produced
-
-const Bool_t SAMPLES = kFALSE; // kFALSE: one sample only
-                               // kTRUE: several samples, usage of posfile is preferred!  
-
-const char * posfile = "data/trackCrab1502_1305_Berlin_5deg.dat"; // file with best position
-                                                                  // if USEFILE == kFALSE : not needed
-
-TString dirname  = "~/data/M87/2004_02_17/";
-TString filename = "M87HillasON.root"; //  NOTE in case of several subsamples (SAMPLES=kTRUE)
-                                         // folllowing name construction is assumed:
-                                         // file = dirname + sample + <number> + / + filename
-                                         // e.g: ~/data/Crab/2004_01_27/sample2/CrabHillasON.root
-#define tolerance 1e-3
-/* ******************************************************   */
-      /*  dynamical cuts  Crab 27th Jan 2004 */
-/*
-#define LENGTHMINParA 0.136  // deg
-#define LENGTHMINParB 0.036  //
-#define LENGTHMINParC -0.0038  //
-#define LENGTHMAXParA 0.332  // deg
-#define LENGTHMAXParB 0.037  //
-#define LENGTHMAXParC 0.0261 //
-#define WIDTHMINParA  0.063  // deg
-#define WIDTHMINParB  0.013  //
-#define WIDTHMINParC  0.0003  //
-#define WIDTHMAXParA  0.123  // deg
-#define WIDTHMAXParB  0.019  //
-#define WIDTHMAXParC  0.0005 //
-#define DISTMINParA   0.6   // deg
-#define DISTMINParB   0.059  //
-#define DISTMINParC   0.  //
-#define DISTMAXParA   1.25   // deg
-#define DISTMAXParB   0.059  //
-#define DISTMAXParC   0.  //
-*/
-
-      /*  dynamical cuts  Mrk 421 and Crab 15th Feb 2004 */
-
-#define LENGTHMINParA 0.12  // deg
-#define LENGTHMINParB 0.034  //
-#define LENGTHMINParC 0.  //
-#define LENGTHMAXParA 0.32  // deg
-#define LENGTHMAXParB 0.034  //
-#define LENGTHMAXParC 0. //
-#define WIDTHMINParA  0.055  // deg
-#define WIDTHMINParB  0.013  //
-#define WIDTHMINParC  0.0  //
-#define WIDTHMAXParA  0.12  // deg
-#define WIDTHMAXParB  0.013  //
-#define WIDTHMAXParC  0.0 //
-#define DISTMINParA   0.6   // deg
-#define DISTMINParB   0.059  //
-#define DISTMINParC   0.  //
-#define DISTMAXParA   1.25   // deg
-#define DISTMAXParB   0.059  //
-#define DISTMAXParC   0.  //
-
-
-#define SIZEMIN 2000
-#define LEAKMAX 0.25
-#define ASYMMIN  -0.1 
-
-#include "mtools.C"
-
-#define ALPHAMAX 15.
-
-#define ALOFFMAX 90.
-#define ALOFFMIN 30.
-
-// histogram to store the sum of alpha plots
-   TH1F histalphaAll("alpha plot", "alpha plot, size cut 2000, 15 deg", 36, 0., 90.);
-   histalphaAll.SetXTitle("alpha (deg)");
-   histalphaAll.SetYTitle("Counts");
-   histalphaAll.SetDirectory(NULL);
-   histalphaAll.SetFillStyle(4000);
-   histalphaAll.UseCurrentStyle();
-
-
-void alphaplots(Int_t num, Double_t XSOURCE, Double_t YSOURCE)
-{
-
-// for USEOFFDATA = kTRUE the ascii file with fit parameters of the OFF sample is read.
-
-   if (USEOFFDATA == kTRUE)
-   {
-	    Int_t event, dummy, numbinsoff;
-	    Float_t binwidthOff, xpos, ypos, aparOff, bparOff, chi2par;
-
-	    FILE *fp;
-	    fp = fopen(offfile,"r");    
-	    while(fscanf(fp,"%d %f %f %f %f %f %f %f %f %f",
-		       &event, &xpos, &ypos,  &aparOff, &bparOff, &chi2par,
-		       &binwidthOff, &dummy, &dummy, &dummy) != EOF)
-	    {
-//cout << event << " " << xpos << " " << ypos << endl;
-		     if(TMath::Abs(xpos-XSOURCE) < tolerance && TMath::Abs(ypos-YSOURCE) < tolerance) break;
-	    }
-	    fclose(fp);
-   }
-
-
-    gStyle->SetCanvasBorderMode(0);
-    gStyle->SetCanvasBorderSize(0);
-    gStyle->SetCanvasColor(10);
-    gStyle->SetPadBorderMode(0);
-    gStyle->SetPadBorderSize(0);
-    gStyle->SetPadColor(10);
-    gStyle->SetOptFit(1);
-    gStyle->SetStatColor(10);
-//    gStyle->SetOptStat(0);
-    gStyle->SetPalette(1,0);
-
-
-
-// the name of the Hillas parameter file, which has to be read in
-    TString ddumy;
-
-    if (SAMPLES == kFALSE)
-        filename = dirname + filename;
-    else
-    {
-       ddumy = dirname;
-       ddumy += "sample"; 
-       ddumy += num; 
-       filename = ddumy + filename; 
-    }
-
-cout << "file to read :" << filename << endl;
-
-
-// create histograms   
-    MBinning bins;
-
-   TH1F histlength;
-   histlength.SetName("Length");
-   histlength.SetTitle("Length");
-   histlength.SetXTitle("Length [deg]");
-   histlength.SetYTitle("Counts");
-   histlength.SetDirectory(NULL);
-   histlength.SetFillStyle(4000);
-   histlength.UseCurrentStyle(); 
-
-
-    bins.SetEdges(100, 0., 1.);
-    bins.Apply(histlength);
-
-
-   TH1F histwidth;
-   histwidth.SetName("Width");
-   histwidth.SetTitle("Width");
-   histwidth.SetXTitle("Width [deg]");
-   histwidth.SetYTitle("Counts");
-   histwidth.SetDirectory(NULL);
-   histwidth.SetFillStyle(4000);
-   histwidth.UseCurrentStyle(); 
-
-    bins.SetEdges(100, 0., 0.5);
-    bins.Apply(histwidth);
-
-
-   TH1F histsize;
-   histsize.SetName("Size");
-   histsize.SetTitle("Size");
-   histsize.SetXTitle("Size");
-   histsize.SetYTitle("Counts");
-   histsize.SetDirectory(NULL);
-   histsize.SetFillStyle(4000);
-   histsize.UseCurrentStyle(); 
-
-//    bins.SetEdges(100, 100., 2e5);
-//    bins.Apply(histsize);
-
-    bins.SetEdgesLog(100, 100., 10e5);
-    bins.Apply(histsize);
-
-   TH1F histalpha;
-   histalpha.SetName("Alpha");
-   histalpha.SetTitle("Alpha");
-   histalpha.SetXTitle("Alpha [deg]");
-   histalpha.SetYTitle("Counts");
-   histalpha.SetDirectory(NULL);
-   histalpha.SetFillStyle(4000);
-   histalpha.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -100., 100.);
-    bins.Apply(histalpha);
-
-   TH1F histdist;
-   histdist.SetName("Dist");
-   histdist.SetTitle("Dist");
-   histdist.SetXTitle("Dist [deg]");
-   histdist.SetYTitle("Counts");
-   histdist.SetDirectory(NULL);
-   histdist.SetFillStyle(4000);
-   histdist.UseCurrentStyle(); 
-
-    bins.SetEdges(100, 0., 2.);
-    bins.Apply(histdist);
-
-   TH1F histmeanx;
-   histmeanx.SetName("MeanX");
-   histmeanx.SetTitle("MeanX");
-   histmeanx.SetXTitle("MeanX [deg]");
-   histmeanx.SetYTitle("Counts");
-   histmeanx.SetDirectory(NULL);
-   histmeanx.SetFillStyle(4000);
-   histmeanx.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -1.8, 1.8);
-    bins.Apply(histmeanx);
-
-   TH1F histmeany;
-   histmeany.SetName("MeanY");
-   histmeany.SetTitle("MeanY");
-   histmeany.SetXTitle("MeanY [deg]");
-   histmeany.SetYTitle("Counts");
-   histmeany.SetDirectory(NULL);
-   histmeany.SetFillStyle(4000);
-   histmeany.UseCurrentStyle(); 
-
-
-    bins.SetEdges(100, -1.8, 1.8);
-    bins.Apply(histmeany);
-
-   TH1F histalphafinal;
-   histalphafinal.SetName("ALPHA");
-   histalphafinal.SetTitle("ALPHA");
-   histalphafinal.SetXTitle("alpha [deg]");
-   histalphafinal.SetYTitle("Counts");
-   histalphafinal.SetDirectory(NULL);
-   histalphafinal.SetFillStyle(4000);
-   histalphafinal.UseCurrentStyle(); 
-
-    bins.SetEdges(36, 0.0, 90.);
-    bins.Apply(histalphafinal);
-
-   TH1F histAssym;
-   histAssym.SetName("Assymetry");
-   histAssym.SetTitle("Assymetry");
-   histAssym.SetXTitle("Assymetry");
-   histAssym.SetYTitle("Counts");
-   histAssym.SetDirectory(NULL);
-   histAssym.SetFillStyle(4000);
-   histAssym.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -1, 1.);
-    bins.Apply(histAssym);
-
-   TH1F histAssymM3;
-   histAssymM3.SetName("Assymetry 3M");
-   histAssymM3.SetTitle("Assymetry 3rd moment");
-   histAssymM3.SetXTitle("Assymetry 3rd moment");
-   histAssymM3.SetYTitle("Counts");
-   histAssymM3.SetDirectory(NULL);
-   histAssymM3.SetFillStyle(4000);
-   histAssymM3.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -1., 1.);
-    bins.Apply(histAssymM3);
-
-   TH2F hist2xy("CoG","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
-   hist2xy.SetXTitle("MeanX [deg]");
-   hist2xy.SetYTitle("MeanY [deg]");
-   hist2xy.SetDirectory(NULL);
-   hist2xy.SetFillStyle(4000);
-   hist2xy.UseCurrentStyle();
- 
-   TH1F histLoverS;
-   histLoverS.SetName("LoverS");
-   histLoverS.SetTitle("LoverS");
-   histLoverS.SetXTitle("LoverS");
-   histLoverS.SetYTitle("Counts");
-   histLoverS.SetDirectory(NULL);
-   histLoverS.SetFillStyle(4000);
-   histLoverS.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -0., 0.0006);
-    bins.Apply(histLoverS);
-
-   TH2F hist2lw("Length-Width", "correlation Length-Width", 100, 0.0, 1.0, 100, 0.0, 0.5);
-   hist2lw.SetXTitle("Length [deg]");
-   hist2lw.SetYTitle("Width [deg]");
-   hist2lw.SetDirectory(NULL);
-   hist2lw.SetFillStyle(4000);
-   hist2lw.UseCurrentStyle();
- 
-   TH2F hist2lalpha("Length-Alpha", "correlation Length-Alpha", 100, 0.0, 1.0, 100, -100., 100.);
-   hist2lalpha.SetXTitle("Length [deg]");
-   hist2lalpha.SetYTitle("Alpha [deg]");
-   hist2lalpha.SetDirectory(NULL);
-   hist2lalpha.SetFillStyle(4000);
-   hist2lalpha.UseCurrentStyle();
- 
-   TH2F hist2ldist("Length-Dist","correlation Length-Dist", 100, 0.0, 1.0, 100, 0.0, 1.7);
-   hist2ldist.SetXTitle("Length [deg]");
-   hist2ldist.SetYTitle("Dist [deg]");
-   hist2ldist.SetDirectory(NULL);
-   hist2ldist.SetFillStyle(4000);
-   hist2ldist.UseCurrentStyle();
- 
-   TH2F hist2walpha("Width-Alpha","correlation Width-Alpha", 100, 0.0, 0.5, 100, -100., 100.);
-   hist2walpha.SetXTitle("Width [deg]");
-   hist2walpha.SetYTitle("Alpha [deg]");
-   hist2walpha.SetDirectory(NULL);
-   hist2walpha.SetFillStyle(4000);
-   hist2walpha.UseCurrentStyle();
- 
-   TH2F hist2wdist("Width-Dist","correlation Width-Dist", 100, 0.0, 0.5, 100, 0.0, 1.7);
-   hist2wdist.SetXTitle("Width [deg]");
-   hist2wdist.SetYTitle("Dist [deg]");
-   hist2wdist.SetDirectory(NULL);
-   hist2wdist.SetFillStyle(4000);
-   hist2wdist.UseCurrentStyle();
- 
-   TH2F hist2alphadist("Alpha-Dist","correlation Alpha-Dist", 100, -100., 100, 100, 0.0, 1.7);
-   hist2alphadist.SetXTitle("Alpha [deg]");
-   hist2alphadist.SetYTitle("Dist [deg]");
-   hist2alphadist.SetDirectory(NULL);
-   hist2alphadist.SetFillStyle(4000);
-   hist2alphadist.UseCurrentStyle();
- 
-   TH1F histphi;
-   histphi.SetName("TelPhia");
-   histphi.SetTitle("Telescope Phi");
-   histphi.SetXTitle("Phi [rad]");
-   histphi.SetYTitle("Counts");
-   histphi.SetDirectory(NULL);
-   histphi.SetFillStyle(4000);
-   histphi.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -10, 10);
-    bins.Apply(histphi);
-
-   TH1F histtheta;
-   histtheta.SetName("TelTheta");
-   histtheta.SetTitle("Telescope Theta");
-   histtheta.SetXTitle("Theta [rad]");
-   histtheta.SetYTitle("Counts");
-   histtheta.SetDirectory(NULL);
-   histtheta.SetFillStyle(4000);
-   histtheta.UseCurrentStyle(); 
-
-    bins.SetEdges(100, -2, 2.);
-    bins.Apply(histtheta);
-
-   TH1F aftercuthistlength;
-   aftercuthistlength.SetName("Length");
-   aftercuthistlength.SetTitle("Length");
-   aftercuthistlength.SetXTitle("Length [deg]");
-   aftercuthistlength.SetYTitle("Counts");
-   aftercuthistlength.SetDirectory(NULL);
-   aftercuthistlength.SetFillStyle(4000);
-   aftercuthistlength.UseCurrentStyle();
-
-
-    bins.SetEdges(100, 0., 1.);
-    bins.Apply(aftercuthistlength);
-
-   TH1F aftercuthistwidth;
-   aftercuthistwidth.SetName("Width");
-   aftercuthistwidth.SetTitle("Width");
-   aftercuthistwidth.SetXTitle("Width [deg]");
-   aftercuthistwidth.SetYTitle("Counts");
-   aftercuthistwidth.SetDirectory(NULL);
-   aftercuthistwidth.SetFillStyle(4000);
-   aftercuthistwidth.UseCurrentStyle();
-
-    bins.SetEdges(100, 0., 0.5);
-    bins.Apply(aftercuthistwidth);
-
-   TH1F aftercuthistsize;
-   aftercuthistsize.SetName("Size");
-   aftercuthistsize.SetTitle("Size");
-   aftercuthistsize.SetXTitle("Size [photons]");
-   aftercuthistsize.SetYTitle("Counts");
-   aftercuthistsize.SetDirectory(NULL);
-   aftercuthistsize.SetFillStyle(4000);
-   aftercuthistsize.UseCurrentStyle();
-
-    bins.SetEdgesLog(100, 100., 10e5);
-    bins.Apply(aftercuthistsize);
-
-   TH1F aftercuthistalpha;
-   aftercuthistalpha.SetName("Alpha");
-   aftercuthistalpha.SetTitle("Alpha");
-   aftercuthistalpha.SetXTitle("Alpha [deg]");
-   aftercuthistalpha.SetYTitle("Counts");
-   aftercuthistalpha.SetDirectory(NULL);
-   aftercuthistalpha.SetFillStyle(4000);
-   aftercuthistalpha.UseCurrentStyle();
-
-    bins.SetEdges(20, 0., 100.);
-    bins.Apply(aftercuthistalpha);
-
-   TH1F aftercuthistdist;
-   aftercuthistdist.SetName("Dist");
-   aftercuthistdist.SetTitle("Dist");
-   aftercuthistdist.SetXTitle("Dist [deg]");
-   aftercuthistdist.SetYTitle("Counts");
-   aftercuthistdist.SetDirectory(NULL);
-   aftercuthistdist.SetFillStyle(4000);
-   aftercuthistdist.UseCurrentStyle();
-
-   bins.SetEdges(100, 0., 2.);
-    bins.Apply(aftercuthistdist);
-
-   TH1F aftercuthistmeanx;
-   aftercuthistmeanx.SetName("MeanX");
-   aftercuthistmeanx.SetTitle("MeanX");
-   aftercuthistmeanx.SetXTitle("MeanX [deg]");
-   aftercuthistmeanx.SetYTitle("Counts");
-   aftercuthistmeanx.SetDirectory(NULL);
-   aftercuthistmeanx.SetFillStyle(4000);
-   aftercuthistmeanx.UseCurrentStyle();
-
-    bins.SetEdges(100, -1.8, 1.8);
-    bins.Apply(aftercuthistmeanx);
-
-   TH1F aftercuthistmeany;
-   aftercuthistmeany.SetName("MeanY");
-   aftercuthistmeany.SetTitle("MeanY");
-   aftercuthistmeany.SetXTitle("MeanY [deg]");
-   aftercuthistmeany.SetYTitle("Counts");
-   aftercuthistmeany.SetDirectory(NULL);
-   aftercuthistmeany.SetFillStyle(4000);
-   aftercuthistmeany.UseCurrentStyle();
-
-
-    bins.SetEdges(100, -1.8, 1.8);
-    bins.Apply(aftercuthistmeany);
-
-   TH2F aftercuthist2xy("CoG","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
-   aftercuthist2xy.SetXTitle("MeanX [deg]");
-   aftercuthist2xy.SetYTitle("MeanY [deg]");
-   aftercuthist2xy.SetDirectory(NULL);
-   aftercuthist2xy.SetFillStyle(4000);
-   aftercuthist2xy.UseCurrentStyle();
-
-
-
-   const Int_t n = 100;
-   Double_t binsize[n];
-
-   Float_t nmin = 100.;
-   Float_t nmax = 1e7;
-
-   for(Int_t i=0; i<n; i++)
-   {
-    binsize[i] = pow(10., log10(nmin) + i * (log10(nmax) - log10(nmin)) / (n-1.));
-   }
-
-   TH2F hist2wsize("Width-Size", "correlation Width-Size", 100, 0.0, 0.5, n-1, binsize);
-   hist2wsize.SetXTitle("Width [deg]");
-   hist2wsize.SetYTitle("Size");
-   hist2wsize.SetDirectory(NULL);
-   hist2wsize.SetFillStyle(4000);
-   hist2wsize.UseCurrentStyle();
-
-
- 
-   TH2F hist2alphasize("Alpha-Size","correlation Alpha-Size", 100, -100., 100., n-1, binsize);
-   hist2alphasize.SetXTitle("Alpha [deg]");
-   hist2alphasize.SetYTitle("Size");
-   hist2alphasize.SetDirectory(NULL);
-   hist2alphasize.SetFillStyle(4000);
-   hist2alphasize.UseCurrentStyle();
- 
-   TH2F hist2distsize("Dist-Size","correlation Dist-Size", 100, 0.0, 1.7, n-1, binsize);
-   hist2distsize.SetXTitle("Dist [deg]");
-   hist2distsize.SetYTitle("Size");
-   hist2distsize.SetDirectory(NULL);
-   hist2distsize.SetFillStyle(4000);
-   hist2distsize.UseCurrentStyle();
-// end create histograms
-
-
- 
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-
-    MReadMarsFile read("Events");
-    read.DisableAutoScheme();
-
-    read.AddFile(filename);
-
-    MHillas mhillas;
-    plist.AddToList(&mhillas);
-
-    MHillasSrc mhillassrc;
-    plist.AddToList(&mhillassrc);
-
-    MHillasExt mhillasext;
-    plist.AddToList(&mhillasext);
-
-    MNewImagePar mnewimpar;
-    plist.AddToList(&mnewimpar);
-
-    MGeomCamMagic cam;
-    plist.AddToList(&cam);
- 
-    MMcEvt mcevt;
-    plist.AddToList(&mcevt);
- 
-    MPointingPos mpoint;
-    plist.AddToList(&mpoint);
-
-    MObservatory observ;
-    plist.AddToList(&observ);
-
-//    MRawRunHeader header;
-//    plist.AddToList(&header);
-    
-    tlist.AddToList(&read);
-   
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-   if (!tlist.PreProcess(&plist))
-      return;
-
-    Float_t fMm2Deg = cam->GetConvMm2Deg();
-    Int_t event = 0;
-    Int_t filenumber = 0;
-
-    Float_t ftheta, fphi, flength, fwidth, fsize, fmeanx, fmeany, falpha, fdist;
-    Float_t fsingam, fcosgam;
-    Double_t  xsournew, ysournew;
-    Float_t fdelta, fleak, fconc1, fcosda, fassym, fassymM3;
-    Int_t AsGrNull=0, AsLessNull=0;
-    Int_t AsGrNullAfter=0, AsLessNullAfter=0;
-    Float_t logsize, lgsize, lgsize2, tanbeta, beta;
-    const Float_t LOG3000 = log(3000.);
-    Char_t stringtriv1[80], stringlima[80], stringNex[80], stringsig[80];
-    Char_t stringNexOnOff[80], stringLiMaOnOff[80];
-
-// initial values:
-     Float_t  xsource = XSOURCE;
-     Float_t  ysource = YSOURCE;
-
-
-    while (tlist.Process())
-    {
-    event++;
-
-    if (mhillas->GetLength() != -1.)
-     {
-      // parameters:
-      flength = (mhillas->GetLength()) * fMm2Deg;
-      fwidth = (mhillas->GetWidth())*fMm2Deg;
-      fsize = mhillas->GetSize();
-      fmeanx = (mhillas->GetMeanX())*fMm2Deg;
-      fmeany = (mhillas->GetMeanY())*fMm2Deg;
-      falpha = mhillassrc->GetAlpha(); 
-      fdist = (mhillassrc->GetDist())*fMm2Deg;
-      fdelta = mhillas->GetDelta();
-      fconc1 = (mnewimpar->GetConc1());
-      fleak = mnewimpar->GetLeakage1();
-
-
-//      ftheta = mcevt->GetTelescopeTheta();
-      ftheta = mpoint->GetZd();
-//      fphi = mcevt->GetTelescopePhi();
-      fphi = mpoint->GetAz();
-// cout << " phi : " << fphi << " theta : " << ftheta << endl;
-      observ.RotationAngle(ftheta, fphi, fsingam, fcosgam);
-
-      fassym = (mhillasext->GetAsym()) * fMm2Deg;
-      fassymM3 = (mhillasext->GetM3Long()) * fMm2Deg;
-      fcosda = mhillassrc->GetCosDeltaAlpha();
-
-      if ((fassymM3*TMath::Sign(1.,fcosda)) > 0.) AsGrNull++;
-      else AsLessNull++;
-
-      if (ROTOPTION == kTRUE) // derotate into sky coordinates
-      {
-      /*     derotation    : correct sky coordinates into camera coordinates */
-             xsournew = fcosgam * xsource - fsingam * ysource;
-             ysournew = fsingam * xsource + fcosgam * ysource;
-       /*    end derotatiom    */
-      }
-      else // do not derotate, plot into camera coordinates
-      {
-             xsournew = xsource;
-             ysournew = ysource;
-      }
-
-      // basic plots:
-
-//    if (fsize > 3000.)
-    if (fsize > 0.)
-     {
-      histphi.Fill(fphi,1.);
-      histtheta.Fill(ftheta,1.);
-
-      histlength.Fill(flength,1.);
-      histwidth.Fill(fwidth,1.);
-      histsize.Fill(fsize,1.);
-      histLoverS.Fill(flength/fsize,1.);
-      histmeanx.Fill(fmeanx,1.);
-      histmeany.Fill(fmeany,1.);
-      histalpha.Fill(falpha,1.);
-      histdist.Fill(fdist,1.);
-      hist2xy.Fill(fmeanx, fmeany, 1.);
-     }
-
-// some cuts:
-     if (flength > 0.1 && flength < 0.32)
-        if (fwidth > 0.06 && fwidth < 0.15)
-          if (fdist > 0.6 && fdist < 1.3)
-            if (fsize > 3000.)
-//              if(sqrt(fmeanx*fmeanx + fmeany*fmeany) < 1.1)  
-//              if((fassymM3*fcosda < 0.3 && fassymM3*fcosda > 0.02) || 
-//                 (fassymM3*fcosda < -0.02 && fassymM3*fcosda > -0.2) )
-//                  if(fassym*fcosda > 0.) 
-                      {
-                       histAssymM3.Fill(fassymM3*TMath::Sign(1.,fcosda), 1.);
-                       histAssym.Fill(fassym*TMath::Sign(1.,fcosda), 1.);
-                       if ((fassymM3*TMath::Sign(1.,fcosda)) > 0.) AsGrNullAfter++;
-                       else AsLessNullAfter++;
-                      }
-
-// **********************************************************************  //
-// calculate alpha and dist according to the source location:
-           tanbeta = (fmeany - ysournew) / (fmeanx - xsournew);
-           beta = TMath::ATan(tanbeta);
-           falpha = (fdelta - beta) * 180./ TMath::Pi();
-           fdist = sqrt((fmeany - ysournew) * (fmeany - ysournew) +
-                             (fmeanx - xsournew) * (fmeanx - xsournew));
-
-          if(falpha > 90.) falpha -= 180.;
-          if(falpha < -90.) falpha += 180.;
-
-// **********************************************************************  //
-
-
-
-      if (fsize > 3000.)
-      {
-      // correlations:
-      hist2lw.Fill(flength, fwidth, 1.);
-      hist2lalpha.Fill(flength, falpha, 1.);
-      hist2ldist.Fill(flength, fdist, 1.);
-      hist2walpha.Fill(fwidth, falpha, 1.);
-      hist2wdist.Fill(fwidth, fdist, 1.);
-      hist2alphadist.Fill(falpha, fdist, 1.);
-      hist2wsize.Fill(fwidth, fsize, 1.);
-      hist2alphasize.Fill(falpha, fsize, 1.);
-      hist2distsize.Fill(fdist, fsize, 1.);
-      }     
-
-     // cuts:
-//cout << " before the cuts"  << "size :" << fsize << endl;
-                 logsize = log(fsize);
-                 lgsize = logsize-LOG3000;
-                 lgsize2 = lgsize*lgsize;
-                 if ( fsize > SIZEMIN )
-                 if ( fleak < LEAKMAX )
-                 if ( flength > (LENGTHMINParA + LENGTHMINParB*lgsize + LENGTHMINParC*lgsize2) &&
-                      flength < (LENGTHMAXParA + LENGTHMAXParB*lgsize + LENGTHMAXParC*lgsize2))
-                 if ( fwidth > (WIDTHMINParA + WIDTHMINParB*lgsize + WIDTHMINParC*lgsize2)  &&
-                      fwidth < (WIDTHMAXParA + WIDTHMAXParB*lgsize + WIDTHMAXParC*lgsize2) )
-                 if ( fdist > (DISTMINParA + DISTMINParB*lgsize + DISTMINParC*lgsize2)  &&
-                      fdist < (DISTMAXParA + DISTMAXParB*lgsize + DISTMAXParC*lgsize2) )
-//                 if ((fassym*TMath::Sign(1.,fcosda)) > ASYMMIN)   // asymmcut
-                 {
-                         falpha = TMath::Abs(falpha);
-                         histalphafinal.Fill(falpha,1.);
-                         histalphaAll.Fill(falpha,1.);
-
-                         aftercuthistlength.Fill(flength,1.);
-                         aftercuthistwidth.Fill(fwidth,1.);
-                         aftercuthistsize.Fill(fsize,1.);
-                         aftercuthistmeanx.Fill(fmeanx,1.);
-                         aftercuthistmeany.Fill(fmeany,1.);
-                         aftercuthistalpha.Fill(falpha,1.);
-                         aftercuthistdist.Fill(fdist,1.);
-                         aftercuthist2xy.Fill(fmeanx, fmeany, 1.);
-
-                 }
-
-
-     }
-    else filenumber++;
-    }
-
-//    cout << " conversion factor is: " << fMm2Deg <<  endl;
-    cout << " events read in from file : " << event <<  endl;
-    cout << " runs found in the file : " << filenumber <<  endl;
-
-    Int_t startbinoff;
-    Float_t Nex, Non, Noff, Sign, SignLiMa;
-    Float_t normf, integon, integoff, NexOnOff, NoffOFF, SignOnOff, SignLiMaOnOff;
-    Float_t binwidth = histalphafinal.GetBinWidth(1);
-    Float_t numbinMax = ALPHAMAX/binwidth;
- 
-// **********************************************************************  //
-/* fit parabel from 30 to 90 degrees   */
-    TF1 * fitbgpar = new TF1("fbgpar", "[0]*x*x + [1]", ALOFFMIN, ALOFFMAX);
-    fitbgpar->SetLineColor(2);
-
-    histalphafinal.Fit("fbgpar","WNR");
-
-    Double_t apar = fitbgpar->GetParameter(0);
-    Double_t bpar = fitbgpar->GetParameter(1);
-
-    TF1 * bgoff = new TF1("bgoffON", parabfunc, 0., 90., 3);
-    bgoff->SetParameters(apar, bpar, 1.);
-    bgoff->FixParameter(0, apar);
-    bgoff->FixParameter(1, bpar);
-    bgoff->FixParameter(2, 1.);
-    bgoff->SetLineColor(9);
-
-/* end of the fit parabel from 30 to 90 degrees*/
-// **********************************************************************  //
-
-
-
-    if (!tlist.PostProcess())
-      return;
-
-    
-    gStyle->SetOptStat(11);
-
-// calculate significance: DO NOT USE FIT FOR Non!!!
-    Non = 0.;
-    for(Int_t i=1; i<=numbinMax;i++) Non += histalphafinal.GetBinContent(i);
-
-    Noff = (1./3. * (fitbgpar->GetParameter(0)) * pow(ALPHAMAX,3.) +
-           (fitbgpar->GetParameter(1)) * ALPHAMAX) /  binwidth;
-    Nex = Non - Noff;
-
-    Sign = Nex / sqrt(Nex + 2.* Noff);
- 
-    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
-    cout << " significance : " << Sign << " sigma" << endl;
-
-    SignLiMa = LiMa17(Non,Noff,1.);
-    cout << " significance Li and Ma (17): " << SignLiMa << " sigma" << endl;
-
-    Char_t stringsig[80];
- 
-    sprintf(stringsig,"S = %.2f sigma", Sign);
-    sprintf(stringtriv1,"Signif:  S = %.2f sigma", Sign);
-    sprintf(stringlima,"Li&Ma 17: S = %.2f sigma", SignLiMa);
-    sprintf(stringNex,"N excess: Nex = %.d ", Nex);
-
-// **********************************************************************  //
-//  use OFF data to estimate background   *******************************  //
-    TF1 * bgoff2 = new TF1("bgoffOFF", parabfunc, 0., 90., 3);
-  if (USEOFFDATA == kTRUE)
-  {
-        // ON:
-
-           integon = 0.;  // number of events between 30 and 90 degrees
-	   numbinsoff = TMath::Nint((ALOFFMAX - ALOFFMIN)/binwidth);
-           startbinoff = TMath::Nint(ALOFFMIN/binwidth) + 1;
-
-           for (Int_t ik = 0; ik < numbinsoff; ik++)
-           {
-            integon += histalphafinal.GetBinContent(startbinoff+ik);  
-           }
-           // OFF:
-
-           integoff = ((1./3. * aparOff * pow(90.,3.) + bparOff * 90.) -
-                      (1./3. * aparOff * pow(30.,3.) + bparOff * 30.)) / binwidthOff;
-
-           normf = integoff / integon;
-
-           NoffOFF = (1./3. * aparOff * pow(ALPHAMAX,3.) +
-                   (bparOff * ALPHAMAX)) /  binwidthOff / normf;
-
-           NexOnOff = Non - NoffOFF;
-
-           SignOnOff = NexOnOff / sqrt(NexOnOff + 2.* NoffOFF);
-
-        // calculate according to Li Ma:
-           SignLiMaOnOff = LiMa17(Non,NoffOFF*normf,1./normf);
-
-cout << " integon: " << integon << ",  integoff : " <<  integoff << ", normf: " << normf
-     << ", NoffOFF : " << NoffOFF << ", Non : " << Non
-     << ", NexOnOff : " << NexOnOff << ", SignOnOff : " << SignOnOff << endl;
- cout << " significance (LiMa 17): " << SignLiMaOnOff << " sigma" << endl;
-
- sprintf(stringNexOnOff,"N excess (ON - OFF) = %.d ", NexOnOff);
- sprintf(stringLiMaOnOff,"Signif (ON - OFF) = %.2f ", SignLiMaOnOff);
-
-
-            bgoff2->SetParameters(aparOff, bparOff, normf/binwidth*binwidthOff);
-            bgoff2->FixParameter(0, aparOff);
-            bgoff2->FixParameter(1, bparOff);
-            bgoff2->FixParameter(2, normf/binwidth*binwidthOff);
-            bgoff2->SetLineColor(2);
-
-   }
-
-/*
-      TCanvas canv("c1", "basic histograms", 600, 500);
-      canv.SetBorderMode(0);
-      canv.Divide(3,3);
-
-     canv.cd(1);
-     gPad->SetBorderMode(0);
-     histlength.Draw();
-
-     canv.cd(2);
-     gPad->SetBorderMode(0);
-     histwidth.Draw();
-  
-     canv.cd(3);
-     gPad->SetBorderMode(0);
-     gPad->SetLogx();
-     gPad->SetLogy();
-     histsize.Draw();
-
-     canv.cd(4);
-     gPad->SetBorderMode(0);
-     histalpha.Draw();
-
-     canv.cd(5);
-     gPad->SetBorderMode(0);
-     histdist.Draw();
-
-     canv.cd(6);
-     gPad->SetBorderMode(0);
-     histmeanx.Draw();
-
-     canv.cd(7);
-     gPad->SetBorderMode(0);
-     histmeany.Draw();
-
-     canv.cd(8);
-     gPad->SetBorderMode(0);
-     hist2xy.Draw();
-
-     canv.cd(9);
-     gPad->SetBorderMode(0);
-     histLoverS.Draw();
-
-     canv.Modified();
-     canv.Update();
-
-     canv.DrawClone();
-
-
-
-
-      TCanvas canvcor("c2", "correlation histograms", 600, 500);
-      canvcor.SetBorderMode(0);
-      canvcor.Divide(3,3);
-
-     canvcor.cd(1);
-     gPad->SetBorderMode(0);
-     hist2lw.Draw();
-
-     canvcor.cd(2);
-     gPad->SetBorderMode(0);
-     hist2lalpha.Draw();
-
-     canvcor.cd(3);
-     gPad->SetBorderMode(0);
-     hist2ldist.Draw();
-
-     canvcor.cd(4);
-     gPad->SetBorderMode(0);
-     hist2walpha.Draw();
-
-     canvcor.cd(5);
-     gPad->SetBorderMode(0);
-     hist2wdist.Draw();
-
-     canvcor.cd(6);
-     gPad->SetBorderMode(0);
-     hist2alphadist.Draw();
-
-     canvcor.cd(7);
-     gPad->SetBorderMode(0);
-     gPad->SetLogy();
-     hist2wsize.Draw();
-
-
-     canvcor.cd(8);
-     gPad->SetBorderMode(0);
-     gPad->SetLogy();
-     hist2alphasize.Draw();
-
-     canvcor.cd(9);
-     gPad->SetBorderMode(0);
-     gPad->SetLogy();
-     hist2distsize.Draw();
-
-
-     canvcor.Modified();
-     canvcor.Update();
-
-     canvcor.DrawClone();
-*/
-
-/**********************************************************/
-/* plot the alpha plot for the current sample */
-
-    Char_t titelname[80];
-    sprintf(titelname,"alpha plot. sample %d assumed source position: x = %.2f y = %.2f", num, XSOURCE, YSOURCE);
-
-
-      TCanvas canval("c3", "canvas for alpha", 600, 500);
-      canval.SetBorderMode(0);
-
-     gPad->SetBorderMode(0);
-     histalphafinal.SetMarkerStyle(20);
-     histalphafinal.SetTitle(titelname);
-     histalphafinal.SetFillColor(8);
-     histalphafinal.Draw();
-     bgoff->Draw("same");
-     if (USEOFFDATA == kTRUE) bgoff2->Draw("same");
-
-    leg = new TLegend(0.1,0.15,0.52,0.35);
-//    leg->Draw();
-    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
-    leg->SetHeader("Legend");
-    leg->SetFillColor(19);
-//    leg->Draw();
-
-    if (USEOFFDATA == kFALSE) 
-    {
-	    text = new TPaveText(0.53,0.45,0.9,0.65,"NDC");
-	    text->AddText(0.4, 0.6, stringNex);
-	    text->AddText(0.5, 0.3, stringlima);
-	    text->SetTextSize(0.032);
-	    text->Draw();
-    }
-    else
-    {
-            text = new TPaveText(0.53,0.25,0.9,0.55,"NDC");
-	    text->AddText(0.4, 0.8, stringNex);
-	    text->AddText(0.45, 0.6, stringlima);
-            text->AddText(0.5, 0.4, stringNexOnOff);
-            text->AddText(0.4, 0.2, stringLiMaOnOff);
-            text->SetTextSize(0.032);
-            text->Draw();
-    }
-     canval.Modified();
-     canval.Update();
-
-//     canval.DrawClone();
-
-     TString strin = dirname + sourcename;
-//     TString strin = "data/plots/alpha/dummySize";
-     strin += SIZEMIN;
-     strin += "Sample";
-     if (num<10) strin +="0";
-     strin += num;
-     strin += ".root";
-
-
-     canval.SaveAs(strin);  // please enable if you want to save alphaplots
-cout << " alpha plot for the sample " << num << " has been saved into " << strin << endl;
-
-     if(bgoff2) delete bgoff2;
-     delete bgoff;
-
-/**********************************************************/
-
-/*
-      TCanvas canvt("c4", "telescope", 600, 500);
-      canvt.SetBorderMode(0);
-      canvt.Divide(2,1);
-
-     canvt.cd(1);
-     gPad->SetBorderMode(0);
-     histphi.Draw();
-
-     canvt.cd(2);
-     gPad->SetBorderMode(0);
-     histtheta.Draw();
-
-     canvt.DrawClone();
-
-      TCanvas canvass("c5", "assymetry", 600, 500);
-      canvass.SetBorderMode(0);
-      canvass.Divide(2,1);
-
-     canvass.cd(1);
-     gPad->SetGridx();
-     gPad->SetGridy();
-     gPad->SetBorderMode(0);
-     histAssym.Draw();
-
-     canvass.cd(2);
-     gPad->SetGridx();
-     gPad->SetGridy();
-     gPad->SetBorderMode(0);
-     histAssymM3.Draw();
-
-     canvass.DrawClone();
-
-    TCanvas aftercutcanv("c1a", "basic histograms", 600, 500);
-    aftercutcanv.SetBorderMode(0);
-    aftercutcanv.Divide(3,3);
-
-    aftercutcanv.cd(1);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistlength.Draw();
-
-    aftercutcanv.cd(2);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistwidth.Draw();
-
-    aftercutcanv.cd(3);
-    gPad->SetBorderMode(0);
-    gPad->SetLogx();
-    gPad->SetLogy();
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistsize.Draw();
-
-    aftercutcanv.cd(4);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistalpha.Draw();
-
-    aftercutcanv.cd(5);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistdist.Draw();
-
-    aftercutcanv.cd(6);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistmeanx.Draw();
-
-    aftercutcanv.cd(7);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthistmeany.Draw();
-
-
-    aftercutcanv.cd(8);
-    gPad->SetBorderMode(0);
-    gPad->SetGridx();
-    gPad->SetGridy();
-    aftercuthist2xy.Draw();
-
-    aftercutcanv.Modified();
-    aftercutcanv.Update();
-
-    aftercutcanv.DrawClone();
-*/
-    Double_t rat1, rat2;
-    rat1 = (double)AsGrNull / (double)AsLessNull;
-    rat2 = (double)AsGrNullAfter / (double)AsLessNullAfter;
-
-    cout << " Asymmetry M3 > 0 : " <<  AsGrNull << endl;
-    cout << " Asymmetry M3 < 0 : " <<  AsLessNull << endl;
-    cout << " Ratio (before cuts) : " <<  rat1 << endl;
-    cout << " Asymmetry M3 > 0 (after): " <<  AsGrNullAfter << endl;
-    cout << " Asymmetry M3 < 0 (after): " <<  AsLessNullAfter << endl;
-    cout << " Ratio (after cuts) : " <<  rat2 << endl;
-
-
-}
-
-void callalphaplot()
-{
-
-
-   Int_t num;
-   Double_t xpeakM, ypeakM, xpeakB, ypeakB;
-
-   FILE *fp;
-//   fp = fopen("data/trackMrk421_0505_2000.dat", "r");
-   if (USEFILE == kTRUE) 
-   {
-	fp = fopen("data/trackCrab1502_1305_Berlin_5deg.dat", "r");
-
-        for(Int_t i = 0; i < 2; i++)
-        {
-       		fscanf(fp,"%d %lf %lf %lf %lf", &num, &xpeakM, &ypeakM, &xpeakB, &ypeakB); 
-       		cout << endl << " SUBS NUMBER " << num << ", xpeakM = " << xpeakM << 
-                     ", ypeakM = " << ypeakM << endl;
-       		cout << "                   xpeakB = " << xpeakB << ", ypeakB = " << ypeakB << endl;
-       		if (num > 0 ) alphaplots(num, xpeakM, ypeakM);  
-   	}
-
-   	fclose(fp); 
-cout << "FERTIG" << endl;
-   }
-   else  
-     alphaplots(NUM, XSOUR, YSOUR);
-
-
-/**********************************************************/
-/* now calculate Nex and S for the overall alpha plot */:
-
-
-
-    TF1 * fitbgparAll = new TF1("fbgparA", "[0]*x*x + [1]", 30., 90.);
-    fitbgparAll->SetLineColor(2);
-    fitbgparAll->SetLineWidth(3);
-
-    histalphaAll.Fit("fbgparA","WR");
-
-    Double_t apar = fitbgparAll->GetParameter(0);
-    Double_t bpar = fitbgparAll->GetParameter(1);
-    Double_t normf = 1.;
-
-    TF1 * bgoff = new TF1("bgoff", parabfunc, 0., 90., 3);
-    bgoff->SetParameters(apar, bpar, normf);
-    bgoff->FixParameter(0, apar);
-    bgoff->FixParameter(1, bpar);
-    bgoff->FixParameter(2, normf);
-    bgoff->SetLineColor(8);
-
-// calc significance:
-    Double_t Sign, Non, Noff, Nex;
-    Double_t binwidth = histalphaAll.GetBinWidth(1);
-    Double_t numbinMax = ALPHAMAX / binwidth;
-
-    Non = 0.;
-    for(Int_t i=1; i<=numbinMax;i++) Non += histalphaAll.GetBinContent(i);
-
-//cout << histalphaAll.GetBinContent(1) + histalphaAll.GetBinContent(2) + 
-//        histalphaAll.GetBinContent(3) + histalphaAll.GetBinContent(4) << endl;
-    Noff = (1./3. * apar * pow(ALPHAMAX,3.) + bpar * ALPHAMAX)  /  binwidth;
-    Nex = Non - Noff;
-
-    Sign = LiMa17(Non,Noff,1.);
-
-    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
-    cout << " significance : " << Sign << " sigma" << endl;
-
-
-    Char_t stringsig[80], stringNex[80];
-
-    sprintf(stringsig,"Signif:  S = %.2f sigma", Sign);
-    sprintf(stringNex,"N excess: Nex = %.d ", Nex);
-/**********************************************************/
-
-
-//  plot all alpha plots together
-
-    TCanvas canvA("cA", "alphacanvas", 600, 500);
-    canvA.SetBorderMode(0);
-
-    gPad->SetBorderMode(0);
-    histalphaAll.SetXTitle("alpha [deg]");
-    histalphaAll.SetYTitle("Counts");
-    histalphaAll.SetMarkerStyle(20);
-    histalphaAll.SetFillColor(17);
-    histalphaAll.Draw();
-    bgoff->Draw("same");
-
-//    leg = new TLegend(0.1,0.15,0.52,0.35);
-//    leg->Draw();
-//    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
-//    leg->SetHeader("Legend");
-//    leg->SetFillColor(19);
-//    leg->Draw();
-
-     text = new TPaveText(0.53,0.45,0.9,0.65,"NDC");
-     text->AddText(0.4, 0.6, stringNex);
-     text->AddText(0.45, 0.3, stringsig);
-     text->SetTextSize(0.032);
-     text->Draw();
-
-     canvA.Modified();
-     canvA.Update();
-
-
-     Char_t xstr[20], ystr[20];
-     if (USEFILE == kTRUE) 
-     {
-	sprintf(xstr,"%3.2f",0.);
-	sprintf(ystr,"%3.2f",0.);
-     }
-     else
-     {
-	sprintf(xstr,"%3.2f",XSOUR);
-	sprintf(ystr,"%3.2f",YSOUR);
-     }
-
-
-     TString string = dirname + sourcename;
-     string += "X";
-     string += xstr;
-     string += "Y";
-     string += ystr;
-     string += "Size";
-     string += SIZEMIN;
-     string += "alpha";
-     string += TMath::Nint(ALPHAMAX);
-     string += ".root";
-
-     canvA.SaveAs(string);
-cout << " alpha plot has been saved into " << string << endl;
-
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/callcleaning.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/callcleaning.C	(revision 7136)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
-// **********************************************************************************
-// this macro is used to make an image cleaning and calculate the Hillas parameters
-// input:  calibrated data (one or more files using wild card)
-// output: hillas parameter
-// **********************************************************************************
-
-#include "cleaninghillas.C"
-void callcleaning()
-{
-  gROOT->Reset();
-
-  TString typeInput ="ON";  // -> please specify "ON" or "OFF"
-
-  const char *onfile="1*.ON";
-  const char *offfile="1*.OFF";
-
-
-  TString sourcename = "Crab";
-  TString inPath;  // directory where to find calibrated files
-  TString outPath; // directory where to write root-file with hillas parameters
-
-
-  inPath = "/.magic/magicserv01/scratch/David/CalibratedData/Crab/2004_01_27/";
-
-  outPath = "~mazin/data/Crab/2004_01_27/";
-
-  cleaninghillas(onfile, offfile, typeInput, inPath, outPath, sourcename);
-
-  cout << " finished, back from callcleaning " << endl;
-  cout << " Hillas file " << outPath << sourcename << "Hillas" << typeInput << ".root is created " << endl;
-
-}
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/cleaninghillas.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/cleaninghillas.C	(revision 7136)
+++ 	(revision )
@@ -1,232 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
-//**********************************************************
-// this macro is a short form of the macro ONOFFAnalysis.C
-// three jobs are executed:
-// 1)  image cleaning
-// 2)  calculation of hillas parameters
-// 3)  writing the root file
-//**********************************************************
-
-gROOT->Reset();
-
-//************************************************************************
-void cleaninghillas(const char *onfile, 
-                    const char *offfile, 
-                    TString typeInput, 
-                    TString inPath, 
-                    TString outPath,
-                    TString sourcename) 
-{
-
-    TString fileON  = inPath;
-    fileON += onfile;
-    fileON += ".root";
-
-    TString fileOFF = inPath;
-    fileOFF += offfile;
-    fileOFF += ".root";
-
-    // name of input root file
-    if (typeInput == "ON")
-      TString filenamein(fileON);
-    else if (typeInput == "OFF")
-      TString filenamein(fileOFF);
-
-    // name of output root file
-    if (typeInput == "ON")
-      TString file(onfile);
-    else if (typeInput == "OFF")
-      TString file(offfile);
-
-    TString outNameImage = outPath;
-    outNameImage += sourcename;
-    outNameImage += "Hillas";
-    outNameImage += typeInput;
-    outNameImage += ".root";
-
-
-    //  set up the task list:
-    //-----------------------------------------------------------
-    MTaskList tliston;
-    MParList pliston;
-
-    MObservatory observ;
-    pliston.AddToList(&observ);
-
-    MPointingPos mpos;
-    pliston.AddToList(&mpos);
-
-    MMcEvt mmc;
-    pliston.AddToList(&mmc);
-
-    char *sourceName = "MSrcPosCam";
-    MSrcPosCam source(sourceName);
-
-    // geometry is needed in  MHHillas... classes 
-    MGeomCam *fGeom = 
-             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
-
-    //-------------------------------------------
-    // create the tasks which should be executed 
-    //
-
-    MReadMarsFile read("Events", filenamein);
-    read.DisableAutoScheme();
-
-    MGeomApply        apply;
-
- // NOTE: MMcEvt is used temporary. MPointingPos should be used as soon as synchronisation is working
- //
- // the following task is used to fill in a MMcEvt container with Theta and Phi values 
- // for each event using an ascii file (which is generated from central control report file) 
- // PLEASE NOTE: only needed if a derotation around the center of the camera is planned 
- // to be performed afterwords
-    MSourcePosfromStarPos sourcefromstar;
-
-    if (typeInput == "ON")
-    {
-	    sourcefromstar.AddFile("~mazin/mars/MarsCVS/Mars/positionsON", 0);
-    }
-    else if (typeInput == "OFF")
-    {
-        sourcefromstar.AddFile("~mazin/mars/MarsCVS/Mars/positionsOFF", 0);
-    }
-
-
-
-// -----------------------------------------------------
-// image cleaning  -------------------------------------
-// -----------------------------------------------------    
-    MSigmabarCalc sigbar;
-
-    MBlindPixelsCalc2 blind;
-    blind.SetUseInterpolation();
-    blind.SetCheckPedestalRms();
-    blind.SetName("BlindAfterPadding");
-
-    MFSelBasic selbasic;
-    MContinue contbasic(&selbasic);
-    contbasic.SetName("SelBasic");
-
-//    MImgCleanStd    clean(3.0, 2.5);  // Crab 27th old calibr (Hendrik)
-    MImgCleanStd    clean(4.0, 3.0);
-//    clean.SetMethod(MImgCleanStd::kDemocratic);
-    clean.SetCleanRings(1); 
-
-
-// -----------------------------------------------------
-// calculation of  image parameters ---------------------
-// -----------------------------------------------------    
-    TString fHilName    = "MHillas";
-    TString fHilNameExt = "MHillasExt";
-    TString fHilNameSrc = "MHillasSrc";
-    TString fImgParName = "MNewImagePar";
-
-    MHillasCalc    hcalc;
-    hcalc.SetNameHillas(fHilName);
-    hcalc.SetNameHillasExt(fHilNameExt);
-    hcalc.SetNameNewImgPar(fImgParName);
-
-    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
-    hsrccalc.SetInput(fHilName);
-
-    MFSelStandard selstandard(fHilNameSrc);
-    selstandard.SetHillasName(fHilName);
-    selstandard.SetImgParName(fImgParName);
-//    selstandard.SetCuts(usedpixelsmax, corepixelsmin, sizemin, distmin, distmax, lengthmin, widthmin);
-    selstandard.SetCuts(200, 5, 200, 0.0, 5.0, 0.07, 0.05);
-    MContinue contstandard(&selstandard);
-    contstandard.SetName("SelStandard");
-
-// -----------------------------------------------------
-// write root file
-// -----------------------------------------------------    
-      MWriteRootFile write(outNameImage);
-
-      write.AddContainer("MRawRunHeader", "RunHeaders");
-      //write.AddContainer("MTime",         "Events");
-      write.AddContainer("MPointingPos",   "Events");
-      //write.AddContainer("ThetaOrig",     "Events");
-      write.AddContainer("MSrcPosCam",    "Events");
-      write.AddContainer("MSigmabar",     "Events");
-      write.AddContainer("MHillas",       "Events");
-      write.AddContainer("MHillasExt",    "Events");
-      write.AddContainer("MHillasSrc",    "Events");
-      write.AddContainer("MNewImagePar",  "Events");
-    
-
-    //*****************************
-    // entries in MParList
-    
-    pliston.AddToList(&tliston);
-    pliston.AddToList(&observ);
-
-    pliston.AddToList(&source);
-
-    //*****************************
-    // entries in MTaskList
-    
-
-    tliston.AddToList(&read);
-    tliston.AddToList(&apply);
-    tliston.AddToList(&sourcefromstar);
-
-
-    tliston.AddToList(&sigbar);
-    tliston.AddToList(&blind);
-    tliston.AddToList(&contbasic);
-
-    tliston.AddToList(&clean);
-
-    tliston.AddToList(&hcalc);
-    tliston.AddToList(&hsrccalc);
-    tliston.AddToList(&contstandard);
-    tliston.AddToList(&write);
-
-    //*****************************
-
-    //-------------------------------------------
-    // Execute event loop
-    //
-    MProgressBar bar;
-    MEvtLoop evtloop;
-    evtloop.SetParList(&pliston);
-    //evtloop.ReadEnv(env, "", printEnv);
-    evtloop.SetProgressBar(&bar);
-    //  evtloop.Write();
-
-    Int_t maxevents = -1;
-    //Int_t maxevents = 1000;
-    if ( !evtloop.Eventloop(maxevents) )
-        return;
-
-    tliston.PrintStatistics(0, kTRUE);
-
-
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/falsesourcemethod.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/falsesourcemethod.C	(revision 7136)
+++ 	(revision )
@@ -1,171 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-
-// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
-// **********************************************************************************
-// this macro is used to produce false source plots 
-// either using one sample only (usually used for OFF, set TYPEOPTION = kFALSE)
-// or in addition using the background estimation from OFF (set TYPEOPTION = kTRUE).
-// The later option can be used ONLY if false source method for the OFF data 
-// has taken place before.
-// input: hillas parameter file
-// output: several 2D plots in a root file + 
-// ascii file with parameters like significance, Nexcess etc.
-// **********************************************************************************
-
-
-// you may want to change these values:
-#define STEPGRID 0.05 //  [deg]
-#define MINXGRID -1.  //  [deg]
-#define MINYGRID -1.  //  [deg]
-#define MAXXGRID 1.   //  [deg]
-#define MAXYGRID 1.   //  [deg]
-
-#define ALPHAMAX 10.  // [deg], ON region in the alpha plot, maybe 5 deg is better
-                      // NOTE: up to now only values of 5, 10, 15, 20 degrees are possible
-
-// if you wish to rotate set to kTRUE, else kFALSE
-const Bool_t ROTOPTION = kFALSE; 
-const Bool_t TYPEOPTION = kFALSE; // kFALSE = estimate background from the same sample
-                                  // kTRUE  = estimate background also from OFF data
-const Bool_t CUTOPTION = kTRUE;  // kTRUE = dynamical cuts
-                                 // kFALSE = statical cuts
-
-/* ******************************************************   */
-      /*  static    cuts   */
-#define LENGTHMIN 0.10  // deg
-#define LENGTHMAX 0.32  // deg
-#define WIDTHMIN  0.06  // deg
-#define WIDTHMAX  0.15  // deg
-#define SIZEMIN   2000. // photons
-#define DISTMIN   0.6   // deg
-#define DISTMAX   1.3   // deg
-#define LEAKMAX   0.25  // deg
-/* ******************************************************   */
-
-/* ******************************************************   */
-      /*  dynamical cuts  Crab 27th Jan 2004 */
-#define LENGTHMINParA 0.136  // deg
-#define LENGTHMINParB 0.036  //
-#define LENGTHMINParC -0.0038  //
-#define LENGTHMAXParA 0.332  // deg
-#define LENGTHMAXParB 0.037  //
-#define LENGTHMAXParC 0.0261 //
-#define WIDTHMINParA  0.063  // deg
-#define WIDTHMINParB  0.013  //
-#define WIDTHMINParC  0.0003  //
-#define WIDTHMAXParA  0.123  // deg
-#define WIDTHMAXParB  0.019  //
-#define WIDTHMAXParC  0.0005 //
-#define DISTMINParA   0.6   // deg
-#define DISTMINParB   0.059  //
-#define DISTMINParC   0.  //
-#define DISTMAXParA   1.25   // deg
-#define DISTMAXParB   0.059  //
-#define DISTMAXParC   0.  //
-/* ******************************************************   */
-
-      /*  dynamical cuts  Mrk 421 and Crab 15th Feb 2004 */
-
-/*
-#define LENGTHMINParA 0.12  // deg
-#define LENGTHMINParB 0.034  //
-#define LENGTHMINParC 0.  //
-#define LENGTHMAXParA 0.32  // deg
-#define LENGTHMAXParB 0.034  //
-#define LENGTHMAXParC 0. //
-#define WIDTHMINParA  0.055  // deg
-#define WIDTHMINParB  0.013  //
-#define WIDTHMINParC  0.0  //
-#define WIDTHMAXParA  0.12  // deg
-#define WIDTHMAXParB  0.013  //
-#define WIDTHMAXParC  0.0 //
-#define DISTMINParA   0.6   // deg
-#define DISTMINParB   0.059  //
-#define DISTMINParC   0.  //
-#define DISTMAXParA   1.25   // deg
-#define DISTMAXParB   0.059  //
-#define DISTMAXParC   0.  //
-*/
-/* ******************************************************   */
-
-// please do not change these values:
-#define NUMSTEPS (int) ((MAXXGRID - MINXGRID) / STEPGRID + 1.5)
-#define GRIDBINS (int) (NUMSTEPS * NUMSTEPS  + 0.5)
-
-
-#include "mtools.C"
-#include <skyplot.h>  // needed histograms
-
-// this helps me to check if the binning is ok
-#define TOLERANCE 1e-3
-
-#include "hillasfileread.C"
-#include "gridloop.C"
-
-void falsesourcemethod()
-{
-
-  if (TYPEOPTION == kTRUE)  // output of OFF data sample
-//      DATPARAMIN = "data/ressignOffMrk3004.dat";  // 3000
-      DATPARAMIN = "paramOffCrab2701.dat";   // 2000
-
-
-   HILLASFILENAME = "~/data/Crab/2004_01_27/CrabHillasOFF.root";
-   DATPARAMOUT = "paramOffCrab2701.dat";
-   ROOTPLOTNAME = "/.magic/magicserv01/scratch/Daniel/plots/RootPlots/Crab/2004_01_27/CrabOffSkyPlots.root";
-   hillasfileread();
-   gridloop();  
-
-/*
-// use this loop for different subsamples
-  for(Int_t i=1; i<10; i++)
-  {
-   HILLASFILENAME = "~/data/Crab15022004Update/sample";
-   DATPARAMOUT = "data/ressignOnOffCrab1502Samp";
-   ROOTPLOTNAME = "/.magic/magicserv01/scratch/Daniel/plots/RootPlots/Crab15022004Update/Crab1502Sample";
-
-   HILLASFILENAME += i;
-   HILLASFILENAME += "/";
-   HILLASFILENAME += "CrabHillasON";
-   HILLASFILENAME += ".root";
-
-   DATPARAMOUT += i;
-   DATPARAMOUT += "_AlphaCut";
-   DATPARAMOUT += TMath::Nint(ALPHAMAX);
-   DATPARAMOUT += "deg";
-   DATPARAMOUT += ".dat";
-
-   ROOTPLOTNAME += i;
-   ROOTPLOTNAME += "_AlphaCut";
-   ROOTPLOTNAME += TMath::Nint(ALPHAMAX);
-   ROOTPLOTNAME += "deg";
-   ROOTPLOTNAME += ".root";
-
-
-   hillasfileread();
-   gridloop();  
-  }
-*/
-}
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/fluxMUnfold.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/fluxMUnfold.C	(revision 7136)
+++ 	(revision )
@@ -1,723 +1,0 @@
-////////////////////////////////////////////////////////////////////////////
-//                                                                        //
-// This program should be run under root:                                 //
-//      root fluxMUnfold.C++                                              //
-//                                                                        //
-// Authors: T. Bretz  02/2002 <mailto:tbretz@astro.uni-wuerzburg.de>      //
-//          W. Wittek 09/2002 <mailto:wittek@mppmu.mpg.de>                //
-//          R. Wagner 11/2004 <mailto:rwagner@mppmu.mpg.de>               //
-//                                                                        //
-// this macro is prepared to be used in the analysis:                     //
-//                                                                        //
-//      the unfolding should be called by                                 //
-//      doUnfolding(TH2D &tobeunfolded,      // (E-est, Theta)            //
-//                  TH3D &migrationmatrix,   // (E-est, E-true, Theta)    //
-//                  TH2D &unfolded)          // (E-true,Theta)            //
-//                                                                        //
-////////////////////////////////////////////////////////////////////////////
-
-#include <TMath.h>
-#include <TRandom3.h>
-#include <TVector.h>
-#include <TMatrixD.h>
-#include <TMatrix.h>
-#include <TH1.h>
-#include <TH2.h>
-#include <TH3.h>
-#include <TProfile.h>
-#include <TF1.h>
-#include <iostream.h>
-#include <TMinuit.h>
-#include <TCanvas.h>
-#include <TMarker.h>
-
-#include <fstream.h>
-#include <iomanip.h>
-
-TH1 *DrawMatrixClone(const TMatrixD &m, Option_t *opt="")
-{
-    const Int_t nrows = m.GetNrows();
-    const Int_t ncols = m.GetNcols();
-
-    TMatrix m2(nrows, ncols);
-    for (int i=0; i<nrows; i++)
-        for (int j=0; j<ncols; j++)
-            m2(i, j) = m(i, j);
-
-    TH2F *hist = new TH2F(m2);
-    hist->SetBit(kCanDelete);
-    hist->Draw(opt);
-    hist->SetDirectory(NULL);
-
-    return hist;
-
-}
-
-TH1 *DrawMatrixColClone(const TMatrixD &m, Option_t *opt="", Int_t col=0)
-{
-    const Int_t nrows = m.GetNrows();
-
-    TVector vec(nrows);
-    for (int i=0; i<nrows; i++)
-        vec(i) = m(i, col);
-
-    TH1F *hist = new TH1F("TVector","",nrows,0,nrows);
-    for (int i=0; i<nrows; i++)
-    {
-      hist->SetBinContent(i+1, vec(i));
-    }
-
-    hist->SetBit(kCanDelete);
-    hist->Draw(opt);
-    hist->SetDirectory(NULL);
-
-    return hist;
-}
-
-
-void PrintTH3Content(const TH3 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-    {
-      for (Int_t j=1; j<=hist.GetNbinsY(); j++)
-        for (Int_t k=1; k<=hist.GetNbinsZ(); k++)
-            cout << hist.GetBinContent(i,j,k) << " \t";
-      cout << endl << endl;
-    }
-}
-
-void PrintTH3Error(const TH3 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-    {
-      for (Int_t j=1; j<=hist.GetNbinsY(); j++)
-        for (Int_t k=1; k<=hist.GetNbinsZ(); k++)
-            cout << hist.GetBinError(i, j, k) << " \t";
-      cout << endl << endl;
-    }
-}
-
-void PrintTH2Content(const TH2 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
-            cout << hist.GetBinContent(i,j) << " \t";
-        cout << endl << endl;
-}
-
-void PrintTH2Error(const TH2 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
-            cout << hist.GetBinError(i, j) << " \t";
-        cout << endl << endl;
-}
-
-void PrintTH1Content(const TH1 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-        cout << hist.GetBinContent(i) << " \t";
-    cout << endl << endl;
-}
-
-void PrintTH1Error(const TH1 &hist)
-{
-    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
-    cout << "-----------------------------------------------------" << endl;
-    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
-        cout << hist.GetBinError(i) << " \t";
-    cout << endl << endl;
-}
-
-void CopyCol(TMatrixD &m, const TH1 &h, Int_t col=0)
-{
-    const Int_t n = m.GetNrows();
-
-    for (Int_t i=0; i<n; i++)
-        m(i, col) = h.GetBinContent(i+1);
-}
-
-void CopyCol(TH1 &h, const TMatrixD &m, Int_t col=0)
-{
-    const Int_t n = m.GetNrows();
-
-    for (Int_t i=0; i<n; i++)
-        h.SetBinContent(i+1, m(i, col));
-}
-
-void CopyH2M(TMatrixD &m, const TH2 &h)
-{
-    const Int_t nx = m.GetNrows();
-    const Int_t ny = m.GetNcols();
-
-    for (Int_t i=0; i<nx; i++)
-        for (Int_t j=0; j<ny; j++)
-            m(i, j) = h.GetBinContent(i+1, j+1);
-}
-
-void CopySqr(TMatrixD &m, const TH1 &h)
-{
-    const Int_t nx = m.GetNrows();
-    const Int_t ny = m.GetNcols();
-
-    for (Int_t i=0; i<nx; i++)
-        for (Int_t j=0; j<ny; j++)
-        {
-            const Double_t bin =  h.GetBinContent(i+1, j+1);
-            m(i, j) = bin*bin;
-        }
-}
-
-Double_t GetMatrixSumRow(const TMatrixD &m, Int_t row)
-{
-    const Int_t n = m.GetNcols();
-
-    Double_t sum = 0;
-    for (Int_t i=0; i<n; i++)
-        sum += m(row, i);
-
-    return sum;
-}
-
-Double_t GetMatrixSumDiag(const TMatrixD &m)
-{
-    const Int_t n = m.GetNcols();
-
-    Double_t sum = 0;
-    for (Int_t i=0; i<n; i++)
-        sum += m(i, i);
-
-    return sum;
-}
-
-Double_t GetMatrixSumCol(const TMatrixD &m, Int_t col=0)
-{
-    const Int_t n = m.GetNrows();
-
-    Double_t sum = 0;
-    for (Int_t i=0; i<n; i++)
-        sum += m(i, col);
-
-    return sum;
-}
-Double_t GetMatrixSum(const TMatrixD &m)
-{
-    const Int_t n = m.GetNrows();
-
-    Double_t sum = 0;
-    for (Int_t i=0; i<n; i++)
-        sum += GetMatrixSumRow(m, i);
-
-    return sum;
-}
-
-
-// ======================================================
-//
-// SteerUnfold
-//
-void SteerUnfold(TString bintitle,
-                 TH1D &ha,     TH2D &hacov, TH2D &hmig,
-                 TH2D &hmigor, TH1D &hb0,   TH1D *hpr,
-                 TH1D &hb)
-{
-    // ha      is the distribution to be unfolded
-    // hacov   is the covariance matrix of the distribution ha
-    // hmig    is the migration matrix;
-    //         it is used in the unfolding unless it is overwritten
-    //         by SmoothMigrationMatrix by the smoothed migration matrix
-    // hmigor  is the migration matrix to be smoothed;
-    //         the smoothed migration matrix will be used in the unfolding
-    // hpr     the prior distribution
-    //         it is only used if SetPriorInput(*hpr) is called   
-    // hb      unfolded distribution
-
-    //..............................................       
-    // create an MUnfold object;
-    // fill histograms into vectors and matrices
-
-    MUnfold unfold(ha, hacov, hmig);
-    unfold.bintitle = bintitle;
-
-    //..............................................       
-    // smooth the migration matrix;
-    //        the smoothed migration matrix will be used in the unfolding
-    //        hmig is the original (unsmoothed) migration matrix
-
-    unfold.SmoothMigrationMatrix(hmigor);
-
-    //..............................................       
-    // define prior distribution (has always to be defined) 
-    // the alternatives are  :
-
-    // 1  SetPriorConstant() :   isotropic distribution
-    // 2  SetPriorPower(gamma) : dN/dE = E^{-gamma}
-    // 3  SetPriorInput(*hpr):   the distribution *hpr is used 
-    // 4  SetPriorRebin(*ha) :   use rebinned histogram ha 
-
-    UInt_t flagprior = 4;
-    cout << "SteerUnfold : flagprior = " << flagprior << endl;
-    cout << "==========================="<< endl;
-
-    Bool_t errorprior=kTRUE;
-    switch (flagprior)
-    {
-    case 1:
-        unfold.SetPriorConstant();
-        break;
-    case 2:
-        errorprior = unfold.SetPriorPower(1.5);
-        break;
-    case 3:
-        if (!hpr)
-        {
-            cout << "Error: No hpr!" << endl;
-            return;
-        }
-        errorprior = unfold.SetPriorInput(*hpr);
-        break;
-    case 4:
-        errorprior = unfold.SetPriorRebin(ha);
-        break;
-    }
-    if (!errorprior)
-    {
-        cout << "MUnfold::SetPrior... : failed.  flagprior = " ;
-        cout << flagprior << endl;
-        return;
-    }
-
-    //..............................................       
-    // calculate the matrix G = M * M(transposed)
-    //           M being the migration matrix
-
-    unfold.CalculateG();
-
-    //..............................................       
-    // call steering routine for the actual unfolding;
-    // the alternatives are :
-
-    // 1  Schmelling : minimize the function Z by Gauss-Newton iteration;
-    //                 the parameters to be fitted are gamma(i) = lambda(i)/w;
-
-    // 2  Tikhonov2 :  regularization term is sum of (2nd deriv.)**2 ;
-    //                 minimization by using MINUIT;
-    //                 the parameters to be fitted are
-    //                 the bin contents of the unfolded distribution
-
-    // 3  Bertero:     minimization by iteration
-    //                 
-
-    UInt_t flagunfold = 1;
-    cout << "SteerUnfold : flagunfold = "  << flagunfold << endl;
-    cout << "============================" << endl;
-
-
-
-    switch (flagunfold)
-    {
-    case 1: // Schmelling
-        cout << "" << endl;
-        cout << "Unfolding algorithm : Schmelling" << endl;
-        cout << "================================" << endl;
-        if (!unfold.Schmelling(hb0))
-            cout << "MUnfold::Schmelling : failed." << endl;
-        break;
-
-    case 2: // Tikhonov2
-        cout << "" << endl;
-        cout << "Unfolding algorithm :   Tikhonov" << endl;
-        cout << "================================" << endl;
-        if (!unfold.Tikhonov2(hb0))
-            cout << "MUnfold::Tikhonov2 : failed." << endl;
-        break;
-
-    case 3: // Bertero
-        cout << "" << endl;
-        cout << "Unfolding algorithm :    Bertero" << endl;
-        cout << "================================" << endl;
-        if (!unfold.Bertero(hb0))
-            cout << "MUnfold::Bertero : failed." << endl;
-        break;
-    }    
-
-
-    //..............................................       
-    // Print fResult
-    unfold.PrintResults();
-
-
-    //..............................................       
-    // Draw the plots
-    unfold.DrawPlots();
-
-    //..............................................       
-    // get unfolded distribution
-    TMatrixD &Vb    = unfold.GetVb();
-    TMatrixD &Vbcov = unfold.GetVbcov();
-
-    UInt_t fNb = unfold.fNb;
-
-    for (UInt_t a=0; a<fNb; a++)
-    {
-      hb.SetBinContent(a+1, Vb(a,0));
-      hb.SetBinError(a+1, sqrt(Vbcov(a, a)) );
-    }
-
-}
-
-//__________________________________________________________________________
-////////////////////////////////////////////////////////////////////////////
-//                                                                        //
-// doUnfolding    (to be called in the analysis)                          //
-//                                                                        //
-// arguments :                                                            //
-//                                                                        //
-//   INPUT                                                                //
-//      TH2D &tobeunfolded : no.of excess events and its error            //
-//                           vs. (E-est, Theta)                           //
-//      TH3D &migration    : migration matrix (E-est, E_true, Theta)      //
-//                                                                        //
-//   OUITPUT                                                              //
-//      TH2D &unfolded     : no.of excess events and its error            //
-//                           vs. (E-true, Theta)                          //
-//                                                                        //
-// calls SteerUnfold to do the unfolding                                  //
-//                                                                        //
-// The "Theta" axis is only used to loop over the bins of theta           //
-// and to do the unfolding for each bin of theta. Instead of theta        //
-// any other variable (or a dummy variable) may be used.                  //
-//                                                                        //
-//                                                                        //
-////////////////////////////////////////////////////////////////////////////
-
-void doUnfolding(TH2D &tobeunfolded, TH3D &migration, TH2D &unfolded)
-{
-  TAxis &taxis  = *tobeunfolded.GetYaxis();
-  Int_t numybins = taxis.GetNbins();
-
-  for (Int_t m=1; m<=numybins; m++)
-  {
-    TString bintitle = "Bin ";
-    bintitle += m;
-    bintitle += ": ";
-
-    // -----------------------------------------
-    // ha : distribution to be unfolded
-
-    TH1D &ha = *tobeunfolded.ProjectionX("", m, m, "e");
-    TString title = bintitle;
-    title += "E-est distr. to be unfolded";
-    ha.SetNameTitle("ha", title);
-    TAxis &aaxis = *ha.GetXaxis();
-    Int_t na = aaxis.GetNbins();
-    Double_t alow = aaxis.GetBinLowEdge(1);
-    Double_t aup  = aaxis.GetBinLowEdge(na+1);
-
-    PrintTH1Content(ha);
-    PrintTH1Error(ha);
-
-    // -----------------------------------------
-    // covariance matrix of the distribution ha
-
-    title = bintitle;
-    title +=  "Error matrix of distribution ha";
-    TH2D hacov("hacov", title, na, alow, aup, na, alow, aup);
-    //MH::SetBinning(&hacov, &aaxis, &aaxis); 
-
-    Double_t errmin = 3.0;
-    for (Int_t i=1; i<=na; i++)
-    {
-      for (Int_t j=1; j<=na; j++)
-      {
-        hacov.SetBinContent(i, j, 0.0);
-      }
-      const Double_t content = ha.GetBinContent(i);
-      const Double_t error2  = (ha.GetBinError(i))*(ha.GetBinError(i));
-      if (content <= errmin  &&  error2 < errmin) 
-        hacov.SetBinContent(i, i, errmin);
-      else
-        hacov.SetBinContent(i, i, error2);
-    }
-
-    //PrintTH2Content(hacov);
-    
-
-    // -----------------------------------------
-    // migration matrix :
-    //           x corresponds to measured quantity
-    //           y corresponds to true quantity
-    TH2D &hmig = *(TH2D*)migration.Project3D("yxe");
-    title = bintitle;
-    title += "Migration Matrix";
-    hmig.SetNameTitle("Migrat", title);
-
-    TAxis &aaxismig = *hmig.GetXaxis();
-    Int_t namig = aaxismig.GetNbins();
-
-    if (na != namig)
-    {
-      cout << "doUnfolding : binnings are incompatible; na, namig = "
-           << na << ",  " << namig << endl;
-      return;
-    }
-
-    TAxis &baxismig = *hmig.GetYaxis();
-    Int_t nbmig = baxismig.GetNbins();
-    Double_t blow = baxismig.GetBinLowEdge(1);
-    Double_t bup  = baxismig.GetBinLowEdge(nbmig+1);
-
-    PrintTH2Content(hmig);
-    //PrintTH2Error(hmig);
-
-
-    // -----------------------------------------
-    // dummy ideal distribution
-
-    Int_t nb = nbmig;
-
-    title = bintitle;
-    title += "Dummy Ideal distribution";
-    TH1D hb0("dummyhb0", title, nb, blow, bup);;
-    //MH::SetBinning(&hb0, &baxismig); 
-    hb0.Sumw2();
-
-    for (Int_t k=1; k<=nb; k++)
-    {
-        hb0.SetBinContent(k, 1.0/nb);
-        hb0.SetBinError  (k, 0.1/nb);
-    }
-
-    //PrintTH1Content(hb0);
-
-    // -----------------------------------------
-    // here the prior distribution can be defined for the call
-    // to SetPriorInput(*hpr)
-
-    title = bintitle;
-    title += "Dummy Prior distribution";
-    TH1D hpr("hpr", title, nb, blow, bup);
-    //MH::SetBinning(&hpr, &baxismig); 
-    
-    for (Int_t k=1; k<=nb; k++)
-        hpr.SetBinContent(k, 1.0/nb);
-
-    //PrintTH1Content(hpr);
-
-
-    // -----------------------------------------
-    // unfolded distribution
-
-
-    title = bintitle;
-    title += "Unfolded distribution";
-    TH1D hb("hb", title, nb, blow, bup);
-    //MH::SetBinning(&hb, &baxismig); 
-
-    // -----------------------------------------
-    SteerUnfold(bintitle, ha, hacov, hmig, hmig, hb0, &hpr, hb);
-
-    for (Int_t k=1; k<=nb; k++)
-    {
-      Double_t content = hb.GetBinContent(k);
-      Double_t error   = hb.GetBinError(k);
-
-      unfolded.SetBinContent(k, m, content);
-      unfolded.SetBinError(k, m, error);
-    }    
-
-    delete &ha;
-    delete &hmig;
-  }
-
-}
-//========================================================================//
-
-
-////////////////////////////////////////////////////////////////////////////
-//                                                                        //
-// Main program   (for testing purposes)                                  //
-//                                                                        //
-//                defines the ideal distribution          (hb0)           //
-//                defines the migration matrix            (hMigrat)       //
-//                defines the distribution to be unfolded (hVa)           //
-//                                                                        //
-//                calls doUnfolding                                       //
-//                      to do the unfolding                               //
-//                                                                        //
-////////////////////////////////////////////////////////////////////////////
-void fluxMUnfold()
-{
-  // -----------------------------------------
-  // migration matrix :
-  //           x corresponds to measured quantity
-  //           y corresponds to true quantity
-
-    const Int_t  na   =   13;
-    //const Int_t  na   =   18;
-    const Axis_t alow = 0.25;
-    const Axis_t aup  = 3.50;
-
-    const Int_t  nb   =   11;
-    //const Int_t  nb   =   22;
-    const Axis_t blow = 0.50;
-    const Axis_t bup  = 3.25;
-
-    const Int_t  nc   =     1;
-    const Axis_t clow =   0.0;
-    const Axis_t cup  =   1.0;
-
-    Int_t m = 1;
-
-    TH3D migration("migration", "Migration Matrix", 
-                   na, alow, aup, nb, blow, bup, nc, clow, cup);
-    migration.Sumw2();
-
-    // parametrize migration matrix as
-    //     <log10(Eest)>      = a0 + a1*log10(Etrue) + a2*log10(Etrue)**2 
-    //                             + log10(Etrue) 
-    //     RMS( log10(Eest) ) = b0 + b1*log10(Etrue) + b2*log10(Etrue)**2
-    Double_t a0 = 0.0;
-    Double_t a1 = 0.0;
-    Double_t a2 = 0.0;
-
-    Double_t b0 = 0.26;
-    Double_t b1 =-0.054;
-    Double_t b2 = 0.0;
-
-    TF1 f2("f2", "gaus(0)", alow, aup);
-    f2.SetParName(0, "ampl");
-    f2.SetParName(1, "mean");
-    f2.SetParName(2, "sigma");
-
-    // loop over log10(Etrue) bins
-    TAxis &yaxis = *migration.GetYaxis();
-    for (Int_t j=1; j<=nb; j++)
-    {
-        Double_t yvalue = yaxis.GetBinCenter(j);
-
-        const Double_t mean  = a0 + a1*yvalue + a2*yvalue*yvalue + yvalue;
-        const Double_t sigma = b0 + b1*yvalue + b2*yvalue*yvalue;
-        const Double_t ampl  = 1./ ( sigma*TMath::Sqrt(2.0*TMath::Pi()));
-
-        // gaus(0) is a substitute for [0]*exp( -0.5*( (x-[1])/[2] )**2 )
-        f2.SetParameter(0, ampl);
-        f2.SetParameter(1, mean);
-        f2.SetParameter(2, sigma);
-
-        // fill temporary 1-dim histogram with the function
-        // fill the histogram using
-        //    - either FillRandom
-        //    - or using Freq
-        TH1D htemp("temp", "temp", na, alow, aup);
-        htemp.Sumw2();
-
-        for (Int_t k=0; k<1000000; k++)
-            htemp.Fill(f2.GetRandom());
-
-        // copy it into the migration matrix
-        Double_t sum = 0;
-        for (Int_t i=1; i<=na; i++)
-        {
-            const Stat_t content = htemp.GetBinContent(i);
-            migration.SetBinContent(i, j, m, content);
-            sum += content;
-        }
-
-        // normalize migration matrix
-        if (sum==0)
-            continue;
-
-        for (Int_t i=1; i<=na; i++)
-        {
-            const Stat_t content = migration.GetBinContent(i,j,m);
-            migration.SetBinContent(i,j,m,       content/sum);
-            migration.SetBinError  (i,j,m, sqrt(content)/sum);
-        }
-    }
-
-    //PrintTH3Content(migration);
-    //PrintTH3Error(migration);
-
-    // -----------------------------------------
-    // ideal distribution
-
-    TH1D hb0("hb0", "Ideal distribution", nb, blow, bup);
-    hb0.Sumw2();
-
-    // fill histogram with random numbers according to 
-    // an exponential function dN/dE = E^{-gamma}
-    //    or with y = log10(E), E = 10^y :             
-    //                          dN/dy = ln10 * 10^{y*(1-gamma)}     
-    TF1 f1("f1", "pow(10.0, x*(1.0-[0]))", blow, bup);
-    f1.SetParName(0,"gamma");
-    f1.SetParameter(0, 2.7);
-
-    // ntimes is the number of entries
-    for (Int_t k=0; k<10000; k++)
-        hb0.Fill(f1.GetRandom());
-
-    // introduce energy threshold at 50 GeV
-
-    const Double_t  lgEth = 1.70;
-    const Double_t dlgEth = 0.09;
-
-    for (Int_t j=1; j<=nb; j++)
-    {
-        const Double_t lgE = hb0.GetBinCenter(j);
-        const Double_t c   = hb0.GetBinContent(j);
-        const Double_t dc  = hb0.GetBinError(j);
-        const Double_t f   = 1.0 / (1.0 + exp( -(lgE-lgEth)/dlgEth ));
-
-        hb0.SetBinContent(j, f* c);
-        hb0.SetBinError  (j, f*dc);
-    }
-
-    //PrintTH1Content(hb0);
-
-    // -----------------------------------------
-    // generate distribution to be unfolded (ha)
-    // by smearing the ideal distribution  (hb0)
-    //
-    TH2D tobeunfolded("tobeunfolded", "Distribution to be unfolded", 
-                      na, alow, aup, nc, clow, cup);
-    tobeunfolded.Sumw2();
-
-    for (Int_t i=1; i<=na; i++)
-    {
-        Double_t cont = 0;
-        for (Int_t j=1; j<=nb; j++)
-            cont += migration.GetBinContent(i, j, m) * hb0.GetBinContent(j);
-
-        tobeunfolded.SetBinContent(i, m, cont);
-        tobeunfolded.SetBinError(i, m, sqrt(cont));
-    }
-
-    //PrintTH2Content(tobeunfolded);
-    //PrintTH2Error(tobeunfolded);
-
-    // -----------------------------------------
-    // unfolded distribution
-
-    TH2D unfolded("unfolded", "Unfolded distribution", 
-                  nb, blow, bup, nc, clow, cup);
-    unfolded.Sumw2();
-
-    // -----------------------------------------
-    doUnfolding(tobeunfolded, migration, unfolded);
-
-}
-//========================================================================//
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/gridloop.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/gridloop.C	(revision 7136)
+++ 	(revision )
@@ -1,441 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-// Daniel Mazin 17.05.2004  mazin@mppmu.mpg.de
-// **********************************************************************************
-// this macro is used to produce false source plots
-// and it is a part from the macro falsesourcemethod.C.
-// See falsesourcemethod.C for more explanation
-// input: hillas parameters as vectors
-// output: several 2D plots in a root file +
-// ascii file with parameters like significance, Nexcess etc.
-// **********************************************************************************
-
-
-void gridloop()
-{
-
-    printf("inside of gridloop() ... \n");
-
-/* emty histograms  */
-
-    histskyplot.Reset();
-    histNexOnOff.Reset();
-    histChi2Off.Reset();
-    histskyplotOnOff.Reset();
-    histNex.Reset();
-    histChi2.Reset();
-    histskyplot4.Reset();
-    histskyLiMa.Reset();
-    histsign.Reset();
-    histsign4.Reset();
-    histBerlin.Reset();
-
-/* end emty histograms  */
-
-
-    TH1F histalphagrid;
-    histalphagrid.SetName("Alpha");
-    histalphagrid.SetTitle("Alpha");
-    histalphagrid.SetXTitle("Alpha (deg)");
-    histalphagrid.SetYTitle("Counts");
-    histalphagrid.SetDirectory(NULL);
-    histalphagrid.SetFillStyle(4000);
-    histalphagrid.UseCurrentStyle();
-  
-    bins.SetEdges(18, 0.0, 90.);
-    bins.Apply(histalphagrid);
-
-    Double_t xcorr, ycorr, xtest, ytest, xtilde, ytilde, fconc1;
-
-    const Float_t binwidth1 = histalphagrid.GetBinWidth(1);
-    if (TMath::Abs( ALPHAMAX/binwidth1 - TMath::Nint(ALPHAMAX/binwidth1)) > TOLERANCE)
-    {
-         cout << "wrong binning for histogram: histalphagrid \n SORRY ... ABORT" << endl;
-         exit(1);
-    }
-    const Int_t numbbinOnMax = TMath::Nint(ALPHAMAX / binwidth1);  // number bins in ON region
-
-  /*   fit functions  */
-    TF1 * fitsig = new TF1("fsig", "[0]", 0., ALPHAMAX);
-    fitsig->SetLineColor(4); 
-    TF1 * fitbgpar = new TF1("fbgpar", "[0]*x*x + [1]", 30., 90.);
-    fitbgpar->SetLineColor(2); 
-
-    TF1 * fitbg4 = new TF1("fbg4", "[0]*x*x*x*x + [1]*x*x + [2]", 30., 90.);
-    fitbg4->SetLineColor(3);
-  /*   end fit functions  */
-
-    Float_t Nex, Non, Noff, Sign;
-    Float_t xsource, ysource, xsournew, ysournew;
-
-    Double_t Nex4, Noff4, Sign4; 
-    Double_t alpha, SignLiMa;
- 
-    Double_t chisquarefit;
-
-    Double_t integon, integoff, normf, NoffOFF, SignOnOff, NexOnOff;
-    Float_t logsize, lgsize, lgsize2, tanbeta, beta;
-    const Float_t LOG3000 = log(3000.);
-
-
-
-    Double_t chi2par[GRIDBINS], apar[GRIDBINS], bpar[GRIDBINS]; // fit parameters from OFF sample
-    Float_t offbin1[GRIDBINS], offbin2[GRIDBINS], offbin3[GRIDBINS]; // Number of events in first 3 bins
-    Double_t xpos, ypos, binwidth2;
-    Int_t  numgrid;
-
-
-    Int_t numbinsoff = 12;  // FIXME: 12 should be changed according to the binning
-    Int_t nbinx, nbiny, gridpoint = 0;
-
-    Char_t psname[120], titelname[120], plot1name[120], plot2name[120], stringsig[120];
- 
-    FILE * fp;
-
-    if (TYPEOPTION == kTRUE)  // read fit parameters from the OFF sample
-    {
-      Char_t * datin = DATPARAMIN;
-              
-      fp = fopen(datin, "r");
-
-      for (Int_t i=0; i<GRIDBINS; i++)
-      {
-        fscanf(fp,"%d %lf %lf %lf %lf %lf %lf %f %f %f",
-                 &numgrid, &xpos, &ypos,  &apar[i], &bpar[i], 
-                 &chi2par[i], &binwidth2,
-                 &offbin1[i], &offbin2[i], &offbin3[i]);
-//  cout << "numgrid: " << numgrid << ",  apar " << apar[i] << endl;
-      }
-
-       fclose(fp);
-    }
-
-
-    Char_t * chout = DATPARAMOUT;  // write parameters into file
-
-    fp = fopen(chout, "w");
-
-
-/* begin of the loop over all bins in the sky map */
-
-   for(Int_t gridx = 0; gridx < NUMSTEPS; gridx++)   
-   { 
-    xsource = MINXGRID + gridx * STEPGRID;
-//cout << xsource << endl;
-
-    for(Int_t gridy = 0; gridy < NUMSTEPS; gridy++)  
-    {
-      ysource = MINYGRID + gridy * STEPGRID;
-//cout << ysource << endl;
-    
-// empty histogram:
-//     nbinx = histalphagrid.GetNbinsX();
-//     for(Int_t ii = 0; ii< (nbinx+1); ii++) histalphagrid.SetBinContent(ii, 0.);
-//     histalphagrid.SetEntries(0);
-     histalphagrid.Reset();
-
-
-//      Bool_t anglephi = kFALSE;
-
-    /* loop over all events */
-      for(Int_t k=0; k< imnum; k++)
-      {
-
-          if (ROTOPTION == kTRUE) // derotate into sky coordinates
-          {
-      /*     derotation    : correct sky coordinates into camera coordinates */
-             xsournew = cosgam(k) * xsource - singam(k) * ysource;
-             ysournew = singam(k) * xsource + cosgam(k) * ysource;
-       /*    end derotatiom    */
-          }
-          else // do not derotate, plot into camera coordinates
-          {
-             xsournew = xsource;
-             ysournew = ysource;
-          }
-
-
-       /* calculate ALPHA und DIST acording to the source position */
-           tanbeta = (ypar(k) - ysournew) / (xpar(k) - xsournew);
-           beta = TMath::ATan(tanbeta);
-           alphapar(k) = (deltapar(k) - beta) * 180./ TMath::Pi();
-           distpar(k) = sqrt((ypar(k) - ysournew) * (ypar(k) - ysournew) +
-                             (xpar(k) - xsournew) * (xpar(k) - xsournew));
-
-
-
-          if(alphapar(k) > 90.) alphapar(k) -= 180.;
-          if(alphapar(k) < -90.) alphapar(k) += 180.;
-
-//          histalpha.Fill(alphapar(k),1.);
-//          histdist.Fill( distpar(k),1.);
-
-          if(CUTOPTION==kFALSE)
-          { 
-/* ******************************************************   */
-      /*   static   cuts   */
-                if (lengthpar(k) > LENGTHMIN && lengthpar(k) < LENGTHMAX)
-                if (widthpar(k) > WIDTHMIN && widthpar(k) < WIDTHMAX)
-                if (sizepar(k) > SIZEMIN)
-                if (distpar(k) > DISTMIN && distpar(k) < DISTMAX)
-                if (leak1(k) < LEAKMAX)
-/* ******************************************************   */
-                     {
-                         alphapar(k) = TMath::Abs(alphapar(k));
-//printf("alpha passed the cuts: %5.2f \n", alphapar(k));
-//printf("histalphagrid:  %5.2f \n", histalphagrid.GetNbinsX());
-                         histalphagrid.Fill(alphapar(k),1.);
-
-                     }
-
-           }
-/* ******************************************************   */
-/*            dynamical cuts                                */
-           else     // if(CUTOPTION==kTRUE)
-           {
-                 logsize = log(sizepar(k));
-                 lgsize = logsize-LOG3000;
-                 lgsize2 = lgsize*lgsize;
-                 if ( sizepar(k) > SIZEMIN )
-                 if ( leak1(k) < LEAKMAX )
-                 if ( lengthpar(k) > (LENGTHMINParA + LENGTHMINParB*lgsize + LENGTHMINParC*lgsize2) &&
-                      lengthpar(k) < (LENGTHMAXParA + LENGTHMAXParB*lgsize + LENGTHMAXParC*lgsize2))
-                 if ( widthpar(k) > (WIDTHMINParA + WIDTHMINParB*lgsize + WIDTHMINParC*lgsize2)  &&
-                      widthpar(k) < (WIDTHMAXParA + WIDTHMAXParB*lgsize + WIDTHMAXParC*lgsize2) )
-                 if ( distpar(k) > (DISTMINParA + DISTMINParB*lgsize + DISTMINParC*lgsize2)  &&
-                      distpar(k) < (DISTMAXParA + DISTMAXParB*lgsize + DISTMAXParC*lgsize2) )
-                 {
-                         alphapar(k) = TMath::Abs(alphapar(k));
-                         histalphagrid.Fill(alphapar(k),1.);
-                         if(alphapar(k) < 8.)   histBerlin.Fill(xsournew, ysournew);
-                 }
-           }
-         
-        }
-//    histalphagrid.Fit("fsig","NR");
-//printf("content bin 1: %4.2f\n", histalphagrid.GetBinContent(1));
-    histalphagrid.Fit(fitsig,"NWR");
-    histalphagrid.Fit("fbg4","+NWR");
-    histalphagrid.Fit("fbgpar","+NWR");
-
-// cout << "OK" << endl;
-// calculate significance:
-    Non = 0.;
-    for(Int_t i=1; i<=numbbinOnMax;i++) Non += histalphagrid.GetBinContent(i);
-//    Non = (fitsig->GetParameter(0)) * numbbinOnMax;
-//cout << "Non : " << Non << endl;
-//    histalphagrid.Draw();
-
-    chisquarefit = fitbgpar->GetChisquare(); 
-    Noff = (1./3. * (fitbgpar->GetParameter(0)) * pow(ALPHAMAX,3.) + 
-           (fitbgpar->GetParameter(1)) * ALPHAMAX) /  binwidth1;
-    
-//cout << "Noff : " << Noff << endl;
-    
-    Nex = Non - Noff;
-
-    Noff4 = (1./5. * fitbg4->GetParameter(0) *  pow(ALPHAMAX,5.) +
-            1./3. * (fitbg4->GetParameter(1)) * pow(ALPHAMAX,3.) +
-           fitbg4->GetParameter(2) * ALPHAMAX ) / binwidth1;
- 
-//cout << "Noff4 : " << Noff4 << endl;
- 
-    Nex4 = Non - Noff4;
- 
-// calculate significance: 
-
-//    Sign4 = Nex4 / sqrt(Nex4 + 2.* Noff4);
-    if (Noff4<0.) Sign4 = 0.;
-    else Sign4 = LiMa17(Non,Noff4,1.);
-
-//cout << "Sign4 : " << Sign4 << endl;
-//    Sign = Nex / sqrt(Nex + 2.* Noff);
-    if (Noff<0.) Sign = 0.;
-    else Sign = LiMa17(Non,Noff,1.);
-//cout << "Sign LiMa : " << Sign << endl;
-
-   /*  calculate Noff from the OFF data  */
-  if (TYPEOPTION == kTRUE)
-  {
-   	// ON: 
-
-   	integon = 0.;  // number of events between 30 and 90 degrees
-
-	   for (Int_t ik = 0; ik < numbinsoff; ik++)
-	   {
-	    integon += histalphagrid.GetBinContent(7+ik);  // FIXME: 7 should be changed according to the binning
-	   }
-	   // OFF: 
-
-	   integoff = ((1./3. * apar[gridpoint] * pow(90.,3.) + bpar[gridpoint] * 90.) -
-        	      (1./3. * apar[gridpoint] * pow(30.,3.) + bpar[gridpoint] * 30.)) / binwidth2;
-	
-	   normf = integoff / integon;
-
-	   NoffOFF = (1./3. * apar[gridpoint] * pow(ALPHAMAX,3.) +
-        	   (bpar[gridpoint] * ALPHAMAX)) /  binwidth2 / normf;
-
-	   NexOnOff = Non - NoffOFF;
-
-  	   SignOnOff = NexOnOff / sqrt(NexOnOff + 2.* NoffOFF);
-
-	// calculate according to Li Ma:
-           if (NoffOFF<0.) SignLiMa=0.;
-	   else SignLiMa = LiMa17(Non,NoffOFF*normf,1./normf);
-
-   }
-
-    cout << endl << "   xsource: " << xsource <<  "   ysource: " << ysource << endl;
-
-    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
-
- if (TYPEOPTION == kTRUE) 
-    cout << " ON and OFF : Non : " << Non << " Noff (estimated) : " << NoffOFF << " Nex : " << NexOnOff << endl;
-
-    cout << endl;
-    cout << " significance (parab): " << Sign << " sigma" << endl;
-    cout << " significance (4th order): " << Sign4 << " sigma" << endl;
- if (TYPEOPTION == kTRUE)
-  {
-    cout << " significance (using ON and OFF): " << SignOnOff << " sigma" << endl;
-    cout << " significance (LiMa 17): " << SignLiMa << " sigma" << endl;
-  }
-
-
-    if (TYPEOPTION == kTRUE)
-      fprintf(fp,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf \n", 
-                xsource, ysource, Sign, Non, Noff, Nex, SignLiMa, 
-                SignOnOff, NoffOFF, NexOnOff, chi2par[gridpoint]);
-    else 
-         fprintf(fp,"%d %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
-            gridpoint+1, xsource, ysource,
-            fitbgpar->GetParameter(0), fitbgpar->GetParameter(1),
-            fitbgpar->GetChisquare(), histalphagrid.GetBinWidth(1),
-            histalphagrid.GetBinContent(1), histalphagrid.GetBinContent(2),
-            histalphagrid.GetBinContent(3));
-
-
-    histskyplot.SetBinContent(gridx+1, gridy+1, Sign);
-    histNex.SetBinContent(gridx+1, gridy+1, Nex);
-    histChi2.SetBinContent(gridx+1, gridy+1, fitbgpar->GetChisquare() / 10.);
-
-    if (TYPEOPTION == kTRUE) histskyplotOnOff.SetBinContent(gridx+1, gridy+1, SignOnOff);
-    if (TYPEOPTION == kTRUE) histNexOnOff.SetBinContent(gridx+1, gridy+1, NexOnOff);
-    if (TYPEOPTION == kTRUE) histChi2Off.SetBinContent(gridx+1, gridy+1, chi2par[gridpoint] / 16.);
-
-    if (TYPEOPTION == kTRUE) histskyLiMa.SetBinContent(gridx+1, gridy+1, SignLiMa);
-    histskyplot4.SetBinContent(gridx+1, gridy+1, Sign4);
-    histsign.Fill(Sign,1.);
-    histsign4.Fill(Sign4,1.);
-//    break;
-
-    if (TYPEOPTION == kTRUE)
-    {
-	    TF1 * bgoff = new TF1("bgoff", parabfunc, 0., 90., 3);
-	    bgoff->SetParameters(apar[gridpoint], bpar[gridpoint], normf);
-	    bgoff->FixParameter(0, apar[gridpoint]);
-	    bgoff->FixParameter(1, bpar[gridpoint]);
-	    bgoff->FixParameter(2, normf);
-	    bgoff->SetLineColor(8);
-    }
-
-//    sprintf(stringsig,"S = %.2f sigma", Sign);
-    if (TYPEOPTION == kTRUE) sprintf(stringsig,"S = %.2f sigma", SignOnOff);
-/*
-    sprintf(psname,"/.magic/magicserv01/scratch/Daniel/plots/RootPlots/040215Mrk421_misp/all/alphaX%.2fY%.2fON.root", xsource, ysource);
-    sprintf(titelname,"alpha plot. assumed source position: x = %.2f y = %.2f", xsource, ysource);
-    TCanvas * cplot  = new TCanvas();
-    histalphagrid.SetTitle(titelname);
-    histalphagrid.Draw();
-    bgoff->Draw("same");
-    leg = new TLegend(0.1,0.15,0.52,0.35);
-    leg->Draw();
-    leg->AddEntry(fitsig,"fit for ON region (0-20 deg)","l");
-    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
-    leg->AddEntry(bgoff,"fit from OFF data (0-90 deg)","l");
-    leg->SetHeader("Legend");
-    leg->SetFillColor(19);
-    leg->Draw();
-
-    text = new TPaveText(50,20,90,80);
-    text->AddText(0.5, 0.8, "calculated significance");
-    text->AddText(0.5, 0.5, "using ON and OFF:");
-    text->AddText(1, 0.2, stringsig);
-    text->SetTextSize(0.04);
-    text->Draw();
-
-    cplot->Modified();
-    cplot->Update();
-
-    cplot->SaveAs(psname);
-    delete cplot;
-*/
-    if (TYPEOPTION == kTRUE) delete  bgoff;
-
-    gridpoint++;
-
-    }
-   }
-
-  /* close file  */
-    fclose(fp);  
-    
-
-    TFile rootfile(ROOTPLOTNAME, "RECREATE",
-                   "sky plots in all variations");
-
-
-//    cout << " end of one of the grids 1 " << endl;
-
-     histskyplot.Write();
-
-     histNex.Write();
-
-     histChi2.Write();
-
-     histsign.Write();
-
-     histskyplot4.Write();
-
-     histsign4.Write();
-
-     histBerlin.Write();
-
-   if (TYPEOPTION == kTRUE)
-   {
-     histNexOnOff.Write();
-     histChi2Off.Write();
-     histskyplotOnOff.Write();
-     histskyLiMa.Write();
-    }
-
-   rootfile.Close();
-
-   delete fitsig;
-   delete fitbgpar;
-   delete fitbg4;
-
-  cout << " end of one of the grids " << endl;
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/hillasfileread.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/hillasfileread.C	(revision 7136)
+++ 	(revision )
@@ -1,181 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Cherenkov 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): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-// Daniel Mazin 17.05.2004  mazin@mppmu.mpg.de
-// **********************************************************************************
-// this macro is a part from the macro falsesourcemethod.C
-// This macro reads mars file with hillas parameters etc. and puts the values into vectors
-// input: hillas parameter file
-// output: vectors with the same information
-// **********************************************************************************
-
-
-void hillasfileread()
-{
-   lengthpar.ResizeTo(MAXNUMEVENTS);
-   widthpar.ResizeTo(MAXNUMEVENTS);
-   sizepar.ResizeTo(MAXNUMEVENTS);
-   xpar.ResizeTo(MAXNUMEVENTS);
-   ypar.ResizeTo(MAXNUMEVENTS);
-   deltapar.ResizeTo(MAXNUMEVENTS);
-   alphapar.ResizeTo(MAXNUMEVENTS);
-   distpar.ResizeTo(MAXNUMEVENTS);
-   cosgam.ResizeTo(MAXNUMEVENTS);
-   singam.ResizeTo(MAXNUMEVENTS);
-   conc1.ResizeTo(MAXNUMEVENTS);
-   leak1.ResizeTo(MAXNUMEVENTS);
-
-   lengthpar.Zero();
-   widthpar.Zero();
-   sizepar.Zero();
-   xpar.Zero();
-   ypar.Zero();
-   deltapar.Zero();
-   alphapar.Zero();
-   distpar.Zero();
-   cosgam.Zero();
-   singam.Zero();
-   conc1.Zero();
-   leak1.Zero();
-
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-    
-
-    MReadMarsFile read("Events");
-    read.DisableAutoScheme();
-
-    read.AddFile(HILLASFILENAME);
-
-    MHillas mhillas;
-    plist.AddToList(&mhillas);
-
-    MHillasSrc mhillassrc;
-    plist.AddToList(&mhillassrc);
-
-    MNewImagePar mnewimpar;
-    plist.AddToList(&mnewimpar);
-
-    MGeomCamMagic cam;
-    plist.AddToList(&cam);
- 
-    MMcEvt mcevt;
-    plist.AddToList(&mcevt); 
-
-    MPointingPos mpoint;
-    plist.AddToList(&mpoint); 
-
-    MObservatory observ;
-    plist.AddToList(&observ);
-
-    MHStarMap starmap;
-    plist.AddToList(&starmap);
-
-//    MRawRunHeader header;
-//    plist.AddToList(&header);
-    
-    tlist.AddToList(&read);
-   
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    Float_t fMm2Deg;
-
-cout << " file name: " << HILLASFILENAME << endl;
-
-   if (!tlist.PreProcess(&plist))
-      return;
-
-    fMm2Deg = cam->GetConvMm2Deg();
-    Int_t event = 0;
-    Int_t filenumber = 0;
-    Float_t theta, phi;
- 
-    imnum = 0;
-
-    while (tlist.Process())
-    {
-    event++;
-//cout << event << endl;
-
-    if (mhillas->GetLength() != -1.)
-     {
-
-
-     if (ROTOPTION == kTRUE) 
-     {
-//        theta = mcevt->GetTelescopeTheta();
-        theta = mpoint->GetZd();
-//        phi = mcevt->GetTelescopePhi();
-        phi = mpoint->GetAz();
-//   printf("theta: %5.3f, phi: %5.3f\n", theta*180./4.1415, phi*180./4.1415);
-        observ.RotationAngle(theta, phi, singam(imnum), cosgam(imnum)); 
-     }
-
-      lengthpar(imnum) = (mhillas->GetLength()) * fMm2Deg;
-      widthpar(imnum) = (mhillas->GetWidth())*fMm2Deg;
-      sizepar(imnum) = mhillas->GetSize();
-      xpar(imnum) = (mhillas->GetMeanX())*fMm2Deg;
-      ypar(imnum) = (mhillas->GetMeanY())*fMm2Deg;
-      deltapar(imnum) = mhillas->GetDelta(); 
-      conc1(imnum) = (mnewimpar->GetConc1());
-      leak1(imnum) = mnewimpar->GetLeakage1();
-
-      imnum++;
-
-     }
-    else filenumber++;
-    }
-
-    if (!tlist.PostProcess())
-      return;
-
-   printf("imnum = %d\n",imnum);
-
-   lengthpar.ResizeTo(imnum);
-   widthpar.ResizeTo(imnum);
-   sizepar.ResizeTo(imnum);
-   xpar.ResizeTo(imnum);
-   ypar.ResizeTo(imnum);
-   deltapar.ResizeTo(imnum);
-   alphapar.ResizeTo(imnum);
-   distpar.ResizeTo(imnum); 
-   cosgam.ResizeTo(imnum); 
-   singam.ResizeTo(imnum); 
-   conc1.ResizeTo(imnum); 
-   leak1.ResizeTo(imnum); 
-
-
-    cout << " conversion factor is: " << fMm2Deg <<  endl;
-    cout << " events read in from file : " << event <<  endl;
-    cout << " runs found in the file : " << filenumber <<  endl;
-
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/mtools.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/mtools.C	(revision 7136)
+++ 	(revision )
@@ -1,19 +1,0 @@
-Double_t LiMa17(Double_t Non, Double_t Noff, Double_t alpha)
-{
-  Double_t term1, term2, signif;
-  term1 = ((1.+alpha) / alpha) * (Non / (Non + Noff));
-  term2 = (1.+alpha) * (Noff / (Non + Noff));
-
-  signif = sqrt(2.* (Non*log(term1) + Noff*log(term2)));
-
-  if (Non>(alpha*Noff)) return signif;
-  else return -signif;
-
-}
-
-Double_t parabfunc(Double_t *x, Double_t *par)
-{
-   Double_t result=0.;
-   if (par[2]!=0)   result = (par[0] * x[0] * x[0] + par[1]) / par[2];
-   return result;
-}
Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/skyplot.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/skyplot.h	(revision 7136)
+++ 	(revision )
@@ -1,201 +1,0 @@
-// temporal solution:
-#define MAXNUMEVENTS 500000
-#define LOG3000      log(3000.)
-
-TString HILLASFILENAME;
-TString DATPARAMIN;
-TString DATPARAMOUT;
-TString ROOTPLOTNAME;
-Int_t imnum = 0;
-
-TVectorD lengthpar(MAXNUMEVENTS);
-TVectorD widthpar(MAXNUMEVENTS);
-TVectorD distpar(MAXNUMEVENTS);
-TVectorD alphapar(MAXNUMEVENTS);
-TVectorD sizepar(MAXNUMEVENTS);
-TVectorD deltapar(MAXNUMEVENTS);
-TVectorD xpar(MAXNUMEVENTS);
-TVectorD ypar(MAXNUMEVENTS);
-TVectorD conc1(MAXNUMEVENTS);
-TVectorD leak1(MAXNUMEVENTS);
-TVectorD cosgam(MAXNUMEVENTS);
-TVectorD singam(MAXNUMEVENTS);
-
-// the alpha histogram
-MBinning bins;
-
-//TH1F histalphagrid;
-//histalphagrid.SetName("Alpha");
-//histalphagrid.SetTitle("Alpha");
-//histalphagrid.SetXTitle("Alpha [deg]");
-//histalphagrid.SetYTitle("Counts");
-//histalphagrid.SetDirectory(NULL);
-//histalphagrid.SetFillStyle(4000);
-//histalphagrid.UseCurrentStyle(); 
-
-bins.SetEdges(18, 0.0, 90.);
-bins.Apply(histalphagrid);
-
-
-
-// possible histograms:
-TH1F histlength;
-TH1F histwidth;
-TH1F histsize;
-TH1F histalpha;
-TH1F histdist;
-TH1F histmeanx;
-TH1F histmeany;
-TH1F histalphafinal;
-
-TH2F hist2xy("CoG1","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
-TH1F histLoverS;
-TH1F aftercuthistlength;
-TH1F aftercuthistwidth;
-TH1F aftercuthistsize;
-TH1F aftercuthistalpha;
-TH1F aftercuthistdist;
-TH1F aftercuthistmeanx;
-TH1F aftercuthistmeany;
-TH2F aftercuthist2xy("CoG2","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
-TH2F hist2lw("Length-Width", "correlation Length-Width", 100, 0.0, 1.0, 100, 0.0, 0.5);
-TH2F hist2lalpha("Length-Alpha", "correlation Length-Alpha", 100, 0.0, 1.0, 100, -100., 100.);
-TH2F hist2ldist("Length-Dist","correlation Length-Dist", 100, 0.0, 1.0, 100, 0.0, 1.6);
-TH2F hist2walpha("Width-Alpha","correlation Width-Alpha", 100, 0.0, 0.5, 100, -100., 100.);
-TH2F hist2wdist("Width-Dist","correlation Width-Dist", 100, 0.0, 0.5, 100, 0.0, 1.6);
-TH2F hist2alphadist("Alpha-Dist","correlation Alpha-Dist", 100, -100., 100, 100, 0.2, 1.4);
-
-
-TH2F histskyplot("SPSignif2ndOrder","Sky Plot of significance (2nd order fit)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histskyplot.SetXTitle("-RA [deg]");
-//histskyplot.SetYTitle("DEC [deg]");
-histskyplot.SetDirectory(NULL);
-histskyplot.SetFillStyle(4000);
-histskyplot.UseCurrentStyle();
-
-TH2F histNexOnOff("SPNexOnOff","Sky Plot of Number of excess events (using ON and OFF data)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histNexOnOff.SetXTitle("-RA [deg]");
-//histNexOnOff.SetYTitle("DEC [deg]");
-histNexOnOff.SetDirectory(NULL);
-histNexOnOff.SetFillStyle(4000);
-histNexOnOff.UseCurrentStyle();
-
-TH2F histChi2Off("SPChi2PerNdf2ndOrderOff","Sky Plot of Chi2/ndf (2nd order fit, OFF data)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histChi2Off.SetXTitle("-RA [deg]");
-//histChi2Off.SetYTitle("DEC [deg]");
-histChi2Off.SetDirectory(NULL);
-histChi2Off.SetFillStyle(4000);
-histChi2Off.UseCurrentStyle();
-
-TH2F histskyplotOnOff("SPSignifOnOff","Sky Plot of significance (using ON and OFF data)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histskyplotOnOff.SetXTitle("-RA [deg]");
-//histskyplotOnOff.SetYTitle("DEC [deg]");
-histskyplotOnOff.SetDirectory(NULL);
-histskyplotOnOff.SetFillStyle(4000);
-histskyplotOnOff.UseCurrentStyle();
-
-TH2F histNex("SPNex2ndOrder","Sky Plot of Number of excess events (2nd order fit)",
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histNex.SetXTitle("-RA [deg]");
-//histNex.SetYTitle("DEC [deg]");
-histNex.SetDirectory(NULL);
-histNex.SetFillStyle(4000);
-histNex.UseCurrentStyle();
-
-TH2F histChi2("SPChi2PerNdf2ndOrderOn","Sky Plot of Chi2/ndf (2nd order fit)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histChi2.SetXTitle("-RA [deg]");
-//histChi2.SetYTitle("DEC [deg]");
-histChi2.SetDirectory(NULL);
-histChi2.SetFillStyle(4000);
-histChi2.UseCurrentStyle();
-
-TH2F histskyplot4("SPSignif4thOrder","Sky Plot of significance (4th order fit)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histskyplot4.SetXTitle("-RA [deg]");
-//histskyplot4.SetYTitle("DEC [deg]");
-histskyplot4.SetDirectory(NULL);
-histskyplot4.SetFillStyle(4000);
-histskyplot4.UseCurrentStyle();
-
-TH2F histskyLiMa("SPSignifLiMaOnOff","Sky Plot of significance (ON - OFF LiMa17)", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histskyLiMa.SetXTitle("-RA [deg]");
-//histskyLiMa.SetYTitle("DEC [deg]");
-histskyLiMa.SetDirectory(NULL);
-histskyLiMa.SetFillStyle(4000);
-histskyLiMa.UseCurrentStyle();
-
-TH2F histBerlin("SPBerlinMethod","Sky Plot of Events below alpha 8 degrees", 
-                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
-                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
-//histskyLiMa.SetXTitle("-RA [deg]");
-//histskyLiMa.SetYTitle("DEC [deg]");
-histBerlin.SetDirectory(NULL);
-histBerlin.SetFillStyle(4000);
-histBerlin.UseCurrentStyle();
-
-TH1F histsign;
-histsign.SetName("Significance 1");
-histsign.SetTitle("Significance (2nd order fit)");
-histsign.SetXTitle("significance");
-histsign.SetYTitle("Counts");
-histsign.SetDirectory(NULL);
-histsign.SetFillStyle(4000);
-histsign.UseCurrentStyle(); 
-
- bins.SetEdges(20, -5., 8.);
- bins.Apply(histsign);
-
-TH1F histsign4;
-histsign4.SetName("Significance 2");
-histsign4.SetTitle("Significance (4th order fit)");
-histsign4.SetXTitle("significance");
-histsign4.SetYTitle("Counts");
-histsign4.SetDirectory(NULL);
-histsign4.SetFillStyle(4000);
-histsign4.UseCurrentStyle(); 
-
- bins.SetEdges(20, -5., 8.);
- bins.Apply(histsign4);
-
-
-TH1F histalphagrid;
-histalphagrid.SetName("Alpha");
-histalphagrid.SetTitle("Alpha");
-//histalphagrid.SetXTitle("Alpha [deg]");
-histalphagrid.SetYTitle("Counts");
-histalphagrid.SetDirectory(NULL);
-histalphagrid.SetFillStyle(4000);
-histalphagrid.UseCurrentStyle(); 
-
- bins.SetEdges(18, 0.0, 90.);
- bins.Apply(histalphagrid);
-
-/*
-#define n 100
-Double_t binsize[n];
-Float_t nmin = 100.;
-Float_t nmax = 1e7;
-
-for(Int_t i=0; i<n; i++)
-{
-binsize[i] = pow(10., log10(nmin) + i * (log10(nmax) - log10(nmin)) / (n-1.));
-}
-
-TH2F hist2wsize("Width-Size", "correlation Width-Size", 100, 0.0, 0.5, n-1, binsize);
-TH2F hist2alphasize("Alpha-Size","correlation Alpha-Size", 100, -100., 100., n-1, binsize);
-TH2F hist2distsize("Dist-Size","correlation Dist-Size", 100, 0.0, 1.6, n-1, binsize);
-*/
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/RanForestDISP.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/RanForestDISP.C	(revision 7136)
+++ trunk/MagicSoft/Mars/mtemp/mpadova/macros/RanForestDISP.C	(revision 7137)
@@ -1,337 +1,1 @@
-/* ======================================================================== *\
-   !
-   ! *
-   ! * 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): Abelardo Moralejo 1/2005 <mailto:moralejo@pd.infn.it>!
-   !
-   !   Copyright: MAGIC Software Development, 2000-2003
-   !
-   !
-   \* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////////
-//
-// macro RanForestDISP.C
-//
-// Version of Random Forest macro, intended to run on real data without assuming 
-// any particular source position in the camera FOV. So we do not use the DIST
-// parameter, but rather (one version of) DISP method. We do not use either the 
-// sign of the third longitudinal moment with respect to the center of the camera 
-// (since the source can be somewhere else like in the case of wobble mode).
-//
-//////////////////////////////////////////////////////////////////////////////////
-
-
-#include "MMcEvt.hxx"
-
-void RanForestDISP(Int_t minsize=1000)
-{
-    Int_t mincorepixels = 6; // minimum number of core pixels.
-//  Int_t mincorepixels = 0;
-
-    TString skipevents;
-    //  skipevents = "(MMcEvt.fImpact>15000.)";
-    //  skipevents = "(MNewImagePar.fLeakage1>0.001)";
-    //  skipevents = "(MHillas.fSize>1000)";
-
-    // Skip calibration events, leaking events and flash events:
-    skipevents = "(MNewImagePar.fLeakage1>0.1) || ({1.5+log10(MNewImagePar.fConc)*2.33333}-{6.5-log10(MHillas.fSize)}>0.)";
-
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-
-    MReadMarsFile  read("Events", "/data1/magic/mc_data/root/Period021_0.73_mirror/FixedWindowPeakSearch/WOBBLE_Calib_6slices/tc_3.84_2.56/star_gamma_train_new.root");
-    Float_t numgammas = read.GetEntries();
-
-    read.AddFile("star_train_20050110_CrabNebulaW1.root");
-    Float_t numhadrons = read.GetEntries() - numgammas;
-
-    // Fraction of gammas to be used in training:
-    //    Float_t gamma_frac = 1.5*(numhadrons / numgammas);
-    Float_t gamma_frac = 1.;
-
-    // Total hadron number to be processed in training:
-    // If you run RF over different data runs, using always the same # of training gammas,
-    // you should also use always a fixed number of hadrons for training (although the data 
-    // runs may be of different duration). Otherwise the meaning of the output hadronness 
-    // would be different for the different subsamples, since its absolute values depend on 
-    // the statistics of the training sample. The number set here is the number BEFORE the
-    // "a priori cuts" set above through "skipevents".
-
-    Float_t select_n_hadrons = 37000.;  
-    Float_t hadron_frac = select_n_hadrons / numhadrons;
-
-    read.DisableAutoScheme();
-
-    tlist.AddToList(&read);
-
-    MFParticleId fgamma("MMcEvt", '=', MMcEvt::kGAMMA);
-    tlist.AddToList(&fgamma);
-
-    MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
-    tlist.AddToList(&fhadrons);
-
-
-    MHMatrix matrixg("MatrixGammas");
-
-    // TEST TEST TEST
-//     matrixg.AddColumn("MMcEvt.fImpact");
-//     matrixg.AddColumn("MMcEvt.fMuonCphFraction");
-
-    //    matrixg.AddColumn("MNewImagePar.fLeakage1");
-    //    matrixg.AddColumn("floor(0.5+(cos(MMcEvt.fTelescopeTheta)/0.01))");
-
-    //    matrixg.AddColumn("MMcEvt.fTelescopePhi");
-    //    matrixg.AddColumn("MSigmabar.fSigmabar");
-
-
-    matrixg.AddColumn("MHillas.fSize");
-
-    // We do not use DIST, since it depends on knowing the source position on camera.
-    // In wobble mode the position changes with time. Besides, we intend to do a 2-d map
-    // with the DISP method, and so we cannot use DIST in the cuts (since it would amde the
-    // camera center a "provoleged" position).
-
-    matrixg.AddColumn("(1.-(MHillas.fWidth/MHillas.fLength))*(0.9776+(0.101062*log10(MHillas.fSize)))");
-
-//     matrixg.AddColumn("MHillas.fWidth");
-//     matrixg.AddColumn("MHillas.fLength");
-
-
-    // Scaling from real data?
-    //    matrixg.AddColumn("MHillas.fWidth/(-8.37847+(9.58826*log10(MHillas.fSize)))");   
-    //    matrixg.AddColumn("MHillas.fLength/(-40.1409+(29.3044*log10(MHillas.fSize)))");
-
-    // Scaling from MC:
-    matrixg.AddColumn("(MHillas.fWidth*3.37e-3)/(-0.028235+(0.03231*log10(MHillas.fSize)))");   
-    matrixg.AddColumn("(MHillas.fLength*3.37e-3)/(-0.13527+(0.09876*log10(MHillas.fSize)))");
-
-    matrixg.AddColumn("MNewImagePar.fConc");
-
-    // TEST TEST TEST TEST
-    //    matrixg.AddColumn("MConcentration.Conc7");
-
-    //    matrixg.AddColumn("MNewImagePar.fConc1");
-    //    matrixg.AddColumn("MNewImagePar.fAsym");
-    //    matrixg.AddColumn("MHillasExt.fM3Trans");
-    //    matrixg.AddColumn("abs(MHillasSrc.fHeadTail)");
-
-
-    // We cannot use the 3rd moment with a sign referred to the nominal source position, if we
-    // assume we do not know it a priori. We cannot use either the sign as referred to the 
-    // reconstructed source position through the DISP method, since that method uses precisely 
-    // fM3Long to solve the "head-tail" asimetry and hence all showers would be "gamma-like" from
-    // that point of view. We add however the 3rd moment with no sign to the separation parameters.
-
-    matrixg.AddColumn("abs(MHillasExt.fM3Long)");
-
-    //    matrixg.AddColumn("MHillasSrc.fAlpha");
-
-    TString dummy("(MHillas.fSize<");
-    dummy += minsize;
-
-    // AM TEST
-    dummy += ") || (MNewImagePar.fNumCorePixels<";
-    dummy += mincorepixels;
-
-    // AM, useful FOR High Energy only:
-    //    dummy += ") || (MImagePar.fNumSatPixelsLG>0";
-    dummy += ")";
-
-    MContinue SizeCut(dummy);
-    tlist.AddToList(&SizeCut);
-
-
-    if (skipevents != "")
-    {
-	MContinue SCut(skipevents);
-	tlist.AddToList(&SCut);
-    }
-
-    plist.AddToList(&matrixg);
-
-    MHMatrix matrixh("MatrixHadrons");
-    matrixh.AddColumns(matrixg.GetColumns());
-    plist.AddToList(&matrixh);
-
-    MFEventSelector reduce_training_hadrons;
-    reduce_training_hadrons.SetSelectionRatio(hadron_frac);
-    MFilterList hadfilter;
-    hadfilter.AddToList(&reduce_training_hadrons);
-    hadfilter.AddToList(&fhadrons);
-    tlist.AddToList(&hadfilter);
-
-    MFillH fillmath("MatrixHadrons");
-    fillmath.SetFilter(&hadfilter);
-    tlist.AddToList(&fillmath);
-
-    MContinue skiphad(&fhadrons);
-    tlist.AddToList(&skiphad);
-
-    MFEventSelector reduce_training_gammas;
-    reduce_training_gammas.SetSelectionRatio(gamma_frac);
-    tlist.AddToList(&reduce_training_gammas);
-
-    MFillH fillmatg("MatrixGammas");
-    fillmatg.SetFilter(&reduce_training_gammas);
-    tlist.AddToList(&fillmatg);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    MProgressBar *bar = new MProgressBar;
-    evtloop.SetProgressBar(bar);
-    //
-    // Execute your analysis
-    //
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist.PrintStatistics();
-
-
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-    // second event loop: the trees of the random forest are grown,
-    // the event loop is now actually a tree loop (loop of training
-    // process)
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-
-    MTaskList tlist2;
-    plist.Replace(&tlist2);
-
-    //
-    //    matrixh.ShuffleRows(9999);
-    //    matrixg.ShuffleRows(1111);
-    //
-
-    MRanForestGrow rfgrow2;
-    rfgrow2.SetNumTrees(100);
-    rfgrow2.SetNumTry(3);
-    rfgrow2.SetNdSize(10);
-
-    MWriteRootFile rfwrite2("RF.root");
-    rfwrite2.AddContainer("MRanTree","Tree");       //save all trees
-    MFillH fillh2("MHRanForestGini");
-
-    tlist2.AddToList(&rfgrow2);
-    tlist2.AddToList(&rfwrite2);
-    tlist2.AddToList(&fillh2);
-
-    // gRandom is accessed from MRanForest (-> bootstrap aggregating)
-    // and MRanTree (-> random split selection) and should be initialized
-    // here if you want to set a certain random number generator
-    if(gRandom)
-        delete gRandom;
-    //    gRandom = new TRandom3(0); // Takes seed from the computer clock
-    gRandom = new TRandom3(); // Uses always  same seed
-    //
-    // Execute tree growing (now the eventloop is actually a treeloop)
-    //
-
-    evtloop.SetProgressBar(bar);
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist2.PrintStatistics();
-
-    plist.FindObject("MHRanForestGini")->DrawClone();
-
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-    // third event loop: the control sample (star2.root) is processed
-    // through the previously grown random forest,
-    //
-    // the histograms MHHadronness (quality of g/h-separation) and
-    // MHRanForest are created and displayed.
-    // MHRanForest shows the convergence of the classification error
-    // as function of the number of grown (and combined) trees
-    // and tells the user how many trees are actually needed in later
-    // classification tasks.
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-
-    MTaskList tlist3;
-
-    plist.Replace(&tlist3);
-
-
-    MReadMarsFile  read3("Events", "star_20050110_CrabNebulaW1.root");
-    //    MReadMarsFile  read3("Events", "/data1/magic/mc_data/root/Period021_0.73_mirror/FixedWindowPeakSearch/WOBBLE_Calib_6slices/tc_3.84_2.56/star_gamma_test.root");
-
-    read3.DisableAutoScheme();
-    tlist3.AddToList(&read3);
-    tlist3.AddToList(&SizeCut);
-
-    if (skipevents != "")
-	tlist3.AddToList(&SCut);
-
-    MRanForestCalc calc;
-    tlist3.AddToList(&calc);
-
-
-    TString outfname = "star_S";
-    outfname += minsize;
-    outfname += "_20050110_CrabNebulaW1.root";
-
-    //    outfname += "_mcgammas.root";
-
-    // parameter containers you want to save
-    //
-
-    MWriteRootFile write(outfname, "recreate");
-
-    //    write.AddContainer("MSigmabar", "Events");
-
-    write.AddContainer("MRawEvtHeader",  "Events");
-    write.AddContainer("MMcEvt",         "Events", kFALSE);
-    write.AddContainer("MHillas",        "Events");
-    write.AddContainer("MHillasExt",     "Events");
-    write.AddContainer("MImagePar",      "Events");
-    write.AddContainer("MNewImagePar",   "Events");
-    write.AddContainer("MHillasSrc",     "Events");
-    write.AddContainer("MHadronness",    "Events");
-    write.AddContainer("MPointingPos",   "Events");
-    write.AddContainer("MTime",          "Events", kFALSE);
-    write.AddContainer("MConcentration", "Events", kFALSE);
-
-    tlist3.AddToList(&write);
-
-    evtloop.SetProgressBar(bar);
-
-    //
-    // Execute your analysis
-    //
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist3.PrintStatistics();
-
-    //    bar->DestroyWindow();
-
-    return;
-}
+matrixg.AddColumn("(1.-(MHillas.fWidth/MHillas.fLength))*(0.9776+(0.101062*log10(MHillas.fSize)))");
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/RanForestPD.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/RanForestPD.C	(revision 7136)
+++ 	(revision )
@@ -1,285 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>!
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-#include "MMcEvt.hxx"
-
-void RanForestPD(Int_t minsize=0)
-{
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    MReadMarsFile  read("Events", "star_gamma_train.root");
-    Float_t numgammas = read.GetEntries();
-
-    read.AddFile("star_proton_train.root");
-    read.AddFile("star_helium_train.root");
-
-    Float_t numhadrons = read.GetEntries() - numgammas;
-
-    // Fraction of gammas to be used in training:
-    // (less than total sample, to speed up execution)
-    //
-    Float_t gamma_frac = 2.*(numhadrons / numgammas);
-
-
-    read.DisableAutoScheme();
-
-    tlist.AddToList(&read);
-
-     MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
-    tlist.AddToList(&fhadrons);
-
-    MHMatrix matrixg("MatrixGammas");
-
-    //    matrixg.AddColumn("floor(0.5+(cos(MMcEvt.fTelescopeTheta)/0.01))");
-    //    matrixg.AddColumn("MMcEvt.fTelescopePhi");
-    //    matrixg.AddColumn("MSigmabar.fSigmabar");
-
-    matrixg.AddColumn("MHillas.fSize");
-    matrixg.AddColumn("MHillasSrc.fDist");
-
-    //    matrixg.AddColumn("MHillas.fWidth");
-    //    matrixg.AddColumn("MHillas.fLength");
-
-    // Scaled Width and Length:
-    //
-    matrixg.AddColumn("MHillas.fWidth/(-13.1618+(10.0492*log10(MHillas.fSize)))");   
-    matrixg.AddColumn("MHillas.fLength/(-57.3784+(32.6131*log10(MHillas.fSize)))");
-
-    //    matrixg.AddColumn("(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))");
-    matrixg.AddColumn("MNewImagePar.fConc");
-
-    //    matrixg.AddColumn("MNewImagePar.fConc1");
-    //    matrixg.AddColumn("MNewImagePar.fAsym");
-    //    matrixg.AddColumn("MHillasExt.fM3Trans");
-    //    matrixg.AddColumn("abs(MHillasSrc.fHeadTail)");
-    //    matrixg.AddColumn("MNewImagePar.fLeakage1");
-
-    //
-    // Third moment, with sign referred to source position:
-    //
-    matrixg.AddColumn("MHillasExt.fM3Long*MHillasSrc.fCosDeltaAlpha/abs(MHillasSrc.fCosDeltaAlpha)");
-
-    //#    matrixg.AddColumn("MHillasSrc.fAlpha");
-
-    //
-    // SIZE cut:
-    //
-    TString dummy("(MHillas.fSize<");
-    dummy += minsize;
-    dummy += ")";
-
-    // AM, useful FOR High Energy only:
-    //    dummy += " || (MImagePar.fNumSatPixelsLG>0)";
-
-    MContinue SizeCut(dummy);
-    tlist.AddToList(&SizeCut);
-
-    // AM TEST!!!, no muons in train
-    //    dummy = "(MMcEvt.fMuonCphFraction>0.1)";
-    //    MContinue MuonsCut(dummy);
-    //    tlist.AddToList(&MuonsCut);
-
-    plist.AddToList(&matrixg);
-
-    MHMatrix matrixh("MatrixHadrons");
-    matrixh.AddColumns(matrixg.GetColumns());
-    plist.AddToList(&matrixh);
-
-    MFillH fillmath("MatrixHadrons");
-    fillmath.SetFilter(&fhadrons);
-    tlist.AddToList(&fillmath);
-
-    MContinue skiphad(&fhadrons);
-    tlist.AddToList(&skiphad);
-
-    MFEventSelector reduce_training_gammas;
-    reduce_training_gammas.SetSelectionRatio(gamma_frac);
-    tlist.AddToList(&reduce_training_gammas);
-
-    MFillH fillmatg("MatrixGammas");
-    fillmatg.SetFilter(&reduce_training_gammas);
-    tlist.AddToList(&fillmatg);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    MProgressBar bar;
-    evtloop.SetProgressBar(&bar);
-    //
-    // Execute your analysis
-    //
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist.PrintStatistics();
-
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-    // second event loop: the trees of the random forest are grown,
-    // the event loop is now actually a tree loop (loop of training
-    // process)
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-
-    MTaskList tlist2;
-    plist.Replace(&tlist2);
-
-    MRanForestGrow rfgrow2;
-    rfgrow2.SetNumTrees(100);
-    rfgrow2.SetNumTry(3);
-    rfgrow2.SetNdSize(10);
-
-    MWriteRootFile rfwrite2("RF.root");
-    rfwrite2.AddContainer("MRanTree","Tree");       //save all trees
-    MFillH fillh2("MHRanForestGini");
-
-    tlist2.AddToList(&rfgrow2);
-    tlist2.AddToList(&rfwrite2);
-    tlist2.AddToList(&fillh2);
-
-    // gRandom is accessed from MRanForest (-> bootstrap aggregating)
-    // and MRanTree (-> random split selection) and should be initialized
-    // here if you want to set a certain random number generator
-    if(gRandom)
-        delete gRandom;
-    //    gRandom = new TRandom3(0); // Takes seed from the computer clock
-    gRandom = new TRandom3(); // Uses always  same seed
-    //
-    // Execute tree growing (now the eventloop is actually a treeloop)
-    //
-
-    evtloop.SetProgressBar(&bar);
-
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist2.PrintStatistics();
-
-    plist.FindObject("MHRanForestGini")->DrawClone();
-
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-    // third event loop: the control sample (star2.root) is processed
-    // through the previously grown random forest,
-    //
-    // the histograms MHHadronness (quality of g/h-separation) and
-    // MHRanForest are created and displayed.
-    // MHRanForest shows the convergence of the classification error
-    // as function of the number of grown (and combined) trees
-    // and tells the user how many trees are actually needed in later
-    // classification tasks.
-    // ---------------------------------------------------------------
-    // ---------------------------------------------------------------
-
-    MTaskList tlist3;
-
-    plist.Replace(&tlist3);
-
-    MReadMarsFile  read3("Events", "star_gamma_test.root");
-
-    read3.AddFile("star_proton_test.root");
-    read3.AddFile("star_helium_test.root");
-
-    read3.DisableAutoScheme();
-    tlist3.AddToList(&read3);
-
-    tlist3.AddToList(&SizeCut);
-
-    MRanForestCalc calc;
-    tlist3.AddToList(&calc);
-
-    // parameter containers you want to save
-    //
-
-    TString outfname = "star_S";
-    outfname += minsize;
-    outfname += "_all.root";
-    MWriteRootFile write(outfname, "recreate");
-
-    write.AddContainer("MMcEvt",         "Events");
-    write.AddContainer("MHillas",        "Events");
-    write.AddContainer("MHillasExt",     "Events");
-    write.AddContainer("MImagePar",      "Events");
-    write.AddContainer("MNewImagePar",   "Events");
-    write.AddContainer("MHillasSrc",     "Events");
-    write.AddContainer("MHadronness",    "Events");
-
-    write.AddContainer("MRawRunHeader", "RunHeaders");
-    write.AddContainer("MSrcPosCam",    "RunHeaders");
-    write.AddContainer("MMcRunHeader",  "RunHeaders");
-
-    /*
-    write.AddContainer("MMcTrig",       "Events");
-    write.AddContainer("MRawEvtData",   "Events");
-    write.AddContainer("MRawEvtHeader", "Events");
-    */
-
-
-    MFillH fillh3a("MHHadronness");
-    MFillH fillh3b("MHRanForest");
-
-    tlist3.AddToList(&fillh3a);
-    tlist3.AddToList(&fillh3b);
-
-
-    tlist3.AddToList(&write);
-
-    evtloop.SetProgressBar(&bar);
-
-    //
-    // Execute your analysis
-    //
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist3.PrintStatistics();
-
-    plist.FindObject("MHRanForest")->DrawClone();
-
-    TCanvas *had = new TCanvas;
-    had->cd();
-    plist.FindObject("MHHadronness")->Draw();
-
-    TString gifname = "had_S";
-    gifname += minsize;
-    gifname += ".gif";
-
-    had->SaveAs(gifname);
-    had->Close();
-
-    plist.FindObject("MHHadronness")->DrawClone();
-    plist.FindObject("MHHadronness")->Print();//*/
-
-    return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/area.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/area.C	(revision 7136)
+++ 	(revision )
@@ -1,113 +1,0 @@
-void area(Char_t* infilename = "star_S500_all.root", Float_t maxhadronness = 0.1)
-{
-  //
-  // N_gamma_original: Number of generated Corsika showers in the MC sample 
-  // from which the star file has been produced. VERY IMPORTANT!
-
-  const Double_t N_gamma_original = 3.9e6;
-  const Double_t MC_diff_spectrum = -2.6;
-  const Double_t E_MC_min = 10.;
-  const Double_t E_MC_max = 30000.;
-  const Double_t sizecut = 0.;
-  const Double_t mincorepixels = 5;
-  const Double_t leakagemax = 1.;
-
-  MHMcCollectionArea collarea;
-
-  //
-  // Calculate approximately the original number of events in each 
-  // energy bin:
-  //
-
-  const Double_t expo = 1 + MC_diff_spectrum;
-  const Double_t k = N_gamma_original / 
-    (pow(E_MC_max,expo) - pow(E_MC_min,expo)) ;
-
-  TH2D* hall = collarea.GetHistAll();
-
-  const Int_t nbinx = hall.GetNbinsX();
-
-  TAxis &axe = *hall.GetXaxis();
-  for (Int_t i = 1; i <= nbinx; i++)
-    {
-      const Float_t e1 = axe.GetBinLowEdge(i);
-      const Float_t e2 = axe.GetBinLowEdge(i+1);
-      
-      if (e1 < E_MC_min || e2 > E_MC_max)
-	continue;
-
-      const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
-      //
-      // We fill the i-th energy bin, with the total number of events
-      // Second argument of Fill would be impact parameter of each
-      // event, but we don't really need it for the collection area,
-      // so we just put a dummy value (1.)
-      //
-
-      const Float_t energy = (e1+e2)/2.;
-      hall.Fill(energy, 1., events);
-    }
-
-  //
-  // Now open input file, loop over the Events tree and fill the energy
-  // histogram for events passing all required cuts.
-  //
-
-  TChain chain("Events");
-  chain.Add(infilename);
-
-  MMcEvt *mcevt;
-  MHillas *mhillas;
-  MNewImagePar *mnew;
-  MHadronness *mhadronness;
-
-  chain.SetBranchAddress("MMcEvt.", &mcevt);
-  chain.SetBranchAddress("MHillas.", &mhillas);
-  chain.SetBranchAddress("MNewImagePar.", &mnew);
-  chain.SetBranchAddress("MHadronness.", &mhadronness);
-
-  chain.SetBranchStatus("MMcEvt.", 1);
-  chain.SetBranchStatus("MHillas.", 1);
-  chain.SetBranchStatus("MNewImagePar.", 1);
-  chain.SetBranchStatus("MHadronness.", 1);
-
-  for (Int_t ievt = 0; ievt < chain.GetEntries(); ievt++)
-    {
-      chain.GetEvent(ievt);
-
-      if (mcevt->GetPartId() > 1)
-	continue;
-
-      if (mhillas->GetSize() < sizecut)
-	continue;
-
-      if (mnew->GetNumCorePixels() < mincorepixels)
-	continue;
-
-      if (mnew->GetLeakage1() > leakagemax)
-	continue;
-
-      if (mhadronness->GetHadronness() > maxhadronness)
-      	continue;
-
-      const Float_t energy = mcevt->GetEnergy();
-
-      collarea.FillSel(energy,1.);
-      // Second argument is again just a dummy value
-    }
-
-
-  gStyle->SetOptStat(0);
-  gStyle->SetOptLogy();
-  collarea.CalcEfficiency2();
-  collarea.DrawClone();
-
-  //  infile->Close();
-
-  TFile *out = new TFile("area.root", "recreate");
-  collarea.Write();
-  out->Close();
-
-  return;
-
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/gammarate.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/gammarate.C	(revision 7136)
+++ 	(revision )
@@ -1,69 +1,0 @@
-void gammarate()
-{  
-
-   gROOT->Reset();
-   c1 = new TCanvas("c1","Gamma rate",700,300,500,500);
-   c1->SetGridx();
-   c1->SetGridy();
-   c1->SetLogy(1);
-   c1->SetLogx(1);
- 
-   TFile f("area.root");
-   MHMcCollectionArea* mhmc = (MHMcCollectionArea*)f.Get("MHMcCollectionArea");
-   TH1D* h1 = (TH1D*)mhmc->GetHist();
-   
-    
-   h1->GetXaxis();
-   Float_t xmin = h1->GetXaxis()->GetXmin();
-   Float_t xmax = h1->GetXaxis()->GetXmax();
-   Int_t nbin = h1->GetNbinsX();
-
-   // gamma spectrum:
-   fun1 = new TF1("fun1","10000*2.706e-11*pow(x,-2.47-0.11*log(x))",xmin/1000.,xmax/1000.);
-
-   TH1F *h3f = (TH1F*)h1->Clone("h3f");
-   h3f->SetTitle("Integrale per bin");
-   h3f->Reset();
-   h3f->SetMinimum(1.e-13);
-   h3f->SetMaximum(1.e-7);
-
-   TH1F *h4f = (TH1F*)h1->Clone("h4f");
-
-   h4f->SetTitle("Rate");
-   h4f->Reset();
-   h4f->SetMinimum(1.e-4);
-   h4f->SetMaximum(1.e-1);
-
-
-   Float_t Error = 0.;
-
-   cout << "Bin\tArea\tCenter\tFlux\t\tMolt\tInt\tRate"<<endl; 
-   for (Int_t i = 1; i <= nbin; i++)
-   {     
-     //area->GetXaxis()->FindBin(i)
-     Float_t valArea = h1->GetBinContent(i);      
-     Float_t bincenter = h1->GetBinCenter(i);
-     Float_t valFlusso = fun1->Eval(bincenter/1000., 0., 0.);
-     Float_t Integral = fun1->Integral(h1->GetBinLowEdge(i)/1000.,h1->GetBinLowEdge(i+1)/1000.);
-     h3f->SetBinContent(i,Integral);
-     Float_t Rate = Integral * valArea;
-     Float_t ErArea = h1->GetBinError(i);
-     Float_t ErRate = ErArea * Integral;
-     Error += ErRate*ErRate;
-     h4f->SetBinContent(i,Rate);
-     h4f->SetBinError(i,ErRate);
-     cout << i << "\t" << bincenter << "\t" << Rate << "\t"<< endl;
-    }
-   //h1->DrawCopy(); 
-   //h3f->DrawCopy();
-   h4f->SetStats(kFALSE);
-   h4f->SetTitle("Gamma rate vs energy");
-   h4f->GetYaxis()->SetTitle("Rate");
-   h4f->DrawCopy("pe");
-
-   cout << "Rate (Hz):" << h4f->Integral(0,100)<< " +- " <<pow(Error, .5)<<endl;
-
-   h4f->Delete();
-   h3f->Delete();
-   h1->Delete();
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/plotnoise.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/plotnoise.C	(revision 7136)
+++ 	(revision )
@@ -1,55 +1,0 @@
-void plotnoise()
-{
-  // Simple macro to read calibrated pedestal files, from MC and real data, and compare 
-  // fluctuations
-
-  gStyle->SetOptStat(kFALSE);
-
-  TChain mc("Events");
-  TChain data("Events");
-
-  // Input files: MC and data files containing calibrated pedestal data, in the form 
-  // of MCerPhotEvt containers (as produced by mccalibrate.C)
-
-  mc.Add("/data1/MAGIC/Period016/mcdata/noise/root/electronic_noise.root");
-  data.Add("/data1/MAGIC/Period014/rootdata/2004_03_03/calibrated_20122.root");
-
-  // Warning! Binnings have to be set somehow manually to get 
-  // nice display... (due to rounding problems...)
-
-  TH1F* hinnermc = new TH1F("hinnermc","Noise inner",1001, -200.5, 200.5);
-  TH1F* hinnerdata = new TH1F("hinnerdata","Noise inner",500, -200.5, 200.5);
-
-  TH1F* houtermc = new TH1F("houtermc","Noise outer",601, -300.5, 300.5);
-  TH1F* houterdata = new TH1F("houterdata","Noise outer",100, -300.5, 300.5);
-
-  hinnermc->Sumw2();
-  hinnerdata->Sumw2();
-  houtermc->Sumw2();
-  houterdata->Sumw2();
-
-  // The normalizations of y axis (multiplicative factors in 3rd argument of Project) 
-  // are for now introduced manually:
-
-  mc.Project("hinnermc", "MCerPhotEvt.fPixels.fPhot", "0.77*(MCerPhotEvt.fPixels.fPixId<397 && MCerPhotEvt.fPixels.fPixId>0 )");
-
-  data.Project("hinnerdata", "MCerPhotEvt.fPixels.fPhot", "(MCerPhotEvt.fPixels.fPixId<397 && MCerPhotEvt.fPixels.fPixId>0 )");
-
-
-  // Same for outer pixels:
-  //  mc.Project("houtermc", "MCerPhotEvt.fPixels.fPhot", "1.26*(MCerPhotEvt.fPixels.fPixId>=397)");
-  //    data.Project("houterdata", "MCerPhotEvt.fPixels.fPhot", "(MCerPhotEvt.fPixels.fPixId>=397)");
-
-  hinnerdata->DrawCopy("e");
-  hinnermc->SetLineColor(2);
-  hinnermc->SetMarkerColor(2);
-  hinnermc->DrawCopy("e,same");
-
-  //     houterdata->DrawCopy("e");
-  //     houtermc->SetLineColor(2);
-  //     houtermc->SetMarkerColor(2);
-  //     houtermc->DrawCopy("e,same");
-
-
-  return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/resize.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/resize.C	(revision 7136)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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.
-! *
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-
-void resize()
-{
-  MParList plist;
-  MTaskList tlist;
-
-  plist.AddToList(&tlist);
-
-  MReadMarsFile  read("Events", "star_gamma_train.root");
-
-  read.DisableAutoScheme();
-  tlist.AddToList(&read);
-
-  MWriteRootFile write("star_gamma_train_new.root", "recreate");
-
-  write.AddContainer("MRawEvtHeader",  "Events");
-  write.AddContainer("MMcEvt",         "Events");
-  write.AddContainer("MHillas",        "Events");
-  write.AddContainer("MHillasExt",     "Events");
-  write.AddContainer("MImagePar",      "Events");
-  write.AddContainer("MNewImagePar",   "Events");
-  write.AddContainer("MHillasSrc",     "Events");
-  write.AddContainer("MSrcPosCam",     "Events", kFALSE);
-  write.AddContainer("MConcentration", "Events", kFALSE);
-  write.AddContainer("MPointingPos",   "Events", kFALSE);
-
-
-  write.AddContainer("MGeomCam",            "RunHeaders");
-  write.AddContainer("MMcConfigRunHeader",  "RunHeaders");
-  write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
-  write.AddContainer("MMcFadcHeader",       "RunHeaders");
-  write.AddContainer("MMcTrigHeader",       "RunHeaders");
-
-  write.AddContainer("MRawRunHeader",       "RunHeaders");
-  write.AddContainer("MMcRunHeader",        "RunHeaders");
-
-  //
-  // Histogram: event acceptance probability vs log10(Size). Binning
-  // and range are completely free. Beyond the histogram limits all 
-  // events are accepted
-  //
-
-  Float_t frac[20] = {0.180451,  0.236564,  0.253332,  0.282566,  0.355083,  
- 		      0.424058,  0.566892,  0.657478,  0.753713,  0.738402,  
- 		      0.789239,  0.762777,  0.857609,  0.833747,  0.923706,  
- 		      1.04348,   0.978622,  0.875537,  0.971831,  1.};
-
-
-  // For MC calibrated in photons:
-  //  TH1F hist("probability", "", 20, 2., 4.);
-
-  // For MC calibrated in phe-:
-  TH1F hist("probability", "", 20, 1.2552725, 3.2552725);
-
-  hist.SetXTitle("log10(MHillas.fSize)");
-  for (Int_t i = 0; i < 20; i++)
-    hist.SetBinContent(i+1, frac[i]);
-
-  MH3 mh(hist);
-  MFEventSelector2 fsize(mh);
-  fsize.SetHistIsProbability(kTRUE);
-
-  write.SetFilter(&fsize);
-
-  tlist.AddToList(&fsize);
-  tlist.AddToList(&write);
-
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-
-  MProgressBar *bar = new MProgressBar;
-  evtloop.SetProgressBar(bar);
-
-  //
-  // Execute your analysis
-  //
-  if (!evtloop.Eventloop())
-    return;
-
-  tlist.PrintStatistics();
-
-  bar->DestroyWindow();
-
-  return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/trainsubsample.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/trainsubsample.C	(revision 7136)
+++ 	(revision )
@@ -1,104 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Abelardo Moralejo 1/2005 <mailto:moralejo@pd.infn.it>!
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-! 
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////////////////
-//
-// Macro trainsubsample.C
-//
-// Reads a star file from real data, and makes a subsample of it, adding a "fake" 
-// MMcEvt container with MMcEvt.fPartId=14. This intended to produce, from real data,
-// a "hadron training file" to be used in random forest (or other) g/h separation. The 
-// MMcEvt container is added so that whatever the method will consider these (real) 
-// showers to be all protons (before cuts, most will be, even in the case of strong 
-// source as Crab).
-//
-/////////////////////////////////////////////////////////////////////////////////////
-
-void trainsubsample()
-{
-  MParList plist;
-  MTaskList tlist;
-
-  plist.AddToList(&tlist);
-
-  MReadMarsFile  read("Events", "star_20040918_CrabNebulaW2.root");
-
-  MFEventSelector evsel;
-
-  Float_t nevents = 50000;   // Number of events to select. 
-  Float_t ratio = nevents / (Float_t) read.GetEntries();
-
-  evsel.SetSelectionRatio(ratio); // Fraction of events in output
-
-  read.DisableAutoScheme();
-  tlist.AddToList(&read);
-
-  MMcEvt* mcevt = new MMcEvt;
-  mcevt->SetPartId(14);
-  plist.AddToList(mcevt);
-
-  MWriteRootFile write("star_train_20040918_CrabNebulaW2.root", "recreate");
-
-  write.AddContainer("MMcEvt",         "Events", kFALSE);
-  write.AddContainer("MHillas",        "Events");
-  write.AddContainer("MHillasExt",     "Events");
-  write.AddContainer("MImagePar",      "Events");
-  write.AddContainer("MNewImagePar",   "Events");
-  write.AddContainer("MHillasSrc",     "Events");
-  write.AddContainer("MSrcPosCam",     "Events");
-  write.AddContainer("MConcentration", "Events", kFALSE);
-  write.AddContainer("MPointingPos",   "Events", kFALSE);
-
-
-  write.AddContainer("MGeomCam",            "RunHeaders", kFALSE);
-  write.AddContainer("MMcConfigRunHeader",  "RunHeaders", kFALSE);
-  write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
-  write.AddContainer("MMcFadcHeader",       "RunHeaders", kFALSE);
-  write.AddContainer("MMcTrigHeader",       "RunHeaders", kFALSE);
-
-  write.AddContainer("MRawRunHeader",       "RunHeaders");
-  write.AddContainer("MMcRunHeader",        "RunHeaders", kFALSE);
-
-  write.SetFilter(&evsel);
-
-  tlist.AddToList(&evsel);
-  tlist.AddToList(&write);
-
-  MEvtLoop evtloop;
-  evtloop.SetParList(&plist);
-
-  MProgressBar *bar = new MProgressBar;
-  evtloop.SetProgressBar(bar);
-
-  //
-  // Execute your analysis
-  //
-  if (!evtloop.Eventloop())
-    return;
-
-  tlist.PrintStatistics();
-
-  bar->DestroyWindow();
-
-  return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mpadova/macros/wobblemap.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpadova/macros/wobblemap.C	(revision 7136)
+++ 	(revision )
@@ -1,982 +1,0 @@
-void wobblemap(Float_t maxhadronness = 0.15, Float_t minsize=2000., Float_t maxsize = 1.e10)
-{
-
-  //// CHANGE NAME OF FILE TO NOT OVERWRITE FORMER FILES!!! ////////
-  TString outname = "Hists_";
-  if (maxsize > 1.e6)
-      outname += "above";
-
-  outname += Form("%4d", (Int_t)minsize);
-
-  if (maxsize < 1.e6)
-    {
-      outname += "to";
-      outname += Form("%4d", (Int_t)maxsize);
-    }
-
-  outname += "_had";
-
-  TString dummy = Form("%3.2f", (Double_t)maxhadronness); // cast is necessary!!
-  outname += dummy;
-  outname += ".root";
-
-  cout << outname << endl;
-
-  TFile* hfile = new TFile(outname,"recreate");
-
-  MGeomCamMagic mgeom;
-  Double_t mm2deg = mgeom.GetConvMm2Deg();
-
-  Double_t CrabDec = 22.014444444; // deg
-  Double_t CrabRA  = 5.5755555555; // hours
-
-//   Double_t CrabDec = 19.8197221; // deg
-//   Double_t CrabRA  = 8.895194; // hours  // FALSE source for the 3EG0853 data!
-
-  Float_t onregion_radius = 0.25; // degree
-  Float_t onr2 = onregion_radius * onregion_radius; // deg2
-  Float_t datatime = 0.;
-
-  // CHANGE MC PARAMETERS AND FILE BELOW ACCORDING TO STUDIED DATA SETS!!!!
-  // Period 025:
-//    TString spotsize = "2.0cm";
-//    Float_t minMCtheta = 5.73;   // lower edge of zbin 1
-//    Float_t maxMCtheta = 23.79;  // upper edge of zbin 8
-//    Float_t n_gamma_produced = 1.e5 * 8. * 6. / 2.; 
-  // #Events per file * #zbins * #files per zbin / 2 (test sample only)
-
-  // YOU ALSO HAVE TO CHANGE THE SCALING OF W, L AND THE EXPRESSION FOR DISP!
-
-  // Period 021
-  TString spotsize = "1.4cm";
-  Float_t minMCtheta = 15.20;   // lower edge of zbin 4
-  Float_t maxMCtheta = 28.96;   // upper edge of zbin 12
-  Float_t n_gamma_produced = 1.e5 * 9. * 6. / 2.; 
-  // #Events per file * #zbins * #files per zbin / 2 (test sample only)
-
-
-
-  TChain *MCchain = new TChain("Events");
-  //  MCchain->Add("/data2/magic/data/rootdata/Crab/Period025/2005_01_10/RandomForest_1.0_spot/star_S1000_mcgammas.root");
-
-  if (spotsize == "1.4cm")
-    MCchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_15/RandomForest_1.4_spot/star_S1000_mcgammas.root");
-  else if (spotsize == "2.0cm")
-    MCchain->Add("/data2/magic/data/rootdata/Crab/Period025/2005_01_10/RandomForest_2.0_spot/star_S1000_mcgammas.root");
-
-  //////////////////////////////////////////////////////////////////////////////////////////////////
-
-  TChain *Wchain = new TChain("Events");
-
-  Wchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_15/RandomForest_1.4_spot/star_S1000_20040915_CrabNebulaW1.root");
-  datatime += 1062.3;
-
-  Wchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_24/RandomForest_1.4_spot/star_S1000_20040924_CrabNebulaW1.root");
-  datatime += 1316.2;
-
-  Wchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_15/RandomForest_1.4_spot/star_S1000_20040915_CrabNebulaW2.root");
-  datatime += 1241.1;
-
-  Wchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_18/RandomForest_1.4_spot/star_S1000_20040918_CrabNebulaW2.root");
-  datatime += 1388.1;
-
-  Wchain->Add("/data2/magic/data/rootdata/Crab/Period021/2004_09_24/RandomForest_1.4_spot/star_S1000_20040924_CrabNebulaW2.root");
-  datatime += 767.0;
-
-
-//   Wchain->Add("/data2/magic/data/rootdata/Crab/Period025/2005_01_10/RandomForest_2.0_spot/star_S1000_20050110_CrabNebulaW1.root");
-//   datatime += 9469.7;
-  
-//   Wchain->Add("/data2/magic/data/rootdata/Crab/Period025/2005_01_11/RandomForest_2.0_spot/star_S1000_20050111_CrabNebulaW1.root");
-//   datatime += 4400.1;
-
-//   Wchain->Add("/data2/magic/data/rootdata/Crab/Period025/2005_01_11/RandomForest_2.0_spot/star_S1000_20050111_CrabNebulaW2.root");
-//   datatime += 4673.1;
-
-
-  // November data: WE SKIP THEM, they are very few!
-  //   Wchain->Add("/data2/magic/data/rootdata/Crab/Period023/2004_11_23/RandomForest_1.0_spot/star_S1000_20041123_CrabNebulaW1.root");
-  //   datatime += 394.2;
-  //   Wchain->Add("/data2/magic/data/rootdata/Crab/Period023/2004_11_23/RandomForest_1.0_spot/star_S1000_20041123_CrabNebulaW2.root");
-  //   datatime += 0.0;  // No data with theta below 28.96 deg!
-
-   
-//   Wchain->Add("/data2/magic/data/rootdata/3EG0853/Period024/2004_12_10/RandomForest_2.0_spot/star_S1000_20041210_3EG0853.root");
-//   datatime += 4487.9;
-
-
- 
-  TH2F *CamMap = new TH2F("CamMap", "Events incoming direction map ",
-			    50, -2.5, 2.5,50, -2.5, 2.5);
-
-
-  TH2F *SkyMap = new TH2F("SkyMap", "Events incoming direction map ",
-			  70, CrabRA-0.175, CrabRA+0.175, 
-			  70, CrabDec-2.8315, CrabDec+2.8315);
-
-  TH2F *ONandOFF = new TH2F("ONandOFF", "ON and OFF regions",
-			    140, CrabRA-0.175, CrabRA+0.175, 
-			    140, CrabDec-2.8315, CrabDec+2.8315);
-
-  ////////////// BACKGROUND MODEL: //////////////////////////////////////////////////
-
-  // Radial distribution, dN/dr with trespect to camera center:
-  // SIZE > 2000
-  TF1* myfunc = new TF1("myfunc","x*([0]+[1]*log(x)+[2]*log(x)*log(x))", 0., 2.);
-  myfunc->SetParameters(2.06765e+02, -2.36253e+02, -2.13230e+01);
-
-  // SIZE 1000-2000
-  // TF1* myfunc = new TF1("myfunc","x*([0]+[1]*log(x)+[2]*log(x)*log(x)+[3]*log(x)**4)", 0., 2.);
-  // myfunc->SetParameters(6.45011e+02, -1.01606e+03, 1.63394e+02, -3.60749e+01);
-
-  TH1F *rndmrad = new TH1F("rndmrad","",200, 0., 2.);
-  rndmrad->FillRandom("myfunc",1e6);
-  rndmrad->Draw("e");
-
-  TH2F *BgMap = (TH2F*) SkyMap->Clone("BgMap");
-  TRandom dice;
-
-  ///////////////////////////////////////////////////////////////////////////////////
-
-
-  TH1F *Alpha = new TH1F("Alpha", "", 60, -90., 90.);
-  TH1F *AbsAlpha = new TH1F("AbsAlpha", "", 45, 0., 90.);
-
-  TH1F *WidthOn = new TH1F("WidthOn", "WIDTH", 120, 0., 0.60);
-  TH1F *WidthOff  = (TH1F*) WidthOn->Clone("WidthOff");
-  WidthOn->Sumw2();
-  WidthOff->Sumw2();
-
-  TH1F *LengthOn = new TH1F("LengthOn", "LENGTH", 50, 0., 1.);
-  TH1F *LengthOff  = (TH1F*) LengthOn->Clone("LengthOff");
-  LengthOn->Sumw2();
-  LengthOff->Sumw2();
-
-  TH1F *SWidthOn = new TH1F("SWidthOn", "SWIDTH", 75, 0.3, 5.3);
-  TH1F *SWidthOff  = (TH1F*) SWidthOn->Clone("SWidthOff");
-  SWidthOn->Sumw2();
-  SWidthOff->Sumw2();
-
-  TH1F *SLengthOn = new TH1F("SLengthOn", "SLENGTH", 45, 0.2, 3.2);
-  TH1F *SLengthOff  = (TH1F*) SLengthOn->Clone("SLengthOff");
-  SLengthOn->Sumw2();
-  SLengthOff->Sumw2();
-
-  TH1F *ConcOn = new TH1F("ConcOn", "CONC", 30, 0., 0.6);
-  TH1F *ConcOff  = (TH1F*) ConcOn->Clone("ConcOff");
-  ConcOn->Sumw2();
-  ConcOff->Sumw2();
-
-  TH1F *M3LongOn = new TH1F("M3LongOn", "M3LONG", 80, -0.8, 0.8);
-  TH1F *M3LongOff  = (TH1F*) M3LongOn->Clone("M3LongOff");
-  M3LongOn->Sumw2();
-  M3LongOff->Sumw2();
-
-  TH1F *DistOn = new TH1F("DistOn", "DIST", 40, 0., 2.);
-  TH1F *DistOff  = (TH1F*) DistOn->Clone("DistOff");
-  DistOn->Sumw2();
-  DistOff->Sumw2();
-
-  TH1F *SizeOn = new TH1F("SizeOn", "LOG10SIZE", 60, 2.5, 5.5);
-  TH1F *SizeOff  = (TH1F*) SizeOn->Clone("SizeOff");
-  SizeOn->Sumw2();
-  SizeOff->Sumw2();
-
-
-  TH1F *HadronnessOn = new TH1F("HadronnessOn", "Hadronness", 101, 0., 1.01);
-  TH1F *HadronnessOff = (TH1F*) HadronnessOn->Clone("HadronnessOff");
-  HadronnessOn->Sumw2();
-  HadronnessOff->Sumw2();
-
-  TH1F* r_source = new TH1F("r_source", "r_source", 50, 0., 2.5);
-
-
-  // Now the MC histograms:
-
-  TH1F *AlphaMC = (TH1F*) Alpha->Clone("AlphaMC");
-  TH1F *AbsAlphaMC = (TH1F*) AbsAlpha->Clone("AbsAlphaMC");
-  TH1F *WidthMC = (TH1F*) WidthOn->Clone("WidthMC");
-  TH1F *LengthMC  = (TH1F*) LengthOn->Clone("LengthMC");
-  TH1F *SWidthMC  = (TH1F*) SWidthOn->Clone("SWidthMC");
-  TH1F *SLengthMC  = (TH1F*) SLengthOn->Clone("SLengthMC");
-  
-  TH1F *ConcMC  = (TH1F*) ConcOn->Clone("ConcMC");
-  TH1F *M3LongMC = (TH1F*) M3LongOn->Clone("M3LongMC");
-  TH1F *M3LongMC_all = (TH1F*) M3LongOn->Clone("M3LongMC_all");
-  TH1F *DistMC  = (TH1F*) DistOn->Clone("DistMC");
-  TH1F *SizeMC  = (TH1F*) SizeOn->Clone("SizeMC");
-
-
-  TH1F *HadronnessMC = (TH1F*) HadronnessOn->Clone("HadronnessMC");
-
-  TH1F *EnergyMC = new TH1F("EnergyMC", "MC, log_{10}E_{\gamma} (GeV)", 1000, 0., 2000.);
-  EnergyMC->Sumw2();
-
-  ////////////////////////////////////////////////////////////////
-
-  MObservatory mobserv;
-  MStarCamTrans* starcamtrans = new MStarCamTrans(mgeom, mobserv);
-
-
-  MHillas *mhil = new MHillas();
-  MHillasSrc *msrc = new MHillasSrc();
-  MHillasExt *mhilext = new MHillasExt();
-  MNewImagePar *mnew = new MNewImagePar();
-  MPointingPos *mpoint = new MPointingPos();
-  MHadronness  *mhad = new MHadronness();
-  MPointingPos *mpoint = new MPointingPos();
-  MTime        *mtime  = new MTime();
-
-  Wchain->SetBranchStatus("*", 0);
-  Wchain->SetBranchStatus("MHillas.fSize", 1);
-  Wchain->SetBranchStatus("MHillas.fWidth", 1);
-  Wchain->SetBranchStatus("MHillas.fLength", 1);
-  Wchain->SetBranchStatus("MHillas.fMeanX", 1);
-  Wchain->SetBranchStatus("MHillas.fMeanY", 1);
-  Wchain->SetBranchStatus("MHillas.fCosDelta", 1);
-  Wchain->SetBranchStatus("MHillas.fSinDelta", 1);
-  Wchain->SetBranchStatus("MHillasSrc.fCosDeltaAlpha", 1);
-  Wchain->SetBranchStatus("MHillasExt.fM3Long", 1);
-  Wchain->SetBranchStatus("MNewImagePar.fNumCorePixels", 1);
-  Wchain->SetBranchStatus("MNewImagePar.fConc", 1);
-  Wchain->SetBranchStatus("MPointingPos.fZd",1);
-  Wchain->SetBranchStatus("MHadronness.fHadronness",1);
-  Wchain->SetBranchStatus("MPointingPos.fDec",1);
-  Wchain->SetBranchStatus("MPointingPos.fRa",1);
-  Wchain->SetBranchStatus("MTime.*",1);
-  Wchain->SetBranchStatus("MHillasSrc.fDist",1);
-
-  Wchain->SetBranchAddress("MHillas.",      &mhil);
-  Wchain->SetBranchAddress("MHillasSrc.",   &msrc);
-  Wchain->SetBranchAddress("MHillasExt.",   &mhilext);
-  Wchain->SetBranchAddress("MNewImagePar.", &mnew);
-  Wchain->SetBranchAddress("MPointingPos.", &mpoint);
-  Wchain->SetBranchAddress("MHadronness.",  &mhad);
-  Wchain->SetBranchAddress("MTime.",        &mtime);
-
-
-  for (Int_t i = 0; i < Wchain->GetEntries(); i++) // event count starts in 0
-    {
-      if ((i+1)%10000 == 0)
-	cout << i+1 << " of " << Wchain->GetEntries() << endl;
-
-      Wchain->GetEvent(i);
-
-      Float_t size = mhil->GetSize();
-
-      if (size < minsize)
-	continue;
-      else if (size > maxsize)
-	continue;
-
-      Float_t log10size = log10(size);
-
-      Float_t ZA = mpoint.GetZd();
-      // Exclude events with no drive info. For Crab ZAmin = 6.8
-      if (ZA < minMCtheta)
-	continue;
-      else if (ZA > maxMCtheta)
-	continue;   // MC up to ~29 deg loaded, but data may have lower upper end!
-
-
-      Float_t width  = mhil->GetWidth()* mm2deg;;
-      Float_t length = mhil->GetLength()* mm2deg;;
-
-
-      Float_t disp;
-
-      // spot 1 cm:
-      //      Float_t disp   = (1.-(width/length))*(2.68576-0.830937*log10size+0.1227*log10size*log10size);
-
-
-      if (spotsize == "1.4cm")
-	disp   = (1.-(width/length))*(3.64292-1.28713*log10size+0.179722*log10size*log10size);
-
-      else if (spotsize == "2.0cm")
-	disp   = (1.-(width/length))*(4.11949-1.39848*log10size+0.183514*log10size*log10size);
-
-
-      Float_t xmean = mhil->GetMeanX()* mm2deg;;
-      Float_t ymean = mhil->GetMeanY()* mm2deg;;
-
-      Float_t cosdelta = mhil->GetCosDelta();
-      Float_t sindelta = mhil->GetSinDelta();
-
-      Float_t asylon = mhilext->GetM3Long();
-
-
-      Double_t sourcex, sourcey;
-
-      // Choose right orientation:
-
-      if (asylon < 0.)
-      	{
-	  sourcex = xmean+cosdelta*disp;
-	  sourcey = ymean+sindelta*disp;
- 	}
-       else
- 	{
- 	  sourcex = xmean-cosdelta*disp;
- 	  sourcey = ymean-sindelta*disp;
- 	}
-
-      Double_t SourceDec = 0;
-      Double_t SourceRA  = 0.;
-      Double_t SourceHA  = 0.;
-
-      Double_t CenterDec = mpoint->GetDec();
-      Double_t CenterRA  = mpoint->GetRa();
-
-      Double_t gmst = mtime->GetGmst(); // Greenwich mean sidereal time [rad]
-
-      gmst *= 24. / (2.*TMath::Pi()); // Conversion to hours
-
-      Double_t Wlongitude = -1. * mobserv.GetLongitudeDeg()/15.; // h
-      // Warning: GetLongitude return is positive if location is E of Greenwich!!
-      Double_t lst =  gmst - Wlongitude; // Local sidereal time [h]
-
-      Double_t CenterHA = lst - CenterRA;
-
-      if (CenterHA < 0.)
-	CenterHA += 24.;
-      else if (CenterHA > 24.)
-	CenterHA -= 24.;
-      // Hour angle of center of camera [h]
-
-
-      // Find Sky coordinates of reconstructed direction:
-
-      starcamtrans->Cel0CamToCel(CenterDec, CenterHA, sourcex/mm2deg, 
-				 sourcey/mm2deg, SourceDec, SourceHA);
-      SourceRA = lst - SourceHA; // Estimated source RA [h]
-      if (SourceRA < 0.)
-	SourceRA += 24.;
-      else if (SourceRA > 24.)
-	SourceRA -= 24.;
-
-
-      // Generate background
-
-      Float_t r = rndmrad->GetRandom();
-      Float_t phi = 2.*TMath::Pi()*dice.Rndm();
-      Float_t xbg = r * cos(phi);
-      Float_t ybg = r * sin(phi);
-      Double_t BGDec = 0.;
-      Double_t BGHA = 0.;
-      Double_t BGRA = 0.;
-      // Sky coordinates:
-      starcamtrans->Cel0CamToCel(CenterDec, CenterHA, xbg/mm2deg, ybg/mm2deg, BGDec, BGHA);
-      BGRA = lst - BGHA; // Estimated source RA [h]
-      if (BGRA < 0.)
-	BGRA += 24.;
-      else if (BGRA > 24.)
-	BGRA -= 24.;
-
-
-      // Now calculate Alpha with respect to true Crab position
-
-      Double_t CrabHA = lst - CrabRA;
-      if (CrabHA > 24.)
-	CrabHA -= 24.;
-      else if (CrabHA < 0.)
-	CrabHA += 24.;
-      
-      Double_t xcrab, ycrab; // mm
-
-      starcamtrans->Cel0CelToCam(CenterDec, CenterHA, CrabDec, CrabHA, 
-				 xcrab, ycrab);
-
-      xcrab *= mm2deg;
-      ycrab *= mm2deg; // Convert to deg
-
-      // Calculate Alpha relative to Crab:
-
-      Float_t scalar = ((xmean-xcrab)*cosdelta + (ymean-ycrab)*sindelta) /
-	sqrt( pow(xmean-xcrab, 2.) + pow(ymean-ycrab, 2.) );
-
-      Float_t alpha = 180./TMath::Pi()*acos(scalar);
-
-      if (alpha > 90.)
-	alpha -= 180.;
-
-
-      // Hadronness cut
-
-      Float_t hadronness = mhad->GetHadronness();
-      if (hadronness > maxhadronness)
-	continue;
-
-      // WARNING!: If scaling is changed, do it also in the MC part !!
-
-//       Float_t swidth  = width/(-0.028235+(0.03231*log10size));
-//       Float_t slength = length/(-0.13527+(0.09876*log10size));
-
-// Spot 1 cm:
-//      Float_t swidth  = width/(-0.0332763+(0.0320227*log10size));
-//      Float_t slength = length/(-0.174697+(0.107548*log10size));
-
-      Float_t swidth, slength;
-
-      if (spotsize == "1.4cm")
-	{
-	  swidth  = width/(-0.0308984+(0.0327119*log10size));
-	  slength = length/(-0.181605+(0.109609*log10size));
-	}
-      else if (spotsize == "2.0cm")
-	{
-	  Float_t swidth  = width/(-0.0279008+(0.0344538*log10size));
-	  Float_t slength = length/(-0.186394+(0.111055*log10size));
-	}
-
-      Float_t conc = mnew->GetConc();
-      Float_t dist = msrc->GetDist()*mm2deg;
-
-
-      Float_t crab_from_center = sqrt(xcrab*xcrab+ycrab*ycrab);
-      Float_t source_from_center = sqrt(sourcex*sourcex+sourcey*sourcey);
-      // Skip events reconstructed further than 2 deg from center:
-
-      if (source_from_center > 2.)
-	continue;
-
-      // Fill histograms
-
-      CamMap->Fill(sourcex, sourcey);
-      SkyMap->Fill(SourceRA, SourceDec);
-
-      BgMap->Fill(BGRA, BGDec);
-
-
-      // Fill histogram of distance from reconstructed source position to camera
-      // center, but exclude the quadrant where the candidate source is.... (dirty trick)
-
-      if ( (xcrab*sourcex+ycrab*sourcey)/
-	   source_from_center / crab_from_center < 0.707) // cos 45 deg
-	r_source->Fill(source_from_center);
-
-
-      // ON region
-      
-      Float_t ondist2 = (sourcex-xcrab)*(sourcex-xcrab) + 
-	(sourcey-ycrab)*(sourcey-ycrab);
-
-      Float_t offdist2_a = (sourcex+xcrab)*(sourcex+xcrab) + 
-	(sourcey+ycrab)*(sourcey+ycrab);
-      Float_t offdist2_b = (sourcex-ycrab)*(sourcex-ycrab) + 
-	(sourcey+xcrab)*(sourcey+xcrab);
-      Float_t offdist2_c = (sourcex+ycrab)*(sourcex+ycrab) + 
-	(sourcey-xcrab)*(sourcey-xcrab);
-
-
-      if (ondist2 < onr2)
-	{
-	  WidthOn->Fill(width);
-	  LengthOn->Fill(length);
-	  SWidthOn->Fill(swidth);
-	  SLengthOn->Fill(slength);
-	  ConcOn->Fill(conc);
-	  DistOn->Fill(dist);
-
-
-	  // 3rd moment with sign referred to source position:
-
-	  //      Float_t m3long = asylon * TMath::Sign(1., msrc->GetCosDeltaAlpha()) * mm2deg;
-	  Float_t m3long = asylon * TMath::Sign(1., xmean-xcrab) * mm2deg;
-
-	  M3LongOn->Fill(m3long);
-	  SizeOn->Fill(log10size);
-
-	  HadronnessOn->Fill(hadronness);
-	  ONandOFF->Fill(SourceRA, SourceDec);
-	}
-
-      if (offdist2_a < onr2 || offdist2_b < onr2 || offdist2_c < onr2)
-	{
-	  WidthOff->Fill(width, 1./3.);
-	  LengthOff->Fill(length, 1./3.);
-	  SWidthOff->Fill(swidth, 1./3.);
-	  SLengthOff->Fill(slength, 1./3.);
-	  ConcOff->Fill(conc, 1./3.);
-	  SizeOff->Fill(log10size, 1./3.);
-
-	  HadronnessOff->Fill(hadronness, 1./3.);
-	  ONandOFF->Fill(SourceRA, SourceDec);
-
-	  if (offdist2_a < onr2)
-	    {
-	      DistOff->Fill(sqrt((xmean+xcrab)*(xmean+xcrab)+(ymean+ycrab)*(ymean+ycrab)), 1./3.);
-
-	      m3long = asylon * TMath::Sign(1.,xmean+xcrab) * mm2deg;
-	      M3LongOff->Fill(m3long, 1./3.);
-	    }
-	  else if (offdist2_b < onr2)
-	    {
-	      DistOff->Fill(sqrt((xmean-ycrab)*(xmean-ycrab)+(ymean+xcrab)*(ymean+xcrab)), 1./3.);
-
-	      m3long = asylon * TMath::Sign(1.,xmean-ycrab) * mm2deg;
-	      M3LongOff->Fill(m3long, 1./3.);
-	    }
-
-	  else if (offdist2_c < onr2)
-	    {
-	      DistOff->Fill(sqrt((xmean+ycrab)*(xmean+ycrab)+(ymean-xcrab)*(ymean-xcrab)), 1./3.);
-
-	      m3long = asylon * TMath::Sign(1.,xmean+ycrab) * mm2deg;
-	      M3LongOff->Fill(m3long, 1./3.);
-	    }
-	}
-
-
-      // Very rough cut on 3rd moment related to Crab position:
-      // (only for alpha plot)
-
-      if ( (asylon < 0. && xcrab < xmean) ||
-	   (asylon > 0. && xcrab > xmean) )
-	continue;
-
-      Alpha->Fill(alpha);
-      AbsAlpha->Fill(abs(alpha));
-
-    }
-
-  // Convert y-axis units to Hz
-
-  WidthOn->Scale(1./datatime);
-  LengthOn->Scale(1./datatime);
-  SWidthOn->Scale(1./datatime);
-  ConcOn->Scale(1./datatime);
-  DistOn->Scale(1./datatime);
-  M3LongOn->Scale(1./datatime);
-  SizeOn->Scale(1./datatime);
-  SLengthOn->Scale(1./datatime);
-  HadronnessOn->Scale(1./datatime);
-
-  WidthOff->Scale(1./datatime);
-  LengthOff->Scale(1./datatime);
-  SWidthOff->Scale(1./datatime);
-  ConcOff->Scale(1./datatime);
-  DistOff->Scale(1./datatime);
-  M3LongOff->Scale(1./datatime);
-  SizeOff->Scale(1./datatime);
-  SLengthOff->Scale(1./datatime);
-  HadronnessOff->Scale(1./datatime);
-
-  TH1F* WidthDiff = (TH1F*) WidthOn->Clone("WidthDiff");
-  WidthDiff->Add(WidthOff, -1.);
-
-  TH1F* LengthDiff = (TH1F*) LengthOn->Clone("LengthDiff");
-  LengthDiff->Add(LengthOff, -1.);
-
-  TH1F* SWidthDiff = (TH1F*) SWidthOn->Clone("SWidthDiff");
-  SWidthDiff->Add(SWidthOff, -1.);
-
-  TH1F* SLengthDiff = (TH1F*) SLengthOn->Clone("SLengthDiff");
-  SLengthDiff->Add(SLengthOff, -1.);
-
-  TH1F* ConcDiff = (TH1F*) ConcOn->Clone("ConcDiff");
-  ConcDiff->Add(ConcOff, -1.);
-
-  TH1F* DistDiff = (TH1F*) DistOn->Clone("DistDiff");
-  DistDiff->Add(DistOff, -1.);
-
-  TH1F* M3LongDiff = (TH1F*) M3LongOn->Clone("M3LongDiff");
-  M3LongDiff->Add(M3LongOff, -1.);
-
-  TH1F* SizeDiff = (TH1F*) SizeOn->Clone("SizeDiff");
-  SizeDiff->Add(SizeOff, -1.);
-
-  TH1F* HadronnessDiff = (TH1F*) HadronnessOn->Clone("HadronnessDiff");
-  HadronnessDiff->Add(HadronnessOff, -1.);
-
-
-  TH2F* SkyMapRaw = SkyMap->Clone("SkyMapRaw");
-  TH2F* SkyMapSubtracted= SkyMap->Clone("SkyMapSubtracted");
-
-  SkyMapSubtracted->Add(BgMap, -1.*(SkyMap->Integral() - 
-				    datatime*WidthDiff->Integral()) /
-			BgMap->Integral());
-
-  SkyMap->Scale(1./datatime);
-  BgMap->Scale(1./datatime);
-
-  SkyMap->Add(BgMap, -1.*(SkyMap->Integral()-WidthDiff->Integral())/BgMap->Integral());
-
-
-  //  gStyle->SetPalette(8,0);   // Greyscale
-  gStyle->SetPalette(1,0);   // Pretty palette
-  //  gStyle->SetPalette(51,0);  // Deep sea palette
-
-  CamMap->SetStats(0);
-  SkyMapRaw->SetStats(0);
-  SkyMapSubtracted->SetStats(0);
-  SkyMap->SetStats(0);
-
-  //  CamMap->Draw("zcol");
-  //  SkyMap->Draw("zcol");
-
-  //  Alpha->Draw();
-  //  AbsAlpha->Draw();
-
-//   WidthOn->Draw("e");
-//   WidthOff->Draw("same");
-
-//   LengthOn->Draw("e");
-//   LengthOff->Draw("histo,same");
-
-
-  ///////////////////// MONTE CARLO /////////////////////////
-
-  Double_t xcrab = 120.; //mm
-  Double_t ycrab = 0.;
-
-  xcrab *= mm2deg;
-  ycrab *= mm2deg; // Convert to deg
-
-
-  mhil = new MHillas();
-  mhilsrc = new MHillasSrc();
-  mhilext = new MHillasExt();
-  mnew = new MNewImagePar();
-  mpoint = new MPointingPos();
-  mhad = new MHadronness();
-  MMcEvt* mcevt = new MMcEvt();
-
-  MCchain->SetBranchStatus("*", 0);
-  MCchain->SetBranchStatus("MHillas.fSize", 1);
-  MCchain->SetBranchStatus("MHillas.fWidth", 1);
-  MCchain->SetBranchStatus("MHillas.fLength", 1);
-  MCchain->SetBranchStatus("MHillas.fMeanX", 1);
-  MCchain->SetBranchStatus("MHillas.fMeanY", 1);
-  MCchain->SetBranchStatus("MHillas.fCosDelta", 1);
-  MCchain->SetBranchStatus("MHillas.fSinDelta", 1);
-  MCchain->SetBranchStatus("MHillasSrc.fCosDeltaAlpha", 1);
-  MCchain->SetBranchStatus("MHillasSrc.fDist", 1);
-  MCchain->SetBranchStatus("MHillasExt.fM3Long", 1);
-  MCchain->SetBranchStatus("MNewImagePar.fNumCorePixels", 1);
-  MCchain->SetBranchStatus("MNewImagePar.fConc", 1);
-  MCchain->SetBranchStatus("MHadronness.fHadronness",1);
-  MCchain->SetBranchStatus("MMcEvt.fTelescopeTheta",1);
-  MCchain->SetBranchStatus("MMcEvt.fEnergy",1);
-
-  MCchain->SetBranchAddress("MHillas.",      &mhil);
-  MCchain->SetBranchAddress("MHillasExt.",   &mhilext);
-  MCchain->SetBranchAddress("MNewImagePar.", &mnew);
-  MCchain->SetBranchAddress("MHadronness.",  &mhad);
-  MCchain->SetBranchAddress("MMcEvt.",       &mcevt);
-  MCchain->SetBranchAddress("MHillasSrc.",   &msrc);
-
-
-  // Original # gammas in the MC sample between 1 and 30 TeV (estimate!):
-  Float_t n_gamma_produced_1to30TeV =  
-    n_gamma_produced*(pow(1000.,-1.6) - pow(30000.,-1.6)) / 
-    (pow(10.,-1.6) - pow(30000.,-1.6));
-
-  // Correction due to the modification of the spectrum: -2.62 instead of -2.6
-  n_gamma_produced_1to30TeV *=  (pow(1000.,-1.62) - pow(30000.,-1.62)) /
-    (pow(1000.,-1.6) - pow(30000.,-1.6));
-
-  Float_t evts2rate =   1.74e-11 / n_gamma_produced_1to30TeV; // cm-2 s-1
-  evts2rate *=  TMath::Pi()*pow(300.e2, 2.); // * MC production  area in cm2 => s-1
-
-  cout << "Processing Monte Carlo gammas...." << endl;
-
-  Int_t MC_gammas_in_off = 0;
-  Int_t MC_gammas_in_on  = 0;
-
-  for (Int_t i = 0; i < MCchain->GetEntries(); i++) // event count starts in 0
-    {
-      if ((i+1)%10000 == 0)
-	cout << i+1 << " of " << MCchain->GetEntries() << endl;
-
-      MCchain->GetEvent(i);
-
-      Float_t size = mhil->GetSize();
-
-      if (size < minsize)
-	continue;
-      else if (size > maxsize)
-	continue;
-
-      Float_t log10size = log10(size);
-
-      Float_t ZA = mcevt->GetTelescopeTheta()*180./TMath::Pi();
-
-      // Exclude MC from zbin0. For Crab ZAmin = 6.8 deg. We do not make exactly that cut
-      // to simplify the flux calculation.
-
-      if (ZA < minMCtheta)  // Corresponds to the upper theta limit of zbin0
-	continue;
-      else if (ZA > maxMCtheta)
-	continue;
-
-      Float_t width  = mhil->GetWidth()* mm2deg;;
-      Float_t length = mhil->GetLength()* mm2deg;;
-
-      //      Float_t disp   = (1.-(width/length))*(0.9776+0.101062*log10(size));
-
-      // spot 1 cm:
-      //      Float_t disp   = (1.-(width/length))*(2.68576-0.830937*log10size+0.1227*log10size*log10size);
-
-      Float_t disp;
-
-      if (spotsize == "1.4cm")
-	disp   = (1.-(width/length))*(3.64292-1.28713*log10size+0.179722*log10size*log10size);
-      else if (spotsize == "2.0cm")
-	disp   = (1.-(width/length))*(4.11949-1.39848*log10size+0.183514*log10size*log10size);
-
-      Float_t xmean = mhil->GetMeanX()* mm2deg;;
-      Float_t ymean = mhil->GetMeanY()* mm2deg;;
-
-      Float_t cosdelta = mhil->GetCosDelta();
-      Float_t sindelta = mhil->GetSinDelta();
-
-      Float_t asylon = mhilext->GetM3Long();
-
-      Double_t sourcex, sourcey;
-
-      // Choose right orientation:
-
-      if (asylon < 0.)
-      	{
-	  sourcex = xmean+cosdelta*disp;
-	  sourcey = ymean+sindelta*disp;
- 	}
-       else
- 	{
- 	  sourcex = xmean-cosdelta*disp;
- 	  sourcey = ymean-sindelta*disp;
- 	}
-
-
-      // Calculate Alpha relative to Crab:
-
-      Float_t scalar = ((xmean-xcrab)*cosdelta + (ymean-ycrab)*sindelta) /
-	sqrt( pow(xmean-xcrab, 2.) + pow(ymean-ycrab, 2.) );
-
-      Float_t alpha = 180./TMath::Pi()*acos(scalar);
-
-      if (alpha > 90.)
-	alpha -= 180.;
-
-
-      // Hadronness cut
-
-      Float_t hadronness = mhad->GetHadronness();
-      if (hadronness > maxhadronness)
-	continue;
-
-//       Float_t swidth  = width/(-0.028235+(0.03231*log10size));
-//       Float_t slength = length/(-0.13527+(0.09876*log10size));
-
-// Spot 1 cm:
-//      Float_t swidth  = width/(-0.0332763+(0.0320227*log10size));
-//      Float_t slength = length/(-0.174697+(0.107548*log10size));
-
-      Float_t swidth, slength;
-
-      if (spotsize == "1.4cm")
-	{
-	  swidth  = width/(-0.0308984+(0.0327119*log10size));
-	  slength = length/(-0.181605+(0.109609*log10size));
-	}
-      else if (spotsize == "2.0cm")
-	{
-	  swidth  = width/(-0.0279008+(0.0344538*log10size));
-	  slength = length/(-0.186394+(0.111055*log10size));
-	}
-
-      Float_t conc = mnew->GetConc();
-      Float_t dist = msrc->GetDist()*mm2deg;
-
-      // ON region
-      
-      Float_t ondist2 = (sourcex-xcrab)*(sourcex-xcrab) + 
-	(sourcey-ycrab)*(sourcey-ycrab);
-
-      Float_t offdist2_a = (sourcex+xcrab)*(sourcex+xcrab) + 
-	(sourcey+ycrab)*(sourcey+ycrab);
-      Float_t offdist2_b = (sourcex-ycrab)*(sourcex-ycrab) + 
-	(sourcey+xcrab)*(sourcey+xcrab);
-      Float_t offdist2_c = (sourcex+ycrab)*(sourcex+ycrab) + 
-	(sourcey-xcrab)*(sourcey-xcrab);
-
-
-      Float_t energy = mcevt->GetEnergy(); // GeV
-
-      // Calculate weight to account for true Crab spectrum:
-      // We take the (curved) shape of the spectrum BELOW 1 TeV from
-      // Astropart.Phys. 19 (2003) 339-350 (Fabrizio, Konopelko):
-      // dN/dE = C*(E/1TeV)^[-2.47-0.11*log(E/1TeV)]
-      // normalizing it above 1 TeV with the value from ApJ614
-
-      // Integrated Crab flux 1 - 30 TeV from Aharonian et al. 2004, ApJ 614: 
-      // 1.74e-11 cm-2 s-1 (shape: power law with index -2.62)
-
-      Float_t mcweight;
-      if (energy > 1000.)
-	mcweight = pow(energy/1000., 2.6-2.62); // correct spectrum
-      else
-	{
-	  mcweight = pow(energy/1000., (2.6-2.47-0.11*log(energy/1000.)));
-	}
-
-      mcweight *= evts2rate;  // weight to get results in Hz
-
-      // 3rd moment with sign referred to source position, convert to degree:
-
-      //      Float_t m3long = asylon * TMath::Sign(1., msrc->GetCosDeltaAlpha()) * mm2deg;
-
-      Float_t m3long = asylon * TMath::Sign(1., xmean-xcrab) * mm2deg;
-
-      M3LongMC_all->Fill(m3long, mcweight);
-
-      if (ondist2 < onr2)
-	{
-	  WidthMC->Fill(width, mcweight);
-	  LengthMC->Fill(length, mcweight);
-	  SWidthMC->Fill(swidth, mcweight);
-	  SLengthMC->Fill(slength, mcweight);
-
-	  ConcMC->Fill(conc, mcweight);
-	  DistMC->Fill(dist, mcweight);
-	  M3LongMC->Fill(m3long, mcweight);
-	  SizeMC->Fill(log10size, mcweight);
-
-	  HadronnessMC->Fill(hadronness, mcweight);
-	  EnergyMC->Fill(energy, mcweight);
-
-	  MC_gammas_in_on++;
-	}
-
-      if (offdist2_a < onr2 || offdist2_b < onr2 || offdist2_c < onr2)
-	MC_gammas_in_off++;
-
-      // Very rough cut on 3rd moment related to Crab position:
-      // (only for alpha plot)
-
-      if ( (asylon < 0. && xcrab < xmean) ||
-	   (asylon > 0. && xcrab > xmean) )
-	continue;
-
-      AlphaMC->Fill(alpha);
-      AbsAlphaMC->Fill(abs(alpha));
-
-    }
-
-  cout << "MC gammas in ON region: "  << MC_gammas_in_on << endl;
-  cout << "MC gammas in OFF region: " << MC_gammas_in_off << " / 3" << endl;
-
-  WidthMC->SetLineColor(4);
-  LengthMC->SetLineColor(4);
-  SWidthMC->SetLineColor(4);
-  SLengthMC->SetLineColor(4);
-  HadronnessMC->SetLineColor(4);
-  ConcMC->SetLineColor(4);
-  DistMC->SetLineColor(4);
-  M3LongMC->SetLineColor(4);
-  M3LongMC_all->SetLineColor(2);
-  SizeMC->SetLineColor(4);
-
-  /////////////////////////    DRAW    /////////////////////////////////
-
-
-  WidthDiff->Draw();
-  WidthMC->Draw("chisto,same");
-
-  cout << "Data rate: " << WidthDiff->Integral() << " Hz" << endl;
-  cout << "MC   rate: " << WidthMC->Integral() << " Hz" << endl;
-  cout << "MC   events: " << WidthMC->GetEntries() << endl;
-
-  hfile->Write();
-
-  return;
-}
-
-///////////////////////////////////////
-
-void Smooth(Char_t* filename="Hists_above2000_had0.15.root")
-{
-  TH2F* SkyMap = new TH2F();
-
-  TFile *f = new TFile(filename);
-  SkyMap->Read("SkyMapSubtracted");
-
-
-  Int_t binfactor = 5;
-  Int_t range = 11;     // odd number both!
-
-  Int_t nx = binfactor*SkyMap->GetNbinsX();
-  Int_t ny = binfactor*SkyMap->GetNbinsY();
-
-  TH2F* SkyMap2 = new TH2F("SkyMap2", "Events incoming direction map ",
-			    nx, 
-			    SkyMap->GetXaxis()->GetXmin(),
-			    SkyMap->GetXaxis()->GetXmax(),
-			    ny, 
-			    SkyMap->GetYaxis()->GetXmin(),
-			    SkyMap->GetYaxis()->GetXmax());
-
-
-  // Parameters from fit to real Crab data
-
-  TF2* angres = new TF2("g", 
-			"exp(-(x/0.01065)**2-(y/0.135684)**2)", 
-			-SkyMap->GetXaxis()->GetBinWidth(1)*range/2., 
-			SkyMap->GetXaxis()->GetBinWidth(1)*range/2.,
-			-SkyMap->GetYaxis()->GetBinWidth(1)*range/2., 
-			SkyMap->GetYaxis()->GetBinWidth(1)*range/2. );
-
-  Int_t nbinsx = (angres->GetXmax() - angres->GetXmin()) / 
-    (SkyMap2->GetXaxis()->GetBinWidth(1));
-
-  Int_t nbinsy = (angres->GetYmax() - angres->GetYmin()) / 
-    (SkyMap2->GetYaxis()->GetBinWidth(1));
-
-  angres->SetNpx(nbinsx);
-  angres->SetNpy(nbinsy);
-
-  angres->Draw("lego1");
- 
-
-  TH2F* hist = (TH2F*)angres->GetHistogram()->Clone("hist");
-
-  Float_t norm = 1./hist->Integral();
-
-  hist->Scale(norm);
-
-  cout << hist->Integral() << endl;
-
-  Float_t maxx = SkyMap2->GetXaxis()->GetXmax();
-  Float_t minx = SkyMap2->GetXaxis()->GetXmin();
-  Float_t maxy = SkyMap2->GetYaxis()->GetXmax();
-  Float_t miny = SkyMap2->GetYaxis()->GetXmin();
-
-  for (Int_t ix = 1; ix <= SkyMap->GetNbinsX(); ix++)
-    {
-      for (Int_t iy = 1; iy <= SkyMap->GetNbinsY(); iy++)
-	{
-	  Float_t events = SkyMap->GetBinContent(ix, iy);
-
-	  for (Int_t ix2 = 1; ix2 <= nbinsx; ix2++)
-	    for (Int_t iy2 = 1; iy2 <= nbinsy; iy2++)
-	      {
-		Float_t events2 = events * hist->GetBinContent(ix2, iy2);
-
-		Float_t newx = SkyMap->GetXaxis()->GetBinCenter(ix)
-		  + hist->GetXaxis()->GetBinCenter(ix2);
-		Float_t newy = SkyMap->GetYaxis()->GetBinCenter(iy) 
-		  + hist->GetYaxis()->GetBinCenter(iy2);
-
-		SkyMap2->Fill(newx, newy, events2);
-	    }
-	}
-      if (ix%10 == 0)
-	cout << ix << endl;
-    }
-
-  gStyle->SetPalette(1,0);
-  SkyMap2->SetStats(0);
-  SkyMap2->Draw("zcol");
-
-  return;
-}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/AlphaPlot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/AlphaPlot.C	(revision 7136)
+++ 	(revision )
@@ -1,63 +1,0 @@
-void AlphaPlot(TString onsource="hillas_Mrk421.root", TString offsource="hillas_OffMrk421.root")
-{
-  const Int_t kMinDeg = 25;
-
-  Int_t i;
-  Float_t EvtOn = 0;
-  Float_t EvtOff = 0;
-
-  TH1F *hon = new TH1F("hon","On Source Histogram",19,0,95);
-  TH1F *hoff = new TH1F("hoff","Off Source Histogram",19,0,95);
-  TH1F *htemp;
-
-  fon = new TFile(onsource,"READ");
-
-  htemp = (TH1F *)fon->FindObjectAny("hAlpha");
-  
-  for(i=0;i<19;i++)
-    hon->SetBinContent(i,htemp->GetBinContent(i));
-
-  for(i=0;i<hon->GetNbinsX();i++){
-    if(hon->GetBinCenter(i) > kMinDeg)
-      EvtOn += hon->GetBinContent(i);
-  }
-
-  fon->Close();
-
-  foff = new TFile(offsource,"READ");
-
-  htemp = (TH1F *)foff->FindObjectAny("hAlpha");
-  for(i=0;i<19;i++)
-    hoff->SetBinContent(i,htemp->GetBinContent(i));
-
-  for(i=0;i<hoff->GetNbinsX();i++){
-    if(hoff->GetBinCenter(i) > kMinDeg)
-      EvtOff += hoff->GetBinContent(i);
-  }
-
-  foff->Close();
-
-  Float_t norm = EvtOn/EvtOff;
-  cout << "EvtOn/EvtOff = " << norm << endl;
-
-  Float_t eccessi = 0;
-  Float_t Noff = 0;
-
-  TH1F *hAlphaPlot = new TH1F("hAlphaPlot","Alpha Plot", 19,0,95);
-  for(i=0; i<hon->GetNbinsX(); i++){
-    hAlphaPlot->SetBinContent(i,hon->GetBinContent(i)-hoff->GetBinContent(i)*norm);
-    if(hAlphaPlot->GetBinCenter(i) < 15){
-      eccessi += hAlphaPlot->GetBinContent(i);
-      Noff += norm*hoff->GetBinContent(i);
-    }
-  }
-
-  cout << "Eccessi = " << eccessi << "   Nsigma = " << eccessi/(TMath::Sqrt(Noff)) <<endl;
-
-  new TCanvas("Alpha On","Alpha plot ON source");
-  hon->DrawCopy();
-  new TCanvas("Alpha Off","Alpha plot OFF source");
-  hoff->DrawCopy();
-  new TCanvas("Alpha","Resulting alpha plot");
-  hAlphaPlot->DrawCopy();
-}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/HillasAnal.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/HillasAnal.C	(revision 7136)
+++ 	(revision )
@@ -1,191 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////
-//
-// MagicHillas.C
-// =============
-//
-// This is a demonstration program which calculates image (Hillas +)
-// parameters using as input a Merpp output file (raw data).
-// All parameters are written to an output file called hillas.root. Also
-// filles histograms are displayed.
-// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
-// is used.
-//
-///////////////////////////////////////////////////////////////////////////
-
-void HillasAnal(const char *filename="output_test.root")
-{
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    //
-    // Use this if you want to change the binning of one of
-    // the histograms. You can use:
-    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
-    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
-    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
-    // BinningPixels and BinningCamera
-    //
-    // For more information see MBinning and the corresponding
-    // histograms
-    //
-    // MBinning binsalpha("BinningAlpha");
-    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
-    // plist.AddToList(&binsalpha);
-
-    // MBinning binssize("BinningSize");
-    // binssize.SetEdgesLog(50, 1, 1e7);
-    // plist.AddToList(&binssize);
-
-    //
-    // Craete the object which hlods the source positions in the camera
-    // plain in respect to which the image parameters will be calculated.
-    // For real data the containers will be filled by a task.
-    //
-    MSrcPosCam source;
-    source.SetReadyToSave();
-    plist.AddToList(&source);
-
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-    // The first argument is the tree you want to read.
-    //   Events:     Cosmic ray events
-    //   PedEvents:  Pedestal Events
-    //   CalEvents:  Calibration Events
-    //
-    MReadMarsFile read("Events", filename);
-    read.DisableAutoScheme();
-
-    // Setup a task which makes sure that all used arrays have
-    // the correct size
-    MGeomApply geomapl;
-
-    // tasks used if MC files are detected to calculate pedestals
-    // MMcPedestalCopy pcopy;
-    // MMcPedestalNSBAdd pnsb;
-
-    // calculate the signal in a very simple way
-    // for real adat files use MCerPhotAnal2 instead which also
-    // calculates the pedestal.
-    // MCerPhotCalc ncalc;
-    //
-    //  Alternative photon calculation:
-    //  Example: use only 2nd to 6th FADC slices for photon calculation:
-    //
-    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-    //    const TArrayF w(15,(Float_t*)x);
-    //    ncalc.SetWeights(w);
-    //
-
-    // setup image cleaning and blind pixel treatment
-    MImgCleanStd    clean;
-    MBlindPixelCalc blind;
-
-    //
-    // Instead of unmapping the pixels you can also (The use of this
-    // class is deprecated, it will be replaced by MBadPixels*)
-    //
-    // blind.SetUseInterpolation();
-    // blind.SetUseCetralPixel();
-    //
-
-    // setup tasks to calculate image parameters
-    MHillasCalc    hcalc;
-    MHillasSrcCalc csrc1;
-
-    // setup tasks to fill histograms
-    MFillH hfill1("MHHillas", "MHillas");
-    MFillH hfill2("MHHillasExt");
-    MFillH hfill3("MHStarMap", "MHillas");
-    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
-    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
-    //MFillH hfill6("MHNewImagePar");
-
-    // setup task to write containers to a file
-    MWriteRootFile write("hillas_Mrk421.root");
-    write.AddContainer("MHillas");
-    write.AddContainer("MHillasExt");
-    write.AddContainer("MHillasSrc");
-    write.AddContainer("MRawEvtHeader");
-    write.AddContainer("MRawRunHeader");
-    //write.AddContainer("HistExtSource");
-    //write.AddContainer("MHNewImagePar");
-
-    // Setup the contents of zour tasklist
-    tlist.AddToList(&read);
-    tlist.AddToList(&geomapl);
-    //tlist.AddToList(&pcopy);
-    //tlist.AddToList(&pnsb);
-    //tlist.AddToList(&ncalc);
-    tlist.AddToList(&clean);
-    tlist.AddToList(&blind);
-
-    tlist.AddToList(&hcalc);
-    tlist.AddToList(&csrc1);
-
-    tlist.AddToList(&hfill1);
-    tlist.AddToList(&hfill2);
-    tlist.AddToList(&hfill3);
-    tlist.AddToList(&hfill4);
-    tlist.AddToList(&hfill5);
-    //tlist.AddToList(&hfill6);
-    tlist.AddToList(&write);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    //
-    // Execute your analysis
-    //
-    MProgressBar bar;
-    evtloop.SetProgressBar(&bar);
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist.PrintStatistics();
-
-    //
-    // After the analysis is finished we can display the histograms
-    //
-    plist.FindObject("MHHillas")->DrawClone();
-    plist.FindObject("MHHillasExt")->DrawClone();
-    plist.FindObject("MHStarMap")->DrawClone();
-    plist.FindObject("HistSource")->DrawClone();
-    plist.FindObject("HistExtSource")->DrawClone();
-    //plist.FindObject("MHNewImagePar")->DrawClone();
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C	(revision 7136)
+++ 	(revision )
@@ -1,685 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-//////////////////////////////////////////////////////////////////////////////
-//
-// pedestalstudies_pisa.C
-//
-// macro to study the pedestal and pedestalRMS with the number of FADC 
-// slices summed up. 
-//
-/////////////////////////////////////////////////////////////////////////////////
-const TString pedfile = "/data0/Temp/20040422_23203_P_Mrk421_E.root";
-
-void pedestalstudies_pisa(const TString pedname=pedfile, Int_t pixin=0, Int_t pixout=397,TString f2="",TString f3="",TString f4="",TString f5="")
-{
-
-  Int_t loops = 1;
-  Int_t stepsize = 2;
-
-  gStyle->SetOptStat(1111);
-  gStyle->SetOptFit();
-  
-  TArrayF *hmeandiffinn = new TArrayF(loops);
-  TArrayF *hrmsdiffinn  = new TArrayF(loops);
-  TArrayF *hmeandiffout = new TArrayF(loops);
-  TArrayF *hrmsdiffout  = new TArrayF(loops);
-  TArrayF *hmeaninn  = new TArrayF(loops);
-  TArrayF *hmeanout  = new TArrayF(loops);
-  TArrayF *hrmsinn   = new TArrayF(loops);
-  TArrayF *hrmsout   = new TArrayF(loops);
-  TArrayF *hmuinn    = new TArrayF(loops);
-  TArrayF *hmuout    = new TArrayF(loops);
-  TArrayF *hsigmainn = new TArrayF(loops);
-  TArrayF *hsigmaout = new TArrayF(loops);
-
-  TArrayF *hmeandiffinnerr = new TArrayF(loops);
-  TArrayF *hrmsdiffinnerr  = new TArrayF(loops);
-  TArrayF *hmeandiffouterr = new TArrayF(loops);
-  TArrayF *hrmsdiffouterr  = new TArrayF(loops);
-  TArrayF *hmeaninnerr  = new TArrayF(loops);
-  TArrayF *hmeanouterr  = new TArrayF(loops);
-  TArrayF *hrmsinnerr   = new TArrayF(loops);
-  TArrayF *hrmsouterr   = new TArrayF(loops);
-  TArrayF *hmuinnerr    = new TArrayF(loops);
-  TArrayF *hmuouterr    = new TArrayF(loops);
-  TArrayF *hsigmainnerr = new TArrayF(loops);
-  TArrayF *hsigmaouterr = new TArrayF(loops);
-
-
-  MStatusDisplay *display = new MStatusDisplay;
-  display->SetUpdateTime(500);
-  display->Resize(850,700);
-      
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  TString tabname="";
-
-  for (Int_t samples=2; samples < stepsize*loops+1; samples=samples+stepsize)
-    {
-
-      plist.Reset();
-      tlist.Reset();
-      
-      //
-      // Now setup the tasks and tasklist for the pedestals:
-      // ---------------------------------------------------
-      //
-      
-      MReadMarsFile read("Events", pedname);
-      read.DisableAutoScheme();
-     
-	Int_t neventi;
- 	neventi=1000;
-
-	Float_t samplingRate=500;	//Hz
-	if (f2!=""){
-	read.AddFile(f2);
-	neventi += 1000;
-	}
-
-	if (f3!=""){
-	read.AddFile(f3);
-	neventi += 1000;
-	}
-
-	if (f4!=""){
-	read.AddFile(f4);
-	neventi += 1000;
-	}
-
-	if (f5!=""){
-	read.AddFile(f5);
-	neventi += 1000;
-	}
-
-	const Int_t NEvt = neventi;
-	cout << "E" <<neventi<< " NEvt:" << NEvt << endl;
-	Float_t timevt[NEvt];
-
-      MGeomApply      geomapl;
-      //
-      // Set the extraction range higher:
-      //		
-      //MExtractFixedWindow sigcalc;
-      //MExtractSignal3 sigcalc;
-      	MExtractSlidingWindow sigcalc;
-      sigcalc.SetRange(0,samples-1,0,1);
-
-     
-  
-      MPedCalcPedRun pedcalc;
-      pedcalc.SetRange(0,samples-1,0,0);
-      pedcalc.SetWindowSize((Int_t)sigcalc.GetNumHiGainSamples());
-
-      //MPedCalcFromData pedcalc;
-      //pedcalc.SetfHiGainThreshold(100);
-
-      //
-      // Additionally to calculating the pedestals, 
-      // you can fill histograms and look at them
-      //
-      MFillH fill("MHPedestalCam", "MExtractedSignalCam");
-      tabname="PedCam ";
-      tabname += samples;
-      //fill.SetNameTab(Form("%s%2d","PedCam",samples));
-      fill.SetNameTab(tabname);
-
-      tlist.AddToList(&read);
-      tlist.AddToList(&geomapl);
-      tlist.AddToList(&sigcalc);
-      tlist.AddToList(&pedcalc);
-      tlist.AddToList(&fill);
-      
-      const MGeomCamMagic      geomcam;
-      MPedestalCam       pedcam;
-      MBadPixelsCam      badcam;
-      badcam.AsciiRead("badpixels.dat");  
-      
-      MHPedestalCam      hpedcam;
-      MCalibrationPedCam cpedcam;
-      
-      plist.AddToList(&geomcam);
-      plist.AddToList(&pedcam);
-      plist.AddToList(&hpedcam);
-      plist.AddToList(&cpedcam);
-      plist.AddToList(&badcam);
-      
-      //
-      // Create and setup the eventloop
-      //
-      MRawEvtHeader *evtheader;
-      MRawEvtData *fRawEvt;
-      TH1F *hpedevt = new TH1F("hpedevt","Pedestals Drift",NEvt,0,(Float_t)NEvt/samplingRate);
-      Bool_t rc;
-      MEvtLoop evtloop;
-      
-      evtloop.SetParList(&plist);
-      evtloop.SetDisplay(display);
-      //tlist.SetDisplay(display);
-      //
-      // Execute first analysis
-      //
-      //if (!evtloop.Eventloop())
-      //  return;
-      rc = evtloop.PreProcess();
-      
-      //while (tlist.Process())
-	//{
-	//cout << "bleah" << endl;
-	//}      
-//tlist.SetDisplay(display);
-
-       Int_t fNumHiGainSample=15;
-	Float_t peddata[NEvt];
-	Int_t evtan=0;
-
-      if (rc){
-          while (tlist.Process())
-          {
-            fRawEvt=(MRawEvtData *)plist.FindObject("MRawEvtData");
-            MRawEvtPixelIter pixel(fRawEvt);
-
-            Float_t ped=0;
-	    evtan++;
-
- 	    while (pixel.Next())
-	     {
-
- 	       const UInt_t idx    = pixel.GetPixelId();
-
-               // lista di pixel da sommare
-               if (idx >pixout || idx < pixin)
-		  continue;
-
-	        Byte_t *ptr = pixel.GetHiGainSamples();
-                const Byte_t *end = ptr + fNumHiGainSample;
-      
-                UInt_t sum = 0;
-	        UInt_t sqr = -1;
-
-	        do
-	          {
-	            sum += *ptr;
-	            //sqr += *ptr * *ptr;
-	          }
-	        while (++ptr != end);
-      
-                 ped += (Float_t)sum;
-
-                  //cout << " Pixel " << idx << " pede: " << ped << " --- ";
-                }
- 
-               //rc = evtloop.Process(0);
-	       evtheader = (MRawEvtHeader *)plist.FindObject("MRawEvtHeader");
-
-             ped /= pixout-pixin+1;
-		Int_t evtn=evtheader->GetDAQEvtNumber();
-             evtn=evtan;
-
-//test
-	//ped =  150 + sin(((Float_t)evtn/16.-TMath::Floor(evtn/16))*6.28); 
-	//cout << ped << " ";
-	timeped = evtn/samplingRate;
-	timevt[evtn-1]=timeped;
-     
-        hpedevt->Fill(timeped,ped);
-
-            //	cout <<" evt:" << evtn;
-	     // Save pedestal in array for Fourier analysis
-	     peddata[evtn-1]=ped;
-          }
-      }
-      if (!evtloop.PostProcess()){
-          rc = kFALSE;
-          return;
-      }
-
-      TCanvas &p1 = display->AddTab("ped studies");
-      p1.Divide(1,2);
-      p1.cd(1);
-	hpedevt->GetXaxis()->SetTitle("Time (s)");
-//      hpedevt->Draw();
-
-	TGraph *drift = new TGraph(evtan,timevt,peddata);
-	drift->SetMarkerStyle(21);
-	drift->SetMarkerSize(0.25);
-	drift->GetXaxis()->SetTitle("time (s)");
-	drift->GetYaxis()->SetTitle(" pedestal");
-	drift->Draw("APL");
-
-
-      // Fourier analysis
-	// campionamento a 500Hz (1000 evt) => freq. max a 250Hz
-
-	MFFT pro;
-	TArrayF *pedarray = new TArrayF(NEvt,peddata);
-	TArrayF *fft; // array con risultato FFT 
-	fft = pro.RealFunctionFFT(pedarray);
-	Int_t nsample = (Int_t)(fft->GetSize()); 
-	
-	const Int_t NNEvt = nsample;
-
-	Float_t x[10000];
-	Float_t prova;
-	for (int i=0;i<NNEvt;i++)
-	 x[i]=(Float_t)i/(NNEvt/(samplingRate/2)); 
-
-	Float_t *ffty = fft->GetArray();
-        cout << "Szie:" << fft->GetSize();
-	ffty[0]=0.;
-	TGraph *gr = new TGraph(nsample,x,ffty);
-	p1.cd(2);
-	gr->GetXaxis()->SetTitle("Frequency (Hz)");
-	gr->SetMarkerStyle(20);
-	gr->SetMarkerSize(0.4);
-	gr->Draw("AP");		
-
-
-
-//-------------------------------
-
-
-      // Set status lines
-      display->SetStatusLine1(evtloop.GetName());
-      display->SetStatusLine2(rc ? "Done." : "Error!");
-      // Stop automatic update
-      display->StopUpdate();
-      // Reallow context menus
-      display->SetNoContextMenu(kFALSE);
-      // Reallow user to exit window by File menu
-      display->UnLock();
-      // 
-      // Look at one specific pixel, after all the histogram manipulations:
-      //
-      /*
-      MHGausEvents &hpix = hpedcam.GetAverageHiGainArea(0);
-      hpix.DrawClone("fourierevents");
-      
-      MHGausEvents &lpix = hpedcam.GetAverageHiGainArea(1);
-      lpix.DrawClone("fourierevents");
-
-      hpedcam[170].DrawClone("fourierevents");
-  
-      */
-
-      MHCamera dispped0  (geomcam, "Ped;Pedestal",       "Mean per Slice");
-      MHCamera dispped2  (geomcam, "Ped;PedestalRms",    "RMS per Slice");
-      MHCamera dispped4  (geomcam, "Ped;Mean",           "Fitted Mean per Slice");
-      MHCamera dispped6  (geomcam, "Ped;Sigma",          "Fitted Sigma per Slice");
-      MHCamera dispped9  (geomcam, "Ped;DeltaPedMean",   "Rel. Diff. Mean per Slice (Fit-Calc.)");
-      MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma",  "Rel. Diff. RMS per Slice (Fit-Calc.)");
-  
-      dispped0.SetCamContent(  pedcam, 0);
-      dispped0.SetCamError(    pedcam, 1);
-      dispped2.SetCamContent(  pedcam, 2);
-      dispped2.SetCamError(    pedcam, 3);
-      
-      dispped4.SetCamContent( hpedcam, 0);
-      dispped4.SetCamError(   hpedcam, 1);
-      dispped6.SetCamContent( hpedcam, 2);
-      dispped6.SetCamError(   hpedcam, 3);
-      dispped9.SetCamContent( hpedcam, 5);
-      dispped9.SetCamError(   hpedcam, 6);
-      dispped11.SetCamContent(hpedcam, 8);
-      dispped11.SetCamError(  hpedcam, 9);
-  
-      dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
-      dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
-      dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
-      dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
-      dispped9.SetYTitle("Rel. Diff. Pedestal per slice Fit-Calc [1]");
-      dispped11.SetYTitle("Rel. Diff. Pedestal RMS per slice Fit-Calc [1]");
-
-
-      // Histogram values
-      tabname="MeanRMS ";
-      tabname += samples;
-      //fill.SetNameTab(tabname);
-      TCanvas &b1 = display->AddTab(tabname);
-      b1.Divide(4,3);
-
-      CamDraw(b1,dispped0,1,4,*hmeaninn,*hmeanout,*hmeaninnerr,*hmeanouterr,samples,stepsize);
-      CamDraw(b1,dispped2,2,4,*hrmsinn,*hrmsout,*hrmsinnerr,*hrmsouterr,samples,stepsize);  
-      CamDraw(b1,dispped4,3,4,*hmuinn,*hmuout,*hmuinnerr,*hmuouterr,samples,stepsize);
-      CamDraw(b1,dispped6,4,4,*hsigmainn,*hsigmaout,*hsigmainnerr,*hsigmaouterr,samples,stepsize); 
-      
-      tabname="MeanRrmSamples ";
-      tabname += samples;
-      display->SaveAsGIF(3*((samples-1)/stepsize)+2,tabname);
-
-      // Differences
-      tabname="RelDiff ";
-      tabname += samples;
-      TCanvas &c4 = display->AddTab(tabname);
-      c4.Divide(2,3);
-      
-      CamDraw(c4,dispped9,1,2,*hmeandiffinn,*hmeandiffout,*hmeandiffinnerr,*hmeandiffouterr,samples,stepsize);
-      CamDraw(c4,dispped11,2,2,*hrmsdiffinn,*hrmsdiffout,*hrmsdiffinnerr,*hrmsdiffouterr,samples,stepsize); 
-
-      tabname="RelDiffSamples ";
-      tabname += samples;
-      display->SaveAsGIF(3*((samples-1)/stepsize)+3,tabname);
-
-   cout << "Loop N. " <<samples << " completed..." <<endl;
-
-    }
-
-  /*
-  TF1 *logg = new TF1("logg","[1]+TMath::Log(x-[0])",1.,30.,2);
-  logg->SetParameters(1.,3.5);
-  logg->SetParLimits(0,-1.,3.);
-  logg->SetParLimits(1,-1.,7.);
-  logg->SetLineColor(kRed);
-  */
-
-  TCanvas *canvas = new TCanvas("PedstudInner","Pedestal Studies Inner Pixels",600,900);
-  canvas->Divide(2,3);
-  canvas->cd(1);
-
-  TGraphErrors *gmeaninn = new TGraphErrors(hmeaninn->GetSize(),
-                                            CreateXaxis(hmeaninn->GetSize(),stepsize),hmeaninn->GetArray(),
-                                            CreateXaxisErr(hmeaninnerr->GetSize(),stepsize),hmeaninnerr->GetArray());
-  gmeaninn->Draw("A*");
-  gmeaninn->SetTitle("Calculated Mean per Slice Inner Pixels");
-  gmeaninn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeaninn->GetYaxis()->SetTitle("Calculated Mean per slice");
-  //  gmeaninn->Fit("pol0");
-  //  gmeaninn->GetFunction("pol0")->SetLineColor(kGreen);
-  //  //  gmeaninn->Fit(logg);
-
-  canvas->cd(2);
-
-  TGraphErrors *gmuinn = new TGraphErrors(hmuinn->GetSize(),
-                                          CreateXaxis(hmuinn->GetSize(),stepsize),hmuinn->GetArray(),
-                                          CreateXaxisErr(hmuinnerr->GetSize(),stepsize),hmuinnerr->GetArray());
-  gmuinn->Draw("A*");
-  gmuinn->SetTitle("Fitted Mean per Slice Inner Pixels");
-  gmuinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmuinn->GetYaxis()->SetTitle("Fitted Mean per Slice");
-  //  gmuinn->Fit("pol0");
-  //  gmuinn->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmuinn->Fit(logg);
-
-
-  canvas->cd(3);
-
-  TGraphErrors *grmsinn = new TGraphErrors(hrmsinn->GetSize(),
-                                           CreateXaxis(hrmsinn->GetSize(),stepsize),hrmsinn->GetArray(),
-                                           CreateXaxisErr(hrmsinnerr->GetSize(),stepsize),hrmsinnerr->GetArray());
-  grmsinn->Draw("A*");
-  grmsinn->SetTitle("Calculated Rms per Slice Inner Pixels");
-  grmsinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsinn->GetYaxis()->SetTitle("Calculated Rms per Slice");
-  //  //grmsinn->Fit("pol2");
-  //  //grmsinn->GetFunction("pol2")->SetLineColor(kRed);
-  //  grmsinn->Fit(logg);
-
-  canvas->cd(4);
-
-  TGraphErrors *gsigmainn = new TGraphErrors(hsigmainn->GetSize(),
-                                             CreateXaxis(hsigmainn->GetSize(),stepsize),hsigmainn->GetArray(),
-                                             CreateXaxisErr(hsigmainnerr->GetSize(),stepsize),hsigmainnerr->GetArray());
-  gsigmainn->Draw("A*");
-  gsigmainn->SetTitle("Fitted Sigma per Slice Inner Pixels");
-  gsigmainn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gsigmainn->GetYaxis()->SetTitle("Fitted Sigma per Slice");
-  //  //  gsigmainn->Fit("pol2");
-  //  //  gsigmainn->GetFunction("pol2")->SetLineColor(kRed);
-  //  gsigmainn->Fit(logg);
-
-  canvas->cd(5);
-
-  TGraphErrors *gmeandiffinn = new TGraphErrors(hmeandiffinn->GetSize(),
-                                                CreateXaxis(hmeandiffinn->GetSize(),stepsize),hmeandiffinn->GetArray(),
-                                                CreateXaxisErr(hmeandiffinnerr->GetSize(),stepsize),hmeandiffinnerr->GetArray());
-  gmeandiffinn->Draw("A*"); 
-  gmeandiffinn->SetTitle("Rel. Difference  Mean per Slice Inner Pixels");
-  gmeandiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeandiffinn->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
-  //  //gmeandiffinn->Fit("pol2");
-  //  //gmeandiffinn->GetFunction("pol2")->SetLineColor(kBlue);
-  //  gmeandiffinn->Fit(logg);
-
-
-  canvas->cd(6);
-
-  TGraphErrors *grmsdiffinn = new TGraphErrors(hrmsdiffinn->GetSize(),
-                                               CreateXaxis(hrmsdiffinn->GetSize(),stepsize),hrmsdiffinn->GetArray(),
-                                               CreateXaxisErr(hrmsdiffinnerr->GetSize(),stepsize),hrmsdiffinnerr->GetArray());
-  grmsdiffinn->Draw("A*");
-  grmsdiffinn->SetTitle("Rel. Difference Sigma per Slice-RMS Inner Pixels");
-  grmsdiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsdiffinn->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
-  //  //grmsdiffinn->Fit("pol2");
-  //  //grmsdiffinn->GetFunction("pol2")->SetLineColor(kBlue);
-  //  grmsdiffinn->Fit(logg);
-
-  canvas->SaveAs("PedestalStudyInner.root");
-  canvas->SaveAs("PedestalStudyInner.ps");
-
-  TCanvas *canvas2 = new TCanvas("PedstudOut","Pedestal Studies Outer Pixels",600,900);
-  canvas2->Divide(2,3);
-  canvas2->cd(1);
-
-  TGraphErrors *gmeanout = new TGraphErrors(hmeanout->GetSize(),
-                                            CreateXaxis(hmeanout->GetSize(),stepsize),hmeanout->GetArray(),
-                                            CreateXaxisErr(hmeanouterr->GetSize(),stepsize),hmeanouterr->GetArray());
-  gmeanout->Draw("A*");
-  gmeanout->SetTitle("Calculated Mean per Slice Outer Pixels");
-  gmeanout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeanout->GetYaxis()->SetTitle("Calculated Mean per Slice");
-  //  gmeanout->Fit("pol0");
-  //  gmeanout->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmeanout->Fit(logg);
-
-  canvas2->cd(2);
-
-  TGraphErrors *gmuout = new TGraphErrors(hmuout->GetSize(),
-                                          CreateXaxis(hmuout->GetSize(),stepsize),hmuout->GetArray(),
-                                          CreateXaxisErr(hmuouterr->GetSize(),stepsize),hmuouterr->GetArray());
-  gmuout->Draw("A*");
-  gmuout->SetTitle("Fitted Mean per Slice Outer Pixels");
-  gmuout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmuout->GetYaxis()->SetTitle("Fitted Mean per Slice");
-  //  gmuout->Fit("pol0");
-  //  gmuout->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmuout->Fit(logg);
-
-  canvas2->cd(3);
-
-  TGraphErrors *grmsout = new TGraphErrors(hrmsout->GetSize(),
-                                           CreateXaxis(hrmsout->GetSize(),stepsize),hrmsout->GetArray(),
-                                           CreateXaxisErr(hrmsouterr->GetSize(),stepsize),hrmsouterr->GetArray());
-  grmsout->Draw("A*");
-  grmsout->SetTitle("Calculated Rms per Slice Outer Pixels");
-  grmsout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsout->GetYaxis()->SetTitle("Calculated Rms per Slice");
-  //  //grmsout->Fit("pol2");
-  //  //grmsout->GetFunction("pol2")->SetLineColor(kRed);
-  //  grmsout->Fit(logg);
-
-  canvas2->cd(4);
-
-  TGraphErrors *gsigmaout = new TGraphErrors(hsigmaout->GetSize(),
-                                             CreateXaxis(hsigmaout->GetSize(),stepsize),hsigmaout->GetArray(),
-                                             CreateXaxisErr(hsigmaouterr->GetSize(),stepsize),hsigmaouterr->GetArray());
-  gsigmaout->Draw("A*");
-  gsigmaout->SetTitle("Fitted Sigma per Slice Outer Pixels");
-  gsigmaout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gsigmaout->GetYaxis()->SetTitle("Fitted Sigma per Slice");
-  //  //gsigmaout->Fit("pol2");
-  //  //gsigmaout->GetFunction("pol2")->SetLineColor(kRed);
-  //  gsigmaout->Fit(logg);
-
-
-  canvas2->cd(5);
-
-  TGraphErrors *gmeandiffout = new TGraphErrors(hmeandiffout->GetSize(),
-                                                CreateXaxis(hmeandiffout->GetSize(),stepsize),hmeandiffout->GetArray(),
-                                                CreateXaxisErr(hmeandiffouterr->GetSize(),stepsize),hmeandiffouterr->GetArray());
-  gmeandiffout->Draw("A*");
-  gmeandiffout->SetTitle("Rel. Difference  Mean per Slice Outer Pixels");
-  gmeandiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeandiffout->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
-  //  //gmeandiffout->Fit("pol2");
-  //w  //gmeandiffout->GetFunction("pol2")->SetLineColor(kBlue);
-  //  gmeandiffout->Fit(logg);
-
-  canvas2->cd(6);
-
-  TGraphErrors *grmsdiffout = new TGraphErrors(hrmsdiffout->GetSize(),
-                                               CreateXaxis(hrmsdiffout->GetSize(),stepsize),hrmsdiffout->GetArray(),
-                                               CreateXaxisErr(hrmsdiffouterr->GetSize(),stepsize),hrmsdiffouterr->GetArray());
-  grmsdiffout->Draw("A*");
-  grmsdiffout->SetTitle("Rel. Difference Sigma per Slice-RMS Outer Pixels");
-  grmsdiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsdiffout->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
-  //  //grmsdiffout->Fit("pol2");
-  //  //grmsdiffout->GetFunction("pol2")->SetLineColor(kBlue);
-  //  grmsdiffout->Fit(logg);
-
-
-  canvas2->SaveAs("PedestalStudyOuter.root");
-  canvas2->SaveAs("PedestalStudyOuter.ps");
-
-
-}
-
-
-void CamDraw(TCanvas &c, MHCamera &cam, Int_t i, Int_t j, TArrayF &a1, TArrayF &a2, 
-             TArrayF &a1err, TArrayF &a2err, Int_t samp, Int_t stepsize)
-{
-
-  c.cd(i);
-  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
-  obj1->SetDirectory(NULL);
-  
-  c.cd(i+j);
-  obj1->Draw();
-  ((MHCamera*)obj1)->SetPrettyPalette();
-
-  c.cd(i+2*j);
-  TH1D *obj2 = (TH1D*)obj1->Projection();
-  obj2->SetDirectory(NULL);
-  
-  //      obj2->Sumw2();
-  obj2->Draw();
-  obj2->SetBit(kCanDelete);
-  
-  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
-  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
-  const Double_t integ = obj2->Integral("width")/2.5066283;
-  const Double_t mean  = obj2->GetMean();
-  const Double_t rms   = obj2->GetRMS();
-  const Double_t width = max-min;
-  
-  if (rms == 0. || width == 0. )
-    return;
-  
-  TArrayI s0(6);
-  s0[0] = 6;
-  s0[1] = 1;
-  s0[2] = 2;
-  s0[3] = 3;
-  s0[4] = 4;
-  s0[5] = 5;
-  
-  TArrayI inner(1);
-  inner[0] = 0;
-  
-  TArrayI outer(1);
-  outer[0] = 1;
-      
-  // Just to get the right (maximum) binning
-  TH1D *half[2];
-  half[0] = obj1->ProjectionS(s0, inner, "Inner");
-  half[1] = obj1->ProjectionS(s0, outer, "Outer");
-
-  half[0]->SetDirectory(NULL);
-  half[1]->SetDirectory(NULL);
-  
-  for (int i=0; i<2; i++)
-    {
-      half[i]->SetLineColor(kRed+i);
-      half[i]->SetDirectory(0);
-      half[i]->SetBit(kCanDelete);
-      half[i]->Draw("same");
-      half[i]->Fit("gaus","Q+");
-
-      if (i==0)
-        {
-          a1[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
-          a1err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
-          if (a1err[(samp-1)/stepsize] > 3.)
-            a1err[(samp-1)/stepsize] = 1.;
-        }
-     if (i==1)
-       {
-         a2[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
-         a2err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
-          if (a2err[(samp-1)/stepsize] > 3.)
-            a2err[(samp-1)/stepsize] = 1.;
-       }
-    }
-  
-  
-}
-
-// -----------------------------------------------------------------------------
-// 
-// Create the x-axis for the event graph
-//
-Float_t *CreateXaxis(Int_t n, Int_t step)
-{
-
-  Float_t *xaxis = new Float_t[n];
-
-  for (Int_t i=0;i<n;i++)
-    xaxis[i] = 2. + step*i;
-
-  return xaxis;
-                 
-}
-
-// -----------------------------------------------------------------------------
-// 
-// Create the x-axis for the event graph
-//
-Float_t *CreateXaxisErr(Int_t n, Int_t step)
-{
-
-  Float_t *xaxis = new Float_t[n];
-
-  for (Int_t i=0;i<n;i++)
-    xaxis[i] = step/2.;
-
-  return xaxis;
-                 
-}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/production.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/production.C	(revision 7136)
+++ 	(revision )
@@ -1,295 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Hendrik Bartko, 03/2004 <mailto:hbartko@mppmu.mpg.de>
-!              Markus Gaug,    03/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////
-//
-//   production.C
-//   ============
-//
-//   This macro takes calibration runs and pedestal runs
-//   to set pedestals and calibration factors
-//   Then raw data files are read and calibrated.
-//   The output file contains the calibrated data, pedestal subtracted,
-//   with the signal (in photons) for each pixels
-//
-//   input:  calibration file(s)
-//           pedestal file(s)
-//           raw data files
-//   
-//   output: root files with following containers (branches)
-//           - MCerPhotEvt
-//           - MPedestalCam
-//           - MCalibrationRelTimeCam
-//           - MCerPhotEvt
-//           - MRawEvtHeader
-//           - MBadPixelsCam
-//           - MPedPhotCam
-//
-///////////////////////////////////////////////////////////////////////////
-
-//
-// Set path for files and run numbers
-//
-const TString defpath = "/data1/earth/magic/data/Period014/rootdata/2004_02_15/";
-const TString defrout = "output_Mrk421_20040215.root";
-
-const Int_t defpedr [] = {17284};
-const Int_t defcalr [] = {17285};
-const Int_t defdatar[] = {17286,17287,17288,17289,17290,17291,17292,17293,
-			  17294,17295,17296,17297,17298,17299,17300,17301,
-			  17302,17303,17304,17305,17306,17307,17308,17309,
-			  17310,17311,17312,17313,17314,17315,17316,17317,
-			  17318,17319,17320,17321,17322,17323,17324,17325,
-			  17326,17327,17328,17329,17330,17331,17332,17333,
-			  17334,17335,17336,17337,17338,17339,17340,17341,
-			  17342,17343,17344,17345,17346,17347,17348,17349,
-			  17350,17351,17352,17353,17354,17355,17356,17357,
-			  17358,17359,17360,17361,17362,17363,17364,17365,
-			  17366,17367,17368,17369,17370,17371,17372,17373,
-			  17374,17375,17376,17377,17378,17379,17380,17381,
-			  17382,17383,17384,17385,17386,17387,17388,17389,
-			  17390,17391,17392,17393,17394,17395,17396,17397,
-			  17398,17399,17400,17401,17402,17403,17404,17405,
-			  17406,17407,17408,17409,17410,17411,17412,17413,
-			  17414,17415,17416,17417,17418,17419,17420,17421,
-			  17422,17423,17424,17425,17426,17427,17428,17429,
-			  17430,17431,17432,17433,17434,17435,17436,17437,
-			  17438,17439,17440,17441,17442,17443,17444,17445,
-			  17446,17447,17448,17449,17450,17451,17452,17453,
-			  17454,17455,17456};
-
-
-void production(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=171, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  MExtractSlidingWindow extractor;
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-  
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-
-  MStatusDisplay *display = new MStatusDisplay;
-  display->SetUpdateTime(3000);
-  display->Resize(850,700);
-
-  gStyle->SetOptStat(1111);
-  gStyle->SetOptFit();
-
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-  
-  MParList plist1;
-  MTaskList tlist1;
-  plist1.AddToList(&tlist1);
-  
-  // containers
-  MPedestalCam   pedcam;
-  MBadPixelsCam  badcam;
-  //
-  // for excluding pixels from the beginning:
-  //
-  // badcam.AsciiRead("badpixels.dat");
-
-
-  plist1.AddToList(&pedcam);
-  plist1.AddToList(&badcam);
-    
-  //tasks
-  MReadMarsFile  read("Events");
-  read.DisableAutoScheme();
-  static_cast<MRead&>(read).AddFiles(pruns);
-
-  MGeomApply     geomapl;
-  MPedCalcPedRun pedcalc;
-  MGeomCamMagic  geomcam;
-    
-  tlist1.AddToList(&read);
-  tlist1.AddToList(&geomapl);
-  tlist1.AddToList(&pedcalc);
-
-  // Create and execute the event looper
-  MEvtLoop pedloop;
-  pedloop.SetParList(&plist1);
-  pedloop.SetDisplay(display);
-
-  cout << "*************************" << endl;
-  cout << "** COMPUTING PEDESTALS **" << endl;
-  cout << "*************************" << endl;
-
-  if (!pedloop.Eventloop())
-    return;
-  
-  tlist1.PrintStatistics();
-
-  // 
-  // Now the short version: 
-  //
-  //
-  // Now setup the new tasks for the calibration:
-  // ---------------------------------------------------
-  //
-  MJCalibration     calloop;
-  calloop.SetInput(&cruns);
-  //  calloop.SetFullDisplay();
-  //
-  calloop.SetExtractor(&extractor);
-  //
-  // Set the corr. cams:
-  //
-  calloop.SetBadPixels(badcam);
-  //
-  // The next two commands are for the display:
-  //
-  calloop.SetDisplay(display);
-  
-  //
-  // Apply rel. time calibration:
-  //
-  calloop.SetRelTimeCalibration();
-  //
-  // Use as arrival time extractor MArrivalTimeCalc2:
-  //
-  calloop.SetArrivalTimeLevel(2);
-  
-  //
-  // Do the event-loop:
-  //
-  cout << "***************************" << endl;
-  cout << "** COMPUTING CALIBRATION **" << endl;
-  cout << "***************************" << endl;
-  
-  if (!calloop.Process(pedcam))
-    return;
-
-  badcam.Print();
-  
-  MBadPixelsCam          &badbad  = calloop.GetBadPixels();
-  MCalibrationChargeCam  &calcam  = calloop.GetCalibrationCam();
-  MCalibrationRelTimeCam &timecam = calloop.GetRelTimeCam();
-  MCalibrationQECam      &qecam   = calloop.GetQECam();
-
-  badbad.Print();
-
-  /************************************************************************/
-  /*                THIRD LOOP: DATA CALIBRATION INTO PHOTONS             */
-  /************************************************************************/
-
-  // Create an empty Parameter List and an empty Task List
-  MParList  plist3;  
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
- 
-  // containers
-  MCerPhotEvt         photevt;
-  MPedPhotCam         pedphotcam;
-  MSrcPosCam          srccam;
-  MRawRunHeader       runhead;
-  MExtractedSignalCam sigcam;
-
-  plist3.AddToList(&geomcam );
-  plist3.AddToList(&pedcam  );
-  plist3.AddToList(&calcam  );
-  plist3.AddToList(&qecam   );
-  plist3.AddToList(&badbad  );
-  plist3.AddToList(&timecam );
-  plist3.AddToList(&sigcam  );
-  plist3.AddToList(&photevt);
-  plist3.AddToList(&pedphotcam);
-  plist3.AddToList(&srccam);
-  plist3.AddToList(&runhead);
-
-  //tasks
-  MReadMarsFile read3("Events");
-  read3.DisableAutoScheme();
-  static_cast<MRead&>(read3).AddFiles(druns);
-
-  MArrivalTimeCalc2   timecalc;
-  MCalibrateData      photcalc;     
-  photcalc.SetCalibrationMode(MCalibrateData::kFfactor);  // !!! was only MCalibrate
-  // MPedPhotCalc     pedphotcalc;   // already done by MCalibrate Data
-  // MCerPhotCalc     cerphotcalc;  // already done by MCalibrate Data
-  
-  tlist3.AddToList(&read3);
-  tlist3.AddToList(&geomapl);
-  tlist3.AddToList(&extractor);
-  tlist3.AddToList(&timecalc);
-  //  tlist3.AddToList(&cerphotcalc); // already done by MCalibrate Data
-  tlist3.AddToList(&photcalc);
-  // tlist3.AddToList(&pedphotcalc);   // already done by MCalibrate Data
-
-  MWriteRootFile write(resname);
-  
-  write.AddContainer("MGeomCam"              , "RunHeaders");
-  write.AddContainer("MRawRunHeader"         , "RunHeaders");
-  write.AddContainer("MSrcPosCam"            , "RunHeaders");
-  write.AddContainer("MCalibrationChargeCam" , "RunHeaders");
-  write.AddContainer("MCalibrationQECam"     , "RunHeaders");
-  //  write.AddContainer("MPedPhotCam","RunHeaders"); // Attention, was in Events - Tree!!
-  write.AddContainer("MPedestalCam"          , "RunHeaders");
-  write.AddContainer("MCalibrationRelTimeCam", "RunHeaders");
-
-  write.AddContainer("MCerPhotEvt"   , "Events");
-  write.AddContainer("MRawEvtHeader" , "Events");
-  write.AddContainer("MBadPixelsCam" , "Events");
-  write.AddContainer("MPedPhotCam"   , "Events");
-
-  tlist3.AddToList(&write);
-  
-  // Create and execute eventloop
-  MEvtLoop evtloop3;
-  evtloop3.SetParList(&plist3);
-    
-  cout << "*************************************************************" << endl;
-  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
-  cout << "*************************************************************" << endl;
-  
-  if (!evtloop3.Eventloop())  
-    return;  
-  tlist3.PrintStatistics();
-
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/production3.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/production3.C	(revision 7136)
+++ 	(revision )
@@ -1,373 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López, 12/2003 <mailto:jlopez@ifae.es>
-!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-/////////////////////////////////////////////////////////////////////////////
-//
-//  bootcampstandardanalysis.C
-//
-//  Updated version of the macro designed at the Wuerzburg bootcamp and 
-//  compatible with the latest changes in Mars for general usage at the
-//  Udine bootcamp. 
-//
-//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
-//  one of a calibration file ("*_C_*.root") and one of a data file 
-//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
-/// constants calculation and the calibration of the data. 
-//
-//  The TString inpath has to be set correctly.
-//
-//  The macro searches for the pulser colour which corresponds to the calibration
-//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
-//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
-//  "ct1" in the filenames. If no colour or multiple colours are found, the 
-//  execution is aborted.  
-//
-//////////////////////////////////////////////////////////////////////////////////
-const Bool_t usedisplay = kTRUE;
-const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
-const TString outpath = "./";
-const TString defrout = "output_Mrk421_20040319.root";
-// Mrk (13)
-const Int_t defpedr[] = {20823};
-//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
-//			  20608,20611,20614,20649,20652,20654};
-// OffMrk (14)
-//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
-//			  20632,20635,20637,20640,20643,20645,20647};
-
-
-//const Int_t defcalr [] = {20651};
-const Int_t defcalr [] = {20822};
-
-// Mrk (20)
-const Int_t defdatar[] = {20824};
-//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
-//			  20603,20604,20606,20607,20609,20610,20612,
-//			  20613,20615,20616,20650,20653,20655};
-// OffMrk (18)
-// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
-// 			  20631,20633,20634,20636,20638,20639,20641,
-//			  20642,20644,20646,20648};
-
-
-void production3(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  //
-  // Choose the signal Extractor:
-  //
-  //MExtractSlidingWindow extractor;
-  MExtractFixedWindowPeakSearch extractor;
-  //MExtractFixedWindow    extractor;   
-
-  //
-  // Set Ranges or Windows
-  //
-  extractor.SetRange(3,14,3,14);
-  //extractor.SetWindows(8,8);
-
-  //
-  // Choose the arrival time Extractor:
-  //
-  MExtractTimeFastSpline       timeext;
-  //  MExtractTimeHighestIntegral timeext;
-  //  MExtractTimeSpline          timeext;
-  //
-  // Set Ranges or Windows
-  //
-  timeext.SetRange(2,12,4,14);
-
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-  
-  //
-  // Now setup the tasks and tasklist for the pedestals:
-  // ---------------------------------------------------
-  //
-  MBadPixelsCam     badcam;
-  MGeomCamMagic     geomcam;
-  MGeomApply        geomapl;
-  //
-  // If you want to exclude pixels from the beginning, read 
-  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
-  //
-  //  badcam.AsciiRead("badpixels.dat");
-  
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-
-  MJPedestal pedloop;
-  pedloop.SetInput(&pruns);
-  if (usedisplay)
-    {
-      MStatusDisplay *display = new MStatusDisplay;
-      display->SetUpdateTime(3000);
-      display->Resize(850,700);
-      pedloop.SetDisplay(display);
-    }
-  pedloop.SetBadPixels(badcam);
-  pedloop.SetExtractor(&extractor);
-
-  if (!pedloop.Process())
-    return;
-
-  /****************************************/
-  /* SECOND LOOP: CALIBRATION COMPUTATION */
-  /****************************************/
-
-  //
-  // Now setup the new tasks for the calibration:
-  // ---------------------------------------------------
-  //
-  MCalibrationQECam qecam;
-  MJCalibration     calloop;
-  calloop.SetInput(&cruns);
-  calloop.SetExtractor(&extractor);
-  //
-  // Apply rel. time calibration:
-  //
-  calloop.SetRelTimeCalibration();
-  calloop.SetTimeExtractor(&timeext);
-  //
-  // Set the corr. cams:
-  //
-  calloop.SetQECam(qecam);
-  calloop.SetBadPixels(pedloop.GetBadPixels());
-  //
-  // The next two commands are for the display:
-  //
-  if (usedisplay)
-      calloop.SetDisplay(display);
-  cout << "Minchia 0" << endl;
-  //
-  // Do the event-loop:
-  //
-  if (!calloop.Process(pedloop.GetPedestalCam()))
-    return;
-  
-  cout << "Minchia 1" << endl;
-  /*************************************/
-  /* THIRD LOOP: PEDESTAL CALIBRATION  */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist3;
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
-  cout << "Minchia 2" << endl;
-  //
-  // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
-  // -----------------------------------------------------------------------------------
-  //
-  
-  MCerPhotEvt    nphot;
-  MPedPhotCam    nphotrms;
-  
-  plist3.AddToList(&geomcam);
-  cout << "Minchia 3" << endl;
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist3.AddToList(&pedloop.GetPedestalCam());
-  plist3.AddToList(&calloop.GetCalibrationCam());
-  plist3.AddToList(&calloop.GetQECam());
-  plist3.AddToList(&calloop.GetRelTimeCam());
-  plist3.AddToList(&calloop.GetBadPixels());
-  plist3.AddToList(&nphot);
-  plist3.AddToList(&nphotrms);
-    cout << "Minchia 4" << endl;
-  //tasks
-  MReadMarsFile read3("Events");
-  read3.DisableAutoScheme();
-  static_cast<MRead&>(read3).AddFiles(pruns);  
-
-  //MCalibrate       photcalc;
-  MCalibrateData       photcalc;
-  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
-  MPedPhotCalc  photrmscalc;  //It doesn't exist yet
-  
-  tlist3.AddToList(&read3);
-  tlist3.AddToList(&geomapl);
-  tlist3.AddToList(&extractor);
-  tlist3.AddToList(&photrmscalc);
-  //tlist3.AddToList(&photcalc);
-  
-  
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop3;
-  evtloop3.SetParList(&plist3);
-  
-  //
-  // Execute first analysis
-  //
-  if (!evtloop3.Eventloop())
-    return;
-  
-  tlist3.PrintStatistics();
-  
-  /*************************************/
-  /* FOURTH LOOP: DATA CALIBRATION     */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist4;
-  MTaskList tlist4;
-  plist4.AddToList(&tlist4);
-  
-  //
-  // Now setup the tasks and tasklist to analize the data
-  // -----------------------------------------------------
-  //
-  
-  plist4.AddToList(&geomcam);
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist4.AddToList(&pedloop.GetPedestalCam());
-  plist4.AddToList(&calloop.GetCalibrationCam());
-  plist4.AddToList(&calloop.GetQECam());
-  plist4.AddToList(&calloop.GetRelTimeCam());
-  plist4.AddToList(&calloop.GetBadPixels());
-  plist4.AddToList(&nphot);
-  plist4.AddToList(&nphotrms);
-
-  MArrivalTime times;
-  plist4.AddToList(&times);
-  
-  //tasks
-  MReadMarsFile read4("Events");
-  read4.DisableAutoScheme();
-  static_cast<MRead&>(read4).AddFiles(druns);  
-  
-  MArrivalTimeCalc2   timecalc;
-  MCalibrateRelTimes  timecal;
-
-  tlist4.AddToList(&read4);
-  tlist4.AddToList(&geomapl);
-  tlist4.AddToList(&extractor);
-  tlist4.AddToList(&timecalc);
-  tlist4.AddToList(&photcalc);
-  tlist4.AddToList(&timecal);
-  
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop4;
-  evtloop4.SetParList(&plist4);
-
-  if (!evtloop4.PreProcess())
-    return;
-  
-  TCanvas *c1 = new TCanvas;
-  MHCamera disp1(geomcam);
-  disp1.SetPrettyPalette();
-  //disp1.SetInvDeepBlueSeaPalette()
-  disp1.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  
-  /*
-  TCanvas *c2 = new TCanvas;
-  MHCamera disp2(geomcam);
-  disp2.SetPrettyPalette();
-  //disp2.SetInvDeepBlueSeaPalette()
-  disp2.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  */
-  while (tlist4.Process())
-    {
-      disp1.SetCamContent(nphot);
-      
-      gPad->Modified();
-      gPad->Update();
-
-      /*    
-      disp2.SetCamContent(times);
-      
-      gPad->Modified();
-      gPad->Update();
-      */
-
-      // Remove the comments if you want to go through the file
-      // event-by-event:
-      if (!HandleInput())
-        break;
-    }
-
-  evtloop4.PostProcess();
-  
-}
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/readIPR.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/readIPR.C	(revision 7136)
+++ 	(revision )
@@ -1,147 +1,0 @@
-///////////////////////////////////////////////////////////////////////////
-// 
-//    readIPR.C
-//
-//   This macro shows how to read the Individual Pixel Rates from 
-//   a CC report file.
-//
-//   Input: 
-//     - root file obtained merpping a .rep CC file
-//       container: MTriggerIPR
-//
-//   Output:
-//     - a camera display showing the IPRs
-//     - Some histos for checking purposes
-//   
-//   Note: 
-//     a similar macro can be used to read the following trigger containers:
-//     - MTriggerIPR        (Individual Pixel Rates)
-//     - MTriggerCell       (Rate of trigger cells)
-//     - MTriggerBit        (Output Bits from prescaler (before/after presc.)
-//     - MTriggerPrescFact  (Prescaling factors for each bit)
-//     - MTriggerLiveTime   (Values of counters for dead/livetime)
-//
-//    Author(s): Antonio Stamerra. 09/04 <antonio.stamerra@pi.infn.it>
-//
-////////////////////////////////////////////////////////////////////////////
-void readIPR(TString fname)
-{
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-
-    // Create the magic geometry
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
-    // First Task: Read ROOT file with Trigger-REPORT data
-    MReadTree read("Trigger", fname);
-    read.DisableAutoScheme();
-
-    tlist.AddToList(&read);
-
-    // Create the container for the IPRs
-    MTriggerIPR ipr;
-    plist.AddToList(&ipr);
-
-    // Create the histo to display the IPRs
-    MHCamEvent IPRhist("IPRhist","IPRs");
-    plist.AddToList(&IPRhist);
-        
-    // create a task to fill a histogram from the container
-    MFillH fillIPR(&IPRhist, "MTriggerIPR");
-    tlist.AddToList(&fillIPR);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    //
-    // Execute the analysis
-    //
-    if (!evtloop.PreProcess())
-      return;
-    
-    if (!evtloop.Eventloop())
-      return;
-
-    tlist.PrintStatistics();
-
-    //-----------------------------------
-    // Now display the result of the loop
-    //
-
-    // create a MHCamera histo where the sum off all events is filled
-    MHCamera &h = *(MHCamera*)IPRhist.GetHistByName("sum");
-
-    TCanvas *c = MH::MakeDefCanvas();
-    c->Divide(3, 2);
-
-    MHCamera *disp1=h.Clone();
-    MHCamera *disp2=h.Clone();
-    MHCamera *disp3=h.Clone();
-    disp2->SetCamContent(h, 1);
-    disp3->SetCamContent(h, 2);
-
-    disp1->SetYTitle("Rate [Hz]");
-    disp2->SetYTitle("\\sigma_{Rate} [Hz]");
-    disp3->SetYTitle("\\sigma_{Rate} [%]");
-    disp1->SetName("IPRs;avg");
-    disp2->SetName("IPRs;err");
-    disp3->SetName("IPRs;rel");
-    disp1->SetTitle("IPRs Average");
-    disp2->SetTitle("IPRs error");
-    disp3->SetTitle("IPRs relative error");
-
-    c->cd(1);
-    TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
-    text.SetTextSize(0.03);
-    text.DrawClone();
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp1->Draw();
-    disp1->SetBit(kCanDelete);
-    c->cd(2);
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp2->Draw();
-    disp2->SetBit(kCanDelete);
-    c->cd(3);
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp3->Draw();
-    disp3->SetBit(kCanDelete);
-    c->cd(4);
-    gPad->SetBorderMode(0);
-    disp1->Draw("EPhist");
-    c->cd(5);
-    gPad->SetBorderMode(0);
-    gPad->SetLogy();
-    disp2->Draw("Phist");
-    c->cd(6);
-    gPad->SetBorderMode(0);
-    gPad->SetLogy();
-    disp3->Draw("Phist");
-
-    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
-    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/timedist3.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/timedist3.C	(revision 7136)
+++ 	(revision )
@@ -1,394 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * 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): Javier López, 12/2003 <mailto:jlopez@ifae.es>
-!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-/////////////////////////////////////////////////////////////////////////////
-//
-//  bootcampstandardanalysis.C
-//
-//  Updated version of the macro designed at the Wuerzburg bootcamp and 
-//  compatible with the latest changes in Mars for general usage at the
-//  Udine bootcamp. 
-//
-//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
-//  one of a calibration file ("*_C_*.root") and one of a data file 
-//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
-/// constants calculation and the calibration of the data. 
-//
-//  The TString inpath has to be set correctly.
-//
-//  The macro searches for the pulser colour which corresponds to the calibration
-//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
-//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
-//  "ct1" in the filenames. If no colour or multiple colours are found, the 
-//  execution is aborted.  
-//
-//////////////////////////////////////////////////////////////////////////////////
-const Bool_t usedisplay = kTRUE;
-const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
-const TString outpath = "./";
-const TString defrout = "output_Mrk421_20040319.root";
-// Mrk (13)
-const Int_t defpedr[] = {20823};
-//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
-//			  20608,20611,20614,20649,20652,20654};
-// OffMrk (14)
-//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
-//			  20632,20635,20637,20640,20643,20645,20647};
-
-
-//const Int_t defcalr [] = {20651};
-const Int_t defcalr [] = {20822};
-
-// Mrk (20)
-const Int_t defdatar[] = {20824};
-//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
-//			  20603,20604,20606,20607,20609,20610,20612,
-//			  20613,20615,20616,20650,20653,20655};
-// OffMrk (18)
-// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
-// 			  20631,20633,20634,20636,20638,20639,20641,
-//			  20642,20644,20646,20648};
-
-
-void timedist3(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  //
-  // Choose the signal Extractor:
-  //
-  //MExtractSlidingWindow extractor;
-  MExtractFixedWindowPeakSearch extractor;
-  //MExtractFixedWindow    extractor;   
-
-  //
-  // Set Ranges or Windows
-  //
-  extractor.SetRange(3,14,3,14);
-  //extractor.SetWindows(8,8);
-
-  //
-  // Choose the arrival time Extractor:
-  //
-  MExtractTimeFastSpline       timeext;
-  //  MExtractTimeHighestIntegral timeext;
-  //  MExtractTimeSpline          timeext;
-  //
-  // Set Ranges or Windows
-  //
-  timeext.SetRange(2,12,4,14);
-
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-  
-  //
-  // Now setup the tasks and tasklist for the pedestals:
-  // ---------------------------------------------------
-  //
-  MBadPixelsCam     badcam;
-  MGeomCamMagic     geomcam;
-  MGeomApply        geomapl;
-  //
-  // If you want to exclude pixels from the beginning, read 
-  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
-  //
-  //  badcam.AsciiRead("badpixels.dat");
-  
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-
-  MJPedestal pedloop;
-  pedloop.SetInput(&pruns);
-  if (usedisplay)
-    {
-      MStatusDisplay *display = new MStatusDisplay;
-      display->SetUpdateTime(3000);
-      display->Resize(850,700);
-      pedloop.SetDisplay(display);
-    }
-  pedloop.SetBadPixels(badcam);
-  pedloop.SetExtractor(&extractor);
-
-  if (!pedloop.Process())
-    return;
-
-//   /****************************************/
-//   /* SECOND LOOP: CALIBRATION COMPUTATION */
-//   /****************************************/
-
-//   //
-//   // Now setup the new tasks for the calibration:
-//   // ---------------------------------------------------
-//   //
-//   MCalibrationQECam qecam;
-//   MJCalibration     calloop;
-//   calloop.SetInput(&cruns);
-//   calloop.SetExtractor(&extractor);
-//   //
-//   // Apply rel. time calibration:
-//   //
-//   calloop.SetRelTimeCalibration();
-//   calloop.SetTimeExtractor(&timeext);
-//   //
-//   // Set the corr. cams:
-//   //
-//   calloop.SetQECam(qecam);
-//   calloop.SetBadPixels(pedloop.GetBadPixels());
-//   //
-//   // The next two commands are for the display:
-//   //
-//   if (usedisplay)
-//       calloop.SetDisplay(display);
-//   cout << "Minchia 0" << endl;
-//   //
-//   // Do the event-loop:
-//   //
-//   if (!calloop.Process(pedloop.GetPedestalCam()))
-//     return;
-  
-//   cout << "Minchia 1" << endl;
-//   /*************************************/
-//   /* THIRD LOOP: PEDESTAL CALIBRATION  */
-//   /*************************************/
-
-//   //
-//   // Create a empty Parameter List and an empty Task List
-//   //
-//   MParList  plist3;
-//   MTaskList tlist3;
-//   plist3.AddToList(&tlist3);
-//   cout << "Minchia 2" << endl;
-//   //
-//   // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
-//   // -----------------------------------------------------------------------------------
-//   //
-  
-//   MCerPhotEvt    nphot;
-//   MPedPhotCam    nphotrms;
-  
-//   plist3.AddToList(&geomcam);
-//   cout << "Minchia 3" << endl;
-//   //
-//   // Retrieve the cameras from the previous runs:
-//   //
-//   plist3.AddToList(&pedloop.GetPedestalCam());
-//   plist3.AddToList(&calloop.GetCalibrationCam());
-//   plist3.AddToList(&calloop.GetQECam());
-//   plist3.AddToList(&calloop.GetRelTimeCam());
-//   plist3.AddToList(&calloop.GetBadPixels());
-//   plist3.AddToList(&nphot);
-//   plist3.AddToList(&nphotrms);
-//     cout << "Minchia 4" << endl;
-//   //tasks
-//   MReadMarsFile read3("Events");
-//   read3.DisableAutoScheme();
-//   static_cast<MRead&>(read3).AddFiles(pruns);  
-
-//   //MCalibrate       photcalc;
-//   MCalibrateData       photcalc;
-//   photcalc.SetCalibrationMode(MCalibrate::kFfactor);
-//   MPedPhotCalc  photrmscalc;  //It doesn't exist yet
-  
-//   tlist3.AddToList(&read3);
-//   tlist3.AddToList(&geomapl);
-//   tlist3.AddToList(&extractor);
-//   tlist3.AddToList(&photrmscalc);
-//   //tlist3.AddToList(&photcalc);
-  
-  
-//   //
-//   // Create and setup the eventloop
-//   //
-//   MEvtLoop evtloop3;
-//   evtloop3.SetParList(&plist3);
-  
-//   //
-//   // Execute first analysis
-//   //
-//   if (!evtloop3.Eventloop())
-//     return;
-  
-//   tlist3.PrintStatistics();
-  
-  /*************************************/
-  /* FOURTH LOOP: DATA CALIBRATION     */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist4;
-  MTaskList tlist4;
-  plist4.AddToList(&tlist4);
-  
-  //
-  // Now setup the tasks and tasklist to analize the data
-  // -----------------------------------------------------
-  //
-  
-  plist4.AddToList(&geomcam);
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist4.AddToList(&pedloop.GetPedestalCam());
-  //  plist4.AddToList(&calloop.GetCalibrationCam());
-  // plist4.AddToList(&calloop.GetQECam());
-  // plist4.AddToList(&calloop.GetRelTimeCam());
-  //plist4.AddToList(&calloop.GetBadPixels());
-  //plist4.AddToList(&nphot);
-  //plist4.AddToList(&nphotrms);
-
-  MArrivalTimeCam times;
-  plist4.AddToList(&times);
-  
-  //tasks
-  MReadMarsFile read4("Events");
-  read4.DisableAutoScheme();
-  static_cast<MRead&>(read4).AddFiles(druns);  
-  
-  MArrivalTimeCalc2   timecalc;
-  //MCalibrateRelTimes  timecal;
-  
-  tlist4.AddToList(&read4);
-  tlist4.AddToList(&geomapl);
-  //tlist4.AddToList(&extractor);
-  tlist4.AddToList(&timecalc);
-  //  tlist4.AddToList(&photcalc);
-  //tlist4.AddToList(&timecal);
-  MRawEvtData *evtData;
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop4;
-  evtloop4.SetParList(&plist4);
-  histTime = new TH1F("histTime","Arrival Time Dist",15,0.0,15.0);
-  Int_t i=0;
-  if (!evtloop4.PreProcess())
-    return;
-  
-  TCanvas *c1 = new TCanvas;
-  MHCamera disp1(geomcam);
-  disp1.SetPrettyPalette();
-  //disp1.SetInvDeepBlueSeaPalette()
-  disp1.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  
-  /*
-  TCanvas *c2 = new TCanvas;
-  MHCamera disp2(geomcam);
-  disp2.SetPrettyPalette();
-  //disp2.SetInvDeepBlueSeaPalette()
-  disp2.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  */
-  while (tlist4.Process())
-    {
-      i++;
-      //disp1.SetCamContent(nphot);
-      
-      //gPad->Modified();
-      //gPad->Update();
-      //      cout << i << endl;
-      //if((i == 16)||(i == 41)||(i == 111)||(i == 173)){
-      if((i == 41)){
-	cout << "Merda" << endl;
-	evtData = (MRawEvtData *)plist4->FindObject("MRawEvtData");
-	cout << "Merda1" << tlist4->FindObject("MRawEvtData") << endl;
-	MRawEvtPixelIter *pixIter = new MRawEvtPixelIter(evtData);
-	cout << "Merda2" << endl;
-	for (Int_t pix=1;pix<576;pix++){	  
-	  pixIter->Next();
-	  cout << "Merda3" << endl;
-	  if(pixIter->GetSumHiGainSamples()>200){
-	    cout << "Merda5" << endl;
-	    cout << "pix #" << pixIter->GetPixelId() << "  FADC Charge = " << pixIter->GetSumHiGainSamples() << endl;
-	    histTime->Fill((times[pix])->GetArrivalTimeHiGain());
-	  }
-	  cout << i << endl;
-	}
-      }
-      
-      /*    
-      disp2.SetCamContent(times);
-      
-      gPad->Modified();
-      gPad->Update();
-      */
-
-      // Remove the comments if you want to go through the file
-      // event-by-event:
-      //if (!HandleInput())
-      //break;
-    }
-
-  evtloop4.PostProcess();
-  histTime->DrawCopy();
-}
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
