Index: trunk/MagicSoft/Mars/mtemp/mmpi/macros/MySkyPlot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mmpi/macros/MySkyPlot.C	(revision 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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 6447)
+++ 	(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);
-*/
