Index: /tags/Mars_V0-7/Mars/.rootrc
===================================================================
--- /tags/Mars_V0-7/Mars/.rootrc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/.rootrc	(revision 9643)
@@ -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.uni-sw.gwdg.de/mars/
+Root.Html.SearchEngine:      http://magic.uni-sw.gwdg.de/mars/search.html
Index: /tags/Mars_V0-7/Mars/BUGS
===================================================================
--- /tags/Mars_V0-7/Mars/BUGS	(revision 9643)
+++ /tags/Mars_V0-7/Mars/BUGS	(revision 9643)
@@ -0,0 +1,7 @@
+                                                               -*-*- END -*-*-
+
+List of known bugs:
+-------------------
+
+ - Reading rootified daq files causes big memory leaks
+
Index: /tags/Mars_V0-7/Mars/Changelog
===================================================================
--- /tags/Mars_V0-7/Mars/Changelog	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Changelog	(revision 9643)
@@ -0,0 +1,3523 @@
+                                                                  -*-*- END -*-*-
+ 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 lis of MHMcRate is created usinf from and to instead of
+       only dimension. Otherwise the cas 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 decide 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-7/Mars/MIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/MIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/MIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/MLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/MLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/MLinkDef.h	(revision 9643)
@@ -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-7/Mars/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile	(revision 9643)
@@ -0,0 +1,123 @@
+##################################################################
+#
+#   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       \
+          mmc         \
+          mgui        \
+	  manalysis   \
+          mbase       \
+          meventdisp  \
+          mdatacheck  \
+          mmontecarlo \
+          mhist       \
+          mdata       \
+          mfilter     \
+          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 $@
+
+$(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-7/Mars/Makefile.conf.general
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile.conf.general	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile.conf.general	(revision 9643)
@@ -0,0 +1,19 @@
+#
+#  ----->>>   root libraries
+#
+
+ROOTVER    =  `root-config --version`
+ROOTLIBS   =  `root-config --libs`
+ROOTGLIBS  =  `root-config --glibs`
+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-7/Mars/Makefile.conf.linux
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile.conf.linux	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile.conf.linux	(revision 9643)
@@ -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-7/Mars/Makefile.conf.linux-gnu
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile.conf.linux-gnu	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile.conf.linux-gnu	(revision 9643)
@@ -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-7/Mars/Makefile.conf.osf1
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile.conf.osf1	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile.conf.osf1	(revision 9643)
@@ -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-7/Mars/Makefile.rules
===================================================================
--- /tags/Mars_V0-7/Mars/Makefile.rules	(revision 9643)
+++ /tags/Mars_V0-7/Mars/Makefile.rules	(revision 9643)
@@ -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-7/Mars/NEWS
===================================================================
--- /tags/Mars_V0-7/Mars/NEWS	(revision 9643)
+++ /tags/Mars_V0-7/Mars/NEWS	(revision 9643)
@@ -0,0 +1,214 @@
+                                                               -*-*- END -*-*-
+
+ *** Version 0.7
+ 
+   - 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 (2001/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-7/Mars/macros/CT1Hillas.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/CT1Hillas.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/CT1Hillas.C	(revision 9643)
@@ -0,0 +1,123 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 CT1Hillas()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a CT1 dataset.
+
+    //
+    // 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);
+
+    //
+    // Setup binning for your histograms.
+    //
+    MBinning binswidth("BinningWidth");
+    binswidth.SetEdges(100, 0, 1);   // 100 bins from 0 to 1 deg
+
+    MBinning binslength("BinningLength");
+    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+
+    MBinning binsalpha("BinningAlpha");
+    binsalpha.SetEdges(90, 0, 90);   // 90 bins from 0 to 90 deg
+
+    MBinning binsdist("BinningDist");
+    binsdist.SetEdges(100, 0, 2);    // 100 bins from 0 to 2 deg
+
+    plist.AddToList(&binswidth);
+    plist.AddToList(&binslength);
+    plist.AddToList(&binsalpha);
+    plist.AddToList(&binsdist);
+
+    //
+    // 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");
+
+    MImgCleanStd   clean;
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1("Source",  "HillasSource");
+
+    MFillH hfill("MHHillas",   "MHillas");
+    MFillH sfill("MHStarMap",  "MHillas");
+    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&hfill);
+    tlist.AddToList(&sfill);
+    tlist.AddToList(&hfill2s);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+}
Index: /tags/Mars_V0-7/Mars/macros/MagicHillas.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/MagicHillas.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/MagicHillas.C	(revision 9643)
@@ -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
+!
+!
+\* ======================================================================== */
+
+
+void MagicHillas(const char *filename="~/data/gamma*.root")
+{
+    //
+    // 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);
+
+    //
+    // 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 choos a wrong geometry by chance
+    //
+    MGeomCamMagic geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // Setup binning for your histograms.
+    //
+    MBinning binswidth("BinningWidth");
+    binswidth.SetEdges(100, 0, 1);   // 100 bins from 0 to 1 deg
+
+    MBinning binslength("BinningLength");
+    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+
+    MBinning binsalpha("BinningAlpha");
+    binsalpha.SetEdges(90, 0, 90);   // 90 bins from 0 to 90 deg
+
+    MBinning binsdist("BinningDist");
+    binsdist.SetEdges(100, 0, 2);    // 100 bins from 0 to 2 deg
+
+    plist.AddToList(&binswidth);
+    plist.AddToList(&binslength);
+    plist.AddToList(&binsalpha);
+    plist.AddToList(&binsdist);
+
+    //
+    // 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);
+
+    MSrcPosCam antisrc("AntiSrc");
+    antisrc.SetXY(240, 0);
+
+    plist.AddToList(&source);
+    plist.AddToList(&antisrc);
+
+    //
+    // 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);
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MImgCleanStd      clean;
+    MBlindPixelCalc   blind;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    csrc1("Source",  "HillasSource");
+    MHillasSrcCalc    csrc2("AntiSrc", "HillasAntiSrc");
+
+    MFillH hfill("MHHillas",   "MHillas");
+    MFillH sfill("MHStarMap",  "MHillas");
+    MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+    MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
+
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHillas",       "Hillas");
+    write.AddContainer("HillasSource",  "Hillas");
+    write.AddContainer("HillasAntiSrc", "Hillas");
+    write.AddContainer("MHStarMap");
+
+    /*
+     MWriteAsciiFile write("hillas.txt");
+     write.AddContainer("MHillas", "fLength");
+     write.AddContainer("MHillas", "fConc");
+     write.AddContainer("MHillas");
+     */
+
+    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(&hfill);
+    tlist.AddToList(&sfill);
+    tlist.AddToList(&hfill2s);
+    tlist.AddToList(&hfill2a);
+    tlist.AddToList(&write);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistAntiSrc")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+}
Index: /tags/Mars_V0-7/Mars/macros/Pedestals_Stability.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/Pedestals_Stability.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/Pedestals_Stability.C	(revision 9643)
@@ -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-7/Mars/macros/collarea.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/collarea.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/collarea.C	(revision 9643)
@@ -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 (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
+    //
+    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-7/Mars/macros/dohtml.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/dohtml.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/dohtml.C	(revision 9643)
@@ -0,0 +1,53 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 dohtml()
+{
+    //
+    //  don't forget that the shared object must have been loaded
+    //
+
+    //
+    //   create the html document class
+    //
+    THtml html;
+
+    html.SetOutputDir("htmldoc");
+    html.SetSourceDir(".:mbase:mraw:mgui:manalysis:mdatacheck:mmain:meventdisp:mmc:mmontecarlo:mhist:mfilter");
+
+    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");
+}
Index: /tags/Mars_V0-7/Mars/macros/flux.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/flux.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/flux.C	(revision 9643)
@@ -0,0 +1,490 @@
+/* ======================================================================== *\
+!
+! *
+! * 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                                    //
+//    - a kind of effective collection areas are calculated                 //
+//                                                                          // 
+//////////////////////////////////////////////////////////////////////////////
+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 binning for the histograms
+    //
+    MBinning binswidth("BinningWidth");
+    binswidth.SetEdges(100, 0, 1);   // 100 bins from 0 to 1 deg
+
+    MBinning binslength("BinningLength");
+    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+
+    MBinning binsdist("BinningDist");
+    binsdist.SetEdges(100, 0, 2);    // 100 bins from 0 to 2 deg
+
+    MBinning binsalpha("BinningAlpha");
+    binsalpha.SetEdges(45, -90, 90);
+
+    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(&binsdist);
+
+    parlist.AddToList(&binsalpha);
+    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", "/hd31/rkb/Camera/mpi/Gamma*.root");
+  //reader.AddFile("/hd31/rkb/Camera/mpi/prot_N_*.root");
+
+    // next 2 statements added
+    MReadMarsFile reader("Events");
+    reader.AddFile("protondata/gamma_10_cn*.root");
+
+    reader.EnableBranch("MMcEvt.fTheta");
+
+    //.....................................
+    // generation of event time
+    MMcTimeGenerate   rand;
+
+    //.....................................
+    // collection area
+    MMcCollectionAreaCalc acalc;
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MImgCleanStd      clean;
+    MBlindPixelCalc   blind;
+
+    //.....................................
+    // source independent image parameters
+    MHillasCalc       hcalc;
+
+    //.....................................
+    // source dependent image parameters
+    MHillasSrcCalc    hsrc1("Source",     "HillasSrc");
+    MHillasSrcCalc    hsrc2("AntiSource", "HillasAntiSrc");
+
+    //.....................................
+    // energy estimation
+    MEnergyEstimate   estim;
+
+    //.....................................
+    // migration matrix (MC)
+    MFillH eestetrue("MHMcEnergyMigration",  "HillasSrc");
+
+
+    //.....................................
+    // plots of width and length
+    MFillH hfill1h("MHHillas",  "MHillas");
+
+    //.....................................
+    // star map
+    MFillH hfill1m("MHStarMap", "MHillas");
+
+    //.....................................
+    // plots of alpha and dist
+    MFillH hfill2s("HSource     [MHHillasSrc]", "HillasSrc");
+    MFillH hfill2a("HAntiSource [MHHillasSrc]", "HillasAntiSrc");
+ 
+    //.....................................
+    // filters
+    MFTriggerLvl1 lvl1;
+
+    const Float_t alpha0 = 15; // [deg]
+    MFAlpha fsrc ("HillasSrc",     '>', alpha0);
+    MFAlpha fasrc("HillasAntiSrc", '>', alpha0);
+
+    //.....................................
+    // 1-D profile plots     (<Theta>,  time)
+    //                       (<Theta>, Theta)
+    MFillH fillthetabartime ("ThetabarTime  [MHThetabarTime]",  "MMcEvt");
+    // fillthetabartime.SetFilter(&lvl1);
+    MFillH fillthetabartheta("ThetabarTheta [MHThetabarTheta]", "MMcEvt");
+    // fillthetabartheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 2-D plots     (Delta(time),  time)
+    //               (Delta(time), Theta)
+    MFillH filldtimetime ("EffOnTime  [MHTimeDiffTime]",  "MMcEvt");
+    // filldtime.SetFilter(&lvl1);
+    MFillH filldtimetheta("EffOnTheta [MHTimeDiffTheta]", "MMcEvt");
+    // fillontheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, time) 
+    MFillH fillsptime  ("FluxSrcTime   [MHAlphaEnergyTime]",  "HillasSrc");
+    fillsptime.SetFilter(&fasrc);
+    MFillH fillasptime ("FluxASrcTime  [MHAlphaEnergyTime]",  "HillasAntiSrc");
+    fillasptime.SetFilter(&fsrc);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, Theta) 
+    MFillH fillsptheta ("FluxSrcTheta  [MHAlphaEnergyTheta]", "HillasSrc");
+    fillsptheta.SetFilter(&fasrc);
+    MFillH fillasptheta("FluxASrcTheta [MHAlphaEnergyTheta]", "HillasAntiSrc");
+    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(&rand);
+
+    tasklist.AddToList(&acalc);
+
+    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(&hfill1m);
+    tasklist.AddToList(&hfill2s);
+    tasklist.AddToList(&hfill2a);
+
+    tasklist.AddToList(&fillthetabartime);
+    tasklist.AddToList(&fillthetabartheta);
+
+    tasklist.AddToList(&filldtimetime);
+    tasklist.AddToList(&filldtimetheta);
+
+    // tasklist.AddToList(&lvl1);
+
+    // 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);
+
+    /*
+     parlist.FindObject("HSource")->DrawClone();;
+     parlist.FindObject("MHHillas")->DrawClone();
+    */
+    /*
+     parlist.FindObject("MHStarMap")->DrawClone();
+    */
+    /*
+     parlist.FindObject("HAntiSource")->DrawClone();
+    */
+    /*
+     parlist.FindObject("MHMcCollectionArea")->DrawClone();
+    */
+
+    //----------------------------------------------------------------------
+    // average Theta versus time
+    //           and versus Theta
+    //
+    MHThetabarTime  *bartime  = (MHThetabarTime*)parlist.FindObject("ThetabarTime");
+    MHThetabarTheta *bartheta = (MHThetabarTheta*)parlist.FindObject("ThetabarTheta");
+    
+    /*
+    bartime->DrawClone();
+    bartheta->DrawClone();
+    */
+
+
+    //----------------------------------------------------------------------
+    // this is something like the collection area
+    //         as a function of time
+    //     and as a function of Theta
+     /*
+     MHEnergyTime  &alltime  = *(MHEnergyTime*)parlist.FindObject("AllTime");
+     MHEnergyTime  &seltime  = *(MHEnergyTime*)parlist.FindObject("SelTime");
+     MHEnergyTime collareatime;
+     collareatime.Divide(&seltime, &alltime);
+
+     MHEnergyTheta &alltheta = *(MHEnergyTheta*)parlist.FindObject("AllTheta");
+     MHEnergyTheta &seltheta = *(MHEnergyTheta*)parlist.FindObject("SelTheta");
+     MHEnergyTheta collareatheta;
+     collareatheta.Divide(&seltheta, &alltheta);
+     */
+
+     //----------------------------------------------------------------------
+     // 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      
+     MHEffOnTimeTime  effontime;
+     MHEffOnTimeTheta effontheta;
+     effontime.SetupFill(&parlist);
+     effontheta.SetupFill(&parlist);
+
+     effontime.Calc(dtimetime->GetHist());
+     effontheta.Calc(dtimetheta->GetHist());
+
+     // plot effective on time versus time
+     //                    and versus Theta
+     
+     effontime.DrawClone();
+     effontheta.DrawClone();
+     
+
+
+     //----------------------------------------------------------------------
+     // 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("FluxSrcTime");
+     MHAlphaEnergyTime  *evtasptime  = (MHAlphaEnergyTime*)parlist.FindObject("FluxASrcTime");
+     MHAlphaEnergyTheta *evtsptheta  = (MHAlphaEnergyTheta*)parlist.FindObject("FluxSrcTheta");
+     MHAlphaEnergyTheta *evtasptheta = (MHAlphaEnergyTheta*)parlist.FindObject("FluxASrcTheta");
+
+     /* this test shows that the addresses
+             'evtsptime' and  '&evtspobj' are identical
+     MHAlphaEnergyTime  &evtspobj     = *(MHAlphaEnergyTime*)parlist.FindObject("FluxSrcTime");
+     cout << "evtsptime = " << evtsptime << endl;
+     cout << "&evtspobj = " << &evtspobj << endl;
+     */
+
+     /*
+      evtsptime->SetTitle("3D-plot Al-En-time, alpha\_{asp} .gt. alpha\_0");
+      evtsptime->DrawClone();
+      evtasptime->SetTitle("3D-plot Al-En-time, alpha\_{sp} .gt. alpha\_0");
+      evtasptime->DrawClone();
+
+      evtsptheta->SetTitle("3D-plot Al-En-Theta, alpha\_{asp} .gt. alpha\_0");
+      evtsptheta->DrawClone();
+      evtasptheta->SetTitle("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 
+      
+     MHAlphaEnergyTime  gammatime("Al-En-time","3D-plot Al-En-time");
+     MHAlphaEnergyTheta gammatheta("Al-En-Theta","3D-plot Al-En-Theta");
+
+     gammatime.SetupFill(&parlist);
+     gammatime.Subtract(evtsptime, evtasptime);
+     gammatheta.SetupFill(&parlist);
+     gammatheta.Subtract(evtsptheta, evtasptheta);
+
+
+     /*
+      gammatime.SetTitle("3D-plot Al-En-time for \'gamma\' sample");
+      gammatime.DrawClone();
+
+      gammatheta.SetTitle("3D-plot Al-En-Theta for \'gamma\' sample");
+      gammatheta.DrawClone();
+     */                
+
+     //----------------------------------------------------------------------
+     // 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 = -10;
+     Axis_t up =  10;
+
+     //     TH2D &evttime  = *gammatime.GetAlphaProjection (lo, up);
+     //     TH2D &evttheta = *gammatheta.GetAlphaProjection(lo, up);
+
+     TH2D *evttime  = gammatime.DrawAlphaProjection (lo, up);
+     TH2D *evttheta = gammatheta.DrawAlphaProjection(lo, up);
+
+
+     //----------------------------------------------------------------------
+     // plot migration matrix:  E-true E-est Theta
+
+     parlist.FindObject("MHMcEnergyMigration")->DrawClone();
+
+     return;
+
+     //----------------------------------------------------------------------
+     for (int i=1; i<=binstime.GetNumBins(); i++)
+     {
+         if (effontime.GetHist()->GetBinContent(i)==0)
+             continue;
+
+         TH1D &hist = *evttime.ProjectionX("Number of Gammas vs. EnergyEst for a fixed time", i, i);
+
+         /* UNFOLDING */
+
+         //hist->Divide(collareatime);
+         hist.Scale(1./effontime.GetHist()->GetBinContent(i));
+
+         for (int j=1; j<=binse.GetNumBins(); j++)
+             hist.SetBinContent(j, hist.GetBinContent(j)/hist.GetBinWidth(j));
+
+         hist.SetName("Flux");
+         hist.SetTitle("Flux[Gammas/s/m^2/GeV] vs. EnergyTrue for a fixed Time");
+
+         char n[100];
+         sprintf(n, "Canv%d", j);
+         c= new TCanvas(n, "Title");
+	 /*
+         hist.DrawCopy();
+	 */
+     }
+
+     delete &evttime;
+     delete &evttheta;
+
+     return;
+
+     // ------------------------------------------
+
+     MHMcCollectionArea carea;
+     TH1D *collareatime  = carea.GetHist();  // FIXME!
+     TH1D *collareatheta = carea.GetHist();  // FIXME!
+}
+//===========================================================================
+
+
Index: /tags/Mars_V0-7/Mars/macros/merpp.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/merpp.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/merpp.C	(revision 9643)
@@ -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-7/Mars/macros/readCT1.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/readCT1.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/readCT1.C	(revision 9643)
@@ -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-7/Mars/macros/readMagic.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/readMagic.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/readMagic.C	(revision 9643)
@@ -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
+!
+!
+\* ======================================================================== */
+
+
+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/camera.root")
+{
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MHillas       hillas;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&hillas);
+    plist.AddToList(&tlist);
+
+    MReadMarsFile     read("Events", fname);
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MClone            clone("MCerPhotEvt");
+    MImgCleanStd      clean;
+    MBlindPixelCalc   blind;
+    MHillasCalc       hcalc;
+
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clone);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+    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-7/Mars/macros/readin.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/readin.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/readin.C	(revision 9643)
@@ -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-7/Mars/macros/readpix.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/readpix.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/readpix.C	(revision 9643)
@@ -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-7/Mars/macros/readraw.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/readraw.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/readraw.C	(revision 9643)
@@ -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-7/Mars/macros/rootlogon.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/rootlogon.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/rootlogon.C	(revision 9643)
@@ -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
+!
+!
+\* ======================================================================== */
+
+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();
+
+    cout << "Welcome to the Mars Root environment." << endl;
+
+    cout << endl;
+}
Index: /tags/Mars_V0-7/Mars/macros/tar.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/tar.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/tar.C	(revision 9643)
@@ -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-7/Mars/macros/threshold.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/threshold.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/threshold.C	(revision 9643)
@@ -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  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
+    //
+    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-7/Mars/macros/trigrate.C
===================================================================
--- /tags/Mars_V0-7/Mars/macros/trigrate.C	(revision 9643)
+++ /tags/Mars_V0-7/Mars/macros/trigrate.C	(revision 9643)
@@ -0,0 +1,111 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 trigrate(int dim=0, char *filename = "data/camera.root" )
+{
+    // 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
+    //
+    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);
+
+    Float_t BgR[10]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    cout << "Number of Trigger conditions: " << num << endl;
+
+    MMcTriggerRateCalc rate(dim, 14, BgR, 100000);
+    tasklist.AddToList(&rate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // Start to loop over all events
+    //
+    if (!magic.Eventloop())
+        return;
+
+    hists.Print();
+}
Index: /tags/Mars_V0-7/Mars/magiclogo.xpm
===================================================================
--- /tags/Mars_V0-7/Mars/magiclogo.xpm	(revision 9643)
+++ /tags/Mars_V0-7/Mars/magiclogo.xpm	(revision 9643)
@@ -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-7/Mars/manalysis/AnalysisIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/AnalysisIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/AnalysisIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/AnalysisLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/AnalysisLinkDef.h	(revision 9643)
@@ -0,0 +1,35 @@
+#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 MCerPhotCalc+;
+
+#pragma link C++ class MImgCleanStd+;
+
+#pragma link C++ class MBlindPixels+;
+#pragma link C++ class MBlindPixelCalc+;
+
+#pragma link C++ class MCT1ReadAscii+;
+
+#pragma link C++ class MPedestalPix+;
+#pragma link C++ class MPedestalCam+;
+#pragma link C++ class MMcPedestalCopy+;
+#pragma link C++ class MMcPedestalNSBAdd+;
+
+#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 MPedCalcPedRun+;
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.cc	(revision 9643)
@@ -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): Oscar Blanch    12/2001 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  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                                  //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MCerPhotEvt                                                           //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MBlindPixels                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MBlindPixelCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+#include "MBlindPixels.h"
+#include "MMcRunHeader.hxx"
+
+ClassImp(MBlindPixelCalc);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBlindPixelCalc::MBlindPixelCalc(const char *name, const char *title)
+
+{
+    fName  = name  ? name  : "MBlindPixelCalc";
+    fTitle = title ? title : "Task which removes a list of pixel from analysis";
+}
+
+// --------------------------------------------------------------------------
+//
+//  - 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)
+{
+    fPixels = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+    if (!fPixels)
+	return kFALSE; 
+    
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    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;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Remove the pixels.
+//
+Bool_t MBlindPixelCalc::Process()
+{
+    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();
+    }
+
+    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 pixels are given by the user, we are already done
+    //
+    if (fPixelsID.GetSize() > 0)
+        return kTRUE;
+
+    //
+    // Set as blind some particular pixels because of a particular
+    // Star Field of View.
+    //
+    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrun)
+        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 - Detected Starfield unknown..." << endl;
+        return kSKIP;
+    }
+
+    //
+    // Case for Crab Nebula FOV
+    //
+    fPixels->Clear();
+    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;
+}
+
+
Index: /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MBlindPixelCalc.h	(revision 9643)
@@ -0,0 +1,36 @@
+#ifndef MARS_MBlindPixelCalc
+#define MARS_MBlindPixelCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MCerPhotEvt;
+class MBlindPixels;
+
+class MBlindPixelCalc : public MTask
+{
+private:
+    MCerPhotEvt  *fEvt;     //!
+    MBlindPixels *fPixels;  //!
+
+    TArrayS fPixelsID;  // Pixel IDs for blind pixels, which are entered by the user.
+
+public:
+    MBlindPixelCalc(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    void SetPixels(Int_t num, Short_t *ids);
+    virtual Bool_t ReInit(MParList *pList);
+
+    ClassDef(MBlindPixelCalc, 0) // task to disable given pixels for analysis
+}; 
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/manalysis/MBlindPixels.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MBlindPixels.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MBlindPixels.cc	(revision 9643)
@@ -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-7/Mars/manalysis/MBlindPixels.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MBlindPixels.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MBlindPixels.h	(revision 9643)
@@ -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 (Bool_t)fPixels[id]; }
+
+    ClassDef(MBlindPixels, 1) // container to store blind pixels
+}; 
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/manalysis/MCT1ReadAscii.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCT1ReadAscii.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCT1ReadAscii.cc	(revision 9643)
@@ -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  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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 "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-7/Mars/manalysis/MCT1ReadAscii.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCT1ReadAscii.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCT1ReadAscii.h	(revision 9643)
@@ -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-7/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotCalc.cc	(revision 9643)
@@ -0,0 +1,191 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//   MCerPhotCalc                                                           //
+//                                                                          //
+//   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 "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 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 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->FindObject("MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    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 (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;
+    }
+
+    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);
+
+    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;
+	}
+
+        Float_t nphot = (Float_t)pixel.GetSumHiGainSamples();
+
+        //
+	// We check that the pixel is not empty, if it is empty
+	// we won't substract the pedestal. Empty means that it has
+        // 0 signal in all the slices.
+        //
+        const Double_t mean = fEnableFix ? ped.GetMean()-0.5 : ped.GetMean();
+        if (nphot!=0)
+            nphot -= fRunHeader->GetNumSamplesHiGain()*mean;
+
+        fCerPhotEvt->AddPixel(pixid, nphot, sqrt(fRunHeader->GetNumSamplesHiGain())*ped.GetSigma());
+
+        // FIXME! Handling of Lo Gains is missing!
+    }
+
+    fCerPhotEvt->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-7/Mars/manalysis/MCerPhotCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotCalc.h	(revision 9643)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCerPhotCalc
+#define MARS_MCerPhotCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotCalc                                                            //
+//                                                                         //
+// 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 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)
+
+public:
+    MCerPhotCalc(const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    Bool_t ReInit(MParList *pList);
+
+    ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.cc	(revision 9643)
@@ -0,0 +1,211 @@
+/* ======================================================================== *\
+!
+! *
+! * 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"
+#include "MGeomPix.h"
+
+#include "MHexagon.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.IsCorePixel())
+            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.;
+
+    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
+
+    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 *= A0/(*geom)[pix.GetPixId()].GetA();
+
+        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.;
+
+    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
+    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 *= A0/(*geom)[pix.GetPixId()].GetA();
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
Index: /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotEvt.h	(revision 9643)
@@ -0,0 +1,53 @@
+#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;
+
+    MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+    MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+
+    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-7/Mars/manalysis/MCerPhotPix.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotPix.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotPix.cc	(revision 9643)
@@ -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-7/Mars/manalysis/MCerPhotPix.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MCerPhotPix.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MCerPhotPix.h	(revision 9643)
@@ -0,0 +1,49 @@
+#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    SetCorePixel()           { fIsCore = kTRUE; }
+    Bool_t  IsCorePixel() const      { return fIsCore;  }
+
+    void    SetNumPhotons(Float_t f) { fPhot    = f; }
+    void    SetErrorPhot(Float_t f)  { fErrPhot = f; }
+
+    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-7/Mars/manalysis/MEnergyEst.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MEnergyEst.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MEnergyEst.cc	(revision 9643)
@@ -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  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"
+
+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]";
+}
+
+
Index: /tags/Mars_V0-7/Mars/manalysis/MEnergyEst.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MEnergyEst.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MEnergyEst.h	(revision 9643)
@@ -0,0 +1,23 @@
+#ifndef MARS_MEnergyEst
+#define MARS_MEnergyEst
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MEnergyEst : public MParContainer
+{
+private:
+    Double_t fEnergy; // [GeV] Estimated Energy
+
+public:
+    MEnergyEst(const char *name=NULL, const char *title=NULL);
+
+    void SetEnergy(Double_t e) { fEnergy = e; }
+    Double_t GetEnergy() const { return fEnergy; }
+
+    ClassDef(MEnergyEst, 1) // Storage Container for the estimated Energy
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MEnergyEstimate.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MEnergyEstimate.cc	(revision 9643)
@@ -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-7/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MEnergyEstimate.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MEnergyEstimate.h	(revision 9643)
@@ -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-7/Mars/manalysis/MHillas.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillas.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillas.cc	(revision 9643)
@@ -0,0 +1,328 @@
+/* ======================================================================== *\
+!
+! *
+! * 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>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillas
+//
+// Storage Container for image parameters
+//
+//    basic image parameters
+// fLength   major axis of ellipse
+// fWidth    minor axis
+// fDelta    angle of major axis wrt x-axis
+// fSize     total sum of pixels
+// fMeanX    x of center of ellipse
+// fMeanY    y of center of ellipse
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillas.h"
+
+#include <fstream.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();
+    // FIXME: (intelligent) initialization of values missing
+
+    fEllipse = new TEllipse;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the TEllipse if one exists.
+//
+MHillas::~MHillas()
+{
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+void MHillas::Reset()
+{
+    fLength = 0;
+    fWidth  = 0;
+    fDelta  = 0;
+    fSize   = 0;
+    fMeanX  = 0;
+    fMeanY  = 0;
+
+    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 << " - Meanx    [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany    [mm]  = " << fMeanY  << endl;
+    *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
+    *fLog << " - atg(y/x) [deg] = " << atg     << endl;
+    *fLog << " - Size     [1]   = " << fSize   << " #CherPhot"   << 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();
+
+    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
+//
+Bool_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    // FIXME: MHillas::Calc is rather slow at the moment because it loops
+    //    unnecessarily over all pixels in all its loops (s.MImgCleanStd)
+    //    The speed could be improved very much by using Hash-Tables
+    //    (linked lists, see THashTable and THashList, too)
+    //
+
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    //
+    // sanity check
+    //
+    if (npixevt <= 2)
+        return kFALSE;
+
+    //
+    // calculate mean value of pixel coordinates and fSize
+    // -----------------------------------------------------
+    //
+    fMeanX = 0;
+    fMeanY = 0;
+    fSize  = 0;
+
+    //
+    // FIXME! npix should be retrieved from MCerPhotEvt
+    //
+    UShort_t npix=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 nphot = pix.GetNumPhotons();
+
+        fSize  += nphot;		             // [counter]
+        fMeanX += nphot * gpix.GetX();               // [mm]
+        fMeanY += nphot * gpix.GetY();               // [mm]
+
+        npix++;
+    }
+
+    //
+    // sanity check
+    //
+    if (fSize==0 || npix<=2)
+        return kFALSE;
+
+    fMeanX /= fSize;                                 // [mm]
+    fMeanY /= fSize;                                 // [mm]
+
+    //
+    // calculate 2nd moments
+    // -------------------
+    //
+    float corrxx=0;                                  // [m^2]
+    float corrxy=0;                                  // [m^2]
+    float 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 dx = gpix.GetX() - fMeanX;       // [mm]
+        const float dy = gpix.GetY() - fMeanY;       // [mm]
+
+        const float nphot = pix.GetNumPhotons();     // [#phot]
+
+        corrxx += nphot * dx*dx;                     // [mm^2]
+        corrxy += nphot * dx*dy;                     // [mm^2]
+        corryy += nphot * dy*dy;                     // [mm^2]
+    }
+
+    //
+    // calculate the basic Hillas parameters: orientation and size of axes
+    // -------------------------------------------------------------------
+    //
+    const float d = corryy - corrxx;
+
+    fDelta = atan2(d + sqrt(d*d + corrxy*corrxy*4), corrxy*2);
+
+    fCosDelta = cos(fDelta);   // need these in derived classes
+    fSinDelta = sin(fDelta);   // like MHillasExt
+
+    float axis1 = ( fCosDelta*fSinDelta*corrxy*2 + fCosDelta*fCosDelta*corrxx + fSinDelta*fSinDelta*corryy) / fSize; // [mm^2]
+    float axis2 = (-fCosDelta*fSinDelta*corrxy*2 + fSinDelta*fSinDelta*corrxx + fCosDelta*fCosDelta*corryy) / fSize; // [mm^2]
+ 
+    // very small numbers can get negative by rounding
+    if (axis1 < 0) axis1=0;
+    if (axis2 < 0) axis2=0; 
+
+    fLength = sqrt(axis1);  // [mm]
+    fWidth  = sqrt(axis2);  // [mm]
+
+    SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+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-7/Mars/manalysis/MHillas.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillas.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillas.h	(revision 9643)
@@ -0,0 +1,64 @@
+#ifndef MARS_MHillas
+#define MARS_MHillas
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+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
+
+    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 Bool_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; }
+
+    virtual void AsciiRead(ifstream &fin);
+    //virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.cc	(revision 9643)
@@ -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  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;
+
+    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()
+{
+    return fHillas->Calc(*fGeomCam, *fCerPhotEvt) ? kTRUE : kCONTINUE;
+}
+
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasCalc.h	(revision 9643)
@@ -0,0 +1,36 @@
+#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;
+public:
+    MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MHillasCalc, 0)   // Task to calculate Hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasExt.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasExt.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasExt.cc	(revision 9643)
@@ -0,0 +1,197 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHillasExt.h"
+
+#include <fstream.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    = 0;
+    fConc1   = 0; 
+    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
+//
+Bool_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    if (!MHillas::Calc(geom, evt))
+        return kFALSE;
+
+    //
+    //   calculate the additional image parameters
+    // --------------------------------------------
+    //
+    //   loop to get third moments along ellipse axes and two max pixels
+    //
+    float m3x = 0;
+    float m3y = 0;
+
+    float maxpix1 = 0;                                               // [#phot]
+    float maxpix2 = 0;                                               // [#phot]
+
+    float maxpixx = 0;                                               // [mm]
+    float maxpixy = 0;                                               // [mm]
+
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    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 dx = gpix.GetX() - GetMeanX();                   // [mm]
+        const float dy = gpix.GetY() - GetMeanY();                   // [mm]
+
+        const float nphot = pix.GetNumPhotons();                     // [1]
+
+        const float dzx =  GetCosDelta()*dx + GetSinDelta()*dy;      // [mm]
+        const float dzy = -GetSinDelta()*dx + GetCosDelta()*dy;      // [mm]
+
+        m3x += nphot * dzx*dzx*dzx;                                  // [mm^3]
+        m3y += nphot * dzy*dzy*dzy;                                  // [mm^3]
+
+        if (nphot>maxpix1)
+        {
+            maxpix2 = maxpix1;
+            maxpix1 = nphot;                                         // [1]
+            maxpixx = dx + GetMeanX();                               // [mm]
+            maxpixy = dy + GetMeanY();                               // [mm]
+            continue;                                                // [1]
+        }
+
+        if (nphot>maxpix2)
+            maxpix2 = nphot;                                         // [1]
+    }
+
+    fAsym  = (GetMeanX()-maxpixx)*GetCosDelta() + (GetMeanY()-maxpixy)*GetSinDelta(); // [mm]
+    fConc  = (maxpix1+maxpix2)/GetSize();                            // [ratio]
+    fConc1 = maxpix1/GetSize();                                      // [ratio]
+
+    //
+    // 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 kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+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-7/Mars/manalysis/MHillasExt.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasExt.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasExt.h	(revision 9643)
@@ -0,0 +1,41 @@
+#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; }
+
+    Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void AsciiRead(ifstream &fin);
+    //void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillasExt, 1) // Storage Container for extended Hillas Parameter
+};
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasSrc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasSrc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasSrc.cc	(revision 9643)
@@ -0,0 +1,113 @@
+/* ======================================================================== *\
+!
+! *
+! * 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>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrc
+//
+// Storage Container for image parameters
+//
+//    source-dependent image parameters
+// fAlpha    angle between major axis and line source-to-center
+// fDist     distance from source to center of ellipse
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrc.h"
+
+#include <fstream.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";
+}
+
+// --------------------------------------------------------------------------
+//
+//  calculation of source-dependent parameters
+//
+void MHillasSrc::Calc(const MHillas *hillas)
+{
+    const Double_t mx = hillas->GetMeanX();        // [mm]
+    const Double_t my = hillas->GetMeanY();        // [mm]
+
+    const Double_t sx = mx - fSrcPos->GetX();      // [mm]
+    const Double_t sy = my - fSrcPos->GetY();      // [mm]
+
+    const Double_t sd = sin(hillas->GetDelta());   // [1]
+    const Double_t cd = cos(hillas->GetDelta());   // [1]
+
+
+    fHeadTail = cd*sx + sd*sy;                     // [mm]
+    fDist     = sqrt(sx*sx + sy*sy);               // [mm]
+    fAlpha    = atan2(cd*sy - sd*sx, fHeadTail);   // [rad]
+    fAlpha   *= kRad2Deg;                          // [deg]
+
+    fHillas   = hillas;
+
+    SetReadyToSave();
+} 
+
+void MHillasSrc::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist     = " << fDist     << " mm"  << endl;
+    *fLog << " - Alpha    = " << fAlpha    << " deg" << endl;
+    *fLog << " - HeadTail = " << fHeadTail << " mm"  << endl;
+}
+
+// -----------------------------------------------------------------------
+//
+// 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-7/Mars/manalysis/MHillasSrc.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasSrc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasSrc.h	(revision 9643)
@@ -0,0 +1,51 @@
+#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 from src to center of ellipse
+    Float_t fHeadTail; // [mm]
+
+public:
+    MHillasSrc(const char *name=NULL, const char *title=NULL);
+
+    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
+    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+
+    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; }
+
+    void Print(Option_t *opt=NULL) const;
+
+    virtual void Calc(const MHillas *hillas);
+
+    virtual void AsciiRead(ifstream &fin);
+    //virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MHillasSrc, 2) // Container to hold source position dependant parameters
+};
+
+/*
+ Version 1: fAlpha, fDist
+ Version 2: fAlpha, fDist, fSign
+ */
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.cc	(revision 9643)
@@ -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 <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 "MParList.h"
+
+#include "MHillasSrc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasSrcCalc);
+
+// -------------------------------------------------------------------------
+//
+// 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)
+{
+    fName  = name  ? name  : "MHillasSrcCalc";
+    fTitle = title ? title : "add parameters dependent on source position (MHillasSrc)";
+
+    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);
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Bool_t MHillasSrcCalc::Process()
+{
+    fHillasSrc->Calc(fHillas);
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MHillasSrcCalc.h	(revision 9643)
@@ -0,0 +1,32 @@
+#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;
+    MSrcPosCam *fSrcPos;
+    MHillasSrc *fHillasSrc;
+
+    TString     fSrcName;
+    TString     fHillasName;
+
+public:
+    MHillasSrcCalc(const char *src="MSrcPosCam", const char *hil="MHillasSrc",
+                   const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *plist);
+    Bool_t Process();
+
+    ClassDef(MHillasSrcCalc, 0) // task to calculate the source position depandant hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.cc	(revision 9643)
@@ -0,0 +1,395 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <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
+};
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Here you can specify the cleaning levels. If you
+// don't specify them the 'common standard' values 2.5 and 3.0 (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  : "MImgCleanStd";
+    fTitle = title ? title : "Task which does a standard image cleaning";
+
+    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)
+//
+void MImgCleanStd::CleanStep1()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    //
+    // 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();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the survived pixel have a neighbor, that also
+//  survived
+//
+void MImgCleanStd::CleanStep2()
+{
+    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[577];
+
+    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 (!pix.IsPixelUsed())
+            continue;
+
+        //
+        // get pixel id of this entry
+        //
+        const Int_t id = pix.GetPixId();
+
+        //
+        // count number of next neighbors of this pixel which
+        // state is 'used'
+        //
+        const MGeomPix &gpix  = (*fCam)[id];
+        const Int_t     nnmax = gpix.GetNumNeighbors();
+
+        Bool_t cnt = kFALSE;
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t id2 = gpix.GetNeighbor(j);
+
+            if (!ispixused[id2])
+                continue;
+
+            cnt = kTRUE;
+            break;
+        }
+        if (cnt)
+            continue;
+
+        //
+        // check if no next neighbor has the state 'used'
+        // set this pixel to 'unused', too.
+        //
+        pix.SetPixelUnused();
+    }
+
+    //
+    // 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.SetCorePixel();
+    }
+} 
+
+// --------------------------------------------------------------------------
+//
+//   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.IsCorePixel())
+            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()
+{
+    CleanStep1();
+    CleanStep2();
+    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;
+}
Index: /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MImgCleanStd.h	(revision 9643)
@@ -0,0 +1,43 @@
+#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);
+
+public:
+    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
+                 const char *name=NULL, const char *title=NULL);
+
+    void CleanStep1();
+    void CleanStep2();
+    void CleanStep3();
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    void Print(Option_t *o="") const;
+
+    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-7/Mars/manalysis/MMcPedestalCopy.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MMcPedestalCopy.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MMcPedestalCopy.cc	(revision 9643)
@@ -0,0 +1,148 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "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. (not yet: If the check fails the eventloop is
+// stopped.)
+// 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-7/Mars/manalysis/MMcPedestalCopy.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MMcPedestalCopy.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MMcPedestalCopy.h	(revision 9643)
@@ -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-7/Mars/manalysis/MMcPedestalNSBAdd.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MMcPedestalNSBAdd.cc	(revision 9643)
@@ -0,0 +1,225 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 that 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 "MPedestalCam.h"
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+#include "MMcFadcHeader.hxx"
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+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-7/Mars/manalysis/MMcPedestalNSBAdd.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MMcPedestalNSBAdd.h	(revision 9643)
@@ -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-7/Mars/manalysis/MPedCalcPedRun.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedCalcPedRun.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedCalcPedRun.cc	(revision 9643)
@@ -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-7/Mars/manalysis/MPedCalcPedRun.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedCalcPedRun.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedCalcPedRun.h	(revision 9643)
@@ -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-7/Mars/manalysis/MPedestalCam.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedestalCam.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedestalCam.cc	(revision 9643)
@@ -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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCam                                                            //
+//                                                                         //
+// Hold the Pedestal information for all pixels in the camera              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCam.h"
+
+#include "MLog.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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if position i is inside bounds
+//
+Bool_t MPedestalCam::CheckBounds(Int_t i)
+{
+    return i < fArray->GetEntriesFast();
+} 
+
+
Index: /tags/Mars_V0-7/Mars/manalysis/MPedestalCam.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedestalCam.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedestalCam.h	(revision 9643)
@@ -0,0 +1,36 @@
+#ifndef MARS_MPedestalCam
+#define MARS_MPedestalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MPedestalPix
+#include "MPedestalPix.h"
+#endif
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+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 InitSize(const UInt_t i) { fArray->ExpandCreate(i); }
+
+    MPedestalPix &operator[](Int_t i)       { return *(MPedestalPix*)fArray->UncheckedAt(i); }
+    MPedestalPix &operator[](Int_t i) const { return *(MPedestalPix*)fArray->UncheckedAt(i); }
+
+    Bool_t CheckBounds(Int_t i);
+
+    ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.cc	(revision 9643)
@@ -0,0 +1,43 @@
+/* ======================================================================== *\
+!
+! *
+! * 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()
+    : fMean(0.0), fSigma(0.0), fMeanRms(0.0), fSigmaRms(0.0)
+{
+}
+
Index: /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MPedestalPix.h	(revision 9643)
@@ -0,0 +1,36 @@
+#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();
+
+    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; }
+
+    ClassDef(MPedestalPix, 1)	// Storage Container for Pedestal information of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.cc
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.cc	(revision 9643)
@@ -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    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);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MSrcPosCam::MSrcPosCam(const char *name, const char *title) : fX(0), fY(0)
+{
+    fName  = name  ? name  : "MSrcPosCam";
+    fTitle = title ? title : "Source position in the camera";
+}
+
+// -----------------------------------------------------------------------
+//
+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;
+}
Index: /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.h
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/MSrcPosCam.h	(revision 9643)
@@ -0,0 +1,34 @@
+#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
+
+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-7/Mars/manalysis/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/manalysis/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/manalysis/Makefile	(revision 9643)
@@ -0,0 +1,65 @@
+##################################################################
+#
+#   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../mgui -I../mmc -I../mraw
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MCT1ReadAscii.cc \
+           MPedestalPix.cc \
+           MPedestalCam.cc \
+           MMcPedestalCopy.cc \
+           MMcPedestalNSBAdd.cc \
+           MImgCleanStd.cc \
+           MEnergyEst.cc \
+           MEnergyEstimate.cc \
+           MSrcPosCam.cc \
+           MHillas.cc \
+           MHillasSrc.cc \
+           MHillasExt.cc \
+           MHillasCalc.cc \
+           MHillasSrcCalc.cc \
+	   MCerPhotPix.cc \
+           MCerPhotCalc.cc \
+	   MCerPhotEvt.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-7/Mars/mars.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mars.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mars.cc	(revision 9643)
@@ -0,0 +1,113 @@
+#include <TROOT.h>
+#include <TApplication.h>
+
+#include "MAGIC.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMars.h"
+#include "MArray.h"
+#include "MParContainer.h"
+
+// **********************************************************************
+//
+//    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 )
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                    MARS V0.7                     " << 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);
+
+    //
+    // start the main window
+    //
+    new MMars;
+
+    //
+    // run the application
+    //
+    app.Run();
+
+    gLog << all << endl;
+
+    return 0;
+}
+ 
+
Index: /tags/Mars_V0-7/Mars/marslogo.xpm
===================================================================
--- /tags/Mars_V0-7/Mars/marslogo.xpm	(revision 9643)
+++ /tags/Mars_V0-7/Mars/marslogo.xpm	(revision 9643)
@@ -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-7/Mars/mbase/BaseIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/BaseIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/BaseIncl.h	(revision 9643)
@@ -0,0 +1,10 @@
+#ifndef __CINT__
+
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mbase/BaseLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/BaseLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/BaseLinkDef.h	(revision 9643)
@@ -0,0 +1,55 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ global kCONTINUE;
+#pragma link C++ global kGAMMA;
+#pragma link C++ global kPROTON;
+#pragma link C++ global kHELIUM;
+#pragma link C++ global kOXIGEN;
+#pragma link C++ global kIRON;
+#pragma link C++ global kPI;
+#pragma link C++ global kRad2Deg;
+
+#pragma link C++ global gLog;
+
+#pragma link C++ class MLog+;
+
+#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 MFilterList+;
+
+#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 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 MArray;
+#pragma link C++ class MArrayB;
+#pragma link C++ class MArrayS;
+
+#pragma link C++ class MTime+;
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MAGIC.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MAGIC.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MAGIC.h	(revision 9643)
@@ -0,0 +1,46 @@
+#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
+//
+const Int_t kGAMMA  =    0;
+const Int_t kPROTON =   14;
+const Int_t kHELIUM =  402;
+const Int_t kOXIGEN = 1608;
+const Int_t kIRON   = 5626;
+
+const Double_t kPI      = 3.1415926535897932384626433832795028841971693993751;
+const Double_t kRad2Deg = 180.0/kPI;
+
+//
+// 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-7/Mars/mbase/MArray.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArray.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArray.cc	(revision 9643)
@@ -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-7/Mars/mbase/MArray.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArray.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArray.h	(revision 9643)
@@ -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-7/Mars/mbase/MArrayB.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArrayB.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArrayB.cc	(revision 9643)
@@ -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-7/Mars/mbase/MArrayB.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArrayB.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArrayB.h	(revision 9643)
@@ -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-7/Mars/mbase/MArrayS.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArrayS.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArrayS.cc	(revision 9643)
@@ -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-7/Mars/mbase/MArrayS.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MArrayS.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MArrayS.h	(revision 9643)
@@ -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-7/Mars/mbase/MClone.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MClone.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MClone.cc	(revision 9643)
@@ -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-7/Mars/mbase/MClone.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MClone.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MClone.h	(revision 9643)
@@ -0,0 +1,40 @@
+#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; }
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MClone, 0) // Task to clone (duplicate) an object in memory
+};
+    
+#endif
+
Index: /tags/Mars_V0-7/Mars/mbase/MEvtLoop.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MEvtLoop.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MEvtLoop.cc	(revision 9643)
@@ -0,0 +1,275 @@
+/* ======================================================================== *\
+!
+! *
+! * 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...                                             //
+//                                                                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MEvtLoop.h"
+
+#include <iostream.h>
+
+#include <TSystem.h>
+#include <TStopwatch.h>
+#include <TGProgressBar.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+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
+//!
+
+// --------------------------------------------------------------------------
+//
+// default constructor - emty
+//
+MEvtLoop::MEvtLoop() : fParList(NULL), fProgress(NULL)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// 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);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 && maxcnt>0)
+        fProgress->SetRange(0, maxcnt);
+
+    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;
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MEvtLoop.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MEvtLoop.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MEvtLoop.h	(revision 9643)
@@ -0,0 +1,51 @@
+#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;
+
+class MEvtLoop : public MParContainer
+{
+private:
+    MParList  *fParList;
+    MTaskList *fTaskList;
+
+    TGProgressBar *fProgress;
+
+    enum { kIsOwner = BIT(14) };
+
+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; }
+
+    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");
+
+    ClassDef(MEvtLoop, 0) // Class to execute the tasks in a tasklist
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MFilter.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MFilter.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MFilter.cc	(revision 9643)
@@ -0,0 +1,99 @@
+/* ======================================================================== *\
+!
+! *
+! * 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;
+}
Index: /tags/Mars_V0-7/Mars/mbase/MFilter.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MFilter.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MFilter.h	(revision 9643)
@@ -0,0 +1,24 @@
+#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();
+
+    ClassDef(MFilter, 0)		// Abstract base class for the filters
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MFilterList.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MFilterList.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MFilterList.cc	(revision 9643)
@@ -0,0 +1,290 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <TString.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFilterList);
+
+// --------------------------------------------------------------------------
+//
+//   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)
+{
+    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
+{
+    TString str(opt);
+    const Bool_t verbose = str.Contains("V", TString::kIgnoreCase);
+
+    //*fLog << all << "(" << GetName() << "=" << (int)fFilterType << ")";
+
+    *fLog << all << "(";
+
+    TIter Next(&fFilters);
+
+    MFilter *filter=(MFilter*)Next();
+
+    //
+    // loop over all filters
+    //
+    if (!filter)
+    {
+        *fLog << "<empty>)" << flush;
+        return;
+    }
+
+    filter->Print();
+
+    while ((filter=(MFilter*)Next()))
+    {
+        switch (fFilterType)
+        {
+        case kEAnd:
+            *fLog << (verbose?" and ":" & ");
+            break;
+
+        case kEOr:
+            *fLog << (verbose?" or ":" | ");
+            break;
+
+        case kEXor:
+            *fLog << (verbose?" xor ":" ^ ");
+            break;
+
+        case kELAnd:
+            *fLog << (verbose?" land ":" && ");
+            break;
+
+        case kELOr:
+            *fLog << (verbose?" lor ":" || ");
+            break;
+        }
+
+        filter->Print();
+    }
+
+    *fLog << ")" << flush;
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MFilterList.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MFilterList.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MFilterList.h	(revision 9643)
@@ -0,0 +1,54 @@
+#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) };
+
+public:
+    MFilterList(const char *type="&&");
+    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;
+
+    ClassDef(MFilterList, 0)		// List to combine several filters logically
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MGGroupFrame.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGGroupFrame.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGGroupFrame.cc	(revision 9643)
@@ -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-7/Mars/mbase/MGGroupFrame.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGGroupFrame.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGGroupFrame.h	(revision 9643)
@@ -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-7/Mars/mbase/MGList.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGList.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGList.cc	(revision 9643)
@@ -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->IsA()->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-7/Mars/mbase/MGList.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGList.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGList.h	(revision 9643)
@@ -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-7/Mars/mbase/MGTask.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGTask.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGTask.cc	(revision 9643)
@@ -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-7/Mars/mbase/MGTask.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MGTask.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MGTask.h	(revision 9643)
@@ -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-7/Mars/mbase/MHtml.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MHtml.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MHtml.cc	(revision 9643)
@@ -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-7/Mars/mbase/MHtml.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MHtml.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MHtml.h	(revision 9643)
@@ -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-7/Mars/mbase/MInputStreamID.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MInputStreamID.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MInputStreamID.cc	(revision 9643)
@@ -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-7/Mars/mbase/MInputStreamID.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MInputStreamID.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MInputStreamID.h	(revision 9643)
@@ -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-7/Mars/mbase/MLog.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MLog.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MLog.cc	(revision 9643)
@@ -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
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// 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), 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), 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), 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()
+{
+    const int len = fPPtr - fBase;
+
+    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;
+    }
+
+    //
+    // restart writing to the buffer at its first char
+    //
+    fPPtr = fBase;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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-7/Mars/mbase/MLog.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MLog.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MLog.h	(revision 9643)
@@ -0,0 +1,127 @@
+#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
+
+    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;
+    }
+
+    ClassDef(MLog, 0) // This is what we call 'The logging system'
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MLogManip.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MLogManip.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MLogManip.cc	(revision 9643)
@@ -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-7/Mars/mbase/MLogManip.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MLogManip.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MLogManip.h	(revision 9643)
@@ -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-7/Mars/mbase/MParContainer.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MParContainer.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MParContainer.cc	(revision 9643)
@@ -0,0 +1,347 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <fstream.h>     // ofstream, AsciiWrite
+
+#include <TClass.h>      // IsA
+#include <TBaseClass.h>  // GetClassPointer
+#include <TROOT.h>       // TROOT::Identlevel
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+#include <TDataMember.h> // TDataMember, AsciiWrite
+#include <TVirtualPad.h> // gPad
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+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);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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;
+    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;
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) the title of the MParContainer.
+//
+void MParContainer::SetTitle(const char *title)
+{
+    fTitle = title;
+    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)
+    {
+        *fLog << err << "'" << name << "' is neither a member of ";
+        *fLog << GetDescriptor() << " nor one of its base classes." << endl;
+        return NULL;
+    }
+
+    TDataMember *member = cls->GetDataMember(name);
+    if (!member)
+    {
+        *fLog << err << "Datamember '" << name << "' not in " << GetDescriptor() << endl;
+        return NULL;
+    }
+
+    TMethodCall *call = member->GetterMethod();
+    if (!call)
+    {
+        *fLog << err << "Sorry, no getter method found for " << name << endl;
+        return NULL;
+    }
+
+    return call;
+}
Index: /tags/Mars_V0-7/Mars/mbase/MParContainer.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MParContainer.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MParContainer.h	(revision 9643)
@@ -0,0 +1,109 @@
+#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:
+    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="") : 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 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   SetLogStream(MLog *lg) { fLog = lg; }
+    virtual void   Reset() { }
+    virtual Bool_t IsReadyToSave()                   { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+
+    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;
+
+    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-7/Mars/mbase/MParList.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MParList.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MParList.cc	(revision 9643)
@@ -0,0 +1,626 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <TNamed.h>
+#include <TClass.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MParList);
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  creates an empty list
+//
+MParList::MParList(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MParList";
+    fTitle = title ? title : "A list of Parameter Containers";
+
+    //
+    // 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.
+    //
+    TestBit(kIsOwner) ? fContainer->SetOwner() : fAutodelete->SetOwner();
+
+    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 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() << 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;
+}
Index: /tags/Mars_V0-7/Mars/mbase/MParList.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MParList.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MParList.h	(revision 9643)
@@ -0,0 +1,82 @@
+#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) };
+
+public:
+    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);
+
+    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);
+
+    void Print(Option_t *t = NULL) const;
+
+    ClassDef(MParList, 0) // list of parameter containers (MParContainer)
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MPrint.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MPrint.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MPrint.cc	(revision 9643)
@@ -0,0 +1,133 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+//
+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
+//
+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... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calls overloaded TObject::Print
+//
+Bool_t MPrint::Process()
+{
+    fObject->Print(fOption);
+    return kTRUE;
+} 
+
Index: /tags/Mars_V0-7/Mars/mbase/MPrint.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MPrint.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MPrint.h	(revision 9643)
@@ -0,0 +1,32 @@
+#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
+
+    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; }
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+
+    ClassDef(MPrint, 0) // Task to call Print() function
+};
+    
+#endif
+
Index: /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.cc	(revision 9643)
@@ -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): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.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"
+
+ClassImp(MReadMarsFile);
+
+// --------------------------------------------------------------------------
+//
+//  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  : "MReadMarsFile";
+    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);
+
+    //
+    // 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()
+{
+    //
+    // Try to read the new run headers. If reading the new run header
+    // was successfull call the ReInits
+    //
+    if (fRun->Process())
+    {
+        *fLog << inf << "MReadMarsFile: Switching to '" << GetFileName() << "' ";
+        *fLog << "(before event #" << GetEventNum()-1 << ")" << endl;
+
+        fTaskList->ReInit();
+        //MReadTree::Notify();
+    }
+    else
+        *fLog << warn << "Warning: Cannot read new runheaders after reading event #" << GetEventNum() << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  PreProcessed the MReadTree to read the run headers and its base class.
+//  see MReadTree::PreProcess for more information
+//
+Bool_t MReadMarsFile::PreProcess(MParList *pList)
+{
+    fTaskList = (MTaskList*)pList->FindObject("MTaskList");
+
+    if (!fRun->PreProcess(pList))
+        return kFALSE;
+
+    if (!fRun->Process())
+        return kFALSE;
+
+    fRun->SetEventNum(0);
+
+    return MReadTree::PreProcess(pList);
+}
Index: /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MReadMarsFile.h	(revision 9643)
@@ -0,0 +1,29 @@
+#ifndef MARS_MReadMarsFile
+#define MARS_MReadMarsFile
+
+#ifndef MARS_MReadTree
+#include "MReadTree.h"
+#endif
+
+class MTaskList;
+
+class MReadMarsFile : public MReadTree
+{
+private:
+    MReadTree *fRun;
+    MTaskList *fTaskList; //! Tasklist for reinitialization
+
+    Bool_t Notify();
+
+    Bool_t PreProcess(MParList *pList);
+  
+public:
+    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, 0)	// Reads a tree from file(s)
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MReadTree.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MReadTree.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MReadTree.cc	(revision 9643)
@@ -0,0 +1,741 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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 <TChain.h>
+#include <TGProgressBar.h>
+#include <TChainElement.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MFilter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MReadTree);
+
+class MChain : public TChain
+{
+public:
+    MChain() : TChain() {}
+    MChain(const char *name, const char *title="") : TChain(name, title) {}
+
+    void ResetTree() { fTree = 0; }
+};
+
+// --------------------------------------------------------------------------
+//
+//  Default 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), fBranchChoosing(kFALSE), fAutoEnable(kTRUE), fProgress(NULL)
+{
+    fName  = name  ? name  : "MReadTree";
+    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)
+        fChain->Add(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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
+    //
+    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 << "MReadTree: 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
+    //
+    return fChain->Add(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 << "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 barnch 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 << "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);
+
+    }
+*/
+}
+
+// --------------------------------------------------------------------------
+//
+//  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
+    //
+    fNumEntries = (UInt_t)fChain->GetEntries();
+
+    if (!fNumEntries)
+    {
+        *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 << "MReadTree setup " << num << " master branches addresses." << endl;
+
+    //
+    // If auto enabling scheme isn't disabled, do auto enabling
+    //
+    if (fAutoEnable)
+        EnableBranches(pList);
+
+    //
+    // If a progress bar is given set its range.
+    //
+    if (fProgress)
+        fProgress->SetRange(0, fNumEntries);
+
+    //
+    // 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 >= fNumEntries)
+        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 >= fNumEntries)
+    {
+        *fLog << warn << "MReadTree::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 >= fNumEntries)
+    {
+        *fLog << warn << "MReadTree::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 >= fNumEntries)
+    {
+        *fLog << warn << "MReadTree::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;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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:" << endl;
+
+    int i = 0;
+    TIter Next(fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        *fLog << " " << i++ << ") " << obj->GetName() << endl;
+
+    *fLog << " Entries: " << fNumEntries << endl;
+    *fLog << " Next Entry: " << fNumEntry << endl;
+}
Index: /tags/Mars_V0-7/Mars/mbase/MReadTree.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MReadTree.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MReadTree.h	(revision 9643)
@@ -0,0 +1,76 @@
+#ifndef MARS_MReadTree
+#define MARS_MReadTree
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MChain;
+class TBranch;
+class TGProgressBar;
+
+class MReadTree : public MTask
+{
+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
+
+private:
+    TGProgressBar  *fProgress; //! Possible display of status
+
+    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);
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    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);
+
+    void   SetProgressBar(TGProgressBar *bar) { fProgress = bar; }
+
+    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() const  { return fNumEntries; }
+
+    TString GetFileName() 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 Bool_t PreProcess(MParList *pList);
+    virtual Bool_t Process();
+
+    virtual Bool_t Notify();
+
+    ClassDef(MReadTree, 0)	// Reads a tree from file(s)
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MTask.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTask.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTask.cc	(revision 9643)
@@ -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 <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 should be executed only if         //
+//                     PreProcess was successfull (returned kTRUE)         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MTask.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, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 this task has been processed.
+// 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.
+//
+void MTask::PrintStatistics(const Int_t lvl) const
+{
+    *fLog << all << setw(lvl) << " " << GetDescriptor() << "\t";
+    *fLog << dec << fNumExecutions << endl;
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MTask.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTask.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTask.h	(revision 9643)
@@ -0,0 +1,87 @@
+#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
+
+    const 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)
+    {
+        AddToBranchList((const char*)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(const MFilter *filter) { fFilter=filter; }
+    const MFilter *GetFilter() const      { return fFilter; }
+    virtual void PrintStatistics(const Int_t lvl=0) 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; }
+
+    ClassDef(MTask, 0) //Abstract base class for a task
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MTaskList.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTaskList.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTaskList.cc	(revision 9643)
@@ -0,0 +1,509 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <TClass.h>
+#include <TBaseClass.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MInputStreamID.h"
+
+ClassImp(MTaskList);
+
+// --------------------------------------------------------------------------
+//
+// 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  : "MTaskList";
+    fTitle = title ? title : "A list for tasks to be executed";
+
+    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))
+            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.Delete();
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for preproccesing
+    //
+    while ((task=(MTask*)Next()))
+    {
+        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.
+    //
+    // 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(&fTasksProcess);
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for processing
+    //
+    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
+            //
+            return kFALSE;
+
+        case kCONTINUE:
+            //
+            // something occured: skip the rest of the tasks for this event
+            //
+            return kTRUE;
+
+        default:
+            *fLog << warn << "MTaskList::Process: Unknown return value from MTask::Process()... ignored." << endl;
+        }
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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()) )
+    {
+        if (!task->CallPostProcess())
+            return kFALSE;
+
+        *fLog << all << task->GetName() << "... " << flush;
+    }
+
+    *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. Use MTaskList::PrintStatistics without an argument.
+//
+void MTaskList::PrintStatistics(const Int_t lvl) const
+{
+    if (lvl==0)
+    {
+        *fLog << all << endl;
+        *fLog << "Execution Statistics: " << endl;
+        *fLog << "---------------------" << endl;
+        *fLog << GetDescriptor() << endl;
+    }
+    else
+    {
+        *fLog << setw(lvl) << " " << GetDescriptor() << endl;
+    }
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    fTasks->ForEach(MTask, PrintStatistics)(lvl+1);
+
+    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;
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MTaskList.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTaskList.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTaskList.h	(revision 9643)
@@ -0,0 +1,63 @@
+#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:
+    TList    *fTasks;	// Container for the ordered list of different tasks
+    TList    fTasksProcess; //!
+    MParList *fParList;
+
+    UInt_t *fCntContinue;
+    UInt_t *fCntTrue;
+
+    enum { kIsOwner = BIT(14) };
+
+    void   Remove(MTask *task);
+    Bool_t CheckClassForProcess(TClass *cls);
+
+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) const;
+    void SetOwner(Bool_t enable=kTRUE);
+
+    const TList *GetList() const { return fTasks; }
+
+    ClassDef(MTaskList, 0)	//collection of tasks to be performed in the eventloop
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTime.cc	(revision 9643)
@@ -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-7/Mars/mbase/MTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MTime.h	(revision 9643)
@@ -0,0 +1,113 @@
+#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 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-7/Mars/mbase/MWriteAsciiFile.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteAsciiFile.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteAsciiFile.cc	(revision 9643)
@@ -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  06/2001 <mailto:tbretz@uni-sw.gwdg.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 <TClass.h>      // IsA
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+#include <TDataMember.h> // TDataMember, AsciiWrite
+
+#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)
+        AddContainer(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)
+        AddContainer(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete the output file if necessary (it is closed
+// automatically by its destructor.
+//
+MWriteAsciiFile::~MWriteAsciiFile()
+{
+    fContNames.SetOwner();
+    fMembers.SetOwner();
+
+    delete fOut;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *cont = NULL;
+
+    Int_t num = fContainer.GetEntries();
+
+    TIter NextCont(&fContainer);
+    TIter NextMemb(&fMembers);
+
+    while ((cont=(MParContainer*)NextCont()))
+    {
+        const MScale *memb = (MScale*)NextMemb();
+
+        if (!cont->IsReadyToSave())
+            continue;
+
+        if (memb->GetTitle()[0]=='\0')
+        {
+            if (!cont->AsciiWrite(*fOut))
+                continue;
+        }
+        else
+        {
+            if (!cont->WriteDataMember(*fOut, memb->GetTitle(), memb->GetScale()))
+                continue;
+        }
+
+        written = kTRUE;
+
+        num--;
+    }
+
+    if (!written)
+        return;
+
+    *fOut << endl;
+
+    if (num!=0)
+        *fLog << warn << "Warning - given number of containers doesn't fit number of written containers." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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)
+{
+    MScale *obj = NULL;
+
+    TIter Next(&fContNames);
+
+    while ((obj=(MScale*)Next()))
+    {
+        const char *name = obj->GetName();
+
+        MParContainer *cont = (MParContainer*)pList->FindObject(name, "MParContainer");
+        if (!cont)
+        {
+            *fLog << err << dbginf << "Cannot find parameter container '" << name << "'." << endl;
+            return kFALSE;
+        }
+
+        AddContainer(cont, obj->GetTitle(), obj->GetScale());
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another container (by name) to be written to the ascii file.
+// The container will be output one after each other in one line.
+// If you want to write only one data member of the container
+// specify the name of the data member (eg. fAlpha) Make sure,
+// that a "GetteMethod" for this data type exists (strip the f and
+// replace it by Get)
+// If you specify a single data member you can add a scale-factor which
+// is (in case of the data member being a floating point value) multiplied
+// with the data member value. This is usefull if you are want to
+// change the scale (unit) of a data member for writing (eg.
+// writing degrees for the hillas parameters instead of the internally
+// used millimeters)
+//
+void MWriteAsciiFile::AddContainer(const char *cname, const char *member, Double_t scale)
+{
+    MScale *name = new MScale(cname, member, scale);
+    fContNames.AddLast(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.
+// If you want to write only one data member of the container
+// specify the name of the data member (eg. fAlpha) Make sure,
+// that a "GetteMethod" for this data type exists (strip the f and
+// replace it by Get)
+// If you specify a single data member you can add a scale-factor which
+// is (in case of the data member being a floating point value) multiplied
+// with the data member value. This is usefull if you are want to
+// change the scale (unit) of a data member for writing (eg.
+// writing degrees for the hillas parameters instead of the internally
+// used millimeters)
+//
+void MWriteAsciiFile::AddContainer(MParContainer *cont, const char *member, Double_t scale)
+{
+    fContainer.AddLast(cont);
+
+    MScale *name = new MScale("", member, scale);
+    fMembers.AddLast(name);
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MWriteAsciiFile.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteAsciiFile.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteAsciiFile.h	(revision 9643)
@@ -0,0 +1,52 @@
+#ifndef MARS_MWriteAsciiFile
+#define MARS_MWriteAsciiFile
+
+#ifndef MARS_MWriteFile
+#include "MWriteFile.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MWriteAsciiFile : public MWriteFile
+{
+private:
+    class MScale : public TNamed
+    {
+    private:
+        Double_t fScale;
+    public:
+        MScale(const char *name, const char *title, Double_t scale)
+            : TNamed(name, title), fScale(scale) {}
+        Double_t GetScale() const { return fScale; }
+    };
+
+    ofstream *fOut;
+
+    TObjArray fContNames;
+    TObjArray fContainer;
+    TObjArray fMembers;
+
+    TString fNameFile;
+
+    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 AddContainer(const char *cname, const char *member="", Double_t scale=1);
+    void AddContainer(MParContainer *cont, const char *member="", Double_t scale=1);
+
+    ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/MWriteFile.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteFile.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteFile.cc	(revision 9643)
@@ -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@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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-7/Mars/mbase/MWriteFile.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteFile.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteFile.h	(revision 9643)
@@ -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-7/Mars/mbase/MWriteRootFile.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteRootFile.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteRootFile.cc	(revision 9643)
@@ -0,0 +1,381 @@
+/* ======================================================================== *\
+!
+! *
+! * 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@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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 <TFile.h>
+#include <TTree.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MRootFileBranch);
+ClassImp(MWriteRootFile);
+
+// --------------------------------------------------------------------------
+//
+// 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  : "MWriteRootFile";
+    fTitle = title ? title : "Task which writes a root-output file";
+
+    //
+    // 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
+    //
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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
+            //
+            tree = new TTree(tname, ttitle ? ttitle : tname);
+            fTrees.AddLast(tree);
+
+            *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();
+}
+
Index: /tags/Mars_V0-7/Mars/mbase/MWriteRootFile.h
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/MWriteRootFile.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/MWriteRootFile.h	(revision 9643)
@@ -0,0 +1,91 @@
+#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(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, 0) // 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;
+
+public:
+    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, 0)	// Class to write one container to a root file
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mbase/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mbase/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mbase/Makefile	(revision 9643)
@@ -0,0 +1,73 @@
+##################################################################
+#
+#   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
+
+# @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 \
+           MFilterList.cc \
+           MEvtLoop.cc \
+           MReadTree.cc \
+           MReadMarsFile.cc \
+           MWriteFile.cc \
+           MWriteAsciiFile.cc \
+           MWriteRootFile.cc \
+           MGList.cc \
+           MGTask.cc \
+           MGGroupFrame.cc \
+	   MArray.cc \
+	   MArrayB.cc \
+	   MArrayS.cc \
+           MTime.cc \
+           MClone.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-7/Mars/mdata/DataIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/DataIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/DataIncl.h	(revision 9643)
@@ -0,0 +1,10 @@
+#ifndef __CINT__
+
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mdata/DataLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/DataLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/DataLinkDef.h	(revision 9643)
@@ -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 MData+;
+#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-7/Mars/mdata/MData.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MData.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MData.cc	(revision 9643)
@@ -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@uni-sw.gwdg.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.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MData.h"
+
+ClassImp(MData);
Index: /tags/Mars_V0-7/Mars/mdata/MData.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MData.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MData.h	(revision 9643)
@@ -0,0 +1,26 @@
+#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;
+
+    ClassDef(MData, 0) // A Base class for a generalized value
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mdata/MDataChain.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataChain.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataChain.cc	(revision 9643)
@@ -0,0 +1,300 @@
+/* ======================================================================== *\
+!
+! *
+! * 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@uni-sw.gwdg.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"
+//
+//
+// 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 <ctype.h>        // isalnum, ...
+#include <stdlib.h>       // strtod, ...
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataList.h"
+#include "MDataValue.h"
+#include "MDataMember.h"
+#
+ClassImp(MDataChain);
+
+MDataChain::MDataChain(const char *rule, const char *name, const char *title)
+{
+    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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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]!='.')
+            return i;
+
+    return l;
+}
+
+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=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 (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 conditional
+                //
+                char 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 (!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;
+            }
+
+            *fLog << err << dbginf << "Syntax Error: First argument of condition missing." << endl;
+            if (member0)
+                delete member0;
+            return NULL;
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+            {
+                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;
+
+        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);
+
+            // *fLog << all << "Creating: '" << text.Data() << "'" << endl;
+
+            newmember = new MDataMember(text.Data());
+        }
+
+        if (!member0)
+        {
+            member0 = newmember;
+            continue;
+        }
+
+        if (!member0->InheritsFrom(MDataList::Class()))
+            continue;
+
+        ((MDataList*)member0)->AddToList(newmember);
+    }
+
+    return member0;
+}
+
+Double_t MDataChain::GetValue() const
+{
+    return fMember ? fMember->GetValue() : 0;
+}
+
+void MDataChain::Print(Option_t *opt) const
+{
+    fMember->Print();
+}
Index: /tags/Mars_V0-7/Mars/mdata/MDataChain.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataChain.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataChain.h	(revision 9643)
@@ -0,0 +1,39 @@
+#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
+
+    Int_t IsAlNum(TString txt);
+
+    MData *ParseString(TString txt, Int_t level);
+
+public:
+    MDataChain(const char *text, 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; }
+
+    void Print(Option_t *opt = "") const;
+
+    ClassDef(MDataChain, 0) // A chain/concatenation of MData objects
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mdata/MDataList.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataList.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataList.cc	(revision 9643)
@@ -0,0 +1,237 @@
+/* ======================================================================== *\
+!
+! *
+! * 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@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataList
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataList);
+
+// --------------------------------------------------------------------------
+//
+//   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
+//
+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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+}
+
+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 << all << "(";
+
+    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;
+}
+
Index: /tags/Mars_V0-7/Mars/mdata/MDataList.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataList.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataList.h	(revision 9643)
@@ -0,0 +1,52 @@
+#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(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; }
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    void Print(Option_t *opt = "") const;
+
+    ClassDef(MDataList, 0) // A concatenation of MData objects by one operator
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mdata/MDataMember.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataMember.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataMember.cc	(revision 9643)
@@ -0,0 +1,138 @@
+/* ======================================================================== *\
+!
+! *
+! * 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@uni-sw.gwdg.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 <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;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the value you requested
+//
+Double_t MDataMember::GetValue() const
+{
+    if (!fCall)
+        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 " << fName << " of ";
+        *fLog << fObject->GetName() << " neither int nor float... abort." << 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(fName);
+    TString mname(fName);
+
+    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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the name of the data member without an CR.
+//
+void MDataMember::Print(Option_t *opt) const
+{
+    *fLog << fName << flush;
+}
+
Index: /tags/Mars_V0-7/Mars/mdata/MDataMember.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataMember.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataMember.h	(revision 9643)
@@ -0,0 +1,37 @@
+#ifndef MARS_MDataMember
+#define MARS_MDataMember
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataMember                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MDataMember : public MData
+{
+private:
+    MParContainer *fObject;
+    TMethodCall   *fCall;
+
+public:
+    MDataMember(const char *member) : fObject(NULL), fCall(NULL)
+    {
+        fName = member;
+    }
+    MDataMember(MParContainer *obj, TMethodCall *call);
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return fCall ? kTRUE : kFALSE; }
+
+    void Print(Option_t *opt = "") const;
+
+    ClassDef(MDataMember, 0) // MData object corresponding to a single data member of a Mars container
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mdata/MDataValue.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataValue.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataValue.cc	(revision 9643)
@@ -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  04/2002 <mailto:tbretz@uni-sw.gwdg.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);
+
+// --------------------------------------------------------------------------
+//
+// Print the value
+//
+void MDataValue::Print(Option_t *opt) const
+{
+    *fLog << fValue << flush;
+}
+
Index: /tags/Mars_V0-7/Mars/mdata/MDataValue.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/MDataValue.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/MDataValue.h	(revision 9643)
@@ -0,0 +1,34 @@
+#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; }
+
+    void Print(Option_t *opt = "") const;
+
+    ClassDef(MDataValue, 0) // MData object corresponding to a single value
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mdata/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mdata/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdata/Makefile	(revision 9643)
@@ -0,0 +1,54 @@
+##################################################################
+#
+#   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
+
+# @code 
+
+CINT     = Data
+LIB      = mdata.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MData.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-7/Mars/mdatacheck/DataCheckIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/DataCheckIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/DataCheckIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mdatacheck/DataCheckLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/DataCheckLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/DataCheckLinkDef.h	(revision 9643)
@@ -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-7/Mars/mdatacheck/MDumpEvtHeader.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/MDumpEvtHeader.cc	(revision 9643)
@@ -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-7/Mars/mdatacheck/MDumpEvtHeader.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/MDumpEvtHeader.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/MDumpEvtHeader.h	(revision 9643)
@@ -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-7/Mars/mdatacheck/MGDisplayAdc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/MGDisplayAdc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/MGDisplayAdc.cc	(revision 9643)
@@ -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-7/Mars/mdatacheck/MGDisplayAdc.h
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/MGDisplayAdc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/MGDisplayAdc.h	(revision 9643)
@@ -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-7/Mars/mdatacheck/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mdatacheck/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mdatacheck/Makefile	(revision 9643)
@@ -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-7/Mars/merpp.cc
===================================================================
--- /tags/Mars_V0-7/Mars/merpp.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/merpp.cc	(revision 9643)
@@ -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 [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-7/Mars/meventdisp/EvtDispIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/EvtDispIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/EvtDispIncl.h	(revision 9643)
@@ -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-7/Mars/meventdisp/EvtDispLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/EvtDispLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/EvtDispLinkDef.h	(revision 9643)
@@ -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-7/Mars/meventdisp/MGCamDisplay.cc
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGCamDisplay.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGCamDisplay.cc	(revision 9643)
@@ -0,0 +1,274 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "MHillas.h"             // MHillas
+#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
+     GetMaiFrame 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;
+
+    plist->AddToList(geom);
+    plist->AddToList(pedest);
+
+    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();
+
+    //
+    // Show camera display for the actual geometry
+    //
+    fDisplay = new MCamDisplay(geom);
+    fDisplay->Draw();
+    fList->Add(fDisplay);
+
+    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");
+    }
+
+    fDisplay->DrawPhotNum(evt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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-7/Mars/meventdisp/MGCamDisplay.h
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGCamDisplay.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGCamDisplay.h	(revision 9643)
@@ -0,0 +1,39 @@
+#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;
+
+    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-7/Mars/meventdisp/MGEvtDisplay.cc
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGEvtDisplay.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGEvtDisplay.cc	(revision 9643)
@@ -0,0 +1,580 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "MReadMarsFile.h"
+
+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("MReadMarsFile");
+}
+
+// --------------------------------------------------------------------------
+//
+//  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);
+
+    //
+    // layout and add frame
+    //
+    TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsTop);
+    fList->Add(laytop1);
+
+    frame->AddFrame(top1, 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 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
+    // 
+    TGTab *tabdisp = new TGTab(frame, 300, 300);
+
+    TGCompositeFrame *tab2 = tabdisp->AddTab("Event Display");
+
+    TRootEmbeddedCanvas *canvas = new TRootEmbeddedCanvas("EventDisplay", tab2, 400, 400);
+
+    TGLayoutHints *laycanvas = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY|kLHintsExpandX|kLHintsExpandY);
+    tab2->AddFrame(canvas, laycanvas);
+
+    fCanvas = canvas->GetCanvas();
+
+    //
+    // Add second part to frame
+    //
+    TGLayoutHints *laydisp = new TGLayoutHints(kLHintsNormal|kLHintsExpandY|kLHintsExpandX, 10, 10, 10, 10);
+    frame->AddFrame(tabdisp, laydisp);
+
+    //
+    // Now add all gui elements to 'autodel'-list
+    //
+    fList->Add(tabdisp);
+    fList->Add(canvas);
+    fList->Add(laycanvas);
+    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);
+    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;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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();
+    }
+
+    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-7/Mars/meventdisp/MGEvtDisplay.h
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGEvtDisplay.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGEvtDisplay.h	(revision 9643)
@@ -0,0 +1,82 @@
+#ifndef MARS_MGEvtDisplay
+#define MARS_MGEvtDisplay
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+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;
+    TGTextEntry *fTxtEvtNr;
+
+    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;
+
+    void   ReadFirstEvent();
+    Bool_t IsInitOk() { return fInitOk; }
+
+    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-7/Mars/meventdisp/MGFadcDisp.cc
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGFadcDisp.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGFadcDisp.cc	(revision 9643)
@@ -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-7/Mars/meventdisp/MGFadcDisp.h
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/MGFadcDisp.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/MGFadcDisp.h	(revision 9643)
@@ -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-7/Mars/meventdisp/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/meventdisp/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/meventdisp/Makefile	(revision 9643)
@@ -0,0 +1,49 @@
+##################################################################
+#
+#   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../manalysis
+
+#------------------------------------------------------------------------------
+
+.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-7/Mars/mfilter/FilterIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/FilterIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/FilterIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mfilter/FilterLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/FilterLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/FilterLinkDef.h	(revision 9643)
@@ -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 MF+;
+#pragma link C++ class MFAlpha+;
+#pragma link C++ class MFTriggerLvl1+;
+#pragma link C++ class MFDataMember+;
+
+#endif
Index: /tags/Mars_V0-7/Mars/mfilter/MF.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MF.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MF.cc	(revision 9643)
@@ -0,0 +1,369 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <stdlib.h>       // strtod, ...
+#include <ctype.h>        // isalnum, ...
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MFilterList.h"
+#include "MFDataMember.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MF);
+
+// --------------------------------------------------------------------------
+//
+// 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  : "MF";
+    fTitle = title ? title : "Filter using a text";
+
+    *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();
+}
Index: /tags/Mars_V0-7/Mars/mfilter/MF.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MF.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MF.h	(revision 9643)
@@ -0,0 +1,39 @@
+#ifndef MARS_MF
+#define MARS_MF
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MF                                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class TMethodCall;
+
+class MF : public MFilter
+{
+private:
+    MFilter *fFilter; // Filter
+
+    Int_t IsAlNum(TString txt);
+
+    MFilter *ParseString(TString txt, Int_t level);
+
+public:
+    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-7/Mars/mfilter/MFAlpha.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFAlpha.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFAlpha.cc	(revision 9643)
@@ -0,0 +1,112 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "MParList.h"
+#include "MLog.h"
+#include "MLogManip.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(const 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;
+}
+
Index: /tags/Mars_V0-7/Mars/mfilter/MFAlpha.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFAlpha.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFAlpha.h	(revision 9643)
@@ -0,0 +1,45 @@
+#ifndef MARS_MFAlpha
+#define MARS_MFAlpha
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFAlpha                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class MHillasSrc;
+
+class MFAlpha : public MFilter
+{
+private:
+    const 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);
+
+public:
+    MFAlpha(const char       *cname="MHillas", const char type='>', const Float_t deg=15,
+            const char *name=NULL, const char *title=NULL);
+    MFAlpha(const 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, 0) // A Filter for cuts in fabs(alpha)
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mfilter/MFDataMember.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFDataMember.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFDataMember.cc	(revision 9643)
@@ -0,0 +1,145 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <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)
+{
+    fName  = name  ? name  : "MFDataMember";
+    fTitle = title ? title : "Filter using any data member of a class";
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+
+    fValue = val;
+
+    fDataMember = member;
+
+    AddToBranchList(fDataMember);
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFDataMember::PreProcess(MParList *plist)
+{
+    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;
+    }
+
+    fMethodCall = fObject->GetterMethod(mname);
+
+    return fMethodCall ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFDataMember::Process()
+{
+    Double_t v;
+    switch (fMethodCall->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        fMethodCall->Execute(fObject, l);
+        v = l;
+        break;
+
+    case TMethodCall::kDouble:
+        fMethodCall->Execute(fObject, v);
+        break;
+
+    default:
+        *fLog << err << "DataMember " << fDataMember << " of ";
+        *fLog << fObject->GetName() << " neither int nor float... abort." << endl;
+        return kFALSE;
+    }
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (v < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (v > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFDataMember::Print(Option_t *) const
+{
+    *fLog << fDataMember << (fFilterType==kELowerThan?"<":">");
+    *fLog << fValue << flush;
+}
Index: /tags/Mars_V0-7/Mars/mfilter/MFDataMember.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFDataMember.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFDataMember.h	(revision 9643)
@@ -0,0 +1,47 @@
+#ifndef MARS_MFDataMember
+#define MARS_MFDataMember
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFDataMember                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class TMethodCall;
+
+class MFDataMember : public MFilter
+{
+private:
+    TString        fDataMember; // Data member which should be used for the filter
+
+    MParContainer *fObject;     // Object from which the value is retrieved
+    TMethodCall   *fMethodCall; // Method call to the getter method of the requested value
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult;
+    Double_t fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+public:
+    MFDataMember(const char *member, const char type, const Double_t deg,
+                 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;
+
+    ClassDef(MFDataMember, 0) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.cc	(revision 9643)
@@ -0,0 +1,117 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "MParList.h"
+#include "MLog.h"
+#include "MLogManip.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(const 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;
+}
+
Index: /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.h
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/MFTriggerLvl1.h	(revision 9643)
@@ -0,0 +1,45 @@
+#ifndef MARS_MFTriggerLvl1
+#define MARS_MFTriggerLvl1
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFTriggerLvl1                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcTrig;
+class MParList;
+
+class MFTriggerLvl1 : public MFilter
+{
+private:
+    const 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);
+
+public:
+    MFTriggerLvl1(const char *cname="MMcTrig", const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+    MFTriggerLvl1(const 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, 0)		// A Filter for the Level 1 Trigger
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mfilter/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mfilter/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mfilter/Makefile	(revision 9643)
@@ -0,0 +1,53 @@
+##################################################################
+#
+#   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
+
+# @code 
+
+CINT     = Filter
+LIB      = mfilter.a
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MFTriggerLvl1.cc \
+	   MF.cc \
+	   MFDataMember.cc \
+	   MFAlpha.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-7/Mars/mgui/GuiIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/GuiIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/GuiIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mgui/GuiLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/GuiLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/GuiLinkDef.h	(revision 9643)
@@ -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 MHexagon+;
+
+#pragma link C++ class MGeomPix+;
+#pragma link C++ class MGeomCam+;
+#pragma link C++ class MGeomCamCT1+;
+#pragma link C++ class MGeomCamMagic+;
+
+#pragma link C++ class MCamDisplay+;
+
+#endif
Index: /tags/Mars_V0-7/Mars/mgui/MCamDisplay.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MCamDisplay.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MCamDisplay.cc	(revision 9643)
@@ -0,0 +1,371 @@
+#include "MCamDisplay.h"
+
+#include <math.h>
+#include <fstream.h>
+
+#include <TClonesArray.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+#include <TBox.h>
+#include <TText.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#define kItemsLegend 25 // see SetPalette(1,0)
+
+ClassImp(MCamDisplay);
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MCamDisplay::MCamDisplay(MGeomCam *geom)
+    : fAutoScale(kTRUE), fMinPhe(-2), fMaxPhe(50), 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)
+    gStyle->SetPalette(1, 0);
+#else
+    gStyle->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;
+
+        const Float_t lvl = 50. / kItemsLegend * i;
+
+        newbox->SetFillColor(GetColor(lvl));
+
+        newtxt->SetTextSize(0.025);
+        newtxt->SetTextAlign(12);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MCamDisplay::~MCamDisplay()
+{
+    fPixels->Delete();
+    fLegend->Delete();
+    fLegText->Delete();
+
+    delete fPixels;
+    delete fLegend;
+    delete fLegText;
+
+    // delete fGeomCam;
+
+    if (fIsAllocated)
+        delete fDrawingPad;
+}
+
+inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i)
+{
+    //
+    // Fixme: Divide pnum by the (real) area of the pixel
+    //
+    const Float_t ratio = (*fGeomCam)[0].GetA()/(*fGeomCam)[i].GetA();
+    const Float_t pnum  = ratio*pix.GetNumPhotons();
+
+    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum));
+}
+
+// ------------------------------------------------------------------------
+//
+// 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);
+}
+
+// ------------------------------------------------------------------------
+//
+// 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;
+    }
+
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Setup the correct environment
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
+    gStyle->SetPalette(1, 0);
+#else
+    gStyle->SetPalette(51, 0);
+#endif
+
+    gPad->SetFillColor(22);
+
+    //
+    // Draw all pixels of the camera
+    //  (means apend all pixelobjects to the current pad)
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+
+    //
+    // 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->Draw();
+
+        TText *txt = GetText(i);
+        txt->SetX(fRange+1.5*w);
+        txt->SetY(H*((i+0.5)*h - 1.));
+        txt->Draw();
+    }
+
+    //fDrawingPad->SetEditable(kFALSE);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the number of photo electron into the
+// camera.
+//
+void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event)
+{
+    if (!event)
+        return;
+
+    if (!fDrawingPad)
+        Draw();
+
+    fDrawingPad->cd();
+
+    //
+    // Reset pixel colors to default value
+    //
+    Reset();
+
+    //
+    //  if the autoscale is true, set the values for the range for
+    //  each event
+    //
+    if (fAutoScale)
+    {
+        fMinPhe = event->GetNumPhotonsMin(fGeomCam);
+        fMaxPhe = event->GetNumPhotonsMax(fGeomCam);
+
+        if (fMaxPhe < 20.)
+            fMaxPhe = 20.;
+
+        UpdateLegend();
+    }
+
+    //
+    //   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);
+    }
+
+    //
+    // Update display physically
+    //
+    gPad->Modified();
+    gPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// 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)
+{
+    //
+    //   first treat the over- and under-flows
+    //
+    const Int_t maxcolidx = 49;
+
+    if (val >= fMaxPhe)
+        return gStyle->GetColorPalette(maxcolidx);
+
+    if (val <= fMinPhe)
+        return gStyle->GetColorPalette(0);
+
+    //
+    // calculate the color index
+    //
+    const Float_t ratio  = (val-fMinPhe) / (fMaxPhe-fMinPhe);
+    const Int_t   colidx = (Int_t)(ratio*maxcolidx + .5);
+
+    return gStyle->GetColorPalette(colidx);
+}
+
+// ------------------------------------------------------------------------
+//
+//    change the text on the legend according to the range of the
+//    Display
+//
+void MCamDisplay::UpdateLegend()
+{
+    char text[10];
+
+    for (Int_t i=0; i<kItemsLegend; i++)
+    {
+        const Float_t val = fMinPhe + (Float_t)i/kItemsLegend * (fMaxPhe-fMinPhe) ;
+
+        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;
+}
Index: /tags/Mars_V0-7/Mars/mgui/MCamDisplay.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MCamDisplay.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MCamDisplay.h	(revision 9643)
@@ -0,0 +1,67 @@
+#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 TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+class MCerPhotEvt;
+class MCerPhotPix;
+
+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
+
+    Float_t        fMinPhe;      // The minimal number of Phe
+    Float_t        fMaxPhe;      // The maximum number of Phe
+
+    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);
+    Int_t GetColor(Float_t wert);
+
+    void UpdateLegend();
+    void Paint(Option_t *option="");
+
+public:
+    MCamDisplay(MGeomCam *geom);
+    ~MCamDisplay();
+
+    void SetAutoScale(Bool_t input=kTRUE) { fAutoScale = input; }
+    void DrawPhotNum(const MCerPhotEvt *event);
+
+    void Reset();
+    void Draw(Option_t *option="");
+    void SavePrimitive(ofstream &out, Option_t *);
+
+    ClassDef(MCamDisplay, 0) // Displays the magic camera
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mgui/MGeomCam.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCam.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCam.cc	(revision 9643)
@@ -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>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// 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"
+#include "MHexagon.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), fMm2Deg(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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  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-7/Mars/mgui/MGeomCam.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCam.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCam.h	(revision 9643)
@@ -0,0 +1,48 @@
+#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  fMm2Deg;     // conversion factor to convert mm in the camera plain into degrees
+
+    TObjArray *fPixels;   // Array of singel pixels storing the geometry
+
+protected:
+    void CalcMaxRadius();
+
+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 fMm2Deg; }
+
+    UInt_t  GetNumPixels() const { return fNumPixels; }
+    Float_t GetMaxRadius() const { return fMaxRadius; }
+
+    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-7/Mars/mgui/MGeomCamCT1.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCamCT1.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCamCT1.cc	(revision 9643)
@@ -0,0 +1,266 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// 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},  // 10
+      {  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},  // 20
+      {  7,   8,  19,  21,  38,  39},
+      {  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},  // 30
+      { 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},  // 40
+      { 21,  22,  39,  41,  64,  65},
+      { 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},  // 50
+      { 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},  // 60
+      { 19,  36,  37,  59,  89,  90},
+      { 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},  // 70
+      { 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},  // 80
+      { 52,  53,  79,  81, 113, 114},
+      { 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},  // 90
+      { 37,  60,  61,  89, 125, 126},
+      { 61,  92, 126, 127,  -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},  // 100
+      { 68,  69,  99, 101,  -1,  -1},
+      { 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},  // 110
+      { 76,  77, 109, 111,  -1,  -1},
+      { 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},  // 120
+      { 85,  86, 119, 121,  -1,  -1},
+      { 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}   // 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]);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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((ring-0.5*i)*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);
+    }
+}
+
Index: /tags/Mars_V0-7/Mars/mgui/MGeomCamCT1.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCamCT1.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCamCT1.h	(revision 9643)
@@ -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-7/Mars/mgui/MGeomCamMagic.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCamMagic.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCamMagic.cc	(revision 9643)
@@ -0,0 +1,898 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// 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,  -1},
+        { 335, 336, 400, 435, 436,  -1},
+        { 337, 338, 399, 401, 437,  -1}, // 400
+        { 339, 340, 400, 402, 438,  -1},
+        { 341, 342, 401, 403, 438, 439},
+        { 342, 343, 402, 404, 440, 441},
+        { 344, 345, 403, 441, 442,  -1},
+        { 346, 347, 404, 442, 443,  -1},
+        { 348, 349, 405, 443, 444,  -1},
+        { 350, 351, 406, 444, 445,  -1},
+        { 352, 353, 407, 409, 445, 446},
+        { 353, 354, 408, 410, 447, 448},
+        { 355, 356, 409, 411, 448,  -1},
+        { 357, 358, 410, 412, 449,  -1},
+        { 359, 360, 411, 450, 451,  -1},
+        { 361, 362, 412, 414, 452,  -1},
+        { 363, 364, 413, 415, 452, 453},
+        { 364, 365, 414, 416, 454, 455},
+        { 366, 367, 415, 417, 455,  -1},
+        { 368, 369, 418, 456, 457,  -1},
+        { 370, 371, 417, 419, 458,  -1},
+        { 372, 373, 418, 420, 459,  -1},
+        { 374, 375, 419, 421, 459, 460}, // 420
+        { 375, 376, 420, 422, 461, 462},
+        { 377, 378, 421, 462, 463,  -1},
+        { 379, 380, 422, 463, 464,  -1},
+        { 381, 382, 423, 464, 465,  -1},
+        { 383, 384, 424, 465, 466,  -1},
+        { 385, 386, 425, 427, 466, 467},
+        { 386, 387, 426, 428, 468, 469},
+        { 388, 389, 427, 429, 469,  -1},
+        { 390, 391, 428, 430, 470,  -1},
+        { 392, 393, 429, 471, 472,  -1},
+        { 394, 395, 430, 432, 473,  -1},
+        { 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]);
+}
Index: /tags/Mars_V0-7/Mars/mgui/MGeomCamMagic.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomCamMagic.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomCamMagic.h	(revision 9643)
@@ -0,0 +1,22 @@
+#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-7/Mars/mgui/MGeomPix.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomPix.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomPix.cc	(revision 9643)
@@ -0,0 +1,99 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MGeomPix
+//
+// This container stores the geometry (position) information of
+// a single pixel together with the information about next neighbors.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomPix.h"
+
+#include <math.h>
+
+#include "MLog.h"
+#include "MLogManip.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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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-7/Mars/mgui/MGeomPix.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MGeomPix.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MGeomPix.h	(revision 9643)
@@ -0,0 +1,46 @@
+#ifndef MARS_MGeomPix
+#define MARS_MGeomPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomPix : public MParContainer
+{ 
+private:
+    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 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]; }
+
+    ClassDef(MGeomPix, 1) // Geometry class describing the geometry of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/mgui/MHexagon.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MHexagon.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MHexagon.cc	(revision 9643)
@@ -0,0 +1,279 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//
+//  The class MHexagon is needed for the Event Display of
+//  MAGIC.
+//
+#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 disthex = TMath::Sqrt((Double_t)((pxhex-px)*(pxhex-px) + (pyhex-py)*(pyhex-py)));
+
+    const Double_t cosa = TMath::Abs(px-pxhex) / disthex;
+    const Double_t sina = TMath::Abs(py-pyhex) / disthex;
+
+    //
+    // comput the distance to pixel border
+    //
+    const Double_t dx = fD * cosa / 2;
+    const Double_t dy = fD * sina / 2;
+
+    const Double_t xborder = fX + dx;
+    const Double_t yborder = fY + dy;
+
+    const Int_t pxborder = gPad->XtoAbsPixel(xborder);
+    const Int_t pyborder = gPad->YtoAbsPixel(yborder);
+
+    const Double_t distborder = TMath::Sqrt((Double_t)((pxborder-pxhex)*(pxborder-pxhex)+(pyborder-pyhex)*(pyborder-pyhex)));
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle inside
+    //
+    return distborder < disthex ? 999999 : 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(MHexagon::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-7/Mars/mgui/MHexagon.h
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/MHexagon.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/MHexagon.h	(revision 9643)
@@ -0,0 +1,63 @@
+#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 *);
+
+    ClassDef(MHexagon, 0)    // A hexagon for MAGIC
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/mgui/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mgui/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mgui/Makefile	(revision 9643)
@@ -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  = Gui
+
+#
+# Library name to creatre
+#
+LIB   = mgui.a
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../meventdisp
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MHexagon.cc \
+           MGeomPix.cc \
+           MGeomCam.cc \
+           MCamDisplay.cc \
+           MGeomCamCT1.cc \
+           MGeomCamMagic.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-7/Mars/mhist/HistIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/HistIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/HistIncl.h	(revision 9643)
@@ -0,0 +1,5 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mhist/HistLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/HistLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/HistLinkDef.h	(revision 9643)
@@ -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 MFillH+;
+
+#pragma link C++ class MH+;
+#pragma link C++ class MH3+;
+#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 MHEffOnTimeTime+;
+#pragma link C++ class MHEffOnTimeTheta+;
+#pragma link C++ class MHTimeDiffTime+;
+#pragma link C++ class MHTimeDiffTheta+;
+
+#pragma link C++ class MHThetabarTime+;
+#pragma link C++ class MHThetabarTheta+;
+
+#pragma link C++ class MBinning+;
+
+#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-7/Mars/mhist/MBinning.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MBinning.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MBinning.cc	(revision 9643)
@@ -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  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MBinning                                                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MBinning.h"
+
+ClassImp(MBinning);
+
+// --------------------------------------------------------------------------
+//
+// 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  : "MBinning";
+    fTitle = title ? title : "Container describing the binning of an axis";
+}
+
Index: /tags/Mars_V0-7/Mars/mhist/MBinning.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MBinning.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MBinning.h	(revision 9643)
@@ -0,0 +1,60 @@
+#ifndef MARS_MBinning
+#define MARS_MBinning
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include "TArrayD.h"
+#endif
+
+class MBinning : public MParContainer
+{
+private:
+    TArrayD fEdges;
+
+public:
+    MBinning(const char *name=NULL, const char *title=NULL);
+
+    void SetEdges(const TArrayD &arr)
+    {
+        fEdges = arr;/*
+        const Int_t nbins = arr.GetSize();
+        fEdges.Set(nbins);
+        for (int i=0; i<nbins; i++)
+            fEdges[i] = (*(TArrayD*)(&arr))[i];*/
+    }
+
+    void 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;
+    }
+
+    void 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;
+    }
+
+    // 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 fEdges.GetArray(); }
+
+    ClassDef(MBinning, 1) //Container to store the binning of a histogram
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/mhist/MFillH.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MFillH.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MFillH.cc	(revision 9643)
@@ -0,0 +1,317 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-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 "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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, const MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainer = par;
+    fParContainerName = par->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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, const MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
+    fParContainer = par;
+    fParContainerName = par->GetName();
+}
+
+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);
+}
+
+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)
+{
+    //
+    // 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)
+            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'.
+        //
+        if (!obj->InheritsFrom(MH::Class()))
+        {
+            *fLog << err << dbginf << obj->GetName() << " doesn't inherit ";
+            *fLog << "from MH - cannot be used for MFillH... 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()
+{
+    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()
+{
+    fH->SetReadyToSave();
+    return kTRUE;
+}
Index: /tags/Mars_V0-7/Mars/mhist/MFillH.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MFillH.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MFillH.h	(revision 9643)
@@ -0,0 +1,39 @@
+#ifndef MARS_MFillH
+#define MARS_MFillH
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MH;
+class MParList;
+
+class MFillH : public MTask
+{
+private:
+    const MParContainer *fParContainer;
+    TString fParContainerName;
+
+    MH* fH;
+    TString fHName;
+
+    TString ExtractName(const char *name) const;
+    TString ExtractClass(const char *name) const;
+
+    void Init(const char *name, const char *title);
+
+public:
+    MFillH(const char *hist, const char *par=NULL,     const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, const 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,         const MParContainer *par, const char *name=NULL, const char *title=NULL);
+
+    Bool_t PreProcess(MParList *pList);
+    Bool_t Process();
+    Bool_t PostProcess();
+
+    ClassDef(MFillH, 0) // Task to fill a histogram with data from a parameter container
+};
+    
+#endif
+
Index: /tags/Mars_V0-7/Mars/mhist/MH.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MH.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MH.cc	(revision 9643)
@@ -0,0 +1,300 @@
+/* ======================================================================== *\
+!
+! *
+! * 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-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.    //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MH.h"
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TCanvas.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";
+}
+
+// --------------------------------------------------------------------------
+//
+// 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);
+}
+
+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
+}
+
+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
+}
+
+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
+}
+
+void MH::SetBinning(TH1 *h, const TArrayD *binsx)
+{
+    MBinning bx;
+    bx.SetEdges(*binsx);
+    SetBinning(h, &bx);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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(TH2::Class()) && x->InheritsFrom(TH2::Class()))
+    {
+        SetBinning((TH2*)h, x->GetXaxis(), x->GetYaxis());
+        return;
+    }
+    if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class()))
+    {
+        SetBinning(h, x->GetXaxis());
+        return;
+    }
+}
Index: /tags/Mars_V0-7/Mars/mhist/MH.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MH.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MH.h	(revision 9643)
@@ -0,0 +1,49 @@
+#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) = 0;
+
+    static TCanvas *MakeDefCanvas(TString name="", const char *title="",
+                                  const UInt_t w=700, const UInt_t h=500);
+    static TCanvas *MakeDefCanvas(const TObject *obj,
+                                  const UInt_t w=700, const UInt_t h=500);
+
+    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);
+
+    ClassDef(MH, 1) //A histogram base class for Mars histograms
+};
+
+#endif
+
Index: /tags/Mars_V0-7/Mars/mhist/MH3.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MH3.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MH3.cc	(revision 9643)
@@ -0,0 +1,366 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <TH2.h>
+#include <TH3.h>
+#include <TProfile.h>
+#include <TProfile2D.h>
+#include <TPad.h>
+#include <TCanvas.h>
+#include <TDataMember.h>
+#include <TMethodCall.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MDataChain.h"
+
+ClassImp(MH3);
+
+// --------------------------------------------------------------------------
+//
+// 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  = "MH3";
+    fTitle = "Container for a 1D Mars Histogram";
+
+    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  = "MH3";
+    fTitle = "Container for a 2D Mars Histogram";
+
+    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  = "MH3";
+    fTitle = "Container for a 3D Mars Histogram";
+
+    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];
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+        }
+        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;
+        }
+        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;
+        }
+        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;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *MH3::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 MH3::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();
+}
Index: /tags/Mars_V0-7/Mars/mhist/MH3.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MH3.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MH3.h	(revision 9643)
@@ -0,0 +1,53 @@
+#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];
+
+public:
+    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);
+
+    TH1 &GetHist() { return *fHist; }
+    const TH1 &GetHist() const { return *fHist; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 9643)
@@ -0,0 +1,356 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  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 << "MEnergyEst not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+   MBinning* binsalpha  = (MBinning*)plist->FindObject("BinningAlpha");
+   MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+   if (!binsenergy || !binsalpha || !binstheta)
+   {
+       *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalpha, binsenergy, binstheta);
+
+   fHist.Sumw2(); 
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the histogram as the difference of two histograms :
+//          fHist(gamma) = h1(source) - h2(antisource)
+// 
+void MHAlphaEnergyTheta::Subtract(const TH3D *h1, const TH3D *h2)
+{
+    // MH::SetBinning(&fHist, (TH1*)h1);
+
+    //    fHist.Sumw2();
+    fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // Root: FIXME
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist(gamma) in the alpha range (lo, up)
+// 
+TH2D *MHAlphaEnergyTheta::GetAlphaProjection(Axis_t lo, Axis_t up)
+{
+    if (up < lo)
+    {
+        *fLog << err << fName << ": 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 << ": 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("ezypro");
+
+    h2D.SetTitle("2D-plot  of Theta vs. E-est");
+    h2D.SetXTitle("E-est [GeV]            ");
+    h2D.SetYTitle("\\Theta [\\circ]");
+
+    return &h2D;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the integrated histogram
+// 
+TH2D *MHAlphaEnergyTheta::DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt)
+{
+    TH2D *h2D = GetAlphaProjection(lo, up);
+
+    if (!h2D)
+        return NULL;
+
+    char txt[100];
+    sprintf(txt, "No.of Gammas vs. E-est and Theta (%.1f < alpha < %.1f deg)", lo, up);
+
+    //    TCanvas *c = MakeDefCanvas("AlphaEnergyTheta", "2D histogram of gamma signal in energy and theta");
+    TCanvas &c = *MakeDefCanvas("AlphaEnergyTheta", txt);
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = h2D->ProjectionX("Eest", -1, 9999, "E");
+    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(2);
+    h = h2D->ProjectionY("theta", -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);
+
+    h2D->DrawCopy(opt);
+    gPad->SetLogx();
+
+    c.Modified();
+    c.Update();
+
+    return h2D;
+}
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTheta.h	(revision 9643)
@@ -0,0 +1,61 @@
+#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; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    void Subtract(const TH3D *h1, const TH3D *h2);
+    void Subtract(const MHAlphaEnergyTheta *h1, const MHAlphaEnergyTheta *h2)
+    {
+        Subtract(h1->GetHist(), h2->GetHist());
+    }
+
+    TH2D *DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt="");
+    TH2D *GetAlphaProjection(Axis_t lo, Axis_t up);
+
+    ClassDef(MHAlphaEnergyTheta, 1) //3D-histogram in alpha, Energy and theta
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.cc	(revision 9643)
@@ -0,0 +1,347 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  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 << "MEnergyEst not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fTime = (MTime*)plist->FindObject("MTime");
+   if (!fTime)
+   {
+       *fLog << err << dbginf << "MTime not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+   MBinning* binsalpha  = (MBinning*)plist->FindObject("BinningAlpha");
+   MBinning* binstime   = (MBinning*)plist->FindObject("BinningTime");
+   if (!binsenergy || !binsalpha || !binstime)
+   {
+       *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalpha, binsenergy, binstime);
+
+   fHist.Sumw2();
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTime::Fill(const MParContainer *par)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the histogram as the difference of two histograms :
+//          fHist(gamma) = h1(source) - h2(antisource)
+// 
+void MHAlphaEnergyTime::Subtract(const TH3D *h1, const TH3D *h2)
+{
+  //    MH::SetBinning(&fHist, (TH1*)h1);
+
+  //    fHist.Sumw2();
+    fHist.Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME!
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist(gamma) in the alpha range (lo, up)
+// 
+TH2D *MHAlphaEnergyTime::GetAlphaProjection(Axis_t lo, Axis_t up)
+{
+    if (up < lo)
+    {
+        *fLog << err << fName << ": 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 << ": 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");
+
+    h2D.SetTitle("2D-plot  of time vs. E-est");
+    h2D.SetXTitle("E-est [GeV]            ");
+    h2D.SetYTitle("time [s]");
+
+    return &h2D;
+}
+
+//---------------------------------------------------------
+//
+// Draw the projected histogram
+//
+TH2D *MHAlphaEnergyTime::DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt)
+{
+    TH2D *h2D = GetAlphaProjection(lo, up);
+
+    if (!h2D)
+        return NULL;
+
+    char txt[100];
+    sprintf(txt, "No.of Gammas vs. E-est and Time (%.1f < alpha < %.1f deg)", lo, up);
+
+    //    TCanvas *c = MakeDefCanvas("AlphaEnergyTime", "2D histogram of gamma signal in energy and time");
+    TCanvas &c = *MakeDefCanvas("AlphaEnergyTime", txt);
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = h2D->ProjectionX("Eest", -1, 9999, "E");
+    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(2);
+    h = h2D->ProjectionY("time", -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);
+
+    h2D->DrawCopy(opt);
+    gPad->SetLogx();
+
+    c.Modified();
+    c.Update();
+
+    return h2D;
+}
+
Index: /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHAlphaEnergyTime.h	(revision 9643)
@@ -0,0 +1,62 @@
+#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; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    void Subtract(const TH3D *h1, const TH3D *h2);
+    void Subtract(const MHAlphaEnergyTime *h1, const MHAlphaEnergyTime *h2)
+    {
+        Subtract(h1->GetHist(), h2->GetHist());
+    }
+
+    TH2D *DrawAlphaProjection(Axis_t lo, Axis_t up, Option_t *opt="");
+    TH2D *GetAlphaProjection(Axis_t lo, Axis_t up);
+
+    ClassDef(MHAlphaEnergyTime, 1) //3D-histogram in alpha, Energy and time
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTheta.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTheta.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTheta.cc	(revision 9643)
@@ -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    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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  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("chi2/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-7/Mars/mhist/MHEffOnTimeTheta.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTheta.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTheta.h	(revision 9643)
@@ -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-7/Mars/mhist/MHEffOnTimeTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTime.cc	(revision 9643)
@@ -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@uni-sw.gwdg.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("chi2/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-7/Mars/mhist/MHEffOnTimeTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEffOnTimeTime.h	(revision 9643)
@@ -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-7/Mars/mhist/MHEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEnergyTheta.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEnergyTheta.cc	(revision 9643)
@@ -0,0 +1,157 @@
+/* ======================================================================== *\
+!
+! *
+! * 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>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#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-7/Mars/mhist/MHEnergyTheta.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEnergyTheta.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEnergyTheta.h	(revision 9643)
@@ -0,0 +1,43 @@
+#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; }
+
+    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-7/Mars/mhist/MHEnergyTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEnergyTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEnergyTime.cc	(revision 9643)
@@ -0,0 +1,165 @@
+/* ======================================================================== *\
+!
+! *
+! * 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>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#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-7/Mars/mhist/MHEnergyTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHEnergyTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHEnergyTime.h	(revision 9643)
@@ -0,0 +1,44 @@
+#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; }
+
+    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-7/Mars/mhist/MHFadcCam.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHFadcCam.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHFadcCam.cc	(revision 9643)
@@ -0,0 +1,113 @@
+/* ======================================================================== *\
+!
+! *
+! * 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;
+}
Index: /tags/Mars_V0-7/Mars/mhist/MHFadcCam.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHFadcCam.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHFadcCam.h	(revision 9643)
@@ -0,0 +1,54 @@
+#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 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)); }
+
+    TH1F *GetHistHi(UInt_t i)  { return (*this)[i]->GetHistHi(); }
+    TH1F *GetHistLo(UInt_t i)  { return (*this)[i]->GetHistLo(); }
+
+    Bool_t Fill(const MParContainer *par);
+
+    //
+    // 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-7/Mars/mhist/MHFadcPix.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHFadcPix.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHFadcPix.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHFadcPix.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHFadcPix.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHFadcPix.h	(revision 9643)
@@ -0,0 +1,39 @@
+#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; }
+
+    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-7/Mars/mhist/MHHillas.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillas.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillas.cc	(revision 9643)
@@ -0,0 +1,262 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHillas
+//
+// This class contains histograms for every Hillas parameter
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHHillas.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MHillas.h"
+#include "MParList.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 : "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
+    //
+    fWidth  = new TH1F("Width",  "Width of Ellipse",  100, 0, 300);
+    fLength = new TH1F("Length", "Length of Ellipse", 100, 0, 300);
+
+    fLength->SetDirectory(NULL);
+    fWidth->SetDirectory(NULL);
+
+    fLength->SetXTitle("Length [mm]");
+    fWidth->SetXTitle("Width [mm]");
+
+    fLength->SetYTitle("Counts");
+    fWidth->SetYTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the four histograms
+//
+MHHillas::~MHHillas()
+{
+    delete fWidth;
+    delete fLength;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MBinning* binsw = (MBinning*)plist->FindObject("BinningWidth");
+    const MBinning* binsl = (MBinning*)plist->FindObject("BinningLength");
+    if (!binsw || !binsl)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(fWidth,  binsw);
+    SetBinning(fLength, binsl);
+
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        return kTRUE;
+    }
+
+    fLength->SetXTitle("Length [\\circ]");
+    fWidth->SetXTitle("Width [\\circ]");
+
+    fMm2Deg     = geom->GetConvMm2Deg();
+    fUseMmScale = kFALSE;
+
+    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 MHHillas::Fill(const MParContainer *par)
+{
+    const MHillas &h = *(MHillas*)par;
+
+    if (fUseMmScale)
+    {
+        fWidth ->Fill(h.GetWidth());
+        fLength->Fill(h.GetLength());
+    }
+    else
+    {
+        fWidth ->Fill(fMm2Deg*h.GetWidth());
+        fLength->Fill(fMm2Deg*h.GetLength());
+    }
+
+    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;
+    }
+
+    if (fUseMmScale)
+    {
+        fLength->SetXTitle("Length [mm]");
+        fWidth->SetXTitle("Width [mm]");
+
+        fLength->Scale(1./fMm2Deg);
+        fWidth->Scale(1./fMm2Deg);
+    }
+    else
+    {
+        fLength->SetXTitle("Length [\\circ]");
+        fWidth->SetXTitle("Width [\\circ]");
+
+        fLength->Scale(fMm2Deg);
+        fWidth->Scale(fMm2Deg);
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *MHHillas::DrawClone(Option_t *opt) const
+{
+    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
+                               350, 500);
+    c->Divide(1, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    c->cd(1);
+    fLength->DrawCopy();
+
+    c->cd(2);
+    fWidth->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 MHHillas::Draw(Option_t *)
+{
+    if (!gPad)
+        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
+
+    gPad->Divide(1, 2);
+
+    gPad->cd(1);
+    fLength->Draw();
+
+    gPad->cd(2);
+    fWidth->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+}
Index: /tags/Mars_V0-7/Mars/mhist/MHHillas.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillas.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillas.h	(revision 9643)
@@ -0,0 +1,40 @@
+#ifndef MARS_MHHillas
+#define MARS_MHHillas
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+
+class MHHillas : public MH
+{
+private:
+    TH1F *fWidth;
+    TH1F *fLength;
+
+protected:
+    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);
+
+    TH1F *GetHistWidth()  { return fWidth; }
+    TH1F *GetHistLength() { return fLength; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHHillas, 1) // Container which holds histograms for length and width
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mhist/MHHillasExt.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillasExt.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillasExt.cc	(revision 9643)
@@ -0,0 +1,285 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MParList.h"
+#include "MHillasExt.h"
+
+ClassImp(MHHillasExt);
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHHillasExt::MHHillasExt(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillasExt";
+    fTitle = title ? title : "Container for Hillas (ext) 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
+    //
+    fHConc.SetDirectory(NULL);
+    fHConc1.SetDirectory(NULL);
+    fHAsym.SetDirectory(NULL);
+    fHM3Long.SetDirectory(NULL);
+    fHM3Trans.SetDirectory(NULL);
+
+    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");
+}
+
+// --------------------------------------------------------------------------
+//
+// 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)
+{
+    const MBinning* binsc  = (MBinning*)plist->FindObject("BinningConc");
+    const MBinning* binsc1 = (MBinning*)plist->FindObject("BinningConc1");
+    const MBinning* binsa  = (MBinning*)plist->FindObject("BinningAsym");
+    const MBinning* binsl  = (MBinning*)plist->FindObject("BinningM3Long");
+    const MBinning* binst  = (MBinning*)plist->FindObject("BinningM3Trans");
+    if (!binsc || !binsc1 || !binsa || !binsl || !binst)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHConc,    binsc);
+    SetBinning(&fHConc1,   binsc1);
+    SetBinning(&fHAsym,    binsa);
+    SetBinning(&fHM3Long,  binsl);
+    SetBinning(&fHM3Trans, binst);
+
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        return kTRUE;
+    }
+
+    fHAsym.SetXTitle("Asym [\\circ]");
+    fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
+    fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
+
+    return MHHillas::SetupFill(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MHillasExt &h = *(MHillasExt*)par;
+
+    fHConc.Fill(h.GetConc());
+    fHConc1.Fill(h.GetConc1());
+
+    if (fUseMmScale)
+    {
+        fHAsym.Fill(h.GetAsym());
+        fHM3Long.Fill(h.GetM3Long());
+        fHM3Trans.Fill(h.GetM3Trans());
+    }
+    else
+    {
+        fHAsym.Fill(fMm2Deg*h.GetAsym());
+        fHM3Long.Fill(fMm2Deg*h.GetM3Long());
+        fHM3Trans.Fill(fMm2Deg*h.GetM3Trans());
+    }
+
+    return MHHillas::Fill(par);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+    }
+
+    if (fUseMmScale)
+    {
+        fHAsym.SetXTitle("Asym [mm]");
+        fHM3Long.SetXTitle("3^{rd} M_{l}[mm]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
+
+        fHAsym.Scale(1./fMm2Deg);
+        fHM3Long.Scale(1./fMm2Deg);
+        fHM3Trans.Scale(1./fMm2Deg);
+    }
+    else
+    {
+        fHAsym.SetXTitle("Asym [\\circ]");
+        fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
+
+        fHAsym.Scale(fMm2Deg);
+        fHM3Long.Scale(fMm2Deg);
+        fHM3Trans.Scale(fMm2Deg);
+    }
+
+    MHHillas::SetMmScale(mmscale);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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("Hillas", "Histograms of Hillas Parameters",
+                               3*350, 2*250);
+    c.Divide(3, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    c.cd(1);
+    ((TH1F&)fHConc).DrawCopy();
+
+    c.cd(4);
+    ((TH1F&)fHConc1).DrawCopy();
+
+    c.cd(2);
+    ((TH1F&)fHAsym).DrawCopy();
+
+    c.cd(3);
+    ((TH1F&)fHM3Long).DrawCopy();
+
+    c.cd(6);
+    ((TH1F&)fHM3Trans).DrawCopy();
+
+    c.Modified();
+    c.Update();
+
+    MHHillas::DrawClone();
+
+    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("Hillas", "Histograms of Hillas Parameters", 350, 3*250);
+
+    gPad->Divide(3, 2);
+
+    gPad->cd(1);
+    fHConc.DrawCopy();
+
+    gPad->cd(4);
+    fHConc1.DrawCopy();
+
+    gPad->cd(2);
+    fHAsym.DrawCopy();
+
+    gPad->cd(3);
+    fHM3Long.DrawCopy();
+
+    gPad->cd(6);
+    fHM3Trans.DrawCopy();
+
+    gPad->Modified();
+    gPad->Update();
+
+    MHHillas::DrawClone();
+}
Index: /tags/Mars_V0-7/Mars/mhist/MHHillasExt.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillasExt.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillasExt.h	(revision 9643)
@@ -0,0 +1,35 @@
+#ifndef MARS_MHHillasExt
+#define MARS_MHHillasExt
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef MARS_MHHillas
+#include "MHHillas.h"
+#endif
+
+class MHHillasExt : public MHHillas
+{
+private:
+    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
+
+public:
+    MHHillasExt(const char *name=NULL, const char *title=NULL);
+    ~MHHillasExt();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHHillasExt, 1) // Container which holds histograms for length and width
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.cc	(revision 9643)
@@ -0,0 +1,202 @@
+/* ======================================================================== *\
+!
+! *
+! * 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",   90, 0,  90);
+    fDist  = new TH1F("Dist",  "Dist of Ellipse",   100, 0, 600);
+
+    fAlpha->SetDirectory(NULL);
+    fDist->SetDirectory(NULL);
+
+    fAlpha->SetXTitle("\\alpha [mm]");
+    fDist->SetXTitle("Dist [mm]");
+
+    fAlpha->SetYTitle("Counts");
+    fDist->SetYTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the four histograms
+//
+MHHillasSrc::~MHHillasSrc()
+{
+    delete fAlpha;
+    delete fDist;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MBinning* binsa = (MBinning*)plist->FindObject("BinningAlpha");
+    const MBinning* binsd = (MBinning*)plist->FindObject("BinningDist");
+    if (!binsa || !binsd)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(fAlpha, binsa);
+    SetBinning(fDist,  binsd);
+
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        return kTRUE;
+    }
+
+    fDist->SetXTitle("Dist [\\circ]");
+
+    fMm2Deg = geom->GetConvMm2Deg();
+    fUseMmScale = kFALSE;
+
+    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(fabs(h.GetAlpha()));
+    fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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("Hillas", "Histograms of Source dependant Parameters",
+                               350, 500);
+    c->Divide(1, 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->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("Hillas", "Histograms of Src dependant Parameters", 350, 500);
+
+    // FIXME: Display Source position
+
+    gPad->Divide(1, 2);
+
+    gPad->cd(1);
+    fAlpha->Draw();
+
+    gPad->cd(2);
+    fDist->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+}
Index: /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHHillasSrc.h	(revision 9643)
@@ -0,0 +1,38 @@
+#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;
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+public:
+    MHHillasSrc(const char *name=NULL, const char *title=NULL);
+    ~MHHillasSrc();
+
+    void SetUseMmScale(Bool_t mmscale=kTRUE) { fUseMmScale = mmscale; }
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par);
+
+    TH1F *GetHistAlpha()  { return fAlpha; }
+    TH1F *GetHistDist()   { return fDist; }
+
+    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-7/Mars/mhist/MHMcCollectionArea.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcCollectionArea.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcCollectionArea.cc	(revision 9643)
@@ -0,0 +1,350 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "MHMcCollectionArea.h" 
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.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 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  : "MHMcCollectionArea";
+    fTitle = title ? title : "Collection Area vs. Energy";
+
+    const Int_t  nbins = 50;
+    const Float_t maxx = 5;
+    const Float_t maxy = 500;
+
+    Float_t *binsx = new Float_t[nbins+1];
+    for (int i=0; i<nbins+1; i++)
+        binsx[i] = pow(10, maxx*i/nbins);
+
+    Float_t *binsy = new Float_t[nbins+1];
+    for (int i=0; i<nbins+1; i++)
+        binsy[i] = maxy*i/nbins;
+
+    fHistAll = new TH2D("AllEvents", "All showers - Radius vs Energy distribution",
+                        nbins, binsx, nbins, binsy);
+    fHistSel = new TH2D("SelectedEvents", "Selected showers - Radius vs Energy distribution",
+                        nbins, binsx, nbins, binsy);
+
+    delete binsx;
+    delete binsy;
+
+    fHistCol = new TH1D;
+    fHistCol->SetName(fName);
+    fHistCol->SetTitle(fTitle);
+
+    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()
+{
+    MHMcEfficiency heff;
+    heff.Calc(*fHistSel, *fHistAll);
+
+    Calc(heff);
+}
+
+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();
+}
+
+void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    MHMcEfficiency heff;
+    heff.Calc(*mcsel.GetHist(), *mcall.GetHist());
+
+    Calc(heff);
+}
+
+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();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+/*
+void MHMcCollectionArea::Calc(MHMcEnergyImpact &mcsel, UInt_t numevents, Float_t angle)
+{
+}
+*/
Index: /tags/Mars_V0-7/Mars/mhist/MHMcCollectionArea.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcCollectionArea.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcCollectionArea.h	(revision 9643)
@@ -0,0 +1,48 @@
+#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
+
+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-7/Mars/mhist/MHMcDifRate.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcDifRate.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcDifRate.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcDifRate.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcDifRate.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcDifRate.h	(revision 9643)
@@ -0,0 +1,42 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcEfficiency.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiency.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiency.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcEfficiency.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiency.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiency.h	(revision 9643)
@@ -0,0 +1,41 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcEfficiencyEnergy.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyEnergy.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcEfficiencyEnergy.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyEnergy.h	(revision 9643)
@@ -0,0 +1,41 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcEfficiencyImpact.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyImpact.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcEfficiencyImpact.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyImpact.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEfficiencyImpact.h	(revision 9643)
@@ -0,0 +1,41 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcEnergy.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergy.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergy.cc	(revision 9643)
@@ -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): 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);
+}
+
Index: /tags/Mars_V0-7/Mars/mhist/MHMcEnergy.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergy.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergy.h	(revision 9643)
@@ -0,0 +1,54 @@
+#ifndef MARS_MHMcEnergy
+#define MARS_MHMcEnergy
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+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);
+
+    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-7/Mars/mhist/MHMcEnergyImpact.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergyImpact.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergyImpact.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcEnergyImpact.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergyImpact.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergyImpact.h	(revision 9643)
@@ -0,0 +1,37 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcEnergyMigration.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergyMigration.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergyMigration.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHMcEnergyMigration.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcEnergyMigration.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcEnergyMigration.h	(revision 9643)
@@ -0,0 +1,46 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcIntRate.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcIntRate.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcIntRate.cc	(revision 9643)
@@ -0,0 +1,150 @@
+/* ======================================================================== *\
+!
+! *
+! * 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"));
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-7/Mars/mhist/MHMcIntRate.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcIntRate.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcIntRate.h	(revision 9643)
@@ -0,0 +1,39 @@
+#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; }
+
+    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-7/Mars/mhist/MHMcRate.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcRate.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcRate.cc	(revision 9643)
@@ -0,0 +1,238 @@
+/* ======================================================================== *\
+!
+! *
+! * 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);
+
+    const Double_t anal2 = 1.0-anal*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-7/Mars/mhist/MHMcRate.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHMcRate.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHMcRate.h	(revision 9643)
@@ -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-7/Mars/mhist/MHStarMap.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHStarMap.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHStarMap.cc	(revision 9643)
@@ -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@uni-sw.gwdg.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 '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 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 *= 2./3;
+        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-7/Mars/mhist/MHStarMap.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHStarMap.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHStarMap.h	(revision 9643)
@@ -0,0 +1,43 @@
+#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);
+
+    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-7/Mars/mhist/MHThetabarTheta.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHThetabarTheta.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHThetabarTheta.cc	(revision 9643)
@@ -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): 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 [s]");
+    fHist.SetYTitle("\\overline{\\Theta} [\\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-7/Mars/mhist/MHThetabarTheta.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHThetabarTheta.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHThetabarTheta.h	(revision 9643)
@@ -0,0 +1,51 @@
+#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; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHThetabarTheta, 1) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-7/Mars/mhist/MHThetabarTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHThetabarTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHThetabarTime.cc	(revision 9643)
@@ -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("\\overline{\\Theta} [\\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-7/Mars/mhist/MHThetabarTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHThetabarTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHThetabarTime.h	(revision 9643)
@@ -0,0 +1,43 @@
+#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; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    ClassDef(MHThetabarTime, 1) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTheta.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTheta.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTheta.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHTimeDiffTheta.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTheta.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTheta.h	(revision 9643)
@@ -0,0 +1,41 @@
+#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; }
+
+    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-7/Mars/mhist/MHTimeDiffTime.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTime.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTime.cc	(revision 9643)
@@ -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-7/Mars/mhist/MHTimeDiffTime.h
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTime.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/MHTimeDiffTime.h	(revision 9643)
@@ -0,0 +1,39 @@
+#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; }
+
+    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-7/Mars/mhist/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mhist/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mhist/Makefile	(revision 9643)
@@ -0,0 +1,76 @@
+##################################################################
+#
+#   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../mdata
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MFillH.cc \
+           MBinning.cc \
+           MH.cc \
+           MH3.cc \
+           MHFadcPix.cc \
+           MHFadcCam.cc \
+           MHHillas.cc \
+           MHHillasSrc.cc \
+           MHHillasExt.cc \
+           MHStarMap.cc \
+           MHEnergyTime.cc \
+           MHEnergyTheta.cc \
+           MHMcCollectionArea.cc \
+           MHAlphaEnergyTime.cc \
+           MHAlphaEnergyTheta.cc \
+           MHEffOnTimeTime.cc \
+           MHEffOnTimeTheta.cc \
+           MHTimeDiffTime.cc \
+           MHTimeDiffTheta.cc \
+           MHMcEnergy.cc \
+           MHMcEfficiency.cc \
+           MHMcEfficiencyImpact.cc \
+           MHMcEfficiencyEnergy.cc \
+           MHMcEnergyImpact.cc \
+           MHThetabarTime.cc \
+           MHThetabarTheta.cc \
+           MHMcEnergyMigration.cc \
+	   MHMcRate.cc \
+	   MHMcIntRate.cc \
+	   MHMcDifRate.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-7/Mars/mmain/MAnalysis.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MAnalysis.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MAnalysis.cc	(revision 9643)
@@ -0,0 +1,296 @@
+/* ======================================================================== *\
+!
+! *
+! * 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);
+    read.SetProgressBar(bar);
+    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-7/Mars/mmain/MAnalysis.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MAnalysis.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MAnalysis.h	(revision 9643)
@@ -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-7/Mars/mmain/MBrowser.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MBrowser.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MBrowser.cc	(revision 9643)
@@ -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-7/Mars/mmain/MBrowser.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MBrowser.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MBrowser.h	(revision 9643)
@@ -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-7/Mars/mmain/MCameraDisplay.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MCameraDisplay.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MCameraDisplay.cc	(revision 9643)
@@ -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-7/Mars/mmain/MCameraDisplay.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MCameraDisplay.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MCameraDisplay.h	(revision 9643)
@@ -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-7/Mars/mmain/MDataCheck.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MDataCheck.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MDataCheck.cc	(revision 9643)
@@ -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  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);
+    read.SetProgressBar(bar);
+    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-7/Mars/mmain/MDataCheck.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MDataCheck.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MDataCheck.h	(revision 9643)
@@ -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-7/Mars/mmain/MEvtDisp.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MEvtDisp.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MEvtDisp.cc	(revision 9643)
@@ -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-7/Mars/mmain/MEvtDisp.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MEvtDisp.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MEvtDisp.h	(revision 9643)
@@ -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-7/Mars/mmain/MMars.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MMars.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MMars.cc	(revision 9643)
@@ -0,0 +1,312 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "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);
+    }
+}
+
+void MMars::CreateTextButton(TGVerticalFrame *tab, const char *text,
+                             const UInt_t id, TGLayoutHints *hints) const
+{
+    //
+    // Create the button
+    //
+    TGTextButton *button = new TGTextButton(tab, text, id);
+
+    //
+    // Add button for 'auto-delete'
+    //
+    fList->Add(button);
+
+    //
+    // Send button events (meesages) to this object (s. ProcessMessage)
+    //
+    button->Associate(this);
+
+    //
+    // Add button with corresponding layout to containing frame
+    //
+    tab->AddFrame(button, hints);
+}
+
+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, 400, 400);
+    fList->Add(tabs);
+    low->AddFrame(tabs, laytabs);
+
+    //
+    // Create Tab1
+    //
+    TGCompositeFrame *tf = tabs->AddTab("Control");
+
+    TGVerticalFrame *tab1 = new TGVerticalFrame(tf, 300, 100);
+    TGVerticalFrame *tab2 = new TGVerticalFrame(tf, 300, 100);
+
+    fList->Add(tab1);
+    fList->Add(tab2);
+
+    TGLayoutHints *laytabx = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(laytabx);
+
+    tf->AddFrame(tab1, laytabx);
+    tf->AddFrame(tab2, laytabx);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 10, 10, 10, 10);
+    fList->Add(laybut);
+
+    CreateTextButton(tab2, "Event Display",  kButEvtDisplay,    laybut);
+    CreateTextButton(tab2, "Data Check",     kButDataCheck,  laybut);
+    CreateTextButton(tab2, "Analysis",       kButAnalysis,    laybut);
+    CreateTextButton(tab2, "Monte Carlo",    kButMonteCarlo, laybut);
+    CreateTextButton(tab2, "Camera Display", kButCameraDisplay, laybut);
+}
+
+MMars::MMars()
+: TGMainFrame(gClient->GetRoot(), 330, 400, kVerticalFrame|kFixedSize)
+{
+    //
+    // Create the deletion list
+    //
+    fList = new MGList;
+    fList->SetOwner();
+
+    //
+    // Create the MenuBar
+    //
+    CreateMenuBar();
+
+    //
+    // create and layout the frame/contents
+    //
+    TGHorizontalFrame *top = new TGHorizontalFrame(this, 300, 100);
+    TGHorizontalFrame *low = new TGHorizontalFrame(this, 300, 100);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+
+    fList->Add(top);
+    fList->Add(low);
+    fList->Add(linesep);
+
+    CreateTopFrame(top);
+    CreateBottomFrame(low);
+
+    TGLayoutHints *layout = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(layout);
+
+    AddFrame(top,     layout);
+    AddFrame(linesep, layout);
+    AddFrame(low,     layout);
+
+    //    CreateTopFrame(fTop2);
+    //    CreateBottomFrame(fTop3);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //   kFixedSize seems to be ignored
+    //
+    SetWMSizeHints(GetWidth(), GetHeight(), GetWidth(), GetHeight(), 0, 0);  // set the smallest and biggest size of the Main frame
+    Move(rand()%100, rand()%100);
+
+    MapSubwindows();
+
+    Layout();
+
+    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:
+                gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
+                return kTRUE;
+
+            case kPicMars:
+                gSystem->Exec("netscape http://magic.uni-sw.gwdg.de/mars/ &");
+                return kTRUE;
+            }
+
+	case kCM_MENU:
+            if (parm1!=kFileExit)
+                return kTRUE;
+
+            CloseWindow();
+            return kTRUE;
+	}
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-7/Mars/mmain/MMars.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MMars.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MMars.h	(revision 9643)
@@ -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 UInt_t id, TGLayoutHints *hints) 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-7/Mars/mmain/MMonteCarlo.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MMonteCarlo.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MMonteCarlo.cc	(revision 9643)
@@ -0,0 +1,510 @@
+/* ======================================================================== *\
+!
+! *
+! * 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);
+    read.SetProgressBar(bar);
+    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);
+    read.SetProgressBar(bar);
+    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);
+    read.SetProgressBar(bar);
+    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-7/Mars/mmain/MMonteCarlo.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MMonteCarlo.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MMonteCarlo.h	(revision 9643)
@@ -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-7/Mars/mmain/MainIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MainIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MainIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mmain/MainLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/MainLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/MainLinkDef.h	(revision 9643)
@@ -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 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 MCameraDisplay+;
+
+#endif
Index: /tags/Mars_V0-7/Mars/mmain/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mmain/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmain/Makefile	(revision 9643)
@@ -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  = 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../mhist -I../mmontecarlo
+
+#------------------------------------------------------------------------------
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MBrowser.cc \
+	   MDataCheck.cc \
+	   MEvtDisp.cc \
+	   MMars.cc \
+           MAnalysis.cc \
+	   MMonteCarlo.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-7/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 9643)
@@ -0,0 +1,148 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "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;
+    }
+
+    fMcTrig = (MMcTrig*)pList->FindObject(fObjName);
+    if (!fMcTrig)
+    {
+        *fLog << err << dbginf << fObjName << " [MMcTrig] 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... exit." << endl;
+
+    fTheta = runheader->GetTelesTheta();
+
+    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
+        *fLog << warn << dbginf << "Warning - Read files have different Corsika versions... exit." << endl;
+
+    fCorsikaVersion = runheader->GetCorsikaVersion();
+
+    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
+
+    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
+
+    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-7/Mars/mmontecarlo/MMcCollectionAreaCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MMcThresholdCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MMcTimeGenerate.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MMcTimeGenerate.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 9643)
@@ -0,0 +1,231 @@
+/* ======================================================================== *\
+!
+! *
+! * 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 "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;
+
+    for (int i=0;i<10;i++)
+        fTrigger[i] = dim&&trigbg ? trigbg[i] : 0;
+
+    fShowers = 0;
+    fAnalShow = simbg;
+
+    fPartId=part;
+
+    fFirst = dim>0 ?   1 : -dim;
+    fLast  = dim>0 ? dim : -dim;
+
+    fNum = fLast-fFirst+1;
+
+    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);
+	if (fPartId ==14)
+	    rate.SetFlux(0.1091, 2.75);
+	else if (fPartId == 402)
+	    rate.SetFlux(0.0660, 2.62);
+	else {
+	    *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-7/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 9643)
@@ -0,0 +1,58 @@
+#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[10];   // 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-7/Mars/mmontecarlo/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/Makefile	(revision 9643)
@@ -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-7/Mars/mmontecarlo/MonteCarloIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MonteCarloIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MonteCarloIncl.h	(revision 9643)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-7/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawCrateArray.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawCrateArray.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawCrateArray.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawCrateArray.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawCrateArray.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawCrateArray.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawCrateData.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawCrateData.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawCrateData.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawCrateData.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawCrateData.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawCrateData.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawEvtData.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtData.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtData.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawEvtData.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtData.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtData.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtHeader.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtHeader.cc	(revision 9643)
@@ -0,0 +1,267 @@
+/* ======================================================================== *\
+!
+! *
+! * 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;
+    *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-7/Mars/mraw/MRawEvtHeader.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtHeader.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtHeader.h	(revision 9643)
@@ -0,0 +1,62 @@
+#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; }
+
+    int ReadEvt(istream& fin);
+
+    ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
+}; 
+
+#endif
Index: /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.cc	(revision 9643)
@@ -0,0 +1,190 @@
+/* ======================================================================== *\
+!
+! *
+! * 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
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  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 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;
+}
Index: /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawEvtPixelIter.h	(revision 9643)
@@ -0,0 +1,108 @@
+#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;
+
+    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;
+
+
+    void Reset();
+
+    void Draw(Option_t *t="GRAPH");
+
+    ClassDef(MRawEvtPixelIter, 0) // iterates over all pixels of one MRawEvtData object
+};
+
+#endif
Index: /tags/Mars_V0-7/Mars/mraw/MRawFileRead.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawFileRead.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawFileRead.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawFileRead.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawFileRead.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawFileRead.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawFileWrite.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawFileWrite.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawFileWrite.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawFileWrite.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawFileWrite.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawFileWrite.h	(revision 9643)
@@ -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-7/Mars/mraw/MRawRunHeader.cc
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawRunHeader.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawRunHeader.cc	(revision 9643)
@@ -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-7/Mars/mraw/MRawRunHeader.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/MRawRunHeader.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/MRawRunHeader.h	(revision 9643)
@@ -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-7/Mars/mraw/Makefile
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/Makefile	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/Makefile	(revision 9643)
@@ -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-7/Mars/mraw/RawIncl.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/RawIncl.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/RawIncl.h	(revision 9643)
@@ -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-7/Mars/mraw/RawLinkDef.h
===================================================================
--- /tags/Mars_V0-7/Mars/mraw/RawLinkDef.h	(revision 9643)
+++ /tags/Mars_V0-7/Mars/mraw/RawLinkDef.h	(revision 9643)
@@ -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-7/Mars/readraw.cc
===================================================================
--- /tags/Mars_V0-7/Mars/readraw.cc	(revision 9643)
+++ /tags/Mars_V0-7/Mars/readraw.cc	(revision 9643)
@@ -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;
+}
+
+
