Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/AlphaPlot.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/AlphaPlot.C	(revision 4992)
+++ 	(revision )
@@ -1,63 +1,0 @@
-void AlphaPlot(TString onsource="hillas_Mrk421.root", TString offsource="hillas_OffMrk421.root")
-{
-  const Int_t kMinDeg = 25;
-
-  Int_t i;
-  Float_t EvtOn = 0;
-  Float_t EvtOff = 0;
-
-  TH1F *hon = new TH1F("hon","On Source Histogram",19,0,95);
-  TH1F *hoff = new TH1F("hoff","Off Source Histogram",19,0,95);
-  TH1F *htemp;
-
-  fon = new TFile(onsource,"READ");
-
-  htemp = (TH1F *)fon->FindObjectAny("hAlpha");
-  
-  for(i=0;i<19;i++)
-    hon->SetBinContent(i,htemp->GetBinContent(i));
-
-  for(i=0;i<hon->GetNbinsX();i++){
-    if(hon->GetBinCenter(i) > kMinDeg)
-      EvtOn += hon->GetBinContent(i);
-  }
-
-  fon->Close();
-
-  foff = new TFile(offsource,"READ");
-
-  htemp = (TH1F *)foff->FindObjectAny("hAlpha");
-  for(i=0;i<19;i++)
-    hoff->SetBinContent(i,htemp->GetBinContent(i));
-
-  for(i=0;i<hoff->GetNbinsX();i++){
-    if(hoff->GetBinCenter(i) > kMinDeg)
-      EvtOff += hoff->GetBinContent(i);
-  }
-
-  foff->Close();
-
-  Float_t norm = EvtOn/EvtOff;
-  cout << "EvtOn/EvtOff = " << norm << endl;
-
-  Float_t eccessi = 0;
-  Float_t Noff = 0;
-
-  TH1F *hAlphaPlot = new TH1F("hAlphaPlot","Alpha Plot", 19,0,95);
-  for(i=0; i<hon->GetNbinsX(); i++){
-    hAlphaPlot->SetBinContent(i,hon->GetBinContent(i)-hoff->GetBinContent(i)*norm);
-    if(hAlphaPlot->GetBinCenter(i) < 15){
-      eccessi += hAlphaPlot->GetBinContent(i);
-      Noff += norm*hoff->GetBinContent(i);
-    }
-  }
-
-  cout << "Eccessi = " << eccessi << "   Nsigma = " << eccessi/(TMath::Sqrt(Noff)) <<endl;
-
-  new TCanvas("Alpha On","Alpha plot ON source");
-  hon->DrawCopy();
-  new TCanvas("Alpha Off","Alpha plot OFF source");
-  hoff->DrawCopy();
-  new TCanvas("Alpha","Resulting alpha plot");
-  hAlphaPlot->DrawCopy();
-}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/HillasAnal.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/HillasAnal.C	(revision 4992)
+++ 	(revision )
@@ -1,191 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
-! * Software. It is distributed to you in the hope that it can be a useful
-! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
-! * It is distributed WITHOUT ANY WARRANTY.
-! *
-! * Permission to use, copy, modify and distribute this software and its
-! * documentation for any purpose is hereby granted without fee,
-! * provided that the above copyright notice appear in all copies and
-! * that both that copyright notice and this permission notice appear
-! * in supporting documentation. It is provided "as is" without express
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////
-//
-// MagicHillas.C
-// =============
-//
-// This is a demonstration program which calculates image (Hillas +)
-// parameters using as input a Merpp output file (raw data).
-// All parameters are written to an output file called hillas.root. Also
-// filles histograms are displayed.
-// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
-// is used.
-//
-///////////////////////////////////////////////////////////////////////////
-
-void HillasAnal(const char *filename="output_test.root")
-{
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    //
-    // Use this if you want to change the binning of one of
-    // the histograms. You can use:
-    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
-    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
-    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
-    // BinningPixels and BinningCamera
-    //
-    // For more information see MBinning and the corresponding
-    // histograms
-    //
-    // MBinning binsalpha("BinningAlpha");
-    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
-    // plist.AddToList(&binsalpha);
-
-    // MBinning binssize("BinningSize");
-    // binssize.SetEdgesLog(50, 1, 1e7);
-    // plist.AddToList(&binssize);
-
-    //
-    // Craete the object which hlods the source positions in the camera
-    // plain in respect to which the image parameters will be calculated.
-    // For real data the containers will be filled by a task.
-    //
-    MSrcPosCam source;
-    source.SetReadyToSave();
-    plist.AddToList(&source);
-
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-    // The first argument is the tree you want to read.
-    //   Events:     Cosmic ray events
-    //   PedEvents:  Pedestal Events
-    //   CalEvents:  Calibration Events
-    //
-    MReadMarsFile read("Events", filename);
-    read.DisableAutoScheme();
-
-    // Setup a task which makes sure that all used arrays have
-    // the correct size
-    MGeomApply geomapl;
-
-    // tasks used if MC files are detected to calculate pedestals
-    // MMcPedestalCopy pcopy;
-    // MMcPedestalNSBAdd pnsb;
-
-    // calculate the signal in a very simple way
-    // for real adat files use MCerPhotAnal2 instead which also
-    // calculates the pedestal.
-    // MCerPhotCalc ncalc;
-    //
-    //  Alternative photon calculation:
-    //  Example: use only 2nd to 6th FADC slices for photon calculation:
-    //
-    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-    //    const TArrayF w(15,(Float_t*)x);
-    //    ncalc.SetWeights(w);
-    //
-
-    // setup image cleaning and blind pixel treatment
-    MImgCleanStd    clean;
-    MBlindPixelCalc blind;
-
-    //
-    // Instead of unmapping the pixels you can also (The use of this
-    // class is deprecated, it will be replaced by MBadPixels*)
-    //
-    // blind.SetUseInterpolation();
-    // blind.SetUseCetralPixel();
-    //
-
-    // setup tasks to calculate image parameters
-    MHillasCalc    hcalc;
-    MHillasSrcCalc csrc1;
-
-    // setup tasks to fill histograms
-    MFillH hfill1("MHHillas", "MHillas");
-    MFillH hfill2("MHHillasExt");
-    MFillH hfill3("MHStarMap", "MHillas");
-    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
-    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
-    //MFillH hfill6("MHNewImagePar");
-
-    // setup task to write containers to a file
-    MWriteRootFile write("hillas_Mrk421.root");
-    write.AddContainer("MHillas");
-    write.AddContainer("MHillasExt");
-    write.AddContainer("MHillasSrc");
-    write.AddContainer("MRawEvtHeader");
-    write.AddContainer("MRawRunHeader");
-    //write.AddContainer("HistExtSource");
-    //write.AddContainer("MHNewImagePar");
-
-    // Setup the contents of zour tasklist
-    tlist.AddToList(&read);
-    tlist.AddToList(&geomapl);
-    //tlist.AddToList(&pcopy);
-    //tlist.AddToList(&pnsb);
-    //tlist.AddToList(&ncalc);
-    tlist.AddToList(&clean);
-    tlist.AddToList(&blind);
-
-    tlist.AddToList(&hcalc);
-    tlist.AddToList(&csrc1);
-
-    tlist.AddToList(&hfill1);
-    tlist.AddToList(&hfill2);
-    tlist.AddToList(&hfill3);
-    tlist.AddToList(&hfill4);
-    tlist.AddToList(&hfill5);
-    //tlist.AddToList(&hfill6);
-    tlist.AddToList(&write);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    //
-    // Execute your analysis
-    //
-    MProgressBar bar;
-    evtloop.SetProgressBar(&bar);
-    if (!evtloop.Eventloop())
-        return;
-
-    tlist.PrintStatistics();
-
-    //
-    // After the analysis is finished we can display the histograms
-    //
-    plist.FindObject("MHHillas")->DrawClone();
-    plist.FindObject("MHHillasExt")->DrawClone();
-    plist.FindObject("MHStarMap")->DrawClone();
-    plist.FindObject("HistSource")->DrawClone();
-    plist.FindObject("HistExtSource")->DrawClone();
-    //plist.FindObject("MHNewImagePar")->DrawClone();
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C	(revision 4992)
+++ 	(revision )
@@ -1,685 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
-! * Software. It is distributed to you in the hope that it can be a useful
-! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
-! * It is distributed WITHOUT ANY WARRANTY.
-! *
-! * Permission to use, copy, modify and distribute this software and its
-! * documentation for any purpose is hereby granted without fee,
-! * provided that the above copyright notice appear in all copies and
-! * that both that copyright notice and this permission notice appear
-! * in supporting documentation. It is provided "as is" without express
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-//////////////////////////////////////////////////////////////////////////////
-//
-// pedestalstudies_pisa.C
-//
-// macro to study the pedestal and pedestalRMS with the number of FADC 
-// slices summed up. 
-//
-/////////////////////////////////////////////////////////////////////////////////
-const TString pedfile = "/data0/Temp/20040422_23203_P_Mrk421_E.root";
-
-void pedestalstudies_pisa(const TString pedname=pedfile, Int_t pixin=0, Int_t pixout=397,TString f2="",TString f3="",TString f4="",TString f5="")
-{
-
-  Int_t loops = 1;
-  Int_t stepsize = 2;
-
-  gStyle->SetOptStat(1111);
-  gStyle->SetOptFit();
-  
-  TArrayF *hmeandiffinn = new TArrayF(loops);
-  TArrayF *hrmsdiffinn  = new TArrayF(loops);
-  TArrayF *hmeandiffout = new TArrayF(loops);
-  TArrayF *hrmsdiffout  = new TArrayF(loops);
-  TArrayF *hmeaninn  = new TArrayF(loops);
-  TArrayF *hmeanout  = new TArrayF(loops);
-  TArrayF *hrmsinn   = new TArrayF(loops);
-  TArrayF *hrmsout   = new TArrayF(loops);
-  TArrayF *hmuinn    = new TArrayF(loops);
-  TArrayF *hmuout    = new TArrayF(loops);
-  TArrayF *hsigmainn = new TArrayF(loops);
-  TArrayF *hsigmaout = new TArrayF(loops);
-
-  TArrayF *hmeandiffinnerr = new TArrayF(loops);
-  TArrayF *hrmsdiffinnerr  = new TArrayF(loops);
-  TArrayF *hmeandiffouterr = new TArrayF(loops);
-  TArrayF *hrmsdiffouterr  = new TArrayF(loops);
-  TArrayF *hmeaninnerr  = new TArrayF(loops);
-  TArrayF *hmeanouterr  = new TArrayF(loops);
-  TArrayF *hrmsinnerr   = new TArrayF(loops);
-  TArrayF *hrmsouterr   = new TArrayF(loops);
-  TArrayF *hmuinnerr    = new TArrayF(loops);
-  TArrayF *hmuouterr    = new TArrayF(loops);
-  TArrayF *hsigmainnerr = new TArrayF(loops);
-  TArrayF *hsigmaouterr = new TArrayF(loops);
-
-
-  MStatusDisplay *display = new MStatusDisplay;
-  display->SetUpdateTime(500);
-  display->Resize(850,700);
-      
-  //
-  // Create a empty Parameter List and an empty Task List
-  // The tasklist is identified in the eventloop by its name
-  //
-  MParList  plist;
-  MTaskList tlist;
-  plist.AddToList(&tlist);
-
-  TString tabname="";
-
-  for (Int_t samples=2; samples < stepsize*loops+1; samples=samples+stepsize)
-    {
-
-      plist.Reset();
-      tlist.Reset();
-      
-      //
-      // Now setup the tasks and tasklist for the pedestals:
-      // ---------------------------------------------------
-      //
-      
-      MReadMarsFile read("Events", pedname);
-      read.DisableAutoScheme();
-     
-	Int_t neventi;
- 	neventi=1000;
-
-	Float_t samplingRate=500;	//Hz
-	if (f2!=""){
-	read.AddFile(f2);
-	neventi += 1000;
-	}
-
-	if (f3!=""){
-	read.AddFile(f3);
-	neventi += 1000;
-	}
-
-	if (f4!=""){
-	read.AddFile(f4);
-	neventi += 1000;
-	}
-
-	if (f5!=""){
-	read.AddFile(f5);
-	neventi += 1000;
-	}
-
-	const Int_t NEvt = neventi;
-	cout << "E" <<neventi<< " NEvt:" << NEvt << endl;
-	Float_t timevt[NEvt];
-
-      MGeomApply      geomapl;
-      //
-      // Set the extraction range higher:
-      //		
-      //MExtractFixedWindow sigcalc;
-      //MExtractSignal3 sigcalc;
-      	MExtractSlidingWindow sigcalc;
-      sigcalc.SetRange(0,samples-1,0,1);
-
-     
-  
-      MPedCalcPedRun pedcalc;
-      pedcalc.SetRange(0,samples-1,0,0);
-      pedcalc.SetWindowSize((Int_t)sigcalc.GetNumHiGainSamples());
-
-      //MPedCalcFromData pedcalc;
-      //pedcalc.SetfHiGainThreshold(100);
-
-      //
-      // Additionally to calculating the pedestals, 
-      // you can fill histograms and look at them
-      //
-      MFillH fill("MHPedestalCam", "MExtractedSignalCam");
-      tabname="PedCam ";
-      tabname += samples;
-      //fill.SetNameTab(Form("%s%2d","PedCam",samples));
-      fill.SetNameTab(tabname);
-
-      tlist.AddToList(&read);
-      tlist.AddToList(&geomapl);
-      tlist.AddToList(&sigcalc);
-      tlist.AddToList(&pedcalc);
-      tlist.AddToList(&fill);
-      
-      const MGeomCamMagic      geomcam;
-      MPedestalCam       pedcam;
-      MBadPixelsCam      badcam;
-      badcam.AsciiRead("badpixels.dat");  
-      
-      MHPedestalCam      hpedcam;
-      MCalibrationPedCam cpedcam;
-      
-      plist.AddToList(&geomcam);
-      plist.AddToList(&pedcam);
-      plist.AddToList(&hpedcam);
-      plist.AddToList(&cpedcam);
-      plist.AddToList(&badcam);
-      
-      //
-      // Create and setup the eventloop
-      //
-      MRawEvtHeader *evtheader;
-      MRawEvtData *fRawEvt;
-      TH1F *hpedevt = new TH1F("hpedevt","Pedestals Drift",NEvt,0,(Float_t)NEvt/samplingRate);
-      Bool_t rc;
-      MEvtLoop evtloop;
-      
-      evtloop.SetParList(&plist);
-      evtloop.SetDisplay(display);
-      //tlist.SetDisplay(display);
-      //
-      // Execute first analysis
-      //
-      //if (!evtloop.Eventloop())
-      //  return;
-      rc = evtloop.PreProcess();
-      
-      //while (tlist.Process())
-	//{
-	//cout << "bleah" << endl;
-	//}      
-//tlist.SetDisplay(display);
-
-       Int_t fNumHiGainSample=15;
-	Float_t peddata[NEvt];
-	Int_t evtan=0;
-
-      if (rc){
-          while (tlist.Process())
-          {
-            fRawEvt=(MRawEvtData *)plist.FindObject("MRawEvtData");
-            MRawEvtPixelIter pixel(fRawEvt);
-
-            Float_t ped=0;
-	    evtan++;
-
- 	    while (pixel.Next())
-	     {
-
- 	       const UInt_t idx    = pixel.GetPixelId();
-
-               // lista di pixel da sommare
-               if (idx >pixout || idx < pixin)
-		  continue;
-
-	        Byte_t *ptr = pixel.GetHiGainSamples();
-                const Byte_t *end = ptr + fNumHiGainSample;
-      
-                UInt_t sum = 0;
-	        UInt_t sqr = -1;
-
-	        do
-	          {
-	            sum += *ptr;
-	            //sqr += *ptr * *ptr;
-	          }
-	        while (++ptr != end);
-      
-                 ped += (Float_t)sum;
-
-                  //cout << " Pixel " << idx << " pede: " << ped << " --- ";
-                }
- 
-               //rc = evtloop.Process(0);
-	       evtheader = (MRawEvtHeader *)plist.FindObject("MRawEvtHeader");
-
-             ped /= pixout-pixin+1;
-		Int_t evtn=evtheader->GetDAQEvtNumber();
-             evtn=evtan;
-
-//test
-	//ped =  150 + sin(((Float_t)evtn/16.-TMath::Floor(evtn/16))*6.28); 
-	//cout << ped << " ";
-	timeped = evtn/samplingRate;
-	timevt[evtn-1]=timeped;
-     
-        hpedevt->Fill(timeped,ped);
-
-            //	cout <<" evt:" << evtn;
-	     // Save pedestal in array for Fourier analysis
-	     peddata[evtn-1]=ped;
-          }
-      }
-      if (!evtloop.PostProcess()){
-          rc = kFALSE;
-          return;
-      }
-
-      TCanvas &p1 = display->AddTab("ped studies");
-      p1.Divide(1,2);
-      p1.cd(1);
-	hpedevt->GetXaxis()->SetTitle("Time (s)");
-//      hpedevt->Draw();
-
-	TGraph *drift = new TGraph(evtan,timevt,peddata);
-	drift->SetMarkerStyle(21);
-	drift->SetMarkerSize(0.25);
-	drift->GetXaxis()->SetTitle("time (s)");
-	drift->GetYaxis()->SetTitle(" pedestal");
-	drift->Draw("APL");
-
-
-      // Fourier analysis
-	// campionamento a 500Hz (1000 evt) => freq. max a 250Hz
-
-	MFFT pro;
-	TArrayF *pedarray = new TArrayF(NEvt,peddata);
-	TArrayF *fft; // array con risultato FFT 
-	fft = pro.RealFunctionFFT(pedarray);
-	Int_t nsample = (Int_t)(fft->GetSize()); 
-	
-	const Int_t NNEvt = nsample;
-
-	Float_t x[10000];
-	Float_t prova;
-	for (int i=0;i<NNEvt;i++)
-	 x[i]=(Float_t)i/(NNEvt/(samplingRate/2)); 
-
-	Float_t *ffty = fft->GetArray();
-        cout << "Szie:" << fft->GetSize();
-	ffty[0]=0.;
-	TGraph *gr = new TGraph(nsample,x,ffty);
-	p1.cd(2);
-	gr->GetXaxis()->SetTitle("Frequency (Hz)");
-	gr->SetMarkerStyle(20);
-	gr->SetMarkerSize(0.4);
-	gr->Draw("AP");		
-
-
-
-//-------------------------------
-
-
-      // Set status lines
-      display->SetStatusLine1(evtloop.GetName());
-      display->SetStatusLine2(rc ? "Done." : "Error!");
-      // Stop automatic update
-      display->StopUpdate();
-      // Reallow context menus
-      display->SetNoContextMenu(kFALSE);
-      // Reallow user to exit window by File menu
-      display->UnLock();
-      // 
-      // Look at one specific pixel, after all the histogram manipulations:
-      //
-      /*
-      MHGausEvents &hpix = hpedcam.GetAverageHiGainArea(0);
-      hpix.DrawClone("fourierevents");
-      
-      MHGausEvents &lpix = hpedcam.GetAverageHiGainArea(1);
-      lpix.DrawClone("fourierevents");
-
-      hpedcam[170].DrawClone("fourierevents");
-  
-      */
-
-      MHCamera dispped0  (geomcam, "Ped;Pedestal",       "Mean per Slice");
-      MHCamera dispped2  (geomcam, "Ped;PedestalRms",    "RMS per Slice");
-      MHCamera dispped4  (geomcam, "Ped;Mean",           "Fitted Mean per Slice");
-      MHCamera dispped6  (geomcam, "Ped;Sigma",          "Fitted Sigma per Slice");
-      MHCamera dispped9  (geomcam, "Ped;DeltaPedMean",   "Rel. Diff. Mean per Slice (Fit-Calc.)");
-      MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma",  "Rel. Diff. RMS per Slice (Fit-Calc.)");
-  
-      dispped0.SetCamContent(  pedcam, 0);
-      dispped0.SetCamError(    pedcam, 1);
-      dispped2.SetCamContent(  pedcam, 2);
-      dispped2.SetCamError(    pedcam, 3);
-      
-      dispped4.SetCamContent( hpedcam, 0);
-      dispped4.SetCamError(   hpedcam, 1);
-      dispped6.SetCamContent( hpedcam, 2);
-      dispped6.SetCamError(   hpedcam, 3);
-      dispped9.SetCamContent( hpedcam, 5);
-      dispped9.SetCamError(   hpedcam, 6);
-      dispped11.SetCamContent(hpedcam, 8);
-      dispped11.SetCamError(  hpedcam, 9);
-  
-      dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
-      dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
-      dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
-      dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
-      dispped9.SetYTitle("Rel. Diff. Pedestal per slice Fit-Calc [1]");
-      dispped11.SetYTitle("Rel. Diff. Pedestal RMS per slice Fit-Calc [1]");
-
-
-      // Histogram values
-      tabname="MeanRMS ";
-      tabname += samples;
-      //fill.SetNameTab(tabname);
-      TCanvas &b1 = display->AddTab(tabname);
-      b1.Divide(4,3);
-
-      CamDraw(b1,dispped0,1,4,*hmeaninn,*hmeanout,*hmeaninnerr,*hmeanouterr,samples,stepsize);
-      CamDraw(b1,dispped2,2,4,*hrmsinn,*hrmsout,*hrmsinnerr,*hrmsouterr,samples,stepsize);  
-      CamDraw(b1,dispped4,3,4,*hmuinn,*hmuout,*hmuinnerr,*hmuouterr,samples,stepsize);
-      CamDraw(b1,dispped6,4,4,*hsigmainn,*hsigmaout,*hsigmainnerr,*hsigmaouterr,samples,stepsize); 
-      
-      tabname="MeanRrmSamples ";
-      tabname += samples;
-      display->SaveAsGIF(3*((samples-1)/stepsize)+2,tabname);
-
-      // Differences
-      tabname="RelDiff ";
-      tabname += samples;
-      TCanvas &c4 = display->AddTab(tabname);
-      c4.Divide(2,3);
-      
-      CamDraw(c4,dispped9,1,2,*hmeandiffinn,*hmeandiffout,*hmeandiffinnerr,*hmeandiffouterr,samples,stepsize);
-      CamDraw(c4,dispped11,2,2,*hrmsdiffinn,*hrmsdiffout,*hrmsdiffinnerr,*hrmsdiffouterr,samples,stepsize); 
-
-      tabname="RelDiffSamples ";
-      tabname += samples;
-      display->SaveAsGIF(3*((samples-1)/stepsize)+3,tabname);
-
-   cout << "Loop N. " <<samples << " completed..." <<endl;
-
-    }
-
-  /*
-  TF1 *logg = new TF1("logg","[1]+TMath::Log(x-[0])",1.,30.,2);
-  logg->SetParameters(1.,3.5);
-  logg->SetParLimits(0,-1.,3.);
-  logg->SetParLimits(1,-1.,7.);
-  logg->SetLineColor(kRed);
-  */
-
-  TCanvas *canvas = new TCanvas("PedstudInner","Pedestal Studies Inner Pixels",600,900);
-  canvas->Divide(2,3);
-  canvas->cd(1);
-
-  TGraphErrors *gmeaninn = new TGraphErrors(hmeaninn->GetSize(),
-                                            CreateXaxis(hmeaninn->GetSize(),stepsize),hmeaninn->GetArray(),
-                                            CreateXaxisErr(hmeaninnerr->GetSize(),stepsize),hmeaninnerr->GetArray());
-  gmeaninn->Draw("A*");
-  gmeaninn->SetTitle("Calculated Mean per Slice Inner Pixels");
-  gmeaninn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeaninn->GetYaxis()->SetTitle("Calculated Mean per slice");
-  //  gmeaninn->Fit("pol0");
-  //  gmeaninn->GetFunction("pol0")->SetLineColor(kGreen);
-  //  //  gmeaninn->Fit(logg);
-
-  canvas->cd(2);
-
-  TGraphErrors *gmuinn = new TGraphErrors(hmuinn->GetSize(),
-                                          CreateXaxis(hmuinn->GetSize(),stepsize),hmuinn->GetArray(),
-                                          CreateXaxisErr(hmuinnerr->GetSize(),stepsize),hmuinnerr->GetArray());
-  gmuinn->Draw("A*");
-  gmuinn->SetTitle("Fitted Mean per Slice Inner Pixels");
-  gmuinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmuinn->GetYaxis()->SetTitle("Fitted Mean per Slice");
-  //  gmuinn->Fit("pol0");
-  //  gmuinn->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmuinn->Fit(logg);
-
-
-  canvas->cd(3);
-
-  TGraphErrors *grmsinn = new TGraphErrors(hrmsinn->GetSize(),
-                                           CreateXaxis(hrmsinn->GetSize(),stepsize),hrmsinn->GetArray(),
-                                           CreateXaxisErr(hrmsinnerr->GetSize(),stepsize),hrmsinnerr->GetArray());
-  grmsinn->Draw("A*");
-  grmsinn->SetTitle("Calculated Rms per Slice Inner Pixels");
-  grmsinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsinn->GetYaxis()->SetTitle("Calculated Rms per Slice");
-  //  //grmsinn->Fit("pol2");
-  //  //grmsinn->GetFunction("pol2")->SetLineColor(kRed);
-  //  grmsinn->Fit(logg);
-
-  canvas->cd(4);
-
-  TGraphErrors *gsigmainn = new TGraphErrors(hsigmainn->GetSize(),
-                                             CreateXaxis(hsigmainn->GetSize(),stepsize),hsigmainn->GetArray(),
-                                             CreateXaxisErr(hsigmainnerr->GetSize(),stepsize),hsigmainnerr->GetArray());
-  gsigmainn->Draw("A*");
-  gsigmainn->SetTitle("Fitted Sigma per Slice Inner Pixels");
-  gsigmainn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gsigmainn->GetYaxis()->SetTitle("Fitted Sigma per Slice");
-  //  //  gsigmainn->Fit("pol2");
-  //  //  gsigmainn->GetFunction("pol2")->SetLineColor(kRed);
-  //  gsigmainn->Fit(logg);
-
-  canvas->cd(5);
-
-  TGraphErrors *gmeandiffinn = new TGraphErrors(hmeandiffinn->GetSize(),
-                                                CreateXaxis(hmeandiffinn->GetSize(),stepsize),hmeandiffinn->GetArray(),
-                                                CreateXaxisErr(hmeandiffinnerr->GetSize(),stepsize),hmeandiffinnerr->GetArray());
-  gmeandiffinn->Draw("A*"); 
-  gmeandiffinn->SetTitle("Rel. Difference  Mean per Slice Inner Pixels");
-  gmeandiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeandiffinn->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
-  //  //gmeandiffinn->Fit("pol2");
-  //  //gmeandiffinn->GetFunction("pol2")->SetLineColor(kBlue);
-  //  gmeandiffinn->Fit(logg);
-
-
-  canvas->cd(6);
-
-  TGraphErrors *grmsdiffinn = new TGraphErrors(hrmsdiffinn->GetSize(),
-                                               CreateXaxis(hrmsdiffinn->GetSize(),stepsize),hrmsdiffinn->GetArray(),
-                                               CreateXaxisErr(hrmsdiffinnerr->GetSize(),stepsize),hrmsdiffinnerr->GetArray());
-  grmsdiffinn->Draw("A*");
-  grmsdiffinn->SetTitle("Rel. Difference Sigma per Slice-RMS Inner Pixels");
-  grmsdiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsdiffinn->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
-  //  //grmsdiffinn->Fit("pol2");
-  //  //grmsdiffinn->GetFunction("pol2")->SetLineColor(kBlue);
-  //  grmsdiffinn->Fit(logg);
-
-  canvas->SaveAs("PedestalStudyInner.root");
-  canvas->SaveAs("PedestalStudyInner.ps");
-
-  TCanvas *canvas2 = new TCanvas("PedstudOut","Pedestal Studies Outer Pixels",600,900);
-  canvas2->Divide(2,3);
-  canvas2->cd(1);
-
-  TGraphErrors *gmeanout = new TGraphErrors(hmeanout->GetSize(),
-                                            CreateXaxis(hmeanout->GetSize(),stepsize),hmeanout->GetArray(),
-                                            CreateXaxisErr(hmeanouterr->GetSize(),stepsize),hmeanouterr->GetArray());
-  gmeanout->Draw("A*");
-  gmeanout->SetTitle("Calculated Mean per Slice Outer Pixels");
-  gmeanout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeanout->GetYaxis()->SetTitle("Calculated Mean per Slice");
-  //  gmeanout->Fit("pol0");
-  //  gmeanout->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmeanout->Fit(logg);
-
-  canvas2->cd(2);
-
-  TGraphErrors *gmuout = new TGraphErrors(hmuout->GetSize(),
-                                          CreateXaxis(hmuout->GetSize(),stepsize),hmuout->GetArray(),
-                                          CreateXaxisErr(hmuouterr->GetSize(),stepsize),hmuouterr->GetArray());
-  gmuout->Draw("A*");
-  gmuout->SetTitle("Fitted Mean per Slice Outer Pixels");
-  gmuout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmuout->GetYaxis()->SetTitle("Fitted Mean per Slice");
-  //  gmuout->Fit("pol0");
-  //  gmuout->GetFunction("pol0")->SetLineColor(kGreen);
-  //gmuout->Fit(logg);
-
-  canvas2->cd(3);
-
-  TGraphErrors *grmsout = new TGraphErrors(hrmsout->GetSize(),
-                                           CreateXaxis(hrmsout->GetSize(),stepsize),hrmsout->GetArray(),
-                                           CreateXaxisErr(hrmsouterr->GetSize(),stepsize),hrmsouterr->GetArray());
-  grmsout->Draw("A*");
-  grmsout->SetTitle("Calculated Rms per Slice Outer Pixels");
-  grmsout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsout->GetYaxis()->SetTitle("Calculated Rms per Slice");
-  //  //grmsout->Fit("pol2");
-  //  //grmsout->GetFunction("pol2")->SetLineColor(kRed);
-  //  grmsout->Fit(logg);
-
-  canvas2->cd(4);
-
-  TGraphErrors *gsigmaout = new TGraphErrors(hsigmaout->GetSize(),
-                                             CreateXaxis(hsigmaout->GetSize(),stepsize),hsigmaout->GetArray(),
-                                             CreateXaxisErr(hsigmaouterr->GetSize(),stepsize),hsigmaouterr->GetArray());
-  gsigmaout->Draw("A*");
-  gsigmaout->SetTitle("Fitted Sigma per Slice Outer Pixels");
-  gsigmaout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gsigmaout->GetYaxis()->SetTitle("Fitted Sigma per Slice");
-  //  //gsigmaout->Fit("pol2");
-  //  //gsigmaout->GetFunction("pol2")->SetLineColor(kRed);
-  //  gsigmaout->Fit(logg);
-
-
-  canvas2->cd(5);
-
-  TGraphErrors *gmeandiffout = new TGraphErrors(hmeandiffout->GetSize(),
-                                                CreateXaxis(hmeandiffout->GetSize(),stepsize),hmeandiffout->GetArray(),
-                                                CreateXaxisErr(hmeandiffouterr->GetSize(),stepsize),hmeandiffouterr->GetArray());
-  gmeandiffout->Draw("A*");
-  gmeandiffout->SetTitle("Rel. Difference  Mean per Slice Outer Pixels");
-  gmeandiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  gmeandiffout->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
-  //  //gmeandiffout->Fit("pol2");
-  //w  //gmeandiffout->GetFunction("pol2")->SetLineColor(kBlue);
-  //  gmeandiffout->Fit(logg);
-
-  canvas2->cd(6);
-
-  TGraphErrors *grmsdiffout = new TGraphErrors(hrmsdiffout->GetSize(),
-                                               CreateXaxis(hrmsdiffout->GetSize(),stepsize),hrmsdiffout->GetArray(),
-                                               CreateXaxisErr(hrmsdiffouterr->GetSize(),stepsize),hrmsdiffouterr->GetArray());
-  grmsdiffout->Draw("A*");
-  grmsdiffout->SetTitle("Rel. Difference Sigma per Slice-RMS Outer Pixels");
-  grmsdiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
-  grmsdiffout->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
-  //  //grmsdiffout->Fit("pol2");
-  //  //grmsdiffout->GetFunction("pol2")->SetLineColor(kBlue);
-  //  grmsdiffout->Fit(logg);
-
-
-  canvas2->SaveAs("PedestalStudyOuter.root");
-  canvas2->SaveAs("PedestalStudyOuter.ps");
-
-
-}
-
-
-void CamDraw(TCanvas &c, MHCamera &cam, Int_t i, Int_t j, TArrayF &a1, TArrayF &a2, 
-             TArrayF &a1err, TArrayF &a2err, Int_t samp, Int_t stepsize)
-{
-
-  c.cd(i);
-  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
-  obj1->SetDirectory(NULL);
-  
-  c.cd(i+j);
-  obj1->Draw();
-  ((MHCamera*)obj1)->SetPrettyPalette();
-
-  c.cd(i+2*j);
-  TH1D *obj2 = (TH1D*)obj1->Projection();
-  obj2->SetDirectory(NULL);
-  
-  //      obj2->Sumw2();
-  obj2->Draw();
-  obj2->SetBit(kCanDelete);
-  
-  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
-  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
-  const Double_t integ = obj2->Integral("width")/2.5066283;
-  const Double_t mean  = obj2->GetMean();
-  const Double_t rms   = obj2->GetRMS();
-  const Double_t width = max-min;
-  
-  if (rms == 0. || width == 0. )
-    return;
-  
-  TArrayI s0(6);
-  s0[0] = 6;
-  s0[1] = 1;
-  s0[2] = 2;
-  s0[3] = 3;
-  s0[4] = 4;
-  s0[5] = 5;
-  
-  TArrayI inner(1);
-  inner[0] = 0;
-  
-  TArrayI outer(1);
-  outer[0] = 1;
-      
-  // Just to get the right (maximum) binning
-  TH1D *half[2];
-  half[0] = obj1->ProjectionS(s0, inner, "Inner");
-  half[1] = obj1->ProjectionS(s0, outer, "Outer");
-
-  half[0]->SetDirectory(NULL);
-  half[1]->SetDirectory(NULL);
-  
-  for (int i=0; i<2; i++)
-    {
-      half[i]->SetLineColor(kRed+i);
-      half[i]->SetDirectory(0);
-      half[i]->SetBit(kCanDelete);
-      half[i]->Draw("same");
-      half[i]->Fit("gaus","Q+");
-
-      if (i==0)
-        {
-          a1[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
-          a1err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
-          if (a1err[(samp-1)/stepsize] > 3.)
-            a1err[(samp-1)/stepsize] = 1.;
-        }
-     if (i==1)
-       {
-         a2[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
-         a2err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
-          if (a2err[(samp-1)/stepsize] > 3.)
-            a2err[(samp-1)/stepsize] = 1.;
-       }
-    }
-  
-  
-}
-
-// -----------------------------------------------------------------------------
-// 
-// Create the x-axis for the event graph
-//
-Float_t *CreateXaxis(Int_t n, Int_t step)
-{
-
-  Float_t *xaxis = new Float_t[n];
-
-  for (Int_t i=0;i<n;i++)
-    xaxis[i] = 2. + step*i;
-
-  return xaxis;
-                 
-}
-
-// -----------------------------------------------------------------------------
-// 
-// Create the x-axis for the event graph
-//
-Float_t *CreateXaxisErr(Int_t n, Int_t step)
-{
-
-  Float_t *xaxis = new Float_t[n];
-
-  for (Int_t i=0;i<n;i++)
-    xaxis[i] = step/2.;
-
-  return xaxis;
-                 
-}
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/production.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/production.C	(revision 4992)
+++ 	(revision )
@@ -1,295 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
-! * Software. It is distributed to you in the hope that it can be a useful
-! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
-! * It is distributed WITHOUT ANY WARRANTY.
-! *
-! * Permission to use, copy, modify and distribute this software and its
-! * documentation for any purpose is hereby granted without fee,
-! * provided that the above copyright notice appear in all copies and
-! * that both that copyright notice and this permission notice appear
-! * in supporting documentation. It is provided "as is" without express
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Hendrik Bartko, 03/2004 <mailto:hbartko@mppmu.mpg.de>
-!              Markus Gaug,    03/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-
-///////////////////////////////////////////////////////////////////////////
-//
-//   production.C
-//   ============
-//
-//   This macro takes calibration runs and pedestal runs
-//   to set pedestals and calibration factors
-//   Then raw data files are read and calibrated.
-//   The output file contains the calibrated data, pedestal subtracted,
-//   with the signal (in photons) for each pixels
-//
-//   input:  calibration file(s)
-//           pedestal file(s)
-//           raw data files
-//   
-//   output: root files with following containers (branches)
-//           - MCerPhotEvt
-//           - MPedestalCam
-//           - MCalibrationRelTimeCam
-//           - MCerPhotEvt
-//           - MRawEvtHeader
-//           - MBadPixelsCam
-//           - MPedPhotCam
-//
-///////////////////////////////////////////////////////////////////////////
-
-//
-// Set path for files and run numbers
-//
-const TString defpath = "/data1/earth/magic/data/Period014/rootdata/2004_02_15/";
-const TString defrout = "output_Mrk421_20040215.root";
-
-const Int_t defpedr [] = {17284};
-const Int_t defcalr [] = {17285};
-const Int_t defdatar[] = {17286,17287,17288,17289,17290,17291,17292,17293,
-			  17294,17295,17296,17297,17298,17299,17300,17301,
-			  17302,17303,17304,17305,17306,17307,17308,17309,
-			  17310,17311,17312,17313,17314,17315,17316,17317,
-			  17318,17319,17320,17321,17322,17323,17324,17325,
-			  17326,17327,17328,17329,17330,17331,17332,17333,
-			  17334,17335,17336,17337,17338,17339,17340,17341,
-			  17342,17343,17344,17345,17346,17347,17348,17349,
-			  17350,17351,17352,17353,17354,17355,17356,17357,
-			  17358,17359,17360,17361,17362,17363,17364,17365,
-			  17366,17367,17368,17369,17370,17371,17372,17373,
-			  17374,17375,17376,17377,17378,17379,17380,17381,
-			  17382,17383,17384,17385,17386,17387,17388,17389,
-			  17390,17391,17392,17393,17394,17395,17396,17397,
-			  17398,17399,17400,17401,17402,17403,17404,17405,
-			  17406,17407,17408,17409,17410,17411,17412,17413,
-			  17414,17415,17416,17417,17418,17419,17420,17421,
-			  17422,17423,17424,17425,17426,17427,17428,17429,
-			  17430,17431,17432,17433,17434,17435,17436,17437,
-			  17438,17439,17440,17441,17442,17443,17444,17445,
-			  17446,17447,17448,17449,17450,17451,17452,17453,
-			  17454,17455,17456};
-
-
-void production(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=171, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  MExtractSlidingWindow extractor;
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-  
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-
-  MStatusDisplay *display = new MStatusDisplay;
-  display->SetUpdateTime(3000);
-  display->Resize(850,700);
-
-  gStyle->SetOptStat(1111);
-  gStyle->SetOptFit();
-
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-  
-  MParList plist1;
-  MTaskList tlist1;
-  plist1.AddToList(&tlist1);
-  
-  // containers
-  MPedestalCam   pedcam;
-  MBadPixelsCam  badcam;
-  //
-  // for excluding pixels from the beginning:
-  //
-  // badcam.AsciiRead("badpixels.dat");
-
-
-  plist1.AddToList(&pedcam);
-  plist1.AddToList(&badcam);
-    
-  //tasks
-  MReadMarsFile  read("Events");
-  read.DisableAutoScheme();
-  static_cast<MRead&>(read).AddFiles(pruns);
-
-  MGeomApply     geomapl;
-  MPedCalcPedRun pedcalc;
-  MGeomCamMagic  geomcam;
-    
-  tlist1.AddToList(&read);
-  tlist1.AddToList(&geomapl);
-  tlist1.AddToList(&pedcalc);
-
-  // Create and execute the event looper
-  MEvtLoop pedloop;
-  pedloop.SetParList(&plist1);
-  pedloop.SetDisplay(display);
-
-  cout << "*************************" << endl;
-  cout << "** COMPUTING PEDESTALS **" << endl;
-  cout << "*************************" << endl;
-
-  if (!pedloop.Eventloop())
-    return;
-  
-  tlist1.PrintStatistics();
-
-  // 
-  // Now the short version: 
-  //
-  //
-  // Now setup the new tasks for the calibration:
-  // ---------------------------------------------------
-  //
-  MJCalibration     calloop;
-  calloop.SetInput(&cruns);
-  //  calloop.SetFullDisplay();
-  //
-  calloop.SetExtractor(&extractor);
-  //
-  // Set the corr. cams:
-  //
-  calloop.SetBadPixels(badcam);
-  //
-  // The next two commands are for the display:
-  //
-  calloop.SetDisplay(display);
-  
-  //
-  // Apply rel. time calibration:
-  //
-  calloop.SetRelTimeCalibration();
-  //
-  // Use as arrival time extractor MArrivalTimeCalc2:
-  //
-  calloop.SetArrivalTimeLevel(2);
-  
-  //
-  // Do the event-loop:
-  //
-  cout << "***************************" << endl;
-  cout << "** COMPUTING CALIBRATION **" << endl;
-  cout << "***************************" << endl;
-  
-  if (!calloop.Process(pedcam))
-    return;
-
-  badcam.Print();
-  
-  MBadPixelsCam          &badbad  = calloop.GetBadPixels();
-  MCalibrationChargeCam  &calcam  = calloop.GetCalibrationCam();
-  MCalibrationRelTimeCam &timecam = calloop.GetRelTimeCam();
-  MCalibrationQECam      &qecam   = calloop.GetQECam();
-
-  badbad.Print();
-
-  /************************************************************************/
-  /*                THIRD LOOP: DATA CALIBRATION INTO PHOTONS             */
-  /************************************************************************/
-
-  // Create an empty Parameter List and an empty Task List
-  MParList  plist3;  
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
- 
-  // containers
-  MCerPhotEvt         photevt;
-  MPedPhotCam         pedphotcam;
-  MSrcPosCam          srccam;
-  MRawRunHeader       runhead;
-  MExtractedSignalCam sigcam;
-
-  plist3.AddToList(&geomcam );
-  plist3.AddToList(&pedcam  );
-  plist3.AddToList(&calcam  );
-  plist3.AddToList(&qecam   );
-  plist3.AddToList(&badbad  );
-  plist3.AddToList(&timecam );
-  plist3.AddToList(&sigcam  );
-  plist3.AddToList(&photevt);
-  plist3.AddToList(&pedphotcam);
-  plist3.AddToList(&srccam);
-  plist3.AddToList(&runhead);
-
-  //tasks
-  MReadMarsFile read3("Events");
-  read3.DisableAutoScheme();
-  static_cast<MRead&>(read3).AddFiles(druns);
-
-  MArrivalTimeCalc2   timecalc;
-  MCalibrateData      photcalc;     
-  photcalc.SetCalibrationMode(MCalibrateData::kFfactor);  // !!! was only MCalibrate
-  // MPedPhotCalc     pedphotcalc;   // already done by MCalibrate Data
-  // MCerPhotCalc     cerphotcalc;  // already done by MCalibrate Data
-  
-  tlist3.AddToList(&read3);
-  tlist3.AddToList(&geomapl);
-  tlist3.AddToList(&extractor);
-  tlist3.AddToList(&timecalc);
-  //  tlist3.AddToList(&cerphotcalc); // already done by MCalibrate Data
-  tlist3.AddToList(&photcalc);
-  // tlist3.AddToList(&pedphotcalc);   // already done by MCalibrate Data
-
-  MWriteRootFile write(resname);
-  
-  write.AddContainer("MGeomCam"              , "RunHeaders");
-  write.AddContainer("MRawRunHeader"         , "RunHeaders");
-  write.AddContainer("MSrcPosCam"            , "RunHeaders");
-  write.AddContainer("MCalibrationChargeCam" , "RunHeaders");
-  write.AddContainer("MCalibrationQECam"     , "RunHeaders");
-  //  write.AddContainer("MPedPhotCam","RunHeaders"); // Attention, was in Events - Tree!!
-  write.AddContainer("MPedestalCam"          , "RunHeaders");
-  write.AddContainer("MCalibrationRelTimeCam", "RunHeaders");
-
-  write.AddContainer("MCerPhotEvt"   , "Events");
-  write.AddContainer("MRawEvtHeader" , "Events");
-  write.AddContainer("MBadPixelsCam" , "Events");
-  write.AddContainer("MPedPhotCam"   , "Events");
-
-  tlist3.AddToList(&write);
-  
-  // Create and execute eventloop
-  MEvtLoop evtloop3;
-  evtloop3.SetParList(&plist3);
-    
-  cout << "*************************************************************" << endl;
-  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
-  cout << "*************************************************************" << endl;
-  
-  if (!evtloop3.Eventloop())  
-    return;  
-  tlist3.PrintStatistics();
-
-}
-
-
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/production3.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/production3.C	(revision 4992)
+++ 	(revision )
@@ -1,373 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
-! * Software. It is distributed to you in the hope that it can be a useful
-! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
-! * It is distributed WITHOUT ANY WARRANTY.
-! *
-! * Permission to use, copy, modify and distribute this software and its
-! * documentation for any purpose is hereby granted without fee,
-! * provided that the above copyright notice appear in all copies and
-! * that both that copyright notice and this permission notice appear
-! * in supporting documentation. It is provided "as is" without express
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es>
-!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-/////////////////////////////////////////////////////////////////////////////
-//
-//  bootcampstandardanalysis.C
-//
-//  Updated version of the macro designed at the Wuerzburg bootcamp and 
-//  compatible with the latest changes in Mars for general usage at the
-//  Udine bootcamp. 
-//
-//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
-//  one of a calibration file ("*_C_*.root") and one of a data file 
-//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
-/// constants calculation and the calibration of the data. 
-//
-//  The TString inpath has to be set correctly.
-//
-//  The macro searches for the pulser colour which corresponds to the calibration
-//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
-//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
-//  "ct1" in the filenames. If no colour or multiple colours are found, the 
-//  execution is aborted.  
-//
-//////////////////////////////////////////////////////////////////////////////////
-const Bool_t usedisplay = kTRUE;
-const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
-const TString outpath = "./";
-const TString defrout = "output_Mrk421_20040319.root";
-// Mrk (13)
-const Int_t defpedr[] = {20823};
-//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
-//			  20608,20611,20614,20649,20652,20654};
-// OffMrk (14)
-//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
-//			  20632,20635,20637,20640,20643,20645,20647};
-
-
-//const Int_t defcalr [] = {20651};
-const Int_t defcalr [] = {20822};
-
-// Mrk (20)
-const Int_t defdatar[] = {20824};
-//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
-//			  20603,20604,20606,20607,20609,20610,20612,
-//			  20613,20615,20616,20650,20653,20655};
-// OffMrk (18)
-// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
-// 			  20631,20633,20634,20636,20638,20639,20641,
-//			  20642,20644,20646,20648};
-
-
-void production3(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  //
-  // Choose the signal Extractor:
-  //
-  //MExtractSlidingWindow extractor;
-  MExtractFixedWindowPeakSearch extractor;
-  //MExtractFixedWindow    extractor;   
-
-  //
-  // Set Ranges or Windows
-  //
-  extractor.SetRange(3,14,3,14);
-  //extractor.SetWindows(8,8);
-
-  //
-  // Choose the arrival time Extractor:
-  //
-  MExtractTimeFastSpline       timeext;
-  //  MExtractTimeHighestIntegral timeext;
-  //  MExtractTimeSpline          timeext;
-  //
-  // Set Ranges or Windows
-  //
-  timeext.SetRange(2,12,4,14);
-
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-  
-  //
-  // Now setup the tasks and tasklist for the pedestals:
-  // ---------------------------------------------------
-  //
-  MBadPixelsCam     badcam;
-  MGeomCamMagic     geomcam;
-  MGeomApply        geomapl;
-  //
-  // If you want to exclude pixels from the beginning, read 
-  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
-  //
-  //  badcam.AsciiRead("badpixels.dat");
-  
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-
-  MJPedestal pedloop;
-  pedloop.SetInput(&pruns);
-  if (usedisplay)
-    {
-      MStatusDisplay *display = new MStatusDisplay;
-      display->SetUpdateTime(3000);
-      display->Resize(850,700);
-      pedloop.SetDisplay(display);
-    }
-  pedloop.SetBadPixels(badcam);
-  pedloop.SetExtractor(&extractor);
-
-  if (!pedloop.Process())
-    return;
-
-  /****************************************/
-  /* SECOND LOOP: CALIBRATION COMPUTATION */
-  /****************************************/
-
-  //
-  // Now setup the new tasks for the calibration:
-  // ---------------------------------------------------
-  //
-  MCalibrationQECam qecam;
-  MJCalibration     calloop;
-  calloop.SetInput(&cruns);
-  calloop.SetExtractor(&extractor);
-  //
-  // Apply rel. time calibration:
-  //
-  calloop.SetRelTimeCalibration();
-  calloop.SetTimeExtractor(&timeext);
-  //
-  // Set the corr. cams:
-  //
-  calloop.SetQECam(qecam);
-  calloop.SetBadPixels(pedloop.GetBadPixels());
-  //
-  // The next two commands are for the display:
-  //
-  if (usedisplay)
-      calloop.SetDisplay(display);
-  cout << "Minchia 0" << endl;
-  //
-  // Do the event-loop:
-  //
-  if (!calloop.Process(pedloop.GetPedestalCam()))
-    return;
-  
-  cout << "Minchia 1" << endl;
-  /*************************************/
-  /* THIRD LOOP: PEDESTAL CALIBRATION  */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist3;
-  MTaskList tlist3;
-  plist3.AddToList(&tlist3);
-  cout << "Minchia 2" << endl;
-  //
-  // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
-  // -----------------------------------------------------------------------------------
-  //
-  
-  MCerPhotEvt    nphot;
-  MPedPhotCam    nphotrms;
-  
-  plist3.AddToList(&geomcam);
-  cout << "Minchia 3" << endl;
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist3.AddToList(&pedloop.GetPedestalCam());
-  plist3.AddToList(&calloop.GetCalibrationCam());
-  plist3.AddToList(&calloop.GetQECam());
-  plist3.AddToList(&calloop.GetRelTimeCam());
-  plist3.AddToList(&calloop.GetBadPixels());
-  plist3.AddToList(&nphot);
-  plist3.AddToList(&nphotrms);
-    cout << "Minchia 4" << endl;
-  //tasks
-  MReadMarsFile read3("Events");
-  read3.DisableAutoScheme();
-  static_cast<MRead&>(read3).AddFiles(pruns);  
-
-  //MCalibrate       photcalc;
-  MCalibrateData       photcalc;
-  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
-  MPedPhotCalc  photrmscalc;  //It doesn't exist yet
-  
-  tlist3.AddToList(&read3);
-  tlist3.AddToList(&geomapl);
-  tlist3.AddToList(&extractor);
-  tlist3.AddToList(&photrmscalc);
-  //tlist3.AddToList(&photcalc);
-  
-  
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop3;
-  evtloop3.SetParList(&plist3);
-  
-  //
-  // Execute first analysis
-  //
-  if (!evtloop3.Eventloop())
-    return;
-  
-  tlist3.PrintStatistics();
-  
-  /*************************************/
-  /* FOURTH LOOP: DATA CALIBRATION     */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist4;
-  MTaskList tlist4;
-  plist4.AddToList(&tlist4);
-  
-  //
-  // Now setup the tasks and tasklist to analize the data
-  // -----------------------------------------------------
-  //
-  
-  plist4.AddToList(&geomcam);
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist4.AddToList(&pedloop.GetPedestalCam());
-  plist4.AddToList(&calloop.GetCalibrationCam());
-  plist4.AddToList(&calloop.GetQECam());
-  plist4.AddToList(&calloop.GetRelTimeCam());
-  plist4.AddToList(&calloop.GetBadPixels());
-  plist4.AddToList(&nphot);
-  plist4.AddToList(&nphotrms);
-
-  MArrivalTime times;
-  plist4.AddToList(&times);
-  
-  //tasks
-  MReadMarsFile read4("Events");
-  read4.DisableAutoScheme();
-  static_cast<MRead&>(read4).AddFiles(druns);  
-  
-  MArrivalTimeCalc2   timecalc;
-  MCalibrateRelTimes  timecal;
-
-  tlist4.AddToList(&read4);
-  tlist4.AddToList(&geomapl);
-  tlist4.AddToList(&extractor);
-  tlist4.AddToList(&timecalc);
-  tlist4.AddToList(&photcalc);
-  tlist4.AddToList(&timecal);
-  
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop4;
-  evtloop4.SetParList(&plist4);
-
-  if (!evtloop4.PreProcess())
-    return;
-  
-  TCanvas *c1 = new TCanvas;
-  MHCamera disp1(geomcam);
-  disp1.SetPrettyPalette();
-  //disp1.SetInvDeepBlueSeaPalette()
-  disp1.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  
-  /*
-  TCanvas *c2 = new TCanvas;
-  MHCamera disp2(geomcam);
-  disp2.SetPrettyPalette();
-  //disp2.SetInvDeepBlueSeaPalette()
-  disp2.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  */
-  while (tlist4.Process())
-    {
-      disp1.SetCamContent(nphot);
-      
-      gPad->Modified();
-      gPad->Update();
-
-      /*    
-      disp2.SetCamContent(times);
-      
-      gPad->Modified();
-      gPad->Update();
-      */
-
-      // Remove the comments if you want to go through the file
-      // event-by-event:
-      if (!HandleInput())
-        break;
-    }
-
-  evtloop4.PostProcess();
-  
-}
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/readIPR.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/readIPR.C	(revision 4992)
+++ 	(revision )
@@ -1,147 +1,0 @@
-///////////////////////////////////////////////////////////////////////////
-// 
-//    readIPR.C
-//
-//   This macro shows how to read the Individual Pixel Rates from 
-//   a CC report file.
-//
-//   Input: 
-//     - root file obtained merpping a .rep CC file
-//       container: MTriggerIPR
-//
-//   Output:
-//     - a camera display showing the IPRs
-//     - Some histos for checking purposes
-//   
-//   Note: 
-//     a similar macro can be used to read the following trigger containers:
-//     - MTriggerIPR        (Individual Pixel Rates)
-//     - MTriggerCell       (Rate of trigger cells)
-//     - MTriggerBit        (Output Bits from prescaler (before/after presc.)
-//     - MTriggerPrescFact  (Prescaling factors for each bit)
-//     - MTriggerLiveTime   (Values of counters for dead/livetime)
-//
-//    Author(s): Antonio Stamerra. 09/04 <antonio.stamerra@pi.infn.it>
-//
-////////////////////////////////////////////////////////////////////////////
-void readIPR(TString fname)
-{
-    //
-    // Create a empty Parameter List and an empty Task List
-    // The tasklist is identified in the eventloop by its name
-    //
-    MParList  plist;
-
-    MTaskList tlist;
-    plist.AddToList(&tlist);
-
-    //
-    // Now setup the tasks and tasklist:
-    // ---------------------------------
-    //
-
-    // Create the magic geometry
-    MGeomCamMagic geom;
-    plist.AddToList(&geom);
-
-    // First Task: Read ROOT file with Trigger-REPORT data
-    MReadTree read("Trigger", fname);
-    read.DisableAutoScheme();
-
-    tlist.AddToList(&read);
-
-    // Create the container for the IPRs
-    MTriggerIPR ipr;
-    plist.AddToList(&ipr);
-
-    // Create the histo to display the IPRs
-    MHCamEvent IPRhist("IPRhist","IPRs");
-    plist.AddToList(&IPRhist);
-        
-    // create a task to fill a histogram from the container
-    MFillH fillIPR(&IPRhist, "MTriggerIPR");
-    tlist.AddToList(&fillIPR);
-
-    //
-    // Create and setup the eventloop
-    //
-    MEvtLoop evtloop;
-    evtloop.SetParList(&plist);
-
-    //
-    // Execute the analysis
-    //
-    if (!evtloop.PreProcess())
-      return;
-    
-    if (!evtloop.Eventloop())
-      return;
-
-    tlist.PrintStatistics();
-
-    //-----------------------------------
-    // Now display the result of the loop
-    //
-
-    // create a MHCamera histo where the sum off all events is filled
-    MHCamera &h = *(MHCamera*)IPRhist.GetHistByName("sum");
-
-    TCanvas *c = MH::MakeDefCanvas();
-    c->Divide(3, 2);
-
-    MHCamera *disp1=h.Clone();
-    MHCamera *disp2=h.Clone();
-    MHCamera *disp3=h.Clone();
-    disp2->SetCamContent(h, 1);
-    disp3->SetCamContent(h, 2);
-
-    disp1->SetYTitle("Rate [Hz]");
-    disp2->SetYTitle("\\sigma_{Rate} [Hz]");
-    disp3->SetYTitle("\\sigma_{Rate} [%]");
-    disp1->SetName("IPRs;avg");
-    disp2->SetName("IPRs;err");
-    disp3->SetName("IPRs;rel");
-    disp1->SetTitle("IPRs Average");
-    disp2->SetTitle("IPRs error");
-    disp3->SetTitle("IPRs relative error");
-
-    c->cd(1);
-    TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
-    text.SetTextSize(0.03);
-    text.DrawClone();
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp1->Draw();
-    disp1->SetBit(kCanDelete);
-    c->cd(2);
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp2->Draw();
-    disp2->SetBit(kCanDelete);
-    c->cd(3);
-    gPad->SetBorderMode(0);
-    gPad->Divide(1,1);
-    gPad->cd(1);
-    gPad->SetLogy();
-    disp3->Draw();
-    disp3->SetBit(kCanDelete);
-    c->cd(4);
-    gPad->SetBorderMode(0);
-    disp1->Draw("EPhist");
-    c->cd(5);
-    gPad->SetBorderMode(0);
-    gPad->SetLogy();
-    disp2->Draw("Phist");
-    c->cd(6);
-    gPad->SetBorderMode(0);
-    gPad->SetLogy();
-    disp3->Draw("Phist");
-
-    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
-    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
-}
-
Index: trunk/MagicSoft/Mars/mtemp/mpisa/macros/timedist3.C
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mpisa/macros/timedist3.C	(revision 4992)
+++ 	(revision )
@@ -1,394 +1,0 @@
-/* ======================================================================== *\
-!
-! *
-! * This file is part of MARS, the MAGIC Analysis and Reconstruction
-! * Software. It is distributed to you in the hope that it can be a useful
-! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
-! * It is distributed WITHOUT ANY WARRANTY.
-! *
-! * Permission to use, copy, modify and distribute this software and its
-! * documentation for any purpose is hereby granted without fee,
-! * provided that the above copyright notice appear in all copies and
-! * that both that copyright notice and this permission notice appear
-! * in supporting documentation. It is provided "as is" without express
-! * or implied warranty.
-! *
-!
-!
-!   Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es>
-!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
-!
-!   Copyright: MAGIC Software Development, 2000-2004
-!
-!
-\* ======================================================================== */
-/////////////////////////////////////////////////////////////////////////////
-//
-//  bootcampstandardanalysis.C
-//
-//  Updated version of the macro designed at the Wuerzburg bootcamp and 
-//  compatible with the latest changes in Mars for general usage at the
-//  Udine bootcamp. 
-//
-//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
-//  one of a calibration file ("*_C_*.root") and one of a data file 
-//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
-/// constants calculation and the calibration of the data. 
-//
-//  The TString inpath has to be set correctly.
-//
-//  The macro searches for the pulser colour which corresponds to the calibration
-//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
-//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
-//  "ct1" in the filenames. If no colour or multiple colours are found, the 
-//  execution is aborted.  
-//
-//////////////////////////////////////////////////////////////////////////////////
-const Bool_t usedisplay = kTRUE;
-const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
-const TString outpath = "./";
-const TString defrout = "output_Mrk421_20040319.root";
-// Mrk (13)
-const Int_t defpedr[] = {20823};
-//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
-//			  20608,20611,20614,20649,20652,20654};
-// OffMrk (14)
-//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
-//			  20632,20635,20637,20640,20643,20645,20647};
-
-
-//const Int_t defcalr [] = {20651};
-const Int_t defcalr [] = {20822};
-
-// Mrk (20)
-const Int_t defdatar[] = {20824};
-//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
-//			  20603,20604,20606,20607,20609,20610,20612,
-//			  20613,20615,20616,20650,20653,20655};
-// OffMrk (18)
-// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
-// 			  20631,20633,20634,20636,20638,20639,20641,
-//			  20642,20644,20646,20648};
-
-
-void timedist3(const TString inpath=defpath, 
-                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
-                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
-                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
-                    const TString resname=defrout)
-
-{
-
-  //
-  // Choose the signal Extractor:
-  //
-  //MExtractSlidingWindow extractor;
-  MExtractFixedWindowPeakSearch extractor;
-  //MExtractFixedWindow    extractor;   
-
-  //
-  // Set Ranges or Windows
-  //
-  extractor.SetRange(3,14,3,14);
-  //extractor.SetWindows(8,8);
-
-  //
-  // Choose the arrival time Extractor:
-  //
-  MExtractTimeFastSpline       timeext;
-  //  MExtractTimeHighestIntegral timeext;
-  //  MExtractTimeSpline          timeext;
-  //
-  // Set Ranges or Windows
-  //
-  timeext.SetRange(2,12,4,14);
-
-
-  MRunIter pruns;
-  MRunIter cruns;
-  MRunIter druns;
-
-  for (Int_t i=0;i<psize;i++) {
-    cout << "Adding pedestal run: " << pedruns[i] << endl;
-    pruns.AddRun(pedruns[i],inpath);
-  }
-  for (Int_t i=0;i<csize;i++) {
-    cout << "Adding calibration run: " << calruns[i] << endl;
-    cruns.AddRun(calruns[i],inpath);
-  }
-  for (Int_t i=0;i<dsize;i++) {
-    cout << "Adding data run: " << dataruns[i] << endl;
-    druns.AddRun(dataruns[i],inpath);
-  }
-
-  
-  //
-  // Now setup the tasks and tasklist for the pedestals:
-  // ---------------------------------------------------
-  //
-  MBadPixelsCam     badcam;
-  MGeomCamMagic     geomcam;
-  MGeomApply        geomapl;
-  //
-  // If you want to exclude pixels from the beginning, read 
-  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
-  //
-  //  badcam.AsciiRead("badpixels.dat");
-  
-  /************************************/
-  /* FIRST LOOP: PEDESTAL COMPUTATION */
-  /************************************/
-
-  MJPedestal pedloop;
-  pedloop.SetInput(&pruns);
-  if (usedisplay)
-    {
-      MStatusDisplay *display = new MStatusDisplay;
-      display->SetUpdateTime(3000);
-      display->Resize(850,700);
-      pedloop.SetDisplay(display);
-    }
-  pedloop.SetBadPixels(badcam);
-  pedloop.SetExtractor(&extractor);
-
-  if (!pedloop.Process())
-    return;
-
-//   /****************************************/
-//   /* SECOND LOOP: CALIBRATION COMPUTATION */
-//   /****************************************/
-
-//   //
-//   // Now setup the new tasks for the calibration:
-//   // ---------------------------------------------------
-//   //
-//   MCalibrationQECam qecam;
-//   MJCalibration     calloop;
-//   calloop.SetInput(&cruns);
-//   calloop.SetExtractor(&extractor);
-//   //
-//   // Apply rel. time calibration:
-//   //
-//   calloop.SetRelTimeCalibration();
-//   calloop.SetTimeExtractor(&timeext);
-//   //
-//   // Set the corr. cams:
-//   //
-//   calloop.SetQECam(qecam);
-//   calloop.SetBadPixels(pedloop.GetBadPixels());
-//   //
-//   // The next two commands are for the display:
-//   //
-//   if (usedisplay)
-//       calloop.SetDisplay(display);
-//   cout << "Minchia 0" << endl;
-//   //
-//   // Do the event-loop:
-//   //
-//   if (!calloop.Process(pedloop.GetPedestalCam()))
-//     return;
-  
-//   cout << "Minchia 1" << endl;
-//   /*************************************/
-//   /* THIRD LOOP: PEDESTAL CALIBRATION  */
-//   /*************************************/
-
-//   //
-//   // Create a empty Parameter List and an empty Task List
-//   //
-//   MParList  plist3;
-//   MTaskList tlist3;
-//   plist3.AddToList(&tlist3);
-//   cout << "Minchia 2" << endl;
-//   //
-//   // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
-//   // -----------------------------------------------------------------------------------
-//   //
-  
-//   MCerPhotEvt    nphot;
-//   MPedPhotCam    nphotrms;
-  
-//   plist3.AddToList(&geomcam);
-//   cout << "Minchia 3" << endl;
-//   //
-//   // Retrieve the cameras from the previous runs:
-//   //
-//   plist3.AddToList(&pedloop.GetPedestalCam());
-//   plist3.AddToList(&calloop.GetCalibrationCam());
-//   plist3.AddToList(&calloop.GetQECam());
-//   plist3.AddToList(&calloop.GetRelTimeCam());
-//   plist3.AddToList(&calloop.GetBadPixels());
-//   plist3.AddToList(&nphot);
-//   plist3.AddToList(&nphotrms);
-//     cout << "Minchia 4" << endl;
-//   //tasks
-//   MReadMarsFile read3("Events");
-//   read3.DisableAutoScheme();
-//   static_cast<MRead&>(read3).AddFiles(pruns);  
-
-//   //MCalibrate       photcalc;
-//   MCalibrateData       photcalc;
-//   photcalc.SetCalibrationMode(MCalibrate::kFfactor);
-//   MPedPhotCalc  photrmscalc;  //It doesn't exist yet
-  
-//   tlist3.AddToList(&read3);
-//   tlist3.AddToList(&geomapl);
-//   tlist3.AddToList(&extractor);
-//   tlist3.AddToList(&photrmscalc);
-//   //tlist3.AddToList(&photcalc);
-  
-  
-//   //
-//   // Create and setup the eventloop
-//   //
-//   MEvtLoop evtloop3;
-//   evtloop3.SetParList(&plist3);
-  
-//   //
-//   // Execute first analysis
-//   //
-//   if (!evtloop3.Eventloop())
-//     return;
-  
-//   tlist3.PrintStatistics();
-  
-  /*************************************/
-  /* FOURTH LOOP: DATA CALIBRATION     */
-  /*************************************/
-
-  //
-  // Create a empty Parameter List and an empty Task List
-  //
-  MParList  plist4;
-  MTaskList tlist4;
-  plist4.AddToList(&tlist4);
-  
-  //
-  // Now setup the tasks and tasklist to analize the data
-  // -----------------------------------------------------
-  //
-  
-  plist4.AddToList(&geomcam);
-  //
-  // Retrieve the cameras from the previous runs:
-  //
-  plist4.AddToList(&pedloop.GetPedestalCam());
-  //  plist4.AddToList(&calloop.GetCalibrationCam());
-  // plist4.AddToList(&calloop.GetQECam());
-  // plist4.AddToList(&calloop.GetRelTimeCam());
-  //plist4.AddToList(&calloop.GetBadPixels());
-  //plist4.AddToList(&nphot);
-  //plist4.AddToList(&nphotrms);
-
-  MArrivalTimeCam times;
-  plist4.AddToList(&times);
-  
-  //tasks
-  MReadMarsFile read4("Events");
-  read4.DisableAutoScheme();
-  static_cast<MRead&>(read4).AddFiles(druns);  
-  
-  MArrivalTimeCalc2   timecalc;
-  //MCalibrateRelTimes  timecal;
-  
-  tlist4.AddToList(&read4);
-  tlist4.AddToList(&geomapl);
-  //tlist4.AddToList(&extractor);
-  tlist4.AddToList(&timecalc);
-  //  tlist4.AddToList(&photcalc);
-  //tlist4.AddToList(&timecal);
-  MRawEvtData *evtData;
-  //
-  // Create and setup the eventloop
-  //
-  MEvtLoop evtloop4;
-  evtloop4.SetParList(&plist4);
-  histTime = new TH1F("histTime","Arrival Time Dist",15,0.0,15.0);
-  Int_t i=0;
-  if (!evtloop4.PreProcess())
-    return;
-  
-  TCanvas *c1 = new TCanvas;
-  MHCamera disp1(geomcam);
-  disp1.SetPrettyPalette();
-  //disp1.SetInvDeepBlueSeaPalette()
-  disp1.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  
-  /*
-  TCanvas *c2 = new TCanvas;
-  MHCamera disp2(geomcam);
-  disp2.SetPrettyPalette();
-  //disp2.SetInvDeepBlueSeaPalette()
-  disp2.Draw();
-  gPad->SetLogy();
-  gPad->cd(1);
-  */
-  while (tlist4.Process())
-    {
-      i++;
-      //disp1.SetCamContent(nphot);
-      
-      //gPad->Modified();
-      //gPad->Update();
-      //      cout << i << endl;
-      //if((i == 16)||(i == 41)||(i == 111)||(i == 173)){
-      if((i == 41)){
-	cout << "Merda" << endl;
-	evtData = (MRawEvtData *)plist4->FindObject("MRawEvtData");
-	cout << "Merda1" << tlist4->FindObject("MRawEvtData") << endl;
-	MRawEvtPixelIter *pixIter = new MRawEvtPixelIter(evtData);
-	cout << "Merda2" << endl;
-	for (Int_t pix=1;pix<576;pix++){	  
-	  pixIter->Next();
-	  cout << "Merda3" << endl;
-	  if(pixIter->GetSumHiGainSamples()>200){
-	    cout << "Merda5" << endl;
-	    cout << "pix #" << pixIter->GetPixelId() << "  FADC Charge = " << pixIter->GetSumHiGainSamples() << endl;
-	    histTime->Fill((times[pix])->GetArrivalTimeHiGain());
-	  }
-	  cout << i << endl;
-	}
-      }
-      
-      /*    
-      disp2.SetCamContent(times);
-      
-      gPad->Modified();
-      gPad->Update();
-      */
-
-      // Remove the comments if you want to go through the file
-      // event-by-event:
-      //if (!HandleInput())
-      //break;
-    }
-
-  evtloop4.PostProcess();
-  histTime->DrawCopy();
-}
-
-Bool_t HandleInput()
-{
-    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
-
-    while (1)
-    {
-        //
-        // While reading the input process gui events asynchronously
-        //
-        timer.TurnOn();
-        TString input = Getline("Type 'q' to exit, <return> to go on: ");
-        timer.TurnOff();
-
-        if (input=="q\n")
-            return kFALSE;
-
-        if (input=="\n")
-            return kTRUE;
-    };
-
-    return kFALSE;
-}
-
