Index: trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.cc	(revision 6939)
+++ 	(revision )
@@ -1,350 +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  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
-!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
-!   Author(s): Abelardo Moralejo 4/2003 <mailto:moralejo@pd.infn.it>
-!   Author(s): Marcos Lopez 5/2004 <mailto:marcos@gae.ucm.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// MMcEnergyEst
-//
-// Class for otimizing the parameters of the energy estimator
-//
-// FIXME: the class must be made more flexible, allowing for different
-// parametrizations to be used. Also a new class is needed, a container
-// for the parameters of the energy estimator.
-// FIXME: the starting values of the parameters are now fixed.
-//
-/////////////////////////////////////////////////////////////////////////////
-#include "MMcEnergyEst.h"
-
-#include <math.h>            // fabs on Alpha
-
-#include <TMinuit.h>
-#include <TStopwatch.h>
-#include <TVirtualFitter.h>
-
-#include "MParList.h"
-#include "MTaskList.h"
-#include "MGeomCamCT1.h"
-#include "MFEventSelector.h"
-#include "MReadTree.h"
-#include "MFCT1SelFinal.h"
-#include "MHMatrix.h"
-#include "MEnergyEstParam.h"
-#include "MMatrixLoop.h"
-#include "MChisqEval.h"
-#include "MEvtLoop.h"
-#include "MDataElement.h"
-#include "MDataMember.h"
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MParameters.h"
-
-ClassImp(MMcEnergyEst);
-
-using namespace std;
-
-//------------------------------------------------------------------------
-//
-// fcn calculates the function to be minimized (using TMinuit::Migrad)
-//
-static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
-{
-    MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
-
-    MParList  *plist  = evtloop->GetParList();
-    MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
- 
-
-    // Pass current minuit parameters to the energy estimation class 
-    MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
-    eest->SetCoeff(TArrayD(eest->GetNumCoeff(), par));
-
-    
-    evtloop->Eventloop();
-
-
-    // Get result of the ChiSquare 
-    MParameterD *eval = (MParameterD*)plist->FindObject("MFitResult", "MParameterD");
-    
-    f = eval->GetVal();
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Default constructor.
-//
-MMcEnergyEst::MMcEnergyEst(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MMcEnergyEst";
-    fTitle = title ? title : "Optimizer of the energy estimator";
-
-    SetHillasName("MHillas");
-    SetHillasSrcName("MHillasSrc");
-
-    //
-    // Set initial values of the parameters (close enough to the final 
-    // ones, taken from previous runs of the procedure). Parameter 
-    // fA[4] is not used in the default energy estimation model (from 
-    // D. Kranich).
-    //
-    fA.Set(5);
-    fB.Set(7);
-
-    fA[0] =  21006.2;
-    fA[1] = -43.2648;
-    fA[2] = -690.403;
-    fA[3] = -0.0428544;
-    fA[4] =  1.;
-    fB[0] = -3391.05;
-    fB[1] =  136.58;
-    fB[2] =  0.253807;
-    fB[3] =  254.363;
-    fB[4] =  61.0386;
-    fB[5] = -0.0190984;
-    fB[6] = -421695;
-}
-
-Bool_t MMcEnergyEst::SetCoeff(TArrayD &coeff)
-{
-  if (coeff.GetSize() != fA.GetSize()+fB.GetSize())
-    {
-      *fLog << err << dbginf << "Wrong number of parameters!" << endl;
-      return(kFALSE);
-    }
-
-  for (Int_t i = 0; i < fA.GetSize(); i++)
-    fA[i] = coeff[i];
-  for (Int_t i = 0; i < fB.GetSize(); i++)
-    fB[i] = coeff[i+fA.GetSize()];
-
-  return(kTRUE);
-
-}
-
-//------------------------------------------------------------------------
-//
-// Optimization (via migrad minimization) of parameters of energy estimation.
-//
-void MMcEnergyEst::FindParams()
-{
-  MParList parlist;
-
-  MFEventSelector selector;
-  selector.SetNumSelectEvts(fNevents);
-  *fLog << inf << "Read events from file '" << fInFile << "'" << endl;    
-
-  MReadTree read("Events");
-  read.AddFile(fInFile);
-  read.DisableAutoScheme();
-  read.SetSelector(&selector);
-
-  *fLog << inf << "Define columns of matrix" << endl;
-  MHMatrix matrix;
-  Int_t colenergy = matrix.AddColumn("MMcEvt.fEnergy");
-  Int_t colimpact = matrix.AddColumn("MMcEvt.fImpact");
-
-  if (colenergy < 0  ||  colimpact < 0)
-  {
-    *fLog << err << dbginf << "colenergy, colimpact = " << colenergy << ",  " 
-	  << colimpact << endl;
-    return;
-  }
-
-  MEnergyEstParam eest(fHillasName);
-  eest.Add(fHillasSrcName);
-  eest.InitMapping(&matrix);
-  
-  *fLog << inf << "--------------------------------------" << endl;
-  *fLog << inf << "Fill events into the matrix" << endl;
-  if ( !matrix.Fill(&parlist, &read, fEventFilter) )
-    return;
-  *fLog << inf << "Matrix was filled with " << matrix.GetNumRows() 
-	<< inf << " events" << endl;  
-
-  //-----------------------------------------------------------------------
-  //
-  // Setup the eventloop which will be executed in the fcn of MINUIT 
-  //
-  *fLog << inf << "--------------------------------------" << endl;
-  *fLog << inf << "Setup event loop to be used in 'fcn'" << endl;
-
-  MTaskList tasklist;
-
-  MMatrixLoop loop(&matrix);
-
-  MChisqEval eval;
-  eval.SetY1(new MDataElement(&matrix, colenergy));
-  eval.SetY2(new MDataMember("MEnergyEst.fEnergy"));
-  eval.SetOwner();
-
-  //
-  // Entries in MParList
-
-  parlist.AddToList(&tasklist);
-
-  //
-  // Entries in MTaskList
-
-  tasklist.AddToList(&loop);
-  tasklist.AddToList(&eest);
-  tasklist.AddToList(&eval);
-
-
-  *fLog << inf << "Event loop was setup" << endl;
-  MEvtLoop evtloop;
-  evtloop.SetParList(&parlist);
-
-  //
-  //----------   Start of minimization part   -------------------- 
-  //
-  // Do the minimization with MINUIT
-  //
-  // Be careful: This is not thread safe
-  //
-  *fLog << inf << "--------------------------------------" << endl;
-  *fLog << inf << "Start minimization for the energy estimator" << endl;
-
-  gMinuit = new TMinuit(12);
-  gMinuit->SetPrintLevel(-1);
-
-  gMinuit->SetFCN(fcn);
-  gMinuit->SetObjectFit(&evtloop);
-
-  // Ready for: gMinuit->mnexcm("SET ERR", arglist, 1, ierflg)
-
-  if (gMinuit->SetErrorDef(1))
-    {
-      *fLog << err << dbginf << "SetErrorDef failed." << endl;
-      return;
-    }
-
-  //
-  // Set starting values and step sizes for parameters
-  //
-  for (Int_t i=0; i<fA.GetSize(); i++)
-    {
-      TString name = "fA[";
-      name += i;
-      name += "]";
-      Double_t vinit = fA[i];
-      Double_t step  = fabs(fA[i]/3);
-
-      Double_t limlo = 0; // limlo=limup=0: no limits
-      Double_t limup = 0; 
-
-      Bool_t rc = gMinuit->DefineParameter(i, name, vinit, step, limlo, limup);
-      if (!rc)
-	continue;
-
-      *fLog << err << dbginf << "Error in defining parameter #" << i << endl;
-      return;
-    }
-
-  for (Int_t i=0; i<fB.GetSize(); i++)
-    {
-      TString name = "fB[";
-      name += i;
-      name += "]";
-      Double_t vinit = fB[i];
-      Double_t step  = fabs(fB[i]/3);
-
-      Double_t limlo = 0; // limlo=limup=0: no limits
-      Double_t limup = 0;
-
-      Bool_t rc = gMinuit->DefineParameter(i+fA.GetSize(), name, vinit, step, limlo, limup);
-      if (!rc)
-	continue;
-
-      *fLog << err << dbginf << "Error in defining parameter #" << i+fA.GetSize() << endl;
-      return;
-    }
-
-  TStopwatch clock;
-  clock.Start();
-
-  // Now ready for minimization step:
-
-  gLog.SetNullOutput(kTRUE);
-  Bool_t rc = gMinuit->Migrad();
-  gLog.SetNullOutput(kFALSE);
-  
-  if (rc)
-    {
-      *fLog << err << dbginf << "Migrad failed." << endl;
-      return;
-    }
-
-  *fLog << inf << endl;
-  clock.Stop();
-  clock.Print();
-  *fLog << inf << endl;
-
-  *fLog << inf << "Resulting Chisq: " << gMinuit->fAmin << endl;
-
-  //
-  // Update values of fA, fB:
-  //
-  for (Int_t i = 0; i < fA.GetSize(); i++)
-    {
-      Double_t x1, x2;
-      gMinuit->GetParameter(i,x1,x2);
-      fA[i] = x1;
-    }
-  for (Int_t i = fA.GetSize(); i < fA.GetSize()+fB.GetSize(); i++)
-    {
-      Double_t x1, x2;
-      gMinuit->GetParameter(i,x1,x2);
-      fB[i-fA.GetSize()] = x1;
-    }
-
-  //    eest.Print();
-  eest.StopMapping();
-  *fLog << inf << "Minimization for the energy estimator finished" << endl;
-
-}
-
-//------------------------------------------------------------------------
-//
-// Print current values of parameters
-//
-void MMcEnergyEst::Print(Option_t *o) const
-{
-  for (Int_t i = 0; i < fA.GetSize(); i++)
-    *fLog << inf << "Parameter " << i << ": " << const_cast<TArrayD&>(fA)[i] << endl;
-
-  for (Int_t i = fA.GetSize(); i < fA.GetSize()+fB.GetSize(); i++)
-    *fLog << inf << "Parameter " << i << ": " << const_cast<TArrayD&>(fB)[i-fA.GetSize()] << endl;
-
-  /*
-    // Print results
-    Double_t amin, edm, errdef;
-    Int_t nvpar, nparx, icstat;
-    gMinuit->mnstat(amin, edm, errdef, nvpar, nparx, icstat);
-    gMinuit->mnprin(3, amin);
-  */
-
-}
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcEnergyEst.h	(revision 6939)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#ifndef MARS_MMcEnergyEst
-#define MARS_MMcEnergyEst
-
-#ifndef MARS_MParContainer
-#include "MParContainer.h"
-#endif
-
-#ifndef ROOT_TArrayD
-#include <TArrayD.h>
-#endif
-
-#include "MFilter.h"
-
-class MMcEnergyEst : public MParContainer
-{
-private:
-
-  TString fInFile, fOutFile;
-  TString fHillasName;
-  TString fHillasSrcName;
-  Int_t   fNevents;
-
-  MFilter *fEventFilter; //!
-
-  TArrayD fA;
-  TArrayD fB;
-
-public:
-  MMcEnergyEst(const char *name=NULL, const char *title=NULL);
-
-  void SetInFile(const TString &name)         {fInFile = name;}
-  void SetOutFile(const TString &name)        {fOutFile = name;}
-  void SetHillasName(const TString &name)     {fHillasName = name;}
-  void SetHillasSrcName(const TString &name)  {fHillasSrcName = name;}
-  void SetEventFilter(MFilter *filter)        {fEventFilter = filter;}
-  void SetNevents(Int_t n)                    {fNevents = n;}
-
-  TString GetInFile()         const {return fInFile;}
-  TString GetOutFile()        const {return fOutFile;}
-  TString GetHillasName()     const {return fHillasName;}
-  TString GetHillasSrcName()  const {return fHillasSrcName;}
-  Int_t   GetNevents()        const {return fNevents;}
-
-  Int_t   GetNumCoeffA()      const {return fA.GetSize(); }
-  Int_t   GetNumCoeffB()      const {return fB.GetSize(); }
-
-  Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }
-
-  Bool_t SetCoeff(TArrayD &coeff);
-
-  void FindParams();
-  void Print(Option_t *o="") const;
-
-  ClassDef(MMcEnergyEst, 1) // Class for optimization of Energy estimator
-};
-
-#endif
-
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 6939)
+++ 	(revision )
@@ -1,90 +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>
-!   Author(s): Harald Kornmayer 1/2001
-!
-!   Copyright: MAGIC Software Development, 2000-2001
-!
-!
-\* ======================================================================== */
-
-#include "MMcTimeGenerate.h"
-
-#include "MLog.h"
-#include "MLogManip.h"
-
-#include "MParList.h"
-#include "MTime.h"
-
-ClassImp(MMcTimeGenerate);
-
-// --------------------------------------------------------------------------
-//
-MMcTimeGenerate::MMcTimeGenerate(const char *name, const char *title)
-{
-    fName  = name  ? name  : "MMcTimeGenerate";
-    fTitle = title ? title : "Task to generate a random event time";
-
-    const Double_t lambda = 100; // [Hz]
-
-    fFunc = new TF1("Poisson", "[0] * exp(-[0]*x)", 0, 1);
-    fFunc->SetParameter(0, lambda);
-
-    fDeadTime = 0.1/lambda;
-}
-
-MMcTimeGenerate::~MMcTimeGenerate()
-{
-    delete fFunc;
-}
-
-
-// --------------------------------------------------------------------------
-//
-//  The PreProcess connects the raw data with this task. It checks if the 
-//  input containers exist, if not a kFalse flag is returned. It also checks
-//  if the output contaniers exist, if not they are created.
-//  This task can read either Montecarlo files with multiple trigger
-//  options, either Montecarlo files with a single trigger option.
-//
-Int_t MMcTimeGenerate::PreProcess (MParList *pList)
-{
-    // connect the raw data with this task
-
-    fTime = (MTime*)pList->FindCreateObj("MTime");
-    if (!fTime)
-        return kFALSE;
-
-    return kTRUE;
-}
-
-// --------------------------------------------------------------------------
-//
-//
-Int_t MMcTimeGenerate::Process()
-{
-    Double_t dt;
-
-    do dt = fFunc->GetRandom();
-    while (dt < fDeadTime);
-
-#warning SetTime not valid anymore!
-//    fTime->SetTime(*fTime+dt/1e4); // [0.1ms]
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 6939)
+++ 	(revision )
@@ -1,33 +1,0 @@
-#ifndef MARS_MMcTimeGenerate
-#define MARS_MMcTimeGenerate
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-#ifndef ROOT_TF1
-#include "TF1.h"
-#endif
-
-class MParList;
-class MTime;
-
-class MMcTimeGenerate : public MTask
-{
-private:
-    MTime    *fTime;        //!
-    TF1      *fFunc;        //!
-
-    Double_t fDeadTime;
-
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-
-public:
-    MMcTimeGenerate(const char *name=NULL, const char *title=NULL);
-
-    ~MMcTimeGenerate();
-
-    ClassDef(MMcTimeGenerate, 0) // To generate a random time
-};
-
-#endif 
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcWeightEnergySpecCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcWeightEnergySpecCalc.cc	(revision 6939)
+++ 	(revision )
@@ -1,358 +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): Marcos Lopez  10/2003 <mailto:marcos@gae.ucm.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2003
-!
-!
-\* ======================================================================== */
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  MMcWeightEnergySlopeCalc
-//               
-//  Change the spectrum of the MC showers simulated with Corsika (a power law)
-//  to a new one, which can be either, again a power law but with a different
-//  spectral index, or a generalizeed spectrum. The new spectrum can be 
-//  pass to this class in different ways:
-//    1. Is the new spectrum will be a power law, just introduce the slope
-//       of this power law.
-//    2. Is the new spectrum will have a general shape, different options are
-//       available:
-//       a) The new spectrum is pass as a TF1 function 
-//       b) The new spectrum is pass as a char*
-//       c) The new spectrum is pass as a "interpreted function", i.e., a 
-//          function defined inside a ROOT macro, which will be invoked by the
-//          ROOT Cint itself. This is the case when we use ROOT macros.
-//       d) The new spectrum is pass as a "real function", i.e., a 
-//          function defined inside normal c++ file.
-//
-//  Method:
-//  ------ 
-//                                 
-//  -Corsika spectrun: dN/dE = A * E^(a)  
-//    with a = fCorsikaSlope, and A = N/integral{E*de} from ELowLim to EUppLim
-//
-//  -New spectrum:     dN/dE = B * g(E)
-//    where B = N/integral{g*dE} from ELowLim to EUppLim, and N=NumEvents 
-//
-//  For converting the spectrum simulated with Corsika to the new one, we apply
-//  a weight to each event, given by:
-//
-//     W(E) = B/A * g(E)/E^(a) 
-//
-//  In the case the new spectrum is simply a power law: dN/dE = B * E^(b), we
-//  have: 
-//
-//     W(E) = B/A * E^(b-a) 
-//
-//  (The factor B/A is used in order both the original and new spectrum have 
-//   the same area (i.e. in order they represent the same number of showers))
-//
-//  Note:
-//  ------
-//   -If the the new spectrum is just a power law (i.e. the user only specify
-//     the slope), the needed calculations (such as the integral of the 
-//     spectrum) are done analytically. But if the new spectrum is given as a 
-//     TF1 object, the calculations is done numerically.
-//
-//  ToDo:
-//  ----- 
-//   -Give to the user also the possibility to specify the integral of the 
-//    spectrum as another TF1 object (or C++ function)
-//
-//
-//  Input Containers:                         
-//   MMcEvt, MMcRunHeader, MMcCorsikaRunHeader
-//                                            
-//  Output Container:                        
-//   MWeight [MParameterD]
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include "MMcWeightEnergySpecCalc.h"
-
-#include "MParList.h"
-#include "MLog.h"
-#include "MLogManip.h"
-#include "MMcEvt.hxx"
-#include "MMcRunHeader.hxx"
-#include "MMcCorsikaRunHeader.h"
-#include "MParameters.h"
-
-#include "TF1.h"
-#include "TGraph.h"
-
-ClassImp(MMcWeightEnergySpecCalc);
-
-using namespace std;
-
-
-
-void MMcWeightEnergySpecCalc::Init(const char *name, const char *title)
-{
-
-    fName  = name  ? name  : "MMcWeightEnergySpecCalc";
-    fTitle = title ? title : "Task to calculate weights to change the energy spectrum"; 
-    
-    AddToBranchList("MMcEvt.fEnergy");
-
-    fAllEvtsTriggered         =  kFALSE;
-    fTotalNumSimulatedShowers =  0;
-}
-
-
-// ---------------------------------------------------------------------------
-//
-// Constructor. The new spectrum will be just a power law.
-//
-MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(Float_t slope, 
-                                                 const char *name, const char *title)
-{
-    fNewSpecIsPowLaw = kTRUE;
-    fNewSlope = slope; 
-
-    fNewSpectrum = NULL; 
-
-    Init(name,title);
-} 
-
-// ---------------------------------------------------------------------------
-//
-// Constructor. The new spectrum will have a general shape, given by the user 
-// as a TF1 function.
-//
-MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(const TF1& spectrum, 
-                                                 const char *name, const char *title)
-{
-    fNewSpecIsPowLaw = kFALSE;
-    fNewSpectrum = (TF1*)spectrum.Clone();
-
-    Init(name,title);
-} 
-
-// ---------------------------------------------------------------------------
-//
-// As before, but the function which represent the new spectrum is given as
-// a char* . Starting from it, we build a TF1 function
-//
-MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(const char* spectrum, 
-                                                 const char *name, const char *title)
-{
-    fNewSpecIsPowLaw = kFALSE;
-    fNewSpectrum = new TF1("NewSpectrum",spectrum);
-
-    Init(name,title);
-} 
-
-// ---------------------------------------------------------------------------
-//
-// As before, but the new spectrum is given as a intrepreted C++ function. 
-// Starting from it we build a TF1 function.
-// This constructor is called for interpreted functions by CINT, i.e., when
-// the functions are declared inside a ROOT macro.
-//
-// NOTE: you muss do a casting to (void*) of the function that you pass to this
-//       constructor before invoking it in a macro, e.g.
-//
-//       Double_t myfunction(Double_t *x, Double_t *par)
-//         {
-//           ...
-//         }
-//
-//        MMcWeightEnergySpecCalc wcalc((void*)myfunction); 
-//
-//        tasklist.AddToList(&wcalc);
-//
-//        otherwise ROOT will invoke the constructor McWeightEnergySpecCalc(
-//         const char* spectrum, const char *name, const char *title)
-//
-MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(void* function, 
-                                                 const char *name, const char *title)
-{
-    fNewSpecIsPowLaw = kFALSE;
-    fNewSpectrum = new TF1("NewSpectrum",function,0,1,1);
-
-    Init(name,title);
-} 
-
-// ---------------------------------------------------------------------------
-//
-// As before, but this is the constructor for real functions, i.e. it is called
-// when invoked with the normal C++ compiler, i.e. not inside a ROOT macro.
-//
-MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(Double_t (*function)(Double_t*x, Double_t* par), const Int_t npar,  const char *name, const char *title)
-{
-    fNewSpecIsPowLaw = kFALSE;
-    fNewSpectrum = new TF1("NewSpectrum",function,0,1,1);
-
-    Init(name,title);
-} 
-
-
-
-// ----------------------------------------------------------------------------
-//
-// Destructor. Deletes the cloned fNewSpectrum.
-//
-MMcWeightEnergySpecCalc::~MMcWeightEnergySpecCalc()
-{
-  if (fNewSpectrum)
-    delete fNewSpectrum; 
-}
-
-
-
-// ---------------------------------------------------------------------------
-//
-//
-Int_t MMcWeightEnergySpecCalc::PreProcess (MParList *pList)
-{
-
-    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
-    if (!fMcEvt)
-      {
-	*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
-	return kFALSE;
-      }
-
-    fWeight = (MParameterD*)pList->FindCreateObj("MParameterD", "MWeight");
-    if (!fWeight)
-	return kFALSE;
-    
-    return kTRUE;
-}
-
-
-
-// ----------------------------------------------------------------------------
-//
-// Executed each time a new root file is loaded
-// We will need fCorsikaSlope and fE{Upp,Low}Lim to calculate the weights
-//
-Bool_t MMcWeightEnergySpecCalc::ReInit(MParList *plist)
-{
-    MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
-    if (!runheader)
-    {
-      *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
-      return kFALSE;
-    }
-
-    MMcCorsikaRunHeader *corrunheader  = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
-    if (!corrunheader)
-      {
-	*fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
-	return kFALSE;
-      }
-
-
-    fCorsikaSlope = (Double_t)corrunheader->GetSlopeSpec();
-    fELowLim      = (Double_t)corrunheader->GetELowLim();
-    fEUppLim      = (Double_t)corrunheader->GetEUppLim();
-
-    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();    
-    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();    
-
-
-
-    *fLog << inf << "Slope of primaries' energy spectrum of Simulated showers: " << fCorsikaSlope << endl;
-    *fLog << inf << "Limits of energy range of Simulated showers: " 
-	  << fELowLim <<" - " << fEUppLim << endl;
-    *fLog << inf << "New Slope for Simulated showers: " << fNewSlope << endl;
-    *fLog << inf << "Total Number of Simulated showers: " 
-	  << fTotalNumSimulatedShowers << endl;    
-    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
-
-
-
-    //
-    // Sanity checks to be sure that we won't divide by zero later on
-    //
-    if(fCorsikaSlope == -1. || fNewSlope == -1.) 
-      {
-	*fLog << err << "The Slope of the power law must be different of -1... exit" << endl;
-	return kFALSE;
-      }
-
-
-    //
-    // Starting from fCorsikaSlope and fE{Upp,Low}Lim, calculate the integrals
-    // of both, the original Corsika spectrum and the new one.
-    //
-    //
-    // For the Corsika simulated spectrum (just a power law), we have:
-    //
-    fCorSpecInt = ( pow(fEUppLim,1+fCorsikaSlope) - pow(fELowLim,1+fCorsikaSlope) ) / ( 1+fCorsikaSlope );
- 
- 
-    //
-    // For the new spectrum:
-    //
-    if (fNewSpecIsPowLaw)     // just the integral of a power law
-      {
-	fNewSpecInt = ( pow(fEUppLim,1+fNewSlope) - pow(fELowLim,1+fNewSlope) )/ ( 1+fNewSlope );
-      }
-    else
-      { 
-	fNewSpectrum->SetRange(fELowLim, fEUppLim);
-
-	// In this case we have to integrate the new spectrum numerically. We 
-	// could do simply fNewSpectrum->Integral(fELowLim,fEUppLim), but ROOT
-	// fails integrating up to fEUppLim for a sharp cutoff spectrum
-	
-	//
-	// Trick to calculate the integral numerically (it works better than 
-	// fNewSpectrum->Integral(fELowLim,fEUppLim) (although not perfectlly)
-	//
-	fNewSpectrum->SetNpx(1000);
-	TGraph gr(fNewSpectrum,"i");
-	Int_t Npx = gr.GetN();
-	Double_t* y = gr.GetY();
-
-	const Double_t integral = y[Npx-1];
-	fNewSpecInt = integral; 
-    }
-
-
-    return kTRUE;
-}
-
-
-
-// ----------------------------------------------------------------------------
-//
-//
-Int_t MMcWeightEnergySpecCalc::Process()
-{
-    const Double_t energy = fMcEvt->GetEnergy();
-
-    const Double_t C = fCorSpecInt / fNewSpecInt;
-    Double_t weight = C;
-
-
-    if (fNewSpecIsPowLaw)   
-        weight *= pow(energy,fNewSlope-fCorsikaSlope);
-    else
-        weight *= fNewSpectrum->Eval(energy) / pow(energy,fCorsikaSlope);
-     
-
-    fWeight->SetVal(weight);
-
-    return kTRUE;
-}
Index: trunk/MagicSoft/Mars/mmontecarlo/MMcWeightEnergySpecCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mmontecarlo/MMcWeightEnergySpecCalc.h	(revision 6939)
+++ 	(revision )
@@ -1,76 +1,0 @@
-#ifndef MARS_MMcWeightEnergySpecCalc
-#define MARS_MWeigthEnergySlopeCalc
-
-#ifndef MARS_MTask
-#include "MTask.h"
-#endif
-
-
-class MParList;
-class MMcEvt;
-class MParameterD;
-class TF1;
-
-
-class MMcWeightEnergySpecCalc : public MTask
-{
-
- private:
-
-    const MMcEvt *fMcEvt;
-    MParameterD  *fWeight;
-
-    TF1*     fNewSpectrum;     // Function with the new spectrum
-
-    Bool_t   fNewSpecIsPowLaw; // Tells whether the new spectrum is introduced 
-                               //as a TF1 object or not
-    Double_t fCorsikaSlope; // Slope of energy spectrum generated with Corsika
-    Double_t fNewSlope;     // Slope of the new spectrum (if it is a power law)
-    Double_t fELowLim;      
-    Double_t fEUppLim;      // Limits of energy range for generation
-    Double_t fCorSpecInt;   // Value of the integrals of the Corsika and new
-    Double_t fNewSpecInt;   //spectrum respectively, between fElow and fUppLim
-
-    UInt_t   fTotalNumSimulatedShowers;
-    Bool_t   fAllEvtsTriggered;
-
-    void   Init(const char *name, const char *title);
-    Bool_t ReInit(MParList *plist); 
-
-    Int_t PreProcess(MParList *pList);
-    Int_t Process();
-   
-
- public:
-
-    MMcWeightEnergySpecCalc(const Float_t slope,
-			    const char *name=NULL, const char *title=NULL);
-
-    MMcWeightEnergySpecCalc(const TF1& spectrum,
-			    const char *name=NULL, const char *title=NULL);
-
-    MMcWeightEnergySpecCalc(const char* spectrum,
-			    const char *name=NULL, const char *title=NULL);
-   
-    MMcWeightEnergySpecCalc(void *function,
-			    const char *name=NULL, const char *title=NULL);
- 
-    MMcWeightEnergySpecCalc(Double_t (*function)(Double_t* x, Double_t* par),
-	      const Int_t npar, const char *name=NULL, const char *title=NULL);
-    
-
-    ~MMcWeightEnergySpecCalc();
-
-
-    ClassDef(MMcWeightEnergySpecCalc, 0) // Task to convert the spectrum of the MC showers simulated with Corsika to a different one, by using weights
-};
-
-#endif 
-
-
-
-
-
-
-
-
