Index: /tags/Mars_V0-8/MagicSoft/Mars/.rootrc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/.rootrc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/.rootrc	(revision 1638)
@@ -0,0 +1,45 @@
+#############################################################################
+#                                                                           #
+# This is the path where root seraches for macros                           #
+# to execute (eg. .x merpp.C)                                               #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.MacroPath:       .:./macros
+
+#############################################################################
+#                                                                           #
+# This is the path where the dynamic loader (eg. gSystem->Load("mars.so")   #
+# is searching for the shared objects                                       #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.DynamicPath:     .:./lib
+
+#############################################################################
+#                                                                           #
+# This is the name of the logon macro (executed at root startup) and the    #
+# logoff macro (executed when quiting root)                                 #
+#                                                                           #
+#############################################################################
+
+Rint.Logon:                  rootlogon.C
+Rint.Logoff:                 rootlogoff.C
+
+#############################################################################
+#                                                                           #
+# This is used if you want to use the root documentation facility to        #
+# create the documentation of the code out of the code                      #
+#                                                                           #
+#############################################################################
+
+Root.Html.DescriptionStyle:  Doc++
+
+Root.Html.Author:            !   Author(s):
+Root.Html.Copyright:         !   Copyright
+Root.Html.Modified:          !   Modified:
+Root.Html.Description        // ----
+
+Root.Html.Root:              http://root.cern.ch/root/htmldoc/
+Root.Html.HomePage:          http://magic.astro.uni-wuerzburg.de/mars/
+Root.Html.SearchEngine:      http://magic.astro.uni-wuerzburg.de/mars/search.html
Index: /tags/Mars_V0-8/MagicSoft/Mars/BUGS
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/BUGS	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/BUGS	(revision 1638)
@@ -0,0 +1,7 @@
+                                                               -*-*- END -*-*-
+
+List of known bugs:
+-------------------
+
+ - Reading rootified daq files causes big memory leaks
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Changelog
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Changelog	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Changelog	(revision 1638)
@@ -0,0 +1,5354 @@
+                                                                  -*-*- END -*-*-
+
+ 2002/11/18: Thomas Bretz
+
+   * macros/CT1Hillas.C:
+     - changed MWRiteRootFile to write the histograms only
+     - renamed HillasSource to MHillasSrc
+
+   * macros/MagicHillas.C:
+     - removed all anti source stuff (corresponding to star.C)
+     - changed MWRiteRootFile to write the histograms only
+     - renamed HillasSource to MHillasSrc
+
+   * macros/estfit.C:
+     - renamed HillasSource to MHillasSrc
+
+   * macros/estimate.C:
+     - renamed HillasSource to MHillasSrc
+     - changed to display more interesting histograms
+
+   * multidimdist.C:
+     - added Theta
+     - added Alpha
+
+   * macros/star.C
+     - removed wrong HillasSource
+     - added MSrcPosCam
+
+   * starplot.C:
+     - removed all anti source stuff (corresponding to star.C)
+     - renamed HillasSource to MHillasSrc
+
+   * macros/multidimdist2.C:
+     - fixed a typo
+     - added Alpha and Theta
+
+   * mbase/MTime.h:
+     - added minus-operator
+
+   * mdata/MDataChain.[h,cc]:
+     - added floor
+
+   * mhist/MFillH.[h,cc]:
+     - moved MMap and MMap support MHArray
+
+   * mhist/MHArray.[h,cc]:
+     - added MMap
+     - added MMap-support
+     - added legend
+     - added more draw options
+
+   * mhist/MHFadcCam.[h,cc]:
+     - added Fill(const MRawEvtData*)
+     - added const getter functions
+
+   * mhist/MHFadcPix.h:
+     - added const getter functions
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - removed underscores from names
+     - removed empty destructor
+
+   * manalysis/MPedestalCalc.[h,cc]:
+     - added (not yet to LinkDef.h and Makefile)
+
+   * mgeom/MGeomMirror.[h,cc], mgeom/MGeomPMT.[h,cc], 
+     mmc/MMcConfigRunHeader.[h,cc], mmc/MMcCorsikaRunHeader.[h,cc]:
+     - changed comments
+     - added missing manalysis-dir (strange!)
+
+
+
+ 2002/11/16: Abelardo Moralejo
+
+   * mmc/MMcCorsikaRunHeader.cc:
+     - added default destructor
+
+
+
+ 2002/11/15: Thomas Bretz
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - small changes
+
+   * mmc/McLinkDef.h:
+     - added missing MMcCorsikaRunHeader
+
+
+
+ 2002/11/15: Oscar Blanch
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - added
+
+
+
+ 2002/11/14: Thomas Bretz
+
+   * mmain/MAnalysis.cc, mmain/MMonteCarlo.cc, mmain/MDataCheck.cc:
+     - removed SetProgressBar of reader
+
+   * mhist/MHFlux.cc:
+     - localized some variables
+     - get rid of old c-style sprintf
+     - return errorflag in Parab as return value!
+
+   * mgeom/MGeomPMT.cc, mgeom/MGeomMirror.cc:
+     - removed redefinition of a default argument
+
+   * mhist/MHMcIntRate.cc, mhist/MHMcCollectionArea.[h,cc]: 
+     - changed the error calculation according to a suggestion from Raquel
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc: 
+     - for collection area: MMcTrig isn't needed if all showers are
+       triggered showers
+
+   * mmc/MMcConfigRunHeader.cc:
+     - made function definition identical to function declaration
+
+   * macros/star.C:
+     - removed anti source for the moment
+
+   * macros/multidimdist2.C:
+     - added
+
+   * macros/comprob.C, macros/multidimdist.C:
+     - changed to use MHillasSrc instead of HillasSource
+
+   * mhist/MHHadronness.cc:
+     - changed the output of Print a bit
+
+
+
+ 2002/11/13: Thomas Bretz
+
+   * mfilter/MFEventSelector.[h,cc]:
+     - if total number of events read from file the selector worked only for
+       one eventloop - fixed.
+     - changed MReadMarsFile to MRead
+
+   * mbase/MContinue.cc:
+     - fixed a typo
+
+   * mbase/MEvtLoop.cc, meventdisp/MGEvtDisplay.cc:
+     - renamed MReadMarsFile/MReadTree to MRead
+
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MRead
+
+   * mfileio/MRead.[h,cc]:
+     - added
+
+   * mfileio/MReadMarsFile.[h,cc], mfileio/MReadTree.[h,cc]:
+     - renamed from MReadMarsFile to MRead
+     - derived from MRead
+     - removed progressbar support from MReadTree
+
+   * mfileio/MWriteRootFile.cc:
+     - added a info output
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - changed to work much much better :)
+
+   * mgeom/GeomLinkDef.h, mmc/McLinkDef.h:
+     - added missing LinkDefs (helllo Oscar!)
+
+   * mgeom/MGeomCamCT1.cc:
+     - mirrored the CT1 camera in x (CT1 default)
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - some small changes
+   
+   * mgeom/MGeomPMT.[h,cc]:
+     - changed usage of TArrayF from pointer to reference
+
+   * mgui/MCamDisplay.cc:
+     - fixed a crash at delete when the user closed a automatically
+       created canvas
+
+   * mhist/MHFadcCam.[h,cc]:
+     - implemented ResetHistograms
+
+   * mhist/MHMatrix.[h,cc]:
+     - implemented ReduceNumberOfRows (preliminary, untested)
+
+   * mmc/MMcConfigRunHeader.[h,cc]:
+     - some small changes
+     - changed usage of TArrayF from pointer to reference
+
+
+
+ 2002/11/11: Thomas Bretz
+
+   * manalysis/MHillas.cc:
+     - moved division by size before test of number of used pixels
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - added a eof-conditional
+
+   * mhist/MH3.cc:
+     - added a 'nonew' option to DrawClone
+
+   * mhist/MHHadronness.cc:
+     - check for NaN in Fill
+
+
+
+ 2002/11/08: Oscar Blanch
+
+   * mgeom/MGeomPMT.[h,cc]:
+     - added
+     - Information about simulated QE
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - added
+     - Mirrors properties
+
+   * mgeom/Makefile:
+     - modified to compile new classes
+
+   * mmc/MMcConfigRunHeader.[h,cc]:
+     - added
+
+   * mmc/Makefile:
+     - modified to compile new classes
+
+
+
+ 2002/11/08: Thomas Bretz
+
+   * mhist/MHMatrix.cc:
+     - implemented a zero suppression
+
+
+
+ 2002/11/07: Thomas Bretz
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFEventSelector
+
+   * mfilter/MFEventSelector.[h,cc]:
+     - added
+
+   * mfilter/MF.[h,cc]:
+     - made gsDef[Name,Title] a static const member
+
+   * manalysis/MMultiDimDistCalc.cc:
+     - changed the default function to kernel
+
+
+
+ 2002/11/07: Oscar Blanch
+   * mmc/MMcEvt.[hxx,cxx]
+     - Some new variable from the reflector header event.
+     - Class version switched to 2
+
+   * mmc/MMcRunHeader.[hxx,cxx]
+     - Varible member fOpticLinksNoise has been introduced
+     - Class version switched to 3
+
+
+ 2002/11/07: Wolfgang Wittek
+
+   * mhist/MHFlux.[h,cc]
+     - changed to avoid warnings : "member initializers will be re-ordered
+                                    to match declaration order"
+
+
+
+ 2002/11/06: Thomas Bretz
+
+   * Makfile.conf.osf5.1:
+     - added
+
+   * mhist/MHMatrix.cc:
+     - changed all math.h functions or similar to TMath
+     - added 2*pow(rows, 1/(4+cols))^2 as the standard kernel window
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - corrected the reading routines
+
+   * mfileio/*.cc:
+     - changed my eMail address
+
+   * mfileio/structures.h:
+     - small changes to make it architecture independant
+
+
+
+ 2002/11/04: Thomas Bretz
+
+   * macros/estimate.C, macros/estfit.C:
+     - added
+     
+   * mfileio/structures.h, mfileio/defines.h:
+     - added from CT1 PreProc 0.5
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - added 
+
+   * mhist/MHArray.[h,cc]:
+     - added
+
+   * Makefile:
+     - changed the order of the libs to make the linker happy
+     
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - changed to be able to use also an existing MBlindPixels from the 
+       parlist
+     - changed to use the pixel Id instead of its index number from the evt
+
+   * manalysis/MCameraSmooth.cc:
+     - changed to use the pixel Id instead of its index number from the evt
+       
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added GetPixById member function
+
+   * manalysis/MCompProbCalc.[h,cc]:
+     - changed Hadroness to Hadronness
+   
+   * manalysis/MHillasExt.cc:
+     - fixed a typo in a comment
+
+   * mbase/MParContainer.[h,cc]:
+     - added New-virtual member function
+
+   * mbase/MTask.[h,cc]:
+     - changed AddToBranchList so that it also accepts comma seperated
+       lists (only when using TString)
+       
+   * mdata/MData.[h,cc], mdata/MDataArray.[h,cc], mdata/MDataChain.[h,cc],
+     mdata/MDataElement.[h,cc], mdata/MDataList.[h,cc]
+     - updated comments
+     - added new GetDataMember member function
+     
+   * mdata/MDataArray.[h,cc]:
+     - added new member function AddEntry(MData*)
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MCT1ReadPreProc
+     
+   * mfileio/MCT1ReadAscii.cc:
+     - removed fNphot->Clear() (automatically called for each event by
+       Reset();
+       
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHArray
+     
+   * mhist/MFillH.[h,cc]:
+     - made work with arrays of histograms (MHArray) the mapping is
+       done by a preliminary class MMap
+       
+   * mhist/MH.[h,cc]:
+     - implemented GetHistByName virtual function
+     - implemented GetDataMember virtual function
+     - small changes to debug output
+     
+   * mhist/MH3.[h,cc]:
+     - implemented usage of GetDataMember for AddBranchToList
+     - implemented GetHistByName
+     - implemented New to be used in MHArray
+
+   * mhist/MHAlphaEnergyTheta.h, mhist/MHAlphaEnergyTime.h,
+     mhist/MHEnergyTheta.h, mhist/MHEnergyTime.h,
+     mhist/MHHillas.[h,cc], mhist/MHHillasExt.[h,cc],
+     mhist/MHHillasSrc.[h,cc], mhist/MHMcDifRate.h,
+     mhist/MHMcEfficiency.h, mhist/MHMcEfficiencyEnergy.h,
+     mhist/MHMcEfficiencyImpact.h, mhist/MHMcEnergy.[h,cc],
+     mhist/MHMcEnergyImpact.h, mhist/MHMcEnergyMigration.h,
+     mhist/MHMcIntRate.h, mhist/MHStarMap.h, mhist/MHThetabarTheta.h,
+     mhist/MHThetabarTime.h, mhist/MHTimeDiffTheta.h, 
+     mhist/MHTimeDiffTime.h:
+     - implemented GetHistByName
+   
+   * mhist/MHHadronness.[h,cc]:
+     - some small changes and checks
+     - changed histogram io from standard pointer to '->'
+
+   * mhist/MHMatrix.cc:
+     - updated comments
+     - implemented GetDataMembers
+
+
+
+ 2002/10/31: Thomas Bretz
+
+   * mfileio/MReadTree.cc:
+     - enhanced the validity of the fNuMEntries workaround from
+       3.02.06 to 3.07.01
+
+   * manalysis/MBlindPixelCalc.h, mhist/MBinning.h:
+     - added an explicit cast to get rid of a compiler warning on Alpha
+
+   * mhist/MH.cc:
+     - removed an unused variable to get rid of a compiler warning on Alpha
+
+
+
+ 2002/10/31: Wolfgang Wittek
+
+   * mhist/MHFlux.[h,cc]:
+     - type of fVarname and fUnit changed from char* to TString
+
+
+
+ 2002/10/30: Thomas Bretz
+
+   * mhist/MHMatrix.cc:
+     - changed the return value for the kernel method from log to -log
+     - fixed a typo in an error message
+     - fixed a crash in case the matrix is singular
+
+   * mhist/MMultiDimDistCalc.cc:
+     - check whether calculation of the distance succeeded
+
+   * mfileio/MReadTree.[h,cc]:
+     - implementation which makes sure, that the number of events returned 
+       by GetEntries always is the correct value.
+     - removed const from the GetEntries definition
+     - mainly use GetEntries now instead of fNumEntries
+
+   * manalysis/MCameraSmooth.cc:
+     - removed include of MMcRunHeader
+
+
+
+ 2002/10/29: Thomas Bretz
+
+   * manalysis/MHadroness.[h,cc]:
+     - renamed to MHadronness
+
+   * mhist/MHHadroness.[h,cc]:
+     - renamed to MHHadronness
+     - small changes to the graphical and text output
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h, macros/multidimdist.C,
+     manalysis/MMultiDimDistCalc.[h,cc], macros/comprob.C,
+     mhist/Makefile, mhist/HistLinkDef.h:
+     - changed Hadroness to Hadronness
+
+   * manalysis/MCerPhotAnal.cc:
+     - small changes to the code layout
+
+
+
+ 2002/10/24: Thomas Bretz
+
+   * macros/multidimdist.C:
+     - some changes to make it work with the latest version of Mars
+
+   * mhist/MHMatrix.cc:
+     - changed the Print member function to be more flexible
+
+   * mhist/MHHadroness.[h,cc]:
+     - changed fQfac from TH to TGraph
+     - changed the Qfactor-plot x-axis from Hadronness to Gamma-Acceptance
+
+   * mgui/MCamDisplay.cc:
+     - changed ratio from ratio to sqrt(ratio) in GetColorError
+
+   * mhist/MH3.cc:
+     - changed plotted errors from spread/sqrt(n) to spread
+
+
+
+ 2002/10/19: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc.cc
+     - Added check of whether a pixel has all its FADC slices empty before
+       subtracting pedestal.
+
+
+
+ 2002/10/18: Thomas Bretz
+
+   * mfileio/MWriteRootFile.cc
+     - make sure that the tree is created in the corresponding file
+
+
+
+ 2002/10/17: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.[h,cc]
+     - added function to get the sum of squares of the samples
+
+
+
+ 2002/10/16: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc], MCerPhotCalc.[h,cc]
+     - Class MCerPhotCalc2 renamed MCerPhotCalc (they were redundant).
+     - Now the default pixel treatment is the same as originally: add 
+       all FADC slices
+
+   * macros/MagicHillas.C
+     - changed accordingly to changes above.
+
+
+
+ 2002/10/16: Thomas Bretz
+
+   * macros/readMagic.C:
+     - added MPrint for MRawEvtHeader
+     - changed to MPrint to new Skip-Style
+
+   * manalysis/MHillasCalc.cc, manalysis/MHillasSrcCalc.cc:
+     - corrected output stream in case of hex or setfill was used
+
+   * mbase/MPrint.[h,cc]:
+     - introduced new behaviour of PreProcess (EnableSkip)
+
+   * mbase/MTaskList.cc:
+     - fixed a bug in Process which caused Histograms to be written
+       after each event
+
+   * meventdisp/MGEvtDisplay.cc:
+     - introduced printing of MRawEvtHeader
+
+   * mmc/MMcEvt.cxx:
+     - some small changes
+     - changed Print output from cout to fLog
+     - changes to the default values
+
+   * mraw/MRawEvtHeader.[h,cc]:
+     - removed the second empty line after Print
+     - added Getter-function for the DAQEvtNumber
+
+   * macros/star.C, macros/starplot.C, macros/threshold.C, macros/trigrate.C,
+     macros/plot.C, macros/plot2.C, macros/MagicHillas.C, macros/CT1Hillas.C,
+     macros/collarea.C:
+     - added ProgressBar
+
+   * macros/flux.C:
+     - fixed some coding bugs (redeclaration of Draw, Draw starting with a
+       capital)
+
+   * macros/MagicHillas.C:
+     - fixed some typos
+
+
+
+ 2002/10/15: Thomas Bretz
+
+   * mbase/MContinue.[h,cc]:
+     - added
+     
+   * Makefile:
+     - added some comments
+     
+   * macros/readMagic.C:
+     - replaced MHillas by MHillasExt
+     - print also MC Information
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - use MGeomCam::GetPixRatio
+     - added GetRatio[Min,Max]
+     - added GetErrorPhot[Min,Max]
+
+   * manalysis/MHillas.[h,cc], manalysis/MHillasExt.[h,cc],
+     manalysis/MHillasSrc.[h,cc]:
+     - return error codes
+     - don't display any error message or warning
+
+   * manalysis/MHillasCalc.[h,cc], manalysis/MHillasSrcCalc.[h,cc]:
+     - evaluate error codes returned by MHillas::Calc
+     - added Postprocess
+
+   * manalysis/MMcPedestalCopy.cc:
+     - removed obsolete comment
+
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - added include MGeomPix
+
+   * manalysis/MPedestalCam.[h,cc]:
+     - moved some stuff from header file to source file
+       to get rid of some includes in the header file
+     - adde GetSize
+     - added GetMean[Min,Max]
+
+   * manalysis/MPedestalPix.[h,cc]:
+     - added Clear
+     - added IsValid
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MContinue
+     
+   * mbase/MClone.h:
+     - added GetObject
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added SetProgressBar II
+
+   * mbase/MTask.[h,cc], mbase/MTaskList.[h,cc]:
+     - enhanced some comments
+     - print the name of the filter in PrintStatistic
+     - made the def name and title a static member
+     
+   * meventdisp/MGCamDisplay.[h,cc]:
+     - added displays for: Errors, Phot/Err, Levels and Pedestals
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - Some simplifications
+     - introduced AddTab
+   
+   * mfileio/MCT1ReadAscii.cc:
+     - added include MPedestalPix
+     
+   * mgeom/MGeomCam.[h,cc]:
+     - added GetPixRatio
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added possibilities to display: errors, ratios, levels and pedestals
+
+   * mhist/MHHillasSrc.cc:
+     - some small changes if mmdeg=0
+     
+   * mhist/MHStarMap.cc:
+     - anhanced displayed radius from 2/3r to 5/6r
+
+   * mmain/MMars.[h,cc]:
+     - changed layout
+     - added comments to display
+
+   * mmain/MProgressBar.cc:
+     - added some comments
+
+   * manalysis/MImgCleanStd.cc:
+     - pixels with to many 'used' neighbors are left used
+
+
+ 2002/10/14: Abelardo Moralejo
+
+   * manalysis/McerPhotCalc.cc, manalysis/MCerPhotCalc2.cc
+     - Initialized fEnableFix (before, bad pedestal subtraction if
+       reading camera 0.4 root files)
+
+
+ 2002/10/09: Abelardo Moralejo
+
+   * mhist/MHMcRate.cc:
+     - fixed a bug in total rate calculation (results change very little, 
+       only a 0.2 percent at most)
+
+
+ 2002/09/16: Thomas Bretz
+
+   * mtools/MagicSnake.cc:
+     - removed some debugging output
+     - fixed a small bug in the initialization
+
+
+
+ 2002/09/16: Thomas Bretz
+
+   * manalysis/MCerPhotPix.cc:
+     - shortened output
+
+   * mbase/MEvtLoop.cc:
+     - added a better progressbar support, if MReadTree or MReadMarsFile
+       exists in the Tasklist 
+
+   * mbase/MTaskList.cc:
+     - fixed a bug which caused MParList::Reset not to be called anymore
+       as soon as kCONTINUE was called once.
+
+   * mfileio/MReadTree.[h,cc]:
+     - added AddFiles member function
+
+   * mmain/MProgressBar.[h,cc]:
+     - added as a simple Progress meter for eventloops
+
+   * mmain/Makefile, mmain/MainLinkDef.h:
+     - added MProgressBar
+
+   * manalysis/MHillas.cc:
+     - removed warning in case of no photons. problems with Thomas' files.
+
+   * mbase/Makefile:
+     - added mfileio
+
+
+
+ 2002/09/16: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added SetMakeSharedLib to make it work correctly on linux
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MEnergyEstParam
+     - added MMatrixLoop
+
+   * manalysis/MEnergyEstParam.[h,cc], manalysis/MMatrixLoop.[h,cc]:
+     - added
+
+   * manalysis/MEnergyEst.h:
+     - added fImpact provisionally
+     - changed to 'no-storage'
+
+   * manalysis/MHillas.[h,cc], manalysis/MHillasExt.[h,cc],
+     manalysis/MHillasSrc.[h,cc]:
+     - added set function to support Thomas Schweitzers Image files
+
+   * mbase/MFilter.cc:
+     - small changes to output
+
+   * mbase/MLog.[h,cc]:
+     - added IsNull to switch off output completely
+
+   * mbase/MParList.[h,cc]:
+     - added Remove function
+     - added IsOwner function
+     - changes to SavePrimitive
+     - kDoNotReset-support
+
+   * mbase/MTaskList.cc:
+     - make sure, that in sub-tasklist the parameterlist isn't reset
+
+   * mdata/MDataLinkDef.h, mdata/Makefile:
+     - added MDataElement
+     - added mhist-path
+
+   * mdata/MDataChain.[h,cc]:
+     - added support for MDataElement
+
+   * mhist/MH3.[h,cc]:
+     - added enums for log-scale
+     - set logscale automatic when drawing
+     - added 'only' option to draw functions
+     - set colors when 'col' option is given
+
+   * mhist/MHHillas.cc:
+     - better hist range for fCenter
+
+   * mhist/MHMatrix.[h,cc]:
+     - made default name and title a static class member
+     - changed AddColumn now returning the new comlumn index
+     - added Fill to fill Matrix from file
+     - added locking
+     - added IsValid
+     - added GetNumRows
+     - added SetNumRow
+     - added []-operator
+     - added GetNumRow
+
+   * mhist/MHStarMap.cc:
+     - fixed some comments
+
+   * mbase/MEvtLoop.[h,cc], MParContainer.[h,cc]:
+     - added support for writing two or more Evtloops into one macro
+
+
+
+ 2002/09/02: Thomas Bretz
+
+   * mhist/MHMatrix.[h,cc]:
+     - added GetIndexdOfSortedColumn
+     - added SortMatrixByColumn
+
+   * mhist/HistIncl.h:
+     - added TArrayI.h (for MHMatrix.h)
+
+
+
+ 2002/08/19: Thomas Bretz
+
+   * mhist/MHillasExt.cc:
+     - removed a wrong 2 in the calculation of fAsym
+
+
+
+ 2002/08/16: Thomas Bretz
+
+   * mhist/MFillH.cc:
+     - if not title is given create a default title from the names
+
+   * mhist/MHHillas.cc, mhist/MHHillasExt.cc:
+     - use the new MH::Draw[Copy] function
+     - added names to the histograms in MHHillasExt
+
+   * manalysis/MCerPhotPix.h:
+     - unimportant change
+
+   * manalysis/MImgCleanStd.cc:
+     - added comment
+
+   * mhist/MH.[h,cc]:
+     - added function to draw two histograms in one pad with
+       a layout of two stat boxes and a legend: Draw[Copy]
+     - added comments
+     - added another sanity check in SetBinning(TH1*,TH1*)
+
+
+
+ 2002/08/14: Thomas Bretz
+
+   * mbase/MTask.[h,cc], mbase/MTaskList.[h,cc]:
+     - added second argument to PrintStatistics
+
+
+
+
+
+ 2002/08/12: Thomas Bretz
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - fixed a typo in the SetUseCentralPixel
+     - only use pixels without starlight for interpolation
+
+
+
+ 2002/08/09: Thomas Bretz
+
+   * mbase/MIter.[h,cc]:
+     - added
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MIter
+
+   * mdata/MDataChain.cc:
+     - added sanity check in StreamPrimitive
+
+   * mfilter/MF.[h,cc]:
+     - fixed StreamPrimitive
+     - don'w stream standard name and title.
+     - added default constructor
+
+   * mfilter/MFDataMeber.cc:
+     - strip spces from value before returning GetRule
+
+   * mfilter/MFilterList.[h,cc]:
+     - fixed StreamPrimitive
+     - don't stream standard name and title.
+
+
+
+ 2002/08/08: Thomas Bretz
+
+   * manalysis/MHillasSrc.cc:
+     - use double dist instead of single fDist for calculation
+
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - added support for the kernel method
+     - added stream primitive
+     - changed version number to 1
+     - adapted to new MHMatrix (using MDataArray)
+
+   * mdata/MDataArray.[h,cc]:
+     - added
+
+   * mdata/DataLinkDef.h, madata/Makefile:
+     - added MDataArray
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed some bugs in StreamPrimitive
+     - StreamPrimtive doesn't write the default name/title anymore
+
+   * mhist/MHMatrix.[h,cc]:
+     - replaced the Arrays for the rules by a MDataArray
+     - implemented StreamPrimitive
+     - implement the use of the kernel function for num<0
+     - multiply fM2 by nevts-1
+     - added sanity check in case of dists[i]<0
+
+   * mhist/MHHillas.[h,cc]:
+     - added fUsedPix, fCorePix
+     - added fUsedPix, fCorePix to plots
+     - changed layout of plots
+     - changed name and title of MakeDefCanvas
+
+   * mhist/MHHillasSrc.[h,cc]:
+     - changed plot of Alpha from fabs(fAlpha) to fAlpha
+     - changed name and title of MakeDefCanvas
+
+   * mhist/MHillasExt.[h,cc]:
+     - changed layout of plots
+     - changed name and title of MakeDefCanvas
+     - made independant of MHillas
+     - exchanged the usage of the Fill-argument (MHillasExt) and the
+       stored pointer (MHillasSrc)
+     - changed the default binning of asym to be symmetric
+
+   * mbase/MTask.cc:
+     - fixed wrong streaming of filter name
+
+   * macros/starplot.C:
+     - added
+
+   * macros/dohtml.C:
+     - added starplot.C
+
+   * macros/MagicHillas.C, macros/CT1Hillas.C:
+     - changed to use new stylish Hillas Histograms
+
+   * macros/star.C:
+     - changed to interpolate pixels around hot spots
+     - write Sourcs and AntoSource to RunHeaders
+
+
+
+ 2002/08/07: Thomas Bretz
+
+   * macros/dohtml.C:
+     - added missing paths
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - replaced booleans by fFlags
+     - added StreamPrimitive
+     - changed version number to 1
+
+   * manalysis/MHillasSrcCalc.[h,cc]:
+     - added correct initializations for the pointers
+     - made the pointers persistent
+
+   * manalysis/MImgCleanStd.cc, manalysis/MSrcPosCam.cc,
+     mfileio/MWriteRootFile.cc:
+     - don't stream name and title if not necessary
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added some output
+     - added print function
+     - added gListOfPrimitives to delete BIT(15) of streamed containers
+     - Added default argument for Read and Write
+
+   * mbase/MParContainer.cc:
+     - added usage of gListOfPrimitives
+
+   * mbase/MParList.cc, mbase/MTaskList.cc, mhist/MBinning.cc:
+     - fixed a bug when only the title is different from the default
+
+   * mhist/MHHillas.cc:
+     - fixed the wrong usage of ApplyBinning for the 2D-Hist fCenter
+
+
+
+ 2002/08/06: Thomas Bretz
+
+   * mhist/MHHillas.cc:
+     - fixed setting of binning for fCamera
+
+   * mhist/MH.cc, mhist/MBinning.cc:
+     - added sanity check in ApplyBinning and Apply
+
+   * mbase/MFilterList.[h,cc]:
+     - moved to mfilter
+
+   * mbase/Makefile, mbase/BaseLinkDef.h, 
+     mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - changed accordingly
+
+
+
+ 2002/08/05: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added a warning in case of duplicate names in the lists
+     - added orresponding member functions (HasDuplicateNames)
+     - added some sanity checks, checking for an open file
+
+   * mbase/MFilter.[h,cc]:
+     - added GetRule virtual member function
+
+   * mbase/MFilterList.[h,cc]:
+     - added GetRule 
+     - added StreamPrimitive
+     - added name and title to the constructor
+     - set version number to 1
+
+   * mbase/MTask.h:
+     - removed const qualifiers from fFilter (seems, that the root io
+       doesn't like it)
+
+   * mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc], mdata/MDataMember.[h,cc],
+     mdata/MDataValue.[h,cc]:
+     - set class version to 1
+     - added default constructor if missing
+     - added fDataMember to MDataMember (formaly fName isn't stored)
+
+   * mfilter/MF.[h,cc], mfilter/MFAlpha.[h,cc], mfilter/MFDataMember.[h,cc],
+     mfilter/MFParticleId.[h,cc], mfilter/MFTriggerLvl1.[h,cc]:
+     - added StreamPrimitive
+     - removed const qualifiers from data members
+     - added the "!" to the data member storing the result
+     - added GetRule
+
+   * mhist/MFillH.[h,cc]:
+     - fixed some small bugs in StreamPrimitive
+
+   * mhist/MH3.[h,cc]:
+     - added the missing const-qualifier of StreamPrimitive
+
+   * mbase/MParContainer.[h,cc]:
+     - implemented setting a unique id in SavePrimitive
+     - imnplemented GetUniqueID 
+     
+   * manalysis/MHillasSrcCalc.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MSrcPosCam.cc, mbase/MEvtLoop.cc, mbase/MParList.cc,
+     mbase/MTaskList.cc, mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc,
+     mhist/MF.cc, mfilter/MFAlpha.cc, mfilter/MFDataMember.cc,
+     mfilter/MFParticleId.cc, mfilter/MFTriggerLvl1.cc, mhist/MBinning.cc,
+     mhist/MFillH.cc, mhist/MH3.cc:
+     - changed the 'instance' name to the UniqueName
+     - in some files: implemented a static constant name and title, which
+       is used to descide whether the name and/or title should be stream
+       in the constructor-call in StreamPrimitive
+
+
+
+ 2002/08/06: Wolfgang Wittek
+
+   * mbase/MTask.cc:
+     - redefinition of default argument in MTask::SavePrimitive removed
+
+
+
+ 2002/08/02: Thomas Bretz
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.cc,
+     manalysis/MSrcPosCam.cc, mbase/MParContainer.[h,cc],
+     mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc, mhist/MBinning.cc:
+     - added comments
+
+   * manalysis/MSrcPosCam.cc, mfileio/MWriteRootFile.cc, mhist/MFillH.cc:
+     - fixed a missing " in SavePrimitive
+
+   * mbase/MTask.[h,cc], mhist/MBinning.[h,cc], mhist/MH3.[h,cc]:
+     - implemented SavePrimitive
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added MakeMacro
+     - added Read and Write
+
+   * mbase/MParContainer.[h,cc], mbase/MParList.[h,cc], 
+     mbase/MTaskList.[h,cc]:
+     - added GetNames, SetNames virtual functions
+
+   * mdata/MData.[h,cc], mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc],
+     mdata/MDataValue.[h,cc], mdata/MDataMember.[h,cc]:
+     - implemented GetRule
+     - move Code from Print to GetRule
+     - removed Print
+
+   * mhist/MH3.[h,cc]:
+     - implemented default constructor
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.[h,cc],
+     manalysis/MSrcPosCam.[h,cc], mbase/MParList.[h,cc], mbase/MTask.h,
+     mbase/MTaskList.[h,cc], mfileio/MReadTree.[h,cc], 
+     mfileio/MWriteRootFile.[h,cc], mhist/MBinning.[h,cc], 
+     mhist/MFillH.[h,cc], mhist/MH3.[h,cc]:
+     - renamed SavePrimitive to StreamPrimitive
+     - implemented more accurate streaming
+     - removed some "//!" from the data members
+
+   * mbase/MParContainer.[h,cc]:
+     - new virtual function StreamPrimitive
+     - implemented flag whether this container has been streamed already
+
+   * mbase/MTask.[h,cc]:
+     - corrected streaming of primitive to stream filters correctly
+     - increased version number to 1
+
+   * mhist/MBinning.[h,cc]:
+     - move SetEdges and SetEdgesLog to the source file
+     - implemented a flag telling something about the type of the binning
+
+
+
+ 2002/08/01: Thomas Bretz
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.[h,cc],
+     manalysis/MSrcPosCam.[h,cc], mbase/MEvtLoop.[h,cc], 
+     mbase/MParContainer.[h,cc], mbase/MParList.[h,cc],
+     mbase/MTaskList.[h,cc], mfileio/MReadTree.[h,cc],
+     mfileio/MWriteRootFile.[h,cc], mhist/MFillH.[h,cc]:
+     - added SavePrimitive
+
+   * mbase/MEvtLoop.h, mbase/MParList.h, mbase/MTaskList.h,
+     mfileio/MReadMarsFile.h, mfileio/MReadTree.h, 
+     mfileio/MWriteRootFile.h, mhist/MFillH.h:
+     - changed from ClassVersion 0 to ClassVersion 1
+   
+   * mfileio/FileIOLinkDef.h:
+     - added MChain
+
+   * mfileio/MReadMarsFile.cc, mfileio/MReadTree.cc, 
+     mfileio/MWriteRootFile.cc, mhist/MFillH.cc:
+     - added default constructor
+
+   * mfileio/MReadTree.cc:
+     - moved MChain to its own file
+
+   * mfileio/MWriteRootFile.cc:
+     - added default constructor to MRootFileBranch
+     - changed Version number from 0 to 1
+
+   * mfileio/Makefile, mfileio/FileIOLinkDef.h:
+     - MChain added
+
+   * mfileio/MChain.[h,cc]:
+     - added (from MReadTree.cc)
+
+   * manalysis/MHillas.[h,cc]:
+     - don't draw ellipse if values are invalid
+     - add used and core pixels to Print-output
+
+   * manalysis/MHillasExt.cc:
+     - reordered some comments
+
+   * mdata/MDataChain.[h,cc]:
+     - fixed a bug causing usage of '-' sometime not to work
+     - added handling of '+' sign
+
+   * mfileio/MReadTree.h:
+     - changed some comments
+
+   * mhist/MBinning.[h,cc]:
+     - added Apply
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc], 
+     mhist/MHHillasExt.[h,cc]:
+     - added default binning (usefull for the Magic Camera)
+     - some changes to the layout
+     - added support for the sign in MHHillasExt
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - added the possibility to use the interpolation of the
+       surrounding pixels
+     - clean the array with the blind pixel IDs at any ReInit
+
+   * manalysis/MBlindPixels.h:
+     - IsBlind now checks also for the validity of the array
+
+   * manalysis/MCerPhotPix.h:
+     - added Set-function
+
+   * manalysis/MHillas.cc:
+     - Don't ouput a warning if fSize==0 or fNumUsedPixels<0
+       (happens too often)
+
+   * manalysis/MCameraSmooth.[h,cc]:
+     - added
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - added MCameraSmooth
+
+
+
+ 2002/07/31: Thomas Bretz
+
+   * mgeom/MGeomPix.[h,cc]:
+     - added bits to flag pixel sin the two most outer rings
+     - added IsInOutermostRing and IsInOuterRing member function
+     - added CheckOuterRing mebmber function
+     - set the bit for the most outer ring in the member function to
+       initialize the next neighbors.
+
+   * mgeom/MGeomCam.[h,cc]:
+     - added InitOuterRing to initialize the bits for the secendmost 
+       outer ring
+
+   * mgeom/MGeomCamMagic.cc:
+     - Call InitOuterRing
+
+   * manalysis/MHillasExt.[h,cc]:
+     - removed AsciiRead member function
+     - reset fConc/fConc1 to -1 instead of 0
+     - replaced float by Float_t
+     - replaced Float_t for m3x/y, dzx and dzy by Double_t
+     - replaced maxpixx and maxpixy by maxpixid
+     - added somew new calculations (still in comments)
+     - scaled nphot by the ratio of the area of the current pixel to
+       the pixel with id zero to make a fair comparison in the maxpix
+       findinng
+
+   * manalysis/MSrcPosCam.[h,cc]:
+     - removed AsciiRead/Write member function
+
+   * manalysis/MImgCleanStd.cc:
+     - changed ispixused array size from max to max+1
+
+   * macros/MagicHillas.C:
+     - use the default binning of the histograms
+
+   * mhist/MH.[h,cc]:
+     - changed argument of SetBinning from TArrayD* to TArrayD&
+     - added ScaleArray
+     - added ScaleAxis
+     - proved that ScaleAxis is really working
+     - Added ApplyBinning
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - corrected the default binning
+     - take use of MH::ApplyBinning
+     - don't stop execution if no binning was found (take default)
+     - made sure, that rescaling of the axis is working properly
+
+
+
+ 2002/07/29: Thomas Bretz
+
+   * manalysis/MImgCleanStd.[h,cc]:
+     - changed ispixused from static size to dynamicly allocated size
+       (thanks to Markus Gaug)
+
+
+
+ 2002/07/29: Thomas Bretz
+
+   * mhist/MH.[h,cc]:
+     - added FindGoodLimits (taken from TTreePlayer)
+     - added GetMinimumGT
+
+   * mbase/MAGIC.h:
+     - removed kPI (redefinition in TVector2.h)
+
+   * mbase/BaseLinkDef.h:
+     - removed kPI (redefinition in TVector2.h)
+
+
+
+ 2002/07/26: Abelardo Moralejo
+
+   * mhist/MH.cc
+     - Fix: removed default arguments of ScaleAxis(...)  (did not 
+       compile on alphas).
+
+
+
+ 2002/07/25: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]:
+     - Changed fWeight into a TArrayF to make the class usable for
+       any number of FADC slices.
+     - added procedure SetDefaultWeights for initialization.
+
+   * macros/MagicHillas.C: 
+     - changed accordingly
+
+
+
+ 2002/07/25: Wolfgang Wittek, Thomas Bretz
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - added some more histograms showing the new parameters.
+
+   * mhist/MH.[h,cc]:
+     - added ScaleAxis member functions
+
+
+
+ 2002/07/25: Thomas Bretz
+
+   * mtools, mtools/Makefile, mtools/ToolsLinkDef.h, mtools/ToolsIncl.h:
+     - added
+
+   * mgeom, mgeom/Makefile, mgeom/GeomLinkDef.h, mgeom/GeomIncl.h:
+     - added
+
+   * Makefile:
+     - mtools added
+     - mgeom added
+
+   * mtools/MagicCivilization.[h,cc], mtools/MagicDomino.[h,cc],
+     mtools/MagicShow.[h,cc], mtools/MagicSnake.[h,cc]:
+     - added
+
+   * mgui/MineSweeper.[h,cc]:
+     - moved to mtools
+
+   * mgui/MGeom*.[h,cc]:
+     - moved to mgeom
+
+   * mgeom/MGeomCamMagic.cc:
+     - corrected 48(!) wrong entries in the Next Neighbor table
+
+   * mmain/Makefile, eventdisp/Makefile:
+     - added mgeom
+
+   * mgui/Makefile, mgui/LinkDef.h, mhist/Makefile, manalysis/Makefile:
+     - removed MGeom* and MineSweeper
+
+   * macros/rootlogon.C:
+     - added new include paths
+
+   * manalysis/MCerPhotEvt.cc, mgeom/MGeomCam.cc:
+     - removed include of MHexagon
+
+
+
+ 2002/07/23: Thomas Bretz
+
+   * mgui/MineSweeper.cc, mgui/MCamDisplay.cc:
+     - fixed a bug which could caused the destructor of the created canvas
+       not to be called if the object was deleted.
+
+   * mgui/MCamDisplay.h:
+     - some reordering
+
+   * mgui/MHexagon.cc:
+     - return the correct distance to primitive
+     - do a sanity check in DistancetoPrimitive
+
+   * mhist/HistLinkDef.h:
+     - added missing classes
+
+
+
+ 2002/07/23: Wolfgang Wittek, Thomas Bretz
+
+   * manalysis/MHillas.cc, manalysis/MHillasSrc.cc:
+     - replaced algorithms by the ones from the corresponding TDAS note
+     - made results of calculations (hopefully) more accurate
+     - added some output warnings and sanity checks
+     - changed the default parameters in the Reset function
+
+   * manalysis/MHillasSrc.[h,cc]:
+     - added fCosDeltaAlpha
+     - made Calc returning a Bool_t
+
+   * manalysis/MHillasSrcCalc.cc:
+     - make use of the return value of MHillasSrc::Calc 
+
+
+
+ 2002/07/22: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]:
+     -added procedure SetWeights.
+
+   * macros/MagicHillas.C:
+     -added example on how to use MCerPhotCalc2
+
+
+
+ 2002/07/22: Thomas Bretz
+
+   * mgui/MCamDisplay.cc:
+     - removed some unecessary includes
+     - replaced *fPixels by *this
+
+   * mgui/MineSweeper.[h,cc]:
+     - added more comments
+     - removed some unnecessary includes
+     - replaced enum constants for colors by the root ones
+     - added gInterpreter->DeleteGlobal(this)
+     - removed the deletion of the self-allocated fDrawingPad
+     - added kUserBits, replacing kBitMask
+
+
+
+ 2002/07/16: Thomas Bretz
+
+   * macros/plot.C, macros/plot2.C, macros/star.C, macros/comprob.C:
+     - updated the comments in the macros
+     
+   * mgui/MHexagon.cc:
+     - added a sanity check in DistanceToPrimitive
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added DistanceToPrimitive
+     - declared virtual functions as virtual (easier to read in the Dox)
+
+   * mfileio/MWriteAsciiFile.[h,cc]:
+     - renamed AddContainer and AddRule to AddColumn and AddColumns
+
+   * macros/MagicHillas.C:
+     - adopted to new names of MWriteAsciiFile member functions
+
+
+
+ 2002/07/16: Wolfgang Wittek
+
+   * new 
+     ---
+     mhist    : MHEffOnTime     (replaces MHEffOnTimeTime and
+                                          MHEffOnTimeTheta)
+                MHThetabarTheta (forgotten to comit last time)
+                MHThetabarTime  (forgotten to comit last time)
+                MHGamma         (makes the subtraction SRC-ASRC and
+                                 counts the events with alpha<alpha0)
+
+   * modified 
+     --------
+     Mars     : Makefile.conf.general 
+                Changelog
+
+
+     mhist    : Makefile
+                HistLinkDef.h 
+                MHFlux             (performs the flux calculation)
+
+                MHAlphaEnergyTheta (replace BinningAlpha by BinningAlphaFlux)
+                MHAlphaEnergyTime  (replace BinningAlpha by BinningAlphaFlux)
+
+     macros   : flux.C       (replace some code by MHGamma,
+                              replace MHEffOnTimeTime and MHEffOnTimeTheta
+                              by MHEffOnTime)
+
+   * removed
+     -------
+     mhist    : MHEffOnTimeTime
+                MHEffOnTimeTheta
+
+
+
+ 2002/07/15: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]
+     - converted fWeight into a static variable.
+
+
+
+ 2002/07/11: Thomas Bretz
+
+   * mgui/MGeomCamCT1.cc:
+     - fixed a bug in the NN-Table (127 doesn't exist, 126 missing)
+
+   * mgui/MCamDisplay.cc:
+     - changed some gPad to fDrawingPad
+     - added kNoContextMenu and kCannotPick flags for the Primitives
+     - scaled the size of the pixel numbers text with the pixel radius
+
+   * mgui/MineSweeper.[h,cc]:
+     - added
+
+   * mgui/Makefile, mgui/GuiLinkDef.h:
+     - added MineSweeper
+
+   * Makefile:
+     - added missing mfileio
+
+
+
+ 2002/07/11: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]
+     - new class to compute nphe weighting FADC slices.
+
+
+
+ 2002/07/10: Oscar Blanch
+
+   * manalysis/MCerPhotAnal.[h,cc]
+     - new class to compute nphe. First version.
+
+
+
+ 2002/07/10: Abelardo Moralejo
+
+   * macros/MagicHillas.C:
+     -added MMcEvt container to hillas.root output
+
+
+
+ 2002/07/10: Thomas Bretz
+
+   * mmain/Makefile:
+     - added -I../mfileio
+
+   * manalysis/MCerPhotPix.h:
+     - renamed IsCorePixel to IsPixelCore
+     - renamed SetCorePixel to SetPixelCore
+
+   * manalysis/MHillas.[h,cc]:
+     - added fNumCorePixel
+     - added fNumUsedPixel
+
+   * manalysis/MImgCleanStd.cc, manalysis/MCerPhotEvt.cc:
+     - renamed IsCorePixel and SetCorePixel
+
+
+
+ 2002/07/08: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added include pathes for ACLIC
+
+   * mfileio, mfileio/FileIOLinkDef.h, mfileio/FileIOIncl.h, 
+     mfileio/Makefile:
+     - new directory
+
+   * mbase/MWriteAsciiFile.[h,cc], mbase/MWriteRootFile.[h,cc],
+     mbase/MReadTree.[h,cc], mbase/MReadMarsFile.[h,cc],
+     manalysis/MCT1ReadAscii.[h,cc]:
+     - moved to mfileio
+
+   * mbase/Makefile, mbase/BaseLinkDef.h, mbase/BaseIncl.h,
+     manalysis/Makefile, manalysis/AnalysisLinkDef.h, 
+     manalysis/AnalysisIncl.h, meventdisp/Makefile:
+     - changed accordingly
+
+   * meventdisp/MGCamDisplay.cc:
+     - cd to right canvas before drawing camera display
+
+   * meventdisp/MGEvtDisplay.[h,cc]:
+     - added the "Geometry"-Tab
+     - added MC informations to gui
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added DrawPixelNumbers
+     - added buttons to change the palette online
+
+   * mgui/MHexagon.h:
+     - added Getter functions
+
+   * macros/MagicHillas.C:
+     - added read.DisableAutoScheme()
+
+   * mhist/MH.[h,cc]:
+     - changed Fill to be non abstract anymore
+
+
+
+ 2002/07/04: Abelardo Moralejo
+
+   * macros/trigrate.C:
+     - Introduced some style improvements suggested by T. Bretz.
+
+
+
+ 2002/07/04: Abelardo Moralejo
+
+   * mmontecarlo/MMcTriggerRateCalc.h,cc:
+     - Now the dimension of fTrigger is set dynamically, to allow
+       the processing of files with an arbitrarily large number of 
+       trigger conditions inside.
+
+   * macros/trigrate.C:
+     - Adapted the macro to changes above, and added a third argument:
+       the name of a file containing pure NSB events from which the
+       accidental trigger rate is calculated. Previously, this had to 
+       be introduced in the macro by hand by the user.
+
+
+
+ 2002/06/14: Thomas Bretz
+
+   * mhist/MBinning.cc:
+     - Initialize the binning with 10 edges from 0 to 1
+
+
+
+ 2002/06/13: Thomas Bretz
+
+   * mdata/MData.cc:
+     - changed ostream.h to ofstream.h to make it compile on alpha
+
+
+
+ 2002/06/10: Thomas Bretz
+
+   * mbase/MReadMarsFile.cc:
+     - changed name of fRun to ReadRunHeaders
+
+   * mbase/MReadTree.cc:
+     - changed output to show name of class
+
+   * macros/plot.C:
+     - added
+
+   * macros/plot2.C:
+     - added
+
+   * manalysis/MHillas.cc:
+     - changed atan2 to atan for fDelta
+
+   * mbase/MAGIC.h, mbase/BaseLinkDef.h:
+     - changed definitions for Particle Id to enum
+
+   * mbase/MGList.cc:
+     - IsA()->InheritsFrom() replaced with InheritsFrom()
+
+   * mbase/MWriteAsciiFile.cc:
+     - IsA()->InheritsFrom() replaced with InheritsFrom()
+     - removed some debug outputs
+
+   * mbase/MDataChain.[h,cc]:
+     - implemented sign '-'
+
+   * mhist/MH.h:
+     - changed default canvas size to 580x435
+
+   * mhist/MHHadroness.cc:
+     - added some more output to Print
+
+   * mhist/MHMatrix.h:
+     - changed some i,j to x,y
+     - removed fabs from distance calculation
+     - added sqrt to distance calculation
+
+   * mmc/MMcEvt.cxx:
+     - changed output of Print
+
+
+
+ 2002/06/06: Thomas Bretz
+
+   * manalysis/MHillasSrc.cc:
+     - changed atan2 to atan for fAlpha
+
+
+
+ 2002/06/05: Thomas Bretz
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed the code completely to support rules (data chains), too.
+       the interface stayed the same.
+
+   * mdata/MDataChain.cc, mhist/MHMatrix.cc:
+     - added math.h for alpha compilers
+
+   * mbase/MParContainer.h:
+     - changes IsReadyToSave to const
+
+   * mdata/MData.[h,cc]:
+     - added AsciiWrite
+
+   * mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc], mdata/MDataValue.h:
+     - added IsReadyToSave
+
+   * mdata/MDataMember.[h,cc]:
+     - added a new constructor
+     - added IsReadyToSave
+
+
+
+ 2002/06/04: Thomas Bretz
+
+   * mhist/MHCompProb.[h,cc]:
+     - added
+
+   * mhist/MHMatrix.cc:
+     - corrected some bugs in the algorithm to calculate the distance
+
+   * mhist/Makefile:
+     - added -I../mmc
+
+   * mbase/Makefile:
+     - added -I../mdata
+
+   * mhist/MHHadroness.cc:
+     - some changes to the layout of the drawn histograms
+
+
+
+ 2002/06/03: Thomas Bretz
+
+   * mhist/MHCompProb.[h,cc]:
+     - added
+
+   * mhist/MHHadroness.[h,cc]:
+     - added
+
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHCompProb
+     - added MHHadroness
+
+   * mhist/MFillH.cc:
+     - added a info-output
+
+   * mhist/MH3.cc:
+     - excluded temporary profiles from directory
+
+   * mhist/MHMatrix.[h,cc]:
+     - added code to calculate multi-dimensional distances
+     - added comments
+
+   * mbase/MAGIC.h:
+     - changed kGAMMA to 1
+
+   * mbase/MParList.[h,cc]:
+     - added Replace-function
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - added correct seeking for the run headers
+
+   * mbase/MReadTree.[h,cc]:
+     - added GetFileIndex()
+
+   * mbase/MTaskList.cc:
+     - changed fTasksProcess.Delete() to fTasksProcess.Clear()
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - added some code for future usage (in comments)
+
+   * mbase/MLogo.[h,cc]:
+     - added (not in use)
+
+   * mfilter/MFParticleId.[h,cc]:
+     - added
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFParticleId
+
+   * manalysis/MHadroness.[h,cc]:
+     - added
+
+   * manalysis/MCompProbCalc.[h,cc]:
+     - added
+
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - added
+                                                           
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MHadroness
+     - added MCompProbCalc
+     - added MMultiDimDistCalc
+
+   * manalysis/Makefile:
+     - added ../mdata
+     - added ../mhist
+
+   * macros/star.C:
+     - added
+
+   * macros/comprob.C:
+     - added
+
+   * macros/multidimdist.C:
+     - added
+  
+  * macros/dohtml.C:
+     - added star.C
+     - added comprob.C
+     - added multidimdist.C
+
+  * mdata/MData.h:
+     - added ()-operator
+
+  * mdata/MDataList.cc:
+     - removed 'all' modifier in Print-statement
+
+  * mdata/MDataChain.[h,cc]:
+     - added default constructor
+
+  * mdata/MReadTree.cc:
+     - fixed a root bug for root versions<3.03/00 (the open file in
+       the TChain was not deleted (closed))           
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - store parlist instead of tasklist
+     - check for run types between files
+     - check for used reflector version (because of a bug in the program)
+
+   * mmc/MMcRunheader.hxx:
+     - added GetReflVersion()
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - changed particle Id numbers to predefined constants
+
+
+
+ 2002/05/29: Thomas Bretz
+
+   * mhist/MHMatrix.[h,cc]:
+     - added
+
+   * mhist/HistLinkDef.h, mhist/Makefile
+     - added MHMatrix
+
+   * mhist/MH.h:
+     - added Finalize-function prototype to be called at the end of
+       the eventloop
+
+   * mhist/MFillH.cc:
+     - added call to Finalize-function to in PostProcess
+
+   * mhist/MH3.cc:
+     - removed old includes
+
+   * mhist/MDataChain.cc:
+     - fixed a harmfull bug in the constructor. fOperatorType wasn't
+       correctly initialized
+
+   * mhist/MDataMember.cc:
+     - added some output in case of failures
+
+   * mgui/MGeomCam.[h,cc]:
+     - renamed fMm2Deg to fConvMm2Deg to be consistent with the Getter
+       function name
+
+
+
+ 2002/05/13: Thomas Bretz
+
+   * mbase/MReadTree.cc:
+     - changed the Notify-workaround from GetEntry to LoadTree.
+
+   * mfilter/MFDataMember.[h,cc]:
+     - changed class to use MDataMember instead of a direct access to
+       TMethodCall
+
+   * mfilter/Makefile:
+     - added path to mdata
+
+
+
+ 2002/05/06: Thomas Bretz
+
+   * mbase/MReadMarsFile.cc, mbase/MReadTree.cc, mbase/MTaskList.cc:
+     - implemented usage of the return value of the Notofy function
+
+   * mdata/MDataChain.[h,cc]:
+     - implemented single-argument operators (like abs or exp)
+
+
+
+ 2002/05/03: Thomas Bretz
+
+   * mars.cc:
+     - changed version to 0.8
+     - added logo stuff
+
+   * merpp.cc:
+     - changed usage-output
+
+   * mgui/MCamDisplay.cc, mgui/MGeomCam.cc, mgui/MGeomCamCT1.cc, 
+     mgui/MGeomCamMagic.cc, mgui/MHexagon.cc, mhist/MBinning.cc,
+     mhist/MFillH.cc, mhist/MH.cc, mhist/MHAlphaEnergyTheta.cc,
+     mhist/MHAlphaEnergyTime.cc, mhist/MHEffOnTimeTheta.cc,
+     mhist/MHEffOnTimeTime.cc, mhist/MHEnergyTheta.cc, MHEnergyTime.cc,
+     mhist/MHMcCollectionArea.cc, mhist/MHStarMap.cc, mmain/MMars.cc,
+     mmontecarlo/MMcCollectionAreaCalc.cc
+     - changed mail address
+     - added missing copyright notices
+     - added missing class description
+
+   * mbase/MWriteRootFile.cc, mbase/MWriteAsciiFile.cc:
+     - added AddToBranch call to AddContainer(const char*, const char*)
+
+
+
+ 2002/04/30: Thomas Bretz
+
+   * macros/MagicHillas.C:
+     - made eventloop infinite
+
+   * macros/tar.C:
+     - implemented some sanity checks (existing files)
+
+   * mgui/MCamDisplay.[h,cc]:
+     - changed to use DeepSea palette in root versions newer than 3.01/05
+     - fixed a bug which caused the destructor to do strange thing
+       (the uncloned fGeomCam was deleted)
+     - implemented a more accurate deletion of the objects in the
+       TClonesArrays by using TClonesArray::Delete
+     - Implemented deletion of automatically created TCanvas
+     - Implemented a sanity check in Draw and DrawPhotNum
+
+   * macros/readCT1.C, macros/readMagic.C:
+     - changed to Handling of the gui and keyboard input
+     - implemented the filename as function argument
+
+   * manalysis/MCT1ReadAscii.cc:
+     - Expanded filename to support filnames containing '~'
+
+   * mhist/MH3.h:
+     - removed 'const' to make 0.7 root 3.01/06 compatible
+
+   * mdata/MDataMember.cc, mdata/MDataValue.cc, mdata/MDataChain.cc:
+     - removed a 'redefinition of default argument'
+
+   * mdata/MFDataMember.cc:
+     - fixed a bug in the process function (second switch was never reached)
+
+
+
+ 2002/04/29: Thomas Bretz
+
+   * macros/tar.C:
+     - added
+
+   * Makefile:
+     - changed "make tar" to use macros/tar.C and root
+
+
+
+ 2002/04/29: Wolfgang Wittek
+
+   * mhist/Makefile, mhist/HistLinkDef.h 
+     - MHThetabarTheta and MHThetabarTime were added
+
+   * mhist/MHThetabarTheta.[h,cc], mhist/MHThetabarTime.[h,cc]:
+     - added
+
+   * mhist/MHMcEnergyMigration.[h,cc]:
+     - added
+
+
+
+ 2002/04/27: Oscar Blanch
+
+   * mmc/MMcRunHedaer.cxx, mmc/MMcTrig.cxx, mmc/MMcTrigHeader:
+     - description of variables that have been introduced in the second
+       version of this Containers.
+
+
+
+ 2002/04/26: Thomas Bretz
+
+   * mhist/MHFadcCam.cc:
+     - start numbering of pixels with 1
+
+   * mhist/MHFadcPix.[h,cc]:
+     - overloaded clone to get rid of the histograms in any directory
+     - removed some unnecessary StrDup calls
+     - changed binning (Thanks to Abelardo)
+
+   * mdata/MData.[h,cc]:
+     - documentation added
+     - implemented a new abstract member function: IsValid
+
+   * mdata/MDataChain.cc, mdata/MDataList.cc:
+     - changed logging output
+     - documentation added
+
+   * mdata/MDataList.h, mdata/MDataMember.h, mdata/MDataValue.h:
+     - implemented IsValid
+
+   * mdata/MDataMember.cc:
+     - Don't preprocess if fCall is already available
+     - documentation added
+
+   * mdata/MDataValue.cc:
+     - documentation added
+
+   * mhist/MHMcDifRate.h, mhist/MHMcEfficiency.h, 
+     mhist/MHMcEfficiencyEnergy.h, mhist/MHMcEfficiencyImpact.h, 
+     mhist/MHMcEnergyImpact.h:
+     - corrected class description
+
+   * mbase/MParList.cc:
+     - fixed a bug in CreateObjList
+
+
+
+ 2002/04/25: Thomas Bretz
+
+   * mmontecarlo/MMcCollectionAreaCalc.[h,cc]:
+     - counts now the number of simulated showers
+     - implemented some sanity checks (corsika version, etc)
+
+   * mhist/MMcCollectionArea.[h,cc]:
+     - added a first implementation of a calculation using only triggered
+       events
+
+   * mhist/MH.[h,cc]:
+     - changed the first argument in SetBinning (according to the number
+       of axis) to TH2 or TH3
+
+   * mhist/MH2.cc:
+     - changed the first argument in SetBinning (according to the number
+       of axis) to TH2 or TH3
+
+   * macros/collarea.C:
+     - replaces MReadTree by MReadMarsFile
+
+   * mmc/MMcRunHeader.hxx:
+     - added GetAllEvtsTriggered
+
+
+
+ 2002/04/24: Thomas Bretz
+
+   * mbase/MReadTree.cc:
+     - made use of TBranch::GetClassName root version dependant 
+
+   * manalysis/MCerPhotCalc.[h,cc]:
+     - added a fix (ped.mean - 0.5) for files from camera with version <= 40
+
+   * mmc/MMcRunHeader.hxx:
+     - added some Getter functions
+
+   * mdata/MDataChain.cc:
+     - use rule as a title if no title ios given
+
+   * mhist/MH3.[h,cc]:
+     - added usage of Data-Chains
+     - added a profiling option to the draw functions
+     - use the title (rule) of the data-chain as axis title
+
+   * mhist/Makefile:
+     - added mdata-path
+
+   * mbase/MParContainer.h:
+     - changed some output in GetterFunction
+
+
+
+ 2002/04/24: Wolfgang Wittek
+
+   * Work was done on the calculation of photon fluxes as a function of
+     Theta and as a function of time. The work is still in progress.
+
+   * macros/wowflux.C
+     - the macr0 was added (extended and improved version of flux.C)
+     - the macro steers the calculation of photon fluxes as a function
+       of Theta and time
+     - the macro is not yet complete; testing and developing is going on
+
+   * mhist/MHAlphaEnergyTheta.[h,cc], mhist/MHAlphaEnergyTime.[h,cc],
+     mhist/MHEffOnTimeTheta.[h,cc], mhist/MHEffOnTimeTime.[h,cc],
+     mhist/MHTimeDiffTheta.[h,cc], mhist/MHTimeDiffTime.[h,cc]:
+     - documentation was added 
+     - histogram axes were labeled
+
+   * mhist/MHEffOnTimeTheta.cc:
+     - range in which the fit of the distribution of time differences
+       is to be performed has been calculated
+     - new histograms were added (chi2/NDF, lambda, N0del)
+
+
+
+ 2002/04/23: Thomas Bretz
+
+   * madata/Makefile, mdata/DataIncl.h, mdata/DataLinkDef.h,
+     mdata/MData.[h,cc], mdata/MDataValue.[h,cc], mdata/MDataList.[h,cc],
+     mdata/MDataChain.[h,cc], mdata/MDataMember.[h,cc]:
+     - added
+
+   * mmc/MMcEvt.[hxx,cxx]:
+     - added correct units for fImpact
+
+
+
+ 2002/04/22: Thomas Bretz
+
+   * Makefile:
+     - added a chapter how to compile mars using shared libraries
+
+   * NEWS:
+     - updated
+ 
+   * mfilter/MF.[h,cc]:
+     - added 
+
+   * mfilter/MFDataMember.[h,cc]:
+     - added 
+
+   * mhist/MH3.[h,cc]:
+     - added 
+
+   * mhist/MHHillasExt.[h,cc]:
+     - added 
+     
+   * macros/rootlogon.C:
+     - added make() function
+     - splitted rootlogon()
+     
+   * mbase/MFilterList.cc:
+     - fixed a bug in the constructor
+     - small changes to the print function
+     
+   * mbase/MParContainer.[h,cc]:
+     - Added GetterMethod-Function
+
+   * mbase/MParList.cc:
+     - Added a security check in case no def. constructor of the new class 
+       is available
+     - changed print function
+     
+   * mbase/MReadTree.cc:
+     - changed so that the class type of the branch is used for creation of 
+       a new object instead of its name
+
+   * mbase/MTaskList.[h,cc]:
+     - fixed the check for the Process function. Only base classes
+       of first order have been checked
+       
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MF, MFDataMember
+
+   * mhist/HistLinkDef.h, mhist/MFillH.cc:
+     - added MH3, MHHillasExt
+
+   * mhist/MFillH.cc:
+     - small changes
+
+   * mhist/MH.[h,cc]:
+     - changed name handling in MakeDefCanvas to TString
+
+   * mhist/MHHillas.cc:
+     - exchanged Get*axis()->SetTitle with Set*Title()
+     
+   * mhist/MHHillas.h:
+     - made SetMm2Deg virtual (for MHHillasExt)
+
+   * mhist/MHStarMap.[h,cc]:
+     - changed layout from mm to deg
+
+   * mhist/MHHillasSrc.cc:
+     - fixed a bug which made it unpossible to display fDist in degrees
+
+
+
+ 2002/04/19: Thomas Bretz
+
+   * mbase/MTaskList.cc:
+     - fixed a heavy bug which caused PreProcess to crash (GetListOfBases
+       return a List of TBaseClasses not a List of TClass objects)
+     - added a security check to Process whether we have something to process or not.
+
+   * macros/CT1Hillas.C:
+     - changed to the new Hillas classes
+
+   * macros/readCT1.C:
+     - fixed a bug causing readCT1.C to crash when reading the first event 
+       being a pedestal event
+
+
+
+ 2002/04/17: Thomas Bretz
+
+   * mbase/MParContainer.cc:
+     - case label TMethodCall::kOther changed to default to get rid of
+       some warnings in newer root's (missing case label kString)
+
+   * mbase/MAGIC.h:
+     - changed defintion of Glog so that it now works on Alpha machines, too.
+
+
+
+ 2002/04/16: Thomas Bretz
+
+   * mhist/MHHillas.cc:
+     - Fixed a 'redefinition of default argument' on alpha
+
+
+
+ 2002/04/15: Thomas Bretz
+
+   * mgui/MGeomCam.cc:
+     - Added SetReadyToSave to Constructor
+
+   * mhist/MH.cc:
+     - Added some #ifdef conditionals for a fix in root
+
+   * mfilter/MFAlpha.[h,cc]:
+     - made IsExpressionTrue inline
+
+
+
+ 2002/04/05: Thomas Bretz
+
+   * mmain/MDataCheck.cc:
+     - exchanged order in call to MFillH constructor
+     - made eventloop infinite (only 300 events have been processed)
+
+   * mbase/MEvtLoop.h:
+     - added GetTaskList
+
+   * mbase/MTaskList.[h,cc]:
+     - introduced fTasksProcess which contains only the tasks
+       which overloads the process function so that processing
+       tasks doesn't waste time if a tasks doesn't have the process
+       function
+
+   * mgui/MGeomPix.[h,cc]:
+     - corrected calculation of pixel area
+
+
+
+ 2002/04/04: Thomas Bretz
+
+   * mbase/MLog.cc:
+     - stripped last character (CR) from output redirected to GUI    
+
+
+
+ 2002/03/21: Thomas Bretz
+
+   * mhists/MH.cc:
+     - TAxis::Set resets the axis title so I implemented a workaround
+       in SetBinning so that the axis title survives.
+
+   * mhists/MHEffOnTimeTheta.cc, MHEffOnTimeTime.cc:
+     - replaced Get*axis()->SetTitle() by Set*Title()
+     - corrected the Name in MakeDefCanvas
+
+
+
+ 2002/03/20: Thomas Bretz
+
+   * macros/flux.C:
+     - fixed a small bug (thanks to Wolfgang)
+
+   * mhist/MHHillas.[h,cc]:
+     - added more scaling options
+     - added setting for scaling factor
+
+   * mhist/MHStarMap.cc:
+     - changed sign of t (due to a mail of Wolfgang)
+
+   * mhist/MHTimeDiff*.cc:
+     - removed an implicit down-cast (TH1D --> TH1)
+
+
+
+ 2002/03/15: Oscar Blanch
+
+   * mmc/McLinkDef.h
+     - Automatic scheme evolution for all MC format classes.
+       It has been checked that it keeps compatibility with old files.
+
+   * mmc/MTriggerDefine.h
+     - Enlarge number of trigger pixels.
+
+   * mmc/MTrigger.[cxx,hxx]
+     - Trigger zone has been enlarged. Now information about status
+       of the pixel is saved for all Camera pixels.
+     - Old files can still be read but becareful when one looks at the
+       data member fPixelsFirst which is an array of different size for
+       the new and old files.
+     - ClassDef version upgraded to 2.
+
+   * mmc/MTriggerHedaer.[cxx,hxx]
+     - Member data fElecNoiseTrig, which has information about the 
+       electronic noise in the trigger chain, has been introduced.
+     - Trigger zone has been enlarged. Now information about status
+       of the pixel is saved for all Camera pixels.
+     - Old files can still be read but becareful when one looks at the
+       data member fThreshold which is an array of diferent size for
+       the new and old files.
+     - ClassDef version upgraded to 2.	
+
+
+
+ 2002/03/13: Oscar Blanch
+
+   * mmc/MMcRunHeader.[cxx,hxx]
+     -  Several new variable members have been added
+     -  Version number updated to 2
+
+
+
+ 2002/03/12: Thomas Bretz
+
+   * mmontecarlo/MMcTimeGenerate.cc (thanks to Wolfgang):
+     - removed wrong comment for Process
+     - changed Int_t to UInt_t (more readable)
+     - replaced unit: ms -> 0.1ms
+
+
+
+ 2002/03/08: Thomas Bretz
+
+   * manalysis/MHillasSrc.[h,cc]:
+     - added fHeadTail
+     - changed version number to 2.
+
+
+
+ 2002/03/07: Thomas Bretz
+
+   * mbase/MParContainer.[h,cc], MWriteAsciiFile.[h,cc]:
+     - added a scale value which can be used in case you are writing
+       single data mambers
+
+
+
+ 2002/03/04: Thomas Bretz
+
+   * mbase/MParContainer.cc:
+     - changed AsciiWrite so that only base classes with a version
+       id > 0 are written (important for MParContainer)
+
+
+
+ 2002/03/01: Thomas Bretz
+
+   * mhist/MHMcEfficiencyEnergy.[h,cc], mhist/MHMcEfficiencyImpact.[h,cc],
+     mhist/MHMcDifRate.[h,cc], mhist/MHMcIntRate.[h,cc]:
+     - added
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHMcEfficiencyEnergy and MHMcEfficiencyImpact
+     - added MHMcDifRate and MHMcIntRate
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed instantiation of collection area histogram
+     - added settings for the binning
+     - replaced division by root function
+     - added Calc-functions
+     - added GetHist
+
+   * mhist/MHMcEfficiency.[h,cc]:
+     - changed pointers in Calc functions to references
+
+
+
+
+
+ 2002/02/28: Thomas Bretz
+
+   * mhist/MHMcEnergyImpact.[h,cc], mhist/MHMcEfficiency.[h,cc]:
+     - added
+     
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHMcEnergyImpact and MHMcEfficiency
+
+   * mhist/*.cc:
+     - repaced some *&-> casts by &.
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed to be able to use new MHMcEfficiency.
+
+
+
+ 2002/02/21: Abelardo Moralejo
+
+   * manalysis/MHillasExt.cc :
+     - added #include <math.h>  (else, fabs not recognized by OSF)
+
+
+
+ 2002/02/21: Thomas Bretz
+ 
+   * manalysis/MHillas.[h,cc]:
+     - changed fMeanx and fMeany to fMeanX and fMeanY to match the names
+       of the getter functions, needed by TDataMember::GetterMethod
+     - commented out WriteAscii (replaced by more general in MParContainer
+       and MWriteAsciiFile)
+
+    * manalysis/MHillasSrc.[h,cc], mmc/MMcEvt.[hxx, cxx]:
+      - commented out WriteAscii (replaced by more general in MParContainer
+        and MWriteAsciiFile)
+
+    * manalysis/MHillasExt.[h,cc]:
+      - added necessary Getter Methods
+     
+    * mbase/MFilterList.cc:
+      - removed a nonsens comment
+    
+    * mbase/MGList.cc:
+      - relay on the bugfix for DynamicCast
+    
+    * mbase/MParContainer.[h,cc]:
+      - implemented WriteDataMember to have a more general interface
+        for readable output.
+      - changed ofstream to a more general ostream
+  
+    * mbase/MWriteAsciiFile.[cc,h]:
+      - generalized ascii writer to be able to write single data members
+
+
+
+ 2002/02/13: Thomas Bretz
+
+   * Makefile:
+     - made 'make dox' dependant on existance of shared object
+
+
+     
+ 2002/02/13: Thomas Bretz
+
+   * macros/MagicHillas.C, mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - implemented variable binning (MBinning)
+     - implemented conversion to degrees (thanks to rudy)
+     
+   * mgui/MGeomCam.[h,cc], mgui/MGeomCamCT1.cc, mgui/MGeomCamMagic.cc:
+     - implemented fMm2Deg and fCamDist
+
+
+
+ 2002/01/23: Thomas Bretz
+
+   * macros/flux.C:
+     - fixed some bugs
+     - uncommented all drawing
+     
+   * mhist/MBinning.h:
+     - changed SetEdges(TArrayD)
+     
+   * mhist/MH.cc:
+     - SetBinning(..., TAxis*,...) didn't work. Corrected.
+     
+   * mhist/MHAlphaEnergyTheta.cc, mhist/MHAlphaEnergyTime.cc,
+     mhist/MHEffOnTimeTheta.cc, mhist/MHEffOnTimeTime.cc,
+     mhist/MHTimeDiffTheta.cc, mhist/MHTimeDiffTime.cc:
+     - changed wrong titles, names, etc.
+     - changed way of drawing projections
+     - fixed usage of MH::SetBinning(TH1*)
+
+
+     
+ 2002/01/22: Thomas Bretz
+ 
+   * mhist/MHHillasSrc.[h,cc], mhist/MHFadcCam.[h,cc]:
+     - changed return type of Fill to Bool_t
+   
+   * mfilter/MFAlpha.[h,cc]:
+     - added
+
+   * mfilter/MFill.[h,cc]:
+     - implemented a new calling style which allows you to let MFillH
+       create the necessary histogram objects
+
+   * mmain/MAnalysis.cc, macros/MagicHillas.C:
+     - changed to new stylish MHillas parameter containers
+
+   * meventdisp/MGEvtDisplay.cc, mgui/MCamDisplay.cc,
+     mmain/MDataCheck.[h,cc]:
+     - fixed a warning in red hat linux
+  
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MFAlpha
+  
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - added SetupFill and usage of MBinning objects
+
+   * manalysis/MEnergyEst.[h,cc], manalysis/MEnergyEstimate.[h,cc],
+     mhist/MHTimeDiffTime.[h,cc], mhist/MHEnergyTheta.[h,cc],
+     mhist/MHEnergyTime.[h,cc], mhist/MHAlphaEnergyTheta.[h,cc],
+     mhist/MHAlphaEnergyTime.[h,cc], mhist/MHTimeDiffTheta.[h,cc],
+     mmontecarlo/MMcTimeGenerate.[h,cc]:
+     - added
+
+   * manalysis/Makefile:
+     - added MEnergyEst.cc
+     - added MEnergyEstimate.cc
+   
+   * mbase/MFilter.[h,cc], mfilter/MF*.[h,cc]:
+     - added name and title to constructor
+
+   * macros/flux.C:
+     - added
+
+
+
+ 2002/01/21: Thomas Bretz
+ 
+   * mbase/MReadMarsFile.cc, mbase/MReadTree.[h,cc]:
+     - implemented GetFileName
+
+   * mmc/MMcEvt.[hxx,cxx]
+     - implemented WriteAscii
+   
+   * mgui/MGeomPix.h:
+     - implemented first version of GetA
+
+   * mhist/MBinning.h:
+     - small changes to formulas
+     
+   * mhist/MH.[h,cc]:
+     - implemented SetBinnign functions
+
+   * macros/readMagic.C:
+     - removed MPedestalCam
+
+
+
+ 2002/01/19: Thomas Bretz
+ 
+   * mbase/MParContainer.cc:
+     - generalized virtual function AsciiWrite
+   
+   * changed to fit new MHillas inhertance model:
+     - manalysis/MHillas.[h,cc]
+     - manalysis/MHillasCalc.[h,cc]
+     - mhist/MHHillas.[h,cc]
+     - mhist/MHStarMap.[h,cc]
+
+   * added to fit new MHillas inhertance model:
+     - manalysis/MSrcPosCam.[h,cc]
+     - manalysis/MHillasSrc.[h,cc]
+     - manalysis/MHillasSrcCalc.[h,cc]
+     - manalysis/MHillasExt.[h,cc]
+     - mhist/MHHillasSrc.[h,cc]
+
+   * manalysis/MCerPhotEvt.[cc,h]:
+     - introduced weighting with pixel size in GetNumPhotonsMin
+     - introduced weighting with pixel size in GetNumPhotonsMax
+
+   * mgui/MCamDisplay.cc:
+     - weight the displayed color with the pixel size
+
+
+
+ 2002/01/18: Thomas Bretz
+ 
+   * mhist/MBinning.[h,cc]:
+     - added (not yet in Makefile)
+   
+   * mbase/MWriteAsciiFile.cc:
+     - fixed a bug: replaced GetSize by GetEntries
+     
+   * mbase/MReadTree.cc:
+     - changed EnableBranch to accept "Master.Sub" also
+
+
+
+ 2002/01/16: Thomas Bretz
+ 
+   * mars.cc:
+     - changed version number to 0.7
+
+   * NEWS:
+     - changed current version to 0.7
+
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - small changes to output
+ 
+   * mbase/MParList.[h,cc]:
+     - added FindObject with class type argument
+   
+   * mbase/MWriteAsciiFile.cc
+     - replaced call to InheritsFrom by new FindObject
+ 
+ 
+ 
+ 2002/01/15: Thomas Bretz
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - added more comments
+     - removed a debug statement
+    
+   * manalysis/MBlindPixels.[h,cc]:
+     - added more comments
+    
+   * manalysis/MCerPhotCalc.cc:
+     - changed the warning output
+    
+   * manalysis/MMcPedestalCopy.h:
+     - added comments
+    
+   * manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - added comments
+     - changed call to AddedToBranchList
+    
+   * mbase/MWriteAsciiFile.cc:
+     - added comments
+    
+   * mmc/MMcRunHeader.[hxx,cxx]:
+     - made getter const
+
+   * meventdisp/MGCamDisplay.cc:
+     - updated to use MBlindPixelCalc
+
+   * mbase/MEvtLoop.cc:
+     - replaced wrong "MTasklist" by "MTaskList"
+
+
+
+ 2002/01/14: Thomas Bretz
+ 
+   * manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalNSBAdd.cc:
+     - added comments
+
+   * mbase/MReadMarsFile.cc:
+     - changed output when switching to new file
+     
+   * meventdisp/MGFadcDisp.cc:
+     - made char array in constructor const
+     - changed char-array to TString
+
+   * mmain/MBrowser.[h,cc]:
+     - changed char-arrays to TString
+
+   * mmain/MDataCheck.[h,cc]:
+     - made char array in constructor const
+     
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - changed to O5
+     
+   * mbase/MEvtLoop.cc:
+     - check for inheritance from MTaskList
+
+   * manalysis/MPedestalCopy.cc, manalysis/MPedestalNSBAdd.cc:
+     - small changes
+   
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed to be able to write more than one container in a line
+
+
+
+ 2002/01/11: Oscar Blanch Bigas
+
+   * mmain/MAnalysis.cc:
+     - added MBlindPixelCalc step.
+
+   * macros/trigrate.C:
+     - the list of MHMcRate is created using from and to instead of
+       only dimension. Otherwise the case of a single trigger option is
+       not well treated.
+
+   * mhist/MHMcRate.[h,cc]:
+     - added funtion members SetFlux and SetIncidentRate and small
+       modification in CalcRate member function
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - now this task sets the parameters to know the incident particle
+       flux using MHMcRate::SetFlux. The value are decided by the task
+       itself depending on the fPartId.
+
+   * manalysis/MBlindPixelCalc.cc:
+     - rename MMcRunHeader:GetStarFieldDe to MMcRunHeader:GetStarFieldDec. 
+
+   * mmc/MMcRunHeader.[hxx, cxx]:
+     - rename MMcRunHeader:GetStarFieldDe to MMcRunHeader:GetStarFieldDec. 
+
+
+
+ 2002/01/10: Oscar Blanch Bigas
+
+   * mbase/Makefile:
+     - added -I../MRawFormat in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mraw/Makefile:
+     - added -I../MBase in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mbase/Makefile:
+     - added -I../MBase- in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mbase/MReadTree.cc:
+     - changed #include "../mraw/MRawEvtData.h" by #include
+       "MRawEvtData.h" to remove dependencies on the directory tree naming.
+
+
+
+ 2002/01/09: Oscar Blanch Bigas
+   
+   * manalysis/MPedestalCam.[h,cc]:
+     - added CheckBounds function to check that program does not try to
+       access pedestal outside the camera size.
+
+   * manalysis/MCerPhotCalc.h:
+     - Member data const MPedestalCam *fPedestals -> MPedestalCam
+     *fPedestals.
+
+   * manalysis/MCerPhotCalc.cc:
+     - Sanity check to avoid searching to pedestals outside the camera
+       size has been added.
+
+   * mmc/MMcRunHeader.[h,cxx]:
+     - added functions GetStarField[De,Ra].
+
+   * manalysis/MBlindPixels.[h,cc]:
+     - new containet that has a list of pixels that should not be used
+       in the analysis for any reason (corrupted, star in them, ...).
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - It is a task used to set up the list of blind pixels. Currently
+       it recognises the CrabNebula starfield and then switch off the
+       Theta Taury pixels. Blind pixels can be also introduced through
+       the macro or analysis program.
+
+   * manalysis/Makefile:
+     - added MBlindPixels and MBlinPixelCalc.
+
+   * manalysis/AnalysisLinkDef.h:
+     - added MBlindPixels and MBlinPixelCalc.
+
+   * macros/MagicHillas.C:
+     - added MBlindPixelCalc to avoid bias results due to Star Field
+       NSB.
+
+   * macros/readMagic.C:
+     - added MBlindPixelCalc to avoid bias results due to Star Field NSB while
+       computing the Hillas parameters.
+
+
+
+ 2001/12/19: Thomas Bretz
+  
+   * mbase/MEvtLoop.cc:
+     - added #ifdef directive to make it work on older root also
+      
+   * mbase/MReadTree.cc:
+     - added #ifdef directive to get rid of the memory leak in prior
+       root 3.02/* versions
+	    
+   * macros/MagicHillas.C, macros/readMagic.C, meventdisp/MGCamDisplay.cc,
+     mmain/MAnalysis.cc:
+     - changes MMcPedestalNSB to MMcPedestalNSBAdd
+     
+   * manalysis/MMcPedestalCopy.[h,cc], manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - reorganized ReInit, PreProcess.
+     - moved some code from ReInit to PreProcess to make the code
+       simpler. At the moment we don't intend to change the 
+       objects in the parlist while runtime.
+
+   * manalysis/MMcPedestalNSB.[h,cc]:
+     - removed
+
+   * mbase/MReadMarsFile.cc:
+     - read the first run header twice. To make it available in the
+       PreProcess of all tasks
+   
+   * mbase/MTaskList.cc:
+     - fixed a bug in the ReInit function. The ReInits where calles with 
+       a NULL-pointer
+
+
+
+ 2001/12/18: Oscar Blanch
+								 
+   * manalysis/Makefile:
+     - Removed MMcPedestalNSB from compilation and added
+       MMcPedestalNSBAdd.
+
+   * manalysis/AnalysisLinkDefine.h:
+     - Removed MMcPedestalNSB from class list and added
+       MMcPedestalNSBAdd.
+
+   * manalysis/MMcPedestalCopy.[h,cc]
+     - added ReInit function.
+     - move all actions needed to redo for each run from PreProcess
+       to ReInit
+     - fix bug of Pedestal and Pedestal fluctuaions correspondence.
+
+   * manalysis/MMcPedestalNSBAdd.[h,cc]
+     - new name for old MMcPedestalNSB.[h,cc]
+     - added ReInit function.
+     - move all actions needed to redo for each run from PreProcess
+       to ReInit
+     - information about pixel size is used from MGeomCam.
+
+   * manalysis/MCerPhotCalc.[h,cc]
+     - remove fNumLoGainFadcSlices and fNumHiGainFadcSlices members
+     - fix bug of Pedestal and Pedestal fluctuaions correspondence.
+
+
+ 2001/12/18: Thomas Bretz
+ 
+   * manalysis/MMcPedestalCopy.cc:
+     - changed output
+     
+   * manalysis/MMcPedestalNSB.cc:
+     - changed output
+     - simplified initialization in PreProcess
+     
+   * mbase/MAGIC.h:
+     - added kSKIP
+     
+   * mbase/MParList.cc:
+     - added a check for the correct inheritance in FindCreateObj
+   
+   * mbase/MTask.cc:
+     - added support for kSKIP in PreProcess
+
+   * mbase/MTaskList.[h,cc]
+     - added support for kSKIP in PreProcess
+     - added Remove function (private)
+
+
+
+ 2001/12/17: Thomas Bretz
+ 
+   * .rootrc:
+     - added Root.Html.DescriptionStyle
+     - added Root.Html.SearchEngine
+     
+   * macros/dohtml.C:
+     - changed to use THtml (root >= 3.02/06 only)
+     
+   * manalysis/Makefile:
+     - changed order to get rid of some wranings
+   
+   * mbase/BaseLinkDef.h:
+     - removed MHtml
+     
+   * mbase/MEvtLoop.cc:
+     - exchanged gSystem->ProcessEvents() by gClient->ProcessEventsFor()
+       to make gui update faster
+       
+   * mbase/MGList.cc:
+     - added a missing sanity check (workaround for a root bug)
+     
+   * mbase/MReadTree.cc:
+     - uncomment EnableBranchCoosing for AutoEnablingScheme
+       (don't know why there was a comment which made things realy slow)
+     - changed the auto enabling scheme, so that a branch isn't enabled
+       more than once. This doesn't hurt, but the output may confuse the
+       users.
+       
+    * mbase/MTask.cc:
+      - added a simple not really necessary check whether the branch is
+        already in the list
+        
+    * mbase/MWriteRootFile.cc:
+      - changed kFillTree to a local const
+      
+    * mbase/Makefile:
+      - removed MHtml.cc
+    
+    * mfilter/MFTriggerLvl1.cc:
+      - changed AddBranchToList to use the correct container name
+
+
+
+ 2001/12/14: Thomas Bretz
+ 
+   * mbase/MReadMarsFile.[h,cc], mbase/MReadFild.[h,cc]:
+     - corrected handling of ReInit/Notify (at the moment I assume 
+       one run per file)
+     - made sure, that we don't get memory leaks when using MReadTree 
+       more than once because the pointer to the pointer isn't deleted.
+     - added a small class MChain which enhances TChain by a function to
+       reset fTree. This is used to control when notification are
+       happening
+
+   * mbase/MTask.cc:
+     - reset the number of executions before the preprocessing
+
+
+
+ 2001/12/11: Thomas Bretz
+
+   * mbase/MGGroupFrame.cc:
+     - removed default arguments from source file
+
+   * mbase/MGList.cc:
+     - changed cast in IsExisting to ?:
+
+   * NEWS:
+     - changed
+
+   * manalysis/MCerPhotCalc.cc, mfilter/MTriggerLvl1.cc,
+     mmontecarlo/MMcCollectionAreaCalc.cc,
+     mmontacarlo/MMcThresholdCalc.cc,
+     MMcTriggerRateCalc.cc:
+     - added Masterbranch name to AddToBranchList
+
+   * manalysis/MMcPedestalCopy.cc:
+     - added Masterbranch name to AddToBranchList
+     - fixed a bug in the branch name
+
+   * mbase/MGList.[h,cc]:
+     - added a better output if a picture wasn't found
+
+   * mbase/MReadTree.[h,cc]:
+     - added support for branches with master branch names to auto scheme
+       (first the complete branch name is tried and if this isn't found
+        only the subbranch name is used to enable the branch)
+
+   * mbase/MWriteRootFile.cc:
+     - appended a '.' to all newly create branches
+
+   * mmain/MBrowser.cc, mmain/MMars.cc:
+     - add the gui elements only if the corresponding picture was found
+
+   * mmain/MMars.[h,cc]:
+     - removed fPic1
+     - removed fPic2
+     - changed TList to MGList
+
+   * mraw/MRawFileWrite.cc:
+     - added a '.' to all branch names
+
+   * mbase/MTask.[h,cc]:
+     - added Prototype for ReInit-function
+
+   * mbase/MTaskList.[h,cc]:
+     - implemented ReInit for a task list
+
+   * mhist/MHFadcCam.h:
+     - added '->' to fArray
+
+
+
+ 2001/12/10: Thomas Bretz
+
+   * mmc/*.hxx:
+     - Changed MPARCONTAINER_H to MARS_MParContainer
+
+   * meventdisp/MGCamDisplay.cc:
+     - added MMcPedestalCopy to task list
+     - added MMcPedestalNSB  to task list
+
+   * mmain/MAnalysis.cc:
+     - added MMcPedestalCopy to task list
+     - added MMcPedestalNSB  to task list
+     - changed reader from MReadTree to MReadMarsFile
+
+   * meventdisp/MGEvtDisplay.cc:
+     - changed reader from MReadTree to MReadMarsFile
+
+   * macros/MagicHillas.C, macros/readMagic.C:
+     - removed unnecessary MReadTree
+
+
+
+ 2001/11/28: Oscar Blanch Bigas
+
+   * mbase/MReadMarsFile.cc:
+     - Added process of fRun = new MReadTree("RunHeaders", fname),
+       needed to read RunHeaders tree information.
+
+   * manalysis/MCerPhotCalc.h:
+     - Added fNumLoGainFadcSlices and fNumHiGainFadcSlices member
+       variables because they are needed for Pedestal substraction.
+
+   * manalysis/MCerPhotCalc.h:
+     - Change in the methode to substract the pedestal. The new
+       methode is valid either for MC data and real data but only for
+       the current integration (GetSumHiGainSamples()).
+
+   * macros/readMagic.C:
+     - Added several tasks in the task list:
+	     MReadMarsFile to read  RunHeaders Tree
+	     MPedestalCopy and MPedestalNSB to treat correctly pedestals.
+
+   * macros/MagicHillas.C:
+     - Added several tasks in the task list:
+	     MReadMarsFile to read  RunHeaders Tree
+	     MPedestalCopy and MPedestalNSB to treat correctly pedestals.
+
+   * mmc/MMcRunHeader.hxx:
+     - Added GetNumPheFromDNSB().
+
+   * mmc/MMcFadcHeader.hxx:
+     - Added GetAmplitud().
+
+   * manalysis/MMcPedestalNSB.h / .cc:
+     - New class which adds to the pedestal rms the contribution from
+      the diffuse NSB.
+
+   * manalysis/Makefile:
+     - New class MMcPedestalNSB added.
+
+   * manalysis/AnalysisLinkDefine.
+     - New class MMcPedestalNSB added.
+
+
+
+ 2001/11/16: Thomas Bretz
+
+   * mhist/MHMcCollectionArea.cc:
+     - set the ReadyToSave bit in CalcEfficiency.
+
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - set the ReadyToSave bit after the calculation has been finished.
+
+   * mhist/MHMcRate.cc:
+     - set the ReadyToSave bit in CalcRate
+
+
+
+ 2001/11/16: Thomas Bretz
+
+   * mbase/MEvtLoop.cc:
+     - removed clock.Print()
+
+   * mbase/MGList.[cc,h]:
+     - added support for TGPictures
+
+   * mbase/MReadTree.[h,cc]:
+     - set ReadyToSave-bit only if reading was successfull
+     - made SetReadyToSave private
+
+   * mbase/MTaskList.cc:
+     - corrected a small bug in the output
+
+   * mbase/MWriteRootFile.cc:
+     - added a workaround in Print (don't know why it fails for me)
+     - removed fTrees.SetOwner()
+
+   * mbase/MTask.cc:
+     - removed include of TOrdCollection, TMethod
+     - some changes to the output
+
+   * mbase/MParContainer.h:
+     - removed old comments
+
+   * mmain/MAnalysis.cc, mmain/MCameraDisplay.cc, mmain/MDataCheck.cc,
+     mmain/MEvtDisp.cc, mmain/MMonteCarlo.cc:
+     - changed Widget IDs to root style enums
+     - moved enumerations in the range below 0x100
+
+   * mmain/MBrowser.[h,cc]:
+     - removed some of the member variables, accessed via MGList now
+     - changed TList to MGList
+     - added a file-filter combo-box
+
+   * mars.cc:
+     - changed output
+
+
+
+ 2001/11/15: Thomas Bretz
+
+   * mbase/MArray.cc, mbase/MArrayB.cc,mbase/MArrayS.cc,
+     mbase/MClone.cc, mbase/MEvtLoop.cc, mbase/MFilter.cc,
+     mbase/MFilterList.cc, mbase/MGGroupFrame.cc, mbase/MGList.cc,
+     mbase/MGTask.cc, mbase/MInputStreamID.cc, mbase/MLog.cc,
+     mbase/MLogManip.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MPrint.cc, mbase/MReadMarsFile.cc, mbase/MReadTree.cc,
+     mbase/MTime.cc, mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc,
+     mbase/MWriteRootFile.cc, manalysis/MCT1ReadAscii.cc,
+     manalysis/MCerPhotCalc.cc, manalysis/MHillas.cc,
+     manalysis/MHillasCalc.cc, manalysis/MMcPedestalCopy.cc,
+     manalysis/MPedCalcPedRun.cc, manalysis/MPedestalCam.cc,
+     manalysis/MPedestalPix.cc, manalysis/MCerPhotEvt.cc,
+     manalysis/MCerPhotPix.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MImgCleanStd.cc, mdatacheck/MDumlEvtHeader.cc,
+     mdatacheck/MGDisplayAdc.cc, meventdisp/MGCamDisplay.cc,
+     meventdisp/MGEvtDisplay.cc, meventdisp/MGFadcDisp.cc,
+     mfilter/MFTriggerLvl1.cc, mgui/MGeomCam.cc, mgui/MGeomCamMagic.cc,
+     mgui/MGeomCamCT1.cc, mgui/MgeomPix.cc, mgui/Mhexagon.cc,
+     hist/MFillH.cc, mhist/MH.cc, mhist/MHFadcCam.cc, mhist/MHFadcPix.cc,
+     hist/MHHillas.cc, mhist/MHMcCollectionArea.cc, mhist/MHMcEnergy.cc,
+     mhist/MHMcRate.cc, mhist/MHStarMap.cc, mmain/MAnalysis.cc,
+     mmain/MBrowser.cc, mmain/MCameraDisplay.cc, mmain/MDataCheck.cc,
+     mmain/MEvtDisp.cc, mmain/MMars.cc, mmain/MMonteCarlo.cc,
+     mmontcarlo/MMcCollectionAreaCalc.cc, mmontecarlo/MMcThresholdCalc.cc,
+     mmontecarlo/MMcTriggerRateCalc.cc, mraw/MrawCrateArray.cc,
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc
+     mraw/MRawEvtPixelIter.cc, mraw/MRawEvtFileRead.cc, 
+     mraw/MRawEvtFileWrite.cc, mraw/MRawEvtRunHeader.cc
+     - changed mailing address of author according to THtml of root 3.02
+
+   * mbase/MClone.cc, mbase/MEvtLoop.cc, mbase/MFilterList.cc,
+     mbase/MGTask.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MPrint.cc, mbase/MReadMarsFile.cc, mbase/MReadTree.cc,
+     mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc,
+     mbase/MWriteRootFile.cc, manalysis/MCerPhotEvt.cc, 
+     manalysis/MCerPhotPix.cc, manalysis/MImgCleanStd.cc,
+     mgui/MGeomCam.cc, mgui/MGeomCamMagic.cc, mgui/MGeomCamCT1.cc, 
+     mgui/MgeomPix.cc, mgui/Mhexagon.cc, hist/MFillH.cc, mhist/MHMcEnergy.cc,
+     mhist/MHMcRate.cc, mmontcarlo/MMcCollectionAreaCalc.cc,
+     mmontecarlo/MMcThresholdCalc.cc, mmontecarlo/MMcTriggerRateCalc.cc
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc
+     mraw/MRawEvtPixelIter.cc, mraw/MRawEvtFileRead.cc, 
+     mraw/MRawEvtFileWrite.cc, mraw/MRawEvtRunHeader.cc
+     - changed output to new style logging (verbosity level introduced)
+
+   * mbase/MGTask.h:
+     - added default to CreateGui
+
+   * mbase/MLog.cc
+     - chnaged comparision between output and debug level from >= to >
+
+   * mbase/MLogManip.h:
+     - added defintions for debug levels
+
+   * mbase/MReadTree.[h,cc]:
+      - added support for filters
+      - SetReadyToSave added
+      - Print added
+
+   * mbase/MTaskList.[h,cc], MTask.[h,cc]:
+     - changed TOrCollection to TList, because TList can be stored in a 
+       root file.
+
+   * mbase/MTask.[h,cc]:
+     - added GetFilter function (used in MReadTree)
+
+   * manalysis/MImgCleanStd.cc:
+     - same changed to the GUI layout
+     - added Print member function
+
+   * meventdisp/MGCamDisplay.cc:
+     - added group frame around some gui elements
+
+   * mfilter/MFTriggerLvl1.cc:
+     - fixed missing Init call
+     - added missing AddToBranchList call
+
+   * mars.cc:
+     - added command line option to set the verbosity level
+
+   * merpp.cc:
+     - added setup for highest verbosity level
+
+
+
+ 2001/11/14: Thomas Bretz
+
+   * macros/dohtml.C:
+     - added missing path to mfilter
+   
+   * manalysis/MHillas.cc:
+     - changed the degree symbol back to 'deg', it seems that the code
+       for it isn't common
+   
+   * mhist/MH.cc:
+     - added comment for MakeDefCanvas
+
+   * mhist/MHFadcCam.[h,cc]:
+     - removed old comments (SaveHist)
+
+   * mhist/MHHillas.cc:
+     - changed the Name of fAlpha back. Symbols are nonsens in the name.
+     
+   * mbase/MGList.[h,cc], mbase/MGTask.[h,cc], mbase/MGGroupFrame.[h,cc]:
+     - added
+
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - changed to O3
+     - added -fnonnull-objects
+     - added -Woverloaded-virtual
+
+   * macros/readCT1.C, macros/readMagic.C:
+     - changed to use MClone
+
+   * manalysis/MImgCleanStd.[h,cc]:
+     - derived from TGTask
+     - added CreateGuiElements 
+     - added ProcessMessage
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MGTask
+     - added MGList
+     - added MGGroupFrame
+
+   * mbase/MInputStreamID.cc:
+     - rmoved old comment
+
+   * mbase/MParContainer.[h,cc]:
+     - changed output
+     - made Hash const
+     - added GetDiscriptor
+
+   * mbase/MParList.[h,cc]:
+     - made FindObject const correct (see TObject)
+
+   * mbase/MTask.[h,cc]:
+     - changed output to use GetDescriptor
+     - made Call* functions virtual (used in TGTask)
+
+   * mbase/MTaskList.[h,cc]:
+     - made FindObject const correct (see TObject)
+     - changed output to use GetDescriptor
+
+   * mbase/MTime.cc:
+     - code reformatting
+
+   * mbase/MWriteRootFile.cc:
+     - small changes in output
+
+   * mgui/MHexagon.cc:
+     - changed output according to TEllipse and similar
+     - made ls const
+
+   * mhist/MFillH.cc:
+     - changed output to use GetDescriptor
+
+   * mmain/MAnalysis.[h,cc]:
+     - changed to use new GUI of MImgCleanStd
+
+   * mraw/MRawEvtData.cc:
+     - small changes to output
+     - better sanity check for non existing fRunHeader
+
+
+
+ 2001/11/09: Thomas Bretz
+
+   * mars.cc, merp.cc, macros/rootlogon.C:
+     - added MArray::Class()->IgnoreTObjectStreamer();
+
+
+
+ 2001/11/08: Thomas Bretz
+
+   * meventdisp/MGCamDisplay.cc:
+     - changed enums to root style
+     - get rid of the problem of button deletion by adding the buttons 
+       as first entries to the list
+
+   * mmain/MMonteCarlo.cc:
+     - changed enums to root style
+     - get rid of the problem of button deletion by adding the buttons 
+       as first entries to the list
+
+   * manalysis/MCerPhotCalc.cc, manalysis/MPedCalcPedRun.cc,
+     mhist/MHFadcCam.cc:
+     - removed 'Fadc' from function names
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - made AddPixel inline
+   
+   * manalysis/MMcPedestalCopy.cc:
+     - added output
+
+   * manalysis/MPedestalCam.cc:
+     - removed FIXME
+
+   * Makefile's:
+     - some reordering
+     - changed to the output
+
+   * mbase/MReadTree.cc:
+     - removed setting of AutoDel-flag (this was not intended and doesn't
+       work for a TChain, yet)
+
+   * meventdisp/MGCamDisplay.cc, meventdisp/MGFadcDisp.cc:
+     - moved SetWMSizeHints to base class
+
+   * meventdisp/MGEvtDisplay.cc:
+     - added a random move and the SetWMSizeHints
+
+   * mhist/MHHillas.cc:
+     - replaced some text by Latex-formulas
+
+   * mmain/MBrowser.cc:
+     - added a menu entry for opening a TBrowser
+     - added a random move
+
+   * mmain/MMars.[h,cc]:
+     - changed enums to root style
+     - moved size specification from header to source
+     - changed SetWMSizeHints call
+
+   * mraw/MrawEvtPixelIter.[h,cc]:
+     - added fNum[Hi,Lo]GainSamples to make GetSum* faster
+     - removed 'Fadc' from function names
+
+
+
+ 2001/11/07: Thomas Bretz
+
+   * Makefile:
+     - changed order in 'mrproper'
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc:
+     - added InitSize
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - introduces InitSize to speed up things
+     - changed []-operator to an unchecked access
+
+   * manalysis/MPedestalCam.h:
+     - changed ExpandCreateFast to ExpandCreate (due to lack of good dox)
+     - changed []-operator to an unchecked access
+
+   * mbase/MEvtLoop.cc:
+     - changed 'total' to 'real' time.
+
+   * mgui/MGeomCam.[h,cc]:
+     - moved []-operator code back to class definition, due to runtime speed
+     - changed []-operator to an unchecked access
+
+   * mhist/MHHillas.cc:
+     - changed 'degree' to Latex-style
+
+   * manalysis/MImgCleanStd.cc:
+     - we are now initialising an array holding the used pixel to prevent
+       looping through all pixel thousands of times
+       (MCerPhotEvt::IsPixelUsed)
+
+   * mbase/MWriteAsciiFile.cc:
+     - enhanced the documentation
+
+   * mmain/MBrowser.[h,cc]:
+     - enhanced the functionality to display the filename
+     - improved the layout
+
+   * mmain/MMars.cc:
+     - added calling of 'netscape' for the two picture buttons
+
+
+
+ 2001/11/06: Thomas Bretz
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - added
+
+   * manalysis/MMcPedestalCopy.[h,cc]:
+     - moved copying to PreProcess
+     - removed Process
+
+   * mbase/Makefile, mbase/BaseLinkDef.h
+     - added MReadMarsFile
+
+   * mbase/MReadTree.[h,cc]:
+     - added a list of TObjects to be called when file in the chain 
+       is changed
+
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - removed -g flag
+
+   * mraw/MRawRunHeader.h:
+     - fixed return type of GetNumEvents
+
+   * mraw/MRawCrateArray.[h,cc]:
+     - added SetSize which takes care of the size of the array
+     - changed the access to an unchecked one
+
+   * mraw/MRawCrateData.h
+     - derives from MParContainer now
+
+   * mraw/MRawEvtData.[h,cc]:
+     - made Print const
+     - changed so, that the arrays are dreed and allocated only
+       as less as possible
+
+   * mraw/MRawFileRead.[h,cc]:
+     - changed to support faster I/O of MRawEvtData and MRawCrateArray
+     - added sanity check (warning) to PostProcess
+
+   * mraw/MRawFileWrite.cc:
+     - removed deletion of trees (done by ~TFile)
+     - switched of AutoSave by use of a big size
+     - removed '.' from Branch names (each tree contains only one master
+       branch with equal subbranches)
+
+   * macros/readCT1.C:
+     - fixed a small bug
+
+   * manalysis/MCerPhotCalc.cc:
+     - removed Clear from Process (done by Reset now)
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added reset-function
+     - some small changes to the code layout
+
+   * mmc/MMcFadcHeader.[h,cc], mmc/MMcTrig.[h,cc]:
+     - chenged constructor to support fName and fTitle
+
+   * mbase/MReadTree.cc:
+     - removes '.' from a branch name now before searching/creating the object
+
+
+
+ 2001/11/01: Thomas Bretz
+ 
+   * mbase/MParContainer.cc:
+     - removed 'newname' from TObject::Clone call.
+
+   * mbase/MParContainer.h:
+     - layout changes
+
+   * mbase/MParList.h:
+     - changed destructor definition to virtual
+
+   * mbase/MReadTree.[h,cc]:
+     - added initialization for fProgress
+     - changed output
+     - move some code to new functions
+     - branch enabling now checks for the existance of the branch
+     - veto branch disables the corresponding sub branches now physically
+     - changed comments
+
+   * mdatacheck/MGDisplayAdc.cc:
+     - added some sanity checks
+
+   * meventdisp/MGCamDisplay.cc, meventdisp/MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.cc:
+     - moved some code to MGEvtDisplay
+
+   * mhist/MFillH.cc:
+     - added warning to comment
+
+   * mhist/MHFadcCam.[h,cc]:
+     - added Clone-function. It seems, that this is necessary since 
+       root 3.01
+
+   * mhist/MHFadcPix.cc:
+     - changed axis titles
+
+   * mmain/MAnalysis.cc:
+     - added progress bar
+
+   * mmain/MBrowser.[h,cc]:
+     - added layout hints to fTop1,2,3
+     - adde Create/DestroyProgrssBar
+
+   * mmain/MDataCheck.cc:
+     - changes to the layout
+     - disable auto scheme
+     - added progress bar
+
+   * mmain/MMonteCarlo.[h,cc]:
+     - layout changes
+     - added progress bar
+     
+   * mraw/MRawEvtData.cc:
+     - new sanity check in Draw
+
+
+
+ 2001/11/01: Thomas Bretz
+
+   * macros/MagicHillas.C:
+     - changed Draw to DrawClone
+
+   * manalysis/MCerPhotPix.h:
+     - some layout changes
+
+   * mbase/MParList.cc: 
+     - fixed a bug in the dstructor which causes the d'tor to crash when
+       the owner bit was set
+     - changed some TCollection loop to macro ForEach
+
+   * mbase/MTaskList.cc:
+     - changed some TCollection loop to macro ForEach
+
+   * meventdisp/MGEvtDisplay.[h,cc]:
+     - added filemenu
+
+   * mgui/MCamDisplay.[h,cc], mgui/MHexagon.[h,cc]:
+     - added SavePrimitive function
+
+   * mhist/MHHillas.cc:
+     - changed 'deg' to '°'
+
+   * mmain/MDataCheck.cc:
+     - changed name of enums for buttons
+
+   * Makefile.conf.osf1:
+     - added some more exclusion flags to get rid of to much informations
+
+   * Makefile:
+     - changed flags of tar from '-cvf' to 'cvf' so that it runs on alpha, too
+
+   * mbase/MAGIC.h:
+     - put brackets around defines, to make it compile on alpha
+
+   * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTask.cc, 
+     mgui/MGeomCam.cc, mhist/MHFadcPix.cc, mmc/MMcTrig.cxx:
+     - removed inline statement, to make it link on alpha
+
+
+
+ 2001/10/31: Thomas Bretz
+
+   * Makefile:             
+     - changed MrProper output   
+
+   * Makefile.conf.general, Makefile.conf.linux,
+     Makefile.conf.linux-gnu, Makefile.conf.osf:
+     - added ARCHDEF environment
+
+   * manalysis/MHillas.[h,cc]:
+     - added units
+
+   * mbase/BaseLinkDef.h:
+     - added '+' for MTime
+
+   * mbase/MAGIC.h:
+     - let Linux find gLog when creating dictionary
+
+   * mbase/MHtml.h:
+     - removed include of TNamed
+
+   * */Makefile
+     - reordered *.cc filed to get rid of some 'rootcint' warnings
+
+   * mgui/MCamDisplay.cc:
+     - added SetBorderMode(0)
+   
+   * mgui/MHexagon.[h,cc]:
+     - changed Print-output to fit into two lines
+     - made Print appear in the context menu
+
+   * merpp.cc:
+     - Added MParContainer::Class()->IgnoreTObjectStreamer()
+
+   * mbase/MEvtLoop.[h,cc],  mbase/MReadTree.[h,cc],
+     mmain/MAnalysis.[h,cc]:
+     - added support for a progressbar
+
+   * mbase/MFilterList.h:
+     - added SetOwner-support
+
+   * mbase/MLogManip.h:
+     - added 'dec' manipulator to dbginf
+
+   * mbase/MTask.h:
+     - added GetNumExecutions
+
+   * mraw/RawLinkDef.h:
+     - added '+' for MRawEvtPixelIter, MRawCrateArray, MRawCrateData and
+       MRawFile[Read,Write]
+
+
+
+ 2001/10/30: Thomas Bretz
+
+   * macros/MagicHillas.C
+     - removed precreated objects
+
+   * macros/readCt1.C:
+     - fixed a bug (-> instead of .)
+
+   * *LinDef.h:
+     - added a '+' to all 'new' classes. 'new' means, that the object
+       is not yet used in Monte Carlo Files.
+
+   * *.h:
+     - changed defines from CLASS_H to MARS_Class type (like root)
+
+   * MMcPedestalCopy.[h,cc]:
+     - added AddToBranchList stamements
+
+   * manalysis/MPedestalPix.h, manalysis/MCerPhotPix.h, mgui/MGeomPix.h:
+     - changed derivement from TObject to MParContainer to be sure
+       fBits are not written, without specifying this for any TObject
+       derived class
+
+
+
+ 2001/10/29: Thomas Bretz
+
+   * Makefile.rules:
+     - changed the output
+
+   * macros/rootlogon.C:
+     - Added IgnorTObjectStreamer
+
+   * manalysis/MCT1ReadAscii.cc:
+     - changed fFileNames to a TList of TNamed objects
+
+   * mbase/MArray.h:
+     - removed include of MArray.h
+
+   * mbase/MParContainer.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - Changed ClassVersion to 0
+
+   * mbase/MParList.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed include of TObjArray to a forward declaration
+       (for faster compilation)
+     - simplified the code
+
+   * mbase/MInputStreamID.[h,cc]:
+     - changed fStreamId from char* to TString
+     - Changed ClassVersion to 0
+ 
+   * mbase/MReadTree.[h,cc]:
+     - changed veto-list to an array of TNamed objects
+     - implemented auto enabeling
+
+   * mbase/MTask.[h,cc]:
+     - implemented fListOfBranches for auto enabeling
+     
+   * mbase/MTaskList.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed include of TObjArray to a forward declaration
+       (for faster compilation)
+
+   * mbase/MWriteRootFile.cc:
+     - changed fName, fTitle from pointer to static object
+     - set splitlevel in TTree::Branch to default
+     - changed kSaveNow to kFillTree
+
+   * mhist/MFillH.cc:
+     - changed fName, fTitle from pointer to static object
+     - check inharitance from MH
+
+   * mhist/MH.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - implementation of simplified static MakeDefCanvas
+
+   * mhist/MHFadcCam.h:
+     - removed include of TH1
+
+   * mhist/MHFadcPix.[h,cc]:
+     - implemented persistent pixid
+     - get rid of 'fixed string sizes'
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - removed include of TH1
+
+   * mhist/MHHillas.cc
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - changed DrawClone to DrawCopy
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - changed DrawClone to DrawCopy
+     - changed binning to log scale
+     - removed include of TH1
+
+   * mhist/MHMcEnergy.cc, mhist/MHStarMap.cc:
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+
+   * manalysis/MCerPhotEvt.cc, manalysis/MHillas.cc, 
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc, 
+     manalysis/MMcPedestalCopy.cc, manalysis/MPedestalCam.cc,
+     mbase/MClone.cc, mbase/MPrint.cc, mbase/MTime.h,
+     mbase/MWriteAsciiFile.cc, mgui/MGeomCam.cc, mhist/MHFadcCam.cc, 
+     mhist/MHMcRate.cc, mmc/MMcTrig.cxx, mraw/MRawCrateArray.cc, 
+     mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc, mraw/MRawFileRead.cc:
+     - changed fName, fTitle from pointer to static object
+
+   * manalysis/MCerPhotCalc.cc, manalysis/MPedCalcPedRun.cc, 
+     mmontecarlo/MMcThresholdCalc.[h,cc], 
+     mmontecarlo/MMcTriggerRateCalc.[h,cc], 
+     mmontecarlo/MMcCollectionAreaCalc.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed to use auto enabling scheme
+
+   * macros/threshold.C, macros/collarea.C, macros/trigrate.C:
+     - removed UseLeaf
+
+   * macros/CT1Hillas.C, macros/readMagic.C:
+     - made run again
+
+   * mraw/MRawFileWrite.cc:
+     - changed fName, fTitle from pointer to static object
+     - changed TTree::Branch to use default split level (99)
+     - added the missing important '.' to the Branch names!
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - implemented enum for Run Type
+
+
+
+ 2001/10/26: Thomas Bretz
+
+   * Makefile.rules:
+     - changed output
+
+   * readraw.cc:
+     - changed name and description in TROOT
+     - removed argument in MMcEvt::Print()
+
+   * manalysis/MCerPhotEvt.[h,cc], manalysis/MCerPhotPix.[h,cc],
+     manalysis/MHillas.[h,cc], mmc/MMcEvt.[hxx,cxx],
+     mmc/MMcFadcHeader.[hxx,cxx], mmc/MMcTrig.[hxx,cxx],
+     mmc/MMcTrigHeader.[hxx,cxx]:
+     - according to root 3.01 made Print const
+
+   * mbase/BaseLinkDef.h:
+     - added MPrint
+
+   * mbase/MPrint.[h,cc]:
+     - added
+
+   * mbase/MClone.[h,cc]:
+     - changed MParContainer to a more general TObject
+
+   * mbase/Makefile:
+     - MPrint.cc added
+
+   * meventdisp/MGCamDisplay.[h,cc], meventdisp/MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.[h,cc]:
+     - introduced fInitOk for the case PreProcessing failed
+
+   * mmain/MMonteCarlo.cc:
+     - added correction for use of several trigger conditions
+     - speedup threshold calc by usage of UseLeaf
+
+   * magiclogo.xpm, marslogo.xpm:
+     - changed
+
+   * mmain/MMonteCarlo.cc:
+     - added a workaround for the <TClass::TClass> no dictionary for MMc*
+       problem
+
+   * mbase/MWriteRootFile.[h,cc]:
+     - simplified code by removing MRootFileTree class
+
+   * mbase/MLog.cc:
+     - changed char[len+1] to 'new' statement
+
+
+
+
+ 2001/10/23: Thomas Bretz
+
+   * mbase/MLog.[h,cc]:
+     - replaced usage of tmpnam by mkstemp
+
+   * mgui/MCamDisplay.[h,cc]:
+     - Paint function added which maintains the aspect ratio of the image
+     - DrawPhotErr removed
+     - removed gPad->Clear, so that we can draw into pads not only
+       canvases
+
+   * mhist/MFillHFadc.[h,cc], mhist/MFillHHillas.[h,cc],
+     mhist/MFillHStarMap.[h,cc]:
+     - removed
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
+     - removed unused spectral index and flux
+
+   * mmontecarlo/MMcThesholdCalc.[h,cc],:
+     mbase/MParList.[h,cc]:
+     - fixed the Dimension handling
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc],
+     - fixed the Dimension handling
+     - added destructor
+
+   * macros/trigrate.C:
+     - fixed some small things
+     - accelerated by use of MReadTree::UseLeaf
+
+   * mhist/MHMcCollectionArea.h:
+     - changed default argument of DrawClone from NULL to "".
+       NULL caused the interpreter to crash.
+
+   * mbase/MFilterList.[h,cc], mbase/MParContainer.[h,cc],
+     mbase/MParList.[h.cc], mbase/MTime.[h,cc],
+     mgui/MGeomCam.[h,cc], mgui/MGeomPix.[h,cc],
+     mgui/MHexagon.[h,cc], mhist/MHMcEnergy.[h,cc],
+     mhist/MHMcRate.[h,cc], mraw/MRawCrateData.[h,cc],
+     mraw/MRawEvtHeader.[h,cc], mraw/MRawRunHeader.[h,cc]:
+     - according to root 3.01 I made Print() const
+
+   * mdatacheck/MViewAdcSoectra.[h,cc], mdatacheck/MShowSpect.[h,cc]:
+     - removed
+
+   * mbase/MReadTree.cc:
+     - removed default argument from GetEntry-call
+
+   * mbase/MTask.[h,cc]:
+     - introduced mapping function for (Pre/Post)&Process
+     - according to root 3.01 I made Print() const
+     - added PrintStatistics
+     - added call counter
+
+   * mbase/MTaskList.[h,cc]:
+     - adapted to new MTask mapping functions
+     - according to root 3.01 I made Print() const
+     - added PrintStatistics
+     - moved some functionality to MTask-Mapper functions
+
+   * mmain/MMonteCarlo.cc:
+     - adapted to some changes in other classes
+     - some small simplifications
+     - accelerated, by use of UseLeaf
+     - workaround for the ButtonGroup/Button delete bug
+
+   * mmain/MAnalysis.cc:
+     - workaround for the ButtonGroup/Button delete bug
+
+
+
+ 2001/10/23: Thomas Bretz
+
+   * macros/dohtml.C:
+     - changed macro names
+
+   * macros/getCollArea.C:
+     - renamed to collarea.C
+     - make use of new fast MReadTree
+
+   * macros/getRate.C:
+     - renamed to trigrate.C
+
+   * macros/getThreshold.C:
+     - renamed to threshold.C
+
+   * Makefile.depend:
+     - removed
+
+   * mgui/MCamDisplay.[h,cc]:
+     - fixed wrong usage of new operator in TClonesArray
+     - the aspect ratio of the Canvas is used now to display geometries
+       correctly (no 'small CT1 camera anymore)
+     - replaced include of MCerPhotPix by a forward declaration
+     - replaced include of MHexagon by a forward declaration
+
+   * mgui/MGeomCam.[h,cc]:
+     - added GetMaxRadius()-function
+     - added CalcMaxRadius()-function
+     - replaced include of MGeomPix by a forward declaration
+     - replaced include of TObjArray by a forward declaration
+
+   * mgui/MGeomCamMagic.cc, mgui/MGeomCamCT1.cc:
+     - call CalcMaxRadius in the constructor
+
+
+
+ 2001/10/22: Thomas Bretz
+
+   * mhist/MH*.[h,cc]:
+     - changed DrawClone according to root 3.01/06 to 'const'
+
+
+
+ 2001/10/16: Thomas Bretz
+
+   * mbase/MReadTree.[h,cc]:
+     - added some output statements
+     - added comments
+     - added UseLeaf
+     - changed AddFile to Int_t
+     - simplified GetEntry call
+
+   * mgui/MGeomCam.[h,cc], MGeomCamCT1.[h,cc], MGeomCamMagic.[h,cc]:
+     - added come comments
+     - removed Draw-function
+   
+   * mars.cc:
+     - Changed name of TROOT object to 'mars'
+
+   * merpp.cc:
+     - changed name of TROOT object to 'merpp'
+     - added some more ouput
+
+   * mbase/MBaseLinkDef.h:
+     - added MRootFileBranch
+     - added MRootFileTree
+
+   * mgui/MGeomPix.cc, mbase/MClone.cc, mraw/MRawRunHeader.cc:
+     - added comments
+
+   * mbase/MEvtLoop.cc:
+     - added missing include
+     - added another time output
+
+   * mbase/MWriteRootFile.cc:
+     - added ClassImp
+   
+   * mhist/MFillH.cc, mmontecarlo/MMcCollectionAreaCalc.cc:
+     - changed output
+   
+   * mhist/MHMcCollectionArea.cc:
+     - small fixes
+     - changed error calculation according to Ciro
+
+   * macros/CT1Hillas.C:
+     - fixes some bugs (typos)
+
+
+
+ 2001/10/05: Thomas Bretz
+
+   * manalysis/MHillas.cc, manalysis/MImgCleanStd.cc, mbase/MClone.[h,cc],
+     mbase/MFilterList.h, mbase/MWriteFile.h, mbase/MWriteRootFile.h,
+     mdatacheck/MGDisplayAdc.cc, meventdisp/MGCamDisplay.cc, 
+     meventdisp/MGCamDisplay.h, meventdisp/MGEvtDisplay.h,
+     mgui/MGeomPix.h, mhist/MFillH.h, mhist/MHHillas.h,
+     mmain/MAnalysis.h, mmain/MBrowser.h, mmain/MCameraDisplay.h,
+     mmain/MDataCheck.h, mmain/MEvtDisp.h, mmain/MMonteCarlo.h,
+     mraw/MRawFileRead.cc
+     - comments updated
+     
+   * mbase/MFilter.[h,cc]:
+     - made IsExpressionTrue abstract
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - fixed a bug that only every second event was displayed
+
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - reorganized code (changing pixel number drawed the histogram twice)
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - added fDrawingPad to make sure that all output goes into the same pad
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - removed old MFillH* classes
+
+
+
+ 2001/10/02: Thomas Bretz
+
+   * mbase/MClone.[h,cc],
+     meventdisp/MGCamDisplay.[h,cc],
+     meventdisp/MGEvtDisplay.[h,cc],
+     mmain/MCameraDisplay.[h,cc]:
+     - added
+     
+   * macros/readMagic.C:
+     - fixed a  "'->' and '.' mixed bug"
+     
+   * manalysis/MCT1ReadAscii.cc:
+     - added initialisation of fIn
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - made IsPixelExisting const
+     - made IsPixelCore const
+     - made IsPixelUsed const
+     - made GetNumPhotons[Min,Max] const
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MClone
+     
+   * mbase/MEvtLoop.[h,cc], mbase/MParList.[h,cc], mbase/MTaskList.[h,cc]:
+     - added SetOwner-support
+     
+   * mdatacheck/DataCheckLinkDef.h, mdatacheck/Makefile:
+     - removed MShowSpect
+     - removed MViewAdcSpect
+     
+   * mdatacheck/MDumpEvtHeader.cc:
+     - added missing descriptions
+     
+   * mdatacheck/MGDisplayAdc.[h,cc]:
+     - small changes
+     
+   * meventdisp/EvtDispLinkDef.h:
+     - added MGEvtDisplay
+     - added MGCamDisplay
+     
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - derived from MGEvtDisplay
+     - most of the code moved to MGEvtDisplay to support MGCamDisplay, too
+     
+   * meventdisp/Makefile:
+     - added MGCamDisplay
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - cleaned
+     - reorganized
+     
+   * mgui/MHexagon.cc:
+     - added missing descriptions
+     
+   * mhist/MHFadcPix.cc:
+     - reorganized some code in the constructor which creates the 'names'
+     
+   * mhist/MHHillas.cc, mhist/MHMcCollectionArea.cc, 
+     mhist/MHMcEnergy.cc, mhist/MHStarMap.cc:
+     - Draw-function supports a default canvas now
+   
+   * mmain/MDataCheck.cc:
+     - added/rorganized comments
+     - removed usage of MViewAdcSpectra
+     
+   * mmain/MMars.[h,cc]:
+     - added new "Camera Display" Button
+     
+   * mmain/MainLinkDef.h, mmain/Makefile:
+     - added MCameraDisplay
+
+
+
+ 2001/09/28: Thomas Bretz
+
+   * macros/getRate.C:
+     - changed TObjArray to a non-pointer object
+     - added Printing of the result at the end of the macro
+     
+   * mhist/MHMcCollectionArea.[h,cc], mhist/MHMcEnergy.[h,cc]:
+     - added DrawClone
+     
+   * mhist/MHMcRate.[h,cc]:
+     - added a dummy for DrawClone
+     
+   * mmain/MMonteCarlo.[cc, h]:
+     - added Gui elements
+     - added CalculateCollectionArea (not yet tested)
+     - added CalculateTriggerRate (not yet tested)
+     - added Threshold (not yet tested)
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - removed output stuff from PostProcessing
+
+   * meventdisp/MGFadcDisp.[h,cc], mdatacheck/MGDisplayAdc.[h,cc]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+
+
+ 2001/09/27: Thomas Bretz
+
+   * mmain/MBrowser.cc:
+     - added comments
+
+   * mmain/MAnalysis.[h,cc]:
+     - added entry field for cleaning levels
+     - restructured code a bit
+
+   * mhist/MFillH.cc:
+     - fixed missing initialization of member variables in Init
+
+   * mhist/MHHillas.[h,cc]:
+     - Added comments
+     - Added DrawClone
+     - Removed kCanDelete bits from Draw function
+
+   * mhist/MHStarMap.[h,cc]:
+     - Added comments
+     - Added DrawClone
+     - moved some code from the Draw-functions to PrepareDrawing
+
+
+
+ 2001/09/26: Thomas Bretz
+
+   * mmain/MMars.[cc,h], mmain/MBrowser.[cc,h], MDataCheck.[cc,h],
+     mmain/MEvtDisp.[cc,h], mmain/MMonteCarlo.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+     - small changes in layout
+
+   * mmain/MAnalysis.[h,cc]:
+     - added
+
+   * macros/*:
+     - added Copyright notice
+     - added some small sanity checks
+
+   * macros/MagicHillas.C:
+     - fixed '->' bug
+     - changed MFillHStarMap to MFillH
+     
+   * mbase/MReadTree.cc, mraw/MRawFileWrite.cc:
+     - removed an old debug statement
+     
+   * mmain/MMars.cc:
+     - added new Analysis functionality
+     
+   * mmain/MainLinkDef.h:
+     - addded MAnalysis
+     
+   * mmain/Makefile:
+     - added MAnalysis.cc
+     
+   * mmc/McLinkDef.h:
+     - removed nonsens define statement
+
+
+
+ 2001/09/25: Thomas Bretz
+
+   * Makefile:
+     - changed make tar so that 'CVS/Root' isn't added to the tar-file anymore
+       It contains the origin (CVSROOT) of the repository and my confuse
+       people triing to commit changed files from such an archive to
+       the repository
+       
+   * mmain/MBrowser.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+   * mmain/MMars.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+
+
+ 2001/09/20: Thomas Bretz
+
+   * mbase/MLog.[h,cc]:
+     - made working with Cosy
+     - fixed gui stuff to work like expected
+
+   * manalysis/MCerPhotPix.h:
+     - replaced TROOT.h by MAGIC.h
+
+   * mfilter/MFTriggerLvl1.h:
+     - added description
+
+
+
+ 2001/09/20: Thomas Bretz
+
+   * released Version 0.4
+
+   * mevtdisp/MGFadcDisp.cc, mmain/MMars.cc:
+     - switched to root version >= 3.00
+     
+   * Makefile.conf.linux:
+     - added to support the new Linux distributions
+
+   * .rootrc:
+     - removed references to MARSSYS
+
+
+
+ 2001/09/13: Thomas Bretz
+ 
+   * Makefile.conf.linux-gnu:
+     - removed "-Woverloaded-virtual". it doesn't really help
+
+
+
+ 2001/08/02: Thomas Bretz
+
+   * macros/getRate.C:
+     - make use of new stylish lists of containers
+
+
+   * macros/CT1Hillas.C, macros/getCollArea.C:
+     - make use of return value of Eventloop
+
+   * macros/merpp.C:
+     - changed return type to void
+
+
+
+ 2001/07/23: Thomas Bretz
+ 
+   * mbase/MParList.cc:
+     - redifinition of default argument: fixed
+
+
+
+ 2001/07/23: Thomas Bretz
+ 
+   * mmontecarlo/MMcThresholdCalc.[cc,h]:
+     - changed PreProcess action to new stylish lists of containers
+
+   * mhist/Makefile:
+     - removed MEnergies.cc
+
+   * mhist/HistLinkDef.h:
+     - removed MEnergies.cc
+   
+   * mbase/MReadTree.cc:
+     - removed a bug which causes MReadTree to show strange behaviour.
+       We cannot use GetBranch()->SetAddress() we have to use
+       SetBranchAddress.
+       
+   * macros/MagicHillas.C:
+     - changed to new stylish histogram fillers.
+
+   * mhist/MHMcRate.cc:
+     - some simplifications to the constructors
+     - some accelerations of the rate calculation
+     
+   * mhist/MHHillas.C:
+     - added axis descriptions (thanks to Rudy)
+
+
+
+ 2001/07/20: Thomas Bretz
+ 
+   * mhist/MH.cc:
+     - added comments
+
+   * mhist/MFillH.cc:
+     - added comments
+
+   * mbase/MParList.[h,cc]:
+     - Added AddToList from a TObjArray
+     - Added GetClassName
+     - Added GetObjName
+     - Added FindObjectList
+     - Added FindCreateObjList
+     - Added CreateObjList
+
+   * mhist/MHMcEnergies.[h,cc]:
+     - deleted
+
+   * mhist/MHMcEnergy.[h,cc]:
+     - rewrote constructor in a way that MHMcEnergies isn't needed anymore
+     - added a SetName function which replaces the old constructor somehow
+
+   * macros/getThreshold.C:
+     - make use of some new features
+
+
+
+ 2001/07/19: Thomas Bretz
+ 
+   * mbase/MEvtLoop.cc:
+     - added comments
+     
+   * mbase/MTaskList.cc:
+     - changed the wrong 'break' for kCONTINUE into 'return kTRUE'
+     
+   * mhist/MH.[cc,h]
+     - added
+
+   * mhist/MFillH.[cc,h]
+     - added
+     - in principal MFillHHillas, MFillHFadc and MFillHStarMap
+       can be deleted now
+     
+   * mhist/HistLinkDef.h:
+     - added MH
+     - added MFillH
+     
+   * mhist/MFillHFadc.cc:
+     - moved source for filling to corresponding histogram class
+     
+   * mhist/MFillHHillas.cc:
+     - included MHillas.h
+     
+   * mhist/MHFadcCam.[cc, h]:
+     - added Fill
+     - made FillHi, FillLo private
+     
+   * mhist/MHHillas.[cc, h], mhist/MHStarMap.[h,cc]:
+     - changed Fill function to new style
+     - derived class from MH
+
+   * mhist/Makefile:
+     - added MH.cc
+     - added MFillH.cc
+
+
+
+ 2001/07/18: Oscar Blanch
+ 
+   * macros/getRate.C:
+     - Macro to compute the trigger rate from a MonteCarlo file
+
+   * mhist/MHMcRate.[h,cc]:
+     - Container to store trigger rate information
+     - Draw() functin member to be implemented
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
+     - Task to compute trigger rate
+
+
+
+ 2001/07/13: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - Added a result value to Eventloop to be able to detect if the
+       execution was successfull
+     - changes postProcess to return the return value from 
+       MTaskList::PostProcess
+     
+   * mbase/MParList.cc:
+     - FindCreateObj removes now a 'dot' from the end of an indexed
+       object name like "Events;7."
+     
+   * mbase/MReadTree.cc:
+     - small changes to the output
+
+   * mbase/MTask.[h,cc]:
+     - added Preprocessed flag. This enables the tasklist to only postprocess
+       already preprocessed tasks
+
+   * mbase/MTaskList.cc:
+     - don't postprocess non preprocessed tasks
+   
+   * mhist/MHMcCollectionArea.cc:
+     - added descriptions to histrograms
+     - changed names of histograms
+     - added drawing of canvas to Draw-functions
+
+   * mhist/MHMcEnergy.[h,cc]:
+     - added variables to store the calculated result
+     - changed names and titles of histogram
+     - added axis titles to histogram
+     - moved result calculation into fit-function
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - added name of input container to be able to process another
+       container than "MMcTrig"
+
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - removed trailing dot from container name creation
+   
+   * mhist/MMcThresholdCalc.cc:
+     - removed a wrong '.' behind the number when processing more than
+       one trigger condition
+
+   * mraw/MRawRunHeader.cc:
+     - added "Monte Carlo Data" as runtype
+
+
+
+ 2001/07/10: Thomas Bretz
+
+   * mhist/MHMcEnergy.h:
+     - renamed SetBins to SetNumBins
+     
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - changed style of comments
+     - moved sqrt(2) from Postprocess to header.
+     
+   * mmontecarlo/MMcEnerHisto.[cc,h], mmontecarlo/MMcEnerThre.[cc,h], 
+     mmontecarlo/MMcEnerThreCalc.[cc,h]:
+     - removed
+
+   * mmontecarlo/MCollArea.[cc,h], mmontecarlo/MCollAreaTrigger.[cc,h]:
+     - removed
+
+
+
+ 2001/07/09: Thomas Bretz
+ 
+   * mbase/MParList.cc:
+     - made handling of already existing containers in AddToList a bit 
+       more convinient
+     
+   * mbase/MTaskList.[h,cc]:
+     - added come comments
+     - made handling of already existing tasks in AddToList a bit 
+       more convinient
+     - Added name-argument to constructor
+     
+   * mraw/MRawFileRead.[cc, h]:
+     - move file-open check from constructor to PreProcess
+     - added variable for filename
+     
+   * mraw/MRawFileWrite.[cc,h]:
+     - moved fOut->Write from PostProcess to destructor
+     - removed PostProcess
+
+
+
+ 2001/07/06: Thomas Bretz
+ 
+   * mfilter/FilterIncl.h, mfilter/FilterLinkDef.h, 
+     mfilter/MFTriggerLvl1.[h,cc], mfilter/mfilter/Makefile:
+     - added
+     
+   * Makefile
+     - mfilter added
+     
+   * Makefile.conf.linux-gnu:
+     - added some warning options
+     
+   * Makefile.conf.osf1:
+     - enhanced warnings
+     
+   * manalysis/MCerPhotEvt.cc:
+     - removed a small buf from the constructor
+     
+   * BaseLinkDef.h:
+     - added MFilter
+     - added MFilterList
+     
+   * mbase/MLog.[h,cc]:
+     - added a non-empty copy constructor to make cxx happy
+     
+   * mbase/MParList.[h,cc]:
+     - added second overload-function FindObject
+   
+   * mbase/MTask.h:
+     - added all Filter stuff
+     
+   * mbase/MTaskList.cc:
+     - changed debug output
+     - added filter-stuff to Process
+     
+   * mbase/MTaskList.h:
+     - changed Print default option from NULL to ""
+     
+   * mbase/Makefile:
+     - added MFilter
+     - added MFilterList
+   
+   * mhist/MFillHFadc.cc:
+     removed a small bug in the PreProcessing
+   
+   * manalysis/MCerPhotEvt.h, manalysis/MHillas.cc, manalysis/MHillas.h, 
+     manalysis/MImgCleanStd.cc, manalysis/MPedestalCam.h, mgui/MGeomCam.h,
+     mhist/MFillHHillas.h, manalysis/MHillasCalc.h, manalysis/MCerPhotCalc.h,
+     manalysis/MImgCleanStd.h, mhist/MFillHStarMap.h, mhist/MHHillas.cc,
+     mhist/MHHillas.h, mhist/MHStarMap.cc, mhist/MHStarMap.h,
+     mmc/MMcFadcHeader.hxx, mmc/MMcFadcHeader.hxx, mmc/MMcTrig.hxx,
+     mmontecarlo/MMcThresholdCalc.h:
+     - made more const-correct
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc, 
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MMcPedestalCopy.cc, manalysis/MPedCalcPedRun.cc,
+     mhist/MFillHFadc.cc, mhist/MFillHHillas.cc, mhist/MFillHStarMap.cc,
+     mmontecarlo/MMcThresholdCalc.cc, mraw/MRawFileRead.cc,
+     mraw/MRawFileWrite.cc:
+     - added comments
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc, 
+     manalysis/MCerPhotPix.cc, manalysis/MHillas.cc,
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc, 
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalCopy.h,
+     manalysis/MPedCalcPedRun.cc, manalysis/MPedestalCam.cc, 
+     manalysis/MPedestalPix.cc,
+     mbase/MArray.cc, mbase/MArrayB.cc, mbase/MArrayS.cc, mbase/MEvtLoop.cc, 
+     mbase/MLog.cc, mbase/MParList.cc, mbase/MReadTree.cc, mbase/MTask.cc, 
+     mbase/MTime.cc, mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc, 
+     mbase/MWriteRootFile.cc,
+     mhist/MFillHFadc.cc, mhist/MFillHFadc.cc, mhist/MFillHHillas.cc,
+     mhist/MFillHStarMap.cc, mhist/MHFadcCam.cc, mhist/MHFadcPix.cc,
+     mhist/MHHillas.cc, mhist/MHMcCollectionArea.cc, mhist/MHMcEnergies.cc,
+     mhist/MHMcEnergy.cc, mhist/MHStarMap.cc, mraw/MRawCrateArray.cc,
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc,
+     mraw/MRawEvtPixelIter.cc, mraw/MRawFileRead.cc,
+     mraw/MRawFileWrite.cc, mraw/MRawRunHeader.cc:
+     - added semicolon after ClassImp to make my editor happy
+
+   * mmain/MEvtDisp.cc:
+     - removed a wrong comma in the enumerations
+     
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - made compile on osf by removing brackets in new steatement (constructor)
+     
+
+
+ 2001/07/05: Thomas Bretz
+
+   * macros/CT1Hillas.C:
+     - changed the wrong pointers to dots.
+     
+   * macros/getThreshold.C:
+     - added some comments
+     - removed the canvas creation
+     - drawing replaced by a loop
+     - changed trigger conditions to 1 (should work with any MC file)
+     
+   * macros/readMagic.C:
+     - changed the event counter to the number of the event in the file
+     - removed icound
+     
+   * manalysis/MPedCalcPedRun.cc, manalysis/MCerPhotCalc.cc,
+     mbase/MParContainer.cc, mbase/MParContainer.h, mbase/MParList.cc,
+     mbase/MParList.h, mbase/MTaskList.cc, mbase/MWriteAsciiFile.cc,
+     mbase/MWriteRootFile.cc, mhist/MFillHFadc.cc, mhist/MFillHHillas.cc,
+     mhist/MFillHStarMap.cc,
+     - changed HasChanged to ReadyToSave
+     
+   * mbase/MReadTree.cc:
+     - added some comments
+     
+   * mhist/MHMcEnergies.h:
+     - fixed bug in []-operator
+     
+   * mhist/MHMcEnergy.cc:
+     - added canvas creation to draw function
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - fixed a bug in the constructor
+ 
+ 
+ 
+ 2001/06/20: Thomas Bretz
+ 
+   * macros/merpp.C:
+     - fixed type in comment
+     
+   * manalysis/MHillas.cc:
+     - fixed 'FIXME' comment
+   
+   * mbase/MWriteFile.[h,cc]:
+     - added
+  
+   * mbase/MWriteRootFile.[h,cc]:
+     - added
+   
+   * mbase/BaseLinkDef.h:
+     - Added MWriteFile
+     - Added MWriteRootFile
+   
+   * mbase/MEvtLoop.cc:
+     - fixed the counting in the eventloop
+     
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed class that it is based on MWriteFile now
+   
+   * mbase/Makefile:
+     - added MWriteFile
+     - added MWriteRootFile
+   
+   * mhist/MFillHFadc.[h,cc]:
+     - added set for HasChanged (new PostProcess)
+   
+   * mhist/MFillHHillas.cc:
+     - added set for HasChanged (new PostProcess)
+   
+   * mhist/MFillHStarMap.cc:
+     - added set for HasChanged (new PostProcess)
+
+   * mhist/MHHillas.cc:
+     - Set kCanDelete to make sure, that the histograms are deleted
+       together with the canvas
+     
+   * mraw/MRawFileWrite.[h,cc]:
+     - changed the handling of opening, closing and checking file
+
+
+
+ 2001/06/13: Thomas Bretz
+
+   * ./.../*.h:
+     - added some comments and corrected some descriptions.
+     
+   * mbase/MParContainer.[h,cc]:
+     - added a 'dummy' function for AsciiRead, AsciiWrite
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - added new constructor (specify directly the pointer to the class)
+
+   * mgui/MHexagon.cc:
+     - made Copy-function more readable
+
+   * mgui/MParContainer.cc:
+     - made Copy-function more readable
+
+   * mhist/MHMcEnergies.[h,cc]:
+     - files added as a container to make handling of several MHMcEnergy easier
+   
+   * mbase/MAGIC.h:
+     - encapsulated include of TROOT
+
+   * mbase/MTaskList.cc:
+     - added SetHasChange and Reset to PostProcess
+
+   * mhist/HistLinkDef.h
+     - added MHMcEnergies
+     
+   * mhist/MHMcEnergy.[h,cc]:
+     - added name and title to constructor
+     - added number to name of container
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - corrected typo in creation of the container names
+   
+   * mraw/MRawEvtData.cc:
+     - Set kCanDelete in Draw function
+
+
+
+ 2001/06/12: Thomas Bretz
+
+   * mmontecarlo/MMcEnerThreCalc.[cc,h] 
+     - copied to mmontecarlo/MMcThresholdCalc.[cc,h]
+
+   * mmontecarlo/MMcEnerThreHistos.[h,cc]
+     - copied to mmhist/MHMcEnergy.[h,cc]
+
+   * mbase/Makefile:
+     - added MWriteAsciiFile.cc
+   
+   * mhist/HistIncl.h:
+     - added TF1.h
+
+   * mhist/HistLinkDef.h:
+     - added MHMcEnergy
+ 
+   * mhist/Makefile
+     - added MHMcEnergy
+   
+   * mmontecarlo/MCollArea.h:
+     - fixed typo in ifndef
+   
+   * mmontecarlo/Makefile:
+     - added MMcThresholdCalc.cc
+     - removed MMcEnerHisto.cc
+     - removed MMcEnerThre.cc
+     - removed MMcEnerThreCalc.cc
+
+   * mmontecarlo/MonteCarloLinkDef.h:
+     - added MMcThresholdCalc.cc
+     - removed MMcEnerHisto.cc
+     - removed MMcEnerThre.cc
+     - removed MMcEnerThreCalc.cc
+ 
+   * mbase/MWriteAsciiFile.[h,cc]: 
+     - added
+
+   * manalysis/MCT1ReadAscii.h: 
+     - removed fFileName from class definition
+ 
+   * manalysis/MCerPhotCalc.cc: 
+     - use of SetHasChanged added
+ 
+   * manalysis/MHillas.[h,cc]: 
+     - Reset added
+     - AsciiRead added
+     - AsciiWrite added
+     - use of SetHasChanged added
+
+   * manalysis/MPedCalcPedRun.[h,cc]:
+     - made fNumHiGainSamples a class member
+     - renamed some member functions
+     - made the 'internal' member functions private
+     - added SetHasChanged
+     - made these functions const
+     
+   * mbase/BaseLinkDef.h
+     - MWriteAsciiFile added
+   
+   * mbase/MEvtLoop.cc:
+     - some small changes to the logging output
+   
+   * mbase/MParContainer.cc:
+     - fHasChanged added 
+   
+   * mbase/MParContainer.h:
+     - Reset prototype added
+     - HasChanged added
+     - SetHasChanged added
+   
+   * mbase/MParList.[cc,h]:
+     - SetHasChanged added
+     - Reset added
+   
+   * mbase/MTaskList.cc:
+     - Process: call SetHasChanged before looping
+     - Process: call Reset before looping
+   
+   * mbase/MTaskList.h:
+     - fParList added to class definition
+
+
+
+ 2001/04/27: Thomas Bretz
+
+   * macros/merpp.C:
+     - made the merpp-macro Mars 0.3 compatible
+
+
+
+ 2001/04/19: Thomas Bretz
+
+   * mbase/MParList.cc:
+     - added stripping of the string after last semicolon (classname)
+
+   * mbase/MReadTree.cc:
+     - added Veto funtionality to PreProcess
+     - added HasVeto
+     - added fVetoList
+     - added VetoBranch
+
+
+
+ 2001/04/18: Thomas Bretz
+
+   * mbase/MHtml.[cc.h]:
+     - Added
+     
+   * mbase/*.cc:
+     - changed comments of member functions to new MHtml-Style
+
+
+
+ 2001/04/09: Thomas Bretz
+
+   * mbase/MParList.cc:
+     - Added the possibility to specify a different object name in
+       FindCreateObj
+
+   * .rootrc:
+     - changed the style for the html documentation
+    
+   * macros/dohtml.C:
+     - added SetXwho
+    
+   * (*.cc):
+     - added the copyright comment block
+  
+   * mgui/MGeomCamMagic.cc:
+     - added some comments to all these numbers
+  
+   * mraw/MRawEvtPixelIter.h:
+     - added Jump member function which jumps directly to the pixel with a
+       given id
+      
+
+
+ 2001/04/09: Thomas Bretz
+
+   * mgui/MGeomPix.cc:
+     - fixed a small error in SetNeighbors (thanks to Oscar)
+     
+   * mgui/MGFadcDisp.[h,cc]:
+     - Fixed many small errors which caused the display to display nonsens
+       in some situations
+
+
+
+ 2001/04/04: Thomas Bretz
+
+   * mraw/MRawEvtData.[cc,h]:
+     - changed wrong return type of GetNumPixels to UShort_t
+
+   * mmain/MBrowser.[cc,h]:
+     - made the dialog somehow work like it should
+
+
+
+ 2001/04/03: Thomas Bretz
+
+   * manalysis/MCT1ReadAscii.cc:
+     - the pedestal values read from the file are now stored in MeanRms 
+       instead of Sigma
+   
+   * manalysis/MCerPhotCalc.cc:
+     - The pedestal mean Rms is used as the pixel error
+   
+   * MImgCleanStd.cc:
+     - CleanStep1: the '<' was replaced by a '<=' to clean also pixels 
+       with value=noise=0
+     
+   * MMcPedestalCopy.cc:
+     - All the pedestal values are now filled in (are they calculated correctly?)
+   
+   * mgui/MGeomCamMagic.cc:
+     - Forgot to initialize the Nextneighbors of the Magic Camera
+       (thanks to Oscar)
+     
+   * mhist/MHStarMap.cc:
+     - I changed the model of the display (colors and bin width) to
+       get a 'better' result
+
+
+
+ 2001/04/02: Thomas Bretz
+ 
+   * mraw/MRawEvtHeader.h, mraw/MRawFileWrite.cc:
+     - added constants (kTT*) for trigger type
+   
+   * manalysis/MImgCleanStd.[h,cc]:
+     - added changeable cleaning levels
+ 
+   * manalysis/MHillas.cc:
+     - added some more sanity checks to the calculation
+     
+   * manalysis/MCT1ReadAscii.[h,cc]:
+     - added some kind of chain feature (AddFile) to process more than one file
+ 
+   * mgui/MGeomPix.[h,c]:
+     - added interface to pixel neighbors
+ 
+   * mgui/MGeomCamCT1.[cc,h], mgui/MGeomCamMagic.[cc,h]:
+     - creates the neighbor geomtry now, too
+ 
+   * manalysis/MImgCleanStd.[cc,h]:
+     - switched to new stylish neighbors from MGeomCam
+
+
+
+ 2001/03/30: Thomas Bretz
+ 
+   * mdatacheck/MH*, mdatacheck/MFillH*:
+     - moved to mhist
+   
+   * mraw/MrawEvtPixelIter:
+     - IsLoGain -> HasLoGain
+   
+   * mgui/MG*:
+     - renamed
+     - moved to mmain
+     - move Browser functionality to MBrowser
+ 
+   * mmain/, mhist:
+     - new
+
+
+
+ 2001/03/21: Thomas Bretz
+                            
+   * manalysis/MHillas.[h,cc]:
+     - fixed some minor errors, added sanity check (N<2) to Calc
+
+   * manalysis/MFillHHillas.cc:
+     - skip event if Hillas calculations fails
+     
+   * macros/getCollArea.C, macros/readMagic.C, 
+     mdatacheck/MViewAdcSpectra.cc, meventdisp/MGFadcDisp.cc:
+     - changed order in MReadTree constructor
+
+   * manalysis/MCT1ReadAscii.[h,cc]:
+     - changed to use MPedestalCam
+     
+   * manalysis/MCT1Pedestals.[h,cc]:
+     - removed
+     
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MCT1Pedestals
+     
+   * mbase/BaseLinkDef.h:
+     - added const values from Magic.h
+     
+   * mbase/MLogManip.h:
+     - changed style of dbginf
+   
+   * mbase/MParList.cc:
+     - make use of dbginf
+     
+   * mbase/MReadTree.[h,cc]:
+     - switched from a TTree to a TChain object
+     - chnaged order of variables of the constructor
+
+
+
+ 2001/03/21: Thomas Bretz
+                                                                  
+   * macros/CT1Hillas.C, manalysis/MImgCleanStd.cc, manalysis/MImgCleanStd.h,
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalCopy.h,
+     manalysis/MCerPhotCalc.h, manalysis/MCerPhotCalc.cc, mdatacheck/MHHillas.h,
+     mdatacheck/MHHillas.cc, mdatacheck/MFillHFadc.cc, mdatacheck/MFillHFadc.h,
+     mdatacheck/MHFadcCam.cc, mdatacheck/MHFadcCam.h, mdatacheck/MHFadcPix.cc,
+     mdatacheck/MHFadcPix.h, mdatacheck/MFillHHillas.cc, 
+     mdatacheck/MFillHHillas.h
+     - added
+
+   * mdatacheck/MHistosAdc.[h,cc]:
+     - replaced by MHFadc[Cam,Pix]
+
+   * mdatacheck/MFillAdcSpect.[h,cc]:
+     - replaced by MFillHFadc
+
+   * macros/readCT1.C:
+     - uses the new classes now
+     - calculates and displays hillas
+
+   * manalysis/AnalysisLinkDef.h:
+     - added MCerPhotCalc, MImgCleanStd, MMcPedestalCopy
+
+   * manalysis/MCT1ReadAscii.cc:
+     - PreProcess uses FindCreateObj now
+
+   * manalysis/MCerPhotEvt.cc, manalysis/MPedestalCam.cc:
+     - changed the new back to 'new with placement'
+
+   * manalysis/MCerPhotEvt.[h, cc]:
+     - removed cleaning from this class
+
+   * manalysis/MHillas.cc:
+     - some small changes in the naming inside Calc()
+
+   * manalysis/MHillas.h:
+     - added Get-functions
+     
+   * manalysis/MPedestalCam.h:
+     - added InitSize-function
+     
+   * manalysis/MPedestalPix.h:
+     - made Get-functions const
+     
+   * manalysis/Makefile:
+     - added MMcPedestalCopy, MImgCleanStd, MCerPhotCalc
+     
+   * mbase/MLogManip.h:
+     - "l." before line number
+     
+   * mbase/MParList.cc:
+     - added the autodelete feature for automatically created classes
+     
+   * mdatacheck/DataCheckLinkDef.h:
+     - added MHFadc[Cam,Pix], MHHillas
+     - removed MHistosAdc
+     - added MFillHFadc, MFillHHillas
+     
+   * mdatacheck/MGDisplayAdc.[h,cc], MShowSpect.[h,cc],
+     mdatacheck/MViewAdcSpectra.[h,cc], :
+     - changed from MHistaosAdc to MHFadcCam
+     
+   * mdatacheck/Makefile:
+     - added MFillHFadc.cc, MFillHHillas.cc
+     - removed MFillAdcSpect.cc
+
+   * manalysis/MCT1ReadAscii.h, mbase/MEvtLoop.h, mbase/MLog.h,
+     mbase/MParList.h, mbase/MReadTree.h, mbase/MTask.h,
+     mbase/MTaskList.h, mdatacheck/MDumpEvtHeader.h,
+     meventdisp/MGFadcDisp.h, mgui/MCamDisplay.h,
+     mgui/MCamNeighbor.h, mgui/MGDataCheckMain.h,
+     mgui/MGEventDispMain.h, mgui/MGMarsMain.h,
+     mgui/MGMonteCarloMain.h, mgui/MGPrototyp.h, mgui/MHexagon.h,
+     mmontecarlo/MCollAreaTrigger.h, mraw/MRawEvtPixelIter.h,
+     mraw/MRawFileRead.h, mraw/MRawFileWrite.h:
+     - set version number to '0' (no i/o for this class)
+
+   * mgui/MGeomCamCT1.cc:
+     - new claculation algorith for the CT1 camera. It is more
+       exact in the camera plain
+       
+   * mgui/MHexagon.cc:
+     - removed Draw-function (it is inherited from TObject)
+     
+   * mmc/MMcFadcHeader.hxx:
+     - Added get-functions
+     
+
+
+
+ 2001/03/20: Thomas Bretz
+                                                                  
+   * manalysis/MPedestalPix.[h,cc], manalysis/MPedestalCam.[h,cc],
+     manalysis/MHillas.[h,cc], manalysis/MHillasCalc.[h,cc],
+     mgui/MGeomCamCT1.[h,cc], mgui/MGeomCamMagic.[h,cc]
+     - added
+
+   * macros/readCT1.C:
+     - added calculation of Hillas parameters
+     - changed from pointers to objects
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MPedestalPix/Cam, MHillas, MHillasCalc
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - removed fType
+     - commented out Draw function - should be fixed soon
+     - renamed *Nb* to *Num*
+     - renamed Get[Min,Max]NumPhotons to GetNumPhontons[Min,Max]
+
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - changed parameter of ReadinEvent to unsigned
+
+   * mgui/GuiLinkDef.h, mgui/Makefile:
+     - added MGeomCamCT1, MGeomCamMagic
+
+   * mgui/MCamDisplay.[h,cc]:
+     - changed constructor argument from int to MGeomCam
+     - renamed *Nb* to *Num*
+
+   * mgui/MGeomCam.[h,cc]:
+     - removed all camara specific stuff
+     - MGeomCam is now used as a base class for the classes
+       MGeomCam[Magic,CT1] which are containing the camera specific stuff
+
+   * mgui/MGeomPix.h:
+     - added Set function
+
+
+
+ 2001/03/02: Thomas Bretz
+   
+   * manalysis/Makefile, mdatacheck/Makefile, meventdisp/Makefile,
+     mgui/Makefile: 
+     - new
+   
+   * mbase/MParList.[cc,h]: 
+     - Added FindCreateObj member function
+     - added a name to the constructor
+ 
+   * mbase/MReadTree.cc: 
+     - changed to use FindCreateObj
+
+   * mdatacheck/MDumpEvtHeader.cc: 
+     - removed fPixelIter from member list
+     - changed cout to *fLog
+   
+   * mdatacheck/MViewAdcSpectra.cc:
+     - removed a HUGE memory leak. All the objects in the list (and the
+       lists itself were NEVER deleted)
+   
+   * mdatacheck/MFillAdcSpect.cc
+     - removed fPixelIter from member list
+     - changed cout to *fLog
+     - changed to use FindCreateObj
+     - changed high and low to hi and lo
+   
+   * mdatacheck/MShowSpect.cc
+     - changed cout to *fLog
+     - added a name to the constructor
+   
+   * mraw/MRawFileRead.cc:
+     - changed to use FindCreateObj
+   
+   * mdatacheck/MGDisplayAdc.[h,cc]: 
+     - added some new member functions to make code more clear
+     - removed fHists from the destructor
+   
+   * mdatacheck/MHistosAdc.h:
+     - changed high and low to hi and lo
+
+   * macros/dohtml.C:
+     - added manalysis
+
+
+
+ 2001/03/01: Thomas Bretz
+
+   * Makefile: 
+     - added headers to dependencies
+ 
+   * Makefile.rules: 
+     - added headers to dependencies
+ 
+   * merpp.cc: 
+     - changed from pointers to objects
+     - added compression level support
+ 
+   * readraw.cc: 
+     - removed unnecessary includes
+ 
+   * mbase/MArray*.*: 
+     - changed all Int_t to UInt_t
+ 
+   * mbase/MLogManip.h: 
+     - changed name of __DINF__ to dbginf
+ 
+   * mraw/MRawCrateData.[h,cc], mraw/MRawEvtHeader.[h,cc],
+     mraw/MRawRunHeader.[h,cc]: 
+     - changed ifstream to istream
+     
+   * mraw/MRawEvtData.cc: 
+     - changed the reading, which speeds up merpp by a factor of 10
+   
+   * mraw/MRawEvtData.h: 
+     - added flag to InitArrays and DeletePixels 
+       (not yet used)
+
+   * mraw/MRawFileRead.h: 
+     - removed pParList from parameter list
+ 
+   * manalysis/AnalysisLinkDef.h
+     - removed MReadCT1Ascii, added MCT1ReadAscii
+     - added MCT1Pedestals
+   
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - changed the constructor a little bit
+     - rewrote Print() to make it a bit more readable
+     - moved MCerphotPix to new File
+     - added many lines of comments
+     - exchanged old stylish new call with new stylish(=) one
+     - replaced all accesses to fPixels with the [] operator to make this
+       lines more readable
+     - made all variable declarations const-correct,
+     - I changed the style of the cleaning method from if(a){if()b{if(c){}}}
+       to if(!a)continue; if(!b)continue if(!c) continue; to make it more
+       compact, readable and easier to understand
+     - renamed the Boolean-functions to Is* to get a stricter structure
+     - replaced mapping function to access the pixel list entries by the new 
+       operator to get rid of more than the necessary number of member 
+       functions without loosing speed or readability
+     - renamed GetMinimum/MaximumPhoton to GetMin/MaxNumPhotons to be 
+       more exact
+   
+   * mgui/MCamGeom.* splitted and changed to MGeomCam/Pix:
+     - added a new operator to access the TObjArray
+     - removed unnecessary code from CreateCT1
+ 
+   * mbase/MAGIC.h: 
+     - added kPI
+ 
+   * mbase/MReadTree.cc: 
+     - added some comments
+ 
+   * mgui/MCamDisplay.[h,cc]: 
+     - added some comments, reordered a bit the calls in the constructor 
+       to get a 'straight forward structure', MGeomCam is now only
+       locally used where it is needed, replaced access to the 
+       TClonesArrays by new member-function to get a more readable code,
+       replaced old stylish new call with new stylish one, made
+       variable decleration const-correct, introduced a new member function
+       to set the pixel color, renamed the overloaded Draw functions to
+       DrawPhotons, DrawPhotErr to prevent missunderstatements, changed
+       the 'layout' of GetColor to make it easier to understand the algorithm,
+   
+   * mgui/MCamNeighbor.[h, cc]:
+     - changed to new log-interface
+     - exchanged -9999 by -1
+     - skipped the exits
+     - you must check for -1 one in any case
+     - this means a warning should be enough
+   
+   * mgui/MHexagon.[h,cc]:
+     - added new constructor whcih uses a MGeomPix-object
+
+
+
+ 2001/02/28: Thomas Bretz
+
+   * mbase/MParList.[h,cc]: 
+      - changed return type of FindObject back to TObject
+      - it seems so, that some compilers don't like overriding the
+        return type of a virtual member function
+
+
+
+ 2001/02/23: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.h: 
+      - added GetSum* functions
+
+   * mbase/MParList.[h,cc]: 
+      - Removed unnecessary fNext-stuff
+
+
+
+ 2001/02/22: Thomas Bretz
+
+   * merpp.cc, readraw.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MParList.h, mbase/MReadTree.cc, mbase/MTask.cc, mbase/MTask.h,
+     mbase/MTaskList.cc, mbase/MTime.cc, mdatacheck/MDumpEvtHeader.cc,
+     mdatacheck/MShowSpect.cc, meventdisp/MGFadcDisp.cc, mgui/MGPrototyp.h,
+     mmc/MHeaderTrig.cxx, mraw/MRawCrateArray.cc, mraw/MRawEvtData.cc,
+     mraw/MRawEvtHeader.cc, mraw/MRawFileRead.cc, mraw/MRawFileWrite.cc,
+     mraw/MRawRunHeader.cc:
+      - exchanged cout with the new logging style (gLog, *fLog)
+
+   * mraw/MRawEvtData.cc: 
+      - added 'dec' option to Print
+  
+   * mmc/MHeaderTrig.cxx, mmc/MMcEvt.cxx, mmc/MMcTrig.cxx:
+      - small changes to the Print funtions
+
+
+
+ 2001/02/21: Thomas Bretz
+
+   * MRawEvtData.cc: 
+      - Changed ReadEvt according to the new raw binary format 2001/02/20
+     
+   * Added MLog.[h,cc], MLogManip.[h,cc]
+   
+   * Adde SetStreamer and fLog to the MParContainer base class
+   
+   * Derived MEvtLoop from MParContainer
+
+   * Makefile: 
+      - added 'tar'
+
+   * mbase/BaseIncl.h: 
+      - added fstream.h, TGListBox.h
+ 
+   * mbase/BaseLinkDef.h: 
+      - added pragma for gLog and MLog
+ 
+   * mbase/MAGIC.h: 
+      - added forward definition for gLog
+ 
+   * mbase/MEvtLoop.cc: 
+      - exchanged cout with *fLog
+      - added statements to provide log-facility to all tasks als parameter 
+        containers
+    
+   * mbase/MEvtLoop.h: 
+      - Small changes
+  
+   * mbase/MParContainer.h: 
+      - Added definitions necessary for use of Log-Facility
+  
+   * mbase/MParList.[h,cc]: 
+      - Added SetLogStream
+  
+   * mbase/MTask.h: 
+      - added fLog
+  
+   * mbase/MTaskList.[h,cc]: 
+      - added SetLogStream
+  
+   * mbase/Makefile: 
+      - Added MLog.cc, MLogManip.cc
+
+
+
+ 2001/02/19: Harald Kornmayer	
+
+  *  implemented the Image Cleaning a la CT1 to the class MCerPhotEvt
+  
+  *  changed the readCT1.C file to show the effects of the image cleaning
+     a la CT1
+
+  *  changed 
+	mgui/MCamNeighbor.cc
+	mananlysis/MCerPhotEvt.cc  .h 
+	macros/readCT1.C
+
+
+
+ 2001/02/19: Thomas Bretz
+
+   * MParContainer.h added prototypes for AsciiRead/Write
+
+   * .rootrc added
+
+   * MEvtLoop.[h,cc]: 
+      - split eventloop in its three parts, this should be used for 
+        debugging only.
+
+
+
+ 2001/02/06: Harald Kornmayer
+
+   *  the first running version with a eventdisplay. Now we are able
+      to display an Event on the photo electron level. To do this, run
+      the macro "macros/readCT1.C" after changing the file name. 
+
+      changed: 
+	macros/readCT1.C
+	manalysis/MNphotEvent.cc, manalysis/MNphotEvent.h
+	analysis/MReadCT1Ascii.cc
+	mgui/MCamDisplay.cc, mgui/MCamDisplay.h
+
+
+
+ 2001/01/23: Harald Kornmayer
+
+   *  the integration of the class FadcDisp in the mars enviroment
+      and further developments in the display
+
+      changed: 
+	meventdisp/MGFadcDisp.h
+	meventdisp/MGFadcDisp.cc
+	mgui/GuiIncl.h
+	mgui/GuiLinkDef.h
+	mgui/MGMarsMain.cc
+	mgui/MGPrototyp.cc
+	mgui/MGPrototyp.h
+	mgui/Makefile
+
+      added: 
+	mgui/MGEventDispMain.h
+	mgui/MGEventDispMain.cc
+
+
+
+ 2001/01/22: Harald Kornmayer
+
+   *  started with the development of a EventDisplay Utitliy. 
+      Therefore I added the following files. 
+
+      meventdisp/EvtDispIncl.h
+      meventdisp/EvtDispLinkDef.h
+      meventdisp/MGFadcDisp.cc
+      meventdisp/MGFadcDisp.h
+      meventdisp/Makefile
+
+      Also a few of the older files where slightly changed. 
+      ./Makefile
+      ./Makefile.rules
+      mraw/MRawEvtData.
+      
+
+
+ 2001/01/19: Thomas Bretz
+
+    * mmc/*.hxx:
+       - changed include of MDefineTrigger.h back
+
+
+
+ 2001/01/19: Oscar Blanch
+
+    * mmc/MTriggerDefine.h:
+       - added
+
+
+
+ 2001/01/18: Thomas Bretz
+
+    * Makefile:
+       - mmc-library added
+
+    * Makefile.conf.general:
+       - Added definition of __MARS__
+
+    * Makefile.rules:
+       - Added definitions to rootcint
+
+    * Oscar added the McFormat subdir of the Monte Carlo as mmc
+
+    * mmc/MMcEvt.h:
+       - renamed to MMcEvt.hxx
+
+    * mmc/*.hxx:
+       - added necessary defintions from MDefineTrigger.h
+
+    * mmc/Makefile, mmc/McLinkDef.h, mmc/McIncl.h, mmc/readme.txt:
+       - added
+
+    * mmc/LinkDef.h:
+       - removed
+
+
+
+ 2001/01/17: Thomas Bretz
+
+    * Makefile:
+       - Exchanged explicit rules to make library by implicit ones
+       - The shared object works now. I exchanged the libraries with the object
+         files. But I don't know why the libraries don't work.
+
+    * Makefile.conf.linux-gnu:
+       - replaced CC with gcc (instead of g++)
+
+    * mdatacheck/DataCheckLinkDef.h:
+       - removed unused statements
+
+    * mraw/RawLinkDef.h:
+       - added globals
+
+    * mraw/MerppLinkDef.h:
+       - removed unused file
+
+
+
+ 2001/01/12: Thomas Bretz
+
+    * MLinkDef.h, MIncl.h, marslogo.xpm, magiclogo.xpm:
+       - added
+
+    * LinkDef.h:
+       - removed
+
+    * Makefile:
+       - Added CINT, mrproper
+
+    * mbase/Makefile, mraw/Makefile, mgui/Makefile, mdatacheck/Makefile:
+       - included makefile.general, Makefile.rules,
+       - removes corresponding lines
+
+    * mdatacheck/MDumpEvtHeader.[h,cc], mdatacheck/MFillAdcSpect.[cc,h],
+      mdatacheck/MFillAdcSpect.[h,cc], mdatacheck/MGDisplayAdc.[cc,h],
+      mdatacheck/MHistsosAdc.[h,cc], mdatacheck.MShowSpect.[cc,h]
+       - changed include statements
+
+    * mgui/MGDataCheckMain.[cc,h], mgui/MGMarsMain.[cc,h]
+       - changed include statements
+       - move enum from h to cc
+       - removed comma operator from delete statements (nonsense)
+
+
+
+ 2001/01/11: Harald Kornmayer
+
+    * ./
+      readraw.cc, Makefile, Makefile.rules, LinkDef.h, MParList.cc, MReadTree.cc,
+      MReadTree.h, mbase/Makefile, mraw/Makefile
+       - small changes in this files. Not really critical.
+
+    * mars.cc
+       - added the main file for the gui
+
+    * mgui/
+      GuiIncl.h, MGMarsMain.cc, GuiLinkDef.h, MGMarsMain.h, MGDataCheckMain.cc,
+      Makefile, MGDataCheckMain.h
+       - added the subdir mgui and this files
+
+    * mdatacheck/
+      DataCheckIncl.h, DataCheckLinkDef.h, MHistosAdc.cc, MHistosAdc.h,
+      MDumpEvtHeader.cc, MDumpEvtHeader.h, MShowSpect.cc, MShowSpect.h,
+      MFillAdcSpect.cc, MFillAdcSpect.h, MViewAdcSpectra.cc, MViewAdcSpectra.h,
+      MGDisplayAdc.cc, MGDisplayAdc.h, Makefile
+       - added the subdir mdatacheck and this files
+
+
+
+ 2000/12/28: Thomas Bretz
+
+    * merpp.cc, MArray.cc, MArray.h, MArrayB.cc, MArrayB.h, MArrayS.cc,
+      MArrayS.h, MEvtLoop.cc, MEvtLoop.h, MInputStreamID.cc, MInputStreamID.h,
+      MParContainer.cc, MParContainer.h, MParList.cc, MParList.h, MReadTree.cc,
+      MTask.cc, MTask.h, MTaskList.cc, MTaskList.h, MTime.cc, MTime.h:
+       - Added changes some comments.
+
+    * MLoopEvt.cc, MLoopEvt.h:
+       - Removed
+
+
+
+ 2000/12/22 - Thomas Bretz:
+
+    * readraw.cc:
+       - changed some comments and the Root-Name of the program
+       - added check for the existance of the file
+       - changed name of numbers of entries from iEnt to nent
+
+    * dohtml.C:
+       - changed title of converted macros
+
+    * MRawEvtData.cc:
+       - added a commet in Draw()
+
+    * MRawEvtPixelIter.[h,cc]:
+       - Added the comment header of the file
+       - removed inheritance from TIterator (not needed)
+       - some changes to get it work (the one in the repository was untested
+         and not working)
+       - changed calling style of iterator from do...while to while-loop
+       - changed some comments
+
+    * MRawRunHeader.cc:
+       - added some comments
+
+    * Changelog, News: added
+
+    * test.C: removed
Index: /tags/Mars_V0-8/MagicSoft/Mars/MIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/MIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/MIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/MLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/MLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/MLinkDef.h	(revision 1638)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile	(revision 1638)
@@ -0,0 +1,138 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include Makefile.conf.$(OSTYPE)
+include Makefile.conf.general
+
+#
+
+PROGRAMS = readraw merpp mars
+SOLIB    = mars.so
+CINT     = M
+
+#
+#  connect the include files defined in the config.mk file
+#
+#    WARNING: the result (whether the linkage works or not) depends on the
+#             order of the libraries. It seems, that the most base library
+#             must be the last one
+#
+
+#
+#  ----->>>   mars libraries
+#
+SUBDIRS = mmain       \
+          mbase       \
+          mfileio     \
+	  manalysis   \
+          mmc         \
+          meventdisp  \
+          mdatacheck  \
+          mmontecarlo \
+          mhist       \
+          mdata       \
+          mfilter     \
+          mtools      \
+          mgui        \
+          mgeom       \
+          mraw
+
+LIBRARIES = $(SUBDIRS:=.a)
+MRPROPERS = $(SUBDIRS:=.mrproper)
+CLEANERS  = $(SUBDIRS:=.clean)
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .h .o 
+
+SRCFILES = 
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: rmlib $(PROGRAMS) $(SOLIB)
+	@echo " Done. "
+	@echo " "
+
+# Use $(CXX) -v ... for a more verbose output
+#
+#
+#$(MARS_LIB)
+$(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o
+	@echo " Linking $(SOLIB) ..."
+	$(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
+	mv mars.so lib
+
+$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o) 
+	@echo " Linking $@ ..." 
+	$(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) MCint.o $(ROOTGLIBS) -o $@
+
+#
+# We could link mars.so instead of all libraries. This would need
+# some MBs less space on the HD. But this means, that the Shared
+# Library Path in your system must be set properly to be able to start
+# 'mars'
+#
+#$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) $(SOLIB) MCint.o $(PROGRAMS:=.o) 
+#	@echo " Linking $@ ..." 
+#	$(CXX) $(CXXFLAGS) $@.o $(OBJS) lib/$(SOLIB)  MCint.o $(ROOTGLIBS) -o $@
+
+#
+# For later use
+#
+#$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o) 
+#	@echo " Linking $@ ..." 
+#	$(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) -L/usr/X11R6/lib -lX11 -lXpm MCint.o $(ROOTGLIBS) -o $@
+#
+#$(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o
+#	@echo " Linking $(SOLIB) ..."
+#	$(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
+#	mv mars.so lib
+
+$(LIBRARIES):
+	@echo " Creating lib$@:"
+	(cd $*; make; cd ..; mv $*/$@ lib/lib$@) 
+
+$(MRPROPERS):
+	@echo " Doing Mr.Proper in $(@:.mrproper=)"
+	(cd $(@:.mrproper=); (make mrproper > /dev/null); cd ..;) 
+
+$(CLEANERS):
+	@echo "Cleaning $(@:.clean=):"
+	(cd $(@:.clean=); make clean; cd ..;) 
+
+dox: $(SOLIB)
+	@echo " Creating html documentation:"
+	root -b -q dohtml.C
+
+include Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	$(MRPROPERS) rmbin rmbak rmbakmac rmhtml clean
+	@echo " Done."
+	@echo " "
+
+tar:	mrproper
+	@echo "Making tar-file"
+	@root -b -q -l -n tar.C
+#	@tar cvf ../mars.tar --exclude=Root .rootrc *
+#	@gzip -9 ../mars.tar
+
+# @endcode
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.general
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.general	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.general	(revision 1638)
@@ -0,0 +1,19 @@
+#
+#  ----->>>   root libraries
+#
+
+ROOTVER    =  `root-config --version`
+ROOTLIBS   =  `root-config --libs` -lMinuit
+ROOTGLIBS  =  `root-config --glibs` -lMinuit
+ROOTCFLAGS =  `root-config --cflags`
+
+#
+#  compiler flags
+#
+
+DEFINES	  = -D__MARS__ -DROOTVER=\"$(ROOTVER)\" $(ARCHDEF)
+
+CXXFLAGS  = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG) $(DEFINES)
+CFLAGS    = $(CXXFLAGS)
+FFLAGS    = $(CXXFLAGS)
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux	(revision 1638)
@@ -0,0 +1,39 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+# compilers
+
+CC       = gcc
+CXX      = g++
+F77      = f77
+AR       = ar -rc
+
+#
+#  ----->>>   settings for compilation
+#
+OPTIM    = -O5 -Wall -fno-rtti -fnonnull-objects -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual
+DEBUG    =
+ARCHDEF  = -D__LINUX__
+
+# For debugging information use '-g'
+# For producing gmon.out use    '-pg'
+
+MARS_LIB = -Llib $(SUBDIRS:%=-l%)
+INCLUDES = -I. $(SUBDIRS:%=-I%)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux-gnu
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux-gnu	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.linux-gnu	(revision 1638)
@@ -0,0 +1,39 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+# compilers
+
+CC       = gcc
+CXX      = g++
+F77      = f77
+AR       = ar -rc
+#
+#  ----->>>   settings for compilation
+#
+
+OPTIM    = -O5 -Wall -fno-rtti -fnonnull-objects -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual
+DEBUG    =
+ARCHDEF  = -D__LINUX__
+
+# For debugging information use '-g'
+# For producing gmon.out use    '-pg'
+
+MARS_LIB = -Llib $(SUBDIRS:%=-l%)
+INCLUDES = -I. $(SUBDIRS:%=-I%)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf1
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf1	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf1	(revision 1638)
@@ -0,0 +1,39 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+#
+# compilers
+#
+
+CC       = cc
+CXX      = cxx
+F77      = f77
+AR       = ar -c -r
+
+#
+#  ----->>>   settings for compilation
+#
+
+OPTIM    = -O2 -ieee -arch host
+DEBUG    = -g  -w0 -msg_display_tag -msg_disable castqualtyp,undpreid,unrfunprm,extrasemi,intconlosbit,nonfundec,partovrd,stoclsnotfirst,boolexprconst
+ARCHDEF  = -D__OSF__
+
+MARS_LIB = -Llib $(SUBDIRS/*/-l&)
+INCLUDES = -I. $(SUBDIRS/*/-I&)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf5.1
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf5.1	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.conf.osf5.1	(revision 1638)
@@ -0,0 +1,39 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+#
+# compilers
+#
+
+CC       = cc
+CXX      = cxx
+F77      = f77
+AR       = ar -c -r
+
+#
+#  ----->>>   settings for compilation
+#
+
+OPTIM    = -O2 -ieee -arch host
+DEBUG    = -g3  -w0 -msg_display_tag -msg_disable castqualtyp,undpreid,unrfunprm,extrasemi,intconlosbit,nonfundec,partovrd,stoclsnotfirst,boolexprconst
+ARCHDEF  = -D__OSF__
+
+MARS_LIB = -Llib $(SUBDIRS/*/-l&)
+INCLUDES = -I. $(SUBDIRS/*/-I&)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/Makefile.rules
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/Makefile.rules	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/Makefile.rules	(revision 1638)
@@ -0,0 +1,68 @@
+
+depend:
+	@makedepend $(SRCS) $(INCLUDES) -I$(INCLUDE_CPLUS) $(ROOTCFLAGS) \
+        -f Makefile.depend 2> kk.kk ; cat kk.kk
+
+$(LIB): $(OBJS) $(HEADERS) $(CINT)Cint.o
+	@echo " - Building Library lib$(LIB)"
+	$(AR) $(LIB) *.o
+	@echo " "
+
+$(CINT)Cint.cc: $(HEADERS) 
+	@echo " - Generating dictionary $(CINT)Cint.cc"
+
+	$(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \
+	-c $(INCLUDES) $(DEFINES) $(HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 
+
+.cxx.o:	
+	@echo " - Compiling" $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.cc.o:	
+	@echo " - Compiling" $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.c.o:	
+	@echo " - Compiling" $<
+	$(CC) $(CFLAGS) -c $< -o $@
+#
+# The cleaning facility
+#
+
+rmcint:	
+	@echo " Removing cint-stuff..."
+	@rm -f *Cint.*
+
+rmlib:	
+	@echo " Removing libraries..."
+	@echo " "
+	@rm -f lib/lib*.a lib*.a
+
+rmobjs:	
+	@echo " Removing object files..."
+	@rm -f *.o
+
+rmcore:	
+	@echo " Removing core files..."
+	@rm -f core*
+
+rmbin:	
+	@echo " Removing binary files..."
+	@rm -f $(PROGRAMS) lib/$(SOLIB) so_locations
+
+rmbak:
+	@echo " Removing backup files..."
+	@rm -f *~ kk.kk *.bak .#* .*~
+
+rmbakmac:
+	@echo " Removing backup files in macros"
+	@rm -f macros/*~
+
+rmhtml:
+	@echo " Removing htmldoc-tree"
+	@rm -rf htmldoc
+
+cflags: 
+	@echo $(INCLUDES) $(CXXFLAGS)
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/NEWS
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/NEWS	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/NEWS	(revision 1638)
@@ -0,0 +1,313 @@
+                                                               -*-*- END -*-*-
+
+ *** Version 0.8 (2002/11/18)
+
+   - added all subdirectories as Include-Paths for ACLIC (s. rootlogon.C)
+
+   - corrected 48(!) wrong entries in the Next Neighbor table of the
+     Magic Camera (all in the inner part of the outer ring, mostly 
+     missing a single NN)
+
+   - Fixed a bug in the table describing the Next Neighbours of the
+     CT1 camera (a pixel 127 doesn't exist and the pixel 126 didn't
+     have any neighbour)
+
+   - changed trigrate.C: now it calculates the pure NSB triggers from
+     a camera file (generated with no showers), so there is no need
+     to introduce them by hand in the BgR array (for more details
+     please ask Abelardo)
+
+   - added MHHadronness (and MHadronness) as a general facility to evaluate
+     the quality of a gamma-hadron seperation method
+
+   - changed MWriteAsciiFile to accept rules (MDataChain)
+
+   - Calls to MWriteAsciiFile::AddContainer and MWriteAsciiFile::AddRule
+     must be replaced by calles to MWriteAsciiFile::AddColumn and
+     MWriteAsciiFile::AddColumns. Be carefull, the arguments have slightly
+     changed.
+
+   - Implemented generalized event-matrices (one row per event)
+     (MHMatrix)
+
+   - implemented the one dimensional composite probabilities
+     (MHCompProb, MCompProbCalc, comprob.C)
+
+   - implemented the Multidimensional Distances (Next Neighbours, Kernel)
+     (MMultiDimDistCalc, multidimdist.C, multidimdist2.C, MHMatrix)
+
+   - Added a camera display displaying the pixel numbers to the
+     event display gui.
+
+   - Added Monte Carlo Informations to event display gui
+
+   - Changed the camera display to display the pixel numbering
+   
+   - Added three buttons to the camera display to change the palette
+
+   - Added the number of used and core pixels after image cleaning
+     to MHillas
+
+   - Changed the algorithm used in MHillas according to TDAS 02-03
+
+   - Changed the Alpha range according to TDAS 02-03 to [-90°,90°]
+
+   - Changed the algorithm used in MHillasSrc according to TDAS 02-03
+
+   - Added fCosDeltaAlpha to MHillasSrc
+
+   - The numbers of photons used to calculate fConc and fConc1 in
+     MHillasExt are now scaled with the pixel size, so that one get
+     a four times smaller value for the bigger pixels in the outer ring.
+
+   - added new task to smooth the camera contents (MCameraSmooth)
+
+   - added possibility to use interpolated pixel values for blind pixels
+     instead of removing it completely from the analysis
+
+   - Implemented the possibility to save the whole eventloop with
+     its setup to a file. This information can be read and from
+     it you can (re)create a Macro. See MEvtLoop::Read, MEvtLoop::Write
+     and MEvtLoop::MakeMacro. If you find something not working, please
+     report - this stuff is still in a beta phase.
+
+   - MBlindPixelCalc set all Ceta-Tauri pixels to unused not only for the
+     file having crab starfield, but also for all following files - fixed
+
+   - MTaskList::PrintStatistics can now be instructud to print also the
+     title, too: use PrintStatistics(0, kTRUE)
+
+   - Changed the image cleaning so that pixels with to many 'used'
+     neighbors are left used (to get rid of 'holes' in events)
+
+   - Introduced more output to the camera displays
+
+   - Added an array of histograms (eg one hist per run), MHArray
+
+   - Added a _preliminary_ version of the reader for CT1 PreProc files
+     (MCT1ReadPreProc)
+
+   - Fixed the error calculation of MHMCollectionArea and MHMcIntRate
+     (thanks to Raquel)
+
+   - added the first energy estimator (MEnergyEstParam, estimate.C,
+     estfit.C) using a parametrization
+
+   - Added some new Monte Carlo paremeter containers used to store
+     setup information from the MC chain (MMcConfigRunHeader, 
+     MMcCorsikaRunHeader, MGeomPMT, MGeomMirror)
+
+
+
+ *** Version 0.7 (2002/04/30)
+ 
+   - added a bugfix to MCerPhotCalc. In older camera versions (<=40)
+     the pedestal mean value was saved incorrectly. For files from
+     this versions we substract 0.5 from the pedestal mean.
+     WARNING: This may effect your results, so don't wonder...
+
+   - First implementation of an algorithm using only triggered events
+     for the collection area calculation
+
+   - Ascii Output can now also be used for parameter containers which
+     doesn't overload MParCointainer::AsciiWrite
+
+   - The Ascii Output is now also capable of writing single data members
+     of one container
+
+   - You are now able to change the order of the values written to the
+     ascii file
+
+   - You can now specify a conversion factor for each data member written
+     to an ascii file. This may be usefull to change the units of the 
+     data member (eg. degrees instead of millimeters in case of the 
+     hillas parameters)
+
+   - Replaced old MHillas by a new structure which allows you to extend
+     the parameters stored in MHillas very easily:
+     see MHillas and MHillasExt
+
+   - Added classes to handle source dependancy of image parameters:
+     see MHillasSrc
+
+   - Added container (MBinning) to have a standard input for the binning
+     in different histograms (eg. the Energy bins should be the same in
+     all histograms)
+
+   - Changed Hillas histograms from mm to deg
+
+   - Added the flexible binning to the hillas histograms
+
+   - Added a filter for the alpha parameter (MFAlpha)
+
+   - It is now possible to write single data members of a class object to
+     an output stream instead of the whole container only
+
+   - Added a generalized filter for a data member:
+     MFDataMember filter("MHillas.fWidth", '<', 0.5);
+
+   - Added a generalized Filter parser for more difficult filter rules
+     MF filter("MHillas.fWidth<0.5 && MHillas.fLength>0.5");
+
+   - Added new Monte Carlo histograms:
+     MHMcEnergyImpact and MHMcEfficiency
+
+   - Added many new histograms needed for the flux calculation.
+
+   - Added a generalized histograms which can fill and show up to three
+     data members in either a one-, two- or three-dimensional histogram, eg:
+     MH3 mh3("MHillas.fWidth", "MHillas.fLength");
+
+   - Added:
+       * calculation of <Theta> as a function of Theta (MHThetabarTheta)
+       * calculation of <Theta> as a function of time (MHThetabarTime)
+     they are needed in the flux calculation in 
+     order to select for a given bin in Theta (or time) the appropriate 
+     effective collection area, which is assumed to be given as a function 
+     of Theta and the true energy
+
+   - Added calculation of the migration matrix in the energy 
+     (MHMcEnergyMigration):
+     the migration matrix describes the migration from the true (E_true)
+     to the estimated energy (E_est); it is needed to determine the
+     distribution of E_true from the measured distribution of E_est 
+     by unfolding
+
+   - changed the color palette in the camera display to DeapSea.
+
+
+
+ *** Version 0.6 (2002/01/15)
+
+   - Introduce the option of disable pixels (MBlindPixels and
+     MBlindPixelCalc) for the analysis (eg MHillasCalc) to be 
+     able to deal with Star Field NSB.
+
+   - Fixed a bug in the pedestals substraction
+
+   - Introduced verbosity levels
+
+   - Introduced a task (MReadMarsFile) which reads the RunHeader tree, too.
+
+   - Fixed several bugs in MFTriggerLvl1 which caused to filter not to
+     work correctly (thanks to Abelardo)
+
+   - Introduced correct treatment of the diffuse Night Sky Background 
+     and NSB (MMcPedestalNSB)
+
+   - Corrected treatment of the electronic noise (MMcPedestalCopy)
+
+   - Introduced MMcRunHeaders which contains monte carlo run informations
+
+   - Added a 'Print'-Task (MPrint) which calls the Print function
+     of a parameter container for each event
+
+   - Removed MHtml (was replaced by THtml of root 3.02) in dohtml.C
+
+   - changes to be more efficient with root 3.02/06
+
+   - root 3.02/06 fixes:
+     + the memory leak when reading MRawEvtData
+     + loosing more time than necessary to update the progress bar
+
+   - MWriteAsciiFile is now capable of writing more than one container
+     in a line. For example: To be able to write Monte Carlo and 
+     Hillas values (energy and alpha) in one line.
+
+
+
+ *** Version 0.5 (2001/11/06)
+
+   - Added new GUI functionality (Analysis)
+
+   - Added a camera display to be able to display events in the camera
+     together with the calculated hillas ellipse
+
+   - Added a 'Clone'-Task (MClone) which can clone a parameter container
+     object at any state of the analysis, so that the output are several
+     states
+
+   - Fixed a bug in the collection area error calculation 
+     (Thanks to Ciro and Abelardo)
+
+   - Fixed a bug which causes merpp to crash in some environments
+
+   - Implemented auto enabling scheme for Branches to speed up reading
+     a lot (see MReadTree and MTask)
+
+   - Fixed a bug in the Histogram classes which caused histograms to
+     be written to a file by MWriteRootFile without request
+
+   - changed the object I/O from the old stylish root I/O to the new
+     'auto evolution scheme' This was done only for classes which are not
+     yet used in Monte Carlo files, so that these files are still readable.
+
+   - Added support for a progress bar in MEvtLoop and MReadTree 
+     (see the Analysis Window in Mars for an example)
+
+   - Fixed a bug in the package creation which disturbed the conversion
+     between a mars version unpacked from a tar file and the repository.
+
+   - Changed the code to writer merpped (converted into root format)
+     raw files, to get faster (around 10%)
+
+
+
+ *** Version 0.4 (2001/09/20)
+
+    - This release is made to compile on a root version >= 3.00
+
+    - Fixed a bug which causes MReadTree to read the first file only
+
+    - Added a task to compute the trigger rate (MMcTriggerRateCalc)
+ 
+    - Added a task to write a container to an Ascii file (MWriteAsciiFile)
+
+    - Added a task to write several container to a root file (MWriteRootFile)
+    
+    - Added calculation of the Enegry Threshold (MMcThresholdCalc)
+    
+    - Added calculation of the collection area (MMcCollectionAreaCalc)
+    
+    - fixed some bugs in the Hillas calculation
+    
+    - added filters to be able to control the task execution dependent on
+      a parameter (for example: the number of level 1 triggers in a MC-file)
+
+
+
+ *** Version 0.3 (2001/04/23)
+	
+    - Many demo macros added    
+  
+    - MCT1ReadAscii is now able to handle more than one file (s. ::AddFile)
+    
+    - Hillas Calculation added
+    
+    - Standard image cleaning available
+    
+    - MReadTree is now able to handle more than one file
+      (Remark: of the same structure)
+    
+    - Now we are able to display events in a first version of the
+      Camera event display. To do this we must run the macro 
+      "macros/readCT1.C" to read data from CT1. 
+
+
+
+ *** Version 0.2 (2001/01/24)
+ 
+    - First Implementation of a Gui to read the raw data. Start the
+      gui with the command mars. 
+
+
+
+ *** Version 0.1 (2000/12/20)
+ 
+    - First official release 0.1
+    
+    - Changes:
+    
+       + changed calling style of MRawPixelIterator from do...while to 
+         while-loop
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/CT1Hillas.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/CT1Hillas.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/CT1Hillas.C	(revision 1638)
@@ -0,0 +1,178 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void CT1Hillas(const char *filename)
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // 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);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamCT1 geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // 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")
+    source.SetXY(0, 0);
+    plist.AddToList(&source);
+
+    //
+    // Now setup the tasks and tasklist:
+    //
+    //  1) read in the data from a ct1 ascii file   MCTReadAscii
+    //  2) clean the image                          MImgCleanStd
+    //  3) calculate hillas                         MHillasCalc
+    //  4) fill the hillas into the histograms      MFillHHillas
+    //
+    MCT1ReadAscii read("../data/CT1_97_on1.dat");
+    //read.AddFile("../data/CT1_97_off1.dat");
+
+    MMcPedestalCopy pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    MCerPhotCalc ncalc;
+    //
+    //  Alternative photon calculation:
+    //  Example: use only 2nd to 6th FADC slices for photon calculation:
+    //
+    //    MCerPhotCalc2 ncalc;
+    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    //    TArrayF w(15,x);
+    //    ncalc.SetWeights(w);
+    //
+
+    MCameraSmooth   smooth;
+    MImgCleanStd    clean;
+    MBlindPixelCalc blind;
+    //
+    // Instead of unmapping the pixels you can also
+    //
+    // blind.SetUseInterpolation();
+    // blind.SetUseCetralPixel();
+    //
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1("Source",  "HillasSource");
+
+    //
+    // Uncomment this two line if you want to use MHillasExt instead
+    // of MHillas
+    //
+    //MHillasExt hext;
+    //plist.AddToList(&hext);
+
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "HillasSource");
+    MFillH hfill5("HistSource [MHHillasSrc]", "HillasSource");
+
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHStarMap");
+    write.AddContainer("MHHillas");
+    write.AddContainer("MHHillasExt");
+    write.AddContainer("HistSource");
+    write.AddContainer("HistExtSource");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    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();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/MagicHillas.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/MagicHillas.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/MagicHillas.C	(revision 1638)
@@ -0,0 +1,176 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void MagicHillas(const char *filename="~/data/Gamma_20_N*.root")
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // 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);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // 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();
+
+    MMcPedestalCopy pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    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};
+    //    TArrayF w(15,x);
+    //    ncalc.SetWeights(w);
+    //
+
+    MImgCleanStd    clean;
+    MBlindPixelCalc blind;
+    //
+    // Instead of unmapping the pixels you can also
+    //
+    // blind.SetUseInterpolation();
+    // blind.SetUseCetralPixel();
+    //
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1;
+
+    //
+    // To use MHillasExt instead of MHillas
+    //
+    MHillasExt hext;
+    plist.AddToList(&hext);
+
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
+    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
+
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHStarMap");
+    write.AddContainer("MHHillas");
+    write.AddContainer("MHHillasExt");
+    write.AddContainer("HistSource");
+    write.AddContainer("HistExtSource");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    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();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/Pedestals_Stability.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/Pedestals_Stability.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/Pedestals_Stability.C	(revision 1638)
@@ -0,0 +1,147 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): ???
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+ void Pedestals_Stability()
+{
+    char *files[11] = {"ped_stab/stab1.root",
+                      "ped_stab/stab2.root",
+                      "ped_stab/stab3.root",
+                      "ped_stab/stab4.root",
+                      "ped_stab/stab5.root",
+                      "ped_stab/stab6.root",
+                      "ped_stab/stab7.root",
+                      "ped_stab/stab8.root",
+                      "ped_stab/stab9.root",
+                      "ped_stab/stab10.root",
+                      "ped_stab/stab11.root"};
+
+    for (Int_t stab_f=0; stab_f<11; stab_f++){
+
+      MParList plist;
+
+      MPedestalCam  pedest;
+      MTaskList     tlist;
+
+      plist->AddToList(&pedest);
+      plist->AddToList(&tlist);
+
+      MReadTree read("Events", files[stab_f] );
+      MPedCalcPedRun pedcalc;
+
+      tlist.AddToList(&read);
+      tlist.AddToList(&pedcalc);
+
+      MEvtLoop evtloop;
+      evtloop.SetParList(&plist);
+
+      if (!evtloop.PreProcess())
+        return;
+
+      const UInt_t NumEnt = read.GetEntries();
+
+      Float_t pedmeantohist[8][NumEnt];
+      Float_t pedMean[8][11];
+      Float_t pedRMS[8][11];
+
+      Int_t Ecount = 0;
+
+      while (read.Process())
+      {
+
+        pedcalc.Process();
+
+        for (Int_t i=0; i<8; i++){
+          pedmeantohist[i][Ecount] = pedest[i].GetMean();
+        }
+
+	Ecount++;
+
+      } 
+
+      evtloop.PostProcess();
+
+
+    // Create Histogram to get Mean & RMS per 100 pixel events
+ 
+      gROOT->Reset();
+
+      PixelHist = new TH1F("Pixel Hist","Pixel x - Ped hist",100,0,1000);
+
+      cout << files[stab_f] << endl;
+
+      for (Int_t pix=0; pix<8 ; pix++){
+         for (Int_t ev=0; ev<NumEnt; ev++){
+           PixelHist->Fill(pedmeantohist[pix][ev]);
+        }
+     
+	 pedMean[pix][stab_f] = PixelHist->GetMean();
+	 pedRMS[pix][stab_f] = PixelHist->GetRMS();
+
+	 //        cout << "Px" << pix << " - Ped = " 
+	 //	     << PixelHist->GetMean() << " +/- " << PixelHist->GetRMS() << endl;
+
+        PixelHist->Reset();     
+
+      }
+    }
+
+
+    // Plot the results
+
+    // Create the Canvas
+
+    c1 = new TCanvas("c1","Pedestals for all pixels",605,0,600,650);
+    c1->Divide(3,3);
+
+    for (Int_t pix=0; pix<8 ; pix++){
+
+      Float_t Time[11] = {0,51,117,170,229,341,409,475,533,585,643};
+      Float_t Err_Time[11];
+
+      Float_t PedestMeantoGraph[11];
+      Float_t PedestRMStoGraph[11];
+
+      char Title[40];
+
+       for (Int_t ev=0; ev<11; ev++){
+	 PedestMeantoGraph[ev] = pedMean[pix][ev];
+	 PedestRMStoGraph[ev] = pedRMS[pix][ev];
+       }
+       c1->cd(pix+1);
+       gr = new TGraphErrors(11,Time,PedestMeantoGraph,Err_Time,PedestRMStoGraph);
+
+       sprintf(Title,"Pedestal Stability - Pixel %d",pix+1);
+       gr->SetMarkerStyle(20);
+       gr->SetMarkerSize(0.7);
+       gr->SetTitle(Title);
+       gr->Draw("ALP");
+       gr->GetXaxis()->SetTitle("Time (min)");
+       gr->GetYaxis()->SetTitle("ADC Counts");
+       gr->Draw("ALP");
+    
+    }
+    c1->Update();
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/collarea.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/collarea.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/collarea.C	(revision 1638)
@@ -0,0 +1,67 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+void collarea(char *filename = "data/camera.root")
+{ 
+    //
+    // first we have to create our empty lists
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    parlist.AddToList(&tasklist);
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can fill the efficiency histograms
+    //
+    MReadMarsFile reader("Events", filename);
+    MMcCollectionAreaCalc effi;
+
+    tasklist.AddToList(&reader);
+    tasklist.AddToList(&effi);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // Start to loop over all events
+    //
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics();
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayd
+    //
+    parlist.FindObject("MHMcCollectionArea")->DrawClone();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/comprob.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/comprob.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/comprob.C	(revision 1638)
@@ -0,0 +1,129 @@
+/* ======================================================================== *\
+ !
+ ! *
+ ! * 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.
+ ! *
+ !
+ !   macro comprob.C
+ !
+ !   Author(s): Abelardo Moralejo
+ !   Author(s): Thomas Bretz, 2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+ !
+ !   Copyright: MAGIC Software Development, 2000-2002
+ !
+ !
+ \* ======================================================================== */
+
+// -------------------------------------------------------------------------
+//
+//  This macro demonstrates one way of gamma hadron separation using the
+//  composite probability method. To use it you need a star-file (which is
+//  a file ouput by the star.C macro containing image parameters)
+//
+void comprob()
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    // Create task list and add it to the parameter list:
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    // First task in list: read the star file (reference data)
+    MReadMarsFile read("Events", "star.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    //
+    // Task to do the composite analysis of Hillas parameters:
+    // Add(rule, number of bins, lower limit, upper limit)
+    // For the meaning of the rule see MDataChain
+    //
+    MHCompProb compprob(500);
+    compprob.Add("MHillas.fWidth",              500,    0, 160);
+    compprob.Add("MHillas.fLength",             500,    0, 300);
+    compprob.Add("abs(MHillas.fAsym)",          500,    0, 400);
+    compprob.Add("MHillasSrc.fDist",            500,    0, 400);
+    compprob.Add("abs(MHillasSrc.fHeadTail)",   500,    0, 400);
+    compprob.Add("abs(MHillas.fM3Long)",        500,    0, 300);
+    compprob.Add("abs(MHillas.fM3Trans)",       500,    0, 150);
+    compprob.Add("MHillas.fConc1",              500,    0, 0.6);
+    compprob.Add("MHillas.fConc",               500,    0, 0.9);
+    compprob.Add("log10(MHillas.fSize)",        500,    0,   5);
+
+    plist.AddToList(&compprob);
+
+    MFillH fill(&compprob, "MMcEvt");
+
+    // Use this if you want to do it for a fixed energy range:
+    /*
+     MF filter("MMcEvt.fEnergy < 100");
+     fill->SetFilter(&filter);
+     tlist.AddToList(&filter);
+     */
+
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    // Loop over all data to fill the "normal" histograms:
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    gLog.SetDebugLevel(2);
+
+    // Loop to fill the variable bin histograms:
+    read.SetEventNum(0);
+    if (!evtloop.Eventloop())
+        return;
+
+    // ------------------------------------------------------------------
+
+    // Create task list and replace the old task list with the new one
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    // First task in list: read star file (test data)
+    MReadMarsFile read2("Events", "star2.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    // create task to calculate composite probabilities
+    MCompProbCalc calc;
+    tlist2.AddToList(&calc);
+
+    // fill probabilities (hadroness) into histogram
+    MFillH fill2("MHHadronness");
+    tlist2.AddToList(&fill2);
+
+    // Loop to fill the hadronness histograms:
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // Display the hadroness histograms and print some informations on
+    // the console window
+    //
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/dohtml.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/dohtml.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/dohtml.C	(revision 1638)
@@ -0,0 +1,81 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+
+void dohtml()
+{
+    //
+    //  don't forget that the shared object must have been loaded
+    //
+
+    //
+    //   create the html document class
+    //
+    THtml html;
+
+    TString sourcedir;
+    sourcedir +== ".:";
+    sourcedir += "manalysis:";
+    sourcedir += "mbase:";
+    sourcedir += "mdata:";
+    sourcedir += "mdatacheck:";
+    sourcedir += "meventdisp:";
+    sourcedir += "mfileio:";
+    sourcedir += "mfilter:";
+    sourcedir += "mgeom:";
+    sourcedir += "mgui:";
+    sourcedir += "mhist:";
+    sourcedir += "mmain:";
+    sourcedir += "mmc:";
+    sourcedir += "mmontecarlo:";
+    sourcedir += "mraw:";
+    sourcedir += "mtools";
+
+    html.SetSourceDir(sourcedir);
+    html.SetOutputDir("htmldoc");
+
+    html.MakeAll(kTRUE);
+
+    html.SetSourceDir("macros");
+    html.Convert("merpp.C",         "MARS - Merging and Preprocessing");
+    html.Convert("readraw.C",       "MARS - How To Read A Raw");
+    html.Convert("rootlogon.C",     "MARS - rootlogon.C");
+    html.Convert("readCT1.C",       "MARS - Read and display CT1 Events");
+    html.Convert("readMagic.C",     "MARS - Read and display Magic Events");
+    html.Convert("CT1Hillas.C",     "MARS - Calculate CT1 Hillas");
+    html.Convert("MagicHillas.C",   "MARS - Calculate Magic Hillas");
+    html.Convert("collarea.C",      "MARS - Calculate Collection Area from a MC root file");
+    html.Convert("threshold.C",     "MARS - Calculate Energy Threshold from a MC root file");
+    html.Convert("trigrate.C",      "MARS - Calculate Trigger Rate from a MC root file");
+    html.Convert("star.C",          "MARS - (St)andard (A)nalysis and (R)econstruction");
+    html.Convert("starplot.C",      "MARS - Plot parameters from file created with star.C");
+    html.Convert("comprob.C",       "MARS - Calculation of composite probabilities for G/H-Seperation");
+    html.Convert("multidimdist.C",  "MARS - Calculation of multidimensional distances for G/H-Seperation");
+    html.Convert("multidimdist2.C", "MARS - Calculation of multidimensional distances for G/H-Seperation");
+    html.Convert("estimate.C",      "MARS - Shows results from the energy estimation");
+    html.Convert("estfit.C",        "MARS - Fits the coefficients of the energy estimator MEnergyEstParam");
+    html.Convert("plot.C",          "MARS - Plots 1D mars histogram");
+    html.Convert("plot2.C",         "MARS - Plots a 2D mars histogram");
+    html.Convert("starplot.C",      "MARS - Plots data from a STAR-file into a mars histogram");
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/estfit.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/estfit.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/estfit.C	(revision 1638)
@@ -0,0 +1,331 @@
+#include <fstream.h>
+
+#include "MTask.h"
+#include "MParList.h"
+
+#include "MDataChain.h"
+
+class MChisqEval : public MTask
+{
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
+    Double_t fChisq; //! Evaluated chi square
+
+    MData   *fData0; // Data Member one (monte carlo data or chisq function)
+    MData   *fData1; // Data Member two (measured data)
+
+    // --------------------------------------------------------------------------
+    //
+    // Implementation of SavePrimitive. Used to write the call to a constructor
+    // to a macro. In the original root implementation it is used to write
+    // gui elements to a macro-file.
+    //
+    void StreamPrimitive(ofstream &out) const
+    {
+        out << "   MChisqEval " << GetUniqueName() << ";";
+        if (fData0)
+            out << "   " << GetUniqueName() << ".SetY1(\"" << fData0->GetRule() << "\");" << endl;
+        if (fData1)
+            out << "   " << GetUniqueName() << ".SetY1(\"" << fData1->GetRule() << "\");" << endl;
+    }
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    MChisqEval(const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+    {
+        fName  = name  ? name  : gsDefName.Data();
+        fTitle = title ? title : gsDefTitle.Data();
+    }
+
+    MChisqEval(MData *y1, const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+    {
+        fName  = name  ? name  : gsDefName.Data();
+        fTitle = title ? title : gsDefTitle.Data();
+        SetY1(y1);
+    }
+    MChisqEval(MData *y1, MData *y2, const char *name=NULL, const char *title=NULL) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+    {
+        fName  = name  ? name  : gsDefName.Data();
+        fTitle = title ? title : gsDefTitle.Data();
+        SetY1(y1);
+        SetY2(y2);
+    }
+    ~MChisqEval()
+    {
+        if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner)))
+            delete fData0;
+
+        if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner)))
+            delete fData1;
+    }
+
+    void SetY1(MData *data)
+    {
+        // Set MC value
+        if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner)))
+            delete fData0;
+        fData0 = data;
+        fData0->SetBit(kCanDelete);
+        AddToBranchList(fData0->GetDataMember());
+    }
+    void SetY2(MData *data)
+    {
+        // Set measured/estimated value
+        if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner)))
+            delete fData1;
+        fData1 = data;
+        fData1->SetBit(kCanDelete);
+        AddToBranchList(fData1->GetDataMember());
+    }
+    void SetY1(const TString data) { SetY1(new MDataChain(data)); }
+    void SetY2(const TString data) { SetY2(new MDataChain(data)); }
+
+    void SetOwner(Bool_t o=kTRUE) { o ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Bool_t PreProcess(MParList *plist)
+    {
+        fChisq = 0;
+
+        if (!fData0)
+            return kFALSE;
+
+        if (!fData0->PreProcess(plist))
+            return kFALSE;
+
+        if (fData1)
+            if (!fData1->PreProcess(plist))
+                return kFALSE;
+
+        return kTRUE;
+    }
+
+    Bool_t Process()
+    {
+        const Double_t y1 = fData0->GetValue();
+        const Double_t y2 = fData1 ? fData1->GetValue() : 0;
+
+        const Double_t dy  = y2-y1;
+        const Double_t err = fData1 ? y1*y1 : 1;
+
+        fChisq += dy*dy/err;
+        return kTRUE;
+    }
+
+    Bool_t PostProcess()
+    {
+        fChisq /= GetNumExecutions();
+        return kTRUE;
+    }
+
+    Double_t GetChisq() const { return fChisq; }
+ 
+    ClassDef(MChisqEval, 0)
+};
+
+ClassImp(MChisqEval);
+
+const TString MChisqEval::gsDefName  = "MChisqEval";
+const TString MChisqEval::gsDefTitle = "Evaluate a chisq";
+
+// --------------------------------------------------------------------------
+
+#include <TMinuit.h>
+
+#include "MEvtLoop.h"
+#include "MTaskList.h"
+#include "MEnergyEstParam.h"
+
+void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    MEvtLoop &evtloop = *(MEvtLoop*)gMinuit->GetObjectFit();
+
+    MTaskList &tlist  = *(MTaskList*)evtloop.GetParList()->FindObject("MTaskList"); //GetTaskList();
+
+    MChisqEval      &eval = *(MChisqEval*)     tlist.FindObject("MChisqEval");
+    MEnergyEstParam &eest = *(MEnergyEstParam*)tlist.FindObject("MEnergyEstParam");
+
+    eest.SetCoeff(TArrayD(eest.GetNumCoeff(), par));
+
+    evtloop.Eventloop();
+
+    f = eval.GetChisq();
+}
+
+// --------------------------------------------------------------------------
+#include <TStopwatch.h>
+
+#include "MHMatrix.h"
+#include "MEnergyEst.h"
+
+#include "MDataMember.h"
+#include "MDataElement.h"
+
+#include "MReadTree.h"
+#include "MMatrixLoop.h"
+
+void estfit(Bool_t evalenergy=kFALSE)
+{
+    //
+    // Fill events into a MHMatrix
+    //
+    MParList parlist;
+    MHMatrix matrix;
+
+    Int_t col = matrix.AddColumn(evalenergy?"MMcEvt.fEnergy":"MMcEvt.fImpact");
+
+    MEnergyEstParam eest;
+    eest.Add("MHillasSrc");
+    eest.InitMapping(&matrix);
+
+    MReadTree read("Events", "gammas.root");
+    read.DisableAutoScheme();
+
+    if (!matrix.Fill(&parlist, &read))
+        return;
+
+    //
+    // Setup the tasklist used to evaluate the needed chisq
+    //
+    MTaskList tasklist;
+    parlist.AddToList(&tasklist);
+
+    MMatrixLoop loop(&matrix);
+
+    MChisqEval eval;
+    eval.SetY1(new MDataElement(&matrix, col));
+    eval.SetY2(new MDataMember(evalenergy ? "MEnergyEst.fEnergy" : "MEnergyEst.fImpact"));
+    eval.SetOwner();
+
+    tasklist.AddToList(&loop);
+    tasklist.AddToList(&eest);
+    tasklist.AddToList(&eval);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&parlist);
+
+    //
+    // Be carefull: This is not thread safe
+    //
+    TMinuit minuit(12);
+    minuit.SetFCN(fcn);
+
+    // Ready for: minuit.mnexcm("SET ERR", arglist, 1, ierflg)
+    if (minuit.SetErrorDef(1))
+    {
+        cout << "SetErrorDef failed." << endl;
+        return;
+    }
+
+    //
+    // Set initial values
+    //
+    TArrayD fA(5);
+    fA[0] =  -2539; // [cm]
+    fA[1] =    900; // [cm]
+    fA[2] =   17.5; // [cm]
+    fA[3] =  1;//    4;
+    fA[4] =   58.3;
+
+    TArrayD fB(7);
+    fB[0] =    -8.64; // [GeV]
+    fB[1] =   -0.069; // [GeV]
+    fB[2] =  0.00066; // [GeV]
+    fB[3] =    0.033; // [GeV]
+    fB[4] = 0.000226; // [GeV]
+    fB[5] =  4.14e-8; // [GeV]
+    fB[6] =    -0.06;
+
+    // Set starting values and step sizes for parameters
+    for (Int_t i=0; i<fA.GetSize(); i++)
+    {
+        TString name = "fA[";
+        name += i;
+        name += "]";
+        Double_t vinit = fA[i];
+        Double_t step  = fabs(fA[i]/3);
+
+        Double_t limlo = 0; // limlo=limup=0: no limits
+        Double_t limup = 0; 
+
+        Bool_t rc = minuit.DefineParameter(i, name, vinit, step, limlo, limup);
+        if (evalenergy)
+            minuit.FixParameter(i);
+
+        if (!rc)
+            continue;
+
+        cout << "Error in defining parameter #" << i << endl;
+        return;
+    }
+
+    for (Int_t i=0; i<fB.GetSize(); i++)
+    {
+        TString name = "fB[";
+        name += i;
+        name += "]";
+        Double_t vinit = fB[i];
+        Double_t step  = fabs(fB[i]/3);
+
+        Double_t limlo = 0; // limlo=limup=0: no limits
+        Double_t limup = 0;
+
+        Bool_t rc = minuit.DefineParameter(i+fA.GetSize(), name, vinit, step, limlo, limup);
+        if (!evalenergy)
+            minuit.FixParameter(i+fA.GetSize());
+
+        if (!rc)
+            continue;
+
+        cout << "Error in defining parameter #" << i+fA.GetSize() << endl;
+        return;
+    }
+
+    //
+    // Setup globals used in FCN
+    //
+    minuit.SetObjectFit(&evtloop);
+
+    TStopwatch clock;
+    clock.Start();
+
+    // Now ready for minimization step: minuit.mnexcm("MIGRAD", arglist, 1, ierflg)
+    gLog.SetNullOutput(kTRUE);
+    Bool_t rc = minuit.Migrad();
+    gLog.SetNullOutput(kFALSE);
+
+    if (rc)
+    {
+        cout << "Migrad failed." << endl;
+        return;
+    }
+
+    cout << endl;
+    clock.Stop();
+    clock.Print();
+    cout << endl;
+
+    for (Int_t i=(evalenergy?fA.GetSize():0); i<(evalenergy?fA.GetSize()+fB.GetSize():fA.GetSize()); i++)
+    {
+        Double_t val;
+        Double_t er;
+
+        if (!minuit.GetParameter(i, val, er))
+        {
+            cout << "Error getting parameter #" << i << endl;
+            return;
+        }
+
+        cout << i << ":  " << val << "  +-  " << er << endl;
+    }
+
+    /*
+     // Print results
+     Double_t amin, edm, errdef;
+     Int_t nvpar, nparx, icstat;
+     minuit.mnstat(amin, edm, errdef, nvpar, nparx, icstat);
+     minuit.mnprin(3, amin);
+     */
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/estimate.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/estimate.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/estimate.C	(revision 1638)
@@ -0,0 +1,245 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 et al,  09/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void estimate()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // 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:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    /*
+     read.AddFile("star.root");
+     read.AddFile("star2.root");
+     */
+    read.AddFile("gammas.root");
+
+    // Create a filter for the gamma events
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+
+    MTaskList tlist2;
+    tlist2.SetFilter(&fgamma);
+
+    MEnergyEstParam eest;
+    eest.Add("MHillasSrc");
+
+    //
+    // Use this to change the binnign of the histograms to CT1-style
+    //
+    Bool_t usect1 = kTRUE;
+
+    //
+    // Here you set up the coefficients of the parametrization
+    // (MEnergyEstParam)
+    //
+    TArrayD fA(5);
+    fA[0] =  -2539; // [cm]
+    fA[1] =    900; // [cm]
+    fA[2] =   17.5; // [cm]
+    fA[3] =      4;
+    fA[4] =   58.3;
+
+    TArrayD fB(7);
+    fB[0] =    -8.64; // [GeV]
+    fB[1] =   -0.069; // [GeV]
+    fB[2] =  0.00066; // [GeV]
+    fB[3] =    0.033; // [GeV]
+    fB[4] = 0.000226; // [GeV]
+    fB[5] =  4.14e-8; // [GeV]
+    fB[6] =    -0.06;
+
+    eest.SetCoeffA(fA);
+    eest.SetCoeffB(fB);
+
+    MH3 mh3e("MMcEvt.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i("MMcEvt.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo("MMcEvt.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io("MMcEvt.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mh3e2("MEnergyEst.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i2("MEnergyEst.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo2("MEnergyEst.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io2("MEnergyEst.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mhe("MMcEvt.fEnergy",     "MEnergyEst.fEnergy");
+    MH3 mhi("MMcEvt.fImpact/100", "MEnergyEst.fImpact/100");
+
+    mh3e.SetName("HistEnergy");
+    mh3i.SetName("HistImpact");
+    mh3eo.SetName("HistEnergyOffset");
+    mh3io.SetName("HistImpactOffset");
+
+    mh3e2.SetName("HistEnergy");
+    mh3i2.SetName("HistImpact");
+    mh3eo2.SetName("HistEnergyOffset");
+    mh3io2.SetName("HistImpactOffset");
+
+    mhe.SetName("HistEE");
+    mhi.SetName("HistII");
+
+    MFillH hfille(&mh3e);
+    MFillH hfilli(&mh3i);
+    MFillH hfilleo(&mh3eo);
+    MFillH hfillio(&mh3io);
+
+    MFillH hfille2(&mh3e2);
+    MFillH hfilli2(&mh3i2);
+    MFillH hfilleo2(&mh3eo2);
+    MFillH hfillio2(&mh3io2);
+
+    MFillH hfillee(&mhe);
+    MFillH hfillii(&mhi);
+
+    MBinning binsex("BinningHistEnergyX");
+    MBinning binsey("BinningHistEnergyY");
+    MBinning binsix("BinningHistImpactX");
+    MBinning binsiy("BinningHistImpactY");
+    MBinning binseox("BinningHistEnergyOffsetX");
+    MBinning binseoy("BinningHistEnergyOffsetY");
+    MBinning binsiox("BinningHistImpactOffsetX");
+    MBinning binsioy("BinningHistImpactOffsetY");
+    MBinning binseex("BinningHistEEX");
+    MBinning binsiix("BinningHistIIX");
+    MBinning binseey("BinningHistEEY");
+    MBinning binsiiy("BinningHistIIY");
+
+    binsex.SetEdgesLog(50, usect1 ? 300: 10, usect1 ? 50000 : 1e4);
+    binsey.SetEdges(50, 0, 1.75);
+    binseox.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 1e4);
+    binseoy.SetEdges(50, -1.75, 1.75);
+
+    binsix.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsiy.SetEdges(50, 0, 1.75);
+    binsiox.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsioy.SetEdges(50, -1.75, 1.75);
+
+    binseex.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 15e3);
+    binseey.SetEdgesLog(50, usect1 ? 300 : 1,  usect1 ? 50000 : 2e3);
+    binsiix.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsiiy.SetEdges(50, 0, usect1 ? 450 : 150);
+
+    plist.AddToList(&binsex);
+    plist.AddToList(&binsey);
+    plist.AddToList(&binsix);
+    plist.AddToList(&binsiy);
+    plist.AddToList(&binseox);
+    plist.AddToList(&binseoy);
+    plist.AddToList(&binsiox);
+    plist.AddToList(&binsioy);
+    plist.AddToList(&binseex);
+    plist.AddToList(&binseey);
+    plist.AddToList(&binsiix);
+    plist.AddToList(&binsiiy);
+
+    //
+    //  Setup tasklists
+    //
+    tlist.AddToList(&read);
+    tlist.AddToList(&fgamma);
+    tlist.AddToList(&tlist2);
+
+    tlist2.AddToList(&eest);
+    tlist2.AddToList(&hfille);
+    tlist2.AddToList(&hfilli);
+    tlist2.AddToList(&hfilleo);
+    tlist2.AddToList(&hfillio);
+
+    tlist2.AddToList(&hfille2);
+    tlist2.AddToList(&hfilli2);
+    tlist2.AddToList(&hfilleo2);
+    tlist2.AddToList(&hfillio2);
+
+    tlist2.AddToList(&hfillee);
+    tlist2.AddToList(&hfillii);
+
+    /*
+     MPrint p("MEnergyEst");
+     tlist2.AddToList(&p);
+     */
+
+    //
+    // Create and setup the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    const TString text = "\\sqrt{<y>}=%.0f%%";
+
+    TCanvas *c=new TCanvas("Est1", "Estimates vs. E_{true}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i.DrawClone("PROFXnonew");
+    TLatex *t = new TLatex(180, 1.6, Form(text, sqrt(mh3i.GetHist().GetMean(2))*100));
+    t->Draw();
+    c->cd(2);
+    mh3e.DrawClone("PROFXnonew");
+    t = new TLatex(2.7, 1.6, Form(text, sqrt(mh3e.GetHist().GetMean(2))*100));
+    t->Draw();
+    c->cd(3);
+    mh3io.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo.DrawClone("PROFXnonew");
+
+    c=new TCanvas("Est2", "Estimates vs. E_{est}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i2.DrawClone("PROFXnonew");
+    c->cd(2);
+    mh3e2.DrawClone("PROFXnonew");
+    c->cd(3);
+    mh3io2.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo2.DrawClone("PROFXnonew");
+
+    mhe.DrawClone("PROFX");
+    mhi.DrawClone("PROFX");
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/flux.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/flux.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/flux.C	(revision 1638)
@@ -0,0 +1,625 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 4/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// This macro calculates photon fluxes as a function of                     //
+//    - energy and time                                                     //
+//    - energy and Theta                                                    //
+//                                                                          //
+// It is assumed that the data have been taken in the wobble mode.          //
+// This means that there is only one set of data, from which both           //
+// 'on' and 'off' data are constructed.                                     //
+//                                                                          //
+// Necessary input from MC :                                                //
+//    - migration matrix (E_est, E_true) as a functioin of Theta            //
+//    - effective collection areas as a function of energy and Theta        //
+//                                                                          //
+//                                                                          // 
+// The input from MC has to refer to the wobble mode too.                   // 
+//                                                                          //
+// The macro includes :                                                     // 
+//    - the calculation of Hillas parameters                                //
+//    - the calculation of the effective on time                            //
+//    - the unfolding of the distributions in the estimated energy E_est    //
+//                                                                          //
+// For testing purposes (as long as no real data, no energy estimator,      //
+// no migration matrices and no effective collection areas are available)   //
+//    - event times are generated (according to a Poissonian with dead time)//
+//    - a dummy energy estimator is provided                                //
+//    - migration matrices are generated                                    //
+//    - dummy effective collection areas are used                           //
+//                                                                          // 
+//////////////////////////////////////////////////////////////////////////////
+void flux()
+{ 
+    //--------------------------------------------------------------
+    // empty lists of parameter containers and tasks
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    //--------------------------------------------------------------
+    // Geometry information of the MAGIC camera
+    //
+    MGeomCamMagic geomcam;
+
+    //--------------------------------------------------------------
+    // Define the two source positions
+    //
+    MSrcPosCam source("Source");
+    MSrcPosCam antisrc("AntiSource");
+    source.SetXY(0, 0);
+    antisrc.SetXY(+240, 0);
+
+    //--------------------------------------------------------------
+    // Setup the binning for the histograms
+    //
+
+    //...............................................................
+    // These are NOT the binnings for the flux determination
+
+    MBinning binswidth("BinningWidth");
+    binswidth.SetEdges(100, 0, 0.5);   // 100 bins from 0 to 0.5 deg
+
+    MBinning binslength("BinningLength");
+    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+
+    MBinning binscamera("BinningCamera");
+    binscamera.SetEdges(90, -2.25, 2.25);  // 90 bins from -2.25 to 2.25 deg
+
+    MBinning binsdist("BinningDist");
+    binsdist.SetEdges(90, 0, 2.25);    // 90 bins from 0 to 2.25 deg
+
+    MBinning binsalpha("BinningAlpha");
+    binsalpha.SetEdges(100, -100, 100);
+
+    MBinning binsasym("BinningAsym");
+    binsasym.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    MBinning binsasymn("BinningAsymn");
+    binsasymn.SetEdges(100, -0.005, 0.005);   // 100 bins from -0.005 to 0.005 deg
+
+    MBinning binsm3long("BinningM3Long");
+    binsm3long.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    MBinning binsm3trans("BinningM3Trans");
+    binsm3trans.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    //...............................................................
+    // These ARE the binnings for the flux determination
+
+    MBinning binsalphaflux("BinningAlphaFlux");
+    binsalphaflux.SetEdges(100, 0, 100);
+
+    MBinning binse("BinningE");
+    binse.SetEdgesLog(10, 10, 1e3);
+
+    MBinning binstheta("BinningTheta");
+    binstheta.SetEdges(7, -2.5, 32.5);
+
+    MBinning binstime("BinningTime");
+    binstime.SetEdges(5, 0, 100);
+
+    MBinning binsdifftime("BinningTimeDiff");
+    binsdifftime.SetEdges(50, 0, 0.1);
+
+
+    //--------------------------------------------------------------
+    // Fill list of parameter containers
+    //
+
+    parlist.AddToList(&tasklist);
+    parlist.AddToList(&geomcam);
+
+    parlist.AddToList(&source);
+    parlist.AddToList(&antisrc);
+
+    parlist.AddToList(&binswidth);
+    parlist.AddToList(&binslength);
+    parlist.AddToList(&binscamera);
+
+    parlist.AddToList(&binsdist);
+
+    parlist.AddToList(&binsalpha);
+
+    parlist.AddToList(&binsasym);
+    parlist.AddToList(&binsasymn);
+    parlist.AddToList(&binsm3long);
+    parlist.AddToList(&binsm3trans);
+
+    parlist.AddToList(&binsalphaflux);
+    parlist.AddToList(&binse);
+    parlist.AddToList(&binstheta);
+    parlist.AddToList(&binstime);
+    parlist.AddToList(&binsdifftime);
+
+    //--------------------------------------------------------------
+    // Setup the tasks
+    //
+
+    //.....................................
+    // input file
+    //
+    // next statement commented out
+    //    MReadMarsFile reader("Events", "~/data/Gamma*.root");
+
+    MReadMarsFile reader("Events");
+
+    //reader.AddFile("/hd31/rkb/Camera/mpi/Gamma*.root");
+    //reader.AddFile("/hd31/rkb/Camera/mpi/prot_N_*.root");
+    //reader.AddFile("/hd31/rkb/Camera/mpi/prot_NS_*.root");
+    //reader.AddFile("protondata/gamma_10_n*.root");
+    reader.AddFile("protondata/gamma_10_cn*.root");
+
+    reader.EnableBranch("MMcEvt.fTheta");
+
+    //.....................................
+    // filters
+    MFTriggerLvl1 lvl1;
+
+    //.....................................
+    // generation of event time
+    MMcTimeGenerate   rand;
+
+    //.....................................
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MImgCleanStd      clean;
+    MBlindPixelCalc   blind;
+
+    //.....................................
+    // source independent image parameters
+    MHillasCalc       hcalc;
+    MHillasExt        hext;
+    parlist.AddToList(&hext);
+
+    //.....................................
+    // source dependent image parameters
+    MHillasSrcCalc    hsrc1("Source",     "HillasSrc");
+    MHillasSrcCalc    hsrc2("AntiSource", "HillasAntiSrc");
+
+    //.....................................
+    // energy estimation
+    MEnergyEstimate   estim;
+
+    //.....................................
+    // migration matrix (MC)
+    MFillH eestetrue("MHMcEnergyMigration",  "HillasSrc");
+    eestetrue.SetTitle("Task to determine the migration matrix for the energy");
+
+    //.....................................
+    // plots of source independent parameters (length, width, delta, size, center)
+    MFillH hfill1h("MHHillas",  "MHillas");
+    hfill1h.SetTitle("Task to plot the source independent image parameters");
+    hfill1h.SetFilter(&lvl1);
+
+    MFillH hfill1x("MHHillasExt", "MHillas");
+    hfill1x.SetTitle("Task to plot the extended image parameters");
+    hfill1x.SetFilter(&lvl1);
+
+    //.....................................
+    // plots of source dependent parameters (alpha, dist)
+    MFillH hfill2s("HSource     [MHHillasSrc]", "HillasSrc");
+    hfill2s.SetTitle("Task to plot the source dependent image parameters (Source)");
+    hfill2s.SetFilter(&lvl1);
+    MFillH hfill2a("HAntiSource [MHHillasSrc]", "HillasAntiSrc");
+    hfill2a.SetTitle("Task to plot the source dependent image parameters (AntiSource)");
+    hfill2a.SetFilter(&lvl1); 
+
+    //.....................................
+    // star map
+    MFillH hfill1m("MHStarMap", "MHillas");
+    hfill1m.SetTitle("Task to plot the Star map");
+
+    //.....................................
+    const Float_t alpha0 = 15; // [deg]
+    MFAlpha fsrc ("HillasSrc",     '>', alpha0);
+    fsrc.SetTitle("Task to check alphaSrc > alpha0");
+
+    MFAlpha fasrc("HillasAntiSrc", '>', alpha0);
+    fasrc.SetTitle("Task to check alphaAntiSrc > alpha0");
+
+    //.....................................
+    // 1-D profile plots     (<Theta>,  time)
+    //                       (<Theta>, Theta)
+    MFillH fillthetabartime ("ThetabarTime  [MHThetabarTime]",  "MMcEvt");
+    fillthetabartime.SetTitle("Task to plot <Theta> vs time");
+    // fillthetabartime.SetFilter(&lvl1);
+
+    MFillH fillthetabartheta("ThetabarTheta [MHThetabarTheta]", "MMcEvt");
+    fillthetabartheta.SetTitle("Task to plot <Theta> vs theta");
+    // fillthetabartheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 2-D plots     (Delta(time),  time)
+    //               (Delta(time), Theta)
+    MFillH filldtimetime ("EffOnTime  [MHTimeDiffTime]",  "MMcEvt");
+    filldtimetime.SetTitle("Task to plot Delta(time) vs time");
+    // filldtime.SetFilter(&lvl1);
+
+    MFillH filldtimetheta("EffOnTheta [MHTimeDiffTheta]", "MMcEvt");
+    filldtimetheta.SetTitle("Task to plot Delta(time) vs theta");
+    // fillontheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, time) 
+    MFillH fillsptime  ("SrcTime   [MHAlphaEnergyTime]",  "HillasSrc");
+    fillsptime.SetTitle("Task for 3D plots (alpha, E_est, time) (Source)");
+    fillsptime.SetFilter(&fasrc);
+
+    MFillH fillasptime ("ASrcTime  [MHAlphaEnergyTime]",  "HillasAntiSrc");
+    fillasptime.SetTitle("Task for 3D plots (alpha, E_est, time) (AntiSource)");
+    fillasptime.SetFilter(&fsrc);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, Theta) 
+    MFillH fillsptheta ("SrcTheta  [MHAlphaEnergyTheta]", "HillasSrc");
+    fillsptheta.SetTitle("Task for 3D plots (alpha, E_est, Theta) (Source)");
+    fillsptheta.SetFilter(&fasrc);
+
+    MFillH fillasptheta("ASrcTheta [MHAlphaEnergyTheta]", "HillasAntiSrc");
+    fillasptheta.SetTitle("Task for 3D plots (alpha, E_est, Theta) (AntiSource)");
+    fillasptheta.SetFilter(&fsrc);
+
+    //.....................................
+    // MFillH fethetaall("AllTheta [MHEnergyTheta]", "MMcEvt");
+    // MFillH fethetasel("SelTheta [MHEnergyTheta]", "MMcEvt");
+    // fethetasel.SetFilter(&lvl1);
+
+    // MFillH fetimeall ("AllTime  [MHEnergyTime]",  "MMcEvt");
+    // MFillH fetimesel ("SelTime  [MHEnergyTime]",  "MMcEvt");
+    // fetimesel.SetFilter(&lvl1);
+
+
+    //---------------------------------------------------------------------
+    // Setup the task list
+    //
+    tasklist.AddToList(&reader);
+
+    tasklist.AddToList(&lvl1);
+    tasklist.AddToList(&rand);
+
+    tasklist.AddToList(&pcopy);
+    tasklist.AddToList(&pnsb);
+    tasklist.AddToList(&ncalc);
+    tasklist.AddToList(&clean);
+    tasklist.AddToList(&blind);
+
+    tasklist.AddToList(&hcalc);
+    
+    tasklist.AddToList(&hsrc1);
+    tasklist.AddToList(&hsrc2);
+    tasklist.AddToList(&estim);
+    tasklist.AddToList(&eestetrue);
+
+    tasklist.AddToList(&hfill1h);
+    tasklist.AddToList(&hfill1x);
+
+    tasklist.AddToList(&hfill1m);
+    tasklist.AddToList(&hfill2s);
+    tasklist.AddToList(&hfill2a);
+
+    tasklist.AddToList(&fillthetabartime);
+    tasklist.AddToList(&fillthetabartheta);
+
+    tasklist.AddToList(&filldtimetime);
+    tasklist.AddToList(&filldtimetheta);
+
+
+
+    // tasklist.AddToList(&fethetaall);
+    // tasklist.AddToList(&fethetasel);
+    // tasklist.AddToList(&fetimeall);
+    // tasklist.AddToList(&fetimesel);
+
+    tasklist.AddToList(&fsrc);
+    tasklist.AddToList(&fasrc);
+
+    tasklist.AddToList(&fillsptime);
+    tasklist.AddToList(&fillasptime);
+
+    tasklist.AddToList(&fillsptheta);
+    tasklist.AddToList(&fillasptheta);
+
+ 
+    //----------------------------------------------------------------------
+    // Event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // loop over all events
+    //
+    if (!magic.Eventloop())
+        return;
+    //----------------------------------------------------------------------
+
+
+    tasklist.PrintStatistics(10);
+
+    
+    MHHillas *mhhillas = (MHHillas*)parlist.FindObject("MHHillas");
+    mhhillas->SetTitle("Source indep. image parameters");
+    mhhillas->DrawClone();
+    
+
+    
+    MHHillasExt *mhhillasext = (MHHillasExt*)parlist.FindObject("MHHillasExt");
+    mhhillasext->SetTitle("Extended image parameters");
+    mhhillasext->DrawClone();
+    
+    
+    MHHillasSrc *hsource = (MHHillasSrc*)parlist.FindObject("HSource");
+    hsource->SetTitle("Source dependent image parameters (Source)");
+    hsource->DrawClone();
+
+    MHHillasSrc *hantisource = (MHHillasSrc*)parlist.FindObject("HAntiSource");
+    hantisource->SetTitle("Source dependent image parameters (AntiSource)");
+    hantisource->DrawClone();
+    
+
+    /*    
+    parlist.FindObject("MHStarMap")->DrawClone();
+    */
+
+    //----------------------------------------------------------------------
+    // average Theta versus time
+    //           and versus Theta
+    // This is needed for selecting later the right collection area 
+    // (at the right Theta) for each bin in time or Theta
+    //
+    MHThetabarTime  *bartime  = (MHThetabarTime*)parlist.FindObject("ThetabarTime");
+    MHThetabarTheta *bartheta = (MHThetabarTheta*)parlist.FindObject("ThetabarTheta");
+    
+    /*    
+    bartime->DrawClone();
+    bartheta->DrawClone();
+    */
+
+     //----------------------------------------------------------------------
+     // Effective on time
+
+     //....................................
+     // get plots of time differences for different intervals in time
+     // and plots of time differences for different intervals in Theta 
+
+     MHTimeDiffTime  *dtimetime  = (MHTimeDiffTime*)parlist.FindObject("EffOnTime");
+     MHTimeDiffTheta *dtimetheta = (MHTimeDiffTheta*)parlist.FindObject("EffOnTheta");
+
+     /*
+     dtimetime->DrawClone();
+     dtimetheta->DrawClone();
+     */
+
+
+     //....................................
+     // calculate effective on time for different intervals in Time
+     //                         and for different intervals in Theta      
+
+     MHEffOnTime effontime ("Time",  "[s]");
+     MHEffOnTime effontheta("Theta", "[\\circ]");
+
+     effontime.SetupFill(&parlist);
+     effontheta.SetupFill(&parlist);
+
+
+     // Draw == 0  don't draw the individual distributions of time differences
+     //      != 0  draw them
+     Bool_t draw=kFALSE;
+     effontime.Calc (dtimetime->GetHist(), draw);
+     effontheta.Calc(dtimetheta->GetHist(),draw);
+
+
+     // plot effective on time versus Time
+     //                    and versus Theta
+     /*     
+     effontime.DrawClone();
+     effontheta.DrawClone();
+     */
+
+
+     //======================================================================
+     //
+     // A : fully differential plots (Alpha, E-est, Var)
+     //
+     //----------------------------------------------------------------------
+     // 3D-plots of alpha, E_est and time
+     //      and of alpha, E_est and Theta 
+     // with alpha calculated relative to the source position
+     //                   and relative to the anti-source position
+
+     MHAlphaEnergyTime  *evtsptime   = (MHAlphaEnergyTime*)parlist.FindObject("SrcTime");
+     MHAlphaEnergyTime  *evtasptime  = (MHAlphaEnergyTime*)parlist.FindObject("ASrcTime");
+     MHAlphaEnergyTheta *evtsptheta  = (MHAlphaEnergyTheta*)parlist.FindObject("SrcTheta");
+     MHAlphaEnergyTheta *evtasptheta = (MHAlphaEnergyTheta*)parlist.FindObject("ASrcTheta");
+
+
+     /*     
+      evtsptime->SetTitle("Source : 3D-plot Al-En-time, alpha\_{asp} .gt. alpha\_0");
+      evtsptime->DrawClone();
+      evtasptime->SetTitle("AntiSource : 3D-plot Al-En-time, alpha\_{sp} .gt. alpha\_0");
+      evtasptime->DrawClone();
+
+      evtsptheta->SetTitle("Source : 3D-plot Al-En-Theta, alpha\_{asp} .gt. alpha\_0");
+      evtsptheta->DrawClone();
+      evtasptheta->SetTitle("AntiSource : 3D-plot Al-En-Theta, alpha\_{sp} .gt. alpha\_0");
+      evtasptheta->DrawClone();
+     */
+                
+     //----------------------------------------------------------------------
+     // Difference between source and antisource (= 'gamma' sample) 
+     // for             3D-plots of alpha, E_est and time
+     //                      and of alpha, E_est and Theta 
+     // 3rd and 4th argument are name and title of the resulting histogram
+
+     MHGamma gamma;
+
+     TH3D *hsubtime  = gamma.Subtract( evtsptime->GetHist(), 
+                                       evtasptime->GetHist(),
+                        "Al-En-time", "3D-plot of Alpha,E-est,time", draw);
+
+     TH3D *hsubtheta = gamma.Subtract( evtsptheta->GetHist(), 
+                                       evtasptheta->GetHist(),
+                        "Al-En-time", "3D-plot of Alpha,E-est,Theta", draw);
+    
+
+     //----------------------------------------------------------------------
+     // get number of 'gammas' in the alpha range (lo, up) as a function of
+     //                 E_est and time
+     //        or       E_est and Theta 
+
+     Axis_t lo =   0;    // [deg]
+     Axis_t up =  10;    // [deg]
+     const TH2D &evttime  = *(gamma.GetAlphaProjection(hsubtime, 
+                              lo, up, draw));
+
+     const TH2D &evttheta = *(gamma.GetAlphaProjection(hsubtheta, 
+                              lo, up, draw));
+     
+
+     //----------------------------------------------------------------------
+     // plot migration matrix:  E-true E-est Theta
+
+
+     /*
+     MHMcEnergyMigration *migrationmatrix = 
+         (MHMcEnergyMigration*)parlist.FindObject("MHMcEnergyMigration");
+     migrationmatrix->SetTitle("Migration matrix");;
+     migrationmatrix->DrawClone();
+     */
+
+
+     //----------------------------------------------------------------------
+     // determine gamma flux from distributions of E-est :
+     //   -  do unfolding to get the distributions in E-unfold
+     //   -  divide by bin width in energy
+     //                effective ontime and
+     //                effective collection area
+     //      to get the absolute gamma flux
+    
+     //.............................................
+     // get flux spectrum for different bins in Time
+     //
+     // use dummy histogram *aeff which eventually will contain
+     //     the effective collection area as a function of Etrue and Theta
+     TH2D aeff;
+
+     // arguments of MHFlux constructor are :
+     //   - 2D histogram containing the no.of gammas as a function of
+     //     E-est and Var
+     //   - name  of variable Var ("Time" or "Theta")
+     //   - units of variable Var ( "[s]" or "[\\circ]")
+
+     // Draw == kTRUE  draw the no.of photons vs. E-est 
+     //                for the individual bins of the variable Var
+     draw=kTRUE;
+     MHFlux fluxtime(evttime, draw, "Time", "[s]");
+     fluxtime.Unfold(draw);
+     fluxtime.CalcFlux(effontime.GetHist(), bartime.GetHist(),
+                       &aeff, draw);
+     
+     fluxtime.DrawClone();
+     
+
+
+     //..............................................
+     // get flux spectrum for different bins in Theta
+     MHFlux fluxtheta(evttheta, draw, "Theta", "[\\circ]");
+     fluxtheta.Unfold(draw);
+     fluxtheta.CalcFlux(effontheta.GetHist(), bartheta.GetHist(),
+                       &aeff, draw);
+     
+     fluxtheta.DrawClone();
+     
+
+return;
+     //----------------------------------------------------------------------
+
+
+     //======================================================================
+     //
+     // B : plots integrated over E-est
+     //
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over E-est
+     //    to get 2D-plot of (alpha, Time) 
+                                   
+     Draw = kFALSE;                        
+     TH2D *evttimesp  = evtsptime.IntegrateEest ("AlphaSP vs. Time", Draw);
+     TH2D *evttimeasp = evtasptime.IntegrateEest("AlphaASP vs. Time",Draw);
+
+
+     //======================================================================
+     //
+     // C : plots integrated over Time
+     //
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over the Time
+     //    to get 2D-plot of (alpha, E_est) 
+                                   
+     Draw = kFALSE;                        
+     TH2D *evteestsp  = evtsptime.IntegrateTime ("AlphaSP vs. E-est", Draw);
+     TH2D *evteestasp = evtasptime.IntegrateTime("AlphaASP vs. E-est",Draw);
+
+
+
+     //======================================================================
+     //
+     // D : plots integrated over E-est and Time
+     //
+
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over E-est and Time
+     //    to get 1D-plot of (alpha) 
+                                   
+     Draw = kFALSE;                        
+     TH1D *evtalphasp  = evtsptime.IntegrateEestTime ("AlphaSP", Draw);
+     TH1D *evtalphaasp = evtasptime.IntegrateEestTime("AlphaASP",Draw);
+
+     //----------------------------------------------------------------------
+     // list of tasks for processing
+
+     cout << " " << endl;
+     cout << "List of tasks for processing :" << endl;
+     cout << "==============================" << endl;
+     cout << " " << endl;
+
+     // was folgt geht nicht :
+
+     // Error: Function Next() is not defined in current scope  FILE:macros/flux.C LINE:636
+
+     //while ( (task=(MTask*)Next()) )
+     //{
+     //  cout << tasklist.GetName() << " :   " << tasklist.GetTitle() << endl;
+     //}
+
+     return;
+
+     //======================================================================                
+}
+//===========================================================================
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/merpp.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/merpp.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/merpp.C	(revision 1638)
@@ -0,0 +1,85 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This is an easy implementation of the Merging process (as root Macro)
+//
+// at the moment it reads a binary file ("rawtest.bin") which was written
+// in the DAQ raw format.
+//
+// The data are stored in root container objects (classes derived from
+// TObject like MRawRunHeader)
+//
+// This containers are written to a root file ("rawtest.root")
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void merpp()
+{
+    //
+    // create a (empty) list of parameters which can be used by the tasks
+    // and an (empty) list of tasks which should be executed
+    //
+    MTaskList tasks;
+    MParList plist;
+
+    plist.AddToList(&tasks);
+
+    //
+    // create the tasks which should be executed and add them to the list
+    // in the case you don't need parameter containers, all of them can
+    // be created by MRawFileRead::PreProcess
+    //
+    // REMARK: Don't change the order of the two instantiations.
+    //         I don't have an idea why, but here it crashes the
+    //         Interpreter.
+    //         (Using root 2.25/03, with Cint 5.14.50 on OSF1)
+    //
+
+    MRawFileRead  reader("/home/tbretz/data/20010219-00020-d-octobertest-e");
+    MRawFileWrite writer("otest.root", "RECREATE");
+    tasks.AddToList(&reader);
+    tasks.AddToList(&writer);
+
+    //
+    // create the looping object and thell it about the parameters to use
+    // and the tasks to execute
+    //
+    MEvtLoop magic;
+
+    magic.SetParList(&plist);
+
+    //
+    // Start the eventloop which reads the raw file (MRawFileRead) and
+    // write all the information into a root file (MRawFileWrite)
+    //
+    // between reading and writing we can do, transformations, checks, etc.
+    // (I'm think of a task like MRawDataCheck)
+    //
+    magic.Eventloop();
+}
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist.C	(revision 1638)
@@ -0,0 +1,176 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+void multidimdist()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file.
+
+    //
+    // 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);
+
+    //
+    // This is an example program which reads image parameters for gammas 
+    // and hadrons, builds a 'matrix' of look-alike events,
+    // and then finds quality numbers and acceptances for the same sample
+
+    // Create an empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+    MTaskList tlistg;
+    plist.AddToList(&tlistg);
+
+    //
+    // ------------- user attention -----------------
+    //
+
+    // cut used both for the matrices and the sample
+    // for more information see the documentation of MF and MDataChain
+    MF filterenergy("MMcEvt.fEnergy > 0");
+
+    // matrix limitation for look-alike events (approximate number)
+    MFEventSelector selector;
+    selector.SetNumSelectEvts(2000);
+
+    // setup an AND-Filterlist from the two filters to be used
+    // in the event selection for the filling of the matrices
+    MFilterList flist;
+    flist.AddToList(&filterenergy);
+    flist.AddToList(&selector);
+
+    //
+    // ---------------------------------------------------------------
+    //  Now set up the tasks and tasklist (first event loop, gammas)
+    // ---------------------------------------------------------------
+    //
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the hadrons
+    // ---------------------------------------------
+    MReadMarsFile read("Events");
+    read.AddFile("star_gammas.root");
+    read.AddFile("star_protons.root");
+    read.DisableAutoScheme();
+    tlistg.AddToList(&read);
+
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    MHMatrix matrix("MatrixGammas");
+    matrix.AddColumn("MHillas.fWidth");
+    matrix.AddColumn("MHillas.fLength");
+    matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
+    matrix.AddColumn("abs(MHillas.fAsym)");
+    matrix.AddColumn("abs(MHillas.fM3Long)");
+    matrix.AddColumn("abs(MHillas.fM3Trans)");
+    matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
+    matrix.AddColumn("MHillas.fConc");
+    matrix.AddColumn("MHillas.fConc1");
+    matrix.AddColumn("MHillasSrc.fDist");
+    matrix.AddColumn("log10(MHillas.fSize)");
+    matrix.AddColumn("MHillasSrc.fAlpha");
+    matrix.AddColumn("MMcEvt.fTheta");
+    plist.AddToList(&matrix);
+
+    MHMatrix matrix2("MatrixHadrons");
+    matrix2.AddColumns(matrix.GetColumns());
+    plist.AddToList(&matrix2);
+
+    MFillH fillmat("MatrixGammas");
+    fillmat.SetFilter(&fgamma);
+    tlist.AddToList(&fillmat);
+
+    MFillH fillmat2("MatrixHadrons");
+    fillmat2.SetFilter(&fhadrons);
+    tlist.AddToList(&fillmat2);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    matrix.Print("size");
+    matrix2.Print("size");
+
+    // ---------------------------------------------------------
+
+    MTaskList tlist2;
+
+    plist.Replace(&tlist2);
+
+    MReadMarsFile read2("Events");
+    read2.("gammas2.root");
+    read2.AddFile("hadrons2.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    MMultiDimDistCalc calc;
+    calc.SetUseNumRows(0);
+    calc.SetUseKernelMethod(kTRUE);
+    tlist2.AddToList(&calc);
+
+    MFillH fillh("MHHadronness");
+
+    /*
+     MF filter("MMcEvt.fEnergy < 100");
+     fillh.SetFilter(&filter);
+     tlist2.AddToList(&filter);
+     */
+
+    tlist2.AddToList(&fillh);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist2.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist2.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/multidimdist2.C	(revision 1638)
@@ -0,0 +1,203 @@
+/* ======================================================================== *\
+!
+! *
+! * 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, 11/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 11/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+void multidimdist2()
+{
+    //
+    // This is an example program which reads image parameters for gammas 
+    // and hadrons, builds a 'matrix' of look-alike events,
+    // and then finds quality numbers and acceptances for the same sample
+
+    // Create an empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+    MTaskList tlistg;
+    plist.AddToList(&tlistg);
+
+    //
+    // ------------- user attention -----------------
+    //
+
+    // cut used both for the matrices and the sample
+    // for more information see the documentation of MF and MDataChain
+    MF filterenergy("MMcEvt.fEnergy > 0");
+
+    // matrix limitation for look-alike events (approximate number)
+    MFEventSelector selector;
+    selector.SetNumSelectEvts(2000);
+
+    // setup an AND-Filterlist from the two filters to be used
+    // in the event selection for the filling of the matrices
+    MFilterList flist;
+    flist.AddToList(&filterenergy);
+    flist.AddToList(&selector);
+
+    //
+    // ---------------------------------------------------------------
+    //  Now set up the tasks and tasklist (first event loop, gammas)
+    // ---------------------------------------------------------------
+    //
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the gammas
+    // ---------------------------------------------
+    MReadMarsFile readg("Events", "star_gammas.root");
+    readg.DisableAutoScheme();
+    tlistg.AddToList(&readg);
+
+    MHMatrix matrix("MatrixGammas");
+    matrix.AddColumn("MHillas.fWidth");
+    matrix.AddColumn("MHillas.fLength");
+    matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
+    matrix.AddColumn("abs(MHillas.fAsym)");
+    matrix.AddColumn("abs(MHillas.fM3Long)");
+    matrix.AddColumn("abs(MHillas.fM3Trans)");
+    matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
+    matrix.AddColumn("MHillas.fConc");
+    matrix.AddColumn("MHillas.fConc1");
+    matrix.AddColumn("MHillasSrc.fDist");
+    matrix.AddColumn("log10(MHillas.fSize)");
+    matrix.AddColumn("MHillasSrc.fAlpha");
+    matrix.AddColumn("MMcEvt.fTheta");
+    plist.AddToList(&matrix);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&flist);
+    tlistg.AddToList(&flist);
+    tlistg.AddToList(&fillmatg);
+
+    //
+    // --- Create and set up the eventloop (gammas) ---
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // --- Execute matrix buildup (gammas) ---
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlistg.PrintStatistics();
+
+    //
+    // ------------------------------------------------------------------
+    //                prepare second event loop, hadrons
+    // ------------------------------------------------------------------
+    //
+    MTaskList tlisth;
+    plist.Replace(&tlisth);
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the hadrons
+    // ---------------------------------------------
+    MReadMarsFile  readh("Events", "star_protons.root");
+    readh.DisableAutoScheme();
+    tlisth.AddToList(&readh);
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.AddColumns(matrix.GetColumns());
+    plist.AddToList(&matrixh); 
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&flist);         // filter list
+    tlisth.AddToList(&flist);
+    tlisth.AddToList(&fillmath);
+
+    //
+    // Create and set up the eventloop (protons)
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute matrix buildup (hadrons)
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    //  sum up in log
+    tlistg.PrintStatistics();
+
+    matrix.Print("size");
+    matrixh.Print("size");
+
+    //
+    // ----------------------------------------------------------
+    //  Go through full sample again, now for getting hadronness
+    //  (third event loop)
+    // ----------------------------------------------------------
+    //
+
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    // ------------------- user change --------------------
+    //    Give the names of the star-files to be read as
+    //  test samples   you should at least have one hadron
+    //          and one gamma file available
+    // ----------------------------------------------------
+    MReadMarsFile read2("Events", "star_protons.root");
+    read2.AddFile("star_gammas.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    // ---------------- user attention -----------------
+    //      Here you may change the algorithm used
+    //    You can switch from Kernel to Next Neighbor
+    //  or change the number of used shortest distances
+    //  For kernel you should always set this to 0 (all)
+    // -------------------------------------------------
+    MMultiDimDistCalc calc;
+    calc.SetUseNumRows(25);
+    calc.SetUseKernelMethod(kFALSE);
+    tlist2.AddToList(&calc);
+
+    MFillH fillh("MHHadronness");
+    fillh.SetFilter(&filterenergy);
+    tlist2.AddToList(&filterenergy);
+    tlist2.AddToList(&fillh);
+
+    //
+    // Execute analysis of gammas and hadrons
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/plot.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/plot.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/plot.C	(revision 1638)
@@ -0,0 +1,128 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void plot()
+{
+    //
+    // 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:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+    MReadMarsFile  read("Events", "star.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    // Create a filter for Gammas
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    // Create a filter for Non-Gammas
+    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    // -------------------------------------------------------
+    //
+    // set the name of the variable to plot and the binning
+    //
+    TString var("MHillas.fSize");
+
+    MBinning bins("BinningMH3X");
+    bins.SetEdgesLog(50, 100, 20000);
+    plist.AddToList(&bins);
+    //
+    // -------------------------------------------------------
+
+    // Create a histogram for the data from gammas and from non-gammas
+    MH3 h3g(var);
+    MH3 h3h(var);
+
+    // Add the histograms to the parameter container list
+    plist.AddToList(&h3g);
+    plist.AddToList(&h3h);
+
+    // Create a task which fills one histogram with the gamma-data
+    MFillH fillg(&h3g);
+    fillg.SetFilter(&fgamma);
+    tlist.AddToList(&fillg);
+
+    // Create a task which fills the other histogram with the non-gamma-data
+    MFillH fillh(&h3h);
+    fillh.SetFilter(&fhadrons);
+    tlist.AddToList(&fillh);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // Create a default canvas called Plot and set the
+    // x-axis to logarithmic scale
+    MH::MakeDefCanvas("Plot");
+    gPad->SetLogx();
+
+    // Setup some style options of the two histograms
+    // and draw a copy of both
+    h3h.GetHist().SetLineColor(kRed);
+    h3h.GetHist().SetFillStyle(4000);
+    h3g.GetHist().DrawCopy();
+    h3h.GetHist().DrawCopy("same");
+
+    // Now create a new histogram, fill it with the division of the
+    // two histograms and draw also a copy of it
+    TH1D h;
+    MH::SetBinning(&h, &bins);
+    h.Divide(&h3g.GetHist(), &h3h.GetHist());
+    h.SetLineColor(kGreen);
+    h.SetFillStyle(4000);
+    h.DrawCopy("same");
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/plot2.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/plot2.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/plot2.C	(revision 1638)
@@ -0,0 +1,140 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a 2D histogram using Mars
+//
+void plot2()
+{
+    //
+    // 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:
+    // ---------------------------------
+    //
+
+    // First Task: read in a file created with star.C
+    MReadMarsFile  read("Events", "star.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    // Create a filter for the gamma events
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    // Create a filter for the non-gamma events
+    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    // -------------------------------------------------------
+    //
+    // set the name of the variable to plot and the binning
+    //
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+
+    TString vary("MHillas.fWidth*MGeomCam.fConvMm2Deg");
+    TString varx("MHillas.fLength*MGeomCam.fConvMm2Deg");
+
+    MBinning binsy("BinningMH3Y");
+    MBinning binsx("BinningMH3X");
+    binsy.SetEdges(11, 0, 0.3);
+    binsx.SetEdges(11, 0, 0.6);
+    plist.AddToList(&binsx);
+    plist.AddToList(&binsy);
+    //
+    // -------------------------------------------------
+
+    // Create two 2D histograms and add them to the list
+    MH3 h3g(varx, vary);
+    MH3 h3h(varx, vary);
+
+    plist.AddToList(&h3g);
+    plist.AddToList(&h3h);
+
+    // Create a task to fill one histogram with the gamma data
+    MFillH fillg(&h3g);
+    fillg.SetFilter(&fgamma);
+    tlist.AddToList(&fillg);
+
+    // Create a task to fill the other one with the non gamma data
+    MFillH fillh(&h3h);
+    fillh.SetFilter(&fhadrons);
+    tlist.AddToList(&fillh);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // Create a default canvas
+    MH::MakeDefCanvas("Plot");
+
+    // setup some style options
+    h3h.GetHist().SetMarkerColor(kRed);
+    h3h.GetHist().SetLineColor(kRed);
+    h3h.GetHist().SetFillStyle(4000);
+
+    // show a contour plot of both histograms
+    h3h.GetHist().DrawCopy("cont3");
+    h3g.GetHist().DrawCopy("cont3same");
+
+    return;
+
+    //
+    // Use this (or something similar) if you want to plot the profile
+    // histograms
+    //
+    TProfile *p = ((TH2&)h3g.GetHist()).ProfileX();
+    p->Draw("same");
+    p->SetBit(kCanDelete);
+
+    TProfile *p = ((TH2&)h3h.GetHist()).ProfileX();
+    p->SetLineColor(kRed);
+    p->SetFillStyle(4000);
+    p->Draw("same");
+    p->SetBit(kCanDelete);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/readCT1.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/readCT1.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/readCT1.C	(revision 1638)
@@ -0,0 +1,102 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
+void readCT1(const char *fname="~/data/CT1_97_on1.dat")
+{
+    MParList plist;
+
+    MGeomCamCT1 geomcam;
+    MHillas     hillas;
+    MTaskList   tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&hillas);
+    plist.AddToList(&tlist);
+
+    MCT1ReadAscii read(fname);
+    MClone        clone("MCerPhotEvt");
+    MImgCleanStd  clean;
+    MHillasCalc   hcalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&clone);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    Int_t icount = 0;
+    MCamDisplay display(&geomcam);
+    display.Draw();
+
+    while (tlist.Process())
+    {
+        cout << "Event #" << icount++ << endl;
+
+        MCerPhotEvt *evt = (MCerPhotEvt*)clone.GetClone();
+
+        if (!evt)
+            continue;
+
+        display.DrawPhotNum(evt);
+
+        if (!HandleInput())
+            break;
+
+        hillas.Print();
+        hillas.Draw();
+        display.DrawPhotNum((MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
+
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/readMagic.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/readMagic.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/readMagic.C	(revision 1638)
@@ -0,0 +1,118 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
+void readMagic(const char *fname="~/data/Gamma_0_7*.root")
+{
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MHillasExt    hillas;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&hillas);
+    plist.AddToList(&tlist);
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MPrint print1("MMcEvt");
+    MPrint print2("MRawEvtHeader");
+    print1.EnableSkip();
+    print2.EnableSkip();
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MBlindPixelCalc   blind;
+    blind.SetUseInterpolation();
+    MClone            clone("MCerPhotEvt");
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&print1);
+    tlist.AddToList(&print2);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&clone);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    MCamDisplay display(&geomcam);
+    display.Draw();
+
+    while (tlist.Process())
+    {
+        cout << "Event #" << read.GetEventNum() ":" << endl;
+
+        display.DrawPhotNum((MCerPhotEvt*)clone.GetClone());
+
+        if (!HandleInput())
+            break;
+
+        hillas.Print();
+	hillas.Draw();
+
+        display.DrawPhotNum((MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
+
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/readin.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/readin.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/readin.C	(revision 1638)
@@ -0,0 +1,91 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+void readin()
+{
+    //
+    // open the file
+    //
+    TFile input("test.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtHeader  *evtheader = new MRawEvtHeader();
+    MTime          *evttime   = new MTime();
+    MRawEvtData    *evtdata   = new MRawEvtData();
+    MRawCrateArray *evtcrate  = new MRawCrateArray();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
+    evttree->GetBranch("MTime")->SetAddress(&evttime);
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+    evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
+
+    //
+    // loop over all events and print the information
+    //
+    Int_t iEnt = evttree->GetEntries();
+    cout << " Entries in Tree Data: " << iEnt << endl;
+
+    for (Int_t i = 0; i<iEnt; i++)
+    {
+      // readin event with the selected branches
+      evttree->GetEvent(i);
+
+      evtheader->Print();
+      evttime->Print();
+      evtcrate->Print();
+      evtdata->Print();
+    } 
+}
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/readpix.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/readpix.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/readpix.C	(revision 1638)
@@ -0,0 +1,97 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+#include <iomanip>
+
+void readpix()
+{
+    //
+    // open the file
+    //
+    TFile input("delme.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtData *evtdata = new MRawEvtData();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+
+    evttree->GetEvent(0);
+
+    MRawEvtPixelIter pixel(evtdata);
+
+    while (pixel.Next())
+    {
+       
+       cout << "Pixel Nr: " << dec << pixel.GetPixelId() << " ";
+       cout << setfill('0') << endl;
+      
+       cout << "Hi Gains: ";
+       for (int i=0; i<evtdata->GetNumHiGainSamples(); i++)
+	  cout << setw(3) << (UInt_t)pixel.GetHiGainFadcSamples()[i];
+       cout << endl;
+      
+       cout << "Lo Gains: ";
+       if (pixel.IsLoGain())
+	  for (int i=0; i<evtdata->GetNumLoGainSamples(); i++)
+	     cout << setw(3) << (UInt_t)pixel.GetLoGainFadcSamples()[i];
+       cout << endl << endl;
+
+       if (pixel.GetPixelId() == 11)
+	 pixel.Draw();
+    };
+}
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/readraw.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/readraw.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/readraw.C	(revision 1638)
@@ -0,0 +1,91 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+void readraw()
+{
+    //
+    // open the file
+    //
+    TFile input("test.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtHeader  *evtheader = new MRawEvtHeader();
+    MTime          *evttime   = new MTime();
+    MRawEvtData    *evtdata   = new MRawEvtData();
+    MRawCrateArray *evtcrate  = new MRawCrateArray();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
+    evttree->GetBranch("MTime")->SetAddress(&evttime);
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+    evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
+
+    //
+    // loop over all events and print the information
+    //
+    Int_t iEnt = evttree->GetEntries();
+    cout << " Entries in Tree Data: " << iEnt << endl;
+
+    for (Int_t i = 0; i<iEnt; i++)
+    {
+      // readin event with the selected branches
+      evttree->GetEvent(i);
+
+      evtheader->Print();
+      evttime->Print();
+      evtcrate->Print();
+      evtdata->Print();
+    } 
+}
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/rootlogon.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/rootlogon.C	(revision 1638)
@@ -0,0 +1,110 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+Bool_t isloaded()
+{
+    TString str = gSystem->GetLibraries("*/mars.so");
+
+    return !str.IsNull();
+}
+
+void unload()
+{
+    if (!isloaded())
+        return;
+
+    cout << "Unloading 'mars.so'... " << flush;
+    if (gSystem->Unload("mars.so"))
+        cout << "error." << endl;
+    else
+        cout << "done." << endl << endl;
+}
+
+void load()
+{
+    if (isloaded())
+        return;
+
+    cout << "Loading 'mars.so'... " << flush;
+
+    if (gSystem->Load("mars.so")!=0)
+        cout << "error." << endl;
+    else
+    {
+        MParContainer::Class()->IgnoreTObjectStreamer();
+        MArray::Class()->IgnoreTObjectStreamer();
+        cout << "done." << endl;
+    }
+
+    cout << endl;
+}
+
+void make()
+{
+    unload();
+
+    if (gSystem->Exec("make"))
+    {
+        cout << "Error calling make..." << endl;
+        return;
+    }
+
+    load();
+}
+
+void rootlogon()
+{
+    cout << endl;
+
+    load();
+
+    gInterpreter->AddIncludePath("macros");
+    gInterpreter->AddIncludePath("manalysis");
+    gInterpreter->AddIncludePath("mbase");
+    gInterpreter->AddIncludePath("mdata");
+    gInterpreter->AddIncludePath("mfileio");
+    gInterpreter->AddIncludePath("mfilter");
+    gInterpreter->AddIncludePath("mgeom");
+    gInterpreter->AddIncludePath("mgui");
+    gInterpreter->AddIncludePath("mhist");
+    gInterpreter->AddIncludePath("mmain");
+    gInterpreter->AddIncludePath("mmc");
+    gInterpreter->AddIncludePath("mmontecarlo");
+    gInterpreter->AddIncludePath("mraw");
+    gInterpreter->AddIncludePath("mtools");
+
+    if (TString("linux")==gSystem->GetBuildArch())
+    {
+        TString options = " -O -pipe -Wall -Woverloaded-virtual -fno-rtti -fno-exceptions -fPIC ";
+
+        TString s = "cd $BuildDir ; ";
+        s += "g++ -c" + options + "-Iinclude -D_REENTRANT $IncludePath $SourceFiles ; ";
+        s += "g++ $ObjectFiles -shared -Wl,-soname,$LibName.so -O -o $SharedLib";
+        gSystem->SetMakeSharedLib(s);
+    }
+
+    cout << "Welcome to the Mars Root environment." << endl;
+
+    cout << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/star.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/star.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/star.C	(revision 1638)
@@ -0,0 +1,124 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  5/2002 <mailto:(tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  STAR - STandard Analysis and Reconstruction
+//
+//  This macro is the standard converter to convert raw data into image
+//  parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void star()
+{
+    //
+    // This is a demonstration program which calculates the image 
+    // parameters from a Magic raw data root file.
+
+    //
+    // 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);
+
+    MSrcPosCam src;
+    src.SetReadyToSave();
+    plist.AddToList(&src);
+
+    //
+    // Uncomment this two line if you want to use MHillasExt instead
+    // of MHillas
+    //
+    MHillasExt hext;
+    plist.AddToList(&hext);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choose a wrong geometry by mistake
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+
+    // ------------- user change -----------------
+    read.AddFile("Pro*.root");
+    //read.AddFile("Gam*.root");
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+
+    MBlindPixelCalc   blind;
+    blind.SetUseInterpolation();
+
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+
+    // ------------- user change -----------------
+    MWriteRootFile write("data/star_protons.root");
+    write.AddContainer("MHillas",       "Events");
+    write.AddContainer("MMcEvt",        "Events");
+    write.AddContainer("MHillasSrc",    "Events");
+    write.AddContainer("MRawRunHeader", "RunHeaders");
+    write.AddContainer("MMcRunHeader",  "RunHeaders");
+    write.AddContainer("MSrcPosCam",    "RunHeaders");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&write);
+
+    //
+    // Create and set up the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/starplot.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/starplot.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/starplot.C	(revision 1638)
@@ -0,0 +1,119 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 et al, 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void starplot(const char *filename="Gamma_*.root")
+{
+    //
+    // This is a demonstration program which plots the Hillas
+    // parameter from a file created with star.C
+    //
+
+    //
+    // 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);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // 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);
+
+    //
+    // 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();
+
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
+    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+
+    //
+    // 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();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/tar.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/tar.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/tar.C	(revision 1638)
@@ -0,0 +1,31 @@
+void tar()
+{
+    TString dir = gSystem->pwd();
+
+    Int_t slash = dir.Last('/');
+
+    TString name = &dir[slash+1];
+
+    if (!gSystem->AccessPathName("../"+name+".tar"))
+    {
+        cout << "File '../" << name << ".tar' existing." << endl;
+        return;
+    }
+
+    if (!gSystem->AccessPathName("../"+name+".tar.gz"))
+    {
+        cout << "File '../" << name << ".tar.gz' existing." << endl;
+        return;
+    }
+
+    gSystem->cd("..");
+
+    TString cmd = "tar cvf "+name+".tar --exclude=Root "+name+"/.rootrc "+name+"/*";
+
+    cout << "Executing: " << cmd << endl;
+
+    gSystem->Exec(cmd);
+    gSystem->Exec("gzip -9 "+name+".tar");
+
+    gSystem->cd(name);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/threshold.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/threshold.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/threshold.C	(revision 1638)
@@ -0,0 +1,106 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+void threshold(char* filename="data/camera.root")
+{
+    //
+    // This macro fill the container MHMcEnergies using the task
+    // MMcThresholdCalc and shows the results.
+    //
+    MParList parlist;
+
+    MTaskList tasklist;
+    parlist.AddToList(&tasklist);
+
+    //
+    // Setup the parameter list
+    // - You need create the container MHMcEnergies.
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MHMcEnergies
+    //    + If you don't put any dimension to MHMcEnergies it works
+    //      taking only the trigger information from MMcTrig
+    //
+    const UInt_t numtrigcond = 0;
+
+    UInt_t from = numtrigcond>0 ?           1 : -numtrigcond;
+    UInt_t to   = numtrigcond>0 ? numtrigcond : -numtrigcond;
+
+    Int_t dim = to-from+1;
+
+    //
+    // Create numtriggerconditions histograms of type MHMcEnergy
+    // and store the histograms in an TObjArray
+    //
+    TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != dim)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    parlist.AddToList(&hists);
+
+    //
+    // Setup the task list
+    // - You need the read and the MMcThresholdCalc tasks
+    // - You have to fill the histograms for the Energy threshold
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcThresholdCalc
+    //    + If you don't put any dimension to MMcThresholdCalc it works
+    //      like one dimension MMcThresholdCalc
+    //
+    MReadTree read("Events", filename);
+    MMcThresholdCalc calc(numtrigcond);
+
+    tasklist.AddToList(&read);
+    tasklist.AddToList(&calc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&parlist);
+
+    //
+    // Begin the loop (if the loop wasn't succesfull
+    // don't try to draw the results
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // Now you can display the results
+    //
+    hists.Print();
+
+    TIter Next(&hists);
+    TObject *obj;
+    while ((obj=Next()))
+        obj->DrawClone();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/macros/trigrate.C
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/macros/trigrate.C	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/macros/trigrate.C	(revision 1638)
@@ -0,0 +1,163 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!   Modified 4/7/2002, Abelardo Moralejo:
+!   Added one optional input parameter: a camera .root file containing
+!   pure NSB events. One such file is generated running the camera over an
+!   "empty" reflector file, with the NSB option on, and MINPHOT=0. The nsb
+!   files must contain the same trigger conditions as the proton file.
+!   If no nsb file is supplied, the macro will assume no triggers from 
+!   pure NSB fluctuations.
+!
+\* ======================================================================== */
+
+Int_t GetNSBEvents(TString name, Float_t *BgR)
+{
+    Int_t numnsbevents;
+
+    TChain events("Events");
+    events.Add(name);
+
+    TH1F h("h","",5,.5,5.5);
+
+    for (Int_t i = from; i <= to; i++)
+    {
+        TString plot = "MMcTrig;";
+        plot+=i;
+        plot+=".fNumFirstLevel>>h";
+
+        if (i == 0)
+            plot = "MMcTrig.fNumFirstLevel>>h";
+
+        events.Draw(plot,"", "goff");
+
+        // Get total number of L1 triggers from histogram:
+        BgR[dim>0? i-1: 0] = h.Integral()*h.GetMean();
+
+        numnsbevents = (Float_t) h.GetEntries();
+    }
+
+    return numnsbevents;
+}
+
+
+void trigrate(int dim=0, char *filename = "data/camera.root", 
+	      char *nsbfile = NULL)
+{
+    // The dim parameter has three possible values:
+    // dim : = 0 -> root file with 1 trigger condition.
+    //       > 0 -> number of trigger condition to be analised 
+    //              in multi conditon file.
+    //       < 0 -> selects the -dim trigger condition.
+    //
+    // first we have to create our empty lists
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    //
+    // Setup the parameter list.
+    //  - we do not need to create any other container. All of them
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //
+    //  - we need to create MHMcRate only. The other containers
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //  - MHMcRate must be created by us because we need the pointer
+    //    to it and if it would get created automatically it would also be
+    //    deleted automatically
+    //  - Actually, depending on using a single trigger option MonteCarlo
+    //    file or a multyple trigger option, a MHMcRate or an array of 
+    //    MHMcRate are needed.
+    //
+    parlist.AddToList(&tasklist);
+
+    //
+    // You don't have to add the MHMcRate container here by hand.
+    // But if you want to print or display these containers later on
+    // it is necessary (Rem: No printing or displaying is done in this
+    // macro yet)
+    //
+    UInt_t from = dim>0 ?   1 : -dim;
+    UInt_t to   = dim>0 ? dim : -dim;
+
+    Int_t num = to-from+1;
+
+    TObjArray hists(MParList::CreateObjList("MHMcRate", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != num)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    parlist.AddToList(&hists);
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can calculate rates, for what the number of
+    //    triggered showers from a empty reflector file for the
+    //    analised trigger conditions should be set (BgR[])
+    //
+    MReadTree reader("Events", filename);
+    tasklist.AddToList(&reader);
+
+    // Now we have to build the BgR array, containing the number 
+    // of triggers (may be more than 1 trigger/event!) from the
+    // numnsbevents simulated in the nsbfile (3rd input parameter).
+    // If no nsbfile is supplied, we assume no triggers from NSB
+
+    Float_t* BgR = new Float_t[num];
+    memset(BgR, 0, num*sizeof(Float_t));
+
+    Float_t numnsbevents = 5.e4; // some default value.
+    if (nsbfile)
+        numnsbevents = GetNSBEvents(nsbfile, BgR);
+
+    cout << "Number of Trigger conditions: " << num << endl;
+
+    MMcTriggerRateCalc rate(dim, kPROTON, BgR, numnsbevents);
+    tasklist.AddToList(&rate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // Start to loop over all events
+    //
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    delete BgR;
+
+    hists.Print();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/magiclogo.xpm
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/magiclogo.xpm	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/magiclogo.xpm	(revision 1638)
@@ -0,0 +1,342 @@
+/* XPM */
+static char *mag1[] = {
+/* width height ncolors chars_per_pixel */
+"176 87 248 2",
+/* colors */
+"   c #F2D25C",
+" . c #FEFAEC",
+" X c #FEF6EC",
+" o c #A69EC4",
+" O c #F2F6F4",
+" + c #524E8C",
+" @ c #F2F2F4",
+" # c #F2EEF4",
+" $ c #9E92BC",
+" % c #EECA44",
+" & c #EEC644",
+" * c #4E4674",
+" = c #968AB4",
+" - c #363E84",
+" ; c #FEEAC4",
+" : c #363A84",
+" > c #E2DAE4",
+" , c #EAC22C",
+" < c #2E367C",
+" 1 c #827EB4",
+" 2 c #2E327C",
+" 3 c #FAEAAC",
+" 4 c #FAE6AC",
+" 5 c #EAC604",
+" 6 c #7A76AC",
+" 7 c #EAC204",
+" 8 c #7A72AC",
+" 9 c #CAA234",
+" 0 c #C6C2DC",
+" q c #C6BEDC",
+" w c #F6DE94",
+" e c #726EA4",
+" r c #CEA224",
+" t c #726AA4",
+" y c #BEBAD4",
+" u c #BEB6D4",
+" i c #6A669C",
+" p c #6A629C",
+" a c #EABE07",
+" s c #B6B2CC",
+" d c #B6AECC",
+" f c #625A94",
+" g c #F6D26C",
+" h c #826A64",
+" j c #76626C",
+" k c #4E5294",
+" l c #4E4E94",
+" z c #FEFAE4",
+" x c #FEF6E4",
+" c c #F2CA54",
+" v c #9A96C4",
+" b c #464A8C",
+" n c #62526C",
+" m c #46468C",
+" M c #564E74",
+" N c #E6E6F4",
+" B c #3E4684",
+" V c #EEC63C",
+" C c #928EBC",
+" Z c #3E4284",
+" A c #FAEECC",
+" S c #3E3E84",
+" D c #FAE2A1",
+" F c #DEDAEC",
+" G c #FEEABC",
+" H c #8A86B4",
+" J c #363A7C",
+" K c #8A82B4",
+" L c #36367C",
+" P c #EAC224",
+" I c #8A7EB4",
+" U c #EABE24",
+" Y c #D6D2E4",
+" T c #D6CEE4",
+" R c #827EAC",
+" E c #2E3274",
+" W c #827AAC",
+" Q c #2E2E74",
+" ! c #FAE6A4",
+" ~ c #2E2A74",
+" ^ c #F2CE5A",
+" / c #CECADC",
+" ( c #CEC6DC",
+" ) c #7A76A4",
+" _ c #7A72A4",
+" ` c #7A6EA4",
+" ' c #DEB604",
+" ] c #C6BED4",
+" [ c #F6DE8C",
+" { c #F6DA8C",
+" } c #5E5E9C",
+" | c #F2D674",
+".  c #5E5A9C",
+".. c #7E6A6C",
+".X c #7E666C",
+".o c #AAA6CC",
+".O c #AAA2CC",
+".+ c #565694",
+".@ c #F6FAFC",
+".# c #565294",
+".$ c #F6F6FC",
+".% c #F6F2FC",
+".& c #A29EC4",
+".* c #A29AC4",
+".= c #4E4E8C",
+".- c #4E4A8C",
+".; c #EEEEF4",
+".: c #FEF6DC",
+".> c #F2CA4C",
+"., c #EEEAF4",
+".< c #FEF2DC",
+".1 c #EAE6F0",
+".2 c #9A92BC",
+".3 c #464684",
+".4 c #9A8EBC",
+".5 c #464284",
+".6 c #E6E2EC",
+".7 c #E6DEEC",
+".8 c #FEEEC8",
+".9 c #EEC634",
+".0 c #EEC234",
+".q c #FAEAC4",
+".w c #323A84",
+".e c #DEDAE4",
+".r c #DED6E4",
+".t c #2A367C",
+".y c #EAC21C",
+".u c #2A327C",
+".i c #EABE1C",
+".p c #F6E6AC",
+".a c #2E266C",
+".s c #7672AC",
+".d c #E6BE04",
+".f c #E6BA04",
+".g c #D6AE1C",
+".h c #E6B604",
+".j c #C2BEDC",
+".k c #6E6AA4",
+".l c #6E66A4",
+".z c #F6DA84",
+".x c #BAB6D4",
+".c c #F6D684",
+".v c #BAB2D4",
+".b c #66629C",
+".n c #665E9C",
+".m c #866E6C",
+".M c #B2AECC",
+".N c #B2AACC",
+".B c #5E5A94",
+".V c #FEFEFC",
+".C c #F2D26C",
+".Z c #AAA2C4",
+".A c #725E6C",
+".S c #F6F2F4",
+".D c #EECE54",
+".F c #EECA54",
+".G c #FEF2D4",
+".H c #FEEED4",
+".J c #3A4284",
+".K c #3A3E84",
+".L c #3A3A84",
+".P c #EEC62C",
+".I c #FAEEBC",
+".U c #EEC22C",
+".Y c #3E3E74",
+".T c #FAEABC",
+".R c #3E3A74",
+".E c #323A7C",
+".W c #8682B4",
+".Q c #32367C",
+".! c #867EB4",
+".~ c #32327C",
+".^ c #D2CEE4",
+"./ c #2A3274",
+".( c #EABE14",
+".) c #7E7AAC",
+"._ c #2A2E74",
+".` c #7E76AC",
+".' c #2A2A74",
+".] c #F6E2A4",
+".[ c #F6D679",
+".{ c #CAC6DC",
+".} c #CAC2DC",
+".| c #7672A4",
+"X  c #766EA4",
+"X. c #C2BED4",
+"XX c #C2BAD4",
+"Xo c #6E669C",
+"XO c #F6DA7C",
+"X+ c #BAB2CC",
+"X@ c #BAAECC",
+"X# c #92765C",
+"X$ c #9E96C1",
+"X% c #5A5A9C",
+"X& c #4A4689",
+"X* c #5A569C",
+"X= c #FEFEF4",
+"X- c #F2D264",
+"X; c #FEFAF4",
+"X: c #A6A2CC",
+"X> c #F2CE64",
+"X, c #525294",
+"X< c #9E9AC4",
+"X1 c #4A4E8C",
+"X2 c #4A4A8C",
+"X3 c #EECA4C",
+"X4 c #EAEAF4",
+"X5 c #5A4E74",
+"X6 c #9692BC",
+"X7 c #968EBC",
+"X8 c #424284",
+"X9 c #E2E2EC",
+"X0 c #E2DEEC",
+"Xq c #928AB8",
+"Xw c #464274",
+"Xe c #E2DAEC",
+"Xr c #EAC234",
+"Xt c #8E8AB4",
+"Xy c #8E86B4",
+"Xu c #3A3A7C",
+"Xi c #8E82B4",
+"Xp c #EEC224",
+"Xa c #DAD6E4",
+"Xs c #FAEAB4",
+"Xd c #EEBE24",
+"Xf c #DAD2E4",
+"Xg c #FAE6B4",
+"Xh c #323674",
+"Xj c #424687",
+"Xk c #867EAC",
+"Xl c #EABA0C",
+"Xz c #F6E29C",
+"Xx c #2A266C",
+"Xc c #F6DE9C",
+"Xv c #DEB214",
+"Xb c #FADA8C",
+"Xn c #6A66A4",
+"Xm c #D2CADF",
+"XM c #B6B2D4",
+"XN c #9A7A5C",
+"XB c #B6AED4",
+"XV c #625E9C",
+"XC c #AEAACC",
+"XZ c #AEA6CC",
+"XA c #5A5A94",
+"XS c #5A5694",
+"XD c #FAFAFC",
+"XF c #FAF6FC",
+/* pixels */
+".1XX ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]XX.^.V.V.V.V.V.V.V.V.V.<.G.G x.V.V.V.V.V.V.V.<.G.G.<.V.V.V.V.V.V.V.V.V.V.V.V X.G.G.<X=.V.V.V.V.V.V.V.V.V.V.V.V.V.V X ;.p DXs AX;.V.V.V.V.V.V.V.V.G.G.<.V.V.V.V.V.V.V.V.V.V.V . A ;.8.<X=.V",
+"X<./.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.=XD.V.V.V.V.V.V.V.<.(.d.d V.V.V.V.V.V.V.8 a.d.d P ..V.V.V.V.V.V.V.V.V.V.V ^.f.d.f D.V.V.V.V.V.V.V.V.V.V.V.V.G g a.dXl.f.f a.y g.V.V.V.V.V.V.8 a.dXpX;.V.V.V.V.V.V.V.V GX-.i a.d.f.dXd.8",
+"X$._././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././._ QX1XD.V.V.V.V.V.V.V.T.f.fXlXl.I.V.V.V.V.V.z.f.fXl a.G.V.V.V.V.V.V.V.V.V.V x.iXl.d.fX>.V.V.V.V.V.V.V.V.V.V.V |.d.f.f.d.f.f.f.f.f c.V.V.V.V.V.V.q.f.f.yX=.V.V.V.V.V.V.V |.f.f.f.f.f.f.f a.8",
+".*.'._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u 2._ +.@.V.V.V.V.V.V.V D.f a.d.f.c.V.V.V.V.V.0.f.d.d.f.8.V.V.V.V.V.V.V.V.V.V 4.f.d.d.d.y x.V.V.V.V.V.V.V.V.V g.f.f.d.f.U.D ^X3.y.f |.V.V.V.V.V.V A.d.f.iX;.V.V.V.V.V.VX-.f a.d.f , V.U a.( .",
+".*._.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u.u._ lXD.V.V.V.V.V.V.VXO.f.f.dXl.9.V.V.V.V.8 a.f.f.d.f 4.V.V.V.V.V.V.V.V.V.VX-.f.f.f.f.f D.V.V.V.V.V.V.V.V.z.f.d.f.P.TX;.V.V.V X D.8.V.V.V.V.V.V.8.d.f.iX=.V.V.V.V.VXc.f.f.fXd !X;.VX= z.q.V",
+"X<._._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./ 2 Q +.@.V.V.V.V.V.V.V ^.f.d.f.d.d ;.V.V.V.z.f a.d a.fXc.V.V.V.V.V.V.V.V.V.<.(.fXp V.d.fX3.V.V.V.V.V.V.V.G.(.f.f.0.H.V.V.V.V.V.V.V.V.V.V.V.V.V.V.q a.d.yX;.V.V.V.VX=.9Xl.d.( A.V.V.V.V.V.V.V",
+".*._./ 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E.u.u.u._ lXD.V.V.V.V.V.VX; ,Xl a U.f.f.[.V.V.VX3.f aXr.fXl.[.V.V.V.V.V.V.V.V.V w.f.f.[Xc.f.f a.G.V.V.V.V.V.V.[.f.d.d.T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.qXlXl.(X=.V.V.V.V ;.d.f.f [.V.V.V.V.V.V.V.V",
+"X$._._./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u E.u.u Q +.@.V.V.V.V.V.V x a.d.y.[Xl.f ,X=.V x.(.f &.[.f.f.D.V.V.V.V.V.V.V.V.V &.f.f.T x a.d.f D.V.V.V.V.V.VX3.fXl.UX;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V A.d.f.yX;.V.V.V.V.p.f.d.f ;.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u./.u.u._ lXD.V.V.V.V.V.V.8.f.f P.I a.d.f G.V.].f.f | !.fXl.PX=.V.V.V.V.V.V.V A.d.f PX;.V.F.f.fX-.V.V.V.V.VX;Xd.d.f ^.V.V.V.V.V.VX;.T.T.8.V.V.V.V.V.V A.dXl.(X=.V.V.V.V w.f.d.d x.V.V.V.V.V.V.V.V",
+"X$._._./.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./ 2 2.u Q +.@.V.V.V.V.V.V.].fXl & ..9.f.f |.VX-.f.fXs A.d.f a x.V.V.V.V.V.V.VXO.f.f g.V.V.].f.d.i x.V.V.V.V ..y.f.fX-.V.V.V.V.V.V A.d.f.iX=.V.V.V.V.V A.d.f.yX;.V.V.V.V {.f.f.(X;.V.V.V.V.V.V.V.V",
+"X<._.u 2 2 E E 2 2 E 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E E 2 E.u./.u E.u._ lXD.V.V.V.V.V.V.z.f.f ^.VX>.f a &.< P.f.i x.<.d.fXl.8.V.V.V.V.V.VX; V.f.dXs.V.V x U.f.f D.V.V.V.VX;.y.d.f ^.V.V.V.V.V.V A a.f.iX=.V.V.V.V.V.8.dXl.(X=.V.V.V.V w.f.d a.G.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u.u./.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u.u.u.u 2.u./.u.u Q +.@.V.V.V.V.V.VX-.f.f.[.VXz.f.f.y.[ a.fX>.VX=.P.f.f D.V.V.V.V.V.V GXl.d.f.[ D w w.9.d.f.F.V.V.V.V.VXr.f.f.i x.V.V.V.V.V ;.f.f.iX;.V.V.V.V.V.q.d.f.yX;.V.V.V.V D.f.f.f 4.V.V.V.V.V.V.V.V",
+".* Q./.u.u././.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u././.u./.u.u 2.u._ lXD.V.V.V.V.VX; V.f.f w.V.:.d.f.dXl.d.fXg.V.V ^.f.f.[.V.V.V.V.V.V.C.f.d.f.fXl.f.h.f a.f.d.8.V.V.V.V.[.f.d.f.[.V.V.V.V.V A.dXl.(X=.V.V.V.V.V.8.dXl.(X=.V.V.V.V.I.d.d.fX3.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u.u././.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./.u.u./ 2 2./.u.u Q +.@.V.V.V.V.V ..(Xl.f.p.V.V ^.f.d.d.f.y x.V.V |.f.fX>.V.V.V.V.V xXd.f a a.d.( a.y a.d a.f.c.V.V.V.V A.d.d.d.d D.V.V.V.V AXl.d.yX;.V.V.V.V.V.q.d.f.yX;.V.V.V.V XXp.f.f.f.[.V.V.V.V.V.V.V",
+"X<._.u 2 E 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E.u./.u 2./ E.u._ lXD.V.V.V.V.V A.d.f a.8.V.V.].f.d.d.fX>.V.V.V w.f.d V.V.V.V.V.V.].f.f a.8X; . X .X; |.f.d.9X=.V.V.V.V.[.fXl.d a ^ DXs 4 |.fXl.(X=.V.V.V.V.V.8.dXl.(X=.V.V.V.V.VXb.f a.d.f %Xc 4 D.[ V.<",
+"X$._._./.u./.u.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u.u./.u 2.u././.u.u.u Q +.@.V.V.V.V.V 4.f.d.d.<.V.V x a.f a.f D.V.V.V 4.f.f.( x.V.V.V.V ^.f.f c.V.V.V.V.V.VXsXl.f.f.T.V.V.V.V . ^.f.f.f.f.f.d.f.f.d.f.(X;.V.V.V.V.V.q.d.f.yX;.V.V.V.V.VX= ^.f.f aXlXl.f.f.f.f G",
+".* Q.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u././.u./.u./.u.u 2.u 2.u._ lXD.V.V.V.V.V [.h.fXpX=.V.V.V ^.f.f.f.8.V.V.V.8Xl.fXl.8.V.V.V.< a.f.f D.V.V.V.V.V.VX=Xp.f.h.C.V.V.V.V.VX=.z.y.d.f.f.f.h.f.d a &X=.V.V.V.V.V ;.d.f.(X=.V.V.V.V.V.V ..[ a.d.f.h.h.f.f.d 4",
+"X$._._.u./.u././.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u./ 2 2./././.u.u Q +.@.V.V.V.V.V.8 D.p.p.V.V.V.V.G D.p 3X;.V.V.VX= 3 !.p x.V.V.V x.p.p.p ..V.V.V.V.V.V.V.T !.p.T.V.V.V.V.V.V.V x G w.z.z [ w.p.GX=.V.V.V.V.V.V . 4 !Xg.V.V.V.V.V.V.V.V.V.:Xg w.z [ w !.qX;",
+"X<._./ 2 2 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 E 2.u.u./ 2.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._././.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u./.u.u E./.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u./.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./.u.u.u.u.u E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u././.u.u./.u././.u.u./.u.u./.u.u./.u.u./.u./.u.u./ E 2./.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2.u Q Q Q ~.'._._._.u.u 2._._ Q.'.' Q Q 2 E 2 E 2 2 2 2 E 2.u.u./ 2./ 2./ 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./._.'._.E b.b RX7.OXZ.v u.{ yXBXZ.& = _ l <._._._.u././.u./.u./ 2./.u.u.u./.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u._._.'.uX1.!XBX0XD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.rX$.b <.'._.u.u./.u./.u./.u E.u E.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._._ <XS.2XfXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXa R :._./.u.u.u 2 2./.u./.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2.u Q Q S H.r.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V TX, Q./././.u 2.u 2./ 2.u E.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u./.u._.' Q l.& @.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$ W Q 2.u./.u././.u.u./.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./._ JXn.xX;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX< 2.u./ 2.u E.u 2./ 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._._.l F.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V d E.u.u./.u.u./.u.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 Q ~X,X..V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V X X.V.V.V.VXi._ 2./ E.u E.u E./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u././.u.u./.u././.u.u./.u././.u.u./.u./.' - v.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V xXp V.V.V.V.V @.=._.u.u.u.u./.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._XS.e.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V xXsXs.I.8.8.G xX=Xg.fXl.:.V.V.V.V.& Q./ E.u 2./ 2./ E.u._ lXD.V.V.V.V.V.V @.^X4.V.V F.r.V.V.V.V.V.V.VX$.M.V.V.V.V.V.V.V.V.V.V.V.V.V.VX0 Y.V.V.V.,.1.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V u.b.7.V.V.V.V.V.V.V.V.V.V.V.V.*.{.V.V.V.V.V",
+"X$._._./.u./.u.u./.u.u./.u.u./.u.u.u.u./.u Q._ 6XF.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.GXd.f.fXl.f.f.f a a aXl a x.V.V.V.V.6 J.u.u.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.* ~ _.VXD m -.%.V.V.V.V.VXF.K.n.V.V.V.V.V.V.V.V.V.V.V.V.V.@ b./ q.V.VX1Xy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V v.'.^.V.V.V.V.V.V.V.V.V.V.V.@.K K.V.V.V.V.V",
+"X<._.u 2 2 E E 2 2 E 2 E 2 2 E E E E 2./._.5XZ.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V [.f a.i a 7 a.d.f.f.d.d g.V.V.V.V.V.V _._ E.u 2.u 2.u 2.u._ lXD.V.V.V.V.V.V.)Xx Z #.^ E.uXe.V o.!X$X4.V K.O.VXaX7X7 /.V T.NX$Xe.V.V.V.x._._.`.VX@.Q. .} NXC.vXq /.MXy.{.V.$.ZXyXCXF.V y WXM.V.MXB.2.M.VX<./.2Xq /.V.%.O.! u.V.^XCX$ /X$XX.VXa.2Xq.6",
+"X$._._.u./.u.u.u./.u./.u.u./.u.u.u.u._ ~ t @.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V {.h V .X; X.G.8.8.I.T.G.V.V.V.V.V.V.V (.t.u.u././././.u.u Q +.@.V.V.V.V.V.V } 2._.M.W < < s.VXn R JX .V Z e.$.5 b m 2XaXqXx b Y.V.V.V tX2Xo.QX4 v.tXj o.v Q ZX2 2.- S.K.V I <X* Q.!XX 2.s.M.@.L < k Q.MXZ.'X8 mX&.V e J e JX0Xy.a Z.xX%XqX0.QX8XV.^",
+".* Q./.u.u././.u.u.u./.u.u./.u./.u.u.uXy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 4.f a.G.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXFX1 Q.u 2.u 2./ 2.u._ lXD.V.V.V.V.VXF.J t Z fX2X  <Xq.V YX7.KX*.@ S.s d.QX4X0._.2X7 :.;.V.V.V.$ m.W.x.' o.V.5Xy.VXB._.NXC.u.6Xq 2X0 Z v.V.B mX:.' W.,.$ <Xo @.u WX:._XXXZ - > : Z i._.OXq._Xa.VX1X7X7._Xe.V.V",
+"X$._._.u./.u.u.u././.u.u./.u./.u._._.2.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.G.d.f {.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 6._.u./.u./.u.u.u Q +.@.V.V.V.V.V.6.uX6.` QXh.x <.` Y.KXn SXAXF Z.|.& -XFX0 Q.2Xt k.V.V.V.V Y.u L -._.b.VXj K.VXM._ /XC.E.V =.t.e L o.V.b ZXDX:.~X&X4 <Xy.V._ K.Z.uXeXZ.KX0 2XS.O o., K 2.%.V +.2 =._X4.V.V",
+"X<._.u 2 E 2 E 2 2 E 2 2 2 2 2 2 QXy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX;Xr.f ^.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.O E.u E.u E.u E.u._ lXD.V.V.V.V.VXX.'X+.xXx S.;X2.B =.' K L.+.$ SX Xf E i.#.Q.7 W +.V.V.V.VXkX8 d u.n Q T.- m d.v.'.}XZ L.VXy Q @ f Z.|._ K.6X6.3.Y.1 :.+ e 2 /.*._Xa.O L.;X, SX$Xt.;.! E.%.VX2Xq.M ~X*.`.^",
+"X$._._./.u./.u.u./.u.u./././._._X7.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V |.f.( x.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V Y.u./.u.u.u./.u.u Q +.@.V.V.V.V.V 0.n Y.%Xn =.VXi 8 F i.+ tXy.@ ZXn.VX7 bXSXM.V.Z.!.V.V.V.V.!X<.V.V 0X%.jX$ bXy /.bX0 0 e.V d.bXD TX*X2 K.V (.=. .{.@ -.L.+XZ.V u.n.,.} tXDXa pX2XS.1XZ i.@.V WXZ.V K.= k.^",
+".* Q.u.u.u./.u.u./.u.u.u.u./ 2X6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXs.f.f D.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.K./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V #.v 2X .V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @.u.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._././.u.u./.u././.u._._.&.V.O.`.* yX0.$.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V ..P.fX>.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.B._.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.{ -X2 T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.S BXq.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u 2 E 2 2 E 2 2 E.u Q.!.VXX <.'._ 2 < Z.+ tXqXC.{.,.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V |.fXpX=.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V p._ E.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.;.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.S.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u./.u.u.u.u Q.+.V.6X8.'.u._./ Q Q Q._.' Q.u.E mXV.) v.x Y @.V.V.V.V.V.V.V.V.V.V.VX= w ^ ^ ^X-X-.[.[ [X3.f.( X.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V W.'.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u./.u.u./././.u.u.u q.V. ._.u 2.u.u.u.u 2.u.u.u.u Q._._.'.'.u 2 :X,Xn.{.V.V.V.V.V.V.V.V.[.f.f.f.h.h.f.f.h.h.f.h.>.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V H.' E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./.u.u.u./.'Xo.V.).'.u././.u.u.u.u.u./.u./ 2.u.u 2./.u._.u._._ ~ :.x.V.V.V.V.V.VX;.0.f P ^.D VXr ,Xp.y P  .G.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXi.'.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 2 E 2 E 2._ ZX4.2._._ 2.u./.u./././ 2./ 2././.u./ 2./.u E.u.u./ E._ 2 RXD.V.V.V.V.VX3.f ^.V.V.VX;X; . .X;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXy.' E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u./.u./.u.u._.*.r L._ 2./.u 2 E 2 2.u.u 2.u.u.u E.u.u.u./.u 2 E.u.u.u./.'.b @.V.V.V.V {.h UX=.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXy.'.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u Q.3.V.4 ~.u.u E.u.u./.u E././.u./ 2.u./.u.u 2./.u.u.u./.u 2.u.u.'.+X4.V.V.V.8.dXl.I.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.W.' E.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./././.u.u._Xq.V q.u././.u.u./.u./.u.u.u./ 2.u./ 2./ E./.u.u./ E.u E.u E.u.u.'XV @.V.VX=.0.h.c.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V t._.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u 2 2 E.u._ LX0.V @.K Q.u./.u.u.u.u E.u 2./.u.u./ 2.u.u E.u.u.u 2.u./.u./ 2.u./.'X,.6.V.V.[Xl %.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXV._ E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u 2 Q.k.V.V.V.+._./ 2 E 2 E./.u E./.u.u E.u.u.u./.u 2 E./.u./.u.u.u./.u.u.u._ m.^.V 4.f a.<.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V l._.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u././.u.u._XB.V.V.V 8._.u.u./.u 2.u.u.u./ 2.u./././ 2./.u.u.u./.u E.u E.u E._ Q Q.u ~.E vX;.U.f w.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @Xu./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./._.J #.V.V.V.* Q._./.u./.u./.u./ 2.u./ 2.u 2.u.u./.u E.u E.u 2._.u.RX5 M *Xu J././XyX-.hX-.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V (.t.u.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u E.u.u ~ i.V.V.V.V Y <.u.u.u./ 2./ 2./.u.u./ 2././ 2.u./.u 2.u./.u.u Q...h a.d.fXvXvXv.g rXl.f g.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V o._./ 2.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u 2.u.'Xq.V.V.V.V.$ b Q 2 E.u.u 2./.u.u E.u./.u.u.u E 2.u././.u.u./.Y ' 7.f a a.d 7 7 7 5 7.g.p.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.!.'.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V T.!XnX  /.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXDXy u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V F.KX$.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q./.u E.u.u.x.V.V.V.V.V 8.'.u E./.u.u./ 2.u.u.u./ 2./.u./.u.u.u E.u.u._Xw.f 7.X *X5X5 n.A.X.m jXu.kXF.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXA._.u E.u 2.u 2.u._ lXD.V.V.V.V.V.V.O./.QX, S.&.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @ Q W.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V >.+XC.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u./ < F.V.V.V.V.V.Z./._.u.u.u./ 2././ 2./ 2./.u./.u E.u E.u E.u.u.u 9 5X#._ Q._./._._._._._.'.+Xa.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.6.L Q.u.u./././.u.u Q +.@.V.V.V.V.V.6 J.=X4.V.V.V.VXMX%. .kX0.V oXn eX*X7Xn.+.v.V YXn.s.+ K.!X,X$.VXDX X%. .M.V.V.V.V.V.V.V #.t.!.V.M.l.kX*X7X .+XX.V FXn. .b T.V @ K. . .  /.VXV.N.V.W eXn.+XC.V.; W.  f.+.o",
+"X<._._.u.u._.K.S.V.V.V.V.V.6 :._ E.u 2./.u.u./ 2.u.u 2.u./.u E.u./.u E.u./._ h 5XN./././././././ 2.u.u._ :XB.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.O././.u 2.u 2./ 2.u._ lXD.V.V.V.V.VXB QXZ.V.V o q.V (.N o./ o.V I.aXy.n._ $X8XS.VXX.'X .|Xx.k 6 S O.@XZX. f.#.V.V.V.V.V.V.V @.t.!.VX7XxXt. .' HXAX*.V.6.o yX8X .VXq._Xa W L.6 @._Xy.V.# Q $ m.#.V 1 2X0.`.a /",
+"X$._.u.u./._X,.V.V.V.V.V.V.VXA._.u 2./.u.u E.u.u././.u E 2.u.u.u.u.u.u E.u./ E MXh./.u.u 2.u.u.u.u.u 2 2 Q E.O.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX .' 2././.u./.u.u.u Q +.@.V.V.V.V.V s.' v.V.VX& W.VXaXn b._ o.V R <.VXk.#.V.+.+.VX. <.6 o E T u - #.VX$X, :.+.V.V.V.V.V.V.V # 2 R.V =.K.V K <.VXk k.VXF KX2.t.k.VX7._.*.nX*.V.,._Xq.V.+X,.V.  +.VXy <X: f.K.%",
+".*._./ 2 2 Q. .V.V.V.V.V.V.VXy.'./.u.u E.u./.u.u 2./.u./.u././ E.u./.u.u.u./._ Q._.u./.u./ 2 E./ E./.u.u.u._ S.%.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @X8._ 2.u E.u E.u E.u._ lXD.V.V.V.V.V N LX8 /.%X2 K.VXSX&.x <X:.V W.K.V R.+.VX,X,.VXX JXDX<./ F.v -XD.j._X$ eX,.V.V.V.V.V.V.V @ <.!.VXq Z.VXk.K.V W k.VXq._XBX2Xn.V.{.uXj iXa.V.,._Xq.VX,. .V. X,.V.x._ b.b.}.V",
+"X$ Q.u./.u._XV.V.V.V.V.V.V.V.x./.u.u E.u.u 2./ 2./.u.u.u E.u 2.u E.u.u 2./.u.u.u.u E 2./ 2./.u.u.u.u./.u./._.uXX.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.{.u.u.u.u.u.u.u./.u.u Q +.@.V.V.V.V.V.V.Z < 2.t.' C.V.b < b.uX$.V 1 -.V WXS.V.+.+.V.j LXD.*._.e.vXu.@.{.uXj.LX1XD.V.V.V.V.V.V #.u W.VXq S.V 1.K.V.!.=.V v Q k./ t.V.v./ SX, K.V.;.uXq.VX,XA.VX% +.V o._X8X, ).,",
+"X$ ~._.u./._.b.V.V.V.V.V.V.V.;.K E.u./.u./ 2./.u E.u./.u 2./.u.u E.u./ 2 2.u.u./.u.u.u.u.u.u E.u./.u E 2.u./._ K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX$._./ E./ 2./ 2.u 2.u._ lXD.V.V.V.V.V.V.VX0 o v d @.V.7X$ u.} F.VXf y.VXa.{.V 0.{.V.;.xX;X0.v.$X4 uX;.V uX< / 0.V.V.V.V.V.V.V.V.x.r.V FXX.V Y y.VXf.}.V.@XZ.O ( /.VX$.w.2 8 QXX.V.v F.V.} /.V /.}.VXy :.2 W.' $",
+".*._.u./.u._XV.V.V.V.V.V.V.V.V.b.'./.u E.u.u.u.u.u E 2.u./.u.u./.u E.u././.u./.u.u./ E.u././.u./ 2 2.u./ 2 2.'X,.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.B._.u.u.u./.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 8./X$.| Z F.V.V.V.V.V.V.V.V.V.VXo.Q.*.).QXX",
+"X<._.u 2.u.'. .V.V.V.V.V.V.V.VX$.'./.u./.u./ E.u.u./.u.u./ E.u.u.u./.u.u E 2 2./.u.u./ 2 2.u 2./.u.u.u./.u.u./.u T.V.V.V.V.V.V.V.V.V.V.V.V.V.VXX._.u./ 2.u E.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.,Xq p 1X9.V.V.V.V.V.V.V.V.V.V.V.1 H.b.`.^.V",
+".*._._.u E./ bXF.V.V.V.V.V.V.VXm <.u.u 2./ 2.u././.u 2./ 2.u E.u./ 2.u.u.u.u./ 2 2./ 2.u./.u./.u./.u./.u.u./.u QX6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.k Q./.u././.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$ Q./.u.u._ J @.V.V.V.V.V.V.V.$.3 Q.u 2./.u 2.u./.u 2./.u.u E.u./ 2 E././.u./.u.u./.u.u E.u./.u E 2./.u 2./.u ~ p.V.V.V.V.V.V.V.V.V.V.V.V.VXf.Q Q 2.u 2./ 2.u E.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._././.u.t (.V.V.V.V.V.V.V.VXk.'._./.u./.u E 2.u./.u.u./.u 2.u./.u.u.u.u.u./ E.u.u./.u.u 2 2.u./ 2 2./ 2./.u.K.,.V.V.V.V.V.V.V.V.V.V.V.V.)._.u.u.u./.u.u./.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._ 2.u.u.u.O.V.V.V.V.V.V.V.V.V.!._._ 2./.u./.u.u./ E.u./.u./.u./ 2 E E.u.u.u./ 2 2./ E./.u./.u./.u.u.u.u./.u.uXB.V.V.V.V.V.V.V.V.V.V.VXe :./.u E.u E.u 2./ 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._.u.u././.'.`.V.V.V.V.V.V.V.V.V.V I.u./.u./.u 2./ 2.u 2.u./ 2.u.u./.u.u E 2./ 2.u./.u.u.u./.u.u.u././.u E.u./.'.`.V.V.V.V.V.V.V.V.V.V.V.|.'.u./.u./.u.u./.u.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._ 2 2 2 QX2XD.V.V.V.V.V.V.V.V.V.V.N L._.u./ 2.u././ 2.u./ 2 E.u.u./.u./.u./.u.u E.u./.u E 2./.u 2./.u E.u./._ mXF.V.V.V.V.V.V.V.V.V.x.u./ 2.u 2./ 2.u E./ 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$ Q.u.u./.u./.t /.V.V.V.V.V.V.V.V.V.V.V 0 S ~.u././.u.u.u E.u./.u.u./.u.u.u E.u.u./.u./ 2 2.u./ 2 2./ 2.u.u 2.u.u.u 0.V.V.V.V.V.V.V.VXD + Q 2.u././.u.u./.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._./.u./.u.u.'Xy.V.V.V.V.V.V.V.V.V.V.V.V YX2.'.u E.u./.u.u.u./ 2 2 E.u./.u./ 2 2.u 2./.u./.u.u./.u./.u././ 2././.'Xq.V.V.V.V.V.V.V.VX$.'._.u 2.u E.u 2./ 2.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._.u.u.u 2 QX2.@.V.V.V.V.V.V.V.V.V.V.V.V.6.+ ~.u E.u./ E./.u.u./.u E 2.u 2././.u./.u./.u.u./.u.u.u E.u.u./.u 2 QX*.V.V.V.V.V.V.V.6.L.u.u./.u./.u.u./.u././././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._ E.u./.u.u QXB.V.V.V.V.V.V.V.V.V.V.V.V.V.;.#.'._.u.u 2 E.u.u./.u./.u./.u.u E.u.u.u E 2.u./ 2./.u E.u.u 2./.u./.EX0.V.V.V.V.V.V H.'./ 2./ 2./ 2.u 2.u 2.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u E.u./.u._X,XD.V.V.V.V.V.V.V.V.V.V.V.V.V.; 8 Q E.u./.u.u./.u.u.u E.u.u./.u.u E E.u.u E 2./ 2.u.u E././.u.u._ ~.*.V.V.V.V.V.M 2 E.u.u.u.u.u./././.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X< Q./.u.u.u./.u./._X:.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXq./._.u E 2 E.u./.u.u E 2./ 2.u.u./.u.u./.u./.u./.u 2.u./.u.u.u.' i.V.V.V.V F.K.' E.u E./ 2.u 2.u E.u E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._.u./ 2 E.u.u.u Q.3 #.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V o < Q.u./.u E 2.u E.u./.u.u././.u.u./.u.u.u E.u.u./.u 2 E./.u./.K #.V.VXDXS Q.u.u./.u.u./.u./.u.u.u.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.^XX.6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @Xn u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V Y.^ Y.^ Y.V.V.V.V.@.l.O.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$.'.u./.u E 2 E.u 2._ K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.x J._.u.u./.u.u.u.u E.u.u.u E 2.u./ E.u.u 2./.u E.u.u 2./ 2.u.u d.V.V.`.'.u./ 2./ 2.u E.u E./ 2./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.^.=.u._.b.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.1._.2.V.V.V.V.V.V.V.V.V.V.V.V.V.V.,.K.u 2.u -.;.V.V.V @ Q.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._./.u.u.u./.u.u.u._ < T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V /.K._./.u E.u././.u.u E E.u.u E 2.u 2././ 2.u.u././.u 2.u._.' o.VX$./.u E.u.u.u.u./.u.u.u.u./.u.u.u././.u.u Q +.@.V.V.V.V.V.V.- 2 o y q.V.{ K.v.V.;XXXB q.VXZXyXe.V (.{XC.2 # # <.*.;.N.,.$ oXqXa @.v.,.V.}.}.V.V.{Xq./XqXmX0X7.*.%.%.t R.V TXy.oXD.V.j K.v.VXFXZ.2.,.V.MXy /.VXa y uXqXa.V @.& = F.V",
+".*.'./.u./.u./.u.u.u.u._.l.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXX.L.'.u./ 2 2./ 2.u.u./.u.u./.u./.u.u./ 2./.u.u././.u.u.'.s.V.M 2./.u E.u E./ 2./ 2./ 2.u E.u E.u 2./ 2.u._ lXD.V.V.V.V.V (._ K.V.V.VXZ <X1.tX$ /.t._X7 R : b.=.%. ._ -._X7XD.tX7.+X8 FX% 2.t :.v.K.2.$ <.|.V.V.V.v._.x.V.+.3 J i.S <Xy T :X2.t KXX.uX2X7.V i._.K.{ `.u < :X0Xq.' -.uX,XDXV -Xj ZX9",
+"X< Q._ E.u.u.u E.u E E.u._.`.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V F.B.'.u.u./.u.u././.u.u./.u./.u E.u.u./.u E 2.u.u._._ R.V y 2._.u.u.u./.u.u.u.u./.u.u./.u./.u././.u.u.u Q +.@.V.V.V.V.V.N ~X$.V.V.V f < p.~XS.j.u.M Y 2XjXV._ yXV S.1XV.k.@ : <.LX9X$ Q /.6 2 _.lX2 C._ (.V.V.VX+.u qXX._.b.3.~X0.Q K.|./ p S.5X$ QX X0 0.'X<.V y._.&XD.3Xq.2._Xm.N.KXZ Q.=XS ~.*",
+"X<._.u 2 E E.u E.u.u./ 2.u Q K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.@X ._.'._._._._.u./.u.u 2.u.u E.u.u 2.u./ 2./.u.'X .V (.K Q 2././ 2./ 2./ E.u E.u 2./ 2.u 2.u E.u E.u._ lXD.V.V.V.V.V (._.k.V.V.V.+Xj o.o 0XX :.$.{ Q i.o.ZX9.+.+.V p p.S J J.Q.rXy._.6.@ < WXZ._ <X%.V.V.V.V.v./ q.N.uX7.oXC.,.E.!.b -X<.o.M #X$ J.-XZ._XB.VXB Q.v.VX2XyX7.u.V.N S o.u 8.o.ZXa",
+"X$ ~._._._._._._._._.'._._.'.'.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXD.vXq tX* Z <./ Q._ Q._ Q._._ ~._._._._._ Q.'Xn.VXX.QXx._.' Q._._._._._._._._._._._._._._._._._._._.'.-.@.V.V.V.V.V.V f.aX,XV 1.`._ H I.v ] L.,XD Z.5X7.W.S.# +.V.b p.$.~XyX&X2.o QXS.n._ y.$.K.a.*.V.V.V.VX+.' y.6 L t =.2X4._XyX$.' WXy.* TX6 m S / 2.3.`XZ.Q b t <XaXq._ RXjX, F JX,.2 W.7",
+"XM.#XSX*X*XSX*XSX*. XAXSX%XS.+.+ u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXFX0 y.*.)XVXSXSX*XAXSXSXSX*XAX%.+Xo @.,Xn.+X*XAX%. X%. XA. X%.BX%.BXA. X%.BXA.BX%.BX%. . .+ 8.V.V.V.V.V.V.VX4.W.#.= =.;.`X1.=XCXa.k @.V /.b m.lXFXi K.VX7X7.$ i 0XXXS.{ o kX,XZ.V.VXq.b.,.V.V.V.VXmXVXm.VXC kX1Xk.@.l.O.V K lX2X$XXX2XV q.VXCX,.+Xa.vX*X2X<.V H.'.-.l T.V.xXAX1XV.7",
+".V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXDXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V I.u.;.V.V.V.V.V.V.V.V",
+".V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXi < @.V.V.V.V.V.V.V.V"
+};
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/AnalysisLinkDef.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MCerPhotPix+;
+#pragma link C++ class MCerPhotEvt+;
+#pragma link C++ class MCerPhotAnal+;
+#pragma link C++ class MCerPhotCalc+;
+
+#pragma link C++ class MImgCleanStd+;
+#pragma link C++ class MCameraSmooth+;
+
+#pragma link C++ class MBlindPixels+;
+#pragma link C++ class MBlindPixelCalc+;
+
+#pragma link C++ class MPedestalPix+;
+#pragma link C++ class MPedestalCam+;
+#pragma link C++ class MMcPedestalCopy+;
+#pragma link C++ class MMcPedestalNSBAdd+;
+
+#pragma link C++ class MHadronness+;
+
+#pragma link C++ class MCompProbCalc+;
+#pragma link C++ class MMultiDimDistCalc+;
+
+#pragma link C++ class MSrcPosCam+;
+#pragma link C++ class MHillas+;
+#pragma link C++ class MHillasSrc+;
+#pragma link C++ class MHillasSrcCalc+;
+#pragma link C++ class MHillasExt+;
+#pragma link C++ class MHillasCalc+;
+
+#pragma link C++ class MEnergyEst+;
+#pragma link C++ class MEnergyEstimate+;
+#pragma link C++ class MEnergyEstParam+;
+
+#pragma link C++ class MMatrixLoop+;
+
+#pragma link C++ class MPedCalcPedRun+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc	(revision 1638)
@@ -0,0 +1,344 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch    12/2001 <mailto:blanch@ifae.es>
+!   Author(s): Thomas Bretz    08/2002 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MBlindPixelCalc                                                        //
+//                                                                         //
+//  This is the specific image cleaning for a list of pixels. This task    //
+//  sets the pixels listed in fPixelsID to unused so they should not be    //
+//  used for analysis (eg calculation of hillas parameters).               //
+//                                                                         //
+//  If you specify an array of pixel IDs this pixels are disabled.         //
+//  In all other cases the task tries to determin the starfield from the   //
+//  MMcRunHeader and disables pixels correspoding to the starfield.        //
+//                                                                         //
+//  Implemented star fields:                                               //
+//   - Crab: 400, 401, 402, 437, 438, 439                                  //
+//                                                                         //
+//  You can use MBlindPixelCalc::SetUseInterpolation to replaced the       //
+//  blind pixels by the average of its neighbors instead of unmapping      //
+//  them. If you want to include the central pixel use                     //
+//  MBlindPixelCalc::SetUseCentralPixel                                    //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MCerPhotEvt                                                           //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MBlindPixels                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MBlindPixelCalc.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+#include "MBlindPixels.h"
+
+#include "MMcRunHeader.hxx"
+
+ClassImp(MBlindPixelCalc);
+
+static const TString gsDefName  = "MBlindPixelCalc";
+static const TString gsDefTitle = "Task to deal with hot spots (star, broken pixels, etc)";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBlindPixelCalc::MBlindPixelCalc(const char *name, const char *title)
+    : fFlags(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  - Try to find or create MBlindPixels in parameter list.
+//  - get the MCerPhotEvt from the parlist (abort if missing)
+//  - if no pixels are given by the user try to determin the starfield
+//    from the monte carlo run header.
+//
+Bool_t MBlindPixelCalc::PreProcess (MParList *pList)
+{
+    if (TESTBIT(fFlags, kUseBlindPixels))
+        fPixels = (MBlindPixels*)pList->FindObject("MBlindPixels");
+    else
+        fPixels = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+    if (!fPixels)
+	return kFALSE; 
+    
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeomCam)
+        *fLog << warn << dbginf << "No camera geometry available... can't use interpolation." << endl;
+
+    if (TESTBIT(fFlags, kUseBlindPixels))
+        return kTRUE;
+
+    const UShort_t size = fPixelsID.GetSize();
+
+    if (size == 0)
+    {
+        if (!pList->FindObject("MMcRunHeader"))
+        {
+            *fLog << warn << "Warning - Neither blind pixels are given nor a MMcRunHeader was found... removing MBlindPixelCalc from list." << endl;
+            return kSKIP;
+        }
+        return kTRUE;
+    }
+
+    // Set as blind pixels the global blind pixels, which are given
+    // through the macros
+
+    UShort_t numids = fPixelsID.GetSize();
+
+    for(Int_t i = 0; i<numids; i++)
+	fPixels->SetPixelBlind(fPixelsID[i]);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Replaces each pixel by the average of its surrounding pixels.
+//  If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also included.
+//
+void MBlindPixelCalc::Interpolate() const
+{
+    const UShort_t entries = fEvt->GetNumPixels();
+
+    Double_t *nphot = new Double_t[entries];
+    Double_t *perr  = new Double_t[entries];
+
+    //
+    // remove the pixels in fPixelsID if they are set to be used,
+    // (set them to 'unused' state)
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t id = pix.GetPixId();
+
+        if (!fPixels->IsBlind(id))
+            continue;
+
+        const MGeomPix &gpix = (*fGeomCam)[id];
+
+        const Int_t n = gpix.GetNumNeighbors();
+
+        Int_t num = TESTBIT(fFlags, kUseCentralPixel) ? 1 : 0;
+
+        nphot[i] = TESTBIT(fFlags, kUseCentralPixel) ? pix.GetNumPhotons() : 0;
+        perr[i]  = TESTBIT(fFlags, kUseCentralPixel) ? pix.GetErrorPhot()  : 0;
+        for (int j=0; j<n; j++)
+        {
+            const UShort_t nid = gpix.GetNeighbor(j);
+
+            if (fPixels->IsBlind(nid))
+                continue;
+
+            const MCerPhotPix *evtpix = fEvt->GetPixById(nid);
+            if (evtpix)
+            {
+                nphot[i] += evtpix->GetNumPhotons();
+                perr[i]  += evtpix->GetErrorPhot();
+            }
+            num++;
+        }
+
+        nphot[i] /= num;
+        perr[i]  /= num;
+    }
+
+    if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam)
+        for (UShort_t i=0; i<entries; i++)
+        {
+            MCerPhotPix &pix = (*fEvt)[i];
+
+            if (fPixels->IsBlind(pix.GetPixId()))
+                pix.Set(nphot[i], perr[i]);
+        }
+
+    delete nphot;
+    delete perr;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Removes all blind pixels from the analysis by setting their state
+//  to unused.
+//
+void MBlindPixelCalc::Unmap() const
+{
+    const UShort_t entries = fEvt->GetNumPixels();
+
+    //
+    // remove the pixels in fPixelsID if they are set to be used,
+    // (set them to 'unused' state)
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        if (fPixels->IsBlind(pix.GetPixId()))
+            pix.SetPixelUnused();
+
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Treat the blind pixels
+//
+Bool_t MBlindPixelCalc::Process()
+{
+    if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam)
+        Interpolate();
+    else
+        Unmap();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set pixels to no be used. 
+//  This member function (public) should be called from the macro (or
+//  analysis program) setting the desired blind pixels.
+//  In the future, the blind pixels may be extracted from information which
+//  is already in the root file.  
+//
+void MBlindPixelCalc::SetPixels(Int_t num, Short_t *ids)
+{
+    fPixelsID.Adopt(num, ids);
+}
+
+// --------------------------------------------------------------------------
+//
+//  - Check whether pixels to disable are available. If pixels are
+//    given by the user nothing more is done.
+//  - Otherwise try to determin the blind pixels from the starfield
+//    given in MMcRunHeader.
+//
+Bool_t MBlindPixelCalc::ReInit(MParList *pList)
+{
+    if (TESTBIT(fFlags, kUseBlindPixels))
+        return kTRUE;
+
+    //
+    // If pixels are given by the user, we are already done
+    //
+    if (fPixelsID.GetSize() > 0)
+        return kTRUE;
+
+    //
+    // Delete the old array holding the blind pixels for the last file
+    //
+    fPixels->Clear();
+
+    //
+    // Set as blind some particular pixels because of a particular
+    // Star Field of View.
+    //
+    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrun)
+    {
+        *fLog << warn << "MBlindPixelCalc::ReInit: Warning - No run header available... no action." << endl;
+        return kTRUE;
+    }
+
+    Int_t rah, ram, ras;
+    Int_t ded, dem, des;
+    mcrun->GetStarFieldRa(&rah, &ram, &ras);
+    mcrun->GetStarFieldDec(&ded, &dem, &des);
+
+    if (rah!=5 || ram!=34 || ras!=32 || ded!=22 || dem!=0 || des!=55)
+    {
+        *fLog << warn << "Warning - Starfield unknown..." << endl;
+        return kTRUE;
+    }
+
+    //
+    // Case for Crab Nebula FOV
+    //
+    fPixels->SetPixelBlind(400);
+    fPixels->SetPixelBlind(401);
+    fPixels->SetPixelBlind(402);
+    fPixels->SetPixelBlind(437);
+    fPixels->SetPixelBlind(438);
+    fPixels->SetPixelBlind(439);
+
+    *fLog << inf;
+    *fLog << "FOV is centered at CRAB NEBULA: Setting 6 blind pixels" << endl;
+    *fLog << "to avoid bias values of analysis due to CRAB NEBULA:" << endl;
+    *fLog << "   Pixels: 400, 401, 402, 437, 438, 439" << endl;
+
+    return kTRUE;
+}
+
+void MBlindPixelCalc::StreamPrimitive(ofstream &out) const
+{
+    out << "   MBlindPixelCalc " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    if (TESTBIT(fFlags, kUseInterpolation))
+        out << "   " << GetUniqueName() << ".SetUseInterpolation();" << endl;
+    if (TESTBIT(fFlags, kUseCentralPixel))
+        out << "   " << GetUniqueName() << ".SetUseCentralPixel();" << endl;
+
+    if (fPixelsID.GetSize()==0)
+        return;
+
+    out << "   {" << endl;
+    out << "      TArrayS dummy;" << endl;
+    for (int i=0; i<fPixelsID.GetSize(); i++)
+        out << "      dummy[" << i << "]=" << ((TArrayS)fPixelsID)[i] << ";" << endl;
+    out << "      " << GetUniqueName() << ".SetPixels(dummy);" << endl;
+    out << "   }" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixelCalc.h	(revision 1638)
@@ -0,0 +1,65 @@
+#ifndef MARS_MBlindPixelCalc
+#define MARS_MBlindPixelCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MBlindPixels;
+
+class MBlindPixelCalc : public MTask
+{
+private:
+    MCerPhotEvt  *fEvt;     //!
+    MBlindPixels *fPixels;  //!
+    MGeomCam     *fGeomCam; //!
+
+    TArrayS fPixelsID;  // Pixel IDs for blind pixels, which are entered by the user.
+
+    Byte_t fFlags;      // flag for the method which is used
+
+    enum
+    {
+        kUseInterpolation = 1,
+        kUseCentralPixel  = 2,
+        kUseBlindPixels   = 3
+    };
+
+    void Interpolate() const;
+    void Unmap() const;
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MBlindPixelCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetUseInterpolation(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kUseInterpolation) : CLRBIT(fFlags, kUseInterpolation);
+    }
+    void SetUseCentralPixel(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kUseCentralPixel) : CLRBIT(fFlags, kUseCentralPixel);
+    }
+    void SetUseBlindPixels(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kUseBlindPixels) : CLRBIT(fFlags, kUseBlindPixels);
+    }
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    void SetPixels(Int_t num, Short_t *ids);
+    void SetPixels(const TArrayS pix) { SetPixels((Int_t)pix.GetSize(), (Short_t*)pix.GetArray()); }
+    virtual Bool_t ReInit(MParList *pList);
+
+    ClassDef(MBlindPixelCalc, 1) // task to deal with hot spots (star, broken pixels, etc)
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.cc	(revision 1638)
@@ -0,0 +1,64 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch    12/2001 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MBlindPixel                                                             //
+//                                                                         //
+// If you want to exclude pixels from the analysis (eg. hillas parameter   //
+// calculation) you can use this container to switch off the pixels by Id  //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MBlindPixels.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MBlindPixels);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBlindPixels::MBlindPixels(const char *name, const char *title) : fPixels(577)
+
+{
+    fName  = name  ? name  : "MBlindPixels";
+    fTitle = title ? title : "Container which have a list of blind pixels";
+}
+
+// -------------------------------------------------------------------------
+//
+// If you don't want to use pixel with Id id call
+//    SetPixelBlind(id, kTRUE)
+// otherwise
+//    SetPixelBlind(id, kFALSE)
+//
+void MBlindPixels::SetPixelBlind(UShort_t id, Bool_t val)
+{
+    fPixels.AddAt(val, id);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MBlindPixels.h	(revision 1638)
@@ -0,0 +1,31 @@
+#ifndef MARS_MBlindPixels
+#define MARS_MBlindPixels
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+class MBlindPixels : public MParContainer
+{
+private:
+    TArrayC fPixels; // Boolean value for every pixel 0=on, 1=blind
+
+public:
+    MBlindPixels(const char *name=NULL, const char *title=NULL);
+
+    void SetPixelBlind(UShort_t id, Bool_t val=kTRUE);
+    void AdoptPixels(Char_t pixels[577]) { fPixels.Adopt(577, pixels); }
+
+    void Clear(Option_t *o="")  { fPixels.Reset(); }
+
+    Bool_t IsBlind(UShort_t id) { return fPixels.GetSize() && fPixels[id]; }
+
+    ClassDef(MBlindPixels, 1) // container to store blind pixels
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.cc	(revision 1638)
@@ -0,0 +1,143 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MCameraSmooth                                                          //
+//                                                                         //
+//  This task fills each pixel in the camera with the average of the       //
+//  number of cerenkov photons from its surrounding pixels. This can       //
+//  be done using the central pixel or ignoring the central pixel.         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraSmooth.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+#include "MBlindPixels.h"
+
+ClassImp(MCameraSmooth);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. You can specify the numer of loops how often a
+// smoothing should be done. The default is 1.
+//
+MCameraSmooth::MCameraSmooth(Byte_t n, const char *name, const char *title)
+    : fCounts(n), fUseCentralPixel(kTRUE)
+{
+    fName  = name  ? name  : "MCameraSmooth";
+    fTitle = title ? title : "Task to smooth the camera";
+}
+
+// --------------------------------------------------------------------------
+//
+//  - get the MCerPhotEvt from the parlist (abort if missing)
+//  - get MGeomCam from the parameter list
+//
+Bool_t MCameraSmooth::PreProcess (MParList *pList)
+{
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeomCam)
+    {
+        *fLog << warn << dbginf << "No camera geometry available... aborting." << endl;
+
+        return kFALSE;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the smoothing
+//
+Bool_t MCameraSmooth::Process()
+{
+    const UShort_t entries = fEvt->GetNumPixels();
+
+    //
+    // remove the pixels in fPixelsID if they are set to be used,
+    // (set them to 'unused' state)
+    //
+
+    Double_t *photons = new Double_t[entries];
+    Double_t *errors  = new Double_t[entries];
+
+    for (int n=0; n<fCounts; n++)
+    {
+        for (UShort_t i=0; i<entries; i++)
+        {
+            MCerPhotPix &pix = (*fEvt)[i];
+
+            const Int_t id = pix.GetPixId();
+
+            const MGeomPix &gpix = (*fGeomCam)[id];
+
+            const Int_t n = gpix.GetNumNeighbors();
+
+            Int_t num  = fUseCentralPixel ? 1 : 0;
+            photons[i] = fUseCentralPixel ? pix.GetNumPhotons() : 0;
+            errors[i]  = fUseCentralPixel ? pix.GetErrorPhot()  : 0;
+
+            for (int j=0; j<n; j++)
+            {
+                const UShort_t nid = gpix.GetNeighbor(j);
+
+                const MCerPhotPix *evtpix = fEvt->GetPixById(nid);
+                if (evtpix)
+                {
+                    photons[i] += evtpix->GetNumPhotons();
+                    errors[i]  += evtpix->GetErrorPhot();
+                }
+                num++;
+            }
+
+            photons[i] /= num;
+            errors[i]  /= num;
+        }
+
+        for (UShort_t i=0; i<entries; i++)
+            (*fEvt)[i].Set(photons[i], errors[i]);
+    }
+
+    delete photons;
+    delete errors;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCameraSmooth.h	(revision 1638)
@@ -0,0 +1,37 @@
+#ifndef MARS_MCameraSmooth
+#define MARS_MCameraSmooth
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MBlindPixels;
+
+class MCameraSmooth : public MTask
+{
+private:
+    MCerPhotEvt *fEvt;     //! Pointer to data to smooth
+    MGeomCam    *fGeomCam; //! Camera geometry
+
+    Byte_t fCounts;           // number of smoothing loops
+    Bool_t fUseCentralPixel;  // use also the central pixel
+
+public:
+    MCameraSmooth(Byte_t cnt=1, const char *name=NULL, const char *title=NULL);
+
+    void SetUseCetralPixel(Bool_t b=kTRUE) { fUseCentralPixel=kTRUE; }
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MCameraSmooth, 0) // task to smooth the camera contants
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.cc	(revision 1638)
@@ -0,0 +1,207 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//   MCerPhotAnal                                                           //
+//                                                                          //
+//   This is a task which calculates the number of photons from the FADC    //
+//   time slices. At the moment it integrates simply the FADC values.       //
+//                                                                          //
+//  Input Containers:                                                       //
+//   MRawEvtData, MPedesdtalCam                                             //
+//                                                                          //
+//  Output Containers:                                                      //
+//   MCerPhotEvt                                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MCerPhotAnal.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtData.h"       // MRawEvtData::GetNumPixels
+#include "MCerPhotEvt.h"
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MCerPhotAnal);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCerPhotAnal::MCerPhotAnal(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCerPhotAnal";
+    fTitle = title ? title : "Task to calculate Cerenkov photons from raw data";
+
+    AddToBranchList("MRawEvtData.fHiGainPixId");
+    AddToBranchList("MRawEvtData.fLoGainPixId");
+    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawRunHeader
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Bool_t MCerPhotAnal::PreProcess(MParList *pList)
+{
+    fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRunHeader)
+    {
+        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Bool_t MCerPhotAnal::Process()
+{
+    fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+	Byte_t *ptr = pixel.GetHiGainSamples();
+	const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
+	const Byte_t *limit = end - 5;
+	
+	Int_t sum=0;
+	Int_t sumpeak=0;
+	Int_t sumlocal =0;
+	Int_t slice=0;
+	Int_t slicelocal=0;
+
+	do
+        {
+            sumlocal = 0;
+            for (Int_t i = 0; i<5;i++)
+                sumlocal += *(ptr+i);
+
+            if (sumpeak < sumlocal)
+            {
+                slice=slicelocal;
+                sumpeak = sumlocal;
+            }
+
+            slicelocal++;
+	    sum += *ptr;
+        } while (++ptr != limit);
+
+        do sum += *ptr;
+        while (++ptr != end);
+
+        Float_t pedes = (Float_t)(sum-sumpeak)/(fRawEvt->GetNumHiGainSamples()-5);
+        Float_t nphot = (Float_t)sumpeak - 5.0*pedes;
+
+        Float_t sigmaped=0;
+
+        slicelocal=0;
+        sumlocal = 0;
+
+	ptr = pixel.GetHiGainSamples();
+        do
+        {
+            if (slicelocal==slice)
+                ptr += 4;
+            else
+            {
+                sumlocal = *ptr;
+
+                const Float_t d = (Float_t)sumlocal-pedes;
+                sigmaped += d*d;
+            }
+            slicelocal++;
+	}
+        while (++ptr != end);
+
+	sigmaped /= (fRawEvt->GetNumHiGainSamples()-5);
+	sigmaped = sqrt(sumlocal);
+
+	const UInt_t pixid = pixel.GetPixelId();
+
+        MPedestalPix &ped = (*fPedestals)[pixid];
+
+	//
+	// sanity check (old MC files sometimes have pixids>577)
+	//
+        if (!fPedestals->CheckBounds(pixid))
+        {
+	    *fLog << inf << "Pixel ID larger than camera... skipping event." << endl;
+	    return kCONTINUE;
+	}
+
+        fCerPhotEvt->AddPixel(pixid, nphot, sigmaped/2.236);
+	ped.SetPedestal(pedes, sigmaped);
+	ped.SetPedestalRms(sigmaped/sqrt(fRawEvt->GetNumHiGainSamples()-5),
+			   sigmaped/sqrt(2*(fRawEvt->GetNumHiGainSamples()-5)));
+
+        // FIXME! Handling of Lo Gains is missing!
+    }
+
+    fCerPhotEvt->SetReadyToSave();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotAnal.h	(revision 1638)
@@ -0,0 +1,38 @@
+#ifndef MARS_MCerPhotAnal
+#define MARS_MCerPhotAnal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotAnal                                                            //
+//                                                                         //
+// Integrates the time slices of one pixel and substracts the pedestal     //
+// (offset) value                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedestalCam;
+class MCerPhotEvt;
+class MRawRunHeader;
+
+class MCerPhotAnal : public MTask
+{
+    MPedestalCam  *fPedestals;  // Pedestals of all pixels in the camera
+    MRawEvtData   *fRawEvt;     // raw event data (time slices)
+    MCerPhotEvt   *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+    MRawRunHeader *fRunHeader;  //  RunHeader information
+ 
+public:
+    MCerPhotAnal(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MCerPhotAnal, 0)   // Task to calculate cerenkov photons from raw data
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.cc	(revision 1638)
@@ -0,0 +1,233 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo 7/2002  (moralejo@pd.infn.it)
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//   MCerPhotCalc                                                          //
+//                                                                          //
+//   This is a task which calculates the number of photons from the FADC    //
+//   time slices. It weights the each slice according to the numbers in     //
+//   the array fWeight (default: all slices added up with weight 1). 
+//                                                                          //
+//  Input Containers:                                                       //
+//   MRawRunHeader, MRawEvtData, MPedestalCam                               //
+//                                                                          //
+//  Output Containers:                                                      //
+//   MCerPhotEvt                                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MCerPhotCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcRunHeader.hxx"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtData.h"       // MRawEvtData::GetNumPixels
+#include "MCerPhotEvt.h"
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MCerPhotCalc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCerPhotCalc::MCerPhotCalc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCerPhotCalc";
+    fTitle = title ? title : "Task to calculate pixel signal from raw data";
+
+    AddToBranchList("MRawEvtData.fHiGainPixId");
+    AddToBranchList("MRawEvtData.fLoGainPixId");
+    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+
+    SetDefaultWeights();
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawRunHeader
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Bool_t MCerPhotCalc::PreProcess(MParList *pList)
+{
+    fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRunHeader)
+    {
+        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    // Calculate quadratic sum of weights:
+    fSumQuadWeights = 0.;
+    for (Int_t i = 0; i < fWeight.GetSize(); i++)
+      fSumQuadWeights += fWeight[i]*fWeight[i];
+
+    fSumQuadWeights = sqrt(fSumQuadWeights);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the run type and camera version.
+// If the file is a MC file and the used camera version is <= 40
+// we enable a fix for truncated pedestal means in this version.
+//
+Bool_t MCerPhotCalc::ReInit(MParList *pList)
+{
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    if (fRunHeader->GetNumSamplesHiGain() != fWeight.GetSize())
+    {
+        *fLog << dbginf << "Number of FADC slices (" << fRunHeader->GetNumSamplesHiGain() <<") is different from assumed one (" << fWeight.GetSize() << ")... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (runheader->GetRunType() != kRTMonteCarlo)
+        return kTRUE;
+
+    MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrunheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check for camera version, MC run header not found." << endl;
+        return kTRUE;
+    }
+
+    fEnableFix = kFALSE;
+    if (mcrunheader->GetCamVersion() <= 40)
+        fEnableFix = kTRUE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Bool_t MCerPhotCalc::Process()
+{
+    fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    TArrayF BinSignal(fWeight.GetSize());
+
+    while (pixel.Next())
+      {
+	const UInt_t pixid = pixel.GetPixelId();
+        const MPedestalPix &ped = (*fPedestals)[pixid];
+
+	//
+	// sanity check (old MC files sometimes have pixids>577)
+	//
+        if (!fPedestals->CheckBounds(pixid))
+        {
+	    *fLog << inf << "Pixel ID larger than camera... skipping event." << endl;
+	    return kCONTINUE;
+	}
+
+	// Mean pedestal:
+        Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
+
+	Byte_t *ptr = pixel.GetHiGainSamples();
+
+	Float_t nphot = 0.;
+	Float_t nphoterr = 0.;
+
+	// Calculate pixel signal unless it has all FADC slices empty:
+
+	if (pixel.GetSumHiGainSamples()>0)
+	  {
+	    for(Int_t i = 0; i<fWeight.GetSize(); i++)
+	      {
+		BinSignal[i] =  (Float_t) ptr[i] - mean;
+		nphot       +=  BinSignal[i] * fWeight[i];
+	      }
+	    nphoterr = ped.GetSigma()* fSumQuadWeights;
+	  }
+
+        fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
+
+        // FIXME! Handling of Lo Gains is missing!
+      }
+
+    fCerPhotEvt->SetReadyToSave();
+
+    return kTRUE;
+}
+
+//
+// Set default values for the number of slices and weights:
+//
+
+void MCerPhotCalc::SetDefaultWeights()
+{
+  const Float_t dummy[15] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,};
+
+  fWeight.Set(15,dummy);
+  return;
+}
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotCalc.h	(revision 1638)
@@ -0,0 +1,52 @@
+#ifndef MARS_MCerPhotCalc
+#define MARS_MCerPhotCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotCalc                                                            //
+//                                                                         //
+// Integrates the desired ADC time slices of one pixel and substracts the  //
+// pedestal (offset) value                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#include <TArrayF.h>
+
+class MRawEvtData;
+class MPedestalCam;
+class MCerPhotEvt;
+class MRawRunHeader;
+class TArrayF;
+
+class MCerPhotCalc : public MTask
+{
+    MPedestalCam   *fPedestals;  // Pedestals of all pixels in the camera
+    MRawEvtData    *fRawEvt;     // raw event data (time slices)
+    MCerPhotEvt    *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+    MRawRunHeader  *fRunHeader;  // RunHeader information
+ 
+    Bool_t          fEnableFix;  // fix for a bug in files from older camera versions (<=40)
+
+    TArrayF         fWeight;  // Weights for adding up the ADC slices
+    Float_t         fSumQuadWeights;
+
+    void SetDefaultWeights();
+
+public:
+    MCerPhotCalc(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t ReInit(MParList *pList);
+
+    void   SetWeights(TArrayF w) {fWeight.Set(w.GetSize(),w.GetArray());}
+
+    ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 1638)
@@ -0,0 +1,323 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MCerPhotEvt.h"
+
+#include <math.h>
+#include <fstream.h>
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MCerPhotEvt);
+
+// --------------------------------------------------------------------------
+//
+// Creates a MCerPhotPix object for each pixel in the event
+//
+MCerPhotEvt::MCerPhotEvt(const char *name, const char *title) : fNumPixels(0)
+{
+    fName  = name  ? name  : "MCerPhotEvt";
+    fTitle = title ? title : "(Number of Photon)-Event Information";
+
+    fPixels = new TClonesArray("MCerPhotPix", 0);
+}
+
+// --------------------------------------------------------------------------
+//
+// This is not yet implemented like it should.
+//
+void MCerPhotEvt::Draw(Option_t* option) 
+{
+    //
+    //   FIXME!!! Here the Draw function of the CamDisplay
+    //   should be called to add the CamDisplay to the Pad.
+    //   The drawing should be done in MCamDisplay::Paint
+    //
+
+    //    MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
+    //    MCamDisplay *disp = new MCamDisplay(geom);
+    //    delete geom;
+    //    disp->DrawPhotNum(this);
+}
+
+// --------------------------------------------------------------------------
+//
+// reset counter and delete netries in list.
+//
+void MCerPhotEvt::Reset()
+{
+    fNumPixels = 0;
+    fPixels->Delete();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Dump the cerenkov photon event to *fLog
+//
+void MCerPhotEvt::Print(Option_t *) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    *fLog << GetDescriptor() << dec << endl;
+    *fLog << " Number of Pixels: " << fNumPixels << "(" << entries << ")" << endl;
+
+    for (Int_t i=0; i<entries; i++ )
+        (*this)[i].Print();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if in the pixel list is an entry with pixel id
+//
+Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        if (id == (*this)[i].GetPixId())
+            return kTRUE;
+    }
+
+    return kFALSE;
+} 
+
+// --------------------------------------------------------------------------
+//
+//   Checks if in the pixel list is an entry with pixel id
+//
+Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        if (id == pix.GetPixId() && pix.IsPixelUsed())
+            return kTRUE;
+    }
+
+    return kFALSE;
+} 
+
+// --------------------------------------------------------------------------
+//
+//   Checks if in the pixel list is an entry with pixel id
+//
+Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
+{
+    const Int_t entries = fPixels->GetEntries();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        if (id == pix.GetPixId() && pix.IsPixelCore())
+            return kTRUE;
+    } 
+
+    return kFALSE;
+} 
+
+// --------------------------------------------------------------------------
+//
+// get the minimum number of photons  of all valid pixels in the list
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t minval = (*this)[0].GetNumPhotons();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval < minval)
+            minval = testval;
+    }
+
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum number of photons of all valid pixels in the list
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetNumPhotons();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the minimum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMin() const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (testval < minval)
+            minval = testval;
+    }
+
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMax() const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t maxval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (testval > maxval)
+            maxval = testval;
+    }
+
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the minimum of error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t minval = (*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetErrorPhot();
+
+    for (UInt_t i=1; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a pointer to the pixel with the requested id. NULL if it doesn't
+// exist.
+//
+MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
+{
+    TIter Next(fPixels);
+    MCerPhotPix *pix = NULL;
+
+    while ((pix=(MCerPhotPix*)Next()))
+        if (pix->GetPixId()==id)
+            return pix;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotEvt.h	(revision 1638)
@@ -0,0 +1,61 @@
+#ifndef MARS_MCerPhotEvt
+#define MARS_MCerPhotEvt
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+#ifndef MARS_MCerPhotPix
+#include "MCerPhotPix.h"
+#endif
+
+class MGeomCam;
+class MCerPhotPix;
+
+class MCerPhotEvt : public MParContainer
+{
+private:
+    UInt_t        fNumPixels;
+    TClonesArray *fPixels;     // FIXME: Change TClonesArray away from a pointer?
+
+public:
+    MCerPhotEvt(const char *name=NULL, const char *title=NULL);
+    ~MCerPhotEvt() { delete fPixels; }
+
+    UInt_t GetNumPixels() const { return fNumPixels; }
+    void   InitSize(UInt_t num) { fPixels->Expand(num); }
+
+    void   AddPixel(Int_t id, Float_t nph, Float_t er)
+    {
+        new ((*fPixels)[fNumPixels++]) MCerPhotPix(id, nph, er);
+    }
+
+
+    Bool_t  IsPixelExisting(Int_t id) const;
+    Bool_t  IsPixelUsed    (Int_t id) const;
+    Bool_t  IsPixelCore    (Int_t id) const;
+
+    Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
+    Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
+
+    Float_t GetRatioMin() const;
+    Float_t GetRatioMax() const;
+
+    Float_t GetErrorPhotMin(const MGeomCam *geom=NULL) const;
+    Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
+
+    MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+    MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+
+    MCerPhotPix *GetPixById(int id) const;
+
+    void Reset();
+
+    void Draw(Option_t* option = "");
+    void Print(Option_t *opt=NULL) const;
+    void Clear(Option_t *opt=NULL) { Reset(); }
+
+    ClassDef(MCerPhotEvt, 1)    // class for an event containing cerenkov photons
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.cc	(revision 1638)
@@ -0,0 +1,65 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MCerPhotPix.h"
+
+#include "MLog.h"
+
+ClassImp(MCerPhotPix);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. The pixel is assumed as used and not a core pixel.
+//
+MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot, Float_t errphot) :
+    fPixId(pix), fIsUsed(kTRUE), fIsCore(kFALSE), fPhot(phot), fErrPhot(errphot)
+{
+} 
+
+// --------------------------------------------------------------------------
+//
+// Sets the information of one pixel.  The pixel is assumed as used and
+// not a core pixel.
+//
+void MCerPhotPix::SetPixelContent(Int_t pix, Float_t phot, Float_t errphot)
+{
+    fPixId   = pix;
+    fIsUsed  = kTRUE;
+    fPhot    = phot;
+    fErrPhot = errphot;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print information to gLog.
+//
+void MCerPhotPix::Print(Option_t *) const
+{ 
+    gLog << GetDescriptor() <<" Pixel: "<< fPixId;
+    gLog << (fIsUsed?"   Used ":" Unused ");
+    gLog << (fIsCore?" Core ":"      ");
+    gLog << "Nphot= " << fPhot << " Error(Nphot)=" << fErrPhot << endl;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCerPhotPix.h	(revision 1638)
@@ -0,0 +1,50 @@
+#ifndef MARS_MCerPhotPix_H
+#define MARS_MCerPhotPix_H
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCerPhotPix : public MParContainer
+{
+private:
+
+    Int_t   fPixId;       // the pixel Id
+
+    Bool_t  fIsUsed;      // the pixel is used for calculations --> kTRUE
+    Bool_t  fIsCore;      // the pixel is a Core pixel          --> kTRUE
+
+    Float_t fPhot;        // The number of Cerenkov photons
+    Float_t fErrPhot;     // the error of fPhot
+
+    // FIXME: arrival time t, and it's error sigma t
+
+public:
+
+    MCerPhotPix(Int_t pix=-1, Float_t phot=0, Float_t errphot=0);
+
+    Int_t   GetPixId() const         { return fPixId;   }
+    Float_t GetNumPhotons() const    { return fPhot;    }
+    Float_t GetErrorPhot() const     { return fErrPhot; }
+
+    void    SetPixelContent(Int_t pix, Float_t phot, Float_t errphot);
+
+    Bool_t  IsPixelUsed() const      { return fIsUsed;   }
+    void    SetPixelUnused()         { fIsUsed = kFALSE; }
+    void    SetPixelUsed()           { fIsUsed = kTRUE;  }
+
+    void    SetPixelCore()           { fIsCore = kTRUE; }
+    Bool_t  IsPixelCore() const      { return fIsCore;  }
+
+    void    SetNumPhotons(Float_t f)    { fPhot    = f; }
+    void    SetErrorPhot(Float_t f)     { fErrPhot = f; }
+    void    Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
+
+    void    Print(Option_t *opt = NULL) const;
+
+    ClassDef(MCerPhotPix, 1)  // class containing information about the Cerenkov Photons in a pixel
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.cc	(revision 1638)
@@ -0,0 +1,164 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz, 5/2002 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCompProbCalc
+//
+// FIXME: Use A huge matrix to evaluate variable bins instead of a
+// histogram
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MCompProbCalc.h"
+
+#include <TH1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MDataChain.h"
+
+#include "MHCompProb.h"
+#include "MHadronness.h"
+
+ClassImp(MCompProbCalc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor
+//
+MCompProbCalc::MCompProbCalc(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MCompProbCalc";
+    fTitle = title ? title : "Composite Probabilities Loop 1/2";
+
+    fData = new TList;
+    fData->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor
+//
+MCompProbCalc::~MCompProbCalc()
+{
+    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MHCompProb
+//  - all data values which were used to build the MHCompProb
+//  - MHadronness
+//
+Bool_t MCompProbCalc::PreProcess(MParList *plist)
+{
+    MHCompProb *p = (MHCompProb*)plist->FindObject("MHCompProb");
+    if (!p)
+    {
+        *fLog << err << dbginf << "MHCompProb not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHistVar = p->GetHistVar();
+    if (fHistVar->GetSize()==0)
+    {
+        *fLog << err << dbginf << "No Entries in MHCompProb::fHistVar... aborting." << endl;
+        return kFALSE;
+    }
+
+    const TList *rules = p->GetRules();
+    if (rules->GetSize()==0)
+    {
+        *fLog << err << dbginf << "No Entries in MHCompProb::fRules... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fHistVar->GetSize() != rules->GetSize())
+    {
+        *fLog << err << dbginf << "Number of rules doesn't match number of var.bin histograms.. aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(rules);
+    TObject *data=NULL;
+    while ((data=Next()))
+    {
+        MDataChain *chain = new MDataChain(data->GetName());
+        if (!chain->PreProcess(plist))
+        {
+            delete chain;
+            return kFALSE;
+        }
+        fData->Add(chain);
+    }
+
+    fHadronness = (MHadronness*)plist->FindCreateObj("MHadronness");
+    if (!fHadronness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the hadroness (composite propability)
+//  - For each data member search the bin corresponding to the data value.
+//  - The value describes with which probability this value corresponds to
+//    a hadron
+//  - For all data members multiply the probabilities.
+//  - For normalization take the n-th root of the result.
+//  - This is the hadroness stored in the MHadronness container
+//
+Bool_t MCompProbCalc::Process()
+{
+    Double_t p = 1;
+
+    TIter NextH(fHistVar);
+    TIter NextD(fData);
+
+    TH1D *hist=NULL;
+
+    Int_t n = 0;
+
+    while ((hist=(TH1D*)NextH()))
+    {
+        MData *data = (MData*)NextD();
+
+        Int_t ibin = hist->FindBin(data->GetValue());
+
+        p *= hist->GetBinContent(ibin) / hist->GetEntries();
+        n++;
+    }
+
+    fHadronness->SetHadronness(pow(p, 1./n));
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MCompProbCalc.h	(revision 1638)
@@ -0,0 +1,33 @@
+#ifndef MARS_MCompProbCalc
+#define MARS_MCompProbCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcEvt;
+class MParList;
+class MHadronness;
+
+class MCompProbCalc : public MTask
+{
+private:
+    MHadronness *fHadronness; //! Output container (Hadronness)
+
+    TList *fData;           //! List of MDataChains to be used
+    TList *fHistVar;        //! List of variable bin size histograms
+
+    void Fill(TList &list);
+    void SetBinningHistVar();
+
+public:
+    MCompProbCalc(const char *name=NULL, const char *title=NULL);
+    ~MCompProbCalc();
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+
+    ClassDef(MCompProbCalc, 1) // Task to calculate composite probabilities
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.cc	(revision 1638)
@@ -0,0 +1,55 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEst                                                              //
+//                                                                         //
+// Storage Container for the estimated energy                              //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEst);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MEnergyEst::MEnergyEst(const char *name, const char *title) : fEnergy(0)
+{
+    fName  = name  ? name  : "MEnergyEst";
+    fTitle = title ? title : "Storage container for the estimated energy [GeV]";
+}
+
+void MEnergyEst::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ": Eest = " << (int)fEnergy << "GeV \t Ir = " << (int)(fImpact/100) << "m" << endl;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEst.h	(revision 1638)
@@ -0,0 +1,28 @@
+#ifndef MARS_MEnergyEst
+#define MARS_MEnergyEst
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MEnergyEst : public MParContainer
+{
+private:
+    Double_t fEnergy; // [GeV] Estimated Energy
+    Double_t fImpact; // [cm]  Estimated Impact
+
+public:
+    MEnergyEst(const char *name=NULL, const char *title=NULL);
+
+    void SetEnergy(Double_t e) { fEnergy = e; }
+    void SetImpact(Double_t i) { fImpact = i; }
+    Double_t GetEnergy() const { return fEnergy; }
+    Double_t GetImpact() const { return fImpact; }
+
+    void Print(Option_t *o="") const;
+
+    ClassDef(MEnergyEst, 0) // Storage Container for the estimated Energy
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.cc	(revision 1638)
@@ -0,0 +1,284 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  9/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEstParam                                                         //
+//                                                                         //
+// Task to estimate the energy using a parametrization.                    //
+// Make sure, that all source dependant containers are based on the same   //
+// set of basic hillas parameters                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEstParam.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+#include "MHMatrix.h"
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEstParam);
+
+// --------------------------------------------------------------------------
+//
+// Initialize the coefficients with (nonsense) values
+//
+void MEnergyEstParam::InitCoefficients()
+{
+    fA[0] =   39.667402; // [cm]
+    fA[1] =  143.081912; // [cm]
+    fA[2] = -395.501677; // [cm]
+    fA[3] =    0.006193;
+
+    fB[0] =   45.037867; // [GeV]
+    fB[1] =    0.087222; // [GeV]
+    fB[2] =   -0.208065; // [GeV/cm]
+    fB[3] =   78.164942; // [GeV]
+    fB[4] = -159.361283; // [GeV]
+    fB[5] =   -0.130455; // [GeV/cm]
+    fB[6] =    0.051139;
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Give the name of the parameter container (MHillas)
+// storing wisth, length and size (Default="MHillas").
+// For the Zenith Angle MMcEvt.fTheta is used.
+//
+MEnergyEstParam::MEnergyEstParam(const char *hillas, const char *name, const char *title)
+   : fMatrix(NULL), fA(4), fB(7)
+{
+    fName  = name  ? name  : "MEnergyEstParam";
+    fTitle = title ? title : "Task to estimate the energy";
+
+    fHillasName = hillas;
+
+    fPairs     = new TList;
+    fEnergy    = new TList;
+    fHillasSrc = new TList;
+
+    fPairs->SetOwner();
+
+    InitCoefficients();
+
+    AddToBranchList("MMcEvt.fTheta");
+    AddToBranchList(fHillasName+"fSize");
+    AddToBranchList(fHillasName+"fWidth");
+    AddToBranchList(fHillasName+"fLength");
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MEnergyEstParam::~MEnergyEstParam()
+{
+    delete fPairs;
+    delete fEnergy;
+    delete fHillasSrc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for all necessary parameter containers.
+//
+Bool_t MEnergyEstParam::PreProcess(MParList *plist)
+{
+    if (!fMatrix)
+    {
+        fHillas = (MHillas*)plist->FindObject(fHillasName, "MHillas");
+        if (!fHillas)
+        {
+            *fLog << err << dbginf << fHillasName << " [MHillas] not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fMc = (MMcEvt*)plist->FindObject("MMcEvt");
+        if (!fMc)
+        {
+            *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    TObject *obj = NULL;
+    TIter Next(fPairs);
+
+    while ((obj=Next()))
+    {
+        TObject *o = plist->FindCreateObj(obj->GetTitle(), "MEnergyEst");
+        if (!o)
+            return kFALSE;
+
+        if (!fEnergy->FindObject(obj->GetTitle()))
+            fEnergy->Add(o);
+
+        if (fMatrix)
+            continue;
+
+        o = plist->FindObject(obj->GetName(), "MHillasSrc");
+        if (!o)
+        {
+            *fLog << err << dbginf << obj->GetName() << " not found... aborting." << endl;
+            return kFALSE;
+        }
+        fHillasSrc->Add(o);
+    }
+
+   return kTRUE;    
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the four coefficients for the estimation of the impact parameter.
+// Argument must ba a TArrayD of size 4.
+//
+void MEnergyEstParam::SetCoeffA(TArrayD arr)
+{
+    if (arr.GetSize() != fA.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fA = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the four coefficients for the estimation of the energy.
+// Argument must ba a TArrayD of size 7.
+//
+void MEnergyEstParam::SetCoeffB(TArrayD arr)
+{
+    if (arr.GetSize() != fB.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fB = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MEnergyEstParam::GetVal(Int_t i) const
+{
+    return (*fMatrix)[fMap[i]];
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
+// will take the values from the matrix instead of the containers.
+//
+void MEnergyEstParam::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MMcEvt.fTheta");
+    fMap[1] = fMatrix->AddColumn(fHillasName+".fWidth");
+    fMap[2] = fMatrix->AddColumn(fHillasName+".fLength");
+    fMap[3] = fMatrix->AddColumn(fHillasName+".fSize");
+
+    Int_t col = 4;
+    TIter Next(fPairs);
+    TObject *o = NULL;
+    while ((o=Next()))
+        fMap[col++] = fMatrix->AddColumn(TString(o->GetName())+".fDist");
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a pair of input/output containers.
+//   eg. Add("MHillasSrc", "MEnergyEst");
+// Usefull if you want to estimate the stuff for the source and antisource
+//
+void MEnergyEstParam::Add(const TString hillas, const TString energy)
+{
+    fPairs->Add(new TNamed(hillas, energy));
+
+    AddToBranchList(hillas+".fDist");
+}
+
+// --------------------------------------------------------------------------
+//
+//  Estimates the impact parameter and energy using a parameterization
+//  (see code)
+//
+Bool_t MEnergyEstParam::Process()
+{
+    const Double_t theta  = fMatrix ? GetVal(0) : fMc->GetTheta();
+    const Double_t width  = fMatrix ? GetVal(1) : fHillas->GetWidth();
+    const Double_t length = fMatrix ? GetVal(2) : fHillas->GetLength();
+    const Double_t size   = fMatrix ? GetVal(3) : fHillas->GetSize();
+
+    const Double_t k   = 1/cos(theta);
+    const Double_t k2  = k*k;
+
+    const Double_t i0 = k * (1+fA[3]*k)/(1+fA[3]);
+    const Double_t i1 = fA[0] + fA[2]*width;
+
+    const Double_t e0 = k2 * (1+fB[6]*k2)/(1+fB[6]);
+    const Double_t e1 = fB[0] + fB[1]*size + fB[3]*length + fB[4]*size*length;
+    const Double_t e2 = fB[2] + fB[5]*length;
+
+    TIter NextH(fHillasSrc);
+    TIter NextE(fEnergy);
+
+    Int_t col = 4;
+
+    while (1)
+    {
+        MEnergyEst *est = (MEnergyEst*)NextE();
+        if (!est)
+            break;
+
+        const Double_t dist = fMatrix ? GetVal(col++) : ((MHillasSrc*)NextH())->GetDist();
+
+        const Double_t ir =  i0 * (i1 + fA[1]*dist); // [cm]
+        const Double_t er = -e0 * (e1 + e2*ir);      // [GeV]
+
+        est->SetEnergy(er);
+        est->SetImpact(ir);
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstParam.h	(revision 1638)
@@ -0,0 +1,59 @@
+#ifndef MARS_MEnergyEstParam
+#define MARS_MEnergyEstParam
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MHillasSrc;
+class MEnergyEst;
+class MHillas;
+class MMcEvt;
+class MHMatrix;
+
+class MEnergyEstParam : public MTask
+{
+private:
+    Int_t     fMap[100];
+
+    MHMatrix *fMatrix;
+
+    TList    *fPairs;
+
+    TList    *fHillasSrc;
+    TList    *fEnergy;
+
+    MHillas  *fHillas;
+    TString   fHillasName;
+
+    TArrayD   fA;
+    TArrayD   fB;
+
+    MMcEvt   *fMc;
+
+    void InitCoefficients();
+
+    Double_t GetVal(Int_t i) const;
+
+public:
+    MEnergyEstParam(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+    ~MEnergyEstParam();
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+
+    void Add(const TString hillas, const TString energy);
+
+    void InitMapping(MHMatrix *mat);
+
+    void SetCoeffA(TArrayD arr);
+    void SetCoeffB(TArrayD arr);
+
+    ClassDef(MEnergyEstParam, 0) // Task to estimate the energy
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.cc	(revision 1638)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEstimate                                                         //
+//                                                                         //
+// Task to estimate the energy                                             //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEstimate.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+#include "MHillas.h"
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEstimate);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MEnergyEstimate::MEnergyEstimate(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MEnergyEstimate";
+    fTitle = title ? title : "Task to estimate the energy";
+
+    AddToBranchList("MMcEvt.fEnergy");
+}
+
+Bool_t MEnergyEstimate::PreProcess(MParList *plist)
+{
+   fHillas = (MHillas*)plist->FindObject("MHillas");
+   if (!fHillas)
+   {
+       *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst");
+   if (!fEnergy)
+      return kFALSE;
+
+   return kTRUE;    
+}
+
+Bool_t MEnergyEstimate::Process()
+{
+  //fEnergy->SetEnergy(fHillas->GetSize());
+  fEnergy->SetEnergy(fMcEvt->GetEnergy());
+  return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MEnergyEstimate.h	(revision 1638)
@@ -0,0 +1,29 @@
+#ifndef MARS_MEnergyEstimate
+#define MARS_MEnergyEstimate
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcEvt;
+class MHillas;
+class MEnergyEst;
+
+class MEnergyEstimate : public MTask
+{
+private:
+    MMcEvt     *fMcEvt;
+    MHillas    *fHillas;
+    MEnergyEst *fEnergy;
+
+public:
+    MEnergyEstimate(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+
+    ClassDef(MEnergyEstimate, 0) // Task to estimate the energy
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.cc	(revision 1638)
@@ -0,0 +1,69 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHadronness
+//
+// The Value must be in the range [0,1]
+// It should be the value used for gamma/hadron seperation.
+// For quality histograms look at MHHadronness
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHadronness.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHadronness);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHadronness::MHadronness(const char *name, const char *title)
+    : fHadronness(-1)
+{
+    fName  = name  ? name  : "MHadronness";
+    fTitle = title ? title : "Storage container for hadroness value";
+}
+
+// --------------------------------------------------------------------------
+//
+// Reset hadroness, -1 indicates: invalid value
+//
+void MHadronness::Reset()
+{
+    fHadronness = -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog
+//
+void MHadronness::Print(Option_t *) const
+{
+    *fLog << all << GetDescriptor() << ": Hadronness = " << fHadronness << endl;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHadronness.h	(revision 1638)
@@ -0,0 +1,26 @@
+#ifndef MARS_MHadronness
+#define MARS_MHadronness
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHadronness : public MParContainer
+{
+private:
+    Double_t fHadronness; // [0,1] Hadronness
+
+public:
+    MHadronness(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    virtual void Print(Option_t *opt=NULL) const;
+
+    Double_t GetHadronness() const { return fHadronness; }
+    void     SetHadronness(Double_t h) { fHadronness = h; }
+
+    ClassDef(MHadronness, 1) // Storage Container for the hadroness
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.cc	(revision 1638)
@@ -0,0 +1,432 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek  6/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillas
+//
+// Storage Container for image parameters
+//
+//    basic image parameters
+//
+// Version 1:
+// ----------
+// fLength   [mm]       major axis of ellipse
+// fWidth    [mm]       minor axis
+// fDelta    [rad]      angle of major axis with x-axis
+//                      by definition the major axis is pointing into
+//                      the hemisphere x>0, thus -pi/2 < delta < pi/2
+// fSize     [#CerPhot] total sum of pixels
+// fMeanX    [mm]       x of center of ellipse
+// fMeanY    [mm]       y of center of ellipse
+//
+// Version 2:
+// ----------
+// fNumCorePixels  number of pixels called core
+// fNumUsedPixels  number of pixels which survived the cleaning
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillas.h"
+
+#include <fstream.h>
+
+#include <TArrayF.h>
+#include <TEllipse.h>
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillas);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillas::MHillas(const char *name, const char *title) : fEllipse(NULL)
+{
+    fName  = name  ? name  : "MHillas";
+    fTitle = title ? title : "Storage container for image parameters of one event";
+
+    Reset();
+
+    fEllipse = new TEllipse;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the TEllipse if one exists.
+//
+MHillas::~MHillas()
+{
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes the values with defaults. For the default values see the
+// source code.
+//
+void MHillas::Reset()
+{
+    fLength = -1;
+    fWidth  = -1;
+    fDelta  =  0;
+
+    fSize   = -1;
+    fMeanX  = -1;
+    fMeanY  = -1;
+
+    fNumUsedPixels = -1;
+    fNumCorePixels = -1;
+
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog
+//
+void MHillas::Print(Option_t *) const
+{
+    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
+
+    if (atg<0)
+        atg += 180;
+
+    *fLog << all;
+    *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Length      [mm]  = " << fLength << endl;
+    *fLog << " - Width       [mm]  = " << fWidth  << endl;
+    *fLog << " - Delta       [deg] = " << fDelta*kRad2Deg << endl;
+    *fLog << " - Size        [1]   = " << fSize   << " #CherPhot"   << endl;
+    *fLog << " - Meanx       [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany       [mm]  = " << fMeanY  << endl;
+    *fLog << " - atg(y/x)    [deg] = " << atg     << endl;
+    *fLog << " - Used Pixels [#]   = " << fNumUsedPixels << " Pixels" << endl;
+    *fLog << " - Core Pixels [#]   = " << fNumCorePixels << " Pixels" << endl;
+}
+
+/*
+// -----------------------------------------------------------
+//
+// call the Paint function of the Ellipse if a TEllipse exists
+//
+void MHillas::Paint(Option_t *)
+{
+     fEllipse->SetLineWidth(2);
+     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
+                            0, 360, fDelta*kRad2Deg+180);
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Instead of adding MHillas itself to the Pad
+// (s. AppendPad in TObject) we create an ellipse,
+// which is added to the Pad by its Draw function
+// You can remove it by deleting the Ellipse Object
+// (s. Clear() )
+//
+void MHillas::Draw(Option_t *opt)
+{
+
+    Clear();
+
+    if (fLength<0 || fWidth<0)
+        return;
+
+    fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth,
+                            0, 360, fDelta*kRad2Deg+180);
+
+    fEllipse->SetLineWidth(2);
+    fEllipse->Draw();
+
+    /*
+     fEllipse->SetPhimin();
+     fEllipse->SetPhimax();
+     fEllipse->SetR1(fLength);
+     fEllipse->SetR2(fWidth);
+     fEllipse->SetTheta(fDelta*kRad2Deg+180);
+     fEllipse->SetX1(fMeanX);
+     fEllipse->SetY1(fMeanY);
+
+     fEllipse->SetLineWidth(2);
+     fEllipse->PaintEllipse(fMeanX, fMeanY, fLength, fWidth,
+                            0, 360, fDelta*kRad2Deg+180);
+
+      AppendPad(opt);
+
+     // This is from TH1
+     TString opt = option;
+     opt.ToLower();
+     if (gPad && !opt.Contains("same")) {
+        //the following statement is necessary in case one attempts to draw
+        //a temporary histogram already in the current pad
+      if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this);
+      gPad->Clear();
+      }
+      */
+}
+
+// --------------------------------------------------------------------------
+//
+// If a TEllipse object exists it is deleted
+//
+void MHillas::Clear(Option_t *)
+{
+    if (!fEllipse)
+        return;
+
+    delete fEllipse;
+
+    fEllipse = NULL;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculate the image parameters from a Cherenkov photon event
+// assuming Cher.photons/pixel and pixel coordinates are given
+// In case you don't call Calc from within an eventloop make sure, that
+// you call the Reset member function before.
+// Returns:
+//   0  no error
+//   1  number of pixels < 3
+//   2  size==0
+//   3  number of used pixel < 3
+//   4  CorrXY == 0
+//
+Int_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    //
+    // sanity check
+    //
+    if (npixevt < 3)
+    {
+        //*fLog << warn << "MHillas::Calc: Event has less than three pixels... skipped." << endl;
+        return 1;
+    }
+
+    //
+    // calculate mean value of pixel coordinates and fSize
+    // -----------------------------------------------------
+    //
+    // Because this are only simple sums of roughly 600 values
+    // with an accuracy less than three digits there should not
+    // be any need to use double precision (Double_t) for the
+    // calculation of fMeanX, fMeanY and fSize.
+    //
+    fMeanX = 0;
+    fMeanY = 0;
+    fSize  = 0;
+
+    fNumUsedPixels = 0;
+    fNumCorePixels = 0;
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const MGeomPix &gpix = geom[pix.GetPixId()];
+
+        const Float_t nphot = pix.GetNumPhotons();
+
+        //if (nphot==0)
+        //    *fLog << warn << GetDescriptor() << ": Pixel #" << pix.GetPixId() << " has no photons." << endl;
+
+        fSize  += nphot;		             // [counter]
+        fMeanX += nphot * gpix.GetX();               // [mm]
+        fMeanY += nphot * gpix.GetY();               // [mm]
+
+        if (pix.IsPixelCore())
+            fNumCorePixels++;
+
+        fNumUsedPixels++;
+    }
+
+    //
+    // sanity checks
+    //
+    if (fSize==0)
+    {
+        //*fLog << inf << GetDescriptor() << ": Event has zero cerenkov photons... skipped." << endl;
+        return 2;
+    }
+
+    fMeanX /= fSize;                                 // [mm]
+    fMeanY /= fSize;                                 // [mm]
+
+    if (fNumUsedPixels<3)
+    {
+        //*fLog << inf << GetDescriptor() << ": Event has less than 3 used pixels... skipped." << endl;
+        return 3;
+    }
+
+    //
+    // calculate 2nd moments
+    // ---------------------
+    //
+    // To make sure that the more complicated sum is evaluated as
+    // accurate as possible (because it is needed for more
+    // complicated calculations (see below) we calculate it using
+    // double prcision.
+    //
+    Double_t corrxx=0;                               // [m^2]
+    Double_t corrxy=0;                               // [m^2]
+    Double_t corryy=0;                               // [m^2]
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const MGeomPix &gpix = geom[pix.GetPixId()];
+
+        const Float_t dx = gpix.GetX() - fMeanX;     // [mm]
+        const Float_t dy = gpix.GetY() - fMeanY;     // [mm]
+
+        const Float_t nphot = pix.GetNumPhotons();   // [#phot]
+
+        corrxx += nphot * dx*dx;                     // [mm^2]
+        corrxy += nphot * dx*dy;                     // [mm^2]
+        corryy += nphot * dy*dy;                     // [mm^2]
+    }
+
+    //
+    // If corrxy=0 (which should never happen, because fSize>0) we
+    // cannot calculate Length and Width. The calculation failed
+    // and returns kFALSE
+    // In reallity it is almost impossible to have a distribution
+    // of cerenkov photons in the used pixels which is exactly symmetric
+    // along one of the axis.
+    //
+    if (corrxy==0)
+    {
+        //*fLog << inf << GetDescriptor() << ": Event has CorrXY==0... skipped." << endl;
+        return 4;
+    }
+
+    //
+    // calculate the basic Hillas parameters: orientation and size of axes
+    // -------------------------------------------------------------------
+    //
+    // fDelta is the angle between the major axis of the ellipse and
+    //  the x axis. It is independent of the position of the ellipse
+    //  in the camera it has values between -pi/2 and pi/2 degrees
+    //
+    const Double_t d0   = corryy - corrxx;
+    const Double_t d1   = corrxy*2;
+    const Double_t d2   = d0 + sqrt(d0*d0 + d1*d1);
+    const Double_t tand = d2 / d1;
+
+    fDelta = atan(tand);
+
+    const Double_t s2 = tand*tand+1;
+    const Double_t s  = sqrt(s2);
+
+    fCosDelta =  1.0/s;   // need these in derived classes
+    fSinDelta = tand/s;   // like MHillasExt
+
+    Double_t axis1 = (tand*tand*corryy + d2 + corrxx)/s2/fSize;
+    Double_t axis2 = (tand*tand*corrxx - d2 + corryy)/s2/fSize;
+
+    //
+    // fLength^2 is the second moment along the major axis of the ellipse
+    // fWidth^2  is the second moment along the minor axis of the ellipse
+    //
+    // From the algorithm we get: fWidth <= fLength is always true
+    //
+    // very small numbers can get negative by rounding
+    //
+    fLength = axis1<0 ? 0 : sqrt(axis1);  // [mm]
+    fWidth  = axis2<0 ? 0 : sqrt(axis2);  // [mm]
+
+    SetReadyToSave();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillas::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 8)
+        return;
+
+    fLength = arr.At(0);  // [mm]        major axis of ellipse
+    fWidth  = arr.At(1);  // [mm]        minor axis of ellipse
+    fDelta  = arr.At(2);  // [rad]       angle of major axis with x-axis
+    fSize   = arr.At(3);  // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
+    fMeanX  = arr.At(4);  // [mm]        x-coordinate of center of ellipse
+    fMeanY  = arr.At(5);  // [mm]        y-coordinate of center of ellipse
+
+    fNumUsedPixels = (Short_t)arr.At(6); // Number of pixels which survived the image cleaning
+    fNumCorePixels = (Short_t)arr.At(7); // number of core pixels
+}
+
+
+// --------------------------------------------------------------------------
+//
+/*
+void MHillas::AsciiRead(ifstream &fin)
+{
+    fin >> fLength;
+    fin >> fWidth;
+    fin >> fDelta;
+    fin >> fSize;
+    fin >> fMeanX;
+    fin >> fMeanY;
+}
+*/
+// --------------------------------------------------------------------------
+/*
+void MHillas::AsciiWrite(ofstream &fout) const
+{
+    fout << fLength << " ";
+    fout << fWidth  << " ";
+    fout << fDelta  << " ";
+    fout << fSize   << " ";
+    fout << fMeanX  << " ";
+    fout << fMeanY;
+}
+*/
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillas.h	(revision 1638)
@@ -0,0 +1,73 @@
+#ifndef MARS_MHillas
+#define MARS_MHillas
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TArrayF;
+class TEllipse;
+
+class MGeomCam;
+class MCerPhotEvt;
+
+class MHillas : public MParContainer
+{
+private:
+    // for description see MHillas.cc
+    Float_t fLength;        // [mm]        major axis of ellipse
+    Float_t fWidth;         // [mm]        minor axis of ellipse
+    Float_t fDelta;         // [rad]       angle of major axis with x-axis
+    Float_t fSize;          // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
+    Float_t fMeanX;         // [mm]        x-coordinate of center of ellipse
+    Float_t fMeanY;         // [mm]        y-coordinate of center of ellipse
+
+    Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
+    Short_t fNumCorePixels; // number of core pixels
+
+    Float_t fSinDelta;      //! [1] sin of Delta (to be used in derived classes)
+    Float_t fCosDelta;      //! [1] cos of Delta (to be used in derived classes)
+
+    TEllipse *fEllipse;     //! Graphical Object to Display Ellipse
+
+protected:
+    //
+    // This is only for calculations in derived classes because
+    // we don't want to read/write this data members
+    //
+    Float_t GetCosDelta() const { return fCosDelta; }
+    Float_t GetSinDelta() const { return fSinDelta; }
+
+public:
+    MHillas(const char *name=NULL, const char *title=NULL);
+    ~MHillas();
+
+    void Reset();
+
+    virtual Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+
+    virtual void Print(Option_t *opt=NULL) const;
+    virtual void Draw(Option_t *opt=NULL);
+    //virtual void Paint(Option_t *);
+
+    virtual void Clear(Option_t *opt=NULL);
+
+    Float_t GetLength() const { return fLength; }
+    Float_t GetWidth() const  { return fWidth; }
+    Float_t GetDelta() const  { return fDelta; }
+    Float_t GetSize() const   { return fSize; }
+    Float_t GetMeanX() const  { return fMeanX; }
+    Float_t GetMeanY() const  { return fMeanY; }
+
+    Int_t GetNumUsedPixels() const { return fNumUsedPixels; }
+    Int_t GetNumCorePixels() const { return fNumCorePixels; }
+
+    virtual void Set(const TArrayF &arr);
+
+    //virtual void AsciiRead(ifstream &fin);
+    //virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillas, 2) // Storage Container for Hillas Parameter
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.cc	(revision 1638)
@@ -0,0 +1,136 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MHillasCalc                                                            //
+//                                                                         //
+//  This is a task to calculate the Hillas parameters from each event      //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MCerPhotEvt, MGeomCam                                                 //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MHillas                                                               //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHillasCalc.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasCalc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasCalc::MHillasCalc(const char *hil, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillasCalc";
+    fTitle = title ? title : "Task to calculate Hillas parameters";
+
+    fHilName = hil;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for a MCerPhotEvt object from which the Hillas are calculated.
+// Try to find the Geometry conatiner. And try to find the output
+// (Hillas) container or create one.
+//
+Bool_t MHillasCalc::PreProcess(MParList *pList)
+{
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fCerPhotEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeomCam)
+    {
+        *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillas = (MHillas*)pList->FindCreateObj(fHilName);
+    if (!fHillas)
+        return kFALSE;
+
+    memset(fErrors, 0, sizeof(fErrors));
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want do complex descisions inside the calculations
+// we must move the calculation code inside this function
+//
+// If the calculation wasn't sucessfull skip this event
+//
+Bool_t MHillasCalc::Process()
+{
+    const Int_t rc = fHillas->Calc(*fGeomCam, *fCerPhotEvt);
+    if (rc<0 || rc>4)
+    {
+        *fLog << err << dbginf << "MHillas::Calc returned unknown error code!" << endl;
+        return kFALSE;
+    }
+    fErrors[rc]++;
+
+    return rc==0 ? kTRUE : kCONTINUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Bool_t MHillasCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) << (int)(fErrors[1]*100/GetNumExecutions()) << "%) Evts skipped due to: Event has less than 3 pixels" << endl;
+    *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) << (int)(fErrors[2]*100/GetNumExecutions()) << "%) Evts skipped due to: Calculated Size == 0" << endl;
+    *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) << (int)(fErrors[3]*100/GetNumExecutions()) << "%) Evts skipped due to: Number of used pixels < 3" << endl;
+    *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) << (int)(fErrors[4]*100/GetNumExecutions()) << "%) Evts skipped due to: CorrXY==0" << endl;
+    *fLog << " " << fErrors[0] << " (" << (int)(fErrors[0]*100/GetNumExecutions()) << "%) Evts survived Hillas calculation!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasCalc.h	(revision 1638)
@@ -0,0 +1,39 @@
+#ifndef MARS_MHillasCalc
+#define MARS_MHillasCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MHillasCalkc                                                            //
+//                                                                         //
+// Task to calculate Hillas Parameters                                     //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MHillas;
+
+class MHillasCalc : public MTask
+{
+    const MGeomCam    *fGeomCam;    // Camera Geometry used to calculate Hillas
+    const MCerPhotEvt *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+          MHillas     *fHillas;     // ouput container to store result
+
+          TString      fHilName;
+          Int_t        fErrors[5];
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+public:
+    MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MHillasCalc, 0)   // Task to calculate Hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.cc	(revision 1638)
@@ -0,0 +1,291 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasExt
+//
+// Storage Container for extended image parameters
+//
+//    extended image parameters
+// fConc     ratio of sum of two highest pixels over fSize
+// fConc1    ratio of highest pixel over fSize
+// fAsym     distance from highest pixel to center, projected onto major axis
+// fM3Long   third moment along major axis
+// fM3Trans  third moment along minor axis
+//
+// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
+//          multiply by the sign of MHillasSrc::fCosDeltaAlpha
+//
+////////////////////////////////////////////////////////////////////////////
+/*
+ // fLeakage1 ratio : (photons in most outer ring of pixels) over fSize
+ // fLeakage2 ratio : (photons in the 2 outer rings of pixels) over fSize
+ //
+ // fAsymna   d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
+ //           projected onto the major axis
+ // fAsym0    (F-B)/(F+B) along the major axis
+ */
+#include "MHillasExt.h"
+
+#include <fstream.h>
+#include <TArrayF.h>
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasExt);
+
+// -------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasExt::MHillasExt(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillas";
+    fTitle = title ? title : "Storage container for extended parameter set of one event";
+
+    Reset();
+      // FIXME: (intelligent) initialization of values missing
+}
+
+// -------------------------------------------------------------------------
+//
+void MHillasExt::Reset()
+{
+    MHillas::Reset();
+
+    fConc    = -1;
+    fConc1   = -1;
+    fAsym    =  0;
+    fM3Long  =  0;
+    fM3Trans =  0;
+}
+
+// -------------------------------------------------------------------------
+//
+void MHillasExt::Print(Option_t *) const
+{
+    MHillas::Print();
+
+    *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Conc      = "        << fConc    << " (ratio)" << endl;
+    *fLog << " - Conc1     = "        << fConc1   << " (ratio)" << endl;
+    *fLog << " - Asymmetry = "        << fAsym    << " mm" << endl;
+    *fLog << " - 3rd Moment Long  = " << fM3Long  << " mm" << endl;
+    *fLog << " - 3rd Moment Trans = " << fM3Trans << " mm" << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+//  calculation of additional parameters based on the camera geometry
+// and the cerenkov photon event
+//
+Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    const Int_t rc = MHillas::Calc(geom, evt);
+    if (rc>0)
+        return rc;
+
+    //
+    //   calculate the additional image parameters
+    // --------------------------------------------
+    //
+    //  loop to get third moments along ellipse axes and two max pixels
+    //
+    //  For the moments double precision is used to make sure, that
+    //  the complex matrix multiplication and sum is evaluated correctly.
+    //
+    Double_t m3x = 0;
+    Double_t m3y = 0;
+
+    Float_t maxpix1 = 0;                                               // [#phot]
+    Float_t maxpix2 = 0;                                               // [#phot]
+
+    Int_t maxpixid = 0;
+
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    const Float_t A0 = geom[0].GetA();
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const MGeomPix &gpix = geom[pix.GetPixId()];
+        const Double_t dx = gpix.GetX() - GetMeanX();                // [mm]
+        const Double_t dy = gpix.GetY() - GetMeanY();                // [mm]
+
+        Double_t nphot = pix.GetNumPhotons();                        // [1]
+
+        const Double_t dzx =  GetCosDelta()*dx + GetSinDelta()*dy;   // [mm]
+        const Double_t dzy = -GetSinDelta()*dx + GetCosDelta()*dy;   // [mm]
+
+        m3x += nphot * dzx*dzx*dzx;                                  // [mm^3]
+        m3y += nphot * dzy*dzy*dzy;                                  // [mm^3]
+
+        /*
+         //
+         // count number of photons in pixels at the edge of the camera
+         //
+         if (gpix.IsInOutermostRing())
+            edgepix1 += nphot;
+         if (gpix.IsInOuterRing())
+            edgepix2 += nphot;
+         */
+
+        //
+        // Now we are working on absolute values of nphot, which
+        // must take pixel size into account
+        //
+        const Double_t r = A0/gpix.GetA();
+        nphot *= r;
+
+        if (nphot>maxpix1)
+        {
+            maxpix2  = maxpix1;
+            maxpix1  = nphot;                                        // [1]
+            maxpixid = pix.GetPixId();
+            continue;                                                // [1]
+        }
+
+        if (nphot>maxpix2)
+            maxpix2 = nphot;                                         // [1]
+
+        /*
+         //
+         // power na for calculating fAsymna;
+         // the value 1.5 was suggested by Thomas Schweizer
+         //
+         Double_t na = 1.5;
+
+         //
+         // get sums for calculating fAsymna
+         // the outer pixels are 4 times as big (in area)
+         // as the inner pixels !
+         //
+         const Double_t dummy = pow(nphot, na)/r;
+
+         sna +=     dummy;
+         xna += dzx*dummy;
+
+         sna1 += sna/nphot;
+         xna1 += xna/nphot;
+
+         //
+         // forward-backward asymmetry
+         //
+         fb += dzx<0 ? -nphot: nphot;
+         */
+    }
+
+    const MGeomPix &maxpix = geom[maxpixid];
+
+    fAsym  = (GetMeanX()-maxpix.GetX())*GetCosDelta() +
+             (GetMeanY()-maxpix.GetY())*GetSinDelta();               // [mm]
+
+    fConc  = (maxpix1+maxpix2)/GetSize();                            // [ratio]
+    fConc1 = maxpix1/GetSize();                                      // [ratio]
+
+    /*
+     fLeakage1 = edgepix1 / GetSize();
+     fLeakage2 = edgepix2 / GetSize();
+     fAsym0    =       fb / GetSize();
+
+     fAsymna   = na * (sna*xna1 - sna1*xna) / (sna*sna);
+     */
+
+    //
+    // Third moments along axes get normalized
+    //
+    m3x /= GetSize();
+    m3y /= GetSize();
+
+    fM3Long  = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3);          // [mm]
+    fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3);          // [mm]
+
+    SetReadyToSave();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillasExt::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 13)
+        return;
+
+    fConc    = arr.At(8);  // [ratio] concentration ratio: sum of the two highest pixels / fSize
+    fConc1   = arr.At(9);  // [ratio] concentration ratio: sum of the highest pixel / fSize
+    fAsym    = arr.At(10); // [mm]    fDist minus dist: center of ellipse, highest pixel
+    fM3Long  = arr.At(11); // [mm]    3rd moment (e-weighted) along major axis
+    fM3Trans = arr.At(12); // [mm]    3rd moment (e-weighted) along minor axis
+
+    TArrayF n(arr);
+    n.Set(8);
+    MHillas::Set(n);
+}
+
+/*
+// -------------------------------------------------------------------------
+//
+void MHillasExt::AsciiRead(ifstream &fin)
+{
+    MHillas::AsciiRead(fin);
+
+    fin >> fConc;
+    fin >> fConc1;
+    fin >> fAsym;
+    fin >> fM3Long;
+    fin >> fM3Trans;
+}
+*/
+// -------------------------------------------------------------------------
+/*
+void MHillasExt::AsciiWrite(ofstream &fout) const
+{
+    MHillas::AsciiWrite(fout);
+
+    fout << " ";
+    fout << fConc   << " ";
+    fout << fConc1  << " ";
+    fout << fAsym   << " ";
+    fout << fM3Long << " ";
+    fout << fM3Trans;
+}
+*/
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasExt.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHillasExt
+#define MARS_MHillasExt
+
+#ifndef MARS_MHillas
+#include "MHillas.h"
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+
+class MHillasExt : public MHillas
+{
+private:
+    // for description see MExtHillas.cc
+    Float_t fConc;    // [ratio] concentration ratio: sum of the two highest pixels / fSize
+    Float_t fConc1;   // [ratio] concentration ratio: sum of the highest pixel / fSize
+    Float_t fAsym;    // [mm]    fDist minus dist: center of ellipse, highest pixel
+    Float_t fM3Long;  // [mm]    3rd moment (e-weighted) along major axis
+    Float_t fM3Trans; // [mm]    3rd moment (e-weighted) along minor axis
+
+public:
+    MHillasExt(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    Float_t GetConc() const    { return fConc; }
+    Float_t GetConc1() const   { return fConc1; }
+    Float_t GetAsym() const    { return fAsym; }
+    Float_t GetM3Long() const  { return fM3Long; }
+    Float_t GetM3Trans() const { return fM3Trans; }
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void Set(const TArrayF &arr);
+
+    //void AsciiRead(ifstream &fin);
+    //void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillasExt, 1) // Storage Container for extended Hillas Parameter
+};
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.cc	(revision 1638)
@@ -0,0 +1,180 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrc
+//
+// Storage Container for image parameters
+//
+//    source-dependent image parameters
+//
+// Version 1:
+// ----------
+//  fAlpha          angle between major axis and line source-to-center
+//  fDist           distance from source to center of ellipse
+//
+// Version 2:
+// ----------
+//  fHeadTail
+//
+// Version 3:
+// ----------
+//  fCosDeltaLenth  cosine of angle between d and a, where
+//                   - d is the vector from the source position to the
+//                     center of the ellipse
+//                   - a is a vector along the main axis of the ellipse
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrc.h"
+
+#include <fstream.h>
+#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MSrcPosCam.h"
+
+ClassImp(MHillasSrc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasSrc::MHillasSrc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillasSrc";
+    fTitle = title ? title : "Parameters depending in source position";
+}
+
+void MHillasSrc::Reset()
+{
+    fDist          = -1;
+    fAlpha         =  0;
+    fHeadTail      =  0;
+    fCosDeltaAlpha =  0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculation of source-dependent parameters
+//  In case you don't call Calc from within an eventloop make sure, that
+//  you call the Reset member function before.
+//
+Bool_t MHillasSrc::Calc(const MHillas *hillas)
+{
+    fHillas = hillas;
+
+    const Double_t mx   = GetMeanX();            // [mm]
+    const Double_t my   = GetMeanY();            // [mm]
+
+    const Double_t sx   = mx - fSrcPos->GetX();  // [mm]
+    const Double_t sy   = my - fSrcPos->GetY();  // [mm]
+
+    const Double_t sd   = sin(GetDelta());       // [1]
+    const Double_t cd   = cos(GetDelta());       // [1]
+
+    const Double_t tand = tan(GetDelta());       // [1]
+
+    fHeadTail = cd*sx + sd*sy;                   // [mm]
+
+    //
+    // Distance from source position to center of ellipse.
+    // If the distance is 0 distance, Alpha is not specified.
+    // The calculation has failed and returnes kFALSE.
+    //
+    Double_t dist = sqrt(sx*sx + sy*sy);         // [mm]
+
+    if (dist==0)
+    {
+        //*fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
+        return kFALSE;
+    }
+
+    //
+    // Calculate Alpha and Cosda = cos(d,a)
+    // The sign of Cosda will be used for quantities containing 
+    // a head-tail information
+    //
+    const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1));
+
+    fAlpha         = asin(arg)*kRad2Deg;        // [deg]
+    fCosDeltaAlpha = fHeadTail/dist;            // [1]
+    fDist          = dist;                      // [mm]
+
+    SetReadyToSave();
+
+    return kTRUE;
+} 
+
+void MHillasSrc::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist          [mm]  = " << fDist << endl;
+    *fLog << " - Alpha         [deg] = " << fAlpha << endl;
+    *fLog << " - HeadTail      [mm]  = " << fHeadTail << endl;
+    *fLog << " - CosDeltaAlpha       = " << fCosDeltaAlpha << endl;
+}
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillasSrc::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 4)
+        return;
+
+    fAlpha = arr.At(0);         // [deg]  angle of major axis with vector to src
+    fDist  = arr.At(1);         // [mm]   distance between src and center of ellipse
+    fHeadTail  = arr.At(2);     // [mm]
+    fCosDeltaAlpha = arr.At(3); // [1]    cosine of angle between d and a
+}
+
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to read MHillasSrc from an ascii file
+//
+/*
+void MHillasSrc::AsciiRead(ifstream &fin)
+{
+    fin >> fAlpha;
+    fin >> fDist;
+    fin >> fHeadTail;
+}
+*/
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to write MHillasSrc to an ascii file
+/*
+void MHillasSrc::AsciiWrite(ofstream &fout) const
+{
+    fout << fAlpha << " " << fDist;
+}
+*/
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrc.h	(revision 1638)
@@ -0,0 +1,52 @@
+#ifndef MARS_MHillasSrc
+#define MARS_MHillasSrc
+
+#ifndef MARS_MHillas
+#include "MHillas.h"
+#endif
+
+class MSrcPosCam;
+
+class MHillasSrc : public MParContainer
+{
+private:
+    const MHillas    *fHillas; //! Input parameters
+    const MSrcPosCam *fSrcPos; //! Source position in the camere
+
+    Float_t fAlpha;         // [deg]  angle of major axis with vector to src
+    Float_t fDist;          // [mm]   distance between src and center of ellipse
+    Float_t fHeadTail;      // [mm]
+    Float_t fCosDeltaAlpha; // [1]    cosine of angle between d and a
+
+public:
+    MHillasSrc(const char *name=NULL, const char *title=NULL);
+
+    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
+    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+
+    void Reset();
+
+    Float_t GetLength()        const { return fHillas->GetLength(); }
+    Float_t GetWidth()         const { return fHillas->GetWidth(); }
+    Float_t GetDelta()         const { return fHillas->GetDelta(); }
+    Float_t GetSize()          const { return fHillas->GetSize(); }
+    Float_t GetMeanX()         const { return fHillas->GetMeanX(); }
+    Float_t GetMeanY()         const { return fHillas->GetMeanY(); }
+    Float_t GetAlpha()         const { return fAlpha; }
+    Float_t GetDist()          const { return fDist; }
+    Float_t GetHeadTail()      const { return fHeadTail; }
+    Float_t GetCosDeltaAlpha() const { return fCosDeltaAlpha; }
+
+    void Print(Option_t *opt=NULL) const;
+
+    virtual Bool_t Calc(const MHillas *hillas);
+
+    void Set(const TArrayF &arr);
+
+    //virtual void AsciiRead(ifstream &fin);
+    //virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillasSrc, 3) // Container to hold source position dependant parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc	(revision 1638)
@@ -0,0 +1,169 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrcCalc
+//
+// Task to calculate the source dependant part of the hillas parameters
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrcCalc.h"
+
+#include <fstream.h>
+
+#include "MParList.h"
+
+#include "MSrcPosCam.h"
+#include "MHillasSrc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasSrcCalc);
+
+static const TString gsDefName  = "MHillasSrcCalc";
+static const TString gsDefTitle = "Calculate position dependant image parameters";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first argument is the name of a container
+// containing the source position in the camera plain (MScrPosCam).
+// The default is "MSrcPosCam". hil is the name of a container
+// of type MHillasSrc (or derived) in which the parameters are stored
+// The default is "MHillasSrc"
+//
+MHillasSrcCalc::MHillasSrcCalc(const char *src, const char *hil,
+                               const char *name, const char *title)
+    : fHillas(NULL), fSrcPos(NULL), fHillasSrc(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fSrcName    = src;
+    fHillasName = hil;
+}
+
+// -------------------------------------------------------------------------
+//
+Bool_t MHillasSrcCalc::PreProcess(MParList *pList)
+{
+    fHillas = (MHillas*)pList->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject(fSrcName, "MSrcPosCam");
+    if (!fSrcPos)
+    {
+        *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", fHillasName);
+    if (!fHillasSrc)
+        return kFALSE;
+
+    fHillasSrc->SetSrcPos(fSrcPos);
+
+    fErrors = 0;
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Bool_t MHillasSrcCalc::Process()
+{
+
+    if (!fHillasSrc->Calc(fHillas))
+    {
+        fErrors++;
+        return kCONTINUE;
+
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Bool_t MHillasSrcCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: Dist==0" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
+{
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    if (fSrcPos)
+        fSrcPos->SavePrimitive(out);
+
+    if (fHillasSrc)
+        fHillasSrc->SavePrimitive(out);
+
+    out << "   MHillasSrcCalc " << GetUniqueName() << "(";
+
+    if (fSrcPos)
+        out << "&" << fSrcPos->GetUniqueName();
+    else
+        out << "\"" << fSrcName << "\"";
+
+    out << ", ";
+
+    if (fHillasSrc)
+        out << "&" << fHillasSrc->GetUniqueName();
+    else
+        out << "\"" << fHillasName << "\"";
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MHillasSrcCalc.h	(revision 1638)
@@ -0,0 +1,37 @@
+#ifndef MARS_MHillasSrcCalc
+#define MARS_MHillasSrcCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MSrcPosCam;
+
+class MHillasSrcCalc : public MTask
+{
+private:
+    MHillas    *fHillas;     //! Pointer to the source independant hillas parameters
+    MSrcPosCam *fSrcPos;     //! Pointer to the source position
+    MHillasSrc *fHillasSrc;  //! Pointer to the output container for the source dependant parameters
+
+    TString     fSrcName;
+    TString     fHillasName;
+
+    Int_t       fErrors;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+public:
+    MHillasSrcCalc(const char *src="MSrcPosCam", const char *hil="MHillasSrc",
+                   const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MHillasSrcCalc, 1) // task to calculate the source position depandant hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.cc	(revision 1638)
@@ -0,0 +1,455 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MImgCleanStd                                                           //
+//                                                                         //
+//  This is the standard image cleaning. If you want to know how it works  //
+//  Please look at the three CleanSteps and Process                        //
+//                                                                         //
+//   FIXME: MImgCleanStd is not yet completely optimized for speed.        //
+//          Maybe we don't have to loop over all pixels all the time...    //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MGeomCam, MCerPhotEvt                                                 //
+//                                                                         //
+//  Output Containers:                                                     //
+//   -/-                                                                   //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MImgCleanStd.h"
+
+#include <stdlib.h>       // atof
+#include <fstream.h>      // ofstream, SavePrimitive
+
+#include <TGFrame.h>      // TGFrame
+#include <TGLabel.h>      // TGLabel
+#include <TGTextEntry.h>  // TGTextEntry
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MGGroupFrame.h" // MGGroupFrame
+
+ClassImp(MImgCleanStd);
+
+enum {
+    kImgCleanLvl1,
+    kImgCleanLvl2
+};
+
+static const TString gsDefName  = "MImgCleanStd";
+static const TString gsDefTitle = "Task to perform a standard image cleaning";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Here you can specify the cleaning levels. If you
+// don't specify them the 'common standard' values 3.0 and 2.5 (sigma
+// above mean) are used
+//
+MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
+                           const char *name, const char *title)
+    : fCleanLvl1(lvl1), fCleanLvl2(lvl2)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    Print();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This method looks for all pixels with an entry (photons)
+//  that is three times bigger than the noise of the pixel
+//  (std: 3 sigma, clean level 1)
+//
+//  Returns the maximum Pixel Id (used for ispixused in CleanStep2)
+//
+Int_t MImgCleanStd::CleanStep1()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    Int_t max = entries;
+
+    //
+    // check the number of all pixels against the noise level and
+    // set them to 'unused' state if necessary
+    //
+    for (Int_t i=0; i<entries; i++ )
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        const Float_t entry = pix.GetNumPhotons();
+        const Float_t noise = pix.GetErrorPhot();
+
+        // COBB: '<=' to skip entry=noise=0
+        if (entry <= fCleanLvl1 * noise)
+            pix.SetPixelUnused();
+
+        if (pix.GetPixId()>max)
+            max = pix.GetPixId();
+    }
+    return max;
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the survived pixel have a neighbor, that also
+//  survived, otherwise set pixel to unused. (removes pixels without
+//  neighbors)
+//
+//  takes the maximum pixel id from CleanStep1 as an argument
+//
+void MImgCleanStd::CleanStep2(Int_t max)
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    //
+    // In the worst case we have to loop 6 times 577 times, to
+    // catch the behaviour of all next neighbors. Here we can gain
+    // much by using an array instead of checking through all pixels
+    // (MCerPhotEvt::IsPixelUsed) all the time.
+    //
+    Byte_t *ispixused = new Byte_t[max+1];
+    memset(ispixused, 0, max+1);
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+        ispixused[pix.GetPixId()] = pix.IsPixelUsed();
+    }
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get entry i from list
+        //
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        //
+        // check if pixel is in use, if not goto next pixel in list
+        //
+#if 0
+        if (!pix.IsPixelUsed())
+            continue;
+#endif
+
+        //
+        // get pixel id of this entry
+        //
+        const Int_t id = pix.GetPixId();
+
+        //
+        // check for 'used' neighbors this pixel which
+        //
+        const MGeomPix &gpix  = (*fCam)[id];
+        const Int_t     nnmax = gpix.GetNumNeighbors();
+
+#if 0
+        Bool_t cnt = kFALSE;
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t id2 = gpix.GetNeighbor(j);
+
+            if (id2>max || !ispixused[id2])
+                continue;
+
+            cnt = kTRUE;
+            break;
+        }
+        if (cnt)
+            continue;
+#else
+        Int_t cnt = 0;
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t id2 = gpix.GetNeighbor(j);
+
+            if (id2>max || !ispixused[id2])
+                continue;
+
+            if (cnt++>nnmax-4)
+                break;
+        }
+        if (cnt==nnmax-2 && nnmax>=4)
+        {
+            pix.SetPixelUsed();
+            continue;
+        }
+        if (cnt>0)
+            continue;
+#endif
+
+        //
+        // check if no next neighbor has the state 'used'
+        // set this pixel to 'unused', too.
+        //
+        pix.SetPixelUnused();
+    }
+
+    delete ispixused;
+
+    //
+    // now we declare all pixels that survive as CorePixels
+    //
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        if (pix.IsPixelUsed())
+            pix.SetPixelCore();
+    }
+} 
+
+// --------------------------------------------------------------------------
+//
+//   Look for the boundary pixels around the core pixels
+//   if a pixel has more than 2.5 (clean level 2.5) sigma, and
+//   a core neigbor it is declared as used.
+//
+void MImgCleanStd::CleanStep3()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get pixel as entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        //
+        // if pixel is a core pixel go to the next pixel
+        //
+        if (pix.IsPixelCore())
+            continue;
+
+        //
+        // check the num of photons against the noise level
+        //
+        const Float_t entry = pix.GetNumPhotons();
+        const Float_t noise = pix.GetErrorPhot();
+
+        if (entry <= fCleanLvl2 * noise)
+            continue;
+
+        //
+        // get pixel id of this entry
+        //
+        const Int_t id = pix.GetPixId();
+
+        //
+        // check if the pixel's next neighbor is a core pixel.
+        // if it is a core pixel set pixel state to: used.
+        //
+        MGeomPix   &gpix  = (*fCam)[id];
+        const Int_t nnmax = gpix.GetNumNeighbors();
+
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t id2 = gpix.GetNeighbor(j);
+
+            if (!fEvt->IsPixelCore(id2))
+                continue;
+
+            pix.SetPixelUsed();
+            break;
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if MEvtHeader exists in the Parameter list already.
+//  if not create one and add them to the list
+//
+Bool_t MImgCleanStd::PreProcess (MParList *pList)
+{
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Cleans the image.
+//
+Bool_t MImgCleanStd::Process()
+{
+    const Int_t max = CleanStep1();
+    CleanStep2(max);
+    CleanStep3();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print descriptor and cleaning levels.
+//
+void MImgCleanStd::Print(Option_t *o) const
+{
+    *fLog << GetDescriptor() << " initialized with noise level ";
+    *fLog << fCleanLvl1 << " and " << fCleanLvl2 << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Craete two text entry fields, one for each cleaning level and a
+//  describing text line.
+//
+void MImgCleanStd::CreateGuiElements(MGGroupFrame *f)
+{
+    //
+    // Create a frame for line 3 and 4 to be able
+    // to align entry field and label in one line
+    //
+    TGHorizontalFrame *f1 = new TGHorizontalFrame(f, 0, 0);
+    TGHorizontalFrame *f2 = new TGHorizontalFrame(f, 0, 0);
+
+    /*
+     * --> use with root >=3.02 <--
+     *
+
+     TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+     TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+
+     */
+    TGTextEntry *entry1 = new TGTextEntry(f1, "****", kImgCleanLvl1);
+    TGTextEntry *entry2 = new TGTextEntry(f2, "****", kImgCleanLvl2);
+
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry1->SetAlignment(kTextRight);
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry2->SetAlignment(kTextRight);
+
+    entry1->SetText("3.0");
+    entry2->SetText("2.5");
+
+    entry1->Associate(f);
+    entry2->Associate(f);
+
+    TGLabel *l1 = new TGLabel(f1, "Cleaning Level 1");
+    TGLabel *l2 = new TGLabel(f2, "Cleaning Level 2");
+
+    l1->SetTextJustify(kTextLeft);
+    l2->SetTextJustify(kTextLeft);
+
+    //
+    // Align the text of the label centered, left in the row
+    // with a left padding of 10
+    //
+    TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10);
+    TGLayoutHints *layframe = new TGLayoutHints(kLHintsCenterY|kLHintsLeft,  5, 0, 10);
+
+    //
+    // Add one entry field and the corresponding label to each line
+    //
+    f1->AddFrame(entry1);
+    f2->AddFrame(entry2);
+
+    f1->AddFrame(l1, laylabel);
+    f2->AddFrame(l2, laylabel);
+
+    f->AddFrame(f1, layframe);
+    f->AddFrame(f2, layframe);
+
+    f->AddToList(entry1);
+    f->AddToList(entry2);
+    f->AddToList(l1);
+    f->AddToList(l2);
+    f->AddToList(laylabel);
+    f->AddToList(layframe);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI Events comming from the two text entry fields.
+//
+Bool_t MImgCleanStd::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
+{
+    if (msg!=kC_TEXTENTRY || submsg!=kTE_ENTER)
+        return kTRUE;
+
+    TGTextEntry *txt = (TGTextEntry*)FindWidget(param1);
+
+    if (!txt)
+        return kTRUE;
+
+    Float_t lvl = atof(txt->GetText());
+
+    switch (param1)
+    {
+    case kImgCleanLvl1:
+        fCleanLvl1 = lvl;
+        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+
+    case kImgCleanLvl2:
+        fCleanLvl2 = lvl;
+        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MImgCleanStd::StreamPrimitive(ofstream &out) const
+{
+    out << "   MImgCleanStd " << GetUniqueName() << "(";
+    out << fCleanLvl1 << ", " << fCleanLvl2;
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MImgCleanStd.h	(revision 1638)
@@ -0,0 +1,47 @@
+#ifndef MARS_MImgCleanStd
+#define MARS_MImgCleanStd
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+
+class MGGroupFrame;
+
+class MImgCleanStd : public MGTask
+{
+private:
+    const MGeomCam    *fCam;  //!
+          MCerPhotEvt *fEvt;  //!
+
+    Float_t fCleanLvl1;
+    Float_t fCleanLvl2;
+
+    void CreateGuiElements(MGGroupFrame *f);
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
+                 const char *name=NULL, const char *title=NULL);
+
+    Int_t CleanStep1();
+    void  CleanStep2(Int_t max);
+    void  CleanStep3();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    void Print(Option_t *o="") const;
+
+    Float_t GetCleanLvl1() const { return fCleanLvl1; }
+    Float_t GetCleanLvl2() const { return fCleanLvl2; }
+
+    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+
+    ClassDef(MImgCleanStd, 0)    // task doing a standard image cleaning
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.cc	(revision 1638)
@@ -0,0 +1,62 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  9/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMatrixLoop
+//
+// Use this task instead of reading from a file. It loops through the rows
+// of a given MHMatrix. PreProcessing the task again starts from scratch.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMatrixLoop.h"
+
+#include "MHMatrix.h"
+
+ClassImp(MMatrixLoop);
+
+const TString MMatrixLoop::gsDefName  = "MMatrixLoop";
+const TString MMatrixLoop::gsDefTitle = "Loop through a MHMatrix (instead of reading from a file)";
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor. Specify the MHMatrix object you want to loop
+//  through.
+//
+MMatrixLoop::MMatrixLoop(MHMatrix *mat, const char *name, const char *title) : fMatrix(mat)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the present row of the Matrix, stops the loop when all rows have
+// been accessed.
+//
+Bool_t MMatrixLoop::Process()
+{
+    return fMatrix->SetNumRow(fNumRow++);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMatrixLoop.h	(revision 1638)
@@ -0,0 +1,35 @@
+#ifndef MARS_MMatrixLoop
+#define MARS_MMatrixLoop
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHMatrix;
+
+class MMatrixLoop : public MTask
+{
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
+protected:
+    MHMatrix *fMatrix;
+    Int_t     fNumRow;    //! Number of dimensions of histogram
+
+public:
+    MMatrixLoop(MHMatrix *mat, const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *plist)
+    {
+        fNumRow = 0;
+
+        return fMatrix ? kTRUE : kFALSE;
+    }
+
+    Bool_t Process();
+
+    ClassDef(MMatrixLoop, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.cc	(revision 1638)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MMcPedestalCopy                                                        //
+//                                                                         //
+//  This task looks for the ìnformation about FADC pedestals in            //
+//  MMcFadcHeader and translates it to the pedestal values in              //
+//  MPedestalCam                                                           //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MMcFadcHeader                                                         //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MPedestalCam                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MMcPedestalCopy.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MRawRunHeader.h"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcPedestalCopy);
+
+MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcPedestalCopy";
+    fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
+
+    //
+    // This is not needed here using MReadMarsFile because for the
+    // RunHeader tree the auto scheme is disabled by default
+    //
+    AddToBranchList("MMcFadcHeader.fPedesMean");
+    AddToBranchList("MMcFadcHeader.fElecNoise");
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the run type. Return kTRUE if it is a MC run or if there
+// is no MC run header (old camera files) kFALSE in case of a different
+// run type
+//
+Bool_t MMcPedestalCopy::CheckRunType(MParList *pList) const
+{
+    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!run)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    return run->GetRunType() == kRTMonteCarlo;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check runtype and search for MPedestalCam and MMcFadcHeader.
+// If the runtype check fails the task is removed from the task list.
+//
+Bool_t MMcPedestalCopy::PreProcess(MParList *pList)
+{
+    if (!CheckRunType(pList))
+    {
+        *fLog << warn << dbginf << " MMcPedestalCopy is for Monte Carlo files only... ";
+        *fLog << "removing task from list." << endl;
+        return kSKIP;
+    }
+
+    fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedCam)
+        return kFALSE;
+
+    fMcPed = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
+    if (!fMcPed)
+    {
+        *fLog << warn << dbginf << "MMcFadcHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the runtype.
+// Initialize the size of MPedestalCam to the number of pixels from
+// MMcFadcHeader.
+//
+Bool_t MMcPedestalCopy::ReInit(MParList *pList)
+{
+    if (!CheckRunType(pList))
+        return kFALSE;
+
+    const int num = fMcPed->GetNumPixel();
+
+    fPedCam->InitSize(num);
+
+    for (int i=0; i<num; i++)
+    {
+        MPedestalPix &pix = (*fPedCam)[i];
+
+        // Here one should compute the Pedestal taking into account how
+        // the MC makes the transformation analogic-digital for the FADC.
+
+        const Float_t pedest = fMcPed->GetPedestal(i);
+        const Float_t pedrms = pedest/sqrt(num);
+
+        const Float_t sigma  = fMcPed->GetPedestalRms(i);
+        const Float_t sigrms = sigma/sqrt(num*2);
+
+	pix.SetPedestal(pedest, sigma);
+        pix.SetPedestalRms(pedrms, sigrms);
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalCopy.h	(revision 1638)
@@ -0,0 +1,29 @@
+#ifndef MARS_MMcPedestalCopy
+#define MARS_MMcPedestalCopy
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcFadcHeader;
+class MPedestalCam;
+
+class MMcPedestalCopy : public MTask
+{
+private:
+    const MMcFadcHeader *fMcPed;
+    MPedestalCam *fPedCam;
+
+    Bool_t CheckRunType(MParList *pList) const;
+
+public:
+    MMcPedestalCopy(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+
+    virtual Bool_t ReInit(MParList *pList);
+
+    ClassDef(MMcPedestalCopy, 0)   // Task which copies the pedestals from the MC into the standard container
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 1638)
@@ -0,0 +1,228 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch  11/2001 < mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MMcPedestalNSBAdd                                                      //
+//  -----------------                                                      //
+//                                                                         //
+//  This Task adds the contribution of the diffuse NSB to the FADC         //
+//  pedestals. We assume that NSB introduces larger fluctuation but does   //
+//  not change the mean value.                                             //
+//  To be precise we add quadratically to the rms, which is already in     //
+//  MPedestalCam, the NSB contribution.                                    //
+//  The number of photons from the diffuse NSB follows a poisson           // 
+//  distribution with expected mean value X, then its standard deviation   //
+//  is sqrt(X).                                                            //
+//  X is the number of phe per ns so we have to convert in FADC counts per // 
+//  slice:                                                                 //
+//                                                                         //
+//  Y = sqrt(X * FADC_time / Number_of_slices * pixel_size)                //
+//      * Amp_single_phe_response                                          //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MMcFadcHeader                                                         //
+//   MMcRunHeader                                                          //
+//   MRawRunHeader                                                         //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MPedestalCam                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcPedestalNSBAdd.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcPedestalNSBAdd);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMcPedestalNSBAdd::MMcPedestalNSBAdd(const Float_t difnsb,
+                                     const char *name, const char *title)
+    : fDnsbPixel(difnsb)
+{
+    fName  = name  ? name  : "MMcPedestalNSBAdd";
+    fTitle = title ? title : "Task to copy monte carlo pedestals into MPedestal Container";
+
+    //
+    // This is not needed here using MReadMarsFile because for the
+    // RunHeader tree the auto scheme is disabled by default
+    //
+    AddToBranchList("MMcFadcHeader.fPedesMean");
+    AddToBranchList("MMcFadcHeader.fElecNoise");
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the run type. Return kTRUE if it is a MC run or if there
+// is no MC run header (old camera files) kFALSE in case of a different
+// run type
+//
+Bool_t MMcPedestalNSBAdd::CheckRunType(MParList *pList) const
+{
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    return runheader->GetRunType() == kRTMonteCarlo;
+}
+
+// --------------------------------------------------------------------------
+//
+// - check whether we have a monte carlo file. if not skip this task
+// - try to get MMcFadcHeader, MGeomCam and MPedestalCam from the parameter
+//   list
+// - try to find a MMcRunHeader, too
+//
+Bool_t MMcPedestalNSBAdd::PreProcess(MParList *pList)
+{
+    if (!CheckRunType(pList))
+    {
+        *fLog << warn << dbginf << "Warning - MMcPedestalNSB is for Monte Carlo files only... removing this task from list." << endl;
+        return kSKIP;
+    }
+
+    fFadc = (MMcFadcHeader*)pList->FindObject("MMcFadcHeader");
+    if (!fFadc)
+    {
+        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
+	return kFALSE;
+    }
+
+    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeom)
+    {
+        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
+	return kFALSE;
+    }
+
+    fPedCam = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedCam)
+	return kFALSE;
+
+    const MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrunheader && fDnsbPixel<0)
+    {
+        *fLog << err << dbginf << "Using the default argument only ";
+        *fLog << "allowed if MMcRunHeader is available... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If a MMcRunHeader is available the DNSB MMcRunHeader::GetNumPheFromDNSB
+// is returned. Otherwise the user given number is used.
+//
+Float_t MMcPedestalNSBAdd::GetDnsb(MParList *pList) const
+{
+    const MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrunheader && fDnsbPixel<0)
+    {
+        *fLog << err << dbginf << "Using the default argument only ";
+        *fLog << "allowed if MMcRunHeader is available... aborting." << endl;
+        return -1;
+    }
+
+    if (!mcrunheader)
+        return fDnsbPixel;
+
+    if (fDnsbPixel >= 0 && fDnsbPixel != mcrunheader->GetNumPheFromDNSB())
+    {
+        *fLog << warn << dbginf << "The MC file has been generated with diffuse nsb " << mcrunheader->GetNumPheFromDNSB();
+        *fLog <<" but you set up the diffuse NSB to " << fDnsbPixel << endl;
+
+        return fDnsbPixel;
+    }
+
+    return mcrunheader->GetNumPheFromDNSB();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This function is called each time MReadTree::Notify is called, which 
+//  happens when it  changes the file to read from.
+//  Here we add the contribution from NSB to the pedestals.
+//  The ReInit searches for the following input containers:
+//   - MRawRunHeader
+//   - MMcRunHeader
+//   - MMcFacdHeader
+//   - MGeomCam
+//
+//   The following output containers are also searched and created if
+//   they were not found:
+//   - MPedestalCam
+//
+Bool_t MMcPedestalNSBAdd::ReInit(MParList *pList)
+{
+    if (!CheckRunType(pList))
+        return kFALSE;
+
+    const Float_t dnsbpix = GetDnsb(pList) * 50.0/15.0;
+
+    if (dnsbpix < 0)
+        return kFALSE;
+
+    const int num = fFadc->GetNumPixel();
+    
+    fPedCam->InitSize(num);
+
+    const Float_t size0 = (*fGeom)[0].GetR() * (*fGeom)[0].GetR();
+
+    for (int i=0; i<num; i++)
+    {
+        MPedestalPix   &pix     = (*fPedCam)[i];
+	const MGeomPix &pixgeom = (*fGeom)[i];
+
+        const Float_t pedrms = pix.GetSigma();
+        const Float_t size   = pixgeom.GetR()*pixgeom.GetR()/size0;
+
+        const Float_t ampl   = fFadc->GetAmplitud();
+
+	pix.SetSigma(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl*size));
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 1638)
@@ -0,0 +1,35 @@
+#ifndef MARS_MMcPedestalNSBAdd
+#define MARS_MMcPedestalNSBAdd
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcFadcHeader;
+class MGeomCam;
+class MPedestalCam;
+
+class MMcPedestalNSBAdd : public MTask
+{
+private:
+    const MGeomCam *fGeom;
+    MMcFadcHeader  *fFadc;
+    MPedestalCam   *fPedCam;
+
+    Float_t fDnsbPixel;
+
+    Bool_t CheckRunType(MParList *pList) const;
+    Float_t GetDnsb(MParList *pList) const;
+
+public:
+    MMcPedestalNSBAdd(const Float_t difnsb = -1.0,
+                      const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+
+    virtual Bool_t ReInit(MParList *pList);
+
+    ClassDef(MMcPedestalNSBAdd, 0)   // Task which adds the NSB fluctuations to the pedestals rms
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.cc	(revision 1638)
@@ -0,0 +1,232 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMultiDimDistCalc
+//
+//  Calculated a multidimensional distance. It calculates the distance to
+//  all vectors in a given matrix describing Gammas and another one
+//  describing Hadrons (non gammas). The shortest distances are avaraged.
+//  How many distances are used for avaraging can be specified in the
+//  constructor.
+//
+//  * If you want to use the nearest neighbor function for calculation use:
+//      MMultiDimDistCalc::SetUseKernelMethod(kFALSE);
+//  * If you want to use the kernel function for calculation use:
+//      MMultiDimDistCalc::SetUseKernelMethod(kTRUE); <default>
+//  * To use only the n next neighbors for your calculation use:
+//      MMultiDimDistCalc::SetUseNumRows(n);
+//  * To use all reference events set the number to 0 <default>
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MMultiDimDistCalc.h"
+
+#include <fstream.h>
+
+#include "MHMatrix.h" // must be before MLogManip.h
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MDataChain.h"
+#include "MDataArray.h"
+
+#include "MHadronness.h"
+
+ClassImp(MMultiDimDistCalc);
+
+static const TString gsDefName  = "MMultiDimDistCalc";
+static const TString gsDefTitle = "Composite Probabilities Loop 1/2";
+// --------------------------------------------------------------------------
+//
+// Setup histograms and the number of distances which are used for
+// avaraging in CalcDist
+//
+MMultiDimDistCalc::MMultiDimDistCalc(const char *name, const char *title)
+    : fNum(0), fUseKernel(kTRUE), fData(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    /*
+     fData = new TList;
+     fData->SetOwner();
+     */
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the data chains
+//
+MMultiDimDistCalc::~MMultiDimDistCalc()
+{
+    //    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MatrixGammas  [MHMatrix]
+//  - MatrixHadrons {MHMatrix]
+//  - MHadroness
+//  - all data containers used to build the matrixes
+//
+// The matrix object can be filles using MFillH. And must be of the same
+// number of columns (with the same meaning).
+//
+Bool_t MMultiDimDistCalc::PreProcess(MParList *plist)
+{
+    fMGammas = (MHMatrix*)plist->FindObject("MatrixGammas", "MHMatrix");
+    if (!fMGammas)
+    {
+        *fLog << err << dbginf << "MatrixGammas [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMHadrons = (MHMatrix*)plist->FindObject("MatrixHadrons", "MHMatrix");
+    if (!fMHadrons)
+    {
+        *fLog << err << dbginf << "MatrixHadrons [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fMGammas->GetM().GetNcols() != fMHadrons->GetM().GetNcols())
+    {
+        *fLog << err << dbginf << "Error matrices have different numbers of columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    /*
+    TIter Next(fMGammas->GetRules());
+    TObject *data=NULL;
+    while ((data=Next()))
+    {
+        MDataChain *chain = new MDataChain(data->GetName());
+        if (!chain->PreProcess(plist))
+        {
+            delete chain;
+            return kFALSE;
+        }
+        fData->Add(chain);
+    }
+    */
+    fData = fMGammas->GetColumns();
+    if (!fData)
+    {
+        *fLog << err << dbginf << "Error matrix doesn't contain columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (!fData->PreProcess(plist))
+    {
+        *fLog << err << dbginf << "PreProcessing of the MDataArray failed for the columns failed... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)plist->FindCreateObj("MHadronness");
+    if (!fHadronness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluates the avarage over the fNum shortest distances in a
+// multidimensional space to a matrix (set of vectors) describing
+// gammas and hadrons.
+// The hadroness of the event is defines as the avarage distance to the
+// set of gammas (dg) divided by the avarage distance to the set of
+// hadrons (dh). Because this value is in teh range [0, inf] it is
+// transformed into [0,1] by:
+//  H = exp(-dh/dg);
+//
+Bool_t MMultiDimDistCalc::Process()
+{
+    const Double_t ncols = fMGammas->GetM().GetNcols();
+
+    TVector event(ncols);
+
+    for (int i=0; i<fData->GetNumEntries(); i++)
+        event(i) = (*fData)(i);
+
+    /*
+    Int_t n=0;
+    TIter Next(fData);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        event(n++) = data->GetValue();
+        */
+
+    Double_t numg = fNum;
+    Double_t numh = fNum;
+    if (fNum==0)
+    {
+        numg = fMGammas->GetM().GetNrows();
+        numh = fMHadrons->GetM().GetNrows();
+    }
+    if (fUseKernel)
+    {
+        numg = -numg;
+        numh = -numh;
+    }
+
+    Double_t dg = fMGammas->CalcDist(event, numg);
+    Double_t dh = fMHadrons->CalcDist(event, numh);
+
+    if (dg<0 || dh<0)
+    {
+        *fLog << err << "MHMatrix::CalcDist failed (dg=" << dg << ", dh=" << dh << ")... aborting" << endl;
+        return kFALSE;
+    }
+
+    //fHadronness->SetHadronness(dg/(dg+dh));
+    fHadronness->SetHadronness(exp(-dh/dg));
+
+    return kTRUE;
+}
+
+void MMultiDimDistCalc::StreamPrimitive(ofstream &out) const
+{
+    out << "   MMultiDimDist " << GetUniqueName();
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\")";
+    }
+    out << ";" << endl;
+
+    if (fNum!=0)
+        out << "   " << GetUniqueName() << ".SetUseNumRows(" << fNum << ");" << endl;
+    if (fUseKernel)
+        out << "   " << GetUniqueName() << ".SetUseKernelMethod();" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MMultiDimDistCalc.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MMultiDimDistCalc
+#define MARS_MMultiDimDistCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHMatrix;
+class MParList;
+class MDataArray;
+class MHadronness;
+
+class MMultiDimDistCalc : public MTask
+{
+private:
+    Int_t  fNum;              // number of distances used for an avarage
+    Bool_t fUseKernel;        // Flag whether kernel method should be used
+
+    MHMatrix   *fMGammas;     //! Gammas describing matrix
+    MHMatrix   *fMHadrons;    //! Hadrons (non gammas) describing matrix
+
+    MHadronness *fHadronness; //! Output container for calculated hadroness
+
+    MDataArray *fData;        //! Used to store the MDataChains to get the event values
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MMultiDimDistCalc(const char *name=NULL, const char *title=NULL);
+    ~MMultiDimDistCalc();
+
+    void SetUseNumRows(UShort_t n=0) { fNum = n; }
+    void SetUseKernelMethod(Bool_t k=kTRUE) { fUseKernel = k; }
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+
+    ClassDef(MMultiDimDistCalc, 0) // Task to calculate multidimensional distances
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc	(revision 1638)
@@ -0,0 +1,144 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 04/2001 <mailto:jflix@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MPedCalcPedRun                                                        //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MRawEvtData                                                           //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MPedestalCam                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MPedCalcPedRun.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+ClassImp(MPedCalcPedRun);
+
+MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPedCalcPedRun";
+    fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+
+    AddToBranchList("fHiGainPixId");
+    //AddToBranchList("fLoGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+    //AddToBranchList("fLoGainFadcSamples");
+}
+
+Bool_t MPedCalcPedRun::PreProcess( MParList *pList )
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+        return kFALSE;
+
+    fNumHiGainSamples = fRawEvt->GetNumHiGainSamples();
+
+    return kTRUE;
+}
+
+
+Bool_t MPedCalcPedRun::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+              Byte_t *ptr = pixel.GetHiGainSamples();
+        const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
+
+        const Float_t higainped = CalcHiGainMean(ptr, end);
+        const Float_t higainrms = CalcHiGainRms(ptr, end, higainped);
+
+        const Float_t higainpederr = CalcHiGainMeanErr(higainrms);
+        const Float_t higainrmserr = CalcHiGainRmsErr(higainrms);
+
+        const UInt_t pixid = pixel.GetPixelId();
+        MPedestalPix &pix = (*fPedestals)[pixid];
+
+        pix.SetPedestal(higainped, higainrms);
+        pix.SetPedestalRms(higainpederr, higainrmserr);
+    }
+
+    fPedestals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const
+{
+    Int_t sum=0;
+
+    do sum += *ptr;
+    while (++ptr != end);
+
+    return (Float_t)sum/fNumHiGainSamples;
+}
+
+
+Float_t MPedCalcPedRun::CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const
+{
+    Float_t rms = 0;
+
+    do
+    {
+        const Float_t diff = (Float_t)(*ptr)-higainped;
+
+        rms += diff*diff;
+    } while (++ptr != end);
+
+    return sqrt(rms/(fNumHiGainSamples-1));
+}
+
+Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
+{
+    return higainrms/sqrt(fNumHiGainSamples);
+}
+
+Float_t MPedCalcPedRun::CalcHiGainRmsErr(Float_t higainrms) const
+{
+    return higainrms/sqrt(2.*fNumHiGainSamples);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedCalcPedRun.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MPedCalcPedRun
+#define MARS_MPedCalcPedRun
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedCalcPedRun                                                          //
+//                                                                         //
+// Evaluate the pedestals from pedestal runs                               //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedestalCam;
+
+class MPedCalcPedRun : public MTask
+{
+    Byte_t fNumHiGainSamples;
+
+    MRawEvtData  *fRawEvt;     // raw event data (time slices)
+    MPedestalCam *fPedestals;  // Pedestals of all pixels in the camera
+
+    Float_t CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const;
+    Float_t CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const;
+    Float_t CalcHiGainMeanErr(Float_t higainrms) const;
+    Float_t CalcHiGainRmsErr(Float_t higainrms) const;
+
+public:
+
+    MPedCalcPedRun(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MPedCalcPedRun, 0)   // Task to calculate pedestals from pedestal runs raw data
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.cc	(revision 1638)
@@ -0,0 +1,229 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 11/2002 <mailto:jflix@ifae.es>
+!   Author(s): Thomas Bretz 11/2002 <mailto:tbretz@astro.uni-wuerburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MPedestalCalc
+//
+//  Task to calculate the pedestals from the event stream.
+//
+//  From the events two streams of pedestals are created like in the
+//  following table
+//  MRawEvtData:    1   2   3   4   5   6   7   8   9  10  11  12
+//  MPedestalCam;1: ------1------   ------2------   ------3------...
+//  MPedestalCam;2:         ------1------   ------2------  ------...
+//
+//  Input Containers:
+//   MRawEvtData
+//
+//  Output Containers:
+//   MPedestalCam;1
+//   MPedestalCam;2
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MHFadcCam.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MPedestalCalc);
+
+MPedestalCalc::MPedestalCalc(const char *name, const char *title)
+    : fNumBranches(2), fTimeSlot(6), fHists(NULL)
+{
+    fName  = name  ? name  : "MPedestalCalc";
+    fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+
+    AddToBranchList("fHiGainPixId");
+    AddToBranchList("fLoGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+    AddToBranchList("fLoGainFadcSamples");
+}
+
+Bool_t MPedestalCalc::PreProcess(MParList *pList)
+{
+    if (fHists)
+    {
+        *fLog << err << "ERROR - Previous PostProcess not called." << endl;
+        return kFALSE;
+    }
+
+    fHists = new MHFadcCam[fNumBranches];
+    fStart = new MTime    [fNumBranches];
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+        return kFALSE;
+
+    fPedTime = (MTime*)pList->FindCreateObj("MTime", "MPedestalTime");
+    if (!fPedTime)
+        return kFALSE;
+
+    //
+    // Fixme: FindCreateObj --> FindObject
+    //
+    fEvtTime = (MTime*)pList->FindCreateObj("MTime", "MRawEvtTime");
+    if (!fEvtTime)
+        return kFALSE;
+
+    for (int i=0; i<fNumBranches; i++)
+        fStart[i].SetTime(fTimeSlot*10/fNumBranches*i, 0);
+
+    fPedTime->SetDuration(fTimeSlot);
+    fEvtTime->SetTime(0, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks whether the current event exceed the validity range of a pedestal
+//  in one of the streams. If this is the case the data from the histogram
+//  is dumped as pedestals into the corresponding containers and the
+//  histograms are reset.
+//
+//  Then the current event is filled into the histograms.
+//
+Bool_t MPedestalCalc::Process()
+{
+    //
+    // Time when filling of stream a/b must be restarted
+    //
+    for (int i=0; i<fNumBranches; i++)
+    {
+        Check(i);
+        Fill(i);
+    }
+
+    fEvtTime->SetTime(fEvtTime->GetTimeLo()+10, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the event in the histogram if the current time of the
+//  event is _after_ the start time for filling
+//
+void MPedestalCalc::Fill(Int_t i)
+{
+    if (*fEvtTime < fStart[i])
+        return;
+
+    fHists[i].Fill(fRawEvt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the current time of the event is equal or after the time
+//  which is given by the start time plus the validity range
+//  calculate the corresponding set of pedestals and reset the
+//  histograms
+//
+void MPedestalCalc::Check(Int_t i)
+{
+    if (*fEvtTime-fStart[i] < fTimeSlot*10)
+        return;
+
+    Calc(i);
+
+    fStart[i] = *fEvtTime;
+    fHists[i].ResetHistograms();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all dynamicly allocated arrays
+//
+Bool_t MPedestalCalc::PostProcess()
+{
+    delete fHists;
+    delete fStart;
+
+    fHists=NULL;
+
+    return kTRUE;
+}
+
+/*
+ #include "MRawEvtData.h"
+ */
+// --------------------------------------------------------------------------
+//
+//  Dumps the mean, rms and their errors from the filled histograms into
+//  the Pedestal container. Sets the ReadyToSaveFlag of the MPedestalCam
+//  container.
+//
+void MPedestalCalc::Calc(Int_t i) const
+{
+    // FIXME! Fit +- 3 sigma to avoid outliers...
+
+    MRawEvtPixelIter pixel(fRawEvt);
+    while (pixel.Next())
+    {
+        const UInt_t pixid = pixel.GetPixelId();
+
+        const TH1 &h = *fHists[i].GetHistHi(pixid);
+
+        const Int_t   entries = (Int_t)h.GetEntries();
+        const Float_t meanhi  = h.GetMean();
+        const Float_t rmshi   = h.GetRMS();
+
+        const Float_t meanhierr = rmshi/sqrt(entries);
+        const Float_t rmshierr  = rmshi/sqrt(entries*2);
+
+        MPedestalPix &pix = (*fPedestals)[pixid];
+        pix.SetPedestal(meanhi, rmshi);
+        pix.SetPedestalRms(meanhierr, rmshierr);
+    }
+
+    *fPedTime = fStart[i];
+
+    fPedTime->SetReadyToSave();
+    fPedestals->SetReadyToSave();
+
+    /*
+     *fLog << i << "[" << fHists[i].GetHistHi(0)->GetEntries()/fRawEvt->GetNumHiGainSamples() << "]:  ";
+     *fLog << fEvtTime->GetTimeLo() << ": Calc [";
+     *fLog << fStart[i].GetTimeLo() << " < ";
+     *fLog << fStart[i].GetTimeLo()+fTimeSlot*10 << "]" << endl;
+     */
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCalc.h	(revision 1638)
@@ -0,0 +1,59 @@
+#ifndef MARS_MPedestalCalc
+#define MARS_MPedestalCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCalc                                                           //
+//                                                                         //
+// Implementation of ped. Eval. defined in Jan 02                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHFadCam
+#include "MHFadcCam.h"
+#endif
+
+class MTime;
+class MRawEvtData;
+class MPedestalCam;
+
+class MPedestalCalc : public MTask 
+{
+private:
+    Int_t   fNumBranches;
+    Float_t fTimeSlot;
+
+    MRawEvtData  *fRawEvt;
+    MPedestalCam *fPedestals;  //
+
+    MHFadcCam *fHists;         //[fNumBranches]
+
+    MTime     *fPedTime; // time of the pedestal event
+    MTime     *fEvtTime; // time of the current event
+    MTime     *fStart;   //[fNumBranches] starting time of the current pedestal
+
+
+    void Calc(Int_t i) const;
+    void Fill(Int_t i);
+    void Check(Int_t i);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+public:
+    MPedestalCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetTimeSlot(Float_t newslot) { fTimeSlot = newslot; }
+    void SetNumBranches(Int_t num) { fNumBranches = num; }
+
+    ClassDef(MPedestalCalc, 0) // Task to calculate the pestels from pedestal events
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.cc	(revision 1638)
@@ -0,0 +1,181 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCam                                                            //
+//                                                                         //
+// Hold the Pedestal information for all pixels in the camera              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+
+ClassImp(MPedestalCam);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates a MPedestalPix object for each pixel
+//
+MPedestalCam::MPedestalCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPedestalCam";
+    fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
+
+    fArray = new TClonesArray("MPedestalPix", 577);
+
+    for (int i=0; i<577; i++)
+        new ((*fArray)[i]) MPedestalPix;
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the pixel pedest information
+//
+MPedestalCam::~MPedestalCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MPedestalCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MPedestalCam
+//
+Int_t MPedestalCam::GetSize() const
+{
+    return fArray->GetEntries();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MPedestalPix &MPedestalCam::operator[](Int_t i)
+{
+    return *(MPedestalPix*)fArray->UncheckedAt(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MPedestalPix &MPedestalCam::operator[](Int_t i) const
+{
+    return *(MPedestalPix*)fArray->UncheckedAt(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if position i is inside bounds
+//
+Bool_t MPedestalCam::CheckBounds(Int_t i)
+{
+    return i < fArray->GetEntriesFast();
+} 
+
+void MPedestalCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
+
+void MPedestalCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int id = 0;
+
+    TIter Next(fArray);
+    MPedestalPix *pix;
+    while ((pix=(MPedestalPix*)Next()))
+    {
+        id++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << id-1 << ": ";
+        *fLog << pix->GetMean() << " " << pix->GetSigma() << " ";
+        *fLog << pix->GetMeanRms() << " " << pix->GetSigmaRms() << endl;
+    }
+}
+
+Float_t MPedestalCam::GetMeanMin(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t minval = (*this)[0].GetMean();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetMean();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+Float_t MPedestalCam::GetMeanMax(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetMean();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetMean();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalCam.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MPedestalCam
+#define MARS_MPedestalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TClonesArray;
+
+class MGeomCam;
+class MPedestalPix;
+
+class MPedestalCam : public MParContainer
+{
+private:
+    TClonesArray *fArray; // FIXME: Change TClonesArray away from a pointer?
+
+public:
+    MPedestalCam(const char *name=NULL, const char *title=NULL);
+    ~MPedestalCam();
+
+    void Clear(Option_t *o="");
+
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    MPedestalPix &operator[](Int_t i);
+    MPedestalPix &operator[](Int_t i) const;
+
+    Float_t GetMeanMin(const MGeomCam *cam) const;
+    Float_t GetMeanMax(const MGeomCam *cam) const;
+
+    Bool_t CheckBounds(Int_t i);
+
+    void Print(Option_t *o="") const;
+
+    ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.cc	(revision 1638)
@@ -0,0 +1,55 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalPix                                                            //
+//                                                                         //
+// This is the storage container to hold informations about the pedestal   //
+// (offset) value of one Pixel (PMT).                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalPix.h"
+
+#include "MLog.h"
+
+ClassImp(MPedestalPix);
+
+MPedestalPix::MPedestalPix()
+{
+    Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MPedestalPix::Clear(Option_t *o)
+{
+    fMean = -1;
+    fSigma = -1;
+    fMeanRms = -1;
+    fSigmaRms = -1;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MPedestalPix.h	(revision 1638)
@@ -0,0 +1,40 @@
+#ifndef MARS_MPedestalPix
+#define MARS_MPedestalPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MPedestalPix : public MParContainer
+{
+private:
+    Float_t fMean;     // mean value of pedestal (PMT offset)
+    Float_t fSigma;    // sigma (standard deviation) of pedestal
+    Float_t fMeanRms;  // root mean square of pedestal
+    Float_t fSigmaRms; // root mean sqare of sigma of the pedestal
+
+public:
+    MPedestalPix();
+
+    void Clear(Option_t *o="");
+
+    Float_t GetMean() const     { return fMean;     }
+    Float_t GetSigma() const    { return fSigma;    }
+    Float_t GetMeanRms() const  { return fMeanRms;  }
+    Float_t GetSigmaRms() const { return fSigmaRms; }
+
+    void SetMean(Float_t f)     { fMean = f;     }
+    void SetSigma(Float_t f)    { fSigma = f;    }
+    void SetMeanRms(Float_t f)  { fMeanRms = f;  }
+    void SetSigmaRms(Float_t f) { fSigmaRms = f; }
+
+    void SetPedestal(Float_t m, Float_t s) { fMean = m; fSigma = s; }
+    void SetPedestalRms(Float_t m, Float_t s) { fMeanRms = m; fSigmaRms = s; }
+
+    Bool_t IsValid() const { return fMean>=0||fSigma>=0||fMeanRms>=0||fSigmaRms>=0; }
+
+    ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.cc	(revision 1638)
@@ -0,0 +1,105 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPosCam
+//
+// Storage Container to hold the current position of the source (or
+// anti/false source) in the camera plain
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MSrcPosCam.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSrcPosCam);
+
+static const TString gsDefName  = "MSrcPosCam";
+static const TString gsDefTitle = "Virtual source position in the camera";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MSrcPosCam::MSrcPosCam(const char *name, const char *title) : fX(0), fY(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// -----------------------------------------------------------------------
+//
+void MSrcPosCam::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source position in the camera plain (" << GetName() << ")" << endl;
+    *fLog << " - x [mm] = " << fX << endl;
+    *fLog << " - y [mm] = " << fY << endl;
+}
+
+/*
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to read MSrcPosCam from an ascii file
+//
+void MSrcPosCam::AsciiRead(ifstream &fin)
+{
+    fin >> fX;
+    fin >> fY;
+}
+
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to write MSrcPosCam to an ascii file
+//
+void MSrcPosCam::AsciiWrite(ofstream &fout) const
+{
+    fout << fX << " " << fY;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MSrcPosCam::StreamPrimitive(ofstream &out) const
+{
+    out << "   MSrcPosCam " << GetUniqueName();
+    if (fName!=gsDefName)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    out << "   " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;}
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/MSrcPosCam.h	(revision 1638)
@@ -0,0 +1,36 @@
+#ifndef MARS_MSrcPosCam
+#define MARS_MSrcPosCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MSrcPosCam : public MParContainer
+{
+private:
+    Float_t fX; // [mm] x position of source in camera
+    Float_t fY; // [mm] y position of source in camera
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MSrcPosCam(const char *name=NULL, const char *title=NULL);
+
+    void Clear(Option_t *)           { fX = 0; fY = 0; }
+
+    void SetX(Float_t x)             { fX = x; }
+    void SetY(Float_t y)             { fY = y; }
+    void SetXY(Float_t x, Float_t y) { fX = x; fY = y; }
+
+    Float_t GetX() const             { return fX; }
+    Float_t GetY() const             { return fY; }
+
+    void Print(Option_t *opt=NULL) const;
+
+    //void AsciiRead(ifstream &fin);
+    //void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MSrcPosCam, 1) // container to store source position in the camera plain
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/manalysis/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/manalysis/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/manalysis/Makefile	(revision 1638)
@@ -0,0 +1,72 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Analysis
+
+#
+# Library name to creatre
+#
+LIB   = manalysis.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mmc -I../mraw -I../mgeom \
+	   -I../mdata -I../mhist 
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MPedestalPix.cc \
+           MPedestalCam.cc \
+           MMcPedestalCopy.cc \
+           MMcPedestalNSBAdd.cc \
+           MImgCleanStd.cc \
+           MEnergyEst.cc \
+           MEnergyEstimate.cc \
+           MEnergyEstParam.cc \
+           MSrcPosCam.cc \
+           MCameraSmooth.cc \
+           MHadronness.cc \
+           MMatrixLoop.cc \
+           MCompProbCalc.cc \
+           MMultiDimDistCalc.cc \
+           MHillas.cc \
+           MHillasSrc.cc \
+           MHillasExt.cc \
+           MHillasCalc.cc \
+           MHillasSrcCalc.cc \
+	   MCerPhotPix.cc \
+	   MCerPhotEvt.cc \
+           MCerPhotAnal.cc \
+	   MCerPhotCalc.cc \
+	   MPedCalcPedRun.cc \
+           MBlindPixels.cc \
+           MBlindPixelCalc.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
Index: /tags/Mars_V0-8/MagicSoft/Mars/mars.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mars.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mars.cc	(revision 1638)
@@ -0,0 +1,127 @@
+#include <TROOT.h>
+#include <TApplication.h>
+
+#include "MAGIC.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMars.h"
+#include "MArray.h"
+#include "MParContainer.h"
+
+//#define HAVE_LOGO 1
+#ifdef HAVE_LOGO
+#include "MLogo.h"
+#endif
+
+// **********************************************************************
+//
+//    MARS main program  
+//
+//    The only job of the main program is the initialisation of ROOT and 
+//    the start of the guiinterface for the mars program
+//
+//    started by  h. kornmayer      january, 3rd  2001 
+
+void Usage()
+{
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   mars [-vn]" << endl << endl;
+    gLog << "     -v0: verbosity level: as less as possible" << endl;
+    gLog << "     -v1: errors only"                          << endl;
+    gLog << "     -v2: errors and warnings <default>"        << endl;
+    gLog << "     -v3: errors, warnings and infos"           << endl;
+}
+
+int main(int argc, char **argv)
+{
+#ifdef HAVE_LOGO
+    MLogo logo;
+    logo.Popup();
+#endif
+
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                    MARS V0.8                     " << endl;
+    gLog << "    Magic Analysis and Reconstruction Software    " << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+
+    //
+    // check for the right usage of the program
+    //
+    if (argc<1 || argc>2)
+    {
+        Usage();
+        return -1;
+    }
+
+    if (argc==2)
+    {
+        if (argv[1][0]!='-' || argv[1][1]!='v')
+        {
+            Usage();
+            return -1;
+        }
+
+        switch (argv[1][2])
+        {
+        case '0':
+            gLog.SetDebugLevel(0);
+            break;
+        case '1':
+            gLog.SetDebugLevel(1);
+            break;
+        case '2':
+            gLog.SetDebugLevel(2);
+            break;
+        case '3':
+            gLog.SetDebugLevel(3);
+            break;
+        default:
+            Usage();
+            return -1;
+        }
+    }
+    else
+        gLog.SetDebugLevel(2);
+
+    //
+    // Swtich of TObjectStreamer in our base classes derived from TObject
+    //
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    //
+    // initialise ROOT
+    //
+    TROOT simple("mars", "MARS - Magic Analysis and Reconstruction Software");
+
+    TApplication app("MarsApp", &argc, argv);
+
+#ifdef HAVE_LOGO
+    logo.Popdown();
+#endif
+
+    //
+    // start the main window
+    //
+    new MMars;
+
+    //
+    // run the application
+    //
+    app.Run();
+
+    gLog << all << endl;
+
+    return 0;
+}
+ 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/marslogo.xpm
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/marslogo.xpm	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/marslogo.xpm	(revision 1638)
@@ -0,0 +1,363 @@
+/* XPM */
+static char *marslogo[] = {
+/* width height ncolors chars_per_pixel */
+"100 100 256 2",
+/* colors */
+"   c #E99C39",
+" . c #71705B",
+" X c #113A42",
+" o c #DBAF21",
+" O c #9A8A76",
+" + c #928282",
+" @ c #7B815E",
+" # c #AD6A4A",
+" $ c #172834",
+" % c #6C7F8E",
+" & c #444B49",
+" * c #1C3B46",
+" = c #785944",
+" - c #28485F",
+" ; c #EA8651",
+" : c #C8714A",
+" > c #8A7145",
+" , c #515759",
+" < c #9E6145",
+" 1 c #061837",
+" 2 c #4F5157",
+" 3 c #636464",
+" 4 c #485750",
+" 5 c #9E962A",
+" 6 c #2C2A24",
+" 7 c #3D464F",
+" 8 c #B17854",
+" 9 c #DBC313",
+" 0 c #647789",
+" q c #867A3A",
+" w c #A7705E",
+" e c #9F7656",
+" r c #D2BE14",
+" t c #82604A",
+" y c #3E4D5D",
+" u c #544C16",
+" i c #A7AB99",
+" p c #C58443",
+" a c #C9B40B",
+" s c #88803F",
+" d c #263542",
+" f c #5C6877",
+" g c #8A7A02",
+" h c #9C7160",
+" j c #9D9C2F",
+" k c #6E6622",
+" l c #5C6463",
+" z c #999F8B",
+" x c #152A3B",
+" c c #A0937E",
+" v c #E9C313",
+" b c #E9B81D",
+" n c #B4833F",
+" m c #90624A",
+" M c #02051B",
+" N c #655244",
+" B c #D1B819",
+" V c #AD7642",
+" C c #AA6853",
+" Z c #2A2A2B",
+" A c #646550",
+" S c #988602",
+" D c #3C4B4D",
+" F c #64693C",
+" G c #5A5850",
+" H c #263F5F",
+" J c #B4A11A",
+" K c #AB8339",
+" L c #3B3C42",
+" P c #D2814F",
+" I c #5A5146",
+" U c #3F5D7E",
+" Y c #2A4A70",
+" T c #273D4C",
+" R c #BABAAE",
+" E c #C88C3B",
+" W c #64716A",
+" Q c #635C1D",
+" ! c #3A3202",
+" ~ c #E8A92C",
+" ^ c #7C783C",
+" / c #746952",
+" ( c #8F5D45",
+" ) c #51524A",
+" _ c #C89D34",
+" ` c #C3AE25",
+" ' c #BAA830",
+" ] c #D17951",
+" [ c #020203",
+" { c #BC8B3C",
+" } c #D46A4A",
+" | c #B0A026",
+".  c #113643",
+".. c #32618B",
+".X c #141525",
+".o c #16253E",
+".O c #776705",
+".+ c #050C20",
+".@ c #92674E",
+".# c #3F4345",
+".$ c #6A5E02",
+".% c #8B7B5E",
+".& c #797174",
+".* c #A96E4A",
+".= c #8E8643",
+".- c #9E826A",
+".; c #CA9232",
+".: c #71696C",
+".> c #255B81",
+"., c #08131C",
+".< c #827716",
+".1 c #B3A81B",
+".2 c #BE704E",
+".3 c #E87A53",
+".4 c #9C8B0B",
+".5 c #DC7951",
+".6 c #D1943C",
+".7 c #18191B",
+".8 c #9A863E",
+".9 c #9C8040",
+".0 c #C5A926",
+".q c #8F6A5B",
+".w c #C87751",
+".e c #9E961A",
+".r c #06203E",
+".t c #DECA10",
+".y c #485A61",
+".u c #EA8C44",
+".i c #B69A8B",
+".p c #DD8155",
+".a c #7E6E4A",
+".s c #334249",
+".d c #DB9A35",
+".f c #9E7D4F",
+".g c #0D3D69",
+".h c #DBAA21",
+".j c #5A5941",
+".k c #785F4E",
+".l c #967947",
+".z c #1A4A6F",
+".x c #D2714A",
+".c c #EBA234",
+".v c #B1933D",
+".b c #323234",
+".n c #826851",
+".m c #293335",
+".M c #165282",
+".N c #4D6376",
+".B c #687876",
+".V c #716054",
+".C c #6A7039",
+".Z c #364E52",
+".A c #83695F",
+".S c #34567B",
+".D c #0A2834",
+".F c #31484D",
+".G c #1D3C61",
+".H c #406380",
+".J c #4E5C70",
+".K c #69651A",
+".L c #B49A3C",
+".P c #171A30",
+".I c #151403",
+".U c #0B0C0D",
+".Y c #C26A4A",
+".T c #3F5261",
+".R c #314B71",
+".E c #B8694A",
+".W c #AB9B15",
+".Q c #324B5E",
+".! c #AB6447",
+".~ c #7E6E56",
+".^ c #757782",
+"./ c #B38A3E",
+".( c #DCBA1A",
+".) c #A89C89",
+"._ c #DD9339",
+".` c #484003",
+".' c #E4764A",
+".] c #425253",
+".[ c #5B6351",
+".{ c #666973",
+".} c #403C26",
+".| c #827E74",
+"X  c #E9943E",
+"X. c #AA8B42",
+"XX c #072130",
+"Xo c #596070",
+"XO c #654D47",
+"X+ c #607184",
+"X@ c #877065",
+"X# c #323C43",
+"X$ c #594A45",
+"X% c #675E56",
+"X& c #273D42",
+"X* c #92928A",
+"X= c #E9BE19",
+"X- c #4E4544",
+"X; c #32425A",
+"X: c #67574C",
+"X> c #E28A4E",
+"X, c #35536A",
+"X< c #CE8A4E",
+"X1 c #728692",
+"X2 c #071A29",
+"X3 c #DB8B3D",
+"X4 c #8C801A",
+"X5 c #061428",
+"X6 c #BD9F33",
+"X7 c #4D4B46",
+"X8 c #C1A123",
+"X9 c #E7AF24",
+"X0 c #968A52",
+"Xq c #715145",
+"Xw c #C2AE06",
+"Xe c #8C9048",
+"Xr c #51574D",
+"Xt c #D29D37",
+"Xy c #2E2E2E",
+"Xu c #9F8B3D",
+"Xi c #C5B420",
+"Xp c #D1A922",
+"Xa c #D5A126",
+"Xs c #8F7155",
+"Xd c #EED506",
+"Xf c #815944",
+"Xg c #AEA831",
+"Xh c #415872",
+"Xj c #BD9536",
+"Xk c #928305",
+"Xl c #242424",
+"Xz c #705947",
+"Xx c #595E4E",
+"Xc c #788A8A",
+"Xv c #DB8343",
+"Xb c #D38D3B",
+"Xn c #919132",
+"Xm c #6A763A",
+"XM c #A17142",
+"XN c #5A5B5C",
+"XB c #E9CA0E",
+"XV c #C07750",
+"XC c #EA7F55",
+"XZ c #365C6A",
+"XA c #AA9605",
+"XS c #685742",
+"XD c #1D1E20",
+"XF c #1A313E",
+"XG c #B56E4F",
+"XH c #D3B220",
+"XJ c #907066",
+"XK c #0B3143",
+"XL c #272202",
+"XP c #082940",
+"XI c #193554",
+"XU c #9E684C",
+/* pixels */
+"XlXlXlXy Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z ZXy",
+"XlXlXlXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXy",
+"Xy.bXl.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U Z",
+".b.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.U.U.+.,.,XXX2X5.,.+.+.U.+ [ M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.,.,XXXXXF $ xXF. XFXF.FX&.FX& * xXF.D x.D.DX2X2., M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [.U [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.+XX.D X X.FX&X&.F.F.s.F.].].].].FX& * * * X. . .DXX.,.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+.UXX.D $X&X&X& *.F.F.Z 4.]Xr.[.B %.B.B.[ D D.s.sX&.FX& *XF.D.DX2X5.+.U [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.U.,XXXF dX&X&X&X&X&.mX#.Z 4 W ..C.B @X* z z z.| F.[Xr & & 4.] 4 DX&X&. . .D.DX5.U M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+.D xX&.F.s.F.sX&X# dXF.m.b A.| i z zX*.).).).) c @ / /.V.jXx.jXx.[Xr & &.F.sX& *XKXXXX.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [.U [ [ [ [ [ [ [ [.U [ [ [ [ [ [ [ [ [ [ [ [ [ [.,XI *.s D.#.s.s.sX#.m.m.m.b.: + R i i.).).) c O O.% / / /XxXx G.[ A.j & & &.ZX&X& XXP.DX5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.,.,.DX& 7.s.#.s.#.s.#.s.b.b.b.b.b.kX@.i.i.i.-.- h m m.n t N.j I I.[.[X% / A I I & & D D.s X. XKXXX5 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+ $X&X&X#.FX- & &X7 &X7X7X7XO IX$X-X-X7 IXzXz N NXS N.V.VXz.j.j I.j.jX: AXzXSXS N.j I uX7 &.#X#.m * XXPX2 1.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.,.D.FX#X#X#.# &X7Xr I NXOXq =Xf ( ( = =XOXOX$X$X$X$X$ I NXS N NXzXzXzXS.~.n.kXzXz NXO N I I ) &.b.bX&X& XXKXKXX.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.+XP d.Z.mX#X#.#X7X7.jXS =XfXfXf ( < ( (XfXf =XqXqXqXq NXqXf = = =.k = t =.n.aXf = =XSXq N N I I &.}X#.FX& *XKXKXPX5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U x. .F.Q.sX#X#X# & I I = = ( < < < < < < < <.! < < < ( < ( < ( ( m m ( ( ( t t = = = =XzXz NXq N NX7 &.F &.s.s X X XXKX2X5.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M x.FX;.s.s.#.#.#.#X7XO NXfXf ( ( < < < < < <.! <.! < ( < < < < ( ( ( ( ( ( ( t t.nXf = = =XzXq NXS N I & & & & &X&X#X& XXKXPXXX5 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [., -.s.s.s.s 7 & &X7 IXOXq t ( < < < < < < <XUXM.! <.! < < <XM < < <XU ( (XfXfXf t t = = =Xz =XSXqXzXS IX-X7X7 & &X#X#X#X& X XXK.r [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" 6XyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ xXF.Z.Z D.F D &X7 &X$ N =Xf ( ( < < m <XU < <.!.! <.! < < <.* < < < < < <Xf ( (Xf (Xf = =XzXzXSXSXSXS N IX7 &X7X7.#.s.s.F.s * X.DXP.+ M [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [.+X2.F.Z.T.] 2 4.] )X7 IXS = m m < < ( ( ( ( m < < < < m < ( ( ( ( ( (Xf tXfXfXfXfXfXf = =XzXzXO NXS N N N I IX7 ) &X7 &.#.}.s.#.s.s.m. .D.r.+ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [.UXF T 7.Q.] 2 2 , ) ).j IXS ( <.! < <XfXf =XqXf ( ( ( ( tXfXfXqXqXzXqXqXSXSXSXq N NXq NXS NXO.jX$X$ I I N I I I )X7X7X7X7 & & & & & &.#X&. XKX2.+ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ [.,X&.F.# 7 4 , 2 2 , ) I I = <.! <.! <Xf =XqXqXf ( ( ( ( t t =XqXOXqXO N I I IXO I I N I N IX$ IX7X7X$ I N I I.jX7X$X7X7X- & & & &X7 &.FX# X. .DX5 [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [X5 x.s.s & & 2 4 ,XN G GXOXO = <.!.!.!.!Xf = = tXf ( (XfXf.n tXf =Xz =XqXS N N N N N.j I IX$X7X7X7.#X7X7X7 I I ).j ) )X7X7 & & & &X-X7 u &X-X#X&XK.rX5 [ [ [ [ [ [ [ [ [ [ [Xl",
+".b.b.7 [ [ [ [ [ [ [ [ [ M -.Z D 7X- 2 4 G G G G IXO NXq <.!.E #.! ( ( ( ( = < < ( ( t t =Xz =XzXzXS = = =Xf I I I IX7X7X-.s.} & & & & ) ) I I IX7X7X7 & &X7X7 I IX7X7.F.s * XXP M [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ d.Z.Z &.#.#.# ) IX7X7 IX$ N NXz.!.!.E.!.!.!.! < < < < < < < < (XzXzXSXzXS NXzXz =XS I N I IX7X7.#.sX#.s.# & &X7X7 IX7X7X7 )X7.j ) )X$ I I I IX7 &X# TXPX5.+ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ M T.Z.].# &X-X-X7 IX7X$ IX$ N N = <.E.E.!.!.!.E < < <XU < <XU < <Xf =.kXSXS IXzXSXSXO N I I IX7 & &.#X#.#.#X7X7 &X7 )X7X$X7 )X7XrXrX7 I.j N N IX7 &.s T.  1X5 [ [ [ [ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [ [ [.+ $.F.] & & &X-X7X-X$ I I IXqXqXfXf.!.E.E.E.Y.E.E.E.!.! # # #.E.! #XU < ( mXfXSXSXzXS I N I IX7 &X7 &.# D D & &X7X7X7X7X7 )X7X7X7X$ I IXSXSXSXS NX7 ) &.Z.GXP.r.+ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [XX -.]X7X7X- &X-X-X$XO N N N = (Xf <.!.!.Y.Y.E.E.E.E.E.!.E.E.E.Y.E.2.2.E.Y #.!.@ m mXfXzXzXz I IX- &X7 & & & & &X7 ) ) &X7 &X7X7 ) N IXq =XzXzX:XS I I 4 D -XKXP.+ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [XFX,.]X7 &X7X-X$X$ I I IXOXOXf ( ( <.!.E.E.E.Y.E.E.E #.!XG.!.Y.2.2 :.Y.Y.2.2.EXUXUXU < t ( t =XS I I IX7 &X7 &X7X7 &X7X7X7X7X7 & IXSXzXz = =XzXzXz I I.].T T.gXKX2.+ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [.+X;.y.]Xr )X7 I = =XqXz NXfXf ( ( < < #.E.E.2.2 :.w :.E.*.E.E : : : : : : :XV : :.E.EXGXG # # # # m (.kXS.jX7X7X7X7 D & )X7X7X7.jXz t t.nXf = =XzXz N G ).Z T H.zXP 1 [ [ [ [ [ [ [Xl",
+" ZXyXD [ [ [ [ [.P x.y 4X7 ) I = t m.@ m < (XU <XU #.! #.E.2.E.2XG : : :.x.x : : : :.x :.xXV.E.2.2XGXU < #.! ( (XU # #.E.!XU <XzXSX7 ) &X7X7 IXSXqXf m m m m t t t =XzXz N ) & -.Q Y.M.g M M [ [ [ [ [Xl",
+".bXyXD [ [ [ [ [ * T.y.y ) ).j t mXUXUXU C.! # # #.EXG.E.2.Y.E.Y.!.E.2 :.x p.x.x.x.x.x ].xXG.EXG.2 #.@ <XU <XqXf mXU.EXG.Y.Y #.n = ) )X7X7X7XSX: (Xf ( m.@ ( ( t t = =X:X% 2.].FX,XZ.M.MX5.+ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [X;.Q.y ) )X: =XUXU C #XU.E.EXGXG.EXG.2.2.2.2.2.! <.!.!XG :.Y.Y.2.x ].x.x.x.Y.2.2 : : < m <XfXz = <XUXUXUXG.E.* t = IX$X7X$ I t t < ( < m m ( ( t t.k =XzXz ) 4.FX,.S...>.rX5 [ [ [ [ [Xl",
+" ZXy.7 [ [ [ [.,Xh.J.] &X: m.q.*.*.!.! C.EXG.2.2.2.2.Y.2 :.2.E <.@ ( < #.EXG #.E :.x :.w.x.x.x.x.x :.@ < m =Xq = <XUXU.!.*.*.!.@ tX$X7 I I = <XU < <.@ mXU m ( ( t t = =Xz GXN.ZX,.S.....gXK [ [ [ [ [Xl",
+" Z 6XD [ [ [.IX& l fXxXx.nXUXUXU C.!.!.* #.2XVXV.2.2 :XV.2 : V.!.!.! # :.x.2.2 : ].x.wXV.xXv ]Xv ]XG.!XU.@ m tXf t < # # # #XGXU mXSXS.a t.@XM.*XUXMXM < m.@ ( t m t =.k =X: G 2.T.N.N.H.>.z.7.U.I.U [Xl",
+" Z Z.7 [ [.`Xk.eXgXg |XgX8 VXU.*XU.!.E.E #.EXVXa.h o.h.h.h.hXa < #.EXG :.x : :XV.x.x.;.h oX9.hX9 o.2XM.*XU.@.n t = ( # # # VXpX8.0 J J.0XwXpXpXpXpXpXpXj.@ < ( m t.n = = =X% GXr.yXnXgXg j jXkXkXk.OXL 6",
+"XyXyXD [ [.$XBXBXdXBXdXdXd nXU.!.!.!.!.!.E.E p 9XdXBXdXdXBXd.( #.2 : :.x.x.5.x.'.x.'.dXdXdXdXdXdXBXb m < <.E.E.E < m m m <.9XBXdXBXdXBXdXBXdXBXdXBXdXB 9XH./ m ( ( m t.V.kX:X% |.1.tXdXdXdXdXBXdXB 9XA.<",
+" ZXy.7 [.`XAXdXdXdXdXdXdXd {.!.!.!.!.E.E.Y.Y.hXBXdXdXdXdXdXBX= :.x.x.x.x.'.'.'.'.'.u bXdXdXdXdXdXd.hXM mXU.2 : : :XG.E # VX8XBXdXdXdXdXdXdXdXdXdXdXdXdXdXB oXM m (.q.AXf.A /.9.t.tXdXdXdXdXdXdXdXdXd.t.W",
+"XyXyXD [ gXBXdXdXdXdXdXdXd.0 V.E.E.E.E.Y } }XBXdXdXdXdXdXd v.d ].'.x.5.3.'.'.'.'XC ~XBXdXBXdXdXdXdXB K ( ( #.x.x.x : } } EX=XdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXB K m m m (.A.k.9 BXdXdXdXdXdXdXdXdXdXdXd 9.<",
+"XyXy.7 [.4XdXdXdXdXdXdXdXd v n #.EXGXG.2.x._XdXdXdXdXdXdXd b.'.'.5.'.'.3XC.3.'.'.uX=XdXdXdXdXdXdXdXd n < (XG.x.x.x :.x :Xb vXdXdXdXdXB.hX9.h o bXdXdXdXdXdXd K m m m.A.k.9XiXdXdXdXdXd `Xg | j S.4XdXw u",
+" ZXy.7 [ SXdXdXdXdXdXdXdXdXB pXGXV.2.2.x ]XdXdXdXdXdXdXdXdX9.'.'.'.3.3.3.3XC.3.3X9XdXdXdXdXdXdXdXdXdXb.Y.2.2 }.x.Y :.x.YX3XBXdXdXdXd b.E #.E.E.;XdXdXdXdXdXd KXU m.A (.A BXdXdXdXdXB r W.S.>.g.U [ J S.}",
+"XyXy.7 [.4XdXdXdXdXdXdXdXdXB p.2XV.2XV ]X3XdXdXdXdXdXdXdXd b.'.'.'.3.3XC.3.3.3.u bXdXdXdXBXdXdXdXdXd._.'.x :.x : : : : }XbXBXdXdXdXd o.Y.2.E.!.;XdXdXdXdXdXd {.@.q.@ m.l.(XdXdXdXd 9Xe.N.N.H.g.+ [XLXL 6",
+" Z 6XD.IXAXdXdXdXdXdXdXdXdXB pXV.2XV.2 P bXdXdXdXdXdXdXdXd b.3.3.3.3.3.3.3.3.3X XBXdXdXBXBXdXdXdXdXdXa.x.x : : :.x : : :.d vXdXdXdXB.h.2.EXG.! pXdXdXdXdXdXd nXs.@.q.qX6XBXdXBXdXd.t @.N.N U.z.+.U [ [Xl",
+"XyXy.7 u 9XdXdXdXdXdXdXdXdXBX<XGXV.2.wX3 vXdXdXdXBXdXdXdXd b.3.'.3.3XC.3XC.3.3  XdXdXB ~ bXdXdXBXdXdX=X3.x ] : ].x.x.w pX9XdXdXdXd o p.2.2.E #.;XdXdXdXdXdXd nXU h.qX@.0XdXdXdXdXd 9 @.N.N.H.z., M [ [Xl",
+" Z 6XD.OXBXdXBXdXa.(XdXdXdXB pXV.2XV P ~XBXdXdXdXdXdXdXd v.u.3.'.3.3.3XCXC.3X X=XdXdXd.c.cXdXdXdXdXdXdX3 ].w P ].x ] ]XbX=XdXdXdXd.h.2.E.2.2.EXbXdXdXdXdXd o e hXU.q.q.0XdXdXdXdXdXd a W.N.H.zX5.+ [ [Xl",
+"XyXy.7.OXdXdXdXdX. BXBXdXdXBX<.2XV P.hXBXdXdXBXdXdXdXBXd bXC.3.3.3.3XCXCXC.u vXdXdXd b.'.u vXdXdXdXdXdX3 ] ] ].wXV : ] P vXdXdXdXd.hXV.2.2XG.;X=XdXdXdXBX9 V w.q.q.q h.fX=XdXdXdXBXdXdXi f.N.z.r.+ [ [Xl",
+".b.bXD.OXdXdXdXBX.XHXdXdXdXB EXVXV.pX=XdXdXdX9 vXdXdXdXdX=.3XC.3.3XC.3.3XC  XdXdXdXB ~.'.'X=XdXdXdXdXd._.x ].w.w.2.x.w PX=XdXdXdXd o pXVXV E.(XdXdXdXdXdX6 C w hXJ h.q.qXiXBXdXdXdXdXdXd jXeXZ.r.+ [ [Xl",
+".b.bXD.OXdXdXd.1.% BXdXdXdXB o pXVX9XBXdXdXBX  vXdXdXdXd bXC.3.3XCXCXCXC.u bXdXdXd b.u.3.' vXdXdXdXdXdX3.5.x.wXV.w.w.2 pX=XdXdXdXdX= oXpXp oXdXdXdXBXd b n w h h h hXJXJX..(XdXdXdXdXdXd.t 9XnXFX5 [ [Xl",
+"Xy.b.`.4XBXdXd s.AXHXdXdXdXdXBX<.wXdXdXdXd b.u vXdXdXdXdX=XC.3.3.3XCXCXC  XdXdXdXd.c.3.3XCX=XdXdXdXdXB.cXv ].x.x.2 #.! E vXdXdXdXdXdXBXdXdXdXdXdXd v o.;XU C w h h hXJX@XJ.v vXdXdXdXdXdXdXd r.KX5 [ [Xl",
+" Z Z.<XBXdXdXd s.AXHXdXdXdXd v.6X<XdXdXB vXC   vXdXdXdXB b ;XC ;.3XC.3XC.cXdXdXdXBX XC.3.3 vXdXdXdXdXdXB.6.2.2 w.@ t.qXBXdXdXdXdXdXdXdXdXdXdXdXdXBXt 8 w w w h h hXJXJXJ.qXJ 'XBXdXdXdXdXdXdXd.tX& [ [Xl",
+" Z Z.<XdXdXdXd.=X@XHXdXdXdXdXB.6 bXdXdXBX>XCXBXdXdXdXd b.uXC ;XC.3.3.3  XBXdXdXd.cXC.3.3.3 ~XBXdXdXdXdXB.dXG w w t =.nXdXdXdXdXdXdXdXdXdXdXdXdXd b 8 wXU w w w hXJXJXJXJXJ.AXJ ` vXdXdXBXdXdXdXd a !.UXl",
+"XyXyX4XdXdXdXd.=.qXHXdXdXdXd vXtXBXdXB bX>.pXdXdXdXdXd bXC.3XC.3.3.3XC ~XdXdXdXd.cX .uX .u  X=XdXdXdXdXB._ w t.kXzXz.VXdXdXdXdXBXB.( 9XdXdXdXdXd b 8 w w w w w h h hXJXJXJXJ.A.| '.(XBXdXdXdXdXdXBXAXLXl",
+".bXyX4XdXdXdXdX0.q.(XdXdXdXdXdX=XdXdXB.c.p.pXdXdXdXdXd bXC.3.3.3.3.3.u vXdXdXdXdXBX= vX= v bXBXdXdXdXdXB.6 CX%X:XqXq.kXdXdXdXdXd r.9Xu bXBXdXdXdXBXj w w C w h h h.- hXJXJX@.A.&.%X0 `XBXdXdXdXdXdXwXLXl",
+".b.}.4XdXBXdXB s.A.0XBXdXdXdXdXdXdXdX=._ ].pXdXdXdXdXd bXCXC.3.3XC.3.uXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXB.d hXzX:X: G.VXdXdXdXdXdXH.a.a EXdXdXdXdXdXt h w C h h h h hXJXJXJX@X@.&.:.& . 9XdXdXdXdXdXwXLXl",
+" Z.KXHXdXdXd ` /.A.8.(XdXBXdXdXdXdXBXtX<.5.5XdXdXdXdXd b ;.3.3.3XC.u bXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXH hX:Xq 2X: |XBXdXdXdXd B.a.V 8XdXdXdXdXd _ w C w w w.- h hXJXJXJX@X@.&.:.:Xo 9XdXdXBXdXdXwXLXl",
+"XyX4XdXdXdXd jXN /X@.0XdXdXdXdXdXdXBX<.w ] ~XdXdXdXd vX XCXC.3.3.3X XdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdX= >X:XN 2 AXBXdXdXdXd v qX%X%XsXdXdXdXdXdX=./ wXU h h h h h hXJXJX@X@.&.:.:Xo 9XdXdXdXdXdXwXLXl",
+"XyX4XdXdXdXd 5XN.V /XpXdXdXdXdXdXd.6XV.w ]XdXdXdXdXdX=.3.3.3.3XCX  bXdXdXdX=    X       .cX X X9XdXBXdXd.t.@XN 2 2.CXBXdXdXdXd 9 IXr GXsX8XdXdXdXdXd _ w C C h h h h h.qXJ.A.A.A.:.: l.(XdXdXdXdXdXwXLXl",
+".bX4XdXdXdXd 5 2Xz.k.0XdXdXdXdXdXB.2.2.w ]XdXdXdXdXd b.p.p.3.3.3.cXdXdXdX=.cXCXCXCXCXCXCXC.3XC.cXdXdXdXdX= >X: I y AXBXdXdXdXd 9 2 ) ).k.9XdXdXdXBXd o n w h h h h.v.L eXJXJ.A.&.: /.=.tXdXdXdXdXB.$.U 6",
+".bX4XdXdXdXBXn 2.V.k _XdXdXdXdXB.(XGXGXV ]XdXdXdXdXdX=.5.5.5.p ; ~XdXdXdX9XC.3XCXCXCXCXC.3.3.3 ~XdXdXdXd 9.lXN I y.CXBXdXdXdXd 9.T & & G.lXBXdXdXdXdXBXpXU.@ h h e.0XBX6X.X.X..8.=XuXiXBXdXdXdXB 9.I [Xl",
+".}.WXdXdXd a.C &X:Xz |XdXdXdXB.( nXGXG.w.xXdXBXdXdXd b.p ].5.p.cXBXdXd v  XC.3XCXCXC.3.3.3.3XC ~XdXdXdXdXBXj G GX7 sXBXdXdXdXd 9.] y &.].C BXdXdXdXdXdXH hXU h.q e.(XdXB.( 9.( 9 9 9XBXdXdXd vXA S [ [Xl",
+" QXBXdXdXdXk * DX:X%.WXBXBXB 9 nXU.EXG.w.5XdXdXdXdXd b ] ].pX>XBXdXdXdX9.pXC.3.3.3.3XC.3.3.3XC ~XdXdXdXdXdXBX%XrXxXiXdXdXdXdXd r.] y & 7X7 K vXdXdXdXd o hXUXJ.q.LXdXdXdXdXdXdXdXdXdXdXdXdXBXwXL.U [ [Xl",
+" kXdXdXdXd.< $.s I IX7 4 GXqXqX:Xq C C.w vXdXdXdXdXd ] ] ].xX3XdXdXdXd ~.3.3.5.3XCXC.3.3.3.p.p.cXBXdXdXdXdXdX: I IXwXdXdXdXdXd , 2 , 2 2.T.=XBXdXdXdXdXB _ hXU.q.LXdXdXdXdXdXdXdXdXdXd v 9.1.m [ [ [ [Xl",
+" Q B a a a.$.+XF ) ) &.sX- )X7X-.#Xf (X<.( vX= vX= v ] ] ] ]X= v v v bXC.3.p.3.3XC.3XC.3XC.3.3XvX9 vX=X=X=.( G I.j.1 B B B B B.T ,XN A GX%.8.( 9.(X= v 9Xj.q.q.q.vX= 9.( 9 r.( B r B r F.FX&., [ [ [ [Xl",
+".} Q Q.`.`XL M $X-X7 7X# LX7 &.#.#XO (.2X<.6._.d.6._ P ] ] ]._X3X X ._.5.5.5.5.p.p.p.p.p.5.5.5.pX<.6 p { K.9 IX7 & F F.K.C.C.CXr ,X%X%.V.kXs.8.8 KX../X..f.q.q.q.lXu.8.8X0 q q ^XmXm.C -XKXK.+ [ [ [ [Xl",
+"Xy 6XD.U [ [ [.P & & 7X#.#X-.#.# LXOXfXG.2XV.w ]XV P.w P.5 ] ].5 ].5.3.p.3.p.5.5.5.p.p.p.5.p ] ] ].2.*.!.@ =X-X- 7.sX# T.s D D & 2 2X:.A.nXs.n.n.n.qXUXs.q.q.A.n.A.A.A.V.VXN , D.F.F * XXK.r.+ [ [ [ [Xl",
+"XyXyXD [ [ [ [.,.# 7X7 &.#.#.#.#.#X: = CXGXGXG.2.2 ].w.w.w :.x.x ].5 ].5 ].5.5.5.5.5.5.5 ] ] ].wXV w.@.@ tX:X- 7 7X# d T TX;.F.# 7 ,XN.n.A.@.n mX@.q.q.q.A.n.kX%X%X%X%X%X% , 4.Q TXIXK.r.r 1 [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [XFX#X7 &.#.#.#.# LXOXO t C C CXU C.w.wXVXVXV.2 ] ] P ].x ].x :.w ].x.5.5 ].w.wXV C.A t.kXq GX- & 7X; T H d T T 7 D GX%.k t t /.A.n.q.A.V /.VXN , , y ,X%XN ,.].Q *.GXP 1 1.+ [ [ [ [ [Xl",
+".b.bXD [ [ [ [ [ $XFX$X7.#.#X-.#.#X-X$XqXU.* m ( <XV.2XV.w.2XV ].w ].w P ] ]XV.2 P.w.x ] ]XV.2.2 w.kXz.VXOX$ 2X- 7.s.Q.F T d H 7 yXN G.A.V.V.V.V.AX@.kXNXNXNX% 2.T.T 2XNXN 2 &.Z * *.r 1 M M [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [X5XD.#X$X-X-X-.# LX-X-X$XqXqXf =XfXU.q C.2XGXGXVXV.w P.w ]XVXV.2.w ] ] ].2XV.2XGXUXqX:XqX:X-X-X- 7.s 7 7X;X;X; D y 2X:X:XqX:X:X:X%X%X% G 2 I 2 y y.F y GXN 2 D TXI. .r 1.+ M [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ M.,X# &X7 IX7X7X-X-X-X-X7X7X$X$XO N NXq m C.E.2.2 ].w.w.w.2.2 :.2XV.2.2.2.2.2 C mX$XOXOXOX-.# LX;.#X7 &X# 7 7 7 7X-X$X$ 2X-X- 7 2 2 2 & & y &.F.F.s.F ) ) D.s TXKXK 1.+ M [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [XlX#X$ I N I IX$X$X$X$X$ IX$X7X7X7X-XO ( mXU C.E.2.2.2.2.E.E.Y.2.Y.Y.EXGXGXU mXqX$XOX$X$X- 7 L 7 7X- &X# 7 7.# 7X-X-.#X; 7 7 7 7 7 7 7 7.s TX;X#.s & & T T. XP.r M M [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [.PX&X- N N N NXOXOX$X$X$XO IX-X-X7X-X-XzXq ( m.!.! :.2.Y.E.E.E.E.YXGXG C C.q mXqXOXOXOX$ 2X- 7 7 7 7X- L.s 7 L 7 &X- LX; L 7 T.s L.s.sX# TX# d TX;.# 7 T d. .r 1 M M [ [ [ [.U [ [Xl",
+"XyXyXD [ [ [ [ [ [ [., $.}X$ IXSXzXq N N NXOXOXqX$X-X-X-X7X-X-XOXO ( ( #.EXG.E.E.EXG.E.Y # <XU t = IXOX$X$X$X-X7X- &X- 7 L L.s L.# 7 L L L.s 7.sX#X; dX# d d T d T dX#X#X# dXFXP 1X5 M [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [.U [ [ [ [ [ [.+ dX$X$XS = =Xf = = =XzXz NXO N NX$X-X-X-X$X$XOXqXq <.Y.EXG.EXG # C m tXqXOX-X-X-X$X$X$X$X7X- 7 L L LX;X#X# L.#X#X#X#X;X#X& d d d d d d d * TXI dXF. XK 1X5 M [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [.X.# &XOXOXz =Xf t t t t =XzXzXqXOXOXOXOX$XOX$XOX$ (XG # # # # C m.@ t ( tXqX$X$X$X-X7X-.# L.#.#.# LX#X#X# L LX; L LX#X# d.b d d d d xXFXF xXK. . XP 1 1 M M [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [.U.b.#XOXOXSXz =.n t t t = = =XzXq N N NXO N IX$X$XfXUXU # #.* # m m m.n tXq I IX7X$X7 &.# L.#.# L L LX#X# L L L 7.sX#X#X# dXF.o.o d.oXF x x. XKXKXP 1 1 M [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [XDXlX7X$ IXSXzXf t =XfXf t t = = = =XzXq N N NXOXz =Xf m mXUXU.@ m mXf =X$.# &X-X7 &X-.# LX-.#.#X#X# L.# 7 LX#X# LX#X# d.b dXF xXF x x x.D.D.DXP 1X5 M [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ M.7 LX7 N IXOXz =Xf t.n = = = = = = = =XzXzXz NX%X:X:XqXf t m m m tXqXOX-.s.#.#X7X7X7 & &X-X7.# L L 7.# 7.#X#X#.#X#.# d d d. . .  x xXPXK xXP.DX5 M M [ [ [ [ [.U [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [.+.}.#X$ IXO = = = =Xf = = = =Xf = = =XzXzXqX:XqX: NXz =.k t t t tXzXOX-.#.#X7X7X7X7X7X7 &.#.#X#.#.s.#.#X#X#X#.# L L d d d. XFXF x x.DXKXPXX.r.+ M [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy ZXD [ [ [ [ [ [ [ [ [ [ [ [XDXyX- & IXSXS NXz =XzXzXz = =XzXqXqXSXq NX: N N I NX: N NXz =Xz N I IX$ I I I I I IX7X-.#X-.#.#.#.#.s L.#.s.#X# LX& d d Z x $ xXPXP.DXXX5X5 M [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [.U Z.bX7 IX7XO NXSXzXSXSXzXSXSXO NXqX: N N I N N N I N I N NXS I N I NXO N I IX7.jX7X7X7X7X7 & &X7.#.#.#.s.#X#X#X& d d x x x xXX.DXX 1 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [.X ZX7X-X$ I I N NXqXSXzXq N N NX:Xz N N I N N I I N I I N N I N I N N N IX7X$ )X7X7X7X7X7X7X7X-.#X-.s.#.sX#.bX&.b d x $ $ xXXXXXXX5 M [ [ [ [ [ [ [.U [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.X.} &X- IX7 I N I IXS I N I IXS N I N IXO I IX7 I I I I I I I I.j I I I IX7 IX7X7 )X7X7X7X7X7 &.#.#.#.#.sX#X& d d $ x x.DXXXXX5.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" ZXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.7.bX#X-X- &X7X7 ) I I I I I I I I I IX7X7X-X-X- &X7 IX7 I.j I I ) I ) I I I I ) I ) & &X7X7 & &X-.#.#.s.sX& d *.o x.o.oX5.+.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.7.7.#.#.# & &X7 2 ) I G ) ) ) )X7X7X7X7X-.# &X-X7X$ I I I.j GXrXr G G G ) 2 ) 2.] y y D D D D &.#.#.F.F d d x x x $X5 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+".bXyXD [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [.+.X.}.#.# & yX7 2 ) ) G G ) ).]X7X7X7X7.#.#X7X7X7 I I I I G G G G GXN , 2 2 2 2 2.T y y 7 y.Q & 7.s.F.F T d x.o $XX.X [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.X L.#X- &X7 2 2 2 2 2 )XrX7X7X7X7Xr.j NXO IXOXOXNXN lXoXo 3 f.NXoXo.J.JXhXhXh.RX, y.Q yX;X;X; d dXIXF.D 1 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U Z.m.m LX7X7 2 2XNXN lXN 2 ,XNXNX%X%X:X% 3 lX+X+X+.^.^.B.^.{.{.{ f fXo.N.JXh.SXhX,X, - - H.GXIXP.r 1 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M.X d.#.#X-X-XNXNXN lXNXNX% 3 3 3 3.{ 0 0 % %Xc.^.^.^.&.:.&.{.{.{.{ f f.JX,Xh.R.R.R.R HXK x 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+XD L.b LX- 2 2 )XN 2 2.JX%.{XNXoX+ 0 %X1X1Xc.^.^.&.&.:.{.{.{ 3 3Xo.NXhXhXZ.S.S.R Y.G.r.r 1.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.+.P.o Z.b L L.#X- 7 7 2 2 y.TX+ % % %X1.^.&.&.& 3Xo 3XoXo.J.J.N U U.H...S.S.G.G.r.+ M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M.X 1.P.o.b dX#X#X; y 2Xh f f 0X+ f fX+ f.NXhXhXh.T.SXh.S.S.S Y YXI.o 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+".b.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [ M M.X 1.o.b d dX; 7 7 2XNXoXo f U.H.H.N U.R.R.R.R.R.R.S Y YXI.oX5 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.+.+.P 1.P.o d d LX;X; 7 y.R.R.R.RX; H HXI.GXIXIXI.o.rX5.+ M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M M M.+.+.+.X.P.P.P.P.P.P 1.P 1 1 1 1.+.+ M M M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M [ M M M M M M M M M [ M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXl.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U [Xl",
+" Z ZXy.b.bXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXy.bXy.bXy.bXy.bXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXy.b L"
+};
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseIncl.h	(revision 1638)
@@ -0,0 +1,12 @@
+#ifndef __CINT__
+
+/*
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+*/
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/BaseLinkDef.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ enum ParticleId_t;
+
+#pragma link C++ global kCONTINUE;
+#pragma link C++ global kRad2Deg;
+//#pragma link C++ global kPI;
+
+#pragma link C++ global gLog;
+
+#pragma link C++ class MLog+;
+
+#pragma link C++ class MIter+;
+
+#pragma link C++ class MTask+;
+#pragma link C++ class MTaskList+;
+
+#pragma link C++ class MParContainer+;
+#pragma link C++ class MParList+;
+
+#pragma link C++ class MFilter+;
+
+#pragma link C++ class MEvtLoop+;
+
+#pragma link C++ class MInputStreamID+;
+
+#pragma link C++ class MGTask+;
+#pragma link C++ class MGList+;
+#pragma link C++ class MGGroupFrame+;
+
+#pragma link C++ class MClone+;
+#pragma link C++ class MPrint+;
+#pragma link C++ class MContinue+;
+
+#pragma link C++ class MArray;
+#pragma link C++ class MArrayB;
+#pragma link C++ class MArrayS;
+
+#pragma link C++ class MTime+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MAGIC.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MAGIC.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MAGIC.h	(revision 1638)
@@ -0,0 +1,48 @@
+#ifndef MARS_MAGIC
+#define MARS_MAGIC
+///////////////////////////////////////////////////////////////////////////////
+//
+//     Magic.h
+//
+//     defines MAGIC base informations
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+
+//
+// Values for the eventloop control
+//
+const Int_t kCONTINUE = 2;
+const Int_t kSKIP     = 2;
+
+//
+//     ParticleId for Monte Carlo simulation
+//
+typedef enum
+{
+    kGAMMA  =    1,
+    kPROTON =   14,
+    kHELIUM =  402,
+    kOXYGEN = 1608,
+    kIRON   = 5626
+} ParticleId_t;
+
+const Double_t kRad2Deg = 180.0/3.1415926535897932384626433832795028841971693993751;
+
+//
+// This is the definition of a global output stream, which by
+// default pipes all output to the stdout
+//
+
+#ifdef __LINUX__
+class MLog;
+#else
+#include "MLog.h"
+#endif
+
+extern MLog gLog;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.cc	(revision 1638)
@@ -0,0 +1,41 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MArray                                                                   //
+//                                                                          //
+// This is an abstract base class for TObject derived Arrays. In principal  //
+// it is almost the same than TArray. The difference is that this array     //
+// base classed is derived from TObject which makes storage of variable     //
+// sized arrays possible with splitlevel=1.                                 //
+//                                                                          //
+// This should not be needed anymore for root >3.00                         //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MArray.h"
+
+ClassImp(MArray);
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArray.h	(revision 1638)
@@ -0,0 +1,35 @@
+#ifndef MARS_MArray
+#define MARS_MArray
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArray                                                                  //
+//                                                                         //
+// Abstract array base class for TObject derived Arrays                    //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+class MArray : public TObject
+{
+protected:
+    UInt_t fN; // Number of array elements
+
+public:
+   MArray()                              { fN = 0; }
+   MArray(UInt_t n)                      { fN = n; }
+   MArray(const MArray &a)               { fN = a.fN; }
+   virtual ~MArray()                     { fN = 0; }
+
+   MArray &operator=(const MArray &rhs)  { fN = rhs.fN; return *this; }
+
+   UInt_t       GetSize() const          { return fN; }
+   virtual void Set(UInt_t n) = 0;
+
+   ClassDef(MArray, 1)  //Abstract array base class for TObject derived Arrays
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.cc	(revision 1638)
@@ -0,0 +1,36 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MArrayB                                                                  //
+//                                                                          //
+// Array of Byte_t. It is almost the same than TArrayC, but it containes    //
+// Byte_t instead of Char_t and it can be stored with splitlevel=1 to a     //
+// a root-file because of it's derivement from MArray (TObject)             //                                                                       //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrayB.h"
+
+ClassImp(MArrayB);
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayB.h	(revision 1638)
@@ -0,0 +1,174 @@
+#ifndef MARS_MArrayB
+#define MARS_MArrayB
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArrayB                                                                 //
+//                                                                         //
+// Array of Byte_t                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MArray
+#include "MArray.h"
+#endif
+
+#include <string.h>
+
+class MArrayB : public MArray
+{
+private:
+    Byte_t *fArray; //[fN] Array of fN chars
+
+public:
+
+    MArrayB()
+    {
+        fN     = 0;
+        fArray = NULL;
+    }
+
+    MArrayB(UInt_t n)
+    {
+        fN     = 0;
+        fArray = NULL;
+
+        Set(n);
+    }
+
+    MArrayB(UInt_t n, Byte_t *array)
+    {
+        // Create TArrayC object and initialize it with values of array.
+        fN     = 0;
+        fArray = NULL;
+
+        Set(n, array);
+    }
+
+    MArrayB(const MArrayB &array)
+    {
+        // Copy constructor.
+        fArray = NULL;
+        Set(array.fN, array.fArray);
+    }
+
+    UInt_t GetSize() const
+    {
+        return fN;
+    }
+
+    MArrayB &operator=(const MArrayB &rhs)
+    {
+        // TArrayC assignment operator.
+        if (this != &rhs)
+            Set(rhs.fN, rhs.fArray);
+        return *this;
+    }
+
+    virtual ~MArrayB()
+    {
+        // Delete TArrayC object.
+        delete [] fArray;
+        fArray = NULL;
+    }
+
+    void Adopt(UInt_t n, Byte_t *array)
+    {
+        // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
+        // in TArrayC. User may not delete arr, TArrayC dtor will do it.
+        if (fArray)
+            delete [] fArray;
+
+        fN     = n;
+        fArray = array;
+    }
+
+    void AddAt(Byte_t c, UInt_t i)
+    {
+        // Add char c at position i. Check for out of bounds.
+        fArray[i] = c;
+    }
+
+    void AddAt(Byte_t *array, UInt_t i, UInt_t n)
+    {
+        // Add char c at position i. Check for out of bounds.
+        memcpy(fArray+i, array, n*sizeof(Byte_t));
+    }
+
+    Byte_t     At(UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    Byte_t    *GetArray() const
+    {
+        return fArray;
+    }
+
+    void Reset()
+    {
+        memset(fArray, 0, fN*sizeof(Byte_t));
+    }
+
+    void Set(UInt_t n)
+    {
+        // Set size of this array to n chars.
+        // A new array is created, the old contents copied to the new array,
+        // then the old array is deleted.
+
+        if (n==fN)
+            return;
+
+        Byte_t *temp = fArray;
+        if (n == 0)
+            fArray = 0;
+        else
+        {
+            fArray = new Byte_t[n];
+            if (n < fN)
+                memcpy(fArray,temp, n*sizeof(Byte_t));
+            else
+            {
+                memcpy(fArray,temp,fN*sizeof(Byte_t));
+                memset(&fArray[fN],0,(n-fN)*sizeof(Byte_t));
+            }
+        }
+
+        if (fN)
+            delete [] temp;
+
+        fN = n;
+    }
+
+    void Set(UInt_t n, Byte_t *array)
+    {
+        // Set size of this array to n chars and set the contents.
+        if (!array)
+            return;
+
+        if (fArray && fN != n)
+        {
+            delete [] fArray;
+            fArray = 0;
+        }
+
+        fN = n;
+
+        if (fN == 0)
+            return;
+
+        if (!fArray)
+            fArray = new Byte_t[fN];
+
+        memcpy(fArray,array, n*sizeof(Byte_t));
+    }
+
+    Byte_t &operator[](UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    ClassDef(MArrayB, 1)  //Array of Byte_t
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.cc	(revision 1638)
@@ -0,0 +1,38 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MArrayS                                                                  //
+//                                                                          //
+// Array of UShort_t. It is almost the same than TArrayS, but it containes  //
+// UShort_t instead of Short_t and it can be stored with splitlevel=1 to a  //
+// a root-file because of it's derivement from MArray (TObject)             //                                                                       //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrayS.h"
+
+ClassImp(MArrayS);
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MArrayS.h	(revision 1638)
@@ -0,0 +1,165 @@
+#ifndef MARS_MArrayS
+#define MARS_MArrayS
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArrayS                                                                 //
+//                                                                         //
+// Array of UShort_t                                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MArray
+#include "MArray.h"
+#endif
+
+#include <string.h>
+
+class MArrayS : public MArray
+{
+private:
+    UShort_t *fArray; //[fN] Array of fN chars
+
+public:
+
+    MArrayS()
+    {
+        fN     = 0;
+        fArray = NULL;
+    }
+
+    MArrayS(UInt_t n)
+    {
+        fN     = 0;
+        fArray = NULL;
+        Set(n);
+    }
+
+    MArrayS(UInt_t n, UShort_t *array)
+    {
+        // Create TArrayC object and initialize it with values of array.
+        fN     = 0;
+        fArray = NULL;
+        Set(n, array);
+    }
+
+    MArrayS(const MArrayS &array)
+    {
+        // Copy constructor.
+        fArray = NULL;
+        Set(array.fN, array.fArray);
+    }
+
+    UInt_t GetSize() const
+    {
+        return fN;
+    }
+
+    MArrayS &operator=(const MArrayS &rhs)
+    {
+        // TArrayC assignment operator.
+        if (this != &rhs)
+            Set(rhs.fN, rhs.fArray);
+        return *this;
+    }
+
+    virtual ~MArrayS()
+    {
+        // Delete TArrayC object.
+        delete [] fArray;
+        fArray = NULL;
+    }
+
+    void Adopt(UInt_t n, UShort_t *array)
+    {
+        // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
+        // in TArrayC. User may not delete arr, TArrayC dtor will do it.
+        if (fArray)
+            delete [] fArray;
+
+        fN     = n;
+        fArray = array;
+    }
+
+    void AddAt(UShort_t c, UInt_t i)
+    {
+        // Add char c at position i. Check for out of bounds.
+        fArray[i] = c;
+    }
+
+    UShort_t     At(UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    UShort_t    *GetArray() const
+    {
+        return fArray;
+    }
+
+    void Reset()
+    {
+        memset(fArray, 0, fN*sizeof(UShort_t));
+    }
+
+    void Set(UInt_t n)
+    {
+        // Set size of this array to n chars.
+        // A new array is created, the old contents copied to the new array,
+        // then the old array is deleted.
+
+        if (n==fN)
+            return;
+
+        UShort_t *temp = fArray;
+        if (n == 0)
+            fArray = NULL;
+        else
+        {
+            fArray = new UShort_t[n];
+            if (n < fN)
+                memcpy(fArray, temp, n*sizeof(UShort_t));
+            else
+            {
+                memcpy(fArray, temp, fN*sizeof(UShort_t));
+                memset(&fArray[fN], 0, (n-fN)*sizeof(UShort_t));
+            }
+        }
+
+        if (fN)
+            delete [] temp;
+
+        fN = n;
+    }
+
+    void Set(UInt_t n, UShort_t *array)
+    {
+        // Set size of this array to n chars and set the contents.
+        if (!array)
+            return;
+
+        if (fArray && fN != n)
+        {
+            delete [] fArray;
+            fArray = 0;
+        }
+        fN = n;
+
+        if (fN == 0)
+            return;
+
+        if (!fArray)
+            fArray = new UShort_t[fN];
+
+        memcpy(fArray, array, n*sizeof(UShort_t));
+    }
+
+    UShort_t &operator[](UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    ClassDef(MArrayS, 1)  //Array of UShort_t
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.cc	(revision 1638)
@@ -0,0 +1,172 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MClone                                                                  //
+//                                                                          //
+//  This task clones a given paramter container. You can either specify     //
+//  the name of the container which should be cloned or a pointer to the    //
+//  container. If you specify a name the preprocessing tries to find the    //
+//  corresponding container in the parameter list.                          //
+//  Cloning in this context means duplicating the object in memory. This    //
+//  may be used if you change an object in the eventloop (eg. the image     //
+//  cleaning is changing the image) and you want to compare both 'version'  //
+//  of this object afterwards.                                              //
+//  The cloned object can be accessed by using MClone::GetClone.            //
+//  To clone the container more than once use several instances of MClone.  //
+//  The object does only exist until a new object is cloned. It is deleted  //
+//  in the destructor.                                                      //
+//                                                                          //
+//  To use MClone you must make sure, that TObject::Clone is correctly      //
+//  working for this class (maybe you have to overload it)                  //
+//                                                                          //
+//  Input Containers:                                                       //
+//   MParContainer                                                          //
+//                                                                          //
+//  Output Containers:                                                      //
+//   -/-                                                                    //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MClone.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MClone);
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MClone::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MClone";
+    fTitle = title ? title : "Task to clone a parameter container for later usage";
+
+    fClone  = NULL;
+    fObject = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remembers the name to search for in the parameter list.
+//
+MClone::MClone(const char *obj, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fObjName = obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remember the pointer of the object which has to be cloned.
+//
+MClone::MClone(const TObject *obj, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fObject  = obj;
+    fObjName = obj->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. Deletes the cloned object.
+//
+MClone::~MClone()
+{
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks the parameter list for the existance of the parameter container. If
+//  the name of it was given in the constructor.
+//
+Bool_t MClone::PreProcess(MParList *pList)
+{
+    //
+    // The pointer is already given by the user.
+    //
+    if (fObject)
+        return kTRUE;
+
+    //
+    // Try to find the parameter container with the given name in the list
+    //
+    fObject = pList->FindObject(fObjName);
+    if (fObject)
+        return kTRUE;
+
+    //
+    // If it couldn't get found stop Eventloop
+    //
+    *fLog << err << dbginf << fObjName << " not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Delete the cloned object if one is existing
+//
+void MClone::Clear(Option_t *)
+{
+    //
+    // Check if an object has been initialized
+    //
+    if (!fClone)
+        return;
+
+    //
+    // Delete it and set the pointer to NULL for the sanity check (above)
+    //
+    delete fClone;
+    fClone = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes an existing clone and clones the object (parameter container)
+//  again.
+//
+Bool_t MClone::Process()
+{
+    //
+    // Delete an existing clone
+    //
+    Clear();
+
+    //
+    // Clone the given parameter container
+    //
+    fClone = fObject->Clone();
+
+    return kTRUE;
+} 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MClone.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MClone
+#define MARS_MClone
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MClone : public MTask
+{
+private:
+    const TObject *fObject; // pointer to container which has to be cloned
+    TString fObjName;       // given name to search for in the parameterlist
+
+    TObject* fClone;        // pointer to the cloned object. deletion is handled by MClone
+
+    void Init(const char *name, const char *title);
+
+public:
+    MClone(const char *obj,    const char *name=NULL, const char *title=NULL);
+    MClone(const TObject *obj, const char *name=NULL, const char *title=NULL);
+    ~MClone();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    TObject *GetClone() const  { return fClone; }
+    const TObject *GetObject() const { return fObject; }
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MClone, 0) // Task to clone (duplicate) an object in memory
+};
+    
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.cc	(revision 1638)
@@ -0,0 +1,49 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <mailto:tbretz@astro.uni-wuerzburg.de>, 10/2002
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MContinue                                                               //
+//                                                                         //
+// Does nothing than return kCONTINUE in the Process-function              //
+// (use with filters)                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MContinue.h"
+
+ClassImp(MContinue);
+
+MContinue::MContinue(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MContinue";
+    fTitle = title ? title : "Task returning kCONTINUE";
+}
+
+MContinue::MContinue(MFilter *f, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MContinue";
+    fTitle = title ? title : "Task returning kCONTINUE";
+
+    SetFilter(f);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MContinue.h	(revision 1638)
@@ -0,0 +1,31 @@
+#ifndef MARS_MContinue
+#define MARS_MContinue
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MContinue                                                               //
+//                                                                         //
+// Does nothing than return kCONTINUE in the Process-fucntion              //
+// (use with filters)                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MFilter;
+
+class MContinue : public MTask
+{
+private:
+    Bool_t Process() { return kCONTINUE; }
+
+public:
+    MContinue(const char *name=NULL, const char *title=NULL);
+    MContinue(MFilter *f, const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MContinue, 1) //Task returning kCONTINUE
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.cc	(revision 1638)
@@ -0,0 +1,654 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MEvtLoop                                                                 //
+//                                                                          //
+// This class is the core of each event processing.                         //
+// First you must set the parameter list to use. The parameter list         //
+// must contain the task list (MTaskList) to use. The name of the task      //
+// list can be specified if you call Eventloop. The standard name is        //
+// "MTaskList". The name you specify must match the name of the MTaskList   //
+// object.                                                                  //
+//                                                                          //
+// If you call Eventloop first all PreProcess functions - with the          //
+// parameter list as an argument - of the tasks in the task list are        //
+// executed. If one of them returns kFALSE then the execution is stopped.   //
+// If the preprocessing was ok. The Process funtion of the tasks are        //
+// as long as one function returns kSTOP. Only the tasks which are marked   //
+// marked as "All" or with a string which matches the MInputStreamID of     //
+// MTaskList are executed. If one tasks returns kCONTINUE the pending       //
+// tasks in the list are skipped and the execution in continued with        //
+// the first one in the list.                                               //
+// Afterwards the PostProcess functions are executed.                       //
+//                                                                          //
+//                                                                          //
+//  Maybe we can add a TProgressMeter sometimes later to be able to show    //
+//  the progress graphically...                                             //
+//                                                                          //
+//                                                                          //
+// You can create a macro from a completely setup eventloop by:             //
+//   evtloop.MakeMacro("mymacro.C");                                        //
+//                                                                          //
+// You will always need to check the macro, it will not run, but it         //
+// should have al important information.                                    //
+//                                                                          //
+//                                                                          //
+// You can also write all this information to a root file:                  //
+//   TFile file("myfile.root");                                             //
+//   evtloop.Write("MyEvtloopKey");                                         //
+//                                                                          //
+// You can afterwards read the information from an open file by:            //
+//   evtloop.Read("MyEvtloopKey");                                          //
+//                                                                          //
+// To lookup the information write it to a file using MakeMacro             //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MEvtLoop.h"
+
+#include <time.h>           // time_t
+#include <fstream.h>        // ofstream, SavePrimitive
+#include <iostream.h>
+
+#include <TFile.h>          // gFile
+#include <TSystem.h>        // gSystem
+#include <TStopwatch.h>
+#include <TGProgressBar.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#ifdef __MARS__
+#include "MRead.h"           // for setting progress bar
+#include "MProgressBar.h"    // MProgressBar::GetBar
+#endif
+
+ClassImp(MEvtLoop);
+
+
+//!
+//! Maybe we can add a static parameter list to MEvtLoop
+//! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too
+//!
+
+TList *gListOfPrimitives; // forard declaration in MParContainer.h
+
+// --------------------------------------------------------------------------
+//
+// default constructor - emty
+//
+MEvtLoop::MEvtLoop() : fParList(NULL), fProgress(NULL)
+{
+    fName = "Evtloop";
+}
+
+// --------------------------------------------------------------------------
+//
+// default destructor - emty
+//
+MEvtLoop::~MEvtLoop()
+{
+    if (TestBit(kIsOwner) && fParList)
+        delete fParList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  if you set the Eventloop as owner the destructor of the given parameter
+//  list is calles by the destructor of MEvtLoop, otherwise not.
+//
+void MEvtLoop::SetOwner(Bool_t enable)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+#ifdef __MARS__
+// --------------------------------------------------------------------------
+//
+//  Specify an existing MProgressBar object. It will display the progress
+//  graphically. This will make thing about 1-2% slower.
+//
+void MEvtLoop::SetProgressBar(MProgressBar *bar)
+{
+    fProgress = bar->GetBar();
+}
+#endif
+
+// --------------------------------------------------------------------------
+//
+// The proprocessing part of the eventloop. Be careful, this is
+// for developers or use in special jobs only!
+//
+Bool_t MEvtLoop::PreProcess(const char *tlist)
+{
+    //
+    // check if the needed parameter list is set.
+    //
+    if (!fParList)
+    {
+        *fLog << err << dbginf << "Parlist not initialized." << endl;
+        return kFALSE;
+    }
+
+    //
+    //  check for the existance of the specified task list
+    //  the default name is "MTaskList"
+    //
+    fTaskList = (MTaskList*)fParList->FindObject(tlist, "MTaskList");
+    if (!fTaskList)
+    {
+        *fLog << err << dbginf << "Cannot find tasklist '" << tlist << "' in parameter list." << endl;
+        return kFALSE;
+    }
+
+    if (fLog != &gLog)
+        fParList->SetLogStream(fLog);
+
+    //
+    //  execute the preprocess of all tasks
+    //  connect the different tasks with the right containers in
+    //  the parameter list
+    //
+    if (!fTaskList->PreProcess(fParList))
+    {
+        *fLog << err << "Error detected while PreProcessing" << endl;
+        return kFALSE;
+    }
+
+    *fLog << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The processing part of the eventloop. Be careful, this is
+// for developers or use in special jobs only!
+//
+void MEvtLoop::Process(Int_t maxcnt) const
+{
+    //
+    //   loop over all events and process all tasks for
+    //   each event
+    //
+    *fLog << all <<"Eventloop running (";
+
+    if (maxcnt<0)
+        *fLog << "all";
+    else
+        *fLog << dec << maxcnt;
+
+    *fLog << " events)..." << flush;
+
+    if (fProgress)
+    {
+        if (maxcnt>0)
+            fProgress->SetRange(0, maxcnt);
+#ifdef __MARS__
+        else
+        {
+            MRead *read = (MRead*)fTaskList->FindObject("MRead");
+            if (read && read->GetEntries()>0)
+                fProgress->SetRange(0, read->GetEntries());
+        }
+#endif
+    }
+
+    Int_t dummy = maxcnt<0 ? 0 : maxcnt;
+
+    //
+    // start a stopwatch
+    //
+    TStopwatch clock;
+    clock.Start();
+
+    //
+    // This is the MAIN EVENTLOOP which processes the data
+    // if maxcnt<0 the number of processed events is counted
+    // else only maxcnt events are processed
+    //
+    if (maxcnt<0)
+        // process first and increment if sucessfull
+        if (fProgress)
+            while (fTaskList->Process())
+            {
+                fProgress->SetPosition(++dummy);
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+                gSystem->ProcessEvents();
+#else
+                gClient->ProcessEventsFor(fProgress);
+#endif
+            }
+        else
+            while (fTaskList->Process()) dummy++;
+    else
+        // check for number and break if unsuccessfull
+        if (fProgress)
+            while (dummy-- && fTaskList->Process())
+            {
+                fProgress->SetPosition(maxcnt - dummy);
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+                gSystem->ProcessEvents();
+#else
+                gClient->ProcessEventsFor(fProgress);
+#endif
+            }
+        else
+            while (dummy-- && fTaskList->Process());
+
+    //
+    // stop stop-watch, print results
+    //
+    clock.Stop();
+
+    *fLog << all << "Ready!" << endl << endl;
+
+    *fLog << dec << endl << "CPU  - "
+        << "Time: " << clock.CpuTime() << "s"
+        << " for " << (maxcnt<0?dummy:maxcnt) << " Events"
+        << " --> " << (maxcnt<0?dummy:maxcnt)/clock.CpuTime() << " Events/s"
+        << endl;
+    *fLog << "Real - "
+        << "Time: " << clock.RealTime() << "s"
+        << " for " << (maxcnt<0?dummy:maxcnt) << " Events"
+        << " --> " << (maxcnt<0?dummy:maxcnt)/clock.RealTime() << " Events/s"
+        << endl << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The postprocessing part of the eventloop. Be careful, this is
+// for developers or use in special jobs only!
+//
+Bool_t MEvtLoop::PostProcess() const
+{
+    //
+    //  execute the post process of all tasks
+    //
+    return fTaskList->PostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+//  See class description above.
+//
+Bool_t MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist)
+{
+    Bool_t rc = PreProcess();
+
+    //
+    // If all Tasks were PreProcesses successfully start Processing.
+    //
+    if (rc)
+        Process(maxcnt);
+
+    //
+    // Now postprocess all tasks. Only successfully preprocessed tasks are
+    // postprocessed. If the Postprocessing of one task fail return an error.
+    //
+    if (!PostProcess())
+        return kFALSE;
+
+    //
+    // If postprocessing of all preprocessed tasks was sucefully return rc.
+    // This gives an error in case the preprocessing has failed already.
+    // Otherwise the eventloop is considered: successfully.
+    //
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  After you setup (or read) an Evtloop you can use this to write the
+//  eventloop setup as a macro. The default name is "evtloop.C". The default
+//  extension is .C If the extension is not given, .C is added.
+//  I the last character in the argument is a '+' the file is not closed.
+//  This is usefull if you have an eventloop which runs three times and
+//  you want to write one macro. If the first character is a '+' no
+//  opening is written, eg:
+//
+//     MEvtLoop evtloop;
+//     // some setup
+//     evtloop.MakeMacro("mymacro+");
+//     // replace the tasklist the first time
+//     evtloop.MakeMacro("+mymacro+");
+//     // replace the tasklist the second time
+//     evtloop.MakeMacro("+mymacro");
+//
+void MEvtLoop::MakeMacro(const char *filename)
+{
+    TString name(filename);
+
+    name = name.Strip(TString::kBoth);
+
+    Bool_t open  = kTRUE;
+    Bool_t close = kTRUE;
+    if (name[0]=='+')
+    {
+        open = kFALSE;
+        name.Remove(0, 1);
+        name = name.Strip(TString::kBoth);
+    }
+
+    if (name[name.Length()-1]=='+')
+    {
+        close = kFALSE;
+        name.Remove(name.Length()-1, 1);
+        name = name.Strip(TString::kBoth);
+    }
+
+    if (!name.EndsWith(".C"))
+        name += ".C";
+
+    ofstream fout;
+
+    if (!open)
+    {
+        fout.open(name, ios::app);
+        fout << endl;
+        fout << "   // ----------------------------------------------------------------------" << endl;
+        fout << endl;
+    }
+    else
+    {
+        fout.open(name);
+
+        time_t t = time(NULL);
+        fout <<
+            "/* ======================================================================== *\\" << endl <<
+            "!" << endl <<
+            "! *" << endl <<
+            "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl <<
+            "! * Software. It is distributed to you in the hope that it can be a useful" << endl <<
+            "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl <<
+            "! * It is distributed WITHOUT ANY WARRANTY." << endl <<
+            "! *" << endl <<
+            "! * Permission to use, copy, modify and distribute this software and its" << endl <<
+            "! * documentation for any purpose is hereby granted without fee," << endl <<
+            "! * provided that the above copyright notice appear in all copies and" << endl <<
+            "! * that both that copyright notice and this permission notice appear" << endl <<
+            "! * in supporting documentation. It is provided \"as is\" without express" << endl <<
+            "! * or implied warranty." << endl <<
+            "! *" << endl <<
+            "!" << endl <<
+            "!" << endl <<
+            "!   Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl <<
+            "!" << endl <<
+            "!   Copyright: MAGIC Software Development, 2000-2002" << endl <<
+            "!" << endl <<
+            "!" << endl <<
+            "\\* ======================================================================== */" << endl << endl <<
+            "// ------------------------------------------------------------------------" << endl <<
+            "//" << endl <<
+            "//     This macro was automatically created on" << endl<<
+            "//             " << ctime(&t) <<
+            "//        with the MEvtLoop::MakeMacro tool." << endl <<
+            "//" << endl <<
+            "// ------------------------------------------------------------------------" << endl << endl <<
+            "void " << name(0, name.Length()-2) << "()" << endl <<
+            "{" << endl;
+    }
+
+    SavePrimitive(fout, (TString)"" + (open?"open":"") + (close?"close":""));
+
+    if (!close)
+        return;
+
+    fout << "}" << endl;
+
+    *fLog << inf << "Macro '" << name << "' written." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+
+void MEvtLoop::StreamPrimitive(ofstream &out) const
+{
+    out << "   MEvtLoop " << GetUniqueName() << ";" << endl;
+}
+
+void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt)
+{
+    TString options = opt;
+    options.ToLower();
+
+    if (HasDuplicateNames("MEvtLoop::SavePrimitive"))
+    {
+        out << "   // !" << endl;
+        out << "   // ! WARNING - Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+        out << "   // ! one object (MParContainer, MTask, ...) with the same name. The created macro" << endl;
+        out << "   // ! may need manual intervention before it can be used." << endl;
+        out << "   // !" << endl;
+        out << endl;
+    }
+
+    if (!options.Contains("open"))
+    {
+        if (gListOfPrimitives)
+        {
+            *fLog << err << "MEvtLoop::SavePrimitive - Error: old file not closed." << endl;
+            gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
+            delete gListOfPrimitives;
+        }
+        gListOfPrimitives = new TList;
+    }
+
+    if (fParList)
+        fParList->SavePrimitive(out);
+
+    MParContainer::SavePrimitive(out);
+
+    if (fParList)
+        out << "   " << GetUniqueName() << ".SetParList(&" << fParList->GetUniqueName() << ");" << endl;
+    else
+        out << "   // fParList empty..." << endl;
+    out << "   if (!" << GetUniqueName() << ".Eventloop())" << endl;
+    out << "      return;" << endl;
+
+    if (!options.Contains("close"))
+        return;
+
+    gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
+    delete gListOfPrimitives;
+    gListOfPrimitives = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(TObjArray &arr, const TString txt) const
+{
+    arr.Sort();
+
+    TIter Next(&arr);
+    TObject *obj;
+    TString name;
+    Bool_t found = kFALSE;
+    while ((obj=Next()))
+    {
+        if (name==obj->GetName())
+        {
+            if (!found)
+            {
+                *fLog << warn << endl;
+                *fLog << " ! WARNING (" << txt << ")" << endl;
+                *fLog << " ! Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+                *fLog << " ! one object (MParContainer, MTask, ...) with the same name." << endl;
+                *fLog << " ! Creating a macro from it using MEvtLoop::MakeMacro may create" << endl;
+                *fLog << " ! a macro which needs manual intervention before it can be used." << endl;
+                found = kTRUE;
+            }
+            *fLog << " ! Please rename: " << obj->GetName() << endl;
+        }
+        name = obj->GetName();
+    }
+
+    return found;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(const TString txt) const
+{
+    if (!fParList)
+        return kFALSE;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    return HasDuplicateNames(list, txt);
+}
+
+// --------------------------------------------------------------------------
+//
+// Reads a saved eventloop from a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "READ");
+//        MEvtLoop evtloop;
+//        evtloop.Read();
+//        evtloop.MakeMacro("mymacro");
+//
+Int_t MEvtLoop::Read(const char *name)
+{
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Read: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Read: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    Int_t n = 0;
+    TObjArray list;
+
+    n += TObject::Read(name);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects read." << endl;
+        return 0;
+    }
+
+    n += list.Read((TString)name+"_names");
+
+    fParList->SetNames(list);
+
+    HasDuplicateNames(list, "MEvtLoop::Read");
+
+    *fLog << inf << "Eventloop '" << name << "' read from file." << endl;
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// If available print the contents of the parameter list.
+//
+void MEvtLoop::Print(Option_t *opt) const
+{
+    if (fParList)
+        fParList->Print();
+    else
+        *fLog << all << "MEvtloop: No Parameter List available." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Writes a eventloop to a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "RECREATE");
+//        MEvtLoop evtloop;
+//        evtloop.Write();
+//        file.Close();
+//
+Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
+{
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Write: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Write: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsWritable())
+    {
+        *fLog << err << "MEvtloop::Write: File not writable." << endl;
+        return 0;
+    }
+
+    Int_t n = 0;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    n += TObject::Write(name, option, bufsize);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects written." << endl;
+        return 0;
+    }
+
+    n += list.Write((TString)name+"_names", kSingleKey);
+
+    HasDuplicateNames(list, "MEvtLoop::Write");
+
+    *fLog << inf << "Eventloop written to file as " << name << "." << endl;
+
+    return n;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MEvtLoop.h	(revision 1638)
@@ -0,0 +1,73 @@
+#ifndef MARS_MEvtLoop
+#define MARS_MEvtLoop
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEvtLoop                                                                //
+//                                                                         //
+// Class to execute the tasks in a tasklist                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MParList;
+class MTaskList;
+class TGProgressBar;
+#ifdef __MARS__
+class MProgressBar;
+#endif
+
+class MEvtLoop : public MParContainer
+{
+private:
+    MParList  *fParList;
+    MTaskList *fTaskList;      //!
+
+    TGProgressBar *fProgress;  //!
+
+    enum { kIsOwner = BIT(14) };
+
+    Bool_t HasDuplicateNames(const TString txt) const;
+    Bool_t HasDuplicateNames(TObjArray &arr, const TString txt) const;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MEvtLoop();
+    virtual ~MEvtLoop();
+
+    void       SetParList(MParList *p)  { fParList = p; }
+    MParList  *GetParList() const       { return fParList; }
+    MTaskList *GetTaskList() const      { return fTaskList; }
+
+    void SetOwner(Bool_t enable=kTRUE);
+
+    void SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
+#ifdef __MARS__
+    void SetProgressBar(MProgressBar *bar);
+#endif
+
+    Bool_t PreProcess(const char *tlist="MTaskList");
+    void   Process(Int_t maxcnt) const;
+    Bool_t PostProcess() const;
+
+    Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList");
+
+    void MakeMacro(const char *filename="evtloop.C");
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    Int_t Read(const char *name="Evtloop");
+    Int_t Write(const char *name="Evtloop", Int_t option=0, Int_t bufsize=0);
+
+    void Print(Option_t *opt="") const;
+
+    ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
+};
+
+R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.cc	(revision 1638)
@@ -0,0 +1,104 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFilter                                                               //
+//                                                                         //
+//   This is a base class which defines an interface to create your own    //
+//   filters. To do it derive a class from MFilter.                        //
+//                                                                         //
+//   You can create two types of Filters:                                  //
+//    - static Filters and                                                 //
+//    - dynamic Filters                                                    //
+//                                                                         //
+//   Static Filters:                                                       //
+//    A static filter is a filter which value doesn't change dynamically,  //
+//    which mean only once while running through your tasklist. To create  //
+//    a static filter override the Process-function of MFilter (this is    //
+//    the function in which the filer-value should be updated). If         //
+//    necessary you can also overwrite Pre-/PostProcess. The process       //
+//    function should calculate the return value of IsExpressionTrue.      //
+//    IsExpressionTrue should simply return this value. This kind of       //
+//    filter must be added to the tasklist at a point which is forseen to  //
+//    update the value of the filter (eg. after the reading task).         //
+//                                                                         //
+//   Dynamic Filters:                                                      //
+//    A dynamic filter is a filter which returns a value which must be     //
+//    calculated at the time the filter is called. To create such a        //
+//    filter you have to overwrite IsExpressionTrue only. If there is      //
+//    no need for a 'one-point' update this filter must not be added to    //
+//    the tasklist.                                                        //
+//                                                                         //
+//   Usage:                                                                //
+//    A Filter is connected to a task by calling MTask::SetFilter. The     //
+//    task is now executed when IsExpressionTrue returns a value           //
+//    (different from kFALSE) only.                                        //
+//                                                                         //
+//   Remarks:                                                              //
+//    - Make sure, that all tasks which depends on this filter are either  //
+//      collected in a MTaskList-object or are conected to the same        //
+//      filter.                                                            //
+//    - If you want to use different filters (combined logically) for one  //
+//      task please look for the MFilterList class.                        //
+//    - Be careful, the return value of IsExpressionTrue is NOT a real     //
+//      boolean. You can return other values, too.                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MFilter.h"
+
+ClassImp(MFilter);
+
+MFilter::MFilter(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFilter";
+    fTitle = title ? title : "Base Class for a filter";
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFilter::PreProcess(MParList *pList)
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFilter::Process()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFilter::PostProcess()
+{
+    return kTRUE;
+}
+
+TString MFilter::GetRule() const
+{
+    return "<GetRule n/a for " + fName + ">";
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MFilter.h	(revision 1638)
@@ -0,0 +1,26 @@
+#ifndef MARS_MFilter
+#define MARS_MFilter
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MFilter : public MTask
+{
+public:
+    MFilter(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t IsExpressionTrue() const = 0;
+
+    virtual Bool_t PreProcess(MParList *pList);
+    virtual Bool_t Process();
+    virtual Bool_t PostProcess();
+
+    virtual TString GetRule() const;
+
+    ClassDef(MFilter, 0)		// Abstract base class for the filters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.cc	(revision 1638)
@@ -0,0 +1,139 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  11/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MGGroupFrame                                                            //
+//                                                                         //
+// This is a group frame derived from TGGroupFrame with some               //
+// enhancements:                                                           //
+//  - It holds a list which deletes all it's members in ~MGGroupFrame      //
+//    (use AddToList to add an object.                                     //
+//  - You can access the members of the list by their widget id (if they   //
+//    have one)                                                            //
+//  - All messages from associated GUI elemets are redirectd to a given    //
+//    task.                                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MGGroupFrame.h"
+
+#include "MGList.h"
+#include "MGTask.h"
+
+ClassImp(MGGroupFrame);
+
+// --------------------------------------------------------------------------
+//
+//  For a detailed description check TGGroupFrame::TGGroupFrame.
+//  All messages from associated GUI elements are redirected to the given
+//  task.
+//  Creates a MGList object to store Widgets. Use AddToList to Add
+//  objects.
+//
+MGGroupFrame::MGGroupFrame(MGTask *task,
+                           const TGWindow *p, TGString *title,
+                           UInt_t options, GContext_t norm,
+                           FontStruct_t font, ULong_t back)
+    : TGGroupFrame(p, title, options, norm, font, back), TGWidget(-1)
+{
+    fWidgetFlags = 0;
+    fMsgWindow   = p;
+    fTask        = task;
+
+    fList = new MGList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  For a detailed description check TGGroupFrame::TGGroupFrame.
+//  All messages from associated GUI elements are redirected to the given
+//  task.
+//  Creates a MGList object to store Widgets. Use AddToList to Add
+//  objects.
+//
+MGGroupFrame::MGGroupFrame(MGTask *task,
+                           const TGWindow *p, const char *title,
+                           UInt_t options, GContext_t norm,
+                           FontStruct_t font, ULong_t back)
+: TGGroupFrame(p, title, options, norm, font, back), TGWidget(-1)
+{
+    fWidgetFlags = 0;
+    fMsgWindow   = p;
+    fTask        = task;
+
+    fList = new MGList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deleted the MGList object and all its members.
+//
+MGGroupFrame::~MGGroupFrame()
+{
+    fList->SetOwner();
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add an object to the MGList. All the objects in MGList are deleted
+//  in the destructor MGGroupFrame automatically.
+//  You can add all object which have to exist until the Group Frame is
+//  destroyed (eg. TGLayoutElements)
+//  If an object is also derived from TGWidget you can get a pointer
+//  to it by its widget Id (use FindWidget)
+//
+void MGGroupFrame::AddToList(TObject *obj)
+{
+    fList->Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  To get an object which has a widget id (is derived from TGWidget) by
+//  its widget id use FindWidget with the widget id of the object you
+//  are searching for. If no object with this widget id exists NULL
+//  is returned. See also MGList::FindWidget(Int_t)
+//
+TObject *MGGroupFrame::FindWidget(Int_t id) const
+{
+    return fList->FindWidget(id);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you associate an object with this MGGroupFrame object, like in the
+//  following example:
+//
+//   MGGroupFrame *f = new MGGroupFrame(...);
+//   TGTextEntry *entry = new TGTextEntry(...);
+//   entry->Associate(f);
+//
+//  All messages send to the group frame by the GUI elent are redirected
+//  to the task corresponing to the MGGroupFrame.
+//
+Bool_t MGGroupFrame::ProcessMessage(Long_t msg, Long_t param1, Long_t param2)
+{
+    return fTask->ProcessMessage(GET_MSG(msg), GET_SUBMSG(msg), param1, param2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGGroupFrame.h	(revision 1638)
@@ -0,0 +1,42 @@
+#ifndef MARS_MGGroupFrame
+#define MARS_MGGroupFrame
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+#ifndef ROOT_TGWidget
+#include <TGWidget.h>
+#endif
+
+class MGTask;
+class MGList;
+
+class MGGroupFrame : public TGGroupFrame, public TGWidget
+{
+    MGTask  *fTask;
+    MGList *fList;
+
+public:
+    MGGroupFrame(MGTask *task,
+                 const TGWindow *p, TGString *title,
+                 UInt_t options = kVerticalFrame,
+                 GContext_t norm=GetDefaultGC()(),
+                 FontStruct_t font=GetDefaultFontStruct(),
+                 ULong_t back=GetDefaultFrameBackground());
+    MGGroupFrame(MGTask *task,
+                 const TGWindow *p, const char *title,
+                 UInt_t options = kVerticalFrame,
+                 GContext_t norm=GetDefaultGC()(),
+                 FontStruct_t font=GetDefaultFontStruct(),
+                 ULong_t back=GetDefaultFrameBackground());
+    virtual ~MGGroupFrame();
+
+    void     AddToList(TObject *obj);
+    TObject *FindWidget(Int_t id) const;
+
+    virtual Bool_t ProcessMessage(Long_t msg, Long_t param1, Long_t param2);
+
+    ClassDef(MGGroupFrame, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.cc	(revision 1638)
@@ -0,0 +1,268 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  11/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MGList                                                                 //
+//                                                                         //
+//  This is a TList object which has some enhancements for GUI elements.   //
+//  Use GetWidget to search for a GUI element with a given widget id.      //
+//  Add checkes for the existances of a GUI element with the same widget   //
+//  id (for IDs>=0).                                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MGList.h"
+
+#include <iostream.h>
+
+#include <TClass.h>
+#include <TGClient.h>
+#include <TGWidget.h>
+#include <TGPicture.h>
+
+
+ClassImp(MGList);
+
+// --------------------------------------------------------------------------
+//
+//  Before destroying the list with all its contents free all TGPicture
+//  objects in the list.
+//
+MGList::~MGList()
+{
+    TObject *obj;
+    TIter Next(this);
+    while ((obj=Next()))
+    {
+        if (!obj->InheritsFrom(TGPicture::Class()))
+            continue;
+
+        //
+        // Remove the object first. Otherwise we would remove
+        // a non existing object...
+        //
+        Remove(obj);
+        gClient->FreePicture((TGPicture*)obj);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Does a dynamic cast from a TObject to a TGWidget. This is necesary
+//  if a class derived from TObject inherits also from TGWidget and
+//  you have only a pointer to the TObject available.
+//
+TGWidget *MGList::GetWidget(TObject *obj) const
+{
+    //
+    // - IsA gives a pointer to the parent class entry in the dictionary
+    // - DynamicCast tries to cast obj of class type obj->IsA to one
+    //   of its base classes TGWidget
+    // - This method is ment for dynamic casts (multi inheritance)
+    //
+    //  If this functions makes trouble check for the correct inheritance
+    //  first via obj->InheritsFrom(TGWidget::Class())
+    //
+    //  The root implementation is used, because for space reasons
+    //  the C++ dynamic_cast<TGWidget*> is turned off by the option
+    //  -fno-rtti, which could be used in 'plain' C++
+    //
+
+    //
+    // FIXME: This should not be necessary but it is, why??
+    //
+    // TRY: TGPicture *pic = gClient->GetPicture("pic");
+    //      cout << pic->IsA()->DynamicCast(TGWidget::Class(), pic) << endl;
+    //
+    //      Is this another bug in root?
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
+    if (!obj->InheritsFrom(TGWidget::Class()))
+        return NULL;
+#endif
+
+    return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns kTRUE if the object is derived from TGWidget and a widget
+//  with the TGWidget id of this object is already in the list.
+//  If the object is not derived from TGWidget or no TGWidget object
+//  with the same widget id is existing in the list kFALSE is returned.
+//  If the TGWidget has an object id < 0 kFALSE is always retuned.
+//
+Bool_t MGList::IsExisting(TObject *obj) const
+{
+    const TGWidget *wid = GetWidget(obj);
+
+    //
+    // check whether it is a TGWidget
+    //
+    if (!wid)
+        return kFALSE;
+
+    const Int_t id = wid->WidgetId();
+
+    //
+    // check whether is has a valid id
+    // (not id=-1, which is the standard id)
+    //
+    if (id < 0)
+        return kFALSE;
+
+    //
+    // check whether Widget id is already existing in the list
+    //
+    return FindWidget(id) ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the given object obj is derived from TGWidget and a TGWidget with
+//  the same widget id is already existing in the list the object is
+//  ignored, otherwise it is added to the list via TList::Add(TObject *)
+//
+void MGList::Add(TObject *obj)
+{
+    if (IsExisting(obj))
+    {
+        const Int_t id = GetWidget(obj)->WidgetId();
+        cout << "Widget with id #" << id << " (";
+        cout << FindWidget(id)->ClassName() << ") already in list... ";
+        cout << obj->GetName() << " ignored." << endl;
+        return;
+    }
+
+    TList::Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the given object obj is derived from TGWidget and a TGWidget with
+//  the same widget id is already existing in the list the object is
+//  ignored, otherwise it is added to the list via
+//  TList::Add(TObject *, Option_t *)
+//
+void MGList::Add(TObject *obj, Option_t *opt)
+{
+    if (IsExisting(obj))
+    {
+        Int_t id = GetWidget(obj)->WidgetId();
+        cout << "Widget with id #" << id << " (";
+        cout << FindWidget(id)->ClassName() << ") already in list... ";
+        cout << obj->GetName() << " ignored." << endl;
+        return;
+    }
+
+    TList::Add(obj, opt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Adds the picture physically to the list. The list takes care of that
+//   - The picture is freed as often as it was retrieved from gClient
+//
+void MGList::AddPicture(const TGPicture *pic, const char *name)
+{
+    //
+    // Check whether the picture exists
+    //
+    if (!pic)
+    {
+        cout << "Warning: Requested picture '" << name << "' not found... ignored." << endl;
+        cout << "    Please copy " << name << " to $HOME or $HOME/icons or add" << endl;
+        cout << "      Unix.*.Gui.IconPath: ~/Path/To/The/Picture" << endl;
+        cout << "    to [$HOME/].rootrc."  << endl;
+        return;
+    }
+
+    //
+    // Add the picture to the list
+    //
+    TList::Add(const_cast<TGPicture*>(pic));
+}
+
+// --------------------------------------------------------------------------
+//
+//  This gets a picture from the picture pool of the TGClient-object.
+//  The pictures are freed automatically in the dstructor of the list.
+//  The picture counts itself how often it got used, so that only
+//  the first call to GetPicture will craete it and the last call to
+//  FreePicture will destroy it. If you access the picture only via
+//  MGList::GetPicture you don't have to care about.
+//
+//  Don't try to call FreePicture by yourself for a picture gotten by
+//  GetPicture. This is independant of the kIsOwner bit.
+//
+const TGPicture *MGList::GetPicture(const char *name)
+{
+    const TGPicture *pic = gClient->GetPicture(name);
+    AddPicture(pic, name);
+    return pic;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This gets a picture from the picture pool of the TGClient-object.
+//  The pictures are freed automatically in the dstructor of the list.
+//  The picture counts itself how often it got used, so that only
+//  the first call to GetPicture will craete it and the last call to
+//  FreePicture will destroy it. If you access the picture only via
+//  MGList::GetPicture you don't have to care about.
+//
+//  Don't try to call FreePicture by yourself for a picture gotten by
+//  GetPicture. This is independant of the kIsOwner bit.
+//
+const TGPicture *MGList::GetPicture(const char *name, Int_t width, Int_t height)
+{
+    const TGPicture *pic = gClient->GetPicture(name, width, height);
+    AddPicture(pic, name);
+    return pic;
+}
+// --------------------------------------------------------------------------
+//
+//  Search the list for a object derived from TGidget which has the given
+//  widget id. Returns a pointer to this object otherwise NULL.
+//  For IDs < 0 the function returns always NULL.
+//
+TObject *MGList::FindWidget(Int_t id) const
+{
+    if (id<0)
+        return NULL;
+
+    TObject *obj;
+    TIter Next(this);
+    while ((obj=Next()))
+    {
+        const TGWidget *wid = GetWidget(obj);
+
+        if (!wid)
+            continue;
+
+        if (id == wid->WidgetId())
+            return obj;
+    }
+    return NULL;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGList.h	(revision 1638)
@@ -0,0 +1,34 @@
+#ifndef MARS_MGList
+#define MARS_MGList
+
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+
+class TGWidget;
+class TGPicture;
+
+class MGList : public TList
+{
+private:
+    TGWidget *GetWidget(TObject *obj) const;
+    Bool_t    IsExisting(TObject *obj) const;
+
+    void      AddPicture(const TGPicture *pic, const char *name);
+
+public:
+    MGList() : TList() {}
+    virtual ~MGList();
+
+    void Add(TObject *obj);
+    void Add(TObject *obj, Option_t *opt);
+
+    const TGPicture *GetPicture(const char *name);
+    const TGPicture *GetPicture(const char *name, Int_t width, Int_t height);
+
+    TObject *FindWidget(Int_t id) const;
+
+    ClassDef(MGList, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.cc	(revision 1638)
@@ -0,0 +1,181 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  11/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MGTask                                                                //
+//                                                                         //
+//   A MTask with several enhancments for a graphical interface.           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MGTask.h"
+
+#include <TMethod.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGGroupFrame.h"
+
+ClassImp(MGTask);
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. Initialized fFrame with NULL.
+//
+MGTask::MGTask(const char *name, const char *title)
+    : fFrame(NULL)
+{
+    fName  = name  ? name  : "MGTask";
+    fTitle = title ? title : "Base class for all tasks with graphical I/O.";
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes the GUI if one was created.
+//
+MGTask::~MGTask()
+{
+    if (fFrame)
+        delete fFrame;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Hides the graphical interface if existing and calls
+//  MTask::CallPreProcess
+//
+Bool_t MGTask::CallPreProcess(MParList *plist)
+{
+    HideGui();
+
+    return MTask::CallPreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Shows the graphical interface if existing and calls
+//  MTask::CallPostProcess
+//
+Bool_t MGTask::CallPostProcess()
+{
+    ShowGui();
+
+    return MTask::CallPostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Widget from the MGGroupFrame (GUI) with the Id id.
+//
+TObject *MGTask::FindWidget(Int_t id) const
+{
+    return fFrame->FindWidget(id);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process a message. Redirect gui events (eg by calling
+//  TGButton->Associate()) to the MGGroupFrame when Creating the GUI in
+//  CreateGuiElements. And process the messages in the overwritten
+//  ProcessMessage function.
+//
+Bool_t MGTask::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
+{
+    fLog->setf(ios::showbase);
+    *fLog << all << "Task " << GetDescriptor() << " received gui msg " << hex;
+    *fLog << msg << " " << submsg << " " << param1 << " " << param2 << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Show the gui (and its gui elements) of the task if existing.
+//
+void MGTask::ShowGui()
+{
+    if (fFrame)
+        fFrame->MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Hide the gui (and its gui elements) of the task if existing.
+//
+void MGTask::HideGui()
+{
+    if (fFrame)
+        fFrame->UnmapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check whether a gui for this task was already created.
+//  If not create a MGGroupFrame to group the gui elements and add it
+//  to the given frame with the given layout hints.
+//  Now call the overwritten function CreateGuiElements to fill the group
+//  frame.
+//
+void MGTask::CreateGui(TGCompositeFrame *f, TGLayoutHints *layout)
+{
+    //
+    // Check whether frame already exists
+    //
+    if (fFrame)
+    {
+        *fLog << warn << GetDescriptor() << " Gui already created... skipped." << endl;
+        return;
+    }
+
+    //
+    // Check whether a gui is implemented for this class
+    //  - IsA gives a pointer to the dictionary entry of the mostly
+    //    inherited class of this Task
+    //  - GetMethodAllAny checks for the existance of CreateGuiElements
+    //    in the class and all its base classes
+    //  - now get the dictionary entry of the corresponding class
+    //    (in which the mathos was found)
+    //  - if method isn't overwritten the result is the dictionary
+    //    entry for MGTask.
+    //
+    TMethod *method = IsA()->GetMethodAllAny("CreateGuiElements");
+    if (method->GetClass() == MGTask::Class())
+    {
+        *fLog << warn << "Sorry, " << GetDescriptor();
+        *fLog << " doesn't override CreateGuiElements." << endl;
+        return;
+    }
+
+    //
+    //  create group frame
+    //
+    fFrame = new MGGroupFrame(this, f, ClassName());
+    f->AddFrame(fFrame, layout);
+
+    //
+    // add gui elements
+    //
+    CreateGuiElements(fFrame);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MGTask.h	(revision 1638)
@@ -0,0 +1,50 @@
+#ifndef MARS_MGTask
+#define MARS_MGTask
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTask                                                                   //
+//                                                                         //
+// Abstract base class for a task                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class TGLayoutHints;
+class TGCompositeFrame;
+
+class MGGroupFrame;
+
+class MGTask : public MTask
+{
+private:
+    MGGroupFrame *fFrame;     //!
+
+    virtual void CreateGuiElements(MGGroupFrame *f) {}
+
+    void ShowGui();
+    void HideGui();
+
+protected:
+    TObject *FindWidget(Int_t id) const;
+
+public:
+    MGTask(const char *name=NULL, const char *title=NULL);
+    virtual ~MGTask();
+
+    Bool_t CallPreProcess(MParList *plist);
+    Bool_t CallPostProcess();
+
+    virtual Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+
+    void CreateGui(TGCompositeFrame *f, TGLayoutHints *layout=NULL);
+
+    ClassDef(MGTask, 0)		//Abstract base class for a task
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.cc	(revision 1638)
@@ -0,0 +1,2902 @@
+// @(#)root/html:$Name: not supported by cvs2svn $:$Id: MHtml.cc,v 1.2 2001-04-18 15:26:04 tbretz Exp $
+// Author: Nenad Buncic   18/10/95
+
+/*************************************************************************
+ * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#include "TROOT.h"
+#include "TBaseClass.h"
+#include "TVirtualPad.h"
+#include "TClass.h"
+#include "TClassTable.h"
+#include "TDataMember.h"
+#include "TDataType.h"
+#include "TDatime.h"
+#include "TEnv.h"
+#include "TError.h"
+#include "MHtml.h"
+#include "TMethod.h"
+#include "TSystem.h"
+#include "TString.h"
+#include "TInterpreter.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <fstream.h>
+
+MHtml *gHtml = 0;
+
+const Int_t   kSpaceNum      = 1;
+const char   *formatStr      = "%12s %5s %s";
+
+enum ESortType {kCaseInsensitive, kCaseSensitive};
+enum EFileType {kSource, kInclude, kTree};
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// This is some kind of clone of the Root THtml class. I didn't change
+// anything, but enhanced the functionality a little bit.
+//
+//   The HyperText Markup Language (HTML) is a simple data format used to
+// create hypertext documents that are portable from one platform to another.
+// HTML documents are SGML documents with generic semantics that are
+// appropriate for representing information from a wide range of domains.
+//
+//   The MHtml class is designed to provide an easy way for converting ROOT
+// classes, and files as well, into HTML documents. Here is the few rules
+// and suggestions for a configuration, coding and usage.
+//
+//
+// Configuration:
+// -------------
+//
+//   The output directory could be specified using the Root.Html.OutputDir
+// environment variable ( default value: "html/" ). Also it is necessary to
+// define Root.Html.SourceDir to point to directories containing .cxx and .h
+// files ( see: TEnv ).
+//
+//       Examples:
+//                Root.Html.OutputDir: html
+//                Root.Html.SourceDir: src:include:.:/usr/user/source
+//                Root.Html.Root:      http://root.cern.ch/root/html
+//
+//
+//   During the conversion, MHtml will look for the certain number of
+// user defined strings, i.e. author's name, copyright note, etc.
+// This could be defined with following environment variables:
+//
+//       Root.Html.Author     ( default: // Author:)
+//       Root.Html.LastUpdate ( default: // @(#))
+//       Root.Html.Copyright  ( default:  * Copyright)
+//
+//
+//
+// Coding rules:
+// ------------
+//
+//   A class description block, which must be placed before the first
+// member function, has a following form:
+//
+//       ////////////////////////////////////////////////////////////////
+//       //                                                            //
+//       // TMyClass                                                   //
+//       //                                                            //
+//       // This is the description block.                             //
+//       //                                                            //
+//       ////////////////////////////////////////////////////////////////
+//
+//   The environment variable Root.Html.Description ( see: TEnv ) contents
+// the delimiter string ( default value: //_________________ ). It means
+// that you can also write your class description block like this:
+//
+//       //_____________________________________________________________
+//       // A description of the class starts with the line above, and
+//       // will take place here !
+//       //
+//
+//   Note that EVERYTHING until the first non-commented line is considered
+// as a valid class description block.
+//
+//   A member function description block starts immediately after '{'
+// and looks like this:
+//
+//       void TWorld::HelloWorldFunc( string *text )
+//       {
+//       // This is an example of description for the
+//       // TWorld member function
+//
+//          helloWorld.Print( text );
+//       }
+//
+//   Like in a class description block, EVERYTHING until the first
+// non-commented line is considered as a valid member function
+// description block.
+//
+//   ==> The "Begin_Html" and "End_Html" special keywords <=========
+//       --------------------------------------------
+// You can insert pure html code in your comment lines. During the
+// generation of the documentation, this code will be inserted as is
+// in the html file.
+// Pure html code must be inserted between the keywords "Begin_Html"
+// and "End_Html" starting/finishing anywhere in the comment lines.
+// Examples of pure html code are given in many Root classes.
+// See for example the classes TDataMember and TMinuit.
+//
+//   ==> The escape character
+//       --------------------
+// Outside blocks starting with "Begin_Html" and finishing with "End_Html"
+// one can prevent the automatic translation of symbols like "<" and ">"
+// to "&lt;" and "&gt;" by using the escape character in front.
+// The default escape character is backslash and can be changed
+// via the member function SetEscape.
+//
+// Usage:
+// -----
+//
+//     Root> gHtml.MakeAll               // invoke a make for all classes
+//     Root> gHtml.MakeClass( TMyClass ) // create a HTML files for that class only
+//     Root> gHtml.MakeIndex()           // creates an index files only
+//     Root> gHtml.MakeTree( TMyClass )  // creates an inheritance tree for a class
+//
+//     Root> gHtml.Convert( hist1.mac, "Histogram example" )
+//
+//
+// Environment variables:
+// ---------------------
+//
+//   Root.Html.OutputDir    ( default: htmldoc/)
+//   Root.Html.SourceDir    ( default: .:src/:include/)
+//   Root.Html.Author       ( default: // Author:)
+//   Root.Html.LastUpdate   ( default: // @(#))
+//   Root.Html.Copyright    ( default:  * Copyright)
+//   Root.Html.Description  ( default: //____________________ )
+//   Root.Html.HomePage     ( URL to the user defined home page )
+//   Root.Html.SearchEngine ( link to the search engine )
+//
+////////////////////////////////////////////////////////////////////////////////
+
+ClassImp( MHtml )
+
+//______________________________________________________________________________
+MHtml::MHtml()
+{
+   // Create a MHtml object. Use object directly or via the global
+   // pointer gHtml. In case output directory does not exist an error
+   // will be printed and gHtml stays 0 also zombie bit will be set.
+
+   fLen       = 1024;
+   fLine      = new char [fLen];
+   fCounter   = new char [6];
+   fEscFlag   = kFALSE;
+   SetEscape();
+
+   // get prefix for source directory
+   fSourcePrefix = gEnv->GetValue( "Root.Html.SourcePrefix", "");
+
+   // check for source directory
+   fSourceDir = gEnv->GetValue( "Root.Html.SourceDir", "./:src/:include/" );
+
+   // check for output directory
+   fOutputDir = gEnv->GetValue( "Root.Html.OutputDir", "htmldoc/" );
+
+   fXwho      = "http://consult.cern.ch/xwho/people?";
+
+   Int_t  st;
+   Long_t sId, sSize, sFlags, sModtime;
+   if ((st = gSystem->GetPathInfo(fOutputDir, &sId, &sSize, &sFlags, &sModtime)) ||
+       !(sFlags & 2)) {
+      if (st == 0) {
+         Error("MHtml", "output directory %s is an existing file", fOutputDir);
+         MakeZombie();
+         return;
+      }
+      // Try creating directory
+      if (gSystem->MakeDirectory(fOutputDir) == -1) {
+         Error("MHtml", "output directory %s does not exist", fOutputDir);
+         MakeZombie();
+         return;
+      }
+   }
+
+   // insert html object in the list of special ROOT objects
+   gHtml = this;
+   gROOT->GetListOfSpecials()->Add(gHtml);
+}
+
+
+//______________________________________________________________________________
+MHtml::~MHtml()
+{
+// Default destructor
+
+    if( fLine    ) delete [] fLine;
+    if( fCounter ) delete [] fCounter;
+
+    fSourceDir = 0;
+    fLen       = 0;
+}
+
+
+//______________________________________________________________________________
+int CaseSensitiveSort( const void *name1, const void *name2 )
+{
+// Friend function for sorting strings, case sensitive
+//
+//
+// Input: name1 - pointer to the first string
+//        name2 - pointer to the second string
+//
+//  NOTE: This function compares its arguments and returns an integer less
+//        than, equal to, or greater than zero, depending on whether name1
+//        is lexicographically less than, equal to, or greater than name2.
+//
+//
+
+    return( strcmp( *( (char **) name1 ), *( (char **) name2 )) );
+}
+
+
+//______________________________________________________________________________
+int CaseInsensitiveSort( const void *name1, const void *name2 )
+{
+// Friend function for sorting strings, case insensitive
+//
+//
+// Input: name1 - pointer to the first string
+//        name2 - pointer to the second string
+//
+//  NOTE: This function compares its arguments and returns an integer less
+//        than, equal to, or greater than zero, depending on whether name1
+//        is lexicographically less than, equal to, or greater than name2,
+//        but characters are forced to lower-case prior to comparison.
+//
+//
+
+    return( strcasecmp( *( (char **) name1 ), *( (char **) name2 )) );
+}
+
+
+//______________________________________________________________________________
+void MHtml::Class2Html( TClass *classPtr, Bool_t force )
+{
+// It creates HTML file for a single class
+//
+//
+// Input: classPtr - pointer to the class
+
+
+    const char *tab = "<!--TAB-->";
+    const char *tab2 = "<!--TAB2-->  ";
+    const char *tab4 = "<!--TAB4-->    ";
+    const char *tab6 = "<!--TAB6-->      ";
+
+    gROOT->GetListOfGlobals( kTRUE );
+
+    // create a filename
+    char *tmp1 = gSystem->ExpandPathName( fOutputDir );
+    char *tmp2 = gSystem->ConcatFileName( tmp1, classPtr->GetName() );
+
+    char *filename = StrDup( tmp2, 6 );
+    strcat( filename, ".html" );
+
+    if( tmp1 ) delete [] tmp1;
+    if( tmp2 ) delete [] tmp2;
+    tmp1 = tmp2 = 0;
+
+    if( IsModified( classPtr, kSource ) || force ) {
+
+        // open class file
+        ofstream classFile;
+        classFile.open( filename, ios::out );
+
+        Bool_t classFlag = kFALSE;
+
+
+        if( classFile.good() ) {
+
+            Printf( formatStr, "", fCounter, filename );
+
+            // write a HTML header for the classFile file
+            WriteHtmlHeader( classFile, classPtr->GetName() );
+
+            // make a link to the description
+            classFile << "<!--BEGIN-->" << endl;
+            classFile << "<center>" << endl;
+            classFile << "<h1>" << classPtr->GetName() << "</h1>" << endl;
+            classFile << "<hr width=300>" << endl;
+            classFile << "<!--SDL--><em><a href=#" << classPtr->GetName()
+                      << ":description>class description</a>";
+
+            // make a link to the '.cxx' file
+            classFile << " - <a href=\"src/" << classPtr->GetName() << ".cxx.html\"";
+            classFile << ">source file</a>";
+
+            // make a link to the inheritance tree
+            classFile << " - <a href=\"" << classPtr->GetName() << "_Tree.ps\"";
+            classFile << ">inheritance tree</a>";
+
+
+            classFile << "</em>" << endl;
+            classFile << "<hr width=300>" << endl;
+            classFile << "</center>" << endl;
+
+
+            // make a link to the '.h' file
+            classFile << "<h2>" << "class <a name=\"" << classPtr->GetName() << "\" href=\"";
+            classFile << GetFileName( (const char * ) classPtr->GetDeclFileName() ) << "\"";
+            classFile << ">" << classPtr->GetName() << "</a> ";
+
+            // copy .h file to the Html output directory
+            char *declf = GetSourceFileName(classPtr->GetDeclFileName());
+            CopyHtmlFile(declf);
+            delete [] declf;
+
+            // make a loop on base classes
+            Bool_t first = kTRUE;
+            TBaseClass *inheritFrom;
+            TIter nextBase( classPtr->GetListOfBases() );
+
+            while (( inheritFrom = ( TBaseClass * ) nextBase() )) {
+                if( first ) {
+                    classFile << ": ";
+                    first = kFALSE;
+                }
+                else classFile << ", ";
+                classFile << "public ";
+
+                // get a class
+                TClass *classInh = GetClass( (const char * ) inheritFrom->GetName() );
+
+                char *htmlFile = GetHtmlFileName( classInh );
+
+                if( htmlFile ) {
+                    classFile << "<a href=\"";
+
+                    // make a link to the base class
+                    classFile << htmlFile;
+                    classFile << "\">" << inheritFrom->GetName() << "</a>";
+                    delete [] htmlFile;
+                    htmlFile = 0;
+                }
+                else classFile << inheritFrom->GetName();
+            }
+
+            classFile << "</h2>" << endl;
+            classFile << "<pre>" << endl;
+
+
+            // make a loop on member functions
+            TMethod *method;
+            TIter nextMethod( classPtr->GetListOfMethods() );
+
+            Int_t len, maxLen[3];
+            len = maxLen[0] = maxLen[1] = maxLen[2] = 0;
+
+            // loop to get a pointers to a method names
+            const Int_t nMethods = classPtr->GetNmethods();
+            const char **methodNames = new const char*[3*2*nMethods];
+
+            Int_t mtype, num[3];
+            mtype = num[0] = num[1] = num[2] = 0;
+
+            while (( method = ( TMethod * ) nextMethod() )) {
+
+                if(
+                    !strcmp( method->GetName(), "Dictionary"    ) ||
+                    !strcmp( method->GetName(), "Class_Version" ) ||
+                    !strcmp( method->GetName(), "Class_Name"    ) ||
+                    !strcmp( method->GetName(), "DeclFileName"  ) ||
+                    !strcmp( method->GetName(), "DeclFileLine"  ) ||
+                    !strcmp( method->GetName(), "ImplFileName"  ) ||
+                    !strcmp( method->GetName(), "ImplFileLine"  )
+                ) continue;
+
+
+                if( kIsPrivate & method->Property() )
+                    mtype = 0;
+                else if( kIsProtected & method->Property() )
+                    mtype = 1;
+                else if( kIsPublic & method->Property() )
+                    mtype = 2;
+
+                methodNames[mtype*2*nMethods+2*num[mtype]] = method->GetName();
+
+                if (method->GetReturnTypeName() ) len = strlen( method->GetReturnTypeName() );
+                else len = 0;
+
+                if( kIsVirtual & method->Property() ) len += 8;
+                if( kIsStatic & method->Property() ) len += 7;
+
+                maxLen[mtype] = maxLen[mtype] > len ? maxLen[mtype] : len;
+
+                const char* type = strrchr( method->GetReturnTypeName(), ' ' );
+                if( ! type ) type = method->GetReturnTypeName();
+                else type++;
+
+                if( classPtr && !strcmp( type, classPtr->GetName() ))
+                    methodNames[mtype*2*nMethods+2*num[mtype]] = "A00000000";
+
+                // if this is the destructor
+                while( '~' == *methodNames[mtype*2*nMethods+2*num[mtype]] )
+                    methodNames[mtype*2*nMethods+2*num[mtype]] = "A00000001";
+
+                methodNames[mtype*2*nMethods+2*num[mtype]+1] = (char *) method;
+
+                num[mtype]++;
+            }
+
+            Int_t i, j;
+
+            for( j = 0; j < 3; j ++ ) {
+                if( *( methodNames+j*2*nMethods ) ) {
+                    qsort( methodNames+j*2*nMethods, num[j], 2*sizeof( methodNames ), CaseInsensitiveSort );
+
+                    const char *ftitle = 0;
+                    switch( j ) {
+                        case 0: ftitle = "private:";
+                                break;
+                        case 1: ftitle = "protected:";
+                                break;
+                        case 2: ftitle = "public:";
+                                break;
+                    }
+                    if( j ) classFile << endl;
+                    classFile << tab4 << "<b>" << ftitle << "</b><br>" << endl;
+
+                    for( i = 0; i < num[j]; i++ ) {
+                        method = (TMethod *) methodNames[j*2*nMethods+2*i+1];
+
+                        if( method ) {
+                            Int_t w = 0;
+                            if( method->GetReturnTypeName() ) len = strlen( method->GetReturnTypeName() );
+                            else len = 0;
+
+                            if( kIsVirtual & method->Property() ) len += 8;
+                            if( kIsStatic & method->Property() ) len += 7;
+
+                            classFile << tab6;
+                            for( w = 0; w < ( maxLen[j]-len ); w++ )
+                                classFile << " ";
+
+                            if( kIsVirtual & method->Property() )
+                                classFile << "virtual ";
+
+                            if( kIsStatic & method->Property() )
+                                classFile << "static ";
+
+                            strcpy( fLine, method->GetReturnTypeName() );
+                            ExpandKeywords( classFile, fLine, classPtr, classFlag );
+
+                            classFile << " " << tab << "<!--BOLD-->";
+                            classFile << "<a href=\"#" << classPtr->GetName();
+                            classFile << ":";
+                            ReplaceSpecialChars( classFile, method->GetName() );
+                            classFile << "\">";
+                            ReplaceSpecialChars( classFile, method->GetName() );
+                            classFile << "</a><!--PLAIN-->";
+
+                            strcpy( fLine, method->GetSignature() );
+                            ExpandKeywords( classFile, fLine, classPtr, classFlag );
+                            classFile << endl;
+                        }
+                    }
+                }
+            }
+
+            delete [] methodNames;
+
+            // make a loop on data members
+            first = kFALSE;
+            TDataMember *member;
+            TIter nextMember( classPtr->GetListOfDataMembers() );
+
+
+            Int_t len1, len2, maxLen1[3], maxLen2[3];
+            len1 = len2 = maxLen1[0] = maxLen1[1] = maxLen1[2] = 0;
+            maxLen2[0] = maxLen2[1] = maxLen2[2] = 0;
+            mtype = num[0] = num[1] = num[2] = 0;
+
+            Int_t ndata = classPtr->GetNdata();
+
+            // if data member exist
+            if( ndata ) {
+                TDataMember **memberArray = new TDataMember*[3*ndata];
+
+                if( memberArray ) {
+                    while (( member = ( TDataMember * ) nextMember() )) {
+
+                        if(
+                            !strcmp( member->GetName(), "fgIsA" )
+                        ) continue;
+
+                        if( kIsPrivate & member->Property() )
+                            mtype = 0;
+                        else if( kIsProtected & member->Property() )
+                            mtype = 1;
+                        else if( kIsPublic & member->Property() )
+                            mtype = 2;
+
+                        memberArray[mtype*ndata+num[mtype]] = member;
+                        num[mtype]++;
+
+                        if( member->GetFullTypeName() )
+                             len1 = strlen( (char * ) member->GetFullTypeName() );
+                        else len1 = 0;
+                        if( member->GetName() )
+                             len2 = strlen( member->GetName() );
+                        else len2 = 0;
+
+                        if( kIsStatic & member->Property() ) len1 += 7;
+
+                       // Take in account the room the array index will occupy
+
+                        Int_t dim = member->GetArrayDim();
+                        Int_t indx = 0;
+                        while (indx < dim ){
+                              indx++;
+                              len2 += Int_t(TMath::Log10(member->GetMaxIndex(indx))) + 3;
+                         }
+
+                        maxLen1[mtype] = maxLen1[mtype] > len1 ? maxLen1[mtype] : len1;
+                        maxLen2[mtype] = maxLen2[mtype] > len2 ? maxLen2[mtype] : len2;
+                    }
+
+                    classFile << endl;
+                    classFile << "<h3>" << tab2 << "<a name=\"";
+                    classFile << classPtr->GetName();
+                    classFile << ":Data Members\">Data Members</a></h3>" << endl;
+
+                    for( j = 0; j < 3; j++ ) {
+                        if( memberArray[j*ndata] ) {
+                            const char *ftitle = 0;
+                            switch( j ) {
+                                case 0: ftitle = "private:";
+                                        break;
+                                case 1: ftitle = "protected:";
+                                        break;
+                                case 2: ftitle = "public:";
+                                        break;
+                            }
+                            if( j ) classFile << endl;
+                            classFile << tab4 << "<b>" << ftitle << "</b><br>" << endl;
+
+                            for( i = 0; i < num[j]; i++ ) {
+                                Int_t w = 0;
+                                member = memberArray[j*ndata+i];
+
+                                classFile << tab6;
+                                if ( member->GetFullTypeName() ) len1 = strlen( member->GetFullTypeName() );
+                                else len1 = 0;
+
+                                if( kIsStatic & member->Property() ) len1 += 7;
+
+                                for( w = 0; w < ( maxLen1[j]-len1 ); w++ )
+                                    classFile << " ";
+
+                                if( kIsStatic & member->Property() )
+                                    classFile << "static ";
+
+                                strcpy( fLine, member->GetFullTypeName() );
+                                ExpandKeywords( classFile, fLine, classPtr, classFlag );
+
+                                classFile << " " << tab << "<!--BOLD-->";
+                                classFile << "<a name=\"" << classPtr->GetName() << ":";
+                                classFile << member->GetName();
+                                classFile << "\">" << member->GetName();
+
+                                // Add the dimensions to "array" members
+
+                                Int_t dim = member->GetArrayDim();
+                                Int_t indx = 0;
+                                Int_t indxlen = 0;
+                                while (indx < dim ){
+                                     classFile <<  "[" << member->GetMaxIndex(indx)<<"]";
+                                     // Take in account the room this index will occupy
+                                     indxlen += Int_t(TMath::Log10(member->GetMaxIndex(indx))) + 3;
+                                     indx++;
+                                }
+
+                                classFile << "</a><!--PLAIN--> ";
+
+                                len2 = 0;
+                                if( member->GetName() )
+                                      len2 = strlen( member->GetName() ) + indxlen;
+
+                                for( w = 0; w < ( maxLen2[j]-len2 ); w++ )
+                                    classFile << " ";
+                                classFile << " " << tab;
+
+                                classFile << "<i><a name=\"Title:";
+                                classFile << member->GetName();
+
+                                classFile << "\">";
+
+                                strcpy( fLine, member->GetTitle() );
+                                ReplaceSpecialChars( classFile, fLine );
+                                classFile << "</a></i>" << endl;
+                            }
+                        }
+                    }
+                    classFile << "</pre>" << endl;
+                    delete [] memberArray;
+                }
+            }
+
+            classFile << "<!--END-->" << endl;
+
+            // create a 'See also' part
+            DerivedClasses( classFile, classPtr );
+
+            // process a '.cxx' file
+            ClassDescription( classFile, classPtr, classFlag );
+
+
+            // close a file
+            classFile.close();
+
+        }
+        else Error( "Make", "Can't open file '%s' !", filename );
+    }
+    else Printf( formatStr, "-no change-", fCounter, filename );
+
+    if( filename ) delete [] filename;
+    filename = 0;
+}
+
+
+//______________________________________________________________________________
+void MHtml::ClassDescription( ofstream &out, TClass *classPtr, Bool_t &flag )
+{
+// This function builds the description of the class
+//
+//
+// Input: out      - output file stream
+//        classPtr - pointer to the class
+//        flag     - this is a 'begin_html/end_html' flag
+//
+
+    char  *ptr, *key;
+    Bool_t tempFlag = kFALSE;
+    char  *filename = 0;
+
+
+    // allocate memory
+    char *nextLine    = new char [256];
+    char *pattern     = new char [80];
+
+    char *lastUpdate  = new char [256];
+    char *author      = new char [80];
+    char *copyright   = new char [80];
+
+
+    char *funcName   = new char [64];
+
+    const char *lastUpdateStr;
+    const char *authorStr;
+    const char *copyrightStr;
+    const char *descriptionStr;
+
+
+    // just in case
+    *lastUpdate = *author = *copyright = 0;
+
+
+    // define pattern
+    strcpy( pattern, classPtr->GetName() );
+    strcat( pattern, "::" );
+    Int_t len = strlen( pattern );
+
+
+    // get environment variables
+    lastUpdateStr  = gEnv->GetValue( "Root.Html.LastUpdate", "// @(#)" );
+    authorStr      = gEnv->GetValue( "Root.Html.Author", "// Author:" );
+    copyrightStr   = gEnv->GetValue( "Root.Html.Copyright", " * Copyright" );
+    descriptionStr = gEnv->GetValue( "Root.Html.Description", "//____________________" );
+
+
+    // find a .cxx file
+    char *tmp1 = GetSourceFileName(classPtr->GetImplFileName());
+    char *realFilename = StrDup( tmp1, 16 );
+    if( !realFilename ) Error( "Make", "Can't find file '%s' !", tmp1 );
+
+    if( tmp1 ) delete [] tmp1;
+    tmp1 = 0;
+
+    Bool_t classDescription    = kTRUE;
+
+    Bool_t foundLastUpdate     = kFALSE;
+    Bool_t foundAuthor         = kFALSE;
+    Bool_t foundCopyright      = kFALSE;
+
+    Bool_t firstCommentLine    = kTRUE;
+    Bool_t extractComments     = kFALSE;
+    Bool_t thisLineIsCommented = kFALSE;
+    Bool_t thisLineIsPpLine    = kFALSE;
+    Bool_t postponeMemberDescr = kFALSE;
+    Bool_t skipMemberName      = kFALSE;
+    Bool_t writeBracket        = kFALSE;
+    streampos postponedpos = 0;
+
+    // Class Description Title
+    out << "<hr>" << endl;
+    out << "<!--DESCRIPTION-->";
+    out << "<h2><a name=\"" << classPtr->GetName();
+    out << ":description\">Class Description</a></h2>" << endl;
+
+
+    // open source file
+    ifstream sourceFile;
+    sourceFile.open( realFilename, ios::in );
+
+
+    if( sourceFile.good() ) {
+        // open a .cxx.html file
+        tmp1 = gSystem->ExpandPathName( fOutputDir );
+        char *tmp2 = gSystem->ConcatFileName( tmp1, "src" );
+        char *dirname = StrDup( tmp2 );
+
+        if( tmp1 ) delete [] tmp1;
+        if( tmp2 ) delete [] tmp2;
+        tmp1 = tmp2 = 0;
+
+        // create directory if necessary
+        if( gSystem->AccessPathName( dirname ))
+            gSystem->MakeDirectory( dirname );
+
+        tmp1 = gSystem->ConcatFileName( dirname, classPtr->GetName() );
+        filename = StrDup( tmp1, 16 );
+        strcat( filename, ".cxx.html" );
+
+        ofstream tempFile;
+        tempFile.open( filename, ios::out );
+
+        if( dirname ) delete [] dirname;
+
+        if( tmp1 ) delete [] tmp1;
+        tmp1 = 0;
+
+        if( tempFile.good() ) {
+
+
+            // create an array of method names
+            Int_t i = 0;
+            TMethod *method;
+            TIter nextMethod( classPtr->GetListOfMethods() );
+            Int_t numberOfMethods = classPtr->GetNmethods();
+            const char **methodNames = new const char* [2*numberOfMethods];
+            while (( method = ( TMethod * ) nextMethod() )) {
+                methodNames[2*i]   = method->GetName();
+                methodNames[2*i+1] = ( const char * ) method;
+                i++;
+            }
+
+
+            // write a HTML header
+            char *sourceTitle = StrDup( classPtr->GetName(), 16 );
+            strcat( sourceTitle, " - source file" );
+            WriteHtmlHeader( tempFile, sourceTitle );
+            if( sourceTitle ) delete [] sourceTitle;
+
+
+            tempFile << "<pre>" << endl;
+
+            while( !sourceFile.eof() ) {
+
+                sourceFile.getline( fLine, fLen-1 );
+                if( sourceFile.eof() ) break;
+
+
+                // set start & end of the line
+                if (!fLine) {
+                   fLine = (char *) " ";
+                   Warning("ClassDescription", "found an empty line");
+                }
+                char *startOfLine = fLine;
+                char *endOfLine   = fLine + strlen( fLine ) - 1;
+
+
+                // remove leading spaces
+                while( isspace( *startOfLine )) startOfLine++;
+
+                // remove trailing spaces
+                while( isspace( *endOfLine )) endOfLine--;
+                if( *startOfLine == '#' && !tempFlag )
+                    thisLineIsPpLine = kTRUE;
+
+                // if this line is a comment line
+                else if( !strncmp( startOfLine, "//", 2 )) {
+
+                    thisLineIsCommented = kTRUE;
+                    thisLineIsPpLine    = kFALSE;
+
+                    // remove a repeating characters from the end of the line
+                    while( (*endOfLine == *startOfLine ) &&
+                            ( endOfLine >= startOfLine )) endOfLine--;
+                    endOfLine++;
+                    char tempChar = *endOfLine;
+                    *endOfLine = 0;
+
+
+                    if( extractComments) {
+                        if( firstCommentLine ) {
+                            out << "<pre>";
+                            firstCommentLine = kFALSE;
+                        }
+                        if( endOfLine >= startOfLine+2 )
+                            ExpandKeywords( out, startOfLine+2, classPtr, flag );
+                        out << endl;
+                    }
+
+                    *endOfLine = tempChar;
+
+                    // if line is composed of the same characters
+                    if( (endOfLine == startOfLine ) && *( startOfLine+2 ) && classDescription ) {
+                        extractComments  = kTRUE;
+                        classDescription = kFALSE;
+                    }
+                }
+                else {
+                    thisLineIsCommented = kFALSE;
+                    if( flag ) {
+                        out << fLine << endl;
+                    }
+                    else {
+                        extractComments = kFALSE;
+                        if( !firstCommentLine ) {
+                            out << "</pre>";
+                            firstCommentLine = kTRUE;
+                        }
+                    }
+                }
+
+
+                // if NOT member function
+                key = strstr( fLine, pattern );
+                if( !key ) {
+                    // check for a lastUpdate string
+                    if( !foundLastUpdate && lastUpdateStr) {
+                        if( !strncmp( fLine, lastUpdateStr, strlen( lastUpdateStr )) ) {
+                            strcpy( lastUpdate, fLine+strlen( lastUpdateStr ));
+                            foundLastUpdate = kTRUE;
+                        }
+                    }
+
+                    // check for an author string
+                    if( !foundAuthor && authorStr) {
+                        if( !strncmp( fLine, authorStr, strlen( authorStr )) ) {
+                            strcpy( author, fLine+strlen( authorStr ));
+                            foundAuthor = kTRUE;
+                        }
+                    }
+
+                    // check for a copyright string
+                    if( !foundCopyright && copyrightStr) {
+                        if( !strncmp( fLine, copyrightStr, strlen( copyrightStr )) ) {
+                            strcpy( copyright, fLine+strlen( copyrightStr ));
+                            foundCopyright = kTRUE;
+                        }
+                    }
+
+                    // check for a description comments
+                    if( descriptionStr && !strncmp( fLine, descriptionStr, strlen( descriptionStr )) ) {
+                        if( classDescription ) {
+                            // write description out
+                            classDescription = kFALSE;
+                            extractComments = kTRUE;
+                        }
+                        else
+                        {
+                            postponeMemberDescr = kTRUE;
+                            postponedpos = sourceFile.tellg();
+                        }
+                    }
+                }
+                else {
+                    Bool_t found = kFALSE;
+                    // find method name
+                    char *funcName = key + len;
+
+                    while( *funcName && isspace( *funcName ) )
+                        funcName++;
+                    char *nameEndPtr = funcName;
+
+                    // In case of destructor
+                    if( *nameEndPtr == '~' ) nameEndPtr++;
+
+                    while( *nameEndPtr && IsName( *nameEndPtr ) )
+                        nameEndPtr++;
+
+                    char c1 = *nameEndPtr;
+                    char pe = 0;
+
+                    char *params, *paramsEnd;
+                    params = nameEndPtr;
+                    paramsEnd = NULL;
+
+                    while( *params  && isspace( *params ) ) params++;
+                    if( *params != '(') params = NULL;
+                    else params++;
+                    paramsEnd = params;
+
+                    // if signature exist, try to find the ending character
+                    if( paramsEnd ) {
+                        Int_t count = 1;
+                        while( *paramsEnd ) {
+                            if( *paramsEnd == '(') count++;
+                            if( *paramsEnd == ')')
+                                if( !--count ) break;
+                            paramsEnd++;
+                        }
+                        pe = *paramsEnd;
+                        *paramsEnd = 0;
+                    }
+                    *nameEndPtr = 0;
+
+                    // get method
+                    TMethod *method;
+                    method = classPtr->GetMethodAny( funcName );
+
+                    // restore characters
+                    if( paramsEnd )  *paramsEnd = pe;
+                    if( nameEndPtr ) *nameEndPtr = c1;
+
+                    if( method ) {
+
+                        if (skipMemberName)
+                        {
+                            skipMemberName = kFALSE;
+                            writeBracket = kTRUE;
+                            sourceFile.seekg(postponedpos);
+                        }
+                        else
+                        {
+                        char *typeEnd = NULL;
+                        char c2 = 0;
+
+                        found = kFALSE;
+
+                        // try to get type
+                        typeEnd = key-1;
+                        while( ( typeEnd > fLine ) && (isspace( *typeEnd ) || *typeEnd == '*') )
+                            typeEnd--;
+                        typeEnd++;
+                        c2 = *typeEnd;
+                        *typeEnd = 0;
+                        char *type = typeEnd - 1;
+                        while( IsName( *type ) && ( type > fLine ))
+                            type--;
+                        if( !IsWord( *type )) type++;
+
+                        while( (type > fLine ) && isspace( *( type-1 )) )
+                            type--;
+                        if( type > fLine ) {
+                            if( !strncmp( type-5, "const", 5 ))
+                                found = kTRUE;
+                            else found = kFALSE;
+                        }
+                        else if( type == fLine )
+                            found = kTRUE;
+
+                        if( !strcmp( type, "void" ) && ( *funcName == '~' ) )
+                            found = kTRUE;
+
+                        *typeEnd = c2;
+
+                        if( found ) {
+                            ptr = strchr( nameEndPtr, '{');
+                            char *semicolon = strchr( nameEndPtr, ';');
+                            if( semicolon )
+                                if( !ptr || ( semicolon < ptr )) found = kFALSE;
+
+                            if( !ptr && found ) {
+                                found = kFALSE;
+                                while( sourceFile.getline( nextLine, 255 ) && fLine && nextLine &&
+                                ( strlen( fLine ) < ( fLen-strlen( nextLine )) )) {
+                                    strcat( fLine, "\n" );
+                                    strcat( fLine, nextLine );
+                                    if (( ptr = strchr( fLine, '{') )) {
+                                        found = kTRUE;
+                                        *ptr = 0;
+                                        break;
+                                    }
+                                }
+                            }
+                            else if( ptr ) *ptr = 0;
+
+                            if( found ) {
+                                char *colonPtr = strrchr( fLine, ':');
+                                if( colonPtr > funcName ) *colonPtr = 0;
+                                if( found ) {
+                                    out << "<hr>" << endl;
+                                    out << "<!--FUNCTION-->";
+                                    if( typeEnd ) {
+                                        c2 = *typeEnd;
+                                        *typeEnd = 0;
+                                        ExpandKeywords( out, fLine, classPtr, flag );
+                                        *typeEnd = c2;
+                                        while( typeEnd < key ) {
+                                            if( *typeEnd == '*')
+                                                out << *typeEnd;
+                                            typeEnd++;
+                                        }
+                                    }
+                                    *nameEndPtr = 0;
+
+                                    out << " <a name=\"" << classPtr->GetName() << ":";
+                                    out << funcName << "\" href=\"src/";
+                                    out << classPtr->GetName() << ".cxx.html#" << classPtr->GetName() << ":";
+                                    ReplaceSpecialChars( out, funcName );
+                                    out << "\">";
+                                    ReplaceSpecialChars( out, funcName );
+                                    out << "</a>";
+
+                                    tempFile << "<a name=\"" << classPtr->GetName() << ":";
+                                    ReplaceSpecialChars( tempFile, funcName );
+                                    tempFile << "\"> </a>";
+
+                                    // remove this method name from the list of methods
+                                    i = 0;
+                                    while( i < numberOfMethods ) {
+                                        const char *mptr = methodNames[2*i];
+                                        if( mptr ) {
+                                           while( *mptr == '*') mptr++;
+                                           if( !strcmp( mptr, funcName )) {
+                                               methodNames[2*i] = NULL;
+                                               break;
+                                           }
+                                        }
+                                        i++;
+                                    }
+
+                                    *nameEndPtr = c1;
+                                    if( colonPtr ) *colonPtr = ':';
+                                    ExpandKeywords( out, nameEndPtr, classPtr, flag );
+                                    out << "<br>" << endl;
+
+                                    if (postponeMemberDescr)
+                                    {
+                                        streampos pos = sourceFile.tellg();
+                                        sourceFile.seekg(postponedpos);
+                                        postponedpos = pos;
+                                        skipMemberName = kTRUE;
+                                        postponeMemberDescr = kFALSE;
+                                    }
+                                    extractComments = kTRUE;
+                                }
+                            }
+                            if( ptr ) *ptr = '{';
+                        }
+                    }
+                }
+                }
+
+                // write to '.cxx.html' file
+                if (!skipMemberName)
+                {
+                    if( thisLineIsPpLine )
+                        ExpandPpLine( tempFile, fLine );
+                    else {
+                        if( thisLineIsCommented) tempFile << "<b>";
+                        ExpandKeywords( tempFile, fLine, classPtr, tempFlag, "../" );
+                        if( thisLineIsCommented ) tempFile << "</b>";
+                    }
+                    tempFile << endl;
+
+                    if (writeBracket)
+                    {
+                        writeBracket = kFALSE;
+                        tempFile << "{" << endl;
+                    }
+                }
+
+            }
+            tempFile << "</pre>" << endl;
+
+            // do some checking
+            Bool_t inlineFunc = kFALSE;
+            i = 0;
+            while( i++ < numberOfMethods ) {
+                if( methodNames[2*i] ) {
+                    inlineFunc = kTRUE;
+                    break;
+                }
+            }
+
+
+            if( inlineFunc ) {
+                out << "<br><br><br>" << endl;
+                out << "<h3>Inline Functions</h3>" << endl;
+                out << "<hr>" << endl;
+                out << "<pre>" << endl;
+
+                Int_t maxlen = 0, len = 0;
+                for( i = 0; i < numberOfMethods; i++ ) {
+                    if( methodNames[2*i] ) {
+                        method = ( TMethod * ) methodNames[2*i+1];
+                        if ( method->GetReturnTypeName() ) len = strlen( method->GetReturnTypeName() );
+                        else len = 0;
+                        maxlen = len > maxlen ? len : maxlen;
+                    }
+                }
+
+
+                // write out an inline functions
+                for( i = 0; i < numberOfMethods; i++ ) {
+                    if( methodNames[2*i] ) {
+
+                        method = ( TMethod * ) methodNames[2*i+1];
+
+                        if( method ) {
+
+                            if(
+                                !strcmp( method->GetName(), "Dictionary"    ) ||
+                                !strcmp( method->GetName(), "Class_Version" ) ||
+                                !strcmp( method->GetName(), "Class_Name"    ) ||
+                                !strcmp( method->GetName(), "DeclFileName"  ) ||
+                                !strcmp( method->GetName(), "DeclFileLine"  ) ||
+                                !strcmp( method->GetName(), "ImplFileName"  ) ||
+                                !strcmp( method->GetName(), "ImplFileLine"  )
+                            ) continue;
+
+                            out << "<!--INLINE FUNCTION-->";
+                            if(method->GetReturnTypeName() ) len = strlen( method->GetReturnTypeName() );
+                            else len = 0;
+
+                            out << "<!--TAB6-->      ";
+                            while( len++ < maxlen+2 ) out << " ";
+
+                            char *tmpstr = StrDup( method->GetReturnTypeName() );
+                            if( tmpstr ) {
+                                ExpandKeywords( out, tmpstr, classPtr, flag );
+                                delete [] tmpstr;
+                            }
+
+                            out << " <a name=\"" << classPtr->GetName();
+                            out << ":" << method->GetName() << "\" href=\"";
+                            out << GetFileName( classPtr->GetDeclFileName() ) << "\">";
+                            out << method->GetName() << "</a>";
+
+                            strcpy( fLine, method->GetSignature() );
+                            ExpandKeywords( out, fLine, classPtr, flag );
+                            out << endl;
+                        }
+                    }
+                }
+                out << "</pre>" << endl;
+            }
+
+
+            // write tempFile footer
+            WriteHtmlFooter( tempFile, "../" );
+
+            // close a temp file
+            tempFile.close();
+
+            delete [] methodNames;
+        }
+        else Error( "MakeClass", "Can't open file '%s' !", filename );
+
+        // close a source file
+        sourceFile.close();
+
+    }
+    else Error( "Make", "Can't open file '%s' !", realFilename );
+
+
+    // write classFile footer
+    WriteHtmlFooter( out, "",  lastUpdate, author, copyright );
+
+    // free memory
+    if( nextLine )     delete [] nextLine;
+    if( pattern )      delete [] pattern;
+
+    if( lastUpdate )   delete [] lastUpdate;
+    if( author )       delete [] author;
+    if( copyright )    delete [] copyright;
+    if( funcName )     delete [] funcName;
+
+    if( realFilename ) delete [] realFilename;
+    if( filename )     delete [] filename;
+}
+
+
+//______________________________________________________________________________
+void MHtml::ClassTree( TVirtualPad *psCanvas, TClass *classPtr, Bool_t force )
+{
+// It makes a class tree
+//
+//
+// Input: psCanvas - pointer to the current canvas
+//        classPtr - pointer to the class
+//
+
+    if( psCanvas && classPtr ) {
+        char *tmp1 = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), classPtr->GetName() );
+        char *filename = StrDup( tmp1 , 16 );
+
+        strcat( filename, "_Tree.ps" );
+
+        if( tmp1 ) delete [] tmp1;
+        tmp1 = 0;
+
+        if( IsModified( classPtr, kTree ) || force ) {
+            Printf( formatStr, "", "", filename );
+            classPtr->Draw( "same" );
+            psCanvas->SaveAs(filename);
+        }
+        else Printf( formatStr, "-no change-", "", filename );
+
+        if( filename ) delete [] filename;
+    }
+}
+
+
+//______________________________________________________________________________
+void MHtml::Convert( const char *filename, const char *title, const char *dirname )
+{
+// It converts a single text file to HTML
+//
+//
+// Input: filename - name of the file to convert
+//        title    - title which will be placed at the top of the HTML file
+//        dirname  - optional parameter, if it's not specified, output will
+//                   be placed in html/examples directory.
+//
+//  NOTE: Output file name is the same as filename, but with extension .html
+//
+
+    const char *dir;
+    char *ptr;
+
+    Bool_t isCommentedLine = kFALSE;
+    Bool_t tempFlag = kFALSE;
+
+    // if it's not defined, make the "examples" as a default directory
+    if( !*dirname ) {
+        dir = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), "examples" );
+
+        // create directory if necessary
+        if( gSystem->AccessPathName( dir ))
+            gSystem->MakeDirectory( dir );
+    }
+    else dir = dirname;
+
+
+    // find a file
+    char *realFilename = gSystem->Which( fSourceDir, filename, kReadPermission );
+
+    if( realFilename ) {
+
+        // open source file
+        ifstream sourceFile;
+        sourceFile.open( realFilename, ios::in );
+
+        delete [] realFilename;
+        realFilename = 0;
+
+        if( sourceFile.good() ) {
+
+            // open temp file with extension '.html'
+            if( !gSystem->AccessPathName( dir )) {
+                char *tmp1 = gSystem->ConcatFileName( dir, GetFileName( filename ));
+                char *htmlFilename = StrDup( tmp1, 16 );
+                strcat( htmlFilename, ".html" );
+
+                if( tmp1 ) delete [] tmp1;
+                tmp1 = 0;
+
+                ofstream tempFile;
+                tempFile.open( htmlFilename, ios::out );
+
+                if( tempFile.good() ) {
+
+                    Printf( "Convert: %s", htmlFilename );
+
+                    // write a HTML header
+                    WriteHtmlHeader( tempFile, title );
+
+                    tempFile << "<h1>" << title << "</h1>" << endl;
+                    tempFile << "<pre>" << endl;
+
+                    while( !sourceFile.eof() ) {
+                        sourceFile.getline( fLine, fLen-1 );
+                        if( sourceFile.eof() ) break;
+
+
+                        // remove leading spaces
+                        ptr = fLine;
+                        while( isspace( *ptr )) ptr++;
+
+
+                        // check for a commented line
+                        if( !strncmp( ptr, "//", 2 )) isCommentedLine = kTRUE;
+                        else isCommentedLine = kFALSE;
+
+
+                        // write to a '.html' file
+                        if( isCommentedLine ) tempFile << "<b>";
+                        gROOT->GetListOfGlobals(kTRUE); // force update of this list
+                        ExpandKeywords( tempFile, fLine, NULL, tempFlag, "../" );
+                        if( isCommentedLine ) tempFile << "</b>";
+                        tempFile << endl;
+                    }
+                    tempFile << "</pre>" << endl;
+
+
+                    // write a HTML footer
+                    WriteHtmlFooter( tempFile, "../" );
+
+
+                    // close a temp file
+                    tempFile.close();
+
+                }
+                else Error( "Convert", "Can't open file '%s' !", htmlFilename );
+
+                // close a source file
+                sourceFile.close();
+                if( htmlFilename ) delete [] htmlFilename;
+                htmlFilename = 0;
+            }
+            else Error( "Convert", "Directory '%s' doesn't exist, or it's write protected !", dir );
+        }
+        else Error( "Convert", "Can't open file '%s' !", realFilename );
+    }
+    else Error( "Convert", "Can't find file '%s' !", filename );
+}
+
+
+//______________________________________________________________________________
+Bool_t MHtml::CopyHtmlFile( const char *sourceName, const char *destName )
+{
+// Copy file to HTML directory
+//
+//
+//  Input: sourceName - source file name
+//         destName   - optional destination name, if not
+//                      specified it would be the same
+//                      as the source file name
+//
+// Output: TRUE if file is successfully copied, or
+//         FALSE if it's not
+//
+//
+//   NOTE: The destination directory is always fOutputDir
+//
+
+    Bool_t ret = kFALSE;
+    Int_t check = 0;
+
+    // source file name
+    char *tmp1 = gSystem->Which( fSourceDir, sourceName, kReadPermission );
+    char *sourceFile = StrDup( tmp1, 16 );
+
+    if( tmp1 ) delete [] tmp1;
+    tmp1 = 0;
+
+    if( sourceFile ) {
+
+        // destination file name
+        char *tmpstr = 0;
+        if( !*destName ) tmpstr = StrDup( GetFileName( sourceFile ), 16 );
+        else tmpstr = StrDup( GetFileName( destName ), 16 );
+        destName = tmpstr;
+
+        tmp1 = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), destName );
+        char *filename = StrDup( tmp1, 16 );
+
+        if( tmp1 ) delete [] tmp1;
+        tmp1 = 0;
+
+        // Get info about a file
+        Long_t sId, sSize, sFlags, sModtime;
+        Long_t dId, dSize, dFlags, dModtime;
+        if( !( check = gSystem->GetPathInfo( sourceFile, &sId, &sSize, &sFlags, &sModtime )) )
+            check = gSystem->GetPathInfo( filename, &dId, &dSize, &dFlags, &dModtime );
+
+
+        if( (sModtime != dModtime ) || check ) {
+
+            char *cmd = new char[256];
+
+#ifdef R__UNIX
+            strcpy( cmd, "/bin/cp " );
+            strcat( cmd, sourceFile );
+            strcat( cmd, " " );
+            strcat( cmd, filename );
+#endif
+
+#ifdef WIN32
+            strcpy( cmd, "copy \"" );
+            strcat( cmd, sourceFile );
+            strcat( cmd, "\" \"" );
+            strcat( cmd, filename );
+            strcat( cmd, "\"");
+            char *bptr = 0;
+            while( bptr = strchr( cmd, '/') )
+                *bptr = '\\';
+#endif
+
+            ret = !gSystem->Exec( cmd );
+
+            delete [] cmd;
+            delete [] filename;
+            delete [] tmpstr;
+            delete [] sourceFile;
+        }
+    }
+    else Error( "Copy", "Can't copy file '%s' to '%s' directory !", sourceName, fOutputDir );
+
+    return( ret );
+}
+
+
+
+//______________________________________________________________________________
+void MHtml::CreateIndex( const char **classNames, Int_t numberOfClasses )
+{
+// Create an index
+//
+//
+// Input: classNames      - pointer to an array of class names
+//        numberOfClasses - number of elements
+//
+
+    Int_t i, len, maxLen = 0;
+
+    char *tmp1 = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), "ClassIndex.html" );
+    char *filename = StrDup( tmp1 );
+
+    if( tmp1 ) delete [] tmp1;
+    tmp1 = 0;
+
+    // open indexFile file
+    ofstream indexFile;
+    indexFile.open( filename, ios::out );
+
+    for( i = 0; i < numberOfClasses; i++ ) {
+        len    = strlen( classNames[i] );
+        maxLen = maxLen > len ? maxLen : len;
+    }
+
+    if( indexFile.good() ) {
+
+        Printf( formatStr, "", fCounter, filename );
+
+        // write indexFile header
+        WriteHtmlHeader( indexFile, "Class Index" );
+        indexFile << "<h1>Index</h1>" << endl;
+
+        // check for a search engine
+        const char *searchEngine = gEnv->GetValue( "Root.Html.SearchEngine", "" );
+
+        // if exists ...
+        if( *searchEngine ) {
+
+            // create link to search engine page
+            indexFile << "<h2><a href=\"" << searchEngine
+                      << "\">Search the Class Reference Guide</a></h2>" << endl;
+
+        }
+
+        indexFile << "<hr>" << endl;
+        indexFile << "<pre>" << endl;
+        indexFile << "<ul>" << endl;
+
+        // loop on all classes
+        for( i = 0; i < numberOfClasses; i++ ) {
+
+            // get class
+            TClass *classPtr = GetClass( (const char * ) classNames[i] );
+
+            indexFile << "<li>";
+            char *htmlFile = GetHtmlFileName( classPtr );
+            if( htmlFile ) {
+                indexFile << "<a name=\"";
+                indexFile << classNames[i];
+                indexFile << "\" href=\"";
+                indexFile << htmlFile;
+                indexFile << "\">";
+                indexFile << classNames[i];
+                indexFile << "</a> ";
+                delete [] htmlFile;
+                htmlFile = 0;
+            }
+            else indexFile << classNames[i];
+
+
+            // write title
+            len = strlen( classNames[i] );
+            for( Int_t w = 0; w < ( maxLen-len+2 ); w++ )
+                indexFile << ".";
+            indexFile << " ";
+
+            indexFile << "<a name=\"Title:";
+            indexFile << classPtr->GetName();
+            indexFile << "\">";
+            ReplaceSpecialChars( indexFile, classPtr->GetTitle() );
+            indexFile << "</a>" << endl;
+        }
+
+        indexFile << "</ul>" << endl;
+        indexFile << "</pre>" << endl;
+
+
+        // write indexFile footer
+        TDatime date;
+        WriteHtmlFooter( indexFile, "", date.AsString() );
+
+
+        // close file
+        indexFile.close();
+
+    }
+    else Error( "MakeIndex", "Can't open file '%s' !", filename );
+
+    if( filename ) delete [] filename;
+}
+
+
+//______________________________________________________________________________
+void MHtml::CreateIndexByTopic( char **fileNames, Int_t numberOfNames, Int_t maxLen )
+{
+// It creates several index files
+//
+//
+// Input: fileNames     - pointer to an array of file names
+//        numberOfNames - number of elements in the fileNames array
+//        maxLen        - maximum length of a single name
+//
+
+    ofstream outputFile;
+    char *filename = NULL;
+    Int_t i;
+
+    for( i = 0; i < numberOfNames; i++ ) {
+        if( !filename ) {
+
+            // create a filename
+            char *tmp1 = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), fileNames[i] );
+            filename = StrDup( tmp1, 16);
+
+            if( tmp1 ) delete [] tmp1;
+            tmp1 = 0;
+
+            char *underlinePtr = strrchr( filename, '_');
+            *underlinePtr = 0;
+
+            strcat( filename, "_Index.html" );
+
+            // open a file
+            outputFile.open( filename, ios::out );
+
+            // check if it's OK
+            if( outputFile.good() ) {
+
+                Printf( formatStr, "", fCounter, filename );
+
+                // write outputFile header
+                WriteHtmlHeader( outputFile, "Index" );
+                outputFile << "<h2>" << "Index" << "</h2><hr>" << endl;
+                outputFile << "<pre>" << endl;
+                outputFile << "<ul>" << endl;
+            }
+            else Error( "MakeIndex", "Can't open file '%s' !", filename );
+            delete [] filename;
+        }
+
+        // get a class
+        TClass *classPtr = GetClass( (const char * ) strrchr( fileNames[i], '_')+1 );
+        if( classPtr ) {
+
+            // write a classname to an index file
+            outputFile << "<li>";
+
+            char *htmlFile = GetHtmlFileName( classPtr );
+
+            if( htmlFile ) {
+                outputFile << "<a name=\"";
+                outputFile << classPtr->GetName();
+                outputFile << "\" href=\"";
+                outputFile << htmlFile;
+                outputFile << "\">";
+                outputFile << classPtr->GetName();
+                outputFile << "</a> ";
+                delete [] htmlFile;
+                htmlFile = 0;
+            }
+            else outputFile << classPtr->GetName();
+
+
+            // write title
+            Int_t len = strlen( classPtr->GetName() );
+            for( Int_t w = 0; w < maxLen-len; w++ )
+                outputFile << ".";
+            outputFile << " ";
+
+            outputFile << "<a name=\"Title:";
+            outputFile << classPtr->GetName();
+            outputFile << "\">";
+            ReplaceSpecialChars( outputFile, classPtr->GetTitle() );
+            outputFile << "</a>" << endl;
+        }
+        else Error( "MakeIndex", "Unknown class '%s' !", strchr( fileNames[i], '_')+1 );
+
+
+        // first base name
+        char *first  = strrchr( fileNames[i], '_');
+        if( first ) *first = 0;
+
+        // second base name
+        char *second = NULL;
+        if( i < ( numberOfNames - 1 )) {
+            second = strrchr( fileNames[i+1], '_');
+            if( second ) *second = 0;
+        }
+
+        // check and close the file if necessary
+        if( !first || !second || strcmp( fileNames[i], fileNames[i+1] )) {
+
+            if( outputFile.good() ) {
+
+                outputFile << "</ul>" << endl;
+                outputFile << "</pre>" << endl;
+
+                // write outputFile footer
+                TDatime date;
+                WriteHtmlFooter( outputFile, "", date.AsString() );
+
+                // close file
+                outputFile.close();
+
+                filename = NULL;
+            }
+            else Error( "MakeIndex", "Corrupted file '%s' !", filename );
+        }
+
+        if( first )  *first  = '_';
+        if( second ) *second = '_';
+    }
+
+    // free memory
+    for( i = 0; i < numberOfNames; i++ )
+        if( *fileNames[i] ) delete [] fileNames[i];
+}
+
+
+//______________________________________________________________________________
+void MHtml::CreateListOfTypes()
+{
+// Create list of all data types
+
+    Int_t maxLen = 0;
+    Int_t len;
+
+    // open file
+    ofstream typesList;
+
+    char *outFile = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), "ListOfTypes.html" );
+    typesList.open( outFile, ios::out );
+
+
+    if( typesList.good() ) {
+        Printf( formatStr, "", "", outFile );
+
+        // write typesList header
+        WriteHtmlHeader( typesList, "List of data types" );
+        typesList << "<h2> List of data types </h2><hr>" << endl;
+
+        typesList << "<dl><dd>" << endl;
+        typesList << "<pre>" << endl;
+
+        // make loop on data types
+        TDataType *type;
+        TIter nextType( gROOT->GetListOfTypes() );
+
+        while (( type = ( TDataType * ) nextType() )) {
+            if( *type->GetTitle() && !strchr( type->GetName(), '(' ) ) {
+                if( type->GetName() ) len = strlen( type->GetName() );
+                else len = 0;
+                maxLen = maxLen > len ? maxLen : len;
+            }
+        }
+        nextType.Reset();
+
+        maxLen += kSpaceNum;
+
+        while (( type = ( TDataType * ) nextType() )) {
+            if( *type->GetTitle() && !strchr( type->GetName(), '(' ) ) {
+                typesList << "<b><a name=\"";
+                typesList << type->GetName();
+                typesList << "\">" << type->GetName();
+                typesList << "</a></b>";
+
+                if( type->GetName() ) len = strlen( type->GetName() );
+                else len = 0;
+                typesList << " ";
+                for( Int_t j = 0; j < ( maxLen-len ); j++ )
+                    typesList << ".";
+                typesList << " ";
+
+                typesList << "<a name=\"Title:";
+                typesList << type->GetTitle();
+                typesList << "\">";
+                char *tempstr = StrDup( type->GetTitle() );
+                ReplaceSpecialChars( typesList, tempstr );
+                typesList << "</a>" << endl;
+
+                if( tempstr ) delete [] tempstr;
+            }
+        }
+
+        typesList << "</pre>" << endl;
+        typesList << "</dl>" << endl;
+
+        // write typesList footer
+        TDatime date;
+        WriteHtmlFooter( typesList, "", date.AsString() );
+
+        // close file
+        typesList.close();
+
+    }
+    else Error( "Make", "Can't open file '%s' !", outFile );
+
+    if (outFile) delete [] outFile;
+}
+
+
+//______________________________________________________________________________
+void MHtml::DerivedClasses( ofstream &out, TClass *classPtr )
+{
+// It creates a list of derived classes
+//
+//
+// Input: out      - output file stream
+//        classPtr - pointer to the class
+//
+
+    Bool_t first = kTRUE;
+    Bool_t found = kFALSE;
+
+
+    // get total number of classes
+    Int_t numberOfClasses = gClassTable->Classes();
+
+    // start from begining
+    gClassTable->Init();
+
+    // get class names
+    TClass *derivedClassPtr;
+    const char *derivedClassName;
+    for( Int_t i = 0; i < numberOfClasses; i++ ) {
+
+        // get class name
+        derivedClassName = gClassTable->Next();
+
+        // get class pointer
+        derivedClassPtr = GetClass( derivedClassName );
+
+        if ( !derivedClassPtr ) {
+           Warning("DerivedClasses","Can not find a definition for class <%s>",derivedClassName);
+           continue;
+        }
+        // make a loop on base classes
+        TBaseClass *inheritFrom;
+        TIter nextBase( derivedClassPtr->GetListOfBases() );
+
+        while (( inheritFrom = ( TBaseClass * ) nextBase() )) {
+            if( !strcmp( inheritFrom->GetName(), classPtr->GetName() )) {
+                if( first ) {
+                    out << "<br><hr>" << endl;
+                    out << "<!--SEE ALSO-->";
+                    out << "<h2>See also</h2><dl><dd>" << endl;
+                }
+                if( !first ) out << ", ";
+
+                char *htmlFile = GetHtmlFileName( derivedClassPtr );
+
+                if( htmlFile ) {
+                    out << "<a href=\"";
+                    out << htmlFile;
+                    out << "\">";
+                    out << derivedClassPtr->GetName() << "</a>";
+                    delete [] htmlFile;
+                    htmlFile = 0;
+                }
+                else out << derivedClassPtr->GetName();
+
+                if( first ) {
+                    first = kFALSE;
+                    found = kTRUE;
+                }
+            }
+        }
+    }
+    if( found ) out << "</dl>" << endl;
+}
+
+
+//______________________________________________________________________________
+void MHtml::ExpandKeywords( ofstream &out, char *text, TClass *ptr2class,
+                            Bool_t &flag, const char *dir )
+{
+// Find keywords in text & create URLs
+//
+//
+// Input: out       - output file stream
+//        text      - pointer to the array of the characters to process
+//        ptr2class - pointer to the class
+//        flag      - this is a 'html_begin/html_end' flag
+//        dir       - usually "" or "../", depends of current file
+//                    directory position
+//
+
+    char *keyword = text;
+    char *end;
+    char *funcName;
+    char *funcNameEnd;
+    char *funcSig;
+    char *funcSigEnd;
+    char c, c2, c3;
+    char *tempEndPtr;
+    c2 = c3 = 0;
+
+    Bool_t hide;
+    Bool_t mmf = 0;
+
+    do {
+        tempEndPtr = end = funcName = funcNameEnd = funcSig = funcSigEnd = NULL;
+
+        hide = kFALSE;
+
+        // skip until start of the word
+        while( !IsWord( *keyword ) && *keyword ) {
+            if( !flag ) ReplaceSpecialChars( out, *keyword );
+            else out << *keyword;
+            keyword++;
+        }
+
+        // get end of the word
+        end = keyword;
+        while( IsName( *end ) && *end ) end++;
+
+        // put '\0' at the end of the keyword
+        c = *end;
+        *end = 0;
+
+        if( strlen( keyword ) > 50 ) {
+            out << keyword;
+            *end = c;
+            keyword = end;
+            continue;
+        }
+
+        // check if this is a HTML block
+        if( flag ) {
+            if( !strcasecmp( keyword, "end_html" ) && *( keyword-1 ) != '\"') {
+                flag = kFALSE;
+                hide = kTRUE;
+            }
+        }
+        else {
+            if( !strcasecmp( keyword, "begin_html" ) && *( keyword-1 ) != '\"') {
+                flag = kTRUE;
+                hide  = kTRUE;
+            }
+            else {
+                *end = c;
+                tempEndPtr = end;
+
+                // skip leading spaces
+                while( *tempEndPtr && isspace( *tempEndPtr ) ) tempEndPtr++;
+
+
+                // check if we have a something like a 'name[arg].name'
+                Int_t count = 0;
+                if( *tempEndPtr == '[') {
+                    count++;
+                    tempEndPtr++;
+                }
+
+                // wait until the last ']'
+                while( count && *tempEndPtr ) {
+                    switch( *tempEndPtr ) {
+                        case '[': count++;
+                                  break;
+                        case ']': count--;
+                                  break;
+                    }
+                    tempEndPtr++;
+                }
+
+                if( !strncmp( tempEndPtr, "::", 2 ) || !strncmp( tempEndPtr, "->", 2 ) || ( *tempEndPtr == '.') ) {
+                    funcName = tempEndPtr;
+
+                    // skip leading spaces
+                    while( isspace( *funcName )) funcName++;
+
+                    // check if we have a '.' or '->'
+                    if( *tempEndPtr == '.') funcName++;
+                    else funcName += 2;
+
+                    if( !strncmp( tempEndPtr, "::", 2 )) mmf = kTRUE;
+                    else mmf = kFALSE;
+
+                    // skip leading spaces
+                    while( *funcName && isspace( *funcName )) funcName++;
+
+                    // get the end of the word
+                    if( !IsWord( *funcName )) funcName = NULL;
+
+                    if( funcName ) {
+                        funcNameEnd = funcName;
+
+                        // find the end of the function name part
+                        while( IsName( *funcNameEnd ) && *funcNameEnd )
+                            funcNameEnd++;
+                        c2 = *funcNameEnd;
+                        if( !mmf ) {
+
+                            // try to find a signature
+                            funcSig = funcNameEnd;
+
+                            // skip leading spaces
+                            while( *funcSig && isspace( *funcSig )) funcSig++;
+                            if( *funcSig != '(') funcSig = NULL;
+                            else funcSig++;
+                            funcSigEnd = funcSig;
+
+                            // if signature exist, try to find the ending character
+                            if( funcSigEnd ) {
+                                Int_t count = 1;
+                                while( *funcSigEnd ) {
+                                    if( *funcSigEnd == '(') count++;
+                                    if( *funcSigEnd == ')')
+                                        if( !--count ) break;
+                                    funcSigEnd++;
+                                }
+                                c3 = *funcSigEnd;
+                                *funcSigEnd = 0;
+                            }
+                        }
+                        *funcNameEnd = 0;
+                    }
+                }
+                *end = 0;
+            }
+        }
+
+        if( !flag && !hide && *keyword ) {
+
+            // get class
+            TClass *classPtr = GetClass( (const char * ) keyword );
+
+            if( classPtr ) {
+
+                char *htmlFile = GetHtmlFileName( classPtr );
+
+                if( htmlFile ) {
+                    out << "<a href=\"";
+                    if( *dir && strncmp( htmlFile, "http://", 7 )) out << dir;
+                    out << htmlFile;
+
+                    if( funcName && mmf ) {
+
+                        // make a link to the member function
+                        out << "#" << classPtr->GetName() << ":";
+                        out << funcName;
+                        out << "\">";
+                        out << classPtr->GetName() << "::";
+                        out << funcName;
+                        out << "</a>";
+
+                        *funcNameEnd = c2;
+                        keyword = funcNameEnd;
+                    }
+                    else {
+                        // make a link to the class
+                        out << "\">";
+                        out << classPtr->GetName();
+                        out << "</a>";
+
+                        keyword = end;
+                    }
+                    delete [] htmlFile;
+                    htmlFile = 0;
+
+                }
+                else {
+                    out << keyword;
+                    keyword = end;
+                }
+                *end = c;
+                if( funcName ) *funcNameEnd = c2;
+                if( funcSig )  *funcSigEnd  = c3;
+            }
+            else {
+                // get data type
+                TDataType *type = gROOT->GetType( (const char *) keyword );
+
+                if( type ) {
+
+                    // make a link to the data type
+                    out << "<a href=\"";
+                    if( *dir ) out << dir;
+                    out << "ListOfTypes.html#";
+                    out << keyword << "\">";
+                    out << keyword << "</a>";
+
+                    *end = c;
+                    keyword = end;
+                }
+                else {
+                    // look for '('
+                    Bool_t isfunc = ( (*tempEndPtr == '(') || c == '(')? kTRUE: kFALSE;
+                    if( !isfunc ) {
+                        char *bptr = tempEndPtr + 1;
+                        while( *bptr && isspace( *bptr ) ) bptr++;
+                        if( *bptr == '(') isfunc = kTRUE;
+                    }
+
+                    if( isfunc && ptr2class && ( ptr2class->GetMethodAny( keyword )) ) {
+                        out << "<a href=\"#";
+                        out << ptr2class->GetName();
+                        out << ":" << keyword << "\">";
+                        out << keyword << "</a>";
+                        *end = c;
+                        keyword = end;
+                    }
+                    else {
+                        const char *anyname = gROOT->FindObjectClassName( keyword );
+
+                        const char *namePtr = NULL;
+                        TClass *cl  = 0;
+                        TClass *cdl = 0;
+
+                        if( anyname ) {
+                            cl = GetClass( anyname );
+                            namePtr = ( const char * ) anyname;
+                            cdl = cl;
+                        }
+                        else if( ptr2class ) {
+                            cl = ptr2class->GetBaseDataMember( keyword );
+                            if( cl ) {
+                                namePtr = cl->GetName();
+                                TDataMember *member = cl->GetDataMember( keyword );
+                                if( member )
+                                    cdl = GetClass( member->GetTypeName() );
+                            }
+                        }
+
+                        if( cl ) {
+                            char *htmlFile = GetHtmlFileName( cl );
+
+                            if( htmlFile ) {
+                                out << "<a href=\"";
+                                if( *dir  && strncmp( htmlFile, "http://", 7 )) out << dir;
+                                out << htmlFile;
+                                if( cl->GetDataMember( keyword ) ) {
+                                    out << "#" << namePtr << ":";
+                                    out << keyword;
+                                }
+                                out << "\">";
+                                out << keyword;
+                                out << "</a>";
+                                delete [] htmlFile;
+                                htmlFile = 0;
+                            }
+                            else out << keyword;
+
+                            if( funcName ) {
+                                char *ptr = end;
+                                ptr++;
+                                ReplaceSpecialChars( out, c );
+                                while( ptr < funcName )
+                                    ReplaceSpecialChars( out, *ptr++ );
+
+                                TMethod *method = NULL;
+                                if( cdl ) method = cdl->GetMethodAny( funcName );
+                                if( method ) {
+                                    TClass *cm = method->GetClass();
+                                    if( cm ) {
+                                        char *htmlFile2 = GetHtmlFileName( cm );
+                                        if( htmlFile2 ) {
+                                            out << "<a href=\"";
+                                            if( *dir  && strncmp( htmlFile2, "http://", 7 )) out << dir;
+                                            out << htmlFile2;
+                                            out << "#" << cm->GetName() << ":";
+                                            out << funcName;
+                                            out << "\">";
+                                            out << funcName;
+                                            out << "</a>";
+                                            delete [] htmlFile2;
+                                            htmlFile2 = 0;
+                                        }
+                                        else out << funcName;
+
+                                        keyword = funcNameEnd;
+                                    }
+                                    else keyword = funcName;
+                                }
+                                else keyword = funcName;
+
+                                *funcNameEnd = c2;
+                                if( funcSig ) *funcSigEnd = c3;
+                            }
+                            else keyword = end;
+                            *end = c;
+                        }
+                        else {
+                            if( funcName ) *funcNameEnd = c2;
+                            if( funcSig )  *funcSigEnd  = c3;
+                            out << keyword;
+                            *end = c;
+                            keyword = end;
+                        }
+                    }
+                }
+            }
+        }
+        else {
+            if( !hide && *keyword )
+                out << keyword;
+            *end = c;
+            keyword = end;
+        }
+    } while( *keyword );
+}
+
+
+//______________________________________________________________________________
+void MHtml::ExpandPpLine( ofstream &out, char *line )
+{
+// Expand preprocessor statements
+//
+//
+// Input: out  - output file stream
+//        line - pointer to the array of characters,
+//               usually one line from the source file
+//
+//  NOTE: Looks for the #include statements and
+//        creates link to the corresponding file
+//        if such file exists
+//
+
+    const char *ptr;
+    const char *ptrStart;
+    const char *ptrEnd;
+    char *fileName;
+
+    Bool_t linkExist = kFALSE;
+
+    ptrEnd = strstr( line, "include" );
+    if( ptrEnd ) {
+        ptrEnd += 7;
+        if (( ptrStart = strpbrk( ptrEnd, "<\"" ))) {
+            ptrStart++;
+            ptrEnd = strpbrk( ptrStart, ">\"" );
+            if( ptrEnd ) {
+                Int_t len = ptrEnd - ptrStart;
+                fileName = new char [len + 1];
+                strncpy( fileName, ptrStart, len );
+
+                char *tmpstr = gSystem->Which( fSourceDir, fileName, kReadPermission );
+                if( tmpstr ) {
+                    char *realFileName = StrDup( tmpstr );
+
+                    if( realFileName ) {
+                        CopyHtmlFile( realFileName );
+
+                        ptr = line;
+                        while( ptr < ptrStart )
+                            ReplaceSpecialChars( out, *ptr++ );
+                        out << "<a href=\"../" << GetFileName( realFileName ) << "\">";
+                        out << fileName << "</a>";
+                        out << ptrEnd;
+
+                        linkExist = kTRUE;
+                    }
+                    if( realFileName ) delete [] realFileName;
+                    if( fileName )     delete [] fileName;
+                    delete [] tmpstr;
+                }
+            }
+        }
+    }
+
+    if( !linkExist ) ReplaceSpecialChars( out, line );
+}
+
+//______________________________________________________________________________
+const char *MHtml::GetFileName( const char *filename )
+{
+// It discards any directory information inside filename
+//
+//
+//  Input: filename - pointer to the file name
+//
+// Output: pointer to the string containing just a file name
+//         without any other directory information, i.e.
+//         '/usr/root/test.dat' will return 'test.dat'
+//
+
+    return( gSystem->BaseName( gSystem->UnixPathName( filename )) );
+}
+
+//______________________________________________________________________________
+char *MHtml::GetSourceFileName(const char *filename)
+{
+   // Find the source file. If filename contains a path it will be used
+   // together with the possible source prefix. If not found we try
+   // old algorithm, by stripping off the path and trying to find it in the
+   // specified source search path. Returned string must be deleted by the
+   // user. In case filename is not found 0 is returned.
+
+   char *tmp1;
+#ifdef WIN32
+   if (strchr(filename, '/') || strchr(filename, '\\')) {
+#else
+   if (strchr(filename, '/')) {
+#endif
+      char *tmp;
+      if (strlen(fSourcePrefix) > 0)
+         tmp = gSystem->ConcatFileName(fSourcePrefix, filename);
+      else
+         tmp = StrDup(filename);
+      if ((tmp1 = gSystem->Which(fSourceDir, tmp, kReadPermission))) {
+         delete [] tmp;
+         return tmp1;
+      }
+      delete [] tmp;
+   }
+
+   if ((tmp1 = gSystem->Which(fSourceDir, GetFileName(filename), kReadPermission)))
+      return tmp1;
+
+   return 0;
+}
+
+//______________________________________________________________________________
+char *MHtml::GetHtmlFileName( TClass *classPtr )
+{
+// Return real HTML filename
+//
+//
+//  Input: classPtr - pointer to a class
+//
+// Output: pointer to the string containing a full name
+//         of the corresponding HTML file. The string must be deleted by the user.
+//
+
+    char htmlFileName [128];
+
+    char *ret  = 0;
+    Bool_t found = kFALSE;
+
+    if( classPtr ) {
+
+        const char *filename = classPtr->GetImplFileName();
+
+        char varName[80];
+        const char *colon = strchr( filename, ':');
+
+
+        // this should be a prefix
+        strcpy( varName, "Root.Html." );
+
+
+        if( colon )
+            strncat( varName, filename, colon-filename );
+        else strcat( varName, "Root" );
+
+        char *tmp;
+        if( !(tmp = gSystem->Which( fSourceDir, filename, kReadPermission ))) {
+            strcpy( htmlFileName, gEnv->GetValue( varName, "" ));
+            if( !*htmlFileName ) found = kFALSE;
+            else found = kTRUE;
+        }
+        else {
+            strcpy( htmlFileName, "." );
+            found = kTRUE;
+        }
+        delete [] tmp;
+
+        if( found ) {
+            char *tmp1 = gSystem->ConcatFileName( htmlFileName, classPtr->GetName() );
+            ret = StrDup( tmp1, 16 );
+            strcat( ret, ".html" );
+
+            if( tmp1 ) delete [] tmp1;
+            tmp1 = 0;
+        }
+        else ret = 0;
+
+    }
+
+    return ret;
+}
+
+//______________________________________________________________________________
+TClass *MHtml::GetClass(const char *name1, Bool_t load)
+{
+//*-*-*-*-*Return pointer to class with name*-*-*-*-*-*-*-*-*-*-*-*-*
+//*-*      =================================
+   Int_t n = strlen(name1);
+   char *name = new char[n+1];
+   strcpy(name, name1);
+   char *t = name+n-1;
+   while(*t == ' ') {
+      *t = 0;
+      if (t == name) break;
+      t--;
+   }
+   t = name;
+   while(*t == ' ') t++;
+
+   TClass *cl = gROOT->GetClass(t,load);
+   delete [] name;
+   return cl;
+}
+
+
+//______________________________________________________________________________
+Bool_t MHtml::IsModified( TClass *classPtr, const Int_t type )
+{
+// Check if file is modified
+//
+//
+//  Input: classPtr - pointer to the class
+//         type     - file type to compare with
+//                    values: kSource, kInclude, kTree
+//
+// Output: TRUE     - if file is modified since last time
+//         FALSE    - if file is up to date
+//
+
+    Bool_t ret = kTRUE;
+
+    char  sourceFile[1024], filename[1024];
+    char *strPtr, *strPtr2;
+
+    switch( type ) {
+       case kSource:
+          strPtr2 = GetSourceFileName(classPtr->GetImplFileName());
+          if (strPtr2) strcpy( sourceFile, strPtr2 );
+          strPtr = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), "src" );
+          strcpy( filename, strPtr );
+          delete [] strPtr;
+          delete [] strPtr2;
+#ifdef WIN32
+          strcat( filename, "\\" );
+#else
+          strcat( filename, "/" );
+#endif
+          strcat( filename, classPtr->GetName() );
+          strcat( filename, ".cxx.html" );
+          break;
+
+       case kInclude:
+          strPtr2 = GetSourceFileName(classPtr->GetDeclFileName());
+          if (strPtr2) strcpy( sourceFile, strPtr2 );
+          strPtr = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), GetFileName( classPtr->GetDeclFileName() ));
+          strcpy( filename,strPtr );
+          delete [] strPtr;
+          delete [] strPtr2;
+          break;
+
+       case kTree:
+          strPtr2 = GetSourceFileName(classPtr->GetDeclFileName());
+          if (strPtr2) strcpy( sourceFile, strPtr2 );
+          strPtr = gSystem->ConcatFileName( gSystem->ExpandPathName( fOutputDir ), GetFileName( classPtr->GetName() ));
+          strcpy( filename, strPtr);
+          delete [] strPtr;
+          delete [] strPtr2;
+          strcat( filename, "_Tree.ps" );
+          break;
+
+       default:
+          Error( "IsModified", "Unknown file type !" );
+    }
+
+    // Get info about a file
+    Long_t sId, sSize, sFlags, sModtime;
+    Long_t dId, dSize, dFlags, dModtime;
+
+    if( !( gSystem->GetPathInfo( sourceFile, &sId, &sSize, &sFlags, &sModtime )) )
+       if( !( gSystem->GetPathInfo( filename, &dId, &dSize, &dFlags, &dModtime )) )
+          ret = ( sModtime > dModtime ) ? kTRUE : kFALSE;
+
+    return( ret );
+}
+
+
+//______________________________________________________________________________
+Bool_t MHtml::IsName( Int_t c )
+{
+// Check if c is a valid C++ name character
+//
+//
+//  Input: c - a single character
+//
+// Output: TRUE if c is a valid C++ name character
+//         and FALSE if it's not.
+//
+//   NOTE: Valid name characters are [a..zA..Z0..9_],
+//
+
+    Bool_t ret = kFALSE;
+
+    if( isalnum( c ) || c == '_') ret = kTRUE;
+
+    return ret;
+}
+
+
+//______________________________________________________________________________
+Bool_t MHtml::IsWord( Int_t c )
+{
+// Check if c is a valid first character for C++ name
+//
+//
+//  Input: c - a single character
+//
+// Output: TRUE if c is a valid first character for C++ name,
+//         and FALSE if it's not.
+//
+//   NOTE: Valid first characters are [a..zA..Z_]
+//
+
+    Bool_t ret = kFALSE;
+
+    if( isalpha( c ) || c == '_') ret = kTRUE;
+
+    return ret;
+}
+
+
+//______________________________________________________________________________
+void MHtml::MakeAll( Bool_t force )
+{
+// It makes everything
+//
+
+    Int_t i;
+
+    MakeIndex();
+
+    Int_t numberOfClasses    = gClassTable->Classes();
+    const char **className = new const char* [numberOfClasses];
+
+    // start from begining
+    gClassTable->Init();
+
+
+    for( i = 0; i < numberOfClasses; i++ )
+        className[i] = gClassTable->Next();
+
+    for( i = 0; i < numberOfClasses; i++ ) {
+        sprintf( fCounter, "%5d", numberOfClasses - i );
+        MakeClass( (char * ) className[i], force );
+    }
+
+    *fCounter = 0;
+
+    delete [] className;
+}
+
+
+//______________________________________________________________________________
+void MHtml::MakeClass(const char *className, Bool_t force )
+{
+// Make HTML files for a single class
+//
+//
+// Input: className - name of the class to process
+//
+
+    TClass *classPtr = GetClass( className );
+
+    if( classPtr ) {
+        char *htmlFile = GetHtmlFileName( classPtr );
+        if( htmlFile && !strncmp( htmlFile, "http://", 7 )) {
+           delete [] htmlFile;
+           htmlFile = 0;
+        }
+        if( htmlFile ) {
+            Class2Html( classPtr, force );
+            MakeTree( className, force );
+            delete [] htmlFile;
+            htmlFile = 0;
+        }
+        else Printf( formatStr, "-skipped-", fCounter, className );
+    }
+    else Error( "MakeClass", "Unknown class '%s' !", className );
+
+}
+
+
+//______________________________________________________________________________
+void MHtml::MakeIndex()
+{
+   // It makes an index files
+
+   CreateListOfTypes();
+
+   // get total number of classes
+   Int_t numberOfClasses = gClassTable->Classes();
+
+
+   // allocate memory
+   const char **classNames = new const char *[numberOfClasses];
+   char       **fileNames  = new       char *[numberOfClasses];
+
+   // start from begining
+   gClassTable->Init();
+
+   // get class names
+   Int_t len = 0;
+   Int_t maxLen = 0;
+   Int_t numberOfImpFiles = 0;
+
+   for( Int_t i = 0; i < numberOfClasses; i++ ) {
+
+      // get class name
+      classNames[i] = gClassTable->Next();
+      len    = strlen( classNames[i] );
+      maxLen = maxLen > len ? maxLen : len;
+
+      // get class & filename
+      TClass *classPtr = GetClass( (const char * ) classNames[i] );
+      const char *impname = classPtr->GetImplFileName();
+
+      if( impname ) {
+         fileNames[numberOfImpFiles] = StrDup( impname, 64 );
+
+         char *underline = strchr( fileNames[numberOfImpFiles], '_');
+         if( underline )
+            strcpy( underline + 1, classNames[i] );
+         else {
+            // for new ROOT install the impl file name has the form: base/src/TROOT.cxx
+            char *srcdir = strstr(fileNames[numberOfImpFiles], "/src/");
+            if (srcdir) {
+               strcpy(srcdir, "_");
+               for (char *t = fileNames[numberOfImpFiles]; (t[0] = toupper(t[0])); t++) ;
+               strcat(srcdir, classNames[i]);
+            } else {
+               strcpy( fileNames[i], "USER_" );
+               strcat( fileNames[i], classNames[i] );
+            }
+         }
+         numberOfImpFiles++;
+      }
+      else cout << "WARNING class:" << classNames[i] << " has no implementation file name !" << endl;
+   }
+   maxLen += kSpaceNum;
+
+   // quick sort
+   SortNames( classNames, numberOfClasses );
+   SortNames( (const char ** ) fileNames,  numberOfImpFiles );
+
+   // create an index
+   CreateIndex( classNames, numberOfClasses );
+   CreateIndexByTopic( fileNames, numberOfClasses, maxLen );
+
+   // free allocated memory
+   delete [] classNames;
+   delete [] fileNames;
+}
+
+
+//______________________________________________________________________________
+void MHtml::MakeTree(const char *className, Bool_t force )
+{
+// Make an inheritance tree
+//
+//
+// Input: className - name of the class to process
+//
+
+    // create canvas & set fill color
+    TVirtualPad *psCanvas = 0;
+    gROOT->ProcessLineFast("new TCanvas(\"\",\"psCanvas\",0,0,1000,750);");
+    psCanvas = gPad->GetVirtCanvas();
+
+    TClass *classPtr = GetClass( className );
+
+    if( classPtr ) {
+
+        char *htmlFile = GetHtmlFileName( classPtr );
+        if( htmlFile && !strncmp( htmlFile, "http://", 7 )) {
+           delete [] htmlFile;
+           htmlFile = 0;
+        }
+        if( htmlFile ) {
+
+            // make a class tree
+            ClassTree( psCanvas, classPtr, force );
+            delete [] htmlFile;
+            htmlFile = 0;
+        }
+        else Printf( formatStr, "-skipped-", "", className );
+
+    }
+    else Error( "MakeTree", "Unknown class '%s' !", className );
+
+    // close canvas
+    psCanvas->Close();
+    delete psCanvas;
+
+}
+
+
+//______________________________________________________________________________
+void MHtml::ReplaceSpecialChars( ofstream &out, const char c )
+{
+// Replace ampersand, less-than and greater-than character
+//
+//
+// Input: out - output file stream
+//        c   - single character
+//
+
+    if (fEscFlag) {
+      out << c;
+      fEscFlag = kFALSE;
+    }
+    else if (c == fEsc)
+      fEscFlag = kTRUE;
+    else
+    {
+      switch( c ) {
+          case '<':
+              out << "&lt;";
+              break;
+          case '&':
+              out << "&amp;";
+              break;
+          case '>':
+              out << "&gt;";
+              break;
+          default:
+             out << c;
+       }
+    }
+}
+
+
+//______________________________________________________________________________
+void MHtml::ReplaceSpecialChars( ofstream &out, const char *string )
+{
+// Replace ampersand, less-than and greater-than characters
+//
+//
+// Input: out    - output file stream
+//        string - pointer to an array of characters
+//
+
+    if( string ) {
+        char *data  = StrDup( string );
+        if( data ) {
+            char *ptr   = NULL;
+            char *start = data;
+
+            while (( ptr = strpbrk( start, "<&>" ))) {
+               char c = *ptr;
+               *ptr = 0;
+               out << start;
+               ReplaceSpecialChars( out, c );
+               start = ptr+1;
+            }
+            out << start;
+            delete [] data;
+        }
+    }
+}
+
+//______________________________________________________________________________
+void MHtml::SortNames( const char **strings, Int_t num, Bool_t type )
+{
+// Sort strings
+//
+//
+// Input: strings - pointer to an array of strings
+//        type    - sort type
+//                  values : kCaseInsensitive, kCaseSensitive
+//                  default: kCaseInsensitive
+//
+
+    if( type == kCaseSensitive )
+        qsort( strings, num, sizeof( strings ), CaseSensitiveSort );
+    else
+        qsort( strings, num, sizeof( strings ), CaseInsensitiveSort );
+}
+
+
+//______________________________________________________________________________
+char *MHtml::StrDup( const char *s1, Int_t n )
+{
+// Returns a pointer to a new string which is a duplicate
+// of the string to which 's1' points.  The space for the
+// new string is obtained using the 'new' operator. The new
+// string has the length of 'strlen(s1) + n'.
+
+
+   char *str = 0;
+
+   if( s1 ) {
+       if( n < 0 ) n = 0;
+       str = new char[ strlen( s1 ) + n + 1 ];
+       if( str ) strcpy( str, s1 );
+   }
+
+   return( str );
+}
+
+//______________________________________________________________________________
+void MHtml::WriteHtmlHeader( ofstream &out, const char *title )
+{
+// Write HTML header
+//
+//
+// Input: out   - output file stream
+//        title - title for the HTML page
+//
+
+    TDatime date;
+
+    out << "<!DOCTYPE HTML PUBLIC \"-// IETF/DTD HTML 2.0// EN\">" << endl;
+    out << "<html>" << endl;
+    out << "<!--                                             -->" << endl;
+    out << "<!-- Author: ROOT team (rootdev@hpsalo.cern.ch)  -->" << endl;
+    out << "<!--                                             -->" << endl;
+    out << "<!--   Date: "<< date.AsString() << "            -->" << endl;
+    out << "<!--                                             -->" << endl;
+    out << "<head>" << endl;
+    out << "<title>";
+    ReplaceSpecialChars( out, title );
+    out << "</title>" << endl;
+    out << "<link rev=made href=\"mailto:rootdev@root.cern.ch\">" << endl;
+    out << "<meta name=\"rating\" content=\"General\">" << endl;
+    out << "<meta name=\"objecttype\" content=\"Manual\">" << endl;
+    out << "<meta name=\"keywords\" content=\"software development, oo, object oriented, ";
+    out << "unix, x11, windows, c++, html, rene brun, fons rademakers\">" << endl;
+    out << "<meta name=\"description\" content=\"ROOT - An Object Oriented Framework For Large Scale Data Analysis.\">" << endl;
+    out << "</head>" << endl;
+
+    out << "<body BGCOLOR=\"#ffffff\" LINK=\"#0000ff\" VLINK=\"#551a8b\" ALINK=\"#ff0000\" TEXT=\"#000000\">" << endl;
+    out << "<a name=\"TopOfPage\"></a>" << endl;
+}
+
+
+//______________________________________________________________________________
+void MHtml::WriteHtmlFooter( ofstream &out, const char *dir, const char *lastUpdate,
+                             const char *author, const char *copyright )
+{
+// Write HTML footer
+//
+//
+// Input: out        - output file stream
+//        dir        - usually equal to "" or "../", depends of
+//                     current file directory position, i.e. if
+//                     file is in the fOutputDir, then dir will be ""
+//        lastUpdate - last update string
+//        author     - author's name
+//        copyright  - copyright note
+//
+
+    out << endl;
+
+    if( *author || *lastUpdate || *copyright ) out << "<hr><br>" << endl;
+
+    out << "<!--SIGNATURE-->" << endl;
+
+    // get the author( s )
+    if( *author )  {
+
+        out << "<em>Author: ";
+
+        char *auth = StrDup(author);
+
+        char *name = strtok( auth, "," );
+
+        Bool_t firstAuthor = kTRUE;
+
+        do {
+            char *ptr = name;
+            char c;
+
+            // remove leading spaces
+            while( *ptr && isspace( *ptr ) ) ptr++;
+
+            if( !firstAuthor ) out << ", ";
+
+            if( !strncmp( ptr, "Nicolas", 7 ) ) {
+                out << "<a href=http://pcbrun.cern.ch/nicolas/index.html";
+                ptr += 12;
+            } else {
+                out << "<a href="<<GetXwho();
+            }
+            while( *ptr ) {
+                // Valery's specific case
+                if( !strncmp( ptr, "Valery", 6 ) ) {
+                    out << "Valeri";
+                    ptr += 6;
+                }
+                else if( !strncmp( ptr, "Fine", 4 ) ) {
+                    out << "Faine";
+                    ptr += 4;
+                }
+                while( *ptr && !isspace( *ptr ) )
+                    out << *ptr++;
+
+                if( isspace( *ptr ) ) {
+                    while( *ptr && isspace( *ptr ) ) ptr++;
+                    if( isalpha( *ptr) ) out << '+';
+                    else break;
+                }
+                else break;
+            }
+            c = *ptr;
+            *ptr = 0;
+            out << ">" << name << "</a>";
+            *ptr = c;
+            out << ptr;
+
+            firstAuthor = kFALSE;
+
+        } while (( name = strtok( NULL, "," )));
+        out << "</em><br>" << endl;
+        delete [] auth;
+    }
+
+    if( *lastUpdate ) out << "<em>Last update: " << lastUpdate << "</em><br>" << endl;
+    if( *copyright )  out << "<em>Copyright " << copyright << "</em><br>" << endl;
+
+
+    // this is a menu
+    out << "<br>" << endl;
+    out << "<address>" << endl;
+    out << "<hr>" << endl;
+    out << "<center>" << endl;
+
+    // link to the ROOT home page
+    out << "<a href=\"http://root.cern.ch/root/Welcome.html\">ROOT page</a> - ";
+
+    // link to the user home page( if exist )
+    const char *userHomePage = gEnv->GetValue( "Root.Html.HomePage", "" );
+    if( *userHomePage ) {
+        out << "<a href=\"";
+        if( *dir ) {
+            if( strncmp( userHomePage, "http://", 7 ))
+                out << dir;
+        }
+        out << userHomePage;
+        out << "\">Home page</a> - ";
+    }
+
+    // link to the index file
+    out << "<a href=\"";
+    if( *dir ) out << dir;
+    out << "ClassIndex.html\">Class index</a> - ";
+
+    // link to the top of the page
+    out << "<a href=\"#TopOfPage\">Top of the page</a><br>" << endl;
+
+    out << "</center>" << endl;
+
+    out << "<hr>This page has been automatically generated. If you have any comments or suggestions ";
+    out << "about the page layout send a mail to <a href=\"mailto:rootdev@root.cern.ch\">ROOT support</a>, or ";
+    out << "contact <a href=\"mailto:rootdev@root.cern.ch\">the developers</a> with any questions or problems regarding ROOT." << endl;
+    out << "</address>" << endl;
+    out << "</body>" << endl;
+    out << "</html>" << endl;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MHtml.h	(revision 1638)
@@ -0,0 +1,91 @@
+// @(#)root/html:$Name: not supported by cvs2svn $:$Id: MHtml.h,v 1.3 2001-10-31 13:46:12 tbretz Exp $
+// Author: Nenad Buncic   18/10/95
+
+/*************************************************************************
+ * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
+ * All rights reserved.                                                  *
+ *                                                                       *
+ * For the licensing terms see $ROOTSYS/LICENSE.                         *
+ * For the list of contributors see $ROOTSYS/README/CREDITS.             *
+ *************************************************************************/
+
+#ifndef MARS_MHtml
+#define MARS_MHtml
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// THtml                                                                  //
+//                                                                        //
+// Html makes a documentation for all ROOT classes                        //
+// using Hypertext Markup Language 2.0                                    //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+
+class TClass;
+class TVirtualPad;
+
+
+class MHtml : public TObject {
+
+private:
+    TString      fXwho;            // by default http://xwho.cern.ch/WHO/people?
+  const char    *fSourcePrefix;    // prefix to relative source path
+  const char    *fSourceDir;       // source path
+  const char    *fOutputDir;       // output directory
+        char    *fLine;            // current line
+        Int_t    fLen;             // maximum line length
+        char    *fCounter;         // counter string
+        Bool_t   fEscFlag;         // Flag to mark the symbol must be written "as is"
+        char     fEsc;             // The special symbol ("backslash" by default) to mark "the next symbol should not be converted
+
+        void    Class2Html(TClass *classPtr, Bool_t force=kFALSE);
+        void    ClassDescription(ofstream &out, TClass *classPtr, Bool_t &flag);
+        void    ClassTree(TVirtualPad *canvas, TClass *classPtr, Bool_t force=kFALSE);
+        Bool_t  CopyHtmlFile(const char *sourceName, const char *destName="");
+        void    CreateIndex(const char **classNames, Int_t numberOfClasses);
+        void    CreateIndexByTopic(char **filenames, Int_t numberOfNames, Int_t maxLen);
+        void    CreateListOfTypes();
+        void    DerivedClasses(ofstream &out, TClass *classPtr);
+        void    ExpandKeywords(ofstream &out, char *text, TClass *ptr2class, Bool_t &flag, const char *dir="");
+        void    ExpandPpLine(ofstream &out, char *line);
+   TClass      *GetClass(const char *name, Bool_t load=kTRUE);
+  const char   *GetFileName(const char *filename);
+        char   *GetSourceFileName(const char *filename);
+        char   *GetHtmlFileName(TClass *classPtr);
+        Bool_t  IsModified(TClass *classPtr, const Int_t type);
+        Bool_t  IsName(Int_t c);
+        Bool_t  IsWord(Int_t c);
+        void    ReplaceSpecialChars(ofstream &out, const char c);
+        void    ReplaceSpecialChars(ofstream &out, const char *string);
+        void    SortNames(const char **strings, Int_t num, Bool_t type=0);
+        char   *StrDup(const char *s1, Int_t n = 1);
+
+   friend Int_t CaseSensitiveSort(const void *name1, const void *name2);
+   friend Int_t CaseInsensitiveSort(const void *name1, const void *name2);
+
+public:
+                 MHtml();
+       virtual   ~MHtml();
+          void   Convert(const char *filename, const char *title, const char *dirname = "");
+    const char  *GetSourceDir()  { return fSourceDir; }
+    const char  *GetOutputDir()  { return fOutputDir; }
+    const char  *GetXwho() const { return fXwho.Data(); }
+          void   MakeAll(Bool_t force=kFALSE);
+          void   MakeClass(const char *className, Bool_t force=kFALSE);
+          void   MakeIndex();
+          void   MakeTree(const char *className, Bool_t force=kFALSE);
+          void   SetEscape(char esc='\\') { fEsc = esc; }
+          void   SetSourcePrefix(const char *prefix) { fSourcePrefix = prefix; }
+          void   SetSourceDir(const char *dir) { fSourceDir = dir; }
+          void   SetOutputDir(const char *dir) { fOutputDir = dir; }
+          void   SetXwho(const char *xwho) { fXwho = xwho; }
+   virtual void  WriteHtmlHeader(ofstream &out, const char *title);
+   virtual void  WriteHtmlFooter(ofstream &out, const char *dir="", const char *lastUpdate="",
+                                 const char *author="", const char *copyright="");
+
+   ClassDef(MHtml,0)  //Convert class(es) into HTML file(s)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.cc	(revision 1638)
@@ -0,0 +1,51 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MInpuStreamID                                                            //
+//                                                                          //
+// This is a ID which is assigned to tasks and to a task list.              //
+// It depends on this ID whether a task is executed by the                  //
+// MTaskList::Process member funtion or not.                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MInputStreamID.h"
+
+ClassImp(MInputStreamID);
+
+// --------------------------------------------------------------------------
+//
+// (default) constructor
+//
+MInputStreamID::MInputStreamID(const char *name, const char *title)
+{
+    fName = name ? name : ClassName();
+    fTitle = title;
+
+    fStreamId = "All";
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MInputStreamID.h	(revision 1638)
@@ -0,0 +1,44 @@
+#ifndef MARS_MInputStreamID
+#define MARS_MInputStreamID
+
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MInpuStreamID                                                     //
+//                                                                   //
+// Assigns an ID to tasks or a task list                             //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+// -----------------------------------------------------------------------
+
+class MInputStreamID : public MParContainer
+{
+private:
+    TString fStreamId;	//! which type of task should be processed?
+
+public:
+    MInputStreamID(const char *name=NULL, const char *title=NULL);
+
+    const TString &GetStreamId() const { return fStreamId; }
+    void SetStreamId(const char *t)    { fStreamId = t; }
+
+    Bool_t operator==(MInputStreamID &id) const
+    {
+        return fStreamId == id.fStreamId;
+    }
+
+    Bool_t operator!=(MInputStreamID &id) const
+    {
+        return fStreamId != id.fStreamId;
+    }
+
+    ClassDef(MInputStreamID, 0)	//Assigns an Id to tasks or a task list
+};
+
+// ---------------------------------------------------------------------
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.cc	(revision 1638)
@@ -0,0 +1,65 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MIter                                                                    //
+//                                                                          //
+// This is the original MIter, but returns a MParContainer instead of a     //
+// TObject.                                                                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MIter.h"
+
+ClassImp(MIter);
+
+//______________________________________________________________________________
+MIter::MIter(const MIter &iter)
+{
+   // Copy a MIter. This involves allocating a new MIterator of the right
+   // sub class and assigning it with the original.
+
+   if (iter.fIterator) {
+      fIterator = iter.GetCollection()->MakeIterator();
+      fIterator->operator=(*iter.fIterator);
+   } else
+      fIterator = 0;
+}
+
+//______________________________________________________________________________
+MIter &MIter::operator=(const MIter &rhs)
+{
+   // Assigning an MIter to another. This involves allocatiing a new MIterator
+   // of the right sub class and assigning it with the original.
+
+   if (this != &rhs) {
+      if (rhs.fIterator) {
+         delete fIterator;
+         fIterator = rhs.GetCollection()->MakeIterator();
+         fIterator->operator=(*rhs.fIterator);
+      }
+   }
+   return *this;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MIter.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MIter
+#define MARS_MIter
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MIter                                                                   //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TIterator
+#include <TIterator.h>
+#endif
+
+class MParContainer;
+
+class MIter
+{
+private:
+   TIterator *fIterator;         //collection iterator
+
+protected:
+   MIter() : fIterator(0) { }
+
+public:
+   MIter(const TCollection *col, Bool_t dir = kIterForward)
+        : fIterator(col ? col->MakeIterator(dir) : 0) { }
+   MIter(TIterator *it) : fIterator(it) { }
+   MIter(const MIter &iter);
+   MIter &operator=(const MIter &rhs);
+   virtual            ~MIter() { SafeDelete(fIterator) }
+   MParContainer     *operator()() { return (MParContainer*)(fIterator ? fIterator->Next() : 0); }
+   MParContainer     *Next() { return (MParContainer*)(fIterator ? fIterator->Next() : 0); }
+   const TCollection *GetCollection() const { return fIterator ? fIterator->GetCollection() : 0; }
+   Option_t          *GetOption() const { return fIterator ? fIterator->GetOption() : ""; }
+   void               Reset() { if (fIterator) fIterator->Reset(); }
+
+   ClassDef(MIter,0)  //Iterator wrapper
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.cc	(revision 1638)
@@ -0,0 +1,253 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MLog                                                                     //
+//                                                                          //
+// This is what we call the logging-system.                                 //
+//                                                                          //
+// It is derived from the C++ streaming classes and can handle our          //
+// logging. The log output can be redirected to stdout, stderr, any other   //
+// stream or a root window.                                                 //
+//                                                                          //
+// There is a global log-instance which you can use like cout, id is gLog.  //
+// A log-instance of your choice (gLog by default) is destributed to all    //
+// Task which are used in an eventloop, so that you can redirect the output //
+// of one eventloop to where you want..                                     //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MLog.h"
+
+#include <stdlib.h>     // mkstempe
+#include <fstream.h>
+#include <TGListBox.h>
+
+#include "MLogManip.h"
+
+ClassImp(MLog);
+
+// root 3.02:
+// check for TObjectWarning, TObject::Info, gErrorIgnoreLevel
+
+//
+// This is the definition of the global log facility
+//
+MLog gLog;
+
+// --------------------------------------------------------------------------
+//
+// this strange usage of an unbufferd buffer is a workaround
+// to make it work on Alpha and Linux!
+//
+void MLog::Init()
+{
+    setp(&fBuffer, &fBuffer+1);
+    *this << '\0';
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the device
+// which is used for the output (i)
+//
+MLog::MLog(int i) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(i), fIsNull(kFALSE), fGuiLineId(0), fout(NULL), fOutAllocated(kFALSE), fgui(NULL)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the given
+// ofstream as the default output device
+//
+MLog::MLog(ofstream &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fGuiLineId(0),  fout(&out), fOutAllocated(kFALSE), fgui(NULL)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the given
+// TGListBox as the default output device
+//
+MLog::MLog(TGListBox &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eGui), fGuiLineId(0),  fout(NULL), fOutAllocated(kFALSE), fgui(&out)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and opens a file with
+// the given name. Dependend on the flag the file is set as output device
+// or not.
+//
+MLog::MLog(const char *fname, int flag) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fGuiLineId(0),  fgui(NULL)
+{
+    Init();
+
+    AllocateFile(fname);
+    CheckFlag(eFile, flag);
+}
+
+// --------------------------------------------------------------------------
+//
+// copyt constructor
+//
+MLog::MLog(MLog &log)
+{
+    fOutputLevel  = log.fOutputLevel;
+    fDebugLevel   = log.fDebugLevel;
+    fDevice       = log.fDevice;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is the function which writes the stream physically to a device.
+// If you want to add a new device this must be done here.
+//
+void MLog::WriteBuffer()
+{
+    //
+    // restart writing to the buffer at its first char
+    //
+    const int len = fPPtr - fBase;
+
+    fPPtr = fBase;
+
+    if (fIsNull)
+        return;
+
+    if (fDevice&eStdout)
+        cout.write(fBase, len);
+
+    if (fDevice&eStderr)
+        cerr.write(fBase, len);
+
+    if (fDevice&eFile && fout)
+        fout->write(fBase, len);
+
+    if (fDevice&eGui && fgui)
+    {
+        char *dummy = new char[len];
+        memcpy(dummy, fBase, len-1);
+        *(dummy+len-1)='\0';
+        fgui->AddEntry(dummy, fGuiLineId);
+        fgui->SetTopEntry(fGuiLineId++);
+        fgui->SetBit(kHasChanged);
+        delete dummy;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// This is called to flush the buffer of the streaming devices
+//
+int MLog::sync()
+{
+    WriteBuffer();
+
+    if (fDevice&eStdout)
+        cout.flush();
+
+    if (fDevice&eStderr)
+        cerr.flush();
+
+    if (fDevice&eFile && fout)
+        fout->flush();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function comes from streambuf and should
+// output the buffer to the device (flush, endl)
+// or handle a buffer overflow (too many chars)
+// If a real overflow happens i contains the next
+// chars which doesn't fit into the buffer anymore.
+// If the buffer is not really filled i is EOF(-1).
+//
+int MLog::overflow(int i) // i=EOF means not a real overflow
+{
+    //
+    // no output if
+    //
+    if (fOutputLevel > fDebugLevel)
+        return 0;
+
+    *fPPtr++ = (char)i;
+
+    if (fPPtr == fEPtr)
+        WriteBuffer();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Create a new instance of an file output stream
+// an set the corresponding flag
+//
+void MLog::AllocateFile(const char *fname)
+{
+    fout = fname ? new ofstream(fname) : new ofstream(mkstemp("logXXXXXX"));
+    fOutAllocated = kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// if fout was allocated by this instance of MLooging
+// delete it.
+//
+void MLog::DeallocateFile()
+{
+    if (fOutAllocated)
+        delete fout;
+}
+
+// --------------------------------------------------------------------------
+//
+// if necessary delete the old in stance of the file
+// output stream and create a new one
+//
+void MLog::ReallocateFile(const char *fname)
+{
+    DeallocateFile();
+    AllocateFile(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// This function checks if a device should get enabled or disabled.
+//
+void MLog::CheckFlag(Flags_t chk, int flag)
+{
+    if (flag==-1)
+        return;
+
+    flag ? EnableOutputDevice(chk) : DisableOutputDevice(chk);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLog.h	(revision 1638)
@@ -0,0 +1,131 @@
+#ifndef MARS_MLog
+#define MARS_MLog
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+
+#include <iostream.h>  // base classes for MLog
+
+#define bsz    160 // two standard lines
+
+enum ELogBits {
+   kHasChanged = BIT(14)  // if gui has changed
+};
+
+
+class TGListBox;
+
+class MLog : public streambuf, public ostream, public TObject
+{
+public:
+    typedef enum _flags { eStdout = 0x1, eStderr = 0x2, eFile = 0x4, eGui = 0x8 } Flags_t;
+
+private:
+    char        fBuffer;     //!
+    char        fBase[bsz];  //! Buffer to store the data in
+    char       *fPPtr;       //! Pointer to present position in buffer
+    const char *fEPtr;       //! Pointer to end of buffer
+
+    UInt_t fOutputLevel;     //! Present output level of the stream
+    UInt_t fDebugLevel;      //! Present global debug level
+    UInt_t fDevice;          //! Flag to indicate the present streams
+
+    Bool_t fIsNull;          //! Switch output completely off
+
+    Int_t fGuiLineId;
+
+    ofstream  *fout;          //! possible file output stream
+    Bool_t     fOutAllocated; //! flag if fout is created by MLogging
+    TGListBox *fgui;          //! Listbox output
+
+    void Init();
+
+    void WriteBuffer();
+    int sync();
+    int overflow(int i); // i=EOF means not a real overflow
+
+    void AllocateFile(const char *f);
+    void DeallocateFile();
+    void ReallocateFile(const char *f);
+    void CheckFlag(Flags_t chk, int flag);
+
+public:
+    MLog(int i=eStdout);
+    MLog(ofstream &out);
+    MLog(TGListBox &out);
+    MLog(const char *fname, int flag=-1);
+
+    MLog(MLog &log);
+
+    ~MLog()
+    {
+        DeallocateFile();
+    }
+
+    void SetDebugLevel(int i)           { fDebugLevel  =  i;  }
+    void SetOutputLevel(int i)          { fOutputLevel =  i;  }
+    void SetOutputDevice(int i)         { fDevice      =  i;  }
+    void EnableOutputDevice(Flags_t f)  { fDevice     |=  f;  }
+    void DisableOutputDevice(Flags_t f) { fDevice     &= ~f;  }
+    void operator=(ofstream &out)       { SetOutputFile(out); }
+    void operator=(TGListBox *out)      { SetOutputGui(out);  }
+
+    Bool_t IsOutputDeviceEnabled(int i) const { return fDevice & i; }
+
+    void SetOutputGui(TGListBox *out, int flag=-1)
+    {
+        fgui = out;
+        CheckFlag(eGui, flag);
+    }
+
+    void SetOutputFile(ofstream &out, int flag=-1)
+    {
+        //
+        // Set new output file by a given stream. The new output
+        // file is not deleted automatically. If no flag is specified
+        // the state of the file-device stream is unchanged.
+        // if the a flag is specified the state is changed
+        // in correspondance to the flag
+        //
+        DeallocateFile();
+        fout = &out;
+        CheckFlag(eFile, flag);
+    }
+
+    void SetOutputFile(const char *f=NULL, int flag=-1)
+    {
+        //
+        // Set new output file by name. The new output file must
+        // not be deleted by the user. If no flag is specified
+        // the state of the file-device stream is unchanged.
+        // if the a flag is specified the state is changed
+        // in correspondance to the flag
+        //
+        ReallocateFile(f);
+        CheckFlag(eFile, flag);
+    }
+
+    ofstream &GetOutputFile()
+    {
+        //
+        // Get the file output stream from MLogging
+        // if no file output stream is existing yet it will be created.
+        // For the creating a C-Temporary file name is used.
+        // if the stream is created here the user must not delete it
+        //
+        // What a pitty, but it seems, that there is now way to ask
+        // an ofstream for the corresponding file name. Elsewhise
+        // I would implement a GetFileName-function, too.
+        //
+        if (!fout)
+            ReallocateFile(NULL);
+        return *fout;
+    }
+
+    void SetNullOutput(Bool_t n=kTRUE) { fIsNull = n; }
+
+    ClassDef(MLog, 0) // This is what we call 'The logging system'
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.cc	(revision 1638)
@@ -0,0 +1,109 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+// ----------------------------------------------------------------
+//            Definitions of the manipulator functions
+// ----------------------------------------------------------------
+
+ostream& __omanip_debug(ostream& lout, int i)
+{
+    //
+    // get the streambuf of the stream
+    // get the pointer to the parent class by casting
+    // set the output level of the logging stream
+    //
+    // Be careful: This manipulator can only be used in MLogging
+    // streams - in other streams SetOutputLevel is a call
+    // of a non existing function
+    //
+    // Be careful 2: The change is valid for everything which is
+    // in the present buffer. This means it can also affect a
+    // part of the stream which is already in the stream but not flushed
+    // to the output device. A flush occures either if you tell a stream
+    // to flush (flush, endl) or if an buffer overflow occures, the
+    // last behaviour could be changed if someone want to have a dynamic
+    // buffer.
+    //
+    MLog *log=(MLog*)lout.rdbuf();
+//    cout << " -" << i << "- ";
+    log->SetOutputLevel(i);
+    return lout;
+}
+
+ostream& __omanip_device(ostream& lout, int i)
+{
+    //
+    // get the streambuf of the stream
+    // get the pointer to the parent class by casting
+    // set the output device of the logging stream, more than
+    // one output device can be ored together
+    //
+    // Be careful: This manipulator can only be used in MLogging
+    // streams - in other streams SetOutputLevel is a call
+    // of a non existing function
+    //
+    MLog *log=(MLog*)lout.rdbuf();
+    log->SetOutputDevice(i);
+    return lout;
+}
+
+ostream& __omanip_edev(ostream& lout, int i)
+{
+    //
+    // get the streambuf of the stream
+    // get the pointer to the parent class by casting
+    // Enable an output device of the logging stream, it should
+    // be possible to enable more than one output device at the
+    // same time by oring them together
+    //
+    // Be careful: This manipulator can only be used in MLogging
+    // streams - in other streams SetOutputLevel is a call
+    // of a non existing function
+    //
+    MLog *log=(MLog*)lout.rdbuf();
+    log->EnableOutputDevice((MLog::_flags)i);
+    return lout;
+}
+
+ostream& __omanip_ddev(ostream& lout, int i)
+{
+    //
+    // get the streambuf of the stream
+    // get the pointer to the parent class by casting
+    // Disable an output device of the logging stream, it should
+    // be possible to disable more than one output device at the
+    // same time by oring them together
+    //
+    // Be careful: This manipulator can only be used in MLogging
+    // streams - in other streams SetOutputLevel is a call
+    // of a non existing function
+    //
+    MLog *log=(MLog*)lout.rdbuf();
+    log->DisableOutputDevice((MLog::_flags)i);
+    return lout;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogManip.h	(revision 1638)
@@ -0,0 +1,93 @@
+#ifndef MARS_MLogManip
+#define MARS_MLogManip
+
+#include <iomanip.h>
+
+// ----------------------------------------------------------------
+//                 Definitions of the manipulators
+// ----------------------------------------------------------------
+
+//
+// define a general simple macro for manipulator definitions (int)
+//
+#ifndef OMANIP
+
+#define MANIPULATOR(name) \
+    extern ostream& __omanip_##name(ostream& lout, int i); \
+    inline omanip<int> ##name(int i)                \
+    {                                               \
+        return omanip<int>(__omanip_##name, i);    \
+    }
+
+#else
+
+#define MANIPULATOR(name) \
+    extern ostream& __omanip_##name(ostream& lout, int i); \
+    inline OMANIP(int) ##name(int i)                \
+    {                                               \
+        return OMANIP(int)(__omanip_##name, i);    \
+    }
+
+#endif
+//
+// definitions
+//
+MANIPULATOR(debug);    // set debug level
+MANIPULATOR(device);   // set ouput devices
+MANIPULATOR(edev);     // enable additional output devices
+MANIPULATOR(ddev);     // disable given output
+//#ifndef __CINT__
+//__DEFINE_IOMANIP_FN1(smanip, int, debug);    // set debug level
+//__DEFINE_IOMANIP_FN1(smanip, int, device);   // set ouput devices
+//__DEFINE_IOMANIP_FN1(smanip, int, edev);     // enable additional output devices
+//__DEFINE_IOMANIP_FN1(smanip, int, ddev);     // disable given output
+//#endif
+
+// ----------------------------------------------------------------
+//                         Debug helper macros
+// ----------------------------------------------------------------
+
+//
+// Output debug information into the stream
+//  - this can only be done by a macro
+//
+#ifndef __CINT__
+#define dbginf      __FILE__ << " l." << dec << __LINE__ << ": "
+#define all    debug(0)
+#define err    debug(1)
+#define warn   debug(2)
+#define inf    debug(3)
+#endif
+//
+// flush the old buffer, set a new debug level
+// and output the debug information code
+//
+// Be careful: Only use them with a MLogging stream facility.
+// Remark:     All this is compiled into the code.
+//
+/*
+#ifndef __CINT__
+#define DEBUG(lvl)  flush << debug(lvl) << dbginf
+#endif
+*/
+/*
+class SMANIP(T) {
+    ios& (*fct)(ios&,T) ;
+    T arg ;
+public:
+    SMANIP(T)(ios& (*f)(ios&, T), T a) :
+        fct(f), arg(a) { }
+        friend istream& operator>>(istream& i, const SMANIP(T)& m)
+        {
+            ios* s = &i ;
+            (*m.fct)(*s,m.arg) ; return i ;
+        }
+        friend ostream& operator<<(ostream& o, const SMANIP(T)& m)
+        {
+            ios* s = &o ;
+            (*m.fct)(*s,m.arg) ; return o ;
+        }
+} ;
+*/
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.cc	(revision 1638)
@@ -0,0 +1,207 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  05/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MLogo                                                                    //
+//                                                                          //
+// X based logo displayer. Displays a given logo after a call to Popup()    //
+// until Popdown() or the destructor is called, but for a minimum of a      //
+// given number of milliseconds.                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MLogo.h"
+
+#include <unistd.h>    // usleep
+#include <iostream.h>  // cout
+#include <sys/time.h>  // gettimeofday
+
+#ifndef XpmSuccess
+#define XpmSuccess       0
+#endif
+#ifndef XpmColorError
+#define XpmColorError    1
+#endif
+
+MLogo::MLogo(int millisec)
+   : fDisplay(0), fLogoWindow(0), fLogoPixmap(0), fMilliSec(millisec)
+{
+    // millisec: time of minimum stayup
+}
+
+void MLogo::Wait() const
+{
+    struct timeval tv;
+
+    gettimeofday(&tv, 0);
+
+    tv.tv_sec  -= fPopupTime.tv_sec;
+    tv.tv_usec -= fPopupTime.tv_usec;
+
+    while (tv.tv_usec < 0)
+    {
+        tv.tv_usec += 1000000;
+        tv.tv_sec--;
+    }
+
+    while (tv.tv_sec > 0)
+        tv.tv_usec += 1000000;
+
+    long sleep = fMilliSec*1000-tv.tv_usec;
+
+    if (sleep <= 0)
+        return;
+
+    usleep(sleep);
+}
+
+Pixmap MLogo::GetLogo() const
+{
+#ifdef XpmVersion
+    int depth = PlanesOfScreen(XDefaultScreenOfDisplay(fDisplay));
+
+    if (depth <= 1)
+        return 0;
+
+    XWindowAttributes win_attr;
+    XGetWindowAttributes(fDisplay, fLogoWindow, &win_attr);
+
+    XpmAttributes attr;
+    attr.valuemask = XpmVisual | XpmColormap | XpmDepth;
+    attr.visual    = win_attr.visual;
+    attr.colormap  = win_attr.colormap;
+    attr.depth     = win_attr.depth;
+
+#ifdef XpmColorKey              // Not available in XPM 3.2 and earlier
+
+    switch (depth)
+    {
+    case 0:
+        attr.valuemask &= ~XpmColorKey;
+        break;
+    case 1:
+        attr.color_key = XPM_MONO;
+        break;
+    case 2:
+        attr.color_key = XPM_GRAY;
+        break;
+    case 3:
+    case 4:
+        attr.color_key = XPM_GRAY4;
+        break;
+    default:
+        attr.color_key = XPM_COLOR;
+    }
+#endif // defined(XpmColorKey)
+
+
+    Pixmap logo;
+#ifdef USE_MAGICLOGO
+#include "../magiclogo.xpm"
+    int ret = XpmCreatePixmapFromData(fDisplay, fLogoWindow,
+                                      mag1, &logo, 0, &attr);
+#else
+#include "../marslogo_neu.xpm"
+    int ret = XpmCreatePixmapFromData(fDisplay, fLogoWindow,
+                                      marslogo_neu_xpm, &logo, 0, &attr);
+#endif
+    XpmFreeAttributes(&attr);
+
+    if (ret == XpmSuccess || ret == XpmColorError)
+        return logo;
+
+    if (logo)
+        XFreePixmap(fDisplay, logo);
+#endif
+    return 0;
+}
+
+void MLogo::Popup()
+{
+#ifdef XpmVersion
+    if (fLogoWindow || fLogoPixmap || fDisplay)
+#endif
+        return;
+
+    fDisplay = XOpenDisplay("");
+    if (!fDisplay)
+        return;
+
+    int screen = DefaultScreen(fDisplay);
+
+    fLogoWindow = XCreateSimpleWindow(fDisplay, DefaultRootWindow(fDisplay),
+                                      -100, -100, 50, 50, 0,
+                                      BlackPixel(fDisplay, screen),
+                                      WhitePixel(fDisplay, screen));
+    fLogoPixmap = GetLogo();
+
+    Window root;
+    int x, y;
+    unsigned int w, h, bw, depth;
+    XGetGeometry(fDisplay, fLogoPixmap,
+                 &root, &x, &y, &w, &h, &bw, &depth);
+
+    Screen *xscreen = XDefaultScreenOfDisplay(fDisplay);
+    x = (WidthOfScreen(xscreen) - w) / 2;
+    y = (HeightOfScreen(xscreen) - h) / 2;
+
+    XMoveResizeWindow(fDisplay, fLogoWindow, x, y, w, h);
+    XSync(fDisplay, False);   // make sure move & resize is done before mapping
+
+    unsigned long valmask  = CWBackPixmap | CWOverrideRedirect;
+
+    XSetWindowAttributes xswa;
+    xswa.background_pixmap = fLogoPixmap;
+    xswa.override_redirect = True;
+    XChangeWindowAttributes(fDisplay, fLogoWindow, valmask, &xswa);
+
+    XMapRaised(fDisplay, fLogoWindow);
+    XSync(fDisplay, False);
+
+    gettimeofday(&fPopupTime, 0);
+}
+
+void MLogo::Popdown()
+{
+    if (fLogoWindow && fLogoPixmap && fDisplay)
+        Wait();
+
+    if (fLogoWindow)
+    {
+        XUnmapWindow(fDisplay, fLogoWindow);
+        XDestroyWindow(fDisplay, fLogoWindow);
+        fLogoWindow = 0;
+    }
+    if (fLogoPixmap)
+    {
+        XFreePixmap(fDisplay, fLogoPixmap);
+        fLogoPixmap = 0;
+    }
+    if (fDisplay)
+    {
+        XSync(fDisplay, False);
+        XCloseDisplay(fDisplay);
+        fDisplay = 0;
+    }
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MLogo.h	(revision 1638)
@@ -0,0 +1,35 @@
+#ifndef MARS_MLogo
+#define MARS_MLogo
+
+#ifndef __CINT__
+
+#include <X11/Xlib.h>
+
+#include "Xpm.h"
+
+class MLogo
+{
+    Display *fDisplay;         // display handle
+    Window   fLogoWindow;      // window handle
+    Pixmap   fLogoPixmap;      // pixmap handle
+    long     fMilliSec;        // stayup time
+
+    struct timeval fPopupTime; // time of popup
+
+    void   Wait() const;
+    Pixmap GetLogo() const;
+
+public:
+    MLogo(int millisec=777);
+    ~MLogo()
+    {
+        Popdown();
+    }
+
+    void Popup();
+    void Popdown();
+};
+
+#endif
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.cc	(revision 1638)
@@ -0,0 +1,446 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MParContainer                                                            //
+//                                                                          //
+// The MParContainer class is the base class for all MARS parameter         //
+// containers. At the moment it is almost the same than ROOT's TNamed.      //
+// A TNamed contains the essential elements (name, title)                   //
+// to identify a derived object in lists like our MParList or MTaskList.    //
+// The main difference is that the name and title isn't stored and read     //
+// to and from root files ("//!")                                           //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MParContainer.h"
+
+#include <ctype.h>       // isdigit
+#include <fstream.h>     // ofstream, AsciiWrite
+
+#include <TROOT.h>       // TROOT::Identlevel
+#include <TClass.h>      // IsA
+#include <TObjArray.h>   // TObjArray
+#include <TBaseClass.h>  // GetClassPointer
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+#include <TDataMember.h> // TDataMember, AsciiWrite
+#include <TVirtualPad.h> // gPad
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MEvtLoop.h"    // gListOfPrimitives
+
+ClassImp(MParContainer);
+
+// --------------------------------------------------------------------------
+//
+//  MParContainer copy ctor
+//
+MParContainer::MParContainer(const MParContainer &named)
+{
+    fName  = named.fName;
+    fTitle = named.fTitle;
+
+    fLog = named.fLog;
+
+    fReadyToSave = named.fReadyToSave;
+}
+
+// --------------------------------------------------------------------------
+//
+//  MParContainer assignment operator.
+//
+MParContainer& MParContainer::operator=(const MParContainer& rhs)
+{
+    if (this == &rhs)
+        return *this;
+
+    TObject::operator=(rhs);
+
+    fName  = rhs.fName;
+    fTitle = rhs.fTitle;
+
+    fLog = rhs.fLog;
+    fReadyToSave = rhs.fReadyToSave;
+
+    return *this;
+}
+
+// --------------------------------------------------------------------------
+//
+// Make a clone of an object using the Streamer facility.
+// If newname is specified, this will be the name of the new object
+//
+TObject *MParContainer::Clone(const char *newname) const
+{
+
+   MParContainer *named = (MParContainer*)TObject::Clone();
+   if (newname && strlen(newname)) named->SetName(newname);
+   return named;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Compare two MParContainer objects. Returns 0 when equal, -1 when this is
+//  smaller and +1 when bigger (like strcmp).
+//
+Int_t MParContainer::Compare(const TObject *obj) const
+{
+    if (this == obj) return 0;
+    return fName.CompareTo(obj->GetName());
+}
+
+// --------------------------------------------------------------------------
+//
+//  Copy this to obj.
+//
+void MParContainer::Copy(TObject &obj)
+{
+    MParContainer &cont = (MParContainer&)obj;
+
+    TObject::Copy(obj);
+
+    cont.fName  = fName;
+    cont.fTitle = fTitle;
+
+    cont.fLog = fLog;
+    cont.fReadyToSave = fReadyToSave;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Encode MParContainer into output buffer.
+//
+void MParContainer::FillBuffer(char *&buffer)
+{
+    fName.FillBuffer(buffer);
+    fTitle.FillBuffer(buffer);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a unique name for this container. It is created from
+//  the container name and the unique Id. (This is mostly used
+//  in the StreamPrimitive member functions)
+//
+const TString MParContainer::GetUniqueName() const
+{
+    TString ret = ToLower(fName);
+
+    if (isdigit(ret[ret.Length()-1]))
+        ret+="_";
+
+    ret+=GetUniqueID();
+
+    return ret;
+}
+
+// --------------------------------------------------------------------------
+//
+//  List MParContainer name and title.
+//
+void MParContainer::ls(Option_t *) const
+{
+    TROOT::IndentLevel();
+    *fLog << all << GetDescriptor() << " " << GetTitle() << ": kCanDelete=";
+    *fLog << Int_t(TestBit(kCanDelete)) << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print MParContainer name and title.
+//
+void MParContainer::Print(Option_t *) const
+{
+    *fLog << all << GetDescriptor() << " " << GetTitle() << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) the name of the MParContainer.
+//  WARNING !!
+//  If the object is a member of a THashTable, THashList container
+//  The HashTable must be Rehashed after SetName
+//  For example the list of objects in the current directory is a THashList
+//
+void MParContainer::SetName(const char *name)
+{
+    fName = name;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) all the MParContainer parameters (name and title).
+//  See also WARNING in SetName
+//
+void MParContainer::SetObject(const char *name, const char *title)
+{
+    fName  = name;
+    fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) the title of the MParContainer.
+//
+void MParContainer::SetTitle(const char *title)
+{
+    fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return size of the MParContainer part of the TObject.
+//
+Int_t MParContainer::Sizeof() const
+{
+    Int_t nbytes = fName.Sizeof() + fTitle.Sizeof();
+    return nbytes;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
+//  container, overload this function.
+//
+void MParContainer::AsciiRead(ifstream &fin)
+{
+    *fLog << warn << "To use the the ascii input of " << GetName();
+    *fLog << " you have to overload " << ClassName() << "::AsciiRead." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member given as a TDataMember object to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member, Double_t scale) const
+{
+    if (!member)
+        return kFALSE;
+
+    if (!member->IsPersistent() || member->Property()&kIsStatic)
+        return kFALSE;
+
+    /*const*/ TMethodCall *call = ((TDataMember*)member)->GetterMethod(); //FIXME: Root
+    if (!call)
+    {
+        *fLog << warn << "Sorry, no getter method found for " << member->GetName() << endl;
+        return kFALSE;
+    }
+
+    // For debugging: out << member->GetName() << ":";
+
+    switch (call->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        call->Execute((void*)this, l); // FIXME: const, root
+        out << l << " ";
+        return kTRUE;
+
+    case TMethodCall::kDouble:
+        Double_t d;
+        call->Execute((void*)this, d); // FIXME: const, root
+        out << (scale*d) << " ";
+        return kTRUE;
+
+    default:
+    //case TMethodCall::kString:
+    //case TMethodCall::kOther:
+        /* someone may want to enhance this? */
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member given by name to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const char *member, Double_t scale) const
+{
+    /*const*/ TClass *cls = IsA()->GetBaseDataMember(member);
+    if (!cls)
+        return kFALSE;
+
+    return WriteDataMember(out, cls->GetDataMember(member), scale);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member from a given TList of TDataMembers.
+//  returns kTRUE when at least one member was successfully written
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const TList *list) const
+{
+    Bool_t rc = kFALSE;
+
+    TDataMember *data = NULL;
+
+    TIter Next(list);
+    while ((data=(TDataMember*)Next()))
+        rc |= WriteDataMember(out, data);
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
+//  container, you may overload this function. If you don't overload it
+//  the data member of a class are written to the file in the order of
+//  appearance in the class header (be more specfic: root dictionary)
+//  Only data members which are of integer (Bool_t, Int_t, ...) or
+//  floating point (Float_t, Double_t, ...) type are written.
+//  returns kTRUE when at least one member was successfully written
+//
+Bool_t MParContainer::AsciiWrite(ostream &out) const
+{
+    // *fLog << warn << "To use the the ascii output of " << GetName();
+    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
+
+    Bool_t rc = WriteDataMember(out, IsA()->GetListOfDataMembers());
+
+    TIter NextBaseClass(IsA()->GetListOfBases());
+    TBaseClass *base;
+    while ((base = (TBaseClass*) NextBaseClass()))
+    {
+        /*const*/ TClass *cls = base->GetClassPointer();
+
+        if (!cls)
+            continue;
+
+        if (cls->GetClassVersion())
+            rc |= WriteDataMember(out, cls->GetListOfDataMembers());
+    }
+
+    return rc;
+}
+
+TMethodCall *MParContainer::GetterMethod(const char *name) const
+{
+    TClass *cls = IsA()->GetBaseDataMember(name);
+    if (cls)
+    {
+        TDataMember *member = cls->GetDataMember(name);
+        if (!member)
+        {
+            *fLog << err << "Datamember '" << name << "' not in " << GetDescriptor() << endl;
+            return NULL;
+        }
+
+        TMethodCall *call = member->GetterMethod();
+        if (call)
+            return call;
+    }
+
+    *fLog << warn << "No standard access for '" << name << "' in ";
+    *fLog << GetDescriptor() << " or one of its base classes." << endl;
+
+    TMethodCall *call = NULL;
+
+    *fLog << warn << "Trying to find MethodCall '" << IsA()->GetName();
+    *fLog << "::Get" << name << "' instead <LEAKS MEMORY>" << endl;
+    call = new TMethodCall(IsA(), (TString)"Get"+name, "");
+    if (call->GetMethod())
+        return call;
+
+    delete call;
+
+    *fLog << warn << "Trying to find MethodCall '" << IsA()->GetName();
+    *fLog << "::" << name << "' instead <LEAKS MEMORY>" << endl;
+    call = new TMethodCall(IsA(), name, "");
+    if (call->GetMethod())
+        return call;
+
+    delete call;
+
+    *fLog << err << "Sorry, no getter method found for " << name << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MParContainer::SavePrimitive(ofstream &out, Option_t *o)
+{
+    static UInt_t uid = 0;
+
+    if (IsSavedAsPrimitive())
+        return;
+
+    SetUniqueID(uid++);
+    SetBit(kIsSavedAsPrimitive);
+
+    if (gListOfPrimitives && !gListOfPrimitives->FindObject(this))
+        gListOfPrimitives->Add(this);
+
+    StreamPrimitive(out);
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates the string written by SavePrimitive and returns it.
+//
+void MParContainer::StreamPrimitive(ofstream &out) const
+{
+    out << "   // Using MParContainer::StreamPrimitive" << endl;
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << fName << "\", \"" << fTitle << "\");" << endl;
+}
+
+void MParContainer::GetNames(TObjArray &arr) const
+{
+    arr.AddLast(new TNamed(fName, fTitle));
+}
+
+void MParContainer::SetNames(TObjArray &arr)
+{
+    TNamed *name = (TNamed*)arr.First();
+
+    fName  = name->GetName();
+    fTitle = name->GetTitle();
+
+    delete arr.Remove(name);
+    arr.Compress();
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new instance of this class. The idea is to create a clone of
+// this class in its initial state.
+//
+MParContainer *MParContainer::New() const
+{
+    return (MParContainer*)IsA()->New();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParContainer.h	(revision 1638)
@@ -0,0 +1,122 @@
+#ifndef MARS_MParContainer
+#define MARS_MParContainer
+
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// MParContainer                                                        //
+//                                                                      //
+// The basis for all parameter containers                               //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+
+class ofstream;
+class ifstream;
+
+class TDataMember;
+class TMethodCall;
+
+class MParContainer : public TObject
+{
+protected:
+    TString fName;        // parameter container identifier (name)
+    TString fTitle;       // parameter container title
+
+    MLog   *fLog;         // The general log facility for this object, initialized with the global object
+
+private:
+    enum {
+        kIsSavedAsPrimitive = BIT(15)
+    };
+
+    Bool_t  fReadyToSave; // should be set to true if the contents of the container is changed somehow
+
+    virtual void StreamPrimitive(ofstream &out) const;
+
+public:
+    MParContainer(const char *name="", const char *title="") : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) {  }
+    MParContainer(const TString &name, const TString &title) : fName(name), fTitle(title), fLog(&gLog), fReadyToSave(kFALSE) {  }
+    MParContainer(const MParContainer &named);
+    MParContainer& operator=(const MParContainer& rhs);
+    virtual ~MParContainer() {}
+
+    virtual TObject    *Clone(const char *newname="") const;
+    virtual Int_t       Compare(const TObject *obj) const;
+    virtual void        Copy(TObject &named);
+    virtual void        FillBuffer(char *&buffer);
+
+    virtual const char   *GetDescriptor() const { return Form("%s [%s]", fName.Data(), ClassName()); }
+    virtual const TString GetUniqueName() const;
+    virtual const char   *GetName() const       { return fName.Data(); }
+    virtual const char   *GetTitle() const      { return fTitle.Data(); }
+    virtual ULong_t       Hash() const          { return fName.Hash(); }
+    virtual Bool_t        IsSortable() const    { return kTRUE; }
+
+    virtual void        SetName(const char *name); // *MENU*
+    virtual void        SetObject(const char *name, const char *title);
+    virtual void        SetTitle(const char *title=""); // *MENU*
+    virtual void        ls(Option_t *option="") const;
+    virtual void        Print(Option_t *option="") const;
+    virtual Int_t       Sizeof() const;
+    virtual void        SavePrimitive(ofstream &out, Option_t *o="");
+
+    virtual MParContainer *New() const;
+    virtual void   SetLogStream(MLog *lg) { fLog = lg; }
+    virtual void   Reset() { }
+    virtual Bool_t IsReadyToSave() const             { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+    virtual Bool_t IsSavedAsPrimitive() const        { return TestBit(kIsSavedAsPrimitive); }
+
+    TMethodCall *GetterMethod(const char *name) const;
+
+    Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const;
+    Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const;
+    Bool_t WriteDataMember(ostream &out, const TList *list) const;
+
+    virtual void AsciiRead(ifstream &fin);
+    virtual Bool_t AsciiWrite(ostream &out) const;
+
+    virtual void GetNames(TObjArray &arr) const;
+    virtual void SetNames(TObjArray &arr);
+
+    ClassDef(MParContainer, 0)  //The basis for all parameter containers
+};
+
+/*
+class MParContainer : public TNamed
+{
+protected:
+    MLog    *fLog;         //! The general log facility for this object, initialized with the global object
+
+private:
+    Bool_t   fReadyToSave; //! should be set to true if the contents of the container is changed somehow
+
+public:
+    MParContainer(const char *name="", const char *title="") : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
+    MParContainer(const TString &name, const TString &title) : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
+
+    void SetLogStream(MLog *lg)                      { fLog = lg; }
+
+    virtual void   Reset()                           {  }
+
+    virtual Bool_t IsReadyToSave()                   { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+
+    virtual void AsciiRead(ifstream &fin);
+    virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MParContainer, 0)  //The basis for all parameter containers
+};
+*/
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.cc	(revision 1638)
@@ -0,0 +1,769 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MParList                                                                //
+//                                                                         //
+// This class contains a list of different parameter containers.           //
+//                                                                         //
+// A parameter container is an object which is derived from                //
+// MParContainer.                                                          //
+//                                                                         //
+// Normally a parameter container is used for data exchange between two    //
+// tasks at runtime.                                                       //
+//                                                                         //
+// You can add every parameter container (Named object) to the             //
+// instance and access it from somewhere else via its Name.                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MParList.h"
+
+#include <fstream.h>     // ofstream, SavePrimitive
+
+#include <TNamed.h>
+#include <TClass.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIter.h"
+
+ClassImp(MParList);
+
+static const TString gsDefName  = "MParList";
+static const TString gsDefTitle = "A list of Parameter Containers";
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  creates an empty list
+//
+MParList::MParList(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    //
+    // This sets a flag that the list is the owner, which means
+    // that the destructor of the list deletes all it's objects
+    //
+    fContainer  = new TOrdCollection;
+    fAutodelete = new TOrdCollection;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Copy constructor. It copies all entries of the parameter list, but it
+//  takes care of, that the automatically created entries are only deleted
+//  once. (doesn't copy the list which holds the automatically created
+//  entries)
+//
+MParList::MParList(MParList &ts)
+{
+    fContainer->AddAll(ts.fContainer);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+MParList::~MParList()
+{
+    //
+    // Case:
+    //  1) MParList is owner of the containers:
+    //     All container are stored in fContainer, and become deleted by
+    //     'delete fContainer'. Some of these containers, which were
+    //     created automatically are stored in fAutodelete, too. To prevent
+    //     double deletion this containers are not deleted by the destructor
+    //     of fAutodelete.
+    //  2) MParList is not owner of the containers:
+    //     The containers which were Added by AddToList are not touched.
+    //     Only the containers which were created automatically are also
+    //     automatically deleted.
+    //
+    IsOwner() ? fContainer->SetOwner() : fAutodelete->SetOwner();
+
+    // FIXME? If fContainer is owner do we have to remove the object
+    //   from fAutodelete due to the acces when checking for a
+    //   garbage collection?
+
+    delete fContainer;
+    delete fAutodelete;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+void MParList::SetOwner(Bool_t enable)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the logging streamer of the parameter list and all contained
+//  parameter containers
+//
+void MParList::SetLogStream(MLog *log)
+{
+    fContainer->ForEach(MParContainer, SetLogStream)(log);
+    MParContainer::SetLogStream(log);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add a single container to the list.
+//
+//  If 'where' is given, the object will be added after this.
+//
+Bool_t MParList::AddToList(MParContainer *cont, MParContainer *where)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+
+    if (!cont)
+        return kFALSE;
+
+    //
+    // Get Name of new container
+    //
+    const char *name = cont->GetName();
+
+    //
+    // Check if the new container is already existing in the list
+    //
+    const TObject *objn = fContainer->FindObject(name);
+    const TObject *objt = fContainer->FindObject(cont);
+
+    if (objn || objt)
+    {
+        //
+        // If the container is already in the list ignore it.
+        //
+        if (objt || objn==cont)
+        {
+            *fLog << warn << dbginf << "Warning: Container '" << cont->GetName() << ", 0x" << (void*)cont;
+            *fLog << "' already existing in '" << GetName() << "'... ignoring." << endl;
+            return kTRUE;
+        }
+
+        //
+        // Otherwise add it to the list, but print a warning message
+        //
+        *fLog << warn << dbginf << "Warning: Container with the same name '" << cont->GetName();
+        *fLog << "' already existing in '" << GetName() << "'." << endl;
+        *fLog << "You may not be able to get a pointer to container task by name." << endl;
+    }
+
+    //
+    //  check if you want to add the new parameter container somewhere
+    //  special (in that case you specify "where")
+    //
+    if (where)
+    {
+        if (!fContainer->FindObject(where))
+        {
+            *fLog << dbginf << "Error: Cannot find parameter container after which the new one should be added!" << endl;
+            return kFALSE;
+        }
+    }
+
+    *fLog << inf << "Adding " << name << " to " << GetName() << "... " << flush;
+
+    fContainer->Add(cont);
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add all entries of the TObjArray to the list.
+//
+void MParList::AddToList(TObjArray *list)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+    if (!list)
+        return;
+
+    TObjArrayIter Next(list);
+
+    MParContainer *cont = NULL;
+    while ((cont=(MParContainer*)Next()))
+        AddToList(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object with the same name in the list and replace it with
+//  the new one. If the kIsOwner flag is set and the object was not
+//  created automatically, the object is deleted.
+//
+Bool_t MParList::Replace(MParContainer *cont)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+    if (!cont)
+        return kFALSE;
+
+    TObject *obj = FindObject(cont->GetName());
+    if (!obj)
+    {
+        *fLog << warn << "No object with the same name '";
+        *fLog << cont->GetName() << "' in list... adding." << endl;
+        return AddToList(cont);
+    }
+
+    fContainer->Remove(obj);
+
+    if (IsOwner() && !fAutodelete->FindObject(obj))
+        delete obj;
+
+    *fLog << inf << "MParContainer '" << cont->GetName() << "' found and replaced..." << endl;
+
+    return AddToList(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object with the same name in the list and remove it.
+//  If the kIsOwner flag is set and the object was not created
+//  automatically, the object is deleted.
+//
+void MParList::Remove(MParContainer *cont)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+    if (!cont)
+        return;
+
+    TObject *obj = fContainer->Remove(cont);
+    if (!obj)
+    {
+        *fLog << warn << "Object not found in list..." << endl;
+        return;
+    }
+
+    *fLog << inf << "MParContainer '" << cont->GetName() << "' removed..." << endl;
+
+    if (IsOwner() && !fAutodelete->FindObject(obj))
+        delete obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MParList::FindObject(const char *name) const
+{
+    return fContainer->FindObject(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not
+//
+TObject *MParList::FindObject(const TObject *obj) const
+{
+    return fContainer->FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list and check for the correct inheritance.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MParList::FindObject(const char *name, const char *classname) const
+{
+    TObject *obj = fContainer->FindObject(name);
+
+    if (!obj)
+        return NULL;
+
+    if (obj->InheritsFrom(classname))
+        return obj;
+
+    *fLog << dbginf << warn << "Found object '" << name << "' doesn't ";
+    *fLog << "inherit from " << "'" << classname << "'" << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not and check for the correct
+//  inheritance
+//
+TObject *MParList::FindObject(const TObject *obj, const char *classname) const
+{
+    TObject *nobj = fContainer->FindObject(obj);
+
+    if (!nobj)
+        return NULL;
+
+    if (nobj->InheritsFrom(classname))
+        return nobj;
+
+    *fLog << dbginf << warn << "Found object '" << nobj->GetName() << "' ";
+    *fLog << "doesn't inherit from " << "'" << classname << "'" << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  returns the ClassName without anything which is behind that last ';' in
+//  string.
+//
+TString MParList::GetClassName(const char *classname)
+{
+    TString cname(classname);
+    const char *semicolon = strrchr(cname, ';');
+
+    if (semicolon)
+        cname.Remove(semicolon-cname);
+
+    return cname;
+}
+
+// --------------------------------------------------------------------------
+//
+//  returns the ObjectName. It is created from a class and object name.
+//  If no object name is given the objectname is the same than the
+//  class name. Leading dots are removed from the object name
+//
+TString MParList::GetObjectName(const char *classname, const char *objname)
+{
+    TString cname(classname);
+    const char *semicolon = strrchr(cname, ';');
+
+    TString oname(objname ? objname : classname);
+
+    if (semicolon)
+    {
+        //
+        // Remove leading dots from objectname (eg. "MMcTrig;5.")
+        //
+        Int_t sz = oname.Sizeof()-2;
+
+        while (sz>=0 && oname[sz]=='.')
+            oname.Remove(sz--);
+    }
+    return oname;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//  If the object doesn't exist we try to create one from the
+//  dictionary. If this isn't possible NULL is returned.
+//
+//  An object which was created automatically is deleted automatically in
+//  the destructor of the parameter list, too. This means, that if an
+//  object should survive (eg. Histograms) you MUST create it by yourself
+//  and add it to the parameter list.
+//
+//  By default (you don't specify an object name) the object name is
+//  the same as the classname
+//
+//  If the classname (default classname) is of the structure
+//  "Name;something" - containing a semicolon - evarything which is
+//  after the last appearance of a semicolon is stripped to get the
+//  Name of the Class. Normally this is used to number your objects.
+//  "Name;1", "Name;2", ... If a semicolon is detected leading dots
+//  are stripped from the object-name (eg. "name;5.")
+//
+MParContainer *MParList::FindCreateObj(const char *classname, const char *objname)
+{
+    //
+    // If now object name (name of the object to identify it in the
+    // List) is given use it's classname as the objectname
+    //
+
+    //
+    // Check if the classname is a 'numbered' name (like: "MTime;2")
+    // if so strip the number from the classname.
+    //
+    // Becareful: We check for the last occurance of a ';' only and we
+    // also don't check if a number follows or something else.
+    //
+    // Rem: I use a TString to make the code more readyble and to get
+    // the new object deleted automatically
+    //
+    TString cname = GetClassName(classname);
+    TString oname = GetObjectName(classname, objname);
+
+    //
+    // Try to find a object with this object name which is already
+    // in the List. If we can find one we are done.
+    //
+    MParContainer *pcont = (MParContainer*)FindObject(oname);
+
+    if (pcont)
+    {
+        if (pcont->InheritsFrom(cname))
+            return pcont;
+
+        *fLog << err << "Warning: Object '" << oname << "' found in list doesn't inherit from " << cname << "." << endl;
+        return NULL;
+    }
+
+    //
+    // if object is not existing in the list try to create one
+    //
+    *fLog << inf << "Object '" << oname << "' [" << cname << "] not yet in " << GetName() << "... creating." << endl;
+
+    //
+    // try to get class from root environment
+    //
+    TClass *cls = gROOT->GetClass(cname);
+    if (!cls)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        *fLog << err << dbginf << "Class '" << cname << "' not existing in dictionary." << endl;
+        return NULL;
+    }
+
+    //
+    // create the parameter container of the the given class type
+    //
+    pcont = (MParContainer*)cls->New();
+    if (!pcont)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
+        return NULL;
+    }
+
+    //
+    // Set the name of the container
+    //
+    pcont->SetName(oname);
+
+    //
+    // Now add the object to the parameter list
+    //
+    AddToList(pcont);
+
+    //
+    // The object was automatically created. This makes sure, that such an
+    // object is deleted together with the list
+    //
+    fAutodelete->Add(pcont);
+
+    //
+    //  Find an object in the list.
+    //  'name' is the name of the object you are searching for.
+    //
+    return pcont;
+}
+
+// --------------------------------------------------------------------------
+//
+//   print some information about the current status of MParList
+//
+void MParList::Print(Option_t *t) const
+{
+    *fLog << all << " " << GetDescriptor() << endl;
+    *fLog << setfill('-') << setw(strlen(GetDescriptor())+2) << "" << endl;
+    MParContainer *obj = NULL;
+    TIter Next(fContainer);
+    while ((obj=(MParContainer*)Next()))
+    {
+        *fLog << " " << obj->GetDescriptor();
+        if (fAutodelete->FindObject(obj))
+            *fLog << " <autodel>";
+        *fLog << endl;
+    }
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Sets the flags off all containers in the list (and the list
+//   itself) to unchanged
+//
+void MParList::SetReadyToSave(Bool_t flag)
+{
+    fContainer->ForEach(MParContainer, SetReadyToSave)(flag);
+    MParContainer::SetReadyToSave(flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//   Reset all containers in the list
+//
+void MParList::Reset()
+{
+    fContainer->ForEach(MParContainer, Reset)();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray.
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+TObjArray MParList::FindObjectList(const char *name, UInt_t first, const UInt_t last) const
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(name);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, name);
+
+    if (first==0 && last!=0)
+        first = 1;
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        TObject *obj = FindObject(auxname);
+        if (!obj)
+            continue;
+
+        list.AddLast(obj);
+    }
+    delete auxname;
+
+    return list;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray. If one of the objects doesn't exist it is created from the
+//  meaning of cname and oname (s. FindCreateObj)
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+TObjArray MParList::FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(cname);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, cname);
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    if (first==0 && last!=0)
+        first = 1;
+
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        TObject *obj = FindCreateObj(auxname, oname);
+        if (!obj)
+            break;
+
+        list.AddLast(obj);
+    }
+    delete auxname;
+
+    return list;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray. If one of the objects doesn't exist it is created from the
+//  meaning of cname and oname (s. FindCreateObj)
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+//  Remark: Because it is static the object are only created and not added to
+//  the parameter list. You must also take care of deleting these objects!
+//  This function is mainly made for use in root macros. Don't use it in
+//  compiled programs if you are not 100% sure what you are doing.
+//
+TObjArray MParList::CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        gLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    //
+    // try to get class from root environment
+    //
+    TClass *cls = gROOT->GetClass(cname);
+    if (!cls)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        gLog << dbginf << "Class '" << cname << "' not existing in dictionary." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(cname);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, cname);
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    if (first==0 && last!=0)
+        first = 1;
+
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        //
+        // create the parameter container of the the given class type
+        //
+        MParContainer *pcont = (MParContainer*)cls->New();
+        if (!pcont)
+        {
+            gLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
+            return list;
+        }
+
+        //
+        // Set the name of the container
+        //
+        pcont->SetName(auxname);
+
+        //
+        // Add new object to the return list
+        //
+        list.AddLast(pcont);
+    }
+    delete auxname;
+
+    return list;
+}
+
+void MParList::SavePrimitive(ofstream &out, Option_t *o)
+{
+    Bool_t saved = IsSavedAsPrimitive();
+
+    MParContainer::SavePrimitive(out);
+
+    MIter Next(fContainer);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        //
+        // Because it was automatically created don't store its primitive
+        // I guess it will be automatically created again
+        //
+        if (fAutodelete->FindObject(cont) || cont->IsSavedAsPrimitive())
+            continue;
+
+        cont->SavePrimitive(out, "");
+
+        out << "   " << GetUniqueName() << ".";
+        out << (cont->InheritsFrom("MTaskList") && saved ? "Replace" : "AddToList");
+        out << "(&" << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MParList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MParList " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds one TNamed object per object in the list. The TNamed object must
+// be deleted by the user.
+//
+void MParList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fContainer->ForEach(MParContainer, GetNames)(arr);
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets name and title of each object in the list from the objects in
+// the array.
+//
+void MParList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    fContainer->ForEach(MParContainer, SetNames)(arr);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MParList.h	(revision 1638)
@@ -0,0 +1,95 @@
+#ifndef MARS_MParList
+#define MARS_MParList
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MParList                                                                //
+//                                                                         //
+// List of parameter containers (MParContainer)                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TClass;
+class TOrdCollection;
+
+class MLog;
+
+class MParList : public MParContainer
+{
+private:
+    TOrdCollection *fContainer;	 // Collection of Parameter and Data Containers
+    TOrdCollection *fAutodelete; //! All what this list contains is deleted in the destructor
+
+    static TString GetClassName(const char *classname);
+    static TString GetObjectName(const char *classname, const char *objname);
+
+    enum { kIsOwner = BIT(14) };
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    enum { kDoNotReset = BIT(15) };
+
+    MParList(const char *name=NULL, const char *title=NULL);
+    MParList(MParList &ts);
+
+    virtual ~MParList();
+
+    Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
+    void   AddToList(TObjArray *list);
+
+    Bool_t Replace(MParContainer *obj);
+    void   Remove(MParContainer *obj);
+
+    void SetLogStream(MLog *log);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(const TObject *obj) const;
+
+    TObject *FindObject(const char *name, const char *classname) const;
+    TObject *FindObject(const TObject *obj, const char *classname) const;
+
+    MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);
+
+    TObjArray FindObjectList(const char *name, UInt_t first, const UInt_t last) const;
+    TObjArray FindObjectList(const char *name, const UInt_t num) const
+    {
+        return FindObjectList(name, 0, num);
+    }
+
+    TObjArray FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
+    TObjArray FindCreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
+    {
+        return FindCreateObjList(cname, 0, num, oname);
+    }
+
+    static TObjArray CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
+    static TObjArray CreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
+    {
+        return CreateObjList(cname, 0, num, oname);
+    }
+
+    void Reset();
+    void SetReadyToSave(Bool_t flag=kTRUE);
+
+    void SetOwner(Bool_t enable=kTRUE);
+    Bool_t IsOwner() const { return TestBit(kIsOwner); }
+
+    void Print(Option_t *t = NULL) const;
+
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    ClassDef(MParList, 1) // list of parameter containers (MParContainer)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.cc	(revision 1638)
@@ -0,0 +1,147 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  10/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MPrint                                                                  //
+//                                                                          //
+//  This task calls the Print() function of a parameter container, to       //
+//  print some information event by event.                                  //
+//  Overload TObject::Print()                                               //
+//                                                                          //
+//  Input Containers:                                                       //
+//   MParContainer                                                          //
+//                                                                          //
+//  Output Containers:                                                      //
+//   -/-                                                                    //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MPrint.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MPrint);
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MPrint::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPrint";
+    fTitle = title ? title : "Task to print a parameter container";
+
+    fObject = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remembers the name to search for in the parameter list
+//  of the object to be printed. The object must be derived from TObject and
+//  TObject::Print(Option_t *) const
+//  must be overloaded. You can also set an option string to use
+//  when calling TObject::Print
+//  If you want that the MPrint instance is removed from the tasklist
+//  if the container to be printed is not found in the PreProcess, call:
+//     MPrint::EnableSkip();
+//
+MPrint::MPrint(const char *obj, const char *option,
+               const char *name, const char *title)
+{
+    Init(name, title);
+    SetOption(option);
+
+    fObjName = obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remember the pointer of the object which has to be
+//  printed. The object must be derived from TObject and
+//  TObject::Print(Option_t *) const
+//  must be overloaded. You can also set an option string to use
+//  when calling TObject::Print
+//  if the container to be printed is not found in the PreProcess, call:
+//     MPrint::EnableSkip();
+//
+MPrint::MPrint(const TObject *obj, const char *option,
+               const char* name, const char *title)
+{
+    Init(name, title);
+    SetOption(option);
+
+    fObject  = obj;
+    fObjName = obj->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks the parameter list for the existance of the parameter container. If
+//  the name of it was given in the constructor.
+//
+Bool_t MPrint::PreProcess(MParList *pList)
+{
+    //
+    // The pointer is already given by the user.
+    //
+    if (fObject)
+        return kTRUE;
+
+    //
+    // Try to find the parameter container with the given name in the list
+    //
+    fObject = pList->FindObject(fObjName);
+    if (fObject)
+        return kTRUE;
+
+    //
+    // If it couldn't get found stop Eventloop
+    //
+    *fLog << err << dbginf << fObjName << " not found... ";
+    if (TestBit(kSKIP))
+    {
+        *fLog << "removing task from list." << endl;
+        return kSKIP;
+    }
+    else
+    {
+        *fLog << "aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calls overloaded TObject::Print
+//
+Bool_t MPrint::Process()
+{
+    fObject->Print(fOption);
+    return kTRUE;
+} 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MPrint.h	(revision 1638)
@@ -0,0 +1,35 @@
+#ifndef MARS_MPrint
+#define MARS_MPrint
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MPrint : public MTask
+{
+private:
+    const TObject *fObject;  // pointer to container which has to be printed
+    TString fObjName;        // given name to search for in the parameterlist
+    TString fOption;         // Print option
+
+    enum { kSkip = BIT(14) };
+
+    void Init(const char *name, const char *title);
+
+public:
+    MPrint(const char *obj,    const char *option="", const char *name=NULL, const char *title=NULL);
+    MPrint(const TObject *obj, const char *option="", const char *name=NULL, const char *title=NULL);
+
+    void SetOption(Option_t *option) { fOption = option; }
+    void EnableSkip(Bool_t skip=kTRUE) { skip ? SetBit(kSkip) : ResetBit(kSkip); }
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MPrint, 0) // Task to call Print() function
+};
+    
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.cc	(revision 1638)
@@ -0,0 +1,316 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <mailto:tbretz@uni-sw.gwdg.de>, 12/2000
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MTask                                                                 //
+//                                                                         //
+//   Base class for all tasks which can perfomed in a tasklist             //
+//   For each event processed in the eventloop all the different           //
+//   tasks in the tasklist will be processed.                              //
+//                                                                         //
+//   So all tasks must inherit from this baseclass.                        //
+//                                                                         //
+//   The inheritance from MInputStreamID is used to indicate the           //
+//   type of event that this task is for. If it is "All" it is executed    //
+//   independantly of the actual ID of the task list.                      //
+//                                                                         //
+//   Inside this abstract class, there are three fundamental function:     //
+//                                                                         //
+//   - PreProcess():   executed before the eventloop starts. Here you      //
+//                     can initiate different things, open files, etc.     //
+//                     As an argument this function gets a pointer to the  //
+//                     parameter list. You can stop the execution by       //
+//                     returning kFALSE instead of kTRUE. If an error      //
+//                     occured and you return kFALSE make sure, that       //
+//                     any action is closed correctly and all newly        //
+//                     created object are deleted. The PostProcess in      //
+//                     such a case won't be executed by the Tasklist or    //
+//                     Eventloop.                                          //
+//                                                                         //
+//   - Process():      executed for each event in the eventloop. Do it     //
+//                     one task after the other (as they occur in the      //
+//                     tasklist). Only the tasks with a Stream ID          //
+//                     which matches the actual ID of the tasklist         //
+//                     are executed. A task can return kFALSE to           //
+//                     stop the execuition of the tasklist or              //
+//                     kCONTINUE to skip the pending tasks.                //
+//                                                                         //
+//   - PostProcess():  executed after the eventloop. Here you can close    //
+//                     output files, start display of the run parameter,   //
+//                     etc. PostProcess is only executed in case of        //
+//                     PreProcess was successfull (returned kTRUE)         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MTask.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFilter.h"
+#include "MGGroupFrame.h"
+
+ClassImp(MTask);
+
+MTask::MTask(const char *name, const char *title)
+    : fFilter(NULL), fIsPreprocessed(kFALSE), fNumExecutions(0)
+{
+    fName  = name  ? name  : "MTask";
+    fTitle = title ? title : "Base class for all tasks (dummy task).";
+
+    fListOfBranches = new TList;
+    fListOfBranches->SetOwner();
+}
+
+MTask::~MTask()
+{
+    delete fListOfBranches;
+}
+
+// --------------------------------------------------------------------------
+//
+// This adds a branch to the list for the auto enabeling schmeme.
+// This makes it possible for MReadTree to decide which branches
+// are really needed for the eventloop. Only the necessary branches
+// are read from disk which speeds up the calculation enormously.
+//
+// You can use TRegExp expressions like "*.fEnergy", but the
+// recommended method is to call this function for exactly all
+// branches you want to have, eg:
+//  AddToBranchList("MMcTrig.fNumFirstLevel");
+//  AddToBranchList("MMcTrig;1.fNumFirstLevel");
+//  AddToBranchList("MMcTrig;2.fNumFirstLevel");
+//
+// We agreed on the convetion, that all branches are stored with
+// a trailing dot '.' so that always the Master Branch name
+// (eg. MMcTrig) is part of the branch name.
+//
+// Remark: The common place to call AddToBranchList is the
+//         constructor of the derived classes (tasks)
+//
+void MTask::AddToBranchList(const char *b)
+{
+    if (fListOfBranches->FindObject(b))
+        return;
+
+    fListOfBranches->Add(new TNamed(b, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+// Using this overloaded member function you may cascade several branches
+// in acomma seperated list, eg: "MMcEvt.fTheta,MMcEvt.fEnergy"
+//
+// For moredetailed information see AddToBranchList(const char *b);
+//
+void MTask::AddToBranchList(const TString &str)
+{
+    TString s = str;
+
+    while (1)
+    {
+        Int_t fst = s.First(',');
+
+        if (fst<0)
+            return;
+
+        AddToBranchList(TString(s(0, fst)));
+
+        s.Remove(0, fst+1);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Copy constructor.
+//
+MTask::MTask(MTask &t)
+{
+    fFilter = t.fFilter;
+    fListOfBranches->AddAll(t.fListOfBranches);
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Sets the preprocessed flag dependend on the return value of PreProcess.
+//
+Bool_t MTask::CallPreProcess(MParList *plist)
+{
+    fNumExecutions = 0;
+
+    switch (PreProcess(plist))
+    {
+    case kFALSE:
+        return kFALSE;
+
+    case kTRUE:
+        fIsPreprocessed = kTRUE;
+        return kTRUE;
+
+    case kSKIP:
+        return kSKIP;
+    }
+
+    *fLog << err << dbginf << "PreProcess of " << GetDescriptor();
+    *fLog << " returned an unknown value... aborting." << endl;
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for Process.
+// Executes Process dependent on the existance of a filter and its possible
+// return value.
+// If Process is executed, the execution counter is increased.
+//
+Bool_t MTask::CallProcess()
+{
+    //
+    // Check for the existance of a filter. If a filter is existing
+    // check for its value. If the value is kFALSE don't execute
+    // this task.
+    //
+    const Bool_t exec = fFilter ? fFilter->IsExpressionTrue() : kTRUE;
+
+    if (!exec)
+        return kTRUE;
+
+    fNumExecutions++;
+    return Process();
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Calls Postprocess dependent on the state of the preprocessed flag,
+// resets this flag.
+//
+Bool_t MTask::CallPostProcess()
+{
+    if (!fIsPreprocessed)
+        return kTRUE;
+
+    fIsPreprocessed = kFALSE;
+
+    return PostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// This is reinit function
+//
+// This function is called asynchronously if the tasks in the tasklist need
+// reinitialization. This for example happens when the eventloop switches
+// from one group of events to another one (eg. switching between events
+// of different runs means reading a new run header and a new run header
+// may mean that some value must be reinitialized)
+//
+// the virtual implementation returns kTRUE
+//
+Bool_t MTask::ReInit(MParList *pList)
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is processed before the eventloop starts
+//
+// It is the job of the PreProcess to connect the tasks
+// with the right container in the parameter list.
+//
+// the virtual implementation returns kTRUE
+//
+Bool_t MTask::PreProcess(MParList *pList)
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is processed for every event in the eventloop
+//
+// the virtual implementation returns kTRUE
+//
+Bool_t MTask::Process()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is processed after the eventloop starts
+//
+// the virtual implementation returns kTRUE
+//
+Bool_t MTask::PostProcess()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the number of times all the tasks in the list has been.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
+//
+void MTask::PrintStatistics(const Int_t lvl, Bool_t title) const
+{
+    *fLog << all << setw(lvl) << " " << GetDescriptor() << "\t";
+    *fLog << dec << fNumExecutions;
+    if (fFilter)
+        *fLog << " <" << fFilter->GetName() << ">";
+    if (title)
+        *fLog << "\t" << fTitle;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// First call MParContainer::SavePrimitive which should stream the primitive
+// to the output stream. Then, if a filter is set, stream first the filter
+// and afterwards set the filter for this task.
+//
+void MTask::SavePrimitive(ofstream &out, Option_t *o)
+{
+    MParContainer::SavePrimitive(out);
+    if (!fFilter)
+        return;
+
+    /*
+     If we don't stream filter which are not in the task list itself
+     (which means: already streamed) we may be able to use
+     SavePrimitive as some kind of validity check for the macros
+
+     fFilter->SavePrimitive(out);
+     */
+     out << "   " << GetUniqueName() << ".SetFilter(&" << fFilter->GetUniqueName() <<");" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTask.h	(revision 1638)
@@ -0,0 +1,86 @@
+#ifndef MARS_MTask
+#define MARS_MTask
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTask                                                                   //
+//                                                                         //
+// Abstract base class for a task                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MInputStreamID
+#include "MInputStreamID.h"
+#endif
+
+class TList;
+
+class MFilter;
+class MParList;
+
+class MTask : public MInputStreamID
+{
+private:
+    TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
+
+    MFilter *fFilter;       // Filter for conditional task execution
+
+    Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
+    UInt_t fNumExecutions;  //! Number of Excutions
+
+    virtual Bool_t PreProcess(MParList *pList);
+    virtual Bool_t Process();
+    virtual Bool_t PostProcess();
+
+protected:
+    void AddToBranchList(const char *b);
+    void AddToBranchList(const TString &str);
+    void AddToBranchList(const char *master, const char *sub, const UInt_t first, const UInt_t last)
+    {
+        if (first==0 && last==0)
+        {
+            AddToBranchList(sub);
+            return;
+        }
+
+        for (unsigned int i=first; i<last+1; i++)
+            AddToBranchList(Form("%s;%d.%s", master, i, sub));
+    }
+    void AddToBranchList(TString &master, TString &sub, const UInt_t first, const UInt_t last)
+    {
+        AddToBranchList((const char*)master, (const char*)sub, first, last);
+    }
+    void AddToBranchList(const char *master, const char *sub, const UInt_t num)
+    {
+        AddToBranchList(master, sub, 0, num);
+    }
+    void AddToBranchList(TString &master, TString &sub, const UInt_t num)
+    {
+        AddToBranchList(master, sub, 0, num);
+    }
+
+public:
+    MTask(const char *name=NULL, const char *title=NULL);
+    MTask(MTask &t);
+    virtual ~MTask();
+
+    void SetFilter(MFilter *filter) { fFilter=filter; }
+    const MFilter *GetFilter() const      { return fFilter; }
+    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+
+    UInt_t GetNumExecutions() { return fNumExecutions; }
+
+    virtual Bool_t ReInit(MParList *pList);
+
+    virtual Bool_t CallPreProcess(MParList *plist);
+    virtual Bool_t CallProcess();
+    virtual Bool_t CallPostProcess();
+
+    const TList *GetListOfBranches() const { return fListOfBranches; }
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    ClassDef(MTask, 1) //Abstract base class for a task
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.cc	(revision 1638)
@@ -0,0 +1,584 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTaskList                                                               //
+//                                                                         //
+// Collection of tasks.                                                    //
+//                                                                         //
+// A tasklist is necessary to run the eventloop. It contains the scheduled //
+// tasks, which should be executed in your program.                        //
+//                                                                         //
+// To add a task use AddToList.                                            //
+//                                                                         //
+// The tasklist itself is a task, too. You can add a tasklist to another   //
+// tasklist. This makes sense, if you want to filter the execution of      //
+// more than one task of your tasklist using the same filter.              //
+//                                                                         //
+// The tasks in the list are idetified by their names. If more than one    //
+// task has the same name, the tasklist will still work correctly, but     //
+// you might run into trouble trying to get a pointer to a task by name    //
+// from the list.                                                          //
+//                                                                         //
+// Warning:                                                                //
+//  Be carefull if you are writing your tasklist                           //
+//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may      //
+//  not be able to initialize a new working tasklist from a file if        //
+//   a) Two Paramerer containers with the same names are existing in the   //
+//      MParList.                                                          //
+//   b) You used a container somewhere which is not part of MParList.      //
+//      (eg. You specified a pointer to a MH container in MFillH which is  //
+//      not added to the parameter list.                                   //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MTaskList.h"
+
+#include <fstream.h>     // ofstream, SavePrimitive
+
+#include <TClass.h>
+#include <TBaseClass.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFilter.h"
+#include "MParList.h"
+#include "MInputStreamID.h"
+
+ClassImp(MTaskList);
+
+const TString MTaskList::gsDefName  = "MTaskList";
+const TString MTaskList::gsDefTitle = "A list for tasks to be executed";
+
+// --------------------------------------------------------------------------
+//
+// the name for the task list must be the same for all task lists
+// because the task list (at the moment) is identified by exactly
+// this name in the parameter list (by MEvtLoop::SetParList)
+//
+MTaskList::MTaskList(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fTasks = new TList;
+}
+
+// --------------------------------------------------------------------------
+//
+//   CopyConstructor
+//   creates a new TaskList and put the contents of an existing
+//   TaskList in the new TaskList.
+//
+MTaskList::MTaskList(MTaskList &ts)
+{
+    fTasks->AddAll(ts.fTasks);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all tasks are deleted
+//  by the destructor
+//
+MTaskList::~MTaskList()
+{
+    if (TestBit(kIsOwner))
+        fTasks->SetOwner();
+
+    delete fTasks;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+void MTaskList::SetOwner(Bool_t enable)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  Set the logging stream for the all tasks in the list and the tasklist
+//  itself.
+//
+void MTaskList::SetLogStream(MLog *log)
+{
+    fTasks->ForEach(MTask, SetLogStream)(log);
+    MParContainer::SetLogStream(log);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// schedule task for execution, whether as first task, or after
+// 'where'. 'tType' is the event type which should be processed
+//
+Bool_t MTaskList::AddToList(MTask *task, const char *type, MTask *where)
+{
+    // FIXME: We agreed to put the task into list in an ordered way.
+
+    //
+    // Sanity check
+    //
+    if (!task)
+        return kFALSE;
+
+    //
+    // Get Name of new task
+    //
+    const char *name = task->GetName();
+
+    //
+    // Check if the new task is already existing in the list
+    //
+    const TObject *objn = fTasks->FindObject(name);
+    const TObject *objt = fTasks->FindObject(task);
+
+    if (objn || objt)
+    {
+        //
+        // If the task is already in the list ignore it.
+        //
+        if (objt || objn==task)
+        {
+            *fLog << warn << dbginf << "Warning: Task '" << task->GetName() << ", 0x" << (void*)task;
+            *fLog << "' already existing in '" << GetName() << "'... ignoring." << endl;
+            return kTRUE;
+        }
+
+        //
+        // Otherwise add it to the list, but print a warning message
+        //
+        *fLog << warn << dbginf << "Warning: Task '" << task->GetName();
+        *fLog << "' already existing in '" << GetName() << "'." << endl;
+        *fLog << "You may not be able to get a pointer to this task by name." << endl;
+    }
+
+    if (where)
+    {
+        if (!fTasks->FindObject(where))
+        {
+            *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl;
+            return kFALSE;
+        }
+    }
+
+    *fLog << inf << "Adding " << name << " to " << GetName() << " for " << type << "... " << flush;
+
+    task->SetStreamId(type);
+    fTasks->Add(task);
+
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MTaskList::FindObject(const char *name) const
+{
+    return fTasks->FindObject(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not
+//
+TObject *MTaskList::FindObject(const TObject *obj) const
+{
+    return fTasks->FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  do reinit of all tasks in the task-list
+//
+Bool_t MTaskList::ReInit(MParList *pList)
+{ 
+    *fLog << all << "Reinit... " << flush;
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+    //
+    // loop over all tasks for preproccesing
+    //
+    while ((task=(MTask*)Next()))
+    {
+        *fLog << all << task->GetName() << "... " << flush;
+
+        if (!task->ReInit(pList?pList:fParList))
+        {
+            *fLog << err << "ERROR - ReInit if Task " << task->GetDescriptor() << " failed." << endl;
+            return kFALSE;
+        }
+    }
+
+    *fLog << all << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  removes a task from the list (used in PreProcess).
+//  if kIsOwner is set the task is deleted. (see SetOwner())
+//
+void MTaskList::Remove(MTask *task)
+{
+    TObject *obj = fTasks->Remove(task);
+
+    if (TestBit(kIsOwner))
+        delete obj;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether this task (or one of it's base classes) overloads
+// MTask::Process. Only if this function is overloaded this task is
+// added to the fTaskProcess-List. This makes the execution of the
+// tasklist a little bit (only a little bit) faster, bacause tasks
+// doing no Processing are not Processed.
+//
+Bool_t MTaskList::CheckClassForProcess(TClass *cls)
+{
+    //
+    // Check whether the class itself overloads the Process function
+    //
+    if (cls->GetName()=="MTask")
+        return kFALSE;
+
+    if (cls->GetMethodAny("Process"))
+        return kTRUE;
+
+    //
+    // If the class itself doesn't overload it check all it's base classes
+    //
+    TBaseClass *base=NULL;
+    TIter NextBase(cls->GetListOfBases());
+    while ((base=(TBaseClass*)NextBase()))
+    {
+        if (CheckClassForProcess(base->GetClassPointer()))
+            return kTRUE;
+    }
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do pre processing (before eventloop) of all tasks in the task-list
+//
+Bool_t MTaskList::PreProcess(MParList *pList)
+{ 
+    *fLog << all << "Preprocessing... " << flush;
+
+    fParList = pList;
+
+    fTasksProcess.Clear();
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for preproccesing
+    //
+    while ((task=(MTask*)Next()))
+    {
+        *fLog << all << task->GetName() << "... " << flush;
+
+        if (CheckClassForProcess(task->IsA()))
+            fTasksProcess.Add(task);
+
+        //
+        // PreProcess the task and check for it's return value.
+        //
+        switch (task->CallPreProcess(fParList))
+        {
+        case kFALSE:
+            return kFALSE;
+
+        case kTRUE:
+            continue;
+
+        case kSKIP:
+            Remove(task);
+            continue;
+        }
+
+        *fLog << err << dbginf << "PreProcess of " << task->GetDescriptor();
+        *fLog << " returned an unknown value... aborting." << endl;
+        return kFALSE;
+    }
+
+    *fLog << all << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// do the event execution of all tasks in the task-list
+//
+Bool_t MTaskList::Process()
+{
+    //
+    // Check whether there is something which can be processed, otherwise
+    // stop the eventloop.
+    //
+    if (fTasksProcess.GetSize()==0)
+    {
+        *fLog << warn << "Warning: No entries in " << GetDescriptor() << " for Processing." << endl;
+        return kFALSE;
+    }
+
+    //
+    // Reset the ReadyToSave flag.
+    // Reset all containers.
+    //
+    // Make sure, that the parameter list is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->Reset();
+        fParList->SetBit(MParList::kDoNotReset);
+    }
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    TIter Next(&fTasksProcess);
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for processing
+    //
+    Bool_t rc = kTRUE;
+    while ( (task=(MTask*)Next()) )
+    {
+        //
+        // if the task has the wrong stream id skip it.
+        //
+        if (GetStreamId() != task->GetStreamId() &&
+            task->GetStreamId() !=  "All")
+            continue;
+
+        //
+        // if it has the right stream id execute the CallProcess() function
+        // and check what the result of it is.
+        // The CallProcess() function increases the execution counter and
+        // calls the Process() function dependent on the existance and
+        // return value of a filter.
+        //
+        switch (task->CallProcess())
+        {
+        case kTRUE:
+            //
+            // everything was OK: go on with the next task
+            //
+            continue;
+
+        case kFALSE:
+            //
+            // an error occured: stop eventloop
+            //
+            rc = kFALSE;
+            break;
+
+        case kCONTINUE:
+            //
+            // something occured: skip the rest of the tasks for this event
+            //
+            rc = kTRUE;
+            break;
+
+        default:
+            *fLog << warn << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl;
+            continue;
+        }
+        break;
+    }
+
+    if (!noreset)
+        fParList->ResetBit(MParList::kDoNotReset);
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do post processing (before eventloop) of all tasks in the task-list
+//  only tasks which have successfully been preprocessed are postprocessed.
+//
+Bool_t MTaskList::PostProcess()
+{
+    *fLog << all << "Postprocessing... " << flush;
+
+    //
+    // Reset the ReadyToSave flag.
+    // Reset all containers.
+    //
+    // FIXME: To run a tasklist as a single task in another tasklist we
+    //        have to make sure, that the Parameter list isn't reset.
+    //
+    fParList->SetReadyToSave(kFALSE);
+    fParList->Reset();
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    //  loop over all tasks for postprocessing
+    //  only tasks which have successfully been preprocessed are postprocessed.
+    //
+    while ( (task=(MTask*)Next()) )
+    {
+        *fLog << all << task->GetName() << "... " << flush;
+
+        if (!task->CallPostProcess())
+            return kFALSE;
+    }
+
+    *fLog << all << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the number of times all the tasks in the list has been.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
+//
+void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title) const
+{
+    if (lvl==0)
+    {
+        *fLog << all << endl;
+        *fLog << "Execution Statistics: " << endl;
+        *fLog << "---------------------" << endl;
+        *fLog << GetDescriptor();
+        if (GetFilter())
+            *fLog << " <" << GetFilter()->GetName() << ">";
+        if (title)
+            *fLog << "\t" << fTitle;
+        *fLog << endl;
+    }
+    else
+    {
+        *fLog << setw(lvl) << " " << GetDescriptor();
+        if (title)
+            *fLog << "\t" << fTitle;
+        *fLog << endl;
+    }
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title);
+
+    if (lvl==0)
+        *fLog << endl;
+}
+
+
+// --------------------------------------------------------------------------
+void MTaskList::Print(Option_t *t) const
+{
+    *fLog << all << endl;
+    *fLog << GetDescriptor() << endl;
+    *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl;
+
+    fTasks->Print();
+
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MTaskList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MTaskList " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl << endl;
+
+    TIter Next(fTasks);
+
+    MParContainer *cont = NULL;
+    while ((cont=(MParContainer*)Next()))
+    {
+        cont->SavePrimitive(out, "");
+        out << "   " << GetUniqueName() << ".AddToList(&";
+        out << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+void MTaskList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fTasks->ForEach(MParContainer, GetNames)(arr);
+}
+
+void MTaskList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    fTasks->ForEach(MParContainer, SetNames)(arr);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTaskList.h	(revision 1638)
@@ -0,0 +1,68 @@
+#ifndef MARS_MTaskList
+#define MARS_MTaskList
+
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MTaskList                                                         //
+//                                                                   //
+// Collection of tasks to be processed in the eventloop              //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MLog;
+class MParList;
+class MInputStreamID;
+
+class MTaskList : public MTask
+{
+private:
+    static const TString gsDefName;  // default name
+    static const TString gsDefTitle; // default title
+
+    TList    *fTasks;        // Container for the ordered list of different tasks
+    TList     fTasksProcess; //! Task which overload the Process function
+    MParList *fParList;      //! The parameter list given in PreProcess
+
+    enum { kIsOwner = BIT(14) };
+
+    void   Remove(MTask *task);
+    Bool_t CheckClassForProcess(TClass *cls);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MTaskList(const char *name=NULL, const char *title=NULL);
+    MTaskList(MTaskList &ts);
+
+    ~MTaskList();
+
+    void SetLogStream(MLog *log);
+
+    Bool_t AddToList(MTask *task, const char *tType="All", MTask *where = NULL);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(const TObject *obj) const;
+
+    Bool_t ReInit(MParList *pList=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    void Print(Option_t *opt = "") const;
+    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const;
+    void SetOwner(Bool_t enable=kTRUE);
+
+    const TList *GetList() const { return fTasks; }
+
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
+    ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.cc	(revision 1638)
@@ -0,0 +1,48 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTime                                                                   //
+//                                                                         //
+// A generalized MARS time stamp                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MTime.h"
+
+#include <iomanip.h>
+
+#include "MLog.h"
+
+ClassImp(MTime);
+
+void MTime::Print(Option_t *) const
+{
+    fLog->setf(ios::showbase);
+    *fLog << "MTime Information:  " << hex 
+        << " " << setfill('0') << setw(2) << fTimeStamp[0]
+        << " " << setfill('0') << setw(2) << fTimeStamp[1] << endl << endl;
+} 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/MTime.h	(revision 1638)
@@ -0,0 +1,118 @@
+#ifndef MARS_MTime
+#define MARS_MTime
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTime                                                                   //
+//                                                                         //
+// A generalized MARS time stamp                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MTime : public MParContainer
+{
+private:
+    UInt_t fTimeStamp[2]; // type of raw event which should be processed by this task
+    UInt_t fDuration;     // time of validity
+
+public:
+
+    MTime(const char *name=NULL, const char *title=NULL)
+    {
+        fName = name ? name : ClassName();
+        fTitle = title;
+
+        SetTime(0, 0);
+    }
+
+    MTime(UInt_t t1, UInt_t t0) 
+    {
+        SetTime(t1, t0);
+    }
+
+    MTime(MTime& t)
+    {
+        fTimeStamp[0] = t.fTimeStamp[0];
+        fTimeStamp[1] = t.fTimeStamp[1];
+        fDuration = t.fDuration;
+    }
+
+    void operator=(MTime &t)
+    {
+        fTimeStamp[0] = t.fTimeStamp[0];
+        fTimeStamp[1] = t.fTimeStamp[1];
+        fDuration = t.fDuration;
+    }
+
+    ~MTime() {}
+
+    void Print(Option_t *t=NULL) const;
+
+    void SetTime(UInt_t t1, UInt_t t0)
+    {
+	fTimeStamp[0] = t1;
+	fTimeStamp[1] = t0;
+    }
+
+    void SetDuration(UInt_t t)
+    {
+	fDuration = t;
+    }
+
+    MTime *GetTime()
+    {
+        return this;
+    }
+
+    UInt_t GetTimeLo()
+    {
+	return fTimeStamp[0];
+    }
+    UInt_t GetTimeHi()
+    {
+	return fTimeStamp[1];
+    }
+
+    UInt_t GetDuration()
+    {
+	return fDuration;
+    }
+
+    ClassDef(MTime, 1)	//A generalized MARS time stamp
+};
+
+inline Double_t operator-(MTime &t1, MTime &t2)
+{
+    return (Double_t)t1.GetTimeLo()-(Double_t)t2.GetTimeLo();
+}
+
+inline Bool_t operator<(MTime &t1, MTime &t2)
+{
+    return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<t2.GetTimeLo());
+}
+
+inline Bool_t operator>(MTime &t1, MTime &t2)
+{
+    return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>t2.GetTimeLo());
+}
+
+inline Bool_t operator<=(MTime &t1, MTime &t2)
+{
+    return (t1.GetTimeHi()<=t2.GetTimeHi()) && (t1.GetTimeLo()<=t2.GetTimeLo());
+}
+
+inline Bool_t operator>=(MTime &t1, MTime &t2)
+{
+    return (t1.GetTimeHi()>=t2.GetTimeHi()) && (t1.GetTimeLo()>=t2.GetTimeLo());
+}
+
+inline Bool_t operator==(MTime &t1, MTime &t2)
+{
+    return (t1.GetTimeLo()==t2.GetTimeLo()) && (t1.GetTimeHi()==t2.GetTimeHi());
+}
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mbase/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mbase/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mbase/Makefile	(revision 1638)
@@ -0,0 +1,69 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+INCLUDES = -I. -I../mraw -I../MRawFormat -I../mmc -I../mfileio -I../mmain
+
+# @code 
+
+CINT     = Base
+LIB      = mbase.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MLog.cc \
+	   MParContainer.cc \
+	   MParList.cc \
+	   MInputStreamID.cc \
+           MTask.cc \
+	   MTaskList.cc \
+           MFilter.cc \
+           MEvtLoop.cc \
+           MIter.cc \
+           MGList.cc \
+           MGTask.cc \
+           MGGroupFrame.cc \
+	   MArray.cc \
+	   MArrayB.cc \
+	   MArrayS.cc \
+           MTime.cc \
+           MClone.cc \
+           MContinue.cc \
+           MPrint.cc \
+           MLogManip.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataIncl.h	(revision 1638)
@@ -0,0 +1,10 @@
+#ifndef __CINT__
+
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/DataLinkDef.h	(revision 1638)
@@ -0,0 +1,15 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MData+;
+#pragma link C++ class MDataArray+;
+#pragma link C++ class MDataElement+;
+#pragma link C++ class MDataList+;
+#pragma link C++ class MDataValue+;
+#pragma link C++ class MDataMember+;
+#pragma link C++ class MDataChain+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.cc	(revision 1638)
@@ -0,0 +1,80 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MData
+//
+//   This base class defines an interface to a generalized value.
+//   This value can be a simple number, it can also be a data member
+//   of a class or some kind of concatenation of MData objects.
+//
+//   A class inheriting from MData must implement:
+//
+//    - Double_t GetValue() const
+//      which return the value corresponding to the object
+//
+//    - Bool_t IsValid() const
+//      should tell whether the object is valid (eg if the object parses
+//      a string the result might be invalid)
+//
+//    - Bool_t PreProcess(const MParList *plist)
+//      which can be used to get some necessary data (befor processing)
+//      from the parlist.
+//
+//    - TString GetRule()
+//      returns the rule as a text which would recreate the same structure
+//      when used in a MDataChain
+//
+//    - TString GetDataMember()
+//      returns the names (seperated by a comma) used by this class. This
+//      is mainly used for the AutoScheme when reading data from a file.
+//      (s.MReadTree)
+//
+//   The 'must' ist represented by the =0 in the class header. In the C++
+//   language this is called an abstract member function. Because the
+//   class contains abstract member function which makes it impossible
+//   to create an instance of this class one calls it also:
+//   abstract base class
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MData.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+
+ClassImp(MData);
+
+Bool_t MData::AsciiWrite(ostream &out) const
+{
+    out << GetValue() << " ";
+    return kTRUE;
+}
+
+void MData::Print(Option_t *opt) const
+{
+    *fLog << GetRule() << flush;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MData.h	(revision 1638)
@@ -0,0 +1,33 @@
+#ifndef MARS_MData
+#define MARS_MData
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MData                                                                  //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MParList;
+
+class MData : public MParContainer
+{
+public:
+    virtual Double_t GetValue() const = 0;
+    virtual Bool_t   IsValid() const = 0;
+    virtual Bool_t   PreProcess(const MParList *plist) = 0;
+    virtual TString  GetRule() const = 0;
+    virtual TString  GetDataMember() const { return ""; }
+
+    Double_t operator()() { return GetValue(); }
+
+    void Print(Option_t *opt = "") const;
+    Bool_t AsciiWrite(ostream &out) const;
+
+    ClassDef(MData, 0) // A Base class for a generalized value
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.cc	(revision 1638)
@@ -0,0 +1,185 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataArray
+//
+//   An Array of MData derived classes.
+//   It can be used, eg, in MHMatrix for description of the columns.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataArray.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataChain.h"
+
+ClassImp(MDataArray);
+
+static const TString gsDefName  = "MDataArray";
+static const TString gsDefTitle = "Array to store MData cntainers";
+
+// --------------------------------------------------------------------------
+//
+// Constructor
+//
+MDataArray::MDataArray(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new data rule as a new entry (MDataChain)
+//
+void MDataArray::AddEntry(const TString rule)
+{
+    TObject *obj = new MDataChain(rule);
+    obj->SetBit(kCanDelete);
+    fList.Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new data as a new entry (MData). If the destructor of MDataArray
+// should delete the object set its bit kCanDelete
+//
+void MDataArray::AddEntry(MData *data)
+{
+    fList.Add(data);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the i-th entry
+//
+MData &MDataArray::operator[](Int_t i) const
+{
+    return (MData&)*((TObjArray)fList)[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data value of the i-th entry
+//
+Double_t MDataArray::operator()(Int_t i)
+{
+    return ((MData*)fList[i])->GetValue();
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataArray::PreProcess(const MParList *plist)
+{
+    if (fList.GetSize()==0)
+    {
+        *fLog << err << "Error - No Column specified... aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        if (!data->PreProcess(plist))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the rules for all entries of the array
+//
+void MDataArray::Print(Option_t *opt) const
+{
+    Int_t n=0;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+    {
+        *fLog << all << " Line " << setw(3) << n++ << ": " << flush;
+        data->Print();
+        *fLog << endl;
+    }
+}
+
+Bool_t MDataArray::AsciiWrite(ostream &out) const
+{
+    ((TObjArray)fList).ForEach(MParContainer, AsciiWrite)(out);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MDataArray::StreamPrimitive(ofstream &out) const
+{
+    out << "   MDataArray " << GetUniqueName();
+
+    if (fName!=gsDefName)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\")";
+    }
+    out << ";" << endl;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        out << "   " << GetUniqueName() << ".AddEntry(\"" << data->GetRule() << "\");" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data members existing in this array in a comma-seperated list
+// (This is mainly used for MTask::AddToBranchList)
+//
+TString MDataArray::GetDataMember() const
+{
+    TString str;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+    {
+        if (data->GetDataMember().IsNull())
+            continue;
+
+        str += ",";
+        str += data->GetDataMember();
+    }
+    return str;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataArray.h	(revision 1638)
@@ -0,0 +1,47 @@
+#ifndef MARS_MDataArray
+#define MARS_MDataArray
+
+/////////////////////////////////////////////////////////////////////////////
+//              
+//  MDataArray  
+//
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MData;
+class MParList;
+
+class MDataArray : public MParContainer
+{
+    TObjArray fList;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MDataArray(const char *name=NULL, const char *title=NULL);
+
+    void AddEntry(const TString rule);
+    void AddEntry(MData *data);
+
+    MData &operator[](Int_t i) const;
+    Double_t operator()(Int_t i);
+
+    Bool_t PreProcess(const MParList *plist);
+
+    TString GetDataMember() const;
+
+    void Print(Option_t *opt = "") const;
+    Bool_t AsciiWrite(ostream &out) const;
+
+    Int_t GetNumEntries() const { return fList.GetEntries(); }
+
+    ClassDef(MDataArray, 1) // An array of MData containers
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.cc	(revision 1638)
@@ -0,0 +1,582 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataChain
+//
+// With this chain you can concatenate simple mathematical operations on
+// members of mars containers.
+//
+// In the constructor you can give rule, like
+//   "HillasSource.fDist / MHillas.fLength"
+// Where MHillas/HillasSource is the name of the parameter container in
+// the parameter list and fDist/fLength is the name of the data members
+// in the containers. The result will be fDist divided by fLength.
+//
+// You can also use brackets:
+//   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
+//
+// The allowed operations are: +, -, *, /
+//
+// Warning: There is no priority rule build in. So better use brackets
+//   to get correct results. The rule is parsed/evaluated from the left
+//   to the right, which means:
+//
+//   "MHillas.fWidth + MHillas.fLength / HillasSource.fDist"
+//
+//    is parses as
+//
+//   "(MHillas.fWidth + MHillas.fLength) / HillasSource.fDist"
+//
+// You can also use mathmatical operators, eg:
+//   "5*log10(MMcEvt.fEnergy*MHillas.fSize)"
+//
+// The allowed operators are:
+//   exp(x)    e^x
+//   log(x)    natural logarithm of x
+//   pow10(x)  10^x
+//   log10(x)  logarithm of x to base ten
+//   cos(x)    cosine of x
+//   sin(x)    sine of x
+//   tan(x)    tangent of x
+//   cosh(x)   hyperbolic cosine of x
+//   sinh(x)   hyperbolic sine of x
+//   tanh(x)   hyperbolic tangent of x
+//   acos(x)   arc cosine (inverse cosine) of x
+//   asin(x)   arc sine (inverse sine) of x
+//   atan(x)   arc tangent (inverse tangent) of x
+//   sqrt(x)   square root of x
+//   abs(x)    absolute value of x, |x|
+//   floor(x)  round down to the nearest integer (floor(9.9)=9)
+//
+//
+// FIXME: The possibility to use other objects inheriting from MData
+//        is missing.
+//        Maybe we can use gInterpreter->Calc("") for this.
+//        gROOT->ProcessLineFast("line");
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataChain.h"
+
+#include <math.h>         // fabs on Alpha
+#include <ctype.h>        // isalnum, ...
+#include <stdlib.h>       // strtod, ...
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataList.h"
+#include "MDataValue.h"
+#include "MDataMember.h"
+#include "MDataElement.h"
+
+ClassImp(MDataChain);
+
+// --------------------------------------------------------------------------
+//
+//  Constructor which takes a rule and a surrounding operator as argument
+//
+MDataChain::MDataChain(const char *rule, OperatorType_t op)
+    : fOperatorType(op)
+{
+    fName  = "MDataChain";
+    fTitle = rule;
+
+    fMember=ParseString(rule, 1);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor
+//
+MDataChain::MDataChain()
+    : fMember(NULL), fOperatorType(kENoop)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor taking a rule as an argument. For more details see
+// class description
+//
+MDataChain::MDataChain(const char *rule, const char *name, const char *title)
+    : fOperatorType(kENoop)
+{
+    fName  = name  ? name  : "MDataChain";
+    fTitle = title ? title : rule;
+
+    *fLog << inf << "Trying to resolve rule... " << flush;
+    if (!(fMember=ParseString(rule, 1)))
+    {
+        *fLog << err << dbginf << "Parsing '" << rule << "' failed." << endl;
+        return;
+    }
+    *fLog << inf << "found: " << flush;
+    fMember->Print();
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataChain::PreProcess(const MParList *pList)
+{
+    return fMember ? fMember->PreProcess(pList) : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one member has the ready-to-save flag.
+//
+Bool_t MDataChain::IsReadyToSave() const
+{
+    *fLog << all << "fM=" << fMember << "/" << (int)fMember->IsReadyToSave() << " " << endl;
+    return fMember ? fMember->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete filters.
+//
+MDataChain::~MDataChain()
+{
+    if (fMember)
+        delete fMember;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of alphanumeric characters (including '.')
+// in the given string
+//
+Int_t MDataChain::IsAlNum(TString txt)
+{
+    int l = txt.Length();
+    for (int i=0; i<l; i++)
+    {
+        if (!isalnum(txt[i]) && txt[i]!='.' && /*txt[i]!='['&&txt[i]!=']'&&*/
+            ((txt[i]!='-' && txt[i]!='+') || i!=0))
+            return i;
+    }
+
+    return l;
+}
+
+Int_t MDataChain::GetBracket(TString txt, char open, char close)
+{
+    Int_t first=1;
+    for (int cnt=0; first<txt.Length(); first++)
+    {
+        if (txt[first]==open)
+            cnt++;
+        if (txt[first]==close)
+            cnt--;
+        if (cnt==-1)
+            break;
+    }
+    return first;
+}
+
+// --------------------------------------------------------------------------
+//
+// Compare a given text with the known operators. If no operator match
+// kENoop is retunred, otherwise the corresponding OperatorType_t
+//
+MDataChain::OperatorType_t MDataChain::ParseOperator(TString txt) const
+{
+    txt.ToLower();
+
+    if (txt=="abs")   return kEAbs;
+    if (txt=="fabs")  return kEAbs;
+    if (txt=="log")   return kELog;
+    if (txt=="log10") return kELog10;
+    if (txt=="sin")   return kESin;
+    if (txt=="cos")   return kECos;
+    if (txt=="tan")   return kETan;
+    if (txt=="sinh")  return kESinH;
+    if (txt=="cosh")  return kECosH;
+    if (txt=="tanh")  return kETanH;
+    if (txt=="asin")  return kEASin;
+    if (txt=="acos")  return kEACos;
+    if (txt=="atan")  return kEATan;
+    if (txt=="sqrt")  return kESqrt;
+    if (txt=="exp")   return kEExp;
+    if (txt=="pow10") return kEPow10;
+    if (txt=="sgn")   return kESgn;
+    if (txt=="floor") return kEFloor;
+    if (txt[0]=='-')  return kENegative;
+    if (txt[0]=='+')  return kEPositive;
+
+    return kENoop;
+}
+
+// --------------------------------------------------------------------------
+//
+// Core of the data chain. Here the chain is constructed out of the rule.
+//
+MData *MDataChain::ParseString(TString txt, Int_t level)
+{
+    MData *member0=NULL;
+
+    char type=0;
+    int nlist = 0;
+
+    while (!txt.IsNull())
+    {
+        MData *newmember = NULL;
+
+        txt = txt.Strip(TString::kBoth);
+
+        switch (txt[0])
+        {
+        case '(':
+            {
+                //
+                // Search for the corresponding bracket
+                //
+                Int_t first=GetBracket(txt, '(', ')');
+
+                if (first==txt.Length())
+                {
+                    *fLog << err << dbginf << "Syntax Error: ')' missing." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+
+                //
+                // Make a copy of the 'interieur' and delete the substringä
+                // including the brackets
+                //
+                TString sub = txt(1, first-1);
+                txt.Remove(0, first+1);
+
+                //
+                // Parse the substring
+                //
+                newmember = ParseString(sub, level+1);
+                if (!newmember)
+                {
+                    *fLog << err << dbginf << "Parsing '" << sub << "' failed." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+            }
+            break;
+
+        case ')':
+            *fLog << err << dbginf << "Syntax Error: Too many ')'" << endl;
+            if (member0)
+                delete member0;
+            return NULL;
+
+        case '+':
+        case '-':
+        case '*':
+        case '/':
+            if (member0)
+            {
+                //
+                // Check for the type of the symbol
+                //
+                char is = txt[0];
+                txt.Remove(0, 1);
+
+                //
+                // If no filter is available or the available filter
+                // is of a different symbols we have to create a new
+                // data list with the new symbol
+                //
+                if (/*!member0->InheritsFrom(MDataMember::Class()) ||*/ type!=is)
+                {
+                    MDataList *list = new MDataList(is);
+                    list->SetName(Form("List_%c_%d", is, 10*level+nlist++));
+
+                    list->SetOwner();
+                    list->AddToList(member0);
+
+                    member0 = list;
+
+                    type = is;
+                }
+                continue;
+            }
+
+            if (txt[0]!='-' && txt[0]!='+')
+            {
+                *fLog << err << dbginf << "Syntax Error: First argument of symbol '";
+                *fLog << txt[0] << "' missing." << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            // FALLTHROU
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+            if ((txt[0]!='-' && txt[0]!='+') || isdigit(txt[1]) || txt[1]=='.')
+            {
+                char *end;
+                Double_t num = strtod(txt.Data(), &end);
+                if (!end || txt.Data()==end)
+                {
+                    *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+
+                txt.Remove(0, end-txt.Data());
+
+                newmember = new MDataValue(num);
+                break;
+            }
+
+            // FALLTHROUH
+
+        default:
+            int i = IsAlNum(txt);
+
+            if (i==0)
+            {
+                *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            TString text = txt(0, i);
+
+            txt.Remove(0, i);
+            txt = txt.Strip(TString::kBoth);
+
+            if (!txt.IsNull() && txt[0]=='[')
+            {
+                Int_t first = GetBracket(txt, '[', ']');
+                TString op  = txt(1, first-1);
+                txt.Remove(0, first+1);
+
+                newmember = new MDataElement(text, atoi(op));
+                break;
+            }
+            if ((txt.IsNull() || txt[0]!='(') && text[0]!='-' && text[0]!='+')
+            {
+                newmember = new MDataMember(text.Data());
+                break;
+            }
+
+            OperatorType_t op = ParseOperator(text);
+            if (op==kENoop)
+            {
+                *fLog << err << dbginf << "Syntax Error: Operator '" << text << "' unknown." << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            Int_t first = GetBracket(txt, '(', ')');
+            TString sub = op==kENegative || op==kEPositive ? text.Remove(0,1) + txt : txt(1, first-1);
+            txt.Remove(0, first+1);
+
+            newmember = new MDataChain(sub, op);
+            if (!newmember->IsValid())
+            {
+                *fLog << err << dbginf << "Syntax Error: Error parsing contents '" << sub << "' of operator " << text << endl;
+                delete newmember;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+        }
+
+        if (!member0)
+        {
+            member0 = newmember;
+            continue;
+        }
+
+        if (!member0->InheritsFrom(MDataList::Class()))
+            continue;
+
+        ((MDataList*)member0)->AddToList(newmember);
+    }
+
+    return member0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the value described by the rule
+//
+Double_t MDataChain::GetValue() const
+{
+    if (!fMember)
+    {
+        *fLog << warn << "MDataChain not valid." << endl;
+        return 0;
+    }
+
+    const Double_t val = fMember->GetValue();
+
+    switch (fOperatorType)
+    {
+    case kEAbs:      return fabs(val);
+    case kELog:      return log(val);
+    case kELog10:    return log10(val);
+    case kESin:      return sin(val);
+    case kECos:      return cos(val);
+    case kETan:      return tan(val);
+    case kESinH:     return sinh(val);
+    case kECosH:     return cosh(val);
+    case kETanH:     return tanh(val);
+    case kEASin:     return asin(val);
+    case kEACos:     return acos(val);
+    case kEATan:     return atan(val);
+    case kESqrt:     return sqrt(val);
+    case kEExp:      return exp(val);
+    case kEPow10:    return pow(10, val);
+    case kESgn:      return val<0 ? -1 : 1;
+    case kENegative: return -val;
+    case kEPositive: return val;
+    case kEFloor:    return floor(val);
+    case kENoop:     return val;
+    }
+
+    *fLog << warn << "No Case for " << fOperatorType << " available." << endl;
+
+    return 0;
+}
+
+    /*
+void MDataChain::Print(Option_t *opt) const
+{
+    *fLog << GetRule() << flush;
+    Bool_t bracket = fOperatorType!=kENoop && !fMember->InheritsFrom(MDataList::Class());
+
+    switch (fOperatorType)
+    {
+    case kEAbs:      *fLog << "abs"   << flush; break;
+    case kELog:      *fLog << "log"   << flush; break;
+    case kELog10:    *fLog << "log10" << flush; break;
+    case kESin:      *fLog << "sin"   << flush; break;
+    case kECos:      *fLog << "cos"   << flush; break;
+    case kETan:      *fLog << "tan"   << flush; break;
+    case kESinH:     *fLog << "sinh"  << flush; break;
+    case kECosH:     *fLog << "cosh"  << flush; break;
+    case kETanH:     *fLog << "tanh"  << flush; break;
+    case kEASin:     *fLog << "asin"  << flush; break;
+    case kEACos:     *fLog << "acos"  << flush; break;
+    case kEATan:     *fLog << "atan"  << flush; break;
+    case kESqrt:     *fLog << "sqrt"  << flush; break;
+    case kEExp:      *fLog << "exp"   << flush; break;
+    case kEPow10:    *fLog << "pow10" << flush; break;
+    case kESgn:      *fLog << "sgn"   << flush; break;
+    case kENegative: *fLog << "-" << flush; break;
+    case kEPositive: *fLog << "+" << flush; break;
+    case kENoop:
+        break;
+    }
+
+    if (bracket)
+        *fLog << "(" << flush;
+
+    fMember->Print();
+
+    if (bracket)
+        *fLog << ")" << flush;
+        }
+        */
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule from all the chain members. This is a rule which could
+// be used to rebuild the chain.
+//
+TString MDataChain::GetRule() const
+{
+    if (!fMember)
+        return "<n/a>";
+
+    TString str;
+
+    Bool_t bracket = fOperatorType!=kENoop && !fMember->InheritsFrom(MDataList::Class());
+
+    switch (fOperatorType)
+    {
+    case kEAbs:      str += "abs"  ; break;
+    case kELog:      str += "log"  ; break;
+    case kELog10:    str += "log10"; break;
+    case kESin:      str += "sin"  ; break;
+    case kECos:      str += "cos"  ; break;
+    case kETan:      str += "tan"  ; break;
+    case kESinH:     str += "sinh" ; break;
+    case kECosH:     str += "cosh" ; break;
+    case kETanH:     str += "tanh" ; break;
+    case kEASin:     str += "asin" ; break;
+    case kEACos:     str += "acos" ; break;
+    case kEATan:     str += "atan" ; break;
+    case kESqrt:     str += "sqrt" ; break;
+    case kEExp:      str += "exp"  ; break;
+    case kEPow10:    str += "pow10"; break;
+    case kESgn:      str += "sgn"  ; break;
+    case kENegative: str += "-"    ; break;
+    case kEPositive: str += "+"    ; break;
+    case kEFloor:    str += "floor"; break;
+    case kENoop:
+        break;
+    }
+
+    if (bracket)
+        str += "(";
+
+    str += fMember->GetRule();
+
+    if (bracket)
+        str += ")";
+
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the chain.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataChain::GetDataMember() const
+{
+    return fMember->GetDataMember();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataChain.h	(revision 1638)
@@ -0,0 +1,74 @@
+#ifndef MARS_MDataChain
+#define MARS_MDataChain
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataList                                                              //
+//                                                                         //
+//  List of several filters                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MDataChain : public MData
+{
+private:
+    MData *fMember; // Filter
+
+    typedef enum {
+        kENoop,
+        kELog10,
+        kELog,
+        kEAbs,
+        kESin,
+        kECos,
+        kETan,
+        kESinH,
+        kECosH,
+        kETanH,
+        kEASin,
+        kEACos,
+        kEATan,
+        kESqrt,
+        kEPow10,
+        kEExp,
+        kESgn,
+        kEPositive,
+        kENegative,
+        kEFloor
+    } OperatorType_t;
+
+    OperatorType_t fOperatorType;
+
+    OperatorType_t ParseOperator(TString txt) const;
+
+    Int_t IsAlNum(TString txt);
+    Int_t GetBracket(TString txt, char open, char close);
+
+    MData *ParseString(TString txt, Int_t level);
+
+    MDataChain(const char *rule, OperatorType_t op);
+
+public:
+    MDataChain();
+    MDataChain(const char *rule, const char *name=NULL, const char *title=NULL);
+    ~MDataChain();
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return fMember ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+//    void Print(Option_t *opt = "") const;
+
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.cc	(revision 1638)
@@ -0,0 +1,118 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataElement
+//
+//  This MData class is used for accessing a column of an MHMatrix object.
+//    eg. MDataElement("Matrix", 5)
+//  will return the 5th column of the MHMatrix object called Matrix.
+//
+//  The row which is accessed must be set before by using
+//  MHMatrix::SetNumRow. If you want to loop through a matrix use
+//  MMatrixLoop.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataElement.h"
+
+#include <fstream.h>
+
+#include "MHMatrix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MDataElement);
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the MHMatrix-object and the column you want to
+// access.
+//
+MDataElement::MDataElement(const char *member, Int_t col)
+    : fMatrixName(member), fNumCol(col), fMatrix(NULL)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the pointer of the MHMatrix-object and the column you want to
+// access.
+//
+MDataElement::MDataElement(MHMatrix *mat, Int_t col)
+    : fMatrixName(mat->GetName()), fNumCol(col), fMatrix(mat)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the value you requested
+//
+Double_t MDataElement::GetValue() const
+{
+    return fMatrix ? (*fMatrix)[fNumCol] : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the pointer to the MHMatrix isn't yet set search for it in the
+// parameter list.
+//
+Bool_t MDataElement::PreProcess(const MParList *plist)
+{
+    if (fMatrix)
+        return kTRUE;
+
+    fMatrix = (MHMatrix*)plist->FindObject(fMatrixName, "MHMatrix");
+    if (!fMatrix)
+    {
+        *fLog << err << "MHMatrix '" << fMatrixName << "' not in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the ready-to-save flag of the data member container
+//
+Bool_t MDataElement::IsReadyToSave() const
+{
+    return IsValid() ? fMatrix->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the rule used to identify this object in a datachain
+//
+TString MDataElement::GetRule() const
+{
+    TString rule = fMatrixName + "[";
+    rule += fNumCol;
+    return rule+"]";
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataElement.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MDataElement
+#define MARS_MDataElement
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataElement                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MHMatrix;
+
+class MDataElement : public MData
+{
+private:
+    TString   fMatrixName;
+    Int_t     fNumCol;
+
+    MHMatrix *fMatrix;
+
+public:
+    MDataElement(const char *member=NULL, Int_t col=-1);
+    MDataElement(MHMatrix *mat, Int_t col=-1);
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return kTRUE; }
+    Bool_t IsReadyToSave() const;
+
+    //void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    Double_t operator()() { return GetValue(); }
+
+    ClassDef(MDataElement, 1) // MData object corresponding to a element of an MHMatrix
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.cc	(revision 1638)
@@ -0,0 +1,344 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataList
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataList);
+
+// --------------------------------------------------------------------------
+//
+//   Default Constructor. Not for usage!
+//
+MDataList::MDataList()
+{
+    fSign = kENone;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Constructor.
+//
+//   Specify the operation which is used to evaluate the
+//   result of this list.
+//
+//   Options:
+//      *,  /,  -,  +
+//
+MDataList::MDataList(char type)
+{
+    switch (type)
+    {
+    case '*':
+        fSign = kEMult;
+        return;
+    case '/':
+        fSign = kEDiv;
+        return;
+    case '-':
+        fSign = kEMinus;
+        return;
+    case '+':
+        fSign = kEPlus;
+        return;
+    default:
+        fSign = kENone;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//   CopyConstructor
+//
+MDataList::MDataList(MDataList &ts)
+{
+    fMembers.AddAll(&ts.fMembers);
+    fSign = ts.fSign;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Evaluates and returns the result of the member list.
+//  The expression is evaluated step by step, eg:
+//  ((member[0] # member[1]) # member[3]) # member[4])
+//  The '#' stands for the boolean operation which is specified in
+//  the constructor.
+//
+Double_t MDataList::GetValue() const
+{
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    if (!member)
+        return kTRUE;
+
+    Double_t val = member->GetValue();
+
+    //
+    // loop over all members
+    //
+    switch (fSign)
+    {
+    case kENone:
+        return 0;
+
+    case kEPlus:
+        while ((member=(MData*)Next()))
+            val += member->GetValue();
+        break;
+
+    case kEMinus:
+        while ((member=(MData*)Next()))
+            val -= member->GetValue();
+        break;
+
+    case kEMult:
+        while ((member=(MData*)Next()))
+            val *= member->GetValue();
+        break;
+
+    case kEDiv:
+        while ((member=(MData*)Next()))
+        {
+            Double_t d = member->GetValue();
+            if (d==0)
+            {
+                *fLog << warn << "Warning: Division by zero (" << member->GetName() << ")" << endl;
+                return 0;
+            }
+            val /= d;
+        }
+        break;
+    }
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one member has the ready-to-save flag.
+//
+Bool_t MDataList::IsReadyToSave() const
+{
+    TIter Next(&fMembers);
+
+    MData *data = NULL;
+
+    while ((data=(MData*)Next()))
+        if (data->IsReadyToSave())
+            return kTRUE;
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to add a new member to the list call this function with the
+// pointer to the member to be added. 
+//
+Bool_t MDataList::AddToList(MData *member)
+{
+    if (!member)
+        return kTRUE;
+
+    if (fMembers.FindObject(member))
+    {
+        *fLog << warn << dbginf << "Filter already existing... skipped." << endl;
+        return kTRUE;
+    }
+
+    fMembers.Add(member);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataList::PreProcess(const MParList *plist)
+{
+    TIter Next(&fMembers);
+
+    MData *member=NULL;
+
+    //
+    // loop over all members
+    //
+    while ((member=(MData*)Next()))
+        if (!member->PreProcess(plist))
+        {
+            *fLog << err << "Error - Preprocessing Data Member ";
+            *fLog << member->GetName() << " in " << fName << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// If you want to use a verbose output ("and") instead of a symbolic ("&")
+// one the option string must conatin a "v"
+//
+/*
+void MDataList::Print(Option_t *opt) const
+{
+    *fLog << "(";
+
+    TIter Next(&fMembers);
+
+    TObject *member=Next();
+
+    //
+    // loop over all members
+    //
+    if (!member)
+    {
+        *fLog << "<empty>)" << flush;
+        return;
+    }
+
+    member->Print();
+
+    while ((member=Next()))
+    {
+        switch (fSign)
+        {
+        case kENone:
+            break;
+
+        case kEPlus:
+            *fLog << "+";
+            break;
+
+        case kEMinus:
+            *fLog << "-";
+            break;
+
+        case kEMult:
+            *fLog << "*";
+            break;
+
+        case kEDiv:
+            *fLog << "/";
+            break;
+        }
+
+        member->Print();
+    }
+
+    *fLog << ")" << flush;
+    }
+    */
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule from all the list members. This is a rule which could
+// be used to rebuild the list using the constructor of a MDataChain
+//
+TString MDataList::GetRule() const
+{
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    //
+    // loop over all members
+    //
+    if (!member)
+        return "(<empty>)";
+
+    TString str = "(";
+
+    str += member->GetRule();
+
+    while ((member=(MData*)Next()))
+    {
+        switch (fSign)
+        {
+        case kENone:
+            break;
+
+        case kEPlus:
+            str += "+";
+            break;
+
+        case kEMinus:
+            str += "-";
+            break;
+
+        case kEMult:
+            str += "*";
+            break;
+
+        case kEDiv:
+            str += "/";
+            break;
+        }
+
+        str += member->GetRule();
+    }
+
+    str += ")";
+
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the chain.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataList::GetDataMember() const
+{
+    TString str;
+
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    if (!member->GetDataMember().IsNull())
+        str += member->GetDataMember();
+
+    while ((member=(MData*)Next()))
+    {
+        if (!member->GetDataMember().IsNull())
+        {
+            str += ",";
+            str += member->GetDataMember();
+        }
+    }
+
+    return str;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataList.h	(revision 1638)
@@ -0,0 +1,56 @@
+#ifndef MARS_MDataList
+#define MARS_MDataList
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataList                                                              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MParList;
+
+class MDataList : public MData
+{
+private:
+    TOrdCollection fMembers;	// Container for the filters
+
+    typedef enum { kENone, kEPlus, kEMinus, kEMult, kEDiv } SignType_t;
+    SignType_t fSign;
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    MDataList();
+    MDataList(char type);
+    MDataList(MDataList &ts);
+    ~MDataList()
+    {
+        if (TestBit(kIsOwner))
+            fMembers.SetOwner();
+    }
+
+    Bool_t AddToList(MData *member);
+    void SetOwner(Bool_t enable=kTRUE) { enable ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Bool_t IsValid() const { return fMembers.GetSize() ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+//    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    ClassDef(MDataList, 1) // A concatenation of MData objects by one operator
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.cc	(revision 1638)
@@ -0,0 +1,189 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataMember
+//
+//   This objects corresponds to the data member of another object.
+//   You can either specify the object as a string, eg "MHillas.fWidth"
+//   where MHillas is the name of the container in the parameterlist
+//   and fWidth is it's data member, or you can specify it by giving
+//   the pointer corresponding to the instance of your object and
+//   a TMethodCall pointer corresponding to the Member function returning
+//   the requested value.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataMember.h"
+
+#include <fstream.h>
+
+#include <TMethodCall.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MDataMember);
+
+// --------------------------------------------------------------------------
+//
+//  obj is a pointer to the instance of your class from which the data
+//  should be requested. TMethodCall (s. root dox) is a pointer
+//  to a TMethodCall object which should be the getter function for
+//  the data you want to get.
+//
+MDataMember::MDataMember(MParContainer *obj, TMethodCall *call)
+{
+    fObject = obj;
+    fCall   = call;
+
+    fDataMember = (TString)obj->GetName() + "." + call->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+//  obj is a pointer to the instance of your class from which the data
+//  should be requested. TMethodCall (s. root dox) is a pointer
+//  to a TMethodCall object which should be the getter function for
+//  the data you want to get.
+//
+MDataMember::MDataMember(MParContainer *obj, const TString call)
+{
+    fObject = obj;
+    fCall   = obj->GetterMethod(call);
+
+    fDataMember = (TString)obj->GetName() + "." + call;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the value you requested
+//
+Double_t MDataMember::GetValue() const
+{
+    if (!fCall)
+    {
+        *fLog << err << "No TMethodCall for " << fDataMember << " of ";
+        *fLog << fObject->GetName() << " available... returning 0." << endl;
+        return 0;
+    }
+
+    switch (fCall->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        fCall->Execute(fObject, l);
+        return (Double_t)l;
+
+    case TMethodCall::kDouble:
+        Double_t v;
+        fCall->Execute(fObject, v);
+        return v;
+
+    default:
+        *fLog << err << "DataMember " << fDataMember << " of ";
+        *fLog << fObject->GetName() << " neither int nor float... returning 0." << endl;
+        return 0;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// If a string was given PreProcess try to resolv the object name and
+// tries to get it from the parlist. And also tries to resolve
+// the data member (variable) name you requested and tries to get a
+// corresponding TMethodCall from the root Dictionary.
+// Remark: If your Data Member is called fDataMember the corresponding
+//         getter Method in your class must be calles fDataMember
+//
+Bool_t MDataMember::PreProcess(const MParList *plist)
+{
+    if (fCall)
+        return kTRUE;
+
+    TString cname(fDataMember);
+    TString mname(fDataMember);
+
+    const char *dot = strrchr(cname, '.');
+
+    if (dot)
+    {
+        const int pos = dot-cname;
+
+        cname.Remove(pos);
+        mname.Remove(0, pos+1);
+    }
+
+    fObject = (MParContainer*)plist->FindObject(cname);
+    if (!fObject)
+    {
+        *fLog << err << "Object '" << cname << "' not in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCall = fObject->GetterMethod(mname);
+
+    return fCall ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the ready-to-save flag of the data member container
+//
+Bool_t MDataMember::IsReadyToSave() const
+{
+    return IsValid() ? fObject->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the name of the data member without an CR.
+//
+/*
+void MDataMember::Print(Option_t *opt) const
+{
+    *fLog << fName << flush;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule which cn be used in a MDataChain to describe this object
+//
+TString MDataMember::GetRule() const
+{
+    return fDataMember;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the data member.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataMember::GetDataMember() const
+{
+    return fDataMember;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataMember.h	(revision 1638)
@@ -0,0 +1,44 @@
+#ifndef MARS_MDataMember
+#define MARS_MDataMember
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataMember                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MDataMember : public MData
+{
+private:
+    TString fDataMember;
+
+    MParContainer *fObject;
+    TMethodCall   *fCall;
+
+public:
+    MDataMember(const char *member=NULL) : fObject(NULL), fCall(NULL)
+    {
+        fDataMember = member;
+    }
+
+    MDataMember(MParContainer *obj, TMethodCall *call);
+    MDataMember(MParContainer *obj, const TString call);
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return fCall ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+    //void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    ClassDef(MDataMember, 1) // MData object corresponding to a single data member of a Mars container
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.cc	(revision 1638)
@@ -0,0 +1,50 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataValue
+//
+//   An MData object which corresponds to a simple value like 5.5, or 7.9
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataValue.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataValue);
+
+// --------------------------------------------------------------------------
+//
+// Return the value as a string
+//
+TString MDataValue::GetRule() const
+{
+    TString str;
+    str += fValue;
+    return str.Strip(TString::kBoth);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/MDataValue.h	(revision 1638)
@@ -0,0 +1,36 @@
+#ifndef MARS_MDataValue
+#define MARS_MDataValue
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataValue                                                             //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MDataValue : public MData
+{
+private:
+    Double_t fValue;
+
+public:
+    MDataValue(Double_t v) : fValue(v)
+    {
+    }
+
+    Double_t GetValue() const { return fValue; }
+    Bool_t PreProcess(const MParList *plist) { return kTRUE; }
+
+    Bool_t IsValid() const { return kTRUE; }
+    Bool_t IsReadyToSave() const { return kFALSE; }
+
+    //void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    ClassDef(MDataValue, 1) // MData object corresponding to a single value
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdata/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdata/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdata/Makefile	(revision 1638)
@@ -0,0 +1,56 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+INCLUDES = -I. -I../mbase -I../mhist
+
+# @code 
+
+CINT     = Data
+LIB      = mdata.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MData.cc \
+	   MDataArray.cc \
+           MDataElement.cc \
+	   MDataMember.cc \
+	   MDataValue.cc \
+	   MDataList.cc \
+	   MDataChain.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/DataCheckLinkDef.h	(revision 1638)
@@ -0,0 +1,9 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MDumpEvtHeader+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 1638)
@@ -0,0 +1,98 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MDumpEvtHeader
+//
+//  Print out some event header information to the screen. This maybe useful
+//  if you are not sure what the events in the file conatins or you
+//  want to check for the contents.
+//
+//  Input Containers:
+//   MRawEvtHeader, MRawEvtData
+//
+//  Output Containers:
+//   -/-
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MDumpEvtHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MDumpEvtHeader);
+
+// --------------------------------------------------------------------------
+//
+// Preprocessing of class. Check for the two container which should
+// get printed by the Process-function: MRawEvtHeader and MRawEvtData.
+// If one of the two doesn't exist (input containers) stop processing of
+// data.
+//
+Bool_t MDumpEvtHeader::PreProcess (MParList *pList)
+{
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+    if (!fRawEvtHeader)
+    {
+        *fLog << err << dbginf << "- Error: MRawEvtHeader not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvtData)
+    {
+        *fLog << err << dbginf << "- Error: MRawEvtData not found... exit." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE ;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Print out information of the actual event (header) and print the
+// pixel ID's of all pixels in this event.
+//
+Bool_t MDumpEvtHeader::Process()
+{
+    fRawEvtHeader->Print();
+
+    *fLog << all;
+
+    MRawEvtPixelIter pixel(fRawEvtData);
+
+    while (pixel.Next())
+        *fLog << " " << pixel.GetPixelId();
+
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MDumpEvtHeader.h	(revision 1638)
@@ -0,0 +1,28 @@
+#ifndef MARS_MDumpEvtHeader
+#define MARS_MDumpEvtHeader
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtHeader;
+class MRawEvtData;
+class MParList;
+
+class MDumpEvtHeader : public MTask
+{
+private:
+    MRawEvtHeader *fRawEvtHeader;
+    MRawEvtData   *fRawEvtData;
+
+public:
+  MDumpEvtHeader () : fRawEvtHeader(NULL) { };
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process();
+  
+  ClassDef(MDumpEvtHeader, 0)	// Class to dump the pixel ids of a raw evt to the screen
+
+};
+    
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.cc	(revision 1638)
@@ -0,0 +1,436 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MGDisplayAdc.h"
+
+#include <iostream.h>            // cout for debugging
+
+#include <TGButton.h>            // TGTextButton
+#include <TCanvas.h>             // TCanvas.h
+#include <TGMsgBox.h>            // TGMsgBox
+#include <TGListBox.h>           // TGListBox
+#include <TGSlider.h>            // TGVSlider
+#include <TGButtonGroup.h>       // TGVButtonGroup
+#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
+
+#include "MHFadcCam.h"
+
+enum ComIdentDisplayAdc
+{
+    M_BUTTON_SAVE,
+    M_BUTTON_PRINT,
+    M_BUTTON_PRINTALL,
+    M_BUTTON_CLOSE,
+
+    M_BUTTON_PREV,
+    M_BUTTON_NEXT,
+
+    M_LIST_HISTO,
+    M_RADIO_HI,
+    M_RADIO_LO,
+    M_RADIO_LH,
+    M_BUTTON_RESET,
+    M_VSId1
+};
+
+void MGDisplayAdc::AddFrameTop(TGHorizontalFrame *frame)
+{
+    //
+    // left part of top frame
+    //
+    TGVerticalFrame *left = new TGVerticalFrame(frame, 80, 300, kFitWidth);
+    fList->Add(left);
+
+    fHistoList = new TGListBox (left, M_LIST_HISTO);
+    fHistoList->Associate(this);
+    fHistoList->Resize(100, 405);
+
+    fList->Add(fHistoList);
+
+    TGLayoutHints *laylist = new TGLayoutHints(kLHintsNormal, 10, 10, 10, 10);
+    fList->Add(laylist);
+
+    left->AddFrame(fHistoList, laylist);
+
+    //
+    //    middle part of top frame
+    //
+    TGVerticalFrame *mid = new TGVerticalFrame(frame, 80, 20, kFitWidth);
+    fList->Add(mid);
+
+    // ---
+
+    TGTextButton *prev = new TGTextButton(mid, "Prev Histo", M_BUTTON_PREV);
+    TGTextButton *next = new TGTextButton(mid, "Next Histo", M_BUTTON_NEXT);
+    prev->Associate(this);
+    next->Associate(this);
+
+    fList->Add(prev);
+    fList->Add(next);
+
+    // ---
+
+    fSlider = new TGVSlider(mid, 250, kSlider1|kScaleBoth, M_VSId1);
+    fSlider->Associate(this);
+    fSlider->SetRange(1, 577);
+
+    fList->Add(fSlider);
+
+    // ---
+
+    TGVButtonGroup *group = new TGVButtonGroup(mid);
+    fList->Add(group);
+
+    TGRadioButton *radio1 = new TGRadioButton(group, "&High Gain",     M_RADIO_HI);
+    TGRadioButton *radio2 = new TGRadioButton(group, "&Low Gain",      M_RADIO_LO);
+    TGRadioButton *radio3 = new TGRadioButton(group, "H&igh/Low Gain", M_RADIO_LH);
+
+    /* FIXME:
+
+    ~TGRadioButton calls TGRadioButton::TGFrame::GetMainFrame
+    which calles fParent->GetFrame()
+
+    fList->Add(radio1);
+    fList->Add(radio2);
+    fList->Add(radio3);
+    */
+
+    radio3->SetState(kButtonDown);
+
+    radio1->Associate(this);
+    radio2->Associate(this);
+    radio3->Associate(this);
+
+    // ---
+
+    TGLayoutHints *laybut1 = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10,  0, 10);
+    TGLayoutHints *laybut2 = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 10,  5);
+    TGLayoutHints *layslid = new TGLayoutHints(kLHintsCenterX|kLHintsTop);
+
+    fList->Add(laybut1);
+    fList->Add(laybut2);
+    fList->Add(layslid);
+
+    mid->AddFrame(prev,    laybut1);
+    mid->AddFrame(fSlider, layslid);
+    mid->AddFrame(next,    laybut2);
+    mid->AddFrame(group,   laybut2);
+
+    //
+    //    right part of top frame
+    //
+    TGVerticalFrame *right = new TGVerticalFrame(frame, 100, 100, kFitWidth);
+    fList->Add(right);
+
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("fECanv", right, 100, 100);
+    fList->Add(canvas);
+
+    TGLayoutHints *laycanv = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
+    fList->Add(laycanv);
+
+    right->AddFrame(canvas, laycanv);
+
+
+    TGTextButton *reset = new TGTextButton(right, "Reset histo", M_BUTTON_RESET);
+    reset->Associate(this);
+    fList->Add(reset);
+
+    TGLayoutHints *layreset = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 0, 10);
+    fList->Add(layreset);
+
+    right->AddFrame(reset, layreset);
+
+    // ---
+
+    fCanvas = canvas->GetCanvas();
+
+    //
+    // layout the three subframes
+    //
+    TGLayoutHints *layframe1 = new TGLayoutHints(kLHintsTop, 10, 10, 10, 10);
+    TGLayoutHints *layframe2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
+    fList->Add(layframe1);
+    fList->Add(layframe2);
+
+    frame->AddFrame(left,  layframe1);
+    frame->AddFrame(mid,   layframe1);
+    frame->AddFrame(right, layframe2);
+}
+
+void MGDisplayAdc::AddFrameLow(TGHorizontalFrame *frame)
+{
+    //
+    //   the low frame for the control buttons
+    //
+    TGTextButton *but1 = new TGTextButton(frame, "Save",     M_BUTTON_SAVE);
+    TGTextButton *but2 = new TGTextButton(frame, "Print",    M_BUTTON_PRINT);
+    TGTextButton *but3 = new TGTextButton(frame, "PrintAll", M_BUTTON_PRINTALL);
+    TGTextButton *but4 = new TGTextButton(frame, "Close",    M_BUTTON_CLOSE);
+
+    but1->Associate(this);
+    but2->Associate(this);
+    but3->Associate(this);
+    but4->Associate(this);
+
+    fList->Add(but1);
+    fList->Add(but2);
+    fList->Add(but3);
+    fList->Add(but4);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    frame->AddFrame(but1, laybut);
+    frame->AddFrame(but2, laybut);
+    frame->AddFrame(but3, laybut);
+    frame->AddFrame(but4, laybut);
+}
+
+MGDisplayAdc::MGDisplayAdc(MHFadcCam *histos,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h,
+                           UInt_t options)
+: TGTransientFrame(p?p:gClient->GetRoot(), main?main:gClient->GetRoot(), w, h, options),
+  fHistoType(M_RADIO_LH)
+{
+    fHists = (MHFadcCam*)histos->Clone();
+
+    fList = new TList;
+    fList->SetOwner();
+
+    //
+    // Create the to frames
+    //
+    TGHorizontalFrame *frametop = new TGHorizontalFrame(this, 60, 20, kFitWidth);
+    TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
+
+    //
+    // Add frames to 'autodel'
+    //
+    fList->Add(frametop);
+    fList->Add(framelow);
+
+    //
+    // Add the gui elements to the two frames
+    //
+    AddFrameTop(frametop);
+    AddFrameLow(framelow);
+
+    //
+    // layout the two frames in this frame
+    //
+    TGLayoutHints *laytop = new TGLayoutHints(kLHintsTop|kLHintsExpandX,    10, 10, 10, 10);
+    TGLayoutHints *laylow = new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 10, 10, 10, 10);
+
+    AddFrame(frametop, laytop);
+    AddFrame(framelow, laylow);
+
+    //
+    // Setup interieur
+    //
+    BuildHistoList();
+
+    //
+    // Here the initial display is set to hitogram 0
+    //
+    fHistoList->Select(1);
+    UpdateHist();
+
+    //
+    // Setup frame
+    //
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("ADC Spectra");
+    SetIconName("ADC Spectra");
+
+    MapWindow();
+    SetWMSizeHints(950, 500, 1000, 1000, 1, 1);
+}  
+
+MGDisplayAdc::~MGDisplayAdc()
+{ 
+    delete fList;
+    delete fHists;
+}  
+
+void MGDisplayAdc::CloseWindow()
+{
+    //
+    // The close message is generated by the window manager when its close
+    // window menu item is selected.
+    //
+    delete this;
+}
+
+Bool_t MGDisplayAdc::BuildHistoList()
+{
+    //
+    //   looks in the container of the AdcSpectra and reads in the
+    //   Histogramms in there.
+    //
+    //   In the class MHFadcCam are in fact two lists. One for the high and
+    //   one for the low gain. Here we will use only the high gain list!!!
+    //   With some special options (settings in the gui) we will also be able
+    //   to plot the low gain
+    //
+    const Int_t nhi = fHists->GetEntries();
+
+    for (Int_t i=0; i<nhi; i++)
+        fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), i+1);
+
+    fHistoList->MapSubwindows();
+    fHistoList->Layout();
+
+    return kTRUE;
+} 
+
+void MGDisplayAdc::UpdateHist()
+{
+    const Int_t selected = fHistoList->GetSelected();
+
+    if (selected<0)
+    {
+        cout << "MGDisplayAdc: No histograms found in list. " << endl;
+        return;
+    }
+
+    fHistoList->Select(selected); // ???
+
+    fCanvas->Clear();
+
+    switch (fHistoType)
+    {
+    case M_RADIO_HI:
+    case M_RADIO_LO:
+        fCanvas->Divide(1, 1);
+
+        fCanvas->cd();
+        if (fHistoType==M_RADIO_HI)
+            fHists->DrawHi(selected-1);
+        else
+            fHists->DrawLo(selected-1);
+        break;
+
+    case M_RADIO_LH:
+        fCanvas->Divide(1, 2);
+
+        fCanvas->cd(1);
+        fHists->DrawHi(selected-1);
+
+        fCanvas->cd(2);
+        fHists->DrawLo(selected-1);
+        break;
+    }
+
+    fHistoList->SetTopEntry(selected);
+
+    fCanvas->Modified();
+    fCanvas->Update();
+
+    fSlider->SetPosition(selected);
+}
+
+Bool_t MGDisplayAdc::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{     
+    //
+    // Process events generated by the buttons in the frame.
+    //
+    switch (GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case M_BUTTON_SAVE:
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
+
+            case M_BUTTON_PRINT:
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
+
+            case M_BUTTON_RESET:
+                cout << "Sorry, not yet implemented!" << endl;
+                return kTRUE;
+
+            case M_BUTTON_CLOSE:
+                CloseWindow();
+                return kTRUE;
+
+            case M_BUTTON_PREV:
+            case M_BUTTON_NEXT:
+                {
+                    const Int_t selected = fHistoList->GetSelected();
+
+                    if ((parm1==M_BUTTON_PREV && selected==1) ||
+                        (parm1==M_BUTTON_NEXT && selected==577))
+                        return kTRUE;
+
+                    fHistoList->Select(parm1==M_BUTTON_PREV ? selected-1 : selected+1);
+                    UpdateHist();
+                }
+                return kTRUE;
+            }
+            return kTRUE;
+
+        case kCM_RADIOBUTTON:
+            switch(parm1)
+            {
+            case M_RADIO_HI:
+            case M_RADIO_LO:
+            case M_RADIO_LH:
+                fHistoType = parm1;
+                UpdateHist();
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+		
+    case kCM_LISTBOX:
+        if (GET_SUBMSG(msg) == M_LIST_HISTO)
+            UpdateHist();
+
+        return kTRUE;
+
+    case kC_VSLIDER:
+        if (GET_SUBMSG(msg)!=kSL_POS || parm1!=M_VSId1)
+            return kTRUE;
+
+        // Check for the slider movement and sicronise with TGListBox
+        if (parm2<1 || parm2>577)
+            return kTRUE;
+
+        fHistoList->Select(parm2);
+        UpdateHist();
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/MGDisplayAdc.h	(revision 1638)
@@ -0,0 +1,56 @@
+#ifndef MARS_MGDisplayAdc
+#define MARS_MGDisplayAdc
+
+#ifndef ROOT_TFrame
+#include <TGFrame.h>    // TGTransientFrame
+#endif
+
+class TList;
+class TCanvas;
+
+class MHFadcCam;
+
+class TGVSlider;
+class TGListBox;
+class TGTextButton;
+class TGRadioButton;
+class TRootEmbeddedCanvas;
+
+class MGDisplayAdc : public TGTransientFrame
+{
+private:
+    MHFadcCam *fHists;		// Pointer to Container with the histograms
+
+    TList     *fList;
+    TCanvas   *fCanvas;
+    TGVSlider *fSlider;
+    TGListBox *fHistoList;
+
+    Int_t      fHistoType;
+
+    void AddFrameTop(TGHorizontalFrame *frame);
+    void AddFrameLow(TGHorizontalFrame *frame);
+
+    //
+    // Create a main frame with a number of different buttons.
+    //
+    void   UpdateHist();
+    Bool_t BuildHistoList();
+
+public:
+
+    MGDisplayAdc(MHFadcCam *fHists ,
+                 const TGWindow *p=NULL, const TGWindow *main=NULL,
+                 UInt_t w=800, UInt_t h=500,
+                 UInt_t options = kMainFrame|kVerticalFrame);
+
+    ~MGDisplayAdc();
+
+    void  CloseWindow();
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mdatacheck/Makefile	(revision 1638)
@@ -0,0 +1,48 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = DataCheck
+
+#
+# Library name to creatre
+#
+LIB   = mdatacheck.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../mhist
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MDumpEvtHeader.cc \
+	   MGDisplayAdc.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/merpp.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/merpp.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/merpp.cc	(revision 1638)
@@ -0,0 +1,156 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MRawFileRead.h"
+#include "MRawFileWrite.h"
+
+#include "MLog.h"
+#include "MTime.h"
+#include "MArray.h"
+#include "MRawEvtData.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawCrateArray.h"
+#include "MInputStreamID.h"
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// This is an easy implementation of the Merging process                    //
+// (as compilable prog)                                                     //
+//                                                                          //
+// at the moment it reads a binary file ("rawtest.bin") which was written   //
+// in the DAQ raw format.                                                   //
+//                                                                          //
+// The data are stored in root container objects (classes derived from      //
+// TObject like MRawRunHeader)                                              //
+//                                                                          //
+// This containers are written to a root file ("rawtest.root")              //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+int main(const int argc, const char **argv)
+{
+    gLog << "==================================================" << endl ;
+    gLog << "                   MERPP v0.1" << endl;
+    gLog << "      MARS Merging and Preprocessing Program" << endl ;
+    gLog << "            Compiled on <" << __DATE__ << ">" << endl ;
+    gLog << "               Using ROOT v" << ROOTVER << endl ;
+    gLog << "==================================================" << endl ;
+    gLog << endl;
+
+    //
+    // check for the right usage of the program
+    //
+    if (argc<3 || argc>4)
+    {
+        gLog << "Sorry the usage is:" << endl;
+        gLog << "   merpp inputfile outputfile [compression level]" << endl << endl;
+        gLog << "     input file:   Magic DAQ binary file." << endl;
+        gLog << "     ouput file:   Merpped root file." << endl;
+        gLog << "     compr. level: 1..9 [default=9]" << endl << endl;
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(2);
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    const char *kNamein   = argv[1];
+    const char *kNameout  = argv[2];
+    const int   kComprlvl = argc==4 ? atoi(argv[3]) : 9;
+
+    //
+    //     initialize ROOT  (this is obligatory here)
+    //
+    TROOT simple("merpp", "Mars - Merging and Preprocessing Program");
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    if (!gSystem->AccessPathName(kNameout, kFileExists))
+        gLog << "Warning: A file '" << kNameout << "' exists." << endl;
+    else
+        if (!gSystem->AccessPathName(kNameout, kWritePermission))
+        {
+            gLog << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
+            return -1;
+        }
+
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    //
+    // create a (empty) list of parameters which can be used by the tasks
+    // and an (empty) list of tasks which should be executed
+    //
+    MParList plist;
+
+    MTaskList tasks;
+    plist.AddToList(&tasks);
+
+    //
+    // ---- Tho following is only necessary to supress some output ----
+    //
+    MRawRunHeader runheader;
+    plist.AddToList(&runheader);
+
+    MRawEvtHeader evtheader;
+    plist.AddToList(&evtheader);
+
+    MRawEvtData evtdata;
+    plist.AddToList(&evtdata);
+
+    MRawCrateArray cratearray;
+    plist.AddToList(&cratearray);
+
+    MTime evttime("MRawEvtTime");
+    plist.AddToList(&evttime);
+
+    //
+    // create the tasks which should be executed and add them to the list
+    // in the case you don't need parameter containers, all of them can
+    // be created by MRawFileRead::PreProcess
+    //
+    MRawFileRead  reader(kNamein);
+    MRawFileWrite writer(kNameout, "RECREATE", "Magic root-file", kComprlvl);
+    tasks.AddToList(&reader);
+    tasks.AddToList(&writer);
+
+    //
+    // create the looping object and thell it about the parameters to use
+    // and the tasks to execute
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Start the eventloop which reads the raw file (MRawFileRead) and
+    // write all the information into a root file (MRawFileWrite)
+    //
+    // between reading and writing we can do, transformations, checks, etc.
+    // (I'm think of a task like MRawDataCheck)
+    //
+    if (!magic.Eventloop())
+    {
+        gLog << "ERROR: Merging and preprocessing failed!" << endl;
+        return -1;
+    }
+
+    gLog << "Merpp finished successfull!" << endl;
+    return 0;
+}
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispIncl.h	(revision 1638)
@@ -0,0 +1,25 @@
+#ifndef __CINT__
+#include "MParList.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MTime.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MReadTree.h"
+
+
+#include <TGButton.h>       // TGPictureButton
+#include <TGTab.h>          // TGTab
+#include <TGMenu.h>         // TGPopupMenu
+#include <TGMsgBox.h>       // TGMsgBox
+#include <TGListBox.h>      // TGListBox
+#include <TGListView.h>     // TGListBox
+#include <TGSplitter.h>     // TGHorizontal3DLine
+#include <TGSlider.h>       // TGVSlider
+#include <TGLabel.h>        // TGLabel
+#include <TRootEmbeddedCanvas.h>        // TGRootEmbeddedCanvas
+#include <TCanvas.h>        // TCanvas
+#include <TGTextEntry.h>
+
+#endif // __CINT__
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/EvtDispLinkDef.h	(revision 1638)
@@ -0,0 +1,12 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MGEvtDisplay+;
+
+#pragma link C++ class MGFadcDisp+;
+#pragma link C++ class MGCamDisplay+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.cc	(revision 1638)
@@ -0,0 +1,308 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  10/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MGCamDisplay.h"
+
+#include <TList.h>               // TList::Add
+#include <TCanvas.h>             // TCanvas::cd
+#include <TGButton.h>            // TGPictureButton
+#include <TGButtonGroup.h>       // TGVButtonGroup
+
+#include "MGTask.h"              // MGTask::CreateGui
+#include "MClone.h"              // MClone
+#include "MHillasExt.h"          // MHillasExt
+#include "MParList.h"            // MParList::AddToList
+#include "MEvtLoop.h"            // MEvtLoop::GetParList
+#include "MTaskList.h"           // MTaskList::AddToList
+#include "MCamDisplay.h"         // MCamDisplay
+#include "MHillasCalc.h"         // MHillasCalc
+#include "MPedestalCam.h"        // MPedestalCam
+#include "MCerPhotCalc.h"        // MCerPhotCalc
+#include "MMcPedestalCopy.h"     // MMcPedestalCopy
+#include "MMcPedestalNSBAdd.h"   // MMcPedestalNSBAdd
+#include "MBlindPixelCalc.h"     // MBlindPixelCalc
+#include "MImgCleanStd.h"        // MImgCleanStd
+#include "MGeomCamMagic.h"       // MGeomMagicCam
+
+ClassImp(MGCamDisplay);
+
+enum
+{
+    kRButRawEvt,
+    kRButCleanedEvt,
+    kCButHillas
+};
+
+// --------------------------------------------------------------------------
+//
+//  Add Setup elements to GUI.
+//
+void MGCamDisplay::AddSetupElements()
+{
+    //
+    // Create gui elements for vertical frame
+    //
+    TGGroupFrame *grp = new TGGroupFrame(fTab1, "Display");
+    TGVButtonGroup *group = new TGVButtonGroup(grp);
+    fList->Add(group);
+
+    TGRadioButton *but1 = new TGRadioButton(group, "Raw Events",      kRButRawEvt);
+    TGRadioButton *but2 = new TGRadioButton(group, "Cleaned Events",  kRButCleanedEvt);
+    TGCheckButton *but3 = new TGCheckButton(grp,   "Display Ellipse", kCButHillas);
+
+    but2->SetState(kButtonDown);
+    but3->SetState(kButtonDown);
+
+    fDisplayRaw    = kFALSE;
+    fDisplayHillas = kTRUE;
+
+    /*
+     WARNING:
+     Bacause of some strage and hidden dependencies the
+     GetMainFrame call in the destructor of TGButton may fail if some
+     of the other gui elements are deleted first.
+     AddFirst adds the buttons at the beginning of the deletion list,
+     this seems to work.
+     */
+    fList->AddFirst(but1);
+    fList->AddFirst(but2);
+
+    but1->Associate(this);
+    but2->Associate(this);
+    but3->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 15, 0);
+    fList->Add(laybut);
+
+    grp->AddFrame(group);
+    grp->AddFrame(but3, laybut);
+
+    TGLayoutHints *laygrp1 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 0);
+    TGLayoutHints *laygrp2 = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 10, 10, 5, 5);
+
+    fTab1->AddFrame(grp, laygrp1);
+    ((MGTask*)GetTaskList()->FindObject("MImgCleanStd"))->CreateGui(fTab1, laygrp2);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Setup Task and parameter list for hillas calculation,
+//  preprocess tasks and read in first event (process)
+//
+MGeomCam *MGCamDisplay::SetupTaskList()
+{
+    MTaskList *tlist = GetTaskList();
+    MParList  *plist = GetParList();
+
+    MMcPedestalCopy   *pcopy = new MMcPedestalCopy;
+    MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
+    MCerPhotCalc      *ncalc = new MCerPhotCalc;
+    MClone            *clone = new MClone("MCerPhotEvt");
+    MImgCleanStd      *clean = new MImgCleanStd;
+    MBlindPixelCalc   *blind = new MBlindPixelCalc;
+    MHillasCalc       *hcalc = new MHillasCalc;
+
+    tlist->AddToList(pcopy);
+    tlist->AddToList(pdnsb);
+    tlist->AddToList(ncalc);
+    tlist->AddToList(clone);
+    tlist->AddToList(clean);
+    tlist->AddToList(blind);
+    tlist->AddToList(hcalc);
+
+    MGeomCamMagic *geom   = new MGeomCamMagic;
+    MPedestalCam  *pedest = new MPedestalCam;
+    MHillasExt    *hext   = new MHillasExt;
+
+    plist->AddToList(geom);
+    plist->AddToList(pedest);
+    plist->AddToList(hext);
+
+    return geom;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor.
+//
+MGCamDisplay::MGCamDisplay(const char *filename,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h)
+: MGEvtDisplay(filename, "Events", p, main, w, h), fDisplay(NULL)
+{
+    //
+    // Setup Task list for hillas calculation
+    //
+    MGeomCam *geom = SetupTaskList();
+
+    //
+    // Add missing setup elements to GUI
+    //
+    AddSetupElements();
+
+    TCanvas *canv2 = AddTab("Errors");
+    TCanvas *canv3 = AddTab("Phot/Err");
+    TCanvas *canv4 = AddTab("Levels");
+    TCanvas *canv5 = AddTab("Pedestals");
+
+    //
+    // Show camera display for the actual geometry
+    //
+    fDisplay  = new MCamDisplay(geom);
+    fDisplay2 = new MCamDisplay(geom);
+    fDisplay3 = new MCamDisplay(geom);
+    fDisplay4 = new MCamDisplay(geom);
+    fDisplay5 = new MCamDisplay(geom);
+
+    fList->Add(fDisplay);
+    fList->Add(fDisplay2);
+    fList->Add(fDisplay3);
+    fList->Add(fDisplay4);
+    fList->Add(fDisplay5);
+
+    fCanvas->cd();
+    fDisplay->Draw();
+    canv2->cd();
+    fDisplay2->Draw();
+    canv3->cd();
+    fDisplay3->Draw();
+    canv4->cd();
+    fDisplay4->Draw();
+    canv5->cd();
+    fDisplay5->Draw();
+
+
+    ReadFirstEvent();
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Hillas Event Display");
+    SetIconName("Hillas");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Update event display:
+//  dependent on the setup either the uncleaned or cleand data is shown
+//  together with the hillas ellipse or not.
+//
+void MGCamDisplay::UpdateDisplay()
+{
+    if (!IsInitOk())
+        return;
+
+    const MParList *plist = fEvtLoop->GetParList();
+
+    //
+    // Show Hillas ellipse
+    //
+    MHillas *hillas = (MHillas*)plist->FindObject("MHillas");
+
+    hillas->Print();
+    if (fDisplayHillas)
+    {
+        fCanvas->cd();
+        hillas->Draw();
+    }
+    else
+        hillas->Clear();
+
+    //
+    // Display the requested event. This does a Canvas update, too.
+    //
+    MCerPhotEvt  *evt = NULL;
+    if (fDisplayRaw)
+    {
+        //
+        // Get a clone of MCerPhotEvt which is made before the image cleaning
+        //
+        const MClone *clone = (MClone*)GetTaskList()->FindObject("MClone");
+        evt = (MCerPhotEvt*)clone->GetClone();
+    }
+    else
+    {
+        //
+        // Get MCerPhotEvt which containes the cleaned data
+        //
+        evt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    }
+
+    const MImgCleanStd *clean = (MImgCleanStd*)GetTaskList()->FindObject("MImgCleanStd");
+    const MPedestalCam *ped   = (MPedestalCam*)plist->FindObject("MPedestalCam");
+
+    fDisplay->DrawPhotNum(evt);
+    fDisplay2->DrawErrorPhot(evt);
+    fDisplay3->DrawRatio(evt);
+    fDisplay4->DrawLevels(evt, *clean);
+    fDisplay5->DrawPedestals(ped);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the messages from the setup GUI elements.
+//
+Bool_t MGCamDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    switch(GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch(GET_SUBMSG(msg))
+        {
+        case kCM_CHECKBUTTON:
+            switch (parm1)
+            {
+            case kCButHillas:
+                fDisplayHillas = !fDisplayHillas;
+                UpdateDisplay();
+                return kTRUE;
+            }
+            break;
+
+        case kCM_RADIOBUTTON:
+            switch (parm1)
+            {
+            case kRButRawEvt:
+                fDisplayRaw = kTRUE;
+                UpdateDisplay();
+                return kTRUE;
+
+            case kRButCleanedEvt:
+                fDisplayRaw = kFALSE;
+                UpdateDisplay();
+                return kTRUE;
+            }
+            break;
+        }
+        break;
+    }
+    return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGCamDisplay.h	(revision 1638)
@@ -0,0 +1,44 @@
+#ifndef MARS_MGCamDisplay
+#define MARS_MGCamDisplay
+
+#ifndef MARS_MGEvtDisplay
+#include "MGEvtDisplay.h"
+#endif
+
+class TGListBox;
+
+class MGeomCam;
+class MCamDisplay;
+
+class MGCamDisplay : public MGEvtDisplay
+{
+private:
+    Bool_t fDisplayRaw;
+    Bool_t fDisplayHillas;
+
+    TGListBox   *fPixelList;
+
+    MCamDisplay *fDisplay;
+    MCamDisplay *fDisplay2;
+    MCamDisplay *fDisplay3;
+    MCamDisplay *fDisplay4;
+    MCamDisplay *fDisplay5;
+
+    void AddSetupElements();
+    void UpdateDisplay();
+
+    MGeomCam *SetupTaskList();
+
+public:
+    MGCamDisplay(const char *filename,
+                 const TGWindow *p, const TGWindow *main,
+                 UInt_t w, UInt_t h);
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MGCamDisplay, 0) // Display for camera images (cerenkov events)
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.cc	(revision 1638)
@@ -0,0 +1,657 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  10/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#include "MGEvtDisplay.h"
+
+#include <stdlib.h>               // atoi
+
+#include <TGTab.h>                // TGTab
+#include <TGMenu.h>               // TGPopupMenu
+#include <TCanvas.h>              // TCanvas::Print
+#include <TGLabel.h>              // TGLabel
+#include <TGButton.h>             // TGPictureButton
+#include <TGMsgBox.h>             // TGMsgBox
+#include <TGTextEntry.h>          // TGTextEntry
+#include <TGFileDialog.h>         // TGFileDialog
+#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
+
+#include <TG3DLine.h>             // TGHorizontal3DLine
+                                  // use TGSplitter instead for root<3.00
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MCamDisplay.h"
+#include "MReadMarsFile.h"
+#include "MGeomCamMagic.h"
+#include "MRawEvtHeader.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MGEvtDisplay);
+
+enum MGCamDisplayCommand
+{
+    kEvtPrev,
+    kEvtNext,
+    kEvtNumber,
+
+    kFileSaveAs,
+    kFileSaveAsRoot,
+    kFileSaveAsC,
+    kFileSaveAsPS,
+    kFileSaveAsEPS,
+    kFileSaveAsGIF,
+    kFilePrint,
+    kClose
+}; 
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the parameter list.
+//
+MParList *MGEvtDisplay::GetParList() const
+{
+    return fEvtLoop->GetParList();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the task list.
+//
+MTaskList *MGEvtDisplay::GetTaskList() const
+{
+    return (MTaskList*)GetParList()->FindObject("MTaskList");
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a pointer to the reader task (MReadTree)
+//
+MReadTree *MGEvtDisplay::GetReader() const
+{
+    return (MReadTree*)GetTaskList()->FindObject("MRead");
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the top part of the frame: This is filename and treename display
+//
+void MGEvtDisplay::AddTopFramePart1(TGVerticalFrame *frame,
+                                    const char *filename,
+                                    const char *treename)
+{
+    //
+    //  --- the top1 part of the window ---
+    //
+    TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 300, 100);
+    fList->Add(top1);
+
+    //
+    // create gui elements
+    //
+    TGLabel *lfile = new TGLabel(top1, new TGString("File:"));
+    TGLabel *file  = new TGLabel(top1, new TGString(filename));
+    TGLabel *ltree = new TGLabel(top1, new TGString("Tree:"));
+    TGLabel *tree  = new TGLabel(top1, new TGString(treename));
+
+    fList->Add(lfile);
+    fList->Add(file);
+    fList->Add(ltree);
+    fList->Add(tree);
+
+    //
+    // layout and add gui elements in/to frame
+    //
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
+    fList->Add(laystd);
+
+    top1->AddFrame(lfile, laystd);
+    top1->AddFrame(file,  laystd);
+    top1->AddFrame(ltree, laystd);
+    top1->AddFrame(tree,  laystd);
+
+    //
+    //  --- the top1 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
+    fList->Add(top2);
+
+    fEvtInfo = new TGLabel(top2, new TGString(""));
+    fList->Add(fEvtInfo);
+
+    top2->AddFrame(fEvtInfo, laystd);
+
+    //
+    // layout and add frames
+    //
+    TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
+    fList->Add(laytop1);
+    frame->AddFrame(top1, laytop1);
+    frame->AddFrame(top2, laytop1);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the second part of the top frame: This are the event number controls
+//
+void MGEvtDisplay::AddTopFramePart2(TGVerticalFrame *frame)
+{
+    //
+    // --- the top2 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 300, 100);
+    fList->Add(top2);
+
+    //
+    // Create the gui elements
+    //
+    TGTextButton *prevevt = new TGTextButton(top2, "<< Previous Event", kEvtPrev);
+    prevevt->Associate(this);
+
+    TGLabel *evtnr = new TGLabel(top2, new TGString("Event: "));
+
+    fTxtEvtNr = new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
+    fTxtEvtNr->Resize(60, fTxtEvtNr->GetDefaultHeight());
+    fTxtEvtNr->Associate(this);
+
+    fNumOfEvts = new TGLabel(top2, "out of           Events.");
+
+    TGTextButton *nextevt = new TGTextButton (top2, "Next Event >>", kEvtNext);
+    nextevt->Associate(this);
+
+    //
+    // Add gui elements to 'atotodel'
+    //
+    fList->Add(prevevt);
+    fList->Add(evtnr);
+    fList->Add(fTxtEvtNr);
+    fList->Add(fNumOfEvts);
+    fList->Add(nextevt);
+
+    //
+    // add the gui elements to the frame
+    //
+    TGLayoutHints *laystd    = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 10, 10, 10, 10);
+
+    fList->Add(laystd);
+
+    top2->AddFrame(prevevt,    laystd);
+    top2->AddFrame(evtnr,      laystd);
+    top2->AddFrame(fTxtEvtNr,  laystd);
+    top2->AddFrame(fNumOfEvts, laystd);
+    top2->AddFrame(nextevt,    laystd);
+
+    frame->AddFrame(top2, new TGLayoutHints(kLHintsCenterX));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add a tab with an embedded canvas for an camera display and return the
+//  pointer to the canvas
+//
+TCanvas *MGEvtDisplay::AddTab(TString name)
+{
+    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
+    fList->Add(laycanvas);
+
+    TGCompositeFrame *frame = fEvtDisplay->AddTab(name);
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas(name+"Display", frame, 400, 400);
+    frame->AddFrame(canvas, laycanvas);
+    fList->Add(canvas);
+    return canvas->GetCanvas();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the mid frame: This are the two tabs with the canvas in the right one
+//
+void MGEvtDisplay::AddMidFrame(TGHorizontalFrame *frame)
+{
+    //
+    // create tab control
+    //
+    TGTab *tabs = new TGTab(frame, 300, 300);
+
+    //
+    // Create Tab1
+    //
+    fTab1 = tabs->AddTab("Setup");
+
+    //
+    // Crete second gui elemet for tab1 (TGVertical Frame)
+    //
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 10, 10, 10, 10);
+    frame->AddFrame(tabs, laytabs);
+
+    //
+    // Create second part of frame
+    //
+    fEvtDisplay = new TGTab(frame, 300, 300);
+
+    fCanvas=AddTab("Photons");
+
+    AddTab("Geometry");
+    MGeomCamMagic geom;
+    MCamDisplay *display = new MCamDisplay(&geom);
+    display->Draw();
+    display->DrawPixelNumbers();
+    fList->Add(display);
+
+    //
+    // Add second part to frame
+    //
+    TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
+    frame->AddFrame(fEvtDisplay, laydisp);
+
+    //
+    // Now add all gui elements to 'autodel'-list
+    //
+    fList->Add(fEvtDisplay);
+    fList->Add(laydisp);
+    fList->Add(laytabs);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the low frame: These are the buttons Print and Close
+//
+void MGEvtDisplay::AddLowFrame(TGHorizontalFrame *frame)
+{
+    TGTextButton *but = new TGTextButton(frame, "Close", kClose);
+
+    but->Associate(this);
+
+    fList->Add(but);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsLeft, 10, 10, 10, 10);
+    fList->Add(laybut);
+
+    frame->AddFrame(but, laybut);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Create and setup all the three frames and build the window interieur
+//
+void MGEvtDisplay::AddFrames(const char *filename, const char *treename)
+{
+    //
+    // Create the frame elements and add gui elements to it
+    //
+    TGVerticalFrame *frametop = new TGVerticalFrame(this, 300, 100);
+    fList->Add(frametop);
+
+    AddTopFramePart1(frametop, filename, treename);
+    AddTopFramePart2(frametop);
+
+    TGLayoutHints *laytop  = new TGLayoutHints(kLHintsTop|kLHintsCenterX);
+    fList->Add(laytop);
+
+    // -----
+
+    TGHorizontalFrame *framemid = new TGHorizontalFrame(this, 300, 100);
+    fList->Add(framemid);
+
+    AddMidFrame(framemid);
+
+    TGLayoutHints *laymid  = new TGLayoutHints(kLHintsExpandY|kLHintsExpandX);
+    fList->Add(laymid);
+
+    //
+    // add frame elements to 'autodel'
+    //
+    TGHorizontal3DLine *line1 = new TGHorizontal3DLine(this);
+    TGHorizontal3DLine *line2   = new TGHorizontal3DLine(this);
+    fList->Add(line1);
+    fList->Add(line2);
+
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(layline);
+
+    // -----
+    TGHorizontalFrame *framelow = new TGHorizontalFrame(this, 300, 100);
+    fList->Add(framelow);
+
+    AddLowFrame(framelow);
+
+    TGLayoutHints *laylow  = new TGLayoutHints(kLHintsTop);
+    fList->Add(laylow);
+
+    //
+    // Layout frame elements and add elements to frame
+    //
+    AddFrame(frametop, laytop);
+    AddFrame(line1,    layline);
+    AddFrame(framemid, laymid);
+    AddFrame(line2,    layline);
+    AddFrame(framelow, laylow);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
+void MGEvtDisplay::AddMenuBar()
+{
+    //
+    // Add all GUI elements and update the event counter
+    //
+    TGLayoutHints *laymenubar  = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
+    TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+
+    fList->Add(laymenubar);
+    fList->Add(laymenuitem);
+    fList->Add(laylinesep);
+
+    TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
+    filemenu->AddEntry("Save &As...",           kFileSaveAs);
+    filemenu->AddEntry("Save As display.p&s",   kFileSaveAsPS);
+    filemenu->AddEntry("Save As display.&eps",  kFileSaveAsEPS);
+    filemenu->AddEntry("Save As display.&gif",  kFileSaveAsGIF);
+    filemenu->AddEntry("Save As display.&C",    kFileSaveAsC);
+    filemenu->AddEntry("Save As display.&root", kFileSaveAsRoot);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("&Print...", kFilePrint);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("E&xit", kClose);
+    filemenu->Associate(this);
+
+    TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
+    menubar->AddPopup("&File", filemenu, laymenuitem);
+    AddFrame(menubar, laymenubar);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    AddFrame(linesep, laylinesep);
+
+    fList->Add(filemenu);
+    fList->Add(menubar);
+    fList->Add(linesep);
+}
+
+MGEvtDisplay::MGEvtDisplay(const char *fname, const char *tname,
+                           const TGWindow *p, const TGWindow *main,
+                           UInt_t w, UInt_t h)
+    : TGTransientFrame(p, main, w, h), fInitOk(kFALSE)
+{
+    //
+    //  create an autodelete-list for the gui elements
+    //
+    fList = new TList;
+    fList->SetOwner();
+
+    //
+    // Setup an empty job, with a reader task only.
+    // All tasks and parameter containers are deleted automatically
+    // (via SetOwner())
+    //
+    MTaskList *tlist = new MTaskList;
+    tlist->SetOwner();
+
+    MReadMarsFile *read = new MReadMarsFile(tname, fname);
+    read->DisableAutoScheme();
+    tlist->AddToList(read);
+
+    MParList *plist = new MParList;
+    plist->SetOwner();
+    plist->AddToList(tlist);
+
+    fEvtLoop = new MEvtLoop;
+    fEvtLoop->SetOwner();
+    fEvtLoop->SetParList(plist);
+
+    AddMenuBar();
+    AddFrames(fname, tname);
+
+    SetWMSizeHints(450, 400, 1000, 1000, 10, 10);
+    Move(rand()%100+50, rand()%100+50);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructs the graphical members and the eventloop members
+//
+MGEvtDisplay::~MGEvtDisplay()
+{
+    fEvtLoop->PostProcess();
+    delete fEvtLoop;
+
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+// The close message is generated by the window manager when its close
+// window menu item is selected.
+//
+void MGEvtDisplay::CloseWindow()
+{
+    delete this;
+}
+
+void MGEvtDisplay::UpdateMcLabel()
+{
+    MMcEvt *evt=(MMcEvt*)GetParList()->FindObject("MMcEvt");
+    if (!evt)
+        return;
+
+    TString txt = " ";
+
+    switch (evt->GetPartId())
+    {
+    case kGAMMA:
+        txt += "Gamma";
+        break;
+    case kPROTON:
+        txt += "Proton";
+        break;
+    case kHELIUM:
+        txt += "Helium";
+        break;
+    default:
+        txt += "Unknown Particle Id";
+    }
+
+    txt += ":  E=";
+    txt += (int)(evt->GetEnergy()+.5);
+    txt += "GeV  r=";
+    txt += (int)(evt->GetImpact()/100+.5);
+    txt += "m  ZA=";
+    txt += (int)(evt->GetTheta()*180/TMath::Pi()+.5);
+    txt += "°  ";
+    txt += evt->GetPhotElfromShower();
+    txt += "PhEl";
+
+    const MRawEvtHeader *hed = (MRawEvtHeader*)GetParList()->FindObject("MRawEvtHeader");
+    if (hed)
+    {
+        txt += "  DAQEvt #";
+        txt += hed->GetDAQEvtNumber();
+    }
+
+    fEvtInfo->SetText(txt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks if the event number is valid, and if so reads the new event
+//  and updates the display
+//
+void MGEvtDisplay::ReadinEvent()
+{
+    if (GetTaskList()->Process())
+    {
+        GetReader()->DecEventNum();
+        UpdateDisplay();
+        UpdateMcLabel();
+    }
+
+    fTxtEvtNr->SetText(Form("%d", GetReader()->GetEventNum()+1));
+}
+
+void MGEvtDisplay::ReadFirstEvent()
+{
+    fInitOk = fEvtLoop->PreProcess();
+
+    if (fInitOk)
+        ReadinEvent();
+
+    TGString *txt = new TGString(Form("out of %d Events", GetReader()->GetEntries()));
+    fNumOfEvts->SetText(txt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Opens a save as dialog, and tries to store the canvas
+//  in the given output format
+//
+void MGEvtDisplay::SaveAsDialog() const
+{
+    static const char *gSaveAsTypes[] =
+    {
+        "PostScript",   "*.ps",
+        "Encapsulated PostScript", "*.eps",
+        "Gif files",    "*.gif",
+        "Macro files",  "*.C",
+        "ROOT files",   "*.root",
+        "All files",    "*",
+        NULL,           NULL
+    };
+
+    static TString dir(".");
+
+    TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
+
+    fi.fFileTypes = (const char**)gSaveAsTypes;
+    fi.fIniDir    = StrDup(dir);
+
+    new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi);
+
+    if (!fi.fFilename)
+        return;
+
+    dir = fi.fIniDir;
+
+    if (strstr(fi.fFilename, ".root") ||
+        strstr(fi.fFilename, ".ps")   ||
+        strstr(fi.fFilename, ".eps")  ||
+        strstr(fi.fFilename, ".gif"))
+    {
+        fCanvas->SaveAs(fi.fFilename);
+        return;
+    }
+    if (strstr(fi.fFilename, ".C"))
+    {
+        fCanvas->SaveSource(fi.fFilename);
+        return;
+    }
+    Warning("SaveAsDialog", "Unknown Extension: %s", fi.fFilename);
+}
+
+// --------------------------------------------------------------------------
+//
+//  ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+//
+// Processes information from all GUI items.
+// Selecting an item usually generates an event with 4 parameters.
+// The first two are packed into msg (first and second bytes).
+// The other two are parm1 and parm2.
+//
+Bool_t MGEvtDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    if (GET_MSG(msg)!=kC_TEXTENTRY && GET_MSG(msg)!=kC_COMMAND)
+        return kTRUE;
+
+    switch(GET_SUBMSG(msg))
+    {
+    case kTE_ENTER:
+    case kCM_BUTTON:
+        if (parm1==kClose)
+        {
+            CloseWindow();
+            return kTRUE;
+        }
+
+        if (!fInitOk)
+            return kTRUE;
+
+        switch(GET_SUBMSG(msg))
+        {
+        case kTE_ENTER:
+            if (GetReader()->SetEventNum(atoi(fTxtEvtNr->GetText())-1))
+                ReadinEvent();
+            return kTRUE;
+
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case kEvtPrev:
+                if (GetReader()->DecEventNum())
+                    ReadinEvent();
+                return kTRUE;
+
+            case kEvtNext:
+                if (GetReader()->IncEventNum())
+                    ReadinEvent();
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        return kTRUE;
+
+    case kCM_MENU:
+        switch (parm1)
+            {
+            case kFileSaveAs:
+                SaveAsDialog();
+                return kTRUE;
+            case kFileSaveAsRoot:
+                fCanvas->SaveAs("display.root");
+                return kTRUE;
+            case kFileSaveAsC:
+                // FIXME: The line opening the canvas is wrong.
+                fCanvas->SaveSource("display.C");
+                return kTRUE;
+            case kFileSaveAsPS:
+                fCanvas->SaveAs("display.ps");
+                return kTRUE;
+            case kFileSaveAsEPS:
+                fCanvas->SaveAs("display.eps");
+                return kTRUE;
+            case kFileSaveAsGIF:
+                fCanvas->SaveAs("display.gif");
+                return kTRUE;
+            case kFilePrint:
+                fCanvas->Print();
+                return kTRUE;
+            case kClose:
+                CloseWindow();
+                return kTRUE;
+            }
+        return kTRUE;
+    }
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGEvtDisplay.h	(revision 1638)
@@ -0,0 +1,90 @@
+#ifndef MARS_MGEvtDisplay
+#define MARS_MGEvtDisplay
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class TGTab;
+class TList;
+class TCanvas;
+class TGLabel;
+class TGTextEntry;
+
+class MEvtLoop;
+class MParList;
+class MTaskList;
+class MReadTree;
+
+class MGEvtDisplay : public TGTransientFrame
+{
+private:
+    //
+    // GUI stuff
+    //
+    TGLabel     *fNumOfEvts;
+    TGLabel     *fEvtInfo;
+    TGTextEntry *fTxtEvtNr;
+
+    TGTab       *fEvtDisplay;
+
+    void AddMenuBar();
+    void AddTopFramePart1(TGVerticalFrame *frame,
+                          const char *filename,
+                          const char *treename);
+    void AddTopFramePart2(TGVerticalFrame *frame);
+    void AddMidFrame(TGHorizontalFrame *frame);
+    void AddLowFrame(TGHorizontalFrame *frame);
+
+    void AddFrames(const char *filename, const char *treename);
+
+    void SaveAsDialog() const;
+    void ReadinEvent();
+
+    Bool_t fInitOk;
+
+protected:
+    TList     *fList;
+    MEvtLoop  *fEvtLoop;
+
+    TCanvas   *fCanvas;
+
+    TGCompositeFrame *fTab1;
+    TGCompositeFrame *fTab2;
+
+    TGVerticalFrame  *fMidFrame;
+
+    MParList  *GetParList() const;
+    MTaskList *GetTaskList() const;
+    MReadTree *GetReader() const;
+
+    TCanvas *AddTab(TString name);
+
+    void   ReadFirstEvent();
+    Bool_t IsInitOk() { return fInitOk; }
+
+    void UpdateMcLabel();
+
+    virtual void UpdateDisplay() = 0;
+
+public:
+    MGEvtDisplay(const char *fname, const char *tname,
+                 const TGWindow *p, const TGWindow *main,
+                 UInt_t w, UInt_t h);
+
+    ~MGEvtDisplay();
+
+    void CloseWindow();
+
+    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MGEvtDisplay, 0) // base class to display something event by event
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.cc	(revision 1638)
@@ -0,0 +1,263 @@
+/*======================================================================== *\
+!
+! *
+! * 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  10/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MGFadcDisp.h"
+
+#include <stdlib.h>               // atoi
+#include <iostream.h>             // cout for debugging
+
+#include <TList.h>                // TList
+#include <TCanvas.h>              // TCanvas
+#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
+
+#include <TGTab.h>                // TGTab
+#include <TGLabel.h>              // TGLabel
+#include <TGButton.h>             // TGPictureButton
+#include <TGSlider.h>             // TGVSlider
+#include <TGMsgBox.h>             // TGMsgBox
+#include <TGListBox.h>            // TGListBox
+#include <TGTextEntry.h>          // TGTextEntry
+
+#include <TG3DLine.h>             // TGHorizontal3DLine
+                                  // use TGSplitter instead for root<3.00
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MReadTree.h"
+#include "MEvtLoop.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MGFadcDisp);
+
+enum MGFadcDispCommand
+{
+    M_PREVPIXEL = 0x1000,
+    M_NEXTPIXEL = 0x1001,
+
+    M_PIXELLIST = 0x1002
+};
+
+// --------------------------------------------------------------------------
+//
+//  Add the missing GUI elements: These are the pixel number controls
+//
+void MGFadcDisp::AddSetupElements()
+{
+    fTab1->ChangeOptions(kHorizontalFrame);
+
+    //
+    // Create first gui element for tab1
+    //
+    fPixelList = new TGListBox(fTab1, M_PIXELLIST);
+    fPixelList->Associate(this);
+    fPixelList->Resize(80, 230);
+
+    TGLayoutHints *layplist = new TGLayoutHints(kLHintsExpandY|kLHintsLeft, 5, 5, 5, 5);
+    fTab1->AddFrame(fPixelList, layplist);
+
+    TGVerticalFrame *fMidFrame = new TGVerticalFrame(fTab1, 300, 100);
+    fList->Add(fMidFrame);
+
+    TGLayoutHints *laytab = new TGLayoutHints(kLHintsRight|kLHintsExpandY, 5, 5, 5, 5);
+    fList->Add(laytab);
+
+    fTab1->AddFrame(fMidFrame, laytab);
+
+    //
+    // Create gui elements for vertical frame
+    //
+    TGTextButton *prevpix = new TGTextButton(fMidFrame, "<< Prev Pixel", M_PREVPIXEL);
+    TGTextButton *nextpix = new TGTextButton(fMidFrame, "Next Pixel >>", M_NEXTPIXEL);
+    prevpix->Associate(this);
+    nextpix->Associate(this);
+
+    TGVSlider *slider = new TGVSlider(fMidFrame, 200, kSlider1|kScaleBoth);
+    slider->Associate(this);
+    slider->SetRange(0, 576);
+
+    //
+    // Layout gui elements
+    //
+    TGLayoutHints *laybut    = new TGLayoutHints(kLHintsRight);
+    TGLayoutHints *layslider = new TGLayoutHints(kLHintsCenterX|kLHintsExpandY);
+
+    fMidFrame->AddFrame(prevpix, laybut);
+    fMidFrame->AddFrame(slider,  layslider);
+    fMidFrame->AddFrame(nextpix, laybut);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
+MGFadcDisp::MGFadcDisp(const char *filename, const char *treename,
+                       const TGWindow *p, const TGWindow *main,
+                       UInt_t w, UInt_t h)
+    : MGEvtDisplay(filename, treename, p, main, w, h)
+{
+    //
+    // Add the missing GUI elements (pixellist, pixel number controls)
+    //
+    AddSetupElements();
+
+    //
+    // preprocess eventloop and read in first event (process)
+    //
+    GetReader()->DisableAutoScheme();
+    ReadFirstEvent();
+
+    //
+    // Map the window, set up the layout, etc.
+    //
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Fadc Event Display");
+    SetIconName("Fadc");
+
+    MapWindow();
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  return pointer to event data
+//
+MRawEvtData *MGFadcDisp::GetEvent() const
+{
+    return (MRawEvtData*)GetParList()->FindObject("MRawEvtData");
+}
+
+// --------------------------------------------------------------------------
+//
+//   after a new event is read in one has to update
+//   the list of pixels in the fPixelList (TGListBox)
+//
+void MGFadcDisp::DisplayPixel(Int_t lastsel, Bool_t update)
+{
+    MRawEvtData *data = GetEvent();
+
+    if (!data)
+        return;
+
+    MRawEvtPixelIter pixel(data);
+
+    if (update)
+    {
+        //
+        //   put the selection of the last event in memory
+        //
+        while (pixel.Next())
+        {
+            TString txt;
+            txt += pixel.GetPixelId();
+            fPixelList->AddEntry(txt, pixel.GetPixelId());
+        }
+
+        fPixelList->MapSubwindows();
+        fPixelList->Layout();
+    }
+
+    //
+    // check if the pixel from last event also occurs in this event
+    //
+    fCanvas->Clear();
+    fCanvas->cd();
+
+    if (lastsel<0 || !pixel.Jump(lastsel))
+    {
+        pixel.Reset();
+        lastsel=0; //pixel.GetPixelId();
+    }
+
+    TString txt("GRAPH");
+    txt += lastsel;
+
+    data->Draw(txt);
+
+    fPixelList->Select(lastsel, kTRUE);
+    fPixelList->SetTopEntry(lastsel);
+
+    fCanvas->Modified();
+    fCanvas->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Update the contents of the canvas
+//
+void MGFadcDisp::UpdateDisplay()
+{
+    if (!IsInitOk())
+        return;
+
+    const Int_t lastsel = fPixelList->GetSelected();
+
+    fPixelList->RemoveEntries(0, GetEvent()->GetNumPixels());
+
+    DisplayPixel(lastsel);
+}
+
+// --------------------------------------------------------------------------
+//
+//    ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+//
+// Processes information from all GUI items.
+// Selecting an item usually generates an event with 4 parameters.
+// The first two are packed into msg (first and second bytes).
+// The other two are parm1 and parm2.
+//
+Bool_t MGFadcDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) 
+{
+    switch(GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch(GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case M_PREVPIXEL:
+                DisplayPixel(fPixelList->GetSelected()-1, kFALSE);
+                return kTRUE;
+
+            case M_NEXTPIXEL:
+                DisplayPixel(fPixelList->GetSelected()+1, kFALSE);
+                return kTRUE;
+            }
+            break;
+
+        case kCM_LISTBOX:
+            if (parm1 != M_PIXELLIST)
+                break;
+
+            DisplayPixel(fPixelList->GetSelected(), kFALSE);
+            return kTRUE;
+        }
+        break;
+    }
+
+    return MGEvtDisplay::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/MGFadcDisp.h	(revision 1638)
@@ -0,0 +1,34 @@
+#ifndef MARS_MGFadcDisp
+#define MARS_MGFadcDisp
+
+#ifndef MARS_MGEvtDisplay
+#include "MGEvtDisplay.h"
+#endif
+
+class TGListBox;
+class MRawEvtData;
+
+class MGFadcDisp : public MGEvtDisplay
+{
+private:
+    TGListBox   *fPixelList;
+
+    void AddSetupElements();
+    void UpdateDisplay();
+    void DisplayPixel(Int_t lastsel=-1, Bool_t update=kTRUE);
+
+    MRawEvtData *GetEvent() const;
+
+public:
+
+    MGFadcDisp(const char *filename, const char *treename,
+               const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
+
+    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MGFadcDisp, 0) // Display for single pixel fadc data
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/meventdisp/Makefile	(revision 1638)
@@ -0,0 +1,50 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = EvtDisp
+
+#
+# Library name to creatre
+#
+LIB   = meventdisp.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../mgui -I../mgeom \
+	   -I../manalysis -I../mfileio -I../mmc
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MGEvtDisplay.cc \
+	   MGFadcDisp.cc \
+	   MGCamDisplay.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/FileIOLinkDef.h	(revision 1638)
@@ -0,0 +1,21 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MChain+;
+#pragma link C++ class MRead+;
+#pragma link C++ class MReadTree+;
+#pragma link C++ class MReadMarsFile+;
+
+#pragma link C++ class MRootFileBranch+;
+
+#pragma link C++ class MWriteFile+;
+#pragma link C++ class MWriteAsciiFile+;
+#pragma link C++ class MWriteRootFile+;
+
+#pragma link C++ class MCT1ReadAscii+;
+#pragma link C++ class MCT1ReadPreProc+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.cc	(revision 1638)
@@ -0,0 +1,299 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCT1ReadAscii                                                           //
+//                                                                         //
+// Reads a ascii file with CT1 data. The file description and some example //
+// files can be found on the Magic homepage.                               //
+//                                                                         //
+//  Input Containers:                                                      //
+//   -/-                                                                   //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MCerPhotEvt                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MCT1ReadAscii.h"
+
+#include <fstream.h>
+
+#include <TList.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+ClassImp(MCT1ReadAscii);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates an array which stores the file names of
+// the files which should be read. If a filename is given it is added
+// to the list.
+//
+MCT1ReadAscii::MCT1ReadAscii(const char *fname,
+			     const char *name, 
+                             const char *title)
+    : fIn(NULL)
+{
+    fName  = name  ? name  : "MCT1ReadAscii";
+    fTitle = title ? title : "Task to loop over events in CT1 ascii file";
+
+    //
+    // remember file name for opening the file in the preprocessor
+    //
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    if (fname)
+        AddFile(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the filename list and the input stream if one exists.
+//
+MCT1ReadAscii::~MCT1ReadAscii()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add this file as the last entry in the chain
+//
+void MCT1ReadAscii::AddFile(const char *txt)
+{
+    TNamed *name = new TNamed(txt, "");
+    fFileNames->AddLast(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MCT1ReadAscii::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existance of a next file to read
+    //
+    TNamed *file = (TNamed*)fFileNames->First();
+    if (!file)
+        return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const char *name = file->GetName();
+
+    fIn = new ifstream(gSystem->ExpandPathName(name));
+
+    const Bool_t noexist = !(*fIn);
+
+    if (noexist)
+        *fLog << dbginf << "Cannot open file '" << name << "'" << endl;
+    else
+        *fLog << "Open file: '" << name << "'" << endl;
+
+    //
+    // Remove this file from the list of pending files
+    //
+    fFileNames->Remove(file);
+
+    return !noexist;
+}
+
+// --------------------------------------------------------------------------
+//
+// Open the first file in the list. Check for the output containers or create
+// them if they don't exist.
+//
+// Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
+//
+Bool_t MCT1ReadAscii::PreProcess(MParList *pList)
+{
+    //
+    // Preprocessing
+    //
+
+    //
+    // Try to open at least one (the first) file
+    //
+    if (!OpenNextFile())
+        return kFALSE;
+
+    //
+    //  look for the MCerPhotEvt class in the plist
+    //
+    fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fNphot)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fPedest = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedest)
+        return kFALSE;
+
+    fPedest->InitSize(127);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read apedestal entry (line) from the file
+//
+void MCT1ReadAscii::ReadPedestals()
+{
+    //
+    // skip the next 4 values
+    //
+    Float_t val;
+
+    *fIn >> val;
+    *fIn >> val;
+    *fIn >> val;
+    *fIn >> val;
+
+    //
+    //    read in the next 127 numbers as the pedestals
+    //
+    for (Int_t i = 0; i<127; i++)
+    {
+        *fIn >> val;
+
+        if (val > 0.0)
+            (*fPedest)[i].SetMeanRms(val);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Read a data entry (line) from the file
+//
+void MCT1ReadAscii::ReadData()
+{
+    /*
+     //
+     // clear the list of cerphot-events
+     //
+     fNphot->Clear();
+     */
+
+    //
+    // five unsused numbers
+    //
+    Int_t val;
+
+    *fIn >> val;   // ener
+    *fIn >> val;   // zenang
+    *fIn >> val;   // sec1
+    *fIn >> val;   // sec2
+
+    //
+    // read in the number of cerenkov photons and add the 'new' pixel
+    // too the list with it's id, number of photons and error
+    //
+    fNphot->InitSize(127);
+
+    for (Int_t i = 0; i<127; i++ )
+    {
+        Float_t nphot;
+
+        *fIn >> nphot;
+
+        if (nphot > 0.0)
+            fNphot->AddPixel(i, nphot, (*fPedest)[i].GetMeanRms());
+    }
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the event number and depending on this number decide if
+// pedestals or event data has to be read.
+//
+// If the end of the file is reached try to open the next in the list. If
+// there is now next file stop the eventloop.
+//
+Bool_t MCT1ReadAscii::Process()
+{
+    //
+    // FIXME. This function should switch between reading pedestals and
+    // reading event data by the 'switch entry'.
+    // After reading it should set the InputStreamID correctly.
+    // ( should use MPedestalCam )
+    //
+ 
+    //
+    // read in the event nr
+    //
+    Int_t evtnr;
+    *fIn >> evtnr;
+
+    //
+    // check if we are done. Try to open the next file in chain.
+    // If it was possible start reading. If not break the event loop
+    //
+    if (fIn->eof())
+        return OpenNextFile() ? kCONTINUE : kFALSE;
+
+    //
+    // if the first number is negativ this is a pedestal line:
+    // read in pedestals
+    //
+    // FIXME! Set InputStreamID
+
+    if (evtnr < 0)
+    {
+        ReadPedestals();
+        return kCONTINUE;
+    }
+
+    ReadData();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadAscii.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MCT1ReadAscii
+#define MARS_MCT1ReadAscii
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TList;
+class MCerPhotEvt;
+class MPedestalCam;
+
+class MCT1ReadAscii : public MTask
+{
+private:
+    ifstream     *fIn;          // the inputfile
+    MCerPhotEvt  *fNphot;       // the data container for all data.
+    MPedestalCam *fPedest;      // ct1 pedestals
+    TList        *fFileNames;   // Array which stores the \0-terminated filenames
+
+    Bool_t OpenNextFile();
+
+    void ReadPedestals();
+    void ReadData();
+
+public:
+    MCT1ReadAscii(const char *filename=NULL,
+                  const char *name=NULL,
+                  const char *title=NULL);
+
+    ~MCT1ReadAscii();
+
+    void AddFile(const char *fname);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MCT1ReadAscii, 0)	// Reads the CT1 data file
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.cc	(revision 1638)
@@ -0,0 +1,802 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCT1ReadPreProc
+//
+// Reads a output file of the CT1 preproc.
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//    MCerPhotEvt     the data container for all data.
+//    MPedestalCam    ct1 pedestals
+//    MMcEvt          monte carlo data container for MC files
+//    MMcTrig         mc data container for trigger information
+//    MSrcPosCam      source position in the camera
+//    MBlindPixels    Array holding blind pixels
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1ReadPreProc.h"
+
+#include <fstream.h>
+
+#include <TList.h>
+#include <TSystem.h>
+
+#define LINUX
+#define HISTO void
+#define HBOOK_FILE int
+#include "defines.h"
+#include "structures.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MBlindPixels.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+
+ClassImp(MCT1ReadPreProc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates an array which stores the file names of
+// the files which should be read. If a filename is given it is added
+// to the list.
+//
+MCT1ReadPreProc::MCT1ReadPreProc(const char *fname, const char *name,
+                                 const char *title) : fIn(NULL), fEntries(0)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Task to loop over events in CT1 ascii file";
+
+    //
+    // remember file name for opening the file in the preprocessor
+    //
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    if (fname)
+        AddFile(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the filename list and the input stream if one exists.
+//
+MCT1ReadPreProc::~MCT1ReadPreProc()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add this file as the last entry in the chain
+//
+void MCT1ReadPreProc::AddFile(const char *txt)
+{
+    ifstream *store = fIn;
+
+    fIn = new ifstream(gSystem->ExpandPathName(txt));
+
+    if (!(*fIn))
+    {
+        *fLog << warn << "Cannot open file '" << txt << "'... ignored." << endl;
+        fIn = store;
+        return;
+    }
+
+    fEntries += GetNumEvents();
+
+    delete fIn;
+
+    fIn = store;
+
+    fFileNames->AddLast(new TNamed(txt, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+// Print data from the header to the screen and analyse the header data,
+// means store and copy the needed data into Mars structures and
+// data members
+//
+void MCT1ReadPreProc::ProcessRunHeader(const struct outputpars &outpars)
+{
+    if (outpars.inumpixels != iMAXNUMPIX)
+        *fLog << warn << "WARNING! File doesn't contain " << iMAXNUMPIX << " Pixels... maybe corrupt." << endl;
+
+    fNumEventsInRun = 0;
+
+    //
+    // ------------------- Output some stuff -----------------------
+    //
+
+    // int     itelescope;       // number of the CT which took the data
+    *fLog << inf << "Telescope: CT" << outpars.itelescope;
+
+    // float   flongitude_deg;   // longitude (counted positive towards West) of CT position */
+    // float   flatitude_deg;    // latitude (counted positive towards North) of CT position */
+    *fLog << " located @ Longitude=" << outpars.flongitude_deg;
+    *fLog << "deg  Latitude=" << outpars.flatitude_deg << "deg" << endl;
+
+    // int     irunnum;          // run number (from parameters file)
+    // enum    onoroff {NEITHER_ON_NOR_OFF, OFF_SOURCE, ON_SOURCE} eruntype; // runtype
+    *fLog << "Run:       #" << outpars.irunnum << "  (";
+    switch (outpars.eruntype)
+    {
+    case NEITHER_ON_NOR_OFF: *fLog << "unknown";    break;
+    case OFF_SOURCE:         *fLog << "off-source"; break;
+    case ON_SOURCE:          *fLog << "on-source";  break;
+    default:                 *fLog << (int)outpars.eruntype; break;
+    }
+    *fLog << ", ";
+    switch (outpars.etrackmode)
+    {
+    case NORMAL:  *fLog << "normal tracking";  break;
+    case REVERSE: *fLog << "reverse tracking"; break;
+    case DUNNO:   *fLog << "unknown tracking"; break;
+    default:      *fLog << (int)outpars.etrackmode; break;
+    }
+    *fLog << ")" << endl;
+
+    //double  dsourcera_hours;  // right ascension of observed source in hours
+    //double  dsourcedec_deg;   // declination of observed source in degrees
+    *fLog << "Source:    RA=" << outpars.dsourcera_hours << "h  DEC=";
+    *fLog << outpars.dsourcedec_deg << "deg" << endl;
+
+    //int     inummuonpixels;   // number of pixels in the muon shield
+    //int     inumcointdcs;     // number of coincidence tdcs recorded in the runfile
+    //float   fpixdiameter_deg; // smallest pixel diameter (degrees) (from parameters file) */
+
+    // enum    axes {RA, DEC, ALT, AZ} ese1_is; // name of the axis to which shaft encoder 1 is attached (implies the type of mount)
+    *fLog << "Shaftencoder 1 @ ";
+    switch (outpars.ese1_is)
+    {
+    case RA:  *fLog << "RA";  break;
+    case DEC: *fLog << "DEC"; break;
+    case ALT: *fLog << "ALT"; break;
+    case AZ:  *fLog << "AZ";  break;
+    default:  *fLog << (int)outpars.ese1_is; break;
+    }
+    *fLog << endl;
+
+    // int     isezeropos[2];       // zero position of shaftencoders 1 and 2 (from parameters file)
+    *fLog << "SE Zero:   SE(1)=" << outpars.isezeropos[0] << "  ";
+    *fLog << "SE(2)=" << outpars.isezeropos[1] << endl;
+
+    // int     iaz_rev_track_corr;  // correction for the azimuth shaft encoder (ALT/AZ mount only) in reverse tracking mode
+    // int     ialt_rev_track_corr; // correction for the altitude shaft encoder (ALT/AZ mount only) in reverse tracking mode
+    *fLog << "Reverse tracking corrections: SE(az)=" << outpars.iaz_rev_track_corr;
+    *fLog << "  SE(alt)=" << outpars.ialt_rev_track_corr << endl;
+
+    // float   fbendingcorr;        // bending correction factor (ALT/AZ mount only)
+    // float   fextinction;         // atmospheric extinction (typically taken from the Carlsberg Meridian Circle data)
+    *fLog << "Bending: Correction factor=" << outpars.fbendingcorr << "  ";
+    *fLog << "Extinction=" << outpars.fextinction << endl;
+
+    // Boolean bdontusepix[iMAXNUMPIX]; // bdontusepix is set true if the pixel should not be used in image analysis, otherwise it is true;
+    fBlinds->Clear();
+    *fLog << "Don't use pixels: ";
+    for (int i=0; i<iMAXNUMPIX; i++)
+        if (outpars.bdontusepix[i])
+        {
+            *fLog << i << " ";
+            fBlinds->SetPixelBlind(i);
+        }
+    *fLog << endl;
+
+    *fLog << "Exclude: ";
+
+    // Boolean bexcludepix[iMAXNUMPIX];
+    for (int i=0; i<iMAXNUMPIX; i++)
+        if (outpars.bexcludepix[i])
+        {
+            *fLog << i << " ";
+            fBlinds->SetPixelBlind(i);
+        }
+    *fLog << endl;
+
+    /* bexcludepix[] is set TRUE (== exclude from pedestal, Laser
+     * calibration and the further analysis) when the Mean value
+     * of a pixel inside a pedestal Run is larger than 50 or ( || )
+     * if the pedestal RMS value of this pixel is larger than 5.0
+     * This is reflected in the (new for versions >= 0.4)
+     * variable "pixonoff" in the ntuple written by preproc:
+     * preproc.nt.hbook
+     *
+     * When the pixel is excluded by the user it will get a -2 otherwise
+     * pixonoff = 0.
+     * Additive to this a -1 is added when preproc excludes the pixel
+     * for a given Run. So the actual value tells you whether you caught
+     * it already by hand or not.
+     *
+     * A plot of pixonoff may also be handy to tell you the status of your
+     * ADC equipment. */
+
+    // float   fphotoel_per_adccnt[iMAXNUMPIX]; // conversion factors for the pixel signals */
+    /*
+    float padc = outpars.fphotoel_per_adccnt[0];
+    *fLog << "Phe/ADC (pixel 0): " << padc << endl;
+    for (int i=0; i<iMAXNUMPIX; i++)
+        *fLog << outpars.fphotoel_per_adccnt[i] << " ";
+    *fLog << endl;
+    */
+    /*
+     --- USEFULL? NEEDED? ---
+     int     irubminusutc_usecs;              // difference between rubidium clock and UTC in microseconds
+     int     isum_thresh_phot;                // threshold for the total sum of photoelectrons filter
+     int     i2out_thresh_phot;               // threshold for the two-pixels-out-of-all software
+     int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; // thresholds for the muon cut
+     Boolean bmuon_suppression;               // "Dolby" noise reduction flag
+     float   ftolerated_pointerror_deg;       // maximum tolerated pointing error in the position
+     */
+
+    // float fxpointcorr_deg; // pointing correction (to be added along the camera x axis) e.g. from point run */
+    // float fypointcorr_deg; // pointing correction (to be added along the camera y axis) e.g. from point run */
+    *fLog << "Pointing correction: dx=" << outpars.fxpointcorr_deg << "deg  ";
+    *fLog << "dy=" << outpars.fypointcorr_deg << "deg" << endl;
+
+    // FIXME? Is x-y echanged between Mars CT1 geometry and CT1 definition?
+    fSrcPos->SetXY(-outpars.fypointcorr_deg/fGeom->GetConvMm2Deg(),
+                   -outpars.fxpointcorr_deg/fGeom->GetConvMm2Deg());
+    fSrcPos->SetReadyToSave();
+
+    /*
+     --- USEFULL? NEEDED? ---
+     float   fcamera_align_angle_deg;         // the angle between the camera y-axis and the meridian when a culminating object is observed (defined counter-clockwise looking at the sky)
+     int     iratecalc_numevents_odd;         // number of events used in the rate calculation (must be odd)
+     int     inumpedfile;                     // number of the pedestal file used
+     int     inumpedrun;                      // number of the pedestal run used in the file (starting at 0)
+     int     inumcalfile;                     // number of the calibration file used
+     int     inumlaserrun;                    // number of the laserrun used in the file (starting at 0)
+     int     inumtellogfile;                  // number of the TelLog file to be used
+     int     inumtellogrun;                   // number of the tellog entry (Runnumber) used from the log file
+     int     imcparticle;                     // CORSIKA-coded Monte Carlo particle type.
+    */
+
+    // ----- preprocessing results -----
+
+    // int     istart_mjdate_day;                 // MJD of run start (first event) */
+    // int     iend_mjdate_day;                   // MJD of run end (last event) */
+    // int     irunduration_secs;                 // difference between start and end time (secs) */
+    *fLog << "Run Time: From " << outpars.istart_mjdate_day << " to ";
+    *fLog << outpars.iend_mjdate_day << " (MJD),  Duration=";
+    *fLog << outpars.irunduration_secs/3600 << "h";
+    *fLog << (outpars.irunduration_secs/60)%60 << "m";
+    *fLog << outpars.irunduration_secs%60 << "s" << endl;
+
+    /*
+     --- USEFULL? NEEDED? ---
+     int     iproc_mjdate;                      // MJD of data processing (i.e. creation of this file)
+     */
+
+    // int     iproc_evts;                        // number of events processed */
+    *fLog << "Number of processed events: " << outpars.iproc_evts << endl;
+
+    // --- USEFULL? NEEDED? ---
+    // double  dactual_sourcera_hours;            // for off runs: the false source (that should have been) observed */
+
+    // float   frms_pedsig_phot[iMAXNUMPIX];      // standard deviation of the calibrated signals from the pedestal run */
+    fPedest->InitSize(iMAXNUMPIX);
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+        (*fPedest)[i].SetMeanRms(outpars.frms_pedsig_phot[i]);
+
+    // Used to communicate the mean over all pixels
+    // pedestal RMS into the Runs NTuple, as it might
+    // be used for e.g. quality cuts.
+    // float   fpedrms_mean;
+    *fLog << "Pedestal RMS: " << outpars.fpedrms_mean << endl;
+
+    // The average current over the active pixels
+    // for this run. This is done separately for
+    // ON and OF runs.
+    //float   fcurrent_mean;
+
+    // enum eERRORTOLERANCE {CAUTIOUS=0, GOODPHYSICS, TANK} eerrortolerance;
+    /* 0 == "cautious", exits on any reason (but tells in
+     * the .err file,
+     * 1 == "goodphysics", exits when physics could be affected
+     * by the error,
+     * 2 == "tank", never exits except on coredumps and when
+     * all files have been processed. Do not use such files for
+     * physics analysis!
+     *
+     * NOTE: the capital letter words are the enums, the small letter
+     * words must be used inside the parameter file. */
+
+    // enum eMCTRIGGERFLAG {ALL=0, FLAG, NOFLAG} emctriggerflag;
+    /* all: all events which survive the filter are written to the
+     *      events NTuple.
+     * flag: When Dorota's triggerflag is set to 1 for a particular
+     *       event, it shall be written to the output. All others shall
+     *       just be disregarded. (Default)
+     * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+     *         be treated further. */
+
+    *fLog << "File is a ";
+    *fLog << (outpars.bmontecarlo ? "Monte Carlo" : "Real Data");
+    *fLog << " file." << endl;
+
+    fIsMcFile = outpars.bmontecarlo==TRUE;
+
+    fPedest->SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+// Read CT1 PreProc File Header:
+//
+Bool_t MCT1ReadPreProc::ReadRunHeader()
+{
+    char cheadertitle[iHEADERTITLELENGTH];
+    fIn->read(cheadertitle, iHEADERTITLELENGTH);
+
+    TString s = cheadertitle;
+    TString m = cTITLE_TEMPLATE;
+
+    if (!s.BeginsWith(m(0, m.First('%'))))
+        return kFALSE;
+
+    *fLog << cheadertitle << flush;
+
+    // cTITLE_TEMPLATE "PREPROC V%f/S%f CT %d RUN %d %d PROCMJD %d\n"
+    struct outputpars outpars;
+
+    int dummy;
+
+    Float_t fpreprocversion, structversion;
+    sscanf(cheadertitle, cTITLE_TEMPLATE,
+           &fpreprocversion,    &structversion,
+           &outpars.itelescope, &outpars.irunnum,
+           &dummy/*&outpars.eruntype*/,   &outpars.iproc_mjdate);
+
+    if (STRUCT_VERSION != structversion)
+    {
+        *fLog << warn << "WARNING: Version of C-structures of file (V";
+        *fLog << structversion << ") not identical with current structures (V";
+        *fLog << STRUCT_VERSION << ")" << endl;
+    }
+
+    fIn->read((Byte_t*)&outpars, sizeof(struct outputpars));
+
+    ProcessRunHeader(outpars);
+
+    return kTRUE;
+}
+
+Bool_t MCT1ReadPreProc::ReadRunFooter()
+{
+    char cheadertitle[iHEADERTITLELENGTH];
+    fIn->read(cheadertitle, iHEADERTITLELENGTH);
+    /*
+     sscanf(cheadertitle, cEND_EVENTS_TEMPLATE,
+     &filterres.ifilter_passed_evts);
+     */
+
+    TString s = cheadertitle;
+    TString m = cEND_EVENTS_TEMPLATE;
+    Int_t p = m.First('%');
+
+    if (!s.BeginsWith(m(0,p)))
+    {
+        fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
+        return kFALSE;
+    }
+
+    *fLog << inf << cheadertitle << flush;
+
+    struct filterresults filterres;
+    fIn->read((Byte_t*)&filterres, sizeof(struct filterresults));
+    /*
+     int   imax_alt_arcs;            // maximum altitude reached during the run
+     int   iaz_at_max_alt_arcs;      // azimuth at the time the max. alt. was reached
+     int   itimeaverage_alt_arcs;    // altitude averaged over the runtime
+     int   icoord_inconsist_evts;    // number of events with time-coordinate inconsistency in this run
+     int   ifilter_passed_evts;      // number of events which passed the filter
+     int   imuon_fail_evts;          // number of events rejected as muons (other filters passed)
+     int   i2out_fail_evts;          // number of events which failed in the two out of all pixels software trigger
+     int   imuon_and_2out_fail_evts; // number of events failing in both muon and 2out filter
+     int   isum_fail_evts;           // number of events which failed the sum-of-all-calibrated ADC counts filter
+     int   isum_and_muon_fail_evts;  // number of events which failed in both the sum and the muon filter
+     int   isum_and_2out_fail_evts;  // number of events which failed in both the sum and the 2out filter
+     int   iall_filters_fail_evts;   // number of events which failed in all filters
+     float favg_event_rate_hz;       // average rate before filtering
+     float fstddev_event_rate_hz;    // standard deviation of the rate before filtering
+     */
+
+    fNumFilterEvts += filterres.ifilter_passed_evts;
+    fNumRuns++;
+
+    *fLog << inf << "Read " << fNumEventsInRun << " events from run." << endl;
+
+    if (fNumEventsInRun!=(UInt_t)filterres.ifilter_passed_evts)
+    {
+        *fLog << warn << "WARNING! Number of events in run doesn't match number of read events." << endl;
+        *fLog << "         File might be corrupt." << endl;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MCT1ReadPreProc::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existance of a next file to read
+    //
+    TNamed *file = (TNamed*)fFileNames->First();
+    if (!file)
+        return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const char *name = file->GetName();
+
+    fIn = new ifstream(gSystem->ExpandPathName(name));
+
+    if (!(*fIn))
+    {
+        *fLog << dbginf << "Cannot open file '" << name << "'" << endl;
+        return kFALSE;
+    }
+
+    *fLog << "Open file: '" << name << "'" << endl;
+
+    //
+    // Remove this file from the list of pending files
+    //
+    fFileNames->Remove(file);
+
+    *fLog << inf << "-----------------------------------------------------------------------" << endl;
+
+    *fLog << "File contains " << GetNumEvents() << " events." << endl;
+
+    // WORKAROUND for not working seekg(0) in GetNumEvents
+    fIn->close();
+    fIn->open(gSystem->ExpandPathName(name));
+
+    Bool_t rc = ReadRunHeader();
+
+    if (!rc)
+        *fLog << warn << "Unable to read first run header... skipping file." << endl;
+
+    return rc;
+}
+
+Int_t MCT1ReadPreProc::GetNumEvents()
+{
+    *fLog << inf << "Scanning file for size" << flush;
+
+    const TString m(cEND_EVENTS_TEMPLATE);
+    const Int_t p = m.First('%');
+    const TString test = m(0, p);
+
+    Int_t nevts = 0;
+    Int_t nruns = 0;
+
+    while (!fIn->eof())
+    {
+        fIn->seekg(iHEADERTITLELENGTH, ios::cur);
+        fIn->seekg(sizeof(struct outputpars), ios::cur);
+
+        while (1)
+        {
+            if (fIn->peek()==cEND_EVENTS_TEMPLATE[0])
+            {
+                char cheadertitle[iHEADERTITLELENGTH];
+                fIn->read(cheadertitle, iHEADERTITLELENGTH);
+
+                const TString s = cheadertitle;
+                if (s.BeginsWith(test))
+                {
+                    fIn->seekg(sizeof(struct filterresults), ios::cur);
+                    nruns++;
+                    break;
+                }
+
+                fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
+            }
+
+            fIn->seekg(sizeof(struct eventrecord), ios::cur);
+            if (fIn->eof())
+                break;
+            nevts++;
+        }
+        *fLog << "." << flush;
+    }
+
+    *fLog << "done." << endl;
+    *fLog << "Found " << nevts << " events in " << nruns << " runs." << endl;
+
+    return nevts;
+}
+
+// --------------------------------------------------------------------------
+//
+// Open the first file in the list. Check for the output containers or create
+// them if they don't exist.
+//
+// Initialize the size of the MPedestalCam container to 127 pixels (CT1 camera)
+//
+Bool_t MCT1ReadPreProc::PreProcess(MParList *pList)
+{
+    //
+    //  look for the MCerPhotEvt class in the plist
+    //
+    fNphot = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fNphot)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fPedest = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedest)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+    if (!fBlinds)
+        return kFALSE;
+
+    //
+    //  look for the source position in the camera
+    //
+    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "Source");
+    if (!fSrcPos)
+        return kFALSE;
+
+    //
+    //  look for the camera geometry
+    //
+    fGeom = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1", "MGeomCam");
+    if (!fGeom)
+        return kFALSE;
+
+    //
+    //  look for the mc event class
+    //
+    fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
+    if (!fMcEvt)
+        return kFALSE;
+
+    //
+    //  look for the mc trigger class
+    //
+    fMcTrig = (MMcTrig*)pList->FindCreateObj("MMcTrig");
+    if (!fMcTrig)
+        return kFALSE;
+
+    fNumFilterEvts = 0;
+    fNumRuns       = 0;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Analyse the event data, means store and copy the needed data into
+// Mars structures and data members
+//
+void MCT1ReadPreProc::ProcessEvent(const struct eventrecord &event)
+{
+    /*
+     --- USEFULL? NEEDED? ---
+     int   isecs_since_midday; // seconds passed since midday before sunset (JD of run start)
+     int   isecfrac_200ns;     // fractional part of isecs_since_midday
+     short snot_ok_flags;      // the bits in these two bytes are flags for additional information on the event: Everything OK =: all Bits = 0
+
+     // for ALT-AZ mount telescopes: rotation angle of the field of
+     // view; this angle is defined mathematically positive looking
+     // towards the sky as the angle between the hour circle through
+     // the object being tracked and the line through pixel 1 and 2
+     int   ifieldrot_arcs;
+
+     // event rate in milli Hertz before filtering calculated by
+     // iratecalc_numevents_odd/(time[i+iratecalc_numevents_odd/2] -
+     // time[i-iratecalc_numevents_odd/2])
+     // For the first and the last iratecalc_numevents_odd/2
+     // events the rate is assumed to be constant
+     unsigned short srate_millihz;
+
+     // This is the angle between the observation of this event and the
+     // culmination point. It is going to be written into the events NTuple.
+     float fhourangle;
+     */
+
+    //
+    // read in the number of cerenkov photons and add the 'new' pixel
+    // too the list with it's id, number of photons and error
+    //
+    fNphot->InitSize(iMAXNUMPIX);
+
+    // number of photoelectrons measured in each pixel only the
+    // actual number of pixels (outputpars.inumpixels) is written out
+    // short spixsig_10thphot[iMAXNUMPIX];
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+    {
+        if (event.spixsig_10thphot[i]==0)
+            continue;
+
+        fNphot->AddPixel(i, 0.1*event.spixsig_10thphot[i],
+                         (*fPedest)[i].GetMeanRms());
+    }
+    fNphot->SetReadyToSave();
+
+    // int ipreproc_alt_arcs; // "should be" alt according to preproc (arcseconds)
+    // int ipreproc_az_arcs;  // "should be" az according to preproc (arcseconds)
+
+    fMcEvt->SetTheta(TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600));   // altitude (arcseconds)
+    fMcEvt->SetPhi(TMath::Pi()/180*event.iaz_arcs/3600);               // azimuth (arcseconds)
+
+    fMcEvt->SetReadyToSave();
+
+    if (!fIsMcFile)
+        return;
+
+    fMcEvt->SetPartId(event.imcparticle);        // corsika particle type
+    fMcEvt->SetEnergy(event.fmcenergy_tev*1000); // simulated energy
+    fMcEvt->SetImpact(event.imcimpact_m*100);    // simulated impact
+
+    fMcTrig->SetFirstLevel(event.imctriggerflag);    // MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
+    fMcTrig->SetReadyToSave();
+
+    //float fmcsize_phel;   // Simulated SIZE
+}
+
+// --------------------------------------------------------------------------
+//
+// Because of the file format of the preproc output we have to check at any
+// event where in the file stream we are...
+//
+Bool_t MCT1ReadPreProc::CheckFilePosition()
+{
+    //
+    // Means: If no file is open (first call) try to open the first file
+    //
+    if (!fIn)
+        return kFALSE;
+
+    //
+    // Because we can have 0-event runs in the file we loop as often
+    // as we don't find a new footer-header combination.
+    //
+    while (1)
+    {
+        //
+        // If the first character isn't the first of the footer it must be
+        // an event
+        //
+        if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
+            return kTRUE;
+
+        //
+        // Try reading the footer. If it isn't succefull...
+        // must be an event
+        //
+        if (!ReadRunFooter())
+            return kTRUE;
+
+        *fLog << inf << "Footer found." << endl;
+
+        //
+        // No after reading the footer check if we reached the end of the file
+        //
+        if (fIn->eof())
+        {
+            *fLog << "End of file." << endl;
+            return kFALSE;
+        }
+
+        //
+        // If the eof isn't reached a new header must follow. Check for it.
+        //
+        if (fIn->peek()!=cTITLE_TEMPLATE[0])
+        {
+            *fLog << inf << "Error finding new run header in file (possible EOF)... skipping rest of file." << endl;
+            return kFALSE;
+        }
+
+        *fLog << "-----------------------------------------------------------------------" << endl;
+        if (!ReadRunHeader())
+            return kTRUE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the event number and depending on this number decide if
+// pedestals or event data has to be read.
+//
+// If the end of the file is reached try to open the next in the list. If
+// there is now next file stop the eventloop.
+//
+Bool_t MCT1ReadPreProc::Process()
+{
+    //
+    // Check where in the file we are. If neither a new event, nor a
+    // footer/header combination is detected go to the next file.
+    //
+    if (!CheckFilePosition())
+        if (!OpenNextFile())
+            return kFALSE;
+
+    // event data to be read from the file
+    struct eventrecord event;
+
+    // read the eventrecord from the file
+    fIn->read((Byte_t*)&event, sizeof(struct eventrecord));
+
+    ProcessEvent(event);
+
+    fNumEvents++;
+    fNumEventsInRun++;
+
+    return kTRUE;
+}
+
+Bool_t MCT1ReadPreProc::PostProcess()
+{
+    *fLog << all;
+    *fLog << "Number events passed the filter: " << fNumFilterEvts << endl;
+    *fLog << "Number of Events read from file: " << fNumEvents << endl;
+    *fLog << "Number of Runs read from file:   " << fNumRuns << endl;
+
+    if (fNumEvents!=fNumFilterEvts)
+    {
+        *fLog << warn << "WARNING! Number of events in file doesn't match number of read events..." << endl;
+        *fLog << "         File might be corrupt." << endl;
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MCT1ReadPreProc.h	(revision 1638)
@@ -0,0 +1,72 @@
+#ifndef MARS_MCT1ReadPreProc
+#define MARS_MCT1ReadPreProc
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class TList;
+class MMcEvt;
+class MMcTrig;
+class MGeomCam;
+class MSrcPosCam;
+class MCerPhotEvt;
+class MPedestalCam;
+class MBlindPixels;
+
+struct outputpars;
+struct eventrecord;
+
+class MCT1ReadPreProc : public MRead
+{
+private:
+    ifstream *fIn;          // the inputfile
+    TList    *fFileNames;   // Array which stores the \0-terminated filenames
+
+    MGeomCam     *fGeom;    // camera geometry
+    MCerPhotEvt  *fNphot;   // the data container for all data.
+    MPedestalCam *fPedest;  // ct1 pedestals
+    MMcEvt       *fMcEvt;   // monte carlo data container for MC files
+    MMcTrig      *fMcTrig;  // mc data container for trigger information
+    MSrcPosCam   *fSrcPos;  // source position in the camera
+    MBlindPixels *fBlinds;  // Array holding blind pixels
+
+    Bool_t fIsMcFile;       // Flag whether current run is a MC run
+
+    UInt_t fNumEvents;      // number of events counted in all runs in all files
+    UInt_t fNumEventsInRun; // number of events in the counted in th ecurrent run
+    UInt_t fNumRuns;        // number of processed runs of all files
+    UInt_t fEntries;        // entries of all files succesfully added
+    UInt_t fNumFilterEvts;  // number of events mentioned in the runs footers
+
+    Bool_t OpenNextFile();
+
+    Int_t  GetNumEvents();
+
+    void   ReadPedestals();
+    Bool_t ReadRunHeader();
+    Bool_t ReadRunFooter();
+    Bool_t CheckFilePosition();
+    void   ProcessRunHeader(const struct outputpars &outpars);
+    void   ProcessEvent(const struct eventrecord &event);
+
+public:
+    MCT1ReadPreProc(const char *filename=NULL,
+                    const char *name=NULL,
+                    const char *title=NULL);
+
+    ~MCT1ReadPreProc();
+
+    void AddFile(const char *fname);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    UInt_t GetEntries() { return fEntries; }
+
+    ClassDef(MCT1ReadPreProc, 0)	// Reads the CT1 data file
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.cc	(revision 1638)
@@ -0,0 +1,60 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MChain                                                                  //
+//                                                                         //
+// Helper class for MReadTree                                              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MChain.h"
+
+ClassImp(MChain);
+
+Int_t MChain::LoadTree(Int_t entry)
+{
+    //
+    // This is the code from TChain::LoadTree but skips the
+    // notification in LoadTree. If LoadTree raises the notification
+    // a flag is set and the notification is done by hand. This
+    // is done to be able to catch the return value from Notify. If
+    // it has not been successfull -15 is returned.
+    // This is to support return values from Notify()/Reinit()
+    //
+    TObject *notify = GetNotify();
+
+    SetNotify(this);
+
+    Int_t rc = TChain::LoadTree(entry);
+
+    if (rc >= 0 && fNotified && notify)
+        if (!notify->Notify())
+            rc = -15;
+
+    SetNotify(notify);
+
+    return rc;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MChain.h	(revision 1638)
@@ -0,0 +1,27 @@
+#ifndef MARS_MChain
+#define MARS_MChain
+
+#ifndef ROOT_TChain
+#include <TChain.h>
+#endif
+
+class MChain : public TChain
+{
+private:
+    Bool_t fNotified;
+
+public:
+    MChain() : TChain(), fNotified(kFALSE) {}
+    MChain(const char *name, const char *title="") : TChain(name, title), fNotified(kFALSE) {}
+
+    void ResetTree() { fTree = 0; }
+
+    virtual Bool_t Notify() { fNotified = kTRUE; return kTRUE; }
+    virtual void   SetNotify(TObject *obj) { fNotify = obj; fNotified = kFALSE; }
+
+    Int_t LoadTree(Int_t entry);
+
+    ClassDef(MChain, 1)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.cc	(revision 1638)
@@ -0,0 +1,35 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MRead                                                                   //
+//                                                                         //
+// Base class for all reading tasks                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MRead.h"
+
+ClassImp(MRead);
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MRead.h	(revision 1638)
@@ -0,0 +1,17 @@
+#ifndef MARS_MRead
+#define MARS_MRead
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRead : public MTask
+{
+public:
+
+    virtual UInt_t GetEntries() = 0;
+
+    ClassDef(MRead, 0)	// Base class for a reading task
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.cc	(revision 1638)
@@ -0,0 +1,204 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MReadMarsFile                                                           //
+//                                                                         //
+// This task works more or less like MReadTree, but in addition PreProcess //
+// reads all the information from the 'RunHeader' tree.                    //
+//                                                                         //
+// Warning: Until now this works only for 'one run header per file'        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MReadMarsFile.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MRawRunHeader.h"
+
+#include "MMcRunHeader.hxx"
+
+ClassImp(MReadMarsFile);
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. Don't use it.
+//
+MReadMarsFile::MReadMarsFile() : fRun(NULL)
+{
+    fName  = "MRead";
+    fTitle = "Task to loop over all events in a tree of a Mars file.";
+}
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. It creates a MReadTree object to read the
+//  RunHeaders and disables Auto Scheme for this tree.
+//
+MReadMarsFile::MReadMarsFile(const char *tname, const char *fname,
+                             const char *name, const char *title)
+    : MReadTree(tname, fname)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Task to loop over all events in a tree of a Mars file.";
+
+    //
+    // open the input stream
+    //
+    fRun = new MReadTree("RunHeaders", fname, "ReadRunHeaders");
+
+    //
+    // This disables the auto scheme. because reading new runheader is done
+    // at a low frequency we don't loose time if we always read all
+    // runheaders
+    //
+    fRun->DisableAutoScheme();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deleted the MReadTree object for the RunHeaders
+//
+MReadMarsFile::~MReadMarsFile()
+{
+    delete fRun;
+}
+
+// --------------------------------------------------------------------------
+//
+//  see MReadTree::AddFile, too. The file is also added to the chain for
+//  the run headers. If adding file gives a different result for both
+//  chains -1 is returned, otherwise the number of files which were added.
+//
+Int_t MReadMarsFile::AddFile(const char *fname)
+{
+    //
+    // FIXME! A check is missing whether the file already exists or not.
+    //
+    //
+    // returns the number of file which were added
+    //
+    Int_t n1 = fRun->AddFile(fname);
+    Int_t n2 = MReadTree::AddFile(fname);
+
+    return n1 != n2 ? -1 : n1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This overload MReadTree::Notify. Before the MReadTree Notify
+//  TObjects are called the RunHeaders of the next files are read.
+//  
+//  WARNING: This doesn't work correctly yet, if the files are not read in
+//           increasing order.
+//
+Bool_t MReadMarsFile::Notify()
+{
+    Int_t runtype = -1;
+
+    const MRawRunHeader *rawheader = (MRawRunHeader*)fParList->FindObject("MRawRunHeader");
+    if (rawheader)
+        runtype = rawheader->GetRunType();
+
+    //
+    // Try to read the new run headers. If reading the new run header
+    // was successfull call the ReInits
+    //
+    const Int_t idx = GetFileIndex();
+    fRun->SetEventNum(idx<0?0:idx); // Assumption: One Entry per File!
+    if (!fRun->Process())
+    {
+        *fLog << err << "ERROR - Cannot read new runheaders #" << idx;
+        *fLog << " after reading event #" << GetEventNum() << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << "MReadMarsFile: Switching to #" << GetFileIndex();
+    *fLog << " '" << GetFileName() << "' (before event #";
+    *fLog << GetEventNum()-1 << ")" << endl;
+
+    if (rawheader)
+    {
+        if (runtype != rawheader->GetRunType())
+            *fLog << warn << "Warning - You are mixing files with different run types!" << endl;
+    }
+
+    const MMcRunHeader *mcheader = (MMcRunHeader*)fParList->FindObject("MMcRunHeader");
+    if (mcheader)
+    {
+        if (mcheader->GetReflVersion()<=40 && mcheader->GetTelesTheta()>15)
+        {
+            *fLog << warn << "Warning - You may use Monte Carlo data produced with a version" << endl;
+            *fLog << "of the reflector program < 0.4 and a zenith angle > 15," << endl;
+            *fLog << "in this case you may get less photons than you would expect." << endl;
+        }
+    }
+
+    MTaskList *tlist = (MTaskList*)fParList->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << err << dbginf << "ERROR - Task List not found in Parameter List." << endl;
+        return kFALSE;
+    }
+
+    if (tlist->ReInit())
+        return kTRUE;
+
+    //MReadTree::Notify();
+
+    *fLog << err << "ERROR - ReInit of '" << tlist->GetName() << "' failed." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  PreProcessed the MReadTree to read the run headers and its base class.
+//  see MReadTree::PreProcess for more information
+//
+Bool_t MReadMarsFile::PreProcess(MParList *pList)
+{
+    fParList = pList;
+
+    if (!fRun->PreProcess(pList))
+    {
+        *fLog << err << "Error - PreProcessing MReadMarsFile::fRun... aborting." << endl;
+        return kFALSE;
+    }
+
+    const Int_t idx = GetFileIndex();
+    fRun->SetEventNum(idx<0?0:idx); // Assumption: One Entry per File!
+    if (!fRun->Process())
+    {
+        *fLog << err << "Error - Processing MReadMarsFile::fRun... aborting." << endl;
+        return kFALSE;
+    }
+
+    return MReadTree::PreProcess(pList);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadMarsFile.h	(revision 1638)
@@ -0,0 +1,31 @@
+#ifndef MARS_MReadMarsFile
+#define MARS_MReadMarsFile
+
+#ifndef MARS_MReadTree
+#include "MReadTree.h"
+#endif
+
+class MParList;
+class MTaskList;
+
+class MReadMarsFile : public MReadTree
+{
+private:
+    MReadTree *fRun;
+    MParList  *fParList;  //! Parlist for reinitialization
+
+    Bool_t Notify();
+
+    Bool_t PreProcess(MParList *pList);
+  
+public:
+    MReadMarsFile();
+    MReadMarsFile(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL);
+    ~MReadMarsFile();
+
+    Int_t AddFile(const char *fname);
+
+    ClassDef(MReadMarsFile, 1)	// Reads a tree from file(s)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.cc	(revision 1638)
@@ -0,0 +1,842 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MReadTree                                                               //
+//                                                                         //
+// This tasks opens all branches in a specified tree and creates the       //
+// corresponding parameter containers if not already existing in the       //
+// parameter list.                                                         //
+//                                                                         //
+// The Process function reads one events from the tree. To go through the  //
+// events of one tree make sure that the event number is increased from    //
+// outside. It makes also possible to go back by decreasing the number.    //
+//                                                                         //
+// If you don't want to start reading the first event you have to call     //
+// MReadTree::SetEventNum after instantiating your MReadTree-object.       //
+//                                                                         //
+// To make reading much faster (up to a factor of 10 to 20) you can        //
+// ensure that only the data you are really processing is enabled by       //
+// calling MReadTree::UseLeaf.                                             //
+//                                                                         //
+// If the chain switches from one file to another file all                 //
+// TObject::Notify() functions are called of TObject objects which were    //
+// added to the Notifier list view MReadTree::AddNotify. If MReadTree      //
+// is the owner (viw MReadTree::SetOwner) all this objects are deleted     //
+// by the destructor of MReadTree                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MReadTree.h"
+
+#include <fstream.h>
+
+#include <TFile.h>           // TFile::GetName
+#include <TSystem.h>         // gSystem->ExpandPath
+//#include <TGProgressBar.h>
+#include <TChainElement.h>
+#include <TOrdCollection.h>
+
+#include "MChain.h"
+#include "MFilter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+
+ClassImp(MReadTree);
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. Don't use it.
+//
+MReadTree::MReadTree()
+    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
+{
+    fName  = "MRead";
+    fTitle = "Task to loop over all events in one single tree";
+
+    fVetoList = NULL;
+    fNotify = NULL;
+
+    fChain = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. It creates an TChain instance which represents the
+//  the Tree you want to read and adds the given file (if you gave one).
+//  More files can be added using MReadTree::AddFile.
+//  Also an empty veto list is created. This list is used if you want to
+//  veto (disable or "don't enable") a branch in the tree, it vetos also
+//  the creation of the corresponding object.
+//  An empty list of TObjects are also created. This objects are called
+//  at any time the TChain starts to read from another file.
+//
+MReadTree::MReadTree(const char *tname, const char *fname,
+                     const char *name, const char *title)
+    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Task to loop over all events in one single tree";
+
+    fVetoList = new TList;
+    fVetoList->SetOwner();
+
+    fNotify = new TList;
+
+    //
+    // open the input stream
+    //
+    fChain = new MChain(tname);
+
+    // root 3.02:
+    // In TChain::Addfile remove the limitation that the file name must contain
+    // the string ".root". ".root" is necessary only in case one wants to specify
+    // a Tree in a subdirectory of a Root file with eg, the format:
+
+    if (fname)
+        if (fChain->Add(fname)>0)
+            SetBit(kChainWasChanged);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. It deletes the TChain and veto list object
+//
+MReadTree::~MReadTree()
+{
+    //
+    // Delete all the pointers to pointers to the objects where the
+    // branche data gets stored.
+    //
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+        delete (MParContainer**)element->GetBaddress();
+
+    //
+    // Delete the chain and the veto list
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
+    if (fChain->GetFile())
+        delete fChain->GetFile();
+#endif
+    delete fChain;
+
+    delete fNotify;
+    delete fVetoList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the owner flag is set all TObjects which are scheduled via
+//  AddNotify are deleted by the destructor of MReadTree
+//
+void MReadTree::SetOwner(Bool_t flag)
+{
+    flag ? fNotify->SetBit(kIsOwner) : fNotify->ResetBit(kIsOwner);
+}
+
+// --------------------------------------------------------------------------
+//
+//  This function is called each time MReadTree changes the file to read
+//  from. It calls all TObject::Notify() functions which are scheduled
+//  via AddNotify.
+//
+Bool_t MReadTree::Notify()
+{
+    *fLog << inf << GetDescriptor() << ": Notify '" << fChain->GetName();
+    *fLog << "' (before processing event #" << GetEventNum()-1 << ")" << endl;
+
+    //fNotify->Notify();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you want to read the given tree over several files you must add
+//  the files here before PreProcess is called. Be careful: If the tree
+//  doesn't have the same contents (branches) it may confuse your
+//  program (trees which are are not existing in later files are not read
+//  anymore, tree wich are not existing in the first file are never read)
+//
+//  Name may use the wildcarding notation, eg "xxx*.root" means all files
+//  starting with xxx in the current file system directory.
+//
+//  AddFile returns the number of files added to the chain.
+//
+Int_t MReadTree::AddFile(const char *fname)
+{
+    //
+    // FIXME! A check is missing whether the file already exists or not.
+    //
+    //
+    // returns the number of file which were added
+    //
+
+    const Int_t numfiles = fChain->Add(fname);
+
+    if (numfiles>0)
+        SetBit(kChainWasChanged);
+
+    return numfiles;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds all files from another MReadTree to this instance
+//
+// Returns the number of file which were added
+//
+Int_t MReadTree::AddFiles(const MReadTree &read)
+{
+    Int_t rc = 0;
+
+    TIter Next(read.fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        rc += AddFile(obj->GetTitle());
+
+    if (rc>0)
+        SetBit(kChainWasChanged);
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This function is called if Branch choosing method should get enabled.
+//  Branch choosing means, that only the enabled branches are read into
+//  memory. To use an enableing scheme we have to disable all branches first.
+//  This is done, if this function is called the first time.
+//
+void MReadTree::EnableBranchChoosing()
+{
+    if (fBranchChoosing)
+        return;
+
+    *fLog << inf << GetDescriptor() << ": Branch choosing method enabled (only enabled branches are read)." << endl;
+    fChain->SetBranchStatus("*", kFALSE);
+    fBranchChoosing = kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The first time this function is called all branches are disabled.
+// The given branch is enabled. By enabling only the branches you
+// are processing you can speed up your calculation many times (up to
+// a factor of 10 or 20)
+//
+void MReadTree::EnableBranch(const char *name)
+{
+    EnableBranchChoosing();
+
+    TNamed branch(name, "");
+    SetBranchStatus(&branch, kTRUE);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set branch status of branch name
+//
+void MReadTree::SetBranchStatus(const char *name, Bool_t status)
+{
+    fChain->SetBranchStatus(name, status);
+
+    *fLog << inf << (status ? "Enabled" : "Disabled");
+    *fLog << " subbranch '" << name << "'." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether a branch with the given name exists in the chain
+// and sets the branch status of this branch corresponding to status.
+//
+void MReadTree::SetBranchStatus(TObject *branch, Bool_t status)
+{
+    //
+    // Get branch name
+    //
+    const char *name = branch->GetName();
+
+    //
+    // Check whether this branch really exists
+    //
+    if (fChain->GetBranch(name))
+        SetBranchStatus(name, status);
+
+    //
+    // Remove trailing '.' if one and try to enable the subbranch without
+    // the master branch name. This is to be compatible with older mars
+    // and camera files.
+    //
+    const char *dot = strrchr(name, '.');
+    if (!dot)
+        return;
+
+    if (fChain->GetBranch(dot+1))
+        SetBranchStatus(dot+1, status);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the status of all branches in the list to status.
+//
+void MReadTree::SetBranchStatus(const TList *list, Bool_t status)
+{
+    //
+    // Loop over all subbranches in this master branch
+    //
+    TIter Next(list);
+
+    TObject *obj;
+    while ((obj=Next()))
+        SetBranchStatus(obj, status);
+}
+
+// --------------------------------------------------------------------------
+//
+//  This is the implementation of the Auto Enabling Scheme.
+//  For more information see MTask::AddBranchToList.
+//  This function loops over all tasks and its filters in the tasklist
+//  and enables all branches which are requested by the tasks and its
+//  filters.
+//
+//  To enable 'unknown' branches which are not in the branchlist of
+//  the tasks you can call EnableBranch
+//
+void MReadTree::EnableBranches(MParList *plist)
+{
+    //
+    // check whether branch choosing must be switched on
+    //
+    EnableBranchChoosing();
+
+    //
+    // request the tasklist from the parameter list.
+    // FIXME: Tasklist can have a different name
+    //
+    const MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << warn << GetDescriptor() << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl;
+        return;
+    }
+
+    //
+    // This loop is not necessary. We could do it like in the commented
+    // loop below. But this loop makes sure, that we don't try to enable
+    // one branch several times. This would not harm, but we would get
+    // an output for each attempt. To have several outputs for one subbranch
+    // may confuse the user, this we don't want.
+    // This loop creates a new list of subbranches and for each branch
+    // which is added we check before whether it already exists or not.
+    //
+    TList list;
+
+    MTask *task;
+    TIter NextTask(tlist->GetList());
+    while ((task=(MTask*)NextTask()))
+    {
+        TObject *obj;
+
+        TIter NextTBranch(task->GetListOfBranches());
+        while ((obj=NextTBranch()))
+            if (!list.FindObject(obj->GetName()))
+                list.Add(obj);
+
+        const MFilter *filter = task->GetFilter();
+
+        if (!filter)
+            continue;
+
+        TIter NextFBranch(filter->GetListOfBranches());
+        while ((obj=NextFBranch()))
+            if (!list.FindObject(obj->GetName()))
+                list.Add(obj);
+    }
+
+    SetBranchStatus(&list, kTRUE);
+/*
+    //
+    // Loop over all tasks iand its filters n the task list.
+    //
+    MTask *task;
+    TIter NextTask(tlist->GetList());
+    while ((task=(MTask*)NextTask()))
+    {
+        SetBranchStatus(task->GetListOfBranches(), kTRUE);
+
+        const MFilter *filter = task->GetFilter();
+        if (!filter)
+           continue;
+
+        SetBranchStatus(filter->GetListOfBranches(), kTRUE);
+
+    }
+*/
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the chain has been changed (by calling AddFile or using a file
+//  in the constructors argument) the number of entries is newly
+//  calculated from the files in the chain - this may take a while.
+//  The number of entries is returned.
+//
+UInt_t MReadTree::GetEntries()
+{
+    if (TestBit(kChainWasChanged))
+    {
+        *fLog << inf << "Scanning chain... " << flush;
+        fNumEntries = (UInt_t)fChain->GetEntries();
+        *fLog << fNumEntries << " events found." << endl;
+        ResetBit(kChainWasChanged);
+    }
+    return fNumEntries;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The disables all subbranches of the given master branch.
+//
+void MReadTree::DisableSubBranches(TBranch *branch)
+{
+    //
+    // This is not necessary, it would work without. But the output
+    // may confuse the user...
+    //
+    if (fAutoEnable || fBranchChoosing)
+        return;
+
+    SetBranchStatus(branch->GetListOfBranches(), kFALSE);
+}
+
+// --------------------------------------------------------------------------
+//
+//  The PreProcess loops (till now) over the branches in the given tree.
+//  It checks if the corresponding containers (containers with the same
+//  name than the branch name) are existing in the Parameter Container List.
+//  If not, a container of objec type 'branch-name' is created (everything
+//  after the last semicolon in the branch name is stripped). Only
+//  branches which don't have a veto (see VetoBranch) are enabled If the
+//  object isn't found in the root dictionary (a list of classes known by the
+//  root environment) the branch is skipped and an error message is printed
+//  out.
+//
+Bool_t MReadTree::PreProcess(MParList *pList)
+{
+    //
+    // Make sure, that all the following calls doesn't result in
+    // Notifications. This may be dangerous, because the notified
+    // tasks are not preprocessed.
+    //
+    fChain->SetNotify(NULL);
+
+    //
+    // get number of events in this tree
+    //
+    if (!GetEntries())
+    {
+        *fLog << warn << dbginf << "No entries found in file(s)" << endl;
+        return kFALSE;
+    }
+
+    //
+    // output logging information
+    //
+    *fLog << inf << fNumEntries << " entries found in file(s)." << endl;
+
+    //
+    // Get all branches of this tree and
+    // create the Iterator to loop over all branches
+    //
+    TIter Next(fChain->GetListOfBranches());
+    TBranch *branch=NULL;
+
+    Int_t num=0;
+    //
+    // loop over all tasks for processing
+    //
+    while ( (branch=(TBranch*)Next()) )
+    {
+        //
+        // Get Name of Branch and Object
+        //
+        const char *bname = branch->GetName();
+
+        TString oname(bname);
+        if (oname.EndsWith("."))
+            oname.Remove(oname.Length()-1);
+
+        //
+        // Check if enabeling the branch is allowed
+        //
+        if (fVetoList->FindObject(oname))
+        {
+            *fLog << inf << "Master branch " << bname << " has veto... skipped." << endl;
+            DisableSubBranches(branch);
+            continue;
+        }
+
+        //
+        // Create a pointer to the pointer to the object in which the
+        // branch data is stored. The pointers are stored in the TChain
+        // object and we get the pointers from there to delete it.
+        //
+        MParContainer **pcont= new MParContainer*;
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+        const char *classname = oname;
+#else
+        const char *classname = branch->GetClassName();
+#endif
+
+        //
+        // check if object is existing in the list
+        //
+        *pcont=pList->FindCreateObj(classname, oname);
+
+        if (!*pcont)
+        {
+            //
+            // if class is not existing in the (root) environment
+            // we cannot proceed reading this branch
+            //
+            *fLog << warn << dbginf << "Warning: Class '" << classname;
+            *fLog << "' for " << oname << " not existing in dictionary. Branch skipped." << endl;
+            DisableSubBranches(branch);
+            continue;
+        }
+
+        //
+        // Check whether a Pointer to a pointer already exists.
+        // If we created one already, delete it.
+        //
+        TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname);
+        if (element)
+            delete (MParContainer**)element->GetBaddress();
+
+        //
+        // here pcont is a pointer the to container in which the data from
+        // the actual branch should be stored - enable branch.
+        //
+        fChain->SetBranchAddress(bname, pcont);
+
+        *fLog << inf << "Master branch address " << bname << " [";
+        *fLog << classname << "] setup for reading." << endl;
+
+        //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl;
+        //branch->SetAutoDelete();
+
+        num++;
+    }
+
+    *fLog << inf << GetDescriptor() << " setup " << num << " master branches addresses." << endl;
+
+    //
+    // If auto enabling scheme isn't disabled, do auto enabling
+    //
+    if (fAutoEnable)
+        EnableBranches(pList);
+
+    //
+    // Now we can start notifying. Reset tree makes sure, that TChain thinks
+    // that the correct file is not yet initialized and reinitilizes it
+    // as soon as the first event is read. This is necessary to call
+    // the notifiers when the first event is read, but after the
+    // PreProcess-function.
+    //
+    fChain->ResetTree();
+    fChain->SetNotify(this);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the ready to save flag of all containers which branchaddresses are
+//  set for. This is necessary to copy data.
+//
+void MReadTree::SetReadyToSave(Bool_t flag)
+{
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+    {
+        //
+        // Check whether the branch is enabled
+        //
+        if (!element->GetStatus())
+            continue;
+
+        //
+        // Get the pointer to the pointer of the corresponding container
+        //
+        MParContainer **pcont = (MParContainer**)element->GetBaddress();
+
+        //
+        // Check whether the pointer is not NULL
+        //
+        if (!pcont || !*pcont)
+            continue;
+
+        //
+        // Set the ready to save status of the container.
+        //
+        (*pcont)->SetReadyToSave(flag);
+    }
+
+    //
+    // Set the ready to save status of this task (used?), too
+    //
+    MTask::SetReadyToSave(flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//  The Process-function reads one event from the tree (this contains all
+//  enabled branches) and increases the position in the file by one event.
+//  (Remark: The position can also be set by some member functions
+//  If the end of the file is reached the Eventloop is stopped.
+//
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+#include "MRawEvtData.h"
+#endif
+Bool_t MReadTree::Process()
+{
+    //
+    // This is necessary due to a bug in TChain::LoadTree in root.
+    // will be fixed in 3.03
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01)
+    if (fNumEntry >= GetEntries())
+        return kFALSE;
+#endif
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+    //
+    // This fixes 99.9% of a memory leak using a root version prior
+    // to 3.02/??
+    //
+    TChainElement *element=NULL;
+    TIter Next(fChain->GetStatus());
+    while ((element=(TChainElement*)Next()))
+    {
+        MParContainer **c = (MParContainer**)element->GetBaddress();
+        if (!c) continue;
+        if ((*c)->InheritsFrom(MRawEvtData::Class()))
+            ((MRawEvtData*)(*c))->DeletePixels(kFALSE);
+
+    }
+#endif
+
+    Bool_t rc = fChain->GetEntry(fNumEntry++) != 0;
+
+    if (rc)
+        SetReadyToSave();
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Event with the current EventNumber fNumEntry
+//
+Bool_t MReadTree::GetEvent()
+{
+    Bool_t rc = fChain->GetEntry(fNumEntry) != 0;
+
+    if (rc)
+        SetReadyToSave();
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Decrease the number of the event which is read by Process() next
+// by one or more
+//
+Bool_t MReadTree::DecEventNum(UInt_t dec)
+{
+    if (fNumEntry-dec >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": DecEventNum, WARNING - Event " << fNumEntry << "-";
+        *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range." << endl;
+        return kFALSE;
+    }
+
+    fNumEntry -= dec;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Increase the number of the event which is read by Process() next
+// by one or more
+//
+Bool_t MReadTree::IncEventNum(UInt_t inc)
+{
+    if (fNumEntry+inc >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": IncEventNum, WARNING - Event " << fNumEntry << "+";
+        *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range." << endl;
+        return kFALSE;
+    }
+
+    fNumEntry += inc;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function makes Process() read event number nr next
+//
+// Remark: You can use this function after instatiating you MReadTree-object
+//         to set the event number from which you want to start reading.
+//
+Bool_t MReadTree::SetEventNum(UInt_t nr)
+{
+    if (nr >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": SetEventNum, WARNING - " << nr << " out of Range." << endl;
+        return kFALSE;
+    }
+
+    fNumEntry = nr;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  For the branch with the given name:
+//   1) no object is automatically created
+//   2) the branch address for this branch is not set
+//      (because we lack the object, see 1)
+//   3) The whole branch (exactly: all its subbranches) are disabled
+//      this means are not read in memory by TTree:GetEntry
+//
+void MReadTree::VetoBranch(const char *name)
+{
+    fVetoList->Add(new TNamed(name, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the name of the file we are actually reading from.
+//
+TString MReadTree::GetFileName() const
+{
+    const TFile *file = fChain->GetFile();
+
+    if (!file)
+        return TString("<unknown>");
+
+    TString name(file->GetName());
+    name.Remove(0, name.Last('/')+1);
+    return name;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the number of the file in the chain, -1 in case of an error
+//
+Int_t MReadTree::GetFileIndex() const
+{
+    return fChain->GetTreeNumber();
+    /*
+    const TString filename = fChain->GetFile()->GetName();
+
+    int i=0;
+    TObject *file = NULL;
+
+    TIter Next(fChain->GetListOfFiles());
+    while ((file=Next()))
+    {
+        if (filename==gSystem->ExpandPathName(file->GetTitle()))
+            return i;
+        i++;
+    }
+    return -1;
+    */
+}
+
+// --------------------------------------------------------------------------
+//
+//  This schedules a TObject which Notify(9 function is called in case
+//  of MReadTree (TChain) switches from one file in the chain to another
+//  one.
+//
+void MReadTree::AddNotify(TObject *obj)
+{
+    fNotify->Add(obj);
+}
+
+void MReadTree::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << dec << endl;
+    *fLog << setfill('-') << setw(strlen(GetDescriptor())) << "" << endl;
+    *fLog << " Files [Tree]:" << endl;
+
+    int i = 0;
+    TIter Next(fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        *fLog << " " << i++ << ") " << obj->GetTitle() << " [" << obj->GetName() << "]" << endl;
+
+    *fLog << " Total Number of Entries: " << fNumEntries << endl;
+    *fLog << " Next Entry to read: " << fNumEntry << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MReadTree::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << fChain->GetName() << "\", \"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    TIter Next(fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        out << "   " << GetUniqueName() << ".AddFile(\"" << obj->GetTitle() << "\");" << endl;
+
+    if (!fAutoEnable)
+        out << "   " << GetUniqueName() << ".DisableAutoScheme();" << endl;
+
+    if (fNumEntry!=0)
+       out << "   " << GetUniqueName() << ".SetEventNum(" << fNumEntry << ");" << endl;
+
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MReadTree.h	(revision 1638)
@@ -0,0 +1,77 @@
+#ifndef MARS_MReadTree
+#define MARS_MReadTree
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class MChain;
+class TBranch;
+
+class MReadTree : public MRead
+{
+private:
+    MChain *fChain;            // Pointer to tree
+
+    UInt_t  fNumEntry;         // Number of actual entry in chain
+    UInt_t  fNumEntries;       // Number of Events in chain
+
+    Bool_t  fBranchChoosing;   // Flag for branch choosing method
+    Bool_t  fAutoEnable;       // Flag for auto enabeling scheme
+
+    TList  *fVetoList;         // List of Branches which are not allowed to get enabled
+    TList  *fNotify;           // List of TObjects to notify when switching files
+
+    enum { kChainWasChanged = BIT(14) };
+
+private:
+    void SetBranchStatus(const TList *list, Bool_t status);
+    void SetBranchStatus(TObject *branch, Bool_t status);
+    void SetBranchStatus(const char *name, Bool_t status);
+
+    void DisableSubBranches(TBranch *b);
+    void EnableBranches(MParList *plist);
+    void EnableBranchChoosing();
+
+    virtual void SetReadyToSave(Bool_t flag=kTRUE);
+    virtual void StreamPrimitive(ofstream &out) const;
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    MReadTree();
+    MReadTree(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL);
+    ~MReadTree();
+
+    void   DisableAutoScheme() { fAutoEnable = kFALSE; }
+    void   EnableBranch(const char *name);
+    void   VetoBranch(const char *name);
+
+    Bool_t GetEvent();
+
+    Bool_t DecEventNum(UInt_t dec=1); // decrease number of event (position in tree)
+    Bool_t IncEventNum(UInt_t inc=1); // increase number of event (position in tree)
+    Bool_t SetEventNum(UInt_t nr);    // set number of event (position in tree)
+
+    UInt_t GetEventNum() const { return fNumEntry; }
+    UInt_t GetEntries();
+
+    TString    GetFileName() const;
+    Int_t      GetFileIndex() const;
+
+    virtual void   AddNotify(TObject *obj);
+    virtual void   SetOwner(Bool_t flag=kTRUE);
+    virtual void   Print(Option_t *opt="") const;
+
+    virtual Int_t  AddFile(const char *fname);
+    virtual Int_t  AddFiles(const MReadTree &read);
+
+    virtual Bool_t PreProcess(MParList *pList);
+    virtual Bool_t Process();
+
+    virtual Bool_t Notify();
+
+    ClassDef(MReadTree, 1)	// Reads a tree from file(s)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.cc	(revision 1638)
@@ -0,0 +1,292 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  06/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MWriteAsciiFile                                                         //
+//                                                                         //
+// If you want to store a single container into an Ascii file you have     //
+// to use this class. You must know the name of the file you wanne write   //
+// (you should know it) and the name of the container you want to write.   //
+// This can be the name of the class or a given name, which identifies     //
+// the container in a parameter container list (MParList).                 //
+// The container is written to the ascii file if its ReadyToSave flag is   //
+// set (MParContainer)                                                     //
+//                                                                         //
+// You can write more than one container in one line of the file, see      //
+// AddContainer.                                                           //
+//                                                                         //
+// You can also write single data members of a container (like fWidth      //
+// of MHillas). For more details see AddContainer. Make sure, that a       //
+// getter method for the data member exist. The name of the method         //
+// must be the same than the data member itself, but the f must be         //
+// replaced by a Get.                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MWriteAsciiFile.h"
+
+#include <fstream.h>
+
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+
+#include "MDataList.h"   // MDataList
+#include "MDataChain.h"  // MDataChain
+#include "MDataValue.h"  // MDataValue
+#include "MDataMember.h" // MDataMember
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MWriteAsciiFile);
+
+// --------------------------------------------------------------------------
+//
+// Init. Replaces the same code used in all constructors.
+//
+void MWriteAsciiFile::Init(const char *filename, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MWriteAsciiFile";
+    fTitle = title ? title : "Task to write one container to an ascii file";
+
+    fNameFile = filename;
+
+    fOut = new ofstream(fNameFile);
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the ascii output file 'filename' and the name
+// of the container you want to write. (Normally this is the name
+// of the class (eg. MHillas) but it can also be a different name which
+// identifies the container in the parameter list.
+// Because you cannot write more than one container there is no Add-function
+// like in MWriteRootFile.
+//
+//  For Example: MWriteAsciiFile("file.txt", "MHillas");
+//
+MWriteAsciiFile::MWriteAsciiFile(const char *filename, const char *contname,
+                                 const char *name, const char *title)
+{
+    Init(filename, name, title);
+
+    if (contname)
+       AddColumns(contname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify a the name of the ascii output file 'filename' and a pointer to
+// the container you want to write. 
+// Because you cannot write more than one container there is no Add-function
+// like in MWriteRootFile.
+//
+//  For Example: MHillas hillas;
+//               MWriteAsciiFile("file.txt", &hillas);
+//
+//
+MWriteAsciiFile::MWriteAsciiFile(const char *filename, MParContainer *cont,
+                                 const char *name, const char *title)
+{
+    Init(filename, name, title);
+
+    if (cont)
+        AddColumns(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete the output file if necessary (it is closed
+// automatically by its destructor.
+//
+MWriteAsciiFile::~MWriteAsciiFile()
+{
+    fAutoDel.SetOwner();
+    delete fOut;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return open state of the file
+//
+Bool_t MWriteAsciiFile::IsFileOpen() const
+{
+    return (bool)(*fOut);
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to get all containers from the ParList which were given by name
+// adds them to the list of pointers to the container which should be
+// written to the ascii file.
+//
+Bool_t MWriteAsciiFile::GetContainer(MParList *plist)
+{
+    TObject *obj=NULL;
+
+    TIter Next(&fList);
+    while ((obj=Next()))
+    {
+        //
+        // MData is the highest class in the inheritance tree
+        //
+        if (obj->InheritsFrom(MData::Class()))
+        {
+            if (!((MData*)obj)->PreProcess(plist))
+                return kFALSE;
+            continue;
+        }
+
+        //
+        // MParContainer is the next class in the inheritance tree
+        //
+        if (obj->InheritsFrom(MParContainer::Class()))
+            continue;
+
+        //
+        // It is neither a MData nor a MParContainer, it must be a TNamed
+        //
+        TObject *o = plist->FindObject(obj->GetName());
+        if (!o)
+            return kFALSE;
+
+        fList[fList.IndexOf(obj)] = o;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if the containers are ready for writing. If so write them.
+// The containers are written in one line, one after each other.
+// If not all containers are written (because of the IsReadyToSave-flag)
+// a warning message is print.
+//
+void MWriteAsciiFile::CheckAndWrite() const
+{
+    Bool_t written = kFALSE;
+
+    MParContainer *obj = NULL;
+
+    Int_t num = fList.GetEntries();
+
+    TIter Next(&fList);
+    while ((obj=(MParContainer*)Next()))
+    {
+        if (!obj->IsReadyToSave())
+            continue;
+
+        if (!obj->AsciiWrite(*fOut))
+            continue;
+
+        written = kTRUE;
+
+        num--;
+    }
+
+    if (!written)
+        return;
+
+    *fOut << endl;
+
+    if (num!=0)
+        *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a rule to be written as a column to the ascii file.
+// For more information about rules see MDataChain.
+//
+//  eg: MWriteAsciiFile::AddColumn("log10(MHillas.fEnergy)/2")
+//
+void MWriteAsciiFile::AddColumn(const TString rule)
+{
+    MDataChain *chain = new MDataChain(rule);
+    fList.Add(chain);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another column to be written to the ascii file. The columns will be
+// output one after each other in one line.
+// Specify the name of the data member to be written (eg fWidth) and
+// a possible scale factor (eg. to transform millimeters to degrees)
+//
+//  eg:
+//       MMcEvt evt;
+//       MWriteAsciiFile::AddColumn(&evt, "fImpact", 0.01);
+//
+void MWriteAsciiFile::AddColumn(MParContainer *cont, const TString member, Double_t scale)
+{
+    MData *data = new MDataMember(cont, member);
+
+    if (scale!=1)
+    {
+        MDataList  *list = new MDataList('*');
+        MDataValue *val  = new MDataValue(scale);
+
+        list->SetOwner();
+        list->AddToList(data);
+        list->AddToList(val);
+
+        data = list;
+    }
+    fList.Add(data);
+    fAutoDel.Add(data);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another container (by name) to be written to the ascii file.
+// The container will be output one after each other in one line.
+// The output will be done either by MParContainer::AsciiWrite or
+// by the corresponding overloaded function.
+//
+//  eg: MWriteAsciiFile::AddColumns("MMcEvt")
+//
+void MWriteAsciiFile::AddColumns(const TString cont)
+{
+    TNamed *name = new TNamed(cont, cont);
+    fList.Add(name);
+    fAutoDel.Add(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another container (by pointer) to be written to the ascii file.
+// The container will be output one after each other in one line.
+// The output will be done either by MParContainer::AsciiWrite or
+// by the corresponding overloaded function.
+//
+//  eg:
+//      MMcEvt evt;
+//      MWriteAsciiFile::AddColumns(&evt);
+//
+void MWriteAsciiFile::AddColumns(MParContainer *cont)
+{
+    fList.Add(cont);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteAsciiFile.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MWriteAsciiFile
+#define MARS_MWriteAsciiFile
+
+#ifndef MARS_MWriteFile
+#include "MWriteFile.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MData;
+
+class MWriteAsciiFile : public MWriteFile
+{
+private:
+    ofstream *fOut;     //! ascii file
+
+    TString fNameFile;  // name of the ascii file
+
+    TObjArray fList;    // list of rules and containers to be written
+    TObjArray fAutoDel; //! List of object to be deleted in the destructor
+
+    virtual void   CheckAndWrite() const;
+    virtual Bool_t IsFileOpen() const;
+    virtual Bool_t GetContainer(MParList *pList);
+    virtual const char *GetFileName() const { return fNameFile; }
+
+    void Init(const char *filename, const char *name, const char *title);
+
+public:
+    MWriteAsciiFile(const char *filename, const char *contname,
+                    const char *name=NULL, const char *title=NULL);
+    MWriteAsciiFile(const char *filename, MParContainer *cont=NULL,
+                    const char *name=NULL, const char *title=NULL);
+    ~MWriteAsciiFile();
+
+    void AddColumn(const TString rule);
+    void AddColumn(MParContainer *cont, const TString member="", Double_t scale=1);
+    void AddColumns(const TString name);
+    void AddColumns(MParContainer *cont);
+
+    ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.cc	(revision 1638)
@@ -0,0 +1,110 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  06/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MWriteFile                                                              //
+//                                                                         //
+// This is a base class for writing tasks. If you want to implement        //
+// writing out parameter containers in a new file format, this is a good   //
+// starting point.                                                         //
+// The class defines a generalized interface between writing out data in   //
+// an eventloop and your file format.                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MWriteFile.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MWriteFile);
+
+// --------------------------------------------------------------------------
+//
+// Tries to open the given output file.
+// The derived class should retrieve needed containers from the parameter
+// list.
+// instance of the container which should be written.
+// If the container has already the HasChanged flag it is immediatly written
+// to the output file.
+//
+Bool_t MWriteFile::PreProcess(MParList *pList)
+{
+    //
+    // test whether file is now open or not
+    //
+    if (!IsFileOpen())
+    {
+        *fLog << err << dbginf << "Cannot open file '" << GetFileName() << "'" << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << "File '" << GetFileName() << "' open for writing." << endl;
+
+    //
+    // Get the containers (pointers) from the parameter list you want to write
+    //
+    if (!GetContainer(pList))
+        return kFALSE;
+
+    //
+    // write the container if it is already in changed state
+    //
+    CheckAndWrite();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the HasChanged flag of the output container is set. If it is set
+// the container should be written to the output.
+//
+Bool_t MWriteFile::Process()
+{
+    CheckAndWrite();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the HasChanged flag of the output container is set. If it is set
+// the container should be written to the output.
+//
+Bool_t MWriteFile::PostProcess()
+{
+    //
+    // check if the container changed state is set
+    //
+    CheckAndWrite();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteFile.h	(revision 1638)
@@ -0,0 +1,23 @@
+#ifndef MARS_MWriteFile
+#define MARS_MWriteFile
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MWriteFile : public MTask
+{
+private:
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    virtual Bool_t      IsFileOpen() const = 0;
+    virtual void        CheckAndWrite() const = 0;
+    virtual Bool_t      GetContainer(MParList *pList) = 0;
+    virtual const char *GetFileName() const = 0;
+
+    ClassDef(MWriteFile, 0)	// Base class for tasks to write single containers to several output formats
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.cc	(revision 1638)
@@ -0,0 +1,452 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  06/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MWriteRootFile                                                          //
+//                                                                         //
+// This is a writer to store several containers to a root file.            //
+// The containers are added with AddContainer.                             //
+// To understand how it works, see base class MWriteFile                   //
+//                                                                         //
+// Warning: Checkout the Warning in MTaskList.                             //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MWriteRootFile.h"
+
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MRootFileBranch);
+ClassImp(MWriteRootFile);
+
+static const TString gsDefName  = "MWriteRootFile";
+static const TString gsDefTitle = "Task which writes a root-output file";
+// --------------------------------------------------------------------------
+//
+// Default constructor. It is there to support some root stuff.
+// Don't use it.
+//
+MWriteRootFile::MWriteRootFile() : fOut(NULL)
+{
+    fName  = gsDefName;
+    fTitle = gsDefTitle;
+
+    fBranches.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the root file. You can also give an option ("UPDATE"
+// and "RECREATE" would make sense only) as well as the file title and
+// compression factor. To a more detaild description of the options see
+// TFile.
+//
+MWriteRootFile::MWriteRootFile(const char *fname,
+                               const Option_t *opt,
+                               const char *ftitle,
+                               const Int_t comp,
+                               const char *name,
+                               const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    //
+    // Set the Arrays the owner of its entries. This means, that the
+    // destructor of the arrays will delete all its entries.
+    //
+    fBranches.SetOwner();
+
+    //
+    // Believing the root user guide, TTree instanced are owned by the
+    // directory (file) in which they are. This means we don't have to
+    // care about their destruction.
+    //
+    //fTrees.SetOwner();
+
+    //
+    // Open the rootfile
+    //
+    fOut = new TFile(fname, opt, ftitle, comp);
+}
+
+// --------------------------------------------------------------------------
+//
+// Prints some statistics about the file to the screen. And closes the file
+// properly.
+//
+MWriteRootFile::~MWriteRootFile()
+{
+    //
+    // Print some statistics to the looging out.
+    //
+    Print();
+
+    //
+    // If the file is still open (no error) write the keys. This is necessary
+    // for appearance of the all trees and branches.
+    //
+    if (IsFileOpen())
+        fOut->Write();
+
+    //
+    // Delete the file. This'll also close the file (if open)
+    //
+    delete fOut;
+
+    //
+    // Remark:
+    // - Trees are automatically deleted by the the file
+    //   (unless file.SetDirectory(0) was called)
+    // - Branches are automatically deleted by the tree destructor
+    //
+
+    *fLog << inf << "Output File closed and deleted." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Prints all trees with the actually number of written entries to log-out.
+//
+void MWriteRootFile::Print(Option_t *) const
+{
+    *fLog << all << " File: " << GetFileName() << endl;
+    *fLog << setfill('-') << setw(strlen(GetFileName())+8) << "" << endl;
+    *fLog << setfill(' '); // FIXME: not resetting setfill results in strange output???
+
+    TTree *t = NULL;
+    TIter Next(&fTrees);
+    while ((t=(TTree*)Next()))
+        *fLog << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new Container to list of containers which should be written to the
+// file. Give the name of the container which will identify the container
+// in the parameterlist. tname is the name of the tree to which the
+// container should be written (Remark: one tree can hold more than one
+// container). The default is the same name as the container name.
+// You can slso specify a title for the tree. This is only
+// used the first time this tree in 'mentioned'. As default the title
+// is the name of the tree.
+//
+void MWriteRootFile::AddContainer(const char *cname, const char *tname, const char *ttitle)
+{
+    //
+    // create a new entry in the list of branches to write and
+    // add the entry to the list.
+    //
+    MRootFileBranch *entry = new MRootFileBranch(cname, tname, ttitle);
+    fBranches.AddLast(entry);
+
+    if (tname && tname[0])
+        AddToBranchList(Form("%s.%s", cname, tname));
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new Container to list of containers which should be written to the
+// file. Give the pointer to the container. tname is the name of the tree to
+// which the container should be written (Remark: one tree can hold more than
+// one container). The default is the same name as the container name.
+// You can slso specify a title for the tree. This is only
+// used the first time this tree in 'mentioned'. As default the title
+// is the name of the tree.
+//
+void MWriteRootFile::AddContainer(MParContainer *cont, const char *tname,
+                                  const char *ttitle)
+{
+    //
+    // create a new entry in the list of branches to write and
+    // add the entry to the list.
+    //
+    MRootFileBranch *entry = new MRootFileBranch(cont, tname, ttitle);
+    fBranches.AddLast(entry);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new Container to list of containers which should be written to the
+// file. Give the pointer to the container. tname is the name of the tree to
+// which the container should be written (Remark: one tree can hold more than
+// one container). The default is the same name as the container name.
+// You can slso specify a title for the tree. This is only
+// used the first time this tree in 'mentioned'. As default the title
+// is the name of the tree.
+//
+Bool_t MWriteRootFile::GetContainer(MParList *pList)
+{
+    MRootFileBranch *entry;
+
+    //
+    // loop over all branches which are 'marked' as branches to get written.
+    //
+    TIter Next(&fBranches);
+    while ((entry=(MRootFileBranch*)Next()))
+    {
+        //
+        // Get the pointer to the container. If the pointer is NULL it seems,
+        // that the user identified the container by name.
+        //
+        MParContainer *cont = entry->GetContainer();
+        if (!cont)
+        {
+            //
+            // Get the name and try to find a container with this name
+            // in the parameter list.
+            //
+            const char *cname = entry->GetContName();
+            cont = (MParContainer*)pList->FindObject(cname);
+            if (!cont)
+            {
+                //
+                // No corresponding container is found
+                //
+                *fLog << dbginf << "Cannot find parameter container '" << cname << "'." << endl;
+                return kFALSE;
+            }
+            //
+            // The container is found. Put the pointer into the entry.
+            //
+            entry->SetContainer(cont);
+        }
+
+        //
+        // Get container name, tree name and tree title of this entry.
+        //
+        const char *cname  = cont->GetName();
+        const char *tname  = entry->GetName();
+        const char *ttitle = entry->GetTitle();
+
+        //
+        // if the tree name is NULL this idetifies it to use the default:
+        // the container name.
+        //
+        if (tname[0] == '\0')
+            tname = cname;
+
+        //
+        // Check if the tree is already existing (part of the file)
+        //
+        TTree *tree = (TTree*)fOut->Get(tname);
+        if (!tree)
+        {
+            //
+            // if the tree doesn't exist create a new tree. Use the tree
+            // name as title if title is NULL.
+            // And add the tree to the list of trees
+            //
+            TDirectory *save = gDirectory;
+            fOut->cd();
+
+            tree = new TTree(tname, ttitle ? ttitle : tname);
+            fTrees.AddLast(tree);
+
+            gDirectory = save;
+
+            *fLog << "Created Tree " << tname << "." << endl;
+        }
+
+        //
+        // Now we have a valid tree. Search the list of trees for this tree
+        // (either it is already there, or we created and add it previously)
+        // Add a pointer to the entry in the tree list to this branch-entry
+        //
+        TObject *obj;
+        TIter NextTree(&fTrees);
+        while ((obj=NextTree()))
+        {
+            if (obj == tree)
+                entry->SetTree((TTree*)obj);
+        }
+
+        //
+        // Try to get the branch from the file. 
+        // If the branch already exists the user specified one branch twice.
+        //
+        TBranch *branch = tree->GetBranch(cname);
+        if (branch)
+        {
+            *fLog << dbginf << "Branch '" << cname << "' is already existing." << endl;
+            return kFALSE;
+        }
+
+        //
+        // Create a new branch in the actual tree. The branch has the name
+        // container name. The type of the container is given by the
+        // ClassName entry in the container. The Address is the address of a
+        // pointer to the container (gotten from the branch entry). As
+        // Basket size we specify a (more or less) common default value.
+        // The containers should be written in Splitlevel=1
+        //
+        TString branchname(cname);
+        branchname.Append(".");
+        branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
+
+        *fLog << "Created Branch " << cname << " of " << cont->ClassName() << "." << endl;
+
+        //
+        // If the branch couldn't be created we have a problem.
+        //
+        if (!branch)
+        {
+            *fLog << dbginf << "Unable to create branch '" << cname << "'." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks all given containers (branch entries) for the write flag.
+// If the write flag is set the corresponding Tree is marked to get filled.
+// All Trees which are marked to be filled are filled with the corresponding
+// branches.
+// Be carefull: If only one container (corresponding to a branch) of a tree
+// has the write flag, all containers in this tree are filled!
+//
+void MWriteRootFile::CheckAndWrite() const
+{
+    const Int_t kFillTree = BIT(14);
+
+    TObject *obj;
+
+    //
+    // Loop over all branch entries
+    //
+    TIter NextBranch(&fBranches);
+    while ((obj=NextBranch()))
+    {
+        MRootFileBranch *b = (MRootFileBranch*)obj;
+
+        //
+        // Check for the Write flag
+        //
+        if (!b->GetContainer()->IsReadyToSave())
+            continue;
+
+        //
+        // If the write flag of the branch entry is set, set the write flag of
+        // the corresponding tree entry.
+        //
+        b->GetTree()->SetBit(kFillTree);
+    }
+
+    //
+    // Loop over all tree entries
+    //
+    TIter NextTree(&fTrees);
+    while ((obj=NextTree()))
+    {
+        TTree *t = (TTree*)obj;
+
+        //
+        // Check the write flag of the tree
+        //
+        if (!t->TestBit(kFillTree))
+            continue;
+
+        //
+        // If the write flag is set, fill the tree (with the corresponding
+        // branches/containers), delete the write flag and increase the number
+        // of written/filled entries.
+        //
+        t->Fill();
+        t->ResetBit(kFillTree);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// return open state of the root file.
+//
+Bool_t MWriteRootFile::IsFileOpen() const
+{
+    return fOut->IsOpen();
+}
+
+// --------------------------------------------------------------------------
+//
+// return name of the root-file
+//
+const char *MWriteRootFile::GetFileName() const
+{
+    return fOut->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MWriteRootFile::StreamPrimitive(ofstream &out) const
+{
+    out << "   MWriteRootFile " << GetUniqueName() << "(\"";
+    out << fOut->GetName() << "\", \"";
+    out << fOut->GetOption() << "\", \"";
+    out << fOut->GetTitle() << "\", ";
+    out << fOut->GetCompressionLevel();
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+
+    MRootFileBranch *entry;
+    TIter Next(&fBranches);
+    while ((entry=(MRootFileBranch*)Next()))
+    {
+        out << "   " << GetUniqueName() << ".AddContainer(";
+
+        if  (entry->GetContainer())
+        {
+            entry->GetContainer()->SavePrimitive(out);
+            out << "&" << entry->GetContainer()->GetUniqueName();
+        }
+        else
+            out << "\"" << entry->GetContName() << "\"";
+
+        out << ", \"" << entry->GetName() << "\"";
+        if ((TString)entry->GetTitle()!="")
+            out << ", \"" << entry->GetTitle() << "\"";
+
+        out <<");" << endl;
+    }
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/MWriteRootFile.h	(revision 1638)
@@ -0,0 +1,100 @@
+#ifndef MARS_MWriteRootFile
+#define MARS_MWriteRootFile
+
+#ifndef MARS_MWriteFile
+#include "MWriteFile.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class TFile;
+class TTree;
+class TBranch;
+
+class MRootFileBranch : public TNamed
+{
+private:
+    TTree         *fTree;       //!
+    TBranch       *fBranch;     //!
+
+    MParContainer *fContainer;
+    TString        fContName;
+
+    void Init(const char *name, const char *title)
+    {
+        SetName(name?name:"");
+        SetTitle(title?title:"");
+    }
+
+public:
+    MRootFileBranch() : fTree(NULL), fBranch(NULL), fContainer(NULL)
+    {
+        Init(NULL, NULL);
+        fContName = "";
+    }
+
+    MRootFileBranch(const char *cname, const char *tname=NULL, const char *ttitle=NULL)
+        : fTree(NULL), fBranch(NULL), fContainer(NULL)
+    {
+        Init(tname, ttitle);
+        fContName = cname;
+    }
+
+    MRootFileBranch(MParContainer *cont, const char *tname=NULL, const char *ttitle=NULL)
+        : fTree(NULL), fBranch(NULL), fContName("")
+    {
+        Init(tname, ttitle);
+        fContainer = cont;
+    }
+
+    TTree         *GetTree() const      { return fTree; }
+    MParContainer *GetContainer() const { return fContainer; }
+    void          *GetAddress()         { return &fContainer; }
+    TBranch       *GetBranch() const    { return fBranch; }
+    const char    *GetContName() const  { return fContName; }
+
+    void SetContainer(MParContainer *cont) { fContainer = cont; }
+    void SetTree(TTree *tree)              { fTree = tree; }
+
+    ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
+};
+
+class MWriteRootFile : public MWriteFile
+{
+private:
+    TFile *fOut;
+
+    TObjArray fBranches;
+    TObjArray fTrees;     //!
+
+    void        CheckAndWrite() const;
+    Bool_t      IsFileOpen() const;
+    Bool_t      GetContainer(MParList *pList);
+    const char *GetFileName() const;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MWriteRootFile();
+    MWriteRootFile(const char *fname,
+                   const Option_t *opt="RECREATE",
+                   const char *ftitle="Untitled",
+                   const Int_t comp=9,
+                   const char *name=NULL,
+                   const char *title=NULL);
+    ~MWriteRootFile();
+
+
+    void AddContainer(const char *cname,
+                      const char *tname=NULL, const char *ttitle=NULL);
+    void AddContainer(MParContainer *cont,
+                      const char *tname=NULL, const char *ttitle=NULL);
+
+
+    void Print(Option_t *t=NULL) const;
+
+    ClassDef(MWriteRootFile, 1)	// Class to write one container to a root file
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/Makefile	(revision 1638)
@@ -0,0 +1,58 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis -I../mgeom
+
+# @code 
+
+CINT     = FileIO
+LIB      = mfileio.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MChain.cc \
+	   MRead.cc \
+           MReadTree.cc \
+           MReadMarsFile.cc \
+           MWriteFile.cc \
+           MWriteAsciiFile.cc \
+           MWriteRootFile.cc \
+           MCT1ReadAscii.cc \
+           MCT1ReadPreProc.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/defines.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/defines.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/defines.h	(revision 1638)
@@ -0,0 +1,788 @@
+/******************************************************************/
+/*              GGG   AAA   M   M M   M  AAA   SSS                */
+/*             G   G A   A  MM MM MM MM A   A S   S               */
+/*             G     A   A  M M M M M M A   A  SS                 */
+/*             G  GG AAAAA  M   M M   M AAAAA   SS                */
+/*             G   G A   A  M   M M   M A   A S   S               */
+/*              GGG  A   A  M   M M   M A   A  SSS                */
+/*       Gamma Astronomer's Munich Madrid Analysis Suite          */
+/*   An Atmospheric Cherenkov Telescope Data Analysis Software    */
+/*  MPI f"ur Physik, M"unchen & Universidad Complutense, Madrid   */
+/******************************************************************/
+
+/******************************************************************/
+/* This File belongs to the programs                              */
+/*                                                                */
+/*  P R E P R O C E S S O R   and   I M A G E R                   */
+/*                                                                */
+/* Purpose: provide the structure definitions common to both      */
+/*          programs, especially the output structures of the     */
+/*          preprocessor                                          */ 
+/*                                                                */
+/******************************************************************/
+
+#ifndef _defines_h_
+#define _defines_h_ "__defines_h__"
+
+#define cIDSTRING(x,y,z) "@(#) GAMMAS "#x" version "#y", date "#z"."
+#define CAT(x,y) #x#y
+#define XCAT(x,y) CAT(x,y)
+
+#define Boolean int
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/*************** DEFINES ******************************************/
+
+/* General defines */
+
+#define cHELLOSTRING(x,y) "This is preproc.\nVersion "#x", date "#y"\n\n"
+#define PREPROCVERSIONSTRING(x) "V"#x  
+
+#define dDEG_PER_HOUR 15.
+#define dRAD_PER_DEG 0.0174532925199 /* = 3.14159265359/180. */
+#define dSECS_PER_DAY 86400.
+#define SQUARE(x) ((x) * (x))
+
+/* defines for histograms and ntuple creation */
+
+#define HMAX 2000000 /* memory reserved for pawc common block 
+		     * used by hbook */
+#define DAB -999 /* if a histogramm parameter is to be Defined 
+		  * At Booking enter -999 */
+#define iADCHISTID 1000 /* id of the first histogram for ADC 
+			 * count spectra */
+#define cADCHISTTITLE "Pixel signals before calibration;pixel \
+number;ADC counts"
+#define iADCHIST_BINS 127 /* This is a good guess. bparametersok()
+			   * will look at parameters for the bins 
+			   * in X direction and adjust the other,
+			   * similar histograms acoordingly. */
+#define fADCHIST_LOLIMX 0.5
+#define fADCHIST_HILIMX 127.5 /* For both of them, see above. */
+
+
+
+#define iPHEHISTID 2000 /* id of the first histogram for photo 
+			 *electron spectra */
+#define cPHEHISTTITLE "Pixel signals after calibration;pixel \
+number;photo electrons"
+#define iPHEHIST_BINS 127 /* This is a good guess. bparametersok()
+			   * will look at parameters for the bins 
+			   * in X direction and adjust the other,
+			   * similar histograms acoordingly. */
+#define fPHEHIST_LOLIMX 0.5
+#define fPHEHIST_HILIMX 127.5 /* For both of them, see above. */
+
+#define iPEDONHISTID 12000 /* id of the first histogram for the 
+			    *signals taken in pedestalruns for ON */
+#define iPEDOFHISTID 11000 /* id of the first histogram for the 
+			    *signals taken in pedestalruns for OF */
+#define cPEDONHISTTITLE "Pixel signals from ON pedestal runs;\
+pixel number;ADC Counts"
+#define cPEDOFHISTTITLE "Pixel signals from OF pedestal runs;\
+pixel number;ADC Counts"
+#define iPEDONMEANHISTID 14000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for ON */
+#define iPEDOFMEANHISTID 13000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for OF */
+#define cPEDONMEANHISTTITLE "Pedestal Means from ON pedestal runs;\
+Event Index;ADC Counts"
+#define cPEDOFMEANHISTTITLE "Pedestal Means from OF pedestal runs;\
+Event Index;ADC Counts"
+#define iPEDONJITTHISTID 16000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for ON */
+#define iPEDOFJITTHISTID 15000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for OF */
+#define cPEDONJITTHISTTITLE "Deviation from Pedestal Means from \
+ON pedestal runs;Pixel Number;ADC Counts"
+#define cPEDOFJITTHISTTITLE "Deviation from Pedestal Means from \
+OF pedestal runs;Pixel Number;ADC Counts"
+#define iCALONHISTID 18000 /* id of the first histogram for the 
+			    *signals taken in laserruns for ON */
+#define iCALOFHISTID 17000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONHISTTITLE "Pixel signals from ON laser runs;\
+pixel number;ADC Counts"
+#define cCALOFHISTTITLE "Pixel signals from OF laser runs;\
+Pixel Number;ADC Counts"
+#define iCALONMEANHISTID 20000 /* id of the first histogram for the 
+				*signals taken in laserruns for ON */
+#define iCALOFMEANHISTID 19000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONMEANHISTTITLE "Laser Means from ON laser runs;\
+Event Index;ADC Counts"
+#define cCALOFMEANHISTTITLE "Laser Means from OF laser runs;\
+Event Index;ADC Counts"
+#define iCALONJITTHISTID 22000 /* id of the first histogram for the 
+				*signals taken in laserruns for ON */
+#define iCALOFJITTHISTID 21000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONJITTHISTTITLE "Deviation from Laser Means from \
+ON laser runs;Pixel Number;ADC counts"
+#define cCALOFJITTHISTTITLE "Deviation from Laser Means from \
+OF laser runs;Pixel Number;ADC counts"
+#define iZENONHISTID 200 /* id of the histogram for the zenith 
+			  * angle distribution before filter ON */
+#define iZENOFHISTID 100 /* id of the histogram for the zenith 
+			  * angle distribution before filter OF */
+#define cZENONHISTTITLE "zenith angle distribution before filter \
+ON;zenith angle;number of events ON"
+#define cZENOFHISTTITLE "zenith angle distribution before filter \
+OFF;zenith angle;number of events OFF"
+#define iZENHISTNUMBINS 90
+#define fZENHISTLOLIM 0.
+#define fZENHISTHILIM 90.
+/* defines for noise pickup correction of pedestal (added D.K.)
+ */
+#define iCORRPEDHISTID 400 /* id of histogram for pedestal correction values
+			      (noise pickup) */
+#define cCORRPEDHISTTIT "Pickup Correction;ADC counts;Nr. of Events"
+#define iCPEDFWHMHISTID 410 /* id of the histogram for FWHM of pedestal
+			       correction values (noise pickup) */
+#define cCPEDFWHMHISTTIT "FWHM of Pickup Correction;ADC counts;Nr. of Events"
+#define fMIN_CORRPEDHIST -20.
+#define fMAX_CORRPEDHIST 20.
+#define iCORRPEDHIST_BINS 80
+#define fMIN_CPEDFWHMHIST 0.
+#define fMAX_CPEDFWHMHIST 20
+#define iCPEDFWHMHIST_BINS 40
+#define iBIAS 50             /* is used to make the pedestals peak at 'iBIAS' */
+#define dPEDCORRSIZELIMIT 500. /* maximum event SIZE for which noise-pickup is
+				  corrected */
+/* end: defines for noise pickup correction of pedestal
+ */
+
+/* MKA May 8 2000: Version > 0.4 */
+#define cHISTOFILENAME ".hbook" 
+#define cCALNTFILENAME ".nt.hbook"
+#define cOUTDIRNAME "preproc_out/"
+#define cPROJECTNAME "check"
+#define iCALIBNTUPLE_ID  3
+#define iRECL 1024 /* the record length of the calibration ntuple */ 
+
+#define iPARTNERSEARCHDEPTH 20 /* Default search depth if not specified. */
+/* various parameters */
+
+#ifdef ALPHA
+#define iMAXNUMLASERRUNS 4 /* maximum number of laser runs 
+			    * recorded in one file 
+			    * (90 degrees * 4 minutes/degree / 20 minutes) */
+#endif
+#ifdef LINUX
+#define iMAXNUMLASERRUNS 6 /* maximum number of laser runs 
+			    * recorded in one file 
+			    * (90 degrees * 4 minutes/degree / 20 minutes) */
+#endif
+#define iMAXNUMLASEREVENTS 250 /* maximum number of laser shots
+				* recorded for one laser run */
+#ifdef ALPHA
+#define iMAXNUMPEDRUNS 4 /* maximum number of pedestal runs 
+			   * recorded in one file */
+#endif
+#ifdef LINUX
+#define iMAXNUMPEDRUNS 26 /* maximum number of pedestal runs 
+			   * recorded in one file */
+#endif
+#define iMAXNUMPEDEVENTS 500 /* maximum number of random triggers 
+			      * recorded for one pedestal run */
+#define iMAXNUMRUNEVENTS 40000 /* maximum number of events recorded 
+				* in one run data file */
+#define iNUMRMSFITXBINS 100 /* Bins in the (vector)histogram for the 
+			     * fit of the Pedestal RMS */
+#define iRMSFITXSTRETCH 50 /* strectch of the (vector)histogram for the 
+			     * fit of the Pedestal RMS */
+/* Attention: for iNUMRMSFITXBINS and iRMSFITXSTRETCH the following
+ * requirement must be fulfilled:
+ * A width of 1 must be achieveble as an integer multiple of the
+ * binwidth, i.e. 5 or 6 times (iRMSFITXSTRETCH/iNUMRMSFITXBINS) must
+ * make up 1. */
+
+#define iRMSFITXOFFSET 2 /* half a bin offset to the left: Start a bin 
+			 * with center at 0 at 1./2. binwidth earlier */
+
+#define iMAXFILENAMELENGTH 400
+/* general limit on the length of filename strings (including path) */ 
+#define iMAXNUMDIRENTRIES 1028 /* MKA: Nonsens to limit this; we 
+				* rewrite this in the future. 
+				* Make a chained list and allocate
+				* memory for it dynamically. Free
+				* this memory afterwards. 
+				* Put on to-do-list Nov 6 1999 */
+/* the maximum number of filenames expected in a directory to 
+ * be read by ireaddir() */
+#define cDIRFILENAME "preproc.dir" 
+/* intermediate file used by ireaddir() */
+#define iMAXNUMCALFILEOFFSET 400 /* That is the number of Runs, which 
+				  * is searched back to find a TelCal 
+				  * file for analysis. */
+
+#define iMAXNUMPEDFILEOFFSET 400 /* That is the number of Runs, which 
+				  * is searched back to find a TelPed 
+				  * file for analysis. */ 
+
+#define iMAXNUMTELLOGFILEOFFSET 400 /* That is the number of Runs, which 
+				     * is searched back to find a TelLog 
+				     * file for analysis. */
+
+/* keywords, numbers of arguments, values and ranges of values 
+   which define the syntax in the parameters file
+   
+   in order to introduce a new input parameter, you have to 
+   a) increase iNUMKEYWORDS
+   b) #define the keyword (cKEYWORDXX), the format for the 
+      arguments (cKEYWORDXXARG)
+      the number of arguments (iKEYWORDXXNUMARG), 
+      the minimum and maximum value 
+      (iMIN..., iMAX...) for numerical arguments
+   c) for enum-type arguments look at keywords 10 or 11 to see 
+      what to #define
+      (iKEYWORDXXARGYNUMVAL = the number of values the arguments 
+      no. Y of keyword no. XX can take, 
+      cKEYWORDXXARGYVALS  = enumeration of the different values 
+      (strings) the argument can have
+   d) put entries into the initialization of the arrays ckeyword, 
+      ckeywordarg, ikeywordnumarg, fargvalmin, fargvalmax, and 
+      for enum-type arguments declare a new array keywordXXvalues 
+      as for keywords 10 and 11
+   e) include the new parameter into the structure inputpars, 
+      and, if you wish to, in outputpars also.
+   f) add the corresponding case to the switch(k) statement in main()
+   g) modify bparametersok(), bprintinputpars() and 
+      vsetinputparsunfilled()
+   h) program the transfer of the parameter from inputpars to 
+      outputpars if necessary
+      .... to be continued  */
+
+
+#define iNUMKEYWORDS 46  /* the number of different kewords 
+			  * defined for use in the
+                          * parameters file */
+
+#define cKEYWORD01                "iTELESCOPE"
+/* keyword no. 1, this keyword must have this number, don't change it */
+#define cKEYWORD01ARG             "%d"
+#define iKEYWORD01NUMARG 1 /* number of arguments */
+#define iMINTELESCOPEID 1 /* minimum value */
+#define iMAXTELESCOPEID 2 /* maximum value */
+
+#define cKEYWORD02                "iRUNNUM"
+/* keyword no. 2, this keyword must have this number, don't change it */
+#define cKEYWORD02ARG             "%d"
+#define iKEYWORD02NUMARG 1
+#define iMINRUNNUM 0 /* minimum value */
+#define iMAXRUNNUM 99999 /* maximum value */
+
+#define cKEYWORD03                "inumpixels"
+/* keyword no. 3 */
+#define cKEYWORD03ARG             "%d"
+#define iKEYWORD03NUMARG 1
+#define iMINNUMPIX 37 /* minimum value for the number of camera 
+		       * pixels (excl. muon shield) */
+/* #define iMAXNUMPIX ..  maximum value defined in structures.h */
+
+#define cKEYWORD04                "fpixdiameter_deg"
+/* keyword no. 4 */
+#define cKEYWORD04ARG             "%f"
+#define iKEYWORD04NUMARG 1
+#define fMINPIXDIA_DEG 0.1 /* minimum value */
+#define fMAXPIXDIA_DEG 1.0 /* maximum value */
+
+#define cKEYWORD05                "ise1zeropos"
+/* keyword no. 5 */
+#define cKEYWORD05ARG             "%d"
+#define iKEYWORD05NUMARG 1
+#define iMINSE1POS 0 /* minimum value */
+#define iMAXSE1POS 50000 /* maximum value */
+
+#define cKEYWORD06                "ise2zeropos"
+/* keyword no. 6 */
+#define cKEYWORD06ARG             "%d"
+#define iKEYWORD06NUMARG 1
+#define iMINSE2POS 0 /* minimum value */
+#define iMAXSE2POS 50000 /* maximum value */
+
+#define cKEYWORD07               "idontusepix"
+/* keyword no. 7 */
+#define cKEYWORD07ARG             "%d"
+#define iKEYWORD07NUMARG 1 
+#define iMINPIXNUM 1 /* in the parameters file counting of the 
+		      * pixels starts at 1 */
+/* maximum value of this parameter is iMAXNUMPIX */
+/* negative parameters in the range -iMINPIXNUM to -iMAXNUMPIX 
+ * are also allowed: */
+/* they switch the pixel back on */
+
+#define cKEYWORD08               "isum_thresh_phot"
+/* keyword no. 8 */
+#define cKEYWORD08ARG             "%d"
+#define iKEYWORD08NUMARG 1
+#define iMINSUMTHRESH_PHOT 0 /* minimum value */
+#define iMAXSUMTHRESH_PHOT 65536 /* maximum value */
+
+#define cKEYWORD09              "i2out_thresh_phot"
+/* keyword no. 9 */
+#define cKEYWORD09ARG             "%d"
+#define iKEYWORD09NUMARG 1
+#define iMIN2OUTTHRESH_PHOT 0 /* minimum value */
+#define iMAX2OUTTHRESH_PHOT 65536 /* maximum value */
+
+#define cKEYWORD10               "usecalfile"
+/* keyword no. 10 */
+#define cKEYWORD10ARG             "%s %d %d"
+#define iKEYWORD10NUMARG 3 /* first arg: search direction, 
+			    * second arg: end of search or
+			    * search depth in case of 
+			    * pingpong method */
+#define iKEYWORD10ARG1NUMVAL 5
+#define cKEYWORD10ARG1VALS "match", "before", "after", "pingpong", "none"
+/* minimum and maximum value of the second argument are 
+ * identical with iMINRUNNUM and iMAXRUNNUM */
+
+#define cKEYWORD11               "usepedfile"
+/* keyword no. 11 */
+#define cKEYWORD11ARG             "%s %d %d"
+#define iKEYWORD11NUMARG 3 /* first arg: search direction,
+			    * second arg: end of search or
+			    * search depth in case of 
+			    * pingpong method */
+#define iKEYWORD11ARG1NUMVAL 5
+#define cKEYWORD11ARG1VALS "match", "before", "after", "pingpong", "none"
+/* minimum and maximum value of the second argument are 
+ * identical with iMINRUNNUM and iMAXRUNNUM */
+
+#define cKEYWORD12                "inummuonpixels"
+/* keyword no. 12 */
+#define cKEYWORD12ARG             "%d"
+#define iKEYWORD12NUMARG 1
+#define iMINNUMMUONPIX 0 /* minimum value */
+/* #define iMAXNUMMUONPIX ..  maximum value defined in structures.h */
+
+#define cKEYWORD13                "inumcointdcs"
+/* keyword no. 13 */
+#define cKEYWORD13ARG             "%d"
+#define iKEYWORD13NUMARG 1
+#define iMINNUMCOINTDCS 0 /* minimum value */
+/* #define iMAXNUMCOINTDCS ..  maximum value defined in structures.h */
+
+#define cKEYWORD14                "fphotoel_per_adccnt"
+/* keyword no. 14 */
+#define cKEYWORD14ARG             "%s %f"
+#define iKEYWORD14NUMARG 2
+#define fMINPHOTOEL_PER_ADCCNT 0.1 /* minimum value for the 
+				    * second argument */
+#define fMAXPHOTOEL_PER_ADCCNT 999.0 /* maximum value for the 
+				      * second argument */
+/* as first argument either a single integer number or a 
+ * range may be given (format: e.g. 10-20) minimum and 
+ * maximum value of the first argument are identical with 
+ * iMINPIXNUM and the number of pixels in the camera */
+
+#define cKEYWORD15               "bmuon_suppression"       
+/* keyword no. 15 */
+#define cKEYWORD15ARG             "%s"
+#define iKEYWORD15NUMARG 1 /* this keyword is a switch */
+#define iKEYWORD15ARG1NUMVAL 2
+#define cKEYWORD15ARG1VALS "off", "on" /* the order of this 
+					* enumeration is essential 
+					* to make off equivalent 
+					* to FALSE */
+
+#define cKEYWORD16                "ftolerated_pointerror_deg"
+/* keyword no. 16 */
+#define cKEYWORD16ARG             "%f"
+#define iKEYWORD16NUMARG 1
+#define fMINTOLERATED_POINTERROR_DEG 0. /* minimum value for 
+					 * the maximum tolerated 
+					 * pointing error in the 
+					 * position check in 
+					 * iprocessdata */
+#define fMAXTOLERATED_POINTERROR_DEG 180. /* maximum value */
+
+#define cKEYWORD17                "iratecalc_numevents_odd"
+/* keyword no. 17 */
+#define cKEYWORD17ARG             "%d"
+#define iKEYWORD17NUMARG 1
+#define iMINRATECALC_NUMEVENTS_ODD 3 /* minimum value for the 
+				      * number of events used 
+				      * in the event rate 
+				      * calculation */
+#define iMAXRATECALC_NUMEVENTS_ODD 999 /* maximum value */
+
+#define cKEYWORD18                "fdegrees_per_step1"
+/* keyword no. 18 */
+#define cKEYWORD18ARG             "%f"
+#define iKEYWORD18NUMARG 1
+#define fMINDEGREES_PER_STEP 0.0001 /* minimum value for the 
+				     * resolution of shaft encoder 1 */
+#define fMAXDEGREES_PER_STEP 0.1 /* maximum value */
+
+#define cKEYWORD19                "fdegrees_per_step2"
+/* keyword no. 19 */
+#define cKEYWORD19ARG             "%f"
+#define iKEYWORD19NUMARG 1
+/* minimum and maximum values as for keyword 18 */
+
+#define cKEYWORD20               "se1_is"
+/* keyword no. 20 */
+#define cKEYWORD20ARG             "%s"
+#define iKEYWORD20NUMARG 1 
+#define iKEYWORD20ARG1NUMVAL 4
+#define cKEYWORD20ARG1VALS "RA", "DEC", "ALT", "AZ"
+
+#define cKEYWORD21                "flongitude_deg"
+/* keyword no. 21 */
+#define cKEYWORD21ARG             "%f"
+#define iKEYWORD21NUMARG 1
+#define fMIN_LONG_DEG 0. /* minimum value for the longitude 
+			  * of the telescope position */
+#define fMAX_LONG_DEG 359.99999 /* maximum value (the 
+				 * longitude is counted 
+				 * positive towards West */
+
+#define cKEYWORD22                "flatitude_deg"
+/* keyword no. 22 */
+#define cKEYWORD22ARG             "%f"
+#define iKEYWORD22NUMARG 1
+#define fMIN_LAT_DEG  -90.0 /* minimum value for the latitude 
+			     * of the telescope position */
+#define fMAX_LAT_DEG +90.0 /* maximum value */
+
+#define cKEYWORD23                "irubminusutc_usecs"
+/* keyword no. 23 */
+#define cKEYWORD23ARG             "%d"
+#define iKEYWORD23NUMARG 1
+#define iMINRUBMINUSUTC_USECS -60E6 /* minimum value for the 
+				     * time difference between 
+				     * rubidium clock and UTC*/
+#define iMAXRUBMINUSUTC_USECS 60e6 /* maximum value */
+
+#define cKEYWORD24                "iaz_rev_track_corr"
+/* keyword no. 24 */
+#define cKEYWORD24ARG             "%d"
+#define iKEYWORD24NUMARG 1
+#define iMINAZ_REV_TRACK_CORR -1000 /* minimum value for the 
+				     * correction of the az 
+				     * shaft encoder values 
+				     * in reverse tracking mode
+				     * see Calc_corr in TIJARAFE */
+#define iMAXAZ_REV_TRACK_CORR 1000 /* maximum value */
+
+#define cKEYWORD25                "ialt_rev_track_corr"
+/* keyword no. 25 */
+#define cKEYWORD25ARG             "%d"
+#define iKEYWORD25NUMARG 1
+#define iMINALT_REV_TRACK_CORR -1000 /* minimum value for the 
+				      * correction of the alt 
+				      * shaft encoder values 
+				      * in reverse tracking mode
+				      * see Calc_corr in TIJARAFE */
+#define iMAXALT_REV_TRACK_CORR 1000 /* maximum value */
+
+#define cKEYWORD26                "fbendingcorr"
+/* keyword no. 26 */
+#define cKEYWORD26ARG             "%f"
+#define iKEYWORD26NUMARG 1
+#define fMINBENDINGCORR  -0.5 /* minimum value for the bending 
+			       * correction factor for the alt 
+			       * shaft encoder values
+			       * see Calc_corr in TIJARAFE */
+#define fMAXBENDINGCORR 0.5 /* maximum value */
+
+#define cKEYWORD27                "fextinction"
+/* keyword no. 27 */
+#define cKEYWORD27ARG             "%f"
+#define iKEYWORD27NUMARG 1
+#define fMINEXTINCTION  0. /* minimum value for the 
+			    * atmospheric extinction */
+#define fMAXEXTINCTION  1. /* maximum value */
+
+#define cKEYWORD28                "dsource_ra_hours"
+/* keyword no. 28 */
+#define cKEYWORD28ARG             "%lf"
+#define iKEYWORD28NUMARG 1
+#define fMINRA_HOURS 0.0   /* minimum value for the right 
+			    * ascension of the assumed source */
+#define fMAXRA_HOURS 23.99999999 /* maximum value */
+
+#define cKEYWORD29                "dsource_dec_deg"
+/* keyword no. 29 */
+#define cKEYWORD29ARG             "%lf"
+#define iKEYWORD29NUMARG 1
+#define fMINDEC_DEG -90.0 /* minimum value for the 
+			   * declination of the assumed source */
+#define fMAXDEC_DEG 90.0        /* maximum value */
+
+#define cKEYWORD30                "imuoncut_thresh_adccnt"
+/* keyword no. 30 */
+#define cKEYWORD30ARG             "%s %d"
+#define iKEYWORD30NUMARG 2
+#define iMINMUONCUT_THRESH_ADCCNT 0 /* minimum value for the 
+				     * second argument */
+#define iMAXMUONCUT_THRESH_ADCCNT 65536 /* maximum value for 
+					 * the second argument */
+/* as first argument either a single integer number or a 
+ * range may be given (format: e.g. 3-5) minimum and maximum 
+ * value of the first argument are the number of pixels in 
+ * the camera +1 and the number of pixels in the camera + 
+ * the number of muonpixels in the camera */
+
+#define cKEYWORD31                "fxpointcorr_deg"
+/* keyword no. 31 */
+#define cKEYWORD31ARG             "%f"
+#define iKEYWORD31NUMARG 1
+#define fMINRAPOINTERROR_DEG -10. /* minimum value for the 
+				   * pointing error correction 
+				   * along camera x axis as known 
+				   * from e.g. a pointrun */
+#define fMAXRAPOINTERROR_DEG +10. /* maximum value */
+
+#define cKEYWORD32                "fypointcorr_deg"
+/* keyword no. 32 */
+#define cKEYWORD32ARG             "%f"
+#define iKEYWORD32NUMARG 1
+#define fMINDECPOINTERROR_DEG -10. /* minimum value for the 
+				    * pointing error correction 
+				    * along camera y axis as known 
+				    * from e.g. a pointrun */
+#define fMAXDECPOINTERROR_DEG +10. /* maximum value */
+
+#define cKEYWORD33                "fcamera_align_angle_deg"
+/* keyword no. 33 */
+#define cKEYWORD33ARG             "%f"
+#define iKEYWORD33NUMARG 1
+#define fMINCAMALIGNANGLE_DEG -180. /* minimum value for the 
+				     * angle between the camera 
+				     * y-axis and the meridian 
+				     * when a culminating object
+				     * is observed (defined 
+				     * counter-clockwise looking 
+				     * at the sky) */
+#define fMAXCAMALIGNANGLE_DEG 180. /* maximum value */
+
+#define cKEYWORD34               "bhistograms"
+/* keyword no. 34 */
+#define cKEYWORD34ARG             "%s"
+#define iKEYWORD34NUMARG 1 /* this keyword is a threefold switch */
+#define iKEYWORD34ARG1NUMVAL 3
+#define cKEYWORD34ARG1VALS "off", "on", "new" /* the order of this 
+					       * enumeration is 
+					       * essential to make 
+					       * off equivalent to FALSE */
+
+#define cKEYWORD35                "iadc_histopars"
+/* keyword no. 35 */
+#define cKEYWORD35ARG             "%d %f %f"
+#define iKEYWORD35NUMARG 3
+#define iMINBINS 3
+#define iMAXBINS 300
+#define fMIN_ADCHIST_LOLIM -50.5
+#define fMAX_ADCHIST_LOLIM 1000.
+#define fMIN_ADCHIST_HILIM 0.5
+#define fMAX_ADCHIST_HILIM 65535.5
+
+#define cKEYWORD36                "iphe_histopars"
+/* keyword no. 36 */
+#define cKEYWORD36ARG             "%d %f %f"
+#define iKEYWORD36NUMARG 3
+#define fMIN_PHEHIST_LOLIM -10000.
+#define fMAX_PHEHIST_LOLIM 1000.
+#define fMIN_PHEHIST_HILIM -1000.
+#define fMAX_PHEHIST_HILIM 10000.
+
+#define cKEYWORD37                "idontusepix_in_trig"
+/* keyword no. 37 */
+#define cKEYWORD37ARG             "%s"
+#define iKEYWORD37NUMARG 1    /* in the parameters file 
+			       * counting of the pixels starts at 1
+                              * minimum value is iMINPIXNUM 
+                              * maximum value of this parameter 
+			      * is iMAXNUMPIX the pixel can only be 
+			      * taken back into trigger by resetting all
+                              * parameters */
+
+#define cKEYWORD38                "fpadlevel_phot_pix"
+/* keyword no. 38 */
+#define cKEYWORD38ARG             "%s %f"
+#define iKEYWORD38NUMARG 2
+#define fMINPADLEVEL_PHOT  0. /* minimum value for the software 
+			       * padding level for each pixel */
+#define fMAXPADLEVEL_PHOT  100. /* maximum value */
+
+#define cKEYWORD39                "frandomseeds"
+/* keyword no. 39 */
+#define cKEYWORD39ARG             "%f %f "
+#define iKEYWORD39NUMARG 2
+#define fMINSEED 1. /* minimum value for the maximum tolerated 
+		     * pointing error in the position check in 
+		     * iprocessmcdata */
+#define fMAXSEED 1.e10 /* maximum value */
+
+#define cKEYWORD40                "iswap_pixels"
+/* keyword no. 40 */
+#define cKEYWORD40ARG             "%d %d " /* the number of the 
+					    * two pixels for which 
+					    * the numbering should 
+					    * be swapped (in 
+					    * ireadrunfile, 
+					    * -pedfile, -calfile) */
+#define iKEYWORD40NUMARG 2
+/* the minimum value for this argument is iMINPIXNUM, the maximum 
+ * is iMAXNUMPIX */
+
+#define cKEYWORD41                "%"
+/* keyword no. 41 */
+#define cKEYWORD41ARG             "\n" /* using this keyword, 
+					* comments can be added 
+					* to the parameter file */
+#define iKEYWORD41NUMARG 0
+
+#define cKEYWORD42           "errortolerance"
+/* keyword no. 42 */
+#define cKEYWORD42ARG        "%s"
+#define iKEYWORD42NUMARG 1
+#define iKEYWORD42ARG1NUMVAL 3
+#define cKEYWORD42ARG1VALS "cautious", "goodphysics", "tank"
+/* cautious: exits on any reason 
+ * normal: the usual way: exit only, when the physics would 
+ *         be affected
+ * tank: exits only when all runs are processed. Otherwise
+ *       it goes through everything, even through the pain of 
+ *       a coredump. */
+
+#define cKEYWORD43           "montecarlo"
+/* keyword no. 43 */
+#define cKEYWORD43ARG        "%s"
+#define iKEYWORD43NUMARG 1
+#define iKEYWORD43ARG1NUMVAL 3
+#define cKEYWORD43ARG1VALS "all", "flag", "noflag"
+/* Whenever this one is specified, there shell apply certain 
+ * limitations: No pedestal and calibration files shall be read in. 
+ * Maybe more.... 
+ * Arguments:
+ * all: all events which survive the filter are written to the 
+ *      events NTuple. 
+ * flag: When Dorota's triggerflag is set to 1 for a particular
+ *       event, it shall be written to the output. All others shall
+ *       just be disregarded.
+ * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+ *         be treated further. */
+
+#define cKEYWORD44           "mcfile"
+/* keyword no. 44 */
+#define cKEYWORD44ARG        "%s"
+#define iKEYWORD44NUMARG 1
+
+#define cKEYWORD45           "fmean_nsb_pe_pix"
+/* keyword no. 45 */
+#define cKEYWORD45ARG             "%s %f"
+#define iKEYWORD45NUMARG 2
+#define fMIN_NSB_PE_PIX  0.
+#define fMAX_NSB_PE_PIX  2000000000. /* some ridiculous number...*/
+
+#define cKEYWORD46           "fitmypedrms"
+/* keyword no. 46 */
+/* Setting this keyword in the parameterfile shall trigger the 
+ * pedestal MEAN and SIGMA=sqrt(MEAN) to be fitted from pickup
+ * corrected pedestal data and not calculated from the pickup 
+ * corrected ADC values, as it was done up to ~November 2000. */
+
+/* Macintosh variable formats */
+#define lMACSIZEOFSHORT  2L
+#define lMACSIZEOFLONG   4L
+#define lMACSIZEOFDOUBLE 8L
+
+/* Time Offsets */
+#define iMACTIMEOFFSET 2082844800 /* offset to be subtracted 
+				   * from the Macintosh time 
+				   * read from the various data 
+				   * files to get DECSTATION/ALPHA 
+				   * time */
+
+/* TIJARAFE filename conventions */
+
+#define cCALFILENAME_TEMPLATE "Te%1sCal_*%s_%2s_*"
+#define cLOGFILENAME_TEMPLATE "Te%1sLog_*%s_%2s_*"
+#define cPEDFILENAME_TEMPLATE "Te%1sPed_*%s_%2s_???????_*"
+#define cRUNFILENAME_TEMPLATE "Te%1sRun_*%s_%2s_*"
+#define cPOIFILENAME_TEMPLATE "Te%1sPoi_*%s_%2s_*"
+#define cCTIDPOSITION_TIJ "2" /* element of the filename character 
+			   * array which contains the telescope id
+			   * a length of 1 character is assumed */
+#define cRUNNUMPOSITION_TIJ "7" /* element of the filename character 
+			     * array which contains the run number */
+#define cRUNNUMLENGTH_TIJ "4" /* number of characters in the run number */
+#define cRUNTYPEPOSITION_TIJ "12" /* element of the filename character 
+			       * array which contains the ON or OF 
+			       * string a length of 2 characters is 
+			       * assumed */
+#define iTIJ_DUMMYLENGTH 20
+
+/* ROBERTO filename conventions */
+
+#define cCTIDPOSITION_ROB "2" /* element of the filename character 
+			       * array which contains the telescope id
+			       * a length of 1 character is assumed */
+#define cRUNNUMPOSITION_ROB "7" /* element of the filename character 
+				 * array which contains the run number */
+#define cRUNNUMLENGTH_ROB "5" /* number of characters in the run number */
+#define cRUNTYPEPOSITION_ROB "13" /* element of the filename character 
+				   * array which contains the ON or OF 
+				   * string a length of 2 characters is 
+				   * assumed */
+#define iROB_DUMMYLENGTH 26
+
+/* Razmick's Method's F Factor for the PMTs: */
+/* #define FIXED_F_VALUE 1.09 */
+/* #define FIXED_F_VALUE 1.15 */
+#define FIXED_F_VALUE 1.075
+
+/* Monte Carlo defines, that _MUST_ be exactly the same as in
+ * zorp's defines.h. */
+#define iMAXNUMCTS 1
+#define iNUMENERGYBINS 19
+#define iNUMIMPACTBINS 60
+#define iNUMZENANGLEBINS 24
+#define iMAXNUMNFLSHIFTS 1
+#define fMAXIMPACTPAR 600.
+
+/* exit codes */
+
+#define iERRORINPROCESSDATA 100
+#define iERRORINMAKEFILENAME 101
+#define iERRORCT2TRACKMODE 102
+#define iERRORGAINZERO 103
+
+/*************** GLOBAL VARIABLES *********************************/
+
+#define FILEHANDLING_VERSION 4.2
+
+#endif
+
+#ifdef _defines_h_
+
+extern char G_cfilehandlingident[];
+extern char G_filehandhfilehident[];
+
+extern char G_cfatalerrortext[22];
+extern Boolean G_bhbook_is_init;
+extern float G_fpreprocversion;
+extern char G_preprocident[];
+extern char G_preprocstrucident[];
+extern char G_preprocfilehident[];
+
+extern char *calnt_var_list[22];
+extern char cprojectname[40];
+
+extern HBOOK_FILE calnt;
+extern HBOOK_FILE calhb;
+extern int G_oferfloweventID;
+extern int G_oferfloweventoffset;
+extern float pixcoords[271][2]; /* For the 2-dim camera pictures of the 
+				 * overflow events */
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfileio/structures.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfileio/structures.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfileio/structures.h	(revision 1638)
@@ -0,0 +1,882 @@
+/******************************************************************/
+/*              GGG   AAA   M   M M   M  AAA   SSS                */
+/*             G   G A   A  MM MM MM MM A   A S   S               */
+/*             G     A   A  M M M M M M A   A  SS                 */
+/*             G  GG AAAAA  M   M M   M AAAAA   SS                */
+/*             G   G A   A  M   M M   M A   A S   S               */
+/*              GGG  A   A  M   M M   M A   A  SSS                */
+/*       Gamma Astronomer's Munich Madrid Analysis Suite          */
+/*   An Atmospheric Cherenkov Telescope Data Analysis Software    */
+/*  MPI f"ur Physik, M"unchen & Universidad Complutense, Madrid   */
+/******************************************************************/
+
+/******************************************************************/
+/* This File belongs to the programs                              */
+/*                                                                */
+/*  P R E P R O C E S S O R   and   I M A G E R                   */
+/*                                                                */
+/* Purpose: provide the structure definitions common to both      */
+/*          programs, especially the output structures of the     */
+/*          preprocessor                                          */ 
+/*                                                                */
+/******************************************************************/
+
+/******************************************************************/
+/* @(#) File name structures.h
+   @(#) latest SID 0.5  
+   @(#) Date of latest delta 26/6/00  
+   Author: D. Petry 
+   changed by M. Kestel */
+/******************************************************************/
+
+#ifndef _structures_h_
+#define _structures_h_ "__structures_h__"
+
+#define STRUCT_VERSION 0.5
+
+#define iHEADERTITLELENGTH 60
+/* length of the string written at the beginning of the */
+/* output for each runfile */
+#define cTITLE_TEMPLATE "PREPROC V%f/S%f CT %d RUN %d %d PROCMJD %d\n"
+
+#define cEND_EVENTS_TEMPLATE "EVENTS AFTER FILTER = %d\n"
+
+#define iMAXNUMPIX 127
+/* maximum value for the number of camera pixels (excl. muon shield) */
+#define iMAXNUMMUONPIX 5 
+/* maximum value for the number of pixels in the muon shield */
+#define iMAXNUMCOINTDCS 5
+/* maximum value for the number of coincidence tdcs */
+
+
+#define iBADMACTIME_BIT 1
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the mactime measurement didn't work */
+#define iBADRUBTIME_BIT 2 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the Rubidium time measurement didn't work */
+#define iBADPOINTING_BIT 4 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the shaft encoder values were inconsistent with 
+ * time OR source coordinates */
+#define iMUON_BIT 8
+ /* snot_ok_flags is ORed with this number to set the bit which 
+  * indicates that the event didn't pass the muon filter 
+  * (for test puposes) */
+
+#define i2OUTFAIL_BIT 16 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the event didn't pass the "two out of all" 
+ * software trigger */
+#define iSUMFAIL_BIT 32 
+/* snot_ok_flags is ORed with this number to set the bit which
+ * indicates that the event didn't pass the "sum of all
+ * photoelectrons" filter */
+
+#define iPARTICLETYPE_FACTOR 1024 
+/* for MC data: the particle type multiplied with this number 
+ * is ORed with snot_ok_flags */
+
+enum onoroff {NEITHER_ON_NOR_OFF, OFF_SOURCE, ON_SOURCE};
+enum trackmodes {NORMAL, REVERSE, DUNNO};
+enum axes {RA, DEC, ALT, AZ};
+enum eERRORTOLERANCE {CAUTIOUS=0, GOODPHYSICS, TANK};
+enum eMCTRIGGERFLAG {ALL=0, FLAG, NOFLAG};
+ 
+struct outputpars {
+  /* preprocessing parameters that are passed to imager.
+   * Note: Not all parameters from the parameter file are passed to
+   * imager, only those that are repeated in this struct outputpars 
+   * here !! That's why these two structs must be the same for both
+   * preproc and imager. */
+
+  int     itelescope;
+  /* number of the CT which took the data (from parameters file */
+  /* crosschecked with run file name) */
+  float   flongitude_deg;
+  /* longitude (counted positive towards West) of CT position */
+  float   flatitude_deg;
+  /* latitude (counted positive towards North) of CT position */
+  int     irunnum;
+  /* run number (from parameters file cross checked with run */
+  /* file name) */
+  enum onoroff eruntype;
+#ifdef LINUX
+  int dummy;
+#endif
+  /* indicates if the */
+  /* run is on- or off source (from runfile cross checked with */
+  /* file name) */
+  double  dsourcera_hours;
+  /* right ascension of observed source in hours */
+  double  dsourcedec_deg; 
+  /* declination of observed source in degrees */
+  int     inumpixels; 
+  /* number of pixels in the camera (from parameters file cross */
+  /* checked with run file, calibration file and pedestal file) */
+  int     inummuonpixels;
+  /* number of pixels in the muon shield (from parameters file */
+  /* cross checked with run file, calibration file and pedestal */
+  /* file) */
+  int     inumcointdcs;
+  /* number of coincidence tdcs recorded in the runfile (from */
+  /* parameters file cross checked */
+  /* with run file) */
+  float   fpixdiameter_deg;
+  /* smallest pixel diameter (degrees) (from parameters file) */ 
+  enum axes ese1_is;
+  /* name of the axis to which shaft encoder 1 is attached */
+  /* (implies the type of mount) */
+  int     isezeropos[2];
+  /* zero position of shaftencoders 1 and 2 (from parameters file) */
+  int     iaz_rev_track_corr;
+  /* correction for the azimuth shaft encoder (ALT/AZ mount */
+  /* only) in reverse tracking mode */
+  int     ialt_rev_track_corr;
+  /* correction for the altitude shaft encoder (ALT/AZ mount */
+  /* only) in reverse tracking mode */
+  float   fbendingcorr;
+  /* bending correction factor (ALT/AZ mount only) */
+  float   fextinction;
+  /* atmospheric extinction (typically taken from the Carlsberg */
+  /* Meridian Circle data) */
+  Boolean bdontusepix[iMAXNUMPIX];
+  /* bdontusepix is set true if the pixel should due to whatever
+   * reason not be used in image analysis, otherwise it is true; 
+   * 
+   * bdontusepix is set by the user inside preproc.par and is 
+   * untouched by preproc (version >= 0.4). */
+  Boolean bexcludepix[iMAXNUMPIX];
+  /* bexcludepix[] is set TRUE (== exclude from pedestal, Laser 
+   * calibration and the further analysis) when the Mean value
+   * of a pixel inside a pedestal Run is larger than 50 or ( || )
+   * if the pedestal RMS value of this pixel is larger than 5.0
+   * This is reflected in the (new for versions >= 0.4) 
+   * variable "pixonoff" in the ntuple written by preproc:
+   * preproc.nt.hbook
+   *
+   * When the pixel is excluded by the user it will get a -2 otherwise 
+   * pixonoff = 0.
+   * Additive to this a -1 is added when preproc excludes the pixel
+   * for a given Run. So the actual value tells you whether you caught 
+   * it already by hand or not.
+   *
+   * A plot of pixonoff may also be handy to tell you the status of your
+   * ADC equipment. */
+  float   fphotoel_per_adccnt[iMAXNUMPIX];
+  /* conversion factors for the pixel signals */
+  int     irubminusutc_usecs;
+  /* difference between rubidium clock and UTC in microseconds */
+  int     isum_thresh_phot;
+  /* threshold for the total sum of photoelectrons filter */
+  /* from the parameters file */
+  int     i2out_thresh_phot;
+  /* threshold for the two-pixels-out-of-all software */
+  /* trigger from parameters file */
+  int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; 
+  /* thresholds for the muon cut */
+  Boolean bmuon_suppression;
+  /* "Dolby" noise reduction flag */
+  float   ftolerated_pointerror_deg;
+  /* maximum tolerated pointing error in the position 
+   * check in iprocessdata */
+  float   fxpointcorr_deg;
+  /* pointing correction (to be added along the camera
+   * x axis) e.g. from point run */ 
+  float   fypointcorr_deg;  
+  /* pointing correction (to be added along the camera 
+   * y axis) e.g. from point run */ 
+  float   fcamera_align_angle_deg;
+  /* the angle between the camera y-axis and the meridian 
+   * when a culminating object is observed (defined 
+   * counter-clockwise looking at the sky) */ 
+  int     iratecalc_numevents_odd;
+  /* number of events used in the rate calculation (must be odd) */
+  int     inumpedfile;
+  /* number of the pedestal file used */
+  int     inumpedrun;
+  /* number of the pedestal run used in the file (starting at 0) */
+  int     inumcalfile;
+  /* number of the calibration file used */
+  int     inumlaserrun;
+  /* number of the laserrun used in the file (starting at 0) */ 
+  int     inumtellogfile;
+  /* number of the TelLog file to be used */
+  int     inumtellogrun;
+  /* number of the tellog entry (Runnumber) used from the log file */
+  int imcparticle; /* CORSIKA-coded Monte Carlo particle type.
+		    * This is given once per run. */
+
+  /* preprocessing results: */
+
+  int     istart_mjdate_day;
+  /* MJD of run start (first event) */
+  int     iend_mjdate_day;
+  /* MJD of run end (last event) */
+  int     irunduration_secs;
+  /* difference between start and end time (secs) */
+  int     iproc_mjdate; 
+  /* MJD of data processing (i.e. creation of this file) */ 
+  enum trackmodes etrackmode;
+  /* tracking mode (for ALT/AZ CTs) */
+  int     iproc_evts;
+#ifdef LINUX
+  int dummy2;
+#endif
+  /* number of events processed */
+  double  dactual_sourcera_hours;
+  /* for off runs: the false source (that should have been) observed */
+  float   frms_pedsig_phot[iMAXNUMPIX];
+  /* standard deviation of the calibrated signals from the pedestal run */ 
+  float   fpedrms_mean; /* Used to communicate the mean over all pixels 
+			 * pedestal RMS into the Runs NTuple, as it might 
+			 * be used for e.g. quality cuts. */
+  float   fcurrent_mean; /* The average current over the active pixels
+			  * for this run. This is done separately for
+			  * ON and OF runs. */
+
+  enum eERRORTOLERANCE eerrortolerance;
+  /* 0 == "cautious", exits on any reason (but tells in 
+   * the .err file,
+   * 1 == "goodphysics", exits when physics could be affected
+   * by the error,
+   * 2 == "tank", never exits except on coredumps and when
+   * all files have been processed. Do not use such files for
+   * physics analysis! 
+   *
+   * NOTE: the capital letter words are the enums, the small letter
+   * words must be used inside the parameter file. */
+  enum eMCTRIGGERFLAG emctriggerflag;
+  /* all: all events which survive the filter are written to the 
+   *      events NTuple. 
+   * flag: When Dorota's triggerflag is set to 1 for a particular
+   *       event, it shall be written to the output. All others shall
+   *       just be disregarded. (Default)
+   * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+   *         be treated further. */
+  Boolean bmontecarlo;
+  /* if TRUE we have a monte carlo dataset before us, if FALSE 
+   * (default value) it is just normal data. */
+};
+
+struct filterresults {
+  int     imax_alt_arcs;
+  /* maximum altitude reached during the run */
+  int     iaz_at_max_alt_arcs;
+  /* azimuth at the time the max. alt. was reached */
+  int     itimeaverage_alt_arcs;
+  /* altitude averaged over the runtime */
+  int     icoord_inconsist_evts;
+  /* number of events with time-coordinate */
+  /* inconsistency in this run */
+  int     ifilter_passed_evts;
+  /* number of events which passed the filter */
+  int     imuon_fail_evts;
+  /* number of events rejected as muons (other filters passed) */
+  int     i2out_fail_evts;
+  /* number of events which failed in the two out of all */
+  /* pixels software trigger */
+  int     imuon_and_2out_fail_evts;
+  /* number of events failing in both muon and */
+  /* 2out filter */  
+  int     isum_fail_evts;
+  /* number of events which failed the sum-of-all-calibrated */
+  /* ADC counts filter */
+  int     isum_and_muon_fail_evts;
+  /* number of events which failed in both the sum and */
+  /* the muon filter */
+  int     isum_and_2out_fail_evts;
+  /* number of events which failed in both the sum and */
+  /* the 2out filter */
+  int     iall_filters_fail_evts;
+  /* number of events which failed in all filters */ 
+  float   favg_event_rate_hz;
+  /* average rate before filtering */
+  float   fstddev_event_rate_hz;
+  /* standard deviation of the rate before filtering */
+
+};
+
+struct eventrecord {
+  int   isecs_since_midday;
+  /* seconds passed since midday before sunset (JD of run start) */
+  int   isecfrac_200ns;
+  /* fractional part of isecs_since_midday */
+  short snot_ok_flags;
+  /* the bits in these two bytes are flags for additional */
+  /* information on the event: Everything OK =: all Bits = 0 */
+  int   ialt_arcs;
+  /* altitude (arcseconds) */
+  int   iaz_arcs;
+  /* azimuth (arcseconds) */
+  int   ipreproc_alt_arcs;
+  /* "should be" alt according to preproc (arcseconds) */
+  int   ipreproc_az_arcs;
+  /* "should be" az according to preproc (arcseconds) */
+  int   ifieldrot_arcs;
+  /* for ALT-AZ mount telescopes: rotation angle of the field of 
+   * view; this angle is defined mathematically positive looking 
+   * towards the sky as the angle between the hour circle through 
+   * the object being tracked and the line through pixel 1 and 2 */
+  unsigned short srate_millihz;
+  /* event rate in milli Hertz before filtering calculated by 
+   * iratecalc_numevents_odd/(time[i+iratecalc_numevents_odd/2] - 
+   * time[i-iratecalc_numevents_odd/2]) 
+   * For the first and the last iratecalc_numevents_odd/2 
+   * events the rate is assumed to be constant */
+  float fhourangle; /* This is the angle between the observation of this
+		     * event and the culmination point. It is going to 
+		     * be written into the events NTuple. */
+  float fmcenergy_tev; /* Simulated Energy.... dropping through to
+			* the Events NTuple. */
+  float fmcsize_phel; /* Simulated SIZE.... dropping through to
+			* the Events NTuple. */
+  int imcimpact_m;
+  /* MC data contain the impact parameter, which is given here in 
+   * meters. */
+  int imcparticle;
+  /* MC data know which particle they are.... all in CORSIKA standard. */
+  int imctriggerflag;
+  /* MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
+  short spixsig_10thphot[iMAXNUMPIX];
+  /* number of photoelectrons measured in each pixel only the 
+   * actual number of pixels (outputpars.inumpixels) is written out */
+};
+
+struct camera { /* camera parameters for imaging */
+  int inumpixels;
+  int inumrings;
+  double dpixdiameter_deg;
+  double dxc[iMAXNUMPIX]; 
+/* Pixel coordinates in camera coordinate system (x points from
+ * pixel 1 to 2). */
+  double dyc[iMAXNUMPIX];
+  /* The numbering of the pixels in these arrays starts at 0! */
+  double dxpointcorr_deg; 
+  /* correction of the pixel coordinates; to be added to dxc[] 
+   * to get correct value */
+  double dypointcorr_deg; 
+  /* correction of the pixel coordinates; to be added to dxc[] 
+   * to get correct value */
+};
+
+
+/* two structures for better file handling */
+struct inputfile {
+  char cname[iMAXFILENAMELENGTH];
+  /* filename (including path) */
+  FILE *pointer;
+  /* filepointer */
+  char ccannotopentext[161];
+  /* Error text printed when file cannot be opened */
+  int  icannotopencode; 
+  /* Error code for the exit statement when file could not be opened */
+  int  iearlyeofcode;
+  /* Error code for the exit statement for unexpected EOF */
+  int  ierroratclosecode;
+  /* Error code for the exit statement for error while trying to close */
+};
+
+struct outputfile {
+  char cname[iMAXFILENAMELENGTH]; /* filename (including path) */
+  FILE *pointer;  /* filepointer */
+  char ccannotopentext[161]; 
+  /* Error text printed when file cannot be opened */
+  int  icannotopencode; 
+  /* Error code for the exit statement when file could not be opened */
+  int  icannotwritecode; 
+  /* Error code for the exit statement for failed fprintf */
+  int  ierroratclosecode; 
+  /* Error code for the exit statement for error while trying to close */
+};
+
+struct P2ALLHISTOS {
+
+  HISTO *p2adchist;
+  HISTO *p2pedonhist;
+  HISTO *p2pedofhist;
+  HISTO *p2pedonmeanhist;
+  HISTO *p2pedofmeanhist;
+  HISTO *p2pedonjitthist;
+  HISTO *p2pedofjitthist;
+  HISTO *p2calonhist;
+  HISTO *p2calofhist;
+  HISTO *p2calonmeanhist;
+  HISTO *p2calofmeanhist;
+  HISTO *p2calonjitthist;
+  HISTO *p2calofjitthist;
+  HISTO *p2phehist;
+  HISTO *p2zenonhist;
+  HISTO *p2zenofhist;
+  HISTO *p2corrpedhist;
+  HISTO *p2pedfwhmhist;
+};
+
+struct CALNT_DAT { 
+  /* the structure for an entry in the calibration ntuple */
+  float CTrunnum;
+  float runtype;
+  float ALT_deg; /* the ALT taken from the first event of the run */
+  float extinct; /* extinction */
+  float RtiSecBF; /* runtime in seconds before filter */
+  float pixnum;  /* number of the pixel for which the following 
+		  * data is given */
+  float pixonoff; /* Quantity telling whether this pixel was switched
+		   * off by the user (-= 2.) or by preproc (-= 1.).
+		   * If ON, its value = 0. */
+  float ped_adcc; /* the standard deviation of the pedestal as 
+		   * calculated by TIJARAFE */
+  float pedrmsac; /* the standard deviation of the pedestal in
+		   * ADC counts as calculated by TIJARAFE */
+  float pedrmsPE; /* the calibrated ped RMS in photoelectrons 
+		   * which is also given to the imager */
+  float las_adcc; /* the mean signal for this pixel from the 
+		   * laser run */
+  float lasrmsac; /* RMS of the laser events after cleaning from cosmics */
+  float conv_fac; /* conversion factor = <Q>/Var(Q) * F^2 */
+  float F;        /* The F from the line before */
+  float rel_gain; /* the relative gain of the pixel */
+  float numtrig;  /* number of events in which the pixel was 
+		   * above trigger threshold */
+  float num3sig;  /* number of events in which the pixel was 
+		   * 3 sigma above its pedestal */ 
+  float HV1;      /* Adjustment of HV1 for this run, if available. */
+  float HV2;      /* Adjustment of HV2 for this run, if available. */
+  float ThrCurr;
+  float AvgCurr;  /* the sum of all currents during this run (with the
+		   * particular runtype in question) from the TelLog 
+		   * file. The currents are averaged over the 2-minute
+		   * intervals but summed over all pixels with currents
+		   * higher than the threshold current value. This sum
+		   * is then stored in the runs ntuple. 
+		   * Same for the scaler values --> */
+  float AvgScal;
+};
+
+struct inputpars {
+  Boolean bkeywordgiven[iNUMKEYWORDS+1]; /* if a valid keyword 
+					  * is given in the 
+					  * parameters file 
+					  * the corresponding
+					  * element in this 
+					  * array is set to true */ 
+  int     itelescope;       /* number of the CT which took the data */
+  float   flongitude_deg;   /* longitude (counted positive 
+			     * towards West) of CT position */
+  float   flatitude_deg;    /* latitude (counted positive 
+			     * towards North) of CT position */
+  int     ifirstrunnum;     /* first run number to which these 
+			     * parameters apply*/
+  int     ilastrunnum;      /* last run number to which these 
+			     * parameters apply, */
+                            /* i.e. this run will be processed 
+			     * with these parameters */
+  int     inumpixels;       /* number of pixels in the camera */
+  int     inummuonpixels;   /* number of pixels in the muon shield */
+  int     inumcointdcs;     /* number of coincidence tdcs recorded 
+			     * in the runfile */
+  float   fpixdiameter_deg; /* smallest pixel diameter (degrees) */
+  enum axes ese1_is;        /* name of the axis to which shaft
+			     * encoder 1 is attached
+			     * (implies the type of mount) (the 
+			     * type axes is declared in structures.h) */
+  float   fdegrees_per_step[2]; /* angular resolution of shaft 
+				 * encoders 1 and 2 */
+  int     isezeropos[2];    /* zero position of shaftencoders 1 and 
+			     * 2 from parameters file */
+  int     iaz_rev_track_corr; /* correction for the azimuth shaft 
+			       * encoder (ALT/AZ mount only) in 
+			       * reverse tracking mode */
+  int     ialt_rev_track_corr; /* correction for the altitude 
+				* shaft encoder (ALT/AZ mount only) 
+				* in reverse tracking mode */
+  float   fbendingcorr;     /* bending correction factor 
+			     * (ALT/AZ mount only) */
+  Boolean bdontusepix[iMAXNUMPIX]; /* bdontusepix is set true 
+				    * if the pixel should due 
+				    * to whatever reason not be 
+				    * used in image analysis, 
+				    * otherwise it is false;
+				    * this is a copy of the 
+				    * input from the parameters file */
+  Boolean bdontusepix_in_trig[iMAXNUMPIX]; /* is set true if the 
+					    * pixel should due 
+					    * to whatever reason not 
+					    * be used in the two out 
+					    * of all trigger, otherwise 
+					    * it is false; this is a 
+					    * copy of the input from 
+					    * the parameters file */
+  float   fphotoel_per_adccnt[iMAXNUMPIX]; /* conversion factors for 
+					    * the pixel signals */
+  float   fextinction;      /* atmospheric extinction (typically 
+			     * taken from the Carlsberg Meridian
+			     * Circle data) */
+  int     irubminusutc_usecs; /* difference between rubidium clock 
+			       * and UTC in microseconds */
+  int     isum_thresh_phot; /* threshold for the total sum of 
+			     * photoelectrons filter from the 
+			     * parameters file */
+  int     i2out_thresh_phot; /* threshold for the 
+			      * two-pixels-out-of-all software 
+			      * trigger from parameters file */
+  int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; /* thresholds for 
+						   * the muon cut */
+  Boolean bmuon_suppression;       /* if true, the events which do 
+				    * not pass the muon cut are not 
+				    * written to the output */
+  float   ftolerated_pointerror_deg; /* maximum tolerated pointing 
+				      * error in the position check 
+				      * in iprocessdata */
+  float   fxpointcorr_deg;  /* pointing correction (to be added 
+			     * along the camera x axis) e.g. 
+			     * from point run */ 
+  float   fypointcorr_deg;  /* pointing correction (to be added 
+			     * along the camera y axis) e.g. 
+			     * from point run */ 
+  float   fcamera_align_angle_deg; /* the angle between the camera 
+				    * y-axis and the meridian when 
+				    * a culminating object is 
+				    * observed (defined 
+				    * counter-clockwise looking at 
+				    * the sky) */ 
+  int     iratecalc_numevents_odd; /* number of events used in the 
+				    * rate calculation (must be odd) */
+  enum pedsearchdirs {MATCH=0, BEFORE, AFTER, PINGPONG, 
+		      PEAKFWHM, NONE} epedsearchdir ; 
+  /* MATCH = only same number as run file (if ipedendofsearch is 0) or 
+     exactly ipedendofsearch;
+     BEFORE = search backwards until pedendofsearch; 
+     AFTER = search forward until pedendofsearch, 
+     PINGPONG = Try to fibnd the matching partner, try run#-1, run#+1,
+     run#-2, run#+2 etc. up to the third argument, the partnerfindrange 
+     NONE = use none of both. This is only useful for Monte Carlo
+     Analysis, for everything else it is highly unrecommended.*/
+  int     ipedendofsearch;  /* pedestal file number until which to 
+			     * search (see epedsearchdir) */
+  int     ipedsearchdepth;  /* depth, until which preproc should
+			     * try to find TelPed* partnerfiles */
+  enum    pedsearchdirs ecalsearchdir; 
+  /* MATCH = only same number as run file (if ipedendofsearch is 0) or 
+     exactly ipedendofsearch;
+     BEFORE = search backwards until pedendofsearch; 
+     AFTER = search forward until pedendofsearch, 
+     PINGPONG = Try to fibnd the matching partner, try run#-1, run#+1,
+     run#-2, run#+2 etc. up to the third argument, the partnerfindrange 
+     NONE = use none of both. This is only useful for Monte Carlo
+     Analysis, for everything else it is highly unrecommended.*/
+  int     icalendofsearch;  /* calibration file number until which 
+			     * to search (see ecalsearchdir)*/
+  int     icalsearchdepth;  /* depth, until which preproc should
+			     * try to find TelCal* partnerfiles */
+  double  dsourcera_hours;  /* right ascension of observed source 
+			     * in hours */
+  double  dsourcedec_deg;   /* declination of observed source in 
+			     * degrees */
+  float   fpadlevel_phot_pix[iMAXNUMPIX];   /* if > 0., software 
+					     * padding to this 
+					     * level is applied 
+					     * for the given pixel */
+  float   fseed1; /* seed for random generators */
+  float   fseed2;
+
+  int iswap_partner_of_pix[iMAXNUMPIX]; /* if >= 0, pixel i is 
+					 * swapped with 
+					 * iswap_partner_of_pix[i] 
+					 * in ireadrunfile, -pedfile, 
+					 * -calfile (internal 
+					 * numbering starting at 0)*/
+
+  Boolean bnewhistograms; /* set to true if new histograms shall be booked */
+  Boolean bhisto_on; /* set to true if histogramming is on */
+
+  enum eERRORTOLERANCE eerrortolerance; 
+  /* 0 == "cautious", exits on any reason (but tells in 
+   * the .err file,
+   * 1 == "normal", exits when physics could be affected
+   * by the error,
+   * 2 == "tank", never exits except on coredumps and when
+   * all files have been processed. Do not use such files for
+   * physics analysis! 
+   *
+   * NOTE: the capital letter words are the enums, the small letter
+   * words are to be used inside the parameter file. */
+  Boolean bmontecarlo;
+  /* if TRUE we have a monte carlo dataset before us, if FALSE 
+   * (default value) it is just normal data. */
+  enum eMCTRIGGERFLAG emctriggerflag;
+  /* all: all events which survive the filter are written to the 
+   *      events NTuple. 
+   * flag: When Dorota's triggerflag is set to 1 for a particular
+   *       event, it shall be written to the output. All others shall
+   *       just be disregarded. (Default)
+   * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+   *         be treated further. */
+  char mcfile[FILENAME_MAX];
+  float fmean_nsb_pe_pix[iMAXNUMPIX];
+  Boolean bfitmypedrms;
+  /* If TRUE, the pedestal MEAN and SIGMA=sqrt(MEAN) is fitted
+   * from pickup corrected pedestal data and not calculated from 
+   * the pickup corrected ADC values, as it was done up to 
+   * ~November 2000. */
+};
+
+struct calibrationdata { /* Calibration (Laser Run) Data to be read 
+			  * from the Te?Cal files */
+  int iid; /* no useful information, is long in the Macintosh format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  enum onoroff eruntype; /* indicates if the run is on- or off 
+			  * (taken from filename) */
+  int inumruns; /* number of laser runs recorded in this file, is 
+		 * long in the Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used when 
+				   * the data was read */
+  double dmean_adc[iMAXNUMLASERRUNS][iMAXNUMPIX]; 
+  /* means of pixel signals over all shots calculated by TIJARAFE /
+   * Roberto: in processdata.c this number is recalculated. */
+  double dmean_lasoutput[iMAXNUMLASERRUNS][iMAXNUMLASEREVENTS]; 
+  /* This new (April 26 2000) quantity monitors the laser mean
+   * output recorded in events, which are not considered cosmics. */
+  double dmean_alladc[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_laserjitter[iMAXNUMPIX]; 
+  /* Here we calc. the deviation from the actual lasergain in a 
+   * single laser shot to the laser mean as averaged over the camera */
+  double drms_adc[iMAXNUMPEDRUNS][iMAXNUMPIX];
+  /* the standard deviations of the pixel signals */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inumevents[iMAXNUMLASERRUNS]; /* number laser shots, 
+				     * short in Macintosh format */
+  int ipixsig_adc[iMAXNUMLASERRUNS][iMAXNUMLASEREVENTS][iMAXNUMPIX]; 
+  /* the signals obtained from each pixel for each laser shot and 
+   * each laser run, unsigned short in the Macintosh format */
+};
+
+struct pedestaldata { /* Pedestal Run Data to be read from the 
+		       * Te?Ped files */
+  int iid; /* no useful information, is long in the Macintosh 
+	    * format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  enum onoroff eruntype; /* indicates if the run is on- or of 
+			  * (taken from filename) */
+  int inumruns; /* number of pedestal events recorded in this file, 
+		 * is long in the Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used 
+				   * when the data was read */
+  double dmean_adc[iMAXNUMPEDRUNS][iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * TIJARAFE using a sigma cut of 2 */
+  double dmean_alladc[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_allPE[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_pedlevel[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS]; 
+  /* This new (preproc_0.4) quantity monitors the pedestal mean
+   * output recorded in events, which are not considered cosmics. 
+   * The calc.ing is done inside processdata.c */
+  double dmean_pedlevelPE[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS]; 
+  /* This new (preproc_0.4) quantity monitors the pedestal mean
+   * output recorded in events, which are not considered cosmics. 
+   * The calc.ing is done inside processdata.c */
+  double dmean_pedoffset[iMAXNUMPIX]; 
+  /* Mean Offset from the ADC spectrum of a pixel to the mean of the
+   * pedestal events. */
+  double dmean_pedoffsetPE[iMAXNUMPIX]; 
+  /* Mean Offset from the ADC spectrum of a pixel to the mean of the
+   * pedestal events. */
+  double drms_adc[iMAXNUMPEDRUNS][iMAXNUMPIX];
+  /* the standard deviations of the pixel signals used in the 
+   * sigma cut mentioned above */
+  double drms_alladc[iMAXNUMPIX];
+  /* The RMS value of the as-is ADC spectrum for all events inside a 
+   * Pedestal file. */
+  double drms_allPE[iMAXNUMPIX];
+  /* The RMS value of the as-is ADC spectrum for all events inside a 
+   * Pedestal file. */
+  double drms_nopickup[iMAXNUMPIX];
+  /* the standard deviations of the pixel signals' deviation from
+   * the events' mean (in ADC counts, of course...)  ---
+   * This is the same as the RMS of the pickup corrected pedestals! */
+  double drms_nopickupPE[iMAXNUMPIX];
+  /* the standard deviations of the pixel signals' deviation from
+   * the events' mean (in ADC counts, of course...)  ---
+   * This is the same as the RMS of the pickup corrected pedestals! */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inumevents[iMAXNUMPEDRUNS]; /* number of random triggers, 
+				   * short in Macintosh format */
+  int ipixsig_adc[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS][iMAXNUMPIX]; 
+  /* the signals obtained from each pixel for each random trigger 
+   * and each pedestal event, short in the Macintosh format */
+}; 
+
+struct runfiledata { /* Data read from Te?Run files */
+  int iformatid; /* Format ID of the data, long in Macintosh format */
+  int iversid;   /* Version ID of the data, long in Macintosh format */
+  int irevid;    /* Revision ID..., long in Macintosh format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  int irunnumx; /* number read from the file, long in Macintosh format */
+  int inumevents; /* number of events recorded in this run, long in 
+		   * Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used when 
+				   * the data was read */
+  int ieventheaderlength; /* number of bytes in the event header,
+			   * long in Macintosh format */
+  int ieventheaderoffset; /* unknown meaning, long in Macintosh 
+			   * format */
+  int isignalslength; /* number of bytes used by the pixel signals, 
+		       * long in Macintosh format */
+  int isignalsoffset; /* unknown meaning, long in Macintosh format */
+  int itdccountslength; /* number of bytes used by the TDC signals, 
+			 * long in Macintosh format */
+  int itdccountsoffset; /* unknown meaning, long in Macintosh format */
+  int iobservtime_mins; /* (planned) observational time (minutes), 
+			 * short in Macintosh format */
+  enum onoroff eruntype; /* indicates if the run is on- or off-source; 
+			  * in the Macintosh format, this is a short
+			  * where 1 means off and 2 means on */
+  int ileapsecs; /* Leap seconds, introduced into UTC in order to 
+		  * keep track of some very small differences 
+		  * accumulated through the years. */
+  int ihv1;
+  int ihv2; /* these two numbers represent the HV adjustment made
+	     * by the shiftpersonnel. The last three items are 
+	     * only read for Roberto files, but not for Tijarafe 
+	     * files, as e.g. the HVs are not written out correctly. */
+  char cdummy[40]; /* unknown meaning */
+  int imactime_secs[iMAXNUMRUNEVENTS]; 
+  /* Macintosh time (time_t mydatum) in seconds since 1970, this is 
+   * put together from two Macintosh shorts and converted to the time 
+   * format required by SYSTEM */
+  unsigned int uigpstime_secs[iMAXNUMRUNEVENTS]; 
+  /* GPS time (time_t mydatum) in seconds since 1970, this is 
+   * put together from two Macintosh shorts and converted to the time 
+   * format required by SYSTEM 
+   * This time is new from Roberto and is coming from the PC-GPS card.
+   * There is another flag available in the runheader, which gives an
+   * overall flag for the run, whether or not the GPS time had been
+   * working. It is, however, not a good idea to use this flag, as 
+   * the workability of this card can also be dedued from the GPS time
+   * itself. This allows to check for failures on a event-by-event 
+   * basis, which seems more reasonable than using the global flag. */
+  unsigned int uigpstime_usecs[iMAXNUMRUNEVENTS]; 
+  /* GPS microseconds -- available from the card, that's why it is 
+   * put to the data, here it is.
+   * This is put together from two Macintosh shorts and converted
+   * to the time format required by SYSTEM */
+  unsigned int uirubsecs_secs[iMAXNUMRUNEVENTS]; 
+  /* the seconds of the Rubidium clock time this is put together 
+   * from two Macintosh shorts and converted to the time format 
+   * required by SYSTEM */
+  unsigned int uirubsecfrac_200ns[iMAXNUMRUNEVENTS]; 
+  /* the fractional part of the Rubidium clock time second, this is 
+   * put together from two Macintosh shorts, unit is 200 ns */
+  int isepos[2][iMAXNUMRUNEVENTS]; 
+  /* positions of shaft encoders 1 and 2, short in Macintosh format */
+  float fhourangle; /* This is the angle between the observation of this
+		     * event and the culmination point. It is going to 
+		     * be written into the events NTuple. */
+  int ieventnumber[iMAXNUMRUNEVENTS]; 
+/* number of the event, short in Macintosh format */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inummuonpixels; /* number of pixels in  the muon shield; 
+		       * the sum of inumpixels and inummuonpixels is 
+		       * part of the event record but should be the 
+		       * same for all events, so it is not put into 
+		       * an array */
+  int inumcointdcs; /* number of coincidence TDCs for which counts 
+		     * were recorded, short in Macintosh format
+                     * this value is part of the event record but 
+		     * should be the same for all events, so it is 
+		     * not put into an array */
+  int ipixsig_adc[iMAXNUMRUNEVENTS][iMAXNUMPIX]; 
+  /* signals from the camera photo multipliers (ADC counts) */
+  int imuonpixsig_adc[iMAXNUMRUNEVENTS][iMAXNUMMUONPIX]; 
+  /* signals from the muon shield photo multipliers (ADC counts) */
+  int itdcsig_cnts[iMAXNUMRUNEVENTS][iMAXNUMCOINTDCS]; 
+  /* counts from the coincidence TDCs if itdccountslength > 0 */
+};
+
+struct TELLOGDATA {
+  int irunnum; /* The runnumber which we are interested in. 
+		* Only data for this runnumber are written into 
+		* this structure and then copied to the calnt NTuple.
+		* 
+		* This runnumber is generally the closest match 
+		* inside the TelLog file. */
+  float pixel_timeaveraged_current[127];
+  float pixel_timeaveraged_scaler[127];
+};
+
+/************************************************
+ * structures in output file                    *
+ * (Konopelko files format)                     *
+ * (from structures.h file 4.4)                 *
+ ************************************************/
+struct mcbankheader { /* Once in every file */
+  int iparticle_type;  
+  /* Primary particle type: 0 = gamma; +-1= e+-; 
+   * +-2 = mu+-; +-3 = p+-, n; +-4 = pi+- */
+  int inum_cts;
+  /* Number of simulated telescopes */
+  int inum_nfl_shifts; 
+  /* Number of NFL shifts for hadrons (per event) */
+  int itrigger_thresh_phot; 
+  /* Only images with two pixels above this threshold are 
+   * in the MC data file */
+  int imin_signal;
+  /* "Tail cut" = smallest signal saved */
+  int inum_sim_showers; 
+  /* Total number of showers simulated for this file */
+  float fatmothick_gcm2; 
+  /* Atmosphere above the telescope [g/cm2] */
+  float fcos_zenangle;
+  /* Cosine of the zenith angle */
+  float fnfl_shift_radius_deg; 
+  /* Maximum angular radius within which a shifted 
+   * hadron shower is sampled [degrees] */
+  float fenergybin_bound_tev[iNUMENERGYBINS+1]; 
+  /* Boundaries for the 14 energy bins [TeV] 
+   * (newline after the first 8 numbers) */
+  float fzenithanglebin_bound[iNUMZENANGLEBINS+1]; 
+  /* Boundaries for the 11 zenith angle bins [degrees] */
+  int inum_show_in_bin[iNUMENERGYBINS]; 
+  /* Number of simulated (or saved) showers 
+   * per energy bin (newline after the first 8 numbers) */
+  float fmaxdist_impact_m[iNUMIMPACTBINS]; 
+  /* Maximum distance of the impact point to the 
+   * central telescope [m] for each energy bin 
+   * (newline after the first 8 numbers) */
+  int inumpixels_for_ct[iMAXNUMCTS]; 
+  /* Number of pixels in the camera of each simulated CT */
+  float fpixwidth_deg_ct[iMAXNUMCTS]; 
+  /* Pixel width [degrees] for each CT */
+  float fmirrsize_m2_ct[iMAXNUMCTS];  
+  /* Mirror area [m^2] for each CT  */
+  float fmean_nsb_phot_ct[iMAXNUMCTS]; 
+  /* Mean signal caused by the NSB in each pixel for each CT 
+   * [photoelectrons]. This is the simulation of the NSB, 
+   * not the electronic noise */
+  float fphes_per_photon_ct[iMAXNUMCTS]; 
+  /* Conversion factor photoelectron per photon */
+  float frelative_x_ct[iMAXNUMCTS]; 
+  /* x position relative to the central CT for each CT */
+  float frelative_y_ct[iMAXNUMCTS]; 
+  /* y position relative to the central CT for each CT */
+}; 
+#endif
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/FilterLinkDef.h	(revision 1638)
@@ -0,0 +1,16 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MFilterList+;
+
+#pragma link C++ class MF+;
+#pragma link C++ class MFAlpha+;
+#pragma link C++ class MFEventSelector+;
+#pragma link C++ class MFTriggerLvl1+;
+#pragma link C++ class MFParticleId+;
+#pragma link C++ class MFDataMember+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.cc	(revision 1638)
@@ -0,0 +1,405 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MF                                                              
+//
+// With this filter you can filter in all variables from Mars parameter
+// containers.
+//
+// In the constructor you can give the filter rule, like
+//   "MHillas.fLength < 15"
+// Where MHillas is the name of the parameter container in the parameter
+// list and fLength is the name of the data member which should be used
+// for the filter rule. If the name of the container is use specified
+// (MyHillas) the name to give would be:
+//   "MyHillas.fLength < 15"
+//
+// Also more difficult rules are allowed, like:
+//   "MHillas.fWidth<0.5 && MHillas.fLength<0.6"
+//
+// You can also use brackets:
+//   "MHillas.fSize>200 || (MHillas.fWidth<0.5 && MHillas.fLength<0.6)"
+//
+// The allowed logigal conditionals are:
+//   &&: logical and
+//   ||: logical or
+//   ^:  exclusive or
+//
+// As conditional signs, for now, only:
+//   <, >
+// are allowed.
+//
+// Warning: There is no priority rule build in. So better use brackets
+//   to get correct results. The rule is parsed/evaluated from the left
+//   to the right, which means:
+//
+//   "MHillas.fSize>200 || MHillas.fWidth<0.5 && MHillas.fLength<0.6"
+//
+//    is parses as
+//
+//   "(MHillas.fSize>200 || MHillas.fWidth<0.5) && MHillas.fLength<0.6"
+//
+//
+// FIXME: The possibility to use also complete filters is missing.
+//        Maybe we can use gInterpreter->Calc("") for this.
+//        gROOT->ProcessLineFast("line");
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MF.h"
+
+#include <ctype.h>        // isalnum, ...
+#include <stdlib.h>       // strtod, ...
+#include <fstream.h>      // ofstream, ...
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MFilterList.h"
+#include "MFDataMember.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MF);
+
+const TString MF::gsDefName  = "MF";
+const TString MF::gsDefTitle = "Filter setup by a text-rule";
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Don't use.
+//
+MF::MF() : fFilter(NULL)
+{
+    fName  = gsDefName.Data();
+    fTitle = gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor. For the text describing the filter rule please see
+// the class description above.
+//
+MF::MF(const char *text, const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    *fLog << inf << "Trying to resolve filter rule..." << endl;
+    if (!(fFilter=ParseString(text, 1)))
+    {
+        *fLog << err << dbginf << "Parsing '" << text << "' failed." << endl;
+        return;
+    }
+
+    *fLog << inf << endl;
+    *fLog << "Using Filter rule " << fFilter->GetName();
+    *fLog << " for " << fName << ":" << endl;
+    fFilter->Print();
+    *fLog << endl << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete filters.
+//
+MF::~MF()
+{
+    if (fFilter)
+        delete fFilter;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of alphanumeric characters (including '.')
+// in the given string
+//
+Int_t MF::IsAlNum(TString txt)
+{
+    int l = txt.Length();
+    for (int i = 0; i<l; i++)
+        if (!isalnum(txt[i]) && txt[i]!='.')
+            return i;
+
+    return l;
+}
+
+// --------------------------------------------------------------------------
+//
+// Parse a text string. Returns a corresponding filter of filter list.
+//
+MFilter *MF::ParseString(TString txt, Int_t level)
+{
+    MFilter *filter0=NULL;
+
+    TString type;
+    int nlist = 0;
+
+    while (!txt.IsNull())
+    {
+        MFilter *newfilter = NULL;
+
+        txt = txt.Strip(TString::kBoth);
+
+        //*fLog << all << setw(level) << " " << "Text: " << level << " '" << txt << "'" << endl;
+
+        switch (txt[0])
+        {
+        case '(':
+            {
+                //
+                // Search for the corresponding bracket
+                //
+                Int_t first=1;
+                for (int cnt=0; first<txt.Length(); first++)
+                {
+                    if (txt[first]=='(')
+                        cnt++;
+                    if (txt[first]==')')
+                        cnt--;
+
+                    if (cnt==-1)
+                        break;
+                }
+
+                if (first==txt.Length())
+                {
+                    *fLog << err << dbginf << "Syntax Error: ')' missing." << endl;
+                    if (filter0)
+                        delete filter0;
+                    return NULL;
+                }
+
+                //
+                // Make a copy of the 'interieur' and delete the substringä
+                // including the brackets
+                //
+                TString sub = txt(1, first-1);
+                txt.Remove(0, first+1);
+
+                //
+                // Parse the substring
+                //
+                newfilter = ParseString(sub, level+1);
+                if (!newfilter)
+                {
+                    *fLog << err << dbginf << "Parsing '" << sub << "' failed." << endl;
+                    if (filter0)
+                        delete filter0;
+                    return NULL;
+                }
+            }
+            break;
+
+        case ')':
+            *fLog << err << dbginf << "Syntax Error: Too many ')'" << endl;
+            if (filter0)
+                delete filter0;
+            return NULL;
+
+        case '&':
+        case '|':
+        case '^':
+            if (filter0)
+            {
+                //
+                // Check for the type of the conditional
+                //
+                TString is = txt[0];
+                txt.Remove(0, 1);
+
+                if (is==txt[0] && is!='^')
+                {
+                    is += txt[0];
+                    txt.Remove(0, 1);
+                }
+
+                //
+                // If no filter is available or the available filter
+                // is of a different conditional we have to create a new
+                // filter list with the new conditional
+                //
+                if (!filter0->InheritsFrom(MFilterList::Class()) || type!=is)
+                {
+                    MFilterList *list = new MFilterList(is);
+                    list->SetName(Form("List_%s_%d", (const char*)is, 10*level+nlist++));
+
+                    list->SetOwner();
+                    list->AddToList(filter0);
+                    filter0 = list;
+
+                    type = is;
+                }
+                continue;
+            }
+
+            *fLog << err << dbginf << "Syntax Error: First argument of condition missing." << endl;
+            if (filter0)
+                delete filter0;
+            return NULL;
+
+        default:
+            int i = IsAlNum(txt);
+
+            if (i==0)
+            {
+                *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;
+                if (filter0)
+                    delete filter0;
+                return NULL;
+            }
+
+            TString text = txt(0, i);
+
+            txt.Remove(0, i);
+            txt = txt.Strip(TString::kBoth);
+
+            if (txt.IsNull())
+            {
+                *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl;
+                if (filter0)
+                    delete filter0;
+                return NULL;
+            }
+
+            char c;
+            switch (txt[0])
+            {
+            case '>':
+            case '<':
+                c = txt[0];
+                txt.Remove(0, 1);
+                break;
+
+            default:
+                *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl;
+                if (filter0)
+                    delete filter0;
+                return NULL;
+            }
+
+            char *end;
+            Double_t num = strtod(txt.Data(), &end);
+            if (!end || txt.Data()==end)
+            {
+                *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;
+                if (filter0)
+                    delete filter0;
+                return NULL;
+            }
+
+            txt.Remove(0, end-txt.Data());
+
+            newfilter = new MFDataMember(text.Data(), c, num);
+            newfilter->SetName(Form("%s%c%f", text.Data(), c, num));
+        }
+
+        if (!filter0)
+        {
+            filter0 = newfilter;
+            continue;
+        }
+
+        if (!filter0->InheritsFrom(MFilterList::Class()))
+            continue;
+
+        ((MFilterList*)filter0)->AddToList(newfilter);
+    }
+
+    return filter0;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess all filters.
+//
+Bool_t MF::PreProcess(MParList *plist)
+{
+    if (!fFilter)
+    {
+        *fLog << err << dbginf << "No filter rule available." << endl;
+        return kFALSE;
+    }
+
+    if (!fFilter->PreProcess(plist))
+    {
+        *fLog << err << dbginf << "PreProcessing filters in ";
+        *fLog << fName << " failed." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process all filters.
+//
+Bool_t MF::Process()
+{
+    return fFilter->Process();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Postprocess all filters.
+//
+Bool_t MF::PostProcess()
+{
+    return fFilter->PostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the result of the filter rule.
+//
+Bool_t MF::IsExpressionTrue() const
+{
+    return fFilter->IsExpressionTrue();
+}
+
+void MF::StreamPrimitive(ofstream &out) const
+{
+    out << "   MF " << GetUniqueName();
+
+    if (!fFilter)
+    {
+        out << ";" << endl;
+        return;
+    }
+
+    out << "(\"" << fFilter->GetRule() << "\"";
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MF.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MF
+#define MARS_MF
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MF                                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class TMethodCall;
+
+class MF : public MFilter
+{
+private:
+    static const TString gsDefName;  //!
+    static const TString gsDefTitle; //!
+
+    MFilter *fFilter; // Filter
+
+    Int_t IsAlNum(TString txt);
+
+    MFilter *ParseString(TString txt, Int_t level);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MF();
+    MF(const char *text, const char *name=NULL, const char *title=NULL);
+    ~MF();
+
+    Bool_t IsExpressionTrue() const;
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MF, 0) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.cc	(revision 1638)
@@ -0,0 +1,128 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFAlpha                                                               //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFAlpha.h"
+
+#include <math.h>
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillasSrc.h"
+
+ClassImp(MFAlpha);
+
+
+// --------------------------------------------------------------------------
+//
+MFAlpha::MFAlpha(const char *cname, const char type, const Float_t val,
+                 const char *name, const char *title) : fHillas(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFAlpha::MFAlpha(MHillasSrc *hillas, const char type, const Float_t val,
+                 const char *name, const char *title) : fHillas(hillas)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFAlpha::Init(const char type, const Int_t val,
+                   const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFAlpha";
+    fTitle = title ? title : "Filter using the alpha angle";
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+
+    fValue = val;
+
+    AddToBranchList(Form("%s.fAlpha", (const char*)fContName));
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFAlpha::PreProcess(MParList *pList)
+{
+    if (fHillas)
+        return kTRUE;
+
+    fHillas = (MHillasSrc*)pList->FindObject(fContName);
+    if (fHillas)
+        return kTRUE;
+
+    *fLog << err << dbginf << fContName << " [MHillas] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFAlpha::Process()
+{
+    const Float_t alpha = fabs(fHillas->GetAlpha());
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (alpha < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (alpha > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFAlpha::StreamPrimitive(ofstream &out) const
+{
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    out << "   MFParticleId " << GetUniqueName() << "(";
+
+    if (fHillas)
+        out << "&" << fHillas->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFAlpha.h	(revision 1638)
@@ -0,0 +1,47 @@
+#ifndef MARS_MFAlpha
+#define MARS_MFAlpha
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFAlpha                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class MHillasSrc;
+
+class MFAlpha : public MFilter
+{
+private:
+    MHillasSrc *fHillas;
+    TString fContName;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult; //!
+    Float_t fValue; // [deg]
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFAlpha(const char *cname="MHillas", const char type='>', const Float_t deg=15,
+            const char *name=NULL, const char *title=NULL);
+    MFAlpha(MHillasSrc *hillas, const char type='>', const Float_t deg=15,
+            const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MFAlpha, 1) // A Filter for cuts in fabs(alpha)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.cc	(revision 1638)
@@ -0,0 +1,121 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MFDataMember                                                              
+//
+// With this filter you can filter in all variables from Mars parameter
+// containers.
+//
+// In the constructor you can give the filter variable, like
+//   "MHillas.fLength"
+// Where MHillas is the name of the parameter container in the parameter
+// list and fLength is the name of the data member which should be used
+// for the filter rule. If the name of the container is use specified
+// (MyHillas) the name to give would be:
+//   "MyHillas.fLength"
+//
+// For example:
+//   MFDataMember filter("MHillas.fLength", '<', 150);
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFDataMember.h"
+
+#include <fstream.h>
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFDataMember);
+
+// --------------------------------------------------------------------------
+//
+MFDataMember::MFDataMember(const char *member, const char type, const Double_t val,
+                           const char *name, const char *title)
+    : fData(member), fValue(val)
+{
+    fName  = name  ? name  : "MFDataMember";
+    fTitle = title ? title : "Filter using any data member of a class";
+
+    AddToBranchList(member);
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFDataMember::PreProcess(MParList *plist)
+{
+    return fData.PreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFDataMember::Process()
+{
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (fData.GetValue() < fValue);
+        return kTRUE;
+    case kEGreaterThan:
+        fResult = (fData.GetValue() > fValue);
+        return kTRUE;
+    }
+
+    return kFALSE;
+}
+
+void MFDataMember::Print(Option_t *) const
+{
+    *fLog << GetRule() << flush;
+}
+
+void MFDataMember::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFDataMember " << GetUniqueName() << "(\"";
+    out << fData.GetRule() << "\", '";
+    out << (fFilterType==kELowerThan?"<":">");
+    out << "', " << fValue << ");" << endl;
+}
+
+TString MFDataMember::GetRule() const
+{
+    TString ret = fData.GetRule();
+    ret += fFilterType==kELowerThan?"<":">";
+
+    TString str;
+    str += fValue;
+
+    return ret+str.Strip(TString::kBoth);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFDataMember.h	(revision 1638)
@@ -0,0 +1,46 @@
+#ifndef MARS_MFDataMember
+#define MARS_MFDataMember
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFDataMember                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+#ifndef MARS_MDataMember
+#include "MDataMember.h"
+#endif
+
+class MParList;
+
+class MFDataMember : public MFilter
+{
+private:
+    MDataMember fData;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult;           //!
+    Double_t fValue;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFDataMember(const char *member, const char type, const Double_t val,
+                 const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    ClassDef(MFDataMember, 1) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.cc	(revision 1638)
@@ -0,0 +1,195 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MFEventSelector
+//
+// This is a filter to make a selection of events from a file. At the
+// present implementation you can only use a random selection.
+//
+// If you want to fill only 50% of your events into a histogram please use:
+//   MFEventSelector sel;
+//   sel.SetSelectionRatio(0.5);
+//   MFillH filler(...);
+//   filler.SetFilter(&sel);
+//   tlist.AddToList(&sel);
+//   tlist.AddToList(&filler);
+//
+// To get around 2000 events from all events use (Remark: This will only
+// work if the parlist has an entry called MTaskList which has a task
+// MRead inheriting from MRead):
+//   MFEventSelector sel;
+//   sel.SetNumSelectEvts(2000);
+//   MFillH filler(...);
+//   filler.SetFilter(&sel);
+//   tlist.AddToList(&sel);
+//   tlist.AddToList(&filler);
+//
+// If you don't have MRead available you have to set the number of
+// total events manually, using sel.SetNumTotalEvts(10732);
+//
+// The random number is generated using gRandom->Uniform(). You may
+// control this procedure using the global object gRandom.
+//
+// Because of the random numbers this works best for huge samples...
+//
+// Don't try to use this filter for the reading task: This won't work!
+//
+// Remark: You can also use the filter together with MContinue
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFEventSelector.h"
+
+#include <TRandom.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MRead.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFEventSelector);
+
+static const TString gsDefName  = "MFEventSelector";
+static const TString gsDefTitle = "Filter to select events";
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Don't use.
+//
+/*
+MFEventSelector::MFEventSelector()
+    : fNumTotalEvts(-1), fNumSelectEvts(-1), fSelRatio(-1), fNumSelectedEvts(0)
+{
+    fName  = gsDefName.Data();
+    fTitle = gsDefTitle.Data();
+}
+*/
+// --------------------------------------------------------------------------
+//
+// Constructor. For the text describing the filter rule please see
+// the class description above.
+//
+MFEventSelector::MFEventSelector(const char *name, const char *title)
+: fNumTotalEvts(-1), fNumSelectEvts(-1), fSelRatio(-1), fNumSelectedEvts(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete filters.
+//
+MFEventSelector::~MFEventSelector()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess all filters.
+//
+Bool_t MFEventSelector::PreProcess(MParList *plist)
+{
+    fNumSelectedEvts = 0;
+    if (fSelRatio>0)
+        return kTRUE;
+
+    if (fNumTotalEvts<0)
+    {
+        MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+        if (!tlist)
+        {
+            *fLog << err << dbginf << "Sorry can't determin total number of events... no MTaskList." << endl;
+            return kFALSE;
+        }
+        MRead *read = (MRead*)tlist->FindObject("MRead");
+        if (!read)
+        {
+            *fLog << err << dbginf << "Sorry can't determin total number of events from 'MRead'." << endl;
+            return kFALSE;
+        }
+        fNumTotalEvts = read->GetEntries();
+
+        SetBit(kNumTotalFromFile);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process all filters.
+//
+Bool_t MFEventSelector::Process()
+{
+    Float_t evt = gRandom->Uniform();
+
+    if (fNumSelectEvts>0)
+        fResult = evt*fNumTotalEvts < fNumSelectEvts;
+    else
+        fResult = evt < fSelRatio;
+
+    if (fResult)
+        fNumSelectedEvts++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Postprocess all filters.
+//
+Bool_t MFEventSelector::PostProcess()
+{
+    if (TestBit(kNumTotalFromFile))
+        fNumTotalEvts = -1;
+    return kTRUE;
+}
+
+void MFEventSelector::StreamPrimitive(ofstream &out) const
+{
+    /*
+    out << "   MF " << GetUniqueName();
+
+    if (!fFilter)
+    {
+        out << ";" << endl;
+        return;
+    }
+
+    out << "(\"" << fFilter->GetRule() << "\"";
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+    */
+
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFEventSelector.h	(revision 1638)
@@ -0,0 +1,56 @@
+#ifndef MARS_MFEventSelector
+#define MARS_MFEventSelector
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFEventSelector                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+
+class MFEventSelector : public MFilter
+{
+private:
+    Int_t   fNumTotalEvts;
+    Int_t   fNumSelectEvts;
+    Float_t fSelRatio;
+
+    Int_t   fNumSelectedEvts; //!
+
+    Bool_t  fResult;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum { kNumTotalFromFile = BIT(14) };
+    /*
+     enum { kUseFixedRatio=BIT(14) }
+     */
+
+public:
+    // MFEventSelector();
+    MFEventSelector(const char *name=NULL, const char *title=NULL);
+    ~MFEventSelector();
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    void SetNumTotalEvts(Int_t n) { fNumTotalEvts = n; ResetBit(kNumTotalFromFile); }
+    void SetNumSelectEvts(Int_t n) { fNumSelectEvts = n; }
+    void SetSelectionRatio(Float_t f) { fSelRatio = f; }
+
+    /*
+     void SetUseFixedRatio(Bool_t b=kTRUE) { b ? SetBit(kUseFixedRatio) : ResetBit(kUseFixedRatio); }
+     */
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MFEventSelector, 0) // A Filter to select events from files
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.cc	(revision 1638)
@@ -0,0 +1,160 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFParticleId                                                          //
+//                                                                         //
+//  A filter to choose between different particle types, identified by     //
+//  their monte carlo particle type. For a list of idetifiers see          //
+//  mbase/MAGIC.h                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFParticleId.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MFParticleId);
+
+
+// --------------------------------------------------------------------------
+//
+MFParticleId::MFParticleId(const char *cname, const char type, const Int_t val,
+                           const char *name, const char *title) : fMcEvt(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFParticleId::MFParticleId(MMcEvt *mcevt, const char type, const Int_t val,
+                           const char *name, const char *title) : fMcEvt(mcevt)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFParticleId::Init(const char type, const Int_t val,
+                        const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFParticleId";
+    fTitle = title ? title : "Filter using monte carlo particle id";
+
+    fFilterType = (type=='=' ? kEEqual : kENotEqual);
+
+    if (type!='=' && type!='!')
+        *fLog << warn << dbginf << "Warning: Neither '=' nor '!' specified... using '>'." << endl;
+
+    fValue = val;
+
+    AddToBranchList(Form("%s.fPartId", (const char*)fContName));
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFParticleId::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFParticleId::PreProcess(MParList *pList)
+{
+    if (fMcEvt)
+        return kTRUE;
+
+    fMcEvt = (MMcEvt*)pList->FindObject(fContName);
+    if (fMcEvt)
+        return kTRUE;
+
+    *fLog << err << dbginf << fContName << " [MMcEvt] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFParticleId::Process()
+{
+    const Int_t id = fMcEvt->GetPartId();
+
+    switch (fFilterType)
+    {
+    case kEEqual:
+        fResult = (id == fValue);
+        return kTRUE;
+    case kENotEqual:
+        fResult = (id != fValue);
+        return kTRUE;
+    }
+
+    *fLog << err << dbginf << "Operation unknown..." << endl;
+    return kFALSE;
+}
+
+void MFParticleId::StreamPrimitive(ofstream &out) const
+{
+    if (fMcEvt)
+        fMcEvt->SavePrimitive(out);
+
+    out << "   MFParticleId " << GetUniqueName() << "(";
+
+    if (fMcEvt)
+        out << "&" << fMcEvt->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kEEqual?"=":"!") << "', ";
+
+    switch (fValue)
+    {
+    case kGAMMA:
+        out << "kGAMMA";
+        break;
+    case kPROTON:
+        out << "kPROTON";
+        break;
+    case kHELIUM:
+        out << "kHELIUM";
+        break;
+    case kOXYGEN:
+        out << "kOXYGEN";
+        break;
+    case kIRON:
+        out << "kIRON";
+        break;
+    default:
+        out << fValue;
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFParticleId.h	(revision 1638)
@@ -0,0 +1,47 @@
+#ifndef MARS_MFParticleId
+#define MARS_MFParticleId
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFParticleId                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MParList;
+
+class MFParticleId : public MFilter
+{
+private:
+    MMcEvt *fMcEvt;
+    TString fContName;
+
+    typedef enum { kEEqual, kENotEqual } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t fResult;    //!
+    Int_t  fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFParticleId(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
+                 const char *name=NULL, const char *title=NULL);
+    MFParticleId(MMcEvt *mcevt, const char type='=', const Int_t val=0,
+                 const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const;
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MFParticleId, 1)		// A Filter for the Level 1 Trigger
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.cc	(revision 1638)
@@ -0,0 +1,134 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFTriggerLvl1                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFTriggerLvl1.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcTrig.hxx"
+
+ClassImp(MFTriggerLvl1);
+
+
+// --------------------------------------------------------------------------
+//
+MFTriggerLvl1::MFTriggerLvl1(const char *cname, const char type, const Int_t val,
+                             const char *name, const char *title) : fMcTrig(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFTriggerLvl1::MFTriggerLvl1(MMcTrig *mctrig, const char type, const Int_t val,
+                             const char *name, const char *title) : fMcTrig(mctrig)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFTriggerLvl1::Init(const char type, const Int_t val,
+                         const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFTriggerLvl1";
+    fTitle = title ? title : "Filter using number of 1st level triggers";
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+
+    fValue = val;
+
+    AddToBranchList(Form("%s.fNumFirstLevel", (const char*)fContName));
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFTriggerLvl1::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFTriggerLvl1::PreProcess(MParList *pList)
+{
+    if (fMcTrig)
+        return kTRUE;
+
+    fMcTrig = (MMcTrig*)pList->FindObject(fContName);
+    if (fMcTrig)
+        return kTRUE;
+
+    *fLog << err << dbginf << fContName << " [MMcTrig] not found... aborting." << endl;
+        return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFTriggerLvl1::Process()
+{
+    const Int_t lvl1 = fMcTrig->GetFirstLevel();
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (lvl1 < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (lvl1 > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFTriggerLvl1::StreamPrimitive(ofstream &out) const
+{
+    if (fMcTrig)
+        fMcTrig->SavePrimitive(out);
+
+    out << "   MFTriggerLvl1 " << GetUniqueName() << "(";
+
+    if (fMcTrig)
+        out << "&" << fMcTrig->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFTriggerLvl1.h	(revision 1638)
@@ -0,0 +1,47 @@
+#ifndef MARS_MFTriggerLvl1
+#define MARS_MFTriggerLvl1
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFTriggerLvl1                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcTrig;
+class MParList;
+
+class MFTriggerLvl1 : public MFilter
+{
+private:
+    MMcTrig *fMcTrig;
+    TString fContName;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType; 
+
+    Bool_t fResult;             //!
+    Int_t  fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFTriggerLvl1(const char *cname="MMcTrig", const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+    MFTriggerLvl1(MMcTrig *mctrig, const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const;
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MFTriggerLvl1, 1) // A Filter for the Level 1 Trigger
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.cc	(revision 1638)
@@ -0,0 +1,353 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFilterList                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFilterList.h"
+
+#include <fstream.h>
+
+#include <TString.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIter.h"
+
+ClassImp(MFilterList);
+
+static const TString gsDefName  = "MFilterList";
+static const TString gsDefTitle = "List combining filters logically.";
+
+// --------------------------------------------------------------------------
+//
+//   Constructor.
+//
+//   Specify the boolean operation which is used to evaluate the
+//   result of this list. If no operation is specified "land" is
+//   used.
+//
+//   Options:
+//      and, &   : is a bitwise and
+//      or, |    : is a bitwise or
+//      xor, ^   : is a bitwise exclusive or
+//      land, && : is a logical and
+//      lor, ||  : is a logical or
+//
+MFilterList::MFilterList(const char *type, const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fFilterType = kEAnd;
+
+    TString str(type);
+
+    if (!str.CompareTo("OR", TString::kIgnoreCase)  || !str.CompareTo("|"))
+        fFilterType = kEOr;
+    if (!str.CompareTo("XOR", TString::kIgnoreCase) || !str.CompareTo("^"))
+        fFilterType = kEXor;
+    if (!str.CompareTo("LAND", TString::kIgnoreCase) || !str.CompareTo("&&"))
+        fFilterType = kELAnd;
+    if (!str.CompareTo("LOR", TString::kIgnoreCase) || !str.CompareTo("||"))
+        fFilterType = kELOr;
+}
+
+// --------------------------------------------------------------------------
+//
+//   CopyConstructor
+//
+MFilterList::MFilterList(MFilterList &ts)
+{
+    fFilters.AddAll(&ts.fFilters);
+    fFilterType = ts.fFilterType;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Evaluates and returns the result of the filter list.
+//  The expression is evaluated step by step, eg:
+//  ((filter[0] # filter[1]) # filter[3]) # filter[4])
+//  The '#' stands for the boolean operation which is specified in
+//  the constructor.
+//
+Bool_t MFilterList::IsExpressionTrue() const
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=(MFilter*)Next();
+
+    if (!filter)
+        return kTRUE;
+
+    Bool_t rc = filter->IsExpressionTrue();
+
+    //
+    // loop over all filters
+    //
+    switch (fFilterType)
+    {
+    case kEAnd:
+        while ((filter=(MFilter*)Next()))
+            rc &= filter->IsExpressionTrue();
+        break;
+
+    case kEOr:
+        while ((filter=(MFilter*)Next()))
+            rc |= filter->IsExpressionTrue();
+        break;
+
+    case kEXor:
+        while ((filter=(MFilter*)Next()))
+            rc ^= filter->IsExpressionTrue();
+        break;
+
+    case kELAnd:
+        while ((filter=(MFilter*)Next()))
+            rc = (rc && filter->IsExpressionTrue());
+        break;
+
+    case kELOr:
+        while ((filter=(MFilter*)Next()))
+            rc = (rc || filter->IsExpressionTrue());
+        break;
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to add a new filter to the list call this function with the
+// pointer to the filter to be added. 
+//
+Bool_t MFilterList::AddToList(MFilter *filter)
+{
+    if (!filter)
+        return kTRUE;
+
+    const char *name = filter->GetName();
+
+    if (fFilters.FindObject(filter))
+    {
+        *fLog << warn << dbginf << "Filter already existing... skipped." << endl;
+        return kTRUE;
+    }
+
+    if (fFilters.FindObject(name))
+    {
+        *fLog << warn << dbginf << "'" << name << "' exists in List already... skipped." << endl;
+        return kTRUE;
+    }
+
+    *fLog << inf << "Adding " << name << " to " << GetName() << "... " << flush;
+
+    fFilters.Add(filter);
+
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all filters in the list
+//
+Bool_t MFilterList::PreProcess(MParList *pList)
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->PreProcess(pList))
+        {
+            *fLog << err << "Error - Preprocessing Filter ";
+            *fLog << filter->GetName() << " in " << fName << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Processes (updates) all filters in the list.
+//
+Bool_t MFilterList::Process()
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->Process())
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PostProcesses all filters in the list.
+//
+Bool_t MFilterList::PostProcess()
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->PostProcess())
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to use a verbose output ("and") instead of a symbolic ("&")
+// one the option string must conatin a "v"
+//
+void MFilterList::Print(Option_t *opt) const
+{
+    *fLog << all << GetRule(opt) << flush;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MFilterList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFilterList " << ToLower(fName) << "(\"";
+
+    switch (fFilterType)
+    {
+    case kEAnd:
+        out << "&";
+        break;
+
+    case kEOr:
+        out  << "|";
+        break;
+
+    case kEXor:
+        out  << "^";
+        break;
+
+    case kELAnd:
+        out << "&&";
+        break;
+
+    case kELOr:
+        out << "||";
+        break;
+    }
+
+    out << "\"";
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl << endl;
+
+    MIter Next(&fFilters);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        cont->SavePrimitive(out, "");
+
+        out << "   " << ToLower(fName) << ".AddToList(&";
+        out << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+TString MFilterList::GetRule(Option_t *opt) const
+{
+    TString str(opt);
+    const Bool_t verbose = str.Contains("V", TString::kIgnoreCase);
+
+    TString ret = "(";
+
+    TIter Next(&fFilters);
+
+    MFilter *filter=(MFilter*)Next();
+
+    //
+    // loop over all filters
+    //
+    if (!filter)
+        return "<empty>";
+
+    ret += filter->GetRule();
+
+    while ((filter=(MFilter*)Next()))
+    {
+        switch (fFilterType)
+        {
+        case kEAnd:
+            ret += (verbose?" and ":" & ");
+            break;
+
+        case kEOr:
+            ret += (verbose?" or ":" | ");
+            break;
+
+        case kEXor:
+            ret += (verbose?" xor ":" ^ ");
+            break;
+
+        case kELAnd:
+            ret += (verbose?" land ":" && ");
+            break;
+
+        case kELOr:
+            ret += (verbose?" lor ":" || ");
+            break;
+        }
+
+        ret += filter->GetRule();
+    }
+
+    return ret+")";
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/MFilterList.h	(revision 1638)
@@ -0,0 +1,57 @@
+#ifndef MARS_MFilterList
+#define MARS_MFilterList
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MFilterList                                                            //
+//                                                                         //
+//  List of several filters                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+
+class MFilterList : public MFilter
+{
+private:
+    TOrdCollection fFilters;	// Container for the filters
+
+    typedef enum { kEAnd, kEOr, kEXor, kELAnd, kELOr } FilterType_t;
+    FilterType_t fFilterType;
+
+    enum { kIsOwner = BIT(14) };
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL);
+    MFilterList(MFilterList &ts);
+    ~MFilterList()
+    {
+        if (TestBit(kIsOwner))
+            fFilters.SetOwner();
+    }
+
+    Bool_t AddToList(MFilter *filter);
+    void SetOwner(Bool_t enable=kTRUE) { enable ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Bool_t IsExpressionTrue() const;
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    void Print(Option_t *opt = "") const;
+    TString GetRule(Option_t *opt="") const;
+
+    ClassDef(MFilterList, 1)		// List to combine several filters logically
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mfilter/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mfilter/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mfilter/Makefile	(revision 1638)
@@ -0,0 +1,57 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+INCLUDES = -I. -I../mbase -I../mmc -I../manalysis -I../mdata -I../mfileio
+
+# @code 
+
+CINT     = Filter
+LIB      = mfilter.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MFTriggerLvl1.cc \
+	   MF.cc \
+           MFilterList.cc \
+           MFEventSelector.cc \
+	   MFDataMember.cc \
+	   MFParticleId.cc \
+	   MFAlpha.cc
+#	   MFDataChain.cc \
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/GeomLinkDef.h	(revision 1638)
@@ -0,0 +1,14 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MGeomPMT+;
+#pragma link C++ class MGeomMirror+;
+#pragma link C++ class MGeomPix+;
+#pragma link C++ class MGeomCam+;
+#pragma link C++ class MGeomCamCT1+;
+#pragma link C++ class MGeomCamMagic+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.cc	(revision 1638)
@@ -0,0 +1,139 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MGeomCam
+//
+// This is the base class of different camera geometries. It creates
+// a pixel object for a given number of pixels and defines the
+// interface of how to acccess the geometry information.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MGeomCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCam);
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Camera Geometry with npix pixels. All pixels
+// are deleted when the corresponding array is deleted.
+//
+MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title)
+    : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000))
+{
+    fName  = name  ? name  : "MGeomCam";
+    fTitle = title ? title : "Storage container for  a camera geometry";
+
+    fPixels = new TObjArray(npix);
+
+    //
+    // make sure that the destructor delete all contained objects
+    //
+    fPixels->SetOwner();
+
+    for (UInt_t i=0; i<npix; i++)
+        (*fPixels)[i] = new MGeomPix;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor delete the pixel array with all pixels
+//
+MGeomCam::~MGeomCam()
+{
+    delete fPixels;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the kIsOuterRing flag for all pixels which have a outermost pixel
+//  as Next Neighbor and don't have the kIsOutermostRing flag itself.
+//
+void MGeomCam::InitOuterRing()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].CheckOuterRing(*this);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the maximum radius of the camera. This is ment for GUI layout.
+//
+void MGeomCam::CalcMaxRadius()
+{
+    fMaxRadius = 0;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeomPix &pix = (*this)[i];
+
+        const Float_t x = pix.GetX();
+        const Float_t y = pix.GetY();
+        const Float_t r = pix.GetR();
+
+        const Float_t maxr = sqrt(x*x+y*y) + r;
+
+        if (maxr>fMaxRadius)
+            fMaxRadius = maxr;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  returns the ratio of the area of the given pixel to the pixel with
+//  the id 0 to scale variables with the pixel size.
+//
+Float_t MGeomCam::GetPixRatio(Int_t i) const
+{
+    return (*this)[0].GetA()/(*this)[i].GetA();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the Geometry information of all pixels in the camera
+//
+void MGeomCam::Print(Option_t *) const
+{
+    //
+    //   Print Information about the Geometry of the camera
+    //
+    *fLog << all << " Number of Pixels (" << GetTitle() << "): " << fNumPixels << endl;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        *fLog << " Pixel: " << i << "  ";
+        (*this)[i].Print();
+    }
+} 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCam.h	(revision 1638)
@@ -0,0 +1,51 @@
+#ifndef MARS_MGeomCam
+#define MARS_MGeomCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MGeomPix;
+
+class MGeomCam : public MParContainer
+{
+private:
+    UInt_t   fNumPixels;  // Number of pixels in this camera
+    Float_t  fMaxRadius;  // maximum radius of the camera (eg. for GUI layout)
+
+    Float_t  fCamDist;    // [m] Average distance of the camera from the mirror
+    Float_t  fConvMm2Deg; // conversion factor to convert mm in the camera plain into degrees
+
+    TObjArray *fPixels;   // Array of singel pixels storing the geometry
+
+protected:
+    void CalcMaxRadius();
+    void InitOuterRing();
+
+public:
+    MGeomCam(UInt_t npix, Float_t dist, const char *name=NULL, const char *title=NULL);
+
+    virtual ~MGeomCam();
+
+    Float_t GetCameraDist() const      { return fCamDist; }
+    Float_t GetConvMm2Deg() const      { return fConvMm2Deg; }
+
+    UInt_t  GetNumPixels() const       { return fNumPixels; }
+    Float_t GetMaxRadius() const       { return fMaxRadius; }
+    Float_t GetPixRatio(Int_t i) const;
+
+    MGeomPix &operator[](Int_t i)       { return *(MGeomPix*)fPixels->UncheckedAt(i); }
+    MGeomPix &operator[](Int_t i) const { return *(MGeomPix*)fPixels->UncheckedAt(i); }
+
+
+
+    virtual void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MGeomCam, 1)  // Geometry base class for the camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.cc	(revision 1638)
@@ -0,0 +1,269 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamCT1
+//
+// This class stores the geometrz information of the CT1 camera.
+// The next neighbor information comes from a table, the geometry layout
+// is calculated (for Algorithm see CreateCam
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomCamCT1.h"
+
+
+#include <math.h>     // floor
+
+#include "TCanvas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamCT1);
+
+// --------------------------------------------------------------------------
+//
+//  CT1 camera has 127 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamCT1::MGeomCamCT1(const char *name)
+    : MGeomCam(127, 4.88, name, "Geometry information of CT1 camera")
+{
+    CreateCam();
+    CreateNN();
+    CalcMaxRadius();
+} 
+
+// --------------------------------------------------------------------------
+//
+//  Create Next Neighbors: Fill the NN Info into the pixel objects.
+//
+void MGeomCamCT1::CreateNN()
+{ 
+    const Short_t nn[127][6] = {       // Neighbors of #
+      {  1,   2,   3,   4,   5,   6},  // 0
+      {  0,   2,   6,   7,   8,  18},
+      {  0,   1,   3,   8,   9,  10},
+      {  0,   2,   4,  10,  11,  12},
+      {  0,   3,   5,  12,  13,  14},
+      {  0,   4,   6,  14,  15,  16},
+      {  0,   1,   5,  16,  17,  18},
+      {  1,   8,  18,  19,  20,  36},
+      {  1,   2,   7,   9,  20,  21},
+      {  2,   8,  10,  21,  22,  23},
+      {  2,   3,   9,  11,  23,  24},  // 10
+      {  3,  10,  12,  24,  25,  26},
+      {  3,   4,  11,  13,  26,  27},
+      {  4,  12,  14,  27,  28,  29},
+      {  4,   5,  13,  15,  29,  30},
+      {  5,  14,  16,  30,  31,  32},
+      {  5,   6,  15,  17,  32,  33},
+      {  6,  16,  18,  33,  34,  35},
+      {  1,   6,   7,  17,  35,  36},
+      {  7,  20,  36,  37,  38,  60},
+      {  7,   8,  19,  21,  38,  39},  // 20
+      {  8,   9,  20,  22,  39,  40},
+      {  9,  21,  23,  40,  41,  42},
+      {  9,  10,  22,  24,  42,  43},
+      { 10,  11,  23,  25,  43,  44},
+      { 11,  24,  26,  44,  45,  46},
+      { 11,  12,  25,  27,  46,  47},
+      { 12,  13,  26,  28,  47,  48},
+      { 13,  27,  29,  48,  49,  50},
+      { 13,  14,  28,  30,  50,  51},
+      { 14,  15,  29,  31,  51,  52},  // 30
+      { 15,  30,  32,  52,  53,  54},
+      { 15,  16,  31,  33,  54,  55},
+      { 16,  17,  32,  34,  55,  56},
+      { 17,  33,  35,  56,  57,  58},
+      { 17,  18,  34,  36,  58,  59},
+      {  7,  18,  19,  35,  59,  60},
+      { 19,  38,  60,  61,  62,  90},
+      { 19,  20,  37,  39,  62,  63},
+      { 20,  21,  38,  40,  63,  64},
+      { 21,  22,  39,  41,  64,  65},  // 40
+      { 22,  40,  42,  65,  66,  67},
+      { 22,  23,  41,  43,  67,  68},
+      { 23,  24,  42,  44,  68,  69},
+      { 24,  25,  43,  45,  69,  70},
+      { 25,  44,  46,  70,  71,  72},
+      { 25,  26,  45,  47,  72,  73},
+      { 26,  27,  46,  48,  73,  74},
+      { 27,  28,  47,  49,  74,  75},
+      { 28,  48,  50,  75,  76,  77},
+      { 28,  29,  49,  51,  77,  78},  // 50
+      { 29,  30,  50,  52,  78,  79},
+      { 30,  31,  51,  53,  79,  80},
+      { 31,  52,  54,  80,  81,  82},
+      { 31,  32,  53,  55,  82,  83},
+      { 32,  33,  54,  56,  83,  84},
+      { 33,  34,  55,  57,  84,  85},
+      { 34,  56,  58,  85,  86,  87},
+      { 34,  35,  57,  59,  87,  88},
+      { 35,  36,  58,  60,  88,  89},
+      { 19,  36,  37,  59,  89,  90},  // 60
+      { 37,  62,  90,  91,  92, 126},
+      { 37,  38,  61,  63,  92,  93},
+      { 38,  39,  62,  64,  93,  94},
+      { 39,  40,  63,  65,  94,  95},
+      { 40,  41,  64,  66,  95,  96},
+      { 41,  65,  67,  96,  97,  98},
+      { 41,  42,  66,  68,  98,  99},
+      { 42,  43,  67,  69,  99, 100},
+      { 43,  44,  68,  70, 100, 101},
+      { 44,  45,  69,  71, 101, 102},  // 70
+      { 45,  70,  72, 102, 103, 104},
+      { 45,  46,  71,  73, 104, 105},
+      { 46,  47,  72,  74, 105, 106},
+      { 47,  48,  73,  75, 106, 107},
+      { 48,  49,  74,  76, 107, 108},
+      { 49,  75,  77, 108, 109, 110},
+      { 49,  50,  76,  78, 110, 111},
+      { 50,  51,  77,  79, 111, 112},
+      { 51,  52,  78,  80, 112, 113},
+      { 52,  53,  79,  81, 113, 114},  // 80
+      { 53,  80,  82, 114, 115, 116},
+      { 53,  54,  81,  83, 116, 117},
+      { 54,  55,  82,  84, 117, 118},
+      { 55,  56,  83,  85, 118, 119},
+      { 56,  57,  84,  86, 119, 120},
+      { 57,  85,  87, 120, 121, 122},
+      { 57,  58,  86,  88, 122, 123},
+      { 58,  59,  87,  89, 123, 124},
+      { 59,  60,  88,  90, 124, 125},
+      { 37,  60,  61,  89, 125, 126},  // 90
+      { 61,  92, 126,  -1,  -1,  -1},
+      { 61,  62,  91,  93,  -1,  -1},
+      { 62,  63,  92,  94,  -1,  -1},
+      { 63,  64,  93,  95,  -1,  -1},
+      { 64,  65,  94,  96,  -1,  -1},
+      { 65,  66,  95,  97,  -1,  -1},
+      { 66,  96,  98,  -1,  -1,  -1},
+      { 66,  67,  97,  99,  -1,  -1},
+      { 67,  68,  98, 100,  -1,  -1},
+      { 68,  69,  99, 101,  -1,  -1},  // 100
+      { 69,  70, 100, 102,  -1,  -1},
+      { 70,  71, 101, 103,  -1,  -1},
+      { 71, 102, 104,  -1,  -1,  -1},
+      { 71,  72, 103, 105,  -1,  -1},
+      { 72,  73, 104, 106,  -1,  -1},
+      { 73,  74, 105, 107,  -1,  -1},
+      { 74,  75, 106, 108,  -1,  -1},
+      { 75,  76, 107, 109,  -1,  -1},
+      { 76, 108, 110,  -1,  -1,  -1},
+      { 76,  77, 109, 111,  -1,  -1},  // 110
+      { 77,  78, 110, 112,  -1,  -1},
+      { 78,  79, 111, 113,  -1,  -1},
+      { 79,  80, 112, 114,  -1,  -1},
+      { 80,  81, 113, 115,  -1,  -1},
+      { 81, 114, 116,  -1,  -1,  -1},
+      { 81,  82, 115, 117,  -1,  -1},
+      { 82,  83, 116, 118,  -1,  -1},
+      { 83,  84, 117, 119,  -1,  -1},
+      { 84,  85, 118, 120,  -1,  -1},
+      { 85,  86, 119, 121,  -1,  -1},  // 120
+      { 86, 120, 122,  -1,  -1,  -1},
+      { 86,  87, 121, 123,  -1,  -1},
+      { 87,  88, 122, 124,  -1,  -1},
+      { 88,  89, 123, 125,  -1,  -1},
+      { 89,  90, 124, 126,  -1,  -1},
+      { 61,  90,  91, 125,  -1,  -1}   // 126
+  };
+
+  for (Int_t i=0; i<127; i++)
+      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                              nn[i][3], nn[i][4], nn[i][5]);
+
+  InitOuterRing();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the geometry information of CT1 and fill this information
+//  into the pixel objects.
+//
+void MGeomCamCT1::CreateCam()
+{
+    //
+    // fill the geometry class with the coordinates of the CT1 camera
+    //
+    *fLog << inf << " Create CT1 geometry " << endl;
+
+    //
+    // this algorithm is from Martin Kestel originally
+    // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
+   
+    const Float_t diameter = 21;    // units are mm
+    const Float_t kS32  = sqrt(3)/2;
+
+    //
+    //  add the first pixel to the list
+    //
+    Int_t pixnum = 0;
+
+    (*this)[pixnum++].Set(0, 0, diameter);
+
+    for (Int_t ring=1; ring<7; ring++)
+    {
+        //
+        // calc. coords for this ring counting from the
+        // starting number to the ending number
+        //
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring-i*0.5)*diameter,
+                                  i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring*0.5-i)*diameter,
+                                  ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
+                                  (ring-i)*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((0.5*i-ring)*diameter,
+                                  -i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((i-ring*0.5)*diameter,
+                                  -ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring+i)*0.5*diameter,
+                                  (-ring+i)*kS32*diameter,
+                                  diameter);
+    }
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamCT1.h	(revision 1638)
@@ -0,0 +1,23 @@
+#ifndef MARS_MGeomCamCT1
+#define MARS_MGeomCamCT1
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamCT1 : public MGeomCam
+{
+private:
+
+    void CreateCam();
+    void CreateNN();
+
+public:
+
+    MGeomCamCT1(const char *name=NULL);
+
+    ClassDef(MGeomCamCT1, 1)		// Geometry class for the CT1 camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.cc	(revision 1638)
@@ -0,0 +1,900 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamMagic
+//
+// This class stores the geometry information of the Magic camera.
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomCamMagic.h"
+
+#include "TCanvas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamMagic);
+
+// --------------------------------------------------------------------------
+//
+//  Magic camera has 577 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamMagic::MGeomCamMagic(const char *name)
+    : MGeomCam(577, 17, name, "Geometry information of Magic Camera")
+{
+    CreateCam();
+    CreateNN();
+    CalcMaxRadius();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the geometry information from a table into the pixel objects.
+//
+void MGeomCamMagic::CreateCam()
+{
+    //
+    //   fill the geometry class with the coordinates of the MAGIC camera
+    //
+    *fLog << inf << " Creating Magic geometry " << endl ;
+
+    //
+    //   here define the hardwire things of the magic telescope
+    //
+    const Float_t xtemp[577] = {
+        +000.000,   30.000,   15.000,  -15.000,  -30.000,  -15.000,   15.000,   60.000,  //   0
+        +045.000,   30.000,    0.000,  -30.000,  -45.000,  -60.000,  -45.000,  -30.000,  //   8
+        +000.000,   30.000,   45.000,   90.000,   75.000,   60.000,   45.000,   15.000,  //  16
+        -015.000,  -45.000,  -60.000,  -75.000,  -90.000,  -75.000,  -60.000,  -45.000,  //  24
+        -015.000,   15.000,   45.000,   60.000,   75.000,  120.000,  105.000,   90.000,  //  32
+        +075.000,   60.000,   30.000,    0.000,  -30.000,  -60.000,  -75.000,  -90.000,  //  40
+        -105.000, -120.000, -105.000,  -90.000,  -75.000,  -60.000,  -30.000,    0.000,  //  48
+        +030.000,   60.000,   75.000,   90.000,  105.000,  150.000,  135.000,  120.000,  //  56
+        +105.000,   90.000,   75.000,   45.000,   15.000,  -15.000,  -45.000,  -75.000,  //  64
+        -090.000, -105.000, -120.000, -135.000, -150.000, -135.000, -120.000, -105.000,  //  72
+        -090.000,  -75.000,  -45.000,  -15.000,   15.000,   45.000,   75.000,   90.000,  //  80
+        +105.000,  120.000,  135.000,  180.000,  165.000,  150.000,  135.000,  120.000,  //  88
+        +105.000,   90.000,   60.000,   30.000,    0.000,  -30.000,  -60.000,  -90.000,  //  96
+        -105.000, -120.000, -135.000, -150.000, -165.000, -180.000, -165.000, -150.000,  // 104
+        -135.000, -120.000, -105.000,  -90.000,  -60.000,  -30.000,    0.000,   30.000,  // 112
+        +060.000,   90.000,  105.000,  120.000,  135.000,  150.000,  165.000,  210.000,  // 120
+        +195.000,  180.000,  165.000,  150.000,  135.000,  120.000,  105.000,   75.000,  // 128
+        +045.000,   15.000,  -15.000,  -45.000,  -75.000, -105.000, -120.000, -135.000,  // 136
+        -150.000, -165.000, -180.000, -195.000, -210.000, -195.000, -180.000, -165.000,  // 144
+        -150.000, -135.000, -120.000, -105.000,  -75.000,  -45.000,  -15.000,   15.000,  // 152
+        +045.000,   75.000,  105.000,  120.000,  135.000,  150.000,  165.000,  180.000,  // 160
+        +195.000,  240.000,  225.000,  210.000,  195.000,  180.000,  165.000,  150.000,  // 168
+        +135.000,  120.000,   90.000,   60.000,   30.000,    0.000,  -30.000,  -60.000,  // 176
+        -090.000, -120.000, -135.000, -150.000, -165.000, -180.000, -195.000, -210.000,  // 184
+        -225.000, -240.000, -225.000, -210.000, -195.000, -180.000, -165.000, -150.000,  // 192
+        -135.000, -120.000,  -90.000,  -60.000,  -30.000,    0.000,   30.000,   60.000,  // 200
+        +090.000,  120.000,  135.000,  150.000,  165.000,  180.000,  195.000,  210.000,  // 208
+        +225.000,  270.000,  255.000,  240.000,  225.000,  210.000,  195.000,  180.000,  // 216
+        +165.000,  150.000,  135.000,  105.000,   75.000,   45.000,   15.000,  -15.000,  // 224
+        -045.000,  -75.000, -105.000, -135.000, -150.000, -165.000, -180.000, -195.000,  // 232
+        -210.000, -225.000, -240.000, -255.000, -270.000, -255.000, -240.000, -225.000,  // 240
+        -210.000, -195.000, -180.000, -165.000, -150.000, -135.000, -105.000,  -75.000,  // 248
+        -045.000,  -15.000,   15.000,   45.000,   75.000,  105.000,  135.000,  150.000,  // 256
+        +165.000,  180.000,  195.000,  210.000,  225.000,  240.000,  255.000,  300.000,  // 264
+        +285.000,  270.000,  255.000,  240.000,  225.000,  210.000,  195.000,  180.000,  // 272
+        +165.000,  150.000,  120.000,   90.000,   60.000,   30.000,    0.000,  -30.000,  // 280
+        -060.000,  -90.000, -120.000, -150.000, -165.000, -180.000, -195.000, -210.000,  // 288
+        -225.000, -240.000, -255.000, -270.000, -285.000, -300.000, -285.000, -270.000,  // 296
+        -255.000, -240.000, -225.000, -210.000, -195.000, -180.000, -165.000, -150.000,  // 304
+        -120.000,  -90.000,  -60.000,  -30.000,    0.000,   30.000,   60.000,   90.000,  // 312
+        +120.000,  150.000,  165.000,  180.000,  195.000,  210.000,  225.000,  240.000,  // 320
+        +255.000,  270.000,  285.000,  330.000,  315.000,  300.000,  285.000,  270.000,  // 328
+        +255.000,  240.000,  225.000,  210.000,  195.000,  180.000,  165.000,  135.000,  // 336
+        +105.000,   75.000,   45.000,   15.000,  -15.000,  -45.000,  -75.000, -105.000,  // 344
+        -135.000, -165.000, -180.000, -195.000, -210.000, -225.000, -240.000, -255.000,  // 352
+        -270.000, -285.000, -300.000, -315.000, -330.000, -315.000, -300.000, -285.000,  // 360
+        -270.000, -255.000, -240.000, -225.000, -210.000, -195.000, -180.000, -165.000,  // 368
+        -135.000, -105.000,  -75.000,  -45.000,  -15.000,   15.000,   45.000,   75.000,  // 376
+        +105.000,  135.000,  165.000,  180.000,  195.000,  210.000,  225.000,  240.000,  // 384
+        +255.000,  270.000,  285.000,  300.000,  315.000,  360.000,  330.000,  300.000,  // 392
+        +270.000,  240.000,  210.000,  150.000,   90.000,   30.000,  -30.000,  -90.000,  // 400
+        -150.000, -210.000, -240.000, -270.000, -300.000, -330.000, -360.000, -360.000,  // 408
+        -330.000, -300.000, -270.000, -240.000, -210.000, -150.000,  -90.000,  -30.000,  // 416
+        +030.000,   90.000,  150.000,  210.000,  240.000,  270.000,  300.000,  330.000,  // 424
+        +360.000,  420.000,  390.000,  360.000,  330.000,  300.000,  270.000,  240.000,  // 432
+        +180.000,  120.000,   60.000,    0.000,  -60.000, -120.000, -180.000, -240.000,  // 440
+        -270.000, -300.000, -330.000, -360.000, -390.000, -420.000, -420.000, -390.000,  // 448
+        -360.000, -330.000, -300.000, -270.000, -240.000, -180.000, -120.000,  -60.000,  // 456
+        +000.000,   60.000,  120.000,  180.000,  240.000,  270.000,  300.000,  330.000,  // 464
+        +360.000,  390.000,  420.000,  480.000,  450.000,  420.000,  390.000,  360.000,  // 472
+        +330.000,  300.000,  270.000,  210.000,  150.000,   90.000,   30.000,  -30.000,  // 480
+        -090.000, -150.000, -210.000, -270.000, -300.000, -330.000, -360.000, -390.000,  // 488
+        -420.000, -450.000, -480.000, -480.000, -450.000, -420.000, -390.000, -360.000,  // 496
+        -330.000, -300.000, -270.000, -210.000, -150.000,  -90.000,  -30.000,   30.000,  // 504
+        +090.000,  150.000,  210.000,  270.000,  300.000,  330.000,  360.000,  390.000,  // 512
+        +420.000,  450.000,  480.000,  540.000,  510.000,  480.000,  450.000,  420.000,  // 520
+        +390.000,  360.000,  330.000,  300.000,  240.000,  180.000,  120.000,   60.000,  // 528
+        +000.000,  -60.000, -120.000, -180.000, -240.000, -300.000, -330.000, -360.000,  // 536
+        -390.000, -420.000, -450.000, -480.000, -510.000, -540.000, -540.000, -510.000,  // 544
+        -480.000, -450.000, -420.000, -390.000, -360.000, -330.000, -300.000, -240.000,  // 552
+        -180.000, -120.000,  -60.000,    0.000,   60.000,  120.000,  180.000,  240.000,  // 560
+        +300.000,  330.000,  360.000,  390.000,  420.000,  450.000,  480.000,  510.000,  // 568
+        +540.000                                                                         // 576
+    };
+
+    const Float_t ytemp[577] = {
+        +000.000,    0.000,   25.981,   25.981,    0.000,  -25.981,  -25.981,    0.000,  //   0
+        +025.981,   51.961,   51.961,   51.961,   25.981,    0.000,  -25.981,  -51.961,  //   8
+        -051.961,  -51.961,  -25.981,    0.000,   25.981,   51.961,   77.942,   77.942,  //  16
+        +077.942,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  -77.942,  //  24
+        -077.942,  -77.942,  -77.942,  -51.961,  -25.981,    0.000,   25.981,   51.961,  //  32
+        +077.942,  103.923,  103.923,  103.923,  103.923,  103.923,   77.942,   51.961,  //  40
+        +025.981,    0.000,  -25.981,  -51.961,  -77.942, -103.923, -103.923, -103.923,  //  48
+        -103.923, -103.923,  -77.942,  -51.961,  -25.981,    0.000,   25.981,   51.961,  //  56
+        +077.942,  103.923,  129.904,  129.904,  129.904,  129.904,  129.904,  129.904,  //  64
+        +103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  -77.942,  //  72
+        -103.923, -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, -103.923,  //  80
+        -077.942,  -51.961,  -25.981,    0.000,   25.981,   51.961,   77.942,  103.923,  //  88
+        +129.904,  155.885,  155.885,  155.885,  155.885,  155.885,  155.885,  155.885,  //  96
+        +129.904,  103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  // 104
+        -077.942, -103.923, -129.904, -155.885, -155.885, -155.885, -155.885, -155.885,  // 112
+        -155.885, -155.885, -129.904, -103.923,  -77.942,  -51.961,  -25.981,    0.000,  // 120
+        +025.981,   51.961,   77.942,  103.923,  129.904,  155.885,  181.865,  181.865,  // 128
+        +181.865,  181.865,  181.865,  181.865,  181.865,  181.865,  155.885,  129.904,  // 136
+        +103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  -77.942,  // 144
+        -103.923, -129.904, -155.885, -181.865, -181.865, -181.865, -181.865, -181.865,  // 152
+        -181.865, -181.865, -181.865, -155.885, -129.904, -103.923,  -77.942,  -51.961,  // 160
+        -025.981,    0.000,   25.981,   51.961,   77.942,  103.923,  129.904,  155.885,  // 168
+        +181.865,  207.846,  207.846,  207.846,  207.846,  207.846,  207.846,  207.846,  // 176
+        +207.846,  207.846,  181.865,  155.885,  129.904,  103.923,   77.942,   51.961,  // 184
+        +025.981,    0.000,  -25.981,  -51.961,  -77.942, -103.923, -129.904, -155.885,  // 192
+        -181.865, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846,  // 200
+        -207.846, -207.846, -181.865, -155.885, -129.904, -103.923,  -77.942,  -51.961,  // 208
+        -025.981,    0.000,   25.981,   51.961,   77.942,  103.923,  129.904,  155.885,  // 216
+        +181.865,  207.846,  233.827,  233.827,  233.827,  233.827,  233.827,  233.827,  // 224
+        +233.827,  233.827,  233.827,  233.827,  207.846,  181.865,  155.885,  129.904,  // 232
+        +103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  -77.942,  // 240
+        -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -233.827, -233.827,  // 248
+        -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -207.846,  // 256
+        -181.865, -155.885, -129.904, -103.923,  -77.942,  -51.961,  -25.981,    0.000,  // 264
+        +025.981,   51.961,   77.942,  103.923,  129.904,  155.885,  181.865,  207.846,  // 272
+        +233.827,  259.808,  259.808,  259.808,  259.808,  259.808,  259.808,  259.808,  // 280
+        +259.808,  259.808,  259.808,  259.808,  233.827,  207.846,  181.865,  155.885,  // 288
+        +129.904,  103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  // 296
+        -077.942, -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808,  // 304
+        -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808,  // 312
+        -259.808, -259.808, -233.827, -207.846, -181.865, -155.885, -129.904, -103.923,  // 320
+        -077.942,  -51.961,  -25.981,    0.000,   25.981,   51.961,   77.942,  103.923,  // 328
+        +129.904,  155.885,  181.865,  207.846,  233.827,  259.808,  285.788,  285.788,  // 336
+        +285.788,  285.788,  285.788,  285.788,  285.788,  285.788,  285.788,  285.788,  // 344
+        +285.788,  285.788,  259.808,  233.827,  207.846,  181.865,  155.885,  129.904,  // 352
+        +103.923,   77.942,   51.961,   25.981,    0.000,  -25.981,  -51.961,  -77.942,  // 360
+        -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788,  // 368
+        -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788,  // 376
+        -285.788, -285.788, -285.788, -259.808, -233.827, -207.846, -181.865, -155.885,  // 384
+        -129.904, -103.923,  -77.942,  -51.961,  -25.981,   34.641,   86.603,  138.564,  // 392
+        +190.526,  242.487,  294.449,  329.090,  329.090,  329.090,  329.090,  329.090,  // 400
+        +329.090,  294.449,  242.487,  190.526,  138.564,   86.603,   34.641,  -34.641,  // 408
+        -086.603, -138.564, -190.526, -242.487, -294.449, -329.090, -329.090, -329.090,  // 416
+        -329.090, -329.090, -329.090, -294.449, -242.487, -190.526, -138.564,  -86.603,  // 424
+        -034.641,   34.641,   86.603,  138.564,  190.526,  242.487,  294.449,  346.410,  // 432
+        +381.051,  381.051,  381.051,  381.051,  381.051,  381.051,  381.051,  346.410,  // 440
+        +294.449,  242.487,  190.526,  138.564,   86.603,   34.641,  -34.641,  -86.603,  // 448
+        -138.564, -190.526, -242.487, -294.449, -346.410, -381.051, -381.051, -381.051,  // 456
+        -381.051, -381.051, -381.051, -381.051, -346.410, -294.449, -242.487, -190.526,  // 464
+        -138.564,  -86.603,  -34.641,   34.641,   86.603,  138.564,  190.526,  242.487,  // 472
+        +294.449,  346.410,  398.372,  433.013,  433.013,  433.013,  433.013,  433.013,  // 480
+        +433.013,  433.013,  433.013,  398.372,  346.410,  294.449,  242.487,  190.526,  // 488
+        +138.564,   86.603,   34.641,  -34.641,  -86.603, -138.564, -190.526, -242.487,  // 496
+        -294.449, -346.410, -398.372, -433.013, -433.013, -433.013, -433.013, -433.013,  // 504
+        -433.013, -433.013, -433.013, -398.372, -346.410, -294.449, -242.487, -190.526,  // 512
+        -138.564,  -86.603,  -34.641,   34.641,   86.603,  138.564,  190.526,  242.487,  // 520
+        +294.449,  346.410,  398.372,  450.333,  484.974,  484.974,  484.974,  484.974,  // 528
+        +484.974,  484.974,  484.974,  484.974,  484.974,  450.333,  398.372,  346.410,  // 536
+        +294.449,  242.487,  190.526,  138.564,   86.603,   34.641,  -34.641,  -86.603,  // 544
+        -138.564, -190.526, -242.487, -294.449, -346.410, -398.372, -450.333, -484.974,  // 552
+        -484.974, -484.974, -484.974, -484.974, -484.974, -484.974, -484.974, -484.974,  // 560
+        -450.333, -398.372, -346.410, -294.449, -242.487, -190.526, -138.564,  -86.603,  // 568
+        -034.641                                                                         // 576
+    };
+
+    const Float_t rtemp[577] = {
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   0
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   8
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  16
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  24
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  32
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  40
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  48
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  56
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  64
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  72
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  80
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  88
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  96
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 104
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 112
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 120
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 128
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 136
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 144
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 152
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 160
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 168
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 176
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 184
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 192
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 200
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 208
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 216
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 224
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 232
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 240
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 248
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 256
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 264
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 272
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 280
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 288
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 296
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 304
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 312
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 320
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 328
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 336
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 344
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 352
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 360
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 368
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 376
+        30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 384
+        30.00, 30.00, 30.00, 30.00, 30.00, 60.00, 60.00, 60.00,  // 392
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 400
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 408
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 416
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 424
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 432
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 440
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 448
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 456
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 464
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 472
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 480
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 488
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 496
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 504
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 512
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 520
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 528
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 536
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 544
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 552
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 560
+        60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 568
+        60.00  };                                                // 576
+
+    //
+    //   fill the pixels list with this data
+    //
+
+    for (UInt_t i=0; i<GetNumPixels(); i++)
+        (*this)[i].Set(xtemp[i], ytemp[i], rtemp[i]) ;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the next neighbor information from a table into the pixel
+//  objects.
+//
+void MGeomCamMagic::CreateNN()
+{
+    const Short_t nn[577][6] = {         // Neighbors of #
+        {   1,   2,   3,   4,   5,   6}, // 0
+        {   0,   2,   6,   7,   8,  18},
+        {   0,   1,   3,   8,   9,  10},
+        {   0,   2,   4,  10,  11,  12},
+        {   0,   3,   5,  12,  13,  14},
+        {   0,   4,   6,  14,  15,  16},
+        {   0,   1,   5,  16,  17,  18},
+        {   1,   8,  18,  19,  20,  36},
+        {   1,   2,   7,   9,  20,  21},
+        {   2,   8,  10,  21,  22,  23},
+        {   2,   3,   9,  11,  23,  24},
+        {   3,  10,  12,  24,  25,  26},
+        {   3,   4,  11,  13,  26,  27},
+        {   4,  12,  14,  27,  28,  29},
+        {   4,   5,  13,  15,  29,  30},
+        {   5,  14,  16,  30,  31,  32},
+        {   5,   6,  15,  17,  32,  33},
+        {   6,  16,  18,  33,  34,  35},
+        {   1,   6,   7,  17,  35,  36},
+        {   7,  20,  36,  37,  38,  60},
+        {   7,   8,  19,  21,  38,  39}, // 20
+        {   8,   9,  20,  22,  39,  40},
+        {   9,  21,  23,  40,  41,  42},
+        {   9,  10,  22,  24,  42,  43},
+        {  10,  11,  23,  25,  43,  44},
+        {  11,  24,  26,  44,  45,  46},
+        {  11,  12,  25,  27,  46,  47},
+        {  12,  13,  26,  28,  47,  48},
+        {  13,  27,  29,  48,  49,  50},
+        {  13,  14,  28,  30,  50,  51},
+        {  14,  15,  29,  31,  51,  52},
+        {  15,  30,  32,  52,  53,  54},
+        {  15,  16,  31,  33,  54,  55},
+        {  16,  17,  32,  34,  55,  56},
+        {  17,  33,  35,  56,  57,  58},
+        {  17,  18,  34,  36,  58,  59},
+        {   7,  18,  19,  35,  59,  60},
+        {  19,  38,  60,  61,  62,  90},
+        {  19,  20,  37,  39,  62,  63},
+        {  20,  21,  38,  40,  63,  64},
+        {  21,  22,  39,  41,  64,  65}, // 40
+        {  22,  40,  42,  65,  66,  67},
+        {  22,  23,  41,  43,  67,  68},
+        {  23,  24,  42,  44,  68,  69},
+        {  24,  25,  43,  45,  69,  70},
+        {  25,  44,  46,  70,  71,  72},
+        {  25,  26,  45,  47,  72,  73},
+        {  26,  27,  46,  48,  73,  74},
+        {  27,  28,  47,  49,  74,  75},
+        {  28,  48,  50,  75,  76,  77},
+        {  28,  29,  49,  51,  77,  78},
+        {  29,  30,  50,  52,  78,  79},
+        {  30,  31,  51,  53,  79,  80},
+        {  31,  52,  54,  80,  81,  82},
+        {  31,  32,  53,  55,  82,  83},
+        {  32,  33,  54,  56,  83,  84},
+        {  33,  34,  55,  57,  84,  85},
+        {  34,  56,  58,  85,  86,  87},
+        {  34,  35,  57,  59,  87,  88},
+        {  35,  36,  58,  60,  88,  89},
+        {  19,  36,  37,  59,  89,  90}, // 60
+        {  37,  62,  90,  91,  92, 126},
+        {  37,  38,  61,  63,  92,  93},
+        {  38,  39,  62,  64,  93,  94},
+        {  39,  40,  63,  65,  94,  95},
+        {  40,  41,  64,  66,  95,  96},
+        {  41,  65,  67,  96,  97,  98},
+        {  41,  42,  66,  68,  98,  99},
+        {  42,  43,  67,  69,  99, 100},
+        {  43,  44,  68,  70, 100, 101},
+        {  44,  45,  69,  71, 101, 102},
+        {  45,  70,  72, 102, 103, 104},
+        {  45,  46,  71,  73, 104, 105},
+        {  46,  47,  72,  74, 105, 106},
+        {  47,  48,  73,  75, 106, 107},
+        {  48,  49,  74,  76, 107, 108},
+        {  49,  75,  77, 108, 109, 110},
+        {  49,  50,  76,  78, 110, 111},
+        {  50,  51,  77,  79, 111, 112},
+        {  51,  52,  78,  80, 112, 113},
+        {  52,  53,  79,  81, 113, 114}, // 80
+        {  53,  80,  82, 114, 115, 116},
+        {  53,  54,  81,  83, 116, 117},
+        {  54,  55,  82,  84, 117, 118},
+        {  55,  56,  83,  85, 118, 119},
+        {  56,  57,  84,  86, 119, 120},
+        {  57,  85,  87, 120, 121, 122},
+        {  57,  58,  86,  88, 122, 123},
+        {  58,  59,  87,  89, 123, 124},
+        {  59,  60,  88,  90, 124, 125},
+        {  37,  60,  61,  89, 125, 126},
+        {  61,  92, 126, 127, 128, 168},
+        {  61,  62,  91,  93, 128, 129},
+        {  62,  63,  92,  94, 129, 130},
+        {  63,  64,  93,  95, 130, 131},
+        {  64,  65,  94,  96, 131, 132},
+        {  65,  66,  95,  97, 132, 133},
+        {  66,  96,  98, 133, 134, 135},
+        {  66,  67,  97,  99, 135, 136},
+        {  67,  68,  98, 100, 136, 137},
+        {  68,  69,  99, 101, 137, 138}, // 100
+        {  69,  70, 100, 102, 138, 139},
+        {  70,  71, 101, 103, 139, 140},
+        {  71, 102, 104, 140, 141, 142},
+        {  71,  72, 103, 105, 142, 143},
+        {  72,  73, 104, 106, 143, 144},
+        {  73,  74, 105, 107, 144, 145},
+        {  74,  75, 106, 108, 145, 146},
+        {  75,  76, 107, 109, 146, 147},
+        {  76, 108, 110, 147, 148, 149},
+        {  76,  77, 109, 111, 149, 150},
+        {  77,  78, 110, 112, 150, 151},
+        {  78,  79, 111, 113, 151, 152},
+        {  79,  80, 112, 114, 152, 153},
+        {  80,  81, 113, 115, 153, 154},
+        {  81, 114, 116, 154, 155, 156},
+        {  81,  82, 115, 117, 156, 157},
+        {  82,  83, 116, 118, 157, 158},
+        {  83,  84, 117, 119, 158, 159},
+        {  84,  85, 118, 120, 159, 160},
+        {  85,  86, 119, 121, 160, 161}, // 120
+        {  86, 120, 122, 161, 162, 163},
+        {  86,  87, 121, 123, 163, 164},
+        {  87,  88, 122, 124, 164, 165},
+        {  88,  89, 123, 125, 165, 166},
+        {  89,  90, 124, 126, 166, 167},
+        {  61,  90,  91, 125, 167, 168},
+        {  91, 128, 168, 169, 170, 216},
+        {  91,  92, 127, 129, 170, 171},
+        {  92,  93, 128, 130, 171, 172},
+        {  93,  94, 129, 131, 172, 173},
+        {  94,  95, 130, 132, 173, 174},
+        {  95,  96, 131, 133, 174, 175},
+        {  96,  97, 132, 134, 175, 176},
+        {  97, 133, 135, 176, 177, 178},
+        {  97,  98, 134, 136, 178, 179},
+        {  98,  99, 135, 137, 179, 180},
+        {  99, 100, 136, 138, 180, 181},
+        { 100, 101, 137, 139, 181, 182},
+        { 101, 102, 138, 140, 182, 183},
+        { 102, 103, 139, 141, 183, 184}, // 140
+        { 103, 140, 142, 184, 185, 186},
+        { 103, 104, 141, 143, 186, 187},
+        { 104, 105, 142, 144, 187, 188},
+        { 105, 106, 143, 145, 188, 189},
+        { 106, 107, 144, 146, 189, 190},
+        { 107, 108, 145, 147, 190, 191},
+        { 108, 109, 146, 148, 191, 192},
+        { 109, 147, 149, 192, 193, 194},
+        { 109, 110, 148, 150, 194, 195},
+        { 110, 111, 149, 151, 195, 196},
+        { 111, 112, 150, 152, 196, 197},
+        { 112, 113, 151, 153, 197, 198},
+        { 113, 114, 152, 154, 198, 199},
+        { 114, 115, 153, 155, 199, 200},
+        { 115, 154, 156, 200, 201, 202},
+        { 115, 116, 155, 157, 202, 203},
+        { 116, 117, 156, 158, 203, 204},
+        { 117, 118, 157, 159, 204, 205},
+        { 118, 119, 158, 160, 205, 206},
+        { 119, 120, 159, 161, 206, 207}, // 160
+        { 120, 121, 160, 162, 207, 208},
+        { 121, 161, 163, 208, 209, 210},
+        { 121, 122, 162, 164, 210, 211},
+        { 122, 123, 163, 165, 211, 212},
+        { 123, 124, 164, 166, 212, 213},
+        { 124, 125, 165, 167, 213, 214},
+        { 125, 126, 166, 168, 214, 215},
+        {  91, 126, 127, 167, 215, 216},
+        { 127, 170, 216, 217, 218, 270},
+        { 127, 128, 169, 171, 218, 219},
+        { 128, 129, 170, 172, 219, 220},
+        { 129, 130, 171, 173, 220, 221},
+        { 130, 131, 172, 174, 221, 222},
+        { 131, 132, 173, 175, 222, 223},
+        { 132, 133, 174, 176, 223, 224},
+        { 133, 134, 175, 177, 224, 225},
+        { 134, 176, 178, 225, 226, 227},
+        { 134, 135, 177, 179, 227, 228},
+        { 135, 136, 178, 180, 228, 229},
+        { 136, 137, 179, 181, 229, 230}, // 180
+        { 137, 138, 180, 182, 230, 231},
+        { 138, 139, 181, 183, 231, 232},
+        { 139, 140, 182, 184, 232, 233},
+        { 140, 141, 183, 185, 233, 234},
+        { 141, 184, 186, 234, 235, 236},
+        { 141, 142, 185, 187, 236, 237},
+        { 142, 143, 186, 188, 237, 238},
+        { 143, 144, 187, 189, 238, 239},
+        { 144, 145, 188, 190, 239, 240},
+        { 145, 146, 189, 191, 240, 241},
+        { 146, 147, 190, 192, 241, 242},
+        { 147, 148, 191, 193, 242, 243},
+        { 148, 192, 194, 243, 244, 245},
+        { 148, 149, 193, 195, 245, 246},
+        { 149, 150, 194, 196, 246, 247},
+        { 150, 151, 195, 197, 247, 248},
+        { 151, 152, 196, 198, 248, 249},
+        { 152, 153, 197, 199, 249, 250},
+        { 153, 154, 198, 200, 250, 251},
+        { 154, 155, 199, 201, 251, 252}, // 200
+        { 155, 200, 202, 252, 253, 254},
+        { 155, 156, 201, 203, 254, 255},
+        { 156, 157, 202, 204, 255, 256},
+        { 157, 158, 203, 205, 256, 257},
+        { 158, 159, 204, 206, 257, 258},
+        { 159, 160, 205, 207, 258, 259},
+        { 160, 161, 206, 208, 259, 260},
+        { 161, 162, 207, 209, 260, 261},
+        { 162, 208, 210, 261, 262, 263},
+        { 162, 163, 209, 211, 263, 264},
+        { 163, 164, 210, 212, 264, 265},
+        { 164, 165, 211, 213, 265, 266},
+        { 165, 166, 212, 214, 266, 267},
+        { 166, 167, 213, 215, 267, 268},
+        { 167, 168, 214, 216, 268, 269},
+        { 127, 168, 169, 215, 269, 270},
+        { 169, 218, 270, 271, 272, 330},
+        { 169, 170, 217, 219, 272, 273},
+        { 170, 171, 218, 220, 273, 274},
+        { 171, 172, 219, 221, 274, 275}, // 220
+        { 172, 173, 220, 222, 275, 276},
+        { 173, 174, 221, 223, 276, 277},
+        { 174, 175, 222, 224, 277, 278},
+        { 175, 176, 223, 225, 278, 279},
+        { 176, 177, 224, 226, 279, 280},
+        { 177, 225, 227, 280, 281, 282},
+        { 177, 178, 226, 228, 282, 283},
+        { 178, 179, 227, 229, 283, 284},
+        { 179, 180, 228, 230, 284, 285},
+        { 180, 181, 229, 231, 285, 286},
+        { 181, 182, 230, 232, 286, 287},
+        { 182, 183, 231, 233, 287, 288},
+        { 183, 184, 232, 234, 288, 289},
+        { 184, 185, 233, 235, 289, 290},
+        { 185, 234, 236, 290, 291, 292},
+        { 185, 186, 235, 237, 292, 293},
+        { 186, 187, 236, 238, 293, 294},
+        { 187, 188, 237, 239, 294, 295},
+        { 188, 189, 238, 240, 295, 296},
+        { 189, 190, 239, 241, 296, 297}, // 240
+        { 190, 191, 240, 242, 297, 298},
+        { 191, 192, 241, 243, 298, 299},
+        { 192, 193, 242, 244, 299, 300},
+        { 193, 243, 245, 300, 301, 302},
+        { 193, 194, 244, 246, 302, 303},
+        { 194, 195, 245, 247, 303, 304},
+        { 195, 196, 246, 248, 304, 305},
+        { 196, 197, 247, 249, 305, 306},
+        { 197, 198, 248, 250, 306, 307},
+        { 198, 199, 249, 251, 307, 308},
+        { 199, 200, 250, 252, 308, 309},
+        { 200, 201, 251, 253, 309, 310},
+        { 201, 252, 254, 310, 311, 312},
+        { 201, 202, 253, 255, 312, 313},
+        { 202, 203, 254, 256, 313, 314},
+        { 203, 204, 255, 257, 314, 315},
+        { 204, 205, 256, 258, 315, 316},
+        { 205, 206, 257, 259, 316, 317},
+        { 206, 207, 258, 260, 317, 318},
+        { 207, 208, 259, 261, 318, 319}, // 260
+        { 208, 209, 260, 262, 319, 320},
+        { 209, 261, 263, 320, 321, 322},
+        { 209, 210, 262, 264, 322, 323},
+        { 210, 211, 263, 265, 323, 324},
+        { 211, 212, 264, 266, 324, 325},
+        { 212, 213, 265, 267, 325, 326},
+        { 213, 214, 266, 268, 326, 327},
+        { 214, 215, 267, 269, 327, 328},
+        { 215, 216, 268, 270, 328, 329},
+        { 169, 216, 217, 269, 329, 330},
+        { 217, 272, 330, 331, 332, 396},
+        { 217, 218, 271, 273, 332, 333},
+        { 218, 219, 272, 274, 333, 334},
+        { 219, 220, 273, 275, 334, 335},
+        { 220, 221, 274, 276, 335, 336},
+        { 221, 222, 275, 277, 336, 337},
+        { 222, 223, 276, 278, 337, 338},
+        { 223, 224, 277, 279, 338, 339},
+        { 224, 225, 278, 280, 339, 340},
+        { 225, 226, 279, 281, 340, 341}, // 280
+        { 226, 280, 282, 341, 342, 343},
+        { 226, 227, 281, 283, 343, 344},
+        { 227, 228, 282, 284, 344, 345},
+        { 228, 229, 283, 285, 345, 346},
+        { 229, 230, 284, 286, 346, 347},
+        { 230, 231, 285, 287, 347, 348},
+        { 231, 232, 286, 288, 348, 349},
+        { 232, 233, 287, 289, 349, 350},
+        { 233, 234, 288, 290, 350, 351},
+        { 234, 235, 289, 291, 351, 352},
+        { 235, 290, 292, 352, 353, 354},
+        { 235, 236, 291, 293, 354, 355},
+        { 236, 237, 292, 294, 355, 356},
+        { 237, 238, 293, 295, 356, 357},
+        { 238, 239, 294, 296, 357, 358},
+        { 239, 240, 295, 297, 358, 359},
+        { 240, 241, 296, 298, 359, 360},
+        { 241, 242, 297, 299, 360, 361},
+        { 242, 243, 298, 300, 361, 362},
+        { 243, 244, 299, 301, 362, 363}, // 300
+        { 244, 300, 302, 363, 364, 365},
+        { 244, 245, 301, 303, 365, 366},
+        { 245, 246, 302, 304, 366, 367},
+        { 246, 247, 303, 305, 367, 368},
+        { 247, 248, 304, 306, 368, 369},
+        { 248, 249, 305, 307, 369, 370},
+        { 249, 250, 306, 308, 370, 371},
+        { 250, 251, 307, 309, 371, 372},
+        { 251, 252, 308, 310, 372, 373},
+        { 252, 253, 309, 311, 373, 374},
+        { 253, 310, 312, 374, 375, 376},
+        { 253, 254, 311, 313, 376, 377},
+        { 254, 255, 312, 314, 377, 378},
+        { 255, 256, 313, 315, 378, 379},
+        { 256, 257, 314, 316, 379, 380},
+        { 257, 258, 315, 317, 380, 381},
+        { 258, 259, 316, 318, 381, 382},
+        { 259, 260, 317, 319, 382, 383},
+        { 260, 261, 318, 320, 383, 384},
+        { 261, 262, 319, 321, 384, 385}, // 320
+        { 262, 320, 322, 385, 386, 387},
+        { 262, 263, 321, 323, 387, 388},
+        { 263, 264, 322, 324, 388, 389},
+        { 264, 265, 323, 325, 389, 390},
+        { 265, 266, 324, 326, 390, 391},
+        { 266, 267, 325, 327, 391, 392},
+        { 267, 268, 326, 328, 392, 393},
+        { 268, 269, 327, 329, 393, 394},
+        { 269, 270, 328, 330, 394, 395},
+        { 217, 270, 271, 329, 395, 396},
+        { 271, 332, 396, 397, 432,  -1},
+        { 271, 272, 331, 333, 397,  -1},
+        { 272, 273, 332, 334, 398,  -1},
+        { 273, 274, 333, 335, 398,  -1},
+        { 274, 275, 334, 336, 399,  -1},
+        { 275, 276, 335, 337, 399,  -1},
+        { 276, 277, 336, 338, 400,  -1},
+        { 277, 278, 337, 339, 400,  -1},
+        { 278, 279, 338, 340, 401,  -1},
+        { 279, 280, 339, 341, 401,  -1}, // 340
+        { 280, 281, 340, 342, 402,  -1},
+        { 281, 341, 343, 402, 403,  -1},
+        { 281, 282, 342, 344, 403,  -1},
+        { 282, 283, 343, 345, 404,  -1},
+        { 283, 284, 344, 346, 404,  -1},
+        { 284, 285, 345, 347, 405,  -1},
+        { 285, 286, 346, 348, 405,  -1},
+        { 286, 287, 347, 349, 406,  -1},
+        { 287, 288, 348, 350, 406,  -1},
+        { 288, 289, 349, 351, 407,  -1},
+        { 289, 290, 350, 352, 407,  -1},
+        { 290, 291, 351, 353, 408,  -1},
+        { 291, 352, 354, 408, 409,  -1},
+        { 291, 292, 353, 355, 409,  -1},
+        { 292, 293, 354, 356, 410,  -1},
+        { 293, 294, 355, 357, 410,  -1},
+        { 294, 295, 356, 358, 411,  -1},
+        { 295, 296, 357, 359, 411,  -1},
+        { 296, 297, 358, 360, 412,  -1},
+        { 297, 298, 359, 361, 412,  -1}, // 360
+        { 298, 299, 360, 362, 413,  -1},
+        { 299, 300, 361, 363, 413,  -1},
+        { 300, 301, 362, 364, 414,  -1},
+        { 301, 363, 365, 414, 415,  -1},
+        { 301, 302, 364, 366, 415,  -1},
+        { 302, 303, 365, 367, 416,  -1},
+        { 303, 304, 366, 368, 416,  -1},
+        { 304, 305, 367, 369, 417,  -1},
+        { 305, 306, 368, 370, 417,  -1},
+        { 306, 307, 369, 371, 418,  -1},
+        { 307, 308, 370, 372, 418,  -1},
+        { 308, 309, 371, 373, 419,  -1},
+        { 309, 310, 372, 374, 419,  -1},
+        { 310, 311, 373, 375, 420,  -1},
+        { 311, 374, 376, 420, 421,  -1},
+        { 311, 312, 375, 377, 421,  -1},
+        { 312, 313, 376, 378, 422,  -1},
+        { 313, 314, 377, 379, 422,  -1},
+        { 314, 315, 378, 380, 423,  -1},
+        { 315, 316, 379, 381, 423,  -1}, // 380
+        { 316, 317, 380, 382, 424,  -1},
+        { 317, 318, 381, 383, 424,  -1},
+        { 318, 319, 382, 384, 425,  -1},
+        { 319, 320, 383, 385, 425,  -1},
+        { 320, 321, 384, 386, 426,  -1},
+        { 321, 385, 387, 426, 427,  -1},
+        { 321, 322, 386, 388, 427,  -1},
+        { 322, 323, 387, 389, 428,  -1},
+        { 323, 324, 388, 390, 428,  -1},
+        { 324, 325, 389, 391, 429,  -1},
+        { 325, 326, 390, 392, 429,  -1},
+        { 326, 327, 391, 393, 430,  -1},
+        { 327, 328, 392, 394, 430,  -1},
+        { 328, 329, 393, 395, 431,  -1},
+        { 329, 330, 394, 396, 431,  -1},
+        { 271, 330, 331, 395, 432,  -1},
+        { 331, 332, 398, 432, 433, 434},
+        { 333, 334, 397, 399, 434, 435},
+        { 335, 336, 398, 400, 435, 436},
+        { 337, 338, 399, 401, 436, 437}, // 400
+        { 339, 340, 400, 402, 437, 438},
+        { 341, 342, 401, 403, 438, 439},
+        { 342, 343, 402, 404, 440, 441},
+        { 344, 345, 403, 405, 441, 442},
+        { 346, 347, 404, 406, 442, 443},
+        { 348, 349, 405, 407, 443, 444},
+        { 350, 351, 406, 408, 444, 445},
+        { 352, 353, 407, 409, 445, 446},
+        { 353, 354, 408, 410, 447, 448},
+        { 355, 356, 409, 411, 448, 449},
+        { 357, 358, 410, 412, 449, 450},
+        { 359, 360, 411, 413, 450, 451},
+        { 361, 362, 412, 414, 451, 452},
+        { 363, 364, 413, 415, 452, 453},
+        { 364, 365, 414, 416, 454, 455},
+        { 366, 367, 415, 417, 455, 456},
+        { 368, 369, 416, 418, 456, 457},
+        { 370, 371, 417, 419, 457, 458},
+        { 372, 373, 418, 420, 458, 459},
+        { 374, 375, 419, 421, 459, 460}, // 420
+        { 375, 376, 420, 422, 461, 462},
+        { 377, 378, 421, 423, 462, 463},
+        { 379, 380, 422, 424, 463, 464},
+        { 381, 382, 423, 425, 464, 465},
+        { 383, 384, 424, 426, 465, 466},
+        { 385, 386, 425, 427, 466, 467},
+        { 386, 387, 426, 428, 468, 469},
+        { 388, 389, 427, 429, 469, 470},
+        { 390, 391, 428, 430, 470, 471},
+        { 392, 393, 429, 431, 471, 472},
+        { 394, 395, 430, 432, 472, 473},
+        { 331, 396, 397, 431, 473, 474},
+        { 397, 434, 474, 475, 476,  -1},
+        { 397, 398, 433, 435, 476, 477},
+        { 398, 399, 434, 436, 477, 478},
+        { 399, 400, 435, 437, 478, 479},
+        { 400, 401, 436, 438, 479, 480},
+        { 401, 402, 437, 439, 480, 481},
+        { 402, 438, 440, 481, 482,  -1},
+        { 403, 439, 441, 483, 484,  -1}, // 440
+        { 403, 404, 440, 442, 484, 485},
+        { 404, 405, 441, 443, 485, 486},
+        { 405, 406, 442, 444, 486, 487},
+        { 406, 407, 443, 445, 487, 488},
+        { 407, 408, 444, 446, 488, 489},
+        { 408, 445, 447, 489, 490,  -1},
+        { 409, 446, 448, 491, 492,  -1},
+        { 409, 410, 447, 449, 492, 493},
+        { 410, 411, 448, 450, 493, 494},
+        { 411, 412, 449, 451, 494, 495},
+        { 412, 413, 450, 452, 495, 496},
+        { 413, 414, 451, 453, 496, 497},
+        { 414, 452, 454, 497, 498,  -1},
+        { 415, 453, 455, 499, 500,  -1},
+        { 415, 416, 454, 456, 500, 501},
+        { 416, 417, 455, 457, 501, 502},
+        { 417, 418, 456, 458, 502, 503},
+        { 418, 419, 457, 459, 503, 504},
+        { 419, 420, 458, 460, 504, 505},
+        { 420, 459, 461, 505, 506,  -1}, // 460
+        { 421, 460, 462, 507, 508,  -1},
+        { 421, 422, 461, 463, 508, 509},
+        { 422, 423, 462, 464, 509, 510},
+        { 423, 424, 463, 465, 510, 511},
+        { 424, 425, 464, 466, 511, 512},
+        { 425, 426, 465, 467, 512, 513},
+        { 426, 466, 468, 513, 514,  -1},
+        { 427, 467, 469, 515, 516,  -1},
+        { 427, 428, 468, 470, 516, 517},
+        { 428, 429, 469, 471, 517, 518},
+        { 429, 430, 470, 472, 518, 519},
+        { 430, 431, 471, 473, 519, 520},
+        { 431, 432, 472, 474, 520, 521},
+        { 432, 433, 473, 521, 522,  -1},
+        { 433, 476, 522, 523, 524,  -1},
+        { 433, 434, 475, 477, 524, 525},
+        { 434, 435, 476, 478, 525, 526},
+        { 435, 436, 477, 479, 526, 527},
+        { 436, 437, 478, 480, 527, 528},
+        { 437, 438, 479, 481, 528, 529}, // 480
+        { 438, 439, 480, 482, 529, 530},
+        { 439, 481, 483, 530, 531,  -1},
+        { 440, 482, 484, 532, 533,  -1},
+        { 440, 441, 483, 485, 533, 534},
+        { 441, 442, 484, 486, 534, 535},
+        { 442, 443, 485, 487, 535, 536},
+        { 443, 444, 486, 488, 536, 537},
+        { 444, 445, 487, 489, 537, 538},
+        { 445, 446, 488, 490, 538, 539},
+        { 446, 489, 491, 539, 540,  -1},
+        { 447, 490, 492, 541, 542,  -1},
+        { 447, 448, 491, 493, 542, 543},
+        { 448, 449, 492, 494, 543, 544},
+        { 449, 450, 493, 495, 544, 545},
+        { 450, 451, 494, 496, 545, 546},
+        { 451, 452, 495, 497, 546, 547},
+        { 452, 453, 496, 498, 547, 548},
+        { 453, 497, 499, 548, 549,  -1},
+        { 454, 498, 500, 550, 551,  -1},
+        { 454, 455, 499, 501, 551, 552}, // 500
+        { 455, 456, 500, 502, 552, 553},
+        { 456, 457, 501, 503, 553, 554},
+        { 457, 458, 502, 504, 554, 555},
+        { 458, 459, 503, 505, 555, 556},
+        { 459, 460, 504, 506, 556, 557},
+        { 460, 505, 507, 557, 558,  -1},
+        { 461, 506, 508, 559, 560,  -1},
+        { 461, 462, 507, 509, 560, 561},
+        { 462, 463, 508, 510, 561, 562},
+        { 463, 464, 509, 511, 562, 563},
+        { 464, 465, 510, 512, 563, 564},
+        { 465, 466, 511, 513, 564, 565},
+        { 466, 467, 512, 514, 565, 566},
+        { 467, 513, 515, 566, 567,  -1},
+        { 468, 514, 516, 568, 569,  -1},
+        { 468, 469, 515, 517, 569, 570},
+        { 469, 470, 516, 518, 570, 571},
+        { 470, 471, 517, 519, 571, 572},
+        { 471, 472, 518, 520, 572, 573},
+        { 472, 473, 519, 521, 573, 574}, // 520
+        { 473, 474, 520, 522, 574, 575},
+        { 474, 475, 521, 575, 576,  -1},
+        { 475, 524, 576,  -1,  -1,  -1},
+        { 475, 476, 523, 525,  -1,  -1},
+        { 476, 477, 524, 526,  -1,  -1},
+        { 477, 478, 525, 527,  -1,  -1},
+        { 478, 479, 526, 528,  -1,  -1},
+        { 479, 480, 527, 529,  -1,  -1},
+        { 480, 481, 528, 530,  -1,  -1},
+        { 481, 482, 529, 531,  -1,  -1},
+        { 482, 530, 532,  -1,  -1,  -1},
+        { 483, 531, 533,  -1,  -1,  -1},
+        { 483, 484, 532, 534,  -1,  -1},
+        { 484, 485, 533, 535,  -1,  -1},
+        { 485, 486, 534, 536,  -1,  -1},
+        { 486, 487, 535, 537,  -1,  -1},
+        { 487, 488, 536, 538,  -1,  -1},
+        { 488, 489, 537, 539,  -1,  -1},
+        { 489, 490, 538, 540,  -1,  -1},
+        { 490, 539, 541,  -1,  -1,  -1}, // 540
+        { 491, 540, 542,  -1,  -1,  -1},
+        { 491, 492, 541, 543,  -1,  -1},
+        { 492, 493, 542, 544,  -1,  -1},
+        { 493, 494, 543, 545,  -1,  -1},
+        { 494, 495, 544, 546,  -1,  -1},
+        { 495, 496, 545, 547,  -1,  -1},
+        { 496, 497, 546, 548,  -1,  -1},
+        { 497, 498, 547, 549,  -1,  -1},
+        { 498, 548, 550,  -1,  -1,  -1},
+        { 499, 549, 551,  -1,  -1,  -1},
+        { 499, 500, 550, 552,  -1,  -1},
+        { 500, 501, 551, 553,  -1,  -1},
+        { 501, 502, 552, 554,  -1,  -1},
+        { 502, 503, 553, 555,  -1,  -1},
+        { 503, 504, 554, 556,  -1,  -1},
+        { 504, 505, 555, 557,  -1,  -1},
+        { 505, 506, 556, 558,  -1,  -1},
+        { 506, 557, 559,  -1,  -1,  -1},
+        { 507, 558, 560,  -1,  -1,  -1},
+        { 507, 508, 559, 561,  -1,  -1}, // 560
+        { 508, 509, 560, 562,  -1,  -1},
+        { 509, 510, 561, 563,  -1,  -1},
+        { 510, 511, 562, 564,  -1,  -1},
+        { 511, 512, 563, 565,  -1,  -1},
+        { 512, 513, 564, 566,  -1,  -1},
+        { 513, 514, 565, 567,  -1,  -1},
+        { 514, 566, 568,  -1,  -1,  -1},
+        { 515, 567, 569,  -1,  -1,  -1},
+        { 515, 516, 568, 570,  -1,  -1},
+        { 516, 517, 569, 571,  -1,  -1}, // 570
+        { 517, 518, 570, 572,  -1,  -1},
+        { 518, 519, 571, 573,  -1,  -1},
+        { 519, 520, 572, 574,  -1,  -1},
+        { 520, 521, 573, 575,  -1,  -1},
+        { 521, 522, 574, 576,  -1,  -1},
+        { 522, 523, 575,  -1,  -1,  -1}  // 576
+    };
+
+  for (Int_t i=0; i<577; i++)
+      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                              nn[i][3], nn[i][4], nn[i][5]);
+
+  InitOuterRing();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomCamMagic.h	(revision 1638)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamMagic
+#define MARS_MGeomCamMagic
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamMagic : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamMagic(const char *name=NULL);
+
+    ClassDef(MGeomCamMagic, 1)		// Geometry class for the Magic camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.cc	(revision 1638)
@@ -0,0 +1,107 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomMirror
+//
+// This is the base class of the Mirror geometry. 
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomMirror.h"
+
+ClassImp(MGeomMirror);
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Mirror geometry with 0 values, except for fMirrorID.
+//
+MGeomMirror::MGeomMirror(Int_t mir, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MGeomMirror";
+    fTitle = title ? title : "Storage container for  a mirror geometry";
+
+    fMirrorId=mir;   // the Mirror Id
+
+    fFocalDist=0.;   //  focal distance of that mirror [cm]
+    fSX=0.;          // curvilinear coordinate of mirror's center in X[cm]
+    fSY=0.;          // curvilinear coordinate of mirror's center in X[cm]
+    fX=0.;           // x coordinate of the center of the mirror [cm]
+    fY=0.;           // y coordinate of the center of the mirror [cm]
+    fZ=0.;           // z coordinate of the center of the mirror [cm]
+    fThetaN=0.;      // polar theta angle of the direction 
+                     //  where the mirror points to
+    fPhiN=0.;        // polar phi angle of the direction
+                     // where the mirror points to
+    fXN=0.;          // xn coordinate of the normal vector
+                     // in the center
+    fYN=0.;          // yn coordinate of the normal vector
+                     // in the center
+    fZN=0.;          // zn coordinate of the normal vector
+                     // in the center
+                     // Note: fXN^2*fYN^2*fZN^2 = 1
+    fDeviationX=0.;  // deviation in x [cm]
+    fDeviationY=0.;  // deviation in y [cm]
+                     // of the spot of a single mirror on the camera plane
+
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING: Please contact Oscar
+//
+void MGeomMirror::SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
+                                   Float_t curv_y, Float_t lin_x, Float_t lin_y,
+				   Float_t lin_z, Float_t theta, Float_t phi,
+				   Float_t x_n, Float_t y_n, Float_t z_n,
+				   Float_t dev_x, Float_t dev_y){
+    fMirrorId=mir;   // the Mirror Id
+
+    fFocalDist=focal;   //  focal distance of that mirror [cm]
+    fSX=curv_x;          // curvilinear coordinate of mirror's center in X[cm]
+    fSY=curv_y;          // curvilinear coordinate of mirror's center in X[cm]
+    fX=lin_x;           // x coordinate of the center of the mirror [cm]
+    fY=lin_y;           // y coordinate of the center of the mirror [cm]
+    fZ=lin_z;           // z coordinate of the center of the mirror [cm]
+    fThetaN=theta;      // polar theta angle of the direction 
+                     //  where the mirror points to
+    fPhiN=phi;        // polar phi angle of the direction
+                     // where the mirror points to
+    fXN=x_n;          // xn coordinate of the normal vector
+                     // in the center
+    fYN=y_n;          // yn coordinate of the normal vector
+                     // in the center
+    fZN=z_n;          // zn coordinate of the normal vector
+                     // in the center
+                     // Note: fXN^2*fYN^2*fZN^2 = 1
+    fDeviationX=dev_x;  // deviation in x [cm]
+    fDeviationY=dev_x;  // deviation in y [cm]
+                     // of the spot of a single mirror on the camera plane
+}
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomMirror.h	(revision 1638)
@@ -0,0 +1,49 @@
+#ifndef MARS_MGeomMirror
+#define MARS_MGeomMirror
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomMirror : public MParContainer
+{
+private:
+    Int_t   fMirrorId;    // the Mirror Id
+
+    Float_t fFocalDist;   //  focal distance of that mirror [cm]
+    Float_t fSX;          // curvilinear coordinate of mirror's center in X[cm]
+    Float_t fSY;          // curvilinear coordinate of mirror's center in X[cm]
+    Float_t fX;           // x coordinate of the center of the mirror [cm]
+    Float_t fY;           // y coordinate of the center of the mirror [cm]
+    Float_t fZ;           // z coordinate of the center of the mirror [cm]
+    Float_t fThetaN;      // polar theta angle of the direction 
+                          //  where the mirror points to
+    Float_t fPhiN;        // polar phi angle of the direction
+                          // where the mirror points to
+    Float_t fXN;          // xn coordinate of the normal vector
+                          // in the center
+    Float_t fYN;          // yn coordinate of the normal vector
+                          // in the center
+    Float_t fZN;          // zn coordinate of the normal vector
+                          // in the center
+                          // Note: fXN^2*fYN^2*fZN^2 = 1
+    Float_t fDeviationX;  // deviation in x [cm]
+    Float_t fDeviationY;  // deviation in y [cm]
+                          // of the spot of a single mirror on the camera plane
+public:
+    MGeomMirror(Int_t mir=-1, const char *name=NULL, const char *title=NULL);
+
+    Int_t GetMirrorId() const         { return fMirrorId;   }
+
+    void  SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
+                           Float_t curv_y, Float_t lin_x, Float_t lin_y,
+                           Float_t lin_z, Float_t theta, Float_t phi,
+                           Float_t x_n, Float_t y_n, Float_t z_n,
+                           Float_t dev_x, Float_t dev_y);
+
+    ClassDef(MGeomMirror, 1)  // geometry class describing one mirror
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.cc	(revision 1638)
@@ -0,0 +1,73 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomPMT
+//
+// This is the base class of the PMT characteristics. 
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomPMT.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MGeomPMT);
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Mirror geometry with 0 values, except for fMirrorID.
+//
+MGeomPMT::MGeomPMT(Int_t pmt, const char *name, const char *title)
+    : fPMTId(pmt), fWavelength(0), fQE(0)
+{
+    fName  = name  ? name  : "MGeomPMT";
+    fTitle = title ? title : "Storage container for  a PMT characteristics";
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING Please contact Oscar
+//
+void MGeomPMT::SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe)
+{
+    if (fWavelength.GetSize()!=wav.GetSize() ||
+        fQE.GetSize()!=qe.GetSize())
+    {
+        *fLog << err << dbginf << " fWavelength or fQE do not have ";
+        *fLog << "size of setting arrays" << endl;
+        return;
+    }
+
+    fPMTId = pmt;
+
+    fWavelength = wav;
+    fQE = qe;
+}
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPMT.h	(revision 1638)
@@ -0,0 +1,34 @@
+#ifndef MARS_MGeomPMT
+#define MARS_MGeomPMT
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomPMT : public MParContainer
+{
+private:
+    Int_t   fPMTId;        // the PMT Id
+
+    TArrayF fWavelength;  // List of wavelength
+    TArrayF fQE;          // QE values
+
+public:
+
+    MGeomPMT(Int_t pmt=-1,const char *name=NULL, const char *title=NULL);
+
+    Int_t   GetPMTId() const         { return fPMTId;   }
+
+    void    SetArraySize(Int_t dim) { fWavelength.Set(dim); fQE.Set(dim); }
+
+    void    SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe);
+
+    ClassDef(MGeomPMT, 1)  // class containing information about PMTs
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.cc	(revision 1638)
@@ -0,0 +1,126 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MGeomPix
+//
+// This container stores the geometry (position) information of
+// a single pixel together with the information about next neighbors.
+//
+// The BIT(22) and BIT(23) is used to flag the pixels in the outer
+// and outermost ring. Please don't use this bits in conjuction with
+// MGeomPix.
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomPix.h"
+
+#include <math.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MGeomPix);
+
+// --------------------------------------------------------------------------
+//
+// Initialiyes one pixel
+//
+MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r) : fX(x), fY(y), fR(r)
+{
+    //  default constructor
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the area of the pixel. A hegagonal shape is assumed.
+//
+Float_t MGeomPix::GetA() const
+{
+    return fR*fR*tan(60/kRad2Deg);
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialiyes Next Neighbors.
+//
+// WARNING: This function is public, but it is not ment for user access.
+// It should only be used from geometry classes (like MGeomCam)
+//
+void MGeomPix::SetNeighbors(Short_t i0, Short_t i1, Short_t i2,
+                            Short_t i3, Short_t i4, Short_t i5)
+{
+    fNeighbors[0] = i0;
+    fNeighbors[1] = i1;
+    fNeighbors[2] = i2;
+    fNeighbors[3] = i3;
+    fNeighbors[4] = i4;
+    fNeighbors[5] = i5;
+
+    int i;
+    for (i=0; i<6; i++)
+        if (fNeighbors[i]<0)
+            break;
+
+    fNumNeighbors = i;
+
+    if (fNumNeighbors<5)
+        SetBit(kIsInOutermostRing);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the kIsOuterRing flag if this pixel has a outermost pixel
+//  as Next Neighbor and don't have the kIsOutermostRing flag itself.
+//
+void MGeomPix::CheckOuterRing(const MGeomCam &cam)
+{
+    if (IsInOutermostRing())
+        return;
+
+    for (int i=0; i<fNumNeighbors; i++)
+        if (cam[fNeighbors[i]].IsInOutermostRing())
+        {
+            SetBit(kIsInOuterRing);
+            return;
+        }
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the geometry information of one pixel.
+//
+void MGeomPix::Print(Option_t *opt) const
+{ 
+    //   information about a pixel
+    *fLog << all << "MPixGeom:  x= " << fX
+        << "  y= " << fY
+        << "  r= " << fR
+        << endl ;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/MGeomPix.h	(revision 1638)
@@ -0,0 +1,70 @@
+#ifndef MARS_MGeomPix
+#define MARS_MGeomPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomCam;
+
+class MGeomPix : public MParContainer
+{ 
+private:
+    enum {
+        kIsInOutermostRing = BIT(22),
+        kIsInOuterRing     = BIT(23),
+        kUserBits          = 0x1fc000 // 14-21 are allowed
+
+    };
+
+    Float_t fX;  // [mm] the x coordinate of the center
+    Float_t fY;  // [mm] the y coordinate of the center
+    Float_t fR;  // [mm] the r coordinate of the pixel (dist between two parallel sides)
+
+    Byte_t  fNumNeighbors; // number of valid neighbors
+    Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
+
+public:
+    MGeomPix(Float_t x=0, Float_t y=0, Float_t r=0);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void Set(Float_t x, Float_t y, Float_t r) { fX=x; fY=y; fR=r; }
+
+    void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
+                      Short_t i3=-1, Short_t i4=-1, Short_t i5=-1);
+
+    void CheckOuterRing(const MGeomCam &cam);
+
+    void SetX(Float_t x) { fX = x; }
+    void SetY(Float_t y) { fY = y; }
+    void SetR(Float_t r) { fR = r; }
+
+    Float_t GetX() const  { return fX; }
+    Float_t GetY() const  { return fY; }
+    Float_t GetR() const  { return fR; }
+
+    Float_t GetA() const;
+
+    Byte_t  GetNumNeighbors() const { return fNumNeighbors; }
+    Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; }
+
+    Bool_t IsInOutermostRing() const { return TestBit(kIsInOutermostRing); }
+    Bool_t IsInOuterRing() const     { return TestBit(kIsInOuterRing); }
+
+    /*
+     //
+     // These function are for future usage. They are not virtual in
+     // root by now.
+     //
+     void SetBit(UInt_t f, Bool_t set) { set ? TObject::SetBit(f) : TObject::ResetBit(f); }
+     void SetBit(UInt_t f)    { TObject::SetBit(f & kUserBits); }
+     void ResetBit(UInt_t f)  { TObject::ResetBit(f & kUserBits); }
+     void InvertBit(UInt_t f) { TObject InvertBit(f & kUserBits); }
+     */
+
+    ClassDef(MGeomPix, 1) // Geometry class describing the geometry of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgeom/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgeom/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgeom/Makefile	(revision 1638)
@@ -0,0 +1,52 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Geom
+
+#
+# Library name to creatre
+#
+LIB   = mgeom.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../MBase
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MGeomPix.cc \
+           MGeomCam.cc \
+           MGeomCamCT1.cc \
+           MGeomCamMagic.cc \
+	   MGeomMirror.cc \
+	   MGeomPMT.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/GuiLinkDef.h	(revision 1638)
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MHexagon+;
+#pragma link C++ class MCamDisplay+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1638)
@@ -0,0 +1,917 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  05/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCamDisplay
+//
+// Camera Display. The Pixels are displayed in
+// contents/area [somthing/mm^2]
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MCamDisplay.h"
+
+#include <fstream.h>
+#include <iostream.h>
+
+#include <TBox.h>
+#include <TText.h>
+#include <TArrow.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TButton.h>
+#include <TClonesArray.h>
+
+#include "MHexagon.h"
+
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MImgCleanStd.h"
+
+#define kItemsLegend 50 // see SetPalette(1,0)
+
+ClassImp(MCamDisplay);
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MCamDisplay::MCamDisplay(MGeomCam *geom)
+    : fAutoScale(kTRUE), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    fGeomCam = (MGeomCam*)geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = geom->GetNumPixels();
+    fRange     = geom->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+
+    // root 3.02
+    //  * base/inc/TObject.h:
+    //    register BIT(8) as kNoContextMenu. If an object has this bit set it will
+    //    not get an automatic context menu when clicked with the right mouse button.
+
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+    for (UInt_t i=0; i<fNumPixels; i++)
+        new ((*fPixels)[i]) MHexagon((*geom)[i]);
+
+    //
+    // set the color palette for the TBox elements
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
+    SetPalette(1, 0);
+#else
+    SetPalette(51, 0);
+#endif
+
+    //
+    // set up the Legend
+    //
+    fLegend  = new TClonesArray("TBox",  kItemsLegend);
+    fLegText = new TClonesArray("TText", kItemsLegend);
+
+    for (Int_t i = 0; i<kItemsLegend; i++)
+    {
+        TBox  *newbox = new ((*fLegend)[i])  TBox;
+        TText *newtxt = new ((*fLegText)[i]) TText;
+
+        newbox->SetFillColor(fColors[i]);
+
+        newtxt->SetTextSize(0.025);
+        newtxt->SetTextAlign(12);
+    }
+
+    fArrowX = new TArrow(-fRange*.9, -fRange*.9, -fRange*.6, -fRange*.9, 0.025);
+    fArrowY = new TArrow(-fRange*.9, -fRange*.9, -fRange*.9, -fRange*.6, 0.025);
+
+    TString text;
+    text += (int)(fRange*.3);
+    text += "mm";
+
+    fLegRadius = new TText(-fRange*.85, -fRange*.85, text);
+    text = "";
+    text += (float)((int)(fRange*.3*geom->GetConvMm2Deg()*10))/10;
+    text += "°";
+    text = text.Strip(TString::kLeading);
+    fLegDegree = new TText(-fRange*.85, -fRange*.75, text);
+    fLegRadius->SetTextSize(0.04);
+    fLegDegree->SetTextSize(0.04);
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MCamDisplay::~MCamDisplay()
+{
+    fPixels->Delete();
+    fLegend->Delete();
+    fLegText->Delete();
+
+    delete fPixels;
+    delete fLegend;
+    delete fLegText;
+
+    delete fArrowX;
+    delete fArrowY;
+
+    delete fLegRadius;
+    delete fLegDegree;
+
+    // delete fGeomCam;
+
+    // Not allocated by MCamDisplay or already deleted by the user
+    if (!fIsAllocated || !gROOT->GetListOfCanvases()->FindObject(fDrawingPad))
+        return;
+
+    // If it is not already removed make sure that nothing of this object
+    // maybe be deleted automatically by the canvas destructor
+    if (!fDrawingPad->GetListOfPrimitives()->FindObject(this))
+        return;
+
+    fDrawingPad->RecursiveRemove(this);
+    delete fDrawingPad;
+}
+
+inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
+    const Float_t pnum  = ratio*pix.GetNumPhotons();
+
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
+    const Float_t pnum  = ratio*pix.GetMean();
+
+    (*this)[i].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t ratio = fGeomCam->GetPixRatio(i);
+    const Float_t pnum  = sqrt(ratio)*pix.GetErrorPhot();
+
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max)
+{
+    //
+    // Fixme: Use absolute value per mm^2. Needs another scaling algorithm.
+    //
+    const Float_t pnum  = pix.GetNumPhotons()/pix.GetErrorPhot();
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum, min, max));
+}
+
+inline void MCamDisplay::SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2)
+{
+    const Int_t maxcolidx = kItemsLegend-1;
+
+    MHexagon &hex = (*this)[pix.GetPixId()];
+
+    const Float_t r = pix.GetNumPhotons()/pix.GetErrorPhot();
+
+    if (r>lvl1)
+        hex.SetFillColor(fColors[4*maxcolidx/5]);
+    else
+        if (r>lvl2)
+            hex.SetFillColor(fColors[maxcolidx/2]);
+        else
+            hex.SetFillColor(fColors[maxcolidx/5]);
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MCamDisplay::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.25)
+    {
+        x = (ratio*2-1)*fRange; 
+        y = fRange;
+    }
+    else
+    {
+        x = fRange*1.5;
+        y = fRange*1.25/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    gPad->Range(-fRange, -y, x, y);
+
+    //
+    // Make sure, that the correct aspect is always displayed also
+    // if - by chance - there is not update for the pad after the
+    // Paint function was called.
+    //
+    gPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+//  With this function you can change the color palette. For more
+// information see TStyle::SetPalette. Only palettes with 50 colors
+// are allowed.
+// In addition you can use SetPalette(52, 0) to create an inverse
+// deep blue sea palette
+//
+void MCamDisplay::SetPalette(Int_t ncolors, Int_t *colors)
+{
+    //
+    // If not enough colors are specified skip this.
+    //
+    if (ncolors>1 && ncolors<50)
+    {
+        cout << "MCamDisplay::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
+        return;
+    }
+
+    //
+    // If ncolors==52 create a reversed deep blue sea palette
+    //
+    if (ncolors==52)
+    {
+        gStyle->SetPalette(51, NULL);
+        Int_t c[50];
+        for (int i=0; i<50; i++)
+            c[49-i] = gStyle->GetColorPalette(i);
+        gStyle->SetPalette(50, c);
+    }
+    else
+        gStyle->SetPalette(ncolors, colors);
+
+    if (fDrawingPad)
+    {
+        //
+        // Set the colors of the legend
+        //
+        for (int i=0; i<kItemsLegend; i++)
+        {
+            Int_t col = GetBox(i)->GetFillColor();
+
+            //
+            // Make sure, that the legend is already colored
+            //
+            if (col==10 || col==22)
+                continue;
+            GetBox(i)->SetFillColor(gStyle->GetColorPalette(i));
+        }
+
+        //
+        // Change the colors of the pixels
+        //
+        for (unsigned int i=0; i<fNumPixels; i++)
+        {
+            //
+            // Get the old color index and check whether it is
+            // background or transparent
+            //
+            Int_t col = (*this)[i].GetFillColor();
+            if (col==10 || col==22)
+                continue;
+
+            //
+            // Search for the color index (level) in the color table
+            //
+            int idx;
+            for (idx=0; idx<kItemsLegend; idx++)
+                if (col==fColors[idx])
+                    break;
+            //
+            // Should not happen
+            //
+            if (idx==kItemsLegend)
+            {
+                cout << "MCamDisplay::SetPalette: Strange... FIXME!" << endl;
+                continue;
+            }
+
+            //
+            // Convert the old color index (level) into the new one
+            //
+            (*this)[i].SetFillColor(gStyle->GetColorPalette(idx));
+        }
+
+        //
+        // Update the pad on the screen
+        //
+        fDrawingPad->Modified();
+        fDrawingPad->Update();
+    }
+
+    //
+    // Store the color palette used for a leter reverse lookup
+    //
+    for (int i=0; i<kItemsLegend; i++)
+        fColors[i] = gStyle->GetColorPalette(i);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MCamDisplay::Draw(Option_t *option)
+{
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+
+    if (fDrawingPad)
+        return;
+
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    if (!gPad)
+    {
+        fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600);
+        fIsAllocated = kTRUE;
+    }
+    else
+    {
+        fDrawingPad = gPad;
+        fIsAllocated = kFALSE;
+    }
+
+    //
+    // Setup the correct environment
+    //
+    fDrawingPad->SetBorderMode(0);
+    fDrawingPad->SetFillColor(22);
+
+    //
+    // Set the initial coordinate range
+    //
+    Paint();
+
+    //
+    // Create and draw the buttons which allows changing the
+    // color palette of the display
+    //
+    TButton *but;
+    char txt[100];
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(1,0);", this);
+    but = new TButton("Pretty", txt, 0.01, 0.95, 0.15, 0.99);
+    but->Draw();
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(51,0);", this);
+    but = new TButton("Deap Sea", txt, 0.16, 0.95, 0.30, 0.99);
+    but->Draw();
+    sprintf(txt, "((MCamDisplay*)%p)->SetPalette(52,0);", this);
+    but = new TButton("Blue Inv", txt, 0.31, 0.95, 0.45, 0.99);
+    but->Draw();
+
+    //
+    // Draw all pixels of the camera
+    //  (means apend all pixelobjects to the current pad)
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        (*this)[i].SetBit(kNoContextMenu|kCannotPick);
+#endif
+        (*this)[i].SetFillColor(22);
+        (*this)[i].Draw();
+    }
+
+    fArrowX->Draw();
+    fArrowY->Draw();
+
+    fLegRadius->Draw();
+    fLegDegree->Draw();
+
+    //
+    // initialize and draw legend
+    //
+    const Float_t H = 0.9*fRange;
+    const Float_t h = 2./kItemsLegend;
+
+    const Float_t w = fRange/sqrt(fNumPixels);
+
+    for (Int_t i=0; i<kItemsLegend; i++)
+    {
+        TBox *box = GetBox(i);
+        box->SetX1(fRange);
+        box->SetX2(fRange+w);
+        box->SetY1(H*( i   *h - 1.));
+        box->SetY2(H*((i+1)*h - 1.));
+        box->SetFillColor(22);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        box->SetBit(kNoContextMenu|kCannotPick);
+#endif
+        box->Draw();
+
+        TText *txt = GetText(i);
+        txt->SetX(fRange+1.5*w);
+        txt->SetY(H*((i+0.5)*h - 1.));
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        txt->SetBit(kNoContextMenu|kCannotPick);
+#endif
+        txt->Draw();
+    }
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    // Add it here so that root will have it first in the internal list:
+    // This means, that root 'sees' the whole camera instead of all the
+    // single hexagons.
+    //
+    AppendPad(option);
+
+    //fDrawingPad->SetEditable(kFALSE);
+}
+
+void MCamDisplay::DrawPixelNumbers()
+{
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    TText txt;
+    txt.SetTextFont(122);
+    txt.SetTextAlign(22);   // centered/centered
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        TString num;
+        num += i;
+
+        const MHexagon &h = (*this)[i];
+        TText *nt = txt.DrawText(h.GetX(), h.GetY(), num);
+        nt->SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius());
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the number of photo electron into the
+// camera.
+//
+void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
+    Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 50;
+    if (fAutoScale)
+    {
+        min = event->GetNumPhotonsMin(fGeomCam);
+        max = event->GetNumPhotonsMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColor(pix, i, min, max);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the number of photo electron into the
+// camera.
+//
+void MCamDisplay::DrawPedestals(const MPedestalCam *event)
+{
+    if (!event)
+        return;
+
+    Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 50;
+    if (fAutoScale)
+    {
+        min = event->GetMeanMin(fGeomCam);
+        max = event->GetMeanMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetSize();
+
+    for (Int_t i=0; i<entries; i++)
+        SetPixColorPedestal((*event)[i], i, min, max);
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the error of number of photo electron
+// into the camera.
+//
+void MCamDisplay::DrawErrorPhot(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 50;
+    if (fAutoScale)
+    {
+        min = event->GetErrorPhotMin(fGeomCam);
+        max = event->GetErrorPhotMax(fGeomCam);
+
+        if (max < 20.)
+            max = 20.;
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColorError(pix, i, min, max);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the ratio of the number of photons
+// divided by its error
+//
+void MCamDisplay::DrawRatio(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    Float_t min = 0;
+    Float_t max = 20;
+    if (fAutoScale)
+    {
+        min = event->GetRatioMin();
+        max = event->GetRatioMax();
+
+        UpdateLegend(min, max);
+    }
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColorRatio(pix, min, max);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw the colors in respect to the cleaning levels
+//
+void MCamDisplay::DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    for (int i=0; i<kItemsLegend; i++)
+        GetBox(i)->SetFillColor(fColors[i]);
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //   update the colors in the picture
+    //
+    const Int_t entries = event->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*event)[i];
+
+        if (!pix.IsPixelUsed())
+            continue;
+
+        SetPixColorLevel(pix, lvl1, lvl2);
+    }
+
+    //
+    // Update display physically
+    //
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw the colors in respect to the cleaning levels
+//
+void MCamDisplay::DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean)
+{
+    DrawLevels(event, clean.GetCleanLvl1(), clean.GetCleanLvl2());
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MCamDisplay::Reset()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].SetFillColor(10);
+} 
+
+// ------------------------------------------------------------------------
+//
+//   Here we calculate the color index for the current value.
+//   The color index is defined with the class TStyle and the
+//   Color palette inside. We use the command gStyle->SetPalette(1,0)
+//   for the display. So we have to convert the value "wert" into
+//   a color index that fits the color palette.
+//   The range of the color palette is defined by the values fMinPhe
+//   and fMaxRange. Between this values we have 50 color index, starting
+//   with 0 up to 49.
+//
+Int_t MCamDisplay::GetColor(Float_t val, Float_t min, Float_t max)
+{
+    //
+    //   first treat the over- and under-flows
+    //
+    const Int_t maxcolidx = kItemsLegend-1;
+
+    if (val >= max)
+        return fColors[maxcolidx];
+
+    if (val <= min)
+        return fColors[0];
+
+    //
+    // calculate the color index
+    //
+    const Float_t ratio  = (val-min) / (max-min);
+    const Int_t   colidx = (Int_t)(ratio*maxcolidx + .5);
+
+    return fColors[colidx];
+}
+
+// ------------------------------------------------------------------------
+//
+//    change the text on the legend according to the range of the
+//    Display
+//
+void MCamDisplay::UpdateLegend(Float_t minphe, Float_t maxphe)
+{
+    char text[10];
+
+    for (Int_t i=0; i<kItemsLegend; i+=3)
+    {
+        const Float_t val = minphe + (Float_t)i/kItemsLegend * (maxphe-minphe) ;
+
+        sprintf(text, "%5.1f", val);
+
+        TText &txt = *GetText(i);
+
+        txt.SetText(txt.GetX(), txt.GetY(), text);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Save primitive as a C++ statement(s) on output stream out
+//
+void MCamDisplay::SavePrimitive(ofstream &out, Option_t *opt)
+{
+    if (!gROOT->ClassSaved(TCanvas::Class()))
+        fDrawingPad->SavePrimitive(out, opt);
+
+    out << "   " << fDrawingPad->GetName() << "->SetWindowSize(";
+    out << fDrawingPad->GetWw() << "," << fDrawingPad->GetWh() << ");" << endl;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Camera
+// this functions needed for graphical primitives, that
+// means without this function you are not able to interact
+// with the graphical primitive with the mouse!!!
+//
+// All calcutations are running in pixel coordinates
+//
+Int_t MCamDisplay::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    Int_t dist = 999999;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Int_t d = (*fPixels)[i]->DistancetoPrimitive(px, py);
+
+        if (d<dist)
+            dist=d;
+    }
+    return dist==0?0:999999;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+/*
+ void MCamDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+ {
+ cout << "Execute Event Camera " << event << " @ " << px << " " << py << endl;
+ }
+ */
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1638)
@@ -0,0 +1,91 @@
+#ifndef MARS_MCamDisplay
+#define MARS_MCamDisplay
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TBox;
+class TText;
+class TArrow;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+class MCerPhotEvt;
+class MCerPhotPix;
+class MImgCleanStd;
+class MPedestalPix;
+class MPedestalCam;
+
+class MCamDisplay : public TObject
+{
+private:
+    MGeomCam      *fGeomCam;     // pointer to camera geometry
+
+    Bool_t         fAutoScale;   // indicating the autoscale function
+
+    UInt_t         fNumPixels;   // number of pixels in the present geometry
+    Float_t        fRange;       // the range in millimeters of the present geometry
+
+    Int_t          fColors[50];
+
+    TArrow        *fArrowX;      // Coordinate System
+    TArrow        *fArrowY;      // Coordinate System
+
+    TText         *fLegRadius;   // Coordinate System
+    TText         *fLegDegree;   // Coordinate System
+
+    TClonesArray  *fPixels;      // array of all hexagons
+    TClonesArray  *fLegend;      // array of all color bars
+    TClonesArray  *fLegText;     // array of all texts
+
+    UInt_t         fW;           // Width of canvas
+    UInt_t         fH;           // Height of canvas
+    TVirtualPad   *fDrawingPad;  // pad in which we are drawing
+    Bool_t         fIsAllocated;
+
+    TBox  *GetBox(Int_t i)  { return (TBox*) fLegend->At(i); }
+    TText *GetText(Int_t i) { return (TText*)fLegText->At(i); }
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void  SetPixColor(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColorRatio(const MCerPhotPix &pix, Float_t min, Float_t max);
+    void  SetPixColorLevel(const MCerPhotPix &pix, Float_t lvl1, Float_t lvl2);
+    void  SetPixColorError(const MCerPhotPix &pix, const Int_t i, Float_t min, Float_t max);
+    void  SetPixColorPedestal(const MPedestalPix &pix, const Int_t i, Float_t min, Float_t max);
+    Int_t GetColor(Float_t val, Float_t min, Float_t max);
+
+    void UpdateLegend(Float_t min, Float_t max);
+    void Paint(Option_t *option="");
+
+public:
+    MCamDisplay(MGeomCam *geom);
+    ~MCamDisplay();
+
+    void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }
+    void DrawPhotNum(const MCerPhotEvt *event);
+    void DrawRatio(const MCerPhotEvt *event);
+    void DrawLevels(const MCerPhotEvt *event, Float_t lvl1, Float_t lvl2);
+    void DrawErrorPhot(const MCerPhotEvt *event);
+    void DrawLevels(const MCerPhotEvt *event, const MImgCleanStd &clean);
+    void DrawPedestals(const MPedestalCam *event);
+
+    void DrawPixelNumbers();
+
+    virtual void  Reset();
+    virtual void  Draw(Option_t *option="");
+    virtual void  SavePrimitive(ofstream &out, Option_t *);
+    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+
+    void SetPalette(Int_t ncolors, Int_t *colors);
+
+    ClassDef(MCamDisplay, 0) // Displays the magic camera
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.cc	(revision 1638)
@@ -0,0 +1,287 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MHexagon                                                                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHexagon.h"
+
+#include <fstream.h>
+#include <iostream.h>
+
+#include <TVirtualPad.h>  // gPad
+
+#include "MGeomPix.h"     // GetX
+
+ClassImp(MHexagon);
+
+// ------------------------------------------------------------------------
+//
+//   default constructor for MHexagon
+//
+MHexagon::MHexagon()
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//    normal constructor for MHexagon
+//
+MHexagon::MHexagon(Float_t x, Float_t y, Float_t d)
+: TAttLine(1, 1, 1), TAttFill(0, 1001), fX(x), fY(y), fD(d)
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//    normal constructor for MHexagon
+//
+MHexagon::MHexagon(MGeomPix &pix)
+: TAttLine(1, 1, 1), TAttFill(0, 1001)
+{
+    fX = pix.GetX();
+    fY = pix.GetY();
+    fD = pix.GetR();
+}
+
+// ------------------------------------------------------------------------
+//
+//    copy constructor for MHexagon
+//
+MHexagon::MHexagon(const MHexagon &hexagon)
+{
+    ((MHexagon&) hexagon).Copy(*this);
+} 
+
+// ------------------------------------------------------------------------
+//
+//     default destructor for MHexagon
+//
+MHexagon::~MHexagon()
+{
+}
+
+// ------------------------------------------------------------------------
+//
+//     copy this hexagon to hexagon
+//
+void MHexagon::Copy(TObject &obj)
+{
+    MHexagon &hex = (MHexagon&) obj;
+
+    TObject::Copy(obj);
+    TAttLine::Copy(hex);
+    TAttFill::Copy(hex);
+
+    hex.fX = fX;
+    hex.fY = fY;
+    hex.fD = fD;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Hexagon
+// this functions needed for graphical primitives, that
+// means without this function you are not able to interact
+// with the graphical primitive with the mouse!!!
+//
+// All calcutations are running in pixel coordinates
+//
+Int_t MHexagon::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Int_t pxhex = gPad->XtoAbsPixel(fX);
+    const Int_t pyhex = gPad->YtoAbsPixel(fY);
+
+    const Double_t x = TMath::Abs(px-pxhex);
+    const Double_t y = TMath::Abs(py-pyhex);
+
+    const Double_t disthex = TMath::Sqrt(x*x + y*y);
+
+    if (disthex==0)
+        return 0;
+
+    const Double_t cosa = x / disthex;
+    const Double_t sina = y / disthex;
+
+    //
+    // comput the distance of hexagon center to pixel border
+    //
+    const Double_t dx = fD * cosa / 2;
+    const Double_t dy = fD * sina / 2;
+
+    const Int_t pxborder = gPad->XtoAbsPixel(fX + dx);
+    const Int_t pyborder = gPad->YtoAbsPixel(fY + dy);
+
+    const Double_t bx = pxhex-pxborder;
+    const Double_t by = pyhex-pyborder;
+
+    const Double_t distborder = TMath::Sqrt(bx*bx + by*by);
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle inside
+    //
+    return distborder < disthex ? (int)(disthex-distborder+1) : 0;
+}
+
+// ------------------------------------------------------------------------
+//
+//  Draw this ellipse with new coordinate
+//
+void MHexagon::DrawHexagon(Float_t x, Float_t y, Float_t d)
+{ 
+    MHexagon *newhexagon = new MHexagon(x, y, d);
+
+    TAttLine::Copy(*newhexagon);
+    TAttFill::Copy(*newhexagon);
+
+    newhexagon->SetBit(kCanDelete);
+    newhexagon->AppendPad();
+}
+
+/*
+// ------------------------------------------------------------------------
+//
+//  This is the first test of implementing a clickable interface
+//  for one pixel
+//
+void MHexagon::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    switch (event)
+    {
+    case kButton1Down:
+        cout << endl << "kButton1Down" << endl;
+        SetFillColor(2);
+        gPad->Modified();
+        break;
+
+    case kButton1Double:
+        SetFillColor(0);
+        gPad->Modified();
+        break;
+        //  case kMouseEnter:
+        //     printf ("\n Mouse inside object \n" ) ;
+        //     break;
+    }
+}
+*/
+
+// ------------------------------------------------------------------------
+//
+//  list this hexagon with its attributes
+//
+void MHexagon::ls(const Option_t *) const
+{
+    TROOT::IndentLevel();
+    Print();
+}
+
+// ------------------------------------------------------------------------
+//
+//  paint this hexagon with its attribute
+//
+void MHexagon::Paint(Option_t *)
+{
+    PaintHexagon(fX, fY, fD);
+}
+
+// ------------------------------------------------------------------------
+//
+//  draw this hexagon with the coordinates
+//
+void MHexagon::PaintHexagon(Float_t inX, Float_t inY, Float_t inD)
+{ 
+
+    const Int_t np = 6;
+
+    const Float_t dx[np+1] = { .5   , 0.    , -.5   , -.5   , 0.    ,  .5   , .5    };
+    const Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 };
+
+    static Float_t x[np+1], y[np+1];
+
+    TAttLine::Modify();    // Change line attributes only if neccessary
+    TAttFill::Modify();    // Change fill attributes only if neccessary
+
+    //  calculate the positions of the pixel corners
+
+    for (Int_t i=0; i<=np; i++)
+    {
+        x[i] = inX + dx[i]* inD;
+        y[i] = inY + dy[i]* inD;
+    }
+
+    //   paint the pixel (hopefully)
+
+    if (GetFillColor())
+        gPad->PaintFillArea(np, x, y);
+
+    if (GetLineStyle())
+        gPad->PaintPolyLine(np+1, x, y);
+
+}
+
+// ------------------------------------------------------------------------
+//
+//  print/dump this hexagon with its attributes
+//
+void MHexagon::Print(Option_t *) const
+{
+    cout << "MHexagon: ";
+    cout << "x=" << fX << "mm y=" << fY << "mm r=" << fD << "mm" << endl;
+
+    cout << " Line:";
+    cout << " Color=" << GetLineColor() << ",";
+    cout << " Style=" << GetLineStyle() << ",";
+    cout << " Width=" << GetLineWidth() << endl;
+    cout << " Fill:";
+    cout << " Color=" << GetFillColor() << ",";
+    cout << " Style=" << GetFillStyle() << endl;
+}
+
+// ------------------------------------------------------------------------
+//
+// Save primitive as a C++ statement(s) on output stream out
+//
+void MHexagon::SavePrimitive(ofstream &out, Option_t *)
+{
+    if (gROOT->ClassSaved(Class()))
+       out << "   ";
+    else
+       out << "   MHexagon *";
+
+    out << "hexagon = new MHexagon(" << fX << "," << fY << "," << fD << ");" << endl;
+
+    SaveFillAttributes(out, "hexagon");
+    SaveLineAttributes(out, "hexagon");
+
+    out << "   hexagon->Draw();" << endl;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/MHexagon.h	(revision 1638)
@@ -0,0 +1,67 @@
+#ifndef MARS_MHexagon
+#define MARS_MHexagon
+
+//////////////////////////////////////////////////////////////
+//
+//   MHexagon
+//
+//   A Hexagon for the MAGIC event display
+//
+//////////////////////////////////////////////////////////////
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif 
+
+#ifndef ROOT_TAttLine
+#include <TAttLine.h>
+#endif 
+
+#ifndef ROOT_TAttFill
+#include <TAttFill.h>
+#endif 
+
+class MGeomPix;
+
+class MHexagon : public TObject, public TAttLine, public TAttFill
+{
+protected:
+
+    Float_t fX;  // X coordinate  of center
+    Float_t fY;  // Y coordinate  of center
+    Float_t fD;  // diameter D or better distance between opposite sides
+
+public:
+
+    MHexagon();
+    MHexagon(Float_t x, Float_t y, Float_t d);
+    MHexagon(MGeomPix &pix);
+    MHexagon(const MHexagon &hexagon);
+    virtual ~MHexagon();
+
+    virtual void  Copy(TObject &hexagon);
+
+    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    virtual void  DrawHexagon(Float_t x, Float_t y, Float_t d);
+
+    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+
+    virtual void  ls(const Option_t *Option="") const;
+    virtual void  Paint(Option_t *Option="");
+    virtual void  PaintHexagon(Float_t x, Float_t y, Float_t d);
+    virtual void  Print(Option_t *Option="") const; // *MENU*
+    virtual void  SavePrimitive(ofstream &out, Option_t *);
+
+    Float_t GetX() const { return fX; }
+    Float_t GetY() const { return fY; }
+    Float_t GetD() const { return fD; }
+
+    ClassDef(MHexagon, 0)    // A hexagon for MAGIC
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mgui/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mgui/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mgui/Makefile	(revision 1638)
@@ -0,0 +1,48 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Gui
+
+#
+# Library name to creatre
+#
+LIB   = mgui.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MHexagon.cc \
+           MCamDisplay.cc 
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistIncl.h	(revision 1638)
@@ -0,0 +1,6 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+#include <TArrayI.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 1638)
@@ -0,0 +1,50 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MFillH+;
+
+#pragma link C++ class MH+;
+#pragma link C++ class MHArray+;
+#pragma link C++ class MH3+;
+
+#pragma link C++ class MBinning+;
+
+#pragma link C++ class MHMatrix+;
+
+#pragma link C++ class MHFadcCam+;
+#pragma link C++ class MHFadcPix+;
+
+#pragma link C++ class MHHillas+;
+#pragma link C++ class MHHillasSrc+;
+#pragma link C++ class MHHillasExt+;
+#pragma link C++ class MHStarMap+;
+#pragma link C++ class MHEnergyTime+;
+#pragma link C++ class MHEnergyTheta+;
+#pragma link C++ class MHAlphaEnergyTime+;
+#pragma link C++ class MHAlphaEnergyTheta+;
+#pragma link C++ class MHGamma+;
+#pragma link C++ class MHFlux;
+#pragma link C++ class MHEffOnTime+;
+#pragma link C++ class MHTimeDiffTime+;
+#pragma link C++ class MHTimeDiffTheta+;
+#pragma link C++ class MHThetabarTime+;
+#pragma link C++ class MHThetabarTheta+;
+
+#pragma link C++ class MHCompProb+;
+#pragma link C++ class MHHadronness+;
+
+#pragma link C++ class MHMcRate+;
+#pragma link C++ class MHMcDifRate+;
+#pragma link C++ class MHMcIntRate+;
+#pragma link C++ class MHMcEfficiency+;
+#pragma link C++ class MHMcEfficiencyImpact+;
+#pragma link C++ class MHMcEfficiencyEnergy+;
+#pragma link C++ class MHMcEnergy+;
+#pragma link C++ class MHMcEnergyImpact+;
+#pragma link C++ class MHMcCollectionArea+;
+#pragma link C++ class MHMcEnergyMigration+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.cc	(revision 1638)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MBinning                                                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MBinning.h"
+
+#include <fstream.h>
+
+#include <TH1.h>        // InheritsFrom
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+
+ClassImp(MBinning);
+
+static const TString gsDefName  = "MBinning";
+static const TString gsDefTitle = "Container describing the binning of an axis";
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title only. Typically you won't
+// need to change this.
+//
+MBinning::MBinning(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetEdges(10, 0, 1);
+
+    fType = kIsDefault;
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins (not the number of edges), the lowest and
+// highest Edge.
+//
+void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    const Double_t binsize = (up-lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+            fEdges[i] = binsize*i + lo;
+
+    fType = kIsLinear;
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins (not the number of edges), the lowest and
+// highest Edge.
+//
+void MBinning::SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    // if (lo==0) ...
+
+    const Double_t binsize = log10(up/lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+        fEdges[i] = pow(10, binsize*i) * lo;
+
+    fType = kIsLogarithmic;
+}
+
+// --------------------------------------------------------------------------
+//
+// Apply this binning to the given histogram.
+// (By definition this works only for 1D-histograms. For 2D- and 3D-
+//  histograms use MH::SetBinning directly)
+//
+void MBinning::Apply(TH1 &h)
+{
+    if (h.InheritsFrom("TH2") || h.InheritsFrom("TH3"))
+    {
+        *fLog << warn << "MBinning::Apply: '" << h.GetName() << "' is not a basic TH1 object... no binning applied." << endl;
+        return;
+    }
+
+    MH::SetBinning(&h, this);
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MBinning::StreamPrimitive(ofstream &out) const
+{
+    out << "   MBinning " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    if (IsDefault())
+        return;
+
+    if (IsLinear() || IsLogarithmic())
+    {
+        out << "   " << GetUniqueName() << ".SetEdges";
+        if (IsLogarithmic())
+            out << "Log";
+        out << "(" << GetNumBins() << ", " << GetEdgeLo() << ", " << GetEdgeHi() << ");" << endl;
+        return;
+    }
+
+    out << "   {" << endl;
+    out << "      TArrayD dummy;" << endl;
+    for (int i=0; i<GetNumEdges(); i++)
+        out << "      dummy[" << i << "]=" << GetEdges()[i] << ";" << endl;
+    out << "      " << GetUniqueName() << ".SetEdges(dummy);" << endl;
+    out << "   }" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MBinning.h	(revision 1638)
@@ -0,0 +1,62 @@
+#ifndef MARS_MBinning
+#define MARS_MBinning
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include "TArrayD.h"
+#endif
+
+class TH1;
+
+class MBinning : public MParContainer
+{
+private:
+    TArrayD fEdges;
+
+    Byte_t  fType;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum {
+        kIsDefault,
+        kIsLinear,
+        kIsLogarithmic,
+        kIsUserArray
+    };
+
+public:
+    MBinning(const char *name=NULL, const char *title=NULL);
+
+    void SetEdges(const TArrayD &arr)
+    {
+        fEdges = arr;
+        fType = kIsUserArray;
+    }
+
+    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
+    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
+
+    // FIXME: ROOT workaround: "operator[] const" missing
+    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
+    Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
+
+    Int_t GetNumEdges() const { return fEdges.GetSize(); }
+    Int_t GetNumBins() const { return fEdges.GetSize()-1; }
+
+    Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }
+
+    Bool_t IsLinear() const { return fType==kIsLinear; }
+    Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
+    Bool_t IsDefault() const { return fType==kIsDefault; }
+    Bool_t IsUserArray() const { return fType==kIsUserArray; }
+
+    void Apply(TH1 &);
+
+    ClassDef(MBinning, 1) //Container to store the binning of a histogram
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.cc	(revision 1638)
@@ -0,0 +1,487 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MFillH                                                                  //
+//                                                                          //
+//  This is a common interface (task) to fill mars histograms. Every mars   //
+//  histogram which is derived from MH can be filled with this task.        //
+//                                                                          //
+//  There are two options to use:                                           //
+//                                                                          //
+//  1) You specifiy the parameter container with which data the             //
+//     histogram container should be filled, and the histogram container    //
+//     which has to be filled. This can be done by either specifing the     //
+//     name of the objects in the parameter list or by specifiing a pointer //
+//     to the object. (s. Constructor)                                      //                  //
+//                                                                          //
+//  2) You specify the name and/or type of the histogram to become filled.  //
+//     Any other action imust be taken by the histogram class.              //
+//                                                                          //
+//  PreProcess: In the preprocessing of this task we setup all pointers     //
+//              to instances which are needed and call FillSetup of the     //
+//              histogram class with the parameter list as an argument.     //
+//                                                                          //
+//  Process: The process function calls the Fill member function of the     //
+//           histogram class instance (inheriting from MH) with either      //
+//           a NULL pointer or a pointer to the corresponding container     //
+//           as an argument.                                                //
+//                                                                          //
+//  WARNING:                                                                //
+//   Because MFillH is a generalized task to fill histograms it doesn't     //
+//   know about which branches from a file are necessary to fill the        //
+//   histograms. If you are reading data from a file which is directly      //
+//   filled into a histogram via MFillH, please call either                 //
+//   MReadTree::DisableAutoScheme() or enable the necessary branches by     //
+//   yourself, using MReadTree::EnableBranch()                              //
+//                                                                          //
+//   Checkout the Warning in MTaskList.                                     //
+//                                                                          //
+//  Input Containers:                                                       //
+//   A parameter container                                                  //
+//                                                                          //
+//  Output Containers:                                                      //
+//   A histogram container                                                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MFillH.h"
+
+#include <fstream.h>
+
+#include <TClass.h>
+
+#include "MDataChain.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+#include "MHArray.h"
+
+#include "MParList.h"
+
+ClassImp(MFillH);
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MFillH::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFillH";
+    fTitle = title ? title : "Task to fill Mars histograms";
+
+    fH            = NULL;
+    fParContainer = NULL;
+
+    fIndex  = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. This is to support some root-stuff.
+// Never try to use it yourself!
+//
+MFillH::MFillH()
+{
+    Init(NULL, NULL);
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// 1) - par is the name of the parameter container which should be filled into
+//      the histogram
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+MFillH::MFillH(const char *hist, const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainerName = par;
+
+    if (title)
+        return;
+
+    fTitle = "Fill " + fHName;
+    if (!par)
+        return;
+
+    fTitle += " from " + fParContainerName;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// 1) - par is a pointer to the instance of your parameter container from which
+//      the data should be used to fill the histogram.
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created. Everything
+//         which is between the first '[' and the last ']' in the string
+//         is used as the histogram type.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+//
+MFillH::MFillH(const char *hist, MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainer = par;
+    fParContainerName = par->GetName();
+
+    if (!title)
+        fTitle = "Fill " + fHName + " from " + par->GetDescriptor();
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// - par is a pointer to the instance of your parameter container from which
+//   the data should be used to fill the histogram.
+// - hist is a pointer to the instance of your histogram container (which must
+//   have been derived from MH) into which the data should flow
+//
+MFillH::MFillH(MH *hist, const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
+    fParContainerName = par;
+
+    AddToBranchList(fH->GetDataMember());
+
+    if (title)
+        return;
+
+    fTitle = (TString)"Fill " + hist->GetDescriptor();
+    if (!par)
+        return;
+
+    fTitle += " from " + fParContainerName;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// - par is a pointer to the instance of your parameter container from which
+//   the data should be used to fill the histogram.
+// - hist is the name of the histogram container (which must have been
+//   derived from MH)
+//
+MFillH::MFillH(MH *hist, MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
+    fParContainer = par;
+    fParContainerName = par->GetName();
+
+    AddToBranchList(fH->GetDataMember());
+
+    if (!title)
+        fTitle = (TString)"Fill " + hist->GetDescriptor() + " from " + par->GetDescriptor();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete fData if existing and kCanDelete is set.
+//
+MFillH::~MFillH()
+{
+    if (fIndex)
+        if (fIndex->TestBit(kCanDelete))
+            delete fIndex;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the histogram to be filles is a MHArray you can specify a 'rule'
+// This rule is used to create an MDataChain. The return value of the chain
+// is casted to int. Each int acts as a key. For each (new) key a new
+// histogram is created in the array. (eg for the rule
+// "MRawEvtHeader::fRunNumber" you would get one histogram per run-number)
+//
+void MFillH::SetRuleForIdx(const TString rule)
+{
+    fIndex = new MDataChain(rule);
+    fIndex->SetBit(kCanDelete);
+}
+
+// --------------------------------------------------------------------------
+//
+// If the histogram to be filles is a MHArray you can specify a MData-object
+// The return value of the object is casted to int. Each int acts as a key.
+// For each (new) key a new histogram is created in the array. (eg for
+// MDataMember("MRawEvtHeader::fRunNumber") you would get one histogram per
+// run-number)
+//
+void MFillH::SetRuleForIdx(MData *data)
+{
+    fIndex = data;
+}
+
+// --------------------------------------------------------------------------
+//
+// Extracts the name of the histogram from the MFillH argument
+//
+TString MFillH::ExtractName(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    return type.Remove(first).Strip(TString::kBoth);
+}
+
+// --------------------------------------------------------------------------
+//
+// Extracts the class-name of the histogram from the MFillH argument
+//
+TString MFillH::ExtractClass(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    const Ssiz_t length = last-first-1;
+
+    TString strip = fHName(first+1, length);
+    return strip.Strip(TString::kBoth);
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks the parameter list for the existance of the parameter container. If
+// the name of it was given in the constructor. It checks also for the
+// existance of the histogram container in the parameter list if a name was
+// given. If it is not available it tried to create a histogram container
+// with the same type as the given object name.
+//
+Bool_t MFillH::PreProcess(MParList *pList)
+{
+    if (fIndex)
+    {
+        if (!fIndex->PreProcess(pList))
+        {
+            *fLog << all << "PreProcessing of Index rule failed... aborting." << endl;
+            return kFALSE;
+        }
+
+        if (!fIndex->IsValid())
+        {
+            *fLog << all << "Given Index rule invalid... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    //
+    // Try to get the histogram container with name fHName from list
+    // or create one with this name
+    //
+    if (!fH)
+    {
+        const TString cls  = ExtractClass(fHName);
+        const TString name = ExtractName(fHName);
+
+        TObject *obj=NULL;
+        if (cls==name)
+            obj = pList->FindObject(fHName);
+
+        if (!obj)
+        {
+            if (cls==name)
+                *fLog << inf << "Object '" << fHName << "' not found in parlist... trying to create one." << endl;
+            obj = pList->FindCreateObj(cls, name);
+        }
+
+        if (!obj)
+            return kFALSE;
+
+        //
+        // We were successfull getting it. Check whether it really inherits
+        // from MH, FindCreateObj does only check for inheritance from
+        // 'type'.
+        //
+        TClass *tcls = fIndex ? MHArray::Class() : MH::Class();
+        if (!obj->InheritsFrom(tcls))
+        {
+            *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
+            *fLog << "from " << tcls->GetName() << " - cannot be used for MFillH...";
+            *fLog << "aborting." << endl;
+            return kFALSE;
+        }
+
+        fH = (MH*)obj;
+    }
+
+    //
+    // Now we have the histogram container available. Try to Setup Fill.
+    //
+    if (!fH->SetupFill(pList))
+    {
+        *fLog << err << dbginf << "Error: calling SetupFill for ";
+        *fLog << fH->GetDescriptor() << "... aborting." << endl;
+        return kFALSE;
+    }
+
+    //
+    // If also a parameter container is already set we are done.
+    //
+    if (fParContainer)
+        return kTRUE;
+
+    //
+    // If a name is given try to find the input container in the
+    // list. If it could not be found we cannot proceed.
+    //
+    if (fParContainerName.IsNull())
+    {
+        fParContainer = pList;
+        return kTRUE;
+    }
+
+    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+    if (fParContainer)
+        return kTRUE;
+
+    *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills the data from the parameter conatiner into the histogram container
+//
+Bool_t MFillH::Process()
+{
+    if (fIndex)
+        ((MHArray*)fH)->SetIndexByKey(fIndex->GetValue());
+    /*
+     const Int_t key = (Int_t)fIndex->GetValue();
+     const Int_t idx = fMapIdx->Add(key);
+     ((MHArray*)fH)->SetIndex(idx);
+     */
+
+    return fH->Fill(fParContainer);
+} 
+
+// --------------------------------------------------------------------------
+//
+// Set the ReadyToSave flag of the histogram container, because now all data
+// has been filled into the histogram.
+//
+Bool_t MFillH::PostProcess()
+{
+    //
+    // Now all data is in the histogram. Maybe some final action is
+    // necessary.
+    //
+    if (!fH->Finalize())
+    {
+        *fLog << err << dbginf << "Error: calling Finalize for ";
+        *fLog << fH->GetDescriptor() << "... aborting." << endl;
+        return kFALSE;
+    }
+
+    fH->SetReadyToSave();
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MFillH::StreamPrimitive(ofstream &out) const
+{
+    if (fH)
+        fH->SavePrimitive(out);
+
+    if (fParContainer)
+        fParContainer->SavePrimitive(out);
+
+    out << "   MFillH " << GetUniqueName() << "(";
+
+    if (fH)
+        out << "&" << fH->GetUniqueName();
+    else
+        out << "\"" << fHName << "\"";
+
+    if (fParContainer)
+        out << ", &" << fParContainer->GetUniqueName();
+    else
+        if (!fParContainerName.IsNull())
+            out << ", \"" << fParContainerName << "\"";
+
+    out << ");" << endl;
+
+    if (!fIndex)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetRuleForIdx(\"";
+    out << fIndex->GetRule() << "\");" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MFillH.h	(revision 1638)
@@ -0,0 +1,53 @@
+#ifndef MARS_MFillH
+#define MARS_MFillH
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MH;
+class MData;
+class MParList;
+
+class MMap;
+
+class MFillH : public MTask
+{
+private:
+    MParContainer *fParContainer;
+    TString fParContainerName;
+
+    MH* fH;
+    TString fHName;
+
+    MData *fIndex;    // MData object describing the 'key' to an automatic index for an MHArray
+    MMap  *fMapIdx;   //! Map to map key-index-pair for an MHArray (MMap see MFillH.cc)
+
+    TString ExtractName(const char *name) const;
+    TString ExtractClass(const char *name) const;
+
+    void Init(const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MFillH();
+    MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, MParContainer *par,   const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         MParContainer *par,   const char *name=NULL, const char *title=NULL);
+
+    ~MFillH();
+
+    void SetRuleForIdx(const TString rule);
+    void SetRuleForIdx(MData *rule);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MFillH, 1) // Task to fill a histogram with data from a parameter container
+};
+    
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.cc	(revision 1638)
@@ -0,0 +1,681 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MH                                                                      //
+//                                                                          //
+//  This is a base tasks for mars histograms. It defines a common interface //
+//  for filling the histograms with events (MH::Fill) which is used by a    //
+//  common 'filler' And a SetupFill member function which may be used       //
+//  by MFillH. The idea is:                                                 //
+//   1) If your Histogram can become filled by one single container         //
+//      (like MHHillas) you overload MH::Fill and it gets called with       //
+//      a pointer to the container with which it should be filled.          //
+//                                                                          //
+//   2) You histogram needs several containers to get filled. Than you      //
+//      have to overload MH::SetupFill and get the necessary objects from   //
+//      the parameter list. Use this objects in Fill to fill your           //
+//      histogram.                                                          //
+//                                                                          //
+//  If you want to create your own histogram class the new class must be    //
+//  derived from MH (instead of the base MParContainer) and you must        //
+//  the fill function of MH. This is the function which is called to fill   //
+//  the histogram(s) by the data of a corresponding parameter container.    //
+//                                                                          //
+//  Remark: the static member function (eg MakeDefCanvas) can be called     //
+//          from everywhere using: MH::MakeDefCanvas(...)                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MH.h"
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TGaxis.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+#include <TPaveStats.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MParContainer.h"
+
+#include "MBinning.h"
+
+ClassImp(MH);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title only. Typically you won't
+// need to change this.
+//
+MH::MH(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MH";
+    fTitle = title ? title : "Base class for Mars histograms";
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to use the automatic filling of your derived class you
+// must overload this function. If it is not overloaded you cannot use
+// FillH with this class. The argument is a pointer to a container
+// in your paremeter list which is specified in the MFillH constructor.
+// If you are not going to use it you should at least add
+//   Bool_t MH::Fill(const MParContainer *) { return kTRUE; }
+// to your class definition.
+//
+Bool_t MH::Fill(const MParContainer *par)
+{
+    *fLog << warn << GetDescriptor() << ": Fill not overloaded! Can't be used!" << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This virtual function is ment as a generalized interface to retrieve
+// a pointer to a root histogram from the MH-derived class.
+//
+TH1 *MH::GetHistByName(const TString name)
+{
+    *fLog << warn << GetDescriptor() << ": GetHistByName not overloaded! Can't be used!" << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is a function which should replace the creation of default
+// canvases like root does. Because this is inconvinient in some aspects.
+// need to change this.
+// You can specify a name for the default canvas and a title. Also
+// width and height can be given.
+// MakeDefCanvas looks for a canvas with the given name. If now name is
+// given the DefCanvasName of root is used. If no such canvas is existing
+// it is created and returned. If such a canvas already exists a new canvas
+// with a name plus anumber is created (the number is calculated by the
+// number of all existing canvases plus one)
+//
+TCanvas *MH::MakeDefCanvas(TString name, const char *title,
+                           const UInt_t w, const UInt_t h)
+{
+    const TList *list = (TList*)gROOT->GetListOfCanvases();
+
+    if (name.IsNull())
+        name = gROOT->GetDefCanvasName();
+
+    if (list->FindObject(name))
+        name += Form(" <%d>", list->GetSize()+1);
+
+    return new TCanvas(name, title, w, h);
+}
+
+// --------------------------------------------------------------------------
+//
+// This function works like MakeDefCanvas(name, title, w, h) but name
+// and title are retrieved from the given TObject.
+//
+TCanvas *MH::MakeDefCanvas(const TObject *obj,
+                           const UInt_t w, const UInt_t h)
+{
+    return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies a given binning to a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const MBinning *binsx)
+{
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+    TAxis &x = *h->GetXaxis();
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binnings to the two axis of a 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy)
+{
+    TAxis &x = *h->GetXaxis();
+    TAxis &y = *h->GetYaxis();
+
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+    TString ytitle = y.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+    y.Set(binsy->GetNumBins(), binsy->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+    y.SetTitle(ytitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binnings to the three axis of a 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)
+{
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+    TAxis &x = *h->GetXaxis();
+    TAxis &y = *h->GetYaxis();
+    TAxis &z = *h->GetZaxis();
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+    TString ytitle = y.GetTitle();
+    TString ztitle = z.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1,
+               binsz->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+    y.Set(binsy->GetNumBins(), binsy->GetEdges());
+    z.Set(binsz->GetNumBins(), binsz->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+    y.SetTitle(ytitle);
+    z.SetTitle(ztitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges)  to the axis of a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const TArrayD &binsx)
+{
+    MBinning bx;
+    bx.SetEdges(binsx);
+    SetBinning(h, &bx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges) to the two axis of a
+// 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy)
+{
+    MBinning bx;
+    MBinning by;
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
+    SetBinning(h, &bx, &by);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges) to the three axis of a
+// 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz)
+{
+    MBinning bx;
+    MBinning by;
+    MBinning bz;
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
+    bz.SetEdges(binsz);
+    SetBinning(h, &bx, &by, &bz);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binning of a TAxis (eg from a root histogram) to the axis
+// of a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const TAxis *binsx)
+{
+    const Int_t nx = binsx->GetNbins();
+
+    TArrayD bx(nx+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+
+    SetBinning(h, bx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of the TAxis' (eg from a root histogram) to the
+// two axis' of a 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy)
+{
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+
+    SetBinning(h, bx, by);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of the TAxis' (eg from a root histogram) to the
+// three axis' of a 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
+{
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+    const Int_t nz = binsz->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    TArrayD bz(nz+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    for (int i=0; i<nz; i++) bz[i] = binsz->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+    bz[nz] = binsz->GetXmax();
+
+    SetBinning(h, bx, by, bz);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of one root-histogram x to another one h
+// Both histograms must be of the same type: TH1, TH2 or TH3
+//
+void MH::SetBinning(TH1 *h, TH1 *x)
+{
+    if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class()))
+    {
+        SetBinning((TH3*)h, x->GetXaxis(), x->GetYaxis(), x->GetZaxis());
+        return;
+    }
+    if (h->InheritsFrom(TH3::Class()) || x->InheritsFrom(TH3::Class()))
+        return;
+    if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class()))
+    {
+        SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis());
+        return;
+    }
+    if (h->InheritsFrom(TH2::Class()) || x->InheritsFrom(TH2::Class()))
+        return;
+    if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class()))
+    {
+        SetBinning(h, x->GetXaxis());
+        return;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Multiplies all entries in a TArrayD by a float f
+//
+void MH::ScaleArray(TArrayD &bins, Double_t f)
+{
+    for (int i=0; i<bins.GetSize(); i++)
+        bins[i] *= f;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scales the binning of a TAxis by a float f
+//
+TArrayD MH::ScaleAxis(TAxis &axe, Double_t f)
+{
+    TArrayD arr(axe.GetNbins()+1);
+
+    for (int i=1; i<=axe.GetNbins()+1; i++)
+        arr[i-1] = axe.GetBinLowEdge(i);
+
+    ScaleArray(arr, f);
+
+    return arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scales the binning of one, two or three axis of a histogram by a float f
+//
+void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz)
+{
+    if (h->InheritsFrom(TH3::Class()))
+    {
+        SetBinning((TH3*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy),
+                   ScaleAxis(*h->GetZaxis(), fz));
+        return;
+    }
+
+    if (h->InheritsFrom(TH2::Class()))
+    {
+        SetBinning((TH2*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy));
+        return;
+    }
+
+    if (h->InheritsFrom(TH1::Class()))
+        SetBinning(h, ScaleAxis(*h->GetXaxis(), fx));
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to find a MBinning container with the name "Binning"+name
+// in the given parameter list. If it was found it is applied to the
+// given histogram. This is only valid for 1D-histograms
+//
+Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h)
+{
+    if (h->InheritsFrom(TH2::Class()) || h->InheritsFrom(TH3::Class()))
+    {
+        gLog << warn << "MH::ApplyBinning: '" << h->GetName() << "' is not a basic TH1 object... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name);
+    if (!bins)
+    {
+        gLog << warn << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(h, bins);
+    return kTRUE;
+}
+
+void MH::FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger)
+{
+//*-*-*-*-*-*-*-*-*Find reasonable bin values*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+//*-*              ==========================
+
+    Double_t dx = 0.1*(xmax-xmin);
+    Double_t umin = xmin - dx;
+    Double_t umax = xmax + dx;
+
+    if (umin < 0 && xmin >= 0)
+        umin = 0;
+
+    if (umax > 0 && xmax <= 0)
+        umax = 0;
+
+    Double_t binlow  =0;
+    Double_t binhigh =0;
+    Double_t binwidth=0;
+    //TGaxis::Optimize(umin, umax, nbins, binlow, binhigh, n, binwidth, "");
+
+    if (binwidth <= 0 || binwidth > 1.e+39)
+    {
+        xmin = -1;
+        xmax = 1;
+    }
+    else
+    {
+        xmin = binlow;
+        xmax = binhigh;
+    }
+
+    if (isInteger)
+    {
+        Int_t ixmin = (Int_t)xmin;
+        Int_t ixmax = (Int_t)xmax;
+        Double_t dxmin = (Double_t)ixmin;
+        Double_t dxmax = (Double_t)ixmax;
+
+        xmin = xmin<0 && xmin!=dxmin ? dxmin - 1 : dxmin;
+        xmax = xmax>0 && xmax!=dxmax ? dxmax + 1 : dxmax;
+
+        if (xmin>=xmax)
+            xmax = xmin+1;
+
+        Int_t bw = 1 + (Int_t)((xmax-xmin)/nbins);
+
+        nbins = (Int_t)((xmax-xmin)/bw);
+
+        if (xmin+nbins*bw < xmax)
+        {
+            nbins++;
+            xmax = xmin +nbins*bw;
+        }
+    }
+
+    newbins = nbins;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns the lowest entry in a histogram which is greater than gt (eg >0)
+//
+Double_t MH::GetMinimumGT(const TH1 &h, Double_t gt)
+{
+    Double_t min = FLT_MAX;
+
+    const TAxis &axe = *((TH1&)h).GetXaxis();
+
+    for (int i=1; i<=axe.GetNbins(); i++)
+    {
+        Double_t x = h.GetBinContent(i);
+        if (gt<x && x<min)
+            min = x;
+    }
+    return min;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws a copy of the two given histograms. Uses title as the pad title.
+// Also layout the two statistic boxes and a legend.
+//
+void MH::DrawCopy(const TH1 &hist1, const TH1 &hist2, const TString title)
+{
+    //
+    // Draw first histogram
+    //
+    TH1 *h1 = (TH1*)((TH1&)hist1).DrawCopy();
+    gPad->Update();
+
+    TPaveText *t = (TPaveText*)gPad->FindObject("title");
+    if (t)
+    {
+        t->SetName((TString)"MHTitle");     // rename object
+        t->Clear();                         // clear old lines
+        t->AddText((TString)" "+title+" "); // add the new title
+        t->SetBit(kCanDelete);              // make sure object is deleted
+
+        //
+        // FIXME: This is a stupid workaround to hide the redrawn
+        // (see THistPainter::PaintTitle) title
+        //
+        gPad->Modified();  // indicates a change
+        gPad->Update();    // recreates the original title
+        t->Pop();          // bring our title on top
+    }
+
+    //
+    // Rename first statistics box
+    //
+    TPaveStats &s1 = *(TPaveStats*)gPad->FindObject("stats");
+    s1.SetX1NDC(s1.GetX1NDC()-0.01);
+    s1.SetName("MHStat");
+
+    //
+    // Draw second histogram
+    //
+    TH1 *h2 = (TH1*)((TH1&)hist2).DrawCopy("sames");
+    gPad->Update();
+
+    //
+    // Set new position of second statistics box
+    //
+    TPaveStats &s2 = *(TPaveStats*)gPad->FindObject("stats");
+    s2.SetX1NDC(s1.GetX1NDC()-(s2.GetX2NDC()-s2.GetX1NDC())-0.01);
+    s2.SetX2NDC(s1.GetX1NDC()-0.01);
+
+    //
+    // Draw Legend
+    //
+    const Int_t    n = s1.GetListOfLines()->GetSize();
+    const Double_t h = s1.GetY2NDC()-s1.GetY1NDC();
+    TLegend &l = *new TLegend(s1.GetX1NDC(), s1.GetY1NDC()-0.015-h*2/n,
+                              s1.GetX2NDC(), s1.GetY1NDC()-0.01
+                            );
+    l.AddEntry(h1, h1->GetTitle());
+    l.AddEntry(h2, h2->GetTitle());
+    l.SetTextSize(s2.GetTextSize());
+    l.SetTextFont(s2.GetTextFont());
+    l.SetBorderSize(s2.GetBorderSize());
+    l.SetBit(kCanDelete);
+
+    l.Draw();
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws the two given histograms. Uses title as the pad title.
+// Also layout the two statistic boxes and a legend.
+//
+void MH::Draw(TH1 &hist1, TH1 &hist2, const TString title)
+{
+    //
+    // Draw first histogram
+    //
+    hist1.Draw();
+    gPad->Update();
+
+    TPaveText *t = (TPaveText*)gPad->FindObject("title");
+    if (t)
+    {
+        t->SetName((TString)"MHTitle");     // rename object
+        t->Clear();                         // clear old lines
+        t->AddText((TString)" "+title+" "); // add the new title
+        t->SetBit(kCanDelete);              // make sure object is deleted
+
+        //
+        // FIXME: This is a stupid workaround to hide the redrawn
+        // (see THistPainter::PaintTitle) title
+        //
+        gPad->Modified();  // indicates a change
+        gPad->Update();    // recreates the original title
+        t->Pop();          // bring our title on top
+    }
+
+    //
+    // Rename first statistics box
+    //
+    TPaveStats &s1 = *(TPaveStats*)gPad->FindObject("stats");
+    s1.SetX1NDC(s1.GetX1NDC()-0.01);
+    s1.SetName((TString)"Stat"+hist1.GetTitle());
+
+    //
+    // Draw second histogram
+    //
+    hist2.Draw("sames");
+
+    gPad->Update();
+
+    //
+    // Set new position of second statistics box
+    //
+    TPaveStats &s2 = *(TPaveStats*)gPad->FindObject("stats");
+    s2.SetX1NDC(s1.GetX1NDC()-(s2.GetX2NDC()-s2.GetX1NDC())-0.01);
+    s2.SetX2NDC(s1.GetX1NDC()-0.01);
+
+    //
+    // Draw Legend
+    //
+    TLegend &l = *new TLegend(s1.GetX1NDC(),
+                              s1.GetY1NDC()-0.015-(s1.GetY2NDC()-s1.GetY1NDC())/2,
+                              s1.GetX2NDC(),
+                              s1.GetY1NDC()-0.01
+                             );
+    l.AddEntry(&hist1, hist1.GetTitle());
+    l.AddEntry(&hist2, hist2.GetTitle());
+    l.SetTextSize(s2.GetTextSize());
+    l.SetTextFont(s2.GetTextFont());
+    l.SetBorderSize(s2.GetBorderSize());
+    l.SetBit(kCanDelete);
+    l.Draw();
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH.h	(revision 1638)
@@ -0,0 +1,66 @@
+#ifndef MARS_MH
+#define MARS_MH
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1;
+class TH2;
+class TH3;
+class TAxis;
+class TArrayD;
+class TCanvas;
+
+class MBinning;
+class MParList;
+
+class MH : public MParContainer
+{
+public:
+    MH(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
+    virtual Bool_t Fill(const MParContainer *par);
+    virtual Bool_t Finalize() { return kTRUE; }
+
+    virtual TString GetDataMember() const { return ""; }
+
+    virtual TH1 *GetHistByName(const TString name);
+
+    static TCanvas *MakeDefCanvas(TString name="", const char *title="",
+                                  const UInt_t w=580, const UInt_t h=435);
+    static TCanvas *MakeDefCanvas(const TObject *obj,
+                                  const UInt_t w=580, const UInt_t h=435);
+
+    static void SetBinning(TH1 *h, const MBinning *binsx);
+    static void SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy);
+    static void SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz);
+
+    static void SetBinning(TH1 *h, const TArrayD &binsx);
+    static void SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy);
+    static void SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz);
+
+    static void SetBinning(TH1 *h, const TAxis *binsx);
+    static void SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy);
+    static void SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz);
+
+    static void SetBinning(TH1 *h, TH1 *x);
+
+    static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
+
+    static void    ScaleArray(TArrayD &bins, Double_t f);
+    static TArrayD ScaleAxis(TAxis &axe, Double_t f);
+    static void    ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
+
+    static void DrawCopy(const TH1 &hist1, const TH1 &hist2, const TString title);
+    static void Draw(TH1 &hist1, TH1 &hist2, const TString title);
+
+    static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
+    static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
+
+    ClassDef(MH, 1) //A histogram base class for Mars histograms
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.cc	(revision 1638)
@@ -0,0 +1,592 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MH3
+//
+// With this histogram you can fill a histogram with up to three
+// variables from Mars parameter containers in an eventloop.
+//
+// In the constructor you can give up to three variables which should be
+// filled in the histogram. Dependend on the number of given variables
+// (data members) a TH1F, TH2F or TH3F is created.
+// Specify the data mamber like the following:
+//   "MHillas.fLength"
+// Where MHillas is the name of the parameter container in the parameter
+// list and fLength is the name of the data member which should be filled
+// in the histogram. Assuming that your MHillas container has a different
+// name (MyHillas) the name to give would be:
+//   "MyHillas.fLength"
+//
+// The axis binning is retrieved from the parameter list, too. Create a
+// MBinning with the name "Binning" plus the name of your MH3 container
+// plus the axis name ("X", "Y" or "Z") and add it to the parameter list.
+//
+// If you want to use a different unit for histogramming use SetScaleX,
+// SetScaleY and SetScaleZ.
+//
+// For example:
+//   MH3 myhist("MHillas.fLength");
+//   myhist.SetName("MyHist");
+//   myhist.SetScaleX(geomcam.GetConvMm2Deg()); //convert length to degree
+//   MBinning bins("BinningMyHistX");
+//   bins.SetEdges(10, 0, 150);
+//   plist.AddToList(&myhist);
+//   plist.AddToList(&bins);
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MH3.h"
+
+#include <fstream.h>
+
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include <TH2.h>
+#include <TH3.h>
+#include <TProfile.h>
+#include <TProfile2D.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MDataChain.h"
+
+ClassImp(MH3);
+
+static const TString gsDefName  = "MH3";
+static const TString gsDefTitle = "Container for a %dD Mars Histogram";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MH3::MH3() : fDimension(0), fHist(NULL)
+{
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 0);
+
+    fData[0]  = fData[1]  = fData[2]  = NULL;
+    fScale[0] = fScale[1] = fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH1F. memberx is filled into the X-bins. For a more detailed
+// description see the class description above.
+//
+MH3::MH3(const char *memberx)
+    : fDimension(1)
+{
+    fHist = new TH1F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = NULL;
+    fData[2] = NULL;
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 1);
+
+    fHist->SetDirectory(NULL);
+    fHist->SetYTitle("Counts");
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH2F. memberx is filled into the X-bins. membery is filled
+// into the Y-bins. For a more detailed description see the class
+// description above.
+//
+MH3::MH3(const char *memberx, const char *membery)
+    : fDimension(2)
+{
+    fHist = new TH2F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = new MDataChain(membery);
+    fData[2] = NULL;
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 2);
+
+    fHist->SetDirectory(NULL);
+    fHist->SetZTitle("Counts");
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH3F. memberx is filled into the X-bins. membery is filled
+// into the Y-bins. membery is filled into the Z-bins. For a more detailed
+// description see the class description above.
+//
+MH3::MH3(const char *memberx, const char *membery, const char *memberz)
+    : fDimension(3)
+{
+    fHist = new TH3F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = new MDataChain(membery);
+    fData[2] = new MDataChain(memberz);
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 3);
+
+    fHist->SetDirectory(NULL);
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the histogram
+//
+MH3::~MH3()
+{
+    delete fHist;
+
+    for (int i=0; i<3; i++)
+        if (fData[i])
+            delete fData[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data members used by the data chain to be used in
+// MTask::AddBranchToList
+//
+TString MH3::GetDataMember() const
+{
+    TString str=fData[0]->GetDataMember();
+    if (fData[1])
+    {
+        str += ";";
+        str += fData[1]->GetDataMember();
+    }
+    if (fData[2])
+    {
+        str += ";";
+        str += fData[2]->GetDataMember();
+    }
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning are found in the parameter list
+// For a more detailed description see class description above.
+//
+Bool_t MH3::SetupFill(const MParList *plist)
+{
+    TString bname("Binning");
+    bname += fName;
+
+    MBinning *binsx = NULL;
+    MBinning *binsy = NULL;
+    MBinning *binsz = NULL;
+    switch (fDimension)
+    {
+    case 3:
+        binsz = (MBinning*)plist->FindObject(bname+"Z");
+        if (!binsz)
+        {
+            *fLog << err << dbginf << "MBinning '" << bname << "X' not found... aborting." << endl;
+            return kFALSE;
+        }
+        if (binsz->IsLogarithmic())
+            fHist->SetBit(kIsLogz);
+        fHist->SetZTitle(fData[2]->GetTitle());
+        if (!fData[2]->PreProcess(plist))
+            return kFALSE;
+    case 2:
+        binsy = (MBinning*)plist->FindObject(bname+"Y");
+        if (!binsy)
+        {
+            *fLog << err << dbginf << "MBinning '" << bname << "Y' not found... aborting." << endl;
+            return kFALSE;
+        }
+        if (binsy->IsLogarithmic())
+            fHist->SetBit(kIsLogy);
+        fHist->SetYTitle(fData[1]->GetTitle());
+        if (!fData[1]->PreProcess(plist))
+            return kFALSE;
+    case 1:
+        binsx = (MBinning*)plist->FindObject(bname+"X");
+        if (!binsx)
+        {
+            *fLog << err << dbginf << "MBinning '" << bname << "X' not found... aborting." << endl;
+            return kFALSE;
+        }
+        if (binsx->IsLogarithmic())
+            fHist->SetBit(kIsLogx);
+        fHist->SetXTitle(fData[0]->GetTitle());
+        if (!fData[0]->PreProcess(plist))
+            return kFALSE;
+    }
+
+    fHist->SetName(fName);
+
+    TString title("Histogram for ");
+    title += fName;
+
+    switch (fDimension)
+    {
+    case 1:
+        fHist->SetTitle(title+" (1D)");
+        SetBinning(fHist, binsx);
+        return kTRUE;
+    case 2:
+        fHist->SetTitle(title+" (2D)");
+        SetBinning((TH2*)fHist, binsx, binsy);
+        return kTRUE;
+    case 3:
+        fHist->SetTitle(title+" (3D)");
+        SetBinning((TH3*)fHist, binsx, binsy, binsz);
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the name of the histogram ant the MH3 container
+//
+void MH3::SetName(const char *name)
+{
+    fHist->SetName(name);
+    MParContainer::SetName(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the title of the histogram ant the MH3 container
+//
+void MH3::SetTitle(const char *title)
+{
+    fHist->SetTitle(title);
+    MParContainer::SetTitle(title);
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills the one, two or three data members into our histogram
+//
+Bool_t MH3::Fill(const MParContainer *par)
+{
+    Double_t x=0;
+    Double_t y=0;
+    Double_t z=0;
+
+    switch (fDimension)
+    {
+    case 3:
+        z = fData[2]->GetValue()*fScale[2];
+    case 2:
+        y = fData[1]->GetValue()*fScale[1];
+    case 1:
+        x = fData[0]->GetValue()*fScale[0];
+    }
+
+    switch (fDimension)
+    {
+    case 3:
+        ((TH3*)fHist)->Fill(x, y, z);
+        return kTRUE;
+    case 2:
+        ((TH2*)fHist)->Fill(x, y);
+        return kTRUE;
+    case 1:
+        fHist->Fill(x);
+        return kTRUE;
+    }
+
+    return kFALSE;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Set the palette you wanna use:
+//  - you could set the root "Pretty Palette Violet->Red" by
+//    gStyle->SetPalette(1, 0), but in some cases this may look
+//    confusing
+//  - The maximum colors root allowes us to set by ourself
+//    is 50 (idx: 51-100). This colors are set to a grayscaled
+//    palette
+//  - the number of contours must be two less than the number
+//    of palette entries
+//
+void MHStarMap::PrepareDrawing() const
+{
+    const Int_t numg = 32; // number of gray scaled colors
+    const Int_t numw = 32; // number of white
+
+    Int_t palette[numg+numw];
+
+    //
+    // The first half of the colors are white.
+    // This is some kind of optical background supression
+    //
+    gROOT->GetColor(51)->SetRGB(1, 1, 1);
+
+    Int_t i;
+    for (i=0; i<numw; i++)
+        palette[i] = 51;
+
+    //
+    // now the (gray) scaled part is coming
+    //
+    for (;i<numw+numg; i++)
+    {
+        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
+
+        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
+        palette[i] = 52+i;
+    }
+
+    //
+    // Set the palette and the number of contour levels
+    //
+    gStyle->SetPalette(numg+numw, palette);
+    fStarMap->SetContour(numg+numw-2);
+}
+*/
+// --------------------------------------------------------------------------
+//
+// Setup a inversed deep blue sea palette for the fCenter histogram.
+//
+void MH3::SetColors() const
+{
+    // FIXME: This must be redone each time the canvas is repainted....
+    gStyle->SetPalette(51, NULL);
+    Int_t c[50];
+    for (int i=0; i<50; i++)
+        c[49-i] = gStyle->GetColorPalette(i);
+    gStyle->SetPalette(50, c);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram. So that the object can be deleted
+//
+// Possible options are:
+//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
+//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
+//   ONLY:  Draw the profile histogram only (for 2D histograms only)
+//
+// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
+// eg this is set when applying a logarithmic MBinning
+//
+// and the histogram is still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MH3::DrawClone(Option_t *opt) const
+{
+    TString str(opt);
+
+    TVirtualPad *c = gPad;
+    if (!str.Contains("nonew", TString::kIgnoreCase))
+    {
+        c = MH::MakeDefCanvas(fHist);
+
+        //
+        // This is necessary to get the expected bahviour of DrawClone
+        //
+        gROOT->SetSelectedPad(NULL);
+    }
+
+    if (str.Contains("COL", TString::kIgnoreCase))
+        SetColors();
+
+    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
+    if (!only)
+        fHist->DrawCopy(opt);
+
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX("_pfx", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY("_pfy", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+
+    if (fHist->TestBit(kIsLogx)) c->SetLogx();
+    if (fHist->TestBit(kIsLogy)) c->SetLogy();
+    if (fHist->TestBit(kIsLogz)) c->SetLogz();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+//
+// Possible options are:
+//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
+//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
+//   ONLY:  Draw the profile histogram only (for 2D histograms only)
+//
+// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
+// eg this is set when applying a logarithmic MBinning
+//
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MH3::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHist);
+
+    TString str(opt);
+
+    if (str.Contains("COL", TString::kIgnoreCase))
+        SetColors();
+
+    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
+    if (!only)
+        fHist->Draw(opt);
+
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX("_pfx", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY("_pfy", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+
+    if (fHist->TestBit(kIsLogx)) gPad->SetLogx();
+    if (fHist->TestBit(kIsLogy)) gPad->SetLogy();
+    if (fHist->TestBit(kIsLogz)) gPad->SetLogz();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MH3::StreamPrimitive(ofstream &out) const
+{
+    TString name = GetUniqueName();
+
+    out << "   MH3 " << name << "(\"";
+    out << fData[0]->GetRule() << "\"";
+    if (fDimension>1)
+        out << ", \"" << fData[1]->GetRule() << "\"";
+    if (fDimension>2)
+        out << ", \"" << fData[2]->GetRule() << "\"";
+
+    out << ");" << endl;
+
+    if (fName!=gsDefName)
+        out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
+
+    if (fTitle!=Form(gsDefTitle.Data(), fDimension))
+        out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
+
+    switch (fDimension)
+    {
+    case 3:
+        if (fScale[2]!=1)
+            out << "   " << name << ".SetScaleZ(" << fScale[2] << ");" << endl;
+    case 2:
+        if (fScale[1]!=1)
+            out << "   " << name << ".SetScaleY(" << fScale[1] << ");" << endl;
+    case 1:
+        if (fScale[0]!=1)
+            out << "   " << name << ".SetScaleX(" << fScale[0] << ");" << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Used to rebuild a MH3 object of the same type (data members,
+// dimension, ...)
+//
+MParContainer *MH3::New() const
+{
+    MH3 *h = NULL;
+    switch (fDimension)
+    {
+    case 1:
+        h=new MH3(fData[0]->GetRule());
+        break;
+    case 2:
+        h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
+        break;
+    case 3:
+        h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
+        break;
+    }
+    switch (fDimension)
+    {
+    case 3:
+        h->SetScaleZ(fScale[2]);
+    case 2:
+        h->SetScaleY(fScale[1]);
+    case 1:
+        h->SetScaleX(fScale[0]);
+    }
+    return h;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MH3.h	(revision 1638)
@@ -0,0 +1,69 @@
+#ifndef MARS_MH3
+#define MARS_MH3
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1;
+class TMethodCall;
+class MDataChain;
+
+class MH3 : public MH
+{
+protected:
+    // Could be const but root < 3.02/06 doesn't like this...
+    Int_t fDimension;            // Number of dimensions of histogram
+    TH1  *fHist;                 // Histogram to fill
+
+    TString     fDataMember[3];  // Data member which should be filled into the histogram x
+    MDataChain *fData[3];        // Object from which the data is filled
+    Double_t    fScale[3];
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum {
+        kIsLogx = BIT(15),
+        kIsLogy = BIT(16),
+        kIsLogz = BIT(17)
+    };
+
+public:
+    MH3();
+    MH3(const char *memberx);
+    MH3(const char *memberx, const char *membery);
+    MH3(const char *memberx, const char *membery, const char *memberz);
+    ~MH3();
+
+    void SetScaleX(Double_t scale) { fScale[0] = scale; }
+    void SetScaleY(Double_t scale) { fScale[1] = scale; }
+    void SetScaleZ(Double_t scale) { fScale[2] = scale; }
+
+    Int_t GetDimension() const { return fDimension; }
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TString GetDataMember() const;
+
+    TH1 &GetHist() { return *fHist; }
+    const TH1 &GetHist() const { return *fHist; }
+
+    TH1 *GetHistByName(const TString name) { return fHist; }
+
+    void SetColors() const;
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    MParContainer *New() const;
+
+    ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 1638)
@@ -0,0 +1,226 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHAlphaEnergyTheta                                                      //
+//                                                                          //
+//  3D-histogram in alpha, E-est and Theta                                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHAlphaEnergyTheta.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MMcEvt.hxx"
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHAlphaEnergyTheta);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram. 
+//
+MHAlphaEnergyTheta::MHAlphaEnergyTheta(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHAlphaEnergyTheta";
+    fTitle = title ? title : "3-D histogram in alpha, energy and theta";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("3D-plot of alpha, E-est, Theta");
+    fHist.SetXTitle("\\alpha [\\circ]");
+    fHist.SetYTitle("E-est [GeV]            ");
+    fHist.SetZTitle("\\Theta [\\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings and prepare filling of the histogram
+// 
+Bool_t MHAlphaEnergyTheta::SetupFill(const MParList *plist)
+{
+   fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
+   if (!fEnergy)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTheta : MEnergyEst not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTheta : MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+   MBinning* binsalphaflux  = (MBinning*)plist->FindObject("BinningAlphaFlux");
+   MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+   if (!binsenergy || !binsalphaflux || !binstheta)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTheta : At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalphaflux, binsenergy, binstheta);
+
+   fHist.Sumw2(); 
+
+   fHist.Sumw2(); 
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHAlphaEnergyTheta::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("AlphaEnergyTheta", fTitle);
+
+    gPad->Divide(2,2);
+
+    TH1 *h;
+
+    gPad->cd(1);
+    h = fHist.Project3D("expro");
+
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    gPad->cd(2);
+    h = fHist.Project3D("eypro");
+
+    h->SetTitle("Distribution of E-est [GeV]");
+    h->SetXTitle("E-est [GeV]            ");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    gPad->cd(3);
+    h = fHist.Project3D("ezpro");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    gPad->cd(4);
+    fHist.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw copies of the histogram
+// 
+TObject *MHAlphaEnergyTheta::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("AlphaEnergyTheta", fTitle);
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = ((TH3*)(&fHist))->Project3D("expro");
+
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    c.cd(2);
+    h = ((TH3*)(&fHist))->Project3D("eypro");
+
+    h->SetTitle("Distribution of E-est [GeV]");
+    h->SetXTitle("E-est [GeV]            ");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    c.cd(3);
+    h = ((TH3*)(&fHist))->Project3D("ezpro");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    c.cd(4);
+    ((TH3&)fHist).DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTheta.h	(revision 1638)
@@ -0,0 +1,54 @@
+#ifndef MARS_MHAlphaEnergyTheta
+#define MARS_MHAlphaEnergyTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include "TH3.h"
+#endif
+
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MMcEvt;
+class MHillasSrc;
+class MEnergyEst;
+class TH2D;
+class MParList;
+
+
+class MHAlphaEnergyTheta : public MH
+{
+private:
+    MMcEvt     *fMcEvt;  //!
+    MHillasSrc *fHillas; //!
+    MEnergyEst *fEnergy; //!
+
+    TH3D fHist;
+
+public:
+    MHAlphaEnergyTheta(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH3D *GetHist()       { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHAlphaEnergyTheta, 1) //3D-histogram in alpha, Energy and theta
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.cc	(revision 1638)
@@ -0,0 +1,335 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHAlphaEnergyTime                                                       //
+//                                                                          //
+//  3D-histogram in alpha, E-est and time                                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHAlphaEnergyTime.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHAlphaEnergyTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram. 
+//
+MHAlphaEnergyTime::MHAlphaEnergyTime(const char *name, const char *title) 
+  : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHAlphaEnergyTime";
+    fTitle = title ? title : "3-D histogram in alpha, energy and time";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("3D-plot of alpha, E-est, time");
+    fHist.SetXTitle("\\alpha [\\circ]");
+    fHist.SetYTitle("E-est [GeV]            ");
+    fHist.SetZTitle("time [s]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings and prepare filling of the histogram
+// 
+Bool_t MHAlphaEnergyTime::SetupFill(const MParList *plist)
+{
+   fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
+   if (!fEnergy)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : MEnergyEst not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fTime = (MTime*)plist->FindObject("MTime");
+   if (!fTime)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : MTime not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+   MBinning* binsalphaflux  = (MBinning*)plist->FindObject("BinningAlphaFlux");
+   MBinning* binstime   = (MBinning*)plist->FindObject("BinningTime");
+   if (!binsenergy || !binsalphaflux || !binstime)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalphaflux, binsenergy, binstime);
+
+   fHist.Sumw2();
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTime::Fill(const MParContainer *par)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), 0.0001*fTime->GetTimeLo());
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHAlphaEnergyTime::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("AlphaEnergyTime", fTitle);
+
+    gPad->Divide(2,2);
+
+    TH1 *h;
+
+    gPad->cd(1);
+    h = fHist.Project3D("ex");
+
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    gPad->cd(2);
+    h = fHist.Project3D("ey");
+
+    h->SetTitle("Distribution of E-est [GeV]");
+    h->SetXTitle("E-est [GeV]            ");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    gPad->cd(3);
+    h = fHist.Project3D("ez");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    gPad->cd(4);
+    fHist.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw copies of the histogram
+// 
+TObject *MHAlphaEnergyTime::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("AlphaEnergyTime", fTitle);
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = ((TH3D*)(&fHist))->Project3D("ex");
+
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    c.cd(2);
+    h = ((TH3D*)(&fHist))->Project3D("ey");
+
+    h->SetTitle("Distribution of E-est [GeV]");
+    h->SetXTitle("E-est [GeV]            ");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    c.cd(3);
+    h = ((TH3D*)(&fHist))->Project3D("ez");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    c.cd(4);
+    ((TH3D&)fHist).DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist     (Alpha,E-est,Time) over the Time to get
+//           fAlphaEest(Alpha,E-est)
+// 
+TH2D *MHAlphaEnergyTime::IntegrateTime(const char *title, Bool_t draw)
+{
+    Int_t nzbins = fHist.GetNbinsZ();
+    TAxis &axez  = *fHist.GetZaxis();
+    axez.SetRange(1,nzbins);
+
+    TH2D &fAlphaEest = *(TH2D *)fHist.Project3D("exy");
+
+    fAlphaEest.SetTitle(title);
+    fAlphaEest.SetXTitle("E-est [GeV]            ");
+    fAlphaEest.SetYTitle("\\alpha  [  \\circ]");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlphaEest.DrawCopy();
+      gPad->SetLogx();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlphaEest;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist     (Alpha,E-est,Time) over E-est to get
+//           fAlphaTime(Alpha,Time)
+// 
+TH2D *MHAlphaEnergyTime::IntegrateEest(const char *title, Bool_t draw)
+{
+    Int_t nybins = fHist.GetNbinsY();
+    TAxis &axey  = *fHist.GetYaxis();
+    axey.SetRange(1,nybins);
+
+    TH2D &fAlphaTime = *(TH2D *)fHist.Project3D("exz");
+
+    fAlphaTime.SetTitle(title);
+    fAlphaTime.SetXTitle("Time [s]");
+    fAlphaTime.SetYTitle("\\alpha  [  \\circ]");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlphaTime.DrawCopy();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlphaTime;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist (Alpha,E-est,Time) over Eest and Time to get
+//           fAlpha(Alpha)
+// 
+TH1D *MHAlphaEnergyTime::IntegrateEestTime(const char *title, Bool_t draw)
+{
+    Int_t nybins = fHist.GetNbinsY();
+    TAxis &axey  = *fHist.GetYaxis();
+    axey.SetRange(1,nybins);
+
+    Int_t nzbins = fHist.GetNbinsZ();
+    TAxis &axez  = *fHist.GetZaxis();
+    axez.SetRange(1,nzbins);
+
+    TH1D &fAlpha = *(TH1D *)fHist.Project3D("ex");
+
+    fAlpha.SetTitle(title);
+    fAlpha.SetXTitle("\\alpha  [  \\circ]");
+    fAlpha.SetYTitle("Counts");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlpha.DrawCopy();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlpha;
+}
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHAlphaEnergyTime.h	(revision 1638)
@@ -0,0 +1,58 @@
+#ifndef MARS_MHAlphaEnergyTime
+#define MARS_MHAlphaEnergyTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include "TH3.h"
+#endif
+
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MHillasSrc;
+class MEnergyEst;
+class MTime;
+class TH2D;
+class MParList;
+
+class MHAlphaEnergyTime : public MH
+{
+private:
+    MHillasSrc *fHillas; //!
+    MEnergyEst *fEnergy; //!
+    MTime      *fTime;   //!
+
+    TH3D    fHist;
+
+public:
+    MHAlphaEnergyTime(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH3D *GetHist()       { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    TH2D *IntegrateTime    (const char *title, Bool_t Draw);
+    TH2D *IntegrateEest    (const char *title, Bool_t Draw);
+    TH1D *IntegrateEestTime(const char *title, Bool_t Draw);
+   
+    ClassDef(MHAlphaEnergyTime, 1) //3D-histogram in alpha, Energy and time
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.cc	(revision 1638)
@@ -0,0 +1,720 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHArray
+//
+//  is a sequential collection of mars histograms. If the given index to
+//  call the Fill function of the histogram excceeds the size of the
+//  array by 1 a new entry is created.
+//
+//  With Set/Inc/DecIndex you may specify the actual index of the histogram
+//  wich should be filles by Fill.
+//
+//  Use GetH to get the current histogram, the []-operator get the histogram
+//  by its index.
+//
+//  To access the histograms by a key instead of an index use SetIndexByKey
+//  instead of Set/Inc/DecIndex. It will take the integerpart of the
+//  floating point value (2 in case of 2.9). For each new key a new
+//  index in the Mapping Table is created. So that you can access your
+//  histograms by the key (eg in case of the Angle Theta=23.2deg use
+//  SetIndexByKey(23.2)
+//
+//  If the index is equal to the number of histograms in the array a call
+//  to the Fill-member-function will create a new histogram.
+//
+//  In the constructor istempl leads to two different behaviours of the
+//  MHArray:
+//
+//  - istempl=kTRUE tells MHArray to use the first histogram retrieved from
+//    the Parameterlist by hname to be used as a template. New histograms
+//    are not created using the root dictionary, but the New-member function
+//    (see MParConatiner)
+//  - In the case istempl=kFALSE new histograms are created using the root
+//    dictionary while hname is the class name. For the creation their
+//    default constructor is used.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHArray.h"
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TStyle.h>
+#include <TGaxis.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+#include <TPaveStats.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MParContainer.h"
+
+#include "MBinning.h"
+
+ClassImp(MHArray);
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MMap
+//
+// This class maps a key-value to a given value. In its simple versions it
+// maps a key to an index.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <TArrayI.h>
+
+class MMap
+{
+private:
+    TArrayI fKeys;
+    TArrayI fValues;
+
+    Int_t K(Int_t i) const { return ((TArrayI)fKeys)[i]; }
+    Int_t V(Int_t i) const { return ((TArrayI)fValues)[i]; }
+
+public:
+    // --------------------------------------------------------------------------
+    //
+    // Return the size of the table
+    //
+    Int_t GetSize() const
+    {
+        return fKeys.GetSize();
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Get the value which corresponds to the given key-value
+    //
+    Int_t GetValue(Int_t key) const
+    {
+        const Int_t n = fKeys.GetSize();
+        for (int i=0; i<n; i++)
+        {
+            if (K(i)==key)
+                return V(i);
+        }
+        return -1;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Get the key which corresponds to the given index
+    //
+    Int_t GetKey(Int_t value) const
+    {
+        const Int_t n = fKeys.GetSize();
+        for (int i=0; i<n; i++)
+        {
+            if (V(i)==value)
+                return K(i);
+        }
+        return -1;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Adds a new pair key-value. While the key is the key to the value.
+    // if the key already exists the pair is ignored.
+    //
+    void Add(Int_t key, Int_t value)
+    {
+        if (GetValue(key)>=0)
+            return;
+
+        const Int_t n = fKeys.GetSize();
+
+        fKeys.Set(n+1);
+        fValues.Set(n+1);
+
+        fKeys[n] = key;
+        fValues[n] = value;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Adds a new pair key-value. While the key is the key to the value.
+    // In this case the value is an automatically sequential created index.
+    // if the key already exists the pair is ignored.
+    //
+    Int_t Add(Int_t key)
+    {
+        const Int_t k = GetValue(key);
+        if (k>=0)
+            return k;
+
+        const Int_t n = fKeys.GetSize();
+
+        fKeys.Set(n+1);
+        fValues.Set(n+1);
+
+        fKeys[n] = key;
+        fValues[n] = n;
+
+        return n;
+    }
+};
+
+// --------------------------------------------------------------------------
+//
+// hname is the name of the histogram class which is in the array.
+//
+// istempl=kTRUE tells MHArray to use the first histogram retrieved from the
+// ParameterList by hname to be used as a template. New histograms are not
+// created using the root dictionary, but the New-member function (see
+// MParConatiner)
+// In the case istempl=kFALSE new histograms are created using the root
+// dictionary while hname is the class name. For the creation their
+// default constructor is used.
+//
+MHArray::MHArray(const TString hname, Bool_t istempl, const char *name, const char *title)
+    : fIdx(0), fClass(NULL), fTemplate(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHArray";
+    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hname);
+
+    fMapIdx = new MMap;
+
+    fArray = new TList;
+    fArray->SetOwner();
+
+    if (istempl)
+    {
+        fTemplateName = hname;
+        return;
+    }
+
+    //
+    // try to get class from root environment
+    //
+    fClass = gROOT->GetClass(hname);
+    if (!fClass)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        *fLog << err << dbginf << "Class '" << hname << "' not existing in dictionary." << endl;
+    }
+
+    //
+    // check for ineritance from MH
+    //
+    if (!fClass->InheritsFrom(MH::Class()))
+    {
+        //
+        // if class doesn't inherit from MH --> error
+        //
+        *fLog << err << dbginf << "Class '" << hname << "' doesn't inherit from MH." << endl;
+        fClass = NULL;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. hname is the name of the histogram class which
+// is in the array.
+//
+// istempl=kTRUE tells MHArray to use the first histogram retrieved from the
+// ParameterList by hname to be used as a template. New histograms are not
+// created using the root dictionary, but the New-member function (see
+// MParConatiner)
+// In the case istempl=kFALSE new histograms are created using the root
+// dictionary while hname is the class name. For the creation their
+// default constructor is used.
+//
+MHArray::MHArray(const MH *hist, const char *name, const char *title)
+    : fIdx(0), fClass(NULL), fTemplate(hist), fTemplateName("<dummy>")
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHArray";
+    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hist->GetName());
+
+    fMapIdx = new MMap;
+
+    fArray = new TList;
+    fArray->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor: Deleteing the array and all histograms which are part of the
+// array.
+//
+MHArray::~MHArray()
+{
+    fArray->Delete();
+    delete fArray;
+    delete fMapIdx;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this to access the histograms by a key. If you use values like
+//   (in this order) 2.5, 7.2, 2.5, 9.3, 9.3, 3.3, 2.2, 1.1
+//  it will be mapped to the following indices internally:
+//                    0    1    0    2    2    3    4    5
+//
+//  WARNING: Make sure that you don't create new histograms by setting
+//           a new index (SetIndex or IncIndex) which is equal the size
+//           of the array and create new histogram by CreateH. In this
+//           case you will confuse the mapping completely.
+//
+void MHArray::SetIndexByKey(Double_t key)
+{
+    fIdx = fMapIdx->Add((Int_t)key);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access a histogram by its index in the array.
+//  Becarefull the index isn't checked!
+//
+MH &MHArray::operator[](Int_t i)
+{
+    return *(MH*)fArray->At(i);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access a histogram by its index in the array.
+//  Becarefull the index isn't checked!
+//
+MH *MHArray::At(Int_t i)
+{
+    return (MH*)fArray->At(i);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access the histogram corresponding to the
+//  currently set index (by Set/Inc/DecIndex or SetIndexByKey)
+//  Becarefull the index set isn't checked!
+//
+MH *MHArray::GetH()
+{
+    return (MH*)fArray->At(fIdx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to create a new histogram, adds it as last entry to the array
+// and tries to call SetupFill for it. In case of success the last entry
+// in the array is the new histogram and kTRUE is returned. Otherwise
+// kFALSE is returned.
+//
+Bool_t MHArray::CreateH()
+{
+    TString cname = fClass ? fClass->GetName() : fTemplate->IsA()->GetName();
+
+    MH *hist = NULL;
+    if (fTemplate)
+    {
+        //
+        // create the parameter container as a clone of the existing
+        // template histogram.
+        //
+        hist = (MH*)fTemplate->New();
+    }
+    else
+    {
+        //
+        // create the parameter container of the the given class type
+        //
+        hist = (MH*)fClass->New();
+    }
+    if (!hist)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '";
+        *fLog << cname << "' (Maybe no def. constructor)" << endl;
+        return kFALSE;
+    }
+
+    //
+    // Set the name of the container
+    //
+    if (!fTemplate)
+    {
+        TString name = TString(hist->GetName())+";";
+        name += fIdx;
+
+        hist->SetName(name);
+    }
+
+    //
+    // Try to setup filling for the histogram
+    //
+    if (!hist->SetupFill(fParList))
+    {
+        *fLog << err << dbginf << "SetupFill for new histogram of type '";
+        *fLog << cname << "' with Index #" << fIdx << " failed." << endl;
+        delete hist;
+        return kFALSE;
+    }
+
+    fArray->AddLast(hist);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns kFALSE if the class couldn't be found in the root dictionary or
+// if it doesn't inherit from MH.
+// The parameter list is remembert to be used for SetupFill in case a new
+// histogram is created.
+// The index is reset to 0
+//
+Bool_t MHArray::SetupFill(const MParList *pList)
+{
+    fParList = pList;
+    fIdx = 0;
+
+    if (fTemplate)
+        return kTRUE;
+
+    if (!fTemplateName.IsNull())
+    {
+        fTemplate = (MH*)pList->FindObject(fTemplateName, "MH");
+        return fTemplate ? kTRUE : kFALSE;
+    }
+
+    return fClass ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call Fill for the present histogram index. If the index is out of
+// bounds the event is skipped. If the index is the number of current
+// histograms in the array a new histogram is created and if creation was
+// successfull filled.
+//
+Bool_t MHArray::Fill(const MParContainer *par)
+{
+    const Int_t n = fArray->GetSize();
+
+    if (fIdx<0 || fIdx>n)
+    {
+        *fLog << warn << "Histogram Index #" << fIdx << " out of bounds (>";
+        *fLog << n << ")... skipped." << endl;
+        return kCONTINUE;
+    }
+
+    if (fIdx==n)
+        if (!CreateH())
+            return kFALSE;
+
+    return GetH()->Fill(par);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls Finalize for all histograms in the list. If at least one Finalize
+// fails kFALSE is returned.
+//
+Bool_t MHArray::Finalize()
+{
+    Bool_t rc = kTRUE;
+
+    TIter Next(fArray);
+    MH *hist = NULL;
+
+    while ((hist=(MH*)Next()))
+        if (!hist->Finalize())
+            rc = kFALSE;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the number of entries in the array
+//
+void MHArray::Print(Option_t *option) const
+{
+    *fLog << all << GetDescriptor() << " contains " << fArray->GetSize();
+    *fLog << " histograms." << endl;
+
+    if (fMapIdx->GetSize()<=0)
+        return;
+
+    *fLog << " idx\t     key" << endl;
+    for (int i=0; i<fMapIdx->GetSize(); i++)
+        *fLog << "  " << i << "\t<-->  " << fMapIdx->GetKey(i) << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds the given object to the given legend (if != NULL). The Legend
+// entry name is created from the key...
+//
+void MHArray::AddLegendEntry(TLegend *leg, TObject *obj, Int_t idx) const
+{
+    if (!leg)
+        return;
+
+    TString name = " ";
+    name += fMapIdx->GetKey(idx);
+    leg->AddEntry(obj, name, "lpf"); // l=line, p=polymarker, f=fill
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The option is the name of the histogram, used to get a histogram from
+// the MH entries by calling their GetHist function.
+//
+void MHArray::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(this);
+
+    const Stat_t sstyle = gStyle->GetOptStat();
+    gStyle->SetOptStat(0);
+
+    //
+    // if the keymapping is used create a legend to identify the histograms
+    //
+    TLegend *leg = NULL;
+    if (fMapIdx->GetSize()>0)
+    {
+        leg = new TLegend(0.85, 0.80, 0.99, 0.99);
+        leg->SetBit(kCanDelete);
+    }
+
+    TIter Next(fArray);
+    MH *hist = (MH*)Next();
+
+    Int_t idx=0;
+    Double_t max=0;
+    Double_t min=0;
+
+    TH1 *h1=NULL;
+
+    //
+    // If the array has at least one entry:
+    //  - find the starting boundaries
+    //  - draw it and set its line color
+    //
+    if (hist)
+    {
+        if ((h1 = hist->GetHistByName(opt)))
+        {
+            h1->Draw();
+            h1->SetLineColor(idx+2);
+            max = h1->GetMaximum();
+            min = h1->GetMinimum();
+
+            AddLegendEntry(leg, h1, idx);
+        }
+    }
+
+    //
+    // For all following histograms:
+    //  - update the boundaries
+    //  - draw it and set its line color
+    //
+    while ((hist=(MH*)Next()))
+    {
+        TH1 *h=NULL;
+
+        if (!(h = hist->GetHistByName(opt)))
+            continue;
+
+        h->Draw("same");
+        h->SetLineColor(idx+2);
+        if (max<h->GetMaximum())
+            max = h->GetMaximum();
+        if (min>h->GetMinimum())
+            min = h->GetMinimum();
+
+        AddLegendEntry(leg, h, idx++);
+    }
+
+    //
+    // Now update the drawing region so that everything is displayed
+    //
+    if (h1)
+    {
+        h1->SetMinimum(min>0 ? min*0.95 : min*1.05);
+        h1->SetMaximum(max>0 ? max*1.05 : max*0.95);
+    }
+
+    if (leg)
+        leg->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+
+    gStyle->SetOptStat(sstyle);
+}
+
+// --------------------------------------------------------------------------
+//
+// The option is the name of the histogram, used to get a histogram from
+// the MH entries by calling their GetHistByName function.
+// If the option also contains 'nonew' no new canvas is created.
+// The option "Scale=1" scales the area of all histogram to 1
+// The option "Scale=max" scales the maximum of all histogram to 1
+//
+TObject *MHArray::DrawClone(Option_t *opt) const
+{
+    TString o(opt);
+
+    TCanvas *c = NULL;
+
+    Int_t scale1   = o.Index("scale=1",   TString::kIgnoreCase);
+    Int_t scalemax = o.Index("scale=max", TString::kIgnoreCase);
+    Int_t nonew    = o.Index("nonew",     TString::kIgnoreCase);
+
+    if (o.BeginsWith("scale=1", TString::kIgnoreCase))
+        scale1 = 0;
+    if (o.BeginsWith("scale=max", TString::kIgnoreCase))
+        scalemax = 0;
+    if (o.BeginsWith("nonew", TString::kIgnoreCase))
+        nonew = 0;
+
+    if (nonew>=0)
+    {
+        c = MH::MakeDefCanvas(this);
+
+        //
+        // This is necessary to get the expected bahviour of DrawClone
+        //
+        gROOT->SetSelectedPad(NULL);
+
+        o.Remove(nonew, 5);
+    }
+    if (scale1>=0)
+        o.Remove(scale1, 7);
+    if (scalemax>=0)
+        o.Remove(scalemax, 9);
+
+    const Stat_t sstyle = gStyle->GetOptStat();
+    gStyle->SetOptStat(0);
+
+    //
+    // if the keymapping is used create a legend to identify the histograms
+    //
+    TLegend *leg = NULL;
+    if (fMapIdx->GetSize()>0)
+    {
+        leg = new TLegend(0.85, 0.80, 0.99, 0.99);
+        leg->SetBit(kCanDelete);
+    }
+
+    TIter Next(fArray);
+    MH *hist = (MH*)Next();
+
+    Int_t idx=0;
+    Double_t max=0;
+    Double_t min=0;
+
+    TH1 *h1=NULL;
+
+     //
+    // If the array has at least one entry:
+    //  - find the starting boundaries
+    //  - draw it and set its line color
+    //
+    if (hist)
+    {
+        if ((h1 = hist->GetHistByName(o)))
+        {
+            h1 = (TH1*)h1->DrawCopy();
+
+            if (scale1>=0)
+                h1->Scale(1./h1->Integral());
+            if (scalemax>=0)
+                h1->Scale(1./h1->GetMaximum());
+
+            h1->SetMarkerColor(idx);
+            h1->SetLineColor(idx+2);
+            h1->SetFillStyle(4000);
+            max = h1->GetMaximum();
+            min = h1->GetMinimum();
+
+            AddLegendEntry(leg, h1, idx++);
+        }
+    }
+
+    //
+    // For all following histograms:
+    //  - update the boundaries
+    //  - draw it and set its line color
+    //
+    while ((hist=(MH*)Next()))
+    {
+        TH1 *h=NULL;
+
+        if (!(h = hist->GetHistByName(o)))
+            continue;
+
+        h = (TH1*)h->DrawCopy("same");
+
+        if (scale1>=0)
+            h->Scale(1./h->Integral());
+        if (scalemax>=0)
+            h->Scale(1./h->GetMaximum());
+
+        h->SetMarkerColor(idx);
+        h->SetLineColor(idx+2);
+        h->SetFillStyle(4000); // transperent (why is this necessary?)
+        if (max<h->GetMaximum())
+            max = h->GetMaximum();
+        if (min>h->GetMinimum())
+            min = h->GetMinimum();
+
+        AddLegendEntry(leg, h, idx++);
+    }
+
+    //
+    // Now update the drawing region so that everything is displayed
+    //
+    if (h1)
+    {
+        h1->SetMinimum(min>0 ? min*0.95 : min*1.05);
+        h1->SetMaximum(max>0 ? max*1.05 : max*0.95);
+    }
+
+    if (leg)
+        leg->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+
+    gStyle->SetOptStat(sstyle);
+
+    return c;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHArray.h	(revision 1638)
@@ -0,0 +1,63 @@
+#ifndef MARS_MHArray
+#define MARS_MHArray
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TList;
+class TLegend;
+
+class MMap;
+
+class MHArray : public MH
+{
+private:
+    Int_t  fIdx;              // current index for the fill function
+    TList *fArray;            //-> Array storing the histograms
+
+    const MParList *fParList; //! pointer to parameter list used for SetupFill when a new Hist is created
+    TClass *fClass;           // pointer to class entry in root dictionary
+
+    const MH *fTemplate;      //-> pointer to a template histogram
+    TString fTemplateName;    // name of the template class
+
+    MMap *fMapIdx;            //! Table to map keys to array indices
+
+    Bool_t CreateH();
+    void   AddLegendEntry(TLegend *leg, TObject *obj, Int_t idx) const;
+
+    enum { kUseTemplate=BIT(14) };
+
+public:
+    MHArray(const TString hname, Bool_t istempl=kFALSE, const char *name=NULL, const char *title=NULL);
+    MHArray(const MH *hist, const char *name=NULL, const char *title=NULL);
+    ~MHArray();
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+    virtual Bool_t Finalize();
+
+    MH &operator[](Int_t i);
+    MH *At(Int_t i);
+
+    MH *GetH();
+
+    void SetIndexByKey(Double_t key);
+
+    void SetIndex(Int_t i) { fIdx=i; }
+    void IncIndex() { fIdx++; }
+    void DecIndex() { fIdx--; }
+
+    Int_t GetIndex() const { return fIdx; }
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+    TObject *DrawClone(Option_t *opt="") const;
+
+    ClassDef(MHArray, 0) //A histogram class for an array of Mars histograms
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.cc	(revision 1638)
@@ -0,0 +1,241 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz, 5/2002 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHCompProb
+//
+// This class contains different histograms of the Hillas parameters
+//   and composite probabilities based on them.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHCompProb.h"
+
+#include <TH2.h>
+#include <TPad.h>
+#include <TText.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TProfile.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MDataChain.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHCompProb);
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms
+//
+MHCompProb::MHCompProb(Int_t nbins, const char *name, const char *title)
+    : fNumLoop(0)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCompProb";
+    fTitle = title ? title : "Gamma/Hadron Separation Quality Histograms";
+
+    fData    = new TList;
+    fRules   = new TList;
+    fHists   = new TList;
+    fHistVar = new TList;
+
+    fData->SetOwner();
+    fRules->SetOwner();
+    fHists->SetOwner();
+    fHistVar->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHCompProb::~MHCompProb()
+{
+    delete fData;
+    delete fRules;
+    delete fHists;
+    delete fHistVar;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::Add(const char *rule, Int_t n, Float_t min, Float_t max)
+{
+    MDataChain &chain = *new MDataChain(rule);
+    fData->Add(&chain);
+
+    TNamed &name = *new TNamed(rule, "");
+    fRules->Add(&name);
+
+    TH1D &hist = *new TH1D(Form("Hist_%s", rule), rule, n, min, max);
+    hist.SetXTitle(rule);
+    hist.SetYTitle("Counts");
+    hist.SetDirectory(NULL);
+    fHists->Add(&hist);
+
+    TH1D &varhist = *new TH1D;
+    varhist.SetName(Form("Var_%s", rule));
+    varhist.SetTitle(rule);
+    varhist.SetXTitle(rule);
+    varhist.SetYTitle("Counts");
+    varhist.SetDirectory(NULL);
+    fHistVar->Add(&varhist);
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::SetupFill(const MParList *plist)
+{
+    if (fData->GetSize()==0)
+    {
+        *fLog << err << "No data members spcified for usage... aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(fData);
+    MData *data=NULL;
+    while ((data=(MData*)Next()))
+        if (!data->PreProcess(plist))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::Fill(TList &list)
+{
+    MData *data = NULL;
+
+    TIter NextD(fData);
+    TIter NextH(&list);
+
+    while ((data=(MData*)NextD()))
+    {
+        TH1D *hist = (TH1D*)NextH();
+        hist->Fill(data->GetValue());
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::Fill(const MParContainer *par)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    switch (fNumLoop)
+    {
+    case 0:  // First loop : fill the fixed-bin histograms with gammas.
+        if (mcevt.GetPartId() == kGAMMA)
+            Fill(*fHists);
+        return kTRUE;
+
+    case 1:   //  Second Loop: fill the variable-bin histograms with protons.
+        if (mcevt.GetPartId() != kGAMMA)
+            Fill(*fHistVar);
+        return kTRUE;
+    default:
+        *fLog << err << "Error - Invalid Loop Number... aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::Finalize()
+{
+    switch (fNumLoop++)
+    {
+    case 0:
+        *fLog << inf << "Finished filling fixed bin size histograms with gamma-data." << endl;
+        SetBinningHistVar();
+        fHists->Delete();
+        return kTRUE;
+    case 1:
+        *fLog << inf << "Finished filling variable bin size histogram with proton data." << endl;
+        return kTRUE;
+    default:
+        *fLog << err << "Error - Invalid Loop Number... aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::SetBinningHistVar()
+{
+    Int_t nedges = 51; // Number of bins in variable-bin histograms.
+
+    TIter NextH(fHists);
+    TIter NextV(fHistVar);
+    TH1D *hist = NULL;
+    while ((hist=(TH1D*)NextH()))
+    {
+        Int_t n = hist->GetNbinsX();
+
+        TArrayD edges(nedges);
+
+        edges[0]        = hist->GetBinLowEdge(1);
+        edges[nedges-1] = hist->GetBinLowEdge(n+1);
+
+        Float_t newwidth = hist->Integral(1, n)/nedges;
+
+        Int_t jbin = 1;
+        for (Int_t j=1; j<n && jbin<nedges-1; j++)
+        {
+            if (hist->Integral(1, j) <= jbin*newwidth)
+                continue;
+
+            edges[jbin++] = hist->GetBinLowEdge(j+1);
+        }
+
+        MBinning bins;
+        bins.SetEdges(edges);
+
+        SetBinning((TH1D*)NextV(), &bins);
+    }
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHCompProb.h	(revision 1638)
@@ -0,0 +1,40 @@
+#ifndef MARS_MHCompProb
+#define MARS_MHCompProb
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MParList;
+
+class MHCompProb : public MH
+{
+private:
+    Int_t fNumLoop;   //! Counter of the loop (two eventloops needed)
+
+    TList *fRules;    // Rules describing the used data sets
+
+    TList *fData;     //! MDataChain objects
+    TList *fHists;    //! fixed bin size histograms
+    TList *fHistVar;  // variable bin size histograms
+
+    void Fill(TList &list);
+    void SetBinningHistVar();
+
+public:
+    MHCompProb(Int_t nbins, const char *name=NULL, const char *title=NULL);
+    ~MHCompProb();
+
+    void Add(const char *rule, Int_t n, Float_t min, Float_t max);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+    const TList *GetRules() const   { return fRules; }
+    TList *GetHistVar() const { return fHistVar; }
+
+    ClassDef(MHCompProb, 1) // Histogram to be used for the calculation of the composite probabilities
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.cc	(revision 1638)
@@ -0,0 +1,453 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 5/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTime                                                             //
+//                                                                          //
+//  calculates the effective on time for each bin in the variable Var       //
+//             (Var may be time or Theta)                                   //
+//                                                                          //
+//  Important : The sample of events used for this should be as close       //
+//              to the sample of recorded events as possible.               //
+//              This means that NO additional cuts (be it quality cuts or   //
+//              gamma/hadron cuts) should be applied (see MAGIC-TDAS 02-02).//
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTime.h"
+
+#include <TStyle.h>
+
+#include <TMinuit.h>
+#include <TFitter.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHEffOnTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets the name of the variable ("Time" or "Theta")
+//                      and the units of the variable ("[s]" or "[\\circ])")
+//
+MHEffOnTime::MHEffOnTime(const char *varname, const char *unit)
+    : fHEffOn(), fHProb(), fHLambda(), fHRdead()
+{
+    fVarname  = varname;
+    fUnit     = unit;
+
+    TString strg(fVarname);
+    strg += "  ";
+    strg += fUnit;
+
+    //
+    //   set the name and title of this object
+    //
+    TString strg1("MHEffOnTime-");
+    strg1 += fVarname;
+    fName  = strg1;
+    fTitle =  "1-D histogram of Eff On Time";
+
+    // effective on time versus Var
+    fHEffOn.SetName("EffOn");
+    TString strg2("effective On Time vs. ");
+    strg2 += fVarname;
+    fHEffOn.SetTitle(strg2);
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle(strg);
+    fHEffOn.SetYTitle("effective ontime [s]");
+
+    // chi2-probability versus Var
+    fHProb.SetName("Chi2-prob");
+    TString strg3("Chi2-prob of OnTimeFit vs. ");
+    strg3 += fVarname;
+    fHProb.SetTitle(strg3);
+
+    fHProb.SetDirectory(NULL);
+
+    fHProb.SetXTitle(strg);
+    fHProb.SetYTitle("chi2-probability");
+
+    // lambda versus Var
+    fHLambda.SetName("lambda");
+    TString strg4("lambda from OnTimeFit vs. ");
+    strg4 += fVarname;
+    fHLambda.SetTitle(strg4);
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle(strg);
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // Rdead versus Var
+    // Rdead is the fraction from real time lost by the dead time
+    fHRdead.SetName("Rdead");
+    TString strg5("Rdead of  OnTimeFit vs. ");
+    strg5 += fVarname;
+    fHRdead.SetTitle(strg5);
+
+    fHRdead.SetDirectory(NULL);
+
+    fHRdead.SetXTitle(strg);
+    fHRdead.SetYTitle("Rdead");
+
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTime::Calc(TH2D *hist, const Bool_t Draw)
+{
+     // Draw != 0   means the distribution of time differences should be drawn
+
+    // nbins = number of Var bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    // start  of 'for' loop ---------------------------
+    for (int i=1; i<=nbins; i++)
+    {
+      TString strg0("Calc-");
+      strg0 += fVarname;
+      TH1D &h = *hist->ProjectionX(strg0, i, i, "E");
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h.GetQuantiles(2,yq,xq);
+
+        const Int_t    jbins  = h.GetNbinsX();
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHProb.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHRdead.SetBinContent (i, 1.e-20);
+
+	// start  of 'if' loop ---------------------------
+        if (Nm > 0.0)
+        {
+	    // del is bin width in time difference
+            const Double_t del = Nmdel/Nm;
+
+            Double_t sum1 = 0.0;
+            yq[0]  = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*Nm)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+        
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                const Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*Nm || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0           with N0 = ideal number of events
+            // parameter 2 = del (fixed)  with del = bin width of time difference
+
+            TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+            func.FixParameter(2, del); 
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nm);
+
+            func.SetParLimits(0,   0,  1000);    // [Hz]
+            func.SetParLimits(1,   0, 10*Nm);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "N0");
+            func.SetParName(2, "del");
+
+            // options : 0  (=zero) do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0     = func.GetParameter(1);
+	    // const Double_t chi2   = func.GetChisquare();
+            const Double_t Prob   = func.GetProb();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0  &&  Prob>0.01  &&  lambda>0.0  &&  N0>0.0)
+            {
+	        // start error calculation .....................
+
+                Double_t emat[2][2];
+                // Double_t eplus, eminus, eparab, gcc;
+                gMinuit->mnemat(&emat[0][0], 2);
+
+                // for (int m=0; m<2; m++)
+                // {
+                //   *fLog << "emat[" << m << "][n] = "; 
+                //   for (int n=0; n<2; n++)
+		//   {
+                //     *fLog << emat[m][n] << "  ";
+		//   }
+                //   *fLog << endl;
+	        // }
+
+                // *fLog << "eplus, eminus, eparab, gcc :" << endl; 
+                // for (int k=0; k<2; k++)
+		// {
+                //   gMinuit->mnerrs(k, eplus, eminus, eparab, gcc);
+                //   *fLog << eplus << " " << eminus << " " << eparab << " "
+                //         << gcc << endl;
+		// }
+
+                // Rdead : fraction of real time lost by the dead time
+                // kappa = number of observed events (Nm) divided by
+                //         the number of genuine events (N0)
+                // Teff  : effective on-time
+
+                Double_t Rdead, kappa, Teff, dTeff, dldl, dl, dRdead;
+                Double_t dN0dN0;
+                //Double_t dldN0,lN0corr;
+                Teff  = Nm/lambda;
+                kappa = Nm/N0;
+                Rdead = 1.0 - kappa;
+
+                dldl   = emat[0][0];
+                dN0dN0 = emat[1][1];
+                // dldN0  = emat[0][1];
+
+                dTeff = Teff * sqrt(dldl/(lambda*lambda) + 1.0/Nm);
+                dl = sqrt(dldl);
+                dRdead = kappa * sqrt(dN0dN0/(N0*N0) + 1.0/Nm);
+
+                // lN0corr = dldN0 / sqrt(dldl * dN0dN0);
+                // *fLog << "MHEffOnTime : correlation between lambda and N0 = "
+                //       << lN0corr << endl;
+
+	        // end error calculation .....................
+
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i,  Teff);
+                fHEffOn.SetBinError  (i, dTeff);
+
+                // plot chi2-probability of fit
+                fHProb.SetBinContent(i, Prob);
+
+                // lambda from fit
+                fHLambda.SetBinContent(i, lambda);
+                fHLambda.SetBinError  (i,     dl);
+
+                // Rdead from fit
+                fHRdead.SetBinContent(i, Rdead);
+                fHRdead.SetBinError  (i,dRdead);
+            }
+
+	    //........................
+            // draw the distribution of time differences if requested
+	    //
+            if (Draw == kTRUE)
+	      {
+                char txt[100];
+                TString strg1(fVarname);
+                strg1 += "-bin %d";
+                sprintf(txt, strg1, i);
+		new TCanvas(txt, txt);
+                // TCanvas &c = *MakeDefCanvas(txt, txt);
+                // gROOT->SetSelectedPad(NULL);
+
+                gPad->SetLogy();
+                gStyle->SetOptFit(1011);
+                // gStyle->SetOptStat(1);
+
+                h.SetName(txt);
+                h.SetXTitle("time difference [s]");
+                h.SetYTitle("Counts");
+                h.DrawCopy();
+
+                func.SetRange(yq[0], yq[1]); // Range of Drawing
+                func.DrawCopy("same");
+
+		// c.Modified();
+                // c.Update();
+	      }
+	    //........................
+        }
+	// end  of 'if' loop ---------------------------
+
+        delete &h;
+    }
+    // end  of 'for' loop ---------------------------
+    //    gStyle->SetOptStat(1111);
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTime::SetupFill(const MParList *plist)
+{
+    TString strg0("Binning");
+    strg0 += fVarname;
+
+    const MBinning* binsVar = (MBinning*)plist->FindObject(strg0);
+
+    if (!binsVar)
+    {
+        *fLog << err << dbginf << strg0 
+              << " [MBinning] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHEffOn,  binsVar);
+    SetBinning(&fHProb,   binsVar);
+    SetBinning(&fHLambda, binsVar);
+    SetBinning(&fHRdead,  binsVar);
+
+    fHEffOn.Sumw2();
+    fHProb.Sumw2();
+    fHLambda.Sumw2();
+    fHRdead.Sumw2();
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Dummy Fill
+//
+Bool_t MHEffOnTime::Fill(const MParContainer *par)
+{
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHEffOnTime::DrawClone(Option_t *opt) const
+{
+    TString strg0("EffOnTime");
+    strg0 += fVarname;    
+    TString strg1("Results from on time fit vs. ");
+    strg1 += fVarname;    
+
+    TCanvas &c = *MakeDefCanvas(strg0, strg1);
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    ((TH2*)&fHEffOn)->DrawCopy(opt);
+
+    c.cd(2);
+    ((TH2*)&fHProb)->DrawCopy(opt);
+
+    c.cd(3);
+    ((TH2*)&fHLambda)->DrawCopy(opt);
+
+    c.cd(4);
+    ((TH2*)&fHRdead)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTime::Draw(Option_t *opt) 
+{
+    TString strg0("EffOnTime");
+    strg0 += fVarname;    
+    TString strg1("Results from on time fit vs. ");
+    strg1 += fVarname;    
+
+    if (!gPad)
+        MakeDefCanvas(strg0, strg1);
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    fHEffOn.Draw(opt);
+
+    gPad->cd(2);
+    fHProb.Draw(opt);
+
+    gPad->cd(3);
+    fHLambda.Draw(opt);
+
+    gPad->cd(4);
+    fHRdead.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTime.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHEffOnTime
+#define MARS_MHEffOnTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include "TH1.h"
+#endif
+
+class TH2D;
+class MParList;
+
+class MHEffOnTime : public MH
+{
+private:
+    TH1D fHEffOn;
+    TH1D fHProb;
+    TH1D fHLambda;
+    TH1D fHRdead;
+
+    const char *fVarname;
+    const char *fUnit;
+
+public:
+    MHEffOnTime(const char *varname=NULL, const char *unit=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(TH2D *hist, const Bool_t Draw);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHEffOnTime, 1) //1D-plot of Delta t vs. Var
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.cc	(revision 1638)
@@ -0,0 +1,323 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTimeTheta                                                        //
+//                                                                          //
+//  calculates the effective on time for each bin in Theta                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTimeTheta.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHEffOnTimeTheta);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histograms. 
+//
+MHEffOnTimeTheta::MHEffOnTimeTheta(const char *name, const char *title)
+    : fHEffOn()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHEffOnTimeTheta";
+    fTitle = title ? title : "1-D histogram of Eff On Time";
+
+    // effective on time versus theta
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle("Effective On Time vs. Theta");
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle("\\Theta [\\circ]");
+    fHEffOn.SetYTitle("t_{eff} [s]");
+
+    // chi2/NDF versus theta
+    fHChi2.SetName("Chi2/NDF");
+    fHChi2.SetTitle("Chi2/NDF of OnTimeFit vs. Theta");
+
+    fHChi2.SetDirectory(NULL);
+
+    fHChi2.SetXTitle("\\Theta [\\circ]");
+    fHChi2.SetYTitle("chi^{2}/NDF");
+
+    // lambda versus theta
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle("lambda of OnTimeFit vs. Theta");
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle("\\Theta [\\circ]");
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // N0del versus theta
+    fHN0del.SetName("N0del");
+    fHN0del.SetTitle("N0del of OnTimeFit vs. Theta");
+
+    fHN0del.SetDirectory(NULL);
+
+    fHN0del.SetXTitle("\\Theta [\\circ]");
+    fHN0del.SetYTitle("N0del");
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTimeTheta::Calc(TH2D *hist)
+{
+    // nbins = number of Theta bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    for (int i=1; i<=nbins; i++)
+    {
+        //        TH1D &h = *hist->ProjectionX("Calc-theta", i, i);
+        TH1D &h = *hist->ProjectionX("Calc-theta", i, i, "E");
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+        //        Double_t mean  = h->GetMean();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h->GetQuantiles(2,yq,xq);
+
+        const Double_t sumtot = h.Integral();
+        const Int_t    jbins  = h.GetNbinsX();
+
+        if (sumtot > 0.0)
+        {
+            Double_t sum1 = 0.0;
+            yq[0] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*sumtot)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*sumtot || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0*del        with N0 = ideal number of events
+            //                             and del = bin width of time difference
+            TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nmdel);
+
+            func.SetParLimits(0, 0, 1000);    // [Hz]
+            func.SetParLimits(1, 0, 10*Nmdel);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "Nmdel");
+
+            // options : 0  do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            // gPad->SetLogy();
+            // gStyle->SetOptFit(1011);
+            // h->GetXaxis()->SetTitle("time difference [s]");
+            // h->GetYaxis()->SetTitle("Counts");
+            // h->DrawCopy();
+
+            // func.SetRange(yq[0], yq[1]); // Range of Drawing
+            // func.DrawCopy("same");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0del  = func.GetParameter(1);
+            const Double_t chi2   = func.GetChisquare();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0 && chi2<2.5*NDF)
+            {
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i, Nm/lambda);
+
+                // plot chi2/NDF of fit
+                fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0);
+
+                // lambda of fit
+                fHLambda.SetBinContent(i, lambda);
+
+                // N0del of fit
+                fHN0del.SetBinContent(i, N0del);
+
+                delete &h;
+                continue;
+            }
+        }
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHChi2.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHN0del.SetBinContent (i, 1.e-20);
+
+        delete &h;
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTimeTheta::SetupFill(const MParList *plist)
+{
+   const MBinning* bins = (MBinning*)plist->FindObject("BinningTheta");
+   if (!bins)
+   {
+       *fLog << err << dbginf << "BinningTheta [MBinning] not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   SetBinning(&fHEffOn,  bins);
+   SetBinning(&fHChi2,   bins);
+   SetBinning(&fHLambda, bins);
+   SetBinning(&fHN0del,  bins);
+
+   fHEffOn.Sumw2();
+   fHChi2.Sumw2();
+   fHLambda.Sumw2();
+   fHN0del.Sumw2();
+
+   return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Dummy Fill
+// without it get the error message :
+// Error: MHEffOnTimeTime() no default constructor FILE:macros/wowflux.C LINE:359
+// *** Interpreter error recovered ***
+//
+Bool_t MHEffOnTimeTheta::Fill(const MParContainer *par)
+{
+  return kTRUE; 
+}     
+// -------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHEffOnTimeTheta::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("EffOnTimeTheta", "Results from on time fit vs. Theta");
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    ((TH2*)&fHEffOn)->DrawCopy(opt);
+
+    c.cd(2);
+    ((TH2*)&fHChi2)->DrawCopy(opt);
+
+    c.cd(3);
+    ((TH2*)&fHLambda)->DrawCopy(opt);
+
+    c.cd(4);
+    ((TH2*)&fHN0del)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTimeTheta::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("EffOnTimeTheta", "Results from on time fit vs. Theta");
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    fHEffOn.Draw(opt);
+
+    gPad->cd(2);
+    fHChi2.Draw(opt);
+
+    gPad->cd(3);
+    fHLambda.Draw(opt);
+
+    gPad->cd(4);
+    fHN0del.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTheta.h	(revision 1638)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHEffOnTimeTheta
+#define MARS_MHEffOnTimeTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include "TH1.h"
+#endif
+
+class MTime;
+class TH2D;
+class MParList;
+
+class MHEffOnTimeTheta : public MH
+{
+private:
+    TH1D fHEffOn;
+    TH1D fHChi2;
+    TH1D fHN0del;
+    TH1D fHLambda;
+
+public:
+    MHEffOnTimeTheta(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(TH2D *hist);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHEffOnTimeTheta, 1) //1D-plot of Delta t vs. Theta
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1638)
@@ -0,0 +1,334 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTimeTime                                                         //
+//                                                                          //
+//  calculates the effective on time for each bin in time                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTimeTime.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHEffOnTimeTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histograms.
+//
+MHEffOnTimeTime::MHEffOnTimeTime(const char *name, const char *title)
+    : fHEffOn()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHEffOnTimeTime";
+    fTitle = title ? title : "1-D histogram of Eff On Time";
+
+    // effective on time versus time
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle("Effective On Time vs. Time");
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle("time [s]");
+    fHEffOn.SetYTitle("t_{eff} [s]");
+
+    // chi2/NDF versus time
+    fHChi2.SetName("Chi2/NDF");
+    fHChi2.SetTitle("Chi2/NDF of OnTimeFit vs. Time");
+
+    fHChi2.SetDirectory(NULL);
+
+    fHChi2.SetXTitle("time [s]");
+    fHChi2.SetYTitle("chi^{2}/NDF");
+
+    // lambda versus time
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle("lambda of OnTimeFit vs. Time");
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle("time [s]");
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // N0del versus time
+    fHN0del.SetName("N0del");
+    fHN0del.SetTitle("N0del of OnTimeFit vs. Time");
+
+    fHN0del.SetDirectory(NULL);
+
+    fHN0del.SetXTitle("time [s]");
+    fHN0del.SetYTitle("N0del");
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTimeTime::Calc(TH2D *hist)
+{
+    // nbins = number of time bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    for (int i=1; i<=nbins; i++)
+    {
+
+        //        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+	//        Double_t mean  = h->GetMean();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h->GetQuantiles(2,yq,xq);
+
+        const Double_t sumtot = h.Integral();
+        const Int_t    jbins  = h.GetNbinsX();
+       
+        if (sumtot > 0.0)
+        {
+            // char txt[100];
+            // sprintf(txt, "time_bin:%d", i);
+            // new TCanvas(txt, txt);
+
+            Double_t sum1 = 0.0;
+            yq[0]  = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*sumtot)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+        
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                const Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*sumtot || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0*del        with N0 = ideal number of events
+            //                             and del = bin width of time difference
+            TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nmdel);
+
+            func.SetParLimits(0, 0, 1000);    // [Hz]
+            func.SetParLimits(1, 0, 10*Nmdel);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "Nmdel");
+
+            // options : 0  (=zero) do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            // gPad->SetLogy();
+            // gStyle->SetOptFit(1011);
+            // h->GetXaxis()->SetTitle("time difference [s]");
+            // h->GetYaxis()->SetTitle("Counts");
+            // h->DrawCopy();
+
+            // func.SetRange(yq[0], yq[1]); // Range of Drawing
+            // func.DrawCopy("same");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0del  = func.GetParameter(1);
+            const Double_t chi2   = func.GetChisquare();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0  &&  chi2<2.5*NDF)
+            {
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i, Nm/lambda);
+
+                // plot chi2/NDF of fit
+                fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0);
+
+                // lambda of fit
+                fHLambda.SetBinContent(i, lambda);
+
+                // N0del of fit
+                fHN0del.SetBinContent(i, N0del);
+
+                delete &h;
+                continue;
+            }
+        }
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHChi2.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHN0del.SetBinContent (i, 1.e-20);
+
+        delete &h;
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTimeTime::SetupFill(const MParList *plist)
+{
+    const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
+    if (!binstime)
+    {
+        *fLog << err << dbginf << "BinningTime [MBinning] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHEffOn,  binstime);
+    SetBinning(&fHChi2,   binstime);
+    SetBinning(&fHLambda, binstime);
+    SetBinning(&fHN0del,  binstime);
+
+    fHEffOn.Sumw2();
+    fHChi2.Sumw2();
+    fHLambda.Sumw2();
+    fHN0del.Sumw2();
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Dummy Fill
+// without it get error message :
+// Error: MHEffOnTimeTime() no default constructor FILE:macros/wowflux.C LINE:359
+//*** Interpreter error recovered ***
+Bool_t MHEffOnTimeTime::Fill(const MParContainer *par)
+{
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("EffOnTimeTime", "Results from on time fit vs. time");
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    ((TH2*)&fHEffOn)->DrawCopy(opt);
+
+    c.cd(2);
+    ((TH2*)&fHChi2)->DrawCopy(opt);
+
+    c.cd(3);
+    ((TH2*)&fHLambda)->DrawCopy(opt);
+
+    c.cd(4);
+    ((TH2*)&fHN0del)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTimeTime::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("EffOnTimeTime", "Results from on time fit vs. time");
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    fHEffOn.Draw(opt);
+
+    gPad->cd(2);
+    fHChi2.Draw(opt);
+
+    gPad->cd(3);
+    fHLambda.Draw(opt);
+
+    gPad->cd(4);
+    fHN0del.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEffOnTimeTime.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHEffOnTimeTime
+#define MARS_MHEffOnTimeTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include "TH1.h"
+#endif
+
+class MTime;
+class TH2D;
+class MParList;
+
+class MHEffOnTimeTime : public MH
+{
+private:
+    TH1D fHEffOn;
+    TH1D fHChi2;
+    TH1D fHLambda;
+    TH1D fHN0del;
+
+public:
+    MHEffOnTimeTime(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(TH2D *hist);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHEffOnTimeTime, 1) //1D-plot of Delta t vs. time
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.cc	(revision 1638)
@@ -0,0 +1,163 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEnergyTheta                                                           //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEnergyTheta.h"
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+#include "MParList.h"
+
+ClassImp(MHEnergyTheta);
+
+// --------------------------------------------------------------------------
+//
+//  Creates the three necessary histograms:
+//   - selected showers (input)
+//   - all showers (input)
+//   - collection area (result)
+//
+MHEnergyTheta::MHEnergyTheta(const char *name, const char *title)
+{ 
+    //   initialize the histogram for the distribution r vs E
+    //
+    //   we set the energy range from 1 Gev to 10000 GeV (in log 5 orders
+    //   of magnitude) and for each order we take 10 subdivision --> 50 xbins
+    //
+    //   we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
+
+  
+    fName  = name  ? name  : "MHEnergyTheta";
+    fTitle = title ? title : "Data to Calculate Collection Area";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("\\Theta [\\circ]");
+    fHist.SetZTitle("N");
+}
+
+Bool_t MHEnergyTheta::SetupFill(const MParList *plist)
+{
+    MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+    MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+    if (!binsenergy || !binstheta)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binsenergy, binstheta);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the three histograms
+//
+MHEnergyTheta::~MHEnergyTheta()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains all showers
+//
+Bool_t MHEnergyTheta::Fill(const MParContainer *par)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    fHist.Fill(mcevt.GetEnergy(), mcevt.GetTheta());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHEnergyTheta::Draw(Option_t* option)
+{
+    if (!gPad)
+        MakeDefCanvas(&fHist);
+
+    fHist.DrawCopy(option);
+    gPad->SetLogy();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+TObject *MHEnergyTheta::DrawClone(Option_t* option) const
+{
+    TCanvas *c = MakeDefCanvas(&fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH2D&)fHist).DrawCopy(option);
+    gPad->SetLogy();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHEnergyTheta::Divide(const TH2D *h1, const TH2D *h2)
+{
+    // Description!
+
+    fHist.Sumw2();
+    fHist.Divide((TH2D*)h1, (TH2D*)h2);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTheta.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHEnergyTheta
+#define MARS_MHEnergyTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MTime;
+class MParList;
+
+class MHEnergyTheta : public MH
+{
+private:
+    TH2D fHist; //! 
+
+public:
+
+    MHEnergyTheta(const char *name=NULL, const char *title=NULL);
+    ~MHEnergyTheta();
+
+    Bool_t Fill(const MParContainer *cont);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    Bool_t SetupFill(const MParList *plist);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Divide(const TH2D *h1, const TH2D *h2);
+    void Divide(const MHEnergyTheta *h1, const MHEnergyTheta *h2)
+    {
+        Divide(h1->GetHist(), h2->GetHist());
+    }
+
+    ClassDef(MHEnergyTheta, 1)  // Data Container to calculate Collection Area
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.cc	(revision 1638)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEnergyTime                                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEnergyTime.h" 
+
+#include <TCanvas.h>
+
+#include "MMcEvt.hxx"
+#include "MTime.h"
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MHEnergyTime);
+
+// --------------------------------------------------------------------------
+//
+//  Creates the three necessary histograms:
+//   - selected showers (input)
+//   - all showers (input)
+//   - collection area (result)
+//
+MHEnergyTime::MHEnergyTime(const char *name, const char *title)
+{ 
+    //   initialize the histogram for the distribution r vs E
+    //
+    //   we set the energy range from 1 Gev to 10000 GeV (in log 5 orders
+    //   of magnitude) and for each order we take 10 subdivision --> 50 xbins
+    //
+    //   we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
+
+  
+    fName  = name  ? name  : "MHEnergyTime";
+    fTitle = title ? title : "Data to Calculate Collection Area";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("t [s]");
+    fHist.SetZTitle("N");
+}
+
+Bool_t MHEnergyTime::SetupFill(const MParList *plist)
+{
+    fTime = (MTime*)plist->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << dbginf << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+    const MBinning* binstime   = (MBinning*)plist->FindObject("BinningTime");
+    if (!binsenergy || !binstime)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binsenergy, binstime);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the three histograms
+//
+MHEnergyTime::~MHEnergyTime()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains all showers
+//
+Bool_t MHEnergyTime::Fill(const MParContainer *par)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    fHist.Fill(mcevt.GetEnergy(), 0.0001*fTime->GetTimeLo());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHEnergyTime::Draw(Option_t* option)
+{
+    if (!gPad)
+        MakeDefCanvas(&fHist);
+
+    fHist.DrawCopy(option);
+    gPad->SetLogy();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+TObject *MHEnergyTime::DrawClone(Option_t* option) const
+{
+    TCanvas *c = MakeDefCanvas(&fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH2D&)fHist).DrawCopy(option);
+    gPad->SetLogy();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHEnergyTime::Divide(const TH2D *h1, const TH2D *h2)
+{
+    // Description!
+
+    fHist.Sumw2();
+    fHist.Divide((TH2D*)h1, (TH2D*)h2);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHEnergyTime.h	(revision 1638)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHEnergyTime
+#define MARS_MHEnergyTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MTime;
+class MParList;
+
+class MHEnergyTime : public MH
+{
+private:
+    MTime *fTime;
+    TH2D fHist; //! 
+
+public:
+
+    MHEnergyTime(const char *name=NULL, const char *title=NULL);
+    ~MHEnergyTime();
+
+    Bool_t Fill(const MParContainer *cont);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    Bool_t SetupFill(const MParList *plist);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Divide(const TH2D *h1, const TH2D *h2);
+    void Divide(const MHEnergyTime *h1, const MHEnergyTime *h2)
+    {
+        Divide(h1->GetHist(), h2->GetHist());
+    }
+
+    ClassDef(MHEnergyTime, 1)  // Data Container to calculate Collection Area
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.cc	(revision 1638)
@@ -0,0 +1,127 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHFadcCam
+//
+// This class contains a list of MHFadcPix.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHFadcCam.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MHFadcCam);
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  creates an a list of histograms for all pixels and both gain channels
+//
+MHFadcCam::MHFadcCam(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHFadcCam";
+    fTitle = title ? title : "Container for ADC spectra histograms";
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+    fArray = new TObjArray(577);
+
+    for (Int_t i=0; i<577; i++)
+        (*fArray)[i] = new MHFadcPix(i+1);
+}
+
+// --------------------------------------------------------------------------
+MHFadcCam::~MHFadcCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Our own clone function is necessary since root 3.01/06 or Mars 0.4
+// I don't know the reason
+//
+TObject *MHFadcCam::Clone(const char *) const
+{
+    MHFadcCam *cam = new MHFadcCam;
+
+    for (int i=0; i<577; i++)
+    {
+        delete (*cam->fArray)[i];
+        (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
+    }
+    return cam;
+}
+
+// --------------------------------------------------------------------------
+Bool_t MHFadcCam::Fill(const MParContainer *par)
+{
+    MRawEvtData *evt = (MRawEvtData*)par;
+
+    MRawEvtPixelIter pixel(evt);
+
+    const Int_t nhisamples = evt->GetNumHiGainSamples();
+    const Int_t nlosamples = evt->GetNumLoGainSamples();
+
+    while (pixel.Next())
+    {
+        const UInt_t id = pixel.GetPixelId();
+
+        for (Int_t i=0; i<nhisamples; i++)
+            FillHi(id, pixel.GetHiGainSamples()[i]);
+
+        if (!pixel.HasLoGain())
+            continue;
+
+        for (Int_t i=0; i<nlosamples; i++)
+            FillLo(id, pixel.GetLoGainSamples()[i]);
+    }
+
+    return kTRUE;
+}
+
+Bool_t MHFadcCam::Fill(const MRawEvtData *par)
+{
+    return Fill((MParContainer*)par);
+}
+
+void MHFadcCam::ResetHistograms()
+{
+    for (Int_t i=0; i<577; i++)
+    {
+        GetHistHi(i)->Reset();
+        GetHistLo(i)->Reset();
+    }
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcCam.h	(revision 1638)
@@ -0,0 +1,63 @@
+#ifndef MARS_MHFadcCam
+#define MARS_MHFadcCam
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef MARS_MHFadcPix
+#include "MHFadcPix.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MRawEvtData;
+
+class MHFadcCam : public MH
+{
+private:
+    TObjArray *fArray;	//-> List of Lo/Hi gain Histograms
+
+    void FillHi(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillHi(data); }
+    void FillLo(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillLo(data); }
+
+public:
+    MHFadcCam(const char *name=NULL, const char *title=NULL);
+    ~MHFadcCam();
+
+    MHFadcPix *operator[](UInt_t i) { return (MHFadcPix*)(fArray->At(i)); }
+    const MHFadcPix *operator[](UInt_t i) const { return (MHFadcPix*)(fArray->At(i)); }
+
+    TH1F *GetHistHi(UInt_t i)  { return (*this)[i]->GetHistHi(); }
+    TH1F *GetHistLo(UInt_t i)  { return (*this)[i]->GetHistLo(); }
+
+    const TH1F *GetHistHi(UInt_t i) const { return (*this)[i]->GetHistHi(); }
+    const TH1F *GetHistLo(UInt_t i) const { return (*this)[i]->GetHistLo(); }
+
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Fill(const MRawEvtData *par);
+
+    void ResetHistograms();
+
+    //
+    // FIXME! This should be replaced by a Draw(Option_t)-function
+    //
+    void DrawHi(UInt_t i)      { GetHistHi(i)->Draw(); }
+    void DrawLo(UInt_t i)      { GetHistLo(i)->Draw(); }
+
+    void DrawPix(UInt_t i)     { (*this)[i]->Draw(); }
+
+    Int_t GetEntries() const   { return fArray->GetEntries(); }
+
+    TObject *Clone(const char *opt="") const;
+
+    ClassDef(MHFadcCam, 1) // A list of histograms storing the Fadc spektrum of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.cc	(revision 1638)
@@ -0,0 +1,130 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHFadcPix
+//
+// This container stores a hostogram to display an Fadc Spekrtum.
+// The spektrum of all the values measured by the Fadcs.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHFadcPix.h"
+
+#include <TH1.h>
+#include <TPad.h>
+
+#include "MH.h"
+
+ClassImp(MHFadcPix);
+
+// --------------------------------------------------------------------------
+//
+// Creates the histograms for lo and hi gain of one pixel
+//
+MHFadcPix::MHFadcPix(UInt_t pixid) : fPixId(pixid)
+{
+    fHistHi =  new TH1F(pixid ? Form("HiGain%03d", pixid) : "HiGain",
+                        pixid ? Form("Hi Gain Pixel #%d", pixid) : "Hi Gain Samples",
+                        256, -.5, 255.5);
+
+    fHistHi->SetDirectory(NULL);
+    fHistHi->SetXTitle("Signal/FADC Units");
+    fHistHi->SetYTitle("Count");
+
+    fHistLo = new TH1F(pixid ? Form("LoGain%03d", pixid) : "LoGain",
+                       pixid ? Form("Lo Gain Pixel #%d", pixid) : "Lo Gain Samples",
+                       256, -.5, 255.5);
+
+    fHistLo->SetDirectory(NULL);
+    fHistLo->SetXTitle("Signal/FADC Units");
+    fHistLo->SetYTitle("Count");
+}
+
+// --------------------------------------------------------------------------
+MHFadcPix::~MHFadcPix()
+{
+    delete fHistHi;
+    delete fHistLo;
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::FillHi(Byte_t i)
+{
+    fHistHi->Fill(i);
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::FillLo(Byte_t i)
+{
+    fHistLo->Fill(i);
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::DrawHi()
+{
+    fHistHi->Draw();
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::DrawLo()
+{
+    fHistLo->Draw();
+}
+
+// --------------------------------------------------------------------------
+//
+// We need our own clone function to get rid of the histogram in any
+// directory
+//
+TObject *MHFadcPix::Clone(const char *) const
+{
+    MHFadcPix &pix = *(MHFadcPix*)TObject::Clone();
+
+    pix.fHistHi->SetDirectory(NULL);
+    pix.fHistLo->SetDirectory(NULL);
+
+    return &pix;
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::Draw(Option_t *)
+{
+    if (!gPad)
+    {
+        const char *name  = StrDup(fPixId ? Form("Pixel #%d", fPixId) : "Pixel");
+        MH::MakeDefCanvas(name, fPixId ? Form("%s FADC Samples", name) : "FADC Samples");
+        delete [] name;
+    }
+
+    gPad->Divide(1, 2);
+
+    gPad->cd(1);
+    fHistHi->Draw();
+
+    gPad->cd(2);
+    fHistLo->Draw();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFadcPix.h	(revision 1638)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHFadcPix
+#define MARS_MHFadcPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1F;
+
+class MHFadcPix : public MParContainer
+{
+private:
+    TH1F *fHistHi;
+    TH1F *fHistLo;
+
+    UInt_t fPixId;
+
+public:
+    MHFadcPix(UInt_t pixid=0);
+    ~MHFadcPix();
+
+    TH1F *GetHistHi() { return fHistHi; }
+    TH1F *GetHistLo() { return fHistLo; }
+
+    const TH1F *GetHistHi() const { return fHistHi; }
+    const TH1F *GetHistLo() const { return fHistLo; }
+
+    void FillHi(Byte_t i);
+    void FillLo(Byte_t i);
+
+    void DrawHi();
+    void DrawLo();
+
+    TObject *Clone(const char *) const;
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHFadcPix, 1) // Conatiner to hold two histograms container spektrums for the lo-/hi gain of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.cc	(revision 1638)
@@ -0,0 +1,700 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 5/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHFlux                                                                 //
+//                                                                          //
+//  calculates absolute photon fluxes                                       //
+//             from the distributions of the estimated energy               //
+//                      for the different bins in some variable 'Var'       //
+//                      (Var = Theta or time)                               //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHFlux.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TProfile.h>
+
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHFlux);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets the variable name (Theta or time)
+//                      and the units for the variable
+// 
+MHFlux::MHFlux(const TH2D &h2d,  const Bool_t Draw,
+	       const TString varname, const TString unit)
+    : fHOrig(), fHUnfold(), fHFlux()
+{
+    if (varname.IsNull() || unit.IsNull())
+        *fLog << warn << dbginf << "varname or unit not defined" << endl;
+
+    fVarname = varname;
+    fUnit    = unit;
+
+    TString strg(varname);
+    strg += unit;
+
+    // char txt[100];
+
+    // original distribution of E-est for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-est and %s",varname);
+
+    TString strg1 = "no.of gammas vs. E-est and ";
+    strg1 += varname;
+    
+    ((TH2D&)h2d).Copy(fHOrig);
+
+    fHOrig.SetName("E-est");
+    fHOrig.SetTitle(strg1);
+
+    fHOrig.SetDirectory(NULL);
+    fHOrig.SetXTitle("E-est [GeV]");
+    fHOrig.SetYTitle(strg);
+    fHOrig.Sumw2();
+
+    SetBinning((TH2*)&fHOrig, (TH2*)&h2d);
+
+
+    // unfolded distribution of E-unfold for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-unfold and %s",varname);
+    TString strg2 = "no.of gammas vs. E-unfold and ";
+    strg2 += varname;
+
+    fHUnfold.SetName("E-unfolded");
+    fHUnfold.SetTitle(strg2);
+
+    fHUnfold.SetDirectory(NULL);
+    fHUnfold.SetXTitle("E-unfold [GeV]");
+    fHUnfold.SetYTitle(strg);
+    fHUnfold.Sumw2();
+    
+    SetBinning((TH2*)&fHUnfold, (TH2*)&fHOrig);
+
+
+    // absolute photon flux vs. E-unfold
+    //          for different bins of the variable (Theta or time)
+    //
+    // sprintf(txt, "gamma flux [1/(s m2 GeV) vs. E-unfold and %s",varname);
+    TString strg3 = "gamma flux [1/(s m2 GeV) vs. E-unfold and ";
+    strg3 += varname;
+
+    fHFlux.SetName("photon flux");
+    fHFlux.SetTitle(strg3);
+
+    fHFlux.SetDirectory(NULL);
+    fHFlux.SetXTitle("E-unfold [GeV]");
+    fHFlux.SetYTitle(strg);
+    fHFlux.Sumw2();
+
+    SetBinning((TH2*)&fHFlux, (TH2*)&fHUnfold);
+
+
+    // copy fHOrig into fHUnfold in case no unfolding is done
+    const Int_t nEunf   = fHUnfold.GetNbinsX();
+    const Int_t nVar    = fHUnfold.GetNbinsY();
+    for (int m=1; m<=nEunf; m++)
+    {
+      for (int n=1; n<=nVar; n++)
+      {
+        Double_t cont  = fHOrig.GetBinContent(m,n);
+        Double_t dcont = fHOrig.GetBinError(m,n);
+        fHUnfold.SetBinContent(m,n,cont);
+        fHUnfold.SetBinError(m,n,dcont);
+      }
+    }
+  //..............................................
+  // draw the No.of photons vs. E-est 
+  // for the individual bins of the variable Var
+
+  if (Draw == kTRUE)
+  {
+    const Int_t nVar = fHOrig.GetNbinsY();
+
+    for (int n=1; n<=nVar; n++)
+    {
+      TString strg0("Orig-");
+      strg0 += fVarname;
+      TH1D &h = *fHOrig.ProjectionX(strg0, n, n, "E");
+
+      strg0  = fVarname;
+      strg0 += "-bin ";
+      strg0 += n;
+
+      TString strg1("No.of photons vs. E-est for ");
+      strg1 += strg0;
+
+      new TCanvas(strg0, strg1);
+      // TCanvas &c = *MakeDefCanvas(txt0, strg1);
+      // gROOT->SetSelectedPad(NULL);
+
+      gPad->SetLogx();
+
+      h.SetName(strg0);
+      h.SetTitle(strg1);
+      h.SetXTitle("E-est [GeV]");
+      h.SetYTitle("No.of photons");
+      h.DrawCopy();
+
+      // c.Modified();
+      // c.Update();
+    }
+  }
+  //........................
+}
+
+// -------------------------------------------------------------------------
+//
+// Dummy Fill (has to be included because in base class MH Fill is set to 0 
+//             (abstract member function));
+// without the dummy Fill one gets the error message :
+//
+// Error: Can't call MHFlux::MHFlux(evttime,"time","[s]") in current scope 
+// FILE:macros/flux.C LINE:465
+// Possible candidates are...
+// filename       line:size busy function type and name  (in MHFlux)
+// filename       line:size busy function type and name  (in MH)
+// filename       line:size busy function type and name  (in MParContainer)
+// filename       line:size busy function type and name  (in TObject)
+//
+Bool_t MHFlux::Fill(const MParContainer *par)
+{
+   return kTRUE;
+}
+
+
+// -------------------------------------------------------------------------
+//
+// Unfold the distribution in E-est
+//
+void MHFlux::Unfold(const Bool_t Draw)
+{
+  //..............................................
+  // draw the No.of photons vs. E-unfold 
+  // for the individual bins of the variable Var
+
+  if (Draw == kTRUE)
+  {
+    const Int_t nVar = fHUnfold.GetNbinsY();
+
+    for (int n=1; n<=nVar; n++)
+    {
+      TString strg0("Unfold-");
+      strg0 += fVarname;
+      TH1D &h = *fHUnfold.ProjectionX(strg0, n, n, "E");
+      strg0  = fVarname;
+      strg0 += "-bin ";
+      strg0 += n;
+
+      TString strg1("No.of photons vs. E-unfold for ");
+      strg1 += strg0;
+
+      new TCanvas(strg0, strg1);
+
+      // TCanvas &c = *MakeDefCanvas(txt0, strg1);
+      // gROOT->SetSelectedPad(NULL);
+
+      gPad->SetLogx();
+
+      h.SetName(strg0);
+      h.SetTitle(strg1);
+      h.SetXTitle("E-unfold [GeV]");
+      h.SetYTitle("No.of photons");
+      h.DrawCopy();
+
+      // c.Modified();
+      // c.Update();
+    }
+  }
+  //........................
+}
+
+
+// -------------------------------------------------------------------------
+//
+// Calculate photon flux by dividing the distribution in Eunf (fHUnfold) by
+//                       the width of the energy interval     (deltaE)
+//                       the effective ontime                 (*teff)
+//                       and the effective collection area    (*aeff)
+//
+void MHFlux::CalcFlux(const TH1D *teff, const TProfile *thetabar,
+                      const TH2D *aeff, const Bool_t Draw)
+{
+  // Note that fHUnfold  has bins in Eunf and Var 
+  //           *teff     has bins in Var  (the same bins in Var as fHUnfold)
+  //           *thetabar has bins in Var  (the same bins in Var as fHUnfold)
+  //           *aeff     has bins in Etru and Theta
+  //                     (where in general the binning in Etru is different
+  //                      from the binning in Eunf)
+  // The variable Var may be 'time' or 'Theta'
+
+  // Draw = kTRUE means the differential flux vs E-unf should be drawn
+  //              for the individual bins of the variable Var
+
+    const TAxis &axex = *((TH2*)aeff)->GetXaxis();
+    const TAxis &axey = *((TH2*)aeff)->GetYaxis();
+
+  //....................................
+  // define dummy histogram *aeff
+  ((TH1*)aeff)->Sumw2();
+  MBinning binsetru("BinningEtru");
+  binsetru.SetEdgesLog(10, 10, 1e3);
+
+  MBinning binsthetatru("BinningThetatru");
+  binsthetatru.SetEdges(7, -2.5, 32.5);
+  //SetBinning((TH1*)aeff, &binsetru, &binsthetatru);
+  SetBinning((TH2*)aeff, &binsetru, &binsthetatru);
+
+  const Int_t netru  = aeff->GetNbinsX();
+  const Int_t ntheta = aeff->GetNbinsY();
+
+  for (int j=1; j<=netru; j++)
+  {
+      for (int k=1; k<=ntheta; k++)
+      {
+          Double_t cont = 10000.0;
+          ((TH1*)aeff)->SetBinContent(j, k, cont);
+
+          Double_t dcont = 100.0;
+          ((TH1*)aeff)->SetBinError(j, k, dcont);
+      }
+  }
+  // *fLog << "Dummy aeff : netru =" << netru << ",  ntheta = " << ntheta << endl;
+  //....................................
+
+  // number of Eunf and Var bins   (histograms : fHUnfold, fHFlux)
+  const Int_t nEunf    = fHFlux.GetNbinsX();
+  const Int_t nVar     = fHFlux.GetNbinsY();
+
+  // number of Etru and Theta bins (histogram *aeff of collection area)
+
+  const Int_t nEtru    = aeff->GetNbinsX();
+  const Int_t nTheta   = aeff->GetNbinsY();
+
+  //*fLog << "nEunf =" << nEunf << ",  nVar = "   << nVar   << endl;
+  //*fLog << "nEtru =" << nEtru << ",  nTheta = " << nTheta << endl;
+
+  //...................................................................
+  // calculate effective collection area 
+  //    for the Eunf and Var bins of the histogram fHUnfold
+  //    from the histogram *aeff, which has bins in Etru and Theta
+  // the result is the histogram fHAeff
+  //
+
+  TH2D fHAeff;
+  fHAeff.Sumw2();
+  SetBinning((TH2*)&fHAeff, (TH2*)&fHUnfold);
+
+  Double_t *aeffbar  = new Double_t[nEtru];
+  Double_t *daeffbar = new Double_t[nEtru];
+
+  Double_t aeffEunfVar;
+  Double_t daeffEunfVar;
+
+  //------   start n loop   ------
+  for (int n=1; n<=nVar; n++)
+  {
+    Double_t Thetabar = thetabar->GetBinContent(n);
+    Double_t cosThetabar = cos(Thetabar);
+
+    // determine Theta bins (k1, k2, k3) for interpolation in Theta
+    // k0 denotes the Theta bin from whicvh the error is copied
+    Int_t k0=0;
+    Int_t k1=0;
+    Int_t k2=0;
+    Int_t k3=0;
+
+    for (int k=3; k<=nTheta; k++)
+    {
+        Double_t Thetalow = axey.GetBinLowEdge(k);
+        if (Thetabar < Thetalow)
+        {
+            k1 = k-2;
+            k2 = k-1;
+            k3 = k;
+            k0 = k2;
+            break;
+        }
+    }
+
+    if (k3 == 0)
+    {
+        k1 = nTheta-2;
+        k2 = nTheta-1;
+        k3 = nTheta;
+        k0 = k2;
+    }
+
+    if (Thetabar <  axey.GetBinLowEdge(2))
+      k0 = 1;
+    else
+        if (Thetabar >  axey.GetBinLowEdge(nTheta))
+            k0 = nTheta;
+
+    Double_t Thetamin = axey.GetBinLowEdge(1);
+    Double_t Thetamax = axey.GetBinLowEdge(nTheta+1);
+    if (Thetabar < Thetamin  ||  Thetabar > Thetamax)
+    {
+      *fLog << "MHFlux.cc : extrapolation in Theta; Thetabar = " << Thetabar
+            << ",  Thetamin =" << Thetamin
+            << ",  Thetamax =" << Thetamax << endl;
+    } 
+
+    //*fLog << "Var bin "   << n  << ":"  <<  endl;
+    //*fLog << "Thetabar= " << Thetabar 
+    //      << ",  k0= "    << k0
+    //      << ",  k1= "    << k1
+    //      << ",  k2= "    << k2
+    //      << ",  k3= "    << k3         <<  endl;
+ 
+
+    // calculate effective collection area at Theta = Thetabar
+    // by quadratic interpolation in cos(Theta);
+    // do this for each bin of Etru 
+    //
+
+    for (int j=1; j<=nEtru; j++)
+    {
+        double c0 = 0;
+        double c1 = 0;
+        double c2 = 0;
+
+        const double t1 = cos( axey.GetBinCenter (k1) );
+        const double t2 = cos( axey.GetBinCenter (k2) );
+        const double t3 = cos( axey.GetBinCenter (k3) );
+
+        const double a1 = aeff->GetBinContent(j, k1);
+        const double a2 = aeff->GetBinContent(j, k2);
+        const double a3 = aeff->GetBinContent(j, k3);
+
+        Parab(t1, t2, t3, a1, a2, a3, &c0, &c1, &c2);
+        aeffbar[j]  = c0 + c1*cosThetabar + c2*cosThetabar*cosThetabar;
+        daeffbar[j] = aeff->GetBinError(j,k0);
+
+        //*fLog << "Etru bin " << j <<  ":  tbar= " << Thetabar
+        //      << ",  abar= "  << aeffbar[j]
+        //      << ",  dabar= " << daeffbar[j] << endl;
+    }
+
+    //---   start m loop ---
+    // calculate effective collection area at (E = Ebar, Theta = Thetabar)
+    // by quadratic interpolation in log10(Etru)
+    // do this for each bin of Eunf
+    //
+    for (int m=1; m<=nEunf; m++)
+    {
+        Double_t log10Ebar = 0.5 * ( log10( fHUnfold.GetXaxis()->GetBinLowEdge(m)  )+
+                                     log10( fHUnfold.GetXaxis()->GetBinLowEdge(m+1)) );
+        Double_t Ebar = pow(10.0, log10Ebar);
+
+        // determine Etru bins (j1, j2, j3) for interpolation in E
+        // j0 denotes the Etru bin from which the error is copied
+        Int_t j0=0;
+        Int_t j1=0;
+        Int_t j2=0;
+        Int_t j3=0;
+
+        for (int j=3; j<=nEtru; j++)
+        {
+            Double_t Elow = axex.GetBinLowEdge(j);
+            if (Ebar < Elow)
+            {
+                j1 = j-2;
+                j2 = j-1;
+                j3 = j;
+                j0 = j2;
+                break;
+            }
+        }
+
+        if (j3 == 0)
+        {
+            j1 = nEtru-2;
+            j2 = nEtru-1;
+            j3 = nEtru;
+            j0 = j2;
+        }
+
+        if (Ebar <  axex.GetBinLowEdge(2))
+            j0 = 1;
+        else
+            if (Ebar >  axex.GetBinLowEdge(nEtru))
+                j0 = nEtru;
+
+        Double_t Etrumin = axex.GetBinLowEdge(1);
+        Double_t Etrumax = axex.GetBinLowEdge(nEtru+1);
+        if (Ebar < Etrumin  ||  Ebar > Etrumax)
+        {
+            *fLog << "MHFlux.cc : extrapolation in Energy; Ebar = " << Ebar
+                << ",  Etrumin =" << Etrumin
+                << ",  Etrumax =" << Etrumax << endl;
+        }
+
+        //*fLog << "Var bin "   << n  << ":"  <<  endl;
+        //*fLog << "Ebar= " << Ebar
+        //      << ",  j1= "    << j1
+        //      << ",  j2= "    << j2
+        //      << ",  j3= "    << j3         <<  endl;
+
+
+        double c0=0.0;
+        double c1=0.0;
+        double c2=0.0;
+
+        const double t1 = 0.5 * ( log10( axex.GetBinLowEdge (j1)  )+
+                                  log10( axex.GetBinLowEdge (j1+1)) );
+        const double t2 = 0.5 * ( log10( axex.GetBinLowEdge (j2)  )+
+                                  log10( axex.GetBinLowEdge (j2+1)) );
+        const double t3 = 0.5 * ( log10( axex.GetBinLowEdge (j3)  )+
+                                  log10( axex.GetBinLowEdge (j3+1)) );
+
+        const double a1 = aeffbar[j1];
+        const double a2 = aeffbar[j2];
+        const double a3 = aeffbar[j3];
+
+        Parab(t1, t2, t3, a1, a2, a3, &c0, &c1, &c2);
+        aeffEunfVar  = c0 + c1*log10(Ebar) + c2*log10(Ebar)*log10(Ebar);
+        daeffEunfVar = daeffbar[j0];
+
+        //*fLog << "Eunf bin " << m     <<  ":  Ebar= " << Ebar
+        //      << ",  aeffEunfVar = "  << aeffEunfVar
+        //      << ",  daeffEunfVar = " << daeffEunfVar << endl;
+
+        fHAeff.SetBinContent(m,n,aeffEunfVar);
+        fHAeff.SetBinError(m,n,daeffEunfVar);
+    }
+    //---   end m loop ---
+  }
+  //------   end n loop   ------
+  delete aeffbar;
+
+  //...................................................................
+  // now calculate the absolute gamma flux
+  //
+  for (int m=1; m<=nEunf; m++)
+  {
+      Double_t DeltaE = fHFlux.GetXaxis()->GetBinWidth(m);
+
+      for (int n=1; n<=nVar; n++)
+      {
+          Double_t Ngam   = fHUnfold.GetBinContent(m,n);
+          Double_t dNgam  = fHUnfold.GetBinError(m,n);
+
+          Double_t Aeff   = fHAeff.GetBinContent(m,n);
+          Double_t dAeff  = fHAeff.GetBinError(m,n);
+
+          Double_t Effon  = teff->GetBinContent(n);
+          Double_t dEffon = teff->GetBinError(n);
+
+          Double_t Cont, dCont;
+          if (Ngam>0 && DeltaE>0 && Effon>0 && Aeff>0)
+          {
+              Cont  = Ngam / (DeltaE * Effon * Aeff);
+              dCont = Cont * sqrt( dNgam *dNgam  / (Ngam*Ngam) +
+                                   dEffon*dEffon / (Effon*Effon) +
+                                   dAeff *dAeff  / (Aeff*Aeff)  );
+          }
+          else
+          {
+              Cont  = 1.e-20;
+              dCont = 1.e-20;
+          }
+
+          fHFlux.SetBinContent(m,n,Cont);
+          fHFlux.SetBinError(m,n,dCont);
+
+          //*fLog << "Eunf bin "    << m      << ",  Var bin " << n
+          //      << ":  Ngam = "   << Ngam   << ",  Flux = "
+          //      << Cont  << ", dFlux = " << dCont << endl;
+          //*fLog << ",  DeltaE = " << DeltaE << ",  Effon = " << Effon
+          //      << ",  Aeff = "   << Aeff   << endl;
+      }
+  }
+
+  //..............................................
+  // draw the differential photon flux vs. E-unf 
+  // for the individual bins of the variable Var
+
+  if (Draw == kTRUE)
+  {
+      for (int n=1; n<=nVar; n++)
+      {
+          TString strg0("Flux-");
+          strg0 += fVarname;
+
+          TH1D &h = *fHFlux.ProjectionX(strg0, n, n, "E");
+
+          TString strg1("Photon flux vs. E-unfold for ");
+          TString strg2 = fVarname;
+
+          strg2 += "-bin ";
+          strg2 += n;
+
+          TString strg3 = strg1 + strg2;
+          new TCanvas(strg2, strg3);
+          // TCanvas &c = *MakeDefCanvas(txt, txt);
+          // gROOT->SetSelectedPad(NULL);
+
+          gPad->SetLogx();
+
+          h.SetName(strg2);
+          h.SetTitle(strg3);
+          h.SetXTitle("E-unfold [GeV]            ");
+          h.SetYTitle("photons / (s m2 GeV)");
+          h.DrawCopy();
+
+          // c.Modified();
+          // c.Update();
+      }
+  }
+  //........................
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw copies of the histograms
+//
+TObject *MHFlux::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("flux", "Orig - Unfold - Flux plots");
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    ((TH2*)&fHOrig)->DrawCopy("");
+    gPad->SetLogx();
+
+    c.cd(2);
+    ((TH2*)&fHUnfold)->DrawCopy("");
+    gPad->SetLogx();
+
+    c.cd(3);
+    ((TH2*)&fHFlux)->DrawCopy("");
+    gPad->SetLogx();
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histograms
+//
+void MHFlux::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("flux", "orig-unfold-flux plots");
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    fHOrig.Draw(opt);
+
+    gPad->cd(2);
+    fHUnfold.Draw(opt);
+
+    gPad->cd(3);
+    fHFlux.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// -------------------------------------------------------------------------
+//
+// Quadratic interpolation
+//
+// *** calculate the parameters of a parabula 
+//                      y = a + b*x + c*x**2 = F(x)
+//     such that       yi = F(xi)       for (i=1,3)
+//
+Bool_t MHFlux::Parab(Double_t x1, Double_t x2, Double_t x3,
+                     Double_t y1, Double_t y2, Double_t y3,
+                     Double_t *a, Double_t *b, Double_t *c)
+{
+    const double det =
+        + x2*x3*x3 + x1*x2*x2 + x3*x1*x1
+        - x2*x1*x1 - x3*x2*x2 - x1*x3*x3;
+
+    if (det == 0.0)
+    {
+        *a = 0;
+        *b = 0;
+        *c = 0;
+        return kFALSE;
+    }
+
+    const double det1 = 1.0/det;
+
+    const double ai11 = x2*x3*x3 - x3*x2*x2;
+    const double ai12 = x3*x1*x1 - x1*x3*x3;
+    const double ai13 = x1*x2*x2 - x2*x1*x1;
+
+    const double ai21 = x2*x2 - x3*x3;
+    const double ai22 = x3*x3 - x1*x1;
+    const double ai23 = x1*x1 - x2*x2;
+
+    const double ai31 = x3 - x2;
+    const double ai32 = x1 - x3;
+    const double ai33 = x2 - x1;
+
+    *a = (ai11*y1 + ai12*y2 + ai13*y3) * det1;
+    *b = (ai21*y1 + ai22*y2 + ai23*y3) * det1;
+    *c = (ai31*y1 + ai32*y2 + ai33*y3) * det1;
+
+    //yt1 = *a + *b * x1 + *c * x1*x1;
+    //yt2 = *a + *b * x2 + *c * x2*x2;
+    //yt3 = *a + *b * x3 + *c * x3*x3;
+
+    //*fLog << "x1 = " << x1 << ",  x2 = " << x2 << ",  x3 = " << x3 << endl;
+    //*fLog << "y1 = " << y1 << ",  y2 = " << y2 << ",  y3 = " << y3 << endl;
+    //*fLog << "yt1 = " << yt1 << ",  yt2 = " << yt2
+    //	  << ",  yt3 = " << yt3 << endl;
+    //*fLog << "*a = " << *a << ",  *b = " << *b << ",  *c= " << *c
+    //      << ",  *errflag = " << *errflag << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHFlux.h	(revision 1638)
@@ -0,0 +1,73 @@
+#ifndef MARS_MHFlux
+#define MARS_MHFlux
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TH1
+#include "TH1.h"
+#endif
+
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class TH2D;
+
+// base class MH is used because it defines "MakeDefCanvas"
+// if base class MH is used one has to define the member function Fill
+//                          because in MH Fill is set to zero
+class MHFlux : public MH 
+{
+private:
+
+    TString fVarname;
+    TString fUnit;
+
+    TH2D fHOrig;       // original distribution of E-est 
+    TH2D fHUnfold;     // unfolded distribution of E-unfold
+    TH2D fHFlux;       // absolute differential photon flux versus E-unfold
+    // all these plots for different bins of the variable (Theta or time)
+
+public:
+    MHFlux(const TH2D &h2d, const Bool_t Draw,
+	   const TString varname, const TString unit);
+
+    Bool_t Fill(const MParContainer *par);
+
+    void Unfold(const Bool_t Draw);
+    void CalcFlux(const TH1D *teff, const TProfile *thetabar,
+                  const TH2D *aeff, const Bool_t Draw);
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    const TH2D *GetHOrig()       { return &fHOrig; }
+    const TH2D *GetHUnfold()     { return &fHUnfold; }
+    const TH2D *GetHFlux()       { return &fHFlux; }
+
+    static Bool_t Parab(double x1, double x2, double x3,
+                        double y1, double y2, double y3,
+                        double *a, double *b, double *c);
+
+    ClassDef(MHFlux, 1) //2D-plots (original, unfolded, flux)
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.cc	(revision 1638)
@@ -0,0 +1,272 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 time saving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 6/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHGamma                                                                 //
+//                                                                          //
+//  manipulation of alpha distributions                                     //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHGamma.h"
+
+#include <TCanvas.h>
+#include <TPad.h>
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHGamma);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHGamma::MHGamma()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Dummy Fill
+//
+Bool_t MHGamma::Fill(const MParContainer *par)
+{
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the histogram as the difference of two histograms :
+//          fHist(gamma) = h1(source) - h2(antisource)
+// 
+TH3D *MHGamma::Subtract(const TH3D *h1, const TH3D *h2,
+                        const char *name, const char *title,
+                        Bool_t Draw)
+{
+    TH3D *fHist;
+    fHist = new TH3D();
+    fHist->SetName(name);
+    fHist->SetTitle(title);
+
+    fHist->SetDirectory(NULL);
+
+    // SetBinning((TH3D*)fHist, (TH3D*)h1);
+    SetBinning((TH1*)fHist, (TH1*)h1);
+
+    TString strg1 =   (((TH1*)h1)->GetXaxis())->GetTitle();
+    TString strg2 =   (((TH1*)h1)->GetYaxis())->GetTitle();
+    TString strg3 =   (((TH1*)h1)->GetZaxis())->GetTitle();
+    fHist->SetXTitle(strg1);
+    fHist->SetYTitle(strg2);
+    fHist->SetZTitle(strg3);
+
+    fHist->Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME!
+
+    //...........................................................
+    // draw histogram
+    if (Draw == kTRUE)
+    {
+      TString strg7 = "3D-plot of ";
+      strg7 += strg1;
+      strg7 += ",";
+      strg7 += strg2;
+      strg7 += ",";
+      strg7 += strg3;
+      strg7 += "  for \'gamma\' sample";
+
+      TCanvas &c = *MakeDefCanvas("Alpha", strg7); 
+
+      c.Divide(2, 2);
+
+      gROOT->SetSelectedPad(NULL);
+
+      TH1 *h;
+
+      c.cd(1);
+      h = ((TH3D*)(fHist))->Project3D("ex");
+
+      TString strg0 = "SRC-ASRC :    ";
+      TString strg4 = strg0 + strg1;
+      h->SetTitle(strg4);
+      h->SetXTitle(strg1);
+      h->SetYTitle("Counts");
+
+      h->Draw();
+      h->SetBit(kCanDelete);
+
+      c.cd(2);
+      h = ((TH3D*)(fHist))->Project3D("ey");
+
+      TString strg5 = strg0 + strg2;
+      h->SetTitle(strg5);
+      h->SetXTitle(strg2);
+      h->SetYTitle("Counts");
+
+      h->Draw();
+      h->SetBit(kCanDelete);
+      gPad->SetLogx();
+
+      c.cd(3);
+      h = ((TH3D*)(fHist))->Project3D("ez");
+
+      TString strg6 = strg0 + strg3;
+      h->SetTitle(strg6);
+      h->SetXTitle(strg3);
+      h->SetYTitle("Counts");
+
+      h->Draw();
+      h->SetBit(kCanDelete);
+
+      c.cd(4);
+      ((TH3D*)fHist)->DrawCopy();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return fHist;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist(gamma) in the alpha range (lo, up)
+// 
+TH2D *MHGamma::GetAlphaProjection(TH3D *fHist, Axis_t lo, Axis_t up,
+                                  Bool_t Drawp)
+{
+    if (up < lo)
+    {
+        *fLog << err << fName << "MHGamma : Alpha projection not possible: lo=" << lo << " up=" << up << endl;
+        return NULL;
+    }
+
+    TAxis &axe = *fHist->GetXaxis();
+
+    Int_t ilo = axe.FindFixBin(lo);
+    Int_t iup = axe.FindFixBin(up);
+
+    const Double_t epslo1 = lo-axe.GetBinLowEdge(ilo);
+    const Double_t epslo2 = axe.GetBinUpEdge(ilo)-lo;
+
+    const Double_t epsup1 = up-axe.GetBinLowEdge(iup);
+    const Double_t epsup2 = axe.GetBinUpEdge(iup)-up;
+
+    const Double_t epslo = epslo1<epslo2 ? epslo1 : epslo2;
+    const Double_t epsup = epsup1<epsup2 ? epsup1 : epsup2;
+
+    if (epslo1>epslo2)
+        ilo++;
+
+    if (epsup1<epsup2)
+        iup--;
+
+    if (epslo>0.01*axe.GetBinWidth(ilo) || epsup>0.01*axe.GetBinWidth(iup))
+    {
+        *fLog << err << fName << "MHGamma : binning is not adequate for the requested projection:" << endl;
+        *fLog << "Please specify a lower or upper limit which is not more than 1% away from a bin edge" << endl;
+        *fLog << " epslo = " << epslo << endl;
+        *fLog << " epsup = " << epsup << endl;
+        *fLog << " dwl   = " << axe.GetBinWidth(ilo) << endl;
+        *fLog << " dwu   = " << axe.GetBinWidth(iup) << endl;
+        return NULL;
+    }
+
+    axe.SetRange(ilo, iup);
+
+    TH2D &h2D = *(TH2D *)fHist->Project3D("ezy");
+
+    TString strg0 = "2D-plot of ";
+    TString strg1 = (fHist->GetYaxis())->GetTitle();
+    TString strg2 = (fHist->GetZaxis())->GetTitle();
+    strg0 += strg2;
+    strg0 += " vs. ";
+    strg0 += strg1;
+    h2D.SetTitle(strg0);
+    h2D.SetXTitle(strg1);
+    h2D.SetYTitle(strg2);
+
+
+    //...........................................................
+    // draw histogram
+    if (Drawp == kTRUE)
+    {
+      char txt[100];
+      TString strg3 = "No.of Gammas vs. ";
+      strg3 += strg1;
+      strg3 += " and ";
+      strg3 += strg2;
+      sprintf(txt, "   (%.1f < alpha < %.1f deg)", lo, up);
+      strg3 += txt;
+
+      TCanvas &c = *MakeDefCanvas("Gamma", strg3);
+
+      c.Divide(2, 2);
+
+      gROOT->SetSelectedPad(NULL);
+
+      TH1 *h;
+
+      c.cd(1);
+      h = h2D.ProjectionX("xpro", -1, 9999, "E");
+      TString strg0 = "No.of gammas : ";
+      TString strg7 = strg0 + strg1;
+      h->SetTitle(strg7);
+      h->SetXTitle(strg1);
+      h->SetYTitle("Counts");
+
+      h->Draw();
+      h->SetBit(kCanDelete);
+      gPad->SetLogx();
+
+      c.cd(2);
+      h = h2D.ProjectionY("ypro", -1, 9999, "E");
+      TString strg8 = strg0 + strg2;
+      h->SetTitle(strg8);
+      h->SetXTitle(strg2);
+      h->SetYTitle("Counts");
+
+      h->Draw();
+      h->SetBit(kCanDelete);
+
+      c.cd(3);
+
+      h2D.DrawCopy();
+      gPad->SetLogx();
+
+      c.Modified();
+      c.Update();
+    }
+    //...........................................................
+
+    return &h2D;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHGamma.h	(revision 1638)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHGamma
+#define MARS_MHGamma
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include "TH3.h"
+#endif
+
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class TH2D;
+class TH3D;
+
+class MHGamma : public MH 
+{
+public:
+    MHGamma();
+
+    Bool_t Fill(const MParContainer *par);
+
+    TH3D *Subtract(const TH3D *h1, const TH3D *h2,
+                   const char *name, const char *title, Bool_t Draw=kFALSE);
+
+    TH2D *GetAlphaProjection(TH3D *fHist, Axis_t lo, Axis_t up, 
+                             Bool_t Drawp=kFALSE);
+
+
+    ClassDef(MHGamma, 1) // manipulation of alpha distributions
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1638)
@@ -0,0 +1,524 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHadronness
+//
+// This is histogram is a way to evaluate the quality of a gamma/hadron
+// seperation method. It is filled from a MHadronness container, which
+// stores a hadroness for the current event. The Value must be in the
+// range [0,1]. To fill the histograms correctly the information
+// whether it is a gamma or hadron (not a gamma) must be available from
+// a MMcEvt container.
+//
+// In the constructor you can change the number of used bns for the
+// evaluation.
+//
+// The meaning of the histograms (Draw, DrawClone) are the following:
+//  * Upper Left Corner:
+//    - black: histogram of all hadronesses for gammas
+//    - red:   histogram of all hadronesses for non gammas
+//  * Upper Right Corner:
+//    - black: acceptance of gammas (Ag) vs. the hadroness
+//    - red:   acceptance of non gammas (Ah) vs. the hadroness
+//    - blue:  2D distance of (acceptance_hadrons, acceptances_gammas)
+//             to optimum (0, 1)
+//             1-sqrt(Ag*Ag + (1-Ah)*(1-Ah))
+//  * Bottom Left Corner:
+//    Naive quality factor: Ag/sqrt(Ah)
+//  * Bottom Right Corner:
+//    - black: Acceprtance Gammas vs. Acceptance Hadrons
+//    - blue cross: minimum of distance to (0, 1)
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHHadronness.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MHadronness.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHHadronness);
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHHadronness::MHHadronness(Int_t nbins, const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHadronness";
+    fTitle = title ? title : "Gamma/Hadron Separation Quality Histograms";
+
+    fGraph = new TGraph;
+    fGraph->SetTitle("Acceptance Gammas vs. Hadrons");
+    fGraph->SetMaximum(1);
+
+    fGhness = new TH1D("Ghness", "Hadronness", nbins, 0, 1);
+    fPhness = new TH1D("Phness", "Hadronness", nbins, 0, 1);
+    fGhness->SetXTitle("Hadronness");
+    fPhness->SetXTitle("Hadronness");
+    fGhness->SetYTitle("Counts");
+    fPhness->SetYTitle("Counts");
+    
+    fIntGhness = new TH1D("AccGammas",  "Acceptance", nbins, 0, 1);
+    fIntPhness = new TH1D("AccHadrons", "Acceptance", nbins, 0, 1);
+    fIntGhness->SetXTitle("Hadronness");
+    fIntPhness->SetXTitle("Hadronness");
+    fIntGhness->SetYTitle("Acceptance");
+    fIntPhness->SetYTitle("Acceptance");
+
+    /*
+    fQfac = new TH1D("Qfac", "Naive Quality factor", nbins, 0, 1);
+    fQfac->SetXTitle("Hadronness");
+    fQfac->SetYTitle("Quality");
+    */
+    fQfac = new TGraph;
+    fQfac->SetTitle(" Naive Quality factor ");
+
+    fMinDist = new TH1D("MinDist", "Minimum Dist to (0, 1)", nbins, 0, 1);
+    fMinDist->SetXTitle("Hadronness");
+    fMinDist->SetYTitle("Distance");
+
+    //fQfac->SetDirectory(NULL);
+    fGhness->SetDirectory(NULL);
+    fPhness->SetDirectory(NULL);
+    fMinDist->SetDirectory(NULL);
+    fIntGhness->SetDirectory(NULL);
+    fIntPhness->SetDirectory(NULL);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHHadronness::~MHHadronness()
+{
+    delete fGhness;
+    delete fIntGhness;
+    delete fPhness;
+    delete fIntPhness;
+    delete fQfac;
+    delete fMinDist;
+    delete fGraph;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MHadronness
+//
+Bool_t MHHadronness::SetupFill(const MParList *plist)
+{
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)plist->FindObject("MHadronness");
+    if (!fHadronness)
+    {
+        *fLog << err << dbginf << "MHadronness not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    /*
+     MBinning* bins = (MBinning*)plist->FindObject("BinningHadronness");
+     if (!bins)
+     {
+     *fLog << err << dbginf << "BinningHadronness [MBinning] not found... aborting." << endl;
+     return kFALSE;
+     }
+
+     SetBinning(&fHist, binsalpha, binsenergy, binstheta);
+
+     fHist.Sumw2();
+     */
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the Hadronness from a MHadronness container into the corresponding
+// histogram dependant on the particle id.
+//
+// Sometimes a distance is calculated as NaN (not a number). Such events
+// are skipped at the moment.
+//
+Bool_t MHHadronness::Fill(const MParContainer *par)
+{
+    // Preliminary Workaround: FIXME!
+
+    const Double_t h = fHadronness->GetHadronness();
+
+    if (TMath::IsNaN(h))
+        return kCONTINUE;
+
+    if (fMcEvt->GetPartId()==kGAMMA)
+        fGhness->Fill(h);
+    else
+        fPhness->Fill(h);
+
+    return kTRUE;
+}
+
+Float_t MHHadronness::GetQ05() const
+{
+    Int_t n = fQfac->GetN();
+
+    Double_t val1x=0;
+    Double_t val2x=1;
+
+    Double_t val1y=0;
+    Double_t val2y=0;
+
+    for (Int_t i=1; i<=n; i++)
+    {
+        Double_t x, y;
+
+        fQfac->GetPoint(i, x, y);
+
+        if (x<0.5 && x>val1x)
+        {
+            val1x = x;
+            val1y = y;
+        }
+
+        if (x>0.5 && x<val2x)
+        {
+            val2x = x;
+            val2y = y;
+        }
+    }
+
+    return val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5);
+}
+
+// --------------------------------------------------------------------------
+//
+// Finalize the histograms:
+//  - integrate the hadroness histograms --> acceptance
+//  - fill the Minimum Distance histogram (formular see class description)
+//  - fill the Quality histogram (formular see class description)
+//
+Bool_t MHHadronness::Finalize()
+{
+    Int_t n = fGhness->GetNbinsX();
+
+    fGraph->Set(n);
+    fQfac->Set(n);
+
+    const Stat_t sumg = fGhness->Integral(1, n+1);
+    const Stat_t sump = fPhness->Integral(1, n+1);
+
+    Float_t max=0;
+
+    for (Int_t i=1; i<=n; i++)
+    {
+        const Stat_t ip = fPhness->Integral(1, i)/sump;
+        const Stat_t ig = fGhness->Integral(1, i)/sumg;
+
+        fIntPhness->SetBinContent(i, ip);
+        fIntGhness->SetBinContent(i, ig);
+
+        fGraph->SetPoint(i, ip, ig);
+
+        if (ip<=0)
+            continue;
+
+        fMinDist->SetBinContent(i, 1-sqrt(ip*ip + (ig-1)*(ig-1)));
+
+        Double_t val = ig/sqrt(ip);
+        fQfac->SetPoint(i, ig, val);
+
+        if (val>max)
+            max = val;
+    }
+
+    fQfac->SetMaximum(max*1.05);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the corresponding points for the given hadron acceptance (acchad)
+// and interpolate the tow points (linear)
+//
+Double_t MHHadronness::GetGammaAcceptance(Double_t acchad) const
+{
+    const Int_t n = fGraph->GetN();
+    const Double_t *x = fGraph->GetX();
+    const Double_t *y = fGraph->GetY();
+
+    Int_t i = 0;
+    while (i<n && x[i]<acchad)
+        i++;
+
+    if (i==0 || i==n)
+        return 0;
+
+    if (i==n-1)
+        i--;
+
+    const Double_t x1 = x[i-1];
+    const Double_t y1 = y[i-1];
+
+    const Double_t x2 = x[i];
+    const Double_t y2 = y[i];
+
+    return (y2-y1)/(x2-x1) * (acchad-x2) + y2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the corresponding points for the given gamma acceptance (accgam)
+// and interpolate the tow points (linear)
+//
+Double_t MHHadronness::GetHadronAcceptance(Double_t accgam) const
+{
+    const Int_t n = fGraph->GetN();
+    const Double_t *x = fGraph->GetX();
+    const Double_t *y = fGraph->GetY();
+
+    Int_t i = 0;
+    while (i<n && y[i]<accgam)
+        i++;
+
+    if (i==0 || i==n)
+        return 0;
+
+    if (i==n-1)
+        i--;
+
+    const Double_t x1 = y[i-1];
+    const Double_t y1 = x[i-1];
+
+    const Double_t x2 = y[i];
+    const Double_t y2 = x[i];
+
+    return (y2-y1)/(x2-x1) * (accgam-x2) + y2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the corresponding Gammas Acceptance for a hadron acceptance of
+// 10%, 20%, 30%, 40% and 50%. Also the minimum distance to the optimum
+// acceptance and the corresponding acceptances and hadroness value is
+// printed, together with the maximum Q-factor.
+//
+void MHHadronness::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Hadronness histograms:" << endl;
+    *fLog << "---------------------" << endl;
+
+    if (fGraph->GetN()==0)
+    {
+        *fLog << " <No Entries>" << endl;
+        return;
+    }
+
+    *fLog << "Used " << fGhness->GetEntries() << " Gammas and " << fPhness->GetEntries() << " Hadrons." << endl;
+    *fLog << " acc(hadron)  acc(gamma)" << endl <<endl;
+
+    *fLog << "    0.005   "  << Form("%6.3f", GetGammaAcceptance(0.005)) << endl;
+    *fLog << "    0.02    "  << Form("%6.3f", GetGammaAcceptance(0.02))  << endl;
+    *fLog << "    0.05    "  << Form("%6.3f", GetGammaAcceptance(0.05))  << endl;
+    *fLog << "    0.1     "  << Form("%6.3f", GetGammaAcceptance(0.1 ))  << endl;
+    *fLog << "    0.2     "  << Form("%6.3f", GetGammaAcceptance(0.2 ))  << endl;
+    *fLog << "    0.3     "  << Form("%6.3f", GetGammaAcceptance(0.3 ))  << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.1)) << "       0.1  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.2)) << "       0.2  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.3)) << "       0.3  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.4)) << "       0.4  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.5)) << "       0.5  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.6)) << "       0.6  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.7)) << "       0.7  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.8)) << "       0.8  " << endl;
+    *fLog << endl;
+
+    const Int_t h = fMinDist->GetMaximumBin();
+    *fLog << "Minimum Distance to (0, 1): " << Form("%.2f", 1-fMinDist->GetMaximum()) << " @ H=" << fMinDist->GetBinCenter(h) << endl;
+    *fLog << "  Acc Gammas = " << Form("%3.0f", fIntGhness->GetBinContent(h)*100) << "%, ";
+    *fLog << "Acc Hadrons = " << Form("%3.0f", fIntPhness->GetBinContent(h)*100) << "%" << endl;
+
+    *fLog << "Q-Factor @ Acc Gammas=0.5: Q(0.5)=" << Form("%.1f", GetQ05()) << endl;
+    *fLog << "  Acc Hadrons = " << Form("%5.1f", GetHadronAcceptance(0.5)*100) << "%" << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clone of all histograms. (For the Meaning see class description)
+//
+TObject *MHHadronness::DrawClone(Option_t *opt) const
+{
+    if (fGraph->GetN()==0)
+        return NULL;
+
+    TCanvas &c = *MakeDefCanvas("Hadronness", fTitle);
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    gStyle->SetOptStat(10);
+    Getghness()->DrawCopy();
+    Getphness()->SetLineColor(kRed);
+    Getphness()->DrawCopy("same");
+    c.cd(2);
+    gStyle->SetOptStat(0);
+    Getighness()->DrawCopy();
+    Getiphness()->SetLineColor(kRed);
+    Getiphness()->DrawCopy("same");
+    fMinDist->SetLineColor(kBlue);
+    fMinDist->DrawCopy("same");
+    c.cd(3);
+    //GetQfac()->DrawCopy();
+    TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*");
+    g2.SetBit(kCanDelete);
+    gPad->Modified();
+    gPad->Update();
+    if (g2.GetHistogram())
+    {
+        g2.GetXaxis()->SetRangeUser(0, 1);
+        g2.GetXaxis()->SetTitle("Acceptance Gammas");
+        g2.GetYaxis()->SetTitle("Quality");
+        g2.SetMarkerStyle(kFullDotSmall);
+        g2.Draw("P");
+
+        gPad->Modified();
+        gPad->Update();
+    }
+    c.cd(4);
+    gPad->Modified();
+    gPad->Update();
+    TGraph &g = (TGraph&)*fGraph->DrawClone("AC");
+    g.SetBit(kCanDelete);
+    gPad->Modified();
+    gPad->Update();
+    if (g.GetHistogram())
+    {
+        g.GetXaxis()->SetRangeUser(0, 1);
+        g.GetXaxis()->SetTitle("Acceptance Hadrons");
+        g.GetYaxis()->SetTitle("Acceptance Gammas");
+        g.SetMarkerStyle(kFullDotSmall);
+        g.Draw("P");
+
+        gPad->Modified();
+        gPad->Update();
+    }
+    const Int_t h = fMinDist->GetMaximumBin();
+    TMarker *m = new TMarker(fIntPhness->GetBinContent(h),
+                             fIntGhness->GetBinContent(h), kStar);
+    m->SetMarkerColor(kBlue);
+    m->SetBit(kCanDelete);
+    m->Draw();
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw all histograms. (For the Meaning see class description)
+//
+void MHHadronness::Draw(Option_t *)
+{
+   if (fGraph->GetN()==0)
+        return;
+
+   if (!gPad)
+        MakeDefCanvas("Hadronness", fTitle);
+
+    gPad->Divide(2, 2);
+
+    gPad->cd(1);
+    gStyle->SetOptStat(10);
+    Getghness()->Draw();
+    Getphness()->SetLineColor(kRed);
+    Getphness()->Draw("same");
+    gPad->cd(2);
+    gStyle->SetOptStat(0);
+    Getighness()->Draw();
+    Getiphness()->SetLineColor(kRed);
+    Getiphness()->Draw("same");
+    fMinDist->SetLineColor(kBlue);
+    fMinDist->Draw("same");
+    gPad->cd(3);
+    //GetQfac()->Draw();
+    fQfac->Draw("A*");
+    gPad->Modified();
+    gPad->Update();
+    if (fQfac->GetHistogram())
+    {
+        fQfac->GetXaxis()->SetRangeUser(0, 1);
+        fQfac->GetXaxis()->SetTitle("Acceptance Gammas");
+        fQfac->GetYaxis()->SetTitle("Quality");
+        fQfac->SetMarkerStyle(kFullDotSmall);
+        fQfac->Draw("P");
+
+        gPad->Modified();
+        gPad->Update();
+    }
+    gPad->cd(4);
+    gPad->Modified();
+    gPad->Update();
+    fGraph->Draw("AC");
+    gPad->Modified();
+    gPad->Update();
+    if (fGraph->GetHistogram())
+    {
+        fGraph->GetXaxis()->SetRangeUser(0, 1);
+        fGraph->GetXaxis()->SetTitle("Acceptance Hadrons");
+        fGraph->GetYaxis()->SetTitle("Acceptance Gammas");
+        fGraph->SetMarkerStyle(kFullDotSmall);
+        fGraph->Draw("P");
+        gPad->Modified();
+        gPad->Update();
+    }
+    const Int_t h = fMinDist->GetMaximumBin();
+    TMarker *m = new TMarker(fIntPhness->GetBinContent(h),
+                             fIntGhness->GetBinContent(h), kStar);
+    m->SetMarkerColor(kBlue);
+    m->SetBit(kCanDelete);
+    m->Draw();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1638)
@@ -0,0 +1,56 @@
+#ifndef MARS_MHHadronness
+#define MARS_MHHadronness
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MMcEvt;
+class MHadronness;
+
+class MHHadronness : public MH
+{
+private:
+    const MMcEvt *fMcEvt;            //!
+    const MHadronness *fHadronness;    //!
+
+    TH1D* fPhness;        //-> Hadrons Hadronness
+    TH1D* fGhness;        //-> Gammas Hadronness
+    TH1D* fIntPhness;     //-> Hadrons Acceptance
+    TH1D* fIntGhness;     //-> Gammas Acceptance
+    TH1D* fMinDist;       //-> Minimum Distance to optimum acceptance
+
+    TGraph *fQfac;        //-> Quality factor
+    TGraph *fGraph;       //-> gamma acceptance vs. hadron acceptance
+
+public:
+    MHHadronness(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHHadronness();
+
+    Double_t GetGammaAcceptance(Double_t acchad) const;
+    Double_t GetHadronAcceptance(Double_t accgam) const;
+
+    TH1D *Getghness() const  { return fGhness; }
+    TH1D *Getphness() const  { return fPhness; }
+    TH1D *Getighness() const { return fIntGhness; }
+    TH1D *Getiphness() const { return fIntPhness; }
+    //TH2D *GetHist() const    { return fHist; }
+
+    Float_t GetQ05() const;
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+    TObject *DrawClone(Option_t *opt="") const;
+
+    ClassDef(MHHadronness, 1) // Gamma/Hadron Separation Quality Histograms
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.cc	(revision 1638)
@@ -0,0 +1,388 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2001 <mailto:tbretz@uni-sw.gwdg.de>
+!              Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHillas
+//
+// This class contains histograms for the source independent image parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHHillas.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MGeomCam.h"
+#include "MBinning.h"
+
+
+ClassImp(MHHillas);
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHHillas::MHHillas(const char *name, const char *title)
+    : fMm2Deg(1), fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillas";
+    fTitle = title ? title : "Source independent image parameters";
+
+    fLength  = new TH1F("Length",  "Length of Ellipse",               100,   0, 296.7);
+    fWidth   = new TH1F("Width",   "Width of Ellipse",                100,   0, 296.7);
+    fDistC   = new TH1F("DistC",   "Distance from center of camera",  100,   0, 445);
+    fDelta   = new TH1F("Delta",   "Angle (Main axis - x-axis)",      101, -90,  90);
+    fUsedPix = new TH1F("UsedPix", "Number of used pixels",           150,   0, 150);
+    fCorePix = new TH1F("CorePix", "Number of core pixels",           150,   0, 150);
+
+    fLength->SetLineColor(kBlue);
+    fCorePix->SetLineColor(kRed);
+    fUsedPix->SetLineColor(kGreen);
+
+    fLength->SetDirectory(NULL);
+    fWidth->SetDirectory(NULL);
+    fDistC->SetDirectory(NULL);
+    fDelta->SetDirectory(NULL);
+    fUsedPix->SetDirectory(NULL);
+    fCorePix->SetDirectory(NULL);
+
+    fLength->SetXTitle("Length [mm]");
+    fWidth->SetXTitle("Width [mm]");
+    fDistC->SetXTitle("Distance [mm]");
+    fDelta->SetXTitle("Delta [\\circ]");
+    fUsedPix->SetXTitle("Number of Pixels");
+    fCorePix->SetXTitle("Number of Pixels");
+
+    fLength->SetYTitle("Counts");
+    fWidth->SetYTitle("Counts");
+    fDistC->SetYTitle("Counts");
+    fDelta->SetYTitle("Counts");
+    fUsedPix->SetYTitle("Counts");
+    fCorePix->SetYTitle("Counts");
+
+    MBinning bins;
+    bins.SetEdgesLog(50, 1, 1e7);
+
+    fSize  = new TH1F;
+    fSize->SetName("Size");
+    fSize->SetTitle("Number of Photons");
+    fSize->SetDirectory(NULL);
+    fSize->SetXTitle("Size");
+    fSize->SetYTitle("Counts");
+    fSize->GetXaxis()->SetTitleOffset(1.2);
+    fSize->GetXaxis()->SetLabelOffset(-0.015);
+
+    bins.Apply(*fSize);
+
+    fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
+    fCenter->SetDirectory(NULL);
+    fCenter->SetXTitle("x [mm]");
+    fCenter->SetYTitle("y [mm]");
+    fCenter->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHHillas::~MHHillas()
+{
+    delete fLength;
+    delete fWidth;
+
+    delete fDistC;
+    delete fDelta;
+
+    delete fSize;
+    delete fCenter;
+
+    delete fUsedPix;
+    delete fCorePix;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHHillas::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Width",  fWidth);
+    ApplyBinning(*plist, "Length", fLength);
+    ApplyBinning(*plist, "Dist",   fDistC);
+    ApplyBinning(*plist, "Delta",  fDelta);
+    ApplyBinning(*plist, "Size",   fSize);
+    ApplyBinning(*plist, "Pixels", fUsedPix);
+    ApplyBinning(*plist, "Pixels", fCorePix);
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera");
+    if (!bins)
+    {
+        float r = geom ? geom->GetMaxRadius() : 600;
+        r *= 0.9;
+        if (!fUseMmScale)
+            r *= fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(61, -r, r);
+        SetBinning(fCenter, &b, &b);
+    }
+    else
+        SetBinning(fCenter, bins, bins);
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillas::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillas::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fLength, scale);
+    MH::ScaleAxis(fWidth,  scale);
+    MH::ScaleAxis(fDistC,  scale);
+    MH::ScaleAxis(fCenter, scale, scale);
+
+    if (mmscale)
+    {
+        fLength->SetXTitle("Length [mm]");
+        fWidth->SetXTitle("Width [mm]");
+        fDistC->SetXTitle("Distance [mm]");
+        fCenter->SetXTitle("x [mm]");
+        fCenter->SetYTitle("y [mm]");
+    }
+    else
+    {
+        fLength->SetXTitle("Length [\\circ]");
+        fWidth->SetXTitle("Width [\\circ]");
+        fDistC->SetXTitle("Distance [\\circ]");
+        fCenter->SetXTitle("x [\\circ]");
+        fCenter->SetYTitle("y [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHHillas::Fill(const MParContainer *par)
+{
+    const MHillas &h = *(MHillas*)par;
+
+    const Double_t d = sqrt(h.GetMeanX()*h.GetMeanX() + h.GetMeanY()*h.GetMeanY());
+    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
+
+    fLength ->Fill(scale*h.GetLength());
+    fWidth  ->Fill(scale*h.GetWidth());
+    fDistC  ->Fill(scale*d);
+    fCenter ->Fill(scale*h.GetMeanX(), scale*h.GetMeanY());
+    fDelta  ->Fill(kRad2Deg*h.GetDelta());
+    fSize   ->Fill(h.GetSize());
+    fUsedPix->Fill(h.GetNumUsedPixels());
+    fCorePix->Fill(h.GetNumCorePixels());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup a inversed deep blue sea palette for the fCenter histogram.
+//
+void MHHillas::SetColors() const
+{
+    // FIXME: This must be redone each time the canvas is repainted....
+    gStyle->SetPalette(51, NULL);
+    Int_t c[50];
+    for (int i=0; i<50; i++)
+        c[49-i] = gStyle->GetColorPalette(i);
+    gStyle->SetPalette(50, c);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clones of four histograms. So that the object can be deleted
+// and the histograms are still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle dostroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHHillas::DrawClone(Option_t *opt) const
+{
+    TCanvas *c = MakeDefCanvas(this, 720, 810);
+    c->Divide(2,3);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c->cd(1);
+    DrawCopy(*fWidth, *fLength, "Width / Length");
+
+    c->cd(2);
+    gPad->SetLogx();
+    fSize->DrawCopy();
+
+    c->cd(3);
+    DrawCopy(*fCorePix, *fUsedPix, "Number of core/used Pixels");
+
+    c->cd(4);
+    fDelta->DrawCopy();
+
+    c->cd(5);
+    fDistC->DrawCopy();
+
+    c->cd(6);
+    SetColors();
+    fCenter->DrawCopy("colz");
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the four histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHHillas::Draw(Option_t *)
+{
+    if (!gPad)
+        MakeDefCanvas(this, 720, 810);
+
+    gPad->Divide(2,3);
+
+    gPad->cd(1);
+    MH::Draw(*fWidth, *fLength, "Width / Length");
+
+    gPad->cd(2);
+    gPad->SetLogx();
+    fSize->Draw();
+
+    gPad->cd(3);
+    MH::Draw(*fCorePix, *fUsedPix, "Number of core/used Pixels");
+
+    gPad->cd(4);
+    fDelta->Draw();
+
+    gPad->cd(5);
+    fDistC->Draw();
+
+    gPad->cd(6);
+    SetColors();
+    fCenter->Draw("colz");
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TH1 *MHHillas::GetHistByName(const TString name)
+{
+    if (name.Contains("Width", TString::kIgnoreCase))
+        return fWidth;
+    if (name.Contains("Length", TString::kIgnoreCase))
+        return fLength;
+    if (name.Contains("Size", TString::kIgnoreCase))
+        return fSize;
+    if (name.Contains("Core", TString::kIgnoreCase))
+        return fCorePix;
+    if (name.Contains("Used", TString::kIgnoreCase))
+        return fUsedPix;
+    if (name.Contains("Delta", TString::kIgnoreCase))
+        return fDelta;
+    if (name.Contains("DistC", TString::kIgnoreCase))
+        return fDistC;
+    if (name.Contains("Center", TString::kIgnoreCase))
+        return fCenter;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillas.h	(revision 1638)
@@ -0,0 +1,60 @@
+#ifndef MARS_MHHillas
+#define MARS_MHHillas
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class TH2F;
+class MHillas;
+
+class MHHillas : public MH
+{
+private:
+
+    TH1F *fLength; //->
+    TH1F *fWidth;  //->
+
+    TH1F *fDistC;  //->
+    TH1F *fDelta;  //->
+
+    TH1F *fSize;   //->
+    TH2F *fCenter; //->
+
+    TH1F *fUsedPix; //->
+    TH1F *fCorePix; //->
+
+    void SetColors() const;
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+public:
+    MHHillas(const char *name=NULL, const char *title=NULL);
+    ~MHHillas();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    virtual void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F *GetHistLength() { return fLength; }
+    TH1F *GetHistWidth()  { return fWidth; }
+
+    TH1F *GetHistDistC()  { return fDistC; }
+    TH1F *GetHistDelta()  { return fDelta; }
+
+    TH1F *GetHistSize()   { return fSize; }
+    TH2F *GetHistCenter() { return fCenter; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHHillas, 1) // Container which holds histograms for the source independent image parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.cc	(revision 1638)
@@ -0,0 +1,329 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHillasExt
+//
+// This class contains histograms for every Hillas parameter
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHHillasExt.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TLegend.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+#include "MParList.h"
+
+#include "MBinning.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+
+ClassImp(MHHillasExt);
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHHillasExt::MHHillasExt(const char *name, const char *title)
+    : fMm2Deg(1), fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillasExt";
+    fTitle = title ? title : "Container for extended Hillas histograms";
+
+    //
+    // loop over all Pixels and create two histograms
+    // one for the Low and one for the High gain
+    // connect all the histogram with the container fHist
+    //
+    fHConc1.SetLineColor(kBlue);
+    fHConc.SetFillStyle(0);
+
+    fHConc.SetDirectory(NULL);
+    fHConc1.SetDirectory(NULL);
+    fHAsym.SetDirectory(NULL);
+    fHM3Long.SetDirectory(NULL);
+    fHM3Trans.SetDirectory(NULL);
+
+    fHConc.SetName("Conc2");
+    fHConc1.SetName("Conc1");
+    fHAsym.SetName("Asymmetry");
+    fHM3Long.SetName("3rd Mom Long");
+    fHM3Trans.SetName("3rd Mom Trans");
+
+    fHConc.SetTitle("Ratio: Conc");
+    fHConc1.SetTitle("Ratio: Conc1");
+    fHAsym.SetTitle("Asymmetry");
+    fHM3Long.SetTitle("3^{rd} Moment Longitudinal");
+    fHM3Trans.SetTitle("3^{rd} Moment Transverse");
+
+    fHConc.SetXTitle("Ratio");
+    fHConc1.SetXTitle("Ratio");
+    fHAsym.SetXTitle("Asym [mm]");
+    fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
+    fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
+
+    fHConc.SetYTitle("Counts");
+    fHConc1.SetYTitle("Counts");
+    fHAsym.SetYTitle("Counts");
+    fHM3Long.SetYTitle("Counts");
+    fHM3Trans.SetYTitle("Counts");
+
+
+    MBinning bins;
+
+    bins.SetEdges(100, 0, 1);
+    bins.Apply(fHConc);
+    bins.Apply(fHConc1);
+
+    bins.SetEdges(101, -326, 326);
+    bins.Apply(fHM3Long);
+    bins.Apply(fHM3Trans);
+
+    bins.SetEdges(101, -593, 593);
+    bins.Apply(fHAsym);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the four histograms
+//
+MHHillasExt::~MHHillasExt()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHHillasExt::SetupFill(const MParList *plist)
+{
+    TObject *obj = plist->FindObject("MHillas");
+    if (!obj)
+    {
+        *fLog << err << dbginf << "Sorry 'MHillas' not found in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+    if (!obj->InheritsFrom(MHillasExt::Class()))
+    {
+        *fLog << err << dbginf << "Sorry 'MHillas' doesn't inherit from MHillasExt... aborting." << endl;
+        return kFALSE;
+    }
+    fHillasExt = (MHillasExt*)obj;
+
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Conc",    &fHConc);
+    ApplyBinning(*plist, "Conc1",   &fHConc1);
+    ApplyBinning(*plist, "Asym",    &fHAsym);
+    ApplyBinning(*plist, "M3Long",  &fHM3Long);
+    ApplyBinning(*plist, "M3Trans", &fHM3Trans);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the four histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHHillasExt::Fill(const MParContainer *par)
+{
+    const MHillasSrc *src = (MHillasSrc*)par;
+
+    const Double_t scale = src ? TMath::Sign(fUseMmScale?1:fMm2Deg, src->GetCosDeltaAlpha()) : 1;
+
+    fHConc.Fill(fHillasExt->GetConc());
+    fHConc1.Fill(fHillasExt->GetConc1());
+
+    fHAsym.Fill(scale*fHillasExt->GetAsym());
+    fHM3Long.Fill(scale*fHillasExt->GetM3Long());
+    fHM3Trans.Fill(scale*fHillasExt->GetM3Trans());
+    //fHAsymna.Fill(scale*ext.GetAsymna());
+    //fHAsym0.Fill(scale*ext.GetAsym0());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillasExt::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(&fHAsym,    scale);
+    MH::ScaleAxis(&fHM3Long,  scale);
+    MH::ScaleAxis(&fHM3Trans, scale);
+
+    if (mmscale)
+    {
+        fHAsym.SetXTitle("Asym [mm]");
+        fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
+    }
+    else
+    {
+        fHAsym.SetXTitle("Asym [\\circ]");
+        fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillasExt::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clones of all four histograms. So that the object can be deleted
+// and the histograms are still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle dostroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHHillasExt::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas(this, 720, 540);
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    DrawCopy(fHConc1, fHConc, "Concentrations");
+
+    c.cd(2);
+    ((TH1&)fHAsym).DrawCopy();
+
+    c.cd(3);
+    ((TH1&)fHM3Long).DrawCopy();
+
+    c.cd(4);
+    ((TH1&)fHM3Trans).DrawCopy();
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the four histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHHillasExt::Draw(Option_t *)
+{
+    if (!gPad)
+        MakeDefCanvas(this, 720, 540);
+
+    gPad->Divide(2, 2);
+
+    gPad->cd(1);
+    MH::Draw(fHConc1, fHConc, "Concentrations");
+
+    gPad->cd(2);
+    fHAsym.Draw();
+
+    gPad->cd(3);
+    fHM3Long.Draw();
+
+    gPad->cd(4);
+    fHM3Trans.Draw();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TH1 *MHHillasExt::GetHistByName(const TString name)
+{
+    if (name.Contains("Conc", TString::kIgnoreCase))
+        return &fHConc;
+    if (name.Contains("Conc1", TString::kIgnoreCase))
+        return &fHConc1;
+    if (name.Contains("Asym", TString::kIgnoreCase))
+        return &fHAsym;
+    if (name.Contains("M3Long", TString::kIgnoreCase))
+        return &fHM3Long;
+    if (name.Contains("M3Trans", TString::kIgnoreCase))
+        return &fHM3Trans;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasExt.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHHillasExt
+#define MARS_MHHillasExt
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MHillasExt;
+
+class MHHillasExt : public MH
+{
+private:
+    MHillasExt *fHillasExt; //! Pointer to the MHillasExt container
+
+    TH1F fHConc;    // [ratio] concentration ratio: sum of the two highest pixels / fSize
+    TH1F fHConc1;   // [ratio] concentration ratio: sum of the highest pixel / fSize
+    TH1F fHAsym;    // [mm]    fDist minus dist: center of ellipse, highest pixel
+    TH1F fHM3Long;  // [mm]    3rd moment (e-weighted) along major axis
+    TH1F fHM3Trans; // [mm]    3rd moment (e-weighted) along minor axis
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+public:
+    MHHillasExt(const char *name=NULL, const char *title=NULL);
+    ~MHHillasExt();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    virtual void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1 *GetHistByName(const TString name);
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHHillasExt, 1) // Container which holds histograms for the extended hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.cc	(revision 1638)
@@ -0,0 +1,286 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHHillasSrc
+//
+// This class contains histograms for every Hillas parameter
+//
+///////////////////////////////////////////////////////////////////////
+#include "MHHillasSrc.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MHillasSrc.h"
+
+ClassImp(MHHillasSrc);
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Alpha, and Dist
+//
+MHHillasSrc::MHHillasSrc(const char *name, const char *title)
+    : fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillasSrc";
+    fTitle = title ? title : "Container for Hillas histograms";
+
+    //
+    // loop over all Pixels and create two histograms
+    // one for the Low and one for the High gain
+    // connect all the histogram with the container fHist
+    //
+    fAlpha    = new TH1F("Alpha",    "Alpha of Ellipse",            181,  -90,  90);
+    fDist     = new TH1F("Dist",     "Dist of Ellipse",             100,    0, 445);
+    fHeadTail = new TH1F("HeadTail", "HeadTail of Ellipse",         101, -445, 445);
+    fCosDA    = new TH1F("CosDA",    "cos(Delta,Alpha) of Ellipse", 101,   -1,   1);
+
+    fAlpha->SetDirectory(NULL);
+    fDist->SetDirectory(NULL);
+    fHeadTail->SetDirectory(NULL);
+    fCosDA->SetDirectory(NULL);
+
+    fAlpha->SetXTitle("\\alpha [\\circ]");
+    fDist->SetXTitle("Dist [mm]");
+    fHeadTail->SetXTitle("Head-Tail [mm]");
+    fCosDA->SetXTitle("cos(\\delta,\\alpha)");
+
+    fAlpha->SetYTitle("Counts");
+    fDist->SetYTitle("Counts");
+    fHeadTail->SetYTitle("Counts");
+    fCosDA->SetYTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the four histograms
+//
+MHHillasSrc::~MHHillasSrc()
+{
+    delete fAlpha;
+    delete fDist;
+    delete fHeadTail;
+    delete fCosDA;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHHillasSrc::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Alpha",    fAlpha);
+    ApplyBinning(*plist, "Dist",     fDist);
+    ApplyBinning(*plist, "HeadTail", fHeadTail);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the four histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHHillasSrc::Fill(const MParContainer *par)
+{
+    const MHillasSrc &h = *(MHillasSrc*)par;
+
+    fAlpha   ->Fill(h.GetAlpha());
+    fDist    ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
+    fHeadTail->Fill(fUseMmScale ? h.GetHeadTail() : fMm2Deg*h.GetHeadTail());
+    fCosDA   ->Fill(h.GetCosDeltaAlpha());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<=0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillasSrc::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fDist,     scale);
+    MH::ScaleAxis(fHeadTail, scale);
+
+    if (mmscale)
+    {
+        fDist->SetXTitle("Dist [mm]");
+        fHeadTail->SetXTitle("Head-Tail [mm]");
+    }
+    else
+    {
+        fDist->SetXTitle("Dist [\\circ]");
+        fHeadTail->SetXTitle("Head-Tail [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clones of all two histograms. So that the object can be deleted
+// and the histograms are still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle dostroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHHillasSrc::DrawClone(Option_t *opt) const
+{
+    TCanvas *c = MakeDefCanvas(this, 700, 500);
+    c->Divide(2, 2);
+
+    // FIXME: Display Source position
+
+    gROOT->SetSelectedPad(NULL);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    c->cd(1);
+    fAlpha->DrawCopy();
+
+    c->cd(2);
+    fDist->DrawCopy();
+
+    c->cd(3);
+    fHeadTail->DrawCopy();
+
+    c->cd(4);
+    gPad->SetLogy();
+    fCosDA->DrawCopy();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the two histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHHillasSrc::Draw(Option_t *)
+{
+    if (!gPad)
+        MakeDefCanvas(this, 700, 500);
+
+    // FIXME: Display Source position
+
+    gPad->Divide(2, 2);
+
+    gPad->cd(1);
+    fAlpha->Draw();
+
+    gPad->cd(2);
+    fDist->Draw();
+
+    gPad->cd(1);
+    fHeadTail->Draw();
+
+    gPad->cd(2);
+    gPad->SetLogy();
+    fCosDA->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TH1 *MHHillasSrc::GetHistByName(const TString name)
+{
+    if (name.Contains("Alpha", TString::kIgnoreCase))
+        return fAlpha;
+    if (name.Contains("Dist", TString::kIgnoreCase))
+        return fDist;
+    if (name.Contains("HeadTail", TString::kIgnoreCase))
+        return fHeadTail;
+    if (name.Contains("CosDA", TString::kIgnoreCase))
+        return fCosDA;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHHillasSrc.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHHillasSrc
+#define MARS_MHHillasSrc
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class MHillas;
+
+class MHHillasSrc : public MH
+{
+private:
+    TH1F *fAlpha;     //->
+    TH1F *fDist;      //->
+    TH1F *fHeadTail;  //->   
+    TH1F *fCosDA;     //->
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+public:
+    MHHillasSrc(const char *name=NULL, const char *title=NULL);
+    ~MHHillasSrc();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F *GetHistAlpha()         { return fAlpha; }
+    TH1F *GetHistDist()          { return fDist; }
+    TH1F *GetHistHeadTail()      { return fHeadTail; }
+    TH1F *GetHistCosDeltaAlpha() { return fCosDA; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.cc	(revision 1638)
@@ -0,0 +1,675 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHMatrix
+//
+// This is a histogram container which holds a matrix with one column per
+// data variable. The data variable can be a complex rule (MDataChain).
+// Each event for wich Fill is called (by MFillH) is added as a new
+// row to the matrix.
+//
+// For example:
+//   MHMatrix m;
+//   m.AddColumn("MHillas.fSize");
+//   m.AddColumn("MMcEvt.fImpact/100");
+//   m.AddColumn("HillasSource.fDist*MGeomCam.fConvMm2Deg");
+//   MFillH fillm(&m);
+//   taskliost.AddToList(&fillm);
+//   [...]
+//   m.Print();
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHMatrix.h"
+
+#include <fstream.h>
+
+#include <TList.h>
+#include <TArrayF.h>
+#include <TArrayD.h>
+#include <TArrayI.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MData.h"
+#include "MDataArray.h"
+
+ClassImp(MHMatrix);
+
+const TString MHMatrix::gsDefName  = "MHMatrix";
+const TString MHMatrix::gsDefTitle = "Multidimensional Matrix";
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor
+//
+MHMatrix::MHMatrix(const char *name, const char *title)
+    : fNumRow(0), fData(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Initializes the columns of the matrix with the entries
+//  from a MDataArray
+//
+MHMatrix::MHMatrix(MDataArray *mat, const char *name, const char *title)
+    : fNumRow(0), fData(mat)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. Does not deleted a user given MDataArray, except IsOwner
+//  was called.
+//
+MHMatrix::~MHMatrix()
+{
+    if (TestBit(kIsOwner) && fData)
+        delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new column to the matrix. This can only be done before the first
+// event (row) was filled into the matrix. For the syntax of the rule
+// see MDataChain.
+// Returns the index of the new column, -1 in case of failure.
+// (0, 1, 2, ... for the 1st, 2nd, 3rd, ...)
+//
+Int_t MHMatrix::AddColumn(const char *rule)
+{
+    if (fM.IsValid())
+    {
+        *fLog << warn << "Warning - matrix is already in use. Can't add a new column... skipped." << endl;
+        return -1;
+    }
+
+    if (TestBit(kIsLocked))
+    {
+        *fLog << warn << "Warning - matrix is locked. Can't add new column... skipped." << endl;
+        return -1;
+    }
+
+    if (!fData)
+    {
+        fData = new MDataArray;
+        SetBit(kIsOwner);
+    }
+
+    fData->AddEntry(rule);
+    return fData->GetNumEntries()-1;
+}
+
+void MHMatrix::AddColumns(MDataArray *matrix)
+{
+    if (fM.IsValid())
+    {
+        *fLog << warn << "Warning - matrix is already in use. Can't add new columns... skipped." << endl;
+        return;
+    }
+
+    if (TestBit(kIsLocked))
+    {
+        *fLog << warn << "Warning - matrix is locked. Can't add new columns... skipped." << endl;
+        return;
+    }
+
+    if (fData)
+        *fLog << warn << "Warning - columns already added... replacing." << endl;
+
+    if (fData && TestBit(kIsOwner))
+    {
+        delete fData;
+        ResetBit(kIsOwner);
+    }
+
+    fData = matrix;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one column is available and PreProcesses all
+// data chains.
+//
+Bool_t MHMatrix::SetupFill(const MParList *plist)
+{
+    if (!fData)
+    {
+        *fLog << err << "Error - No Columns initialized... aborting." << endl;
+        return kFALSE;
+    }
+
+    return fData->PreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// If the matrix has not enough rows double the number of available rows.
+//
+void MHMatrix::AddRow()
+{
+    fNumRow++;
+
+    if (fM.GetNrows() > fNumRow)
+        return;
+
+    if (!fM.IsValid())
+    {
+        fM.ResizeTo(1, fData->GetNumEntries());
+        return;
+    }
+
+    TMatrix m(fM);
+
+    fM.ResizeTo(fM.GetNrows()*2, fData->GetNumEntries());
+
+    for (int x=0; x<m.GetNcols(); x++)
+        for (int y=0; y<m.GetNrows(); y++)
+            fM(y, x) = m(y, x);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the values correspoding to the columns to the new row
+//
+Bool_t MHMatrix::Fill(const MParContainer *par)
+{
+    AddRow();
+
+    for (int col=0; col<fData->GetNumEntries(); col++)
+        fM(fNumRow-1, col) = (*fData)(col);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Resize the matrix to a number of rows which corresponds to the number of
+// rows which have really been filled with values.
+//
+Bool_t MHMatrix::Finalize()
+{
+    //
+    // It's not a fatal error so we don't need to stop PostProcessing...
+    //
+    if (fData->GetNumEntries()==0 || fNumRow<1)
+        return kTRUE;
+
+    TMatrix m(fM);
+
+    fM.ResizeTo(fNumRow, fData->GetNumEntries());
+
+    for (int x=0; x<fM.GetNcols(); x++)
+        for (int y=0; y<fM.GetNrows(); y++)
+            fM(y, x) = m(y, x);
+
+    return kTRUE;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram. So that the object can be deleted
+// and the histogram is still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHMatrix::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MH::MakeDefCanvas(fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHist->DrawCopy(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHMatrix::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHist);
+
+    fHist->Draw(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Prints the meaning of the columns and the contents of the matrix.
+// Becareful, this can take a long time for matrices with many rows.
+// Use the option 'size' to print the size of the matrix.
+// Use the option 'cols' to print the culumns
+// Use the option 'data' to print the contents
+//
+void MHMatrix::Print(Option_t *o) const
+{
+    TString str(o);
+
+    *fLog << all << flush;
+
+    if (str.Contains("size", TString::kIgnoreCase))
+    {
+        *fLog << GetDescriptor() << ": NumColumns=" << fM.GetNcols();
+        *fLog << " NumRows=" << fM.GetNrows() << endl;
+    }
+
+    if (!fData && str.Contains("cols", TString::kIgnoreCase))
+        *fLog << "Sorry, no column information available." << endl;
+
+    if (fData && str.Contains("cols", TString::kIgnoreCase))
+        fData->Print();
+
+    if (str.Contains("data", TString::kIgnoreCase))
+        fM.Print();
+}
+
+const TMatrix *MHMatrix::InvertPosDef()
+{
+    TMatrix m(fM);
+
+    const Int_t rows = m.GetNrows();
+    const Int_t cols = m.GetNcols();
+
+    for (int x=0; x<cols; x++)
+    {
+        Double_t avg = 0;
+        for (int y=0; y<rows; y++)
+            avg += fM(y, x);
+
+        avg /= rows;
+
+        for (int y=0; y<rows; y++)
+            m(y, x) -= avg;
+    }
+
+    TMatrix *m2 = new TMatrix(m, TMatrix::kTransposeMult, m);
+
+    Double_t det;
+    m2->Invert(&det);
+    if (det==0)
+    {
+        *fLog << err << "ERROR - MHMatrix::InvertPosDef failed (Matrix is singular)." << endl;
+        delete m2;
+        return NULL;
+    }
+
+    // m2->Print();
+
+    return m2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculated the distance of vector evt from the reference sample
+// represented by the covariance metrix m.
+//  - If n<0 the kernel method is applied and
+//    -log(sum(epx(-d/h))/n) is returned.
+//  - For n>0 the n nearest neighbors are summed and
+//    sqrt(sum(d)/n) is returned.
+//  - if n==0 all distances are summed
+//
+Double_t MHMatrix::CalcDist(const TMatrix &m, const TVector &evt, Int_t num) const
+{
+    if (num==0) // may later be used for another method
+    {
+        TVector d = evt;
+        d *= m;
+        return TMath::Sqrt(d*evt);
+    }
+
+    const Int_t rows = fM.GetNrows();
+    const Int_t cols = fM.GetNcols();
+
+    TArrayD dists(rows);
+
+    //
+    // Calculate:  v^T * M * v
+    //
+    for (int i=0; i<rows; i++)
+    {
+        TVector col(cols);
+        col = TMatrixRow(fM, i);
+
+        TVector d = evt;
+        d -= col;
+
+        TVector d2 = d;
+        d2 *= m;
+
+        dists[i] = d2*d; // square of distance
+
+        //
+        // This corrects for numerical uncertanties in cases of very
+        // small distances...
+        //
+        if (dists[i]<0)
+            dists[i]=0;
+    }
+
+    TArrayI idx(rows);
+    TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE);
+
+    Int_t from = 0;
+    Int_t to   = TMath::Abs(num)<rows ? TMath::Abs(num) : rows;
+    //
+    // This is a zero-suppression for the case a test- and trainings
+    // sample is identical. This would result in an unwanted leading
+    // zero in the array. To suppress also numerical uncertanties of
+    // zero we cut at 1e-5. Due to Rudy this should be enough. If
+    // you encounter problems we can also use (eg) 1e-25
+    //
+    if (dists[idx[0]]<1e-5)
+    {
+        from++;
+        to ++;
+        if (to>rows)
+            to = rows;
+    }
+
+    if (num<0)
+    {
+        //
+        // Kernel function sum (window size h set according to literature)
+        //
+        const Double_t h    = TMath::Power(rows, -1./(cols+4));
+        const Double_t hwin = h*h*2;
+
+        Double_t res = 0;
+        for (int i=from; i<to; i++)
+            res += TMath::Exp(-dists[idx[i]]/hwin);
+
+        return -TMath::Log(res/(to-from));
+    }
+    else
+    {
+        //
+        // Nearest Neighbor sum
+        //
+        Double_t res = 0;
+        for (int i=from; i<to; i++)
+            res += dists[idx[i]];
+
+        return TMath::Sqrt(res/(to-from));
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls calc dist. In the case of the first call the covariance matrix
+// fM2 is calculated.
+//  - If n<0 it is divided by (nrows-1)/h while h is the kernel factor.
+//
+Double_t MHMatrix::CalcDist(const TVector &evt, Int_t num)
+{
+    if (!fM2.IsValid())
+    {
+        const TMatrix *m = InvertPosDef();
+        if (!m)
+            return -1;
+
+        fM2.ResizeTo(*m);
+        fM2 = *m;
+        fM2 *= fM.GetNrows()-1;
+        delete m;
+    }
+
+    return CalcDist(fM2, evt, num);
+}
+
+void MHMatrix::Reassign()
+{
+    TMatrix m = fM;
+    fM.ResizeTo(1,1);
+    fM.ResizeTo(m);
+    fM = m;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MHMatrix::StreamPrimitive(ofstream &out) const
+{
+    Bool_t data = fData && !TestBit(kIsOwner);
+
+    if (data)
+    {
+        fData->SavePrimitive(out);
+        out << endl;
+    }
+
+    out << "   MHMatrix " << GetUniqueName();
+
+    if (data || fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(";
+        if (data)
+            out << "&" << fData->GetUniqueName();
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+        {
+            if (data)
+                out << ", ";
+            out << "\"" << fName << "\"";
+            if (fTitle!=gsDefTitle)
+                out << ", \"" << fTitle << "\"";
+        }
+    }
+    out << ");" << endl;
+
+    if (fData && TestBit(kIsOwner))
+        for (int i=0; i<fData->GetNumEntries(); i++)
+            out << "   " << GetUniqueName() << ".AddColumn(\"" << (*fData)[i].GetRule() << "\");" << endl;
+}
+
+const TArrayI MHMatrix::GetIndexOfSortedColumn(Int_t ncol, Bool_t desc) const
+{
+    TMatrixColumn col(fM, ncol);
+
+    const Int_t n = fM.GetNrows();
+
+    TArrayF array(n);
+
+    for (int i=0; i<n; i++)
+        array[i] = col(i);
+
+    TArrayI idx(n);
+    TMath::Sort(n, array.GetArray(), idx.GetArray(), desc);
+
+    return idx;
+}
+
+void MHMatrix::SortMatrixByColumn(Int_t ncol, Bool_t desc)
+{
+    TArrayI idx = GetIndexOfSortedColumn(ncol, desc);
+
+    const Int_t n = fM.GetNrows();
+
+    TMatrix m(n, fM.GetNcols());
+    for (int i=0; i<n; i++)
+    {
+        TVector vold(n);
+        vold = TMatrixRow(fM, idx[i]);
+
+        TMatrixRow rownew(m, i);
+        rownew = vold;
+    }
+
+    fM = m;
+}
+
+Bool_t MHMatrix::Fill(MParList *plist, MTask *read)
+{
+    //
+    // Read data into Matrix
+    //
+    const Bool_t is = plist->IsOwner();
+    plist->SetOwner(kFALSE);
+
+    MTaskList tlist;
+    plist->Replace(&tlist);
+
+    MFillH fillh(this);
+
+    tlist.AddToList(read);
+    tlist.AddToList(&fillh);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(plist);
+
+    if (!evtloop.Eventloop())
+        return kFALSE;
+
+    plist->Remove(&tlist);
+    plist->SetOwner(is);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the matrix.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MHMatrix::GetDataMember() const
+{
+    return fData ? fData->GetDataMember() : TString("");
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the matrix.
+// This is mainly used in MTask::AddToBranchList
+//
+void MHMatrix::ReduceNumberOfRows(UInt_t numrows, const TString opt)
+{
+    UInt_t rows = fM.GetNrows();
+
+    if (rows==numrows)
+    {
+        *fLog << warn << "Matrix has already the correct number of rows..." << endl;
+        return;
+    }
+
+    Float_t ratio = (Float_t)numrows/fM.GetNrows();
+
+    if (ratio>=1)
+    {
+        *fLog << warn << "Matrix cannot be enlarged..." << endl;
+        return;
+    }
+
+    Double_t sum = 0;
+
+    UInt_t oldrow = 0;
+    UInt_t newrow = 0;
+
+    while (oldrow<rows)
+    {
+        sum += ratio;
+
+        if (newrow<=(unsigned int)sum)
+        {
+            TVector vold(fM.GetNcols());
+            vold = TMatrixRow(fM, oldrow);
+
+            TMatrixRow rownew(fM, newrow);
+            rownew = vold;
+            newrow++;
+        }
+
+        oldrow++;
+    }
+
+/*
+
+    TMatrix m(n, fM.GetNcols());
+    for (int i=0; i<n; i++)
+    {
+        TVector vold(n);
+        vold = TMatrixRow(fM, idx[i]);
+
+        TMatrixRow rownew(m, i);
+        rownew = vold;
+    }
+*/
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMatrix.h	(revision 1638)
@@ -0,0 +1,96 @@
+#ifndef MARS_MHMatrix
+#define MARS_MHMatrix
+
+#ifdef MARS_MLogManip
+#error Please make ensure that MLogManip.h are included _after_ MHMatrix.h
+#endif
+
+#ifndef ROOT_TMatrix
+#include <TMatrix.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TArrayI;
+
+class MTask;
+class MParList;
+class MDataArray;
+
+class MHMatrix : public MH
+{
+private:
+    static const TString gsDefName;  //! Default Name
+    static const TString gsDefTitle; //! Default Title
+
+    Int_t   fNumRow;    //! Number of dimensions of histogram
+    Int_t   fRow;       //! Present row
+    TMatrix fM;         // Matrix to be filled
+
+    TMatrix fM2;        //! Covariance Matrix
+
+    MDataArray *fData;  // List of data members (columns)
+
+    enum {
+        kIsOwner  = BIT(14),
+        kIsLocked = BIT(16)
+    };
+
+    void AddRow();
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+    Bool_t Finalize();
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MHMatrix(const char *name=NULL, const char *title=NULL);
+    MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
+    ~MHMatrix();
+
+    void Lock()   { SetBit(kIsLocked); }
+    void Unlock() { ResetBit(kIsLocked); }
+
+    Int_t AddColumn(const char *name);
+    void AddColumns(MDataArray *mat);
+
+    MDataArray *GetColumns() { return fData; }
+
+    const TMatrix &GetM() const { return fM; }
+
+    Bool_t IsValid() const { return fM.IsValid(); }
+    Int_t  GetNumRows() const { return fNumRow; }
+
+    //void Draw(Option_t *opt=NULL);
+    //TObject *DrawClone(Option_t *opt=NULL) const;
+
+    void Print(Option_t *) const;
+
+    const TMatrix *InvertPosDef();
+
+    Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
+    Double_t CalcDist(const TVector &v, Int_t num = 25);
+
+    void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    void Reassign();
+
+    const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
+    void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
+
+    Bool_t SetNumRow(Int_t row) { if (row>=fNumRow || row<0) return kFALSE; fRow = row; return kTRUE; }
+    Int_t GetNumRow() const { return fRow; };
+    Double_t operator[](Int_t col) { return fM(fRow, col); }
+
+    Bool_t Fill(MParList *plist, MTask *read);
+
+    TString GetDataMember() const;
+
+    void ReduceNumberOfRows(UInt_t numrows, const TString opt);
+
+    ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.cc	(revision 1638)
@@ -0,0 +1,375 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHMcCollectionArea                                                      //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcCollectionArea.h" 
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+#include "MHMcEfficiency.h"
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcCollectionArea);
+
+// --------------------------------------------------------------------------
+//
+//  Creates the three necessary histograms:
+//   - selected showers (input)
+//   - all showers (input)
+//   - collection area (result)
+//
+MHMcCollectionArea::MHMcCollectionArea(const char *name, const char *title)
+{ 
+    //   initialize the histogram for the distribution r vs E
+    //
+    //   we set the energy range from 10 Gev to 20000 GeV (in log 5 orders
+    //   of magnitude) and for each order we take 10 subdivision --> 50 xbins
+    //
+    //   we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
+    //
+    fName  = name  ? name  : "MHMcCollectionArea";
+    fTitle = title ? title : "Collection Area vs. Energy";
+
+    MBinning binsx;
+    MBinning binsy;
+    binsx.SetEdgesLog(50, 10, 20000);
+    binsy.SetEdges   (50,  0,   500);
+
+    fHistAll = new TH2D;
+    fHistSel = new TH2D;
+    fHistCol = new TH1D;
+ 
+    MH::SetBinning(fHistAll, &binsx, &binsy);
+    MH::SetBinning(fHistSel, &binsx, &binsy);
+
+    fHistCol->SetName(fName);
+    fHistAll->SetName("AllEvents");
+    fHistSel->SetName("SelectedEvents");
+
+    fHistCol->SetTitle(fTitle);
+    fHistAll->SetTitle("All showers - Radius vs Energy distribution");
+    fHistSel->SetTitle("Selected showers - Radius vs Energy distribution");
+
+    fHistAll->SetDirectory(NULL);
+    fHistSel->SetDirectory(NULL);
+    fHistCol->SetDirectory(NULL);
+
+    fHistAll->SetXTitle("E [GeV]");
+    fHistAll->SetYTitle("r [m]");
+    fHistAll->SetZTitle("N");
+
+    fHistSel->SetXTitle("E [GeV]");
+    fHistSel->SetYTitle("r [m]");
+    fHistSel->SetYTitle("N");
+
+    fHistCol->SetXTitle("E [GeV]");
+    fHistCol->SetYTitle("A [m^{2}]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the three histograms
+//
+MHMcCollectionArea::~MHMcCollectionArea()
+{
+    delete fHistAll;
+    delete fHistSel;
+    delete fHistCol;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains all showers
+//
+void MHMcCollectionArea::FillAll(Float_t energy, Float_t radius)
+{
+    fHistAll->Fill(energy, radius);
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains the selected showers
+//
+void MHMcCollectionArea::FillSel(Float_t energy, Float_t radius)
+{
+    fHistSel->Fill(energy, radius);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHMcCollectionArea::DrawAll(Option_t* option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHistAll);
+
+    fHistAll->Draw(option);
+
+    gPad->SetLogx();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with the selected showers only.
+//
+void MHMcCollectionArea::DrawSel(Option_t* option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHistSel);
+
+    fHistSel->Draw(option);
+
+    gPad->SetLogx();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+TObject *MHMcCollectionArea::DrawClone(Option_t* option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(fHistCol);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHistCol->DrawCopy(option);
+
+    gPad->SetLogx();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcCollectionArea::Draw(Option_t* option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHistCol);
+
+    fHistCol->Draw(option);
+
+    gPad->SetLogx();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::CalcEfficiency()
+{
+    Calc(*fHistSel, *fHistAll);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc((TH2D&)*mcsel.GetHist(), (TH2D&)*mcall.GetHist());
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(TH2D &hsel, TH2D &hall)
+{
+    MH::SetBinning(fHistCol, hsel.GetXaxis());
+
+    fHistCol->Sumw2();
+
+    TH1D &psel = *hsel.ProjectionX();
+    TH1D &pall = *hall.ProjectionX();
+
+    const Double_t max = psel.GetYaxis()->GetXmax();
+
+    fHistCol->Divide(&psel, &pall, TMath::Pi()*max*max, 1);
+    fHistCol->SetEntries(hsel.GetEntries());
+
+    delete &psel;
+    delete &pall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::CalcEfficiency(UInt_t numevts, Float_t angle)
+{
+    // Here we estimate the total number of showers in each energy bin
+    // known the energy range and spectral index of the generated showers
+    // (set now by hand since the info is not available in the header!)
+
+    TH1D &histsel = *fHistSel->ProjectionX();
+
+    TH1D histall;
+
+    TAxis &xaxis = *histsel.GetXaxis();
+
+    MH::SetBinning(&histall, &xaxis);
+    MH::SetBinning(fHistCol, &xaxis);
+
+    const Float_t emin  = 10.;
+    const Float_t emax  = 30000.;  // Energies in GeV.
+    const Float_t index = 2.6;     // Differential spectral Index.
+
+    const Float_t expo = 1.-index;
+
+    const Float_t k = (Float_t)numevts / (pow(emax,expo) - pow(emin,expo));
+
+    const Int_t nbinx = xaxis.GetNbins();
+
+    for (Int_t i=1; i<=nbinx; i++)
+    {
+        const Float_t e1 = histall.GetBinLowEdge(i);
+        const Float_t e2 = histall.GetBinLowEdge(i+1);
+
+        if (e1 < emin || e2 > emax)
+            continue;
+
+        const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
+
+        histall.SetBinContent(i, events);
+        histall.SetBinError(i, sqrt(events));
+
+    }
+
+    // -----------------------------------------------------------
+
+    // Impact parameter range:
+    const Float_t r1 = 0;
+    const Float_t r2 = 400;
+
+    const Float_t dr = TMath::Pi() * (r2*r2 - r1*r1);
+
+    angle *= TMath::Pi()/180;
+
+    for (Int_t ix=1; ix<=nbinx; ix++)
+    {
+        const Float_t Na = histall.GetBinContent(ix);
+
+        if (Na <= 0)
+            continue;
+
+        const Float_t Ns = histsel.GetBinContent(ix);
+
+        // Since Na is an estimate of the total number of showers generated
+        // in the energy bin, it may happen that Ns (triggered showers) is
+        // larger than Na. In that case, the bin is skipped:
+
+        if (Na < Ns)
+            continue;
+
+        const Double_t eff = Ns/Na;
+
+        const Double_t err = sqrt((1.-eff)*Ns)/Na;
+
+        const Float_t area = dr * cos(angle);
+
+        fHistCol->SetBinContent(ix, eff*area);
+        fHistCol->SetBinError(ix, err*area);
+    }
+
+    delete &histsel;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(const MHMcEfficiency &heff)
+{
+    //
+    //  now calculate the Collection area for different
+    //  energies
+    //
+    TH2D &h = (TH2D&)*heff.GetHist();
+
+    MH::SetBinning(fHistCol, h.GetXaxis());
+
+    const Int_t nbinx = h.GetXaxis()->GetNbins();
+    const Int_t nbiny = h.GetYaxis()->GetNbins();
+
+    for (Int_t ix=1; ix<=nbinx; ix++)
+    {
+        Double_t errA = 0;
+        Double_t colA = 0;
+
+        for (Int_t iy=1; iy<=nbiny; iy++)
+        {
+            TAxis *yaxis = h.GetYaxis();
+
+            const Double_t r1  = yaxis->GetBinLowEdge(iy);
+            const Double_t r2  = yaxis->GetBinLowEdge(iy+1);
+
+            const Double_t A   = TMath::Pi() * (r2*r2 - r1*r1);
+
+            const Double_t eff = h.GetCellContent(ix, iy);
+            const Double_t err = h.GetCellError(ix, iy);
+
+            colA += eff*A;
+            errA += A*A * err*err;
+        }
+
+        fHistCol->SetBinContent(ix, colA);
+        fHistCol->SetBinError(ix, sqrt(errA));
+    }
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcCollectionArea.h	(revision 1638)
@@ -0,0 +1,49 @@
+#ifndef MARS_MHMcCollectionArea
+#define MARS_MHMcCollectionArea
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1D;
+class TH2D;
+
+class MHMcEfficiency;
+class MHMcEnergyImpact;
+
+class MHMcCollectionArea : public MParContainer
+{
+private:
+    TH2D *fHistAll; //! all simulated showers
+    TH2D *fHistSel; //! the selected showers
+
+    TH1D *fHistCol; //  the collection area
+
+    void Calc(TH2D &hsel, TH2D &hall);
+
+public:
+    MHMcCollectionArea(const char *name=NULL, const char *title=NULL);
+    ~MHMcCollectionArea();
+
+    void FillAll(Float_t energy, Float_t radius);
+    void FillSel(Float_t energy, Float_t radius);
+
+    void DrawAll(Option_t *option="");
+    void DrawSel(Option_t *option="");
+
+    const TH1D *GetHist()       { return fHistCol; }
+    const TH1D *GetHist() const { return fHistCol; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    void CalcEfficiency();
+    void CalcEfficiency(UInt_t allevts, Float_t theta);
+
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+    void Calc(const MHMcEfficiency &heff);
+
+    ClassDef(MHMcCollectionArea, 1)  // Data Container to calculate Collection Area
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.cc	(revision 1638)
@@ -0,0 +1,183 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcDifRate
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcDifRate.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcCollectionArea.h"
+
+ClassImp(MHMcDifRate);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcDifRate::MHMcDifRate(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcDifRate";
+    fTitle = title ? title : "Differential Trigger Rate";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("dR/dE [Hz/GeV]");
+}
+
+void MHMcDifRate::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcDifRate::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcDifRate::~MHMcDifRate()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcDifRate::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcDifRate::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+/*
+void MHMcDifRate::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
+
+    SetReadyToSave();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the DifRate and set the 'ReadyToSave' flag.
+//  The DifRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcDifRate::Calc(const MHMcCollectionArea &cola, const TF1 &spect)
+{
+    /*const*/ TH1D &hcol = (TH1D&)*cola.GetHist();
+
+    fHist.Reset();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, hcol.GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    fHist.Add(&hcol);
+    fHist.Multiply((TF1*)&spect);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcDifRate.h	(revision 1638)
@@ -0,0 +1,44 @@
+#ifndef MARS_MHMcDifRate
+#define MARS_MHMcDifRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class TF1;
+class MMcEvt;
+class MHMcCollectionArea;
+
+class MHMcDifRate : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcDifRate(const char *name=NULL, const char *title=NULL);
+    ~MHMcDifRate();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+//    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcCollectionArea &cola, const TF1 &spect);
+
+    ClassDef(MHMcDifRate, 1)  // Histogram container for differential trigger rate
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.cc	(revision 1638)
@@ -0,0 +1,173 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEfficiency
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEfficiency.h" 
+
+#include <math.h>
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcEfficiency);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEfficiency::MHMcEfficiency(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEfficiency";
+    fTitle = title ? title : "Trigger Efficieny (Energy-Impact parameter plane)";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("r [m]");
+    fHist.SetZTitle("Trig. Eff. [1]");
+
+
+    MBinning binsx;
+    binsx.SetEdgesLog(10, 1, 100000); // [GeV]
+
+    MBinning binsy;
+    binsy.SetEdges(9, 0, 450);       // [m]
+    MH::SetBinning(&fHist, &binsx, &binsy);
+}
+
+void MHMcEfficiency::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEfficiency::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEfficiency::~MHMcEfficiency()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiency::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEfficiency::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH2D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcEfficiency::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency and set the 'ReadyToSave' flag.
+//  The Efficiency is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiency::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiency.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHMcEfficiency
+#define MARS_MHMcEfficiency
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MHMcEnergyImpact;
+
+class MHMcEfficiency : public MParContainer
+{
+private:
+
+    TH2D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcEfficiency(const char *name=NULL, const char *title=NULL);
+    ~MHMcEfficiency();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiency, 1)  // Histogram container for 2D trigger efficiency
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 1638)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEfficiencyEnergy
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEfficiencyEnergy.h" 
+
+#include <math.h>
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcEfficiencyEnergy);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEfficiencyEnergy::MHMcEfficiencyEnergy(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEfficiencyEnergy";
+    fTitle = title ? title : "Trigger Efficieny vs. Energy";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("Trig. Eff. [1]");
+
+    MBinning binse;
+    binse.SetEdgesLog(10, 1, 100000); // [GeV]
+    MH::SetBinning(&fHist, &binse);
+}
+
+void MHMcEfficiencyEnergy::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEfficiencyEnergy::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEfficiencyEnergy::~MHMcEfficiencyEnergy()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyEnergy::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEfficiencyEnergy::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcEfficiencyEnergy::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionX();
+    TH1D &tall = *((TH2D&)hall).ProjectionX();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyEnergy and set the 'ReadyToSave' flag.
+//  The EfficiencyEnergy is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyEnergy::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHMcEfficiencyEnergy
+#define MARS_MHMcEfficiencyEnergy
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MHMcEnergyImpact;
+
+class MHMcEfficiencyEnergy : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcEfficiencyEnergy(const char *name=NULL, const char *title=NULL);
+    ~MHMcEfficiencyEnergy();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyEnergy, 1)  // Histogram container for 1D trigger efficiency in energy
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 1638)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEfficiencyImpact
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEfficiencyImpact.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcEnergyImpact.h"
+
+ClassImp(MHMcEfficiencyImpact);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEfficiencyImpact::MHMcEfficiencyImpact(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEfficiencyImpact";
+    fTitle = title ? title : "Trigger Efficieny vs. Impact";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("r [m]");
+    fHist.SetYTitle("Trig. Eff. [1]");
+
+
+    MBinning binsr;
+    binsr.SetEdges(9, 0, 450);       // [m]
+    MH::SetBinning(&fHist, &binsr);
+}
+
+void MHMcEfficiencyImpact::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEfficiencyImpact::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEfficiencyImpact::~MHMcEfficiencyImpact()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyImpact::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEfficiencyImpact::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+void MHMcEfficiencyImpact::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionY();
+    TH1D &tall = *((TH2D&)hall).ProjectionY();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyImpact and set the 'ReadyToSave' flag.
+//  The EfficiencyImpact is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyImpact::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEfficiencyImpact.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHMcEfficiencyImpact
+#define MARS_MHMcEfficiencyImpact
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MHMcEnergyImpact;
+
+class MHMcEfficiencyImpact : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcEfficiencyImpact(const char *name=NULL, const char *title=NULL);
+    ~MHMcEfficiencyImpact();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyImpact, 1) // Histogram container for 1D trigger efficiency in impact
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.cc	(revision 1638)
@@ -0,0 +1,265 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEnergy
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEnergy.h" 
+
+#include <stdlib.h>
+#include <iostream.h>
+
+#include <TH1.h> 
+#include <TF1.h> 
+#include <TCanvas.h>
+#include <TPaveLabel.h> 
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcEnergy);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEnergy::MHMcEnergy(const char *name, const char *title)
+{ 
+    fTitle = title ? title : "Container for an energy distribution histogram";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist = new TH1F("", "", 20, 0.5, 4.5);
+
+    fHist->SetDirectory(NULL);
+    fHist->SetXTitle("log(E/GeV)");
+    fHist->SetYTitle("dN/dE");
+
+    SetName(name ? name : "MHMcEnergy");
+}
+
+// -------------------------------------------------------------------------
+//
+//  This doesn't only set the name. It tries to get the number from the
+//  name and creates also name and title of the histogram.
+//
+//  This is necessary for example if a list of such MHMcEnergy histograms
+//  is created (s. MParList::CreateObjList)
+//
+void MHMcEnergy::SetName(const char *name)
+{
+    TString cname(name);
+    const char *semicolon = strrchr(cname, ';');
+
+    UInt_t idx = semicolon ? atoi(semicolon+1) : 0;
+
+    fName = cname;
+
+    char text[256];
+    if (idx>0)
+        sprintf(text, "Energy Distribution for trigger condition #%i", idx);
+    else
+        sprintf(text, "Energy Distribution");
+
+    char aux[256];
+    strcpy(aux, "Threshold");
+
+    if (idx>0)
+        sprintf(aux+strlen(aux), " #%i", idx);
+
+    fHist->SetName(aux);
+    fHist->SetTitle(text);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEnergy::~MHMcEnergy()
+{
+    delete fHist;
+}
+
+//--------------------------------------------------------------------------
+//
+//  Fill the histogram with the log10 of the energy for triggered events.
+//
+void MHMcEnergy::Fill(Float_t log10E, Float_t w)
+{
+    fHist->Fill(log10E, w);
+}
+
+// -------------------------------------------------------------------------
+//
+// Fitting function
+//
+void MHMcEnergy::Fit(Axis_t xxmin, Axis_t xxmax)
+{
+    //
+    // 0: don't draw the function (it is drawn together with the histogram)
+    // Q: quiet mode
+    //
+    fHist->Fit("gaus", "Q0", "", xxmin, xxmax);
+
+    TF1 *result = fHist->GetFunction("gaus");
+
+    fThreshold    = CalcThreshold(result);
+    fThresholdErr = CalcThresholdErr(result);
+    fGaussPeak    = CalcGaussPeak(result);
+    fGaussSigma   = CalcGaussSigma(result);
+}
+
+// ------------------------------------------------------------------------
+// 
+//  Helper function for Draw() and DrawClone() which adds some useful
+//  information to the plot.
+//
+void MHMcEnergy::DrawLegend() const
+{
+    char text[256];
+
+    const Float_t min = fHist->GetMinimum();
+    const Float_t max = fHist->GetMaximum();
+    const Float_t sum = min+max;
+
+    sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV",
+            fThreshold, fThresholdErr);
+
+    TPaveLabel* label = new TPaveLabel(2.2, 0.75*sum, 4.4, 0.90*sum, text);
+    label->SetFillColor(10);
+    label->SetTextSize(0.3);
+    label->SetBit(kCanDelete);
+    label->Draw();
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEnergy::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHist);
+
+    fHist->Draw(option);
+
+    DrawLegend();
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEnergy::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHist->DrawClone(option);
+
+    DrawLegend();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the number of bins in the histogran.
+//
+void MHMcEnergy::SetNumBins(Int_t nbins)
+{
+    fHist->SetBins(nbins, 0.5, 4.5);
+}
+// --------------------------------------------------------------------------
+//
+// Write the threshold and its error in the standard output
+//
+void MHMcEnergy::Print(Option_t*) const
+{
+    *fLog << all << "Threshold: " << fThreshold << " +- " << fThresholdErr << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+//  Return the threshold
+//
+Float_t MHMcEnergy::CalcThreshold(TF1 *gauss)
+{
+    const Float_t p1 = gauss->GetParameter(1);
+
+    return pow(10, p1);
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the error of the threshold.
+//
+Float_t MHMcEnergy::CalcThresholdErr(TF1 *gauss)
+{
+    const Float_t lg10  = log(10);
+    const Float_t p1    = gauss->GetParameter(1);
+    const Float_t p1err = gauss->GetParError(1);
+
+    // The error has into accuont the error in the fit
+    return pow(10, p1) * p1err * lg10;
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the peak of the fitted gaussan function.
+//
+Float_t MHMcEnergy::CalcGaussPeak(TF1 *gauss)
+{
+    return gauss->GetParameter(1);
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the sigma of the fitted gaussan function.
+//
+Float_t MHMcEnergy::CalcGaussSigma(TF1 *gauss)
+{
+    return gauss->GetParameter(2);
+}
+
+TH1 *MHMcEnergy::GetHistByName(const TString name)
+{
+    return fHist;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergy.h	(revision 1638)
@@ -0,0 +1,58 @@
+#ifndef MARS_MHMcEnergy
+#define MARS_MHMcEnergy
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1;
+class TH1F;
+class TF1;
+
+class MHMcEnergy : public MParContainer
+{
+private:
+
+    TH1F *fHist;  // histogram with the logarith of the energy
+
+    Float_t fThreshold;
+    Float_t fThresholdErr;
+    Float_t fGaussPeak;
+    Float_t fGaussSigma;
+
+    Float_t CalcThreshold(TF1 *gauss);
+    Float_t CalcThresholdErr(TF1 *gauss);
+
+    Float_t CalcGaussPeak(TF1 *gauss);
+    Float_t CalcGaussSigma(TF1 *gauss);
+
+    void DrawLegend() const;
+
+public:
+
+    MHMcEnergy(const char *name=NULL, const char *title=NULL);
+    ~MHMcEnergy();
+
+    void SetName(const char *name);
+
+    Float_t GetThreshold() const { return fThreshold; }
+    Float_t GetThresholdErr() const { return fThresholdErr; }
+
+    Float_t GetGaussPeak() const { return fGaussPeak; }
+    Float_t GetGaussSigma() const { return fGaussSigma; };
+
+    void Fill(Float_t log10E, Float_t w);
+    void Fit(Axis_t xxmin, Axis_t xxmax);
+    void SetNumBins(Int_t nbins = 100);
+
+    TH1 *GetHistByName(const TString name);
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Print(Option_t* option = NULL) const;
+
+    ClassDef(MHMcEnergy, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.cc	(revision 1638)
@@ -0,0 +1,168 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcEnergyImpact
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcEnergyImpact.h" 
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHMcEnergyImpact);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcEnergyImpact::MHMcEnergyImpact(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcEnergyImpact";
+    fTitle = title ? title : "Impact (radius) vs Energy distribution";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("r [m]");
+    fHist.SetZTitle("N");
+
+    MBinning binsx;
+    binsx.SetEdgesLog(10, 1, 100000); // [GeV]
+
+    MBinning binsy;
+    binsy.SetEdges(9, 0, 450);       // [m]
+
+    SetBinning(&fHist, &binsx, &binsy);
+
+}
+
+void MHMcEnergyImpact::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcEnergyImpact::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetName(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcEnergyImpact::~MHMcEnergyImpact()
+{
+}
+
+
+Bool_t MHMcEnergyImpact::SetupFill(const MParList *pList)
+{
+    const MBinning *binsx = (MBinning*)pList->FindObject("BinningEnergy", "MBinning");
+    const MBinning *binsy = (MBinning*)pList->FindObject("BinningImpact", "MBinning");
+
+    if (!binsx || !binsy)
+        return kTRUE;
+
+    SetBinning(&fHist, binsx, binsy);
+
+    return kTRUE;
+}
+
+//--------------------------------------------------------------------------
+//
+//  Fill the histogram with the log10 of the energy for triggered events.
+//
+Bool_t MHMcEnergyImpact::Fill(const MParContainer *cont)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)cont;
+
+    const Float_t energy = mcevt.GetEnergy();
+    const Float_t impact = mcevt.GetImpact()/100.;
+
+    fHist.Fill(energy, impact);
+
+    return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEnergyImpact::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcEnergyImpact::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH2D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyImpact.h	(revision 1638)
@@ -0,0 +1,39 @@
+#ifndef MARS_MHMcEnergyImpact
+#define MARS_MHMcEnergyImpact
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+
+class MHMcEnergyImpact : public MH
+{
+private:
+    TH2D fHist; // histogram with the logarith of the energy
+
+public:
+    MHMcEnergyImpact(const char *name=NULL, const char *title=NULL);
+    ~MHMcEnergyImpact();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *pcont=NULL);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    ClassDef(MHMcEnergyImpact, 1)  // Histogram container for 2D histogram in Energy and Impact
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.cc	(revision 1638)
@@ -0,0 +1,226 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 4/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHMcEnergyMigration                                                     //
+//                                                                          //
+//  calculates the migration matrix E-est vs. E-true                        //
+//  for different bins in Theta                                             //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcEnergyMigration.h"
+
+#include <TCanvas.h>
+
+#include "MMcEvt.hxx"
+
+#include "MEnergyEst.h"
+#include "MBinning.h"
+#include "MHillasSrc.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcEnergyMigration);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHMcEnergyMigration::MHMcEnergyMigration(const char *name, const char *title)
+    : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHMcEnergyMigration";
+    fTitle = title ? title : "3-D histogram   E-true E-est Theta";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("3D-plot   E-true E-est Theta");
+    fHist.SetXTitle("E_{true} [GeV]");
+    fHist.SetYTitle("E_{est} [GeV]");
+    fHist.SetZTitle("\\Theta [\\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHMcEnergyMigration::SetupFill(const MParList *plist)
+{
+    fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
+    if (!fEnergy)
+    {
+        *fLog << err << dbginf << "MEnergyEst not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+    const MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+    if (!binsenergy || !binstheta)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binsenergy, binsenergy, binstheta);
+
+    fHist.Sumw2();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHMcEnergyMigration::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("EnergyMigration", "E-est vs. E-true");
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = ((TH3*)(&fHist))->Project3D("expro");
+
+    h->SetTitle("Distribution of E-true");
+    h->SetXTitle("E_{true} [GeV]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+
+    c.cd(2);
+    h = ((TH3*)(&fHist))->Project3D("eypro");
+
+    h->SetTitle("Distribution of E-est");
+    h->SetXTitle("E_{est} [GeV]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    c.cd(3);
+    h = ((TH3*)(&fHist))->Project3D("ezpro");
+
+    h->SetTitle("Distribution of Theta");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+
+    c.cd(4);
+    ((TH3*)(&fHist))->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHMcEnergyMigration::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("EnergyMigration", "E-est vs. E-true");
+
+    gPad->Divide(2,2);
+    
+    TH1 *h;
+
+    gPad->cd(1);
+    h = fHist.Project3D("ex_pro");
+
+    h->SetTitle("Distribution of E-true");
+    h->SetXTitle("E_{true} [GeV]");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+
+    gPad->cd(2);
+    h = fHist.Project3D("ey_pro");
+
+    h->SetTitle("Distribution of E-est");
+    h->SetXTitle("E_{est} [GeV]");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    gPad->cd(3);
+    h = fHist.Project3D("ez_pro");
+
+    h->SetTitle("Distribution of Theta");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+
+    gPad->cd(4);
+    fHist.DrawCopy(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHMcEnergyMigration::Fill(const MParContainer *par)
+{
+    //    MHillasSrc &hil = *(MHillasSrc*)par;
+    //    fHist.Fill(fMcEvt->GetEnergy(), hil.GetSize());
+
+    // get E-true from fMcEvt and E-est from fEnergy
+    fHist.Fill(fMcEvt->GetEnergy(), fEnergy->GetEnergy(), fMcEvt->GetTheta()*kRad2Deg);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcEnergyMigration.h	(revision 1638)
@@ -0,0 +1,49 @@
+#ifndef MARS_MHMcEnergyMigration
+#define MARS_MHMcEnergyMigration
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include "TH3.h"
+#endif
+
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MMcEvt;
+class MEnergyEst;
+class MParList;
+
+class MHMcEnergyMigration : public MH
+{
+private:
+    MMcEvt      *fMcEvt;
+    MEnergyEst  *fEnergy;
+
+    TH3D        fHist;
+
+public:
+    MHMcEnergyMigration(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH3D *GetHist() { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHMcEnergyMigration, 1) //3D-histogram   E-true E-est Theta
+
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.cc	(revision 1638)
@@ -0,0 +1,155 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 05/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcIntRate
+//
+// This class holds the information (histogram and fit function)
+// about the energy threshold for a particular trigger condition.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHMcIntRate.h" 
+
+#include <math.h>
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MHMcDifRate.h"
+
+ClassImp(MHMcIntRate);
+
+// -------------------------------------------------------------------------
+//
+//  Default Constructor.
+//
+MHMcIntRate::MHMcIntRate(const char *name, const char *title)
+    : fHist()
+{
+    fName  = name  ? name  : "MHMcIntRate";
+    fTitle = title ? title : "Integral Trigger Rate";
+
+    //  - we initialize the histogram
+    //  - we have to give diferent names for the diferent histograms because
+    //    root don't allow us to have diferent histograms with the same name
+
+    fHist.SetName(fName);
+    fHist.SetTitle(fTitle);
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("E [GeV]");
+    fHist.SetYTitle("Rate [Hz]");
+}
+
+void MHMcIntRate::SetName(const char *name)
+{
+    fName = name;
+    fHist.SetName(name);
+    fHist.SetDirectory(NULL);
+}
+
+void MHMcIntRate::SetTitle(const char *title)
+{
+    fTitle = title;
+    fHist.SetTitle(title);
+}
+
+//-------------------------------------------------------------------------
+//
+//  Defualt Destructor
+//
+MHMcIntRate::~MHMcIntRate()
+{
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcIntRate::Draw(Option_t *option)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(&fHist);
+
+    gPad->SetLogx();
+
+    fHist.Draw(option);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+TObject *MHMcIntRate::DrawClone(Option_t *option) const
+{
+    TCanvas *c = MH::MakeDefCanvas(&fHist);
+
+    c->SetLogx();
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    ((TH1D&)fHist).DrawCopy(option);
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the IntRate and set the 'ReadyToSave' flag.
+//  The IntRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcIntRate::Calc(const MHMcDifRate &rate)
+{
+    /*const*/ TH1D  &hist = (TH1D&)*rate.GetHist();
+    const TAxis &axis = *hist.GetXaxis();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, &axis);
+
+    const Int_t nbinsx = axis.GetNbins();
+
+    for (Int_t i=1; i<=nbinsx; i++)
+    {
+        fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
+        fHist.SetBinError(i, hist.GetBinError(i)*axis.GetBinWidth(i));
+    }
+
+    fHist.SetEntries(hist.GetEntries());
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcIntRate.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHMcIntRate
+#define MARS_MHMcIntRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MHMcDifRate;
+
+class MHMcIntRate : public MParContainer
+{
+private:
+
+    TH1D fHist;           // histogram with the logarith of the energy
+
+    // const MMcEvt *fMcEvt;  //! container to fill histogram from
+
+public:
+    MHMcIntRate(const char *name=NULL, const char *title=NULL);
+    ~MHMcIntRate();
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+    TObject *DrawClone(Option_t* option = "") const;
+
+    void Calc(const MHMcDifRate &rate);
+
+    ClassDef(MHMcIntRate, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.cc	(revision 1638)
@@ -0,0 +1,242 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MHMcRate.h" 
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcRate);
+
+void MHMcRate::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcTriggerRate";
+    fTitle = title ? title : "Task to calc the collection area ";
+
+    fPartId=0;               // Type of particle
+
+    fEnergyMax=0.0;          // Maximum Energy in GeV
+    fEnergyMin=1000000.0;    // Minimum Energy in GeV
+
+    fThetaMax=0.0;           // Maximum theta angle of run
+    fThetaMin=370.0;         // Minimum theta angle of run
+    fPhiMax=0.0;             // Maximum phi angle of run
+    fPhiMin=370.0;           // Minimum phi angle of run
+
+    fImpactMax=0.0;          // Maximum impact parameter
+    fImpactMin=100000.0;     // Minimum impact parameter
+
+    fBackTrig=-1.0;          // Number of triggers from background
+    fBackSim=-1.0;           // Number of simulated showers for the background
+
+    fTriggerRate= -1.0;      // Trigger rate in Hz
+    fTriggerRateError= -1.0; // Estimated error for the trigger rate in Hz
+}
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  fills all member data with initial values
+//
+MHMcRate::MHMcRate(const char *name, const char *title)
+{
+    Init(name, title);
+
+    fSpecIndex=0.0;         // dn/dE = k * e^{- fSpecIndex}
+    fFlux0=-1.0;            // dn/dE = fFlux0 * E^{-a}
+
+    fShowerRate= -1.0;      // Showers rate in Hz
+    fShowerRateError=0.0;   // Estimated error of shower rate in Hz
+}
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor I
+//  fills all member data with initial values and sets the rate of
+//  incident showers to ShowRate
+//
+MHMcRate::MHMcRate(Float_t showrate,
+                   const char *name, const char *title)
+{
+    Init(name, title);
+
+    fSpecIndex=0.0;                  // dn/dE = k * e^{- fSpecIndex}
+    fFlux0=-1.0;                     // dn/dE = fFlux0 * E^{-a}
+
+    fShowerRate= showrate;           // Showers rate in Hz
+    fShowerRateError=sqrt(showrate); // Estimated error of shower rate in Hz
+}
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor I
+//  fills all member data with initial values and sets the
+//  spectral index and the initial flux to SpecIndex and Flux0
+//
+MHMcRate::MHMcRate(Float_t specindex, Float_t flux0,
+                   const char *name, const char *title)
+{
+    Init(name, title);
+
+    fSpecIndex=specindex;   // dn/dE = k * e^{- fSpecIndex}
+    fFlux0=flux0;           // dn/dE = fFlux0 * E^{-a}
+
+    fShowerRate= -1.0;
+    fShowerRateError=0.0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  set the particle that produces the showers in the athmosphere
+//
+void MHMcRate:: SetParticle(UShort_t part)
+{
+    fPartId=part;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the information about trigger due only to the background conditions
+//
+void MHMcRate::SetBackground (Float_t showers, Float_t triggers)
+{
+    fBackTrig=showers;      // Number of triggers from background
+    fBackSim=triggers;      // Number of simulated showers for the background
+}
+
+// --------------------------------------------------------------------------
+//
+//  set the parameters to compute the incident rate 
+//
+void MHMcRate:: SetFlux(Float_t flux0, Float_t specindx)
+{
+    fFlux0=flux0;
+    fSpecIndex=specindx;
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  set the incident rate 
+//
+void MHMcRate:: SetIncidentRate(Float_t showerrate)
+{
+    fShowerRate=showerrate;
+}
+
+// --------------------------------------------------------------------------
+//
+//  update the limits for energy, theta, phi and impact parameter
+//
+void MHMcRate::UpdateBoundaries(Float_t energy, Float_t theta,
+                                Float_t phi, Float_t impact)
+{ 
+    // It updates the limit values
+
+    if (fThetaMax<theta) fThetaMax=theta;
+    if (fThetaMin>theta) fThetaMin=theta;
+
+    if (fPhiMax<phi) fPhiMax=phi;
+    if (fPhiMin>phi) fPhiMin=phi;
+
+    if (fImpactMax<impact) fImpactMax=impact;
+    if (fImpactMin>impact) fImpactMin=impact;
+
+    if (fEnergyMax<energy) fEnergyMax=energy;
+    if (fEnergyMin>energy) fEnergyMin=energy;
+} 
+
+// --------------------------------------------------------------------------
+//
+//  compute the trigger rate and set the ReadyToSave bit
+//
+void MHMcRate::CalcRate(Float_t trig, Float_t anal, Float_t simu) 
+{ 
+    // It computes the trigger rate
+
+    // First one computes the rate of incident showers.
+    const Double_t specidx = 1.0-fSpecIndex;
+
+    const Double_t epowmax = pow(fEnergyMax, specidx);
+    const Double_t epowmin = pow(fEnergyMin, specidx);
+
+    if (fShowerRate <= 0)
+	fShowerRate = fFlux0/specidx*(epowmin-epowmax);
+
+    if (fPartId!=1)
+        fShowerRate *= (fPhiMax-fPhiMin)*(cos(fThetaMax)-cos(fThetaMin));
+
+    const Double_t impactdiff = fImpactMax-fImpactMin;
+
+    fShowerRate *= TMath::Pi()*(impactdiff/100.0*impactdiff/100.0);
+
+    fShowerRateError = sqrt(fShowerRate);
+
+    // The simulated trigger time in the camera program is 160 ns:
+    // 9/10/2002, AM: Fixed error below in calculation of "anal2"
+    // ( added factor fShowerRate/simu )
+
+    const Double_t anal2 = 1.0-fShowerRate*(anal/simu)*160.0e-9;
+    const Double_t back2 = fBackSim*160.0e-9;
+
+    // Then the trigger rate and its error is evaluated
+    if(fBackTrig<0){
+        fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
+                                 (anal2*anal2*1/(fBackSim*back2*back2)));
+        fBackTrig=0;
+    }
+    else
+        fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
+                                 (anal2*anal2*fBackTrig/(back2*back2)));
+
+    fTriggerRate = trig*fShowerRate/simu + anal2*fBackTrig/back2;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  print the trigger rate
+//
+void MHMcRate::Print(Option_t *) const
+{
+    *fLog << all << "Incident rate " << fShowerRate << " Hz " << endl;
+    *fLog << "Trigger Rate " << fTriggerRate << " +- " << fTriggerRateError << " Hz" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  draw the trigger rate
+//
+void MHMcRate::Draw(Option_t *)
+{
+    *fLog << all << dbginf << " - MHMcRate::Draw: To be iplemented" << endl;
+}
+
+TObject *MHMcRate::DrawClone(Option_t *) const
+{
+    *fLog << all << dbginf << " - MHMcRate::DrawClone: To be iplemented" << endl;
+    return NULL;
+} 
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHMcRate.h	(revision 1638)
@@ -0,0 +1,64 @@
+#ifndef MARS_MHMcRate
+#define MARS_MHMcRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHMcRate : public MParContainer
+{
+
+private:
+    UShort_t fPartId;           // Type of particle
+
+    Float_t fEnergyMax;         // Maximum Energy in GeV
+    Float_t fEnergyMin;         // Minimum Energy in GeV
+
+    Float_t fThetaMax;          // Maximum theta angle of run
+    Float_t fThetaMin;          // Minimum theta angle of run
+    Float_t fPhiMax;            // Maximum phi angle of run
+    Float_t fPhiMin;            // Minimum phi angle of run
+
+    Float_t fImpactMax;         // Maximum impact parameter
+    Float_t fImpactMin;         // Minimum impact parameter
+
+    Float_t fBackTrig;          // Number of triggers from background
+    Float_t fBackSim;           // Number of simulated showers for the background
+
+    Float_t fSpecIndex;         // dn/dE = k * e^{- fSpecIndex}
+    Float_t fFlux0;             // dn/dE = fFlux0 * E^{-a}
+
+    Float_t fShowerRate;        // Showers rate in Hz
+    Float_t fShowerRateError;   // Estimated error of shower rate in Hz
+
+    Float_t fTriggerRate;       // Trigger rate in Hz
+    Float_t fTriggerRateError;  // Estimated error for the trigger rate in Hz
+
+    void Init(const char *name, const char *title);
+
+public:
+
+    MHMcRate(const char *name=NULL, const char *title=NULL);
+    MHMcRate(Float_t showrate,
+             const char *name=NULL, const char *title=NULL);
+    MHMcRate(Float_t specindex, Float_t flux0,
+             const char *name=NULL, const char *title=NULL);
+
+    void SetParticle(UShort_t part);
+    void SetBackground(Float_t showers, Float_t triggers);
+    void SetFlux(Float_t flux0, Float_t specindx);
+    void SetIncidentRate(Float_t showerrate);
+
+    void UpdateBoundaries(Float_t energy, Float_t theta, Float_t phi, Float_t impact);
+
+    void CalcRate(Float_t trig, Float_t anal, Float_t simu);
+
+    void Print(Option_t *o=NULL) const;
+
+    void Draw(Option_t *o=NULL);
+    TObject *DrawClone(Option_t *o=NULL) const;
+
+    ClassDef(MHMcRate, 1)  // Data Container to calculate Collection Area
+};
+
+#endif 
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.cc	(revision 1638)
@@ -0,0 +1,336 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHStarMap
+//
+// This class contains a 2-dimensional histogram. It should show some
+// kind of star map. The algorith which calculates the star map
+// from the Hillas parameters (Fill) can be enhanced.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHStarMap.h"
+
+#include <TStyle.h>   // gStyle
+#include <TColor.h>   // SetRGB
+#include <TCanvas.h>  // TCanvas
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MHillas.h"
+#include "MBinning.h"
+
+ClassImp(MHStarMap);
+
+// --------------------------------------------------------------------------
+//
+// Create the star map histogram
+//
+MHStarMap::MHStarMap(const char *name, const char *title)
+    : fMm2Deg(-1), fUseMmScale(kTRUE)
+{
+    //
+    //  default constructor
+    //  creates an a list of histograms for all pixels and both gain channels
+    //
+
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHStarMap" ;
+    fTitle = title ? title : "Container for a Star Map" ;
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+    fStarMap = new TH2F("StarMap", " 2D Hillas Star Map ",
+                        150, -300, 300,
+                        150, -300, 300);
+
+    fStarMap->SetDirectory(NULL);
+
+    fStarMap->SetXTitle("x [mm]");
+    fStarMap->SetYTitle("y [mm]");
+    fStarMap->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// delete the histogram instance
+//
+MHStarMap::~MHStarMap()
+{
+    delete fStarMap;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningCamera')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHStarMap::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (geom)
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        fUseMmScale = kFALSE;
+
+        fStarMap->SetXTitle("x [\\circ]");
+        fStarMap->SetYTitle("y [\\circ]");
+    }
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap");
+    if (!bins)
+    {
+        float r = geom ? geom->GetMaxRadius() : 600;
+        r *= 5./6;
+        if (!fUseMmScale)
+            r *= fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(100, -r, r);
+        SetBinning(fStarMap, &b, &b);
+    }
+    else
+        SetBinning(fStarMap, bins, bins);
+
+    if (!geom)
+    {
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the four histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHStarMap::Fill(const MParContainer *par)
+{
+    const MHillas &h = *(MHillas*)par;
+
+    const float delta = h.GetDelta();
+
+    const float m = tan(delta);
+
+    float t = h.GetMeanY() - m*h.GetMeanX();
+
+    if (!fUseMmScale)
+        t *= fMm2Deg;
+
+    if (m>-1 && m<1)
+    {
+        TAxis &axe = *fStarMap->GetXaxis();
+
+        const int N = axe.GetXbins()->GetSize();
+        for (int i=0; i<N; i++)
+        {
+            const float x = axe.GetBinCenter(i);
+            const float y = m*x+t;
+
+            fStarMap->Fill(x, y);
+        }
+    }
+    else
+    {
+        TAxis &axe = *fStarMap->GetYaxis();
+
+        const int N = axe.GetXbins()->GetSize();
+        for (int i=0; i<N; i++)
+        {
+            const float y = axe.GetBinCenter(i);
+            const float x = (y-t)/m;
+
+            fStarMap->Fill(x, y);
+        }
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHStarMap::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHStarMap::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    if (fUseMmScale)
+    {
+        fStarMap->SetXTitle("x [mm]");
+        fStarMap->SetYTitle("y [mm]");
+
+        fStarMap->Scale(1./fMm2Deg);
+    }
+    else
+    {
+        fStarMap->SetXTitle("x [\\circ]");
+        fStarMap->SetYTitle("y [\\circ]");
+
+        fStarMap->Scale(1./fMm2Deg);
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the palette you wanna use:
+//  - you could set the root "Pretty Palette Violet->Red" by
+//    gStyle->SetPalette(1, 0), but in some cases this may look
+//    confusing
+//  - The maximum colors root allowes us to set by ourself
+//    is 50 (idx: 51-100). This colors are set to a grayscaled
+//    palette
+//  - the number of contours must be two less than the number
+//    of palette entries
+//
+void MHStarMap::PrepareDrawing() const
+{
+    const Int_t numg = 32; // number of gray scaled colors
+    const Int_t numw = 32; // number of white
+
+    Int_t palette[numg+numw];
+
+    //
+    // The first half of the colors are white.
+    // This is some kind of optical background supression
+    //
+    gROOT->GetColor(51)->SetRGB(1, 1, 1);
+
+    Int_t i;
+    for (i=0; i<numw; i++)
+        palette[i] = 51;
+
+    //
+    // now the (gray) scaled part is coming
+    //
+    for (;i<numw+numg; i++)
+    {
+        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
+
+        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
+        palette[i] = 52+i;
+    }
+
+    //
+    // Set the palette and the number of contour levels
+    //
+    gStyle->SetPalette(numg+numw, palette);
+    fStarMap->SetContour(numg+numw-2);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Draw clones of the  histograms, so that the object can be deleted
+// and the histogram is still visible in the canvas.
+// The cloned object is deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHStarMap::DrawClone(Option_t *opt) const
+{
+    TCanvas *c=MakeDefCanvas(fStarMap, 500, 500);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    PrepareDrawing();
+
+    fStarMap->DrawCopy("colz");
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draw the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHStarMap::Draw(Option_t *)
+{
+    if (!gPad)
+        MakeDefCanvas(fStarMap, 500, 500);
+
+    PrepareDrawing();
+
+    fStarMap->Draw("colz");
+
+    gPad->Modified();
+    gPad->Update();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHStarMap.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHStarMap
+#define MARS_MHStarMap
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MHillas;
+
+class MHStarMap : public MH
+{
+private:
+    TH2F *fStarMap;
+
+    Float_t fMm2Deg;
+
+    Bool_t fUseMmScale;
+
+    void PrepareDrawing() const;
+
+public:
+    MHStarMap(const char *name=NULL, const char *title=NULL);
+    ~MHStarMap();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1 *GetHistByName(const TString name) { return fStarMap; }
+
+    TH2F *GetHist() { return fStarMap; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHStarMap, 1) // Container to hold 2-dim histogram (starmap)
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.cc	(revision 1638)
@@ -0,0 +1,146 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHThetabarTheta                                                         //
+//                                                                          //
+//  calculates the average Theta for different bins in Theta                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHThetabarTheta.h"
+
+#include <TCanvas.h>
+
+#include "MMcEvt.hxx"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHThetabarTheta);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHThetabarTheta::MHThetabarTheta(const char *name, const char *title)
+    : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHThetabarTheta";
+    fTitle = title ? title : "1-D profile histogram Thetabar vs. Theta";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("\\Theta [\\circ]");
+    fHist.SetYTitle("Theta-bar [ \\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHThetabarTheta::SetupFill(const MParList *plist)
+{
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
+    if (!binstheta )
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binstheta);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHThetabarTheta::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("ThetabarTheta", "Thetabar vs. Theta");
+
+    gROOT->SetSelectedPad(NULL);
+
+    ((TProfile*)&fHist)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHThetabarTheta::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("ThetabarTheta", "Thetabar vs. Theta");
+
+    fHist.DrawCopy(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHThetabarTheta::Fill(const MParContainer *par)
+{
+    fHist.Fill(fMcEvt->GetTheta()*kRad2Deg, fMcEvt->GetTheta()*kRad2Deg);
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTheta.h	(revision 1638)
@@ -0,0 +1,53 @@
+#ifndef MARS_MHThetabarTheta
+#define MARS_MHThetabarTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TProfile
+#include "TProfile.h"
+#endif
+
+class MTime;
+class MMcEvt;
+
+class MParList;
+
+class MHThetabarTheta : public MH
+{
+private:
+    MTime  *fTime;   //!
+    MMcEvt *fMcEvt;  //!
+
+    TProfile    fHist;
+
+public:
+    MHThetabarTheta(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TProfile *GetHist() { return &fHist; }
+    const TProfile *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHThetabarTheta, 1) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.cc	(revision 1638)
@@ -0,0 +1,144 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 3/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHThetabarTime                                                          //
+//                                                                          //
+//  calculates the average Theta for different bins in time                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHThetabarTime.h"
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+#include "MMcEvt.hxx"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHThetabarTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHThetabarTime::MHThetabarTime(const char *name, const char *title)
+    : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHThetabarTime";
+    fTitle = title ? title : "1-D profile histogram Thetabar vs. time";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("time [s]");
+    fHist.SetYTitle("Theta-bar [ \\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHThetabarTime::SetupFill(const MParList *plist)
+{
+    fTime = (MTime*)plist->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << dbginf << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+    }
+
+    const MBinning* binstime  = (MBinning*)plist->FindObject("BinningTime");
+    if (!binstime )
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binstime);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHThetabarTime::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("ThetabarTime", "Thetabar vs. time");
+
+    gROOT->SetSelectedPad(NULL);
+
+    ((TProfile*)&fHist)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHThetabarTime::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("ThetabarTime", "Thetabar vs. time");
+
+    fHist.DrawCopy(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHThetabarTime::Fill(const MParContainer *par)
+{
+    const Int_t time = fTime->GetTimeLo();
+
+    fHist.Fill(0.0001*time, fMcEvt->GetTheta()*kRad2Deg);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHThetabarTime.h	(revision 1638)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHThetabarTime
+#define MARS_MHThetabarTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TProfile
+#include "TProfile.h"
+#endif
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MTime;
+class MMcEvt;
+
+class MParList;
+
+class MHThetabarTime : public MH
+{
+private:
+    MTime  *fTime;   //!
+    MMcEvt *fMcEvt;
+
+    TProfile   fHist;
+
+public:
+    MHThetabarTime(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TProfile *GetHist() { return &fHist; }
+    const TProfile *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHThetabarTime, 1) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1638)
@@ -0,0 +1,205 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHTimeDiffTheta                                                         //
+//                                                                          //
+//  calculates the 2D-histogram   time-difference vs. Theta                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHTimeDiffTheta.h"
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+#include "MMcEvt.hxx"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHTimeDiffTheta);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHTimeDiffTheta::MHTimeDiffTheta(const char *name, const char *title)
+    : fLastTime(0), fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHTimeDiffTheta";
+    fTitle = title ? title : "2-D histogram in Theta and time difference";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("\\Delta t [s]");
+    fHist.SetYTitle("\\Theta [\\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHTimeDiffTheta::SetupFill(const MParList *plist)
+{
+   fTime = (MTime*)plist->FindObject("MTime");
+   if (!fTime)
+   {
+       *fLog << err << dbginf << "MTime not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
+   const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
+   if (!binstheta || !binsdtime)
+   {
+       *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsdtime, binstheta);
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHTimeDiffTheta::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, Theta");
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    //
+    // FIXME: ProjectionX,Y is not const within root
+    //
+
+    TH1D *h;
+
+    c.cd(1);
+    h = ((TH2*)&fHist)->ProjectionX("ProjX-Theta", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
+    gPad->SetLogy();
+
+    c.cd(2);
+    h = ((TH2*)&fHist)->ProjectionY("ProjY-timediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
+
+    c.cd(3);
+    ((TH2*)&fHist)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHTimeDiffTheta::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
+
+    TH1D *h;
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    h = fHist.ProjectionX("ProjX_Theta", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
+    gPad->SetLogy();
+
+    gPad->cd(2);
+    h = fHist.ProjectionY("ProjY_timediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
+
+    gPad->cd(3);
+    fHist.DrawCopy(opt);
+
+    gPad->Modified();
+    gPad->Update();
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
+Bool_t MHTimeDiffTheta::Fill(const MParContainer *par)
+{
+    const Int_t time = fTime->GetTimeLo();
+
+    fHist.Fill(0.0001*(time-fLastTime), fMcEvt->GetTheta()*kRad2Deg);
+    fLastTime = time;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTheta.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHTimeDiffTheta
+#define MARS_MHTimeDiffTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MTime;
+class MMcEvt;
+
+class MParList;
+
+class MHTimeDiffTheta : public MH
+{
+private:
+    MTime  *fTime;   //!
+    MMcEvt *fMcEvt;  //!
+    Int_t   fLastTime;
+
+    TH2D    fHist;
+
+public:
+    MHTimeDiffTheta(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHTimeDiffTheta, 1) //2D-histogram  time-diff vs. Theta
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1638)
@@ -0,0 +1,199 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHTimeDiffTime                                                          //
+//                                                                          //
+//  calculates the 2D-histogram   time-difference vs. time                  //
+//                                                                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHTimeDiffTime.h"
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHTimeDiffTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram
+//
+MHTimeDiffTime::MHTimeDiffTime(const char *name, const char *title)
+    : fLastTime(0), fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHTimeDiffTime";
+    fTitle = title ? title : "2-D histogram in time and time difference";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("\\Delta t [s]");
+    fHist.SetYTitle("t [s]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHTimeDiffTime::SetupFill(const MParList *plist)
+{
+    fTime = (MTime*)plist->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << dbginf << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
+    const MBinning* binstime  = (MBinning*)plist->FindObject("BinningTime");
+    if (!binstime || !binsdtime)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHist, binsdtime, binstime);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHTimeDiffTime::DrawClone(Option_t *opt) const
+{
+
+    TCanvas &c = *MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1D *h;
+
+    c.cd(1);
+    h = ((TH2*)&fHist)->ProjectionX("ProjX-sumtime", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogy();
+
+    c.cd(2);
+    h = ((TH2*)&fHist)->ProjectionY("ProjY-sumtimediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    c.cd(3);
+    ((TH2*)&fHist)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHTimeDiffTime::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
+
+    gPad->Divide(2,2);
+
+    TH1D *h;
+
+    gPad->cd(1);
+    h = fHist.ProjectionX("ProjX_sumtime", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+    gPad->SetLogy();
+
+    gPad->cd(2);
+    h = fHist.ProjectionY("ProjY_sumtimediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    gPad->cd(3);
+    fHist.DrawCopy(opt);
+
+    gPad->Modified();
+    gPad->Update();
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
+Bool_t MHTimeDiffTime::Fill(const MParContainer *par)
+{
+    const Int_t time = fTime->GetTimeLo();
+
+    fHist.Fill(0.0001*(time-fLastTime), 0.0001*time);
+
+    fLastTime = time;
+
+    return kTRUE;
+}
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/MHTimeDiffTime.h	(revision 1638)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHTimeDiffTime
+#define MARS_MHTimeDiffTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH2
+#include "TH2.h"
+#endif
+
+class MTime;
+
+class MParList;
+
+class MHTimeDiffTime : public MH
+{
+private:
+    MTime *fTime;   //!
+    Int_t  fLastTime;
+
+    TH2D   fHist;
+
+public:
+    MHTimeDiffTime(const char *name=NULL, const char *title=NULL);
+
+    virtual Bool_t SetupFill(const MParList *pList);
+    virtual Bool_t Fill(const MParContainer *par);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHTimeDiffTime, 1) //2D-histogram  time-diff vs. time
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mhist/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mhist/Makefile	(revision 1638)
@@ -0,0 +1,92 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Hist
+
+#
+# Library name to creatre
+#
+LIB   = mhist.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc \
+	   -I../mgui -I../mgeom -I../mdata
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MFillH.cc \
+           MBinning.cc \
+           MH.cc \
+           MHArray.cc \
+           MH3.cc \
+           MHMatrix.cc \
+           MHFadcPix.cc \
+           MHFadcCam.cc \
+           MHHillas.cc \
+           MHHillasSrc.cc \
+           MHHillasExt.cc \
+           MHStarMap.cc \
+           MHEnergyTime.cc \
+           MHEnergyTheta.cc \
+           MHMcCollectionArea.cc \
+           MHAlphaEnergyTime.cc \
+           MHAlphaEnergyTheta.cc \
+           MHEffOnTime.cc \
+           MHTimeDiffTime.cc \
+           MHTimeDiffTheta.cc \
+           MHCompProb.cc \
+           MHHadronness.cc \
+           MHMcEnergy.cc \
+           MHMcEfficiency.cc \
+           MHMcEfficiencyImpact.cc \
+           MHMcEfficiencyEnergy.cc \
+           MHMcEnergyImpact.cc \
+	   MHMcRate.cc \
+	   MHMcIntRate.cc \
+           MHMcDifRate.cc \
+           MHThetabarTime.cc \
+           MHThetabarTheta.cc \
+           MHMcEnergyMigration.cc \
+           MHGamma.cc \
+           MHFlux.cc 
+ 
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.cc	(revision 1638)
@@ -0,0 +1,295 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  9/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#include "MAnalysis.h"
+
+#include <iostream.h>
+
+#include <TGLabel.h>       // TGlabel
+#include <TGButton.h>      // TGTextButton
+#include <TGTextEntry.h>   // TGNumberEntry
+
+#include "MGList.h"
+#include "MImgCleanStd.h"  // MImgCleanStd
+
+ClassImp(MAnalysis)
+
+enum {
+    kButHillas = 0x100
+};
+
+void MAnalysis::AddButtons()
+{
+    TGTextButton *hillas = new TGTextButton(fTop2, "Calculate Standard Hillas", kButHillas);
+
+    hillas->Associate(this);
+
+    fList->Add(hillas);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop2->AddFrame(hillas, laybut);
+}
+
+void MAnalysis::AddSetupTab()
+{
+    //
+    // Create Setup Tab
+    //
+    TGCompositeFrame *frame = CreateNewTab("Setup");
+
+    TGGroupFrame *grp = new TGGroupFrame(frame, "Setup Display");
+    fList->Add(grp);
+
+    //
+    // Align the lines:
+    //  - top, left
+    //  - padding: top=20, bottom=0, left=20, right=0
+    //
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 10, 10, 10);
+    fList->Add(laybut);
+
+    //
+    // Create check buttons for the first two lines
+    //
+    fCheckButton1 = new TGCheckButton(grp, "Display Hillas Histograms when finished");  //, M_CHECK_DISPLHIL);
+    fCheckButton2 = new TGCheckButton(grp, "Display Star Map Histogram when finished"); //, M_CHECK_DISPLHIL);
+
+    fList->AddFirst(fCheckButton1);
+    fList->AddFirst(fCheckButton2);
+
+    //
+    // Create first two lines with the checkbuttons
+    //
+    grp->AddFrame(fCheckButton1, laybut);
+    grp->AddFrame(fCheckButton2, laybut);
+
+    TGLayoutHints *laygrp = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 20, 20, 20);
+    fList->Add(laygrp);
+
+    frame->AddFrame(grp, laygrp);
+
+    /*
+     * Create GUI for image cleaning
+     */
+    fImgClean = new MImgCleanStd;
+    fImgClean->CreateGui(frame, laygrp);
+    fList->Add(fImgClean);
+}
+
+MAnalysis::MAnalysis(const TGWindow *main, const TGWindow *p,
+                     const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    AddButtons();
+    AddSetupTab();
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Analysis Window");
+    SetIconName("Analysis");
+
+    MapWindow();
+}
+
+// ======================================================================
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamMagic.h"
+#include "MPedestalCam.h"
+#include "MHHillas.h"
+#include "MHStarMap.h"
+#include "MReadMarsFile.h"
+#include "MMcPedestalCopy.h"     // MMcPedestalCopy
+#include "MMcPedestalNSBAdd.h"   // MMcPedestalNSB
+#include "MCerPhotCalc.h"
+#include "MImgCleanStd.h"
+#include "MBlindPixelCalc.h"
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MSrcPosCam.h"
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MHillas.h"
+
+void MAnalysis::CalculateHillas()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file.
+
+    const Bool_t displhillas  = fCheckButton1->GetState();
+    const Bool_t displstarmap = fCheckButton2->GetState();
+
+    //
+    // 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);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    MSrcPosCam source("Source");
+    source.SetXY(0, 0);
+
+    MSrcPosCam antisrc("AntiSrc");
+    antisrc.SetXY(240, 0);
+
+    plist.AddToList(&source);
+    plist.AddToList(&antisrc);
+
+    //
+    // Now setup the tasks and tasklist:
+    //
+    //  1) read in the data from a magic root file   MReadTree
+    //  2) calculate number of cerenkov photons      MCerPhotCalc
+    //  3) clean the image                           MImgCleanStd
+    //  4) calculate hillas                          MHillasCalc
+    //  5) fill the hillas into the histograms       MFillH
+    //
+
+    //
+    // The first argument is the tree you want to read.
+    //   Events:     Cosmic ray events
+    //   PedEvents:  Pedestal Events
+    //   CalEvents:  Calibration Events
+    //
+    MReadMarsFile read("Events", fInputFile);
+
+    MMcPedestalCopy    pcopy;
+    MMcPedestalNSBAdd  pdnsb;
+    MCerPhotCalc       ncalc;
+    MBlindPixelCalc    blind;
+    MHillasCalc        hcalc;
+    MHillasSrcCalc    csrc1("Source",     "HillasSource");
+    MHillasSrcCalc    csrc2("AntiSource", "HillasAntiSrc");
+
+    MFillH hfill("MHHillas",   "MHillas");
+    MFillH sfill("MHStarMap",  "MHillas");
+
+    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pdnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(fImgClean);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
+
+    if (displhillas)
+    {
+        tlist.AddToList(&hfill);
+        tlist.AddToList(&hfill2s);
+        tlist.AddToList(&hfill2a);
+    }
+
+    if (displstarmap)
+        tlist.AddToList(&sfill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    evtloop.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = evtloop.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    if (displhillas)
+    {
+        plist.FindObject("MHHillas")->DrawClone();
+        plist.FindObject("HistSource")->DrawClone();
+        plist.FindObject("HistAntiSrc")->DrawClone();
+    }
+
+    if (displstarmap)
+        plist.FindObject("MHStarMap")->DrawClone();
+
+    cout << endl;
+    cout << "Calculation of Hillas Parameters finished without error!" << endl;
+}
+
+// ======================================================================
+
+Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case kButHillas:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case kButHillas:
+            CalculateHillas();
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MAnalysis.h	(revision 1638)
@@ -0,0 +1,40 @@
+#ifndef MARS_MAnalysis
+#define MARS_MAnalysis
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class TGTextEntry;
+class TGCheckButton;
+
+class MImgCleanStd;
+
+class MAnalysis : public MBrowser
+{
+private:
+    TGCheckButton *fCheckButton1;
+    TGCheckButton *fCheckButton2;
+
+//    TGTextEntry   *fNumEntry1;
+//    TGTextEntry   *fNumEntry2;
+
+    MImgCleanStd  *fImgClean;
+
+    void CalculateHillas();
+
+    void AddButtons();
+    void AddSetupTab();
+
+public:
+    MAnalysis(const TGWindow *main=NULL, const TGWindow *p=NULL,
+              const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MAnalysis, 0) // GUI: The 'Analysis' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.cc	(revision 1638)
@@ -0,0 +1,589 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MBrowser.h"
+
+#include <iostream.h>
+#include <sys/stat.h>       // S_ISDIR
+
+#include <TSystem.h>        // gSystem
+
+#include <TGTab.h>          // TGTab
+#include <TGMenu.h>         // TGPopupMenu
+#include <TG3DLine.h>       // TGHorizontal3DLine
+#include <TGButton.h>       // TGTextButton
+#include <TGMsgBox.h>       // TGMsgBox
+#include <TBrowser.h>       // TBrowser
+#include <TGTextEntry.h>    // TGTextEntry
+#include <TGFSComboBox.h>   // TGFSComboBox, TGFSLboxEntry
+#include <TGProgressBar.h>  // TGHProgressBar
+#include <TGFSContainer.h>  // TGFileContainer
+
+#include "MGList.h"
+
+ClassImp(MBrowser);
+
+enum {
+    kFileTBrowser,
+    kFileClose,
+    kButDirUp,
+    kButListMode,
+    kButDetailMode,
+    kCBDirectory,
+    kCBFilter,
+    kTEFileName
+};
+
+void MBrowser::CreateMenuBar()
+{
+    //
+    //  crate the menu bar
+    //
+    TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
+    filemenu->AddEntry("Open &TBrowser", kFileTBrowser);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("&Close", kFileClose);
+    filemenu->Associate(this);
+    fList->Add(filemenu);
+
+    //
+    //  the button messages are handled by main frame (this)
+    //
+    TGLayoutHints *laymenubar  = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
+    TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
+
+    fList->Add(laymenubar);
+    fList->Add(laymenuitem);
+
+    TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
+    menubar->AddPopup("&File", filemenu, laymenuitem);
+    AddFrame(menubar, laymenubar);
+    fList->Add(menubar);
+}
+
+void MBrowser::CreateUpperFrame(TGCompositeFrame *frametop)
+{
+    TGLayoutHints *lay1 = new TGLayoutHints(kLHintsTop    |kLHintsExpandX, 2, 2, 2, 0);
+    TGLayoutHints *lay2 = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX, 2, 2, 2, 2);
+    TGLayoutHints *lay3 = new TGLayoutHints(kLHintsBottom |kLHintsExpandX, 2, 2, 0, 2);
+    fList->Add(lay1);
+    fList->Add(lay2);
+    fList->Add(lay3);
+
+    //
+    // *********** Create Contents of frame top (upper part) **********
+    //
+    fTop1 = new TGHorizontalFrame(frametop, 500, 50);
+    fTop2 = new TGHorizontalFrame(frametop, 500, 50);
+    fTop3 = new TGHorizontalFrame(frametop, 500, 50);
+
+    // FIXME: If I use TGLayoutHints the Progress Bar doesn't disappear!
+    frametop->AddFrame(fTop1);//, lay1);
+    frametop->AddFrame(fTop2);//, lay2);
+    frametop->AddFrame(fTop3);//, lay3);
+
+    fList->Add(fTop1);
+    fList->Add(fTop2);
+    fList->Add(fTop3);
+}
+
+void MBrowser::CreateDirListMenu(TGCompositeFrame *frame)
+{
+    //
+    // Layout Dir-Listbox and buttons in one row (frame)
+    //
+    //  - layout:
+    //    alignment: top, left
+    //    padding:   5, 5, 5, 5
+    //
+    TGLayoutHints *laydir = new TGLayoutHints(kLHintsExpandX|kLHintsLeft|kLHintsCenterY); //, 5, 5, 5, 5);
+    TGLayoutHints *layout = new TGLayoutHints(kLHintsRight|kLHintsCenterY, 10); //, 5, 5, 5);
+
+    fList->Add(laydir);
+    fList->Add(layout);
+
+    //
+    // Create Dir-Listbox and buttons in first frame
+    //
+    TGFSComboBox *dir = new TGFSComboBox(frame, kCBDirectory);
+    dir->SetHeight(fEntry->GetHeight());
+    dir->Associate(this);
+    fList->Add(dir);
+    frame->AddFrame(dir, laydir);
+
+    //
+    // Get the three picturs from the system (must be deleted by FreePicture)
+    //
+    const TGPicture *pic1 = fList->GetPicture("tb_list.xpm");
+    if (pic1)
+    {
+        TGPictureButton *list = new TGPictureButton(frame, pic1, kButListMode);
+        list->SetToolTipText("List Mode");
+        list->SetState(kButtonUp);
+        list->AllowStayDown(kTRUE);
+        list->Associate(this);
+        fList->Add(list);
+        frame->AddFrame(list, layout);
+    }
+
+    const TGPicture *pic2 = fList->GetPicture("tb_details.xpm");
+    if (pic2)
+    {
+        TGPictureButton *detail = new TGPictureButton(frame, pic2, kButDetailMode);
+        detail->SetToolTipText("Details Mode");
+        detail->SetState(kButtonEngaged);
+        detail->AllowStayDown(kTRUE);
+        detail->Associate(this);
+        fList->Add(detail);
+        frame->AddFrame(detail, layout);
+    }
+
+    const TGPicture *pic3 = fList->GetPicture("tb_uplevel.xpm");
+    if (pic3)
+    {
+        TGPictureButton *cdup = new TGPictureButton(frame, pic3, kButDirUp);
+        cdup->SetToolTipText("One Level up!");
+        cdup->Associate(this);
+        fList->Add(cdup);
+        frame->AddFrame(cdup, layout);
+    }
+}
+
+void MBrowser::CreateDirListBox(TGCompositeFrame *frame)
+{
+    //
+    // Create file viewer (browser)
+    //
+    fFileView = new TGListView(frame, 540, 380);
+    fList->Add(fFileView);
+
+    TGViewPort *port = fFileView->GetViewPort();
+    port->SetBackgroundColor(fgWhitePixel);
+
+    fFileCont = new TGFileContainer(port, 100, 100, kVerticalFrame, fgWhitePixel);
+    fList->Add(fFileCont);
+
+    fFileView->SetContainer(fFileCont);
+    fFileView->SetViewMode(kLVDetails);
+
+    fFileCont->SetFilter("*.root");
+    fFileCont->Associate(this);
+    fFileCont->Sort(kSortByName);
+
+    TGLayoutHints *layview = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY); //, 5, 5, 5, 5);
+    fList->Add(layview);
+
+    frame->AddFrame(fFileView, layview);
+}
+
+void MBrowser::CreateTab1()
+{
+    static const char *filters[] =
+    {
+        "*.root <root-files>",
+        "*      <All Files>",
+        NULL
+    };
+
+    TGCompositeFrame *frame = CreateNewTab("Input File");
+
+    //
+    // Create three frames for the first tab
+    //
+    TGHorizontalFrame *tab1 = new TGHorizontalFrame(frame, 100, 100);
+    TGVerticalFrame   *tab2 = new TGVerticalFrame  (frame, 100, 100);
+
+    TGLayoutHints *laytab1   = new TGLayoutHints(kLHintsNormal|kLHintsExpandX,  10, 10, 10);
+    TGLayoutHints *laytab2   = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 10, 10, 10, 10);
+    TGLayoutHints *layfilter = new TGLayoutHints(kLHintsNormal|kLHintsExpandX,  10, 10, 10);
+
+    fEntry = new TGTextEntry(frame, "", kTEFileName);
+    fEntry->Associate(this);
+
+    TGComboBox *filter = new TGComboBox(frame, kCBFilter);
+    filter->SetHeight(fEntry->GetHeight());
+    filter->Associate(this);
+    for (int i=0; filters[i]; i++)
+        filter->AddEntry(filters[i], i);
+    filter->Select(0);
+
+    frame->AddFrame(fEntry, laytab1);
+    frame->AddFrame(tab1,   laytab1);
+    frame->AddFrame(filter, layfilter);
+    frame->AddFrame(tab2,   laytab2);
+
+    CreateDirListMenu(tab1);
+    CreateDirListBox(tab2);
+
+    fList->Add(laytab1);
+    fList->Add(laytab2);
+    fList->Add(tab1);
+    fList->Add(tab2);
+    fList->Add(layfilter);
+    fList->Add(fEntry);
+    fList->Add(filter);
+}
+
+TGCompositeFrame *MBrowser::CreateNewTab(const char *name)
+{
+    return fTabs->AddTab(name);
+}
+
+void MBrowser::CreateLowerFrame(TGCompositeFrame *framelow)
+{
+    //
+    // *********** Create Contents of frame low (downer part) **********
+    //
+
+    //
+    // ----- Create Object holding the Tabs -----
+    //
+    fTabs = new TGTab(framelow, 400, 400);
+    fList->Add(fTabs);
+
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
+    fList->Add(laytabs);
+
+    framelow->AddFrame(fTabs, laytabs);
+
+    //
+    // --- Create the first tab of the tabs ---
+    //
+    CreateTab1();
+}
+
+MBrowser::MBrowser(const TGWindow *main, const TGWindow *p,
+                     const UInt_t w, const UInt_t h)
+: TGTransientFrame(p?p:gClient->GetRoot(),
+                   main?main:gClient->GetRoot(), w, h)
+{
+    fList = new MGList;
+    fList->SetOwner();
+
+    CreateMenuBar();
+
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(laylinesep);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    fList->Add(linesep);
+    AddFrame(linesep, laylinesep);
+
+
+    //
+    // ---- Create the top window with a lot of buttons ----
+    //
+    TGLayoutHints *layframetop = new TGLayoutHints(kLHintsExpandX);
+    fList->Add(layframetop);
+
+    TGCompositeFrame *frametop = new TGCompositeFrame(this, 300, 100, kVerticalFrame);
+    fList->Add(frametop);
+    AddFrame(frametop, layframetop);
+
+    linesep = new TGHorizontal3DLine(this);
+    fList->Add(linesep);
+    AddFrame(linesep, laylinesep);
+
+    //
+    // ---- Create the low window with a tabs in it ----
+    //
+    TGLayoutHints *layframelow = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY);
+    fList->Add(layframelow);
+
+    TGCompositeFrame *framelow = new TGCompositeFrame(this, 300, 100, kHorizontalFrame);
+    fList->Add(framelow);
+
+    AddFrame(framelow, layframelow);
+
+    CreateUpperFrame(frametop);
+    CreateLowerFrame(framelow);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    ChangeDir();
+    SetWMSizeHints(400, 350, 1000, 1000, 10, 10); // set the smallest and biggest size of the Main frame
+    Move(rand()%100+50, rand()%100+50);
+}
+
+
+MBrowser::~MBrowser()
+{
+    delete fList;
+} 
+
+TGProgressBar *MBrowser::CreateProgressBar(TGHorizontalFrame *frame)
+{
+    static TGLayoutHints laybar(kLHintsCenterY|kLHintsRight/*|kLHintsExpandX*/,
+                                10, 10);
+
+    TGHProgressBar *bar=new TGHProgressBar(frame);
+
+    bar->SetWidth(150);
+    bar->ShowPosition();
+
+    frame->AddFrame(bar, &laybar);
+
+    Layout();
+    MapSubwindows();
+
+    return bar;
+}
+
+void MBrowser::DestroyProgressBar(TGProgressBar *bar)
+{
+    TGHorizontalFrame *frame = (TGHorizontalFrame*)bar->GetParent();
+
+    frame->RemoveFrame(bar);
+
+    Layout();
+    MapSubwindows();
+
+    delete bar;
+}
+
+void MBrowser::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+    delete this;
+}
+
+Bool_t MBrowser::InputFileSelected() 
+{
+    //
+    // Checks if there is a selected input root file
+    //
+    return !fInputFile.IsNull(); //[0]!='\0';
+}
+
+void MBrowser::DisplError(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Error!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::DisplWarning(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Warning!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::DisplInfo(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Information!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::ChangeDir(const char *txt)
+{
+    fFileCont->ChangeDirectory(txt?txt:gSystem->WorkingDirectory());
+
+    const char *dir = fFileCont->GetDirectory();
+
+    TGFSComboBox *cbox = (TGFSComboBox*)fList->FindWidget(kCBDirectory);
+    if (cbox)
+        cbox->Update(dir);
+}
+
+void MBrowser::SetFileName(TString name)
+{
+    if (name[0]!='/')
+    {
+        name.Insert(0, "/");
+        name.Insert(0, fFileCont->GetDirectory());
+    }
+
+    if (gSystem->AccessPathName(name, kFileExists))
+        return;
+
+    if (name.EndsWith(".root", TString::kIgnoreCase))
+        fInputFile = name;
+
+    fEntry->SetText(gSystem->BaseName(name));
+
+    ChangeDir(gSystem->DirName(name));
+}
+
+void MBrowser::SetDir()
+{
+    TGFSComboBox *cbox = (TGFSComboBox*)fList->FindWidget(kCBDirectory);
+    if(!cbox)
+        return;
+
+    const TGTreeLBEntry *entry = (TGTreeLBEntry*)cbox->GetSelectedEntry();
+
+    ChangeDir(entry->GetPath()->GetString());
+}
+
+void MBrowser::SetFilter()
+{
+    //
+    // Try to get widget from list
+    //
+    TGComboBox *filter = (TGComboBox*)fList->FindWidget(kCBFilter);
+    if (!filter)
+        return;
+
+    //
+    // Get the selected text from the list box
+    //
+    const TGTextLBEntry *selected = (TGTextLBEntry*)filter->GetListBox()->GetSelectedEntry();
+
+    //
+    // find filter and remove leading spaces
+    //
+    TString txt = selected->GetText()->GetString();
+    if (txt.First('<') < 0)
+        return;
+
+    //
+    // Set new filter and refresh the file container
+    //
+    txt.Remove(txt.First('<'));
+
+    TString ftxt = txt.Strip();
+    fFileCont->SetFilter(ftxt);
+    fFileCont->DisplayDirectory();
+}
+
+void MBrowser::SetViewMode(const Int_t mode)
+{
+    fFileView->SetViewMode(mode ? kLVList : kLVDetails);
+
+    TGButton *but = (TGButton*)fList->FindWidget(mode);
+    if(!but)
+        return;
+
+    but->SetState(kButtonUp);
+}
+
+// --------------------------------------------------------------------------
+//
+// Process events generated by the gui elements in the frame.
+//
+Bool_t MBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{
+    switch (GET_MSG(msg))
+    {
+    case kC_TEXTENTRY:
+        if (GET_SUBMSG(msg)!=kTE_ENTER)
+            return kTRUE;
+
+        SetFileName(fEntry->GetText());
+        return kTRUE;
+
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_MENU:
+            switch (parm1)
+            {
+            case kFileClose:
+                CloseWindow();
+                return kTRUE;
+
+            case kFileTBrowser:
+                new TBrowser();
+                return kTRUE;
+            }
+            return kTRUE;
+
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case kButDirUp:
+                //
+                //  goto the parent directory
+                //
+                ChangeDir("..");
+                return kTRUE;
+
+            case kButListMode:
+            case kButDetailMode:
+                SetViewMode(parm1);
+                return kTRUE;
+            }
+            return kTRUE;
+
+        case kCM_COMBOBOX:
+            switch (parm1)
+            {
+            case kCBDirectory:
+                SetDir();
+                return kTRUE;
+            case kCBFilter:
+                SetFilter();
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        return kTRUE;
+
+    case kC_CONTAINER:
+        switch (GET_SUBMSG(msg))
+        {
+
+            //      case kCT_ITEMCLICK:
+            // 	printf ("itemclick\n");
+            //      break;
+
+        case kCT_ITEMDBLCLICK:
+            //
+            //  process the double click in the file view container
+            //
+            if (parm1 != kButton1 || fFileCont->NumSelected() != 1)
+                return kTRUE;
+
+            //
+            //  one file selected
+            //
+            void *dummy = NULL;
+            const TGFileItem *item = (TGFileItem *)fFileCont->GetNextSelected(&dummy);
+
+            const char *str = item->GetItemName()->GetString();
+
+            //
+            // if the user choose a directory
+            // change to this directory
+            //
+            if (S_ISDIR(item->GetType()))
+            {
+                ChangeDir(str);
+                return kTRUE;
+            }
+
+            SetFileName(str);
+            return kTRUE;
+        }
+    }
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MBrowser.h	(revision 1638)
@@ -0,0 +1,80 @@
+#ifndef MARS_MBrowser
+#define MARS_MBrowser
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class MGList;
+class TGTab;
+class TGListView;
+class TGTextEntry;
+class TGFSComboBox;
+class TGProgressBar;
+class TGPictureButton;
+class TGFileContainer;
+
+class MBrowser : public TGTransientFrame
+{
+private:
+    TGTab            *fTabs;
+
+    TGTextEntry      *fEntry;
+
+    TGFileContainer  *fFileCont;
+    TGListView       *fFileView;
+
+    void CreateMenuBar();
+    void CreateTab1();
+    void CreateUpperFrame(TGCompositeFrame *frameup);
+    void CreateLowerFrame(TGCompositeFrame *framelow);
+    void CreateDirListMenu(TGCompositeFrame *frame);
+    void CreateDirListBox(TGCompositeFrame *frame);
+
+    void SetFileName(TString name);
+
+    void SetFilter();
+    void SetDir();
+    void SetViewMode(const Int_t mode);
+
+protected:
+    MGList *fList;
+    TString fInputFile;
+
+    TGCompositeFrame *CreateNewTab(const char *name);
+
+    void DisplError(const char *txt);
+    void DisplWarning(const char *txt);
+    void DisplInfo(const char *txt);
+
+    void ChangeDir(const char *txt=NULL);
+
+    TGProgressBar *CreateProgressBar(TGHorizontalFrame *frame);
+    void DestroyProgressBar(TGProgressBar *bar);
+
+    TGHorizontalFrame *fTop1;
+    TGHorizontalFrame *fTop2;
+    TGHorizontalFrame *fTop3;
+
+ public: 
+     MBrowser(const TGWindow *main=NULL, const TGWindow *p=NULL,
+               const UInt_t w=500, const UInt_t h=500) ;
+
+     virtual ~MBrowser();
+
+     void   CloseWindow();
+
+     Bool_t InputFileSelected();
+
+     virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+     ClassDef(MBrowser, 0)   // Base class for the Gui-Browsers
+} ; 
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.cc	(revision 1638)
@@ -0,0 +1,100 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MCameraDisplay.h"
+
+#include <TGButton.h>  // TGTextButton
+
+#include "MGList.h"
+#include "MGCamDisplay.h"
+
+ClassImp(MCameraDisplay)
+
+enum {
+    kButDisplay = 0x100
+};
+
+// --------------------------------------------------------------------------
+//
+//  Create the 'Data Check' GUI Controls (Window) on the screen. To use it
+//  from within the interpreter you can call a Standard Version with
+//  'new MCameraDisplay()'
+//
+MCameraDisplay::MCameraDisplay(const TGWindow *main, const TGWindow *p,
+                       const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    TGTextButton *disp = new TGTextButton(fTop2, "Display Events", kButDisplay);
+    fList->Add(disp);
+
+    disp->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop2->AddFrame(disp, laybut);
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("Camera Display Window");
+    SetIconName("Camera Dsiplay");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI control events (here: mainly button clicks)
+//
+Bool_t MCameraDisplay::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case kButDisplay:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case kButDisplay:
+            new MGCamDisplay(fInputFile,
+                             fClient->GetRoot(), this, 600, 500);
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MCameraDisplay.h	(revision 1638)
@@ -0,0 +1,21 @@
+#ifndef MARS_MCameraDisplay
+#define MARS_MCameraDisplay
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class MCameraDisplay : public MBrowser
+{
+public:
+    MCameraDisplay(const TGWindow *main=NULL, const TGWindow *p=NULL,
+                   const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MCameraDisplay, 0) // GUI: The 'camera display' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.cc	(revision 1638)
@@ -0,0 +1,198 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#include "MDataCheck.h"
+
+#include <TGButton.h>  // TGTextButton
+
+#include "MGList.h"
+#include "MFillH.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MReadTree.h"
+#include "MGDisplayAdc.h"
+
+// ---
+
+ClassImp(MDataCheck)
+
+enum {
+    kButPedAdc = 0x100,
+    kButEvtAdc = 0x101,
+    kButPedTdc = 0x102,
+    kButEvtTdc = 0x103
+};
+
+// --------------------------------------------------------------------------
+//
+//  Create the 'Data Check' GUI Controls (Window) on the screen. To use it
+//  from within the interpreter you can call a Standard Version with
+//  'new MDataCheck()'
+//
+MDataCheck::MDataCheck(const TGWindow *main, const TGWindow *p,
+                       const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    TGTextButton *pedadc = new TGTextButton(fTop1, "ADC Spectra of Pedestals", kButPedAdc);
+    TGTextButton *cradc  = new TGTextButton(fTop1, "ADC Specta of Cosmics",    kButEvtAdc);
+    TGTextButton *pedtdc = new TGTextButton(fTop3, "TDC Spectra of Pedestals", kButPedTdc);
+    TGTextButton *crtdc  = new TGTextButton(fTop3, "TDC Specta of Cosmics",    kButEvtTdc);
+
+    pedadc->Associate(this);
+    cradc ->Associate(this);
+    pedtdc->Associate(this);
+    crtdc ->Associate(this);
+
+    fList->Add(pedadc);
+    fList->Add(cradc);
+    fList->Add(pedtdc);
+    fList->Add(crtdc);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop1->AddFrame(pedadc, laybut);
+    fTop1->AddFrame(cradc,  laybut);
+
+    fTop3->AddFrame(pedtdc, laybut);
+    fTop3->AddFrame(crtdc,  laybut);
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("DataCheck Window");
+    SetIconName("DataCheck");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Create the 'View Adc' GUI Controls (Window) on the screen.
+//  Therefor we have to process all data in a file and fill the corresponding
+//  histograms.
+//
+void MDataCheck::ViewAdcSpectra(const char *inputfile, const char *treeName)
+{
+    //
+    // create a (empty) list of parameters which can be used by the tasks
+    // and an (empty) list of tasks which should be executed
+    // connect them in the required way.
+    //
+
+    //
+    //   create the data containers for the raw data
+    //
+    MParList plist;
+
+    //
+    // set up the tasks for this job
+    //
+    MTaskList tasks;
+    plist.AddToList(&tasks);
+
+    MReadTree read(treeName, inputfile);
+    read.DisableAutoScheme();
+
+    MFillH fill("MHFadcCam", "MRawEvtData");
+
+    tasks.AddToList(&read);
+    tasks.AddToList(&fill);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop1);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    new MGDisplayAdc((MHFadcCam*)plist.FindObject("MHFadcCam"));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI control events (here: mainly button clicks)
+//
+Bool_t MDataCheck::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case kButPedAdc:
+    case kButEvtAdc:
+    case kButPedTdc:
+    case kButEvtTdc:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case kButPedAdc:
+            ViewAdcSpectra(fInputFile, "PedEvents");
+            return kTRUE;
+
+        case kButEvtAdc:
+            ViewAdcSpectra(fInputFile, "Events");
+            return kTRUE;
+
+        case kButPedTdc:
+            // fOctober.PedTdcSpectra(fInputFile) ;
+            return kTRUE;
+
+        case kButEvtTdc:
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MDataCheck.h	(revision 1638)
@@ -0,0 +1,24 @@
+#ifndef MARS_MDataCheck
+#define MARS_MDataCheck
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class MDataCheck : public MBrowser
+{
+private:
+    void ViewAdcSpectra(const char *inputfile, const char *treeName);
+
+public:
+    MDataCheck(const TGWindow *main=NULL, const TGWindow *p=NULL,
+               const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MDataCheck, 0) // GUI: The 'data-check' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.cc	(revision 1638)
@@ -0,0 +1,115 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MEvtDisp.h"
+
+#include <TGButton.h>       // TGTextButton
+
+#include "MGList.h"
+#include "MGFadcDisp.h"
+
+ClassImp(MEvtDisp)
+
+enum {
+  kButDispEvt          = 0x100,
+  kButDispPedestal     = 0x101,
+  kButDispCalibration  = 0x102
+};
+
+MEvtDisp::MEvtDisp(const TGWindow *main, const TGWindow *p,
+                   const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    TGTextButton *fadcevt = new TGTextButton(fTop1, "FADC Disp for Events",  kButDispEvt);
+    TGTextButton *fadcped = new TGTextButton(fTop1, "FADC Disp for PedEvts", kButDispPedestal);
+    TGTextButton *fadccal = new TGTextButton(fTop1, "FADC Disp for CalEvts", kButDispCalibration);
+
+    fadcevt->Associate(this);
+    fadcped->Associate(this);
+    fadccal->Associate(this);
+
+    fList->Add(fadcevt);
+    fList->Add(fadcped);
+    fList->Add(fadccal);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    fTop1->AddFrame(fadcevt, laybut);
+    fTop1->AddFrame(fadcped, laybut);
+    fTop1->AddFrame(fadccal, laybut);
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("EventDispMain");
+    SetIconName("EventDispMain");
+
+    MapWindow();
+} 
+
+// ======================================================================
+
+Bool_t MEvtDisp::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{     
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg) != kC_COMMAND || GET_SUBMSG(msg) != kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case kButDispEvt:
+    case kButDispPedestal:
+    case kButDispCalibration:
+        if (!InputFileSelected())
+        {        
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case kButDispEvt:
+            new MGFadcDisp(fInputFile, "Events",
+                           fClient->GetRoot(), this, 600, 500);
+            return kTRUE;
+
+        case kButDispPedestal:
+            new MGFadcDisp(fInputFile , "PedEvts",
+                           fClient->GetRoot(), this, 600, 500);
+            return kTRUE;
+
+        case kButDispCalibration:
+            new MGFadcDisp(fInputFile , "CalEvts",
+                           fClient->GetRoot(), this, 600, 500);
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+} 
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MEvtDisp.h	(revision 1638)
@@ -0,0 +1,21 @@
+#ifndef MARS_MEvtDisp
+#define MARS_MEvtDisp
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class MEvtDisp : public MBrowser
+{ 
+public:
+    MEvtDisp(const TGWindow *main=NULL, const TGWindow *p=NULL,
+             const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MEvtDisp, 0) // GUI: The 'event display' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.cc	(revision 1638)
@@ -0,0 +1,319 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#include "MMars.h"
+
+#include <iostream.h>
+
+#include <TApplication.h>  // gROOT->GetApplication()->...
+
+#include <TGTab.h>         // TGTab
+#include <TGMenu.h>        // TGPopupMenu
+#include <TSystem.h>       // gSystem->Exec
+#include <TGMsgBox.h>      // TGMsgBox
+#include <TGButton.h>      // TGPictureButton
+#include <TG3DLine.h>      // TGHorizontal3DLine
+
+#include "MGList.h"
+#include "MEvtDisp.h"
+#include "MAnalysis.h"
+#include "MDataCheck.h"
+#include "MMonteCarlo.h"
+#include "MCameraDisplay.h"
+
+ClassImp(MMars)
+
+enum {
+    kFileExit,
+    kFileAbout,
+
+    kPicMagic,
+    kPicMars,
+
+    kButEvtDisplay,
+    kButDataCheck,
+    kButAnalysis,
+    kButMonteCarlo,
+    kButCameraDisplay
+};
+
+void MMars::CreateMenuBar()
+{
+    TGLayoutHints *laymenubar  = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
+    TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+
+    fList->Add(laymenubar);
+    fList->Add(laymenuitem);
+    fList->Add(laylinesep);
+
+    TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
+    filemenu->AddEntry("E&xit", kFileExit);
+    filemenu->Associate(this);
+
+    TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
+    menubar->AddPopup("&File", filemenu, laymenuitem);
+    AddFrame(menubar, laymenubar);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    AddFrame(linesep, laylinesep);
+
+    fList->Add(filemenu);
+    fList->Add(menubar);
+    fList->Add(linesep);
+}
+
+void MMars::CreateTopFrame(TGHorizontalFrame *top)
+{
+    const TGPicture *pic1 = fList->GetPicture("magiclogo.xpm");
+    if (pic1)
+    {
+        TGPictureButton *magic = new TGPictureButton(top, pic1, kPicMagic);
+        fList->Add(magic);
+        magic->Associate(this);
+        TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft,  10., 10., 20., 10.);
+        fList->Add(lay1);
+        top->AddFrame(magic, lay1);
+    }
+
+    const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
+    if (pic2)
+    {
+        TGPictureButton *mars  = new TGPictureButton(top, pic2, kPicMars);
+        fList->Add(mars);
+        mars->Associate(this);
+        TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10., 10., 10., 10.);
+        fList->Add(lay2);
+        top->AddFrame(mars,  lay2);
+    }
+}
+
+#include <TGLabel.h>
+
+void MMars::CreateTextButton(TGVerticalFrame *tab,
+                             const char *text, const char *descr,
+                             const UInt_t id) const
+{
+    //
+    // Create the button
+    //
+    TGHorizontalFrame *frame  = new TGHorizontalFrame(tab, 1, 1);
+    TGTextButton      *button = new TGTextButton(frame, text, id);
+    TGLabel           *label  = new TGLabel(frame, descr);
+    TGLayoutHints     *hints1 = new TGLayoutHints(kLHintsLeft|kLHintsCenterY|kLHintsExpandX, 5, 5, 2, 2);
+
+    //
+    // Add button for 'auto-delete'
+    //
+    fList->Add(hints1);
+    fList->Add(button);
+    fList->Add(label);
+    fList->Add(frame);
+
+    //
+    // Send button events (meesages) to this object (s. ProcessMessage)
+    //
+    button->Associate(this);
+
+    //
+    // Add button with corresponding layout to containing frame
+    //
+    tab->AddFrame(frame,    hints1);
+    frame->AddFrame(button, hints1);
+    frame->AddFrame(label,  hints1);
+}
+
+void MMars::CreateBottomFrame(TGHorizontalFrame *low)
+{
+    //
+    // Create Tab Container
+    //
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
+    fList->Add(laytabs);
+
+    TGTab *tabs = new TGTab(low, 1, 1);
+    fList->Add(tabs);
+    low->AddFrame(tabs, laytabs);
+
+    //
+    // Create Tab1
+    //
+    TGCompositeFrame *tf = tabs->AddTab("Control");
+
+    TGLayoutHints   *laytab = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX);
+    TGVerticalFrame *tab    = new TGVerticalFrame(tf, 1, 1);
+    fList->Add(laytab);
+    fList->Add(tab);
+
+    CreateTextButton(tab, "Event Display",  "Historgrams: Pix per Event",
+                     kButEvtDisplay);
+    CreateTextButton(tab, "Data Check",     "Histograms: Pix per Run",
+                     kButDataCheck);
+    CreateTextButton(tab, "Analysis",       "Calculate image parameters",
+                     kButAnalysis);
+    CreateTextButton(tab, "Monte Carlo",    "Calculate MC stuff",
+                     kButMonteCarlo);
+    CreateTextButton(tab, "Camera Display", "Display Cerenekov Photons",
+                     kButCameraDisplay);
+
+    tf->AddFrame(tab, laytab);
+}
+
+MMars::MMars()
+: TGMainFrame(gClient->GetRoot(), 400, 400, kVerticalFrame)
+{
+    //
+    // Create the deletion list
+    //
+    fList = new MGList;
+    fList->SetOwner();
+
+    //
+    // Create the MenuBar
+    //
+    CreateMenuBar();
+
+    //
+    // create and layout the frame/contents
+    //
+    TGHorizontalFrame *top = new TGHorizontalFrame(this, 1, 1);
+    TGHorizontalFrame *low = new TGHorizontalFrame(this, 1, 1);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+
+    fList->Add(top);
+    fList->Add(low);
+    fList->Add(linesep);
+
+    CreateTopFrame(top);
+    CreateBottomFrame(low);
+
+    TGLayoutHints *layout1 = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY);
+    fList->Add(layout1);
+    fList->Add(layout2);
+
+    AddFrame(top,     layout1);
+    AddFrame(linesep, layout1);
+    AddFrame(low,     layout2);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    Move(rand()%100, rand()%100);
+
+    Layout();
+
+    MapSubwindows();
+
+    SetWindowName("MARS Main Window");
+    SetIconName("MARS");
+
+    MapWindow();
+} 
+
+// ======================================================================
+
+MMars::~MMars()
+{
+    delete fList;
+}  
+// ======================================================================
+
+void MMars::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+   TGMainFrame::CloseWindow();
+   gROOT->GetApplication()->Terminate(0);
+}
+
+void MMars::DisplWarning(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this,
+                 "WARNING!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{     
+    // Process events generated by the buttons in the frame.
+
+    switch (GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+
+            switch (parm1)
+            {
+
+            case kButEvtDisplay:
+                new MEvtDisp(this);
+                return kTRUE;
+
+            case kButDataCheck:
+                new MDataCheck(this);
+                return kTRUE;
+
+            case kButAnalysis:
+                new MAnalysis(this);
+                return kTRUE;
+
+            case kButMonteCarlo:
+                new MMonteCarlo(this);
+                return kTRUE;
+
+            case kButCameraDisplay:
+                new MCameraDisplay(this);
+                return kTRUE;
+
+            case kPicMagic:
+                cout << "Trying to start 'netscape http://hegra1.mppmu.mpg.de/MAGICWeb/'..." << endl;
+                gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
+                return kTRUE;
+
+            case kPicMars:
+                cout << "Trying to start 'netscape http://magic.astro.uni-wuerzburg.de/mars/'..." << endl;
+                gSystem->Exec("netscape http://magic.astro.uni-wuerzburg.de/mars/ &");
+                return kTRUE;
+            }
+
+	case kCM_MENU:
+            if (parm1!=kFileExit)
+                return kTRUE;
+
+            CloseWindow();
+            return kTRUE;
+	}
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMars.h	(revision 1638)
@@ -0,0 +1,44 @@
+#ifndef MARS_MMars
+#define MARS_MMars
+
+#ifndef MMARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class MGList;
+class TGVerticalFrame;
+class TGLayoutHints;
+
+class MMars : public TGMainFrame
+{
+private:
+
+    MGList *fList;
+
+    void CreateTextButton(TGVerticalFrame *tab, const char *text,
+                          const char *descr, const UInt_t id) const;
+
+    void CreateMenuBar();
+    void CreateTopFrame(TGHorizontalFrame *top);
+    void CreateBottomFrame(TGHorizontalFrame *low);
+
+    void DisplWarning(const char *txt);
+
+public:
+    MMars();
+    ~MMars();
+
+    void CloseWindow();
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MMars, 0) // GUI: Mars - the main window
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.cc	(revision 1638)
@@ -0,0 +1,507 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MMonteCarlo.h"
+
+#include <stdlib.h>
+#include <iostream.h>
+
+#include <TGLabel.h>        // TGLabel
+#include <TGButton.h>       // TGTextButton
+#include <TGTextEntry.h>    // TGTextEntry
+#include <TGProgressBar.h>  // TGHProgressBar
+#include <TGButtonGroup.h>  // TGVButtonGroup
+
+#include "MGList.h"
+
+ClassImp(MMonteCarlo)
+
+enum {
+    kButCollArea  = 0x100,
+    kButTrigRate  = 0x101,
+    kButThreshold = 0x102
+};
+
+void MMonteCarlo::AddButtons()
+{
+    TGTextButton *carea = new TGTextButton(fTop2, "Collection Area", kButCollArea);
+    TGTextButton *trate = new TGTextButton(fTop2, "Trigger Rate",    kButTrigRate);
+    TGTextButton *thold = new TGTextButton(fTop2, "Threshold",       kButThreshold);
+
+    fList->Add(carea);
+    fList->Add(trate);
+    fList->Add(thold);
+
+    carea->Associate(this);
+    trate->Associate(this);
+    thold->Associate(this);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsNormal, 5, 5, 10, 10);
+    fList->Add(laybut);
+
+    fTop2->AddFrame(carea, laybut);
+    fTop2->AddFrame(trate, laybut);
+    fTop2->AddFrame(thold, laybut);
+}
+
+void MMonteCarlo::AddSetupTab()
+{
+    //
+    // Create Setup Tab
+    //
+    TGCompositeFrame *frame = CreateNewTab("Setup");
+
+    //
+    // Create a button group (it alignes the buttons and make
+    // them automatic radio buttons)
+    // Create three (auto) radio buttons in the button group
+    //
+    TGVButtonGroup *group = new TGVButtonGroup(frame);
+    fList->Add(group);
+
+    fRadioButton1 = new TGRadioButton(group, "Use unnumbered trigger condition olny.");
+    fRadioButton2 = new TGRadioButton(group, "Use only one trigger condition (specify number below).");
+    fRadioButton3 = new TGRadioButton(group, "Use a number of trigger conditions (1..n).");
+
+    fRadioButton1->SetState(kButtonDown);
+
+    /*
+     WARNING:
+     Bacause of some strage and hidden dependencies the
+     GetMaiFrame call in the destructor of TGButton may fail if some
+     of the other gui elemts is deleted first.
+     AddFirst adds the buttons at the beginning of the deletion list,
+     this seems to work.
+     */
+    fList->AddFirst(fRadioButton1);
+    fList->AddFirst(fRadioButton2);
+    fList->AddFirst(fRadioButton3);
+
+    //
+    // Add the button group (all buttons) as first line
+    //
+    frame->AddFrame(group);
+
+    //
+    // Create entry fields and labels for line 3 and 4
+    //
+
+    /*
+     * --> use with root >=3.02 <--
+     *
+
+     TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+     TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+
+     */
+
+    //
+    // Align the lines:
+    //  - top, left
+    //  - padding: top=20, bottom=0, left=20, right=0
+    //
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsNormal, 20, 0, 20);
+    fList->Add(layline);
+
+
+    //
+    // Create a frame for line 3 and 4 to be able
+    // to align entry field and label in one line
+    //
+    TGHorizontalFrame *f = new TGHorizontalFrame(frame, 0, 0);
+    fNumEntry = new TGTextEntry(f, "****");
+    fNumEntry->SetText("1");
+    fList->Add(fNumEntry);
+
+    // --- doesn't work like expected --- fNumEntry1->SetAlignment(kTextRight);
+    // --- doesn't work like expected --- fNumEntry2->SetAlignment(kTextRight);
+
+    TGLabel *l = new TGLabel(f, "Trigger Condition Setup.");
+    l->SetTextJustify(kTextLeft);
+    fList->Add(l);
+
+    //
+    // Align the text of the label centered, left in the row
+    // with a left padding of 10
+    //
+    TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10); //, 10); //, 5, 5);
+    fList->Add(laylabel);
+
+    //
+    // Add one entry field and the corresponding label to each line
+    //
+    f->AddFrame(fNumEntry);
+    f->AddFrame(l, laylabel);
+
+    //
+    // Add line 3 and 4 to tab
+    //
+    frame->AddFrame(f, layline);
+}
+
+MMonteCarlo::MMonteCarlo(const TGWindow *main, const TGWindow *p,
+                         const UInt_t w, const UInt_t h)
+: MBrowser(main, p, w, h)
+{
+    AddButtons();
+    AddSetupTab();
+
+    MapSubwindows();
+
+    Layout();
+
+    SetWindowName("MonteCarlo Main");
+    SetIconName("MonteCarlo");
+
+    MapWindow();
+} 
+
+// ======================================================================
+#include <TObjArray.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MReadTree.h"
+
+#include "MHMcRate.h"
+#include "MHMcEnergy.h"
+
+#include "MMcTriggerRateCalc.h"
+#include "MMcThresholdCalc.h"
+#include "MMcCollectionAreaCalc.h"
+
+#include "../mmc/MMcTrig.hxx" // FIXME: see FIXME below
+
+Int_t MMonteCarlo::GetDim() const
+{
+    Int_t dim = atoi(fNumEntry->GetText());
+
+    if (dim<0)
+    {
+        dim=0;
+        fNumEntry->SetText("0");
+    }
+
+    if (fRadioButton1->GetState())
+        dim = 0;
+
+    if (fRadioButton2->GetState())
+        dim = -dim;
+
+    return dim;
+}
+
+void MMonteCarlo::CalculateCollectionArea()
+{
+    //
+    // first we have to create our empty lists
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // FIXME: This line is needed that root finds the MMc-classes in the
+    // dictionary when calling the constructor of MReadTree
+    // I don't have any idea why...
+    // Rem: This happens only in this GUI!
+    //
+    MMcTrig trig;
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can fill the efficiency histograms
+    //
+    MReadTree read("Events", fInputFile);
+    tlist.AddToList(&read);
+
+    MMcCollectionAreaCalc effi;
+    tlist.AddToList(&effi);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayd
+    //
+    plist.FindObject("MHMcCollectionArea")->DrawClone();
+}
+
+void MMonteCarlo::CalculateTriggerRate()
+{
+    // This macro has two input parameter:
+    // dim : = 0 -> root file with 1 trigger condition.
+    //       > 0 -> number of trigger condition to be analised 
+    //              in multi conditon file.
+    //       < 0 -> selects the -dim trigger condition.
+    //
+    // first we have to create our empty lists
+    //
+    const Int_t dim = GetDim();
+
+    MParList plist;
+    MTaskList tlist;
+
+    //
+    // Setup the parameter list.
+    //  - we do not need to create any other container. All of them
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //
+    //  - we need to create MHMcRate only. The other containers
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //  - MHMcRate must be created by us because we need the pointer
+    //    to it and if it would get created automatically it would also be
+    //    deleted automatically
+    //  - Actually, depending on using a single trigger option MonteCarlo
+    //    file or a multyple trigger option, a MHMcRate or an array of 
+    //    MHMcRate are needed.
+    //
+    plist.AddToList(&tlist);
+
+    //
+    // You don't have to add the MHMcRate container here by hand.
+    // But if you want to print or display these containers later on
+    // it is necessary (Rem: No printing or displaying is done in this
+    // macro yet)
+    //
+    const UInt_t from = dim>0 ?   1 : -dim;
+    const UInt_t to   = dim>0 ? dim : -dim;
+    const Int_t  num  = to-from+1;
+
+    TObjArray hists(MParList::CreateObjList("MHMcRate", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != num)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    plist.AddToList(&hists);
+
+    //
+    // FIXME: This line is needed that root finds the MMc-classes in the
+    // dictionary when calling the constructor of MReadTree
+    // I don't have any idea why...
+    // Rem: This happens only in this GUI!
+    //
+    MMcTrig trig;
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can calculate rates, for what the number of
+    //    triggered showers from a empty reflector file for the
+    //    analised trigger conditions should be set (BgR[])
+    //
+    MReadTree read("Events", fInputFile);
+    tlist.AddToList(&read);
+
+    Float_t BgR[10]={660, 4, 0, 0, 0, 0, 0, 0, 0, 0};
+
+    MMcTriggerRateCalc crate(dim, 14, BgR, 100000);
+    tlist.AddToList(&crate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    hists.Print();
+}
+
+void MMonteCarlo::CalculateThreshold()
+{
+    const Int_t dim = GetDim();
+
+    //
+    // This macro fill the container MHMcEnergies using the task
+    // MMcThresholdCalc and shows the results.
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Setup the parameter list
+    // - You need create the container MHMcEnergies.
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MHMcEnergies
+    //    + If you don't put any dimension to MHMcEnergies it works
+    //      taking only the trigger information from MMcTrig
+    //
+
+    //
+    // Create numtriggerconditions histograms of type MHMcEnergy
+    // and store the histograms in an TObjArray
+    //
+    const UInt_t from = dim>0 ?   1 : -dim;
+    const UInt_t to   = dim>0 ? dim : -dim;
+    const Int_t  num  = to-from+1;
+
+    TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != num)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    plist.AddToList(&hists);
+
+    //
+    // FIXME: This line is needed that root finds the MMc-classes in the
+    // dictionary when calling the constructor of MReadTree
+    // I don't have any idea why...
+    // Rem: This happens only in this GUI!
+    //
+    MMcTrig trig;
+
+    //
+    // Setup the task list
+    // - You need the read and the MMcThresholdCalc tasks
+    // - You have to fill the histograms for the Energy threshold
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcThresholdCalc
+    //    + If you don't put any dimension to MMcThresholdCalc it works
+    //      like one dimension MMcThresholdCalc
+    //
+
+    MReadTree read("Events", fInputFile);
+
+    MMcThresholdCalc calc(dim);
+    tlist.AddToList(&read);
+    tlist.AddToList(&calc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    evtloop.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = evtloop.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    //
+    // Now you can display the results
+    //
+    TIter Next(&hists);
+    TObject *obj;
+    while ((obj=Next()))
+    obj->DrawClone();
+}
+
+// ======================================================================
+
+Bool_t MMonteCarlo::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON)
+        switch (parm1)
+        {
+        case kButCollArea:
+            CalculateCollectionArea();
+            return kTRUE;
+
+        case kButTrigRate:
+            CalculateTriggerRate();
+            return kTRUE;
+
+        case kButThreshold:
+            CalculateThreshold();
+            return kTRUE;
+        }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MMonteCarlo.h	(revision 1638)
@@ -0,0 +1,40 @@
+#ifndef MARS_MMonteCarlo
+#define MARS_MMonteCarlo
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class TGTextEntry;
+class TGRadioButton;
+
+class MMonteCarlo : public MBrowser
+{
+private:
+    TGRadioButton *fRadioButton1;
+    TGRadioButton *fRadioButton2;
+    TGRadioButton *fRadioButton3;
+
+    TGTextEntry   *fNumEntry;
+
+    Int_t GetDim() const;
+
+    void CalculateCollectionArea();
+    void CalculateTriggerRate();
+    void CalculateThreshold();
+
+    void AddButtons();
+    void AddSetupTab();
+
+public:
+    MMonteCarlo(const TGWindow *main=NULL, const TGWindow *p=NULL,
+                const UInt_t w=500, const UInt_t h=500);
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MMonteCarlo, 0) // GUI: The 'monte-carlo' browser
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.cc	(revision 1638)
@@ -0,0 +1,87 @@
+/* ======================================================================== *\
+!
+! *
+! * 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  9/2002 <mailto:tbretz@astro-uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrc
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MProgressBar.h"
+
+#include <TSystem.h>        // gSystem
+#include <TGProgressBar.h>  // TGHProgressBar
+
+#include "MGList.h"
+
+ClassImp(MProgressBar);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Opens a window with a progress bar. Get a pointer
+// to the bar by calling GetBar. This pointer can be used for the
+// eventloop.
+//
+// Be carefull: killing or closing the window while the progress meter
+//   is still in use may cause segmentation faults. Please kill the window
+//   always by deleting the corresponding object.
+//
+MProgressBar::MProgressBar() : TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 1, 1)
+{
+    fList = new MGList;
+    fList->SetOwner();
+
+    //SetMWMHints(0, 0, 0);
+
+    SetWMSizeHints(150, 15, 640, 480, 10, 10); // set the smallest and biggest size of the Main frame
+    Move(rand()%100+50, rand()%100+50);
+
+    TGLayoutHints *laybar=new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2,2,2,2);
+    fList->Add(laybar);
+
+    fBar=new TGHProgressBar(this);
+    fBar->ShowPosition();
+    AddFrame(fBar, laybar);
+    fList->Add(fBar);
+
+    Layout();
+
+    MapSubwindows();
+
+    SetWindowName("Progress");
+    SetIconName("Progress");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destruct the window with all its tiles. Also the Progress Bar object
+// is deleted.
+//
+MProgressBar::~MProgressBar()
+{
+    delete fList;
+} 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MProgressBar.h	(revision 1638)
@@ -0,0 +1,33 @@
+#ifndef MARS_MProgressBar
+#define MARS_MProgressBar
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class MGList;
+class TGProgressBar;
+class TGHProgressBar;
+
+class MProgressBar : public TGTransientFrame
+{
+private:
+    MGList         *fList;
+    TGHProgressBar *fBar;
+
+public:
+     MProgressBar();
+     virtual ~MProgressBar();
+
+     TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
+
+     ClassDef(MProgressBar, 0)   // A simple progress bar window for the Eventloop
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/MainLinkDef.h	(revision 1638)
@@ -0,0 +1,17 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MBrowser+;
+
+#pragma link C++ class MMars+;
+#pragma link C++ class MAnalysis+;
+#pragma link C++ class MEvtDisp+;
+#pragma link C++ class MDataCheck+;
+#pragma link C++ class MMonteCarlo+;
+#pragma link C++ class MProgressBar+;
+#pragma link C++ class MCameraDisplay+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmain/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmain/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmain/Makefile	(revision 1638)
@@ -0,0 +1,55 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Main
+
+#
+# Library name to creatre
+#
+LIB   = mmain.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp \
+	   -I../mgui -I../mgeom -I../mhist -I../mmontecarlo -I../mfileio
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MBrowser.cc \
+	   MDataCheck.cc \
+	   MEvtDisp.cc \
+	   MMars.cc \
+           MAnalysis.cc \
+	   MMonteCarlo.cc \
+           MProgressBar.cc \
+           MCameraDisplay.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 1638)
@@ -0,0 +1,159 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHMcCollectionAreaCalc                                                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MMcCollectionAreaCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+#include "MMcRunHeader.hxx"
+
+#include "MHMcCollectionArea.h"
+
+ClassImp(MMcCollectionAreaCalc);
+
+MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
+                                             const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcCollectionAreaCalc";
+    fTitle = title ? title : "Task to calculate the collection area";
+
+    fObjName = input ? input : "MMcTrig";
+    AddToBranchList(Form("%s.fNumFirstLevel", input));
+
+    AddToBranchList("MMcEvt.fEnergy");
+    AddToBranchList("MMcEvt.fImpact");
+} 
+
+Bool_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
+{
+    // connect the raw data with this task
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
+    if (!fCollArea)
+        return kFALSE;
+
+
+    fTotalNumSimulatedShowers = 0;
+    fCorsikaVersion           = 0;
+    fAllEvtsTriggered         = kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
+{
+    MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
+    if (!runheader)
+    {
+        *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
+
+    *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
+
+    if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
+        *fLog << warn << dbginf << "Warning - Read files have different TelesTheta..." << endl;
+
+    fTheta = runheader->GetTelesTheta();
+
+    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
+        *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
+
+    fCorsikaVersion = runheader->GetCorsikaVersion();
+
+    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
+
+    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
+
+    if (fAllEvtsTriggered)
+        return kTRUE;
+
+    fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
+    if (!fMcTrig)
+    {
+        *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+Bool_t MMcCollectionAreaCalc::Process()
+{
+    const Float_t energy = fMcEvt->GetEnergy();
+    const Float_t impact = fMcEvt->GetImpact()/100.;
+
+    if (!fAllEvtsTriggered)
+    {
+        fCollArea->FillAll(energy, impact);
+
+        if (fMcTrig->GetFirstLevel() <= 0)
+            return kTRUE;
+    }
+
+    fCollArea->FillSel(energy, impact);
+
+    return kTRUE;
+}
+
+Bool_t MMcCollectionAreaCalc::PostProcess()
+{ 
+    //
+    //   do the calculation of the effectiv area
+    //
+    *fLog << inf << "Calculation Collection Area..." << endl;
+
+    if (!fAllEvtsTriggered)
+        fCollArea->CalcEfficiency();
+    else
+    {
+        *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
+        fCollArea->CalcEfficiency(fTotalNumSimulatedShowers,
+                                  fCorsikaVersion == 5200 ? fTheta : 0);
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 1638)
@@ -0,0 +1,43 @@
+#ifndef MARS_MMcCollectionAreaCalc
+#define MARS_MMcCollectionAreaCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+class MMcEvt;
+class MMcTrig;
+class MHMcCollectionArea;
+
+class MMcCollectionAreaCalc : public MTask
+{
+private:
+    const MMcEvt  *fMcEvt;
+    const MMcTrig *fMcTrig;
+
+    MHMcCollectionArea *fCollArea;
+
+    TString fObjName;
+
+    UInt_t fTotalNumSimulatedShowers;
+    UInt_t fCorsikaVersion;
+    Float_t fTheta;
+
+    Bool_t fAllEvtsTriggered;
+
+public:
+    MMcCollectionAreaCalc(const char *input=NULL,
+                          const char *name=NULL, const char *title=NULL);
+
+    Bool_t ReInit(MParList *plist);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MMcCollectionAreaCalc, 0) // Task to calculate the collection area histogram
+};
+
+#endif 
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 1638)
@@ -0,0 +1,183 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier Lopez 05/2001 <mailto:jlopez@ifae.es>
+!   Author(s): Thomas Bretz 06/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+//  MMcThresholdCalc
+//                                                                         
+//  Input Containers:
+//   MMcEvt, MMcTrig;*
+//
+//  Output Containers:
+//   MHMcEnergies
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MMcThresholdCalc.h"
+
+#include <math.h>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+
+#include "MHMcEnergy.h"
+
+ClassImp(MMcThresholdCalc);
+
+const Float_t MMcThresholdCalc::fSqrt2 = sqrt(2);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor.
+//
+// Specify the number of trigger conditions you want to use.
+// The default is 0.
+//
+// dim < 0: use only condition number dim (eg "MMcTrig;3")
+// dim = 0: use only condition without a number ("MMcTrig")
+// dim > 0: use conditions up to dim (from "MMcTrig;1" to "MMcTrig;dim")
+//
+MMcThresholdCalc::MMcThresholdCalc(const Int_t dim, const char* name,
+                                   const char* title)
+    : fMcTrig(NULL), fEnergy(NULL)
+{
+    fName  = name  ? name  : "MMcThresholdCalc";
+    fTitle = title ? title : "Task to calculate the energy threshold from Monte Carlo";
+
+    fFirst = dim>0 ?   1 : -dim;
+    fLast  = dim>0 ? dim : -dim;
+
+    fNum = fLast-fFirst+1;
+
+    AddToBranchList("MMcEvt.fEnergy");
+    AddToBranchList("MMcTrig", "fNumFirstLevel", fFirst, fLast);
+}
+
+// -------------------------------------------------------------------------
+//
+// Destructor.
+//
+MMcThresholdCalc::~MMcThresholdCalc()
+{
+    if (fMcTrig)
+        delete fMcTrig;
+
+    if (fEnergy)
+        delete fEnergy;
+}
+
+// --------------------------------------------------------------------------
+//
+// connect Monte Carlo data with this task
+//
+Bool_t MMcThresholdCalc::PreProcess(MParList* pList)
+{
+    //
+    // This task takes into accout if the root file has one trigger
+    // condition (MMcTrig) or severl of them (MMcTrig;#.)
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    UInt_t num;
+
+    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", fFirst, fLast));
+    num = fMcTrig->GetEntriesFast();
+    if (num != fNum)
+    {
+        *fLog << err << dbginf << fNum << " MMcTrig objects requested, ";
+        *fLog << num << " are available... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEnergy = new TObjArray(pList->FindCreateObjList("MHMcEnergy", fFirst, fLast));
+    num = fMcTrig->GetEntriesFast();
+    if (num != fNum)
+    {
+        *fLog << err << dbginf << fNum << " MHMcEnergy objects requested, ";
+        *fLog << num << " are available... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The histograms are filled with log10 of the energy for triggered
+// events and weighted with 1/E because it is needed the dN/dE vs. logE
+// distribution to get the energy threshold.
+//
+Bool_t MMcThresholdCalc::Process()
+{
+    const Float_t energy   = fMcEvt->GetEnergy();
+    const Float_t lg10     = log10(energy);
+    const Float_t reciproc = 1./energy;
+
+    for (UInt_t i=0; i<fNum; i++)
+        if (GetTrig(i)->GetFirstLevel()>0)
+            GetHEnergy(i)->Fill(lg10, reciproc);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// fit the energy distribution to get the threshold
+// Some iterations are done to be sure the fit parameters converge.
+//
+Bool_t MMcThresholdCalc::PostProcess()
+{
+    for (UInt_t i=0; i<fNum; i++)
+    {
+        MHMcEnergy &hist = *GetHEnergy(i);
+
+        Float_t peak;
+        Float_t sigma;
+
+        hist.Fit(1, 3);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - 2.   *sigma, peak + 2.   *sigma);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
+
+        hist.SetReadyToSave();
+    }
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 1638)
@@ -0,0 +1,57 @@
+#ifndef MARS_MMcThresholdCalc
+#define MARS_MMcThresholdCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MMcThresholdCalc                                                        //
+//                                                                         //
+// Compute the energy threshold from Monte Carlo data                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef ROOT_TObjArray
+#include "TObjArray.h"
+#endif
+
+class MMcEvt;
+class MMcTrig;
+class MHMcEnergy;
+
+class MMcThresholdCalc : public MTask
+{
+private:
+    UInt_t fFirst;
+    UInt_t fLast;
+
+    UInt_t fNum;
+
+    const MMcEvt  *fMcEvt;       // Container with Monte Carlo information
+
+    TObjArray    *fMcTrig;       // Container with Monte Carlo trigger information
+    TObjArray    *fEnergy;       // Container where we save the energy (threshold)
+
+    const static Float_t fSqrt2; // sqrt(2)
+
+    MMcTrig    *GetTrig   (UInt_t i) { return (MMcTrig*)   (*fMcTrig)[i]; }
+    MHMcEnergy *GetHEnergy(UInt_t i) { return (MHMcEnergy*)(*fEnergy)[i]; }
+
+public:
+
+    MMcThresholdCalc(const Int_t dim = 0,
+                     const char* name = NULL, const char* title = NULL);
+    ~MMcThresholdCalc();
+
+    Bool_t PreProcess(MParList* pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MMcThresholdCalc, 0) // Task to compute the energy threshold
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 1638)
@@ -0,0 +1,91 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MMcTimeGenerate.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTime.h"
+
+ClassImp(MMcTimeGenerate);
+
+// --------------------------------------------------------------------------
+//
+MMcTimeGenerate::MMcTimeGenerate(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcTimeGenerate";
+    fTitle = title ? title : "Task to generate a random event time";
+
+    const Double_t lambda = 100; // [Hz]
+
+    fFunc = new TF1("Poisson", "[0] * exp(-[0]*x)", 0, 1);
+    fFunc->SetParameter(0, lambda);
+
+    fDeadTime = 0.1/lambda;
+}
+
+MMcTimeGenerate::~MMcTimeGenerate()
+{
+    delete fFunc;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  The PreProcess connects the raw data with this task. It checks if the 
+//  input containers exist, if not a kFalse flag is returned. It also checks
+//  if the output contaniers exist, if not they are created.
+//  This task can read either Montecarlo files with multiple trigger
+//  options, either Montecarlo files with a single trigger option.
+//
+Bool_t MMcTimeGenerate::PreProcess (MParList *pList)
+{
+    // connect the raw data with this task
+
+    fTime = (MTime*)pList->FindCreateObj("MTime");
+    if (!fTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MMcTimeGenerate::Process()
+{
+    Double_t dt;
+
+    do dt = fFunc->GetRandom();
+    while (dt < fDeadTime);
+
+    const UInt_t t = fTime->GetTimeLo();
+
+    fTime->SetTime(t+dt*10000, 0); // [0.1ms]
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 1638)
@@ -0,0 +1,33 @@
+#ifndef MARS_MMcTimeGenerate
+#define MARS_MMcTimeGenerate
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef ROOT_TF1
+#include "TF1.h"
+#endif
+
+class MParList;
+class MTime;
+
+class MMcTimeGenerate : public MTask
+{
+private:
+    MTime    *fTime;        //!
+    TF1      *fFunc;        //!
+
+    Double_t fDeadTime;
+
+public:
+    MMcTimeGenerate(const char *name=NULL, const char *title=NULL);
+
+    ~MMcTimeGenerate();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MMcTimeGenerate, 0) // To generate a random time
+};
+
+#endif 
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 1638)
@@ -0,0 +1,241 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!   Modified 4/7/2002 Abelardo Moralejo: now the dimension of fTrigger is
+!    set dinamically, to allow an arbitrary large number of trigger 
+!    conditions to be processed.
+!
+!
+\* ======================================================================== */
+
+#include "MMcTriggerRateCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MHMcRate.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+
+ClassImp(MMcTriggerRateCalc);
+
+void MMcTriggerRateCalc::Init(int dim, int part, float *trigbg,
+                              float simbg,
+                              const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcTriggerRateCalc";
+    fTitle = title ? title : "Task to calc the trigger rate ";
+
+    fMcTrig = NULL;
+    fMcRate = NULL;
+
+    fShowers = 0;
+    fAnalShow = simbg;
+
+    fPartId=part;
+
+    fFirst = dim>0 ?   1 : -dim;
+    fLast  = dim>0 ? dim : -dim;
+
+    fNum = fLast-fFirst+1;
+
+    fTrigger = new float[fNum];
+
+    for (UInt_t i=0;i<fNum;i++)
+        fTrigger[i] = dim&&trigbg ? trigbg[i] : 0;
+
+    AddToBranchList("MMcEvt.fImpact");
+    AddToBranchList("MMcEvt.fEnergy");
+    AddToBranchList("MMcEvt.fPhi");
+    AddToBranchList("MMcEvt.fTheta");
+    AddToBranchList("MMcEvt.fPhotElfromShower");
+    AddToBranchList("MMcTrig", "fNumFirstLevel", fFirst, fLast);
+}
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor I
+//
+//      dim:     fDimension
+//      part:    fPartId
+//      *trigbg: number of shower from bacground that triggers
+//               a given trigger condition.
+//      simbg:   Number of simulated showers for the background
+//      rate:    rate of incident showers
+//
+
+MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim, int part,
+                                       float *trigbg, float simbg,
+                                       const char *name, const char *title)
+{
+    Init(dim, part, trigbg, simbg, name, title);
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor II
+//
+//      dim:     fDimension
+//      part:    fPartId
+//      *trigbg: number of shower from bacground that triggers
+//               a given trigger condition.
+//      simbg:   Number of simulated showers for the background
+//
+MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, int part, float *trigbg,
+                                       float simbg,
+                                       const char *name, const char *title)
+{
+    Init(dim, part, trigbg, simbg, name, title);
+}
+
+MMcTriggerRateCalc::~MMcTriggerRateCalc()
+{
+    if (fMcTrig)
+        delete fMcTrig;
+
+    if (fMcRate)
+        delete fMcRate;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  The PreProcess connects the raw data with this task. It checks if the 
+//  input containers exist, if not a kFalse flag is returned. It also checks
+//  if the output contaniers exist, if not they are created.
+//  This task can read either Montecarlo files with multiple trigger
+//  options, either Montecarlo files with a single trigger option.
+//
+Bool_t MMcTriggerRateCalc::PreProcess (MParList *pList)
+{
+    // connect the raw data with this task
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    UInt_t num;
+
+    fMcTrig = new TObjArray(pList->FindObjectList("MMcTrig", fFirst, fLast));
+    num = fMcTrig->GetEntriesFast();
+    if (num != fNum)
+    {
+        *fLog << err << dbginf << fNum << " MMcTrig objects requested, ";
+        *fLog << num << " are available... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcRate = new TObjArray(pList->FindObjectList("MHMcRate", fFirst, fLast));
+    num = fMcRate->GetEntriesFast();
+    if (num != fNum)
+    {
+        *fLog << err << dbginf << fNum << " MHMcRate objects requested, ";
+        *fLog << num << " are available... aborting." << endl;
+        return kFALSE;
+    }
+
+    for (UInt_t i=0; i<fNum; i++)
+    {
+        MHMcRate &rate = *GetRate(i);
+
+        rate.SetParticle(fPartId);
+        switch (fPartId)
+        {
+        case kPROTON:
+            rate.SetFlux(0.1091, 2.75);
+            break;
+        case kHELIUM:
+            rate.SetFlux(0.0660, 2.62);
+            break;
+        default:
+	    *fLog << err << dbginf << "Unknown incident flux parameters for ";
+	    *fLog << fPartId<< " particle Id ... aborting." << endl;
+	    return kFALSE;
+	}
+        rate.SetBackground(fTrigger[i], fAnalShow);
+
+        fTrigger[i]=0;
+    }
+
+    fAnalShow=0.0;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The Process-function counts the number of simulated showers, the
+//  number of analised showers and the number of triggers. It also updates
+//  the limits for theta, phi, energy and impact parameter in the
+//  MHMcRate container.
+//
+Bool_t MMcTriggerRateCalc::Process()
+{
+    //
+    //  Counting analysed and simulated showers
+    //
+    fShowers++;
+    if (fMcEvt->GetPhotElfromShower())
+        fAnalShow++;
+
+    //
+    //  Getting angles, energy and impact parameter to set boundaries
+    //
+    const Float_t theta = fMcEvt->GetTheta();
+    const Float_t phi   = fMcEvt->GetPhi();
+    const Float_t param = fMcEvt->GetImpact();
+    const Float_t ener  = fMcEvt->GetEnergy()/1000.0;
+
+    //
+    //  Counting number of triggers
+    //
+    for (UInt_t i=0; i<fNum; i++)
+    {
+	if (GetTrig(i)->GetFirstLevel())
+	    fTrigger[i] ++; 
+
+        GetRate(i)->UpdateBoundaries(ener, theta, phi, param);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The PostProcess-function calculates and shows the trigger rate
+//
+Bool_t MMcTriggerRateCalc::PostProcess()
+{
+    //
+    // Computing trigger rate
+    //
+    for (UInt_t i=0; i<fNum; i++)
+        GetRate(i)->CalcRate(fTrigger[i], fAnalShow, fShowers);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 1638)
@@ -0,0 +1,59 @@
+#ifndef MARS_MMcTriggerRateCalc
+#define MARS_MMcTriggerRateCalc
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+class MMcEvt;
+class MMcTrig;
+class MHMcRate;
+
+class MMcTriggerRateCalc : public MTask
+{
+private:
+    MMcEvt    *fMcEvt;        //!
+
+    TObjArray *fMcRate;
+    TObjArray *fMcTrig;
+
+    UInt_t     fNum;           // decoded dimension
+    UInt_t     fFirst;
+    UInt_t     fLast;
+
+    Float_t*    fTrigger;   // Number of triggered showers
+
+    Float_t    fShowers;       // Number of simulated showers
+    Float_t    fAnalShow;      // Number of analysed showers
+
+    Int_t      fPartId;        // Incident particle that generates showers
+
+    void Init(int dim, int part, float *trigbg,
+              float simbg, const char *name, const char *title);
+
+    MHMcRate *GetRate(UInt_t i) const { return (MHMcRate*)((*fMcRate)[i]); }
+    MMcTrig  *GetTrig(UInt_t i) const { return (MMcTrig*)((*fMcTrig)[i]); }
+
+public:
+    MMcTriggerRateCalc(int dim=0, int part=14, float *trigbg=NULL,
+                       float simbg=100000,
+                       const char *name=NULL, const char *title=NULL);
+
+    MMcTriggerRateCalc(float rate, int dim, int part, float *trigbg,
+                       float simbg,
+                       const char *name=NULL, const char *title=NULL);
+
+    ~MMcTriggerRateCalc();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MMcTriggerRateCalc, 0)	// Task to compute the trigger rate
+};
+
+#endif 
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/Makefile	(revision 1638)
@@ -0,0 +1,50 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = MonteCarlo
+
+#
+# Library name to creatre
+#
+LIB   = mmontecarlo.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mmc -I../mhist
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MMcCollectionAreaCalc.cc \
+	   MMcThresholdCalc.cc \
+           MMcTimeGenerate.cc \
+	   MMcTriggerRateCalc.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o)
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 1638)
@@ -0,0 +1,12 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MMcThresholdCalc+;
+#pragma link C++ class MMcTimeGenerate+;
+#pragma link C++ class MMcCollectionAreaCalc+;
+#pragma link C++ class MMcTriggerRateCalc+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.cc	(revision 1638)
@@ -0,0 +1,119 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRawCrateArray
+//
+//  This class exists to make it possible to read in the crate data
+//  TClones Array. In principal we can directly write the TClonesArray
+//  to the root file, but when we read in again the root file we cannot
+//  put the TClonesArray into our parameter list, becaus it isn't derived
+//  from MParContainer. This class is derived from MParContainer and can be
+//  put in the list. The TClones Array containes conatiners which store
+//  the information about one crate (MRawCrateData).
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRawCrateArray.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MRawCrateData.h"
+
+ClassImp(MRawCrateArray);
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor. It creates the TClonesArray which is used to store
+//  the crate data.
+//
+MRawCrateArray::MRawCrateArray(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRawCrateArray";
+    fTitle = title ? title : "Array of MRawCrateData Information";
+
+    //
+    // craete an (almost) empty array. The size is easily determined
+    // while filling the array
+    //
+    fArray = new TClonesArray("MRawCrateData", 0);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. Deletes the TClones Array which stores the crate information
+//
+MRawCrateArray::~MRawCrateArray()
+{
+    //  FIXME: Is the contained data deleted, too?
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// clear the entries in the TClonesArray
+//
+void MRawCrateArray::Clear(Option_t *opt)
+{
+    fArray->Clear();
+}
+
+void MRawCrateArray::SetSize(Int_t i)
+{
+    if (fArray->GetEntriesFast() == i)
+        return;
+
+    fArray->ExpandCreateFast(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a pointer the i-th entry in the array, without range check
+//
+MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
+{
+    return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the i-th entry in the array, with range check
+//
+MRawCrateData* &MRawCrateArray::operator[](Int_t i)
+{
+    return (MRawCrateData*&)(*fArray)[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// return a pointer to the pointer of the array
+// (actually not used. You may need it if you want to write
+//  the TClonesArray directly)
+//
+TClonesArray **MRawCrateArray::GetArray()
+{
+    return &fArray;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateArray.h	(revision 1638)
@@ -0,0 +1,37 @@
+#ifndef MARS_MRawCrateArray
+#define MARS_MRawCrateArray
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MRunHeader                                                        //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TClonesArray;
+class MRawCrateData;
+
+class MRawCrateArray : public MParContainer
+{
+private:
+    TClonesArray *fArray;
+
+public:
+    MRawCrateArray(const char *name=NULL, const char *title=NULL);
+    ~MRawCrateArray();
+
+    void Clear(Option_t *opt=NULL);
+
+    void SetSize(Int_t i);
+    MRawCrateData *GetEntry(Int_t i);
+
+    MRawCrateData* &operator[](Int_t i);
+
+    TClonesArray **GetArray();
+
+    ClassDef(MRawCrateArray, 1)	// Mapping container for the MRawCrateData TClonesArray
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.cc	(revision 1638)
@@ -0,0 +1,71 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRawCrateData
+//
+//  This container stores the information about one crate. A list of this
+//  informations can be find at MRawCrateArray
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRawCrateData.h"
+
+#include <iostream.h>
+#include <iomanip.h>
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MRawCrateData);
+
+MRawCrateData::MRawCrateData() : fDAQCrateNumber(0), fFADCEvtNumber(0), fFADCClockTick(0)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+//  read the information from a binary input stream about the CRATE DATA,
+//  like specified in a TDAS note
+//
+void MRawCrateData::ReadEvt(istream& fin)
+{
+    fin.read((Byte_t*)&fDAQCrateNumber, 2);
+    fin.read((Byte_t*)&fFADCEvtNumber,  4);
+    fin.read((Byte_t*)&fFADCClockTick,  4);
+}
+
+// --------------------------------------------------------------------------
+//
+//  print all stored information to gLog
+//
+void MRawCrateData::Print(Option_t *t) const
+{
+    *fLog << all;
+    *fLog << "Crate Number " << fDAQCrateNumber << ":  ";
+    *fLog << "FADCEventNr=" << fFADCEvtNumber << "  ";
+    *fLog << "FADCClockTick=" << fFADCClockTick << " (20MHz)" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawCrateData.h	(revision 1638)
@@ -0,0 +1,31 @@
+#ifndef MARS_MRawCrateData
+#define MARS_MRawCrateData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class ifstream;
+
+class MRawCrateData : public MParContainer
+{
+private:
+    UShort_t fDAQCrateNumber;  // Crate number the information corresponds to
+    UInt_t   fFADCEvtNumber;   // event number from the fadc
+    UInt_t   fFADCClockTick;   // clock tick from the fadc (20MHz)
+
+public:
+    MRawCrateData();
+
+    UChar_t GetDAQCrateNumber() const  { return fDAQCrateNumber; }
+    UInt_t  GetFADCEvtNumber() const   { return fFADCEvtNumber;  }
+    UInt_t  GetFADCClockTick() const   { return fFADCClockTick;  }
+
+    void Print(Option_t *t=NULL) const;
+
+    void ReadEvt(istream& fin);
+
+    ClassDef(MRawCrateData, 1) //Container to store the Raw CRATE DATA
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.cc	(revision 1638)
@@ -0,0 +1,447 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRawEvtData
+//
+//  Storage container to store the raw FADC values.
+//
+//  MArrayS fHiGainPixId
+//  ---------------------
+//  Array of Pixel Numbers for their high voltage channel in the order the
+//  FADC values are stored in fHiGainFadcSamples
+//
+//  MArrayB fHiGainFadcSaples
+//  -------------------------
+//  FADC samples (hi gain) of all pixels
+//
+//  MArrayS fLoGainPixId
+//  --------------------
+//  see fHiGainPixId
+//
+//  MArrayB fLoGainFadcSamples
+//  --------------------------
+//  see fHiGainFadcSaples
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MRawEvtData.h"
+
+#include <fstream.h>
+
+#include <TH1.h>
+#include <TGraph.h>
+#include <TArrayC.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArrayS.h"
+#include "MArrayB.h"
+#include "MRawRunHeader.h"
+
+ClassImp(MRawEvtData);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It initializes all arrays with zero size.
+//
+MRawEvtData::MRawEvtData(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRawEvtData";
+    fTitle = title ? title : "Raw Event Data Information";
+
+    InitArrays();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes all the arrays.
+//
+MRawEvtData::~MRawEvtData()
+{
+    DeleteArrays();
+}
+
+// --------------------------------------------------------------------------
+//
+// reset all arrays
+//
+void MRawEvtData::Clear(Option_t *)
+{
+    /*
+     FIXME:
+     Is Reset (set all entries to zero) what you want to do
+     or Set(0) (delete the array)
+     */
+    fHiGainPixId->Reset();
+    fLoGainPixId->Reset();
+    fHiGainFadcSamples->Reset();
+    fLoGainFadcSamples->Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of hi gain samples per pixel
+//
+Byte_t MRawEvtData::GetNumHiGainSamples() const
+{
+    return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/fHiGainPixId->GetSize() : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of lo gain samples per pixel
+//
+Byte_t MRawEvtData::GetNumLoGainSamples() const
+{
+    return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/fLoGainPixId->GetSize() : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of stored pixel
+//
+UShort_t MRawEvtData::GetNumPixels() const
+{
+    return fHiGainPixId->GetSize();
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  Print out the onformation to *fLog.
+//  Options:
+//     "hex"      Prints the time slices hexadecimal (default)
+//     "dec"      Prints the time slices decimal
+//
+void MRawEvtData::Print(Option_t *opt) const
+{
+    //
+    // print fadc inforation to screen
+    // Possible Options:
+    // - DEC: Print values decimal instead of hexadecimal (default)
+    //
+    const Byte_t nHiSamp = GetNumHiGainSamples();
+    const Byte_t nLoSamp = GetNumLoGainSamples();
+
+    const UShort_t nHiPix = fHiGainPixId->GetSize();;
+    const UShort_t nLoPix = fLoGainPixId->GetSize();;
+
+    fLog->unsetf(ios::showbase);
+
+    *fLog << dec << all;
+    *fLog << "HiGain: " << nHiPix << " Pixels with " << (Int_t)nHiSamp << " Samples" << endl;
+    *fLog << "LoGain: " << nLoPix << " Pixels with " << (Int_t)nLoSamp << " Samples";;
+
+    TString str(opt);
+    Int_t manip = str.Contains("dec", TString::kIgnoreCase);
+
+    Int_t l=0;
+    for (int i=0; i<nHiPix; i++)
+    {
+        *fLog << endl;
+        *fLog << " " << setfill(' ') << setw(3) << dec << i << ": ";
+        *fLog << (manip?dec:hex) << flush;
+
+        if (!manip)
+            *fLog << setfill('0');
+
+        for (int j=0; j<nHiSamp; j++)
+        {
+            *fLog << setw(manip?3:2);
+            *fLog << ((UShort_t)(*fHiGainFadcSamples)[j+i*nHiSamp]&0xff);
+            if (manip)
+                *fLog << ' ';
+            *fLog << flush;
+        }
+
+        if (!(l<nLoPix && (*fLoGainPixId)[l]==(*fHiGainPixId)[i]))
+            continue;
+
+        if (manip)
+            *fLog << "/ ";
+
+        for (int j=0; j<nLoSamp; j++)
+        {
+            *fLog << setw(manip?3:2);
+            *fLog << ((UShort_t)(*fLoGainFadcSamples)[j+i*nLoSamp]&0xff);
+            if (manip)
+                *fLog << ' ';
+            *fLog << flush;
+        }
+        l++;
+    }
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a pixel. A Histogram or Graph is created and it's draw function is
+// called.
+//  Options:
+//     "GRAPH"      A graph is drawn
+//     "HIST"       A histogram is drawn
+//     number       The pixel with the given number is drawn
+//
+void MRawEvtData::Draw(Option_t *opt)
+{
+    if (GetNumPixels()==0)
+    {
+        *fLog << warn << "Sorry, no pixel to draw!" << endl;
+        return;
+    }
+
+    TString str(opt);
+
+    UInt_t num = 0;
+
+    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
+    {
+        if (str.Length()>5)
+            sscanf(&str[5], "%d", &num);
+
+        if (num>=GetNumPixels())
+            num= GetNumPixels();
+
+        *fLog << inf << "Drawing Graph: Pixel #" << num << " of " << (int)GetNumPixels() << endl;
+
+        const Int_t n = GetNumHiGainSamples();
+
+        Float_t *x = new Float_t[n];
+        Float_t *y = new Float_t[n];
+
+        for (int i=0; i<n; i++)
+        {
+            x[i] = i;
+            y[i] = (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()];
+        }
+
+        TGraph *graph = new TGraph(n, x, y);
+        graph->SetMaximum(256);
+        graph->SetMinimum(0);
+
+        graph->SetBit(kCanDelete);
+        graph->Draw("AC*");
+
+        TH1F *hist = graph->GetHistogram();
+
+        hist->SetXTitle("Time/FADC Slices");
+        hist->SetYTitle("Signal/FADC Units");
+
+        return;
+    }
+
+    if (str.BeginsWith("HIST", TString::kIgnoreCase))
+    {
+        *fLog << "Length: " << str.Length() << endl;
+
+        if (str.Length()>4)
+            sscanf(&str[4], "%d", &num);
+
+        if (num>=GetNumPixels())
+            num= GetNumPixels();
+
+        *fLog << "Drawing Histogram of Pixel " << num << endl;
+
+        const Int_t n = GetNumHiGainSamples();
+
+        char *name = new char[16];
+
+        sprintf(name, "Pixel No.%d", (*fHiGainPixId)[num]);
+
+        TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n);
+        hist->SetXTitle("Time/FADC Slices");
+        hist->SetYTitle("Signal/FADC Units");
+
+        for (int i=0; i<n; i++)
+            hist->Fill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]);
+
+        hist->SetBit(kCanDelete);
+        hist->Draw();
+
+        return;
+    }
+
+    *fLog << warn << dbginf << "Warning - You must specify either 'GRAPH' or 'HIST'" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes all arrays describing the pixel Id and Samples in pixels.
+// The flag is for future usage.
+//
+void MRawEvtData::DeletePixels(Bool_t flag)
+{
+    if (fRunHeader && flag)
+    {
+        const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
+
+        if (fArraySize == npix)
+        {
+            fPosInArray = 0;
+            return;
+        }
+    }
+
+    DeleteArrays();
+    InitArrays(flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all the arrays
+//
+void MRawEvtData::DeleteArrays()
+{
+    delete fHiGainPixId;
+    delete fLoGainPixId;
+    delete fHiGainFadcSamples;
+    delete fLoGainFadcSamples;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all the arrays
+//  The flag is for future usage.
+//
+void MRawEvtData::InitArrays(Bool_t flag)
+{
+    if (flag && fRunHeader)
+    {
+        const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
+
+        fHiGainPixId       = new MArrayS(npix);
+        fLoGainPixId       = new MArrayS(npix);
+        fHiGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesHiGain());
+        fLoGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesLoGain());
+
+        fArraySize  = npix;
+    }
+    else
+    {
+        fHiGainPixId       = new MArrayS(0);
+        fLoGainPixId       = new MArrayS(0);
+        fHiGainFadcSamples = new MArrayB(0);
+        fLoGainFadcSamples = new MArrayB(0);
+
+        fArraySize = 0;
+    }
+
+    fPosInArray = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This is to fill the data of one pixel to the MRawEvtHeader Class.
+//  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
+//  Add to lo gains if lflag = 1
+//
+void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag)
+{
+    MArrayS *arrpix = lflag ? fLoGainPixId       : fHiGainPixId;
+    MArrayB *arrsam = lflag ? fLoGainFadcSamples : fHiGainFadcSamples;
+
+    //
+    // check whether we got the right number of new samples
+    // if there are no samples already stored: this is the new number of samples
+    //
+    const Byte_t ns    = data->GetSize();
+    const Byte_t nSamp = lflag ? GetNumLoGainSamples() : GetNumHiGainSamples();
+    if (nSamp && ns!=nSamp)
+    {
+        *fLog << err << "RawEvtData::AddPixel: Error, number of samples in ";
+        *fLog << "TArrayC doesn't match actual number" << endl;
+        return;
+    }
+
+    //
+    // enhance pixel array by one
+    //
+    arrpix->Set(arrpix->GetSize()+1);
+
+    //
+    // add the number of the new pixel to the array as last entry
+    //
+    arrpix->AddAt(nOfPixel, arrpix->GetSize()-1);
+
+    //
+    // enhance the array by the number of new samples
+    //
+    arrsam->Set(arrsam->GetSize()+ns);
+
+    //
+    // add the new slices as last entries to array
+    //
+    arrsam->AddAt((Byte_t*)data->GetArray(), arrsam->GetSize()-ns, ns);
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills members with information from a magic binary file.
+//   WARNING: you have to use Init() before you can do this
+//
+void MRawEvtData::ReadEvt(istream &fin)
+{
+    const UShort_t nlo = fRunHeader->GetNumSamplesLoGain();
+    const UShort_t nhi = fRunHeader->GetNumSamplesHiGain();
+
+    const UShort_t npic = fRunHeader->GetNumPixInCrate();
+
+    const UShort_t npos = npic*fPosInArray;
+
+    Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nhi*npos;
+    Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nlo*npos;
+
+    // UShort_t *hipixid = (UShort_t*)fHiGainPixId->GetArray()+npos;
+    // UShort_t *lopixid = (UShort_t*)fLoGainPixId->GetArray()+npos;
+
+    for (int i=0; i<npic; i++)
+    {
+        //
+        // get the spiral pixel number from the run header
+        //
+        const UShort_t npix = fRunHeader->GetPixAssignment(i);
+
+        const UShort_t ipos = npos+i;
+        //
+        //  This is to fill the data of one pixel to the MRawEvtHeader Class.
+        //  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
+        //  Add to lo gains if lflag = 1
+        //
+        fHiGainPixId->AddAt(npix, ipos);
+        fin.read(higainsam, nhi);
+        higainsam += nhi;
+
+        // FIXME: Not implemented in the raw files yet
+        //if (IsLoGainOn(i, j))
+        //{
+        fLoGainPixId->AddAt(npix, ipos);
+        fin.read(logainsam, nlo);
+        logainsam += nlo;
+        //}
+    }
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtData.h	(revision 1638)
@@ -0,0 +1,65 @@
+#ifndef MARS_MRawEvtData
+#define MARS_MRawEvtData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class ifstream;
+class MRawRunHeader;
+
+class TArrayC;
+class MArrayS;
+class MArrayB;
+
+class MRawEvtData : public MParContainer
+{
+    friend class MRawEvtPixelIter;
+private:
+    MRawRunHeader *fRunHeader;    //! provides information about numbers
+
+    // FIXME: COMMENT ABOUT ORDERING
+
+    MArrayS *fHiGainPixId;        // list of pixel IDs of hi gain channel
+    MArrayB *fHiGainFadcSamples;  // list of hi gain samples of all pixels (ordering: see fHiGainPixId)
+
+    MArrayS *fLoGainPixId;        // list of pixel IDs of lo gain channel
+    MArrayB *fLoGainFadcSamples;  // list of lo gain samples of all pixels (ordering: see fLoGainPixId)
+
+    Int_t fPosInArray;   //!
+    Int_t fArraySize;    //!
+
+    void InitArrays(Bool_t flag=kFALSE);
+    void DeleteArrays();
+
+public:
+    MRawEvtData(const char *name=NULL, const char *title=NULL);
+    ~MRawEvtData();
+
+    void Init(MRawRunHeader *rh)
+    {
+        //
+        // you have to set this before you can read information
+        // from a magic binary file
+        //
+        fRunHeader = rh;
+    }
+
+    void Clear(Option_t * = NULL);
+    void Print(Option_t * = NULL) const;
+    void Draw (Option_t * = NULL);
+
+    void DeletePixels(Bool_t flag=kFALSE);
+    void ResetPixels() { DeletePixels(kTRUE); }
+    void AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag=kFALSE);
+
+    Byte_t   GetNumHiGainSamples() const;
+    Byte_t   GetNumLoGainSamples() const;
+    UShort_t GetNumPixels() const;
+
+    void ReadEvt(istream &fin);
+
+    ClassDef(MRawEvtData, 1) //Container to store the raw Event Data
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.cc	(revision 1638)
@@ -0,0 +1,265 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRawEvtHeader 
+//    
+// One Event is a sample of FADC measurements of different Pixels 
+// (Photomultipliers) from the Camera of MAGIC. So all data (FADC) of the 
+// interesting pixels are the modules of an event. To describe pixels the 
+// class MRawPixel is used and the class MRawCrate to describe Crates.
+// To define a single events some other data members are needed 
+// (Time of the events, tirgger pattern of event..)
+// 
+// To describe one event on the level of FADC values the Class MRawEvtHeader is
+// created. It has the following data members: 
+//
+// UInt_t    fDAQEvtNumber
+// -----------------------
+// This it the number of the Event in one 
+// data run. The first event in this run get
+// the number zero. The next one is one bigger.
+//
+// Assuming that one run takes 1 hour and a
+// triggerrate of 1kHz the number must be able
+// to reach 3.6e6 Events. To reach this number
+// you need at least 22 bits. This is the reason
+// why we use an integer (of root type UInt_t)
+// with a range to 4.2e9. 
+//
+// MTime   fRawEvtTime
+// -------------------
+// Time of the event. 
+// The start point of the time determination can be
+// the millenium. From that start point the time is
+// measured in 200ns-count. One day for example
+// contains 432.e9 counts. An array of two unsigned Int is able to 
+// contain 1.8e19 200ns-counts. This corresponds to 41.e6
+// days. This should be more than the livetime of MAGIC.
+// Private member of MTime.h
+//
+// UInt_t  fNumTrigLvl1
+// --------------------
+//
+// Number of first level trigger
+// This member counts the number of First Level Trigger
+// between the last and this event. May be that due to 
+// dead time of the DAQ this number is different from 1.
+// If the DAQ is fast enough, this value should be 1. 
+// This may be usefull in GammaRayBursts and if we 
+// apply a data reduction in the DAQ-chain, which selects
+// only good events. 
+//
+// UInt_t  fNumTrigLvl2
+// ------------------ -
+//
+// Number of second level trigger
+// This member counts the number of Second Level Trigger
+// between the last and this event. 
+//
+// UInt_t  fTrigPattern[2]
+// -----------------------
+// Trigger Pattern used for this event
+// Each event triggers for a particular configuration and each  
+// configuration shoul have an ID (which is not fixed yet).
+//
+// UShort_t fAllLowGainOn
+// ----------------------
+// Type of Trigger. 
+// This is a Byte (8 bit) to indicated if any of the pixels 
+// have a non-negligible low gain (1) or not (0) 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRawEvtHeader.h"
+
+#include <iomanip.h>
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MArrayB.h"
+#include "MRawRunHeader.h"
+
+ClassImp(MRawEvtHeader);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Create the array to store the data.
+//
+MRawEvtHeader::MRawEvtHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRawEvtHeader";
+    fTitle = title ? title : "Raw Event Header Information";
+
+    //
+    //   set all member to zero, init the pointer to ClonesArray,
+    //
+    fPixLoGainOn = new MArrayB;
+
+    Clear();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the array to store pixlogainon
+//
+MRawEvtHeader::~MRawEvtHeader()
+{
+    delete fPixLoGainOn;
+}
+
+// --------------------------------------------------------------------------
+//
+// you have to init the conatainer before you can read from
+// a raw binary file
+//
+void MRawEvtHeader::Init(MRawRunHeader *rh, MTime *t)
+{
+    //
+    // this is the number of entries in the array like specification
+    //
+    UInt_t fN = (rh->GetNumCrates() * rh->GetNumPixInCrate() + 7) / 8;
+
+    //
+    // initialize the array
+    //
+    fPixLoGainOn->Set(fN);
+
+    //
+    // this is the conatiner where we have to store the time of the event we
+    // read from the input stream
+    //
+    fTime = t;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Implementation of the Clear function
+//
+//   Resets all members to zero, clear the list of Pixels
+//
+void MRawEvtHeader::Clear(Option_t *)
+{
+    fDAQEvtNumber   = 0;
+    fNumTrigLvl1    = 0;
+    fNumTrigLvl2    = 0;
+    fTrigPattern[0] = 0;
+    fTrigPattern[1] = 0;
+    fTrigType       = 0;
+    fNumLoGainOn    = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This member function prints all Data of one Event to *fLog.
+//
+void MRawEvtHeader::Print(Option_t *o) const
+{
+    *fLog << all;
+    *fLog << "DAQEvtNr: " << dec << fDAQEvtNumber << "  (";
+    *fLog << "Trigger: ";
+    *fLog << "NumLvl1=" << fNumTrigLvl1 << " ";
+    *fLog << "NumLvl2=" << fNumTrigLvl2 << " ";
+    *fLog << "Pattern=" << hex << setfill('0');
+    *fLog << setw(2) << fTrigPattern[0];
+    *fLog << setw(2) << fTrigPattern[1] << " " << dec;
+
+    *fLog << "Type=";
+    switch (fTrigType)
+    {
+    case 0:
+        *fLog << "Trigger";
+        break;
+    case 1:
+        *fLog << "Pedestal";
+        break;
+    case 2:
+        *fLog << "Calibration";
+        break;
+    }
+    *fLog << ")" << endl;
+    *fLog << "Number of Lo Gains On: " << fNumLoGainOn << endl;
+
+    for (unsigned int i=0; i<fPixLoGainOn->GetSize(); i++)
+    {
+        for (int j=0; j<8; j++)
+        {
+            const UInt_t on = (*fPixLoGainOn)[i]&(1<<j) ? 1 : 0;
+            *fLog << on;
+        }
+    }
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// used to set the header information (eg. from MC)
+//
+void MRawEvtHeader::FillHeader(UInt_t uiN, Float_t ulTP)
+{
+    fDAQEvtNumber = uiN;
+    fTrigPattern[0] = (UInt_t) (ulTP/4294967296.0) ;
+    fTrigPattern[1] = (UInt_t) (ulTP-fTrigPattern[0]*4294967296.0);
+}
+
+// --------------------------------------------------------------------------
+//
+// read the EVENT HEADER information from the input stream
+// return FALSE if there is now header anymore, else TRUE
+//
+int MRawEvtHeader::ReadEvt(istream &fin)
+{
+    fin.read((Byte_t*)&fDAQEvtNumber, 4);
+
+    UInt_t fAbsTime[2];
+    fin.read((Byte_t*)fAbsTime,       8);
+
+    //
+    // store the time of the event in the corresponding container
+    //
+    fTime->SetTime(fAbsTime[0], fAbsTime[1]);
+
+    Byte_t dummy[4];
+
+    fin.read((Byte_t*)&fNumTrigLvl1,  4);
+    fin.read((Byte_t*)&fNumTrigLvl2,  4);
+    fin.read((Byte_t*)fTrigPattern,   8);
+    fin.read((Byte_t*)&fTrigType,     2);
+    fin.read((Byte_t*)dummy,          2); // was fAllLoGainOn
+    fin.read((Byte_t*)fPixLoGainOn->GetArray(), fPixLoGainOn->GetSize());
+
+    fNumLoGainOn = 0;
+    for (unsigned int i=0; i<fPixLoGainOn->GetSize(); i++)
+        for (int j=0; j<8; j++)
+            if ((*fPixLoGainOn)[i] & (1<<j))
+                fNumLoGainOn++;
+
+    fin.read((Byte_t*)&dummy, 4);
+
+    return !fin.eof();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtHeader.h	(revision 1638)
@@ -0,0 +1,63 @@
+#ifndef MARS_MRawEvtHeader
+#define MARS_MRawEvtHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class ifstream;
+class MTime;
+class MArrayB;
+class MRawRunHeader;
+
+//
+// Trigger Type (TT)
+//
+enum {
+    kTTEvent       = 0,
+    kTTPedestal    = 1,
+    kTTCalibration = 2
+};
+
+class MRawEvtHeader : public MParContainer
+{
+private:
+    MTime   *fTime;            //! object to store the time in (ReadEvt)
+
+    UInt_t   fDAQEvtNumber;    // Number of Event
+
+    UInt_t   fNumTrigLvl1;     // Number of 1st level tiggers between 2 events
+    UInt_t   fNumTrigLvl2;     // Number of 2nd level tiggers between 2 events
+    UInt_t   fTrigPattern[2];  // Trigger configuration
+
+    UShort_t fNumLoGainOn;     // Indicating if no pixel has a neglegible
+                               // low gain signal (0), else it is the number
+                               // of pixels with lo gain on
+
+    //
+    // Informations only needed to read the raw file correctly
+    //
+    UShort_t fTrigType;        //! Trigger Type of this event
+    MArrayB *fPixLoGainOn;     //! Array which tell you which pixels have lo gain on
+
+public:
+
+    MRawEvtHeader(const char *name=NULL, const char *title=NULL);
+    ~MRawEvtHeader();
+
+    void Init(MRawRunHeader *rh, MTime *t);
+
+    void Clear(Option_t * = NULL);
+    void Print(Option_t * = NULL) const;
+
+    void FillHeader(UInt_t, Float_t=0);
+
+    UShort_t GetTrigType() const { return fTrigType; }
+    UInt_t GetDAQEvtNumber() const { return fDAQEvtNumber; }
+
+    int ReadEvt(istream& fin);
+
+    ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
+}; 
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc	(revision 1638)
@@ -0,0 +1,234 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Markus Gaus 10/2002 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  MRawEvtPixelIter
+//
+//  class to iterate over all pixels of one event.
+//  The calling is similar to a root iterator:
+//  
+//  MRawEvtData *evtdata;            // must be filled with data from somewhere
+//  MRawEvtPixelIter pixel(evtdata); // evtdata: ptr to event you want to iterate
+//
+//  while (pixel.Next())
+//  {
+//     // here you can access the actual time slices by using
+//     //   pixel.GetPixelId();
+//     //   pixel.GetHiGainFadcSamples()[i]; // i is the number of the slice
+//     //   pixel.HasLoGain();               // check if pixel has
+//     //   pixel.GetLoGainFadcSamples()[i]; // i is the number of the slice
+//
+//     // WARNING: Don't acces more time slices than available.
+//     //   Get the numbers by calling: evtdata->GetNum[Lo,Hi]GainSamples()
+//     //   This number is constant for one event
+//  }
+//
+///////////////////////////////////////////////////////////////////////////////
+#include "MRawEvtPixelIter.h"
+
+#include "MRawEvtData.h"
+
+#include "MArrayS.h"
+#include "MArrayB.h"
+
+ClassImp(MRawEvtPixelIter);
+
+MRawEvtPixelIter::MRawEvtPixelIter(MRawEvtData *dat) : fData(dat)
+{
+    fNumHiGainSamples = dat->GetNumHiGainSamples();
+    fNumLoGainSamples = dat->GetNumLoGainSamples();
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the number of stored pixels
+//
+Byte_t MRawEvtPixelIter::GetNumPixels() const
+{
+    return fData->GetNumPixels();
+}
+
+// --------------------------------------------------------------------------
+//
+// It steps to the next pixel. If there is no next pixel NULL is returned.
+// If a next pixel where found, a pointer to the primary given (constructor)
+// data structur is returned.
+//
+MRawEvtData *MRawEvtPixelIter::Next()
+{
+    //
+    // if we are already at the last entry there is no 'next' entry anymore
+    //
+    if (fNumHiGainEntry==fData->fHiGainPixId->GetSize())
+        return NULL;
+
+    //
+    // if we are already at the last entry there is no 'next' entry anymore
+    //
+    if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
+        if (*fHiGainId == *fLoGainId)
+        {
+            //
+            // if higainpixid and logainpixid of the actual pixel are
+            // identical then we have to move the pointer to the next
+            // entry in the lo gains
+            //
+            fNumLoGainEntry++;
+            fLoGainId++;
+            fLoGainPos += fNumLoGainSamples;
+        }
+
+    //
+    // here we have to move the pointer to the next entry in the hi gains
+    //
+    fNumHiGainEntry++;
+    fHiGainId++;
+    fHiGainPos += fNumHiGainSamples;
+
+    //
+    // return a pointer to the 'source' class if we succeed
+    //
+    return fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Reset the iteration. Jump to the first pixel.
+//
+void MRawEvtPixelIter::Reset()
+{
+    //
+    // set counter to zero
+    //
+    fNumLoGainEntry = 0;
+    fNumHiGainEntry = 0;
+
+    //
+    // set pointer to first entry of arrays
+    //
+    fHiGainId   = fData->fHiGainPixId->GetArray()-1;
+    fLoGainId   = fData->fLoGainPixId->GetArray()-1;
+    fHiGainPos  = fData->fHiGainFadcSamples->GetArray()-fNumHiGainSamples;
+    fLoGainPos  = fData->fLoGainFadcSamples->GetArray()-fNumLoGainSamples;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the draw-function of the actual pixel (see MRawEvtData::Draw)
+//
+void MRawEvtPixelIter::Draw(Option_t *t)
+{ 
+    fData->Draw(Form("%s%d", t, *fHiGainId));
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of all hi gain fadc samples of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const
+{
+    //
+    // return the sum of the hi gain samples of the present pixel
+    //
+    Byte_t *ptr = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += *ptr++;
+    while (ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of squares of all hi gain fadc sample of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumSqrHiGainSamples() const
+{
+    //
+    // return the sum of the squares of the hi gain samples of the present pixel
+    //
+    Byte_t *ptr = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += (*ptr)*(*ptr);
+    while (++ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of all lo gain fadc samples of the actual pixel.
+// if no lo gain information is available 0 is returned.
+//
+ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const
+{
+    //
+    // return the sum of the lo gain samples of the present pixel
+    //
+    if (!HasLoGain())
+        return 0;
+
+    Byte_t *ptr = fLoGainPos;
+    const Byte_t *end = ptr + fNumLoGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += *ptr++;
+    while (ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of squares of all hi gain fadc sample of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumSqrLoGainSamples() const
+{
+    //
+    // return the sum of the lo gain samples squares of the present pixel
+    //
+    if (!HasLoGain())
+        return 0;
+
+    Byte_t *ptr = fLoGainPos;
+    const Byte_t *end = ptr + fNumLoGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += (*ptr)*(*ptr);
+    while (++ptr != end);
+
+    return sum;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawEvtPixelIter.h	(revision 1638)
@@ -0,0 +1,109 @@
+#ifndef MARS_MRawEvtPixelIter
+#define MARS_MRawEvtPixelIter
+///////////////////////////////////////////////////////////////////////////////
+//
+//  MRawEvtPixelIter
+//
+//  class to iterate over all pixels of one event.
+//
+///////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+class MRawEvtData;
+
+class MRawEvtPixelIter : public TObject
+{
+private:
+    UShort_t fNumHiGainEntry;   //! actual number of entry in fHiGainPixId
+    UShort_t fNumLoGainEntry;   //! actual number of entry in fLoGainPixId
+
+    UShort_t *fHiGainId;        //! actual entry of fHiGainPixId
+    UShort_t *fLoGainId;        //! actual entry of fLoGainPixId
+
+    Byte_t   *fHiGainPos;       //! pointer to hi-gain samples of actual pixel
+    Byte_t   *fLoGainPos;       //! pointer to lo-gain samples of actual pixel
+
+    UShort_t fNumEntry;
+
+    Byte_t fNumHiGainSamples;   //!
+    Byte_t fNumLoGainSamples;   //!
+
+    MRawEvtData *fData;         //! pointer to object which we are iterating
+
+public:
+    MRawEvtPixelIter(MRawEvtData *dat);
+
+    MRawEvtData *Next();
+
+    Bool_t Jump(UShort_t id)
+    {
+        //
+        // Jump to the pixel with the pixel-id ID
+        // If it doesn't exist return FALSE
+        //
+        Reset();
+        while (Next())
+            if (GetPixelId() == id)
+                return kTRUE;
+        return kFALSE;
+    }
+
+    UShort_t GetPixelId() const
+    {
+        //
+        // return Id of actual pixel
+        //
+        return *fHiGainId;
+    }
+
+    UShort_t GetNumEntry() const
+    {
+        return fNumHiGainEntry;
+    }
+
+    Byte_t GetNumPixels() const;
+
+    Byte_t *GetHiGainSamples() const
+    {
+        //
+        // return a pointer to the fadc samples of the hi gains
+        // WARNING: Don't forget to get the number of valid entries
+        //          (GetNumSamples) to know how many entries of the array
+        //          belong to the actual pixel
+        //
+        return fHiGainPos;
+    }
+
+    ULong_t GetSumHiGainSamples() const;
+    ULong_t GetSumSqrHiGainSamples() const;
+
+    Bool_t HasLoGain() const
+    {
+        //
+        // return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
+        //
+        return *fHiGainId==*fLoGainId;
+    }
+
+    Byte_t *GetLoGainSamples() const
+    {
+        //
+        // return a pointer to the fadc samples of the lo gains if they exist
+        // for the actual pixel, else return zero
+        //
+        return HasLoGain() ? fLoGainPos : NULL;
+    }
+
+    ULong_t GetSumLoGainSamples() const;
+    ULong_t GetSumSqrLoGainSamples() const;
+
+    void Reset();
+
+    void Draw(Option_t *t="GRAPH");
+
+    ClassDef(MRawEvtPixelIter, 0) // iterates over all pixels of one MRawEvtData object
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.cc	(revision 1638)
@@ -0,0 +1,250 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MRawFileRead                                                            //
+//                                                                          //
+//  This tasks reads the raw binary file like specified in the TDAS???      //
+//  and writes the data in the corresponding containers which are           //
+//  either retrieved from the parameter list or created and added.          //
+//                                                                          //
+//  Input Containers:                                                       //
+//   -/-                                                                    //
+//                                                                          //
+//  Output Containers:                                                      //
+//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MRawFileRead.h"
+
+#include <fstream.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MParList.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateData.h"
+#include "MRawCrateArray.h"
+
+ClassImp(MRawFileRead);
+
+
+/*  ----------- please don't delete and don't care about (Thomas) ------------
+#define kBUFSZ 64 //1024*1024*64
+#include <iomanip.h>
+class bifstream : public istream, public streambuf
+{
+private:
+    char fBuffer[kBUFSZ]; //!
+    FILE *fd;
+
+    int sync()
+    {
+        memset(fBuffer, 0, kBUFSZ);
+        return 0; 
+    }
+    int underflow()
+    {
+        int sz=fread(fBuffer, kBUFSZ, 1, fd);
+        //int sz=fread(fBuffer, 1, kBUFSZ, fd);
+        setg(fBuffer, fBuffer, fBuffer+kBUFSZ);
+
+        return sz==1 ? *(unsigned char*)fBuffer : EOF;//EOF;
+        //return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF;
+    }
+public:
+    bifstream(const char *name) : istream(this)
+    {
+        fd = fopen(name, "rb");
+        setbuf(fBuffer, kBUFSZ);
+    }
+};
+*/
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It tries to open the given file.
+//
+MRawFileRead::MRawFileRead(const char *fname, const char *name, const char *title)
+    : fFileName(fname), fIn(NULL)
+{
+    fName  = name  ? name  : "MRawFileRead";
+    fTitle = title ? title : "Read task to read DAQ binary files";
+
+    fIn = new ifstream;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete input stream.
+//
+MRawFileRead::~MRawFileRead()
+{
+    delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess of this task checks for the following containers in the
+// list:
+//   MRawRunHeader <output>   if not found it is created
+//   MRawEvtHeader <output>   if not found it is created
+//   MRawEvtData <output>     if not found it is created
+//   MRawCrateArray <output>  if not found it is created
+//   MRawEvtTime <output>     if not found it is created (MTime)
+//
+// If all containers are found or created the run header is read from the
+// binary file and printed.  If the Magic-Number (file identification)
+// doesn't match we stop the eventloop.
+//
+// Now the EvtHeader and EvtData containers are initialized.
+//
+Bool_t MRawFileRead::PreProcess(MParList *pList)
+{
+    //
+    // open the input stream
+    // first of all check if opening the file in the constructor was
+    // successfull
+    //
+    fIn->open(fFileName);
+    if (!(*fIn))
+    {
+        *fLog << err << "Error: Cannot open file '" << fFileName << "'" << endl;
+        return kFALSE;
+    }
+
+    //
+    //  check if all necessary containers exist in the Parameter list.
+    //  if not create one and add them to the list
+    //
+    fRawRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
+    if (!fRawRunHeader)
+        return kFALSE;
+
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindCreateObj("MRawEvtHeader");
+    if (!fRawEvtHeader)
+        return kFALSE;
+
+    fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
+    if (!fRawEvtData)
+        return kFALSE;
+
+    fRawCrateArray = (MRawCrateArray*)pList->FindCreateObj("MRawCrateArray");
+    if (!fRawCrateArray)
+        return kFALSE;
+
+    fRawEvtTime = (MTime*)pList->FindCreateObj("MTime", "MRawEvtTime");
+    if (!fRawEvtTime)
+        return kTRUE;
+
+    //
+    // Read RUN HEADER (see specification) from input stream
+    //
+    fRawRunHeader->ReadEvt(*fIn);
+    fRawRunHeader->Print();
+
+    if (fRawRunHeader->GetMagicNumber()!=kMagicNumber)
+        return kFALSE;
+
+    //
+    // Give the run header information to the 'sub-classes'
+    //
+    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
+    fRawEvtData  ->Init(fRawRunHeader);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The Process reads one event from the binary file:
+//  - The event header is read
+//  - the run header is read
+//  - all crate information is read
+//  - the raw data information of one event is read
+//
+Bool_t MRawFileRead::Process()
+{
+    //
+    //  Read in the next EVENT HEADER (see specification),
+    // if there is no next event anymore stop eventloop
+    //
+    if (!fRawEvtHeader->ReadEvt(*fIn))
+        return kFALSE;
+
+    //
+    //  Get number of crates from the run header
+    //
+    const UShort_t nc = fRawRunHeader->GetNumCrates();
+
+    //
+    // Delete arrays which stores the pixel information (time slices)
+    //
+    fRawEvtData->ResetPixels();
+
+    //
+    // clear the TClonesArray which stores the Crate Information
+    // and create a new array of the correct size
+    //
+    fRawCrateArray->SetSize(nc);
+
+    //
+    // read the CRATE DATA (see specification) from file
+    //
+    for (int i=0; i<nc; i++)
+    {
+        fRawCrateArray->GetEntry(i)->ReadEvt(*fIn);
+
+        fRawEvtData->ReadEvt(*fIn);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Close the file. Check whether the number of read events differs from
+//  the number the file should containe (MRawRunHeader). Prints a warning
+//  if it doesn't match.
+//
+Bool_t MRawFileRead::PostProcess()
+{
+    //
+    // Sanity check for the number of events
+    //
+    if (fRawRunHeader->GetNumEvents() == GetNumExecutions()-1)
+        return kTRUE;
+
+    *fLog << warn << "Warning - number of read events (" << GetNumExecutions()-1;
+    *fLog << ") doesn't match number in run header (";
+    *fLog << fRawRunHeader->GetNumEvents() << ")." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileRead.h	(revision 1638)
@@ -0,0 +1,40 @@
+#ifndef MARS_MRawFileRead
+#define MARS_MRawFileRead
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class ifstream;
+
+class MTime;
+class MParList;
+class MRawRunHeader;
+class MRawEvtHeader;
+class MRawEvtData;
+class MRawCrateArray;
+
+class MRawFileRead : public MTask
+{
+private:
+    MRawRunHeader  *fRawRunHeader;  // run header information container to fill from file
+    MRawEvtHeader  *fRawEvtHeader;  // event header information container to fill from file
+    MRawEvtData    *fRawEvtData;    // raw evt header infomation container to fill from file
+    MRawCrateArray *fRawCrateArray; // crate information array container to fill from file
+    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
+
+    TString         fFileName;
+    ifstream       *fIn;            //! buffered input stream (file to read from)
+
+public:
+    MRawFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    ~MRawFileRead();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.cc	(revision 1638)
@@ -0,0 +1,261 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MRawFileWrite
+//
+//  Here we write the root containers which contains the data from a
+//  root binary file to a root file. See also MRawFileRead
+//
+//  Input Containers:
+//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
+//
+//  Output Containers:
+//   -/-
+//
+////////////////////////////////////////////////////////////////////////
+
+#include "MRawFileWrite.h"
+
+#include <TFile.h>
+#include <TTree.h>
+#include <TBranch.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+
+ClassImp(MRawFileWrite);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It opens the output file (root-file)
+//
+MRawFileWrite::MRawFileWrite(const char *fname,
+                             const Option_t *opt,
+                             const char *ftitle,
+                             const Int_t comp,
+                             const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRawFileWrite";
+    fTitle = title ? title : "Write task to write DAQ root files";
+
+    //
+    // Open a rootfile
+    //
+    fOut = new TFile(fname, opt, ftitle, comp);
+}
+
+MRawFileWrite::~MRawFileWrite()
+{
+    //
+    // delete instance, this also does a fOut->Close()
+    //
+    if (fOut->IsOpen())
+        fOut->Write();
+
+    delete fOut;
+
+    //
+    // Remark:
+    // - Trees are automatically deleted by the the file
+    //   (unless file.SetDirectory(0) was called)
+    // - Branches are automatically deleted by the tree destructor
+    //
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess function checks for the following input containers:
+//  - MRawEvtHeader
+//  - MRawEvtData
+//  - MRawCrateArray
+//  - MRawEvtTime <MTime>
+//  - MRawRunHeader
+// if a container isn't found the eventloop is stopped.
+//
+// The tree which should containe the run header is created. <RunHeaders>
+// The trees which contains the Events <Events>, <PedEvents>, <CalEvents>
+// are created.
+//
+Bool_t MRawFileWrite::PreProcess (MParList *pList)
+{
+    //
+    // test whether file is now open or not
+    //
+    if (!fOut->IsOpen())
+    {
+        *fLog << dbginf << "Error: Cannot open file '" << fOut->GetName() << "'" << endl;
+        return kFALSE;
+    }
+
+    //
+    // remember the pointer to the parameter list fur further usage
+    //
+    pParList = pList;
+
+    //
+    //  check if MEvtHeader exists in the Parameter list already.
+    //  if not create one and add them to the list
+    //
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+    if (!fRawEvtHeader)
+    {
+        *fLog << err << dbginf << "MRawEvtHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvtData)
+    {
+        *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawCrateArray = (MRawCrateArray*)pList->FindObject("MRawCrateArray");
+    if (!fRawCrateArray)
+    {
+        *fLog << err << dbginf << "MRawCrateArray not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvtTime = (MTime*)pList->FindObject("MRawEvtTime");
+    if (!fRawEvtTime)
+    {
+        *fLog << err << dbginf << "MRawEvtTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRawRunHeader)
+    {
+        *fLog << err << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    //
+    // Remark:
+    // - Trees are automatically deleted by the the file
+    //   (unless file.SetDirectory(0) was called)
+    // - Branches are automatically deleted by the tree destructor
+    //
+
+    //
+    // Write the run header information to the file
+    //
+    TTree *rh = new TTree("RunHeaders", "Run headers of all runs in this file");
+    rh->Branch("MRawRunHeader", "MRawRunHeader", &fRawRunHeader, 32000);
+    rh->Fill();
+    //rh->Write();
+
+    //
+    // create data trees for the three types of data
+    //
+    fTData        = new TTree("Events",    "Normal Triggered Events");
+    fTPedestal    = new TTree("PedEvents", "Pedestal Triggered Events");
+    fTCalibration = new TTree("CalEvents", "Calibration Triggered Events");
+
+    //
+    // From the root dicumentation:
+    //
+    // Note that calling TTree::AutoSave too frequently (or similarly calling
+    // TTree::SetAutoSave with a small value) is an expensive operation.
+    // You should make tests for your own application to find a compromize
+    // between speed and the quantity of information you may loose in case of
+    // a job crash.
+    //
+    // In case your program crashes before closing the file holding this tree,
+    // the file will be automatically recovered when you will connect the file
+    // in UPDATE mode.
+    // The Tree will be recovered at the status corresponding to the last AutoSave.
+    //
+    fTData       ->SetAutoSave(2000000000); // 2GB
+    fTPedestal   ->SetAutoSave(2000000000); // 2GB
+    fTCalibration->SetAutoSave(2000000000); // 2GB
+
+    //
+    // create all branches which are necessary
+    //
+    // FIXME: Can we calculate a good buffer size out of the event size?
+    //        using splitlevel=0 sppeds up writing by a factor of 5-10%
+    fTData       ->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
+    fTPedestal   ->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
+    fTCalibration->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
+    fTData       ->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
+    fTPedestal   ->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
+    fTCalibration->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
+    fTData       ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
+    fTPedestal   ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
+    fTCalibration->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
+    //fTree->Branch("MRawCrateArray",  fRawCrateArray->GetArray(),      32000, 1);
+    fTData       ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
+    fTPedestal   ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
+    fTCalibration->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
+
+    return kTRUE;
+}
+    
+// --------------------------------------------------------------------------
+//
+// Gets the trigger type from the run header to decide into which tree the
+// event should be filled in and fills  it into this tree.
+//
+Bool_t MRawFileWrite::Process()
+{
+    //
+    // get the trigger type of the actual event
+    //
+    const UShort_t type = fRawEvtHeader->GetTrigType();
+
+    //
+    // writa data to the tree. the tree is choosen by the type of the event
+    //
+    switch (type)
+    {
+    case kTTEvent:
+        fTData->Fill();
+        return kTRUE;
+
+    case kTTPedestal:
+        fTPedestal->Fill();
+        return kTRUE;
+
+    case kTTCalibration:
+        fTCalibration->Fill();
+        return kTRUE;
+    }
+
+    *fLog << warn << dbginf << "Got wrong number for the trigger type: " << type;
+    *fLog << " - skipped" << endl;
+
+    return kCONTINUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawFileWrite.h	(revision 1638)
@@ -0,0 +1,49 @@
+#ifndef MARS_MRawFileWrite
+#define MARS_MRawFileWrite
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TFile;
+class TTree;
+
+class MTime;
+class MParList;
+class MRawRunHeader;
+class MRawEvtHeader;
+class MRawCrateArray;
+class MRawEvtData;
+
+class MRawFileWrite : public MTask
+{
+private:
+    MParList *pParList;
+
+    MTime          *fRawEvtTime;
+    MRawRunHeader  *fRawRunHeader;
+    MRawEvtHeader  *fRawEvtHeader;
+    MRawEvtData    *fRawEvtData;
+    MRawCrateArray *fRawCrateArray;
+
+    TTree *fTData;                  //!
+    TTree *fTPedestal;              //!
+    TTree *fTCalibration;           //!
+
+    TFile *fOut;                    //!
+
+public:
+    MRawFileWrite(const char *fname,
+                  const Option_t *opt="UPDATE",
+                  const char *ftitle="Untitled",
+                  const Int_t comp=9,
+                  const char *name=NULL, const char *title=NULL);
+    ~MRawFileWrite();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MRawFileWrite, 0)	// Task to write the raw data containers to a root file
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.cc	(revision 1638)
@@ -0,0 +1,180 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRawRunHeader
+//
+// Root storage container for the RUN HEADER information
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MRawRunHeader.h"
+
+#include <fstream.h>
+#include <iomanip.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArrayS.h"
+
+ClassImp(MRawRunHeader);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates array which stores the pixel assignment.
+//
+//
+MRawRunHeader::MRawRunHeader(const char *name, const char *title) : fPixAssignment(NULL)
+{
+    fName  = name  ? name  : "MRawRunHeader";
+    fTitle = title ? title : "Raw Run Header Information";
+
+    fPixAssignment = new MArrayS(0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the 'pixel-assignment-array'
+//
+MRawRunHeader::~MRawRunHeader()
+{
+    delete fPixAssignment;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read in one run header from the binary file
+//
+void MRawRunHeader::ReadEvt(istream& fin)
+{
+    //
+    // read one RUN HEADER from the input stream
+    //
+    fin.read((Byte_t*)&fMagicNumber,       2);
+
+    //
+    // check whether the the file has the right file type or not
+    //
+    if (fMagicNumber != kMagicNumber)
+    {
+        *fLog << err << "Error: Wrong Magic Number: Not a Magic File!" << endl;
+        return;
+    }
+
+    Byte_t dummy[16];
+
+    fin.read((Byte_t*)&fFormatVersion,    2);
+    fin.read((Byte_t*)&fSoftVersion,      2);
+    fin.read((Byte_t*)&fRunType,          2);
+    fin.read((Byte_t*)&fRunNumber,        4);
+    fin.read((Byte_t*)&fProjectName,     22);
+    fin.read((Byte_t*)&fSourceName,      12);
+    fin.read((Byte_t*)dummy,              4); // was RA  (moved to tracking system)
+    fin.read((Byte_t*)dummy,              4); // was DEC (moved to tracking system)
+    fin.read((Byte_t*)&fSourceEpochChar,  2);
+    fin.read((Byte_t*)&fSourceEpochDate,  2);
+    fin.read((Byte_t*)&fMJD,              4);
+    fin.read((Byte_t*)&fDateYear,         2);
+    fin.read((Byte_t*)&fDateMonth,        2);
+    fin.read((Byte_t*)&fDateDay,          2);
+    fin.read((Byte_t*)&fNumCrates,        2);
+    fin.read((Byte_t*)&fNumPixInCrate,    2);
+    fin.read((Byte_t*)&fNumSamplesLoGain, 2);
+    fin.read((Byte_t*)&fNumSamplesHiGain, 2);
+    fin.read((Byte_t*)&fNumEvents,        4);
+
+
+    //
+    // calculate size of array, create it and fill it
+    //
+    Int_t nPixel = fNumCrates*fNumPixInCrate;
+    fPixAssignment->Set(nPixel);
+
+    fin.read((Byte_t*)fPixAssignment->GetArray(), nPixel*2);
+    fin.read((Byte_t*)&dummy, 16);
+}
+
+// --------------------------------------------------------------------------
+//
+// print run header information on *fLog
+//
+void MRawRunHeader::Print(Option_t *t) const
+{
+    *fLog << all << endl;
+    *fLog << "MagicNumber:  0x" << hex << fMagicNumber << " - " << (fMagicNumber==kMagicNumber?"OK":"Wrong!") << endl;
+    *fLog << "Version:      " << dec << "Format=" << fFormatVersion << "  ";
+    *fLog << "Software=" << fSoftVersion << endl;
+    *fLog << "RunNumber:    " << fRunNumber << " (Type=";
+    switch (fRunType)
+    {
+    case kRTData:
+        *fLog << "Data";
+        break;
+    case kRTPedestal:
+        *fLog << "Pedestal";
+        break;
+    case kRTCalibration:
+        *fLog << "Calibration";
+        break;
+    case kRTMonteCarlo:
+        *fLog << "Monte Carlo Data";
+        break;
+    }
+    *fLog << ")" << endl;
+    *fLog << "ProjectName: '" << fProjectName << "'" << endl;
+    *fLog << "Source:      '" << fSourceName << "' " << "  ";
+    *fLog << fSourceEpochChar << dec << fSourceEpochDate << endl;
+    *fLog << "Date:         " << setprecision(1) << setiosflags(ios::fixed) << fMJD << " (MJD)  " << fDateYear << "/" << fDateMonth << "/" << fDateDay << endl;
+    *fLog << "Crates:       " << fNumCrates << " x " << fNumPixInCrate << " Pixel/Crate = " << fNumCrates*fNumPixInCrate << " Pixel/Evt" << endl;
+    *fLog << "Samples:      " << fNumSamplesLoGain << "/" << fNumSamplesHiGain << " (lo/hi) = " << (fNumSamplesLoGain+fNumSamplesHiGain) * fNumCrates * fNumPixInCrate /1024 << "kB/Evt" << endl;
+    *fLog << "Evt Counter:  " << fNumEvents << endl;
+
+    *fLog << hex;
+    for (int i=0; i<GetNumPixel(); i++)
+        *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
+    *fLog << hex << endl;
+
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the assigned pixel number for the given FADC channel
+//
+UShort_t MRawRunHeader::GetPixAssignment(UShort_t i) const
+{
+    // FIXME: Do we need a range check here?
+    return (*fPixAssignment)[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of pixel in this event.
+//
+UShort_t MRawRunHeader::GetNumPixel() const
+{
+    return fPixAssignment->GetSize();
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/MRawRunHeader.h	(revision 1638)
@@ -0,0 +1,108 @@
+#ifndef MARS_MRawRunHeader
+#define MARS_MRawRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MRunHeader                                                        //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TBuffer;
+class ifstream;
+class MArrayS;
+
+//
+// Magic number to detect the magic file type
+//
+const UShort_t kMagicNumber = 0xc0c0;
+
+enum {
+    kRTData        = 0,
+    kRTPedestal    = 1,
+    kRTCalibration = 2,
+    kRTMonteCarlo  = 256
+};
+
+class MRawRunHeader : public MParContainer
+{
+private:
+    /* ---- Run Header Informations ---- */
+    UShort_t  fMagicNumber;
+    UShort_t  fFormatVersion;
+    UShort_t  fSoftVersion;
+    UShort_t  fRunType;
+    UInt_t    fRunNumber;
+    Char_t    fProjectName[22];
+    Char_t    fSourceName[12];
+    //Float_t   fSourceRA;
+    //Float_t   fSourceDEC;
+    Char_t    fSourceEpochChar[2];
+    UShort_t  fSourceEpochDate;
+    Float_t   fMJD;
+    UShort_t  fDateYear;
+    UShort_t  fDateMonth;
+    UShort_t  fDateDay;
+    UShort_t  fNumCrates;
+    UShort_t  fNumPixInCrate;
+    UShort_t  fNumSamplesLoGain;
+    UShort_t  fNumSamplesHiGain;
+    UInt_t    fNumEvents;
+    MArrayS  *fPixAssignment;
+
+public:
+    MRawRunHeader(const char *name=NULL, const char *title=NULL);
+    ~MRawRunHeader();
+
+    void SetMagicNumber(UShort_t a)  { fMagicNumber=a; }
+    void SetFormatVersion(UShort_t a){ fFormatVersion=a; }
+    void SetSoftVersion(UShort_t a)  { fSoftVersion=a; }
+    void SetRunType(UShort_t a)      { fRunType=a; }
+    void SetRunNumber(UInt_t a)      { fRunNumber=a; }
+    void SetNumEvents(UInt_t a)      { fNumEvents=a; }
+    void SetNumSamples(UShort_t low, UShort_t high)
+    {
+        fNumSamplesLoGain=low;
+        fNumSamplesHiGain=high;
+    }
+    void SetNumCrates(UShort_t a)    {fNumCrates=a; }
+    void SetNumPixInCrate(UShort_t a){fNumPixInCrate=a; }
+
+    UShort_t GetMagicNumber() const       { return fMagicNumber; }
+    UShort_t GetFormatversion() const     { return fFormatVersion; }
+    UShort_t GetSoftVersion() const       { return fSoftVersion; }
+    UShort_t GetRunType() const           { return fRunType; }
+    UInt_t   GetRunNumber() const         { return fRunNumber; }
+    const Char_t  *GetProjectName() const { return fProjectName; }
+    const Char_t  *GetSourceName() const  { return fSourceName; }
+    //Float_t  GetSourceRa() const         { return fSourceRA; }
+    //Float_t  GetSourceDec() const        { return fSourceDEC; }
+    const Char_t  *GetSourceEpocheChar() const { return fSourceEpochChar; }
+    UShort_t GetSourceEpocheDate() const  { return fSourceEpochDate; }
+    Float_t  GetMJD() const               { return fMJD; }
+    UShort_t GetDateYear() const          { return fDateYear; }
+    Byte_t   GetDateMonth() const         { return fDateMonth; }
+    Byte_t   GetDateDay() const           { return fDateDay; }
+    UShort_t GetNumCrates() const         { return fNumCrates; }
+    UShort_t GetNumPixInCrate() const     { return fNumPixInCrate; }
+    UShort_t GetNumSamplesLoGain() const  { return fNumSamplesLoGain; }
+    UShort_t GetNumSamplesHiGain() const  { return fNumSamplesHiGain; }
+    UInt_t   GetNumEvents() const         { return fNumEvents; }
+    UShort_t GetPixAssignment(UShort_t i) const;
+
+    UInt_t GetNumSamplesPerCrate() const
+    {
+        return fNumPixInCrate*(fNumSamplesLoGain+fNumSamplesHiGain);
+    }
+
+    UShort_t GetNumPixel() const;
+
+    void Print(Option_t *t=NULL) const;
+
+    void ReadEvt(istream& fin);
+
+    ClassDef(MRawRunHeader, 1)	// storage container for general info
+};
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/Makefile	(revision 1638)
@@ -0,0 +1,54 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Raw
+
+#
+# Library name to creatre
+#
+LIB   = mraw.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../MBase
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MRawRunHeader.cc \
+	   MRawEvtHeader.cc \
+	   MRawEvtData.cc \
+	   MRawEvtPixelIter.cc \
+	   MRawCrateArray.cc \
+	   MRawCrateData.cc \
+           MRawFileRead.cc \
+           MRawFileWrite.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawIncl.h	(revision 1638)
@@ -0,0 +1,10 @@
+#ifndef __CINT__
+
+#include "MTime.h"
+#include "MArrayB.h"
+#include "MArrayS.h"
+#include "MParList.h"
+
+#include <TClonesArray.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mraw/RawLinkDef.h	(revision 1638)
@@ -0,0 +1,19 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MRawRunHeader;
+
+#pragma link C++ class MRawEvtHeader;
+#pragma link C++ class MRawEvtData;
+#pragma link C++ class MRawEvtPixelIter+;
+
+#pragma link C++ class MRawCrateArray+;
+#pragma link C++ class MRawCrateData+;
+
+#pragma link C++ class MRawFileRead+;
+#pragma link C++ class MRawFileWrite+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.cc	(revision 1638)
@@ -0,0 +1,439 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicCivilization
+// ---------
+//
+// Tool to visualize Next Neighbours.
+//
+// Start the show by:
+//   MagicCivilization show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Space:
+//     Toggle between auto increment and manual increment
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Up/Down:
+//     Increment/Decrement pixel number by 10
+//
+//   * PageUp/PageDown:
+//     Increment/Decrement pixel number by 100
+//
+//   * Home/End:
+//     Jump to first/last pixel
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicCivilization.h"
+
+#include <iostream.h>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicCivilization);
+
+void MagicCivilization::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicCivilization::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+void MagicCivilization::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    DrawHexagons();
+}
+
+void MagicCivilization::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicCivilization::MagicCivilization(Byte_t lim, UShort_t init)
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    fTimer.TurnOn();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicCivilization::~MagicCivilization()
+{
+    fTimer.TurnOff();
+    Free();
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicCivilization::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+void MagicCivilization::Reset()
+{
+    if (fNumInit>=fNumPixels)
+        fNumInit = fNumPixels-1;
+    if (fNumInit<0)
+        fNumInit = 0;
+
+    if (fLimit<0)
+        fLimit=6;
+    if (fLimit>6)
+        fLimit=0;
+
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumPixels; i++)
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+    for (int i=0; i<fNumInit; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBit(kHasFlag));
+
+        if (idx>=fNumPixels)
+            cout << "!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+
+        (*fGeomCam)[idx].SetBit(kHasFlag);
+    }
+
+    fAuto = kFALSE;
+    fStep = 0;
+
+    Update();
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicCivilization::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+    fDrawingPad->SetFillColor(22);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    DrawHexagons();
+
+    fCivilization.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fCivilization.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fCivilization.Draw();
+
+    Reset();
+}
+
+void MagicCivilization::Update()
+{
+    TString txt = "Lim: ";
+    txt += (int)fLimit;
+    txt += "  Init: ";
+    txt += fNumInit;
+    txt += "  On: ";
+    txt += fNumCivilizations;
+    txt += "  Step: ";
+    txt += fStep;
+
+    if (!fAuto)
+        txt += "  (paused)";
+
+    fCivilization.SetText(0, fRange, txt);
+}
+
+
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicCivilization::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    default:
+        return;
+
+    case kKey_Space:
+        if ((fNumCivilizations==0 || fNumCivilizations==fNumPixels) && !fAuto)
+            Reset();
+        fAuto = !fAuto;
+        Update();
+        fDrawingPad->Update();
+        return;
+
+    case kKey_Right:
+        fNumInit += 1;;
+        break;
+
+    case kKey_Left:
+        fNumInit -= 1;
+        break;
+
+    case kKey_Up:
+        fNumInit += 10;
+        break;
+
+    case kKey_Down:
+        fNumInit -= 10;
+        break;
+
+    case kKey_PageUp:
+        fNumInit += 100;
+        break;
+
+    case kKey_PageDown:
+        fNumInit -= 100;
+        break;
+
+    case kKey_Plus:
+        fLimit++;
+        break;
+
+    case kKey_Minus:
+        fLimit--;
+        break;
+    }
+
+    Reset();
+}
+
+Bool_t MagicCivilization::HandleTimer(TTimer *timer)
+{
+    if (!fAuto)
+        return kTRUE;
+
+    for (int i=0; i<fNumPixels; i++)
+    {
+        MGeomPix &pix = (*fGeomCam)[i];
+
+        Byte_t cnt=0;
+        for (int j=0; j<pix.GetNumNeighbors(); j++)
+            if ((*fGeomCam)[pix.GetNeighbor(j)].TestBit(kHasFlag))
+                cnt++;
+
+        cnt += (6-pix.GetNumNeighbors())*cnt/6;
+
+        if (cnt>fLimit)
+            pix.SetBit(kHasCreation);
+    }
+
+    fNumCivilizations = 0;
+    for (int i=0; i<fNumPixels; i++)
+    {
+        MGeomPix &pix = (*fGeomCam)[i];
+        MHexagon &hex = (*this)[i];
+
+        if (pix.TestBit(kHasCreation))
+        {
+            pix.SetBit(kHasFlag);
+            hex.SetFillColor(kBlack);
+            fNumCivilizations++;
+        }
+        else
+        {
+            pix.ResetBit(kHasFlag);
+            hex.SetFillColor(kBackground);
+        }
+        pix.ResetBit(kHasCreation);
+    }
+
+    if (fNumCivilizations==0 || fNumCivilizations==fNumPixels)
+        fAuto = kFALSE;
+
+    fStep++;
+
+    Update();
+
+    fDrawingPad->Update();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicCivilization.h	(revision 1638)
@@ -0,0 +1,81 @@
+#ifndef MARS_MagicCivilization
+#define MARS_MagicCivilization
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicCivilization : public TObject
+{
+private:
+    enum
+    {
+        kBackground   = 50,
+        kHasFlag      = BIT(17),
+        kHasCreation  = BIT(18),
+        kUserBits     = 0x7fc000 // 14-23 are allowed
+    };
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumInit;         // number of bombs in the field
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Bool_t    fAuto;
+
+    Char_t    fLimit;
+
+    UShort_t  fNumCivilizations;
+    UInt_t    fStep;
+
+    TText     fCivilization;    // TText showing the numbers of pixels and bombs
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    void   SetNewCamera(MGeomCam *);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicCivilization(Byte_t lim=2, UShort_t init=200);
+    ~MagicCivilization();
+
+    void ChangeCamera(); //*MENU*
+    void Reset();        //*MENU*
+
+    ClassDef(MagicCivilization, 0) // Tool to visualize next neighbours
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.cc	(revision 1638)
@@ -0,0 +1,722 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicDomino
+// -----------
+//
+// Magic Camera games.
+//
+// Start the show by:
+//   MagicDomino show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Cursor up/down, left/right:
+//     Move tile
+//
+//   * Space:
+//     Rotate tile
+//
+//   * Enter:
+//     Set tile
+//
+//   * Esc:
+//     Skip tile
+//
+//  Rules:
+//  ------
+//
+//   Each hexagon in the tile must at least have one neighbor
+//   which has the same color. It is not allowed to put a tile onto
+//   another one. The game is over if you have skipped three tiles
+//   in a row.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicDomino.h"
+
+#include <iostream.h>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicDomino);
+
+// ------------------------------------------------------------------------
+//
+// Free all onbects connected to a special camera geometry
+//
+void MagicDomino::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicDomino::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Change camera from Magic to CT1 and back
+//
+void MagicDomino::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/set all veriables needed for a new camera geometry
+//
+void MagicDomino::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// remove the pixel numbers in the tile from the pad
+//
+void MagicDomino::RemoveNumbers()
+{
+    for (int i=0; i<6; i++)
+        if (fText[i])
+        {
+            delete fText[i];
+            fText[i] = NULL;
+        }
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/restart the game
+//
+void MagicDomino::Reset()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = (*this)[i];
+        h.SetFillColor(kBackground);
+        h.ResetBit(kUserBits);
+    }
+
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+
+    fDrawingPad->SetFillColor(22);
+
+    fNumPixel = -1;
+    fNumTile  =  0;
+    fPoints   =  0;
+
+    NewTile();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicDomino::MagicDomino()
+    : fGeomCam(NULL), fDir(kBottom), fDone(NULL)
+{
+    memset(fText, 0, sizeof(fText));
+
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicDomino::~MagicDomino()
+{
+    Free();
+
+    RemoveNumbers();
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicDomino::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicDomino::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+
+    /*
+     TPave *p = new TPave(-0.66*fRange, 0.895*fRange, 0.66*fRange, 0.995*fRange, 4, "br");
+     p->ConvertNDCtoPad();
+     p->SetFillColor(12);
+     p->SetBit(kCanDelete);
+     p->Draw();
+     */
+
+    fDomino.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDomino.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDomino.Draw();
+}
+
+void MagicDomino::Update()
+{
+    TString txt = "Points: ";
+    txt += fPoints;
+    txt += "  Tile: ";
+    txt += fNumTile;
+
+    switch (fSkipped)
+    {
+    case 0:
+        fDomino.SetTextColor(8/*kGreen*/);
+        break;
+    case 1:
+        fDomino.SetTextColor(kYellow);
+        break;
+    case 2:
+        fDomino.SetTextColor(kRed);
+        break;
+    default:
+        fDomino.SetTextColor(kWhite);
+        break;
+    }
+    fDomino.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// Choose new colors for the tile
+//
+void MagicDomino::NewColors()
+{
+    TRandom rnd(0);
+    for (int i=0; i<3; i++)
+    {
+        Int_t color = (Int_t)rnd.Uniform(5)+2;
+        fNewColors[i*2]   = color;
+        fNewColors[i*2+1] = color;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Create a new tile
+//
+void MagicDomino::NewTile()
+{
+    if (fNumPixel>=0)
+    {
+        const MGeomPix &pix=(*fGeomCam)[fNumPixel];
+        (*this)[fNumPixel].ResetBit(kIsTile);
+        for (int i=0; i<pix.GetNumNeighbors(); i++)
+            (*this)[pix.GetNeighbor(i)].ResetBit(kIsTile);
+
+        fPoints += pix.GetNumNeighbors();
+    }
+
+    RemoveNumbers();
+
+    fNumPixel = -1;
+    fSkipped  =  0;
+    fNumTile++;
+
+    NewColors();
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+//  Check for at least one correct color for each pixel in tile.
+//  Ignore the tile itself and all background pixels. Check whether
+//  background of tile is empty.
+//
+Bool_t MagicDomino::CheckTile()
+{
+    if (fNumPixel<0)
+        return kFALSE;
+
+    for (int i=0; i<7; i++)
+        if (fOldColors[i]!=kBackground)
+            return kFALSE;
+
+    Int_t cnt=0;
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        const Int_t idx1 = pix1.GetNeighbor(i);
+        const MGeomPix &pix2 = (*fGeomCam)[idx1];
+
+        Byte_t ignored = 0;
+        Byte_t found   = 0;
+        for (int j=0; j<pix2.GetNumNeighbors(); j++)
+        {
+            const Int_t    idx2 = pix2.GetNeighbor(j);
+            const MHexagon &hex = (*this)[idx2];
+
+            if (hex.TestBit(kIsTile) || hex.GetFillColor()==kBackground)
+            {
+                ignored++;
+                continue;
+            }
+
+            if (hex.GetFillColor()==(*this)[idx1].GetFillColor())
+                found++;
+        }
+        if (ignored==pix2.GetNumNeighbors() || found>0)
+            cnt++;
+    }
+
+    return cnt==pix1.GetNumNeighbors();
+}
+
+// ------------------------------------------------------------------------
+//
+// Game over!
+//
+void MagicDomino::Done()
+{
+    fDone = new TText(0, 0, "Game Over!");
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+    fDone->Draw();
+
+    fDomino.SetTextColor(kBlue);
+
+    fDrawingPad->SetFillColor(kRed);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicDomino::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress || fDone)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Escape:
+        fPoints -= 6;
+        fSkipped++;
+        if (fSkipped==3)
+        {
+            Done();
+            return;
+        }
+        NewColors();
+        RotateTile(0);
+        return;
+
+    case kKey_Space:
+        RotateTile(-1);
+        return;
+
+    case kKey_Return:
+        if (CheckTile())
+            NewTile();
+        return;
+
+    case kKey_Right:
+        fDir = kRight;
+        Step(kRight);
+        return;
+
+    case kKey_Left:
+        fDir = kLeft;
+        Step(kLeft);
+        return;
+
+    case kKey_Up:
+        Step(kTop|fDir);
+        return;
+
+    case kKey_Down:
+        Step(kBottom|fDir);
+        return;
+
+    case kKey_Plus:
+        RotateTile(+1);
+        return;
+
+    case kKey_Minus:
+        RotateTile(-1);
+        return;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Rotate the colors in the tile
+//
+void MagicDomino::RotateTile(Int_t add)
+{
+    fPosition += add+6;  // Make result positive
+    fPosition %= 6;      // Align result between 0 and 5
+
+    HideTile();
+    ShowTile();
+
+    Update();
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Hide the tile from the pad
+//
+void MagicDomino::HideTile()
+{
+    if (fNumPixel<0)
+        return;
+
+    MagicDomino &This = *this;
+
+    RemoveNumbers();
+
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(fOldColors[6]);
+    This[fNumPixel].ResetBit(kIsTile);
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix1.GetNeighbor(i);
+
+        This[idx].SetFillColor(fOldColors[i]);
+        This[idx].ResetBit(kIsTile);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Show the tile on the pad
+//
+void MagicDomino::ShowTile()
+{
+    if (fNumPixel<0)
+        return;
+
+    MagicDomino &This = *this;
+
+    Int_t indices[6];
+    GetSortedNeighbors(indices);
+
+    RemoveNumbers();
+
+    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
+    fOldColors[6] = This[fNumPixel].GetFillColor();
+    This[fNumPixel].SetFillColor(kBlack);
+    This[fNumPixel].SetBit(kIsTile);
+    for (int i=0; i<pix2.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix2.GetNeighbor(i);
+
+        fOldColors[i] = This[idx].GetFillColor();
+
+        int j=0;
+        while (indices[j]!=i)
+            j++;
+
+        This[idx].SetFillColor(fNewColors[(j+fPosition)%6]);
+        This[idx].SetBit(kIsTile);
+
+        TString num;
+        num += idx;
+
+        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
+        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+        fText[i]->Draw();
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Hide the tile, change its position, show it again, update status text
+//
+void MagicDomino::ChangePixel(Int_t add)
+{
+    HideTile();
+
+    fNumPixel = add;
+
+    ShowTile();
+
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Analyse the directions of the next neighbors
+//
+Short_t MagicDomino::AnalysePixel(Int_t dir)
+{
+    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+
+    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
+    }
+
+    Int_t indices[6];
+    TMath::Sort(6, fAngle, indices); // left, top, right, bottom
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        const Int_t    idx   = pix.GetNeighbor(indices[i]);
+        const Double_t angle = fAngle[indices[i]]*180/TMath::Pi();
+
+        if (angle<-149 && dir==kLeft)
+            return idx;
+        if (angle>-149 && angle<-90 && dir==kBottomLeft)
+            return idx;
+        //if (angle==-90 && dir==kBottom)
+        //    return idx;
+        if (angle>-90 && angle<-31 && dir==kBottomRight)
+            return idx;
+        if (angle>-31 && angle<31 && dir==kRight)
+            return idx;
+        if (angle>31 && angle<90 && dir==kTopRight)
+            return idx;
+        //if (angle==90 && dir==kTop)
+        //    return idx;
+        if (angle>90 && angle<149 && dir==kTopLeft)
+            return idx;
+        if (angle>149 && dir==kLeft)
+            return idx;
+    }
+    return -1;
+}
+
+// ------------------------------------------------------------------------
+//
+// Sort the next neighbort from the left, top, right, bottom
+//
+void MagicDomino::GetSortedNeighbors(Int_t indices[6])
+{
+    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+
+    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
+    }
+
+    TMath::Sort(6, fAngle, indices); // left, top, right, bottom
+}
+
+// ------------------------------------------------------------------------
+//
+// Move tile one step in the given direction
+//
+void MagicDomino::Step(Int_t dir)
+{
+    Short_t newidx = AnalysePixel(dir);
+    if (newidx<0)
+        return;
+    ChangePixel(newidx);
+}
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicDomino.h	(revision 1638)
@@ -0,0 +1,101 @@
+#ifndef MARS_MagicDomino
+#define MARS_MagicDomino
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicDomino : public TObject
+{
+private:
+    enum
+    {
+        kBackground  = 50,
+        kIsTile      = BIT(16),
+        kRight       = BIT(17),
+        kLeft        = BIT(18),
+        kTop         = BIT(19),
+        kBottom      = BIT(20),
+        kUserBits    = 0x7fc000, // 14-23 are allowed
+
+        kBottomLeft  = kBottom|kLeft,
+        kBottomRight = kBottom|kRight,
+        kTopLeft     = kTop|kLeft,
+        kTopRight    = kTop|kRight
+
+    };
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumPixel;        // number of actual pixel
+    Int_t     fNumTile;         // number of setteled tiles
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Int_t     fPoints;          // points you got
+
+    Int_t     fDir;             // direction you move the tile
+
+    Int_t     fOldColors[7];    // colors of hexagons which are under the tile
+    Int_t     fNewColors[6];    // colors of the tile itself
+    Byte_t    fPosition;        // rotation position of colors in tile
+    Byte_t    fSkipped;         // number of skipped tiles
+
+    TText     fDomino;          // TText showing status informations
+    TText    *fText[6];         // ttext showing the six numbers in the tile
+    TText    *fDone;            // game over text
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    Bool_t  CheckTile();
+    void    NewTile();
+    void    NewColors();
+    void    HideTile();
+    void    ShowTile();
+    void    RotateTile(Int_t add);
+    void    Update();
+    void    Free();
+    void    Done();
+    void    RemoveNumbers();
+    void    DrawHexagons();
+    void    SetNewCamera(MGeomCam *);
+    void    ChangePixel(Int_t add);
+    void    Step(Int_t dir);
+    Short_t AnalysePixel(Int_t dir);
+    void    GetSortedNeighbors(Int_t indices[6]);
+
+    void  Draw(Option_t *option="");
+    void  Paint(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicDomino();
+    ~MagicDomino();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicDomino, 0) // Tool to visualize next neighbours
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.cc	(revision 1638)
@@ -0,0 +1,421 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicShow
+// ---------
+//
+// Tool to visualize Next Neighbours.
+//
+// Start the show by:
+//   MagicShow show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Space:
+//     Toggle between auto increment and manual increment
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Up/Down:
+//     Increment/Decrement pixel number by 10
+//
+//   * PageUp/PageDown:
+//     Increment/Decrement pixel number by 100
+//
+//   * Home/End:
+//     Jump to first/last pixel
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicShow.h"
+
+#include <iostream.h>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicShow);
+
+// ------------------------------------------------------------------------
+//
+// Free all onbects connected to a special camera geometry
+//
+void MagicShow::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicShow::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = (*this)[i];
+
+        h.SetFillColor(kBackground);
+        h.Draw();
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Change camera from Magic to CT1 and back
+//
+void MagicShow::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    DrawHexagons();
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/set all veriables needed for a new camera geometry
+//
+void MagicShow::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    fNumPixel  = fNumPixels-1;
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicShow::MagicShow()
+    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    memset(fText, 0, sizeof(fText));
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    fTimer.TurnOn();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicShow::~MagicShow()
+{
+    Free();
+
+    for (int i=0; i<6; i++)
+        if (fText[i])
+            delete fText[i];
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicShow::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicShow::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+    fDrawingPad->SetFillColor(22);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    DrawHexagons();
+
+    fShow.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow.Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Update Status text
+//
+void MagicShow::Update()
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Pixel: ";
+    txt += fNumPixel;
+
+    if (fAuto)
+        txt += "  (auto)";
+
+    fShow.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicShow::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Space:
+        fAuto = !fAuto;
+        Update();
+        fDrawingPad->Update();
+        return;
+
+    case kKey_Right:
+        ChangePixel(+1);
+        return;
+
+    case kKey_Left:
+        ChangePixel(-1);
+        return;
+
+    case kKey_Up:
+        ChangePixel(+10);
+        return;
+
+    case kKey_Down:
+        ChangePixel(-10);
+        return;
+
+    case kKey_PageUp:
+        ChangePixel(+100);
+        return;
+
+    case kKey_PageDown:
+        ChangePixel(-100);
+        return;
+
+    case kKey_Home:
+        ChangePixel(-fNumPixel);
+        return;
+
+    case kKey_End:
+        ChangePixel(fNumPixels-fNumPixel-1);
+        return;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Change the shown pixel by add indices
+//
+void MagicShow::ChangePixel(Int_t add)
+{
+    MagicShow &This = *this;
+
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(kBackground);
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        This[pix1.GetNeighbor(i)].SetFillColor(kBackground);
+        if (!fText[i])
+            continue;
+
+        delete fText[i];
+        fText[i] = NULL;
+    }
+
+    fNumPixel += add;
+
+    if (fNumPixel>=fNumPixels)
+        fNumPixel = 0;
+    if (fNumPixel<0)
+        fNumPixel = fNumPixels-1;
+
+    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(kBlue);
+    for (int i=0; i<pix2.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix2.GetNeighbor(i);
+
+        This[idx].SetFillColor(kMagenta);
+
+        TString num;
+        num += idx;
+
+        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
+        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+        fText[i]->Draw();
+    }
+
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// If automatic is switched on step one pixel forward
+//
+Bool_t MagicShow::HandleTimer(TTimer *timer)
+{
+    if (fAuto)
+        ChangePixel(+1);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicShow.h	(revision 1638)
@@ -0,0 +1,76 @@
+#ifndef MARS_MagicShow
+#define MARS_MagicShow
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicShow : public TObject
+{
+private:
+    enum
+    {
+        kBackground = 50,
+        kUserBits   = 0x7fc000 // 14-23 are allowed
+
+    };
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumPixel;        // number of pixel actually shown
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Bool_t    fAuto;            // automatic stepping on/off
+
+    TText     fShow;            // TText showing the numbers of pixels and bombs
+    TText    *fText[6];         // ttext showing the pixel numbers of the neighbors
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    void   SetNewCamera(MGeomCam *);
+    void   ChangePixel(Int_t add);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicShow();
+    ~MagicShow();
+
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicShow, 0) // Tool to visualize next neighbours
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.cc	(revision 1638)
@@ -0,0 +1,630 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicSnake
+// ----------
+//
+// Camera Display Games: Snake
+//
+// Start the game by:
+//   MagicSnake snake;
+//
+// Controll the worm using right/left. Make sure, that the mouse pointer
+// is inside the canvas.
+//
+// Move the mouse pointer outside the canvas to pause the game.
+//
+// The pixel colors have the following meaning:
+// --------------------------------------------
+//  Green:   Food, collect all packages.
+//  Red:     Bombs, don't touch it!
+//  Yellow:  Transport, try it.
+//  Magenta: Home, touch it to win the game.
+//
+// To restart the game use the context menu. It can only be accessed if
+// the game has been stopped (either because you win the game or because
+// you hit a bomb) With the context menu you can also toggle between
+// different camera layouts.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicSnake.h"
+
+#include <iostream.h>
+
+#include <KeySymbols.h>
+
+#include <TColor.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicSnake);
+
+void MagicSnake::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+
+    delete fArray;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicSnake::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+void MagicSnake::ChangeCamera()
+{
+    if (!fDone)
+        Done("Changing Camera...", 22);
+
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MagicSnake::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicSnake::MagicSnake()
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    Pause();
+
+    fTimer.TurnOn();
+}
+
+void MagicSnake::Pause(Bool_t yes)
+{
+    if (yes && !fPaused)
+    {
+        fPaused = new TText(0, 0, "Paused!");
+        fPaused->SetTextColor(kWhite);
+        fPaused->SetTextAlign(22);
+        fPaused->SetTextSize(0.05); // white
+        fPaused->Draw();
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fPaused->SetBit(kNoContextMenu|kCannotPick);
+        fDrawingPad->ResetBit(kNoContextMenu);
+        ResetBit(kNoContextMenu);
+#endif
+        fDrawingPad->Update();
+    }
+
+    if (yes)
+        return;
+
+    if (!fDone)
+    {
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fDrawingPad->SetBit(kNoContextMenu);
+        SetBit(kNoContextMenu);
+#endif
+    }
+    if (!fPaused)
+        return;
+
+    Remove(fPaused);
+
+    fDrawingPad->Update();
+
+    delete fPaused;
+    fPaused=NULL;
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicSnake::~MagicSnake()
+{
+    Free();
+    Pause(kFALSE);
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicSnake::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicSnake::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+
+    fShow.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow.Draw();
+}
+
+void MagicSnake::Update()
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Bombs: ";
+    txt += fNumBombs;
+    txt += "  Food: ";
+    txt += fNumFood;
+
+    fShow.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MagicSnake::Reset()
+{
+    fDirection = fGeomCam->InheritsFrom("MGeomCamCT1") ? kLeft : kRight;
+    fLength = 2;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        (*this)[i].SetFillColor(kBackground);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+    }
+
+    (*fGeomCam)[0].SetBit(kHasWorm);
+
+    fNumBombs = fNumPixels/30;
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumBombs; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasWorm));
+
+        (*fGeomCam)[idx].SetBit(kHasBomb);
+        (*this)[idx].SetFillColor(kRed);
+    }
+
+    fNumFood = fNumPixels/6;
+
+    fArray = new Int_t[fNumFood+3];
+
+    fArray[0] = 0;
+    fArray[1] = 1;
+
+    for (int i=0; i<fNumFood+3; i++)
+    {
+        Float_t f = (float)i/(fNumFood+3);
+        gROOT->GetColor(51+i)->SetRGB(f, f, f);
+    }
+    for (int i=0; i<fNumFood; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasFood|kHasWorm));
+
+        (*fGeomCam)[idx].SetBit(kHasFood);
+        (*this)[idx].SetFillColor(kGreen);
+    }
+
+    SetWormColor();
+
+    for (int i=0; i<2; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasFood|kHasWorm|kHasTransport));
+
+        fTransport[i] = idx;
+        (*fGeomCam)[idx].SetBit(kHasTransport);
+        (*this)[idx].SetFillColor(kYellow);
+    }
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+
+    if (!fDone)
+        return;
+
+    delete fDone;
+    fDone = NULL;
+}
+
+void MagicSnake::Done(TString txt, Int_t col)
+{
+    //(*this)[fArray[fLength-1]].SetFillColor(kBlue);
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+    fDone->Draw();
+    fDrawingPad->SetFillColor(col);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+void MagicSnake::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicSnake::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event==kMouseEnter || event==kMouseMotion)
+    {
+        Pause(kFALSE);
+        return;
+    }
+
+    if (fDone)
+        return;
+
+    if (event==kMouseLeave)
+    {
+        Pause();
+        return;
+    }
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Left:
+        fDirection --;
+        break;
+
+    case kKey_Right:
+        fDirection ++;
+        break;
+
+    case kKey_Escape:
+        Done("Reset...", 22);
+        Reset();
+        return;
+
+    default:
+        cout << "Keysym=0x" << hex << keysym << endl;
+    }
+
+     if (fDirection < kRightTop)
+         fDirection = kLeftTop;
+     if (fDirection > kLeftTop)
+         fDirection = kRightTop;
+}
+
+void MagicSnake::Step(Int_t newpix)
+{
+    if ((*fGeomCam)[newpix].TestBit(kHasTransport))
+    {
+        (*this)[fArray[0]].SetFillColor(kBackground);
+        (*fGeomCam)[fArray[0]].ResetBit(kHasWorm);
+
+        for (int i=1; i<fLength; i++)
+            fArray[i-1] = fArray[i];
+
+        fArray[fLength-1] = newpix==fTransport[0]?fTransport[1]:fTransport[0];
+
+        return;
+    }
+
+    if (!(*fGeomCam)[newpix].TestBit(kHasFood))
+    {
+        MGeomPix &pix = (*fGeomCam)[fArray[0]];
+
+        if (!pix.TestBit(kHasTransport))
+            if (pix.TestBit(kHasDoor))
+                (*this)[fArray[0]].SetFillColor(kMagenta);
+            else
+                (*this)[fArray[0]].SetFillColor(kBackground);
+
+        pix.ResetBit(kHasWorm);
+
+        for (int i=1; i<fLength; i++)
+            fArray[i-1] = fArray[i];
+
+        fArray[fLength-1] = newpix;
+    }
+    else
+    {
+        fArray[fLength++] = newpix;
+        (*fGeomCam)[newpix].ResetBit(kHasFood);
+
+        fNumFood--;
+
+        if (fNumFood==0)
+            for (int i=1; i<7; i++)
+            {
+                (*this)[i].SetFillColor(kMagenta);
+                (*fGeomCam)[i].SetBit(kHasDoor);
+            }
+    }
+
+    SetWormColor();
+}
+
+void MagicSnake::SetWormColor()
+{
+    for (int i=0; i<fLength; i++)
+    {
+        const Int_t idx = fArray[i];
+
+        MGeomPix &pix = (*fGeomCam)[idx];
+
+        if (pix.TestBit(kHasTransport))
+            continue;
+
+        pix.SetBit(kHasWorm);
+
+        Int_t color = 51+fLength-i;
+        (*this)[idx].SetFillColor(color);
+    }
+}
+
+Int_t MagicSnake::ScanNeighbours()
+{
+    const Int_t first = fArray[fLength-1];
+
+    const MGeomPix &pix=(*fGeomCam)[first];
+
+    Double_t dx = pix.GetX();
+    Double_t dy = pix.GetY();
+
+    Int_t newpix = -1;
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        const Int_t     idx  = pix.GetNeighbor(i);
+        const MGeomPix &next = (*fGeomCam)[idx];
+
+        const Double_t x = next.GetX();
+        const Double_t y = next.GetY();
+
+        switch (fDirection)
+        {
+        case kRightTop:    if (x>=dx && y>dy) { newpix=idx; dy=y; } continue;
+        case kRight:       if (x>dx)          { newpix=idx; dx=x; } continue;
+        case kRightBottom: if (x>=dx && y<dy) { newpix=idx; dy=y; } continue;
+        case kLeftTop:     if (x<=dx && y>dy) { newpix=idx; dy=y; } continue;
+        case kLeft:        if (x<dx)          { newpix=idx; dx=x; } continue;
+        case kLeftBottom:  if (x<=dx && y<dy) { newpix=idx; dy=y; } continue;
+        }
+    }
+
+    if (newpix<0)
+        return -1;
+
+    const MGeomPix &np = (*fGeomCam)[newpix];
+
+    if (fNumFood==0 && np.TestBit(kHasDoor))
+        return -4;
+
+    if (np.TestBit(kHasBomb))
+        return -2;
+
+    if (np.TestBit(kHasWorm))
+        return -3;
+
+    return newpix;
+}
+
+Bool_t MagicSnake::HandleTimer(TTimer *timer)
+{
+    if (fDone || fPaused)
+        return kTRUE;
+
+    const Int_t newpix = ScanNeighbours();
+
+    switch (newpix)
+    {
+    case -1:
+        Done("You crashed! Don't drink and drive!", kRed);
+        break;
+    case -2:
+        Done("Ouch, you found the bomb!", kRed);
+        break;
+    case -3:
+        Done("Argh... don't eat yourself!", kRed);
+        break;
+    case -4:
+        Done("Congratulations! You won the game!", kGreen);
+        break;
+    default:
+        Step(newpix);
+    }
+
+    Update();
+
+    //cout << "Update " << flush;
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+
+    //cout << "Done." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MagicSnake.h	(revision 1638)
@@ -0,0 +1,101 @@
+#ifndef MARS_MagicSnake
+#define MARS_MagicSnake
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicSnake : public TObject
+{
+private:
+    enum {
+        kRightTop,
+        kRight,
+        kRightBottom,
+        kLeftBottom,
+        kLeft,
+        kLeftTop
+    };
+
+    enum
+    {
+        kBackground   = 50,
+        kHasBomb      = BIT(16),
+        kHasFood      = BIT(17),
+        kHasWorm      = BIT(18),
+        kHasTransport = BIT(19),
+        kHasDoor      = BIT(20),
+        kUserBits     = 0x7fc000 // 14-23 are allowed
+
+    };
+
+    Byte_t    fLength;          // actual length of worm
+    Int_t    *fArray;           // inices of pixels which are 'wormed'
+    Char_t    fDirection;       // actual direction of worm
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fTransport[2];    // pixel ids with the yellow transpoters
+    UInt_t    fNumPixels;       // number of pixels in the present geometry
+    Byte_t    fNumBombs;        // number of bombs in the field
+    Byte_t    fNumFood;         // number of food packages
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    TText    *fDone;            // TText showing the 'Game over'
+    TText    *fPaused;          // TText showing the 'Game over'
+    TText     fShow;            // TText showing the numbers of pixels and bombs
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray  *fPixels;     // array of all hexagons
+    TVirtualPad   *fDrawingPad; // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Remove(TObject *);
+    void   Done(TString, Int_t col);
+    void   Step(Int_t newpix);
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    Int_t  ScanNeighbours();
+    void   SetNewCamera(MGeomCam *);
+    void   SetWormColor();
+    void   Pause(Bool_t yes=kTRUE);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicSnake();
+    ~MagicSnake();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicSnake, 0) // Magic Camera Games
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/Makefile	(revision 1638)
@@ -0,0 +1,51 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Tools
+
+#
+# Library name to creatre
+#
+LIB   = mtools.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MagicSnake.cc \
+           MagicShow.cc \
+           MagicDomino.cc \
+           MagicCivilization.cc \
+           MineSweeper.cc
+
+SRCS    = $(SRCFILES)
+HEADERS = $(SRCFILES:.cc=.h)
+OBJS    = $(SRCFILES:.cc=.o) 
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
+
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.cc	(revision 1638)
@@ -0,0 +1,526 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MineSweeper
+// -----------
+//
+// Camera Display Games: Mine Sweeper
+//
+// Start the game by:
+//   MineSweeper mine;
+//
+// It is the well known Mine Sweeper.
+// Set a mark using a single mouse click.
+// Open a pixel using a double click.
+//
+// Try to open all pixels without bombs. If you open a pixel with no
+// bomb around all pixels around are opened.
+//
+// To restart the game use the context menu. It can only be accessed if
+// the game has been stopped (either because you win the game or because
+// you hit a bomb) With the context menu you can also toggle between
+// different camera layouts.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MineSweeper.h"
+
+#include <iostream.h>
+
+#include <TText.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MineSweeper);
+
+const Int_t MineSweeper::fColorBombs[7] = {
+    22,
+    kYellow,
+    kGreen,
+    kBlue,
+    kCyan,
+    kMagenta,
+    kRed
+};
+
+void MineSweeper::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+    fText->Delete();
+    fFlags->Delete();
+
+    delete fText;
+    delete fFlags;
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+void MineSweeper::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MineSweeper::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fNumBombs = fNumPixels/5;
+
+    fText   = new TClonesArray("TText",    fNumPixels);
+    fFlags  = new TClonesArray("TMarker",  fNumPixels);
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        TText &t = *new ((*fText)[i]) TText;
+        t.SetTextFont(122);
+        t.SetTextAlign(22);   // centered/centered
+        t.SetTextSize(0.3*h.GetD()/fRange);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        t.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        const MGeomPix &pix = (*fGeomCam)[i];
+
+        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        m.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MineSweeper::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MineSweeper::MineSweeper()
+    : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MineSweeper::~MineSweeper()
+{
+    Free();
+
+    delete fShow;
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MineSweeper::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+
+    //
+    // Adopt absolute sized of markers to relative range
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MineSweeper::Draw(Option_t *option)
+{
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+
+    if (fDrawingPad)
+        return;
+
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    if (!gPad)
+    {
+        /*TCanvas *c =*/ new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
+        //c->ToggleEventStatus();
+        fIsAllocated = kTRUE;
+    }
+    else
+        fIsAllocated = kFALSE;
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Draw the title text
+    //
+    fShow = new TText;
+    fShow->SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow->Draw();
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+}
+
+void MineSweeper::Update(Int_t num)
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Bombs: ";
+    txt += num;
+
+    fShow->SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MineSweeper::Reset()
+{
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Remove(GetText(i));
+        Remove(GetFlag(i));
+
+        (*this)[i].SetFillColor(kHidden);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+        GetFlag(i)->SetMarkerColor(kBlack);
+    }
+    Update(fNumBombs);
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumBombs; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBit(kHasBomb));
+
+        (*fGeomCam)[idx].SetBit(kHasBomb);
+    }
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+}
+
+void MineSweeper::Done(TString txt, Int_t col)
+{
+    for (unsigned int j=0; j<fNumPixels; j++)
+        if ((*fGeomCam)[j].TestBit(kHasBomb))
+        {
+            (*this)[j].SetFillColor(kBlack);
+            GetFlag(j)->SetMarkerColor(kWhite);
+        }
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDone->Draw();
+
+    fDrawingPad->SetFillColor(col);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+// ------------------------------------------------------------------------
+//
+// Check whether a hexagon should be opened and which color/number should
+// be visible
+//
+void MineSweeper::OpenHexagon(Int_t idx)
+{
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    if (pix.TestBit(kIsVisible))
+        return;
+
+    if (pix.TestBit(kHasFlag))
+        Remove(GetFlag(idx));
+
+    pix.SetBit(kIsVisible);
+    pix.ResetBit(kHasFlag);
+
+    Int_t cnt=0;
+    for (int j=0; j<pix.GetNumNeighbors(); j++)
+        if ((*fGeomCam)[pix.GetNeighbor(j)].TestBit(kHasBomb))
+            cnt++;
+
+    (*this)[idx].SetFillColor(fColorBombs[cnt]);
+
+    if (cnt)
+    {
+        TText *txt = GetText(idx);
+        TString str;
+        str += cnt;
+        txt->SetText(pix.GetX(), pix.GetY(), str);
+        txt->Draw();
+        return;
+    }
+
+    for (int j=0; j<pix.GetNumNeighbors(); j++)
+        OpenHexagon(pix.GetNeighbor(j));
+}
+
+void MineSweeper::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MineSweeper::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    if (event==kMouseMotion   || event==kMouseEnter    || event==kMouseLeave    ||
+        event==kButton1Up     || event==kButton2Up     || event==kButton3Up     ||
+        event==kButton1Motion || event==kButton2Motion || event==kButton3Motion ||
+                                 event==kButton2Double || event==kButton3Double ||
+        fDone)
+        return;
+
+    /*
+    if (event==kKeyPress && py==0x1000)
+    {
+        Reset();
+        return;
+    }
+    */
+
+    UInt_t idx;
+    for (idx=0; idx<fNumPixels; idx++)
+        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+            break;
+
+    if (idx==fNumPixels)
+        return;
+
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    if (event==kButton1Double)
+    {
+        OpenHexagon(idx);
+
+        if (pix.TestBit(kHasBomb))
+            Done("Argh... you hit the Bomb!!!", kRed);
+    }
+
+    if (event==kButton1Down && !pix.TestBit(kIsVisible))
+    {
+        if (pix.TestBit(kHasFlag))
+            Remove(GetFlag(idx));
+        else
+            GetFlag(idx)->Draw();
+
+        pix.InvertBit(kHasFlag);
+    }
+
+    UInt_t vis=fNumBombs;
+    UInt_t flg=fNumBombs;
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        if ((*fGeomCam)[i].TestBit(kIsVisible))
+            vis++;
+        if ((*fGeomCam)[i].TestBit(kHasFlag))
+            flg--;
+    }
+
+    Update(flg);
+
+    if (vis==fNumPixels && !fDone)
+        Done("Great! Congratulations, you did it!", kGreen);
+
+    fDrawingPad->Modified();
+
+    /*
+     switch (event)
+     {
+     case kNoEvent:       cout << "No Event" << endl; break;
+     case kButton1Down:   cout << "Button 1 down" << endl; break;
+     case kButton2Down:   cout << "Button 2 down" << endl; break;
+     case kButton3Down:   cout << "Button 3 down" << endl; break;
+     case kKeyDown:       cout << "Key down" << endl; break;
+     case kKeyUp:         cout << "Key up" << endl; break;
+     case kKeyPress:      cout << "Key press" << endl; break;
+     case kButton1Locate: cout << "Button 1 locate" << endl; break;
+     case kButton2Locate: cout << "Button 2 locate" << endl; break;
+     case kButton3Locate: cout << "Button 3 locate" << endl; break;
+    }
+    */
+}
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/MineSweeper.h	(revision 1638)
@@ -0,0 +1,78 @@
+#ifndef MARS_MineSweeper
+#define MARS_MineSweeper
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TText;
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MineSweeper : public TObject
+{
+private:
+    static const Int_t fColorBombs[7]; // colors for the hexagons
+
+    MGeomCam      *fGeomCam;       // pointer to camera geometry
+
+    UInt_t         fNumPixels;     // number of pixels in the present geometry
+    Int_t          fNumBombs;      // number of bombs in total
+    Float_t        fRange;         // the range in millimeters of the present geometry
+
+    TClonesArray  *fPixels;        // array of all hexagons
+    TClonesArray  *fText;          // array of all texts
+    TClonesArray  *fFlags;         // array of all texts
+
+    TText         *fDone;          // TText showing the 'Game over'
+    TText         *fShow;          // TText showing the numbers of pixels and bombs
+
+    UInt_t         fW;             // Width of canvas
+    UInt_t         fH;             // Height of canvas
+    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
+    Bool_t         fIsAllocated;
+
+    enum
+    {
+        kHidden    = 50,
+        kIsVisible = BIT(16),
+        kHasBomb   = BIT(17),
+        kHasFlag   = BIT(18),
+        kUserBits  = 0x7fc000 // 14-23 are allowed
+    };
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
+    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
+
+    void  Remove(TObject *);
+    void  OpenHexagon(Int_t idx);
+    void  Done(TString, Int_t);
+    void  Update(Int_t);
+    void  SetNewCamera(MGeomCam *);
+    void  DrawHexagons();
+    void  Free();
+
+    void  Paint(Option_t *option="");
+    void  Draw(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MineSweeper();
+    ~MineSweeper();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MineSweeper, 0) // Magic Camera Games
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/mtools/ToolsLinkDef.h	(revision 1638)
@@ -0,0 +1,13 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MineSweeper+;
+#pragma link C++ class MagicSnake+;
+#pragma link C++ class MagicShow+;
+#pragma link C++ class MagicDomino+;
+#pragma link C++ class MagicCivilization+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/Mars/readraw.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/Mars/readraw.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/Mars/readraw.cc	(revision 1638)
@@ -0,0 +1,167 @@
+#include <TSystem.h>
+
+#include "TFile.h"
+#include "TTree.h"
+#include "TBranch.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MLog.h"
+#include "MTime.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MInputStreamID.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This is an demonstration how to read in a merpped root file
+//
+/////////////////////////////////////////////////////////////////////////////
+
+int main(const int argc, const char **argv)
+{
+    gLog << "==================================================" << endl;
+    gLog << "                   ReadRaw v0.1                   " << endl;
+    gLog << "       MARS - Read and print raw data file        " << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">" << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+
+    //
+    // check for the right usage of the program
+    //
+    if (argc!=2)
+    {
+        gLog << "Sorry the usage is:" << endl;
+        gLog << "   readraw inputfile" << endl << endl;
+        return -1;
+    }
+
+    //
+    //     initialize ROOT  (this is obligatory here)
+    //
+    TROOT simple("readraw","Mars - Read and print raw data file");
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(argv[1], kFileExists))
+    {
+        gLog << "Sorry, the file '" << argv[1] << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    MRawRunHeader  *runheader = new MRawRunHeader();
+    MRawEvtHeader  *evtheader = new MRawEvtHeader();
+    MTime          *evttime   = new MTime();
+    MRawEvtData    *evtdata   = new MRawEvtData();
+    MRawCrateArray *evtcrate  = new MRawCrateArray();
+
+    MMcEvt         *evtmc     = new MMcEvt() ; 
+    MMcTrig        *trigmc    = new MMcTrig() ; 
+
+    //
+    //  open the file
+    //
+    gLog << " Open the file " << endl ; 
+    TFile input(argv[1], "READ");
+
+    //
+    // open the Run Header and read in
+    //
+    gLog << " Check the RunHeader " << endl ; 
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+    
+    if (!runtree)
+    {
+        gLog << endl
+            << "  WARNING: This file has NO RunHeader "
+            << endl << endl ;
+    }
+    else
+    {
+        gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
+
+        runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+        runtree->GetEvent(0);
+
+        runheader->Print();
+    }
+
+    //
+    // open the DataTree and read in 
+    //
+    gLog << " Check the Event Tree " << endl ; 
+    TTree *evttree = (TTree*) input.Get("Events") ;
+    gLog << " Check all the Branches in the Tree " << endl ; 
+    
+    //
+    //  check the branches in the Tree 
+    //
+    TIter Next(evttree->GetListOfBranches());
+    TBranch *branch=NULL;
+    
+    while ((branch=(TBranch*)Next()))
+    {
+        //
+        // Get Name of Branch
+        //
+        const char *name = branch->GetName();
+	
+        if (!strcmp(name, "MRawEvtHeader"))
+            evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
+
+        if (!strcmp(name, "MTime"))
+            evttree->GetBranch("MTime")->SetAddress(&evttime);
+
+        if (!strcmp(name, "MRawEvtData"))
+            evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+
+        if (!strcmp(name, "MRawCrateArray"))
+            evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
+
+        if (!strcmp(name, "MMcTrig"))
+            evttree->GetBranch("MMcTrig")->SetAddress(&trigmc);
+
+        if (!strcmp(name, "MMcEvt"))
+            evttree->GetBranch("MMcEvt")->SetAddress(&evtmc);
+    } 
+
+    //
+    // loop over all entries 
+    //
+    Int_t nent = (Int_t)evttree->GetEntries();
+
+    gLog << endl << endl;
+    gLog << " Entries in Tree Data: " << dec << nent << endl;
+
+    for (Int_t i = 0; i<nent; i++)
+    {
+        gLog << "Entry: " << i << endl;
+
+        //
+        // readin event with the selected branches
+        //
+        evttree->GetEvent(i);
+
+	evtmc->Print();
+	
+        evtheader->Print();
+        evttime->Print();
+        evtcrate->Print();
+        evtdata->Print();
+    } 
+    
+    //   end of small readin program 
+
+    return 0;
+}
+
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MFadcDefine.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MFadcDefine.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MFadcDefine.h	(revision 1638)
@@ -0,0 +1,43 @@
+//
+//  --> Frist of all the WIDTH of the time slice of one FADC slice 
+//      this is 3.33333 nsec.
+//
+#define WIDTH_FADC_TIMESLICE   (50./15.)       //  this means 3.33 nsec 
+//
+//  --> Second the number of slices to fill in MFADC. This must by 
+//      connected to the MTrigger class. The time of interest must be
+//      equal in both classes. 
+//
+#define SLICES_MFADC           (TOTAL_TRIGGER_TIME / WIDTH_FADC_TIMESLICE)
+//
+//  --> The amount of FADC slice written to the raw format.
+//
+#define FADC_SLICES  15
+//
+//  --> The amount of ns before trigger that would be read from the ADC
+//      in oder to show also the start of the pulse before the
+//      the trigger time.
+//
+#define TIME_BEFORE_TRIGGER    10.
+//  --> like the trigger the FADC value will also have a standard response
+//      to one single Photo electron. This response is binned with smaller
+//      bins. The WIDTH of that response function is done here. 
+// 
+#define SUBBINS     5.
+#define WIDTH_RESPONSE_MFADC   (WIDTH_FADC_TIMESLICE /  SUBBINS )  
+// 5 sub-bin in one FADC slice 
+//
+//  --> the number of Response slices
+//
+#define RESPONSE_SLICES_MFADC   45         
+//
+//
+#define MFADC_RESPONSE_FWHM        5.0
+
+//
+//
+#define MFADC_RESPONSE_AMPLITUDE   4.0
+//
+// -->  The maximum number of FADC channels
+//      Most likely it will be always equal to CAMERA_PIXELS 
+#define MFADC_CHANNELS  577
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.cc	(revision 1638)
@@ -0,0 +1,114 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch  11/2002 (blanch@ifae.es)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcConfigRunHeader
+//
+// Root storage container for the MONTE CARLO CONFIGURATION information
+//
+// It saves in a root file all the infromation about values in the configuration
+// files used in the Monte Carlo production: MagicDef (definition of the teslescope),
+// Reflectivity.dat (mirror reflectivities), qe.dat (PMT QEs), axisdev.dat (mirrors 
+// deviations) and lightguides.dat (Effect of the Light Guides).
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MMcConfigRunHeader.h"
+
+#include <fstream.h>
+#include <iomanip.h>
+
+#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MMcConfigRunHeader);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcConfigRunHeader::MMcConfigRunHeader(const char *name, const char *title)
+    : fNumMirrors(0), fNumPMTs(0), fIncidentTheta(181), fLightGuidesFactor(181)
+{
+    fName  = name  ? name  : "MMcConfigRunHeader";
+    fTitle = title ? title : "Mc Configuration Information";
+
+    fRadiusMirror=-1;
+    fFocalDist   =-1;
+    fFocalStdev  =-1;
+    fPointSpread =-1;
+    fPointStdev  =-1;
+    fDevAdjust   =-1;
+    fBlackSpot   =-1;
+    fCameraWidth =-1;
+
+    fMirrors = new TClonesArray("MGeomMirror", 0);
+    fPMTs = new TClonesArray("MGeomPMT", 0);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING Please contact Oscar
+//
+void MMcConfigRunHeader::SetMagicDef(Float_t radius,
+				     Float_t focal,
+				     Float_t stdfocal,
+				     Float_t point,
+				     Float_t stdpoint,
+				     Float_t adjust,
+				     Float_t spot,
+				     Float_t camwidth)
+{
+    fRadiusMirror=radius;
+    fFocalDist=focal;
+    fFocalStdev=stdfocal;
+    fPointSpread=point;
+    fPointStdev=stdpoint;
+    fDevAdjust=adjust;
+    fBlackSpot=spot;
+    fCameraWidth=camwidth;
+    
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING Please contact Oscar
+//
+void  MMcConfigRunHeader::SetLightGuides(const TArrayF &theta, const TArrayF &factor)
+{
+    if (fIncidentTheta.GetSize()    !=theta.GetSize() ||
+        fLightGuidesFactor.GetSize()!=factor.GetSize())
+    {
+        *fLog<< err << dbginf << "fIncidentTheta or fLightGuidesFactor ";
+        *fLog << "do not have size of setting arrays" << endl;
+        return;
+    }
+
+    fIncidentTheta = theta;
+    fLightGuidesFactor = factor;
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcConfigRunHeader.h	(revision 1638)
@@ -0,0 +1,78 @@
+#ifndef MARS_MMcConfigRunHeader
+#define MARS_MMcConfigRunHeader
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+#ifndef MARS_MGeomMirror
+#include "MGeomMirror.h"
+#endif
+#ifndef MARS_MGeomPMT
+#include "MGeomPMT.h"
+#endif
+
+class MGeomMirror;
+class MGeomPMT;
+
+class MMcConfigRunHeader : public MParContainer
+{
+private:
+    // Mirror Information
+    UShort_t      fNumMirrors;
+    Float_t       fRadiusMirror;// [cm] Radius of a single mirror
+    TClonesArray *fMirrors;     // FIXME: Change TClonesArray away from a pointer?
+
+    // Magic Def Parameters
+    Float_t fFocalDist;         // [cm] Focal distance
+    Float_t fFocalStdev;       // [cm] Standard deviation of focal distance
+    Float_t fPointSpread;       // [cm] Point spread function
+    Float_t fPointStdev;        // [cm] Standard deviation of point spread function
+    Float_t fDevAdjust;         // [cm] Standard deviation of the adjustment value
+    Float_t fBlackSpot;         // [cm] Radius of black spot in the mirror center
+    Float_t fCameraWidth;       // [cm] Radius on the camera plain 
+                                // inside which the phe are kept.
+
+    // QE Information
+    UInt_t  fNumPMTs;
+    TClonesArray  *fPMTs;
+
+    // Light Guides Information
+    TArrayF fIncidentTheta;    // [deg]
+    TArrayF fLightGuidesFactor;// []
+
+public:
+    MMcConfigRunHeader(const char *name=NULL, const char *title=NULL);
+    ~MMcConfigRunHeader() { delete fMirrors; delete fPMTs; }
+
+    void SetMagicDef(Float_t radius, Float_t focal, Float_t stdfocal, Float_t point,
+		     Float_t stdpoint, Float_t adjust, Float_t spot, Float_t camwidth);
+    void SetLightGuides(const TArrayF &theta, const TArrayF &factor);
+
+    UInt_t GetNumMirror() const { return fNumMirrors; }
+    void   InitSizeMirror(UInt_t num) { fMirrors->Expand(num); }
+
+    UInt_t GetNumPMTs() const { return fNumPMTs; }
+    void   InitSizePMTs(UInt_t num) { fPMTs->Expand(num); }
+
+    void   AddMirror(Int_t id)
+    {
+        new ((*fMirrors)[fNumMirrors++]) MGeomMirror(id);
+    }
+
+    void   AddPMT(Int_t id)
+    {
+        new ((*fPMTs)[fNumPMTs++]) MGeomPMT(id);
+    }
+
+    MGeomMirror &GetMirror(int i)  { return *(MGeomMirror*)(fMirrors->UncheckedAt(i)); }
+    MGeomMirror &GetMirror(int i) const { return *(MGeomMirror*)(fMirrors->UncheckedAt(i)); }
+
+    MGeomPMT &GetPMT(int i)  { return *(MGeomPMT*)(fPMTs->UncheckedAt(i)); }
+    MGeomPMT &GetPMT(int i) const { return *(MGeomPMT*)(fPMTs->UncheckedAt(i)); }
+
+    ClassDef(MMcConfigRunHeader, 1)  // class for monte carlo configuration information
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.cc
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.cc	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.cc	(revision 1638)
@@ -0,0 +1,137 @@
+/* ======================================================================== *\
+!
+! *
+! * 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): Oscar Blanch  11/2002 (blanch@ifae.es)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcCorsikaRunHeader
+//
+// Root storage container for the CORSIKA run header
+//
+// It saves in a root file all variable that are in the CORSIKA run header, except
+// dummies.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MMcCorsikaRunHeader.h"
+
+ClassImp(MMcCorsikaRunHeader);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcCorsikaRunHeader::MMcCorsikaRunHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcCorsikaRunHeader";
+    fTitle = title ? title : "Translation of the CORSIKA header";
+
+    fRunNumber = 0;
+    fDate = 0;
+    fCorsikaVersion = 0;
+    fNumObsLev = 0;
+
+    for (int i=0; i<10; i++)
+        fHeightLev[i]=0;
+
+    fSlopeSpec = 0;
+    fELowLim = 0;
+    fEUppLim = 0;
+    fEGS4flag = 0;
+    fNKGflag = 0;
+    fEcutoffh = 0;
+    fEcutoffm = 0;
+    fEcutoffe = 0;
+    fEcutoffg = 0;
+
+    for(int i=0; i<50; i++)  fC[i] = 0;
+    for(int i=0; i<40; i++)  fCKA[i] = 0;
+    for(int i=0; i<5; i++)  fCETA[i] = 0;
+    for(int i=0; i<11; i++)  fCSTRBA[i] = 0;
+    for(int i=0; i<5; i++)
+    {
+        fAATM[i] = 0;
+        fBATM[i] = 0;
+        fCATM[i] = 0;
+    }
+    for (int i=0;i<4; i++)  fNFL[i] = 0;
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Fill Corsika Run Header
+//
+void MMcCorsikaRunHeader::Fill(const Float_t  runnumber,
+                               const Float_t  date,
+			       const Float_t  vers,
+			       const Float_t  numobslev,
+			       const Float_t  height[10],
+			       const Float_t  slope,
+			       const Float_t  elow,
+			       const Float_t  eupp,
+			       const Float_t  egs4,
+			       const Float_t  nkg,
+			       const Float_t  eh,
+			       const Float_t  em,
+			       const Float_t  ee,
+			       const Float_t  eg,
+			       const Float_t  c[50],
+			       const Float_t  cka[40],
+			       const Float_t  ceta[5],
+			       const Float_t  cstrba[11],
+			       const Float_t  aatm[5],
+			       const Float_t  batm[5],
+			       const Float_t  catm[5],
+			       const Float_t  nfl[4])
+{
+    fRunNumber = runnumber;
+    fDate = date;
+    fCorsikaVersion = vers;
+    fNumObsLev = numobslev;
+
+    for (int i=0; i<10; i++)
+        fHeightLev[i]=height[i];
+
+    fSlopeSpec = slope;
+    fELowLim = elow;
+    fEUppLim = eupp;
+    fEGS4flag = egs4;
+    fNKGflag = nkg;
+    fEcutoffh = eh;
+    fEcutoffm = em;
+    fEcutoffe = ee;
+    fEcutoffg = eg;
+
+    for (int i=0; i<50; i++)  fC[i] = c[i];
+    for (int i=0; i<40; i++)  fCKA[i] = cka[i];
+    for (int i=0; i<5 ; i++)  fCETA[i] = ceta[i];
+    for (int i=0; i<11; i++)  fCSTRBA[i] = cstrba[i];
+    for (int i=0; i<5; i++)
+    {
+        fAATM[i] = aatm[i];
+        fBATM[i] = batm[i];
+        fCATM[i] = catm[i];
+    }
+    for (int i=0; i<4; i++)  fNFL[i] = nfl[i];
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcCorsikaRunHeader.h	(revision 1638)
@@ -0,0 +1,76 @@
+#ifndef MARS_MMcCorsikaRunHeader
+#define MARS_MMcCorsikaRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MMcCorsikaRunHeader                                               //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+
+class MMcCorsikaRunHeader : public MParContainer
+{
+private:
+    // Header copied directly from CORSIKA header, skiping dummy values.
+    // The propouse of this container is being able to cmopare with
+    // Corsika run Header
+    // See CORSIKA manual for explanations
+    Float_t fRunNumber;
+    Float_t fDate;
+    Float_t fCorsikaVersion;
+    Float_t fNumObsLev;
+    Float_t fHeightLev[10];
+    Float_t fSlopeSpec;  // Slope of primaries' energy spectrum
+    Float_t fELowLim;
+    Float_t fEUppLim;    // Limits of energy range for generation
+    Float_t fEGS4flag;
+    Float_t fNKGflag;
+    Float_t fEcutoffh;
+    Float_t fEcutoffm;
+    Float_t fEcutoffe;
+    Float_t fEcutoffg;
+
+    // Physical constants and interaction flags (see CORSIKA manual):
+    Float_t fC[50];
+    Float_t fCKA[40];
+    Float_t fCETA[5];
+    Float_t fCSTRBA[11];
+    Float_t fAATM[5];
+    Float_t fBATM[5];
+    Float_t fCATM[5];
+    Float_t fNFL[4];
+
+public:
+    MMcCorsikaRunHeader(const char *name=NULL, const char *title=NULL);
+
+    void Fill(const Float_t  runnumber,
+              const Float_t  date,
+              const Float_t  vers,
+              const Float_t  fNumObsLev,
+              const Float_t  height[10],
+              const Float_t  slope,
+              const Float_t  elow,
+              const Float_t  eupp,
+              const Float_t  egs4,
+              const Float_t  nkg,
+              const Float_t  eh,
+              const Float_t  em,
+              const Float_t  ee,
+              const Float_t  eg,
+              const Float_t  c[50],
+              const Float_t  cka[40],
+              const Float_t  ceta[5],
+              const Float_t  cstrba[11],
+              const Float_t  aatm[5],
+              const Float_t  batm[5],
+              const Float_t  catm[5],
+              const Float_t  nfl[4]
+             );
+
+    ClassDef(MMcCorsikaRunHeader, 1) // storage container for corsika setup information
+};
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.cxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.cxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.cxx	(revision 1638)
@@ -0,0 +1,271 @@
+#include "MMcEvt.hxx"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+//==========
+// MMcEvt
+//    
+// This class handles and contains the MonteCarlo information
+// with which the events have been generated
+// This information exists for each event.
+ 
+
+
+ClassImp(MMcEvt);
+
+
+
+MMcEvt::MMcEvt()
+{
+    //
+    //  default constructor
+    //  set all values to zero
+    fName  = "MMcEvt";
+    fTitle = "Event info from Monte Carlo";
+
+    Clear();
+}
+
+MMcEvt::MMcEvt( UInt_t  fEvtNum,
+		UShort_t usPId,
+		Float_t  fEner,
+		Float_t  fThi0,
+		Float_t  fFirTar,
+		Float_t  fzFirInt,
+		Float_t  fThet, 
+		Float_t  fPhii, 
+		Float_t  fCorD, 
+		Float_t  fCorX, 
+		Float_t  fCorY,
+		Float_t  fImpa,
+		Float_t  fTPhii,
+		Float_t  fTThet,
+		Float_t  fTFirst,
+		Float_t  fTLast,
+		Float_t  fL_Nmax,
+		Float_t  fL_t0,
+		Float_t  fL_tmax,
+		Float_t  fL_a,
+		Float_t  fL_b,
+		Float_t  fL_c,
+		Float_t  fL_chi2,
+		UInt_t   uiPin, 
+		UInt_t   uiPat,  
+		UInt_t   uiPre, 
+		UInt_t   uiPco,  
+		UInt_t   uiPelS,
+		UInt_t   uiPelC ) {
+
+    fName  = "MMcEvt";
+    fTitle = "Event info from Monte Carlo";
+  //
+  //  constuctor II 
+  //
+  //  All datamembers are parameters. 
+  //
+  //  Don't use this memberfunction in analysis
+  //  
+
+  fEvtNumber = fEvtNum;
+  fPartId = usPId  ;
+  fEnergy  = fEner  ;
+  fThick0 = fThi0;
+  fFirstTarget = fFirTar;
+  fZFirstInteraction = fzFirInt;
+
+  fTheta   = fThet ;
+  fPhi     = fPhii ;
+
+  fCoreD   = fCorD ;
+  fCoreX   = fCorX ;
+  fCoreY   = fCorY ;
+  fImpact  = fImpa ;
+
+  fTelescopePhi = fTPhii;
+  fTelescopeTheta = fTThet;
+  fTimeFirst = fTFirst;
+  fTimeLast = fTLast;
+  fLongiNmax = fL_Nmax;
+  fLongit0 = fL_t0;
+  fLongia = fL_a;
+  fLongib = fL_b;
+  fLongic = fL_c;
+  fLongichi2 = fL_chi2;
+
+
+  fPhotIni      = uiPin ;
+  fPassPhotAtm  = uiPat ;
+  fPassPhotRef  = uiPre ;
+  fPassPhotCone = uiPco ;
+  fPhotElfromShower = uiPelS ;
+  fPhotElinCamera   = uiPelC ;
+}
+
+
+
+MMcEvt::~MMcEvt() {
+  //
+  //  default destructor
+  //
+}
+
+
+
+
+void MMcEvt::Clear(Option_t *opt)
+{
+    //
+    //  reset all values to values as nonsense as possible
+    //
+    fPartId = 0;
+    fEnergy = -1;
+
+    fTheta = 0;
+    fPhi   = 0;
+
+    fCoreD  =  0;
+    fCoreX  =  0;
+    fCoreY  =  0;
+    fImpact = -1;
+
+    fPhotIni          = 0;
+    fPassPhotAtm      = 0;
+    fPassPhotRef      = 0;
+    fPassPhotCone     = 0;
+    fPhotElfromShower = 0;
+    fPhotElinCamera   = 0;
+}
+
+void MMcEvt::Fill( UInt_t  fEvtNum,
+		   UShort_t usPId, 
+		   Float_t  fEner, 
+		   Float_t  fThi0,
+		   Float_t  fFirTar,
+		   Float_t  fzFirInt,
+		   Float_t  fThet, 
+		   Float_t  fPhii, 
+		   Float_t  fCorD, 
+		   Float_t  fCorX, 
+		   Float_t  fCorY,
+		   Float_t  fImpa, 
+		   Float_t  fTPhii,
+		   Float_t  fTThet,
+		   Float_t  fTFirst,
+		   Float_t  fTLast,
+		   Float_t  fL_Nmax,
+		   Float_t  fL_t0,
+		   Float_t  fL_tmax,
+		   Float_t  fL_a,
+		   Float_t  fL_b,
+		   Float_t  fL_c,
+		   Float_t  fL_chi2,
+		   UInt_t   uiPin, 
+		   UInt_t   uiPat,  
+		   UInt_t   uiPre, 
+		   UInt_t   uiPco,  
+		   UInt_t   uiPelS,  
+		   UInt_t   uiPelC ) {
+  //
+  //  All datamembers are filled with the correspondin parameters. 
+  //
+  //  Don't use this memberfunction in analysis
+  //  
+
+  fEvtNumber = fEvtNum;
+  fPartId = usPId  ;
+  fEnergy = fEner  ;
+  fThick0 = fThi0;
+  fFirstTarget = fFirTar;
+  fZFirstInteraction = fzFirInt;
+
+  fTheta  = fThet ;
+  fPhi    = fPhii ;
+
+  fCoreD  = fCorD ;
+  fCoreX  = fCorX ;
+  fCoreY  = fCorY ;
+  fImpact = fImpa ;
+
+  fTelescopePhi = fTPhii;
+  fTelescopeTheta = fTThet;
+  fTimeFirst = fTFirst;
+  fTimeLast = fTLast;
+  fLongiNmax = fL_Nmax;
+  fLongit0 = fL_t0;
+  fLongia = fL_a;
+  fLongib = fL_b;
+  fLongic = fL_c;
+  fLongichi2 = fL_chi2;
+
+  fPhotIni      = uiPin ;
+  fPassPhotAtm  = fPhotIni-uiPat ;
+  fPassPhotRef  = fPassPhotAtm-uiPre ;
+  fPassPhotCone = uiPco ;
+  fPhotElfromShower = uiPelS ;
+  fPhotElinCamera = uiPelC ;
+}
+
+/*
+void MMcEvt::AsciiWrite(ofstream &fout) const
+{
+    fout << fEnergy << " ";
+    fout << fTheta ;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of the container.
+//
+//  if you specify an option only the requested data members are printed:
+//  allowed options are:
+//   id, energy, impact
+//
+void MMcEvt::Print(Option_t *opt) const
+{
+    //
+    //  print out the data member on screen
+    //
+    TString str(opt);
+    if (str.IsNull())
+    {
+        *fLog << all << endl;
+        *fLog << "Monte Carlo output:" << endl;
+        *fLog << " Particle Id:    ";
+        switch(fPartId)
+        {
+        case kGAMMA:
+            *fLog << "Gamma" << endl;
+            break;
+        case kPROTON:
+            *fLog << "Proton" << endl;
+            break;
+        case kHELIUM:
+            *fLog << "Helium" << endl;
+            break;
+        }
+        *fLog << " Energy:         " << fEnergy << "GeV" << endl;
+        *fLog << " Impactpar.:     " << fImpact/100 << "m" << endl;
+        *fLog << " Photoelectrons: " << fPhotElfromShower << endl;
+        *fLog << endl;
+        return;
+    }
+    if (str.Contains("id", TString::kIgnoreCase))
+        switch(fPartId)
+        {
+        case kGAMMA:
+            *fLog << "Particle: Gamma" << endl;
+            break;
+        case kPROTON:
+            *fLog << "Particle: Proton" << endl;
+            break;
+        case kHELIUM:
+            *fLog << "Particle: Helium" << endl;
+            break;
+        }
+    if (str.Contains("energy", TString::kIgnoreCase))
+        *fLog << "Energy: " << fEnergy << "GeV" << endl;
+    if (str.Contains("impact", TString::kIgnoreCase))
+        *fLog << "Impact: " << fImpact << "cm" << endl;
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.hxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.hxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcEvt.hxx	(revision 1638)
@@ -0,0 +1,136 @@
+#ifndef __MMcEvt__
+#define __MMcEvt__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MMcEvt : public MParContainer
+{
+ private:
+  UInt_t      fEvtNumber;
+  UShort_t     fPartId;             // Type of particle
+  Float_t      fEnergy;             // [GeV] Energy
+  Float_t      fThick0;             // [g/cm2]
+  Float_t      fFirstTarget;        // []
+  Float_t      fZFirstInteraction;  // [cm]
+
+  Float_t fTheta;           // [rad] Theta angle of event 
+  Float_t fPhi;             // [rad] Phi angle of event 
+
+  Float_t fCoreD;           // [cm] Core d pos
+  Float_t fCoreX;           // [cm] Core x pos
+  Float_t fCoreY;           // [cm] Core y pos
+  Float_t fImpact;          // [cm] impact parameter
+
+  // Up to here, the info from the CORSIKA event header. 
+
+  // Telescope orientation: 
+  Float_t	fTelescopePhi;    // [rad]
+  Float_t	fTelescopeTheta;  // [rad]
+
+  // Time of first and last photon:
+  Float_t      fTimeFirst;   // [ns]
+  Float_t      fTimeLast;    // [ns]
+
+  // 6 parameters and chi2 of the NKG fit to the longitudinal 
+  // particle distribution. See CORSIKA manual for explanation,
+  // section 4.42 "Longitudinal shower development": 
+  //
+  Float_t       fLongiNmax;   // [particles]
+  Float_t       fLongit0;     // [g/cm2]
+  Float_t       fLongitmax;   // [g/cm2]
+  Float_t       fLongia;      // [g/cm2]
+  Float_t       fLongib;      // []
+  Float_t       fLongic;      // [cm2/g]
+  Float_t       fLongichi2;
+
+  UInt_t fPhotIni;          // [ph] Initial number of photons
+  UInt_t fPassPhotAtm;      // [ph] Passed atmosphere
+  UInt_t fPassPhotRef;      // [ph] Passed reflector(reflectivity + effective area)
+  UInt_t fPassPhotCone;     // [ph] Passed glas
+  UInt_t fPhotElfromShower; // [phe] Passed qe coming from the shower
+  UInt_t fPhotElinCamera;   // [phe] usPhotElfromShower + mean of phe
+                            // from NSB
+
+ public:
+  MMcEvt() ;
+  
+  MMcEvt( UInt_t, UShort_t, Float_t, Float_t, Float_t,
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, 
+	  Float_t, Float_t, Float_t, Float_t, Float_t, Float_t, 
+	  UInt_t, UInt_t, UInt_t, UInt_t, UInt_t, UInt_t ) ; 
+  
+  ~MMcEvt(); 
+
+  void Clear(Option_t *opt=NULL);
+
+  void Fill( UInt_t, UShort_t, Float_t, Float_t, Float_t, 
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     Float_t, Float_t, Float_t, Float_t, Float_t, Float_t,
+	     UInt_t, UInt_t, UInt_t, UInt_t, UInt_t, UInt_t ) ; 
+
+  //virtual void AsciiWrite(ofstream &fout) const;
+
+  void Print(Option_t *opt=NULL) const;
+
+  Short_t GetPartId() const { return fPartId; }       //Get Type of particle
+  Float_t GetEnergy() const { return fEnergy; }        //Get Energy
+
+  Float_t GetTheta() const { return fTheta; }          //Get Theta angle
+  Float_t GetPhi() const { return fPhi ;  }            //Get Phi angle
+
+/*    Float_t GetCoreD() { return fCoreD; }          //Get Core d pos */
+/*    Float_t GetCoreX() { return fCoreX; }          //Get Core x pos */
+/*    Float_t GetCoreY() { return fCoreY; }          //Get Core y pos */
+  Float_t GetImpact() const { return fImpact;}         //Get impact parameter 
+
+/*    UInt_t GetPhotIni() { return fPhotIni; }           //Get Initial photons */
+/*    UInt_t GetPassPhotAtm() { return fPassPhotAtm;}    //Get Passed atmosphere */
+/*    UInt_t GetPassPhotRef() { return fPassPhotRef; }   //Get Passed reflector */
+/*    UInt_t GetPassPhotCone() { return fPassPhotCone; } //Get Passed glas */
+  UInt_t GetPhotElfromShower() { return fPhotElfromShower; }             //Get Passed qe from shower
+/*    UInt_t GetPhotElinCamera() { return fPhotElinCamera; }             //Get Passed qe total*/
+
+
+  void SetPartId(Short_t PartId)
+  {fPartId=PartId;}             //Set Type of particle 
+
+  void SetEnergy(Float_t Energy)
+  { fEnergy=Energy; }              //Set Energy 
+ 
+  void SetTheta(Float_t Theta) 
+  { fTheta=Theta; }                //Set Theta angle 
+
+  void SetPhi(Float_t Phi) 
+  { fPhi=Phi;  }                   //Set Phi angle 
+ 
+  void SetCoreD(Float_t CoreD) 
+  { fCoreD=CoreD; }                //Set Core d pos
+
+  void SetCoreX(Float_t CoreX)
+  { fCoreX=CoreX; }                //Set Core x pos 
+
+  void SetCoreY(Float_t CoreY ) 
+  { fCoreY=CoreY; }                //Set Core y pos
+
+  void SetImpact(Float_t Impact) 
+  { fImpact=Impact;}               //Set impact parameter
+  
+/*    void SetPhotIni(Short_t PhotIni)  */
+/*      { fPhotIni=PhotIni; }                 //Set Initial photons */
+/*    void SetPassPhotAtm(Short_t PassPhotAtm)  */
+/*      { fPassPhotAtm=PassPhotAtm;}         //Set Passed atmosphere */
+/*    void SetPassPhotRef(Short_t PassPhotRef)  */
+/*      { fPassPhotRef=PassPhotRef ; }       //Set Passed reflector */
+/*    void SetPassPhotCone(Short_t PhotCon)  */
+/*      { fPassPhotCone=PhotCon; }           //Set Passed glas */
+
+
+  ClassDef(MMcEvt, 2)  //Stores Montecarlo Information of one event (eg. the energy)
+
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.cxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.cxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.cxx	(revision 1638)
@@ -0,0 +1,61 @@
+#include "MMcFadcHeader.hxx"
+
+#include <iostream.h>
+
+//==========
+// MMcFadcHeader
+//    
+// This class contains the MonteCarlo information
+// of the FADC simulation for the current run.
+// The information is saved only once, whatever the
+// number of events is
+ 
+
+
+ClassImp(MMcFadcHeader);
+
+
+
+MMcFadcHeader::MMcFadcHeader(const char *name, const char *title) {
+  //
+  //  default constructor
+
+  fName  = name  ? name  : "MMcFadcHeader";
+  fTitle = title ? title : "Fadc Header Information from Monte Carlo";
+
+  //  set all values to zero
+
+  Int_t i;
+
+  fFadcShape=0.0; 
+  fAmplFadc=MFADC_RESPONSE_AMPLITUDE;
+  fFwhmFadc=MFADC_RESPONSE_FWHM;
+
+  for(i=0;i<MFADC_CHANNELS;i++){
+    fPedesMean[i]= 0.0    ;
+    fElecNoise[i]=-1.0   ;
+  }
+}
+
+MMcFadcHeader::~MMcFadcHeader(){
+  //
+  //  default destructor
+  //
+}
+
+
+void MMcFadcHeader::Print(Option_t *Option) const {
+  //
+  //  print out the data member on screen
+  //
+  cout << endl;
+  cout << "Monte Carlo Fadc output:" << endl;
+  cout << " Shape type of the signal: "       << fFadcShape << endl;
+  cout << " Amplitude of the trigger in mV: " << fAmplFadc << endl;
+  cout << " Width of the signal in nsec: "    << fFwhmFadc << endl;
+  cout << " Pedestals and ElecNoise in fadc counts: " << endl;
+  for (int i=0;i<MFADC_CHANNELS;i++){
+    cout << " Pixel "<<i<<": "<<fPedesMean[i]<<"  "<<fElecNoise[i]<<endl;
+  }
+  cout << endl ; 
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcFadcHeader.hxx	(revision 1638)
@@ -0,0 +1,64 @@
+#ifndef __MMcFadcHeader__
+#define __MMcFadcHeader__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MFadcDefine.h"
+
+class MMcFadcHeader : public MParContainer{
+ private:
+
+  Float_t  fFadcShape   ;   // a number that indicate the shape type of 
+                            // the signal   
+                            // = 0 --> a gaussian  
+  Float_t  fAmplFadc    ;   // the amplitude of the trigger in mV
+  Float_t  fFwhmFadc    ;   // the width of the signal in nsec
+  Float_t  fPedesMean[MFADC_CHANNELS]    ;  //  The mean value for the pedestal
+                                            //  of each pixel (channel)
+  Float_t  fElecNoise[MFADC_CHANNELS]   ;  //  The rms value in the pedestal 
+                                           //  due to the electronics for
+                                           //  each pixel (channel)
+
+ public:
+  MMcFadcHeader(const char *name=NULL, const char *title=NULL);
+
+  ~MMcFadcHeader(); 
+
+  void Print(Option_t *opt=NULL) const;
+  
+  void SetShape(Float_t shape){
+    fFadcShape=shape;
+  }
+
+  void SetAmplitud(Float_t amp){
+    fAmplFadc=amp;
+ }
+
+  void SetFwhm(Float_t fwhm){
+    fFwhmFadc=fwhm;
+  }
+
+  void SetPedestal(Float_t *mean, Int_t dim){
+    for (Int_t i=0;i<dim;i++)
+      fPedesMean[i]=mean[i];
+  }
+
+  void SetElecNoise(Float_t *sigma, Int_t dim){
+    for (Int_t i=0;i<dim;i++)
+      fElecNoise[i]=sigma[i];
+  }
+  
+  Float_t GetPedestal(UInt_t i) const    { return fPedesMean[i]; }
+  Float_t GetPedestalRms(UInt_t i) const { return fElecNoise[i]; }
+  Float_t GetAmplitud() const { return fAmplFadc; }
+
+  UInt_t GetNumPixel() const { return MFADC_CHANNELS; }
+
+  ClassDef(MMcFadcHeader, 1)  //Stores Montecarlo Information describing the FADC behaviour
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.cxx	(revision 1638)
@@ -0,0 +1,247 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcRunHeader
+//
+// Root storage container for the RUN MONTE CARLO HEADER information
+//
+// This the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The following data member have been introduced in this second version 
+// and they do not exist in the previous one:
+//
+//  Float_t fMcRunNumber;      Run Number
+//  UInt_t  fProductionSite;   code to know where the run was generated
+//  Float_t fDateRunMMCs;      Date of the MMCs production
+//  Float_t fDateRunCamera;    Date, when the Camera program is run.
+//  Byte_t  fRawEvt;           RawEvt[Data,Hedaer] stored or not
+//  Byte_t  fElecNoise;        Electronic Noise simulated or not
+//  Byte_t  fStarFieldRotate;  Is the starfield rotation switched on (1) or
+//                             off (0)
+//  Float_t fCWaveLower;       Wavelength limits for the Cerenkov photons
+//  Float_t fCWaveUpper;
+//  UInt_t  fNumObsLev;        Observation levels
+//  Float_t fHeightLev[10];
+//  Float_t fSlopeSpec;        Spectral index
+//
+//  Third version:
+//
+//  Byte_t fOpticLinksNoise;   Flag to state if the optic noise is simualted or not
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MMcRunHeader.hxx"
+
+#include <fstream.h>
+#include <iomanip.h>
+
+#include "MLog.h"
+
+ClassImp(MMcRunHeader);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+//
+MMcRunHeader::MMcRunHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcRunHeader";
+    fTitle = title ? title : "Raw Run Header Information";
+
+    fMcRunNumber =0;
+    fProductionSite = 0;
+    fDateRunMMCs = 0;
+    fDateRunCamera = 0;
+    fNumTrigCond = 0;
+    fAllEvtsTriggered = 0 ;
+    fMcEvt = 0;
+    fMcTrig = 0;
+    fMcFadc = 0;
+    fRawEvt = 0;
+    fElecNoise = 0;
+    fStarFieldRotate = 0;
+    fNumAnalisedPixels = 0;
+    fNumSimulatedShowers = 0;
+    fNumStoredShowers = 0;
+
+    fStarFieldRaH = 0;
+    fStarFieldRaM = 0;
+    fStarFieldRaS = 0;
+    fStarFieldDeD = 0;
+    fStarFieldDeM = 0;
+    fStarFieldDeS = 0;
+
+    fNumPheFromDNSB = 0.0;
+    fTelesTheta = 0.0;
+    fTelesPhi = 0.0;
+    fSourceOffsetTheta = 0.0; 
+    fSourceOffsetPhi = 0.0;
+    fShowerThetaMax = 0.0;
+    fShowerThetaMin = 0.0;
+    fShowerPhiMax = 0.0;
+    fShowerPhiMin = 0.0;
+
+    fCWaveLower = 0.0;
+    fCWaveUpper = 0.0;
+
+    fNumObsLev = 0;
+    for (int i=0; i<10; i++){
+      fHeightLev[i]=0.0;
+    }
+    fSlopeSpec = 0.0;
+
+    fCorsikaVersion = 0;
+    fReflVersion = 0;
+    fCamVersion = 0;
+    fOpticLinksNoise= 0;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MMcRunHeader::~MMcRunHeader()
+{
+
+}
+
+// -------------------------------------------------------------------------
+//
+// Fill. Put data in the container
+//
+void MMcRunHeader::Fill(const Float_t  runnumber,
+			const UInt_t   productionsite,
+			const Float_t  daterunMMCs,
+			const Float_t   daterunCamera,
+			const UInt_t   numtrigcond,
+			const Byte_t   allevts,
+			const Byte_t   mcevt,
+			const Byte_t   mctrig,
+			const Byte_t   mcfadc,
+			const Byte_t   rawevt,
+			const Byte_t   elecnoise, 
+			const Int_t    numanalpixels,
+			const UInt_t   numsim,
+			const UInt_t   numsto,
+			const Byte_t   starfieldrotate,
+			const Int_t    sfRaH,
+			const Int_t    sfRaM,
+			const Int_t    sfRaS,
+			const Int_t    sfDeD,
+			const Int_t    sfDeM,
+			const Int_t    sfDeS,
+			const Float_t  numdnsb,
+			const Float_t  telestheta,
+			const Float_t  telesphi,
+			const Float_t  sofftheta,
+			const Float_t  soffphi,
+			const Float_t  shthetamax,
+			const Float_t  shthetamin,
+			const Float_t  shphimax,
+			const Float_t  shphimin,
+			const Float_t  cwavelower,
+			const Float_t  cwaveupper,
+			const Float_t  slopespec,
+			const UInt_t   numObslev,
+			const Float_t  heightlev[10],
+			const UInt_t   corsika,
+			const UInt_t   refl,
+			const UInt_t   cam,
+			const Byte_t   opticnoise)
+{
+    fMcRunNumber =runnumber;
+    fProductionSite = productionsite;
+    fDateRunMMCs = daterunMMCs;
+    fDateRunCamera = daterunCamera;
+    fNumTrigCond = numtrigcond;
+    fAllEvtsTriggered = allevts;
+    fMcEvt = mcevt;
+    fMcTrig = mctrig;
+    fMcFadc = mcfadc;
+    fRawEvt = rawevt;
+    fElecNoise = elecnoise;
+    fStarFieldRotate = starfieldrotate;
+    fNumAnalisedPixels = numanalpixels;
+    fNumSimulatedShowers = numsim;
+    fNumStoredShowers = numsto;
+
+    fStarFieldRaH = sfRaH;
+    fStarFieldRaM = sfRaM;
+    fStarFieldRaS = sfRaS;
+    fStarFieldDeD = sfDeD;
+    fStarFieldDeM = sfDeM;
+    fStarFieldDeS = sfDeS;
+
+    fNumPheFromDNSB = numdnsb;
+    fTelesTheta = telestheta;
+    fTelesPhi = telesphi;
+    fSourceOffsetTheta = sofftheta; 
+    fSourceOffsetPhi = soffphi;
+    fShowerThetaMax = shthetamax;
+    fShowerThetaMin = shthetamin;
+    fShowerPhiMax = shphimax;
+    fShowerPhiMin = shphimin;
+
+    fCWaveLower = cwavelower;
+    fCWaveUpper = cwaveupper;
+
+    fNumObsLev = numObslev;
+    for (UInt_t i=0; i<numObslev; i++){
+      fHeightLev[i]=heightlev[i];
+    }
+    fSlopeSpec = slopespec;
+
+    fCorsikaVersion = corsika;
+    fReflVersion = refl;
+    fCamVersion = cam;
+    fOpticLinksNoise= opticnoise;
+}
+
+// -------------------------------------------------------------------------
+//
+// GetStarFieldRa. Get RA coordinates of the starfield
+//
+void MMcRunHeader::GetStarFieldRa(Int_t *hour, Int_t *minute, Int_t *second) const
+{
+    *hour   = fStarFieldRaH;
+    *minute = fStarFieldRaM;
+    *second = fStarFieldRaS;
+}
+// -------------------------------------------------------------------------
+//
+// GetStarFieldDec. Get DE coordinates of the starfield
+//
+void MMcRunHeader::GetStarFieldDec(Int_t *degree, Int_t *minute, Int_t *second) const
+{
+    *degree = fStarFieldDeD;
+    *minute = fStarFieldDeM;
+    *second = fStarFieldDeS;
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.hxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.hxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcRunHeader.hxx	(revision 1638)
@@ -0,0 +1,153 @@
+#ifndef MARS_MMcRunHeader
+#define MARS_MMcRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MRunHeader                                                        //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+
+class MMcRunHeader : public MParContainer
+{
+private:
+  UInt_t  fNumTrigCond;     // Number of trigger conditions in this file,
+  // zero means single condition mode
+  
+  //-- 0 means: MMcTrig
+  //-- 1 means: MMcTrig;1
+  //-- 2 means: MMcTrig;1 MMcTrig;2
+  
+  Byte_t  fAllEvtsTriggered;  // boolean that indicates is all images are 
+                              // saved or only the ones that trigger
+
+  Byte_t  fMcEvt;           // McEvt stored or not
+  Byte_t  fMcTrig;          // McTrig stored or not
+  Byte_t  fMcFadc;          // McFadc stored or not
+
+  Int_t   fNumAnalisedPixels;  // Number of analised pixels
+  
+  UInt_t  fNumSimulatedShowers; // Number of showers that were simualted
+  UInt_t  fNumStoredShowers;    // Number of store showers in this run
+  
+  //  Coordinates of the Starfield
+  
+  Int_t fStarFieldRaH;
+  Int_t fStarFieldRaM;
+  Int_t fStarFieldRaS;
+  Int_t fStarFieldDeD;
+  Int_t fStarFieldDeM;
+  Int_t fStarFieldDeS;
+
+  Float_t fNumPheFromDNSB;  // Number of phe/ns from diffuse NSB
+  
+  //  Telescope axis position (zenith and azimutal angle)
+  Float_t fTelesTheta;  // >180 (200) means that telescope is always pointing the 
+                        // shower. Otherwise it is Theta where Telescope is pointing.
+  Float_t fTelesPhi;    // > 360 (400) means that telescope is always pointing the 
+                        //  shower. Otherwise it is Phi where Telescope is pointing.
+
+  //  Angular distance from the source position to the camera center
+  Float_t fSourceOffsetTheta; 
+  Float_t fSourceOffsetPhi;
+  
+  //  Angular range used in the Corsika showers generation (degrees)
+  Float_t fShowerThetaMax;
+  Float_t fShowerThetaMin;
+  Float_t fShowerPhiMax;
+  Float_t fShowerPhiMin;
+
+  UShort_t fCorsikaVersion;
+  UShort_t fReflVersion;
+  UShort_t fCamVersion;
+
+  /* ---- Run Header Informations ---- */
+  Float_t fMcRunNumber;     // Run Number
+  UInt_t  fProductionSite;  // code to know where the run was generated
+  Float_t fDateRunMMCs;     // Date of the MMCs production
+  Float_t fDateRunCamera;   // Date, when the Camera program is run.
+
+  Byte_t  fRawEvt;          // RawEvt[Data,Hedaer] stored or not
+
+  Byte_t  fElecNoise;       // Electronic Noise simulated or not
+  Byte_t  fStarFieldRotate; // Is the starfield rotation 
+                            // switched on (1) or off (0)
+
+  //  Wavelength limits for the Cerenkov photons
+  Float_t fCWaveLower;
+  Float_t fCWaveUpper;
+
+  //  Observation levels  
+  UInt_t    fNumObsLev;
+  Float_t   fHeightLev[10]; 
+
+  //  Spectral index
+  Float_t   fSlopeSpec;
+
+  // Noise from Optic Links
+  Byte_t  fOpticLinksNoise;  // Noise from Optic Links simualted or not.
+
+public:
+  MMcRunHeader(const char *name=NULL, const char *title=NULL);
+  ~MMcRunHeader();
+
+  void Fill(const Float_t  runnumber,
+	    const UInt_t   productionsite,
+	    const Float_t  daterunMMCs,
+	    const Float_t   daterunCamera,
+	    const UInt_t   numtrigcond,
+	    const Byte_t   allevts,
+	    const Byte_t   mcevt,
+	    const Byte_t   mctrig,
+	    const Byte_t   mcfadc,
+	    const Byte_t   rawevt,
+	    const Byte_t   elecnoise, 
+	    const Int_t    numanalpixels,
+	    const UInt_t   numsim,
+	    const UInt_t   numsto,
+	    const Byte_t   starfieldrotate,
+	    const Int_t    sfRaH,
+	    const Int_t    sfRaM,
+	    const Int_t    sfRaS,
+	    const Int_t    sfDeD,
+	    const Int_t    sfDeM,
+	    const Int_t    sfDeS,
+	    const Float_t  numdnsb,
+	    const Float_t  telestheta,
+	    const Float_t  telesphi,
+	    const Float_t  sofftheta,
+	    const Float_t  soffphi,
+	    const Float_t  shthetamax,
+	    const Float_t  shthetamin,
+	    const Float_t  shphimax,
+	    const Float_t  shphimin,
+	    const Float_t  cwavelower,
+	    const Float_t  cwaveupper,
+	    const Float_t  slopespec,
+	    const UInt_t   num0bslev,
+	    const Float_t  heightlev[10],
+	    const UInt_t   corsika,
+	    const UInt_t   refl,
+	    const UInt_t   cam,
+	    const Byte_t   opticnoise 
+	    );
+  
+  void     GetStarFieldRa(Int_t *hour, Int_t *minute, Int_t *second) const;
+  void     GetStarFieldDec(Int_t *degree, Int_t *minute, Int_t *second) const;
+
+  Float_t  GetNumPheFromDNSB() const      { return fNumPheFromDNSB; }
+  Float_t  GetTelesTheta() const          { return fTelesTheta; }
+  UShort_t GetCamVersion() const          { return fCamVersion; }
+  UShort_t GetReflVersion() const         { return fReflVersion; }
+  UInt_t   GetNumSimulatedShowers() const { return fNumSimulatedShowers; }
+  UInt_t   GetCorsikaVersion() const      { return fCorsikaVersion; }
+  Bool_t   GetAllEvtsTriggered() const    { return fAllEvtsTriggered ? kTRUE : kFALSE; }
+
+  ClassDef(MMcRunHeader, 3)	// storage container for general run info
+};
+#endif
+
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.cxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.cxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.cxx	(revision 1638)
@@ -0,0 +1,135 @@
+#include "MMcTrig.hxx"
+
+#include <iostream.h>
+
+
+//==========
+// MMcTrig
+//    
+// This class handles and contains the MonteCarlo information
+// with which the events have been generated
+// This information exists for each event.
+//
+// This the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The fPixelsFirst array has been increased from 273 (which was the trigger 
+// zone) to 577 (which is the full Camera)
+//
+////////////////////////////////////////////////////////////// 
+
+
+ClassImp(MMcTrig);
+
+
+
+MMcTrig::MMcTrig(const char *name, const char *title) {
+  //
+  //  default constructor
+  //  set all values to zero
+
+  
+  fName  = name  ? name  : "MMcTrig";
+  fTitle = title ? title : "Trigger info from Monte Carlo";
+
+    
+  Int_t i,j;
+
+  fNumFirstLevel  = 0 ;
+
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1;i++){
+    fTimeFirst[i]    = -99.9;
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      fPixelsFirst[j][i]   = 0;
+    }
+  }
+
+  fNumSecondLevel = 0 ; 
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME+1;i++){
+    fFirstToSecond[i]=0;
+  }
+}
+
+MMcTrig::~MMcTrig() {
+  //
+  //  default destructor
+  //
+}
+
+void MMcTrig::SetTime(Float_t t, Int_t i)
+{
+    if (i>TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1  || i<1)
+    {
+        cout << "fNumFirstLevel out of range. Time will be -99" << endl;
+        return;
+    }
+
+    fTimeFirst[i-1]=t;
+}
+
+void MMcTrig::Clear(Option_t *opt) {
+  //
+  //  
+  //  reset all values to zero
+  Int_t i,j;
+
+  fNumFirstLevel  = 0 ;
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME+1;i++){
+    fTimeFirst[i]    = -99.9;
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      fPixelsFirst[j][i]   = 0;
+    }
+  }
+
+  fNumSecondLevel = 0 ; 
+  for(i=0;i<TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME+1;i++){
+    fFirstToSecond[i]=0;
+  }
+
+  //  cout << "MMcTrig::Clear() " << endl ; 
+}
+
+void MMcTrig::Print(Option_t *Option) const {
+  //
+  //  print out the data member on screen
+  //
+  Int_t i,j;
+
+  cout <<endl << "Monte Carlo Trigger output:" <<endl;
+  cout << " First  Level Trigger in this Event: "<<fNumFirstLevel<<endl; 
+  cout << " Times of first  Level Trigger in this Event: ";
+  for (i=0;i<fNumFirstLevel;i++){
+    cout<< fTimeFirst[i]<<"-";
+  }
+  cout<<endl;
+  cout << " Pixels of first  Level Trigger in this Event : ";
+  for (i=0;i<fNumFirstLevel;i++){
+    for(j=0;j<CAMERA_PIXELS/8+1;j++){
+      cout<<fPixelsFirst[j][i]<<"-";
+    }
+  }
+  cout<<endl;
+  cout << " Second Level Trigger in this Event: " << fNumSecondLevel << endl; 
+  cout << endl ; 
+}
+
+Byte_t MMcTrig::IsPixelFired(Int_t npix, Int_t nfirstlevel){
+  //======================================================================
+  //
+  //  It returns >1 if the pixel npix was fired when the nfirstlevel
+  //  first level trigger happened, 0 if not.
+  //
+
+  Byte_t ret=0;
+  Byte_t reminder;
+  Int_t body;
+
+  body=npix/8;
+  reminder=(Byte_t)(pow(2,npix%8));
+
+  ret=reminder&fPixelsFirst[body][nfirstlevel];
+  return(ret);
+
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.hxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.hxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrig.hxx	(revision 1638)
@@ -0,0 +1,63 @@
+#ifndef __MMcTrig__
+#define __MMcTrig__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MTriggerDefine.h"
+#include "Mdefine.h"
+
+class MMcTrig : public MParContainer {
+ private:
+
+  Short_t fNumFirstLevel  ;    // Number of First Level Trigger in this Event
+  Short_t fNumSecondLevel ;    // Number of Second Level Trigger in this Event
+
+  Float_t fTimeFirst[((Int_t)(TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME))+1];
+                            // Time when it triggers
+  Byte_t fPixelsFirst[((Int_t)(CAMERA_PIXELS/8))+1][((Int_t)(TOTAL_TRIGGER_TIME/LEVEL1_DEAD_TIME))+1];
+                            // Pixel which are above threshold when trigger happens
+  Short_t fFirstToSecond[((Int_t)(TOTAL_TRIGGER_TIME/LEVEL2_DEAD_TIME))+1];
+
+ public:
+  MMcTrig(const char *name=NULL, const char *title=NULL);
+
+  ~MMcTrig(); 
+
+  void Clear(Option_t *opt=NULL);
+  
+  void Print(Option_t *opt=NULL) const;
+
+  void SetFirstLevel  ( Short_t nTr ) {
+    fNumFirstLevel = nTr ; 
+  } 
+  void SetSecondLevel ( Short_t nTr ) {
+    fNumSecondLevel = nTr ; 
+  } 
+
+  void SetTime( Float_t t, Int_t i);
+
+  void SetMapPixels(Byte_t *map,Int_t nfirst){
+    //  
+    //  It sets the map of pixel that are above the trheshold
+    //
+
+    int i;
+
+    for(i=0;i<((Int_t)(CAMERA_PIXELS/8))+1;i++){
+      fPixelsFirst[i][nfirst]=map[i];
+    }
+  }
+
+  Int_t GetFirstLevel() const {
+    return ( fNumFirstLevel );  
+  }
+
+  Byte_t IsPixelFired(Int_t npix, Int_t nfirstlevel);
+
+  ClassDef(MMcTrig, 2)  //Stores Montecarlo Information (number of 1st, 2nd level triggers)
+
+};
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.cxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.cxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.cxx	(revision 1638)
@@ -0,0 +1,73 @@
+#include "MMcTrigHeader.hxx"
+
+#include <iostream.h>
+
+
+//==========
+// MMcTrigHeader
+//    
+// This class contains the MonteCarlo information
+// of the trigger simulation for the current run.
+// The information is saved only once, whatever the
+// number of events is
+//
+// This is the second version of this output class. Old root files, which have
+// a previous version of this class, are still compatibles and can be used.
+// But of course, you can no try to get infromatino in these old files about
+// the new data members.
+//
+// The following data member have been introduced in this second version 
+// and they do not exist in the previous one:
+//
+//   Float_t  fElecNoiseTrig;  The width of the gaussian noise is that times
+//                             the amplitude of the single phe response 
+//                             for the trigger 
+//
+/////////////////////////
+
+ClassImp(MMcTrigHeader);
+
+
+
+MMcTrigHeader::MMcTrigHeader() {
+  //
+  //  default constructor
+  //  set all values to zero
+
+  Int_t i;
+
+  fTopology     = -1 ;
+  fMultiplicity = -1 ;
+  for(i=0;i<CAMERA_PIXELS;i++){
+    fThreshold[i] = -1.0;
+  }
+  
+  fTrigPattern[0]=0;
+  fTrigPattern[1]=0;
+
+  fTrigShape=0.0; 
+  fAmplTrig=RESPONSE_AMPLITUDE;
+  fFwhmTrig=RESPONSE_FWHM;
+  fOverlapingTime=TRIGGER_OVERLAPING;
+  fGateLeng=TRIGGER_GATE ;
+}
+
+MMcTrigHeader::~MMcTrigHeader() {
+  //
+  //  default destructor
+  //
+}
+
+
+void MMcTrigHeader::Print(Option_t *opt) const {
+  //
+  //  print out the data member on screen
+  //
+  cout << endl;
+  cout << "Monte Carlo Trigger output:" << endl;
+  cout << " XSTopology Trigger in this run: "   << fTopology << endl;
+  cout << " Multiplicity Trigger in this run: " << fMultiplicity << endl;
+  cout << " Trigger Pattern in this run: ";
+  cout << fTrigPattern[0] << ", " << fTrigPattern[1] << endl;
+  cout << endl; 
+}
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.hxx
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.hxx	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.hxx	(revision 1638)
@@ -0,0 +1,97 @@
+#ifndef __MMcTrigHeader__
+#define __MMcTrigHeader__
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#include "MTriggerDefine.h"
+#include "Mdefine.h"
+
+class MMcTrigHeader : public MParContainer{
+ private:
+
+  Short_t fTopology     ;      // Topology of the trigger
+                                   // 0 = N-1 neighbours of one pixel
+                                   // 1 = N neighbours
+                                   // 2 = N closed pack
+  Short_t fMultiplicity ;      // Pixel multiplicity of trigger configuration
+  Float_t fThreshold[CAMERA_PIXELS] ; // Threshold for trigger
+  UInt_t fTrigPattern[2];     // Used to inddentify with 
+                              // RawEvt::Trigger Pattern identification  
+  Float_t  fTrigShape   ;   // a number that indicate the shape type of 
+                            // the signal   
+                            // = 0 --> a gaussian  
+  Float_t  fAmplTrig    ;   // the amplitude of the trigger in mV
+  Float_t  fFwhmTrig    ;   // the width of the signal in nsec
+  Float_t  fOverlapingTime;// Minimum coincidence time
+  Float_t  fGateLeng;       // the length of the digital signal if analog 
+                            // signal is above threshold
+  Float_t  fElecNoiseTrig;  // The width of the gaussian noise is that times
+                            // the amplitude of the single phe response 
+                            // for the trigger
+
+ public:
+  MMcTrigHeader() ;
+
+  ~MMcTrigHeader(); 
+
+  void Print(Option_t *opt=NULL) const;
+  
+  void SetTopology(Short_t nTop) {
+    fTopology=nTop;
+  }
+
+  void SetMultiplicity(Short_t nMul) {
+    fMultiplicity=nMul;
+  }
+
+  void SetThreshold(Float_t fthr[]){
+    int i;
+    for(i=0;i<CAMERA_PIXELS;i++){
+      fThreshold[i]=fthr[i];
+    }
+  }
+
+  void SetTrigPattern (UInt_t upi, UInt_t loi){
+
+    if (upi==loi==0) {
+      fTrigPattern[0]= (UInt_t) fThreshold[0];
+      fTrigPattern[1]= (UInt_t) (100*fMultiplicity+fTopology);
+    }
+    else {
+      fTrigPattern[0]=upi;
+      fTrigPattern[1]=loi;
+    }
+  }
+
+  void SetShape(Float_t shape){
+    fTrigShape=shape;
+  }
+
+  void SetAmplitud(Float_t amp){
+    fAmplTrig=amp;
+ }
+
+  void SetFwhm(Float_t fwhm){
+    fFwhmTrig=fwhm;
+  }
+
+  void SetOverlap(Float_t overlap){
+    fOverlapingTime=overlap;
+  }
+
+  void SetGate(Float_t gate){
+    fGateLeng=gate;
+  }
+
+  void SetElecNoise( Float_t elecnoise){
+    fElecNoiseTrig = elecnoise;
+  }
+
+  ClassDef(MMcTrigHeader, 2)  //Stores Montecarlo Information which describes the used trigger
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MTriggerDefine.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MTriggerDefine.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/MTriggerDefine.h	(revision 1638)
@@ -0,0 +1,98 @@
+//
+//
+//      In this file are the fundamental definitions for the class MCTrigger
+//
+//
+#define TRIGGER_PIXELS        397
+//
+//      This is the number of Pixels contributing to the TRIGGER logic
+//      All Pixels-Id above that value don't do an trigger stuff. 
+//      Actually, not all of them are involved in TRIGGER logic, only the
+//      ones of them that are also in some TRIGGER_CELL 
+//   (MagicSoft/Simulation/Detector/include-MTrigger/TABLE_PIXELS_IN_CELLS)
+//
+#define TOTAL_TRIGGER_TIME    160 
+//
+//      This values defines the total range in that we try to find
+//      a trigger. 
+//
+#define LEVEL1_DEAD_TIME    50
+//
+//      Dead time of the detector after one first level trigger happens.
+//
+#define LEVEL2_DEAD_TIME    300
+//
+//      Dead time of the detector after second level trigger fires
+//
+#define SLICES_PER_NSEC         4
+//      
+//      Each nano second is divided into the number of this values slices. 
+//      So you can get the total number of timeslices for one Pixel by 
+//      ( TOTAL_TRIGGER_TIME * SLICES_PER_NSEC ). 
+//      In the current settings this are 1000 slices
+//
+#define TRIGGER_TIME_SLICES     (TOTAL_TRIGGER_TIME*SLICES_PER_NSEC) 
+//
+//
+//
+//
+//       ------>>>   SETTINGS for the RESPONSE FUNCTION
+// 
+#define RESPONSE_SLICES        40
+//
+//       This is for the standard response Signal to 1 Photoelectron
+//       that leaves the Photocathode
+//       The whole Timescale for the signal is 10 nsec
+//
+//       The Response function
+//
+//       These values are discussed with Eckart. We start from this point. 
+//
+#define RESPONSE_FWHM          2. 
+
+#define RESPONSE_AMPLITUDE     1. 
+//
+//       This are the Standard values of the response function for
+//       1 photo electron. ( 1 means 1 mV per phote electron ) 
+//
+//
+//       -------->>> SETTINGS for the DISKRIMINATORS
+//
+//
+#define CHANNEL_THRESHOLD      2.5 
+//
+//       This is the diskriminator threshold for each individual channel
+//       First we set the value to 2 unit of the RESPONSE_AMPLITUDE 
+//
+#define TRIGGER_GATE           3. 
+// 
+//       Here we set the width of the digital signal we get if the signal
+//       passes the diskriminator
+//
+//
+#define TRIGGER_OVERLAPING           0.25 
+// 
+//       Here we set the required overlaping time among pixels
+//       to be in coincidence.
+//
+//
+//      --------->>>> SETTINGS for the TRIGGER logic
+//
+//
+#define TRIGGER_CELLS          19  
+//
+//       Number of trigger cells that cover the trigger zone
+//
+#define TRIGGER_MULTI          4.  
+//
+//       We get a Level Zero Trigger, if we have a least TRIGGER_MULTI
+//       channels with a diskrimiator signal at the same time 
+//
+#define TRIGGER_GEOM           0
+//
+//      This defines the geometry required for a trigger. There exists 
+//      different meaning for this behaviour: 
+//         0 means a pixel with trigger_multi-1 neighbours
+//         1 means trigger_multi neighbours
+//         2 means trigger_multi closed neighbours
+//
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Makefile
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Makefile	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Makefile	(revision 1638)
@@ -0,0 +1,58 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+# @endcode 
+
+INCLUDES = -I.  -I../mbase -I../MBase -I../mgeom
+
+# @code 
+
+CINT     = Mc
+LIB      = mmc.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MMcTrigHeader.cxx \
+	   MMcFadcHeader.cxx \
+	   MMcRunHeader.cxx \
+	   MMcEvt.cxx \
+           MMcTrig.cxx 
+
+SRCFILESCC = MMcConfigRunHeader.cc \
+	     MMcCorsikaRunHeader.cc
+
+
+SRCS    = $(SRCFILES) 
+
+HEADERS = $(SRCFILES:.cxx=.hxx) $(SRCFILESCC:.cc=.h)
+OBJS    = $(SRCFILES:.cxx=.o) $(SRCFILESCC:.cc=.o)
+
+############################################################
+
+all: $(LIB)
+
+include ../Makefile.rules 
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
+
+# @endcode
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McIncl.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McIncl.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McIncl.h	(revision 1638)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McLinkDef.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McLinkDef.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/McLinkDef.h	(revision 1638)
@@ -0,0 +1,15 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+ 
+#pragma link C++ class MMcEvt+;
+#pragma link C++ class MMcTrig+;
+#pragma link C++ class MMcRunHeader+;
+#pragma link C++ class MMcTrigHeader+;
+#pragma link C++ class MMcFadcHeader+;
+#pragma link C++ class MMcConfigRunHeader+;
+#pragma link C++ class MMcCorsikaRunHeader+;
+
+#endif
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Mdefine.h
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Mdefine.h	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/Mdefine.h	(revision 1638)
@@ -0,0 +1,41 @@
+//
+//     Mdefine.h
+//
+//     defines some Values for the MAGIC telecope
+//
+
+//     Number of the Pixels in the Camera
+
+#define     CAMERA_PIXELS         577
+
+//     Number of the Slices of one Fadc. Be carefull this is the number of 
+//     slices for one gain branch. We sample two times this number. 
+
+#define     FADC_SLICES            15
+
+//     ParticleId for Monte Carlo simulation
+
+#define  GAMMA 0
+#define  PROTON 14
+#define  HELIUM 402
+#define  OXIGEN 1608
+#define  IRON 5626
+
+
+//---------------------------------------------------------
+// definition of constants
+
+#define TRUE 1
+#define FALSE 0
+
+#define MAX_ADC 30  // nummber of ADC conversions per pixel
+
+//camera dimensions and definitions
+#define PIXEL_DIST  10.0  //cm
+#define CAMERA_COLOR 13   //Background light grey
+#define DEFAULT_COLOR 1 //black
+//#define TRACK_WALL_COLOR 7   //light blue
+#define PIXEL_LINE_COLOR 15 //dark grey
+#define COLORTABLE_START 18 //Begin of colortable
+#define MAX_PH_EL 500 //upper limit for colortable
+
Index: /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/readme.txt
===================================================================
--- /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/readme.txt	(revision 1638)
+++ /tags/Mars_V0-8/MagicSoft/include-Classes/MMcFormat/readme.txt	(revision 1638)
@@ -0,0 +1,6 @@
+
+ Please be aware of that this subdirectory is used in two CVS modules.
+ 
+ If you change something it can affect the Mars and/or Monte Carlo
+ code!
+ 
